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.

48094 lines
1.4 MiB

  1. /*!
  2. * (The MIT License)
  3. *
  4. * Copyright (c) 2012-2014 Marcin Warpechowski
  5. * Copyright (c) 2015 Handsoncode sp. z o.o. <hello@handsoncode.net>
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining
  8. * a copy of this software and associated documentation files (the
  9. * 'Software'), to deal in the Software without restriction, including
  10. * without limitation the rights to use, copy, modify, merge, publish,
  11. * distribute, sublicense, and/or sell copies of the Software, and to
  12. * permit persons to whom the Software is furnished to do so, subject to
  13. * the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be
  16. * included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  22. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. * Version: 0.34.0
  27. * Date: Thu Jul 27 2017 13:34:25 GMT+0200 (CEST)
  28. */
  29. (function webpackUniversalModuleDefinition(root, factory) {
  30. if(typeof exports === 'object' && typeof module === 'object')
  31. module.exports = factory(require("moment"), require("numbro"), require("pikaday"));
  32. else if(typeof define === 'function' && define.amd)
  33. define("Handsontable", ["moment", "numbro", "pikaday"], factory);
  34. else if(typeof exports === 'object')
  35. exports["Handsontable"] = factory(require("moment"), require("numbro"), require("pikaday"));
  36. else
  37. root["Handsontable"] = factory(root["moment"], root["numbro"], root["Pikaday"]);
  38. })(this, function(__WEBPACK_EXTERNAL_MODULE_61__, __WEBPACK_EXTERNAL_MODULE_87__, __WEBPACK_EXTERNAL_MODULE_302__) {
  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 = 208);
  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__(44)
  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 meta is removed.
  2506. *
  2507. * @event Hooks#afterRemoveCellMeta
  2508. * @since 0.33.1
  2509. * @param {Number} row Visual row index.
  2510. * @param {Number} col Visual column index.
  2511. * @param {String} key The removed meta key.
  2512. * @param {*} value Value which was under removed key of cell meta.
  2513. */
  2514. 'afterRemoveCellMeta',
  2515. /**
  2516. * Called after cell data was changed.
  2517. *
  2518. * @event Hooks#afterSetDataAtCell
  2519. * @since 0.28.0
  2520. * @param {Array} changes An array of changes in format `[[row, col, oldValue, value], ...]`.
  2521. * @param {String} [source] String that identifies source of hook call
  2522. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2523. */
  2524. 'afterSetDataAtCell',
  2525. /**
  2526. * Called after cell data was changed.
  2527. *
  2528. * @event Hooks#afterSetDataAtRowProp
  2529. * @since 0.28.0
  2530. * @param {Array} changes An array of changes in format `[[row, prop, oldValue, value], ...]`.
  2531. * @param {String} [source] String that identifies source of hook call
  2532. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2533. */
  2534. 'afterSetDataAtRowProp',
  2535. /**
  2536. * Fired after calling the `updateSettings` method.
  2537. *
  2538. * @event Hooks#afterUpdateSettings
  2539. * @param {Object} settings New settings object.
  2540. */
  2541. 'afterUpdateSettings',
  2542. /**
  2543. * @description
  2544. * A plugin hook executed after validator function, only if validator function is defined.
  2545. * Validation result is the first parameter. This can be used to determinate if validation passed successfully or not.
  2546. *
  2547. * __Returning false from the callback will mark the cell as invalid.__
  2548. *
  2549. * @event Hooks#afterValidate
  2550. * @since 0.9.5
  2551. * @param {Boolean} isValid `true` if valid, `false` if not.
  2552. * @param {*} value The value in question.
  2553. * @param {Number} row Row index.
  2554. * @param {String|Number} prop Property name / column index.
  2555. * @param {String} [source] String that identifies source of hook call
  2556. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2557. */
  2558. 'afterValidate',
  2559. /**
  2560. * Fired before populating the data in the autofill feature.
  2561. *
  2562. * @event Hooks#beforeAutofill
  2563. * @param {Object} start Object containing information about first filled cell: `{row: 2, col: 0}`.
  2564. * @param {Object} end Object containing information about last filled cell: `{row: 4, col: 1}`.
  2565. * @param {Array} data 2D array containing information about fill pattern: `[["1', "Ted"], ["1', "John"]]`.
  2566. */
  2567. 'beforeAutofill',
  2568. /**
  2569. * Fired before aligning the cell contents.
  2570. *
  2571. * @event Hooks#beforeCellAlignment
  2572. * @param stateBefore
  2573. * @param range
  2574. * @param {String} type Type of the alignment - either `horizontal` or `vertical`
  2575. * @param {String} alignmentClass String defining the alignment class added to the cell.
  2576. * Possible values:
  2577. * * `htLeft`,
  2578. * * `htCenter`,
  2579. * * `htRight`,
  2580. * * `htJustify`
  2581. * for horizontal alignment,
  2582. *
  2583. *
  2584. * * `htTop`,
  2585. * * `htMiddle`,
  2586. * * `htBottom`
  2587. * for vertical alignment.
  2588. */
  2589. 'beforeCellAlignment',
  2590. /**
  2591. * Callback fired before one or more cells is changed. Its main purpose is to alter changes silently before input.
  2592. *
  2593. * @event Hooks#beforeChange
  2594. * @param {Array} changes 2D array containing information about each of the edited cells.
  2595. * @param {String} [source] String that identifies source of hook call
  2596. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2597. * @example
  2598. * ```js
  2599. * // To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1).
  2600. * ...
  2601. * new Handsontable(document.getElementById('example'), {
  2602. * beforeChange: function(changes, source) {
  2603. * // [[row, prop, oldVal, newVal], ...]
  2604. * changes[0] = null;
  2605. * }
  2606. * });
  2607. * ...
  2608. *
  2609. * // To alter a single change, overwrite the desired value to changes[i][3].
  2610. * ...
  2611. * new Handsontable(document.getElementById('example'), {
  2612. * beforeChange: function(changes, source) {
  2613. * // [[row, prop, oldVal, newVal], ...]
  2614. * changes[0][3] = 10;
  2615. * }
  2616. * });
  2617. * ...
  2618. *
  2619. * // To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0).
  2620. * ...
  2621. * new Handsontable(document.getElementById('example'), {
  2622. * beforeChange: function(changes, source) {
  2623. * // [[row, prop, oldVal, newVal], ...]
  2624. * return false;
  2625. * }
  2626. * });
  2627. * ...
  2628. * ```
  2629. */
  2630. 'beforeChange',
  2631. /**
  2632. * Fired right before rendering the changes.
  2633. *
  2634. * @event Hooks#beforeChangeRender
  2635. * @since 0.11
  2636. * @param {Array} changes Array in form of [row, prop, oldValue, newValue].
  2637. * @param {String} [source] String that identifies source of hook call
  2638. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2639. */
  2640. 'beforeChangeRender',
  2641. /**
  2642. * Fired before drawing the borders.
  2643. *
  2644. * @event Hooks#beforeDrawBorders
  2645. * @param {Array} corners Array specifying the current selection borders.
  2646. * @param {String} borderClassName Specifies the border class name.
  2647. */
  2648. 'beforeDrawBorders',
  2649. /**
  2650. * Callback fired before getting cell settings.
  2651. *
  2652. * @event Hooks#beforeGetCellMeta
  2653. * @param {Number} row Visual row index.
  2654. * @param {Number} col Visual column index.
  2655. * @param {Object} cellProperties Object containing the cell's properties.
  2656. */
  2657. 'beforeGetCellMeta',
  2658. /**
  2659. * Called before cell meta is removed.
  2660. *
  2661. * @event Hooks#beforeRemoveCellMeta
  2662. * @since 0.33.1
  2663. * @param {Number} row Visual row index.
  2664. * @param {Number} col Visual column index.
  2665. * @param {String} key The removed meta key.
  2666. * @param {*} value Value which is under removed key of cell meta.
  2667. */
  2668. 'beforeRemoveCellMeta',
  2669. /**
  2670. * @description
  2671. * Callback fired before Handsontable instance is initiated.
  2672. *
  2673. * @event Hooks#beforeInit
  2674. */
  2675. 'beforeInit',
  2676. /**
  2677. * Callback fired before Walkontable instance is initiated.
  2678. *
  2679. * @since 0.11
  2680. * @event Hooks#beforeInitWalkontable
  2681. * @param {Object} walkontableConfig Walkontable configuration object.
  2682. */
  2683. 'beforeInitWalkontable',
  2684. /**
  2685. * Callback fired before keydown event is handled. It can be used to overwrite default key bindings.
  2686. * Caution - in your `beforeKeyDown` handler you need to call `event.stopImmediatePropagation()` to prevent default key behavior.
  2687. *
  2688. * @event Hooks#beforeKeyDown
  2689. * @since 0.9.0
  2690. * @param {Event} event Original DOM event.
  2691. */
  2692. 'beforeKeyDown',
  2693. /**
  2694. * Fired after the user clicked a cell, but before all the calculations related with it.
  2695. *
  2696. * @event Hooks#beforeOnCellMouseDown
  2697. * @param {Event} event The `mousedown` event object.
  2698. * @param {CellCoords} coords Cell coords object containing the visual coordinates of the clicked cell.
  2699. * @param {Element} TD TD element.
  2700. */
  2701. 'beforeOnCellMouseDown',
  2702. /**
  2703. * Fired after the user moved cursor over a cell, but before all the calculations related with it.
  2704. *
  2705. * @event Hooks#beforeOnCellMouseOver
  2706. * @param {Event} event The `mouseover` event object.
  2707. * @param {CellCoords} coords CellCoords object containing the visual coordinates of the clicked cell.
  2708. * @param {Element} TD TD element.
  2709. * @param {Object} blockCalculations Contain keys 'row' and 'column' with boolean value.
  2710. */
  2711. 'beforeOnCellMouseOver',
  2712. /**
  2713. * Fired after the user moved cursor out from a cell, but before all the calculations related with it.
  2714. *
  2715. * @event Hooks#beforeOnCellMouseOut
  2716. * @since 0.31.1
  2717. * @param {Event} event The `mouseout` event object.
  2718. * @param {WalkontableCellCoords} coords WalkontableCellCoords object containing the visual coordinates of the leaved cell.
  2719. * @param {Element} TD TD element.
  2720. */
  2721. 'beforeOnCellMouseOut',
  2722. /**
  2723. * Callback is fired when one or more columns are about to be removed.
  2724. *
  2725. * @event Hooks#beforeRemoveCol
  2726. * @param {Number} index Visual index of starter column.
  2727. * @param {Number} amount Amount of columns to be removed.
  2728. * @param {Array} [visualCols] Consists of visual indexes of processed columns.
  2729. */
  2730. 'beforeRemoveCol',
  2731. /**
  2732. * Callback is fired when one or more rows are about to be removed.
  2733. *
  2734. * @event Hooks#beforeRemoveRow
  2735. * @param {Number} index Visual index of starter column.
  2736. * @param {Number} amount Amount of columns to be removed.
  2737. * @param {Array} [visualRows] Consists of visual indexes of processed rows.
  2738. */
  2739. 'beforeRemoveRow',
  2740. /**
  2741. * Callback fired before Handsontable table is rendered.
  2742. *
  2743. * @event Hooks#beforeRender
  2744. * @param {Boolean} isForced If `true` rendering was triggered by a change of settings or data; or `false` if
  2745. * rendering was triggered by scrolling or moving selection.
  2746. */
  2747. 'beforeRender',
  2748. /**
  2749. * Callback fired before setting range is started.
  2750. *
  2751. * @event Hooks#beforeSetRangeStart
  2752. * @param {Array} coords CellCoords array.
  2753. */
  2754. 'beforeSetRangeStart',
  2755. /**
  2756. * Callback fired before setting range is ended.
  2757. *
  2758. * @event Hooks#beforeSetRangeEnd
  2759. * @param {Array} coords CellCoords array.
  2760. */
  2761. 'beforeSetRangeEnd',
  2762. /**
  2763. * Fired before the logic of handling a touch scroll, when user started scrolling on a touch-enabled device.
  2764. *
  2765. * @event Hooks#beforeTouchScroll
  2766. */
  2767. 'beforeTouchScroll',
  2768. /**
  2769. * @description
  2770. * A plugin hook executed before validator function, only if validator function is defined.
  2771. * This can be used to manipulate the value of changed cell before it is applied to the validator function.
  2772. *
  2773. * __Notice:__ this will not affect values of changes. This will change value ONLY for validation!
  2774. *
  2775. * @event Hooks#beforeValidate
  2776. * @since 0.9.5
  2777. * @param {*} value Value of the cell.
  2778. * @param {Number} row Row index.
  2779. * @param {String|Number} prop Property name / column index.
  2780. * @param {String} [source] String that identifies source of hook call
  2781. * ([list of all available sources]{@link http://docs.handsontable.com/tutorial-using-callbacks.html#page-source-definition}).
  2782. */
  2783. 'beforeValidate',
  2784. /**
  2785. * Callback fired before cell value is rendered into the DOM (through renderer function).
  2786. *
  2787. * @event Hooks#beforeValueRender
  2788. * @since 0.29.0
  2789. * @param {*} value Cell value to render.
  2790. */
  2791. 'beforeValueRender',
  2792. /**
  2793. * Callback fired after Handsontable instance is constructed (via `new` operator).
  2794. *
  2795. * @event Hooks#construct
  2796. * @since 0.16.1
  2797. */
  2798. 'construct',
  2799. /**
  2800. * Callback fired after Handsontable instance is initiated but before table is rendered.
  2801. *
  2802. * @event Hooks#init
  2803. * @since 0.16.1
  2804. */
  2805. 'init',
  2806. /**
  2807. * Fired when a column index is about to be modified by a callback function.
  2808. *
  2809. * @event Hooks#modifyCol
  2810. * @since 0.11
  2811. * @param {Number} col Visual column index.
  2812. */
  2813. 'modifyCol',
  2814. /**
  2815. * Fired when a column index is about to be de-modified by a callback function.
  2816. *
  2817. * @event Hooks#unmodifyCol
  2818. * @since 0.23.0
  2819. * @param {Number} col Physical column index.
  2820. */
  2821. 'unmodifyCol',
  2822. /**
  2823. * Fired when a physical row index is about to be de-modified by a callback function.
  2824. *
  2825. * @event Hooks#unmodifyRow
  2826. * @since 0.26.2
  2827. * @param {Number} row Physical row index.
  2828. */
  2829. 'unmodifyRow',
  2830. /**
  2831. * Fired when a column header index is about to be modified by a callback function.
  2832. *
  2833. * @event Hooks#modifyColHeader
  2834. * @since 0.20.0
  2835. * @param {Number} column Visual column header index.
  2836. */
  2837. 'modifyColHeader',
  2838. /**
  2839. * Fired when a column width is about to be modified by a callback function.
  2840. *
  2841. * @event Hooks#modifyColWidth
  2842. * @since 0.11
  2843. * @param {Number} width Current column width.
  2844. * @param {Number} col Column index.
  2845. */
  2846. 'modifyColWidth',
  2847. /**
  2848. * Fired when a row index is about to be modified by a callback function.
  2849. *
  2850. * @event Hooks#modifyRow
  2851. * @since 0.11
  2852. * @param {Number} row Row index.
  2853. */
  2854. 'modifyRow',
  2855. /**
  2856. * Fired when a row header index is about to be modified by a callback function.
  2857. *
  2858. * @event Hooks#modifyRowHeader
  2859. * @since 0.20.0
  2860. * @param {Number} row Row header index.
  2861. */
  2862. 'modifyRowHeader',
  2863. /**
  2864. * Fired when a row height is about to be modified by a callback function.
  2865. *
  2866. * @event Hooks#modifyRowHeight
  2867. * @since 0.11.0
  2868. * @param {Number} height Row height.
  2869. * @param {Number} row Row index.
  2870. */
  2871. 'modifyRowHeight',
  2872. /**
  2873. * Fired when a data was retrieved or modified.
  2874. *
  2875. * @event Hooks#modifyData
  2876. * @since 0.28.0
  2877. * @param {Number} row Row height.
  2878. * @param {Number} column Column index.
  2879. * @param {Object} valueHolder Object which contains original value which can be modified by overwriting `.value` property.
  2880. * @param {String} ioMode String which indicates for what operation hook is fired (`get` or `set`).
  2881. */
  2882. 'modifyData',
  2883. /**
  2884. * Fired when a data was retrieved or modified.
  2885. *
  2886. * @event Hooks#modifyRowData
  2887. * @since 0.28.0
  2888. * @param {Number} row Physical row index.
  2889. */
  2890. 'modifyRowData',
  2891. /**
  2892. * Fired after loading data using the Persistent State plugin.
  2893. *
  2894. * @event Hooks#persistentStateLoad
  2895. * @param {String} key Key string.
  2896. * @param {Object} valuePlaceholder Object containing the loaded data.
  2897. */
  2898. 'persistentStateLoad',
  2899. /**
  2900. * Fired after resetting data using the Persistent State plugin.
  2901. *
  2902. * @event Hooks#persistentStateReset
  2903. * @param {String} key Key string.
  2904. */
  2905. 'persistentStateReset',
  2906. /**
  2907. * Fired after resetting data using the Persistent State plugin.
  2908. *
  2909. * @event Hooks#persistentStateSave
  2910. * @param {String} key Key string.
  2911. * @param {Mixed} value Value to save.
  2912. */
  2913. 'persistentStateSave',
  2914. /**
  2915. * Fired before sorting the column. If you return `false` value then sorting will be not applied by
  2916. * Handsontable (useful for server-side sorting).
  2917. *
  2918. * @event Hooks#beforeColumnSort
  2919. * @param {Number} column Sorted visual column index.
  2920. * @param {Boolean} order Soring order where:
  2921. * * `true` means ascending order,
  2922. * * `false` means descending order,
  2923. * * `undefined` means original order.
  2924. */
  2925. 'beforeColumnSort',
  2926. /**
  2927. * Fired after sorting the column.
  2928. *
  2929. * @event Hooks#afterColumnSort
  2930. * @param {Number} column Sorted visual column index.
  2931. * @param {Boolean} order Soring order where:
  2932. * * `true` means ascending order
  2933. * * `false` means descending order
  2934. * * `undefined` means original order
  2935. */
  2936. 'afterColumnSort',
  2937. /**
  2938. * @description
  2939. * Fired after setting range of autofill.
  2940. * Both arguments are provided in the following format:
  2941. * ```js
  2942. * [startRow, startColumn, endRow, endColumn]
  2943. * ```
  2944. *
  2945. * @event Hooks#modifyAutofillRange
  2946. * @param {Array} startArea Array of visual coordinates of the starting point for the drag-down operation.
  2947. * @param {Array} entireArea Array of visual coordinates of the entire area of the drag-down operation.
  2948. */
  2949. 'modifyAutofillRange',
  2950. /**
  2951. * Fired to allow modifying the copyable range with a callback function.
  2952. *
  2953. * @since 0.19.0
  2954. * @event Hooks#modifyCopyableRange
  2955. * @param {Array} copyableRanges Array of objects defining copyable cells.
  2956. */
  2957. 'modifyCopyableRange',
  2958. /**
  2959. * Called before copying the values into clipboard and before clearing values of the selected cells.
  2960. *
  2961. * @event Hooks#beforeCut
  2962. * @since 0.31.1
  2963. * @param {Array} data An array of arrays which contains data to cut.
  2964. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  2965. * which will be cut out.
  2966. * @returns {*} If returns `false` then operation of the cutting out is cancelled.
  2967. *
  2968. * @example
  2969. * ```js
  2970. * // To disregard a single row, remove it from array using data.splice(i, 1).
  2971. * ...
  2972. * new Handsontable(document.getElementById('example'), {
  2973. * beforeCut: function(data, coords) {
  2974. * // data -> [[1, 2, 3], [4, 5, 6]]
  2975. * data.splice(0, 1);
  2976. * // data -> [[4, 5, 6]]
  2977. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  2978. * }
  2979. * });
  2980. * ...
  2981. *
  2982. * // To cancel cutting out, return false from the callback.
  2983. * ...
  2984. * new Handsontable(document.getElementById('example'), {
  2985. * beforeCut: function(data, coords) {
  2986. * return false;
  2987. * }
  2988. * });
  2989. * ...
  2990. * ```
  2991. */
  2992. 'beforeCut',
  2993. /**
  2994. * Fired after data are cutted out from the table.
  2995. *
  2996. * @event Hooks#afterCut
  2997. * @since 0.31.1
  2998. * @param {Array} data An array of arrays which contains the cutted out data.
  2999. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3000. * which was cut out.
  3001. */
  3002. 'afterCut',
  3003. /**
  3004. * Fired before values are copied into clipboard.
  3005. *
  3006. * @event Hooks#beforeCopy
  3007. * @since 0.31.1
  3008. * @param {Array} data An array of arrays which contains data to copied.
  3009. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3010. * which will copied.
  3011. * @returns {*} If returns `false` then copying is cancelled.
  3012. *
  3013. * @example
  3014. * ```js
  3015. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3016. * ...
  3017. * new Handsontable(document.getElementById('example'), {
  3018. * beforeCopy: function(data, coords) {
  3019. * // data -> [[1, 2, 3], [4, 5, 6]]
  3020. * data.splice(0, 1);
  3021. * // data -> [[4, 5, 6]]
  3022. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3023. * }
  3024. * });
  3025. * ...
  3026. *
  3027. * // To cancel copying, return false from the callback.
  3028. * ...
  3029. * new Handsontable(document.getElementById('example'), {
  3030. * beforeCopy: function(data, coords) {
  3031. * return false;
  3032. * }
  3033. * });
  3034. * ...
  3035. * ```
  3036. */
  3037. 'beforeCopy',
  3038. /**
  3039. * Fired after data are pasted into table.
  3040. *
  3041. * @event Hooks#afterCopy
  3042. * @since 0.31.1
  3043. * @param {Array} data An array of arrays which contains the copied data.
  3044. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3045. * which was copied.
  3046. */
  3047. 'afterCopy',
  3048. /**
  3049. * Fired before values are pasted into table.
  3050. *
  3051. * @event Hooks#beforePaste
  3052. * @since 0.31.1
  3053. * @param {Array} data An array of arrays which contains data to paste.
  3054. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3055. * that correspond to the previously selected area.
  3056. * @returns {*} If returns `false` then pasting is cancelled.
  3057. *
  3058. * @example
  3059. * ```js
  3060. * // To disregard a single row, remove it from array using data.splice(i, 1).
  3061. * ...
  3062. * new Handsontable(document.getElementById('example'), {
  3063. * beforePaste: function(data, coords) {
  3064. * // data -> [[1, 2, 3], [4, 5, 6]]
  3065. * data.splice(0, 1);
  3066. * // data -> [[4, 5, 6]]
  3067. * // coords -> [{startRow: 0, startCol: 0, endRow: 1, endCol: 2}]
  3068. * }
  3069. * });
  3070. * ...
  3071. *
  3072. * // To cancel pasting, return false from the callback.
  3073. * ...
  3074. * new Handsontable(document.getElementById('example'), {
  3075. * beforePaste: function(data, coords) {
  3076. * return false;
  3077. * }
  3078. * });
  3079. * ...
  3080. * ```
  3081. */
  3082. 'beforePaste',
  3083. /**
  3084. * Fired after values are pasted into table.
  3085. *
  3086. * @event Hooks#afterePaste
  3087. * @since 0.31.1
  3088. * @param {Array} data An array of arrays which contains the pasted data.
  3089. * @param {Array} coords An array of objects with ranges of the visual indexes (`startRow`, `startCol`, `endRow`, `endCol`)
  3090. * that correspond to the previously selected area.
  3091. */
  3092. 'afterPaste',
  3093. /**
  3094. * Fired before change order of the visual indexes.
  3095. *
  3096. * @event Hooks#beforeColumnMove
  3097. * @param {Array} columns Array of visual column indexes to be moved.
  3098. * @param {Number} target Visual column index being a target for moved columns.
  3099. */
  3100. 'beforeColumnMove',
  3101. /**
  3102. * Fired after change order of the visual indexes.
  3103. *
  3104. * @event Hooks#afterColumnMove
  3105. * @param {Array} columns Array of visual column indexes that were moved.
  3106. * @param {Number} target Visual column index being a target for moved columns.
  3107. */
  3108. 'afterColumnMove',
  3109. /**
  3110. * Fired before change order of the visual indexes.
  3111. *
  3112. * @event Hooks#beforeRowMove
  3113. * @param {Array} rows Array of visual row indexes to be moved.
  3114. * @param {Number} target Visual row index being a target for moved rows.
  3115. */
  3116. 'beforeRowMove',
  3117. /**
  3118. * Fired after change order of the visual indexes.
  3119. *
  3120. * @event Hooks#afterRowMove
  3121. * @param {Array} rows Array of visual row indexes that were moved.
  3122. * @param {Number} target Visual row index being a target for moved rows.
  3123. */
  3124. 'afterRowMove',
  3125. /**
  3126. * Fired before rendering the table with modified column sizes.
  3127. *
  3128. * @event Hooks#beforeColumnResize
  3129. * @param {Number} currentColumn Visual index of the resized column.
  3130. * @param {Number} newSize Calculated new column width.
  3131. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3132. * @returns {Number} Returns a new column size or `undefined`, if column size should be calculated automatically.
  3133. */
  3134. 'beforeColumnResize',
  3135. /**
  3136. * Fired after rendering the table with modified column sizes.
  3137. *
  3138. * @event Hooks#afterColumnResize
  3139. * @param {Number} currentColumn Visual index of the resized column.
  3140. * @param {Number} newSize Calculated new column width.
  3141. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3142. */
  3143. 'afterColumnResize',
  3144. /**
  3145. * Fired before rendering the table with modified row sizes.
  3146. *
  3147. * @event Hooks#beforeRowResize
  3148. * @param {Number} currentRow Visual index of the resized row.
  3149. * @param {Number} newSize Calculated new row height.
  3150. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3151. * @returns {Number} Returns the new row size or `undefined` if row size should be calculated automatically.
  3152. */
  3153. 'beforeRowResize',
  3154. /**
  3155. * Fired after rendering the table with modified row sizes.
  3156. *
  3157. * @event Hooks#afterRowResize
  3158. * @param {Number} currentRow Visual index of the resized row.
  3159. * @param {Number} newSize Calculated new row height.
  3160. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  3161. */
  3162. 'afterRowResize',
  3163. /**
  3164. * Fired after getting the column header renderers.
  3165. *
  3166. * @event Hooks#afterGetColumnHeaderRenderers
  3167. * @param {Array} array Array of the column header renderers.
  3168. */
  3169. 'afterGetColumnHeaderRenderers',
  3170. /**
  3171. * Fired after getting the row header renderers.
  3172. *
  3173. * @event Hooks#afterGetRowHeaderRenderers
  3174. * @param {Array} array Array of the row header renderers.
  3175. */
  3176. 'afterGetRowHeaderRenderers',
  3177. /**
  3178. * Fired before applying stretched column width to column.
  3179. *
  3180. * @event Hooks#beforeStretchingColumnWidth
  3181. * @param {Number} stretchedWidth Calculated width.
  3182. * @param {Number} column Visual column index.
  3183. * @returns {Number} Returns new width which will be applied to the column element.
  3184. */
  3185. 'beforeStretchingColumnWidth',
  3186. /**
  3187. * Fired before applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3188. *
  3189. * @pro
  3190. * @event Hooks#beforeFilter
  3191. * @param {Array} conditionsStack An array of objects with added formulas.
  3192. * @returns {Boolean} If hook returns `false` value then filtering won't be applied on the UI side (server-side filtering).
  3193. */
  3194. 'beforeFilter',
  3195. /**
  3196. * Fired after applying [filtering]{@link http://docs.handsontable.com/pro/demo-filtering.html}.
  3197. *
  3198. * @pro
  3199. * @event Hooks#afterFilter
  3200. * @param {Array} conditionsStack An array of objects with added formulas.
  3201. */
  3202. 'afterFilter',
  3203. /**
  3204. * Used to modify the column header height.
  3205. *
  3206. * @event Hooks#modifyColumnHeaderHeight
  3207. * @since 0.25.0
  3208. * @param {Number} col Visual column index.
  3209. */
  3210. 'modifyColumnHeaderHeight',
  3211. /**
  3212. * Fired before the undo action. Contains information about the action that is being undone.
  3213. *
  3214. * @event Hooks#beforeUndo
  3215. * @since 0.26.2
  3216. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3217. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3218. */
  3219. 'beforeUndo',
  3220. /**
  3221. * Fired after the undo action. Contains information about the action that is being undone.
  3222. *
  3223. * @event Hooks#afterUndo
  3224. * @since 0.26.2
  3225. * @param {Object} action The action object. Contains information about the action being undone. The `actionType`
  3226. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3227. */
  3228. 'afterUndo',
  3229. /**
  3230. * Fired before the redo action. Contains information about the action that is being redone.
  3231. *
  3232. * @event Hooks#beforeRedo
  3233. * @since 0.26.2
  3234. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3235. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3236. */
  3237. 'beforeRedo',
  3238. /**
  3239. * Fired after the redo action. Contains information about the action that is being redone.
  3240. *
  3241. * @event Hooks#afterRedo
  3242. * @since 0.26.2
  3243. * @param {Object} action The action object. Contains information about the action being redone. The `actionType`
  3244. * property of the object specifies the type of the action in a String format. (e.g. `'remove_row'`).
  3245. */
  3246. 'afterRedo',
  3247. /**
  3248. * Used to modify the row header width.
  3249. *
  3250. * @event Hooks#modifyRowHeaderWidth
  3251. * @param {Number} rowHeaderWidth Row header width.
  3252. */
  3253. 'modifyRowHeaderWidth',
  3254. /**
  3255. * Fired from the `populateFromArray` method during the `autofill` process. Fired for each "autofilled" cell individually.
  3256. *
  3257. * @event Hooks#beforeAutofillInsidePopulate
  3258. * @param {Object} index Object containing `row` and `col` properties, defining the number of rows/columns from the initial cell of the autofill.
  3259. * @param {String} direction Declares the direction of the autofill. Possible values: `up`, `down`, `left`, `right`.
  3260. * @param {Array} input Array of arrays. Contains an array of rows with data being used in the autofill.
  3261. * @param {Array} deltas The deltas array passed to the `populateFromArray` method.
  3262. */
  3263. 'beforeAutofillInsidePopulate',
  3264. /**
  3265. * Fired when the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3266. *
  3267. * @event Hooks#modifyTransformStart
  3268. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3269. */
  3270. 'modifyTransformStart',
  3271. /**
  3272. * Fired when the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3273. *
  3274. * @event Hooks#modifyTransformEnd
  3275. * @param {CellCoords} delta Cell coords object declaring the delta of the new selection relative to the previous one.
  3276. */
  3277. 'modifyTransformEnd',
  3278. /**
  3279. * Fired after the start of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3280. *
  3281. * @event Hooks#afterModifyTransformStart
  3282. * @param {CellCoords} coords Coords of the freshly selected cell.
  3283. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3284. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3285. */
  3286. 'afterModifyTransformStart',
  3287. /**
  3288. * Fired after the end of the selection is being modified. (e.g. moving the selection with the arrow keys).
  3289. *
  3290. * @event Hooks#afterModifyTransformEnd
  3291. * @param {CellCoords} coords Visual coords of the freshly selected cell.
  3292. * @param {Number} rowTransformDir `-1` if trying to select a cell with a negative row index. `0` otherwise.
  3293. * @param {Number} colTransformDir `-1` if trying to select a cell with a negative column index. `0` otherwise.
  3294. */
  3295. 'afterModifyTransformEnd',
  3296. /**
  3297. * Fired inside the `viewportRowCalculatorOverride` method. Allows modifying the row calculator parameters.
  3298. *
  3299. * @event Hooks#afterViewportRowCalculatorOverride
  3300. * @param {Object} calc The row calculator.
  3301. */
  3302. 'afterViewportRowCalculatorOverride',
  3303. /**
  3304. * Fired inside the `viewportColumnCalculatorOverride` method. Allows modifying the row calculator parameters.
  3305. *
  3306. * @event Hooks#afterViewportColumnCalculatorOverride
  3307. * @param {Object} calc The row calculator.
  3308. */
  3309. 'afterViewportColumnCalculatorOverride',
  3310. /**
  3311. * Fired after initializing all the plugins.
  3312. *
  3313. * @event Hooks#afterPluginsInitialized
  3314. */
  3315. 'afterPluginsInitialized',
  3316. /**
  3317. * Used when saving/loading the manual row heights state.
  3318. *
  3319. * @event Hooks#manualRowHeights
  3320. * @param {Array} state The current manual row heights state.
  3321. */
  3322. 'manualRowHeights',
  3323. /**
  3324. * Used to skip the length cache calculation for a defined period of time.
  3325. *
  3326. * @event Hooks#skipLengthCache
  3327. * @param {Number} delay The delay in milliseconds.
  3328. */
  3329. 'skipLengthCache',
  3330. /**
  3331. * Fired after trimming rows in the TrimRows plugin.
  3332. *
  3333. * @pro
  3334. * @event Hooks#afterTrimRow
  3335. * @param {Array} rows Physical indexes of trimmed rows.
  3336. */
  3337. 'afterTrimRow',
  3338. /**
  3339. * Fired after untrimming rows in the TrimRows plugin.
  3340. *
  3341. * @pro
  3342. * @event Hooks#afterUntrimRow
  3343. * @param {Array} rows Physical indexes of untrimmed rows.
  3344. */
  3345. 'afterUntrimRow',
  3346. /**
  3347. * Fired after opening the dropdown menu.
  3348. *
  3349. * @pro
  3350. * @event Hooks#afterDropdownMenuShow
  3351. * @param {DropdownMenu} instance The DropdownMenu instance.
  3352. */
  3353. 'afterDropdownMenuShow',
  3354. /**
  3355. * Fired after hiding the dropdown menu.
  3356. *
  3357. * @pro
  3358. * @event Hooks#afterDropdownMenuHide
  3359. * @param {DropdownMenu} instance The DropdownMenu instance.
  3360. */
  3361. 'afterDropdownMenuHide',
  3362. /**
  3363. * Used to check whether the provided row index is hidden.
  3364. *
  3365. * @pro
  3366. * @event Hooks#hiddenRow
  3367. * @param {Number} row The visual row index in question.
  3368. */
  3369. 'hiddenRow',
  3370. /**
  3371. * Used to check whether the provided column index is hidden.
  3372. *
  3373. * @pro
  3374. * @event Hooks#hiddenColumn
  3375. * @param {Number} column The visual column index in question.
  3376. */
  3377. 'hiddenColumn',
  3378. /**
  3379. * Fired before adding a children to the NestedRows structure.
  3380. *
  3381. * @pro
  3382. * @event Hooks#beforeAddChild
  3383. * @param {Object} parent The parent object.
  3384. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3385. * @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.
  3386. */
  3387. 'beforeAddChild',
  3388. /**
  3389. * Fired after adding a children to the NestedRows structure.
  3390. *
  3391. * @pro
  3392. * @event Hooks#afterAddChild
  3393. * @param {Object} parent The parent object.
  3394. * @param {Object|undefined} element The element added as a child. If `undefined`, a blank child was added.
  3395. * @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.
  3396. */
  3397. 'afterAddChild',
  3398. /**
  3399. * Fired before detaching a child from its parent in the NestedRows plugin.
  3400. *
  3401. * @pro
  3402. * @event Hooks#beforeDetachChild
  3403. * @param {Object} parent An object representing the parent from which the element is to be detached.
  3404. * @param {Object} element The detached element.
  3405. */
  3406. 'beforeDetachChild',
  3407. /**
  3408. * Fired after detaching a child from its parent in the NestedRows plugin.
  3409. *
  3410. * @pro
  3411. * @event Hooks#afterDetachChild
  3412. * @param {Object} parent An object representing the parent from which the element was detached.
  3413. * @param {Object} element The detached element.
  3414. */
  3415. 'afterDetachChild',
  3416. /**
  3417. * Fired after the editor is opened and rendered.
  3418. *
  3419. * @event Hooks#afterBeginEditing
  3420. * @param {Number} row Row index of the edited cell.
  3421. * @param {Number} column Column index of the edited cell.
  3422. */
  3423. 'afterBeginEditing'];
  3424. var Hooks = function () {
  3425. _createClass(Hooks, null, [{
  3426. key: 'getSingleton',
  3427. value: function getSingleton() {
  3428. return globalSingleton;
  3429. }
  3430. /**
  3431. *
  3432. */
  3433. }]);
  3434. function Hooks() {
  3435. _classCallCheck(this, Hooks);
  3436. this.globalBucket = this.createEmptyBucket();
  3437. }
  3438. /**
  3439. * Returns a new object with empty handlers related to every registered hook name.
  3440. *
  3441. * @returns {Object} The empty bucket object.
  3442. *
  3443. * @example
  3444. * ```js
  3445. * Handsontable.hooks.createEmptyBucket();
  3446. * // Results:
  3447. * {
  3448. * ...
  3449. * afterCreateCol: [],
  3450. * afterCreateRow: [],
  3451. * beforeInit: [],
  3452. * ...
  3453. * }
  3454. * ```
  3455. */
  3456. _createClass(Hooks, [{
  3457. key: 'createEmptyBucket',
  3458. value: function createEmptyBucket() {
  3459. var bucket = Object.create(null);
  3460. // eslint-disable-next-line no-return-assign
  3461. (0, _array.arrayEach)(REGISTERED_HOOKS, function (hook) {
  3462. return bucket[hook] = [];
  3463. });
  3464. return bucket;
  3465. }
  3466. /**
  3467. * Get hook bucket based on the context of the object or if argument is `undefined`, get the global hook bucket.
  3468. *
  3469. * @param {Object} [context=null] A Handsontable instance.
  3470. * @returns {Object} Returns a global or Handsontable instance bucket.
  3471. */
  3472. }, {
  3473. key: 'getBucket',
  3474. value: function getBucket() {
  3475. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3476. if (context) {
  3477. if (!context.pluginHookBucket) {
  3478. context.pluginHookBucket = this.createEmptyBucket();
  3479. }
  3480. return context.pluginHookBucket;
  3481. }
  3482. return this.globalBucket;
  3483. }
  3484. /**
  3485. * Adds a listener (globally or locally) to a specified hook name.
  3486. * If the `context` parameter is provided, the hook will be added only to the instance it references.
  3487. * Otherwise, the callback will be used everytime the hook fires on any Handsontable instance.
  3488. * You can provide an array of callback functions as the `callback` argument, this way they will all be fired
  3489. * once the hook is triggered.
  3490. *
  3491. * @see Core#addHook
  3492. * @param {String} key Hook name.
  3493. * @param {Function|Array} callback Callback function or an array of functions.
  3494. * @param {Object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
  3495. * @returns {Hooks} Instance of Hooks.
  3496. *
  3497. * @example
  3498. * ```js
  3499. * // single callback, added locally
  3500. * Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
  3501. *
  3502. * // single callback, added globally
  3503. * Handsontable.hooks.add('beforeInit', myCallback);
  3504. *
  3505. * // multiple callbacks, added locally
  3506. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
  3507. *
  3508. * // multiple callbacks, added globally
  3509. * Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
  3510. * ```
  3511. */
  3512. }, {
  3513. key: 'add',
  3514. value: function add(key, callback) {
  3515. var _this = this;
  3516. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3517. if (Array.isArray(callback)) {
  3518. (0, _array.arrayEach)(callback, function (c) {
  3519. return _this.add(key, c, context);
  3520. });
  3521. } else {
  3522. var bucket = this.getBucket(context);
  3523. if (typeof bucket[key] === 'undefined') {
  3524. this.register(key);
  3525. bucket[key] = [];
  3526. }
  3527. callback.skip = false;
  3528. if (bucket[key].indexOf(callback) === -1) {
  3529. // only add a hook if it has not already been added (adding the same hook twice is now silently ignored)
  3530. var foundInitialHook = false;
  3531. if (callback.initialHook) {
  3532. (0, _array.arrayEach)(bucket[key], function (cb, i) {
  3533. if (cb.initialHook) {
  3534. bucket[key][i] = callback;
  3535. foundInitialHook = true;
  3536. return false;
  3537. }
  3538. });
  3539. }
  3540. if (!foundInitialHook) {
  3541. bucket[key].push(callback);
  3542. }
  3543. }
  3544. }
  3545. return this;
  3546. }
  3547. /**
  3548. * Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
  3549. *
  3550. * @see Core#addHookOnce
  3551. * @param {String} key Hook/Event name.
  3552. * @param {Function|Array} callback Callback function.
  3553. * @param {Object} [context=null] A Handsontable instance.
  3554. *
  3555. * @example
  3556. * ```js
  3557. * Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
  3558. * ```
  3559. */
  3560. }, {
  3561. key: 'once',
  3562. value: function once(key, callback) {
  3563. var _this2 = this;
  3564. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3565. if (Array.isArray(callback)) {
  3566. (0, _array.arrayEach)(callback, function (c) {
  3567. return _this2.once(key, c, context);
  3568. });
  3569. } else {
  3570. callback.runOnce = true;
  3571. this.add(key, callback, context);
  3572. }
  3573. }
  3574. /**
  3575. * 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.
  3576. *
  3577. * @see Core#removeHook
  3578. * @param {String} key Hook/Event name.
  3579. * @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
  3580. * @param {Object} [context=null] Handsontable instance.
  3581. * @return {Boolean} Returns `true` if hook was removed, `false` otherwise.
  3582. *
  3583. * @example
  3584. * ```js
  3585. * Handsontable.hooks.remove('beforeInit', myCallback);
  3586. * ```
  3587. */
  3588. }, {
  3589. key: 'remove',
  3590. value: function remove(key, callback) {
  3591. var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  3592. var bucket = this.getBucket(context);
  3593. if (typeof bucket[key] !== 'undefined') {
  3594. if (bucket[key].indexOf(callback) >= 0) {
  3595. callback.skip = true;
  3596. return true;
  3597. }
  3598. }
  3599. return false;
  3600. }
  3601. /**
  3602. * Checks whether there are any registered listeners for the provided hook name.
  3603. * If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
  3604. *
  3605. * @param {String} key Hook name.
  3606. * @param {Object} [context=null] A Handsontable instance.
  3607. * @returns {Boolean} `true` for success, `false` otherwise.
  3608. */
  3609. }, {
  3610. key: 'has',
  3611. value: function has(key) {
  3612. var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  3613. var bucket = this.getBucket(context);
  3614. return !!(bucket[key] !== void 0 && bucket[key].length);
  3615. }
  3616. /**
  3617. * Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
  3618. * It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
  3619. *
  3620. * @see Core#runHooks
  3621. * @param {Object} context Handsontable instance.
  3622. * @param {String} key Hook/Event name.
  3623. * @param {*} [p1] Parameter to be passed as an argument to the callback function.
  3624. * @param {*} [p2] Parameter to be passed as an argument to the callback function.
  3625. * @param {*} [p3] Parameter to be passed as an argument to the callback function.
  3626. * @param {*} [p4] Parameter to be passed as an argument to the callback function.
  3627. * @param {*} [p5] Parameter to be passed as an argument to the callback function.
  3628. * @param {*} [p6] Parameter to be passed as an argument to the callback function.
  3629. * @returns {*} Either a return value from the last called callback or `p1`.
  3630. *
  3631. * @example
  3632. * ```js
  3633. * Handsontable.hooks.run(hot, 'beforeInit');
  3634. * ```
  3635. */
  3636. }, {
  3637. key: 'run',
  3638. value: function run(context, key, p1, p2, p3, p4, p5, p6) {
  3639. {
  3640. var globalHandlers = this.globalBucket[key];
  3641. var index = -1;
  3642. var length = globalHandlers ? globalHandlers.length : 0;
  3643. if (length) {
  3644. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  3645. while (++index < length) {
  3646. if (!globalHandlers[index] || globalHandlers[index].skip) {
  3647. /* eslint-disable no-continue */
  3648. continue;
  3649. }
  3650. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  3651. var res = globalHandlers[index].call(context, p1, p2, p3, p4, p5, p6);
  3652. if (res !== void 0) {
  3653. p1 = res;
  3654. }
  3655. if (globalHandlers[index] && globalHandlers[index].runOnce) {
  3656. this.remove(key, globalHandlers[index]);
  3657. }
  3658. }
  3659. }
  3660. }
  3661. {
  3662. var localHandlers = this.getBucket(context)[key];
  3663. var _index = -1;
  3664. var _length = localHandlers ? localHandlers.length : 0;
  3665. if (_length) {
  3666. // Do not optimise this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
  3667. while (++_index < _length) {
  3668. if (!localHandlers[_index] || localHandlers[_index].skip) {
  3669. /* eslint-disable no-continue */
  3670. continue;
  3671. }
  3672. // performance considerations - http://jsperf.com/call-vs-apply-for-a-plugin-architecture
  3673. var _res = localHandlers[_index].call(context, p1, p2, p3, p4, p5, p6);
  3674. if (_res !== void 0) {
  3675. p1 = _res;
  3676. }
  3677. if (localHandlers[_index] && localHandlers[_index].runOnce) {
  3678. this.remove(key, localHandlers[_index], context);
  3679. }
  3680. }
  3681. }
  3682. }
  3683. return p1;
  3684. }
  3685. /**
  3686. * Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
  3687. *
  3688. * @param {Object} [context=null] A Handsontable instance.
  3689. * @example
  3690. * ```js
  3691. * // destroy the global listeners
  3692. * Handsontable.hooks.destroy();
  3693. *
  3694. * // destroy the local listeners
  3695. * Handsontable.hooks.destroy(hotInstance);
  3696. * ```
  3697. */
  3698. }, {
  3699. key: 'destroy',
  3700. value: function destroy() {
  3701. var context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  3702. // eslint-disable-next-line no-return-assign
  3703. (0, _object.objectEach)(this.getBucket(context), function (value, key, bucket) {
  3704. return bucket[key].length = 0;
  3705. });
  3706. }
  3707. /**
  3708. * Registers a hook name (adds it to the list of the known hook names). Used by plugins.
  3709. * It is not necessary to call register, but if you use it, your plugin hook will be used returned by
  3710. * the `getRegistered` method. (which itself is used in the demo http://docs.handsontable.com/tutorial-callbacks.html).
  3711. *
  3712. * @param key {String} The hook name.
  3713. *
  3714. * @example
  3715. * ```js
  3716. * Handsontable.hooks.register('myHook');
  3717. * ```
  3718. */
  3719. }, {
  3720. key: 'register',
  3721. value: function register(key) {
  3722. if (!this.isRegistered(key)) {
  3723. REGISTERED_HOOKS.push(key);
  3724. }
  3725. }
  3726. /**
  3727. * Deregisters a hook name (removes it from the list of known hook names).
  3728. *
  3729. * @param key {String} Hook name.
  3730. *
  3731. * @example
  3732. * ```js
  3733. * Handsontable.hooks.deregister('myHook');
  3734. * ```
  3735. */
  3736. }, {
  3737. key: 'deregister',
  3738. value: function deregister(key) {
  3739. if (this.isRegistered(key)) {
  3740. REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
  3741. }
  3742. }
  3743. /**
  3744. * Returns a boolean depending on if a hook by such name has been registered.
  3745. *
  3746. * @param key {String} Hook name.
  3747. * @returns {Boolean} `true` for success, `false` otherwise.
  3748. *
  3749. * @example
  3750. * ```js
  3751. * Handsontable.hooks.isRegistered('beforeInit');
  3752. *
  3753. * // Results:
  3754. * true
  3755. * ```
  3756. */
  3757. }, {
  3758. key: 'isRegistered',
  3759. value: function isRegistered(key) {
  3760. return REGISTERED_HOOKS.indexOf(key) >= 0;
  3761. }
  3762. /**
  3763. * Returns an array of registered hooks.
  3764. *
  3765. * @returns {Array} An array of registered hooks.
  3766. *
  3767. * @example
  3768. * ```js
  3769. * Handsontable.hooks.getRegistered();
  3770. *
  3771. * // Results:
  3772. * [
  3773. * ...
  3774. * 'beforeInit',
  3775. * 'beforeRender',
  3776. * 'beforeSetRangeEnd',
  3777. * 'beforeDrawBorders',
  3778. * 'beforeChange',
  3779. * ...
  3780. * ]
  3781. * ```
  3782. */
  3783. }, {
  3784. key: 'getRegistered',
  3785. value: function getRegistered() {
  3786. return REGISTERED_HOOKS;
  3787. }
  3788. }]);
  3789. return Hooks;
  3790. }();
  3791. var globalSingleton = new Hooks();
  3792. exports.default = Hooks;
  3793. /***/ }),
  3794. /* 9 */
  3795. /***/ (function(module, exports, __webpack_require__) {
  3796. "use strict";
  3797. exports.__esModule = true;
  3798. exports.getRegisteredRenderers = exports.getRegisteredRendererNames = exports.hasRenderer = exports.getRenderer = exports.registerRenderer = undefined;
  3799. var _staticRegister2 = __webpack_require__(50);
  3800. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  3801. var _cellDecorator = __webpack_require__(262);
  3802. var _cellDecorator2 = _interopRequireDefault(_cellDecorator);
  3803. var _autocompleteRenderer = __webpack_require__(263);
  3804. var _autocompleteRenderer2 = _interopRequireDefault(_autocompleteRenderer);
  3805. var _checkboxRenderer = __webpack_require__(264);
  3806. var _checkboxRenderer2 = _interopRequireDefault(_checkboxRenderer);
  3807. var _htmlRenderer = __webpack_require__(265);
  3808. var _htmlRenderer2 = _interopRequireDefault(_htmlRenderer);
  3809. var _numericRenderer = __webpack_require__(266);
  3810. var _numericRenderer2 = _interopRequireDefault(_numericRenderer);
  3811. var _passwordRenderer = __webpack_require__(267);
  3812. var _passwordRenderer2 = _interopRequireDefault(_passwordRenderer);
  3813. var _textRenderer = __webpack_require__(268);
  3814. var _textRenderer2 = _interopRequireDefault(_textRenderer);
  3815. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3816. var _staticRegister = (0, _staticRegister3.default)('renderers'),
  3817. register = _staticRegister.register,
  3818. getItem = _staticRegister.getItem,
  3819. hasItem = _staticRegister.hasItem,
  3820. getNames = _staticRegister.getNames,
  3821. getValues = _staticRegister.getValues;
  3822. register('base', _cellDecorator2.default);
  3823. register('autocomplete', _autocompleteRenderer2.default);
  3824. register('checkbox', _checkboxRenderer2.default);
  3825. register('html', _htmlRenderer2.default);
  3826. register('numeric', _numericRenderer2.default);
  3827. register('password', _passwordRenderer2.default);
  3828. register('text', _textRenderer2.default);
  3829. /**
  3830. * Retrieve renderer function.
  3831. *
  3832. * @param {String} name Renderer identification.
  3833. * @returns {Function} Returns renderer function.
  3834. */
  3835. function _getItem(name) {
  3836. if (typeof name === 'function') {
  3837. return name;
  3838. }
  3839. if (!hasItem(name)) {
  3840. throw Error('No registered renderer found under "' + name + '" name');
  3841. }
  3842. return getItem(name);
  3843. }
  3844. exports.registerRenderer = register;
  3845. exports.getRenderer = _getItem;
  3846. exports.hasRenderer = hasItem;
  3847. exports.getRegisteredRendererNames = getNames;
  3848. exports.getRegisteredRenderers = getValues;
  3849. /***/ }),
  3850. /* 10 */
  3851. /***/ (function(module, exports, __webpack_require__) {
  3852. var store = __webpack_require__(83)('wks')
  3853. , uid = __webpack_require__(49)
  3854. , Symbol = __webpack_require__(13).Symbol
  3855. , USE_SYMBOL = typeof Symbol == 'function';
  3856. var $exports = module.exports = function(name){
  3857. return store[name] || (store[name] =
  3858. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  3859. };
  3860. $exports.store = store;
  3861. /***/ }),
  3862. /* 11 */
  3863. /***/ (function(module, exports, __webpack_require__) {
  3864. "use strict";
  3865. exports.__esModule = true;
  3866. 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;
  3867. __webpack_require__(97);
  3868. __webpack_require__(114);
  3869. __webpack_require__(123);
  3870. __webpack_require__(124);
  3871. __webpack_require__(108);
  3872. __webpack_require__(122);
  3873. __webpack_require__(105);
  3874. __webpack_require__(106);
  3875. __webpack_require__(107);
  3876. __webpack_require__(96);
  3877. __webpack_require__(119);
  3878. __webpack_require__(117);
  3879. __webpack_require__(115);
  3880. __webpack_require__(120);
  3881. __webpack_require__(121);
  3882. __webpack_require__(116);
  3883. __webpack_require__(118);
  3884. __webpack_require__(109);
  3885. __webpack_require__(110);
  3886. __webpack_require__(111);
  3887. __webpack_require__(113);
  3888. __webpack_require__(112);
  3889. __webpack_require__(94);
  3890. __webpack_require__(95);
  3891. __webpack_require__(90);
  3892. __webpack_require__(93);
  3893. __webpack_require__(92);
  3894. __webpack_require__(91);
  3895. __webpack_require__(67);
  3896. __webpack_require__(99);
  3897. __webpack_require__(100);
  3898. __webpack_require__(102);
  3899. __webpack_require__(101);
  3900. __webpack_require__(98);
  3901. __webpack_require__(104);
  3902. __webpack_require__(103);
  3903. __webpack_require__(125);
  3904. __webpack_require__(128);
  3905. __webpack_require__(126);
  3906. __webpack_require__(127);
  3907. __webpack_require__(130);
  3908. __webpack_require__(129);
  3909. __webpack_require__(132);
  3910. __webpack_require__(131);
  3911. var _viewportColumns = __webpack_require__(136);
  3912. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  3913. var _viewportRows = __webpack_require__(137);
  3914. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  3915. var _coords = __webpack_require__(42);
  3916. var _coords2 = _interopRequireDefault(_coords);
  3917. var _range = __webpack_require__(68);
  3918. var _range2 = _interopRequireDefault(_range);
  3919. var _column = __webpack_require__(140);
  3920. var _column2 = _interopRequireDefault(_column);
  3921. var _row = __webpack_require__(141);
  3922. var _row2 = _interopRequireDefault(_row);
  3923. var _debug = __webpack_require__(184);
  3924. var _debug2 = _interopRequireDefault(_debug);
  3925. var _left = __webpack_require__(185);
  3926. var _left2 = _interopRequireDefault(_left);
  3927. var _top = __webpack_require__(186);
  3928. var _top2 = _interopRequireDefault(_top);
  3929. var _topLeftCorner = __webpack_require__(187);
  3930. var _topLeftCorner2 = _interopRequireDefault(_topLeftCorner);
  3931. var _border = __webpack_require__(135);
  3932. var _border2 = _interopRequireDefault(_border);
  3933. var _core = __webpack_require__(138);
  3934. var _core2 = _interopRequireDefault(_core);
  3935. var _event = __webpack_require__(139);
  3936. var _event2 = _interopRequireDefault(_event);
  3937. var _overlays = __webpack_require__(142);
  3938. var _overlays2 = _interopRequireDefault(_overlays);
  3939. var _scroll = __webpack_require__(143);
  3940. var _scroll2 = _interopRequireDefault(_scroll);
  3941. var _selection = __webpack_require__(188);
  3942. var _selection2 = _interopRequireDefault(_selection);
  3943. var _settings = __webpack_require__(144);
  3944. var _settings2 = _interopRequireDefault(_settings);
  3945. var _table = __webpack_require__(145);
  3946. var _table2 = _interopRequireDefault(_table);
  3947. var _tableRenderer = __webpack_require__(146);
  3948. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  3949. var _viewport = __webpack_require__(147);
  3950. var _viewport2 = _interopRequireDefault(_viewport);
  3951. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  3952. exports.ViewportColumnsCalculator = _viewportColumns2.default;
  3953. exports.ViewportRowsCalculator = _viewportRows2.default;
  3954. exports.CellCoords = _coords2.default;
  3955. exports.CellRange = _range2.default;
  3956. exports.ColumnFilter = _column2.default;
  3957. exports.RowFilter = _row2.default;
  3958. exports.DebugOverlay = _debug2.default;
  3959. exports.LeftOverlay = _left2.default;
  3960. exports.TopOverlay = _top2.default;
  3961. exports.TopLeftCornerOverlay = _topLeftCorner2.default;
  3962. exports.Border = _border2.default;
  3963. exports.default = _core2.default;
  3964. exports.Core = _core2.default;
  3965. exports.Event = _event2.default;
  3966. exports.Overlays = _overlays2.default;
  3967. exports.Scroll = _scroll2.default;
  3968. exports.Selection = _selection2.default;
  3969. exports.Settings = _settings2.default;
  3970. exports.Table = _table2.default;
  3971. exports.TableRenderer = _tableRenderer2.default;
  3972. exports.Viewport = _viewport2.default;
  3973. /***/ }),
  3974. /* 12 */
  3975. /***/ (function(module, exports, __webpack_require__) {
  3976. "use strict";
  3977. exports.__esModule = true;
  3978. 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; }; }();
  3979. var _object = __webpack_require__(1);
  3980. var _array = __webpack_require__(2);
  3981. var _recordTranslator = __webpack_require__(153);
  3982. var _plugins = __webpack_require__(5);
  3983. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3984. var privatePool = new WeakMap();
  3985. var initializedPlugins = null;
  3986. /**
  3987. * @private
  3988. */
  3989. var BasePlugin = function () {
  3990. /**
  3991. * @param {Object} hotInstance Handsontable instance.
  3992. */
  3993. function BasePlugin(hotInstance) {
  3994. var _this = this;
  3995. _classCallCheck(this, BasePlugin);
  3996. /**
  3997. * Handsontable instance.
  3998. *
  3999. * @type {Core}
  4000. */
  4001. (0, _object.defineGetter)(this, 'hot', hotInstance, {
  4002. writable: false
  4003. });
  4004. (0, _object.defineGetter)(this, 't', (0, _recordTranslator.getTranslator)(hotInstance), {
  4005. writable: false
  4006. });
  4007. privatePool.set(this, { hooks: {} });
  4008. initializedPlugins = null;
  4009. this.pluginName = null;
  4010. this.pluginsInitializedCallbacks = [];
  4011. this.isPluginsReady = false;
  4012. this.enabled = false;
  4013. this.initialized = false;
  4014. this.hot.addHook('afterPluginsInitialized', function () {
  4015. return _this.onAfterPluginsInitialized();
  4016. });
  4017. this.hot.addHook('afterUpdateSettings', function () {
  4018. return _this.onUpdateSettings();
  4019. });
  4020. this.hot.addHook('beforeInit', function () {
  4021. return _this.init();
  4022. });
  4023. }
  4024. _createClass(BasePlugin, [{
  4025. key: 'init',
  4026. value: function init() {
  4027. this.pluginName = (0, _plugins.getPluginName)(this.hot, this);
  4028. if (this.isEnabled && this.isEnabled()) {
  4029. this.enablePlugin();
  4030. }
  4031. if (!initializedPlugins) {
  4032. initializedPlugins = (0, _plugins.getRegistredPluginNames)(this.hot);
  4033. }
  4034. if (initializedPlugins.indexOf(this.pluginName) >= 0) {
  4035. initializedPlugins.splice(initializedPlugins.indexOf(this.pluginName), 1);
  4036. }
  4037. if (!initializedPlugins.length) {
  4038. this.hot.runHooks('afterPluginsInitialized');
  4039. }
  4040. this.initialized = true;
  4041. }
  4042. /**
  4043. * Enable plugin for this Handsontable instance.
  4044. */
  4045. }, {
  4046. key: 'enablePlugin',
  4047. value: function enablePlugin() {
  4048. this.enabled = true;
  4049. }
  4050. /**
  4051. * Disable plugin for this Handsontable instance.
  4052. */
  4053. }, {
  4054. key: 'disablePlugin',
  4055. value: function disablePlugin() {
  4056. if (this.eventManager) {
  4057. this.eventManager.clear();
  4058. }
  4059. this.clearHooks();
  4060. this.enabled = false;
  4061. }
  4062. /**
  4063. * Add listener to plugin hooks system.
  4064. *
  4065. * @param {String} name
  4066. * @param {Function} callback
  4067. */
  4068. }, {
  4069. key: 'addHook',
  4070. value: function addHook(name, callback) {
  4071. privatePool.get(this).hooks[name] = privatePool.get(this).hooks[name] || [];
  4072. var hooks = privatePool.get(this).hooks[name];
  4073. this.hot.addHook(name, callback);
  4074. hooks.push(callback);
  4075. privatePool.get(this).hooks[name] = hooks;
  4076. }
  4077. /**
  4078. * Remove all hooks listeners by hook name.
  4079. *
  4080. * @param {String} name
  4081. */
  4082. }, {
  4083. key: 'removeHooks',
  4084. value: function removeHooks(name) {
  4085. var _this2 = this;
  4086. (0, _array.arrayEach)(privatePool.get(this).hooks[name] || [], function (callback) {
  4087. _this2.hot.removeHook(name, callback);
  4088. });
  4089. }
  4090. /**
  4091. * Clear all hooks.
  4092. */
  4093. }, {
  4094. key: 'clearHooks',
  4095. value: function clearHooks() {
  4096. var _this3 = this;
  4097. var hooks = privatePool.get(this).hooks;
  4098. (0, _object.objectEach)(hooks, function (callbacks, name) {
  4099. return _this3.removeHooks(name);
  4100. });
  4101. hooks.length = 0;
  4102. }
  4103. /**
  4104. * Register function which will be immediately called after all plugins initialized.
  4105. *
  4106. * @param {Function} callback
  4107. */
  4108. }, {
  4109. key: 'callOnPluginsReady',
  4110. value: function callOnPluginsReady(callback) {
  4111. if (this.isPluginsReady) {
  4112. callback();
  4113. } else {
  4114. this.pluginsInitializedCallbacks.push(callback);
  4115. }
  4116. }
  4117. /**
  4118. * On after plugins initialized listener.
  4119. *
  4120. * @private
  4121. */
  4122. }, {
  4123. key: 'onAfterPluginsInitialized',
  4124. value: function onAfterPluginsInitialized() {
  4125. (0, _array.arrayEach)(this.pluginsInitializedCallbacks, function (callback) {
  4126. return callback();
  4127. });
  4128. this.pluginsInitializedCallbacks.length = 0;
  4129. this.isPluginsReady = true;
  4130. }
  4131. /**
  4132. * On update settings listener.
  4133. *
  4134. * @private
  4135. */
  4136. }, {
  4137. key: 'onUpdateSettings',
  4138. value: function onUpdateSettings() {
  4139. if (this.isEnabled) {
  4140. if (this.enabled && !this.isEnabled()) {
  4141. this.disablePlugin();
  4142. }
  4143. if (!this.enabled && this.isEnabled()) {
  4144. this.enablePlugin();
  4145. }
  4146. if (this.enabled && this.isEnabled()) {
  4147. this.updatePlugin();
  4148. }
  4149. }
  4150. }
  4151. /**
  4152. * Updates the plugin to use the latest options you have specified.
  4153. *
  4154. * @private
  4155. */
  4156. }, {
  4157. key: 'updatePlugin',
  4158. value: function updatePlugin() {}
  4159. /**
  4160. * Destroy plugin.
  4161. */
  4162. }, {
  4163. key: 'destroy',
  4164. value: function destroy() {
  4165. var _this4 = this;
  4166. if (this.eventManager) {
  4167. this.eventManager.destroy();
  4168. }
  4169. this.clearHooks();
  4170. (0, _object.objectEach)(this, function (value, property) {
  4171. if (property !== 'hot' && property !== 't') {
  4172. _this4[property] = null;
  4173. }
  4174. });
  4175. delete this.t;
  4176. delete this.hot;
  4177. }
  4178. }]);
  4179. return BasePlugin;
  4180. }();
  4181. exports.default = BasePlugin;
  4182. /***/ }),
  4183. /* 13 */
  4184. /***/ (function(module, exports) {
  4185. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  4186. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  4187. ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  4188. if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
  4189. /***/ }),
  4190. /* 14 */
  4191. /***/ (function(module, exports, __webpack_require__) {
  4192. "use strict";
  4193. exports.__esModule = true;
  4194. exports.getRegisteredEditors = exports.getRegisteredEditorNames = exports.hasEditor = exports.getEditorInstance = exports.getEditor = exports.registerEditor = undefined;
  4195. exports.RegisteredEditor = RegisteredEditor;
  4196. exports._getEditorInstance = _getEditorInstance;
  4197. var _staticRegister2 = __webpack_require__(50);
  4198. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  4199. var _pluginHooks = __webpack_require__(8);
  4200. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  4201. var _baseEditor = __webpack_require__(36);
  4202. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  4203. var _autocompleteEditor = __webpack_require__(148);
  4204. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  4205. var _checkboxEditor = __webpack_require__(201);
  4206. var _checkboxEditor2 = _interopRequireDefault(_checkboxEditor);
  4207. var _dateEditor = __webpack_require__(202);
  4208. var _dateEditor2 = _interopRequireDefault(_dateEditor);
  4209. var _dropdownEditor = __webpack_require__(203);
  4210. var _dropdownEditor2 = _interopRequireDefault(_dropdownEditor);
  4211. var _handsontableEditor = __webpack_require__(149);
  4212. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  4213. var _mobileTextEditor = __webpack_require__(204);
  4214. var _mobileTextEditor2 = _interopRequireDefault(_mobileTextEditor);
  4215. var _numericEditor = __webpack_require__(205);
  4216. var _numericEditor2 = _interopRequireDefault(_numericEditor);
  4217. var _passwordEditor = __webpack_require__(206);
  4218. var _passwordEditor2 = _interopRequireDefault(_passwordEditor);
  4219. var _selectEditor = __webpack_require__(207);
  4220. var _selectEditor2 = _interopRequireDefault(_selectEditor);
  4221. var _textEditor = __webpack_require__(43);
  4222. var _textEditor2 = _interopRequireDefault(_textEditor);
  4223. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4224. var registeredEditorClasses = new WeakMap(); /**
  4225. * Utility to register editors and common namespace for keeping reference to all editor classes
  4226. */
  4227. var _staticRegister = (0, _staticRegister3.default)('editors'),
  4228. register = _staticRegister.register,
  4229. getItem = _staticRegister.getItem,
  4230. hasItem = _staticRegister.hasItem,
  4231. getNames = _staticRegister.getNames,
  4232. getValues = _staticRegister.getValues;
  4233. _register('base', _baseEditor2.default);
  4234. _register('autocomplete', _autocompleteEditor2.default);
  4235. _register('checkbox', _checkboxEditor2.default);
  4236. _register('date', _dateEditor2.default);
  4237. _register('dropdown', _dropdownEditor2.default);
  4238. _register('handsontable', _handsontableEditor2.default);
  4239. _register('mobile', _mobileTextEditor2.default);
  4240. _register('numeric', _numericEditor2.default);
  4241. _register('password', _passwordEditor2.default);
  4242. _register('select', _selectEditor2.default);
  4243. _register('text', _textEditor2.default);
  4244. function RegisteredEditor(editorClass) {
  4245. var instances = {};
  4246. var Clazz = editorClass;
  4247. this.getConstructor = function () {
  4248. return editorClass;
  4249. };
  4250. this.getInstance = function (hotInstance) {
  4251. if (!(hotInstance.guid in instances)) {
  4252. instances[hotInstance.guid] = new Clazz(hotInstance);
  4253. }
  4254. return instances[hotInstance.guid];
  4255. };
  4256. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  4257. instances = {};
  4258. });
  4259. }
  4260. /**
  4261. * Returns instance (singleton) of editor class.
  4262. *
  4263. * @param {String} name Name of an editor under which it has been stored.
  4264. * @param {Object} hotInstance Instance of Handsontable.
  4265. * @returns {Function} Returns instance of editor.
  4266. */
  4267. function _getEditorInstance(name, hotInstance) {
  4268. var editor = void 0;
  4269. if (typeof name === 'function') {
  4270. if (!registeredEditorClasses.get(name)) {
  4271. _register(null, name);
  4272. }
  4273. editor = registeredEditorClasses.get(name);
  4274. } else if (typeof name === 'string') {
  4275. editor = getItem(name);
  4276. } else {
  4277. throw Error('Only strings and functions can be passed as "editor" parameter');
  4278. }
  4279. if (!editor) {
  4280. throw Error('No editor registered under name "' + name + '"');
  4281. }
  4282. return editor.getInstance(hotInstance);
  4283. }
  4284. /**
  4285. * Retrieve editor class.
  4286. *
  4287. * @param {String} name Editor identification.
  4288. * @returns {Function} Returns editor class.
  4289. */
  4290. function _getItem(name) {
  4291. if (!hasItem(name)) {
  4292. throw Error('No registered editor found under "' + name + '" name');
  4293. }
  4294. return getItem(name).getConstructor();
  4295. }
  4296. /**
  4297. * Register editor class under specified name.
  4298. *
  4299. * @param {String} name Editor identification.
  4300. * @param {Function} editorClass Editor class.
  4301. */
  4302. function _register(name, editorClass) {
  4303. var editorWrapper = new RegisteredEditor(editorClass);
  4304. if (typeof name === 'string') {
  4305. register(name, editorWrapper);
  4306. }
  4307. registeredEditorClasses.set(editorClass, editorWrapper);
  4308. }
  4309. exports.registerEditor = _register;
  4310. exports.getEditor = _getItem;
  4311. exports.getEditorInstance = _getEditorInstance;
  4312. exports.hasEditor = hasItem;
  4313. exports.getRegisteredEditorNames = getNames;
  4314. exports.getRegisteredEditors = getValues;
  4315. /***/ }),
  4316. /* 15 */
  4317. /***/ (function(module, exports) {
  4318. module.exports = function(it){
  4319. return typeof it === 'object' ? it !== null : typeof it === 'function';
  4320. };
  4321. /***/ }),
  4322. /* 16 */
  4323. /***/ (function(module, exports, __webpack_require__) {
  4324. "use strict";
  4325. exports.__esModule = true;
  4326. exports.KEY_CODES = undefined;
  4327. exports.isPrintableChar = isPrintableChar;
  4328. exports.isMetaKey = isMetaKey;
  4329. exports.isCtrlKey = isCtrlKey;
  4330. exports.isKey = isKey;
  4331. var _array = __webpack_require__(2);
  4332. var KEY_CODES = exports.KEY_CODES = {
  4333. MOUSE_LEFT: 1,
  4334. MOUSE_RIGHT: 3,
  4335. MOUSE_MIDDLE: 2,
  4336. BACKSPACE: 8,
  4337. COMMA: 188,
  4338. INSERT: 45,
  4339. DELETE: 46,
  4340. END: 35,
  4341. ENTER: 13,
  4342. ESCAPE: 27,
  4343. CONTROL_LEFT: 91,
  4344. COMMAND_LEFT: 17,
  4345. COMMAND_RIGHT: 93,
  4346. ALT: 18,
  4347. HOME: 36,
  4348. PAGE_DOWN: 34,
  4349. PAGE_UP: 33,
  4350. PERIOD: 190,
  4351. SPACE: 32,
  4352. SHIFT: 16,
  4353. CAPS_LOCK: 20,
  4354. TAB: 9,
  4355. ARROW_RIGHT: 39,
  4356. ARROW_LEFT: 37,
  4357. ARROW_UP: 38,
  4358. ARROW_DOWN: 40,
  4359. F1: 112,
  4360. F2: 113,
  4361. F3: 114,
  4362. F4: 115,
  4363. F5: 116,
  4364. F6: 117,
  4365. F7: 118,
  4366. F8: 119,
  4367. F9: 120,
  4368. F10: 121,
  4369. F11: 122,
  4370. F12: 123,
  4371. A: 65,
  4372. X: 88,
  4373. C: 67,
  4374. V: 86
  4375. };
  4376. /**
  4377. * Returns true if keyCode represents a printable character.
  4378. *
  4379. * @param {Number} keyCode
  4380. * @returns {Boolean}
  4381. */
  4382. function isPrintableChar(keyCode) {
  4383. return keyCode == 32 || // space
  4384. keyCode >= 48 && keyCode <= 57 || // 0-9
  4385. keyCode >= 96 && keyCode <= 111 || // numpad
  4386. keyCode >= 186 && keyCode <= 192 || // ;=,-./`
  4387. keyCode >= 219 && keyCode <= 222 || // []{}\|"'
  4388. keyCode >= 226 || // special chars (229 for Asian chars)
  4389. keyCode >= 65 && keyCode <= 90; // a-z
  4390. }
  4391. /**
  4392. * @param {Number} keyCode
  4393. * @returns {Boolean}
  4394. */
  4395. function isMetaKey(keyCode) {
  4396. 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];
  4397. return metaKeys.indexOf(keyCode) !== -1;
  4398. }
  4399. /**
  4400. * @param {Number} keyCode
  4401. * @returns {Boolean}
  4402. */
  4403. function isCtrlKey(keyCode) {
  4404. return [KEY_CODES.CONTROL_LEFT, 224, KEY_CODES.COMMAND_LEFT, KEY_CODES.COMMAND_RIGHT].indexOf(keyCode) !== -1;
  4405. }
  4406. /**
  4407. * @param {Number} keyCode
  4408. * @param {String} baseCode
  4409. * @returns {Boolean}
  4410. */
  4411. function isKey(keyCode, baseCode) {
  4412. var keys = baseCode.split('|');
  4413. var result = false;
  4414. (0, _array.arrayEach)(keys, function (key) {
  4415. if (keyCode === KEY_CODES[key]) {
  4416. result = true;
  4417. return false;
  4418. }
  4419. });
  4420. return result;
  4421. }
  4422. /***/ }),
  4423. /* 17 */
  4424. /***/ (function(module, exports, __webpack_require__) {
  4425. "use strict";
  4426. exports.__esModule = true;
  4427. exports.normalizeSelection = normalizeSelection;
  4428. exports.isSeparator = isSeparator;
  4429. exports.hasSubMenu = hasSubMenu;
  4430. exports.isDisabled = isDisabled;
  4431. exports.isSelectionDisabled = isSelectionDisabled;
  4432. exports.getValidSelection = getValidSelection;
  4433. exports.prepareVerticalAlignClass = prepareVerticalAlignClass;
  4434. exports.prepareHorizontalAlignClass = prepareHorizontalAlignClass;
  4435. exports.getAlignmentClasses = getAlignmentClasses;
  4436. exports.align = align;
  4437. exports.checkSelectionConsistency = checkSelectionConsistency;
  4438. exports.markLabelAsSelected = markLabelAsSelected;
  4439. exports.isItemHidden = isItemHidden;
  4440. exports.filterSeparators = filterSeparators;
  4441. var _array = __webpack_require__(2);
  4442. var _element = __webpack_require__(0);
  4443. var _separator = __webpack_require__(71);
  4444. function normalizeSelection(selRange) {
  4445. return {
  4446. start: selRange.getTopLeftCorner(),
  4447. end: selRange.getBottomRightCorner()
  4448. };
  4449. }
  4450. function isSeparator(cell) {
  4451. return (0, _element.hasClass)(cell, 'htSeparator');
  4452. }
  4453. function hasSubMenu(cell) {
  4454. return (0, _element.hasClass)(cell, 'htSubmenu');
  4455. }
  4456. function isDisabled(cell) {
  4457. return (0, _element.hasClass)(cell, 'htDisabled');
  4458. }
  4459. function isSelectionDisabled(cell) {
  4460. return (0, _element.hasClass)(cell, 'htSelectionDisabled');
  4461. }
  4462. function getValidSelection(hot) {
  4463. var selected = hot.getSelected();
  4464. if (!selected) {
  4465. return null;
  4466. }
  4467. if (selected[0] < 0) {
  4468. return null;
  4469. }
  4470. return selected;
  4471. }
  4472. function prepareVerticalAlignClass(className, alignment) {
  4473. if (className.indexOf(alignment) != -1) {
  4474. return className;
  4475. }
  4476. className = className.replace('htTop', '').replace('htMiddle', '').replace('htBottom', '').replace(' ', '');
  4477. className += ' ' + alignment;
  4478. return className;
  4479. }
  4480. function prepareHorizontalAlignClass(className, alignment) {
  4481. if (className.indexOf(alignment) != -1) {
  4482. return className;
  4483. }
  4484. className = className.replace('htLeft', '').replace('htCenter', '').replace('htRight', '').replace('htJustify', '').replace(' ', '');
  4485. className += ' ' + alignment;
  4486. return className;
  4487. }
  4488. function getAlignmentClasses(range, callback) {
  4489. var classes = {};
  4490. for (var row = range.from.row; row <= range.to.row; row++) {
  4491. for (var col = range.from.col; col <= range.to.col; col++) {
  4492. if (!classes[row]) {
  4493. classes[row] = [];
  4494. }
  4495. classes[row][col] = callback(row, col);
  4496. }
  4497. }
  4498. return classes;
  4499. }
  4500. function align(range, type, alignment, cellDescriptor, propertySetter) {
  4501. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  4502. applyAlignClassName(range.from.row, range.from.col, type, alignment, cellDescriptor, propertySetter);
  4503. } else {
  4504. for (var row = range.from.row; row <= range.to.row; row++) {
  4505. for (var col = range.from.col; col <= range.to.col; col++) {
  4506. applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter);
  4507. }
  4508. }
  4509. }
  4510. }
  4511. function applyAlignClassName(row, col, type, alignment, cellDescriptor, propertySetter) {
  4512. var cellMeta = cellDescriptor(row, col);
  4513. var className = alignment;
  4514. if (cellMeta.className) {
  4515. if (type === 'vertical') {
  4516. className = prepareVerticalAlignClass(cellMeta.className, alignment);
  4517. } else {
  4518. className = prepareHorizontalAlignClass(cellMeta.className, alignment);
  4519. }
  4520. }
  4521. propertySetter(row, col, 'className', className);
  4522. }
  4523. function checkSelectionConsistency(range, comparator) {
  4524. var result = false;
  4525. if (range) {
  4526. range.forAll(function (row, col) {
  4527. if (comparator(row, col)) {
  4528. result = true;
  4529. return false;
  4530. }
  4531. });
  4532. }
  4533. return result;
  4534. }
  4535. function markLabelAsSelected(label) {
  4536. // workaround for https://github.com/handsontable/handsontable/issues/1946
  4537. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label;
  4538. }
  4539. function isItemHidden(item, instance) {
  4540. return !item.hidden || !(typeof item.hidden == 'function' && item.hidden.call(instance));
  4541. }
  4542. function shiftSeparators(items, separator) {
  4543. var result = items.slice(0);
  4544. for (var i = 0; i < result.length;) {
  4545. if (result[i].name === separator) {
  4546. result.shift();
  4547. } else {
  4548. break;
  4549. }
  4550. }
  4551. return result;
  4552. }
  4553. function popSeparators(items, separator) {
  4554. var result = items.slice(0);
  4555. result.reverse();
  4556. result = shiftSeparators(result, separator);
  4557. result.reverse();
  4558. return result;
  4559. }
  4560. function removeDuplicatedSeparators(items) {
  4561. var result = [];
  4562. (0, _array.arrayEach)(items, function (value, index) {
  4563. if (index > 0) {
  4564. if (result[result.length - 1].name !== value.name) {
  4565. result.push(value);
  4566. }
  4567. } else {
  4568. result.push(value);
  4569. }
  4570. });
  4571. return result;
  4572. }
  4573. function filterSeparators(items) {
  4574. var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _separator.KEY;
  4575. var result = items.slice(0);
  4576. result = shiftSeparators(result, separator);
  4577. result = popSeparators(result, separator);
  4578. result = removeDuplicatedSeparators(result);
  4579. return result;
  4580. }
  4581. /***/ }),
  4582. /* 18 */
  4583. /***/ (function(module, exports, __webpack_require__) {
  4584. var isObject = __webpack_require__(15);
  4585. module.exports = function(it){
  4586. if(!isObject(it))throw TypeError(it + ' is not an object!');
  4587. return it;
  4588. };
  4589. /***/ }),
  4590. /* 19 */
  4591. /***/ (function(module, exports, __webpack_require__) {
  4592. var anObject = __webpack_require__(18)
  4593. , IE8_DOM_DEFINE = __webpack_require__(160)
  4594. , toPrimitive = __webpack_require__(86)
  4595. , dP = Object.defineProperty;
  4596. exports.f = __webpack_require__(21) ? Object.defineProperty : function defineProperty(O, P, Attributes){
  4597. anObject(O);
  4598. P = toPrimitive(P, true);
  4599. anObject(Attributes);
  4600. if(IE8_DOM_DEFINE)try {
  4601. return dP(O, P, Attributes);
  4602. } catch(e){ /* empty */ }
  4603. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  4604. if('value' in Attributes)O[P] = Attributes.value;
  4605. return O;
  4606. };
  4607. /***/ }),
  4608. /* 20 */
  4609. /***/ (function(module, exports, __webpack_require__) {
  4610. "use strict";
  4611. exports.__esModule = true;
  4612. 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; };
  4613. exports.stringify = stringify;
  4614. exports.isDefined = isDefined;
  4615. exports.isUndefined = isUndefined;
  4616. exports.isEmpty = isEmpty;
  4617. exports.isRegExp = isRegExp;
  4618. /**
  4619. * Converts any value to string.
  4620. *
  4621. * @param {*} value
  4622. * @returns {String}
  4623. */
  4624. function stringify(value) {
  4625. var result = void 0;
  4626. switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {
  4627. case 'string':
  4628. case 'number':
  4629. result = '' + value;
  4630. break;
  4631. case 'object':
  4632. result = value === null ? '' : value.toString();
  4633. break;
  4634. case 'undefined':
  4635. result = '';
  4636. break;
  4637. default:
  4638. result = value.toString();
  4639. break;
  4640. }
  4641. return result;
  4642. }
  4643. /**
  4644. * Checks if given variable is defined.
  4645. *
  4646. * @param {*} variable Variable to check.
  4647. * @returns {Boolean}
  4648. */
  4649. function isDefined(variable) {
  4650. return typeof variable !== 'undefined';
  4651. }
  4652. /**
  4653. * Checks if given variable is undefined.
  4654. *
  4655. * @param {*} variable Variable to check.
  4656. * @returns {Boolean}
  4657. */
  4658. function isUndefined(variable) {
  4659. return typeof variable === 'undefined';
  4660. }
  4661. /**
  4662. * Check if given variable is null, empty string or undefined.
  4663. *
  4664. * @param {*} variable Variable to check.
  4665. * @returns {Boolean}
  4666. */
  4667. function isEmpty(variable) {
  4668. return variable === null || variable === '' || isUndefined(variable);
  4669. }
  4670. /**
  4671. * Check if given variable is a regular expression.
  4672. *
  4673. * @param {*} variable Variable to check.
  4674. * @returns {Boolean}
  4675. */
  4676. function isRegExp(variable) {
  4677. return Object.prototype.toString.call(variable) === '[object RegExp]';
  4678. }
  4679. /***/ }),
  4680. /* 21 */
  4681. /***/ (function(module, exports, __webpack_require__) {
  4682. // Thank's IE8 for his funny defineProperty
  4683. module.exports = !__webpack_require__(31)(function(){
  4684. return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
  4685. });
  4686. /***/ }),
  4687. /* 22 */
  4688. /***/ (function(module, exports) {
  4689. var hasOwnProperty = {}.hasOwnProperty;
  4690. module.exports = function(it, key){
  4691. return hasOwnProperty.call(it, key);
  4692. };
  4693. /***/ }),
  4694. /* 23 */
  4695. /***/ (function(module, exports, __webpack_require__) {
  4696. // to indexed object, toObject with fallback for non-array-like ES3 strings
  4697. var IObject = __webpack_require__(77)
  4698. , defined = __webpack_require__(30);
  4699. module.exports = function(it){
  4700. return IObject(defined(it));
  4701. };
  4702. /***/ }),
  4703. /* 24 */
  4704. /***/ (function(module, exports, __webpack_require__) {
  4705. // 7.1.15 ToLength
  4706. var toInteger = __webpack_require__(60)
  4707. , min = Math.min;
  4708. module.exports = function(it){
  4709. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  4710. };
  4711. /***/ }),
  4712. /* 25 */
  4713. /***/ (function(module, exports, __webpack_require__) {
  4714. "use strict";
  4715. exports.__esModule = true;
  4716. exports.isIE8 = isIE8;
  4717. exports.isIE9 = isIE9;
  4718. exports.isSafari = isSafari;
  4719. exports.isChrome = isChrome;
  4720. exports.isMobileBrowser = isMobileBrowser;
  4721. var _isIE8 = !document.createTextNode('test').textContent;
  4722. function isIE8() {
  4723. return _isIE8;
  4724. }
  4725. var _isIE9 = !!document.documentMode;
  4726. function isIE9() {
  4727. return _isIE9;
  4728. }
  4729. var _isSafari = /Safari/.test(navigator.userAgent) && /Apple Computer/.test(navigator.vendor);
  4730. function isSafari() {
  4731. return _isSafari;
  4732. }
  4733. var _isChrome = /Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor);
  4734. function isChrome() {
  4735. return _isChrome;
  4736. }
  4737. function isMobileBrowser(userAgent) {
  4738. if (!userAgent) {
  4739. userAgent = navigator.userAgent;
  4740. }
  4741. return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent)
  4742. );
  4743. }
  4744. /***/ }),
  4745. /* 26 */
  4746. /***/ (function(module, exports, __webpack_require__) {
  4747. "use strict";
  4748. exports.__esModule = true;
  4749. exports.getRegisteredValidators = exports.getRegisteredValidatorNames = exports.hasValidator = exports.getValidator = exports.registerValidator = undefined;
  4750. var _staticRegister2 = __webpack_require__(50);
  4751. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  4752. var _autocompleteValidator = __webpack_require__(273);
  4753. var _autocompleteValidator2 = _interopRequireDefault(_autocompleteValidator);
  4754. var _dateValidator = __webpack_require__(274);
  4755. var _dateValidator2 = _interopRequireDefault(_dateValidator);
  4756. var _numericValidator = __webpack_require__(275);
  4757. var _numericValidator2 = _interopRequireDefault(_numericValidator);
  4758. var _timeValidator = __webpack_require__(276);
  4759. var _timeValidator2 = _interopRequireDefault(_timeValidator);
  4760. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4761. var _staticRegister = (0, _staticRegister3.default)('validators'),
  4762. register = _staticRegister.register,
  4763. getItem = _staticRegister.getItem,
  4764. hasItem = _staticRegister.hasItem,
  4765. getNames = _staticRegister.getNames,
  4766. getValues = _staticRegister.getValues;
  4767. register('autocomplete', _autocompleteValidator2.default);
  4768. register('date', _dateValidator2.default);
  4769. register('numeric', _numericValidator2.default);
  4770. register('time', _timeValidator2.default);
  4771. /**
  4772. * Retrieve validator function.
  4773. *
  4774. * @param {String} name Validator identification.
  4775. * @returns {Function} Returns validator function.
  4776. */
  4777. function _getItem(name) {
  4778. if (typeof name === 'function') {
  4779. return name;
  4780. }
  4781. if (!hasItem(name)) {
  4782. throw Error('No registered validator found under "' + name + '" name');
  4783. }
  4784. return getItem(name);
  4785. }
  4786. exports.registerValidator = register;
  4787. exports.getValidator = _getItem;
  4788. exports.hasValidator = hasItem;
  4789. exports.getRegisteredValidatorNames = getNames;
  4790. exports.getRegisteredValidators = getValues;
  4791. /***/ }),
  4792. /* 27 */
  4793. /***/ (function(module, exports, __webpack_require__) {
  4794. "use strict";
  4795. exports.__esModule = true;
  4796. exports.toUpperCaseFirst = toUpperCaseFirst;
  4797. exports.equalsIgnoreCase = equalsIgnoreCase;
  4798. exports.randomString = randomString;
  4799. exports.isPercentValue = isPercentValue;
  4800. exports.substitute = substitute;
  4801. exports.stripTags = stripTags;
  4802. var _mixed = __webpack_require__(20);
  4803. var _number = __webpack_require__(6);
  4804. /**
  4805. * Convert string to upper case first letter.
  4806. *
  4807. * @param {String} string String to convert.
  4808. * @returns {String}
  4809. */
  4810. function toUpperCaseFirst(string) {
  4811. return string[0].toUpperCase() + string.substr(1);
  4812. }
  4813. /**
  4814. * Compare strings case insensitively.
  4815. *
  4816. * @param {...String} strings Strings to compare.
  4817. * @returns {Boolean}
  4818. */
  4819. function equalsIgnoreCase() {
  4820. var unique = [];
  4821. for (var _len = arguments.length, strings = Array(_len), _key = 0; _key < _len; _key++) {
  4822. strings[_key] = arguments[_key];
  4823. }
  4824. var length = strings.length;
  4825. while (length--) {
  4826. var string = (0, _mixed.stringify)(strings[length]).toLowerCase();
  4827. if (unique.indexOf(string) === -1) {
  4828. unique.push(string);
  4829. }
  4830. }
  4831. return unique.length === 1;
  4832. }
  4833. /**
  4834. * Generates a random hex string. Used as namespace for Handsontable instance events.
  4835. *
  4836. * @return {String} Returns 16-long character random string (eq. `'92b1bfc74ec4'`).
  4837. */
  4838. function randomString() {
  4839. function s4() {
  4840. return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  4841. }
  4842. return s4() + s4() + s4() + s4();
  4843. }
  4844. /**
  4845. * Checks if value is valid percent.
  4846. *
  4847. * @param {String} value
  4848. * @returns {Boolean}
  4849. */
  4850. function isPercentValue(value) {
  4851. return (/^([0-9][0-9]?%$)|(^100%$)/.test(value)
  4852. );
  4853. }
  4854. /**
  4855. * Substitute strings placed beetwen square brackets into value defined in `variables` object. String names defined in
  4856. * square brackets must be the same as property name of `variables` object.
  4857. *
  4858. * @param {String} template Template string.
  4859. * @param {Object} variables Object which contains all available values which can be injected into template.
  4860. * @returns {String}
  4861. */
  4862. function substitute(template) {
  4863. var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  4864. return ('' + template).replace(/(?:\\)?\[([^[\]]+)]/g, function (match, name) {
  4865. if (match.charAt(0) === '\\') {
  4866. return match.substr(1, match.length - 1);
  4867. }
  4868. return variables[name] === void 0 ? '' : variables[name];
  4869. });
  4870. }
  4871. var STRIP_TAGS_REGEX = /<\/?\w+\/?>|<\w+[\s|/][^>]*>/gi;
  4872. /**
  4873. * Strip any HTML tag from the string.
  4874. *
  4875. * @param {String} string String to cut HTML from.
  4876. * @return {String}
  4877. */
  4878. function stripTags(string) {
  4879. string += '';
  4880. return string.replace(STRIP_TAGS_REGEX, '');
  4881. }
  4882. /***/ }),
  4883. /* 28 */
  4884. /***/ (function(module, exports, __webpack_require__) {
  4885. "use strict";
  4886. exports.__esModule = true;
  4887. 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; }; }();
  4888. var _element = __webpack_require__(0);
  4889. var _object = __webpack_require__(1);
  4890. var _array = __webpack_require__(2);
  4891. var _eventManager = __webpack_require__(4);
  4892. var _eventManager2 = _interopRequireDefault(_eventManager);
  4893. var _core = __webpack_require__(138);
  4894. var _core2 = _interopRequireDefault(_core);
  4895. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  4896. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4897. var registeredOverlays = {};
  4898. /**
  4899. * Creates an overlay over the original Walkontable instance. The overlay renders the clone of the original Walkontable
  4900. * and (optionally) implements behavior needed for native horizontal and vertical scrolling.
  4901. *
  4902. * @class Overlay
  4903. */
  4904. var Overlay = function () {
  4905. _createClass(Overlay, null, [{
  4906. key: 'registerOverlay',
  4907. /**
  4908. * Register overlay class.
  4909. *
  4910. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4911. * @param {Overlay} overlayClass Overlay class extended from base overlay class {@link Overlay}
  4912. */
  4913. value: function registerOverlay(type, overlayClass) {
  4914. if (Overlay.CLONE_TYPES.indexOf(type) === -1) {
  4915. throw new Error('Unsupported overlay (' + type + ').');
  4916. }
  4917. registeredOverlays[type] = overlayClass;
  4918. }
  4919. /**
  4920. * Create new instance of overlay type.
  4921. *
  4922. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4923. * @param {Walkontable} wot Walkontable instance
  4924. */
  4925. }, {
  4926. key: 'createOverlay',
  4927. value: function createOverlay(type, wot) {
  4928. return new registeredOverlays[type](wot);
  4929. }
  4930. /**
  4931. * Check if specified overlay was registered.
  4932. *
  4933. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4934. * @returns {Boolean}
  4935. */
  4936. }, {
  4937. key: 'hasOverlay',
  4938. value: function hasOverlay(type) {
  4939. return registeredOverlays[type] !== void 0;
  4940. }
  4941. /**
  4942. * Checks if overlay object (`overlay`) is instance of overlay type (`type`).
  4943. *
  4944. * @param {Overlay} overlay Overlay object
  4945. * @param {String} type Overlay type, one of the CLONE_TYPES value
  4946. * @returns {Boolean}
  4947. */
  4948. }, {
  4949. key: 'isOverlayTypeOf',
  4950. value: function isOverlayTypeOf(overlay, type) {
  4951. if (!overlay || !registeredOverlays[type]) {
  4952. return false;
  4953. }
  4954. return overlay instanceof registeredOverlays[type];
  4955. }
  4956. /**
  4957. * @param {Walkontable} wotInstance
  4958. */
  4959. }, {
  4960. key: 'CLONE_TOP',
  4961. /**
  4962. * @type {String}
  4963. */
  4964. get: function get() {
  4965. return 'top';
  4966. }
  4967. /**
  4968. * @type {String}
  4969. */
  4970. }, {
  4971. key: 'CLONE_BOTTOM',
  4972. get: function get() {
  4973. return 'bottom';
  4974. }
  4975. /**
  4976. * @type {String}
  4977. */
  4978. }, {
  4979. key: 'CLONE_LEFT',
  4980. get: function get() {
  4981. return 'left';
  4982. }
  4983. /**
  4984. * @type {String}
  4985. */
  4986. }, {
  4987. key: 'CLONE_TOP_LEFT_CORNER',
  4988. get: function get() {
  4989. return 'top_left_corner';
  4990. }
  4991. /**
  4992. * @type {String}
  4993. */
  4994. }, {
  4995. key: 'CLONE_BOTTOM_LEFT_CORNER',
  4996. get: function get() {
  4997. return 'bottom_left_corner';
  4998. }
  4999. /**
  5000. * @type {String}
  5001. */
  5002. }, {
  5003. key: 'CLONE_DEBUG',
  5004. get: function get() {
  5005. return 'debug';
  5006. }
  5007. /**
  5008. * List of all availables clone types
  5009. *
  5010. * @type {Array}
  5011. */
  5012. }, {
  5013. key: 'CLONE_TYPES',
  5014. get: function get() {
  5015. return [Overlay.CLONE_TOP, Overlay.CLONE_BOTTOM, Overlay.CLONE_LEFT, Overlay.CLONE_TOP_LEFT_CORNER, Overlay.CLONE_BOTTOM_LEFT_CORNER, Overlay.CLONE_DEBUG];
  5016. }
  5017. }]);
  5018. function Overlay(wotInstance) {
  5019. _classCallCheck(this, Overlay);
  5020. (0, _object.defineGetter)(this, 'wot', wotInstance, {
  5021. writable: false
  5022. });
  5023. // legacy support, deprecated in the future
  5024. this.instance = this.wot;
  5025. this.type = '';
  5026. this.mainTableScrollableElement = null;
  5027. this.TABLE = this.wot.wtTable.TABLE;
  5028. this.hider = this.wot.wtTable.hider;
  5029. this.spreader = this.wot.wtTable.spreader;
  5030. this.holder = this.wot.wtTable.holder;
  5031. this.wtRootElement = this.wot.wtTable.wtRootElement;
  5032. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5033. this.areElementSizesAdjusted = false;
  5034. this.updateStateOfRendering();
  5035. }
  5036. /**
  5037. * Update internal state of object with an information about the need of full rendering of the overlay.
  5038. *
  5039. * @returns {Boolean} Returns `true` if the state has changed since the last check.
  5040. */
  5041. _createClass(Overlay, [{
  5042. key: 'updateStateOfRendering',
  5043. value: function updateStateOfRendering() {
  5044. var previousState = this.needFullRender;
  5045. this.needFullRender = this.shouldBeRendered();
  5046. var changed = previousState !== this.needFullRender;
  5047. if (changed && !this.needFullRender) {
  5048. this.reset();
  5049. }
  5050. return changed;
  5051. }
  5052. /**
  5053. * Checks if overlay should be fully rendered
  5054. *
  5055. * @returns {Boolean}
  5056. */
  5057. }, {
  5058. key: 'shouldBeRendered',
  5059. value: function shouldBeRendered() {
  5060. return true;
  5061. }
  5062. /**
  5063. * Update the trimming container.
  5064. */
  5065. }, {
  5066. key: 'updateTrimmingContainer',
  5067. value: function updateTrimmingContainer() {
  5068. this.trimmingContainer = (0, _element.getTrimmingContainer)(this.hider.parentNode.parentNode);
  5069. }
  5070. /**
  5071. * Update the main scrollable element.
  5072. */
  5073. }, {
  5074. key: 'updateMainScrollableElement',
  5075. value: function updateMainScrollableElement() {
  5076. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5077. }
  5078. /**
  5079. * Make a clone of table for overlay
  5080. *
  5081. * @param {String} direction Can be `Overlay.CLONE_TOP`, `Overlay.CLONE_LEFT`,
  5082. * `Overlay.CLONE_TOP_LEFT_CORNER`, `Overlay.CLONE_DEBUG`
  5083. * @returns {Walkontable}
  5084. */
  5085. }, {
  5086. key: 'makeClone',
  5087. value: function makeClone(direction) {
  5088. if (Overlay.CLONE_TYPES.indexOf(direction) === -1) {
  5089. throw new Error('Clone type "' + direction + '" is not supported.');
  5090. }
  5091. var clone = document.createElement('DIV');
  5092. var clonedTable = document.createElement('TABLE');
  5093. clone.className = 'ht_clone_' + direction + ' handsontable';
  5094. clone.style.position = 'absolute';
  5095. clone.style.top = 0;
  5096. clone.style.left = 0;
  5097. clone.style.overflow = 'hidden';
  5098. clonedTable.className = this.wot.wtTable.TABLE.className;
  5099. clone.appendChild(clonedTable);
  5100. this.type = direction;
  5101. this.wot.wtTable.wtRootElement.parentNode.appendChild(clone);
  5102. var preventOverflow = this.wot.getSetting('preventOverflow');
  5103. if (preventOverflow === true || preventOverflow === 'horizontal' && this.type === Overlay.CLONE_TOP || preventOverflow === 'vertical' && this.type === Overlay.CLONE_LEFT) {
  5104. this.mainTableScrollableElement = window;
  5105. } else {
  5106. this.mainTableScrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  5107. }
  5108. return new _core2.default({
  5109. cloneSource: this.wot,
  5110. cloneOverlay: this,
  5111. table: clonedTable
  5112. });
  5113. }
  5114. /**
  5115. * Refresh/Redraw overlay
  5116. *
  5117. * @param {Boolean} [fastDraw=false]
  5118. */
  5119. }, {
  5120. key: 'refresh',
  5121. value: function refresh() {
  5122. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  5123. // When hot settings are changed we allow to refresh overlay once before blocking
  5124. var nextCycleRenderFlag = this.shouldBeRendered();
  5125. if (this.clone && (this.needFullRender || nextCycleRenderFlag)) {
  5126. this.clone.draw(fastDraw);
  5127. }
  5128. this.needFullRender = nextCycleRenderFlag;
  5129. }
  5130. /**
  5131. * Reset overlay styles to initial values.
  5132. */
  5133. }, {
  5134. key: 'reset',
  5135. value: function reset() {
  5136. if (!this.clone) {
  5137. return;
  5138. }
  5139. var holder = this.clone.wtTable.holder;
  5140. var hider = this.clone.wtTable.hider;
  5141. var holderStyle = holder.style;
  5142. var hidderStyle = hider.style;
  5143. var rootStyle = holder.parentNode.style;
  5144. (0, _array.arrayEach)([holderStyle, hidderStyle, rootStyle], function (style) {
  5145. style.width = '';
  5146. style.height = '';
  5147. });
  5148. }
  5149. /**
  5150. * Destroy overlay instance
  5151. */
  5152. }, {
  5153. key: 'destroy',
  5154. value: function destroy() {
  5155. new _eventManager2.default(this.clone).destroy();
  5156. }
  5157. }]);
  5158. return Overlay;
  5159. }();
  5160. exports.default = Overlay;
  5161. /***/ }),
  5162. /* 29 */
  5163. /***/ (function(module, exports, __webpack_require__) {
  5164. // optional / simple context binding
  5165. var aFunction = __webpack_require__(72);
  5166. module.exports = function(fn, that, length){
  5167. aFunction(fn);
  5168. if(that === undefined)return fn;
  5169. switch(length){
  5170. case 1: return function(a){
  5171. return fn.call(that, a);
  5172. };
  5173. case 2: return function(a, b){
  5174. return fn.call(that, a, b);
  5175. };
  5176. case 3: return function(a, b, c){
  5177. return fn.call(that, a, b, c);
  5178. };
  5179. }
  5180. return function(/* ...args */){
  5181. return fn.apply(that, arguments);
  5182. };
  5183. };
  5184. /***/ }),
  5185. /* 30 */
  5186. /***/ (function(module, exports) {
  5187. // 7.2.1 RequireObjectCoercible(argument)
  5188. module.exports = function(it){
  5189. if(it == undefined)throw TypeError("Can't call method on " + it);
  5190. return it;
  5191. };
  5192. /***/ }),
  5193. /* 31 */
  5194. /***/ (function(module, exports) {
  5195. module.exports = function(exec){
  5196. try {
  5197. return !!exec();
  5198. } catch(e){
  5199. return true;
  5200. }
  5201. };
  5202. /***/ }),
  5203. /* 32 */
  5204. /***/ (function(module, exports, __webpack_require__) {
  5205. var dP = __webpack_require__(19)
  5206. , createDesc = __webpack_require__(40);
  5207. module.exports = __webpack_require__(21) ? function(object, key, value){
  5208. return dP.f(object, key, createDesc(1, value));
  5209. } : function(object, key, value){
  5210. object[key] = value;
  5211. return object;
  5212. };
  5213. /***/ }),
  5214. /* 33 */
  5215. /***/ (function(module, exports, __webpack_require__) {
  5216. var global = __webpack_require__(13)
  5217. , hide = __webpack_require__(32)
  5218. , has = __webpack_require__(22)
  5219. , SRC = __webpack_require__(49)('src')
  5220. , TO_STRING = 'toString'
  5221. , $toString = Function[TO_STRING]
  5222. , TPL = ('' + $toString).split(TO_STRING);
  5223. __webpack_require__(44).inspectSource = function(it){
  5224. return $toString.call(it);
  5225. };
  5226. (module.exports = function(O, key, val, safe){
  5227. var isFunction = typeof val == 'function';
  5228. if(isFunction)has(val, 'name') || hide(val, 'name', key);
  5229. if(O[key] === val)return;
  5230. if(isFunction)has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
  5231. if(O === global){
  5232. O[key] = val;
  5233. } else {
  5234. if(!safe){
  5235. delete O[key];
  5236. hide(O, key, val);
  5237. } else {
  5238. if(O[key])O[key] = val;
  5239. else hide(O, key, val);
  5240. }
  5241. }
  5242. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  5243. })(Function.prototype, TO_STRING, function toString(){
  5244. return typeof this == 'function' && this[SRC] || $toString.call(this);
  5245. });
  5246. /***/ }),
  5247. /* 34 */
  5248. /***/ (function(module, exports, __webpack_require__) {
  5249. "use strict";
  5250. exports.__esModule = true;
  5251. 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; };
  5252. exports.requestAnimationFrame = requestAnimationFrame;
  5253. exports.cancelAnimationFrame = cancelAnimationFrame;
  5254. exports.isTouchSupported = isTouchSupported;
  5255. exports.isWebComponentSupportedNatively = isWebComponentSupportedNatively;
  5256. exports.hasCaptionProblem = hasCaptionProblem;
  5257. exports.getComparisonFunction = getComparisonFunction;
  5258. // https://gist.github.com/paulirish/1579671
  5259. var lastTime = 0;
  5260. var vendors = ['ms', 'moz', 'webkit', 'o'];
  5261. var _requestAnimationFrame = window.requestAnimationFrame;
  5262. var _cancelAnimationFrame = window.cancelAnimationFrame;
  5263. for (var x = 0; x < vendors.length && !_requestAnimationFrame; ++x) {
  5264. _requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
  5265. _cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
  5266. }
  5267. if (!_requestAnimationFrame) {
  5268. _requestAnimationFrame = function _requestAnimationFrame(callback) {
  5269. var currTime = new Date().getTime();
  5270. var timeToCall = Math.max(0, 16 - (currTime - lastTime));
  5271. var id = window.setTimeout(function () {
  5272. callback(currTime + timeToCall);
  5273. }, timeToCall);
  5274. lastTime = currTime + timeToCall;
  5275. return id;
  5276. };
  5277. }
  5278. if (!_cancelAnimationFrame) {
  5279. _cancelAnimationFrame = function _cancelAnimationFrame(id) {
  5280. clearTimeout(id);
  5281. };
  5282. }
  5283. /**
  5284. * Polyfill for requestAnimationFrame
  5285. *
  5286. * @param {Function} callback
  5287. * @returns {Number}
  5288. */
  5289. function requestAnimationFrame(callback) {
  5290. return _requestAnimationFrame.call(window, callback);
  5291. }
  5292. /**
  5293. * Polyfill for cancelAnimationFrame
  5294. *
  5295. * @param {Number} id
  5296. */
  5297. function cancelAnimationFrame(id) {
  5298. _cancelAnimationFrame.call(window, id);
  5299. }
  5300. function isTouchSupported() {
  5301. return 'ontouchstart' in window;
  5302. }
  5303. /**
  5304. * Checks if browser is support web components natively
  5305. *
  5306. * @returns {Boolean}
  5307. */
  5308. function isWebComponentSupportedNatively() {
  5309. var test = document.createElement('div');
  5310. return !!(test.createShadowRoot && test.createShadowRoot.toString().match(/\[native code\]/));
  5311. }
  5312. var _hasCaptionProblem;
  5313. function detectCaptionProblem() {
  5314. var TABLE = document.createElement('TABLE');
  5315. TABLE.style.borderSpacing = 0;
  5316. TABLE.style.borderWidth = 0;
  5317. TABLE.style.padding = 0;
  5318. var TBODY = document.createElement('TBODY');
  5319. TABLE.appendChild(TBODY);
  5320. TBODY.appendChild(document.createElement('TR'));
  5321. TBODY.firstChild.appendChild(document.createElement('TD'));
  5322. TBODY.firstChild.firstChild.innerHTML = '<tr><td>t<br>t</td></tr>';
  5323. var CAPTION = document.createElement('CAPTION');
  5324. CAPTION.innerHTML = 'c<br>c<br>c<br>c';
  5325. CAPTION.style.padding = 0;
  5326. CAPTION.style.margin = 0;
  5327. TABLE.insertBefore(CAPTION, TBODY);
  5328. document.body.appendChild(TABLE);
  5329. _hasCaptionProblem = TABLE.offsetHeight < 2 * TABLE.lastChild.offsetHeight; // boolean
  5330. document.body.removeChild(TABLE);
  5331. }
  5332. function hasCaptionProblem() {
  5333. if (_hasCaptionProblem === void 0) {
  5334. detectCaptionProblem();
  5335. }
  5336. return _hasCaptionProblem;
  5337. }
  5338. var comparisonFunction = void 0;
  5339. /**
  5340. * Get string comparison function for sorting purposes. It supports multilingual string comparison base on Internationalization API.
  5341. *
  5342. * @param {String} [language]
  5343. * @param {Object} [options]
  5344. * @returns {*}
  5345. */
  5346. function getComparisonFunction(language) {
  5347. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  5348. if (comparisonFunction) {
  5349. return comparisonFunction;
  5350. }
  5351. if ((typeof Intl === 'undefined' ? 'undefined' : _typeof(Intl)) === 'object') {
  5352. comparisonFunction = new Intl.Collator(language, options).compare;
  5353. } else if (typeof String.prototype.localeCompare === 'function') {
  5354. comparisonFunction = function comparisonFunction(a, b) {
  5355. return ('' + a).localeCompare(b);
  5356. };
  5357. } else {
  5358. comparisonFunction = function comparisonFunction(a, b) {
  5359. if (a === b) {
  5360. return 0;
  5361. }
  5362. return a > b ? -1 : 1;
  5363. };
  5364. }
  5365. return comparisonFunction;
  5366. }
  5367. /***/ }),
  5368. /* 35 */
  5369. /***/ (function(module, exports, __webpack_require__) {
  5370. "use strict";
  5371. exports.__esModule = true;
  5372. exports.isFunction = isFunction;
  5373. exports.throttle = throttle;
  5374. exports.throttleAfterHits = throttleAfterHits;
  5375. exports.debounce = debounce;
  5376. exports.pipe = pipe;
  5377. exports.partial = partial;
  5378. exports.curry = curry;
  5379. exports.curryRight = curryRight;
  5380. var _array = __webpack_require__(2);
  5381. /**
  5382. * Checks if given variable is function.
  5383. *
  5384. * @param {*} func Variable to check.
  5385. * @returns {Boolean}
  5386. */
  5387. function isFunction(func) {
  5388. return typeof func === 'function';
  5389. }
  5390. /**
  5391. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over time (`wait`).
  5392. *
  5393. * @param {Function} func Function to invoke.
  5394. * @param {Number} wait Delay in miliseconds.
  5395. * @returns {Function}
  5396. */
  5397. function throttle(func) {
  5398. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5399. var lastCalled = 0;
  5400. var result = {
  5401. lastCallThrottled: true
  5402. };
  5403. var lastTimer = null;
  5404. function _throttle() {
  5405. var _this = this;
  5406. var args = arguments;
  5407. var stamp = Date.now();
  5408. var needCall = false;
  5409. result.lastCallThrottled = true;
  5410. if (!lastCalled) {
  5411. lastCalled = stamp;
  5412. needCall = true;
  5413. }
  5414. var remaining = wait - (stamp - lastCalled);
  5415. if (needCall) {
  5416. result.lastCallThrottled = false;
  5417. func.apply(this, args);
  5418. } else {
  5419. if (lastTimer) {
  5420. clearTimeout(lastTimer);
  5421. }
  5422. lastTimer = setTimeout(function () {
  5423. result.lastCallThrottled = false;
  5424. func.apply(_this, args);
  5425. lastCalled = 0;
  5426. lastTimer = void 0;
  5427. }, remaining);
  5428. }
  5429. return result;
  5430. }
  5431. return _throttle;
  5432. }
  5433. /**
  5434. * Creates throttle function that enforces a maximum number of times a function (`func`) can be called over
  5435. * time (`wait`) after specified hits.
  5436. *
  5437. * @param {Function} func Function to invoke.
  5438. * @param {Number} wait Delay in miliseconds.
  5439. * @param {Number} hits Number of hits after throttling will be applied.
  5440. * @returns {Function}
  5441. */
  5442. function throttleAfterHits(func) {
  5443. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5444. var hits = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
  5445. var funcThrottle = throttle(func, wait);
  5446. var remainHits = hits;
  5447. function _clearHits() {
  5448. remainHits = hits;
  5449. }
  5450. function _throttleAfterHits() {
  5451. if (remainHits) {
  5452. remainHits--;
  5453. return func.apply(this, arguments);
  5454. }
  5455. return funcThrottle.apply(this, arguments);
  5456. }
  5457. _throttleAfterHits.clearHits = _clearHits;
  5458. return _throttleAfterHits;
  5459. }
  5460. /**
  5461. * Creates debounce function that enforces a function (`func`) not be called again until a certain amount of time (`wait`)
  5462. * has passed without it being called.
  5463. *
  5464. * @param {Function} func Function to invoke.
  5465. * @param {Number} wait Delay in milliseconds.
  5466. * @returns {Function}
  5467. */
  5468. function debounce(func) {
  5469. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
  5470. var lastTimer = null;
  5471. var result = void 0;
  5472. function _debounce() {
  5473. var _this2 = this;
  5474. var args = arguments;
  5475. if (lastTimer) {
  5476. clearTimeout(lastTimer);
  5477. }
  5478. lastTimer = setTimeout(function () {
  5479. result = func.apply(_this2, args);
  5480. }, wait);
  5481. return result;
  5482. }
  5483. return _debounce;
  5484. }
  5485. /**
  5486. * Creates the function that returns the result of calling the given functions. Result of the first function is passed to
  5487. * the second as an argument and so on. Only first function in the chain can handle multiple arguments.
  5488. *
  5489. * @param {Function} functions Functions to compose.
  5490. * @returns {Function}
  5491. */
  5492. function pipe() {
  5493. for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) {
  5494. functions[_key] = arguments[_key];
  5495. }
  5496. var firstFunc = functions[0],
  5497. restFunc = functions.slice(1);
  5498. return function _pipe() {
  5499. return (0, _array.arrayReduce)(restFunc, function (acc, fn) {
  5500. return fn(acc);
  5501. }, firstFunc.apply(this, arguments));
  5502. };
  5503. }
  5504. /**
  5505. * Creates the function that returns the function with cached arguments.
  5506. *
  5507. * @param {Function} func Function to partialization.
  5508. * @param {Array} params Function arguments to cache.
  5509. * @returns {Function}
  5510. */
  5511. function partial(func) {
  5512. for (var _len2 = arguments.length, params = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  5513. params[_key2 - 1] = arguments[_key2];
  5514. }
  5515. return function _partial() {
  5516. for (var _len3 = arguments.length, restParams = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  5517. restParams[_key3] = arguments[_key3];
  5518. }
  5519. return func.apply(this, params.concat(restParams));
  5520. };
  5521. }
  5522. /**
  5523. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  5524. * to the arguments defined in `func` then function will be invoked.
  5525. * Arguments are added to the stack in direction from the left to the right.
  5526. *
  5527. * @example
  5528. * ```
  5529. * var replace = curry(function(find, replace, string) {
  5530. * return string.replace(find, replace);
  5531. * });
  5532. *
  5533. * // returns function with bounded first argument
  5534. * var replace = replace('foo')
  5535. *
  5536. * // returns replaced string - all arguments was passed so function was invoked
  5537. * replace('bar', 'Some test with foo...');
  5538. *
  5539. * ```
  5540. *
  5541. * @param {Function} func Function to currying.
  5542. * @returns {Function}
  5543. */
  5544. function curry(func) {
  5545. var argsLength = func.length;
  5546. function given(argsSoFar) {
  5547. return function _curry() {
  5548. for (var _len4 = arguments.length, params = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  5549. params[_key4] = arguments[_key4];
  5550. }
  5551. var passedArgsSoFar = argsSoFar.concat(params);
  5552. var result = void 0;
  5553. if (passedArgsSoFar.length >= argsLength) {
  5554. result = func.apply(this, passedArgsSoFar);
  5555. } else {
  5556. result = given(passedArgsSoFar);
  5557. }
  5558. return result;
  5559. };
  5560. }
  5561. return given([]);
  5562. }
  5563. /**
  5564. * Creates the functions that returns the function with cached arguments. If count if passed arguments will be matched
  5565. * to the arguments defined in `func` then function will be invoked.
  5566. * Arguments are added to the stack in direction from the right to the left.
  5567. *
  5568. * @example
  5569. * ```
  5570. * var replace = curry(function(find, replace, string) {
  5571. * return string.replace(find, replace);
  5572. * });
  5573. *
  5574. * // returns function with bounded first argument
  5575. * var replace = replace('Some test with foo...')
  5576. *
  5577. * // returns replaced string - all arguments was passed so function was invoked
  5578. * replace('bar', 'foo');
  5579. *
  5580. * ```
  5581. *
  5582. * @param {Function} func Function to currying.
  5583. * @returns {Function}
  5584. */
  5585. function curryRight(func) {
  5586. var argsLength = func.length;
  5587. function given(argsSoFar) {
  5588. return function _curry() {
  5589. for (var _len5 = arguments.length, params = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
  5590. params[_key5] = arguments[_key5];
  5591. }
  5592. var passedArgsSoFar = argsSoFar.concat(params.reverse());
  5593. var result = void 0;
  5594. if (passedArgsSoFar.length >= argsLength) {
  5595. result = func.apply(this, passedArgsSoFar);
  5596. } else {
  5597. result = given(passedArgsSoFar);
  5598. }
  5599. return result;
  5600. };
  5601. }
  5602. return given([]);
  5603. }
  5604. /***/ }),
  5605. /* 36 */
  5606. /***/ (function(module, exports, __webpack_require__) {
  5607. "use strict";
  5608. exports.__esModule = true;
  5609. exports.EditorState = undefined;
  5610. var _src = __webpack_require__(11);
  5611. var _mixed = __webpack_require__(20);
  5612. var EditorState = exports.EditorState = {
  5613. VIRGIN: 'STATE_VIRGIN', // before editing
  5614. EDITING: 'STATE_EDITING',
  5615. WAITING: 'STATE_WAITING', // waiting for async validation
  5616. FINISHED: 'STATE_FINISHED'
  5617. };
  5618. function BaseEditor(instance) {
  5619. this.instance = instance;
  5620. this.state = EditorState.VIRGIN;
  5621. this._opened = false;
  5622. this._fullEditMode = false;
  5623. this._closeCallback = null;
  5624. this.init();
  5625. }
  5626. BaseEditor.prototype._fireCallbacks = function (result) {
  5627. if (this._closeCallback) {
  5628. this._closeCallback(result);
  5629. this._closeCallback = null;
  5630. }
  5631. };
  5632. BaseEditor.prototype.init = function () {};
  5633. BaseEditor.prototype.getValue = function () {
  5634. throw Error('Editor getValue() method unimplemented');
  5635. };
  5636. BaseEditor.prototype.setValue = function (newValue) {
  5637. throw Error('Editor setValue() method unimplemented');
  5638. };
  5639. BaseEditor.prototype.open = function () {
  5640. throw Error('Editor open() method unimplemented');
  5641. };
  5642. BaseEditor.prototype.close = function () {
  5643. throw Error('Editor close() method unimplemented');
  5644. };
  5645. BaseEditor.prototype.prepare = function (row, col, prop, td, originalValue, cellProperties) {
  5646. this.TD = td;
  5647. this.row = row;
  5648. this.col = col;
  5649. this.prop = prop;
  5650. this.originalValue = originalValue;
  5651. this.cellProperties = cellProperties;
  5652. this.state = EditorState.VIRGIN;
  5653. };
  5654. BaseEditor.prototype.extend = function () {
  5655. var baseClass = this.constructor;
  5656. function Editor() {
  5657. baseClass.apply(this, arguments);
  5658. }
  5659. function inherit(Child, Parent) {
  5660. function Bridge() {}
  5661. Bridge.prototype = Parent.prototype;
  5662. Child.prototype = new Bridge();
  5663. Child.prototype.constructor = Child;
  5664. return Child;
  5665. }
  5666. return inherit(Editor, baseClass);
  5667. };
  5668. BaseEditor.prototype.saveValue = function (value, ctrlDown) {
  5669. var selection = void 0;
  5670. var tmp = void 0;
  5671. // if ctrl+enter and multiple cells selected, behave like Excel (finish editing and apply to all cells)
  5672. if (ctrlDown) {
  5673. selection = this.instance.getSelected();
  5674. if (selection[0] > selection[2]) {
  5675. tmp = selection[0];
  5676. selection[0] = selection[2];
  5677. selection[2] = tmp;
  5678. }
  5679. if (selection[1] > selection[3]) {
  5680. tmp = selection[1];
  5681. selection[1] = selection[3];
  5682. selection[3] = tmp;
  5683. }
  5684. } else {
  5685. selection = [this.row, this.col, null, null];
  5686. }
  5687. this.instance.populateFromArray(selection[0], selection[1], value, selection[2], selection[3], 'edit');
  5688. };
  5689. BaseEditor.prototype.beginEditing = function (initialValue, event) {
  5690. if (this.state != EditorState.VIRGIN) {
  5691. return;
  5692. }
  5693. this.instance.view.scrollViewport(new _src.CellCoords(this.row, this.col));
  5694. this.instance.view.render();
  5695. this.state = EditorState.EDITING;
  5696. initialValue = typeof initialValue == 'string' ? initialValue : this.originalValue;
  5697. this.setValue((0, _mixed.stringify)(initialValue));
  5698. this.open(event);
  5699. this._opened = true;
  5700. this.focus();
  5701. // only rerender the selections (FillHandle should disappear when beginediting is triggered)
  5702. this.instance.view.render();
  5703. this.instance.runHooks('afterBeginEditing', this.row, this.col);
  5704. };
  5705. BaseEditor.prototype.finishEditing = function (restoreOriginalValue, ctrlDown, callback) {
  5706. var _this = this,
  5707. val;
  5708. if (callback) {
  5709. var previousCloseCallback = this._closeCallback;
  5710. this._closeCallback = function (result) {
  5711. if (previousCloseCallback) {
  5712. previousCloseCallback(result);
  5713. }
  5714. callback(result);
  5715. _this.instance.view.render();
  5716. };
  5717. }
  5718. if (this.isWaiting()) {
  5719. return;
  5720. }
  5721. if (this.state == EditorState.VIRGIN) {
  5722. this.instance._registerTimeout(setTimeout(function () {
  5723. _this._fireCallbacks(true);
  5724. }, 0));
  5725. return;
  5726. }
  5727. if (this.state == EditorState.EDITING) {
  5728. if (restoreOriginalValue) {
  5729. this.cancelChanges();
  5730. this.instance.view.render();
  5731. return;
  5732. }
  5733. var value = this.getValue();
  5734. if (this.instance.getSettings().trimWhitespace) {
  5735. // We trim only string values
  5736. val = [[typeof value === 'string' ? String.prototype.trim.call(value || '') : value]];
  5737. } else {
  5738. val = [[value]];
  5739. }
  5740. this.state = EditorState.WAITING;
  5741. this.saveValue(val, ctrlDown);
  5742. if (this.instance.getCellValidator(this.cellProperties)) {
  5743. this.instance.addHookOnce('postAfterValidate', function (result) {
  5744. _this.state = EditorState.FINISHED;
  5745. _this.discardEditor(result);
  5746. });
  5747. } else {
  5748. this.state = EditorState.FINISHED;
  5749. this.discardEditor(true);
  5750. }
  5751. }
  5752. };
  5753. BaseEditor.prototype.cancelChanges = function () {
  5754. this.state = EditorState.FINISHED;
  5755. this.discardEditor();
  5756. };
  5757. BaseEditor.prototype.discardEditor = function (result) {
  5758. if (this.state !== EditorState.FINISHED) {
  5759. return;
  5760. }
  5761. // validator was defined and failed
  5762. if (result === false && this.cellProperties.allowInvalid !== true) {
  5763. this.instance.selectCell(this.row, this.col);
  5764. this.focus();
  5765. this.state = EditorState.EDITING;
  5766. this._fireCallbacks(false);
  5767. } else {
  5768. this.close();
  5769. this._opened = false;
  5770. this._fullEditMode = false;
  5771. this.state = EditorState.VIRGIN;
  5772. this._fireCallbacks(true);
  5773. }
  5774. };
  5775. /**
  5776. * Switch editor into full edit mode. In this state navigation keys don't close editor. This mode is activated
  5777. * automatically after hit ENTER or F2 key on the cell or while editing cell press F2 key.
  5778. */
  5779. BaseEditor.prototype.enableFullEditMode = function () {
  5780. this._fullEditMode = true;
  5781. };
  5782. /**
  5783. * Checks if editor is in full edit mode.
  5784. *
  5785. * @returns {Boolean}
  5786. */
  5787. BaseEditor.prototype.isInFullEditMode = function () {
  5788. return this._fullEditMode;
  5789. };
  5790. BaseEditor.prototype.isOpened = function () {
  5791. return this._opened;
  5792. };
  5793. BaseEditor.prototype.isWaiting = function () {
  5794. return this.state === EditorState.WAITING;
  5795. };
  5796. BaseEditor.prototype.checkEditorSection = function () {
  5797. var totalRows = this.instance.countRows();
  5798. var section = '';
  5799. if (this.row < this.instance.getSettings().fixedRowsTop) {
  5800. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  5801. section = 'top-left-corner';
  5802. } else {
  5803. section = 'top';
  5804. }
  5805. } else if (this.instance.getSettings().fixedRowsBottom && this.row >= totalRows - this.instance.getSettings().fixedRowsBottom) {
  5806. if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  5807. section = 'bottom-left-corner';
  5808. } else {
  5809. section = 'bottom';
  5810. }
  5811. } else if (this.col < this.instance.getSettings().fixedColumnsLeft) {
  5812. section = 'left';
  5813. }
  5814. return section;
  5815. };
  5816. exports.default = BaseEditor;
  5817. /***/ }),
  5818. /* 37 */
  5819. /***/ (function(module, exports, __webpack_require__) {
  5820. // 22.1.3.31 Array.prototype[@@unscopables]
  5821. var UNSCOPABLES = __webpack_require__(10)('unscopables')
  5822. , ArrayProto = Array.prototype;
  5823. if(ArrayProto[UNSCOPABLES] == undefined)__webpack_require__(32)(ArrayProto, UNSCOPABLES, {});
  5824. module.exports = function(key){
  5825. ArrayProto[UNSCOPABLES][key] = true;
  5826. };
  5827. /***/ }),
  5828. /* 38 */
  5829. /***/ (function(module, exports) {
  5830. var toString = {}.toString;
  5831. module.exports = function(it){
  5832. return toString.call(it).slice(8, -1);
  5833. };
  5834. /***/ }),
  5835. /* 39 */
  5836. /***/ (function(module, exports, __webpack_require__) {
  5837. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  5838. var $keys = __webpack_require__(169)
  5839. , enumBugKeys = __webpack_require__(75);
  5840. module.exports = Object.keys || function keys(O){
  5841. return $keys(O, enumBugKeys);
  5842. };
  5843. /***/ }),
  5844. /* 40 */
  5845. /***/ (function(module, exports) {
  5846. module.exports = function(bitmap, value){
  5847. return {
  5848. enumerable : !(bitmap & 1),
  5849. configurable: !(bitmap & 2),
  5850. writable : !(bitmap & 4),
  5851. value : value
  5852. };
  5853. };
  5854. /***/ }),
  5855. /* 41 */
  5856. /***/ (function(module, exports, __webpack_require__) {
  5857. // 7.1.13 ToObject(argument)
  5858. var defined = __webpack_require__(30);
  5859. module.exports = function(it){
  5860. return Object(defined(it));
  5861. };
  5862. /***/ }),
  5863. /* 42 */
  5864. /***/ (function(module, exports, __webpack_require__) {
  5865. "use strict";
  5866. exports.__esModule = true;
  5867. 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; }; }();
  5868. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5869. /**
  5870. * CellCoords holds cell coordinates (row, column) and few method to validate them and
  5871. * retrieve as an array or an object
  5872. *
  5873. * @class CellCoords
  5874. */
  5875. var CellCoords = function () {
  5876. /**
  5877. * @param {Number} row Row index
  5878. * @param {Number} col Column index
  5879. */
  5880. function CellCoords(row, col) {
  5881. _classCallCheck(this, CellCoords);
  5882. if (typeof row !== 'undefined' && typeof col !== 'undefined') {
  5883. this.row = row;
  5884. this.col = col;
  5885. } else {
  5886. this.row = null;
  5887. this.col = null;
  5888. }
  5889. }
  5890. /**
  5891. * Checks if given set of coordinates is valid in context of a given Walkontable instance
  5892. *
  5893. * @param {Walkontable} wotInstance
  5894. * @returns {Boolean}
  5895. */
  5896. _createClass(CellCoords, [{
  5897. key: 'isValid',
  5898. value: function isValid(wotInstance) {
  5899. // is it a valid cell index (0 or higher)
  5900. if (this.row < 0 || this.col < 0) {
  5901. return false;
  5902. }
  5903. // is selection within total rows and columns
  5904. if (this.row >= wotInstance.getSetting('totalRows') || this.col >= wotInstance.getSetting('totalColumns')) {
  5905. return false;
  5906. }
  5907. return true;
  5908. }
  5909. /**
  5910. * Checks if this cell coords are the same as cell coords given as a parameter
  5911. *
  5912. * @param {CellCoords} cellCoords
  5913. * @returns {Boolean}
  5914. */
  5915. }, {
  5916. key: 'isEqual',
  5917. value: function isEqual(cellCoords) {
  5918. if (cellCoords === this) {
  5919. return true;
  5920. }
  5921. return this.row === cellCoords.row && this.col === cellCoords.col;
  5922. }
  5923. /**
  5924. * Checks if tested coordinates are positioned in south-east from this cell coords
  5925. *
  5926. * @param {Object} testedCoords
  5927. * @returns {Boolean}
  5928. */
  5929. }, {
  5930. key: 'isSouthEastOf',
  5931. value: function isSouthEastOf(testedCoords) {
  5932. return this.row >= testedCoords.row && this.col >= testedCoords.col;
  5933. }
  5934. /**
  5935. * Checks if tested coordinates are positioned in north-east from this cell coords
  5936. *
  5937. * @param {Object} testedCoords
  5938. * @returns {Boolean}
  5939. */
  5940. }, {
  5941. key: 'isNorthWestOf',
  5942. value: function isNorthWestOf(testedCoords) {
  5943. return this.row <= testedCoords.row && this.col <= testedCoords.col;
  5944. }
  5945. /**
  5946. * Checks if tested coordinates are positioned in south-west from this cell coords
  5947. *
  5948. * @param {Object} testedCoords
  5949. * @returns {Boolean}
  5950. */
  5951. }, {
  5952. key: 'isSouthWestOf',
  5953. value: function isSouthWestOf(testedCoords) {
  5954. return this.row >= testedCoords.row && this.col <= testedCoords.col;
  5955. }
  5956. /**
  5957. * Checks if tested coordinates are positioned in north-east from this cell coords
  5958. *
  5959. * @param {Object} testedCoords
  5960. * @returns {Boolean}
  5961. */
  5962. }, {
  5963. key: 'isNorthEastOf',
  5964. value: function isNorthEastOf(testedCoords) {
  5965. return this.row <= testedCoords.row && this.col >= testedCoords.col;
  5966. }
  5967. }]);
  5968. return CellCoords;
  5969. }();
  5970. exports.default = CellCoords;
  5971. /***/ }),
  5972. /* 43 */
  5973. /***/ (function(module, exports, __webpack_require__) {
  5974. "use strict";
  5975. exports.__esModule = true;
  5976. var _element = __webpack_require__(0);
  5977. var _autoResize = __webpack_require__(183);
  5978. var _autoResize2 = _interopRequireDefault(_autoResize);
  5979. var _baseEditor = __webpack_require__(36);
  5980. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  5981. var _eventManager = __webpack_require__(4);
  5982. var _eventManager2 = _interopRequireDefault(_eventManager);
  5983. var _unicode = __webpack_require__(16);
  5984. var _event = __webpack_require__(7);
  5985. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5986. var TextEditor = _baseEditor2.default.prototype.extend();
  5987. /**
  5988. * @private
  5989. * @editor TextEditor
  5990. * @class TextEditor
  5991. * @dependencies autoResize
  5992. */
  5993. TextEditor.prototype.init = function () {
  5994. var that = this;
  5995. this.createElements();
  5996. this.eventManager = new _eventManager2.default(this);
  5997. this.bindEvents();
  5998. this.autoResize = (0, _autoResize2.default)();
  5999. this.instance.addHook('afterDestroy', function () {
  6000. that.destroy();
  6001. });
  6002. };
  6003. TextEditor.prototype.getValue = function () {
  6004. return this.TEXTAREA.value;
  6005. };
  6006. TextEditor.prototype.setValue = function (newValue) {
  6007. this.TEXTAREA.value = newValue;
  6008. };
  6009. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  6010. var instance = this,
  6011. that = instance.getActiveEditor(),
  6012. ctrlDown;
  6013. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  6014. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  6015. // Process only events that have been fired in the editor
  6016. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  6017. return;
  6018. }
  6019. if (event.keyCode === 17 || event.keyCode === 224 || event.keyCode === 91 || event.keyCode === 93) {
  6020. // when CTRL or its equivalent is pressed and cell is edited, don't prepare selectable text in textarea
  6021. (0, _event.stopImmediatePropagation)(event);
  6022. return;
  6023. }
  6024. switch (event.keyCode) {
  6025. case _unicode.KEY_CODES.ARROW_RIGHT:
  6026. if (that.isInFullEditMode()) {
  6027. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6028. (0, _event.stopImmediatePropagation)(event);
  6029. }
  6030. }
  6031. break;
  6032. case _unicode.KEY_CODES.ARROW_LEFT:
  6033. if (that.isInFullEditMode()) {
  6034. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6035. (0, _event.stopImmediatePropagation)(event);
  6036. }
  6037. }
  6038. break;
  6039. case _unicode.KEY_CODES.ARROW_UP:
  6040. case _unicode.KEY_CODES.ARROW_DOWN:
  6041. if (that.isInFullEditMode()) {
  6042. if (!that.isWaiting() && !that.allowKeyEventPropagation || !that.isWaiting() && that.allowKeyEventPropagation && !that.allowKeyEventPropagation(event.keyCode)) {
  6043. (0, _event.stopImmediatePropagation)(event);
  6044. }
  6045. }
  6046. break;
  6047. case _unicode.KEY_CODES.ENTER:
  6048. var selected = that.instance.getSelected();
  6049. var isMultipleSelection = !(selected[0] === selected[2] && selected[1] === selected[3]);
  6050. if (ctrlDown && !isMultipleSelection || event.altKey) {
  6051. // if ctrl+enter or alt+enter, add new line
  6052. if (that.isOpened()) {
  6053. var caretPosition = (0, _element.getCaretPosition)(that.TEXTAREA),
  6054. value = that.getValue();
  6055. var newValue = value.slice(0, caretPosition) + '\n' + value.slice(caretPosition);
  6056. that.setValue(newValue);
  6057. (0, _element.setCaretPosition)(that.TEXTAREA, caretPosition + 1);
  6058. } else {
  6059. that.beginEditing(that.originalValue + '\n');
  6060. }
  6061. (0, _event.stopImmediatePropagation)(event);
  6062. }
  6063. event.preventDefault(); // don't add newline to field
  6064. break;
  6065. case _unicode.KEY_CODES.A:
  6066. case _unicode.KEY_CODES.X:
  6067. case _unicode.KEY_CODES.C:
  6068. case _unicode.KEY_CODES.V:
  6069. if (ctrlDown) {
  6070. (0, _event.stopImmediatePropagation)(event); // CTRL+A, CTRL+C, CTRL+V, CTRL+X should only work locally when cell is edited (not in table context)
  6071. }
  6072. break;
  6073. case _unicode.KEY_CODES.BACKSPACE:
  6074. case _unicode.KEY_CODES.DELETE:
  6075. case _unicode.KEY_CODES.HOME:
  6076. case _unicode.KEY_CODES.END:
  6077. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  6078. break;
  6079. default:
  6080. break;
  6081. }
  6082. 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) {
  6083. that.autoResize.resize(String.fromCharCode(event.keyCode));
  6084. }
  6085. };
  6086. TextEditor.prototype.open = function () {
  6087. this.refreshDimensions(); // need it instantly, to prevent https://github.com/handsontable/handsontable/issues/348
  6088. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  6089. };
  6090. TextEditor.prototype.close = function (tdOutside) {
  6091. this.textareaParentStyle.display = 'none';
  6092. this.autoResize.unObserve();
  6093. if (document.activeElement === this.TEXTAREA) {
  6094. this.instance.listen(); // don't refocus the table if user focused some cell outside of HT on purpose
  6095. }
  6096. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  6097. };
  6098. TextEditor.prototype.focus = function () {
  6099. this.TEXTAREA.focus();
  6100. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  6101. };
  6102. TextEditor.prototype.createElements = function () {
  6103. // this.$body = $(document.body);
  6104. this.TEXTAREA = document.createElement('TEXTAREA');
  6105. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  6106. this.textareaStyle = this.TEXTAREA.style;
  6107. this.textareaStyle.width = 0;
  6108. this.textareaStyle.height = 0;
  6109. this.TEXTAREA_PARENT = document.createElement('DIV');
  6110. (0, _element.addClass)(this.TEXTAREA_PARENT, 'handsontableInputHolder');
  6111. this.textareaParentStyle = this.TEXTAREA_PARENT.style;
  6112. this.textareaParentStyle.top = 0;
  6113. this.textareaParentStyle.left = 0;
  6114. this.textareaParentStyle.display = 'none';
  6115. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  6116. this.instance.rootElement.appendChild(this.TEXTAREA_PARENT);
  6117. var that = this;
  6118. this.instance._registerTimeout(setTimeout(function () {
  6119. that.refreshDimensions();
  6120. }, 0));
  6121. };
  6122. TextEditor.prototype.getEditedCell = function () {
  6123. var editorSection = this.checkEditorSection(),
  6124. editedCell;
  6125. switch (editorSection) {
  6126. case 'top':
  6127. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  6128. row: this.row,
  6129. col: this.col
  6130. });
  6131. this.textareaParentStyle.zIndex = 101;
  6132. break;
  6133. case 'top-left-corner':
  6134. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  6135. row: this.row,
  6136. col: this.col
  6137. });
  6138. this.textareaParentStyle.zIndex = 103;
  6139. break;
  6140. case 'bottom-left-corner':
  6141. editedCell = this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell({
  6142. row: this.row,
  6143. col: this.col
  6144. });
  6145. this.textareaParentStyle.zIndex = 103;
  6146. break;
  6147. case 'left':
  6148. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  6149. row: this.row,
  6150. col: this.col
  6151. });
  6152. this.textareaParentStyle.zIndex = 102;
  6153. break;
  6154. case 'bottom':
  6155. editedCell = this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.getCell({
  6156. row: this.row,
  6157. col: this.col
  6158. });
  6159. this.textareaParentStyle.zIndex = 102;
  6160. break;
  6161. default:
  6162. editedCell = this.instance.getCell(this.row, this.col);
  6163. this.textareaParentStyle.zIndex = '';
  6164. break;
  6165. }
  6166. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  6167. };
  6168. TextEditor.prototype.refreshValue = function () {
  6169. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  6170. this.originalValue = sourceData;
  6171. this.setValue(sourceData);
  6172. this.refreshDimensions();
  6173. };
  6174. TextEditor.prototype.refreshDimensions = function () {
  6175. if (this.state !== _baseEditor.EditorState.EDITING) {
  6176. return;
  6177. }
  6178. this.TD = this.getEditedCell();
  6179. // TD is outside of the viewport.
  6180. if (!this.TD) {
  6181. this.close(true);
  6182. return;
  6183. }
  6184. var currentOffset = (0, _element.offset)(this.TD),
  6185. containerOffset = (0, _element.offset)(this.instance.rootElement),
  6186. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  6187. totalRowsCount = this.instance.countRows(),
  6188. // If colHeaders is disabled, cells in the first row have border-top
  6189. editTopModifier = currentOffset.top === containerOffset.top ? 0 : 1,
  6190. editTop = currentOffset.top - containerOffset.top - editTopModifier - (scrollableContainer.scrollTop || 0),
  6191. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  6192. settings = this.instance.getSettings(),
  6193. rowHeadersCount = this.instance.hasRowHeaders(),
  6194. colHeadersCount = this.instance.hasColHeaders(),
  6195. editorSection = this.checkEditorSection(),
  6196. backgroundColor = this.TD.style.backgroundColor,
  6197. cssTransformOffset;
  6198. // TODO: Refactor this to the new instance.getCell method (from #ply-59), after 0.12.1 is released
  6199. switch (editorSection) {
  6200. case 'top':
  6201. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  6202. break;
  6203. case 'left':
  6204. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  6205. break;
  6206. case 'top-left-corner':
  6207. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  6208. break;
  6209. case 'bottom-left-corner':
  6210. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  6211. break;
  6212. case 'bottom':
  6213. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  6214. break;
  6215. default:
  6216. break;
  6217. }
  6218. if (colHeadersCount && this.instance.getSelected()[0] === 0 || settings.fixedRowsBottom && this.instance.getSelected()[0] === totalRowsCount - settings.fixedRowsBottom) {
  6219. editTop += 1;
  6220. }
  6221. if (this.instance.getSelected()[1] === 0) {
  6222. editLeft += 1;
  6223. }
  6224. if (cssTransformOffset && cssTransformOffset != -1) {
  6225. this.textareaParentStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  6226. } else {
  6227. (0, _element.resetCssTransform)(this.TEXTAREA_PARENT);
  6228. }
  6229. this.textareaParentStyle.top = editTop + 'px';
  6230. this.textareaParentStyle.left = editLeft + 'px';
  6231. var firstRowOffset = this.instance.view.wt.wtViewport.rowsRenderCalculator.startPosition;
  6232. var firstColumnOffset = this.instance.view.wt.wtViewport.columnsRenderCalculator.startPosition;
  6233. var horizontalScrollPosition = this.instance.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  6234. var verticalScrollPosition = this.instance.view.wt.wtOverlays.topOverlay.getScrollPosition();
  6235. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  6236. var cellTopOffset = this.TD.offsetTop + firstRowOffset - verticalScrollPosition;
  6237. var cellLeftOffset = this.TD.offsetLeft + firstColumnOffset - horizontalScrollPosition;
  6238. var width = (0, _element.innerWidth)(this.TD) - 8;
  6239. var actualVerticalScrollbarWidth = (0, _element.hasVerticalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  6240. var actualHorizontalScrollbarWidth = (0, _element.hasHorizontalScrollbar)(scrollableContainer) ? scrollbarWidth : 0;
  6241. var maxWidth = this.instance.view.maximumVisibleElementWidth(cellLeftOffset) - 9 - actualVerticalScrollbarWidth;
  6242. var height = this.TD.scrollHeight + 1;
  6243. var maxHeight = Math.max(this.instance.view.maximumVisibleElementHeight(cellTopOffset) - actualHorizontalScrollbarWidth, 23);
  6244. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  6245. this.TEXTAREA.style.fontSize = cellComputedStyle.fontSize;
  6246. this.TEXTAREA.style.fontFamily = cellComputedStyle.fontFamily;
  6247. this.TEXTAREA.style.backgroundColor = ''; // RESET STYLE
  6248. this.TEXTAREA.style.backgroundColor = backgroundColor ? backgroundColor : (0, _element.getComputedStyle)(this.TEXTAREA).backgroundColor;
  6249. this.autoResize.init(this.TEXTAREA, {
  6250. minHeight: Math.min(height, maxHeight),
  6251. maxHeight: maxHeight, // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  6252. minWidth: Math.min(width, maxWidth),
  6253. maxWidth: maxWidth // TEXTAREA should never be wider than visible part of the viewport (should not cover the scrollbar)
  6254. }, true);
  6255. this.textareaParentStyle.display = 'block';
  6256. };
  6257. TextEditor.prototype.bindEvents = function () {
  6258. var editor = this;
  6259. this.eventManager.addEventListener(this.TEXTAREA, 'cut', function (event) {
  6260. (0, _event.stopPropagation)(event);
  6261. });
  6262. this.eventManager.addEventListener(this.TEXTAREA, 'paste', function (event) {
  6263. (0, _event.stopPropagation)(event);
  6264. });
  6265. this.instance.addHook('afterScrollHorizontally', function () {
  6266. editor.refreshDimensions();
  6267. });
  6268. this.instance.addHook('afterScrollVertically', function () {
  6269. editor.refreshDimensions();
  6270. });
  6271. this.instance.addHook('afterColumnResize', function () {
  6272. editor.refreshDimensions();
  6273. editor.focus();
  6274. });
  6275. this.instance.addHook('afterRowResize', function () {
  6276. editor.refreshDimensions();
  6277. editor.focus();
  6278. });
  6279. this.instance.addHook('afterDestroy', function () {
  6280. editor.eventManager.destroy();
  6281. });
  6282. };
  6283. TextEditor.prototype.destroy = function () {
  6284. this.eventManager.destroy();
  6285. };
  6286. exports.default = TextEditor;
  6287. /***/ }),
  6288. /* 44 */
  6289. /***/ (function(module, exports) {
  6290. var core = module.exports = {version: '2.4.0'};
  6291. if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
  6292. /***/ }),
  6293. /* 45 */
  6294. /***/ (function(module, exports) {
  6295. module.exports = {};
  6296. /***/ }),
  6297. /* 46 */
  6298. /***/ (function(module, exports, __webpack_require__) {
  6299. var META = __webpack_require__(49)('meta')
  6300. , isObject = __webpack_require__(15)
  6301. , has = __webpack_require__(22)
  6302. , setDesc = __webpack_require__(19).f
  6303. , id = 0;
  6304. var isExtensible = Object.isExtensible || function(){
  6305. return true;
  6306. };
  6307. var FREEZE = !__webpack_require__(31)(function(){
  6308. return isExtensible(Object.preventExtensions({}));
  6309. });
  6310. var setMeta = function(it){
  6311. setDesc(it, META, {value: {
  6312. i: 'O' + ++id, // object ID
  6313. w: {} // weak collections IDs
  6314. }});
  6315. };
  6316. var fastKey = function(it, create){
  6317. // return primitive with prefix
  6318. if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  6319. if(!has(it, META)){
  6320. // can't set metadata to uncaught frozen object
  6321. if(!isExtensible(it))return 'F';
  6322. // not necessary to add metadata
  6323. if(!create)return 'E';
  6324. // add missing metadata
  6325. setMeta(it);
  6326. // return object ID
  6327. } return it[META].i;
  6328. };
  6329. var getWeak = function(it, create){
  6330. if(!has(it, META)){
  6331. // can't set metadata to uncaught frozen object
  6332. if(!isExtensible(it))return true;
  6333. // not necessary to add metadata
  6334. if(!create)return false;
  6335. // add missing metadata
  6336. setMeta(it);
  6337. // return hash weak collections IDs
  6338. } return it[META].w;
  6339. };
  6340. // add metadata on freeze-family methods calling
  6341. var onFreeze = function(it){
  6342. if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
  6343. return it;
  6344. };
  6345. var meta = module.exports = {
  6346. KEY: META,
  6347. NEED: false,
  6348. fastKey: fastKey,
  6349. getWeak: getWeak,
  6350. onFreeze: onFreeze
  6351. };
  6352. /***/ }),
  6353. /* 47 */
  6354. /***/ (function(module, exports) {
  6355. exports.f = {}.propertyIsEnumerable;
  6356. /***/ }),
  6357. /* 48 */
  6358. /***/ (function(module, exports, __webpack_require__) {
  6359. var def = __webpack_require__(19).f
  6360. , has = __webpack_require__(22)
  6361. , TAG = __webpack_require__(10)('toStringTag');
  6362. module.exports = function(it, tag, stat){
  6363. if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
  6364. };
  6365. /***/ }),
  6366. /* 49 */
  6367. /***/ (function(module, exports) {
  6368. var id = 0
  6369. , px = Math.random();
  6370. module.exports = function(key){
  6371. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  6372. };
  6373. /***/ }),
  6374. /* 50 */
  6375. /***/ (function(module, exports, __webpack_require__) {
  6376. "use strict";
  6377. exports.__esModule = true;
  6378. exports.default = staticRegister;
  6379. 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); } }
  6380. var collection = exports.collection = new Map();
  6381. function staticRegister() {
  6382. var namespace = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'common';
  6383. if (!collection.has(namespace)) {
  6384. collection.set(namespace, new Map());
  6385. }
  6386. var subCollection = collection.get(namespace);
  6387. /**
  6388. * Register an item to the collection. If the item under the same was exist earlier then this item will be replaced with new one.
  6389. *
  6390. * @param {String} name Identification of the item.
  6391. * @param {*} item Item to save in the collection.
  6392. */
  6393. function register(name, item) {
  6394. subCollection.set(name, item);
  6395. }
  6396. /**
  6397. * Retrieve the item from the collection.
  6398. *
  6399. * @param {String} name Identification of the item.
  6400. * @returns {*} Returns item which was saved in the collection.
  6401. */
  6402. function getItem(name) {
  6403. return subCollection.get(name);
  6404. }
  6405. /**
  6406. * Check if item under specyfied name is exists.
  6407. *
  6408. * @param {String} name Identification of the item.
  6409. * @returns {Boolean} Returns `true` or `false` depends on if element exists in the collection.
  6410. */
  6411. function hasItem(name) {
  6412. return subCollection.has(name);
  6413. }
  6414. /**
  6415. * Retrieve list of names registered from the collection.
  6416. *
  6417. * @returns {Array} Returns an array of strings with all names under which objects are stored.
  6418. */
  6419. function getNames() {
  6420. return [].concat(_toConsumableArray(subCollection.keys()));
  6421. }
  6422. /**
  6423. * Retrieve all registered values from the collection.
  6424. *
  6425. * @returns {Array} Returns an array with all values stored in the collection.
  6426. */
  6427. function getValues() {
  6428. return [].concat(_toConsumableArray(subCollection.values()));
  6429. }
  6430. return {
  6431. register: register,
  6432. getItem: getItem,
  6433. hasItem: hasItem,
  6434. getNames: getNames,
  6435. getValues: getValues
  6436. };
  6437. }
  6438. /***/ }),
  6439. /* 51 */
  6440. /***/ (function(module, exports) {
  6441. module.exports = function(it, Constructor, name, forbiddenField){
  6442. if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
  6443. throw TypeError(name + ': incorrect invocation!');
  6444. } return it;
  6445. };
  6446. /***/ }),
  6447. /* 52 */
  6448. /***/ (function(module, exports, __webpack_require__) {
  6449. // 0 -> Array#forEach
  6450. // 1 -> Array#map
  6451. // 2 -> Array#filter
  6452. // 3 -> Array#some
  6453. // 4 -> Array#every
  6454. // 5 -> Array#find
  6455. // 6 -> Array#findIndex
  6456. var ctx = __webpack_require__(29)
  6457. , IObject = __webpack_require__(77)
  6458. , toObject = __webpack_require__(41)
  6459. , toLength = __webpack_require__(24)
  6460. , asc = __webpack_require__(280);
  6461. module.exports = function(TYPE, $create){
  6462. var IS_MAP = TYPE == 1
  6463. , IS_FILTER = TYPE == 2
  6464. , IS_SOME = TYPE == 3
  6465. , IS_EVERY = TYPE == 4
  6466. , IS_FIND_INDEX = TYPE == 6
  6467. , NO_HOLES = TYPE == 5 || IS_FIND_INDEX
  6468. , create = $create || asc;
  6469. return function($this, callbackfn, that){
  6470. var O = toObject($this)
  6471. , self = IObject(O)
  6472. , f = ctx(callbackfn, that, 3)
  6473. , length = toLength(self.length)
  6474. , index = 0
  6475. , result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined
  6476. , val, res;
  6477. for(;length > index; index++)if(NO_HOLES || index in self){
  6478. val = self[index];
  6479. res = f(val, index, O);
  6480. if(TYPE){
  6481. if(IS_MAP)result[index] = res; // map
  6482. else if(res)switch(TYPE){
  6483. case 3: return true; // some
  6484. case 5: return val; // find
  6485. case 6: return index; // findIndex
  6486. case 2: result.push(val); // filter
  6487. } else if(IS_EVERY)return false; // every
  6488. }
  6489. }
  6490. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
  6491. };
  6492. };
  6493. /***/ }),
  6494. /* 53 */
  6495. /***/ (function(module, exports, __webpack_require__) {
  6496. "use strict";
  6497. var global = __webpack_require__(13)
  6498. , $export = __webpack_require__(3)
  6499. , redefine = __webpack_require__(33)
  6500. , redefineAll = __webpack_require__(58)
  6501. , meta = __webpack_require__(46)
  6502. , forOf = __webpack_require__(55)
  6503. , anInstance = __webpack_require__(51)
  6504. , isObject = __webpack_require__(15)
  6505. , fails = __webpack_require__(31)
  6506. , $iterDetect = __webpack_require__(78)
  6507. , setToStringTag = __webpack_require__(48)
  6508. , inheritIfRequired = __webpack_require__(283);
  6509. module.exports = function(NAME, wrapper, methods, common, IS_MAP, IS_WEAK){
  6510. var Base = global[NAME]
  6511. , C = Base
  6512. , ADDER = IS_MAP ? 'set' : 'add'
  6513. , proto = C && C.prototype
  6514. , O = {};
  6515. var fixMethod = function(KEY){
  6516. var fn = proto[KEY];
  6517. redefine(proto, KEY,
  6518. KEY == 'delete' ? function(a){
  6519. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  6520. } : KEY == 'has' ? function has(a){
  6521. return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
  6522. } : KEY == 'get' ? function get(a){
  6523. return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
  6524. } : KEY == 'add' ? function add(a){ fn.call(this, a === 0 ? 0 : a); return this; }
  6525. : function set(a, b){ fn.call(this, a === 0 ? 0 : a, b); return this; }
  6526. );
  6527. };
  6528. if(typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function(){
  6529. new C().entries().next();
  6530. }))){
  6531. // create collection constructor
  6532. C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
  6533. redefineAll(C.prototype, methods);
  6534. meta.NEED = true;
  6535. } else {
  6536. var instance = new C
  6537. // early implementations not supports chaining
  6538. , HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance
  6539. // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false
  6540. , THROWS_ON_PRIMITIVES = fails(function(){ instance.has(1); })
  6541. // most early implementations doesn't supports iterables, most modern - not close it correctly
  6542. , ACCEPT_ITERABLES = $iterDetect(function(iter){ new C(iter); }) // eslint-disable-line no-new
  6543. // for early implementations -0 and +0 not the same
  6544. , BUGGY_ZERO = !IS_WEAK && fails(function(){
  6545. // V8 ~ Chromium 42- fails only with 5+ elements
  6546. var $instance = new C()
  6547. , index = 5;
  6548. while(index--)$instance[ADDER](index, index);
  6549. return !$instance.has(-0);
  6550. });
  6551. if(!ACCEPT_ITERABLES){
  6552. C = wrapper(function(target, iterable){
  6553. anInstance(target, C, NAME);
  6554. var that = inheritIfRequired(new Base, target, C);
  6555. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  6556. return that;
  6557. });
  6558. C.prototype = proto;
  6559. proto.constructor = C;
  6560. }
  6561. if(THROWS_ON_PRIMITIVES || BUGGY_ZERO){
  6562. fixMethod('delete');
  6563. fixMethod('has');
  6564. IS_MAP && fixMethod('get');
  6565. }
  6566. if(BUGGY_ZERO || HASNT_CHAINING)fixMethod(ADDER);
  6567. // weak collections should not contains .clear method
  6568. if(IS_WEAK && proto.clear)delete proto.clear;
  6569. }
  6570. setToStringTag(C, NAME);
  6571. O[NAME] = C;
  6572. $export($export.G + $export.W + $export.F * (C != Base), O);
  6573. if(!IS_WEAK)common.setStrong(C, NAME, IS_MAP);
  6574. return C;
  6575. };
  6576. /***/ }),
  6577. /* 54 */
  6578. /***/ (function(module, exports, __webpack_require__) {
  6579. "use strict";
  6580. var hide = __webpack_require__(32)
  6581. , redefine = __webpack_require__(33)
  6582. , fails = __webpack_require__(31)
  6583. , defined = __webpack_require__(30)
  6584. , wks = __webpack_require__(10);
  6585. module.exports = function(KEY, length, exec){
  6586. var SYMBOL = wks(KEY)
  6587. , fns = exec(defined, SYMBOL, ''[KEY])
  6588. , strfn = fns[0]
  6589. , rxfn = fns[1];
  6590. if(fails(function(){
  6591. var O = {};
  6592. O[SYMBOL] = function(){ return 7; };
  6593. return ''[KEY](O) != 7;
  6594. })){
  6595. redefine(String.prototype, KEY, strfn);
  6596. hide(RegExp.prototype, SYMBOL, length == 2
  6597. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  6598. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  6599. ? function(string, arg){ return rxfn.call(string, this, arg); }
  6600. // 21.2.5.6 RegExp.prototype[@@match](string)
  6601. // 21.2.5.9 RegExp.prototype[@@search](string)
  6602. : function(string){ return rxfn.call(string, this); }
  6603. );
  6604. }
  6605. };
  6606. /***/ }),
  6607. /* 55 */
  6608. /***/ (function(module, exports, __webpack_require__) {
  6609. var ctx = __webpack_require__(29)
  6610. , call = __webpack_require__(165)
  6611. , isArrayIter = __webpack_require__(161)
  6612. , anObject = __webpack_require__(18)
  6613. , toLength = __webpack_require__(24)
  6614. , getIterFn = __webpack_require__(176)
  6615. , BREAK = {}
  6616. , RETURN = {};
  6617. var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
  6618. var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
  6619. , f = ctx(fn, that, entries ? 2 : 1)
  6620. , index = 0
  6621. , length, step, iterator, result;
  6622. if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
  6623. // fast case for arrays with default iterator
  6624. if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
  6625. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  6626. if(result === BREAK || result === RETURN)return result;
  6627. } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
  6628. result = call(iterator, f, step.value, entries);
  6629. if(result === BREAK || result === RETURN)return result;
  6630. }
  6631. };
  6632. exports.BREAK = BREAK;
  6633. exports.RETURN = RETURN;
  6634. /***/ }),
  6635. /* 56 */
  6636. /***/ (function(module, exports) {
  6637. module.exports = false;
  6638. /***/ }),
  6639. /* 57 */
  6640. /***/ (function(module, exports) {
  6641. exports.f = Object.getOwnPropertySymbols;
  6642. /***/ }),
  6643. /* 58 */
  6644. /***/ (function(module, exports, __webpack_require__) {
  6645. var redefine = __webpack_require__(33);
  6646. module.exports = function(target, src, safe){
  6647. for(var key in src)redefine(target, key, src[key], safe);
  6648. return target;
  6649. };
  6650. /***/ }),
  6651. /* 59 */
  6652. /***/ (function(module, exports, __webpack_require__) {
  6653. var toInteger = __webpack_require__(60)
  6654. , max = Math.max
  6655. , min = Math.min;
  6656. module.exports = function(index, length){
  6657. index = toInteger(index);
  6658. return index < 0 ? max(index + length, 0) : min(index, length);
  6659. };
  6660. /***/ }),
  6661. /* 60 */
  6662. /***/ (function(module, exports) {
  6663. // 7.1.4 ToInteger
  6664. var ceil = Math.ceil
  6665. , floor = Math.floor;
  6666. module.exports = function(it){
  6667. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  6668. };
  6669. /***/ }),
  6670. /* 61 */
  6671. /***/ (function(module, exports) {
  6672. module.exports = __WEBPACK_EXTERNAL_MODULE_61__;
  6673. /***/ }),
  6674. /* 62 */
  6675. /***/ (function(module, exports, __webpack_require__) {
  6676. "use strict";
  6677. exports.__esModule = true;
  6678. exports.getRegisteredCellTypes = exports.getRegisteredCellTypeNames = exports.hasCellType = exports.getCellType = exports.registerCellType = undefined;
  6679. var _staticRegister2 = __webpack_require__(50);
  6680. var _staticRegister3 = _interopRequireDefault(_staticRegister2);
  6681. var _editors = __webpack_require__(14);
  6682. var _renderers = __webpack_require__(9);
  6683. var _validators = __webpack_require__(26);
  6684. var _autocompleteType = __webpack_require__(189);
  6685. var _autocompleteType2 = _interopRequireDefault(_autocompleteType);
  6686. var _checkboxType = __webpack_require__(190);
  6687. var _checkboxType2 = _interopRequireDefault(_checkboxType);
  6688. var _dateType = __webpack_require__(191);
  6689. var _dateType2 = _interopRequireDefault(_dateType);
  6690. var _dropdownType = __webpack_require__(192);
  6691. var _dropdownType2 = _interopRequireDefault(_dropdownType);
  6692. var _handsontableType = __webpack_require__(193);
  6693. var _handsontableType2 = _interopRequireDefault(_handsontableType);
  6694. var _numericType = __webpack_require__(194);
  6695. var _numericType2 = _interopRequireDefault(_numericType);
  6696. var _passwordType = __webpack_require__(195);
  6697. var _passwordType2 = _interopRequireDefault(_passwordType);
  6698. var _textType = __webpack_require__(196);
  6699. var _textType2 = _interopRequireDefault(_textType);
  6700. var _timeType = __webpack_require__(197);
  6701. var _timeType2 = _interopRequireDefault(_timeType);
  6702. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6703. var _staticRegister = (0, _staticRegister3.default)('cellTypes'),
  6704. register = _staticRegister.register,
  6705. getItem = _staticRegister.getItem,
  6706. hasItem = _staticRegister.hasItem,
  6707. getNames = _staticRegister.getNames,
  6708. getValues = _staticRegister.getValues;
  6709. _register('autocomplete', _autocompleteType2.default);
  6710. _register('checkbox', _checkboxType2.default);
  6711. _register('date', _dateType2.default);
  6712. _register('dropdown', _dropdownType2.default);
  6713. _register('handsontable', _handsontableType2.default);
  6714. _register('numeric', _numericType2.default);
  6715. _register('password', _passwordType2.default);
  6716. _register('text', _textType2.default);
  6717. _register('time', _timeType2.default);
  6718. /**
  6719. * Retrieve cell type object.
  6720. *
  6721. * @param {String} name Cell type identification.
  6722. * @returns {Object} Returns cell type object.
  6723. */
  6724. function _getItem(name) {
  6725. if (!hasItem(name)) {
  6726. 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');
  6727. }
  6728. return getItem(name);
  6729. }
  6730. /**
  6731. * Register cell type under specified name.
  6732. *
  6733. * @param {String} name Cell type identification.
  6734. * @param {Object} type An object with contains keys (eq: `editor`, `renderer`, `validator`) which describes specified behaviour of the cell.
  6735. */
  6736. function _register(name, type) {
  6737. var editor = type.editor,
  6738. renderer = type.renderer,
  6739. validator = type.validator;
  6740. if (editor) {
  6741. (0, _editors.registerEditor)(name, editor);
  6742. }
  6743. if (renderer) {
  6744. (0, _renderers.registerRenderer)(name, renderer);
  6745. }
  6746. if (validator) {
  6747. (0, _validators.registerValidator)(name, validator);
  6748. }
  6749. register(name, type);
  6750. }
  6751. exports.registerCellType = _register;
  6752. exports.getCellType = _getItem;
  6753. exports.hasCellType = hasItem;
  6754. exports.getRegisteredCellTypeNames = getNames;
  6755. exports.getRegisteredCellTypes = getValues;
  6756. /***/ }),
  6757. /* 63 */
  6758. /***/ (function(module, exports, __webpack_require__) {
  6759. "use strict";
  6760. exports.__esModule = true;
  6761. 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"); } }; }();
  6762. 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; };
  6763. exports.default = Core;
  6764. var _numbro = __webpack_require__(87);
  6765. var _numbro2 = _interopRequireDefault(_numbro);
  6766. var _element = __webpack_require__(0);
  6767. var _setting = __webpack_require__(65);
  6768. var _function = __webpack_require__(35);
  6769. var _mixed = __webpack_require__(20);
  6770. var _browser = __webpack_require__(25);
  6771. var _dataMap = __webpack_require__(198);
  6772. var _dataMap2 = _interopRequireDefault(_dataMap);
  6773. var _editorManager = __webpack_require__(200);
  6774. var _editorManager2 = _interopRequireDefault(_editorManager);
  6775. var _eventManager = __webpack_require__(4);
  6776. var _eventManager2 = _interopRequireDefault(_eventManager);
  6777. var _object = __webpack_require__(1);
  6778. var _array = __webpack_require__(2);
  6779. var _plugins = __webpack_require__(5);
  6780. var _renderers = __webpack_require__(9);
  6781. var _validators = __webpack_require__(26);
  6782. var _string = __webpack_require__(27);
  6783. var _number = __webpack_require__(6);
  6784. var _tableView = __webpack_require__(269);
  6785. var _tableView2 = _interopRequireDefault(_tableView);
  6786. var _dataSource = __webpack_require__(199);
  6787. var _dataSource2 = _interopRequireDefault(_dataSource);
  6788. var _data = __webpack_require__(64);
  6789. var _recordTranslator = __webpack_require__(153);
  6790. var _src = __webpack_require__(11);
  6791. var _pluginHooks = __webpack_require__(8);
  6792. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  6793. var _defaultSettings = __webpack_require__(88);
  6794. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  6795. var _cellTypes = __webpack_require__(62);
  6796. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6797. 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); } }
  6798. var activeGuid = null;
  6799. /**
  6800. * Handsontable constructor
  6801. *
  6802. * @core
  6803. * @dependencies numbro
  6804. * @constructor Core
  6805. * @description
  6806. *
  6807. * After Handsontable is constructed, you can modify the grid behavior using the available public methods.
  6808. *
  6809. * ---
  6810. * ## How to call methods
  6811. *
  6812. * These are 2 equal ways to call a Handsontable method:
  6813. *
  6814. * ```js
  6815. * // all following examples assume that you constructed Handsontable like this
  6816. * var ht = new Handsontable(document.getElementById('example1'), options);
  6817. *
  6818. * // now, to use setDataAtCell method, you can either:
  6819. * ht.setDataAtCell(0, 0, 'new value');
  6820. * ```
  6821. *
  6822. * Alternatively, you can call the method using jQuery wrapper (__obsolete__, requires initialization using our jQuery guide
  6823. * ```js
  6824. * $('#example1').handsontable('setDataAtCell', 0, 0, 'new value');
  6825. * ```
  6826. * ---
  6827. */
  6828. function Core(rootElement, userSettings) {
  6829. var priv,
  6830. datamap,
  6831. dataSource,
  6832. grid,
  6833. selection,
  6834. editorManager,
  6835. instance = this,
  6836. GridSettings = function GridSettings() {},
  6837. eventManager = new _eventManager2.default(instance);
  6838. (0, _object.extend)(GridSettings.prototype, _defaultSettings2.default.prototype); // create grid settings as a copy of default settings
  6839. (0, _object.extend)(GridSettings.prototype, userSettings); // overwrite defaults with user settings
  6840. (0, _object.extend)(GridSettings.prototype, expandType(userSettings));
  6841. this.rootElement = rootElement;
  6842. this.isHotTableEnv = (0, _element.isChildOfWebComponentTable)(this.rootElement);
  6843. _eventManager2.default.isHotTableEnv = this.isHotTableEnv;
  6844. this.container = document.createElement('DIV');
  6845. this.renderCall = false;
  6846. rootElement.insertBefore(this.container, rootElement.firstChild);
  6847. this.guid = 'ht_' + (0, _string.randomString)(); // this is the namespace for global events
  6848. var recordTranslator = (0, _recordTranslator.getTranslator)(instance);
  6849. dataSource = new _dataSource2.default(instance);
  6850. if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
  6851. this.rootElement.id = this.guid; // if root element does not have an id, assign a random id
  6852. }
  6853. priv = {
  6854. cellSettings: [],
  6855. columnSettings: [],
  6856. columnsSettingConflicts: ['data', 'width'],
  6857. settings: new GridSettings(), // current settings instance
  6858. selRange: null, // exposed by public method `getSelectedRange`
  6859. isPopulated: null,
  6860. scrollable: null,
  6861. firstRun: true
  6862. };
  6863. grid = {
  6864. /**
  6865. * Inserts or removes rows and columns
  6866. *
  6867. * @memberof Core#
  6868. * @function alter
  6869. * @private
  6870. * @param {String} action Possible values: "insert_row", "insert_col", "remove_row", "remove_col"
  6871. * @param {Number} index
  6872. * @param {Number} amount
  6873. * @param {String} [source] Optional. Source of hook runner.
  6874. * @param {Boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows.
  6875. */
  6876. alter: function alter(action, index, amount, source, keepEmptyRows) {
  6877. var delta;
  6878. amount = amount || 1;
  6879. function spliceWith(data, index, count, toInject) {
  6880. var valueFactory = function valueFactory() {
  6881. var result = void 0;
  6882. if (toInject === 'array') {
  6883. result = [];
  6884. } else if (toInject === 'object') {
  6885. result = {};
  6886. }
  6887. return result;
  6888. };
  6889. var spliceArgs = (0, _array.arrayMap)(new Array(count), function () {
  6890. return valueFactory();
  6891. });
  6892. spliceArgs.unshift(index, 0);
  6893. data.splice.apply(data, _toConsumableArray(spliceArgs));
  6894. }
  6895. /* eslint-disable no-case-declarations */
  6896. switch (action) {
  6897. case 'insert_row':
  6898. var numberOfSourceRows = instance.countSourceRows();
  6899. if (instance.getSettings().maxRows === numberOfSourceRows) {
  6900. return;
  6901. }
  6902. index = (0, _mixed.isDefined)(index) ? index : numberOfSourceRows;
  6903. delta = datamap.createRow(index, amount, source);
  6904. spliceWith(priv.cellSettings, index, amount, 'array');
  6905. if (delta) {
  6906. if (selection.isSelected() && priv.selRange.from.row >= index) {
  6907. priv.selRange.from.row += delta;
  6908. selection.transformEnd(delta, 0); // will call render() internally
  6909. } else {
  6910. selection.refreshBorders(); // it will call render and prepare methods
  6911. }
  6912. }
  6913. break;
  6914. case 'insert_col':
  6915. delta = datamap.createCol(index, amount, source);
  6916. for (var row = 0, len = instance.countSourceRows(); row < len; row++) {
  6917. if (priv.cellSettings[row]) {
  6918. spliceWith(priv.cellSettings[row], index, amount);
  6919. }
  6920. }
  6921. if (delta) {
  6922. if (Array.isArray(instance.getSettings().colHeaders)) {
  6923. var spliceArray = [index, 0];
  6924. spliceArray.length += delta; // inserts empty (undefined) elements at the end of an array
  6925. Array.prototype.splice.apply(instance.getSettings().colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
  6926. }
  6927. if (selection.isSelected() && priv.selRange.from.col >= index) {
  6928. priv.selRange.from.col += delta;
  6929. selection.transformEnd(0, delta); // will call render() internally
  6930. } else {
  6931. selection.refreshBorders(); // it will call render and prepare methods
  6932. }
  6933. }
  6934. break;
  6935. case 'remove_row':
  6936. datamap.removeRow(index, amount, source);
  6937. priv.cellSettings.splice(index, amount);
  6938. var totalRows = instance.countRows();
  6939. var fixedRowsTop = instance.getSettings().fixedRowsTop;
  6940. if (fixedRowsTop >= index + 1) {
  6941. instance.getSettings().fixedRowsTop -= Math.min(amount, fixedRowsTop - index);
  6942. }
  6943. var fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  6944. if (fixedRowsBottom && index >= totalRows - fixedRowsBottom) {
  6945. instance.getSettings().fixedRowsBottom -= Math.min(amount, fixedRowsBottom);
  6946. }
  6947. grid.adjustRowsAndCols();
  6948. selection.refreshBorders(); // it will call render and prepare methods
  6949. break;
  6950. case 'remove_col':
  6951. var visualColumnIndex = recordTranslator.toPhysicalColumn(index);
  6952. datamap.removeCol(index, amount, source);
  6953. for (var _row = 0, _len = instance.countSourceRows(); _row < _len; _row++) {
  6954. if (priv.cellSettings[_row]) {
  6955. // if row hasn't been rendered it wouldn't have cellSettings
  6956. priv.cellSettings[_row].splice(visualColumnIndex, amount);
  6957. }
  6958. }
  6959. var fixedColumnsLeft = instance.getSettings().fixedColumnsLeft;
  6960. if (fixedColumnsLeft >= index + 1) {
  6961. instance.getSettings().fixedColumnsLeft -= Math.min(amount, fixedColumnsLeft - index);
  6962. }
  6963. if (Array.isArray(instance.getSettings().colHeaders)) {
  6964. if (typeof visualColumnIndex === 'undefined') {
  6965. visualColumnIndex = -1;
  6966. }
  6967. instance.getSettings().colHeaders.splice(visualColumnIndex, amount);
  6968. }
  6969. grid.adjustRowsAndCols();
  6970. selection.refreshBorders(); // it will call render and prepare methods
  6971. break;
  6972. default:
  6973. throw new Error('There is no such action "' + action + '"');
  6974. }
  6975. if (!keepEmptyRows) {
  6976. grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
  6977. }
  6978. },
  6979. /**
  6980. * Makes sure there are empty rows at the bottom of the table
  6981. */
  6982. adjustRowsAndCols: function adjustRowsAndCols() {
  6983. if (priv.settings.minRows) {
  6984. // should I add empty rows to data source to meet minRows?
  6985. var rows = instance.countRows();
  6986. if (rows < priv.settings.minRows) {
  6987. for (var r = 0, minRows = priv.settings.minRows; r < minRows - rows; r++) {
  6988. datamap.createRow(instance.countRows(), 1, 'auto');
  6989. }
  6990. }
  6991. }
  6992. if (priv.settings.minSpareRows) {
  6993. var emptyRows = instance.countEmptyRows(true);
  6994. // should I add empty rows to meet minSpareRows?
  6995. if (emptyRows < priv.settings.minSpareRows) {
  6996. for (; emptyRows < priv.settings.minSpareRows && instance.countSourceRows() < priv.settings.maxRows; emptyRows++) {
  6997. datamap.createRow(instance.countRows(), 1, 'auto');
  6998. }
  6999. }
  7000. }
  7001. {
  7002. var emptyCols = void 0;
  7003. // count currently empty cols
  7004. if (priv.settings.minCols || priv.settings.minSpareCols) {
  7005. emptyCols = instance.countEmptyCols(true);
  7006. }
  7007. // should I add empty cols to meet minCols?
  7008. if (priv.settings.minCols && !priv.settings.columns && instance.countCols() < priv.settings.minCols) {
  7009. for (; instance.countCols() < priv.settings.minCols; emptyCols++) {
  7010. datamap.createCol(instance.countCols(), 1, 'auto');
  7011. }
  7012. }
  7013. // should I add empty cols to meet minSpareCols?
  7014. if (priv.settings.minSpareCols && !priv.settings.columns && instance.dataType === 'array' && emptyCols < priv.settings.minSpareCols) {
  7015. for (; emptyCols < priv.settings.minSpareCols && instance.countCols() < priv.settings.maxCols; emptyCols++) {
  7016. datamap.createCol(instance.countCols(), 1, 'auto');
  7017. }
  7018. }
  7019. }
  7020. var rowCount = instance.countRows();
  7021. var colCount = instance.countCols();
  7022. if (rowCount === 0 || colCount === 0) {
  7023. selection.deselect();
  7024. }
  7025. if (selection.isSelected()) {
  7026. var selectionChanged = false;
  7027. var fromRow = priv.selRange.from.row;
  7028. var fromCol = priv.selRange.from.col;
  7029. var toRow = priv.selRange.to.row;
  7030. var toCol = priv.selRange.to.col;
  7031. // if selection is outside, move selection to last row
  7032. if (fromRow > rowCount - 1) {
  7033. fromRow = rowCount - 1;
  7034. selectionChanged = true;
  7035. if (toRow > fromRow) {
  7036. toRow = fromRow;
  7037. }
  7038. } else if (toRow > rowCount - 1) {
  7039. toRow = rowCount - 1;
  7040. selectionChanged = true;
  7041. if (fromRow > toRow) {
  7042. fromRow = toRow;
  7043. }
  7044. }
  7045. // if selection is outside, move selection to last row
  7046. if (fromCol > colCount - 1) {
  7047. fromCol = colCount - 1;
  7048. selectionChanged = true;
  7049. if (toCol > fromCol) {
  7050. toCol = fromCol;
  7051. }
  7052. } else if (toCol > colCount - 1) {
  7053. toCol = colCount - 1;
  7054. selectionChanged = true;
  7055. if (fromCol > toCol) {
  7056. fromCol = toCol;
  7057. }
  7058. }
  7059. if (selectionChanged) {
  7060. instance.selectCell(fromRow, fromCol, toRow, toCol);
  7061. }
  7062. }
  7063. if (instance.view) {
  7064. instance.view.wt.wtOverlays.adjustElementsSize();
  7065. }
  7066. },
  7067. /**
  7068. * Populate the data from the provided 2d array from the given cell coordinates.
  7069. *
  7070. * @private
  7071. * @param {Object} start Start selection position. Visual indexes.
  7072. * @param {Array} input 2d data array.
  7073. * @param {Object} [end] End selection position (only for drag-down mode). Visual indexes.
  7074. * @param {String} [source="populateFromArray"] Source information string.
  7075. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  7076. * @param {String} direction (left|right|up|down) String specifying the direction.
  7077. * @param {Array} deltas The deltas array. A difference between values of adjacent cells.
  7078. * Useful **only** when the type of handled cells is `numeric`.
  7079. * @returns {Object|undefined} ending td in pasted area (only if any cell was changed).
  7080. */
  7081. populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) {
  7082. // TODO: either remove or implement the `direction` argument. Currently it's not working at all.
  7083. var r,
  7084. rlen,
  7085. c,
  7086. clen,
  7087. setData = [],
  7088. current = {};
  7089. rlen = input.length;
  7090. if (rlen === 0) {
  7091. return false;
  7092. }
  7093. var repeatCol,
  7094. repeatRow,
  7095. cmax,
  7096. rmax,
  7097. baseEnd = {
  7098. row: end === null ? null : end.row,
  7099. col: end === null ? null : end.col
  7100. };
  7101. /* eslint-disable no-case-declarations */
  7102. // insert data with specified pasteMode method
  7103. switch (method) {
  7104. case 'shift_down':
  7105. repeatCol = end ? end.col - start.col + 1 : 0;
  7106. repeatRow = end ? end.row - start.row + 1 : 0;
  7107. input = (0, _data.translateRowsToColumns)(input);
  7108. for (c = 0, clen = input.length, cmax = Math.max(clen, repeatCol); c < cmax; c++) {
  7109. if (c < clen) {
  7110. var _instance;
  7111. for (r = 0, rlen = input[c].length; r < repeatRow - rlen; r++) {
  7112. input[c].push(input[c][r % rlen]);
  7113. }
  7114. input[c].unshift(start.col + c, start.row, 0);
  7115. (_instance = instance).spliceCol.apply(_instance, _toConsumableArray(input[c]));
  7116. } else {
  7117. var _instance2;
  7118. input[c % clen][0] = start.col + c;
  7119. (_instance2 = instance).spliceCol.apply(_instance2, _toConsumableArray(input[c % clen]));
  7120. }
  7121. }
  7122. break;
  7123. case 'shift_right':
  7124. repeatCol = end ? end.col - start.col + 1 : 0;
  7125. repeatRow = end ? end.row - start.row + 1 : 0;
  7126. for (r = 0, rlen = input.length, rmax = Math.max(rlen, repeatRow); r < rmax; r++) {
  7127. if (r < rlen) {
  7128. var _instance3;
  7129. for (c = 0, clen = input[r].length; c < repeatCol - clen; c++) {
  7130. input[r].push(input[r][c % clen]);
  7131. }
  7132. input[r].unshift(start.row + r, start.col, 0);
  7133. (_instance3 = instance).spliceRow.apply(_instance3, _toConsumableArray(input[r]));
  7134. } else {
  7135. var _instance4;
  7136. input[r % rlen][0] = start.row + r;
  7137. (_instance4 = instance).spliceRow.apply(_instance4, _toConsumableArray(input[r % rlen]));
  7138. }
  7139. }
  7140. break;
  7141. case 'overwrite':
  7142. default:
  7143. // overwrite and other not specified options
  7144. current.row = start.row;
  7145. current.col = start.col;
  7146. var selected = { // selected range
  7147. row: end && start ? end.row - start.row + 1 : 1,
  7148. col: end && start ? end.col - start.col + 1 : 1
  7149. };
  7150. var skippedRow = 0;
  7151. var skippedColumn = 0;
  7152. var pushData = true;
  7153. var cellMeta = void 0;
  7154. var getInputValue = function getInputValue(row) {
  7155. var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  7156. var rowValue = input[row % input.length];
  7157. if (col !== null) {
  7158. return rowValue[col % rowValue.length];
  7159. }
  7160. return rowValue;
  7161. };
  7162. var rowInputLength = input.length;
  7163. var rowSelectionLength = end ? end.row - start.row + 1 : 0;
  7164. if (end) {
  7165. rlen = rowSelectionLength;
  7166. } else {
  7167. rlen = Math.max(rowInputLength, rowSelectionLength);
  7168. }
  7169. for (r = 0; r < rlen; r++) {
  7170. if (end && current.row > end.row && rowSelectionLength > rowInputLength || !priv.settings.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= priv.settings.maxRows) {
  7171. break;
  7172. }
  7173. var visualRow = r - skippedRow;
  7174. var colInputLength = getInputValue(visualRow).length;
  7175. var colSelectionLength = end ? end.col - start.col + 1 : 0;
  7176. if (end) {
  7177. clen = colSelectionLength;
  7178. } else {
  7179. clen = Math.max(colInputLength, colSelectionLength);
  7180. }
  7181. current.col = start.col;
  7182. cellMeta = instance.getCellMeta(current.row, current.col);
  7183. if ((source === 'CopyPaste.paste' || source === 'Autofill.autofill') && cellMeta.skipRowOnPaste) {
  7184. skippedRow++;
  7185. current.row++;
  7186. rlen++;
  7187. /* eslint-disable no-continue */
  7188. continue;
  7189. }
  7190. skippedColumn = 0;
  7191. for (c = 0; c < clen; c++) {
  7192. if (end && current.col > end.col && colSelectionLength > colInputLength || !priv.settings.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= priv.settings.maxCols) {
  7193. break;
  7194. }
  7195. cellMeta = instance.getCellMeta(current.row, current.col);
  7196. if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) {
  7197. skippedColumn++;
  7198. current.col++;
  7199. clen++;
  7200. continue;
  7201. }
  7202. if (cellMeta.readOnly) {
  7203. current.col++;
  7204. /* eslint-disable no-continue */
  7205. continue;
  7206. }
  7207. var visualColumn = c - skippedColumn;
  7208. var value = getInputValue(visualRow, visualColumn);
  7209. var orgValue = instance.getDataAtCell(current.row, current.col);
  7210. var index = {
  7211. row: visualRow,
  7212. col: visualColumn
  7213. };
  7214. if (source === 'Autofill.fill') {
  7215. var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
  7216. if (result) {
  7217. value = (0, _mixed.isUndefined)(result.value) ? value : result.value;
  7218. }
  7219. }
  7220. if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  7221. if (orgValue === null || (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) !== 'object') {
  7222. pushData = false;
  7223. } else {
  7224. var orgValueSchema = (0, _object.duckSchema)(orgValue[0] || orgValue);
  7225. var valueSchema = (0, _object.duckSchema)(value[0] || value);
  7226. /* eslint-disable max-depth */
  7227. if ((0, _object.isObjectEquals)(orgValueSchema, valueSchema)) {
  7228. value = (0, _object.deepClone)(value);
  7229. } else {
  7230. pushData = false;
  7231. }
  7232. }
  7233. } else if (orgValue !== null && (typeof orgValue === 'undefined' ? 'undefined' : _typeof(orgValue)) === 'object') {
  7234. pushData = false;
  7235. }
  7236. if (pushData) {
  7237. setData.push([current.row, current.col, value]);
  7238. }
  7239. pushData = true;
  7240. current.col++;
  7241. }
  7242. current.row++;
  7243. }
  7244. instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
  7245. break;
  7246. }
  7247. }
  7248. };
  7249. /* eslint-disable no-multi-assign */
  7250. this.selection = selection = { // this public assignment is only temporary
  7251. inProgress: false,
  7252. selectedHeader: {
  7253. cols: false,
  7254. rows: false
  7255. },
  7256. /**
  7257. * @param {Boolean} [rows=false]
  7258. * @param {Boolean} [cols=false]
  7259. * @param {Boolean} [corner=false]
  7260. */
  7261. setSelectedHeaders: function setSelectedHeaders() {
  7262. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  7263. var cols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  7264. var corner = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  7265. instance.selection.selectedHeader.rows = rows;
  7266. instance.selection.selectedHeader.cols = cols;
  7267. instance.selection.selectedHeader.corner = corner;
  7268. },
  7269. /**
  7270. * Sets inProgress to `true`. This enables onSelectionEnd and onSelectionEndByProp to function as desired.
  7271. */
  7272. begin: function begin() {
  7273. instance.selection.inProgress = true;
  7274. },
  7275. /**
  7276. * Sets inProgress to `false`. Triggers onSelectionEnd and onSelectionEndByProp.
  7277. */
  7278. finish: function finish() {
  7279. var sel = instance.getSelected();
  7280. instance.runHooks('afterSelectionEnd', sel[0], sel[1], sel[2], sel[3]);
  7281. instance.runHooks('afterSelectionEndByProp', sel[0], instance.colToProp(sel[1]), sel[2], instance.colToProp(sel[3]));
  7282. instance.selection.inProgress = false;
  7283. },
  7284. /**
  7285. * @returns {Boolean}
  7286. */
  7287. isInProgress: function isInProgress() {
  7288. return instance.selection.inProgress;
  7289. },
  7290. /**
  7291. * Starts selection range on given td object.
  7292. *
  7293. * @param {CellCoords} coords Visual coords.
  7294. * @param keepEditorOpened
  7295. */
  7296. setRangeStart: function setRangeStart(coords, keepEditorOpened) {
  7297. instance.runHooks('beforeSetRangeStart', coords);
  7298. priv.selRange = new _src.CellRange(coords, coords, coords);
  7299. selection.setRangeEnd(coords, null, keepEditorOpened);
  7300. },
  7301. /**
  7302. * Starts selection range on given td object.
  7303. *
  7304. * @param {CellCoords} coords Visual coords.
  7305. * @param keepEditorOpened
  7306. */
  7307. setRangeStartOnly: function setRangeStartOnly(coords) {
  7308. instance.runHooks('beforeSetRangeStartOnly', coords);
  7309. priv.selRange = new _src.CellRange(coords, coords, coords);
  7310. },
  7311. /**
  7312. * Ends selection range on given td object.
  7313. *
  7314. * @param {CellCoords} coords Visual coords.
  7315. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to range end
  7316. * @param {Boolean} [keepEditorOpened] If `true`, cell editor will be still opened after changing selection range
  7317. */
  7318. setRangeEnd: function setRangeEnd(coords, scrollToCell, keepEditorOpened) {
  7319. if (priv.selRange === null) {
  7320. return;
  7321. }
  7322. var disableVisualSelection,
  7323. isHeaderSelected = false,
  7324. areCoordsPositive = true;
  7325. var firstVisibleRow = instance.view.wt.wtTable.getFirstVisibleRow();
  7326. var firstVisibleColumn = instance.view.wt.wtTable.getFirstVisibleColumn();
  7327. var newRangeCoords = {
  7328. row: null,
  7329. col: null
  7330. };
  7331. // trigger handlers
  7332. instance.runHooks('beforeSetRangeEnd', coords);
  7333. instance.selection.begin();
  7334. newRangeCoords.row = coords.row < 0 ? firstVisibleRow : coords.row;
  7335. newRangeCoords.col = coords.col < 0 ? firstVisibleColumn : coords.col;
  7336. priv.selRange.to = new _src.CellCoords(newRangeCoords.row, newRangeCoords.col);
  7337. if (!priv.settings.multiSelect) {
  7338. priv.selRange.from = coords;
  7339. }
  7340. // set up current selection
  7341. instance.view.wt.selections.current.clear();
  7342. disableVisualSelection = instance.getCellMeta(priv.selRange.highlight.row, priv.selRange.highlight.col).disableVisualSelection;
  7343. if (typeof disableVisualSelection === 'string') {
  7344. disableVisualSelection = [disableVisualSelection];
  7345. }
  7346. if (disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('current') === -1) {
  7347. instance.view.wt.selections.current.add(priv.selRange.highlight);
  7348. }
  7349. // set up area selection
  7350. instance.view.wt.selections.area.clear();
  7351. if ((disableVisualSelection === false || Array.isArray(disableVisualSelection) && disableVisualSelection.indexOf('area') === -1) && selection.isMultiple()) {
  7352. instance.view.wt.selections.area.add(priv.selRange.from);
  7353. instance.view.wt.selections.area.add(priv.selRange.to);
  7354. }
  7355. // set up highlight
  7356. if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  7357. instance.view.wt.selections.highlight.clear();
  7358. instance.view.wt.selections.highlight.add(priv.selRange.from);
  7359. instance.view.wt.selections.highlight.add(priv.selRange.to);
  7360. }
  7361. var preventScrolling = (0, _object.createObjectPropListener)('value');
  7362. // trigger handlers
  7363. instance.runHooks('afterSelection', priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col, preventScrolling);
  7364. instance.runHooks('afterSelectionByProp', priv.selRange.from.row, datamap.colToProp(priv.selRange.from.col), priv.selRange.to.row, datamap.colToProp(priv.selRange.to.col), preventScrolling);
  7365. 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) {
  7366. isHeaderSelected = true;
  7367. }
  7368. if (coords.row < 0 || coords.col < 0) {
  7369. areCoordsPositive = false;
  7370. }
  7371. if (preventScrolling.isTouched()) {
  7372. scrollToCell = !preventScrolling.value;
  7373. }
  7374. if (scrollToCell !== false && !isHeaderSelected && areCoordsPositive) {
  7375. if (priv.selRange.from && !selection.isMultiple()) {
  7376. instance.view.scrollViewport(priv.selRange.from);
  7377. } else {
  7378. instance.view.scrollViewport(coords);
  7379. }
  7380. }
  7381. if (selection.selectedHeader.rows && selection.selectedHeader.cols) {
  7382. (0, _element.addClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  7383. } else if (selection.selectedHeader.rows) {
  7384. (0, _element.removeClass)(instance.rootElement, 'ht__selection--columns');
  7385. (0, _element.addClass)(instance.rootElement, 'ht__selection--rows');
  7386. } else if (selection.selectedHeader.cols) {
  7387. (0, _element.removeClass)(instance.rootElement, 'ht__selection--rows');
  7388. (0, _element.addClass)(instance.rootElement, 'ht__selection--columns');
  7389. } else {
  7390. (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  7391. }
  7392. selection.refreshBorders(null, keepEditorOpened);
  7393. },
  7394. /**
  7395. * Destroys editor, redraws borders around cells, prepares editor.
  7396. *
  7397. * @param {Boolean} [revertOriginal]
  7398. * @param {Boolean} [keepEditor]
  7399. */
  7400. refreshBorders: function refreshBorders(revertOriginal, keepEditor) {
  7401. if (!keepEditor) {
  7402. editorManager.destroyEditor(revertOriginal);
  7403. }
  7404. instance.view.render();
  7405. if (selection.isSelected() && !keepEditor) {
  7406. editorManager.prepareEditor();
  7407. }
  7408. },
  7409. /**
  7410. * Returns information if we have a multiselection.
  7411. *
  7412. * @returns {Boolean}
  7413. */
  7414. isMultiple: function isMultiple() {
  7415. var isMultiple = !(priv.selRange.to.col === priv.selRange.from.col && priv.selRange.to.row === priv.selRange.from.row),
  7416. modifier = instance.runHooks('afterIsMultipleSelection', isMultiple);
  7417. if (isMultiple) {
  7418. return modifier;
  7419. }
  7420. },
  7421. /**
  7422. * Selects cell relative to current cell (if possible).
  7423. */
  7424. transformStart: function transformStart(rowDelta, colDelta, force, keepEditorOpened) {
  7425. var delta = new _src.CellCoords(rowDelta, colDelta),
  7426. rowTransformDir = 0,
  7427. colTransformDir = 0,
  7428. totalRows,
  7429. totalCols,
  7430. coords,
  7431. fixedRowsBottom;
  7432. instance.runHooks('modifyTransformStart', delta);
  7433. totalRows = instance.countRows();
  7434. totalCols = instance.countCols();
  7435. fixedRowsBottom = instance.getSettings().fixedRowsBottom;
  7436. if (priv.selRange.highlight.row + rowDelta > totalRows - 1) {
  7437. if (force && priv.settings.minSpareRows > 0 && !(fixedRowsBottom && priv.selRange.highlight.row >= totalRows - fixedRowsBottom - 1)) {
  7438. instance.alter('insert_row', totalRows);
  7439. totalRows = instance.countRows();
  7440. } else if (priv.settings.autoWrapCol) {
  7441. delta.row = 1 - totalRows;
  7442. delta.col = priv.selRange.highlight.col + delta.col == totalCols - 1 ? 1 - totalCols : 1;
  7443. }
  7444. } else if (priv.settings.autoWrapCol && priv.selRange.highlight.row + delta.row < 0 && priv.selRange.highlight.col + delta.col >= 0) {
  7445. delta.row = totalRows - 1;
  7446. delta.col = priv.selRange.highlight.col + delta.col == 0 ? totalCols - 1 : -1;
  7447. }
  7448. if (priv.selRange.highlight.col + delta.col > totalCols - 1) {
  7449. if (force && priv.settings.minSpareCols > 0) {
  7450. instance.alter('insert_col', totalCols);
  7451. totalCols = instance.countCols();
  7452. } else if (priv.settings.autoWrapRow) {
  7453. delta.row = priv.selRange.highlight.row + delta.row == totalRows - 1 ? 1 - totalRows : 1;
  7454. delta.col = 1 - totalCols;
  7455. }
  7456. } else if (priv.settings.autoWrapRow && priv.selRange.highlight.col + delta.col < 0 && priv.selRange.highlight.row + delta.row >= 0) {
  7457. delta.row = priv.selRange.highlight.row + delta.row == 0 ? totalRows - 1 : -1;
  7458. delta.col = totalCols - 1;
  7459. }
  7460. coords = new _src.CellCoords(priv.selRange.highlight.row + delta.row, priv.selRange.highlight.col + delta.col);
  7461. if (coords.row < 0) {
  7462. rowTransformDir = -1;
  7463. coords.row = 0;
  7464. } else if (coords.row > 0 && coords.row >= totalRows) {
  7465. rowTransformDir = 1;
  7466. coords.row = totalRows - 1;
  7467. }
  7468. if (coords.col < 0) {
  7469. colTransformDir = -1;
  7470. coords.col = 0;
  7471. } else if (coords.col > 0 && coords.col >= totalCols) {
  7472. colTransformDir = 1;
  7473. coords.col = totalCols - 1;
  7474. }
  7475. instance.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
  7476. selection.setRangeStart(coords, keepEditorOpened);
  7477. },
  7478. /**
  7479. * Sets selection end cell relative to current selection end cell (if possible).
  7480. */
  7481. transformEnd: function transformEnd(rowDelta, colDelta) {
  7482. var delta = new _src.CellCoords(rowDelta, colDelta),
  7483. rowTransformDir = 0,
  7484. colTransformDir = 0,
  7485. totalRows,
  7486. totalCols,
  7487. coords;
  7488. instance.runHooks('modifyTransformEnd', delta);
  7489. totalRows = instance.countRows();
  7490. totalCols = instance.countCols();
  7491. coords = new _src.CellCoords(priv.selRange.to.row + delta.row, priv.selRange.to.col + delta.col);
  7492. if (coords.row < 0) {
  7493. rowTransformDir = -1;
  7494. coords.row = 0;
  7495. } else if (coords.row > 0 && coords.row >= totalRows) {
  7496. rowTransformDir = 1;
  7497. coords.row = totalRows - 1;
  7498. }
  7499. if (coords.col < 0) {
  7500. colTransformDir = -1;
  7501. coords.col = 0;
  7502. } else if (coords.col > 0 && coords.col >= totalCols) {
  7503. colTransformDir = 1;
  7504. coords.col = totalCols - 1;
  7505. }
  7506. instance.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
  7507. selection.setRangeEnd(coords, true);
  7508. },
  7509. /**
  7510. * Returns `true` if currently there is a selection on screen, `false` otherwise.
  7511. *
  7512. * @returns {Boolean}
  7513. */
  7514. isSelected: function isSelected() {
  7515. return priv.selRange !== null;
  7516. },
  7517. /**
  7518. * Returns `true` if coords is within current selection coords.
  7519. *
  7520. * @param {CellCoords} coords
  7521. * @returns {Boolean}
  7522. */
  7523. inInSelection: function inInSelection(coords) {
  7524. if (!selection.isSelected()) {
  7525. return false;
  7526. }
  7527. return priv.selRange.includes(coords);
  7528. },
  7529. /**
  7530. * Deselects all selected cells
  7531. */
  7532. deselect: function deselect() {
  7533. if (!selection.isSelected()) {
  7534. return;
  7535. }
  7536. instance.selection.inProgress = false; // needed by HT inception
  7537. priv.selRange = null;
  7538. instance.view.wt.selections.current.clear();
  7539. instance.view.wt.selections.area.clear();
  7540. if (priv.settings.currentHeaderClassName || priv.settings.currentRowClassName || priv.settings.currentColClassName) {
  7541. instance.view.wt.selections.highlight.clear();
  7542. }
  7543. editorManager.destroyEditor();
  7544. selection.refreshBorders();
  7545. (0, _element.removeClass)(instance.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
  7546. instance.runHooks('afterDeselect');
  7547. },
  7548. /**
  7549. * Select all cells
  7550. */
  7551. selectAll: function selectAll() {
  7552. if (!priv.settings.multiSelect) {
  7553. return;
  7554. }
  7555. selection.setSelectedHeaders(true, true, true);
  7556. selection.setRangeStart(new _src.CellCoords(0, 0));
  7557. selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, instance.countCols() - 1), false);
  7558. },
  7559. /**
  7560. * Deletes data from selected cells
  7561. */
  7562. empty: function empty() {
  7563. if (!selection.isSelected()) {
  7564. return;
  7565. }
  7566. var topLeft = priv.selRange.getTopLeftCorner();
  7567. var bottomRight = priv.selRange.getBottomRightCorner();
  7568. var r,
  7569. c,
  7570. changes = [];
  7571. for (r = topLeft.row; r <= bottomRight.row; r++) {
  7572. for (c = topLeft.col; c <= bottomRight.col; c++) {
  7573. if (!instance.getCellMeta(r, c).readOnly) {
  7574. changes.push([r, c, '']);
  7575. }
  7576. }
  7577. }
  7578. instance.setDataAtCell(changes);
  7579. }
  7580. };
  7581. this.init = function () {
  7582. dataSource.setData(priv.settings.data);
  7583. instance.runHooks('beforeInit');
  7584. if ((0, _browser.isMobileBrowser)()) {
  7585. (0, _element.addClass)(instance.rootElement, 'mobile');
  7586. }
  7587. this.updateSettings(priv.settings, true);
  7588. this.view = new _tableView2.default(this);
  7589. editorManager = new _editorManager2.default(instance, priv, selection, datamap);
  7590. this.forceFullRender = true; // used when data was changed
  7591. instance.runHooks('init');
  7592. this.view.render();
  7593. if (_typeof(priv.firstRun) === 'object') {
  7594. instance.runHooks('afterChange', priv.firstRun[0], priv.firstRun[1]);
  7595. priv.firstRun = false;
  7596. }
  7597. instance.runHooks('afterInit');
  7598. };
  7599. function ValidatorsQueue() {
  7600. // moved this one level up so it can be used in any function here. Probably this should be moved to a separate file
  7601. var resolved = false;
  7602. return {
  7603. validatorsInQueue: 0,
  7604. valid: true,
  7605. addValidatorToQueue: function addValidatorToQueue() {
  7606. this.validatorsInQueue++;
  7607. resolved = false;
  7608. },
  7609. removeValidatorFormQueue: function removeValidatorFormQueue() {
  7610. this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
  7611. this.checkIfQueueIsEmpty();
  7612. },
  7613. onQueueEmpty: function onQueueEmpty(valid) {},
  7614. checkIfQueueIsEmpty: function checkIfQueueIsEmpty() {
  7615. if (this.validatorsInQueue == 0 && resolved == false) {
  7616. resolved = true;
  7617. this.onQueueEmpty(this.valid);
  7618. }
  7619. }
  7620. };
  7621. }
  7622. function validateChanges(changes, source, callback) {
  7623. var waitingForValidator = new ValidatorsQueue();
  7624. waitingForValidator.onQueueEmpty = resolve;
  7625. for (var i = changes.length - 1; i >= 0; i--) {
  7626. if (changes[i] === null) {
  7627. changes.splice(i, 1);
  7628. } else {
  7629. var row = changes[i][0];
  7630. var col = datamap.propToCol(changes[i][1]);
  7631. var cellProperties = instance.getCellMeta(row, col);
  7632. if (cellProperties.type === 'numeric' && typeof changes[i][3] === 'string') {
  7633. if (changes[i][3].length > 0 && (/^-?[\d\s]*(\.|,)?\d*$/.test(changes[i][3]) || cellProperties.format)) {
  7634. var len = changes[i][3].length;
  7635. if ((0, _mixed.isUndefined)(cellProperties.language)) {
  7636. _numbro2.default.culture('en-US');
  7637. } else if (changes[i][3].indexOf('.') === len - 3 && changes[i][3].indexOf(',') === -1) {
  7638. // this input in format XXXX.XX is likely to come from paste. Let's parse it using international rules
  7639. _numbro2.default.culture('en-US');
  7640. } else {
  7641. _numbro2.default.culture(cellProperties.language);
  7642. }
  7643. var _numbro$cultureData = _numbro2.default.cultureData(_numbro2.default.culture()),
  7644. delimiters = _numbro$cultureData.delimiters;
  7645. // try to parse to float - https://github.com/foretagsplatsen/numbro/pull/183
  7646. if (_numbro2.default.validate(changes[i][3]) && !isNaN(changes[i][3])) {
  7647. changes[i][3] = parseFloat(changes[i][3]);
  7648. } else {
  7649. changes[i][3] = (0, _numbro2.default)().unformat(changes[i][3]) || changes[i][3];
  7650. }
  7651. }
  7652. }
  7653. /* eslint-disable no-loop-func */
  7654. if (instance.getCellValidator(cellProperties)) {
  7655. waitingForValidator.addValidatorToQueue();
  7656. instance.validateCell(changes[i][3], cellProperties, function (i, cellProperties) {
  7657. return function (result) {
  7658. if (typeof result !== 'boolean') {
  7659. throw new Error('Validation error: result is not boolean');
  7660. }
  7661. if (result === false && cellProperties.allowInvalid === false) {
  7662. changes.splice(i, 1); // cancel the change
  7663. cellProperties.valid = true; // we cancelled the change, so cell value is still valid
  7664. var cell = instance.getCell(cellProperties.row, cellProperties.col);
  7665. (0, _element.removeClass)(cell, instance.getSettings().invalidCellClassName);
  7666. --i;
  7667. }
  7668. waitingForValidator.removeValidatorFormQueue();
  7669. };
  7670. }(i, cellProperties), source);
  7671. }
  7672. }
  7673. }
  7674. waitingForValidator.checkIfQueueIsEmpty();
  7675. function resolve() {
  7676. var beforeChangeResult;
  7677. if (changes.length) {
  7678. beforeChangeResult = instance.runHooks('beforeChange', changes, source);
  7679. if ((0, _function.isFunction)(beforeChangeResult)) {
  7680. 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).');
  7681. } else if (beforeChangeResult === false) {
  7682. changes.splice(0, changes.length); // invalidate all changes (remove everything from array)
  7683. }
  7684. }
  7685. callback(); // called when async validators are resolved and beforeChange was not async
  7686. }
  7687. }
  7688. /**
  7689. * Internal function to apply changes. Called after validateChanges
  7690. *
  7691. * @private
  7692. * @param {Array} changes Array in form of [row, prop, oldValue, newValue]
  7693. * @param {String} source String that identifies how this change will be described in changes array (useful in onChange callback)
  7694. * @fires Hooks#beforeChangeRender
  7695. * @fires Hooks#afterChange
  7696. */
  7697. function applyChanges(changes, source) {
  7698. var i = changes.length - 1;
  7699. if (i < 0) {
  7700. return;
  7701. }
  7702. for (; i >= 0; i--) {
  7703. var skipThisChange = false;
  7704. if (changes[i] === null) {
  7705. changes.splice(i, 1);
  7706. /* eslint-disable no-continue */
  7707. continue;
  7708. }
  7709. if (changes[i][2] == null && changes[i][3] == null) {
  7710. /* eslint-disable no-continue */
  7711. continue;
  7712. }
  7713. if (priv.settings.allowInsertRow) {
  7714. while (changes[i][0] > instance.countRows() - 1) {
  7715. var numberOfCreatedRows = datamap.createRow(void 0, void 0, source);
  7716. if (numberOfCreatedRows === 0) {
  7717. skipThisChange = true;
  7718. break;
  7719. }
  7720. }
  7721. }
  7722. if (skipThisChange) {
  7723. /* eslint-disable no-continue */
  7724. continue;
  7725. }
  7726. if (instance.dataType === 'array' && (!priv.settings.columns || priv.settings.columns.length === 0) && priv.settings.allowInsertColumn) {
  7727. while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
  7728. datamap.createCol(void 0, void 0, source);
  7729. }
  7730. }
  7731. datamap.set(changes[i][0], changes[i][1], changes[i][3]);
  7732. }
  7733. instance.forceFullRender = true; // used when data was changed
  7734. grid.adjustRowsAndCols();
  7735. instance.runHooks('beforeChangeRender', changes, source);
  7736. selection.refreshBorders(null, true);
  7737. instance.view.wt.wtOverlays.adjustElementsSize();
  7738. instance.runHooks('afterChange', changes, source || 'edit');
  7739. var activeEditor = instance.getActiveEditor();
  7740. if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
  7741. activeEditor.refreshValue();
  7742. }
  7743. }
  7744. this.validateCell = function (value, cellProperties, callback, source) {
  7745. var validator = instance.getCellValidator(cellProperties);
  7746. function done(valid) {
  7747. var col = cellProperties.visualCol,
  7748. row = cellProperties.visualRow,
  7749. td = instance.getCell(row, col, true);
  7750. if (td && td.nodeName != 'TH') {
  7751. instance.view.wt.wtSettings.settings.cellRenderer(row, col, td);
  7752. }
  7753. callback(valid);
  7754. }
  7755. if ((0, _mixed.isRegExp)(validator)) {
  7756. validator = function (validator) {
  7757. return function (value, callback) {
  7758. callback(validator.test(value));
  7759. };
  7760. }(validator);
  7761. }
  7762. if ((0, _function.isFunction)(validator)) {
  7763. value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source);
  7764. // To provide consistent behaviour, validation should be always asynchronous
  7765. instance._registerTimeout(setTimeout(function () {
  7766. validator.call(cellProperties, value, function (valid) {
  7767. valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  7768. cellProperties.valid = valid;
  7769. done(valid);
  7770. instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
  7771. });
  7772. }, 0));
  7773. } else {
  7774. // resolve callback even if validator function was not found
  7775. instance._registerTimeout(setTimeout(function () {
  7776. cellProperties.valid = true;
  7777. done(cellProperties.valid);
  7778. }, 0));
  7779. }
  7780. };
  7781. function setDataInputToArray(row, propOrCol, value) {
  7782. if ((typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  7783. // is it an array of changes
  7784. return row;
  7785. }
  7786. return [[row, propOrCol, value]];
  7787. }
  7788. /**
  7789. * @description
  7790. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, col, value], ...]` as
  7791. * the only parameter. `col` is the index of a __visible__ column (note that if columns were reordered,
  7792. * the current visible order will be used). `source` is a flag for before/afterChange events. If you pass only array of
  7793. * changes then `source` could be set as second parameter.
  7794. *
  7795. * @memberof Core#
  7796. * @function setDataAtCell
  7797. * @param {Number|Array} row Visual row index or array of changes in format `[[row, col, value], ...]`.
  7798. * @param {Number} col Visual column index.
  7799. * @param {String} value New value.
  7800. * @param {String} [source] String that identifies how this change will be described in the changes array (useful in onAfterChange or onBeforeChange callback).
  7801. */
  7802. this.setDataAtCell = function (row, col, value, source) {
  7803. var input = setDataInputToArray(row, col, value),
  7804. i,
  7805. ilen,
  7806. changes = [],
  7807. prop;
  7808. for (i = 0, ilen = input.length; i < ilen; i++) {
  7809. if (_typeof(input[i]) !== 'object') {
  7810. throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
  7811. }
  7812. if (typeof input[i][1] !== 'number') {
  7813. throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`');
  7814. }
  7815. prop = datamap.colToProp(input[i][1]);
  7816. changes.push([input[i][0], prop, dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  7817. }
  7818. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  7819. source = col;
  7820. }
  7821. instance.runHooks('afterSetDataAtCell', changes, source);
  7822. validateChanges(changes, source, function () {
  7823. applyChanges(changes, source);
  7824. });
  7825. };
  7826. /**
  7827. * @description
  7828. * Set new value to a cell. To change many cells at once, pass an array of `changes` in format `[[row, prop, value], ...]` as
  7829. * the only parameter. `prop` is the name of the object property (e.g. `first.name`). `source` is a flag for before/afterChange events.
  7830. * If you pass only array of changes then `source` could be set as second parameter.
  7831. *
  7832. * @memberof Core#
  7833. * @function setDataAtRowProp
  7834. * @param {Number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`.
  7835. * @param {String} prop Property name or the source string.
  7836. * @param {String} value Value to be set.
  7837. * @param {String} [source] String that identifies how this change will be described in changes array (useful in onChange callback).
  7838. */
  7839. this.setDataAtRowProp = function (row, prop, value, source) {
  7840. var input = setDataInputToArray(row, prop, value),
  7841. i,
  7842. ilen,
  7843. changes = [];
  7844. for (i = 0, ilen = input.length; i < ilen; i++) {
  7845. changes.push([input[i][0], input[i][1], dataSource.getAtCell(recordTranslator.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
  7846. }
  7847. if (!source && (typeof row === 'undefined' ? 'undefined' : _typeof(row)) === 'object') {
  7848. source = prop;
  7849. }
  7850. instance.runHooks('afterSetDataAtRowProp', changes, source);
  7851. validateChanges(changes, source, function () {
  7852. applyChanges(changes, source);
  7853. });
  7854. };
  7855. /**
  7856. * Listen to the keyboard input on document body.
  7857. *
  7858. * @memberof Core#
  7859. * @function listen
  7860. * @since 0.11
  7861. */
  7862. this.listen = function () {
  7863. var invalidActiveElement = !document.activeElement || document.activeElement && document.activeElement.nodeName === void 0;
  7864. if (document.activeElement && document.activeElement !== document.body && !invalidActiveElement) {
  7865. document.activeElement.blur();
  7866. } else if (invalidActiveElement) {
  7867. // IE
  7868. document.body.focus();
  7869. }
  7870. activeGuid = instance.guid;
  7871. };
  7872. /**
  7873. * Stop listening to keyboard input on the document body.
  7874. *
  7875. * @memberof Core#
  7876. * @function unlisten
  7877. * @since 0.11
  7878. */
  7879. this.unlisten = function () {
  7880. if (this.isListening()) {
  7881. activeGuid = null;
  7882. }
  7883. };
  7884. /**
  7885. * Returns `true` if the current Handsontable instance is listening to keyboard input on document body.
  7886. *
  7887. * @memberof Core#
  7888. * @function isListening
  7889. * @since 0.11
  7890. * @returns {Boolean} `true` if the instance is listening, `false` otherwise.
  7891. */
  7892. this.isListening = function () {
  7893. return activeGuid === instance.guid;
  7894. };
  7895. /**
  7896. * Destroys the current editor, renders and selects the current cell.
  7897. *
  7898. * @memberof Core#
  7899. * @function destroyEditor
  7900. * @param {Boolean} [revertOriginal] If != `true`, edited data is saved. Otherwise the previous value is restored.
  7901. */
  7902. this.destroyEditor = function (revertOriginal) {
  7903. selection.refreshBorders(revertOriginal);
  7904. };
  7905. /**
  7906. * Populate cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`).
  7907. * Use `endRow`, `endCol` when you want to cut input when a certain row is reached.
  7908. * Optional `source` parameter (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange).
  7909. * Optional `populateMethod` parameter (default value "overwrite", possible values "shift_down" and "shift_right")
  7910. * has the same effect as pasteMode option {@link Options#pasteMode}
  7911. *
  7912. * @memberof Core#
  7913. * @function populateFromArray
  7914. * @since 0.9.0
  7915. * @param {Number} row Start visual row index.
  7916. * @param {Number} col Start visual column index.
  7917. * @param {Array} input 2d array
  7918. * @param {Number} [endRow] End visual row index (use when you want to cut input when certain row is reached).
  7919. * @param {Number} [endCol] End visual column index (use when you want to cut input when certain column is reached).
  7920. * @param {String} [source="populateFromArray"] Source string.
  7921. * @param {String} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
  7922. * @param {String} direction Populate direction. (left|right|up|down)
  7923. * @param {Array} deltas Deltas array.
  7924. * @returns {Object|undefined} The ending TD element in pasted area (only if any cells were changed).
  7925. */
  7926. this.populateFromArray = function (row, col, input, endRow, endCol, source, method, direction, deltas) {
  7927. var c;
  7928. if (!((typeof input === 'undefined' ? 'undefined' : _typeof(input)) === 'object' && _typeof(input[0]) === 'object')) {
  7929. 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
  7930. }
  7931. c = typeof endRow === 'number' ? new _src.CellCoords(endRow, endCol) : null;
  7932. return grid.populateFromArray(new _src.CellCoords(row, col), input, c, source, method, direction, deltas);
  7933. };
  7934. /**
  7935. * Adds/removes data from the column. This function is modelled after Array.splice.
  7936. * Parameter `col` is the index of the column in which do you want to do splice.
  7937. * Parameter `index` is the row index at which to start changing the array.
  7938. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of the old array elements to remove.
  7939. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  7940. * If you don't specify any elements, spliceCol simply removes elements from the array.
  7941. * {@link DataMap#spliceCol}
  7942. *
  7943. * @memberof Core#
  7944. * @function spliceCol
  7945. * @since 0.9-beta2
  7946. * @param {Number} col Index of the column in which do you want to do splice.
  7947. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  7948. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  7949. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  7950. */
  7951. this.spliceCol = function (col, index, amount /* , elements... */) {
  7952. var _datamap;
  7953. return (_datamap = datamap).spliceCol.apply(_datamap, arguments);
  7954. };
  7955. /**
  7956. * Adds/removes data from the row. This function works is modelled after Array.splice.
  7957. * Parameter `row` is the index of row in which do you want to do splice.
  7958. * Parameter `index` is the column index at which to start changing the array.
  7959. * If negative, will begin that many elements from the end. Parameter `amount`, is the number of old array elements to remove.
  7960. * If the amount is 0, no elements are removed. Fourth and further parameters are the `elements` to add to the array.
  7961. * If you don't specify any elements, spliceCol simply removes elements from the array.
  7962. * {@link DataMap#spliceRow}
  7963. *
  7964. * @memberof Core#
  7965. * @function spliceRow
  7966. * @since 0.11
  7967. * @param {Number} row Index of column in which do you want to do splice.
  7968. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  7969. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  7970. * @param {*} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
  7971. */
  7972. this.spliceRow = function (row, index, amount /* , elements... */) {
  7973. var _datamap2;
  7974. return (_datamap2 = datamap).spliceRow.apply(_datamap2, arguments);
  7975. };
  7976. /**
  7977. * Returns indexes of the currently selected cells as an array `[startRow, startCol, endRow, endCol]`.
  7978. *
  7979. * Start row and start col are the coordinates of the active cell (where the selection was started).
  7980. *
  7981. * @memberof Core#
  7982. * @function getSelected
  7983. * @returns {Array} Array of the selection's indexes.
  7984. */
  7985. this.getSelected = function () {
  7986. // https://github.com/handsontable/handsontable/issues/44 //cjl
  7987. if (selection.isSelected()) {
  7988. return [priv.selRange.from.row, priv.selRange.from.col, priv.selRange.to.row, priv.selRange.to.col];
  7989. }
  7990. };
  7991. /**
  7992. * Returns the current selection as a CellRange object.
  7993. *
  7994. * @memberof Core#
  7995. * @function getSelectedRange
  7996. * @since 0.11
  7997. * @returns {CellRange} Selected range object or undefined` if there is no selection.
  7998. */
  7999. this.getSelectedRange = function () {
  8000. // https://github.com/handsontable/handsontable/issues/44 //cjl
  8001. if (selection.isSelected()) {
  8002. return priv.selRange;
  8003. }
  8004. };
  8005. /**
  8006. * Rerender the table.
  8007. *
  8008. * @memberof Core#
  8009. * @function render
  8010. */
  8011. this.render = function () {
  8012. if (instance.view) {
  8013. instance.renderCall = true;
  8014. instance.forceFullRender = true; // used when data was changed
  8015. selection.refreshBorders(null, true);
  8016. }
  8017. };
  8018. /**
  8019. * Reset all cells in the grid to contain data from the data array.
  8020. *
  8021. * @memberof Core#
  8022. * @function loadData
  8023. * @param {Array} data Array of arrays or array of objects containing data.
  8024. * @fires Hooks#afterLoadData
  8025. * @fires Hooks#afterChange
  8026. */
  8027. this.loadData = function (data) {
  8028. if (Array.isArray(priv.settings.dataSchema)) {
  8029. instance.dataType = 'array';
  8030. } else if ((0, _function.isFunction)(priv.settings.dataSchema)) {
  8031. instance.dataType = 'function';
  8032. } else {
  8033. instance.dataType = 'object';
  8034. }
  8035. if (datamap) {
  8036. datamap.destroy();
  8037. }
  8038. datamap = new _dataMap2.default(instance, priv, GridSettings);
  8039. if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null) {
  8040. if (!(data.push && data.splice)) {
  8041. // check if data is array. Must use duck-type check so Backbone Collections also pass it
  8042. // when data is not an array, attempt to make a single-row array of it
  8043. data = [data];
  8044. }
  8045. } else if (data === null) {
  8046. data = [];
  8047. var row;
  8048. var r = 0;
  8049. var rlen = 0;
  8050. var dataSchema = datamap.getSchema();
  8051. for (r = 0, rlen = priv.settings.startRows; r < rlen; r++) {
  8052. if ((instance.dataType === 'object' || instance.dataType === 'function') && priv.settings.dataSchema) {
  8053. row = (0, _object.deepClone)(dataSchema);
  8054. data.push(row);
  8055. } else if (instance.dataType === 'array') {
  8056. row = (0, _object.deepClone)(dataSchema[0]);
  8057. data.push(row);
  8058. } else {
  8059. row = [];
  8060. for (var c = 0, clen = priv.settings.startCols; c < clen; c++) {
  8061. row.push(null);
  8062. }
  8063. data.push(row);
  8064. }
  8065. }
  8066. } else {
  8067. throw new Error('loadData only accepts array of objects or array of arrays (' + (typeof data === 'undefined' ? 'undefined' : _typeof(data)) + ' given)');
  8068. }
  8069. priv.isPopulated = false;
  8070. GridSettings.prototype.data = data;
  8071. if (Array.isArray(data[0])) {
  8072. instance.dataType = 'array';
  8073. }
  8074. datamap.dataSource = data;
  8075. dataSource.data = data;
  8076. dataSource.dataType = instance.dataType;
  8077. dataSource.colToProp = datamap.colToProp.bind(datamap);
  8078. dataSource.propToCol = datamap.propToCol.bind(datamap);
  8079. clearCellSettingCache();
  8080. grid.adjustRowsAndCols();
  8081. instance.runHooks('afterLoadData', priv.firstRun);
  8082. if (priv.firstRun) {
  8083. priv.firstRun = [null, 'loadData'];
  8084. } else {
  8085. instance.runHooks('afterChange', null, 'loadData');
  8086. instance.render();
  8087. }
  8088. priv.isPopulated = true;
  8089. function clearCellSettingCache() {
  8090. priv.cellSettings.length = 0;
  8091. }
  8092. };
  8093. /**
  8094. * Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method,
  8095. * unless the `modifyRow` hook was used to trim some of the rows. If that's the case - use the {@link Core#getSourceData} method.).
  8096. * Optionally you can provide cell range by defining `row`, `col`, `row2`, `col2` to get only a fragment of grid data.
  8097. *
  8098. * Note: getData functionality changed with the release of version 0.20. If you're looking for the previous functionality,
  8099. * you should use the {@link Core#getSourceData} method.
  8100. *
  8101. * @memberof Core#
  8102. * @function getData
  8103. * @param {Number} [r] From visual row index.
  8104. * @param {Number} [c] From visual column index.
  8105. * @param {Number} [r2] To visual row index.
  8106. * @param {Number} [c2] To visual column index.
  8107. * @returns {Array} Array with the data.
  8108. */
  8109. this.getData = function (r, c, r2, c2) {
  8110. if ((0, _mixed.isUndefined)(r)) {
  8111. return datamap.getAll();
  8112. }
  8113. return datamap.getRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), datamap.DESTINATION_RENDERER);
  8114. };
  8115. /**
  8116. * Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new line character.
  8117. * {@link DataMap#getCopyableText}
  8118. *
  8119. * @memberof Core#
  8120. * @function getCopyableText
  8121. * @since 0.11
  8122. * @param {Number} startRow From visual row index.
  8123. * @param {Number} startCol From visual column index.
  8124. * @param {Number} endRow To visual row index.
  8125. * @param {Number} endCol To visual column index.
  8126. * @returns {String}
  8127. */
  8128. this.getCopyableText = function (startRow, startCol, endRow, endCol) {
  8129. return datamap.getCopyableText(new _src.CellCoords(startRow, startCol), new _src.CellCoords(endRow, endCol));
  8130. };
  8131. /**
  8132. * Returns the data's copyable value at specified row and column index ({@link DataMap#getCopyable}).
  8133. *
  8134. * @memberof Core#
  8135. * @function getCopyableData
  8136. * @since 0.19.0
  8137. * @param {Number} row Visual row index.
  8138. * @param {Number} column Visual column index.
  8139. * @returns {String}
  8140. */
  8141. this.getCopyableData = function (row, column) {
  8142. return datamap.getCopyable(row, datamap.colToProp(column));
  8143. };
  8144. /**
  8145. * Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data
  8146. * structure in the first row.
  8147. *
  8148. * @memberof Core#
  8149. * @function getSchema
  8150. * @since 0.13.2
  8151. * @returns {Object} Schema object.
  8152. */
  8153. this.getSchema = function () {
  8154. return datamap.getSchema();
  8155. };
  8156. /**
  8157. * Use it if you need to change configuration after initialization. The `settings` parameter is an object containing the new
  8158. * settings, declared the same way as in the initial settings object.
  8159. * Note, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset
  8160. * the settings made post-initialization. (for example - ignore changes made using the columnResize feature).
  8161. *
  8162. * @memberof Core#
  8163. * @function updateSettings
  8164. * @param {Object} settings New settings object.
  8165. * @param {Boolean} init Calls this method in the initialization mode. Internal use only.
  8166. * Used by API could be cause of the unexpected behaviour of the Handsontable.
  8167. * @example
  8168. * ```js
  8169. * hot.updateSettings({
  8170. * contextMenu: true,
  8171. * colHeaders: true,
  8172. * fixedRowsTop: 2
  8173. * });
  8174. * ```
  8175. * @fires Hooks#afterCellMetaReset
  8176. * @fires Hooks#afterUpdateSettings
  8177. */
  8178. this.updateSettings = function (settings, init) {
  8179. var columnsAsFunc = false;
  8180. var i = void 0;
  8181. var j = void 0;
  8182. var clen = void 0;
  8183. if ((0, _mixed.isDefined)(settings.rows)) {
  8184. throw new Error('"rows" setting is no longer supported. do you mean startRows, minRows or maxRows?');
  8185. }
  8186. if ((0, _mixed.isDefined)(settings.cols)) {
  8187. throw new Error('"cols" setting is no longer supported. do you mean startCols, minCols or maxCols?');
  8188. }
  8189. for (i in settings) {
  8190. if (i === 'data') {
  8191. /* eslint-disable no-continue */
  8192. continue; // loadData will be triggered later
  8193. } else if (_pluginHooks2.default.getSingleton().getRegistered().indexOf(i) > -1) {
  8194. if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
  8195. settings[i].initialHook = true;
  8196. instance.addHook(i, settings[i]);
  8197. }
  8198. } else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
  8199. // Update settings
  8200. GridSettings.prototype[i] = settings[i];
  8201. }
  8202. }
  8203. // Load data or create data map
  8204. if (settings.data === void 0 && priv.settings.data === void 0) {
  8205. instance.loadData(null); // data source created just now
  8206. } else if (settings.data !== void 0) {
  8207. instance.loadData(settings.data); // data source given as option
  8208. } else if (settings.columns !== void 0) {
  8209. datamap.createMap();
  8210. }
  8211. clen = instance.countCols();
  8212. var columnSetting = settings.columns || GridSettings.prototype.columns;
  8213. // Init columns constructors configuration
  8214. if (columnSetting && (0, _function.isFunction)(columnSetting)) {
  8215. clen = instance.countSourceCols();
  8216. columnsAsFunc = true;
  8217. }
  8218. // Clear cellSettings cache
  8219. if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) {
  8220. priv.cellSettings.length = 0;
  8221. }
  8222. if (clen > 0) {
  8223. var proto = void 0;
  8224. var column = void 0;
  8225. for (i = 0, j = 0; i < clen; i++) {
  8226. if (columnsAsFunc && !columnSetting(i)) {
  8227. /* eslint-disable no-continue */
  8228. continue;
  8229. }
  8230. priv.columnSettings[j] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  8231. // shortcut for prototype
  8232. proto = priv.columnSettings[j].prototype;
  8233. // Use settings provided by user
  8234. if (columnSetting) {
  8235. if (columnsAsFunc) {
  8236. column = columnSetting(i);
  8237. } else {
  8238. column = columnSetting[j];
  8239. }
  8240. if (column) {
  8241. (0, _object.extend)(proto, column);
  8242. (0, _object.extend)(proto, expandType(column));
  8243. }
  8244. }
  8245. j++;
  8246. }
  8247. }
  8248. if ((0, _mixed.isDefined)(settings.cell)) {
  8249. for (var key in settings.cell) {
  8250. if ((0, _object.hasOwnProperty)(settings.cell, key)) {
  8251. var cell = settings.cell[key];
  8252. instance.setCellMetaObject(cell.row, cell.col, cell);
  8253. }
  8254. }
  8255. }
  8256. instance.runHooks('afterCellMetaReset');
  8257. if ((0, _mixed.isDefined)(settings.className)) {
  8258. if (GridSettings.prototype.className) {
  8259. (0, _element.removeClass)(instance.rootElement, GridSettings.prototype.className);
  8260. }
  8261. if (settings.className) {
  8262. (0, _element.addClass)(instance.rootElement, settings.className);
  8263. }
  8264. }
  8265. var currentHeight = instance.rootElement.style.height;
  8266. if (currentHeight !== '') {
  8267. currentHeight = parseInt(instance.rootElement.style.height, 10);
  8268. }
  8269. var height = settings.height;
  8270. if ((0, _function.isFunction)(height)) {
  8271. height = height();
  8272. }
  8273. if (init) {
  8274. var initialStyle = instance.rootElement.getAttribute('style');
  8275. if (initialStyle) {
  8276. instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style'));
  8277. }
  8278. }
  8279. if (height === null) {
  8280. var _initialStyle = instance.rootElement.getAttribute('data-initialstyle');
  8281. if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) {
  8282. instance.rootElement.setAttribute('style', _initialStyle);
  8283. } else {
  8284. instance.rootElement.style.height = '';
  8285. instance.rootElement.style.overflow = '';
  8286. }
  8287. } else if (height !== void 0) {
  8288. instance.rootElement.style.height = height + 'px';
  8289. instance.rootElement.style.overflow = 'hidden';
  8290. }
  8291. if (typeof settings.width !== 'undefined') {
  8292. var width = settings.width;
  8293. if ((0, _function.isFunction)(width)) {
  8294. width = width();
  8295. }
  8296. instance.rootElement.style.width = width + 'px';
  8297. }
  8298. if (!init) {
  8299. datamap.clearLengthCache(); // force clear cache length on updateSettings() #3416
  8300. if (instance.view) {
  8301. instance.view.wt.wtViewport.resetHasOversizedColumnHeadersMarked();
  8302. }
  8303. instance.runHooks('afterUpdateSettings', settings);
  8304. }
  8305. grid.adjustRowsAndCols();
  8306. if (instance.view && !priv.firstRun) {
  8307. instance.forceFullRender = true; // used when data was changed
  8308. selection.refreshBorders(null, true);
  8309. }
  8310. if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) {
  8311. instance.view.wt.wtOverlays.updateMainScrollableElements();
  8312. }
  8313. };
  8314. /**
  8315. * Get value from the selected cell.
  8316. *
  8317. * @memberof Core#
  8318. * @function getValue
  8319. * @since 0.11
  8320. * @returns {*} Value of selected cell.
  8321. */
  8322. this.getValue = function () {
  8323. var sel = instance.getSelected();
  8324. if (GridSettings.prototype.getValue) {
  8325. if ((0, _function.isFunction)(GridSettings.prototype.getValue)) {
  8326. return GridSettings.prototype.getValue.call(instance);
  8327. } else if (sel) {
  8328. return instance.getData()[sel[0]][GridSettings.prototype.getValue];
  8329. }
  8330. } else if (sel) {
  8331. return instance.getDataAtCell(sel[0], sel[1]);
  8332. }
  8333. };
  8334. function expandType(obj) {
  8335. if (!(0, _object.hasOwnProperty)(obj, 'type')) {
  8336. // ignore obj.prototype.type
  8337. return;
  8338. }
  8339. var type,
  8340. expandedType = {};
  8341. if (_typeof(obj.type) === 'object') {
  8342. type = obj.type;
  8343. } else if (typeof obj.type === 'string') {
  8344. type = (0, _cellTypes.getCellType)(obj.type);
  8345. }
  8346. for (var i in type) {
  8347. if ((0, _object.hasOwnProperty)(type, i) && !(0, _object.hasOwnProperty)(obj, i)) {
  8348. expandedType[i] = type[i];
  8349. }
  8350. }
  8351. return expandedType;
  8352. }
  8353. /**
  8354. * Returns the object settings.
  8355. *
  8356. * @memberof Core#
  8357. * @function getSettings
  8358. * @returns {Object} Object containing the current grid settings.
  8359. */
  8360. this.getSettings = function () {
  8361. return priv.settings;
  8362. };
  8363. /**
  8364. * Clears the data from the grid. (The table settings remain intact.)
  8365. *
  8366. * @memberof Core#
  8367. * @function clear
  8368. * @since 0.11
  8369. */
  8370. this.clear = function () {
  8371. selection.selectAll();
  8372. selection.empty();
  8373. };
  8374. /**
  8375. * @memberof Core#
  8376. * @function alter
  8377. * @param {String} action See grid.alter for possible values: `"insert_row"`, `"insert_col"`, `"remove_row"`, `"remove_col"`
  8378. * @param {Number} index Visual index of the row/column before which the new row/column will be inserted/removed.
  8379. * @param {Number} [amount = 1] Amound of rows/columns to be inserted/removed.
  8380. * @param {String} [source] Source indicator.
  8381. * @param {Boolean} [keepEmptyRows] Flag for preventing deletion of empty rows.
  8382. * @description
  8383. *
  8384. * Allows altering the table structure by either inserting/removing rows or inserting/removing columns:
  8385. *
  8386. * Insert new row(s) above the row with a given `index`. If index is `null` or `undefined`, the new row will be
  8387. * added after the last row.
  8388. * ```js
  8389. * var hot = new Handsontable(document.getElementById('example'));
  8390. * hot.alter('insert_row', 10);
  8391. * ```
  8392. *
  8393. * Insert new column(s) before the column with a given `index`. If index is `null` or `undefined`, the new column
  8394. * will be added after the last column.
  8395. * ```js
  8396. * var hot = new Handsontable(document.getElementById('example'));
  8397. * hot.alter('insert_col', 10);
  8398. * ```
  8399. *
  8400. * Remove the row(s) at the given `index`.
  8401. * ```js
  8402. * var hot = new Handsontable(document.getElementById('example'));
  8403. * hot.alter('remove_row', 10);
  8404. * ```
  8405. *
  8406. * Remove the column(s) at the given `index`.
  8407. * ```js
  8408. * var hot = new Handsontable(document.getElementById('example'));
  8409. * hot.alter('remove_col', 10);
  8410. * ```
  8411. */
  8412. this.alter = function (action, index, amount, source, keepEmptyRows) {
  8413. grid.alter(action, index, amount, source, keepEmptyRows);
  8414. };
  8415. /**
  8416. * Returns a TD element for the given `row` and `col` arguments, if it is rendered on screen.
  8417. * Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible).
  8418. *
  8419. * @memberof Core#
  8420. * @function getCell
  8421. * @param {Number} row Visual row index.
  8422. * @param {Number} col Visual column index.
  8423. * @param {Boolean} topmost If set to true, it returns the TD element from the topmost overlay. For example,
  8424. * if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
  8425. * @returns {Element} The cell's TD element.
  8426. */
  8427. this.getCell = function (row, col, topmost) {
  8428. return instance.view.getCellAtCoords(new _src.CellCoords(row, col), topmost);
  8429. };
  8430. /**
  8431. * Returns the coordinates of the cell, provided as a HTML Element.
  8432. *
  8433. * @memberof Core#
  8434. * @function getCoords
  8435. * @param {Element} elem The HTML Element representing the cell.
  8436. * @returns {CellCoords} Visual coordinates object.
  8437. */
  8438. this.getCoords = function (elem) {
  8439. return this.view.wt.wtTable.getCoords.call(this.view.wt.wtTable, elem);
  8440. };
  8441. /**
  8442. * Returns the property name that corresponds with the given column index. {@link DataMap#colToProp}
  8443. * If the data source is an array of arrays, it returns the columns index.
  8444. *
  8445. * @memberof Core#
  8446. * @function colToProp
  8447. * @param {Number} col Visual column index.
  8448. * @returns {String|Number} Column property or physical column index.
  8449. */
  8450. this.colToProp = function (col) {
  8451. return datamap.colToProp(col);
  8452. };
  8453. /**
  8454. * Returns column index that corresponds with the given property. {@link DataMap#propToCol}
  8455. *
  8456. * @memberof Core#
  8457. * @function propToCol
  8458. * @param {String|Number} prop Property name or physical column index.
  8459. * @returns {Number} Visual column index.
  8460. */
  8461. this.propToCol = function (prop) {
  8462. return datamap.propToCol(prop);
  8463. };
  8464. /**
  8465. * Translate physical row index into visual.
  8466. *
  8467. * @since 0.29.0
  8468. * @memberof Core#
  8469. * @function toVisualRow
  8470. * @param {Number} row Physical row index.
  8471. * @returns {Number} Returns visual row index.
  8472. */
  8473. this.toVisualRow = function (row) {
  8474. return recordTranslator.toVisualRow(row);
  8475. };
  8476. /**
  8477. * Translate physical column index into visual.
  8478. *
  8479. * @since 0.29.0
  8480. * @memberof Core#
  8481. * @function toVisualColumn
  8482. * @param {Number} column Physical column index.
  8483. * @returns {Number} Returns visual column index.
  8484. */
  8485. this.toVisualColumn = function (column) {
  8486. return recordTranslator.toVisualColumn(column);
  8487. };
  8488. /**
  8489. * Translate visual row index into physical.
  8490. * If displayed rows order is different than the order of rows stored in memory (i.e. sorting is applied)
  8491. * to retrieve valid physical row index you can use this method.
  8492. *
  8493. * @since 0.29.0
  8494. * @memberof Core#
  8495. * @function toPhysicalRow
  8496. * @param {Number} row Visual row index.
  8497. * @returns {Number} Returns physical row index.
  8498. */
  8499. this.toPhysicalRow = function (row) {
  8500. return recordTranslator.toPhysicalRow(row);
  8501. };
  8502. /**
  8503. * Translate visual column index into physical.
  8504. * If displayed columns order is different than the order of columns stored in memory (i.e. manual column move is applied)
  8505. * to retrieve valid physical column index you can use this method.
  8506. *
  8507. * @since 0.29.0
  8508. * @memberof Core#
  8509. * @function toPhysicalColumn
  8510. * @param {Number} column Visual column index.
  8511. * @returns {Number} Returns physical column index.
  8512. */
  8513. this.toPhysicalColumn = function (column) {
  8514. return recordTranslator.toPhysicalColumn(column);
  8515. };
  8516. /**
  8517. * @description
  8518. * Returns the cell value at `row`, `col`. `row` and `col` are the __visible__ indexes (note, that if columns were reordered or sorted,
  8519. * the currently visible order will be used).
  8520. *
  8521. * @memberof Core#
  8522. * @function getDataAtCell
  8523. * @param {Number} row Visual row index.
  8524. * @param {Number} col Visual column index.
  8525. * @returns {String|Boolean|null} Data at cell.
  8526. */
  8527. this.getDataAtCell = function (row, col) {
  8528. return datamap.get(row, datamap.colToProp(col));
  8529. };
  8530. /**
  8531. * Return value at `row`, `prop`. (Uses {@link DataMap#get})
  8532. *
  8533. * @memberof Core#
  8534. * @function getDataAtRowProp
  8535. * @param {Number} row Visual row index.
  8536. * @param {String} prop Property name.
  8537. * @returns {*} Cell value.
  8538. */
  8539. this.getDataAtRowProp = function (row, prop) {
  8540. return datamap.get(row, prop);
  8541. };
  8542. /**
  8543. * @description
  8544. * Returns array of column values from the data source. `col` is the __visible__ index of the column.
  8545. * Note, that if columns were reordered or sorted, the currently visible order will be used.
  8546. *
  8547. * @memberof Core#
  8548. * @function getDataAtCol
  8549. * @since 0.9-beta2
  8550. * @param {Number} col Visual column index.
  8551. * @returns {Array} Array of cell values.
  8552. */
  8553. this.getDataAtCol = function (col) {
  8554. var out = [];
  8555. 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)));
  8556. };
  8557. /**
  8558. * Given the object property name (e.g. `'first.name'`), returns an array of column's values from the data source.
  8559. * You can also provide a column index as the first argument.
  8560. *
  8561. * @memberof Core#
  8562. * @function getDataAtProp
  8563. * @since 0.9-beta2
  8564. * @param {String|Number} prop Property name / physical column index.
  8565. * @returns {Array} Array of cell values.
  8566. */
  8567. // TODO: Getting data from `datamap` should work on visual indexes.
  8568. this.getDataAtProp = function (prop) {
  8569. var out = [],
  8570. range;
  8571. range = datamap.getRange(new _src.CellCoords(0, datamap.propToCol(prop)), new _src.CellCoords(priv.settings.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
  8572. return out.concat.apply(out, _toConsumableArray(range));
  8573. };
  8574. /**
  8575. * Returns the source data object (the same that was passed by `data` configuration option or `loadData` method).
  8576. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  8577. *
  8578. * @memberof Core#
  8579. * @function getSourceData
  8580. * @since 0.20.0
  8581. * @param {Number} [r] From physical row index.
  8582. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  8583. * @param {Number} [r2] To physical row index.
  8584. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  8585. * @returns {Array} Array of grid data.
  8586. */
  8587. this.getSourceData = function (r, c, r2, c2) {
  8588. var data = void 0;
  8589. if (r === void 0) {
  8590. data = dataSource.getData();
  8591. } else {
  8592. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2));
  8593. }
  8594. return data;
  8595. };
  8596. /**
  8597. * Returns the source data object as an arrays of arrays format even when source data was provided in another format.
  8598. * Optionally you can provide a cell range by using the `row`, `col`, `row2`, `col2` arguments, to get only a fragment of grid data.
  8599. *
  8600. * @memberof Core#
  8601. * @function getSourceDataArray
  8602. * @since 0.28.0
  8603. * @param {Number} [r] From physical row index.
  8604. * @param {Number} [c] From physical column index (or visual index, if data type is an array of objects).
  8605. * @param {Number} [r2] To physical row index.
  8606. * @param {Number} [c2] To physical column index (or visual index, if data type is an array of objects).
  8607. * @returns {Array} An array of arrays.
  8608. */
  8609. this.getSourceDataArray = function (r, c, r2, c2) {
  8610. var data = void 0;
  8611. if (r === void 0) {
  8612. data = dataSource.getData(true);
  8613. } else {
  8614. data = dataSource.getByRange(new _src.CellCoords(r, c), new _src.CellCoords(r2, c2), true);
  8615. }
  8616. return data;
  8617. };
  8618. /**
  8619. * Returns an array of column values from the data source. `col` is the index of the row in the data source.
  8620. *
  8621. * @memberof Core#
  8622. * @function getSourceDataAtCol
  8623. * @since 0.11.0-beta3
  8624. * @param {Number} column Visual column index.
  8625. * @returns {Array} Array of the column's cell values.
  8626. */
  8627. // TODO: Getting data from `sourceData` should work always on physical indexes.
  8628. this.getSourceDataAtCol = function (column) {
  8629. return dataSource.getAtColumn(column);
  8630. };
  8631. /**
  8632. * 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.
  8633. *
  8634. * @memberof Core#
  8635. * @function getSourceDataAtRow
  8636. * @since 0.11.0-beta3
  8637. * @param {Number} row Physical row index.
  8638. * @returns {Array|Object} Single row of data.
  8639. */
  8640. this.getSourceDataAtRow = function (row) {
  8641. return dataSource.getAtRow(row);
  8642. };
  8643. /**
  8644. * Returns a single value from the data source.
  8645. *
  8646. * @memberof Core#
  8647. * @function getSourceDataAtCell
  8648. * @param {Number} row Physical row index.
  8649. * @param {Number} column Visual column index.
  8650. * @returns {*} Cell data.
  8651. * @since 0.20.0
  8652. */
  8653. // TODO: Getting data from `sourceData` should work always on physical indexes.
  8654. this.getSourceDataAtCell = function (row, column) {
  8655. return dataSource.getAtCell(row, column);
  8656. };
  8657. /**
  8658. * @description
  8659. * Returns a single row of the data. The `row` argument is the __visible__ index of the row.
  8660. *
  8661. * @memberof Core#
  8662. * @function getDataAtRow
  8663. * @param {Number} row Visual row index.
  8664. * @returns {Array} Array of row's cell data.
  8665. * @since 0.9-beta2
  8666. */
  8667. this.getDataAtRow = function (row) {
  8668. var data = datamap.getRange(new _src.CellCoords(row, 0), new _src.CellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
  8669. return data[0] || [];
  8670. };
  8671. /**
  8672. * @description
  8673. * Returns a data type defined in the Handsontable settings under the `type` key ([Options#type](http://docs.handsontable.com/Options.html#type)).
  8674. * If there are cells with different types in the selected range, it returns `'mixed'`.
  8675. *
  8676. * @since 0.18.1
  8677. * @memberof Core#
  8678. * @function getDataType
  8679. * @param {Number} rowFrom From visual row index.
  8680. * @param {Number} columnFrom From visual column index.
  8681. * @param {Number} rowTo To visual row index.
  8682. * @param {Number} columnTo To visual column index.
  8683. * @returns {String} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`).
  8684. */
  8685. this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) {
  8686. var _this = this;
  8687. var previousType = null;
  8688. var currentType = null;
  8689. if (rowFrom === void 0) {
  8690. rowFrom = 0;
  8691. rowTo = this.countRows();
  8692. columnFrom = 0;
  8693. columnTo = this.countCols();
  8694. }
  8695. if (rowTo === void 0) {
  8696. rowTo = rowFrom;
  8697. }
  8698. if (columnTo === void 0) {
  8699. columnTo = columnFrom;
  8700. }
  8701. var type = 'mixed';
  8702. (0, _number.rangeEach)(Math.min(rowFrom, rowTo), Math.max(rowFrom, rowTo), function (row) {
  8703. var isTypeEqual = true;
  8704. (0, _number.rangeEach)(Math.min(columnFrom, columnTo), Math.max(columnFrom, columnTo), function (column) {
  8705. var cellType = _this.getCellMeta(row, column);
  8706. currentType = cellType.type;
  8707. if (previousType) {
  8708. isTypeEqual = previousType === currentType;
  8709. } else {
  8710. previousType = currentType;
  8711. }
  8712. return isTypeEqual;
  8713. });
  8714. type = isTypeEqual ? currentType : 'mixed';
  8715. return isTypeEqual;
  8716. });
  8717. return type;
  8718. };
  8719. /**
  8720. * Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `col` coordinates.
  8721. *
  8722. * @memberof Core#
  8723. * @function removeCellMeta
  8724. * @param {Number} row Visual row index.
  8725. * @param {Number} col Visual column index.
  8726. * @param {String} key Property name.
  8727. * @fires Hooks#beforeRemoveCellMeta
  8728. * @fires Hooks#afterRemoveCellMeta
  8729. */
  8730. this.removeCellMeta = function (row, col, key) {
  8731. var _recordTranslator$toP = recordTranslator.toPhysical(row, col),
  8732. _recordTranslator$toP2 = _slicedToArray(_recordTranslator$toP, 2),
  8733. physicalRow = _recordTranslator$toP2[0],
  8734. physicalColumn = _recordTranslator$toP2[1];
  8735. var cachedValue = priv.cellSettings[physicalRow][physicalColumn][key];
  8736. var hookResult = instance.runHooks('beforeRemoveCellMeta', row, col, key, cachedValue);
  8737. if (hookResult !== false) {
  8738. delete priv.cellSettings[physicalRow][physicalColumn][key];
  8739. instance.runHooks('afterRemoveCellMeta', row, col, key, cachedValue);
  8740. }
  8741. cachedValue = null;
  8742. };
  8743. /**
  8744. * Remove one or more rows from the cell meta object.
  8745. *
  8746. * @since 0.30.0
  8747. * @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.
  8748. * @param {Number} deleteAmount The number of items to be removed. If set to 0, no items will be removed.
  8749. * @param {Array} items The new items to be added to the array.
  8750. */
  8751. this.spliceCellsMeta = function (index, deleteAmount) {
  8752. var _priv$cellSettings;
  8753. for (var _len2 = arguments.length, items = Array(_len2 > 2 ? _len2 - 2 : 0), _key = 2; _key < _len2; _key++) {
  8754. items[_key - 2] = arguments[_key];
  8755. }
  8756. (_priv$cellSettings = priv.cellSettings).splice.apply(_priv$cellSettings, [index, deleteAmount].concat(items));
  8757. };
  8758. /**
  8759. * Set cell meta data object defined by `prop` to the corresponding params `row` and `col`.
  8760. *
  8761. * @memberof Core#
  8762. * @function setCellMetaObject
  8763. * @since 0.11
  8764. * @param {Number} row Visual row index.
  8765. * @param {Number} col Visual column index.
  8766. * @param {Object} prop Meta object.
  8767. */
  8768. this.setCellMetaObject = function (row, col, prop) {
  8769. if ((typeof prop === 'undefined' ? 'undefined' : _typeof(prop)) === 'object') {
  8770. for (var key in prop) {
  8771. if ((0, _object.hasOwnProperty)(prop, key)) {
  8772. var value = prop[key];
  8773. this.setCellMeta(row, col, key, value);
  8774. }
  8775. }
  8776. }
  8777. };
  8778. /**
  8779. * Sets a property defined by the `key` object to the meta object of a cell corresponding to params `row` and `col`.
  8780. *
  8781. * @memberof Core#
  8782. * @function setCellMeta
  8783. * @since 0.11
  8784. * @param {Number} row Visual row index.
  8785. * @param {Number} col Visual column index.
  8786. * @param {String} key Property name.
  8787. * @param {String} val Property value.
  8788. * @fires Hooks#afterSetCellMeta
  8789. */
  8790. this.setCellMeta = function (row, col, key, val) {
  8791. var _recordTranslator$toP3 = recordTranslator.toPhysical(row, col),
  8792. _recordTranslator$toP4 = _slicedToArray(_recordTranslator$toP3, 2),
  8793. physicalRow = _recordTranslator$toP4[0],
  8794. physicalColumn = _recordTranslator$toP4[1];
  8795. if (!priv.columnSettings[physicalColumn]) {
  8796. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  8797. }
  8798. if (!priv.cellSettings[physicalRow]) {
  8799. priv.cellSettings[physicalRow] = [];
  8800. }
  8801. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  8802. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  8803. }
  8804. priv.cellSettings[physicalRow][physicalColumn][key] = val;
  8805. instance.runHooks('afterSetCellMeta', row, col, key, val);
  8806. };
  8807. /**
  8808. * Get all the cells meta settings at least once generated in the table (in order of cell initialization).
  8809. *
  8810. * @since 0.19.0
  8811. * @returns {Array} Returns Array of ColumnSettings object.
  8812. */
  8813. this.getCellsMeta = function () {
  8814. return (0, _array.arrayFlatten)(priv.cellSettings);
  8815. };
  8816. /**
  8817. * Returns the cell properties object for the given `row` and `col` coordinates.
  8818. *
  8819. * @memberof Core#
  8820. * @function getCellMeta
  8821. * @param {Number} row Visual row index.
  8822. * @param {Number} col Visual column index.
  8823. * @returns {Object} The cell properties object.
  8824. * @fires Hooks#beforeGetCellMeta
  8825. * @fires Hooks#afterGetCellMeta
  8826. */
  8827. this.getCellMeta = function (row, col) {
  8828. var prop = datamap.colToProp(col);
  8829. var cellProperties = void 0;
  8830. var _recordTranslator$toP5 = recordTranslator.toPhysical(row, col),
  8831. _recordTranslator$toP6 = _slicedToArray(_recordTranslator$toP5, 2),
  8832. physicalRow = _recordTranslator$toP6[0],
  8833. physicalColumn = _recordTranslator$toP6[1];
  8834. if (!priv.columnSettings[physicalColumn]) {
  8835. priv.columnSettings[physicalColumn] = (0, _setting.columnFactory)(GridSettings, priv.columnsSettingConflicts);
  8836. }
  8837. if (!priv.cellSettings[physicalRow]) {
  8838. priv.cellSettings[physicalRow] = [];
  8839. }
  8840. if (!priv.cellSettings[physicalRow][physicalColumn]) {
  8841. priv.cellSettings[physicalRow][physicalColumn] = new priv.columnSettings[physicalColumn]();
  8842. }
  8843. cellProperties = priv.cellSettings[physicalRow][physicalColumn]; // retrieve cellProperties from cache
  8844. cellProperties.row = physicalRow;
  8845. cellProperties.col = physicalColumn;
  8846. cellProperties.visualRow = row;
  8847. cellProperties.visualCol = col;
  8848. cellProperties.prop = prop;
  8849. cellProperties.instance = instance;
  8850. instance.runHooks('beforeGetCellMeta', row, col, cellProperties);
  8851. (0, _object.extend)(cellProperties, expandType(cellProperties)); // for `type` added in beforeGetCellMeta
  8852. if (cellProperties.cells) {
  8853. var settings = cellProperties.cells.call(cellProperties, physicalRow, physicalColumn, prop);
  8854. if (settings) {
  8855. (0, _object.extend)(cellProperties, settings);
  8856. (0, _object.extend)(cellProperties, expandType(settings)); // for `type` added in cells
  8857. }
  8858. }
  8859. instance.runHooks('afterGetCellMeta', row, col, cellProperties);
  8860. return cellProperties;
  8861. };
  8862. /**
  8863. * Returns a row off the cell meta array.
  8864. *
  8865. * @memberof Core#
  8866. * @function getCellMetaAtRow
  8867. * @since 0.30.0
  8868. * @param {Number} row Physical index of the row to return cell meta for.
  8869. * @returns {Array}
  8870. */
  8871. this.getCellMetaAtRow = function (row) {
  8872. return priv.cellSettings[row];
  8873. };
  8874. /**
  8875. * Checks if the data format and config allows user to modify the column structure.
  8876. * @returns {boolean}
  8877. */
  8878. this.isColumnModificationAllowed = function () {
  8879. return !(instance.dataType === 'object' || instance.getSettings().columns);
  8880. };
  8881. var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer');
  8882. /**
  8883. * Returns the cell renderer function by given `row` and `col` arguments.
  8884. *
  8885. * @memberof Core#
  8886. * @function getCellRenderer
  8887. * @since 0.11
  8888. * @param {Number|Object} row Visual row index or cell meta object.
  8889. * @param {Number} [col] Visual column index.
  8890. * @returns {Function} The renderer function.
  8891. */
  8892. this.getCellRenderer = function (row, col) {
  8893. return (0, _renderers.getRenderer)(rendererLookup.call(this, row, col));
  8894. };
  8895. /**
  8896. * Returns the cell editor by the provided `row` and `col` arguments.
  8897. *
  8898. * @memberof Core#
  8899. * @function getCellEditor
  8900. * @param {Number} row Visual row index.
  8901. * @param {Number} col Visual column index.
  8902. * @returns {Object} The Editor object.
  8903. */
  8904. this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor');
  8905. var validatorLookup = (0, _data.cellMethodLookupFactory)('validator');
  8906. /**
  8907. * Returns the cell validator by `row` and `col`, provided a validator is defined. If not - it doesn't return anything.
  8908. *
  8909. * @memberof Core#
  8910. * @function getCellValidator
  8911. * @param {Number} row Visual row index.
  8912. * @param {Number} col Visual column index.
  8913. * @returns {Function|RegExp|undefined} The validator function.
  8914. */
  8915. this.getCellValidator = function (row, col) {
  8916. var validator = validatorLookup.call(this, row, col);
  8917. if (typeof validator === 'string') {
  8918. validator = (0, _validators.getValidator)(validator);
  8919. }
  8920. return validator;
  8921. };
  8922. /**
  8923. * Validates all cells using their validator functions and calls callback when finished.
  8924. *
  8925. * If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
  8926. *
  8927. * @memberof Core#
  8928. * @function validateCells
  8929. * @param {Function} [callback] The callback function.
  8930. */
  8931. this.validateCells = function (callback) {
  8932. var waitingForValidator = new ValidatorsQueue();
  8933. if (callback) {
  8934. waitingForValidator.onQueueEmpty = callback;
  8935. }
  8936. var i = instance.countRows() - 1;
  8937. while (i >= 0) {
  8938. var j = instance.countCols() - 1;
  8939. while (j >= 0) {
  8940. waitingForValidator.addValidatorToQueue();
  8941. instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) {
  8942. if (typeof result !== 'boolean') {
  8943. throw new Error('Validation error: result is not boolean');
  8944. }
  8945. if (result === false) {
  8946. waitingForValidator.valid = false;
  8947. }
  8948. waitingForValidator.removeValidatorFormQueue();
  8949. }, 'validateCells');
  8950. j--;
  8951. }
  8952. i--;
  8953. }
  8954. waitingForValidator.checkIfQueueIsEmpty();
  8955. };
  8956. /**
  8957. * 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.
  8958. *
  8959. * @memberof Core#
  8960. * @function getRowHeader
  8961. * @param {Number} [row] Visual row index.
  8962. * @fires Hooks#modifyRowHeader
  8963. * @returns {Array|String} Array of header values / single header value.
  8964. */
  8965. this.getRowHeader = function (row) {
  8966. var rowHeader = priv.settings.rowHeaders;
  8967. if (row !== void 0) {
  8968. row = instance.runHooks('modifyRowHeader', row);
  8969. }
  8970. if (row === void 0) {
  8971. rowHeader = [];
  8972. (0, _number.rangeEach)(instance.countRows() - 1, function (i) {
  8973. rowHeader.push(instance.getRowHeader(i));
  8974. });
  8975. } else if (Array.isArray(rowHeader) && rowHeader[row] !== void 0) {
  8976. rowHeader = rowHeader[row];
  8977. } else if ((0, _function.isFunction)(rowHeader)) {
  8978. rowHeader = rowHeader(row);
  8979. } else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
  8980. rowHeader = row + 1;
  8981. }
  8982. return rowHeader;
  8983. };
  8984. /**
  8985. * Returns information about if this table is configured to display row headers.
  8986. *
  8987. * @memberof Core#
  8988. * @function hasRowHeaders
  8989. * @returns {Boolean} `true` if the instance has the row headers enabled, `false` otherwise.
  8990. * @since 0.11
  8991. */
  8992. this.hasRowHeaders = function () {
  8993. return !!priv.settings.rowHeaders;
  8994. };
  8995. /**
  8996. * Returns information about if this table is configured to display column headers.
  8997. *
  8998. * @memberof Core#
  8999. * @function hasColHeaders
  9000. * @since 0.11
  9001. * @returns {Boolean} `True` if the instance has the column headers enabled, `false` otherwise.
  9002. */
  9003. this.hasColHeaders = function () {
  9004. if (priv.settings.colHeaders !== void 0 && priv.settings.colHeaders !== null) {
  9005. // Polymer has empty value = null
  9006. return !!priv.settings.colHeaders;
  9007. }
  9008. for (var i = 0, ilen = instance.countCols(); i < ilen; i++) {
  9009. if (instance.getColHeader(i)) {
  9010. return true;
  9011. }
  9012. }
  9013. return false;
  9014. };
  9015. /**
  9016. * 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.
  9017. *
  9018. * @memberof Core#
  9019. * @function getColHeader
  9020. * @param {Number} [col] Visual column index.
  9021. * @fires Hooks#modifyColHeader
  9022. * @returns {Array|String} The column header(s).
  9023. */
  9024. this.getColHeader = function (col) {
  9025. var columnsAsFunc = priv.settings.columns && (0, _function.isFunction)(priv.settings.columns);
  9026. var result = priv.settings.colHeaders;
  9027. col = instance.runHooks('modifyColHeader', col);
  9028. if (col === void 0) {
  9029. var out = [];
  9030. var ilen = columnsAsFunc ? instance.countSourceCols() : instance.countCols();
  9031. for (var i = 0; i < ilen; i++) {
  9032. out.push(instance.getColHeader(i));
  9033. }
  9034. result = out;
  9035. } else {
  9036. var translateVisualIndexToColumns = function translateVisualIndexToColumns(col) {
  9037. var arr = [];
  9038. var columnsLen = instance.countSourceCols();
  9039. var index = 0;
  9040. for (; index < columnsLen; index++) {
  9041. if ((0, _function.isFunction)(instance.getSettings().columns) && instance.getSettings().columns(index)) {
  9042. arr.push(index);
  9043. }
  9044. }
  9045. return arr[col];
  9046. };
  9047. var baseCol = col;
  9048. col = instance.runHooks('modifyCol', col);
  9049. var prop = translateVisualIndexToColumns(col);
  9050. if (priv.settings.columns && (0, _function.isFunction)(priv.settings.columns) && priv.settings.columns(prop) && priv.settings.columns(prop).title) {
  9051. result = priv.settings.columns(prop).title;
  9052. } else if (priv.settings.columns && priv.settings.columns[col] && priv.settings.columns[col].title) {
  9053. result = priv.settings.columns[col].title;
  9054. } else if (Array.isArray(priv.settings.colHeaders) && priv.settings.colHeaders[col] !== void 0) {
  9055. result = priv.settings.colHeaders[col];
  9056. } else if ((0, _function.isFunction)(priv.settings.colHeaders)) {
  9057. result = priv.settings.colHeaders(col);
  9058. } else if (priv.settings.colHeaders && typeof priv.settings.colHeaders !== 'string' && typeof priv.settings.colHeaders !== 'number') {
  9059. result = (0, _data.spreadsheetColumnLabel)(baseCol); // see #1458
  9060. }
  9061. }
  9062. return result;
  9063. };
  9064. /**
  9065. * Return column width from settings (no guessing). Private use intended.
  9066. *
  9067. * @private
  9068. * @memberof Core#
  9069. * @function _getColWidthFromSettings
  9070. * @param {Number} col Visual col index.
  9071. * @returns {Number}
  9072. */
  9073. this._getColWidthFromSettings = function (col) {
  9074. var cellProperties = instance.getCellMeta(0, col);
  9075. var width = cellProperties.width;
  9076. if (width === void 0 || width === priv.settings.width) {
  9077. width = cellProperties.colWidths;
  9078. }
  9079. if (width !== void 0 && width !== null) {
  9080. switch (typeof width === 'undefined' ? 'undefined' : _typeof(width)) {
  9081. case 'object':
  9082. // array
  9083. width = width[col];
  9084. break;
  9085. case 'function':
  9086. width = width(col);
  9087. break;
  9088. default:
  9089. break;
  9090. }
  9091. if (typeof width === 'string') {
  9092. width = parseInt(width, 10);
  9093. }
  9094. }
  9095. return width;
  9096. };
  9097. /**
  9098. * Returns the width of the requested column.
  9099. *
  9100. * @memberof Core#
  9101. * @function getColWidth
  9102. * @since 0.11
  9103. * @param {Number} col Visual column index.
  9104. * @returns {Number} Column width.
  9105. * @fires Hooks#modifyColWidth
  9106. */
  9107. this.getColWidth = function (col) {
  9108. var width = instance._getColWidthFromSettings(col);
  9109. width = instance.runHooks('modifyColWidth', width, col);
  9110. if (width === void 0) {
  9111. width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH;
  9112. }
  9113. return width;
  9114. };
  9115. /**
  9116. * Return row height from settings (no guessing). Private use intended.
  9117. *
  9118. * @private
  9119. * @memberof Core#
  9120. * @function _getRowHeightFromSettings
  9121. * @param {Number} row Visual row index.
  9122. * @returns {Number}
  9123. */
  9124. this._getRowHeightFromSettings = function (row) {
  9125. // let cellProperties = instance.getCellMeta(row, 0);
  9126. // let height = cellProperties.height;
  9127. //
  9128. // if (height === void 0 || height === priv.settings.height) {
  9129. // height = cellProperties.rowHeights;
  9130. // }
  9131. var height = priv.settings.rowHeights;
  9132. if (height !== void 0 && height !== null) {
  9133. switch (typeof height === 'undefined' ? 'undefined' : _typeof(height)) {
  9134. case 'object':
  9135. // array
  9136. height = height[row];
  9137. break;
  9138. case 'function':
  9139. height = height(row);
  9140. break;
  9141. default:
  9142. break;
  9143. }
  9144. if (typeof height === 'string') {
  9145. height = parseInt(height, 10);
  9146. }
  9147. }
  9148. return height;
  9149. };
  9150. /**
  9151. * Returns the row height.
  9152. *
  9153. * @memberof Core#
  9154. * @function getRowHeight
  9155. * @since 0.11
  9156. * @param {Number} row Visual row index.
  9157. * @returns {Number} The given row's height.
  9158. * @fires Hooks#modifyRowHeight
  9159. */
  9160. this.getRowHeight = function (row) {
  9161. var height = instance._getRowHeightFromSettings(row);
  9162. height = instance.runHooks('modifyRowHeight', height, row);
  9163. return height;
  9164. };
  9165. /**
  9166. * Returns the total number of rows in the data source.
  9167. *
  9168. * @memberof Core#
  9169. * @function countSourceRows
  9170. * @since 0.20.0
  9171. * @returns {Number} Total number in rows in data source.
  9172. */
  9173. this.countSourceRows = function () {
  9174. var sourceLength = instance.runHooks('modifySourceLength');
  9175. return sourceLength || (instance.getSourceData() ? instance.getSourceData().length : 0);
  9176. };
  9177. /**
  9178. * Returns the total number of columns in the data source.
  9179. *
  9180. * @memberof Core#
  9181. * @function countSourceCols
  9182. * @since 0.26.1
  9183. * @returns {Number} Total number in columns in data source.
  9184. */
  9185. this.countSourceCols = function () {
  9186. var len = 0;
  9187. var obj = instance.getSourceData() && instance.getSourceData()[0] ? instance.getSourceData()[0] : [];
  9188. if ((0, _object.isObject)(obj)) {
  9189. len = (0, _object.deepObjectSize)(obj);
  9190. } else {
  9191. len = obj.length || 0;
  9192. }
  9193. return len;
  9194. };
  9195. /**
  9196. * Returns the total number of rows in the grid.
  9197. *
  9198. * @memberof Core#
  9199. * @function countRows
  9200. * @returns {Number} Total number in rows the grid.
  9201. */
  9202. this.countRows = function () {
  9203. return datamap.getLength();
  9204. };
  9205. /**
  9206. * Returns the total number of columns in the grid.
  9207. *
  9208. * @memberof Core#
  9209. * @function countCols
  9210. * @returns {Number} Total number of columns.
  9211. */
  9212. this.countCols = function () {
  9213. var maxCols = this.getSettings().maxCols;
  9214. var dataHasLength = false;
  9215. var dataLen = 0;
  9216. if (instance.dataType === 'array') {
  9217. dataHasLength = priv.settings.data && priv.settings.data[0] && priv.settings.data[0].length;
  9218. }
  9219. if (dataHasLength) {
  9220. dataLen = priv.settings.data[0].length;
  9221. }
  9222. if (priv.settings.columns) {
  9223. var columnsIsFunction = (0, _function.isFunction)(priv.settings.columns);
  9224. if (columnsIsFunction) {
  9225. if (instance.dataType === 'array') {
  9226. var columnLen = 0;
  9227. for (var i = 0; i < dataLen; i++) {
  9228. if (priv.settings.columns(i)) {
  9229. columnLen++;
  9230. }
  9231. }
  9232. dataLen = columnLen;
  9233. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  9234. dataLen = datamap.colToPropCache.length;
  9235. }
  9236. } else {
  9237. dataLen = priv.settings.columns.length;
  9238. }
  9239. } else if (instance.dataType === 'object' || instance.dataType === 'function') {
  9240. dataLen = datamap.colToPropCache.length;
  9241. }
  9242. return Math.min(maxCols, dataLen);
  9243. };
  9244. /**
  9245. * Returns an visual index of the first rendered row.
  9246. *
  9247. * @memberof Core#
  9248. * @function rowOffset
  9249. * @returns {Number} Visual index of first rendered row.
  9250. */
  9251. this.rowOffset = function () {
  9252. return instance.view.wt.wtTable.getFirstRenderedRow();
  9253. };
  9254. /**
  9255. * Returns the visual index of the first rendered column.
  9256. *
  9257. * @memberof Core#
  9258. * @function colOffset
  9259. * @returns {Number} Visual index of the first visible column.
  9260. */
  9261. this.colOffset = function () {
  9262. return instance.view.wt.wtTable.getFirstRenderedColumn();
  9263. };
  9264. /**
  9265. * Returns the number of rendered rows (including rows partially or fully rendered outside viewport).
  9266. *
  9267. * @memberof Core#
  9268. * @function countRenderedRows
  9269. * @returns {Number} Returns -1 if table is not visible.
  9270. */
  9271. this.countRenderedRows = function () {
  9272. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedRowsCount() : -1;
  9273. };
  9274. /**
  9275. * Returns the number of visible rows (rendered rows that fully fit inside viewport).
  9276. *
  9277. * @memberof Core#
  9278. * @function countVisibleRows
  9279. * @returns {Number} Number of visible rows or -1.
  9280. */
  9281. this.countVisibleRows = function () {
  9282. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleRowsCount() : -1;
  9283. };
  9284. /**
  9285. * Returns the number of rendered columns (including columns partially or fully rendered outside viewport).
  9286. *
  9287. * @memberof Core#
  9288. * @function countRenderedCols
  9289. * @returns {Number} Returns -1 if table is not visible.
  9290. */
  9291. this.countRenderedCols = function () {
  9292. return instance.view.wt.drawn ? instance.view.wt.wtTable.getRenderedColumnsCount() : -1;
  9293. };
  9294. /**
  9295. * Returns the number of visible columns. Returns -1 if table is not visible
  9296. *
  9297. * @memberof Core#
  9298. * @function countVisibleCols
  9299. * @return {Number} Number of visible columns or -1.
  9300. */
  9301. this.countVisibleCols = function () {
  9302. return instance.view.wt.drawn ? instance.view.wt.wtTable.getVisibleColumnsCount() : -1;
  9303. };
  9304. /**
  9305. * Returns the number of empty rows. If the optional ending parameter is `true`, returns the
  9306. * number of empty rows at the bottom of the table.
  9307. *
  9308. * @memberof Core#
  9309. * @function countEmptyRows
  9310. * @param {Boolean} [ending] If `true`, will only count empty rows at the end of the data source.
  9311. * @returns {Number} Count empty rows
  9312. * @fires Hooks#modifyRow
  9313. */
  9314. this.countEmptyRows = function (ending) {
  9315. var i = instance.countRows() - 1,
  9316. empty = 0,
  9317. row;
  9318. while (i >= 0) {
  9319. row = instance.runHooks('modifyRow', i);
  9320. if (instance.isEmptyRow(row)) {
  9321. empty++;
  9322. } else if (ending) {
  9323. break;
  9324. }
  9325. i--;
  9326. }
  9327. return empty;
  9328. };
  9329. /**
  9330. * Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty
  9331. * columns at right hand edge of the table.
  9332. *
  9333. * @memberof Core#
  9334. * @function countEmptyCols
  9335. * @param {Boolean} [ending] If `true`, will only count empty columns at the end of the data source row.
  9336. * @returns {Number} Count empty cols
  9337. */
  9338. this.countEmptyCols = function (ending) {
  9339. if (instance.countRows() < 1) {
  9340. return 0;
  9341. }
  9342. var i = instance.countCols() - 1,
  9343. empty = 0;
  9344. while (i >= 0) {
  9345. if (instance.isEmptyCol(i)) {
  9346. empty++;
  9347. } else if (ending) {
  9348. break;
  9349. }
  9350. i--;
  9351. }
  9352. return empty;
  9353. };
  9354. /**
  9355. * Check if all cells in the row declared by the `row` argument are empty.
  9356. *
  9357. * @memberof Core#
  9358. * @function isEmptyRow
  9359. * @param {Number} row Row index.
  9360. * @returns {Boolean} `true` if the row at the given `row` is empty, `false` otherwise.
  9361. */
  9362. this.isEmptyRow = function (row) {
  9363. return priv.settings.isEmptyRow.call(instance, row);
  9364. };
  9365. /**
  9366. * Check if all cells in the the column declared by the `col` argument are empty.
  9367. *
  9368. * @memberof Core#
  9369. * @function isEmptyCol
  9370. * @param {Number} col Column index.
  9371. * @returns {Boolean} `true` if the column at the given `col` is empty, `false` otherwise.
  9372. */
  9373. this.isEmptyCol = function (col) {
  9374. return priv.settings.isEmptyCol.call(instance, col);
  9375. };
  9376. /**
  9377. * Select cell specified by `row` and `col` values or a range of cells finishing at `endRow`, `endCol`.
  9378. * By default, viewport will be scrolled to selection.
  9379. * After the `selectCell` method had finished, the instance will be listening to keyboard input on the document.
  9380. *
  9381. * @memberof Core#
  9382. * @function selectCell
  9383. * @param {Number} row Visual row index.
  9384. * @param {Number} col Visual column index.
  9385. * @param {Number} [endRow] Visual end row index (if selecting a range).
  9386. * @param {Number} [endCol] Visual end column index (if selecting a range).
  9387. * @param {Boolean} [scrollToCell=true] If `true`, the viewport will be scrolled to the selection.
  9388. * @param {Boolean} [changeListener=true] If `false`, Handsontable will not change keyboard events listener to himself.
  9389. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  9390. */
  9391. this.selectCell = function (row, col, endRow, endCol, scrollToCell, changeListener) {
  9392. var coords;
  9393. changeListener = (0, _mixed.isUndefined)(changeListener) || changeListener === true;
  9394. if (typeof row !== 'number' || row < 0 || row >= instance.countRows()) {
  9395. return false;
  9396. }
  9397. if (typeof col !== 'number' || col < 0 || col >= instance.countCols()) {
  9398. return false;
  9399. }
  9400. if ((0, _mixed.isDefined)(endRow)) {
  9401. if (typeof endRow !== 'number' || endRow < 0 || endRow >= instance.countRows()) {
  9402. return false;
  9403. }
  9404. if (typeof endCol !== 'number' || endCol < 0 || endCol >= instance.countCols()) {
  9405. return false;
  9406. }
  9407. }
  9408. coords = new _src.CellCoords(row, col);
  9409. priv.selRange = new _src.CellRange(coords, coords, coords);
  9410. if (changeListener) {
  9411. instance.listen();
  9412. }
  9413. if ((0, _mixed.isUndefined)(endRow)) {
  9414. selection.setRangeEnd(priv.selRange.from, scrollToCell);
  9415. } else {
  9416. selection.setRangeEnd(new _src.CellCoords(endRow, endCol), scrollToCell);
  9417. }
  9418. instance.selection.finish();
  9419. return true;
  9420. };
  9421. /**
  9422. * Select the cell specified by the `row` and `prop` arguments, or a range finishing at `endRow`, `endProp`.
  9423. * By default, viewport will be scrolled to selection.
  9424. *
  9425. * @memberof Core#
  9426. * @function selectCellByProp
  9427. * @param {Number} row Visual row index.
  9428. * @param {String} prop Property name.
  9429. * @param {Number} [endRow] visual end row index (if selecting a range).
  9430. * @param {String} [endProp] End property name (if selecting a range).
  9431. * @param {Boolean} [scrollToCell=true] If `true`, viewport will be scrolled to the selection.
  9432. * @returns {Boolean} `true` if selection was successful, `false` otherwise.
  9433. */
  9434. this.selectCellByProp = function (row, prop, endRow, endProp, scrollToCell) {
  9435. var _instance5;
  9436. arguments[1] = datamap.propToCol(arguments[1]);
  9437. if ((0, _mixed.isDefined)(arguments[3])) {
  9438. arguments[3] = datamap.propToCol(arguments[3]);
  9439. }
  9440. return (_instance5 = instance).selectCell.apply(_instance5, arguments);
  9441. };
  9442. /**
  9443. * Deselects the current cell selection on grid.
  9444. *
  9445. * @memberof Core#
  9446. * @function deselectCell
  9447. */
  9448. this.deselectCell = function () {
  9449. selection.deselect();
  9450. };
  9451. /**
  9452. * Scroll viewport to coords specified by the `row` and `column` arguments.
  9453. *
  9454. * @since 0.24.3
  9455. * @memberof Core#
  9456. * @function scrollViewportTo
  9457. * @param {Number} [row] Visual row index.
  9458. * @param {Number} [column] Visual column index.
  9459. * @param {Boolean} [snapToBottom = false] If `true`, viewport is scrolled to show the cell on the bottom of the table.
  9460. * @param {Boolean} [snapToRight = false] If `true`, viewport is scrolled to show the cell on the right side of the table.
  9461. * @returns {Boolean} `true` if scroll was successful, `false` otherwise.
  9462. */
  9463. this.scrollViewportTo = function (row, column) {
  9464. var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  9465. var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  9466. if (row !== void 0 && (row < 0 || row >= instance.countRows())) {
  9467. return false;
  9468. }
  9469. if (column !== void 0 && (column < 0 || column >= instance.countCols())) {
  9470. return false;
  9471. }
  9472. var result = false;
  9473. if (row !== void 0 && column !== void 0) {
  9474. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  9475. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  9476. result = true;
  9477. }
  9478. if (typeof row === 'number' && typeof column !== 'number') {
  9479. instance.view.wt.wtOverlays.topOverlay.scrollTo(row, snapToBottom);
  9480. result = true;
  9481. }
  9482. if (typeof column === 'number' && typeof row !== 'number') {
  9483. instance.view.wt.wtOverlays.leftOverlay.scrollTo(column, snapToRight);
  9484. result = true;
  9485. }
  9486. return result;
  9487. };
  9488. /**
  9489. * Removes grid from the DOM.
  9490. *
  9491. * @memberof Core#
  9492. * @function destroy
  9493. * @fires Hooks#afterDestroy
  9494. */
  9495. this.destroy = function () {
  9496. instance._clearTimeouts();
  9497. if (instance.view) {
  9498. // in case HT is destroyed before initialization has finished
  9499. instance.view.destroy();
  9500. }
  9501. if (dataSource) {
  9502. dataSource.destroy();
  9503. }
  9504. dataSource = null;
  9505. (0, _element.empty)(instance.rootElement);
  9506. eventManager.destroy();
  9507. instance.runHooks('afterDestroy');
  9508. _pluginHooks2.default.getSingleton().destroy(instance);
  9509. for (var i in instance) {
  9510. if ((0, _object.hasOwnProperty)(instance, i)) {
  9511. // replace instance methods with post mortem
  9512. if ((0, _function.isFunction)(instance[i])) {
  9513. instance[i] = postMortem;
  9514. } else if (i !== 'guid') {
  9515. // replace instance properties with null (restores memory)
  9516. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  9517. instance[i] = null;
  9518. }
  9519. }
  9520. }
  9521. // replace private properties with null (restores memory)
  9522. // it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
  9523. if (datamap) {
  9524. datamap.destroy();
  9525. }
  9526. datamap = null;
  9527. priv = null;
  9528. grid = null;
  9529. selection = null;
  9530. editorManager = null;
  9531. instance = null;
  9532. GridSettings = null;
  9533. };
  9534. /**
  9535. * Replacement for all methods after Handsotnable was destroyed.
  9536. *
  9537. * @private
  9538. */
  9539. function postMortem() {
  9540. throw new Error('This method cannot be called because this Handsontable instance has been destroyed');
  9541. }
  9542. /**
  9543. * Returns the active editor object.
  9544. *
  9545. * @memberof Core#
  9546. * @function getActiveEditor
  9547. * @returns {Object} The active editor object.
  9548. */
  9549. this.getActiveEditor = function () {
  9550. return editorManager.getActiveEditor();
  9551. };
  9552. /**
  9553. * Returns plugin instance using the plugin name provided.
  9554. *
  9555. * @memberof Core#
  9556. * @function getPlugin
  9557. * @param {String} pluginName The plugin name.
  9558. * @returns {*} The plugin instance.
  9559. * @since 0.15.0
  9560. */
  9561. this.getPlugin = function (pluginName) {
  9562. return (0, _plugins.getPlugin)(this, pluginName);
  9563. };
  9564. /**
  9565. * Returns the Handsontable instance.
  9566. *
  9567. * @memberof Core#
  9568. * @function getInstance
  9569. * @returns {Handsontable} The Handsontable instance.
  9570. */
  9571. this.getInstance = function () {
  9572. return instance;
  9573. };
  9574. /**
  9575. * Adds listener to the specified hook name (only for this Handsontable instance).
  9576. *
  9577. * @memberof Core#
  9578. * @function addHook
  9579. * @see Hooks#add
  9580. * @param {String} key Hook name.
  9581. * @param {Function|Array} callback Function or array of Functions.
  9582. *
  9583. * @example
  9584. * ```js
  9585. * hot.addHook('beforeInit', myCallback);
  9586. * ```
  9587. */
  9588. this.addHook = function (key, callback) {
  9589. _pluginHooks2.default.getSingleton().add(key, callback, instance);
  9590. };
  9591. /**
  9592. * Check if for a specified hook name there are added listeners (only for this Handsontable instance).
  9593. *
  9594. * @memberof Core#
  9595. * @function hasHook
  9596. * @see Hooks#has
  9597. * @param {String} key Hook name
  9598. * @return {Boolean}
  9599. *
  9600. * @example
  9601. * ```js
  9602. * var hasBeforeInitListeners = hot.hasHook('beforeInit');
  9603. * ```
  9604. */
  9605. this.hasHook = function (key) {
  9606. return _pluginHooks2.default.getSingleton().has(key, instance);
  9607. };
  9608. /**
  9609. * Adds listener to specified hook name (only for this Handsontable instance).
  9610. * After the listener is triggered, it will be automatically removed.
  9611. *
  9612. * @memberof Core#
  9613. * @function addHookOnce
  9614. * @see Hooks#once
  9615. * @param {String} key Hook name.
  9616. * @param {Function|Array} callback Function or array of Functions.
  9617. *
  9618. * @example
  9619. * ```js
  9620. * hot.addHookOnce('beforeInit', myCallback);
  9621. * ```
  9622. */
  9623. this.addHookOnce = function (key, callback) {
  9624. _pluginHooks2.default.getSingleton().once(key, callback, instance);
  9625. };
  9626. /**
  9627. * Removes the hook listener previously registered with {@link Core#addHook}.
  9628. *
  9629. * @memberof Core#
  9630. * @function removeHook
  9631. * @see Hooks#remove
  9632. * @param {String} key Hook name.
  9633. * @param {Function} callback Function which have been registered via {@link Core#addHook}.
  9634. *
  9635. * @example
  9636. * ```js
  9637. * hot.removeHook('beforeInit', myCallback);
  9638. * ```
  9639. */
  9640. this.removeHook = function (key, callback) {
  9641. _pluginHooks2.default.getSingleton().remove(key, callback, instance);
  9642. };
  9643. /**
  9644. * Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments.
  9645. *
  9646. * @memberof Core#
  9647. * @function runHooks
  9648. * @see Hooks#run
  9649. * @param {String} key Hook name.
  9650. * @param {*} [p1] Argument passed to the callback.
  9651. * @param {*} [p2] Argument passed to the callback.
  9652. * @param {*} [p3] Argument passed to the callback.
  9653. * @param {*} [p4] Argument passed to the callback.
  9654. * @param {*} [p5] Argument passed to the callback.
  9655. * @param {*} [p6] Argument passed to the callback.
  9656. * @returns {*}
  9657. *
  9658. * @example
  9659. * ```js
  9660. * hot.runHooks('beforeInit');
  9661. * ```
  9662. */
  9663. this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
  9664. return _pluginHooks2.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
  9665. };
  9666. this.timeouts = [];
  9667. /**
  9668. * Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
  9669. *
  9670. * @param {*} handle
  9671. * @private
  9672. */
  9673. this._registerTimeout = function (handle) {
  9674. this.timeouts.push(handle);
  9675. };
  9676. /**
  9677. * Clears all known timeouts.
  9678. *
  9679. * @private
  9680. */
  9681. this._clearTimeouts = function () {
  9682. for (var i = 0, ilen = this.timeouts.length; i < ilen; i++) {
  9683. clearTimeout(this.timeouts[i]);
  9684. }
  9685. };
  9686. /**
  9687. * Handsontable version
  9688. *
  9689. * @type {String}
  9690. */
  9691. // this.version = Handsontable.version;
  9692. _pluginHooks2.default.getSingleton().run(instance, 'construct');
  9693. };
  9694. /***/ }),
  9695. /* 64 */
  9696. /***/ (function(module, exports, __webpack_require__) {
  9697. "use strict";
  9698. exports.__esModule = true;
  9699. exports.spreadsheetColumnLabel = spreadsheetColumnLabel;
  9700. exports.spreadsheetColumnIndex = spreadsheetColumnIndex;
  9701. exports.createSpreadsheetData = createSpreadsheetData;
  9702. exports.createSpreadsheetObjectData = createSpreadsheetObjectData;
  9703. exports.createEmptySpreadsheetData = createEmptySpreadsheetData;
  9704. exports.translateRowsToColumns = translateRowsToColumns;
  9705. exports.cellMethodLookupFactory = cellMethodLookupFactory;
  9706. var _cellTypes = __webpack_require__(62);
  9707. var _object = __webpack_require__(1);
  9708. var COLUMN_LABEL_BASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  9709. var COLUMN_LABEL_BASE_LENGTH = COLUMN_LABEL_BASE.length;
  9710. /**
  9711. * Generates spreadsheet-like column names: A, B, C, ..., Z, AA, AB, etc.
  9712. *
  9713. * @param {Number} index Column index.
  9714. * @returns {String}
  9715. */
  9716. function spreadsheetColumnLabel(index) {
  9717. var dividend = index + 1;
  9718. var columnLabel = '';
  9719. var modulo = void 0;
  9720. while (dividend > 0) {
  9721. modulo = (dividend - 1) % COLUMN_LABEL_BASE_LENGTH;
  9722. columnLabel = String.fromCharCode(65 + modulo) + columnLabel;
  9723. dividend = parseInt((dividend - modulo) / COLUMN_LABEL_BASE_LENGTH, 10);
  9724. }
  9725. return columnLabel;
  9726. }
  9727. /**
  9728. * Generates spreadsheet-like column index from theirs labels: A, B, C ...., Z, AA, AB, etc.
  9729. *
  9730. * @param {String} label Column label.
  9731. * @returns {Number}
  9732. */
  9733. function spreadsheetColumnIndex(label) {
  9734. var result = 0;
  9735. if (label) {
  9736. for (var i = 0, j = label.length - 1; i < label.length; i += 1, j -= 1) {
  9737. result += Math.pow(COLUMN_LABEL_BASE_LENGTH, j) * (COLUMN_LABEL_BASE.indexOf(label[i]) + 1);
  9738. }
  9739. }
  9740. --result;
  9741. return result;
  9742. }
  9743. /**
  9744. * Creates 2D array of Excel-like values "A1", "A2", ...
  9745. *
  9746. * @param {Number} rows Number of rows to generate.
  9747. * @param {Number} columns Number of columns to generate.
  9748. * @returns {Array}
  9749. */
  9750. function createSpreadsheetData() {
  9751. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  9752. var columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  9753. var _rows = [],
  9754. i,
  9755. j;
  9756. for (i = 0; i < rows; i++) {
  9757. var row = [];
  9758. for (j = 0; j < columns; j++) {
  9759. row.push(spreadsheetColumnLabel(j) + (i + 1));
  9760. }
  9761. _rows.push(row);
  9762. }
  9763. return _rows;
  9764. }
  9765. /**
  9766. * Creates 2D array of Excel-like values "A1", "A2", as an array of objects.
  9767. *
  9768. * @param {Number} rows Number of rows to generate.
  9769. * @param {Number} colCount Number of columns to generate.
  9770. * @returns {Array}
  9771. */
  9772. function createSpreadsheetObjectData() {
  9773. var rows = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
  9774. var colCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
  9775. var _rows = [],
  9776. i,
  9777. j;
  9778. for (i = 0; i < rows; i++) {
  9779. var row = {};
  9780. for (j = 0; j < colCount; j++) {
  9781. row['prop' + j] = spreadsheetColumnLabel(j) + (i + 1);
  9782. }
  9783. _rows.push(row);
  9784. }
  9785. return _rows;
  9786. }
  9787. /**
  9788. * Generates an empty data object.
  9789. *
  9790. * @param {Number} rows Number of rows to generate.
  9791. * @param {Number} columns Number of columns to generate
  9792. * @returns {Array}
  9793. */
  9794. function createEmptySpreadsheetData(rows, columns) {
  9795. var data = [];
  9796. var row = void 0;
  9797. for (var i = 0; i < rows; i++) {
  9798. row = [];
  9799. for (var j = 0; j < columns; j++) {
  9800. row.push('');
  9801. }
  9802. data.push(row);
  9803. }
  9804. return data;
  9805. }
  9806. function translateRowsToColumns(input) {
  9807. var i,
  9808. ilen,
  9809. j,
  9810. jlen,
  9811. output = [],
  9812. olen = 0;
  9813. for (i = 0, ilen = input.length; i < ilen; i++) {
  9814. for (j = 0, jlen = input[i].length; j < jlen; j++) {
  9815. if (j == olen) {
  9816. output.push([]);
  9817. olen++;
  9818. }
  9819. output[j].push(input[i][j]);
  9820. }
  9821. }
  9822. return output;
  9823. }
  9824. /**
  9825. * Factory that produces a function for searching methods (or any properties) which could be defined directly in
  9826. * table configuration or implicitly, within cell type definition.
  9827. *
  9828. * For example: renderer can be defined explicitly using "renderer" property in column configuration or it can be
  9829. * defined implicitly using "type" property.
  9830. *
  9831. * Methods/properties defined explicitly always takes precedence over those defined through "type".
  9832. *
  9833. * If the method/property is not found in an object, searching is continued recursively through prototype chain, until
  9834. * it reaches the Object.prototype.
  9835. *
  9836. *
  9837. * @param methodName {String} name of the method/property to search (i.e. 'renderer', 'validator', 'copyable')
  9838. * @param allowUndefined {Boolean} [optional] if false, the search is continued if methodName has not been found in cell "type"
  9839. * @returns {Function}
  9840. */
  9841. function cellMethodLookupFactory(methodName, allowUndefined) {
  9842. allowUndefined = typeof allowUndefined == 'undefined' ? true : allowUndefined;
  9843. return function cellMethodLookup(row, col) {
  9844. return function getMethodFromProperties(properties) {
  9845. if (!properties) {
  9846. return; // method not found
  9847. } else if ((0, _object.hasOwnProperty)(properties, methodName) && properties[methodName] !== void 0) {
  9848. // check if it is own and is not empty
  9849. return properties[methodName]; // method defined directly
  9850. } else if ((0, _object.hasOwnProperty)(properties, 'type') && properties.type) {
  9851. // check if it is own and is not empty
  9852. var type;
  9853. if (typeof properties.type != 'string') {
  9854. throw new Error('Cell type must be a string ');
  9855. }
  9856. type = (0, _cellTypes.getCellType)(properties.type);
  9857. if ((0, _object.hasOwnProperty)(type, methodName)) {
  9858. return type[methodName]; // method defined in type.
  9859. } else if (allowUndefined) {
  9860. return; // method does not defined in type (eg. validator), returns undefined
  9861. }
  9862. }
  9863. return getMethodFromProperties(Object.getPrototypeOf(properties));
  9864. }(typeof row == 'number' ? this.getCellMeta(row, col) : row);
  9865. };
  9866. }
  9867. /***/ }),
  9868. /* 65 */
  9869. /***/ (function(module, exports, __webpack_require__) {
  9870. "use strict";
  9871. exports.__esModule = true;
  9872. exports.columnFactory = columnFactory;
  9873. var _object = __webpack_require__(1);
  9874. /* eslint-disable import/prefer-default-export */
  9875. /**
  9876. * Factory for columns constructors.
  9877. *
  9878. * @param {Object} GridSettings
  9879. * @param {Array} conflictList
  9880. * @return {Object} ColumnSettings
  9881. */
  9882. function columnFactory(GridSettings, conflictList) {
  9883. function ColumnSettings() {};
  9884. (0, _object.inherit)(ColumnSettings, GridSettings);
  9885. // Clear conflict settings
  9886. for (var i = 0, len = conflictList.length; i < len; i++) {
  9887. ColumnSettings.prototype[conflictList[i]] = void 0;
  9888. }
  9889. return ColumnSettings;
  9890. }
  9891. /***/ }),
  9892. /* 66 */
  9893. /***/ (function(module, exports, __webpack_require__) {
  9894. "use strict";
  9895. exports.__esModule = true;
  9896. 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; }; }();
  9897. var _element = __webpack_require__(0);
  9898. var _array = __webpack_require__(2);
  9899. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9900. /**
  9901. * @class GhostTable
  9902. * @util
  9903. */
  9904. var GhostTable = function () {
  9905. function GhostTable(hotInstance) {
  9906. _classCallCheck(this, GhostTable);
  9907. /**
  9908. * Handsontable instance.
  9909. *
  9910. * @type {Core}
  9911. */
  9912. this.hot = hotInstance;
  9913. /**
  9914. * Container element where every table will be injected.
  9915. *
  9916. * @type {HTMLElement|null}
  9917. */
  9918. this.container = null;
  9919. /**
  9920. * Flag which determine is table was injected to DOM.
  9921. *
  9922. * @type {Boolean}
  9923. */
  9924. this.injected = false;
  9925. /**
  9926. * Added rows collection.
  9927. *
  9928. * @type {Array}
  9929. */
  9930. this.rows = [];
  9931. /**
  9932. * Added columns collection.
  9933. *
  9934. * @type {Array}
  9935. */
  9936. this.columns = [];
  9937. /**
  9938. * Samples prepared for calculations.
  9939. *
  9940. * @type {Map}
  9941. * @default {null}
  9942. */
  9943. this.samples = null;
  9944. /**
  9945. * Ghost table settings.
  9946. *
  9947. * @type {Object}
  9948. * @default {Object}
  9949. */
  9950. this.settings = {
  9951. useHeaders: true
  9952. };
  9953. }
  9954. /**
  9955. * Add row.
  9956. *
  9957. * @param {Number} row Row index.
  9958. * @param {Map} samples Samples Map object.
  9959. */
  9960. _createClass(GhostTable, [{
  9961. key: 'addRow',
  9962. value: function addRow(row, samples) {
  9963. if (this.columns.length) {
  9964. throw new Error('Doesn\'t support multi-dimensional table');
  9965. }
  9966. if (!this.rows.length) {
  9967. this.container = this.createContainer(this.hot.rootElement.className);
  9968. }
  9969. var rowObject = { row: row };
  9970. this.rows.push(rowObject);
  9971. this.samples = samples;
  9972. this.table = this.createTable(this.hot.table.className);
  9973. this.table.colGroup.appendChild(this.createColGroupsCol());
  9974. this.table.tr.appendChild(this.createRow(row));
  9975. this.container.container.appendChild(this.table.fragment);
  9976. rowObject.table = this.table.table;
  9977. }
  9978. /**
  9979. * Add a row consisting of the column headers.
  9980. */
  9981. }, {
  9982. key: 'addColumnHeadersRow',
  9983. value: function addColumnHeadersRow(samples) {
  9984. if (this.hot.getColHeader(0) != null) {
  9985. var rowObject = { row: -1 };
  9986. this.rows.push(rowObject);
  9987. this.container = this.createContainer(this.hot.rootElement.className);
  9988. this.samples = samples;
  9989. this.table = this.createTable(this.hot.table.className);
  9990. this.table.colGroup.appendChild(this.createColGroupsCol());
  9991. this.table.tHead.appendChild(this.createColumnHeadersRow());
  9992. this.container.container.appendChild(this.table.fragment);
  9993. rowObject.table = this.table.table;
  9994. }
  9995. }
  9996. /**
  9997. * Add column.
  9998. *
  9999. * @param {Number} column Column index.
  10000. * @param {Map} samples Samples Map object.
  10001. */
  10002. }, {
  10003. key: 'addColumn',
  10004. value: function addColumn(column, samples) {
  10005. if (this.rows.length) {
  10006. throw new Error('Doesn\'t support multi-dimensional table');
  10007. }
  10008. if (!this.columns.length) {
  10009. this.container = this.createContainer(this.hot.rootElement.className);
  10010. }
  10011. var columnObject = { col: column };
  10012. this.columns.push(columnObject);
  10013. this.samples = samples;
  10014. this.table = this.createTable(this.hot.table.className);
  10015. if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
  10016. this.hot.view.appendColHeader(column, this.table.th);
  10017. }
  10018. this.table.tBody.appendChild(this.createCol(column));
  10019. this.container.container.appendChild(this.table.fragment);
  10020. columnObject.table = this.table.table;
  10021. }
  10022. /**
  10023. * Get calculated heights.
  10024. *
  10025. * @param {Function} callback Callback which will be fired for each calculated row.
  10026. */
  10027. }, {
  10028. key: 'getHeights',
  10029. value: function getHeights(callback) {
  10030. if (!this.injected) {
  10031. this.injectTable();
  10032. }
  10033. (0, _array.arrayEach)(this.rows, function (row) {
  10034. // -1 <- reduce border-top from table
  10035. callback(row.row, (0, _element.outerHeight)(row.table) - 1);
  10036. });
  10037. }
  10038. /**
  10039. * Get calculated widths.
  10040. *
  10041. * @param {Function} callback Callback which will be fired for each calculated column.
  10042. */
  10043. }, {
  10044. key: 'getWidths',
  10045. value: function getWidths(callback) {
  10046. if (!this.injected) {
  10047. this.injectTable();
  10048. }
  10049. (0, _array.arrayEach)(this.columns, function (column) {
  10050. callback(column.col, (0, _element.outerWidth)(column.table));
  10051. });
  10052. }
  10053. /**
  10054. * Set the Ghost Table settings to the provided object.
  10055. *
  10056. * @param {Object} settings New Ghost Table Settings
  10057. */
  10058. }, {
  10059. key: 'setSettings',
  10060. value: function setSettings(settings) {
  10061. this.settings = settings;
  10062. }
  10063. /**
  10064. * Set a single setting of the Ghost Table.
  10065. *
  10066. * @param {String} name Setting name.
  10067. * @param {*} value Setting value.
  10068. */
  10069. }, {
  10070. key: 'setSetting',
  10071. value: function setSetting(name, value) {
  10072. if (!this.settings) {
  10073. this.settings = {};
  10074. }
  10075. this.settings[name] = value;
  10076. }
  10077. /**
  10078. * Get the Ghost Table settings.
  10079. *
  10080. * @returns {Object|null}
  10081. */
  10082. }, {
  10083. key: 'getSettings',
  10084. value: function getSettings() {
  10085. return this.settings;
  10086. }
  10087. /**
  10088. * Get a single Ghost Table setting.
  10089. *
  10090. * @param {String} name
  10091. * @returns {Boolean|null}
  10092. */
  10093. }, {
  10094. key: 'getSetting',
  10095. value: function getSetting(name) {
  10096. if (this.settings) {
  10097. return this.settings[name];
  10098. }
  10099. return null;
  10100. }
  10101. /**
  10102. * Create colgroup col elements.
  10103. *
  10104. * @returns {DocumentFragment}
  10105. */
  10106. }, {
  10107. key: 'createColGroupsCol',
  10108. value: function createColGroupsCol() {
  10109. var _this = this;
  10110. var d = document;
  10111. var fragment = d.createDocumentFragment();
  10112. if (this.hot.hasRowHeaders()) {
  10113. fragment.appendChild(this.createColElement(-1));
  10114. }
  10115. this.samples.forEach(function (sample) {
  10116. (0, _array.arrayEach)(sample.strings, function (string) {
  10117. fragment.appendChild(_this.createColElement(string.col));
  10118. });
  10119. });
  10120. return fragment;
  10121. }
  10122. /**
  10123. * Create table row element.
  10124. *
  10125. * @param {Number} row Row index.
  10126. * @returns {DocumentFragment} Returns created table row elements.
  10127. */
  10128. }, {
  10129. key: 'createRow',
  10130. value: function createRow(row) {
  10131. var _this2 = this;
  10132. var d = document;
  10133. var fragment = d.createDocumentFragment();
  10134. var th = d.createElement('th');
  10135. if (this.hot.hasRowHeaders()) {
  10136. this.hot.view.appendRowHeader(row, th);
  10137. fragment.appendChild(th);
  10138. }
  10139. this.samples.forEach(function (sample) {
  10140. (0, _array.arrayEach)(sample.strings, function (string) {
  10141. var column = string.col;
  10142. var cellProperties = _this2.hot.getCellMeta(row, column);
  10143. cellProperties.col = column;
  10144. cellProperties.row = row;
  10145. var renderer = _this2.hot.getCellRenderer(cellProperties);
  10146. var td = d.createElement('td');
  10147. renderer(_this2.hot, td, row, column, _this2.hot.colToProp(column), string.value, cellProperties);
  10148. fragment.appendChild(td);
  10149. });
  10150. });
  10151. return fragment;
  10152. }
  10153. }, {
  10154. key: 'createColumnHeadersRow',
  10155. value: function createColumnHeadersRow() {
  10156. var _this3 = this;
  10157. var d = document;
  10158. var fragment = d.createDocumentFragment();
  10159. if (this.hot.hasRowHeaders()) {
  10160. var th = d.createElement('th');
  10161. this.hot.view.appendColHeader(-1, th);
  10162. fragment.appendChild(th);
  10163. }
  10164. this.samples.forEach(function (sample) {
  10165. (0, _array.arrayEach)(sample.strings, function (string) {
  10166. var column = string.col;
  10167. var th = d.createElement('th');
  10168. _this3.hot.view.appendColHeader(column, th);
  10169. fragment.appendChild(th);
  10170. });
  10171. });
  10172. return fragment;
  10173. }
  10174. /**
  10175. * Create table column elements.
  10176. *
  10177. * @param {Number} column Column index.
  10178. * @returns {DocumentFragment} Returns created column table column elements.
  10179. */
  10180. }, {
  10181. key: 'createCol',
  10182. value: function createCol(column) {
  10183. var _this4 = this;
  10184. var d = document;
  10185. var fragment = d.createDocumentFragment();
  10186. this.samples.forEach(function (sample) {
  10187. (0, _array.arrayEach)(sample.strings, function (string) {
  10188. var row = string.row;
  10189. var cellProperties = _this4.hot.getCellMeta(row, column);
  10190. cellProperties.col = column;
  10191. cellProperties.row = row;
  10192. var renderer = _this4.hot.getCellRenderer(cellProperties);
  10193. var td = d.createElement('td');
  10194. var tr = d.createElement('tr');
  10195. renderer(_this4.hot, td, row, column, _this4.hot.colToProp(column), string.value, cellProperties);
  10196. tr.appendChild(td);
  10197. fragment.appendChild(tr);
  10198. });
  10199. });
  10200. return fragment;
  10201. }
  10202. /**
  10203. * Remove table from document and reset internal state.
  10204. */
  10205. }, {
  10206. key: 'clean',
  10207. value: function clean() {
  10208. this.rows.length = 0;
  10209. this.rows[-1] = void 0;
  10210. this.columns.length = 0;
  10211. if (this.samples) {
  10212. this.samples.clear();
  10213. }
  10214. this.samples = null;
  10215. this.removeTable();
  10216. }
  10217. /**
  10218. * Inject generated table into document.
  10219. *
  10220. * @param {HTMLElement} [parent=null]
  10221. */
  10222. }, {
  10223. key: 'injectTable',
  10224. value: function injectTable() {
  10225. var parent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  10226. if (!this.injected) {
  10227. (parent || this.hot.rootElement).appendChild(this.container.fragment);
  10228. this.injected = true;
  10229. }
  10230. }
  10231. /**
  10232. * Remove table from document.
  10233. */
  10234. }, {
  10235. key: 'removeTable',
  10236. value: function removeTable() {
  10237. if (this.injected && this.container.container.parentNode) {
  10238. this.container.container.parentNode.removeChild(this.container.container);
  10239. this.container = null;
  10240. this.injected = false;
  10241. }
  10242. }
  10243. /**
  10244. * Create col element.
  10245. *
  10246. * @param {Number} column Column index.
  10247. * @returns {HTMLElement}
  10248. */
  10249. }, {
  10250. key: 'createColElement',
  10251. value: function createColElement(column) {
  10252. var d = document;
  10253. var col = d.createElement('col');
  10254. col.style.width = this.hot.view.wt.wtTable.getStretchedColumnWidth(column) + 'px';
  10255. return col;
  10256. }
  10257. /**
  10258. * Create table element.
  10259. *
  10260. * @param {String} className
  10261. * @returns {Object}
  10262. */
  10263. }, {
  10264. key: 'createTable',
  10265. value: function createTable() {
  10266. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  10267. var d = document;
  10268. var fragment = d.createDocumentFragment();
  10269. var table = d.createElement('table');
  10270. var tHead = d.createElement('thead');
  10271. var tBody = d.createElement('tbody');
  10272. var colGroup = d.createElement('colgroup');
  10273. var tr = d.createElement('tr');
  10274. var th = d.createElement('th');
  10275. if (this.isVertical()) {
  10276. table.appendChild(colGroup);
  10277. }
  10278. if (this.isHorizontal()) {
  10279. tr.appendChild(th);
  10280. tHead.appendChild(tr);
  10281. table.style.tableLayout = 'auto';
  10282. table.style.width = 'auto';
  10283. }
  10284. table.appendChild(tHead);
  10285. if (this.isVertical()) {
  10286. tBody.appendChild(tr);
  10287. }
  10288. table.appendChild(tBody);
  10289. (0, _element.addClass)(table, className);
  10290. fragment.appendChild(table);
  10291. return { fragment: fragment, table: table, tHead: tHead, tBody: tBody, colGroup: colGroup, tr: tr, th: th };
  10292. }
  10293. /**
  10294. * Create container for tables.
  10295. *
  10296. * @param {String} className
  10297. * @returns {Object}
  10298. */
  10299. }, {
  10300. key: 'createContainer',
  10301. value: function createContainer() {
  10302. var className = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  10303. var d = document;
  10304. var fragment = d.createDocumentFragment();
  10305. var container = d.createElement('div');
  10306. className = 'htGhostTable htAutoSize ' + className.trim();
  10307. (0, _element.addClass)(container, className);
  10308. fragment.appendChild(container);
  10309. return { fragment: fragment, container: container };
  10310. }
  10311. /**
  10312. * Checks if table is raised vertically (checking rows).
  10313. *
  10314. * @returns {Boolean}
  10315. */
  10316. }, {
  10317. key: 'isVertical',
  10318. value: function isVertical() {
  10319. return !!(this.rows.length && !this.columns.length);
  10320. }
  10321. /**
  10322. * Checks if table is raised horizontally (checking columns).
  10323. *
  10324. * @returns {Boolean}
  10325. */
  10326. }, {
  10327. key: 'isHorizontal',
  10328. value: function isHorizontal() {
  10329. return !!(this.columns.length && !this.rows.length);
  10330. }
  10331. }]);
  10332. return GhostTable;
  10333. }();
  10334. exports.default = GhostTable;
  10335. /***/ }),
  10336. /* 67 */
  10337. /***/ (function(module, exports, __webpack_require__) {
  10338. "use strict";
  10339. var addToUnscopables = __webpack_require__(37)
  10340. , step = __webpack_require__(167)
  10341. , Iterators = __webpack_require__(45)
  10342. , toIObject = __webpack_require__(23);
  10343. // 22.1.3.4 Array.prototype.entries()
  10344. // 22.1.3.13 Array.prototype.keys()
  10345. // 22.1.3.29 Array.prototype.values()
  10346. // 22.1.3.30 Array.prototype[@@iterator]()
  10347. module.exports = __webpack_require__(166)(Array, 'Array', function(iterated, kind){
  10348. this._t = toIObject(iterated); // target
  10349. this._i = 0; // next index
  10350. this._k = kind; // kind
  10351. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  10352. }, function(){
  10353. var O = this._t
  10354. , kind = this._k
  10355. , index = this._i++;
  10356. if(!O || index >= O.length){
  10357. this._t = undefined;
  10358. return step(1);
  10359. }
  10360. if(kind == 'keys' )return step(0, index);
  10361. if(kind == 'values')return step(0, O[index]);
  10362. return step(0, [index, O[index]]);
  10363. }, 'values');
  10364. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  10365. Iterators.Arguments = Iterators.Array;
  10366. addToUnscopables('keys');
  10367. addToUnscopables('values');
  10368. addToUnscopables('entries');
  10369. /***/ }),
  10370. /* 68 */
  10371. /***/ (function(module, exports, __webpack_require__) {
  10372. "use strict";
  10373. exports.__esModule = true;
  10374. 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; }; }();
  10375. var _coords = __webpack_require__(42);
  10376. var _coords2 = _interopRequireDefault(_coords);
  10377. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10378. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10379. /**
  10380. * A cell range is a set of exactly two CellCoords (that can be the same or different)
  10381. *
  10382. * @class CellRange
  10383. */
  10384. var CellRange = function () {
  10385. /**
  10386. * @param {CellCoords} highlight Used to draw bold border around a cell where selection was
  10387. * started and to edit the cell when you press Enter
  10388. * @param {CellCoords} from Usually the same as highlight, but in Excel there is distinction - one can change
  10389. * highlight within a selection
  10390. * @param {CellCoords} to End selection
  10391. */
  10392. function CellRange(highlight, from, to) {
  10393. _classCallCheck(this, CellRange);
  10394. this.highlight = highlight;
  10395. this.from = from;
  10396. this.to = to;
  10397. }
  10398. /**
  10399. * Checks if given coords are valid in context of a given Walkontable instance
  10400. *
  10401. * @param {Walkontable} wotInstance
  10402. * @returns {Boolean}
  10403. */
  10404. _createClass(CellRange, [{
  10405. key: 'isValid',
  10406. value: function isValid(wotInstance) {
  10407. return this.from.isValid(wotInstance) && this.to.isValid(wotInstance);
  10408. }
  10409. /**
  10410. * Checks if this cell range is restricted to one cell
  10411. *
  10412. * @returns {Boolean}
  10413. */
  10414. }, {
  10415. key: 'isSingle',
  10416. value: function isSingle() {
  10417. return this.from.row === this.to.row && this.from.col === this.to.col;
  10418. }
  10419. /**
  10420. * Returns selected range height (in number of rows)
  10421. *
  10422. * @returns {Number}
  10423. */
  10424. }, {
  10425. key: 'getHeight',
  10426. value: function getHeight() {
  10427. return Math.max(this.from.row, this.to.row) - Math.min(this.from.row, this.to.row) + 1;
  10428. }
  10429. /**
  10430. * Returns selected range width (in number of columns)
  10431. *
  10432. * @returns {Number}
  10433. */
  10434. }, {
  10435. key: 'getWidth',
  10436. value: function getWidth() {
  10437. return Math.max(this.from.col, this.to.col) - Math.min(this.from.col, this.to.col) + 1;
  10438. }
  10439. /**
  10440. * Checks if given cell coords is within `from` and `to` cell coords of this range
  10441. *
  10442. * @param {CellCoords} cellCoords
  10443. * @returns {Boolean}
  10444. */
  10445. }, {
  10446. key: 'includes',
  10447. value: function includes(cellCoords) {
  10448. var row = cellCoords.row,
  10449. col = cellCoords.col;
  10450. var topLeft = this.getTopLeftCorner();
  10451. var bottomRight = this.getBottomRightCorner();
  10452. return topLeft.row <= row && bottomRight.row >= row && topLeft.col <= col && bottomRight.col >= col;
  10453. }
  10454. /**
  10455. * Checks if given range is within of this range
  10456. *
  10457. * @param {CellRange} testedRange
  10458. * @returns {Boolean}
  10459. */
  10460. }, {
  10461. key: 'includesRange',
  10462. value: function includesRange(testedRange) {
  10463. return this.includes(testedRange.getTopLeftCorner()) && this.includes(testedRange.getBottomRightCorner());
  10464. }
  10465. /**
  10466. * Checks if given range is equal to this range
  10467. *
  10468. * @param {CellRange} testedRange
  10469. * @returns {Boolean}
  10470. */
  10471. }, {
  10472. key: 'isEqual',
  10473. value: function isEqual(testedRange) {
  10474. 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);
  10475. }
  10476. /**
  10477. * Checks if tested range overlaps with the range.
  10478. * Range A is considered to to be overlapping with range B if intersection of A and B or B and A is not empty.
  10479. *
  10480. * @param {CellRange} testedRange
  10481. * @returns {Boolean}
  10482. */
  10483. }, {
  10484. key: 'overlaps',
  10485. value: function overlaps(testedRange) {
  10486. return testedRange.isSouthEastOf(this.getTopLeftCorner()) && testedRange.isNorthWestOf(this.getBottomRightCorner());
  10487. }
  10488. /**
  10489. * @param {CellRange} testedCoords
  10490. * @returns {Boolean}
  10491. */
  10492. }, {
  10493. key: 'isSouthEastOf',
  10494. value: function isSouthEastOf(testedCoords) {
  10495. return this.getTopLeftCorner().isSouthEastOf(testedCoords) || this.getBottomRightCorner().isSouthEastOf(testedCoords);
  10496. }
  10497. /**
  10498. * @param {CellRange} testedCoords
  10499. * @returns {Boolean}
  10500. */
  10501. }, {
  10502. key: 'isNorthWestOf',
  10503. value: function isNorthWestOf(testedCoords) {
  10504. return this.getTopLeftCorner().isNorthWestOf(testedCoords) || this.getBottomRightCorner().isNorthWestOf(testedCoords);
  10505. }
  10506. /**
  10507. * Adds a cell to a range (only if exceeds corners of the range). Returns information if range was expanded
  10508. *
  10509. * @param {CellCoords} cellCoords
  10510. * @returns {Boolean}
  10511. */
  10512. }, {
  10513. key: 'expand',
  10514. value: function expand(cellCoords) {
  10515. var topLeft = this.getTopLeftCorner();
  10516. var bottomRight = this.getBottomRightCorner();
  10517. if (cellCoords.row < topLeft.row || cellCoords.col < topLeft.col || cellCoords.row > bottomRight.row || cellCoords.col > bottomRight.col) {
  10518. this.from = new _coords2.default(Math.min(topLeft.row, cellCoords.row), Math.min(topLeft.col, cellCoords.col));
  10519. this.to = new _coords2.default(Math.max(bottomRight.row, cellCoords.row), Math.max(bottomRight.col, cellCoords.col));
  10520. return true;
  10521. }
  10522. return false;
  10523. }
  10524. /**
  10525. * @param {CellRange} expandingRange
  10526. * @returns {Boolean}
  10527. */
  10528. }, {
  10529. key: 'expandByRange',
  10530. value: function expandByRange(expandingRange) {
  10531. if (this.includesRange(expandingRange) || !this.overlaps(expandingRange)) {
  10532. return false;
  10533. }
  10534. var topLeft = this.getTopLeftCorner();
  10535. var bottomRight = this.getBottomRightCorner();
  10536. var topRight = this.getTopRightCorner();
  10537. var bottomLeft = this.getBottomLeftCorner();
  10538. var expandingTopLeft = expandingRange.getTopLeftCorner();
  10539. var expandingBottomRight = expandingRange.getBottomRightCorner();
  10540. var resultTopRow = Math.min(topLeft.row, expandingTopLeft.row);
  10541. var resultTopCol = Math.min(topLeft.col, expandingTopLeft.col);
  10542. var resultBottomRow = Math.max(bottomRight.row, expandingBottomRight.row);
  10543. var resultBottomCol = Math.max(bottomRight.col, expandingBottomRight.col);
  10544. var finalFrom = new _coords2.default(resultTopRow, resultTopCol),
  10545. finalTo = new _coords2.default(resultBottomRow, resultBottomCol);
  10546. var isCorner = new CellRange(finalFrom, finalFrom, finalTo).isCorner(this.from, expandingRange),
  10547. onlyMerge = expandingRange.isEqual(new CellRange(finalFrom, finalFrom, finalTo));
  10548. if (isCorner && !onlyMerge) {
  10549. if (this.from.col > finalFrom.col) {
  10550. finalFrom.col = resultBottomCol;
  10551. finalTo.col = resultTopCol;
  10552. }
  10553. if (this.from.row > finalFrom.row) {
  10554. finalFrom.row = resultBottomRow;
  10555. finalTo.row = resultTopRow;
  10556. }
  10557. }
  10558. this.from = finalFrom;
  10559. this.to = finalTo;
  10560. return true;
  10561. }
  10562. /**
  10563. * @returns {String}
  10564. */
  10565. }, {
  10566. key: 'getDirection',
  10567. value: function getDirection() {
  10568. if (this.from.isNorthWestOf(this.to)) {
  10569. // NorthWest - SouthEast
  10570. return 'NW-SE';
  10571. } else if (this.from.isNorthEastOf(this.to)) {
  10572. // NorthEast - SouthWest
  10573. return 'NE-SW';
  10574. } else if (this.from.isSouthEastOf(this.to)) {
  10575. // SouthEast - NorthWest
  10576. return 'SE-NW';
  10577. } else if (this.from.isSouthWestOf(this.to)) {
  10578. // SouthWest - NorthEast
  10579. return 'SW-NE';
  10580. }
  10581. }
  10582. /**
  10583. * @param {String} direction
  10584. */
  10585. }, {
  10586. key: 'setDirection',
  10587. value: function setDirection(direction) {
  10588. switch (direction) {
  10589. case 'NW-SE':
  10590. var _ref = [this.getTopLeftCorner(), this.getBottomRightCorner()];
  10591. this.from = _ref[0];
  10592. this.to = _ref[1];
  10593. break;
  10594. case 'NE-SW':
  10595. var _ref2 = [this.getTopRightCorner(), this.getBottomLeftCorner()];
  10596. this.from = _ref2[0];
  10597. this.to = _ref2[1];
  10598. break;
  10599. case 'SE-NW':
  10600. var _ref3 = [this.getBottomRightCorner(), this.getTopLeftCorner()];
  10601. this.from = _ref3[0];
  10602. this.to = _ref3[1];
  10603. break;
  10604. case 'SW-NE':
  10605. var _ref4 = [this.getBottomLeftCorner(), this.getTopRightCorner()];
  10606. this.from = _ref4[0];
  10607. this.to = _ref4[1];
  10608. break;
  10609. default:
  10610. break;
  10611. }
  10612. }
  10613. /**
  10614. * Get top left corner of this range
  10615. *
  10616. * @returns {CellCoords}
  10617. */
  10618. }, {
  10619. key: 'getTopLeftCorner',
  10620. value: function getTopLeftCorner() {
  10621. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  10622. }
  10623. /**
  10624. * Get bottom right corner of this range
  10625. *
  10626. * @returns {CellCoords}
  10627. */
  10628. }, {
  10629. key: 'getBottomRightCorner',
  10630. value: function getBottomRightCorner() {
  10631. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  10632. }
  10633. /**
  10634. * Get top right corner of this range
  10635. *
  10636. * @returns {CellCoords}
  10637. */
  10638. }, {
  10639. key: 'getTopRightCorner',
  10640. value: function getTopRightCorner() {
  10641. return new _coords2.default(Math.min(this.from.row, this.to.row), Math.max(this.from.col, this.to.col));
  10642. }
  10643. /**
  10644. * Get bottom left corner of this range
  10645. *
  10646. * @returns {CellCoords}
  10647. */
  10648. }, {
  10649. key: 'getBottomLeftCorner',
  10650. value: function getBottomLeftCorner() {
  10651. return new _coords2.default(Math.max(this.from.row, this.to.row), Math.min(this.from.col, this.to.col));
  10652. }
  10653. /**
  10654. * @param {CellCoords} coords
  10655. * @param {CellRange} expandedRange
  10656. * @returns {*}
  10657. */
  10658. }, {
  10659. key: 'isCorner',
  10660. value: function isCorner(coords, expandedRange) {
  10661. if (expandedRange) {
  10662. if (expandedRange.includes(coords)) {
  10663. 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))) {
  10664. return true;
  10665. }
  10666. }
  10667. }
  10668. return coords.isEqual(this.getTopLeftCorner()) || coords.isEqual(this.getTopRightCorner()) || coords.isEqual(this.getBottomLeftCorner()) || coords.isEqual(this.getBottomRightCorner());
  10669. }
  10670. /**
  10671. * @param {CellCoords} coords
  10672. * @param {CellRange} expandedRange
  10673. * @returns {CellCoords}
  10674. */
  10675. }, {
  10676. key: 'getOppositeCorner',
  10677. value: function getOppositeCorner(coords, expandedRange) {
  10678. if (!(coords instanceof _coords2.default)) {
  10679. return false;
  10680. }
  10681. if (expandedRange) {
  10682. if (expandedRange.includes(coords)) {
  10683. if (this.getTopLeftCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.from.col))) {
  10684. return this.getBottomRightCorner();
  10685. }
  10686. if (this.getTopRightCorner().isEqual(new _coords2.default(expandedRange.from.row, expandedRange.to.col))) {
  10687. return this.getBottomLeftCorner();
  10688. }
  10689. if (this.getBottomLeftCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.from.col))) {
  10690. return this.getTopRightCorner();
  10691. }
  10692. if (this.getBottomRightCorner().isEqual(new _coords2.default(expandedRange.to.row, expandedRange.to.col))) {
  10693. return this.getTopLeftCorner();
  10694. }
  10695. }
  10696. }
  10697. if (coords.isEqual(this.getBottomRightCorner())) {
  10698. return this.getTopLeftCorner();
  10699. } else if (coords.isEqual(this.getTopLeftCorner())) {
  10700. return this.getBottomRightCorner();
  10701. } else if (coords.isEqual(this.getTopRightCorner())) {
  10702. return this.getBottomLeftCorner();
  10703. } else if (coords.isEqual(this.getBottomLeftCorner())) {
  10704. return this.getTopRightCorner();
  10705. }
  10706. }
  10707. /**
  10708. * @param {CellRange} range
  10709. * @returns {Array}
  10710. */
  10711. }, {
  10712. key: 'getBordersSharedWith',
  10713. value: function getBordersSharedWith(range) {
  10714. if (!this.includesRange(range)) {
  10715. return [];
  10716. }
  10717. var thisBorders = {
  10718. top: Math.min(this.from.row, this.to.row),
  10719. bottom: Math.max(this.from.row, this.to.row),
  10720. left: Math.min(this.from.col, this.to.col),
  10721. right: Math.max(this.from.col, this.to.col)
  10722. };
  10723. var rangeBorders = {
  10724. top: Math.min(range.from.row, range.to.row),
  10725. bottom: Math.max(range.from.row, range.to.row),
  10726. left: Math.min(range.from.col, range.to.col),
  10727. right: Math.max(range.from.col, range.to.col)
  10728. };
  10729. var result = [];
  10730. if (thisBorders.top == rangeBorders.top) {
  10731. result.push('top');
  10732. }
  10733. if (thisBorders.right == rangeBorders.right) {
  10734. result.push('right');
  10735. }
  10736. if (thisBorders.bottom == rangeBorders.bottom) {
  10737. result.push('bottom');
  10738. }
  10739. if (thisBorders.left == rangeBorders.left) {
  10740. result.push('left');
  10741. }
  10742. return result;
  10743. }
  10744. /**
  10745. * Get inner selected cell coords defined by this range
  10746. *
  10747. * @returns {Array}
  10748. */
  10749. }, {
  10750. key: 'getInner',
  10751. value: function getInner() {
  10752. var topLeft = this.getTopLeftCorner();
  10753. var bottomRight = this.getBottomRightCorner();
  10754. var out = [];
  10755. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  10756. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  10757. if (!(this.from.row === r && this.from.col === c) && !(this.to.row === r && this.to.col === c)) {
  10758. out.push(new _coords2.default(r, c));
  10759. }
  10760. }
  10761. }
  10762. return out;
  10763. }
  10764. /**
  10765. * Get all selected cell coords defined by this range
  10766. *
  10767. * @returns {Array}
  10768. */
  10769. }, {
  10770. key: 'getAll',
  10771. value: function getAll() {
  10772. var topLeft = this.getTopLeftCorner();
  10773. var bottomRight = this.getBottomRightCorner();
  10774. var out = [];
  10775. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  10776. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  10777. if (topLeft.row === r && topLeft.col === c) {
  10778. out.push(topLeft);
  10779. } else if (bottomRight.row === r && bottomRight.col === c) {
  10780. out.push(bottomRight);
  10781. } else {
  10782. out.push(new _coords2.default(r, c));
  10783. }
  10784. }
  10785. }
  10786. return out;
  10787. }
  10788. /**
  10789. * Runs a callback function against all cells in the range. You can break the iteration by returning
  10790. * `false` in the callback function
  10791. *
  10792. * @param callback {Function}
  10793. */
  10794. }, {
  10795. key: 'forAll',
  10796. value: function forAll(callback) {
  10797. var topLeft = this.getTopLeftCorner();
  10798. var bottomRight = this.getBottomRightCorner();
  10799. for (var r = topLeft.row; r <= bottomRight.row; r++) {
  10800. for (var c = topLeft.col; c <= bottomRight.col; c++) {
  10801. var breakIteration = callback(r, c);
  10802. if (breakIteration === false) {
  10803. return;
  10804. }
  10805. }
  10806. }
  10807. }
  10808. }]);
  10809. return CellRange;
  10810. }();
  10811. exports.default = CellRange;
  10812. /***/ }),
  10813. /* 69 */
  10814. /***/ (function(module, exports, __webpack_require__) {
  10815. "use strict";
  10816. exports.__esModule = true;
  10817. var _array = __webpack_require__(2);
  10818. var _object = __webpack_require__(1);
  10819. var MIXIN_NAME = 'localHooks';
  10820. /**
  10821. * Mixin object to extend objects functionality for local hooks.
  10822. *
  10823. * @type {Object}
  10824. */
  10825. var localHooks = {
  10826. /**
  10827. * Internal hooks storage.
  10828. */
  10829. _localHooks: Object.create(null),
  10830. /**
  10831. * Add hook to the collection.
  10832. *
  10833. * @param {String} key Hook name.
  10834. * @param {Function} callback Hook callback
  10835. */
  10836. addLocalHook: function addLocalHook(key, callback) {
  10837. if (!this._localHooks[key]) {
  10838. this._localHooks[key] = [];
  10839. }
  10840. this._localHooks[key].push(callback);
  10841. },
  10842. /**
  10843. * Run hooks.
  10844. *
  10845. * @param {String} key Hook name.
  10846. * @param {*} params
  10847. */
  10848. runLocalHooks: function runLocalHooks(key) {
  10849. var _this = this;
  10850. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  10851. params[_key - 1] = arguments[_key];
  10852. }
  10853. if (this._localHooks[key]) {
  10854. (0, _array.arrayEach)(this._localHooks[key], function (callback) {
  10855. return callback.apply(_this, params);
  10856. });
  10857. }
  10858. },
  10859. /**
  10860. * Clear all added hooks.
  10861. */
  10862. clearLocalHooks: function clearLocalHooks() {
  10863. this._localHooks = {};
  10864. }
  10865. };
  10866. (0, _object.defineGetter)(localHooks, 'MIXIN_NAME', MIXIN_NAME, {
  10867. writable: false,
  10868. enumerable: false
  10869. });
  10870. exports.default = localHooks;
  10871. /***/ }),
  10872. /* 70 */
  10873. /***/ (function(module, exports, __webpack_require__) {
  10874. "use strict";
  10875. exports.__esModule = true;
  10876. 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;
  10877. var _predefinedItems2;
  10878. var _alignment = __webpack_require__(223);
  10879. Object.defineProperty(exports, 'ALIGNMENT', {
  10880. enumerable: true,
  10881. get: function get() {
  10882. return _alignment.KEY;
  10883. }
  10884. });
  10885. var _clearColumn = __webpack_require__(224);
  10886. Object.defineProperty(exports, 'CLEAR_COLUMN', {
  10887. enumerable: true,
  10888. get: function get() {
  10889. return _clearColumn.KEY;
  10890. }
  10891. });
  10892. var _columnLeft = __webpack_require__(225);
  10893. Object.defineProperty(exports, 'COLUMN_LEFT', {
  10894. enumerable: true,
  10895. get: function get() {
  10896. return _columnLeft.KEY;
  10897. }
  10898. });
  10899. var _columnRight = __webpack_require__(226);
  10900. Object.defineProperty(exports, 'COLUMN_RIGHT', {
  10901. enumerable: true,
  10902. get: function get() {
  10903. return _columnRight.KEY;
  10904. }
  10905. });
  10906. var _readOnly = __webpack_require__(227);
  10907. Object.defineProperty(exports, 'READ_ONLY', {
  10908. enumerable: true,
  10909. get: function get() {
  10910. return _readOnly.KEY;
  10911. }
  10912. });
  10913. var _redo = __webpack_require__(228);
  10914. Object.defineProperty(exports, 'REDO', {
  10915. enumerable: true,
  10916. get: function get() {
  10917. return _redo.KEY;
  10918. }
  10919. });
  10920. var _removeColumn = __webpack_require__(229);
  10921. Object.defineProperty(exports, 'REMOVE_COLUMN', {
  10922. enumerable: true,
  10923. get: function get() {
  10924. return _removeColumn.KEY;
  10925. }
  10926. });
  10927. var _removeRow = __webpack_require__(230);
  10928. Object.defineProperty(exports, 'REMOVE_ROW', {
  10929. enumerable: true,
  10930. get: function get() {
  10931. return _removeRow.KEY;
  10932. }
  10933. });
  10934. var _rowAbove = __webpack_require__(231);
  10935. Object.defineProperty(exports, 'ROW_ABOVE', {
  10936. enumerable: true,
  10937. get: function get() {
  10938. return _rowAbove.KEY;
  10939. }
  10940. });
  10941. var _rowBelow = __webpack_require__(232);
  10942. Object.defineProperty(exports, 'ROW_BELOW', {
  10943. enumerable: true,
  10944. get: function get() {
  10945. return _rowBelow.KEY;
  10946. }
  10947. });
  10948. var _separator = __webpack_require__(71);
  10949. Object.defineProperty(exports, 'SEPARATOR', {
  10950. enumerable: true,
  10951. get: function get() {
  10952. return _separator.KEY;
  10953. }
  10954. });
  10955. var _undo = __webpack_require__(233);
  10956. Object.defineProperty(exports, 'UNDO', {
  10957. enumerable: true,
  10958. get: function get() {
  10959. return _undo.KEY;
  10960. }
  10961. });
  10962. exports.predefinedItems = predefinedItems;
  10963. exports.addItem = addItem;
  10964. var _object = __webpack_require__(1);
  10965. var _alignment2 = _interopRequireDefault(_alignment);
  10966. var _clearColumn2 = _interopRequireDefault(_clearColumn);
  10967. var _columnLeft2 = _interopRequireDefault(_columnLeft);
  10968. var _columnRight2 = _interopRequireDefault(_columnRight);
  10969. var _readOnly2 = _interopRequireDefault(_readOnly);
  10970. var _redo2 = _interopRequireDefault(_redo);
  10971. var _removeColumn2 = _interopRequireDefault(_removeColumn);
  10972. var _removeRow2 = _interopRequireDefault(_removeRow);
  10973. var _rowAbove2 = _interopRequireDefault(_rowAbove);
  10974. var _rowBelow2 = _interopRequireDefault(_rowBelow);
  10975. var _separator2 = _interopRequireDefault(_separator);
  10976. var _undo2 = _interopRequireDefault(_undo);
  10977. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10978. 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; }
  10979. 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];
  10980. 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);
  10981. /**
  10982. * Gets new object with all predefined menu items.
  10983. *
  10984. * @returns {Object}
  10985. */
  10986. function predefinedItems() {
  10987. var items = {};
  10988. (0, _object.objectEach)(_predefinedItems, function (itemFactory, key) {
  10989. items[key] = itemFactory();
  10990. });
  10991. return items;
  10992. }
  10993. /**
  10994. * Add new predefined menu item to the collection.
  10995. *
  10996. * @param {String} key Menu command id.
  10997. * @param {Object} item Object command descriptor.
  10998. */
  10999. function addItem(key, item) {
  11000. if (ITEMS.indexOf(key) === -1) {
  11001. _predefinedItems[key] = item;
  11002. }
  11003. }
  11004. /***/ }),
  11005. /* 71 */
  11006. /***/ (function(module, exports, __webpack_require__) {
  11007. "use strict";
  11008. exports.__esModule = true;
  11009. exports.default = separatorItem;
  11010. var KEY = exports.KEY = '---------';
  11011. function separatorItem() {
  11012. return {
  11013. name: KEY
  11014. };
  11015. }
  11016. /***/ }),
  11017. /* 72 */
  11018. /***/ (function(module, exports) {
  11019. module.exports = function(it){
  11020. if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  11021. return it;
  11022. };
  11023. /***/ }),
  11024. /* 73 */
  11025. /***/ (function(module, exports, __webpack_require__) {
  11026. "use strict";
  11027. var $defineProperty = __webpack_require__(19)
  11028. , createDesc = __webpack_require__(40);
  11029. module.exports = function(object, index, value){
  11030. if(index in object)$defineProperty.f(object, index, createDesc(0, value));
  11031. else object[index] = value;
  11032. };
  11033. /***/ }),
  11034. /* 74 */
  11035. /***/ (function(module, exports, __webpack_require__) {
  11036. var isObject = __webpack_require__(15)
  11037. , document = __webpack_require__(13).document
  11038. // in old IE typeof document.createElement is 'object'
  11039. , is = isObject(document) && isObject(document.createElement);
  11040. module.exports = function(it){
  11041. return is ? document.createElement(it) : {};
  11042. };
  11043. /***/ }),
  11044. /* 75 */
  11045. /***/ (function(module, exports) {
  11046. // IE 8- don't enum bug keys
  11047. module.exports = (
  11048. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  11049. ).split(',');
  11050. /***/ }),
  11051. /* 76 */
  11052. /***/ (function(module, exports, __webpack_require__) {
  11053. var MATCH = __webpack_require__(10)('match');
  11054. module.exports = function(KEY){
  11055. var re = /./;
  11056. try {
  11057. '/./'[KEY](re);
  11058. } catch(e){
  11059. try {
  11060. re[MATCH] = false;
  11061. return !'/./'[KEY](re);
  11062. } catch(f){ /* empty */ }
  11063. } return true;
  11064. };
  11065. /***/ }),
  11066. /* 77 */
  11067. /***/ (function(module, exports, __webpack_require__) {
  11068. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  11069. var cof = __webpack_require__(38);
  11070. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
  11071. return cof(it) == 'String' ? it.split('') : Object(it);
  11072. };
  11073. /***/ }),
  11074. /* 78 */
  11075. /***/ (function(module, exports, __webpack_require__) {
  11076. var ITERATOR = __webpack_require__(10)('iterator')
  11077. , SAFE_CLOSING = false;
  11078. try {
  11079. var riter = [7][ITERATOR]();
  11080. riter['return'] = function(){ SAFE_CLOSING = true; };
  11081. Array.from(riter, function(){ throw 2; });
  11082. } catch(e){ /* empty */ }
  11083. module.exports = function(exec, skipClosing){
  11084. if(!skipClosing && !SAFE_CLOSING)return false;
  11085. var safe = false;
  11086. try {
  11087. var arr = [7]
  11088. , iter = arr[ITERATOR]();
  11089. iter.next = function(){ return {done: safe = true}; };
  11090. arr[ITERATOR] = function(){ return iter; };
  11091. exec(arr);
  11092. } catch(e){ /* empty */ }
  11093. return safe;
  11094. };
  11095. /***/ }),
  11096. /* 79 */
  11097. /***/ (function(module, exports, __webpack_require__) {
  11098. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  11099. var anObject = __webpack_require__(18)
  11100. , dPs = __webpack_require__(288)
  11101. , enumBugKeys = __webpack_require__(75)
  11102. , IE_PROTO = __webpack_require__(82)('IE_PROTO')
  11103. , Empty = function(){ /* empty */ }
  11104. , PROTOTYPE = 'prototype';
  11105. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  11106. var createDict = function(){
  11107. // Thrash, waste and sodomy: IE GC bug
  11108. var iframe = __webpack_require__(74)('iframe')
  11109. , i = enumBugKeys.length
  11110. , lt = '<'
  11111. , gt = '>'
  11112. , iframeDocument;
  11113. iframe.style.display = 'none';
  11114. __webpack_require__(159).appendChild(iframe);
  11115. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  11116. // createDict = iframe.contentWindow.Object;
  11117. // html.removeChild(iframe);
  11118. iframeDocument = iframe.contentWindow.document;
  11119. iframeDocument.open();
  11120. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  11121. iframeDocument.close();
  11122. createDict = iframeDocument.F;
  11123. while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
  11124. return createDict();
  11125. };
  11126. module.exports = Object.create || function create(O, Properties){
  11127. var result;
  11128. if(O !== null){
  11129. Empty[PROTOTYPE] = anObject(O);
  11130. result = new Empty;
  11131. Empty[PROTOTYPE] = null;
  11132. // add "__proto__" for Object.getPrototypeOf polyfill
  11133. result[IE_PROTO] = O;
  11134. } else result = createDict();
  11135. return Properties === undefined ? result : dPs(result, Properties);
  11136. };
  11137. /***/ }),
  11138. /* 80 */
  11139. /***/ (function(module, exports, __webpack_require__) {
  11140. var pIE = __webpack_require__(47)
  11141. , createDesc = __webpack_require__(40)
  11142. , toIObject = __webpack_require__(23)
  11143. , toPrimitive = __webpack_require__(86)
  11144. , has = __webpack_require__(22)
  11145. , IE8_DOM_DEFINE = __webpack_require__(160)
  11146. , gOPD = Object.getOwnPropertyDescriptor;
  11147. exports.f = __webpack_require__(21) ? gOPD : function getOwnPropertyDescriptor(O, P){
  11148. O = toIObject(O);
  11149. P = toPrimitive(P, true);
  11150. if(IE8_DOM_DEFINE)try {
  11151. return gOPD(O, P);
  11152. } catch(e){ /* empty */ }
  11153. if(has(O, P))return createDesc(!pIE.f.call(O, P), O[P]);
  11154. };
  11155. /***/ }),
  11156. /* 81 */
  11157. /***/ (function(module, exports, __webpack_require__) {
  11158. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  11159. var $keys = __webpack_require__(169)
  11160. , hiddenKeys = __webpack_require__(75).concat('length', 'prototype');
  11161. exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O){
  11162. return $keys(O, hiddenKeys);
  11163. };
  11164. /***/ }),
  11165. /* 82 */
  11166. /***/ (function(module, exports, __webpack_require__) {
  11167. var shared = __webpack_require__(83)('keys')
  11168. , uid = __webpack_require__(49);
  11169. module.exports = function(key){
  11170. return shared[key] || (shared[key] = uid(key));
  11171. };
  11172. /***/ }),
  11173. /* 83 */
  11174. /***/ (function(module, exports, __webpack_require__) {
  11175. var global = __webpack_require__(13)
  11176. , SHARED = '__core-js_shared__'
  11177. , store = global[SHARED] || (global[SHARED] = {});
  11178. module.exports = function(key){
  11179. return store[key] || (store[key] = {});
  11180. };
  11181. /***/ }),
  11182. /* 84 */
  11183. /***/ (function(module, exports, __webpack_require__) {
  11184. // helper for String#{startsWith, endsWith, includes}
  11185. var isRegExp = __webpack_require__(164)
  11186. , defined = __webpack_require__(30);
  11187. module.exports = function(that, searchString, NAME){
  11188. if(isRegExp(searchString))throw TypeError('String#' + NAME + " doesn't accept regex!");
  11189. return String(defined(that));
  11190. };
  11191. /***/ }),
  11192. /* 85 */
  11193. /***/ (function(module, exports, __webpack_require__) {
  11194. var ctx = __webpack_require__(29)
  11195. , invoke = __webpack_require__(284)
  11196. , html = __webpack_require__(159)
  11197. , cel = __webpack_require__(74)
  11198. , global = __webpack_require__(13)
  11199. , process = global.process
  11200. , setTask = global.setImmediate
  11201. , clearTask = global.clearImmediate
  11202. , MessageChannel = global.MessageChannel
  11203. , counter = 0
  11204. , queue = {}
  11205. , ONREADYSTATECHANGE = 'onreadystatechange'
  11206. , defer, channel, port;
  11207. var run = function(){
  11208. var id = +this;
  11209. if(queue.hasOwnProperty(id)){
  11210. var fn = queue[id];
  11211. delete queue[id];
  11212. fn();
  11213. }
  11214. };
  11215. var listener = function(event){
  11216. run.call(event.data);
  11217. };
  11218. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  11219. if(!setTask || !clearTask){
  11220. setTask = function setImmediate(fn){
  11221. var args = [], i = 1;
  11222. while(arguments.length > i)args.push(arguments[i++]);
  11223. queue[++counter] = function(){
  11224. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  11225. };
  11226. defer(counter);
  11227. return counter;
  11228. };
  11229. clearTask = function clearImmediate(id){
  11230. delete queue[id];
  11231. };
  11232. // Node.js 0.8-
  11233. if(__webpack_require__(38)(process) == 'process'){
  11234. defer = function(id){
  11235. process.nextTick(ctx(run, id, 1));
  11236. };
  11237. // Browsers with MessageChannel, includes WebWorkers
  11238. } else if(MessageChannel){
  11239. channel = new MessageChannel;
  11240. port = channel.port2;
  11241. channel.port1.onmessage = listener;
  11242. defer = ctx(port.postMessage, port, 1);
  11243. // Browsers with postMessage, skip WebWorkers
  11244. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  11245. } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
  11246. defer = function(id){
  11247. global.postMessage(id + '', '*');
  11248. };
  11249. global.addEventListener('message', listener, false);
  11250. // IE8-
  11251. } else if(ONREADYSTATECHANGE in cel('script')){
  11252. defer = function(id){
  11253. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
  11254. html.removeChild(this);
  11255. run.call(id);
  11256. };
  11257. };
  11258. // Rest old browsers
  11259. } else {
  11260. defer = function(id){
  11261. setTimeout(ctx(run, id, 1), 0);
  11262. };
  11263. }
  11264. }
  11265. module.exports = {
  11266. set: setTask,
  11267. clear: clearTask
  11268. };
  11269. /***/ }),
  11270. /* 86 */
  11271. /***/ (function(module, exports, __webpack_require__) {
  11272. // 7.1.1 ToPrimitive(input [, PreferredType])
  11273. var isObject = __webpack_require__(15);
  11274. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  11275. // and the second argument - flag - preferred type is a string
  11276. module.exports = function(it, S){
  11277. if(!isObject(it))return it;
  11278. var fn, val;
  11279. if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  11280. if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
  11281. if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  11282. throw TypeError("Can't convert object to primitive value");
  11283. };
  11284. /***/ }),
  11285. /* 87 */
  11286. /***/ (function(module, exports) {
  11287. module.exports = __WEBPACK_EXTERNAL_MODULE_87__;
  11288. /***/ }),
  11289. /* 88 */
  11290. /***/ (function(module, exports, __webpack_require__) {
  11291. "use strict";
  11292. exports.__esModule = true;
  11293. 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; };
  11294. var _mixed = __webpack_require__(20);
  11295. var _object = __webpack_require__(1);
  11296. /**
  11297. * @alias Options
  11298. * @constructor
  11299. * @description
  11300. * ## Constructor options
  11301. *
  11302. * Constructor options are applied using an object literal passed as a second argument to the Handsontable constructor.
  11303. *
  11304. * ```js
  11305. * var hot = new Handsontable(document.getElementById('example1'), {
  11306. * data: myArray,
  11307. * width: 400,
  11308. * height: 300
  11309. * });
  11310. * ```
  11311. *
  11312. * ---
  11313. * ## Cascading configuration
  11314. *
  11315. * Handsontable 0.9 and newer is using *Cascading Configuration*, which is a fast way to provide configuration options
  11316. * for the entire table, including its columns and particular cells.
  11317. *
  11318. * Consider the following example:
  11319. * ```js
  11320. * var hot = new Handsontable(document.getElementById('example'), {
  11321. * readOnly: true,
  11322. * columns: [
  11323. * {readOnly: false},
  11324. * {},
  11325. * {}
  11326. * ],
  11327. * cells: function (row, col, prop) {
  11328. * var cellProperties = {};
  11329. *
  11330. * if (row === 0 && col === 0) {
  11331. * cellProperties.readOnly = true;
  11332. * }
  11333. *
  11334. * return cellProperties;
  11335. * }
  11336. * });
  11337. * ```
  11338. *
  11339. * 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*.
  11340. *
  11341. * ### The Cascading Configuration model
  11342. *
  11343. * ##### 1. Constructor
  11344. *
  11345. * Configuration options that are provided using first-level `handsontable(container, {option: "value"})` and `updateSettings` method.
  11346. *
  11347. * ##### 2. Columns
  11348. *
  11349. * Configuration options that are provided using second-level object `handsontable(container, {columns: {option: "value"}]})`
  11350. *
  11351. * ##### 3. Cells
  11352. *
  11353. * Configuration options that are provided using second-level function `handsontable(container, {cells: function: (row, col, prop){ }})`
  11354. *
  11355. * ---
  11356. * ## Architecture performance
  11357. *
  11358. * The Cascading Configuration model is based on prototypical inheritance. It is much faster and memory efficient compared
  11359. * to the previous model that used jQuery extend. See: [http://jsperf.com/extending-settings](http://jsperf.com/extending-settings).
  11360. *
  11361. * ---
  11362. * __Important notice:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  11363. */
  11364. function DefaultSettings() {};
  11365. DefaultSettings.prototype = {
  11366. /**
  11367. * @description
  11368. * Initial data source that will be bound to the data grid __by reference__ (editing data grid alters the data source).
  11369. * Can be declared as an Array of Arrays, Array of Objects or a Function.
  11370. *
  11371. * See [Understanding binding as reference](http://docs.handsontable.com/tutorial-data-binding.html#page-reference).
  11372. *
  11373. * @type {Array|Function}
  11374. * @default undefined
  11375. */
  11376. data: void 0,
  11377. /**
  11378. * @description
  11379. * Defines the structure of a new row when data source is an array of objects.
  11380. *
  11381. * See [data-schema](http://docs.handsontable.com/tutorial-data-sources.html#page-data-schema) for examples.
  11382. *
  11383. * @type {Object}
  11384. * @default undefined
  11385. */
  11386. dataSchema: void 0,
  11387. /**
  11388. * Width of the grid. Can be a value or a function that returns a value.
  11389. *
  11390. * @type {Number|Function}
  11391. * @default undefined
  11392. */
  11393. width: void 0,
  11394. /**
  11395. * Height of the grid. Can be a number or a function that returns a number.
  11396. *
  11397. * @type {Number|Function}
  11398. * @default undefined
  11399. */
  11400. height: void 0,
  11401. /**
  11402. * @description
  11403. * Initial number of rows.
  11404. *
  11405. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  11406. *
  11407. * @type {Number}
  11408. * @default 5
  11409. */
  11410. startRows: 5,
  11411. /**
  11412. * @description
  11413. * Initial number of columns.
  11414. *
  11415. * __Notice:__ This option only has effect in Handsontable constructor and only if `data` option is not provided
  11416. *
  11417. * @type {Number}
  11418. * @default 5
  11419. */
  11420. startCols: 5,
  11421. /**
  11422. * Setting `true` or `false` will enable or disable the default row headers (1, 2, 3).
  11423. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  11424. * If a function is set the index of the row is passed as a parameter.
  11425. *
  11426. * @type {Boolean|Array|Function}
  11427. * @default null
  11428. * @example
  11429. * ```js
  11430. * ...
  11431. * // as boolean
  11432. * rowHeaders: true,
  11433. * ...
  11434. *
  11435. * ...
  11436. * // as array
  11437. * rowHeaders: [1, 2, 3],
  11438. * ...
  11439. *
  11440. * ...
  11441. * // as function
  11442. * rowHeaders: function(index) {
  11443. * return index + ': AB';
  11444. * },
  11445. * ...
  11446. * ```
  11447. */
  11448. rowHeaders: void 0,
  11449. /**
  11450. * Setting `true` or `false` will enable or disable the default column headers (A, B, C).
  11451. * You can also define an array `['One', 'Two', 'Three', ...]` or a function to define the headers.
  11452. * If a function is set, then the index of the column is passed as a parameter.
  11453. *
  11454. * @type {Boolean|Array|Function}
  11455. * @default null
  11456. * @example
  11457. * ```js
  11458. * ...
  11459. * // as boolean
  11460. * colHeaders: true,
  11461. * ...
  11462. *
  11463. * ...
  11464. * // as array
  11465. * colHeaders: ['A', 'B', 'C'],
  11466. * ...
  11467. *
  11468. * ...
  11469. * // as function
  11470. * colHeaders: function(index) {
  11471. * return index + ': AB';
  11472. * },
  11473. * ...
  11474. * ```
  11475. */
  11476. colHeaders: null,
  11477. /**
  11478. * Defines column widths in pixels. Accepts number, string (that will be converted to a number),
  11479. * array of numbers (if you want to define column width separately for each column) or a
  11480. * function (if you want to set column width dynamically on each render).
  11481. *
  11482. * @type {Array|Function|Number|String}
  11483. * @default undefined
  11484. * @example
  11485. * ```js
  11486. * ...
  11487. * // as numeric, for each column.
  11488. * colWidths: 100,
  11489. * ...
  11490. *
  11491. * * ...
  11492. * // as string, for each column.
  11493. * colWidths: '100px',
  11494. * ...
  11495. *
  11496. * ...
  11497. * // as array, based on visual indexes. The rest of the columns have a default width.
  11498. * colWidths: [100, 120, 90],
  11499. * ...
  11500. *
  11501. * ...
  11502. * // as function, based on visual indexes.
  11503. * colWidths: function(index) {
  11504. * return index * 10;
  11505. * },
  11506. * ...
  11507. * ```
  11508. */
  11509. colWidths: void 0,
  11510. /**
  11511. * Defines row heights in pixels. Accepts numbers, strings (that will be converted into a number),
  11512. * array of numbers (if you want to define row height separately for each row) or a
  11513. * function (if you want to set row height dynamically on each render).
  11514. * If the ManualRowResize or AutoRowSize plugins are enabled, this is also the minimum height that can be set
  11515. * via either of those two plugins.
  11516. * Height should be equal or greater than 23px. Table is rendered incorrectly if height is less than 23px.
  11517. *
  11518. * @type {Array|Function|Number|String}
  11519. * @default undefined
  11520. * @example
  11521. * ```js
  11522. * ...
  11523. * // as numeric, for each row.
  11524. * rowHeights: 100,
  11525. * ...
  11526. *
  11527. * * ...
  11528. * // as string, for each row.
  11529. * rowHeights: '100px',
  11530. * ...
  11531. *
  11532. * ...
  11533. * // as array, based on visual indexes. The rest of the rows have a default height.
  11534. * rowHeights: [100, 120, 90],
  11535. * ...
  11536. *
  11537. * ...
  11538. * // as function, based on visual indexes.
  11539. * rowHeights: function(index) {
  11540. * return index * 10;
  11541. * },
  11542. * ...
  11543. * ```
  11544. */
  11545. rowHeights: void 0,
  11546. /**
  11547. * @description
  11548. * Defines the cell properties and data binding for certain columns.
  11549. *
  11550. * __Notice:__ Using this option sets a fixed number of columns (options `startCols`, `minCols`, `maxCols` will be ignored).
  11551. *
  11552. * See [documentation -> datasources.html](http://docs.handsontable.com/tutorial-data-sources.html#page-nested) for examples.
  11553. *
  11554. * @type {Array|Function}
  11555. * @default undefined
  11556. * @example
  11557. * ```js
  11558. * ...
  11559. * // as an array of objects. Order of the objects in array is representation of physical indexes.
  11560. * columns: [
  11561. * {
  11562. * // column options for the first column
  11563. * type: 'numeric',
  11564. * format: '0,0.00 $'
  11565. * },
  11566. * {
  11567. * // column options for the second column
  11568. * type: 'text',
  11569. * readOnly: true
  11570. * }
  11571. * ],
  11572. * ...
  11573. *
  11574. * // or as function, based on physical indexes
  11575. * ...
  11576. * columns: function(index) {
  11577. * return {
  11578. * type: index > 0 ? 'numeric' : 'text',
  11579. * readOnly: index < 1
  11580. * }
  11581. * }
  11582. * ...
  11583. * ```
  11584. */
  11585. columns: void 0,
  11586. /**
  11587. * @description
  11588. * Defines the cell properties for given `row`, `col`, `prop` coordinates.
  11589. * Any constructor or column option may be overwritten for a particular cell (row/column combination)
  11590. * using the `cells` property in the Handsontable constructor.
  11591. *
  11592. * __Note:__ Parameters `row` and `col` always represent __physical indexes__. Example below show how to execute
  11593. * operations based on the __visual__ representation of Handsontable.
  11594. *
  11595. * Possible values of `prop`:
  11596. * - property name for column's data source object, when dataset is an [array of objects](/tutorial-data-sources.html#page-object)
  11597. * - the same number as `col`, when dataset is an [array of arrays](/tutorial-data-sources.html#page-array)
  11598. *
  11599. * @type {Function}
  11600. * @default undefined
  11601. * @example
  11602. * ```js
  11603. * ...
  11604. * cells: function (row, col, prop) {
  11605. * var cellProperties = {};
  11606. * var visualRowIndex = this.instance.toVisualRow(row);
  11607. * var visualColIndex = this.instance.toVisualColumn(col);
  11608. *
  11609. * if (visualRowIndex === 0 && visualColIndex === 0) {
  11610. * cellProperties.readOnly = true;
  11611. * }
  11612. *
  11613. * return cellProperties;
  11614. * },
  11615. * ...
  11616. * ```
  11617. */
  11618. cells: void 0,
  11619. /**
  11620. * Any constructor or column option may be overwritten for a particular cell (row/column combination), using `cell`
  11621. * array passed to the Handsontable constructor.
  11622. *
  11623. * @type {Array}
  11624. * @default []
  11625. * @example
  11626. * ```js
  11627. * ...
  11628. * cell: [
  11629. * {row: 0, col: 0, readOnly: true}
  11630. * ],
  11631. * ...
  11632. * ```
  11633. */
  11634. cell: [],
  11635. /**
  11636. * @description
  11637. * If `true`, enables the {@link Comments} plugin, which enables an option to apply cell comments through the context menu
  11638. * (configurable with context menu keys `commentsAddEdit`, `commentsRemove`).
  11639. *
  11640. * To initialize Handsontable with predefined comments, provide cell coordinates and comment text values in a form of an array.
  11641. *
  11642. * See [Comments](http://docs.handsontable.com/demo-comments_.html) demo for examples.
  11643. *
  11644. * @since 0.11.0
  11645. * @type {Boolean|Array}
  11646. * @default false
  11647. * @example
  11648. * ```js
  11649. * ...
  11650. * comments: [{row: 1, col: 1, comment: {value: "Test comment"}}],
  11651. * ...
  11652. * ```
  11653. */
  11654. comments: false,
  11655. /**
  11656. * @description
  11657. * 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`).
  11658. *
  11659. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  11660. *
  11661. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for examples.
  11662. *
  11663. * @since 0.11.0
  11664. * @type {Boolean|Array}
  11665. * @default false
  11666. * @example
  11667. * ```js
  11668. * ...
  11669. * customBorders: [
  11670. * {range: {
  11671. * from: {row: 1, col: 1},
  11672. * to: {row: 3, col: 4}},
  11673. * left: {},
  11674. * right: {},
  11675. * top: {},
  11676. * bottom: {}
  11677. * }
  11678. * ],
  11679. * ...
  11680. *
  11681. * // or
  11682. * ...
  11683. * customBorders: [
  11684. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  11685. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  11686. * ],
  11687. * ...
  11688. * ```
  11689. */
  11690. customBorders: false,
  11691. /**
  11692. * Minimum number of rows. At least that number of rows will be created during initialization.
  11693. *
  11694. * @type {Number}
  11695. * @default 0
  11696. */
  11697. minRows: 0,
  11698. /**
  11699. * Minimum number of columns. At least that number of columns will be created during initialization.
  11700. *
  11701. * @type {Number}
  11702. * @default 0
  11703. */
  11704. minCols: 0,
  11705. /**
  11706. * 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.
  11707. *
  11708. * @type {Number}
  11709. * @default Infinity
  11710. */
  11711. maxRows: Infinity,
  11712. /**
  11713. * 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.
  11714. *
  11715. * @type {Number}
  11716. * @default Infinity
  11717. */
  11718. maxCols: Infinity,
  11719. /**
  11720. * When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
  11721. * (unless the number of rows exceeds the one set in the `maxRows` property)
  11722. *
  11723. * @type {Number}
  11724. * @default 0
  11725. */
  11726. minSpareRows: 0,
  11727. /**
  11728. * When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
  11729. * (unless the number of rows exceeds the one set in the `maxCols` property)
  11730. *
  11731. * @type {Number}
  11732. * @default 0
  11733. */
  11734. minSpareCols: 0,
  11735. /**
  11736. * If set to `false`, there won't be an option to insert new rows in the Context Menu.
  11737. *
  11738. * @type {Boolean}
  11739. * @default true
  11740. */
  11741. allowInsertRow: true,
  11742. /**
  11743. * If set to `false`, there won't be an option to insert new columns in the Context Menu.
  11744. *
  11745. * @type {Boolean}
  11746. * @default true
  11747. */
  11748. allowInsertColumn: true,
  11749. /**
  11750. * If set to `false`, there won't be an option to remove rows in the Context Menu.
  11751. *
  11752. * @type {Boolean}
  11753. * @default true
  11754. */
  11755. allowRemoveRow: true,
  11756. /**
  11757. * If set to `false`, there won't be an option to remove columns in the Context Menu.
  11758. *
  11759. * @type {Boolean}
  11760. * @default true
  11761. */
  11762. allowRemoveColumn: true,
  11763. /**
  11764. * If true, selection of multiple cells using keyboard or mouse is allowed.
  11765. *
  11766. * @type {Boolean}
  11767. * @default true
  11768. */
  11769. multiSelect: true,
  11770. /**
  11771. * Enables the fill handle (drag-down and copy-down) functionality, which shows a small rectangle in bottom
  11772. * right corner of the selected area, that let's you expand values to the adjacent cells.
  11773. *
  11774. * Possible values: `true` (to enable in all directions), `'vertical'` or `'horizontal'` (to enable in one direction),
  11775. * `false` (to disable completely). Setting to `true` enables the fillHandle plugin.
  11776. *
  11777. * Since 0.23.0 you can pass object to plugin which allows you to add more options for this functionality. If `autoInsertRow`
  11778. * option is `true`, fill-handler will create new rows till it reaches the last row. It is enabled by default.
  11779. *
  11780. * @example
  11781. * ```js
  11782. * ...
  11783. * fillHandle: true // enable plugin in all directions and with autoInsertRow as true
  11784. * ...
  11785. * // or
  11786. * ...
  11787. * fillHandle: 'vertical' // enable plugin in vertical direction and with autoInsertRow as true
  11788. * ...
  11789. * // or
  11790. * ...
  11791. * fillHandle: { // enable plugin in both directions and with autoInsertRow as false
  11792. * autoInsertRow: false,
  11793. * }
  11794. * // or
  11795. * ...
  11796. * fillHandle: { // enable plugin in vertical direction and with autoInsertRow as false
  11797. * autoInsertRow: false,
  11798. * direction: 'vertical' // 'vertical' or 'horizontal'
  11799. * }
  11800. * ```
  11801. *
  11802. * @type {Boolean|String|Object}
  11803. * @default true
  11804. */
  11805. fillHandle: true,
  11806. /**
  11807. * Allows to specify the number of fixed (or *frozen*) rows at the top of the table.
  11808. *
  11809. * @type {Number}
  11810. * @default 0
  11811. * @example
  11812. * ```js
  11813. * fixedRowsTop: 3 // This would freeze the top 3 rows of the table.
  11814. * ```
  11815. */
  11816. fixedRowsTop: 0,
  11817. /**
  11818. * Allows to specify the number of fixed (or *frozen*) rows at the bottom of the table.
  11819. *
  11820. * @pro
  11821. * @type {Number}
  11822. * @default 0
  11823. * @example
  11824. * ```js
  11825. * fixedRowsBottom: 3 // This would freeze the top 3 rows of the table.
  11826. * ```
  11827. */
  11828. fixedRowsBottom: 0,
  11829. /**
  11830. * Allows to specify the number of fixed (or *frozen*) columns on the left of the table.
  11831. *
  11832. * @type {Number}
  11833. * @default 0
  11834. * @example
  11835. * ```js
  11836. * fixedColumnsLeft: 3 // This would freeze the top 3 rows of the table.
  11837. * ```
  11838. */
  11839. fixedColumnsLeft: 0,
  11840. /**
  11841. * If `true`, mouse click outside the grid will deselect the current selection.
  11842. * Can be a function that takes the click event target and returns a boolean.
  11843. *
  11844. * @type {Boolean|Function}
  11845. * @default true
  11846. */
  11847. outsideClickDeselects: true,
  11848. /**
  11849. * If `true`, <kbd>ENTER</kbd> begins editing mode (like in Google Docs). If `false`, <kbd>ENTER</kbd> moves to next
  11850. * row (like Excel) and adds a new row if necessary. <kbd>TAB</kbd> adds new column if necessary.
  11851. *
  11852. * @type {Boolean}
  11853. * @default true
  11854. */
  11855. enterBeginsEditing: true,
  11856. /**
  11857. * Defines the cursor movement after <kbd>ENTER</kbd> was pressed (<kbd>SHIFT</kbd> + <kbd>ENTER</kbd> uses a negative vector).
  11858. * Can be an object or a function that returns an object. The event argument passed to the function
  11859. * is a DOM Event object received after the <kbd>ENTER</kbd> key has been pressed. This event object can be used to check
  11860. * whether user pressed <kbd>ENTER</kbd> or <kbd>SHIFT</kbd> + <kbd>ENTER</kbd>.
  11861. *
  11862. * @type {Object|Function}
  11863. * @default {row: 1, col: 0}
  11864. */
  11865. enterMoves: { row: 1, col: 0 },
  11866. /**
  11867. * Defines the cursor movement after <kbd>TAB</kbd> is pressed (<kbd>SHIFT</kbd> + <kbd>TAB</kbd> uses a negative vector).
  11868. * Can be an object or a function that returns an object. The event argument passed to the function
  11869. * is a DOM Event object received after the <kbd>TAB</kbd> key has been pressed. This event object can be used to check
  11870. * whether user pressed <kbd>TAB</kbd> or <kbd>SHIFT</kbd> + <kbd>TAB</kbd>.
  11871. *
  11872. * @type {Object}
  11873. * @default {row: 0, col: 1}
  11874. */
  11875. tabMoves: { row: 0, col: 1 },
  11876. /**
  11877. * If `true`, pressing <kbd>TAB</kbd> or right arrow in the last column will move to first column in next row.
  11878. *
  11879. * @type {Boolean}
  11880. * @default false
  11881. */
  11882. autoWrapRow: false,
  11883. /**
  11884. * If `true`, pressing <kbd>ENTER</kbd> or down arrow in the last row will move to the first row in the next column.
  11885. *
  11886. * @type {Boolean}
  11887. * @default false
  11888. */
  11889. autoWrapCol: false,
  11890. /**
  11891. * @description
  11892. * Turns on saving the state of column sorting, column positions and column sizes in local storage.
  11893. *
  11894. * You can save any sort of data in local storage to preserve table state between page reloads.
  11895. * In order to enable data storage mechanism, `persistentState` option must be set to `true` (you can set it
  11896. * either during Handsontable initialization or using the `updateSettings` method). When `persistentState` is enabled it exposes 3 hooks:
  11897. *
  11898. * __persistentStateSave__ (key: String, value: Mixed)
  11899. *
  11900. * * Saves value under given key in browser local storage.
  11901. *
  11902. * __persistentStateLoad__ (key: String, valuePlaceholder: Object)
  11903. *
  11904. * * Loads `value`, saved under given key, form browser local storage. The loaded `value` will be saved in `valuePlaceholder.value`
  11905. * (this is due to specific behaviour of `Hooks.run()` method). If no value have been saved under key `valuePlaceholder.value`
  11906. * will be `undefined`.
  11907. *
  11908. * __persistentStateReset__ (key: String)
  11909. *
  11910. * * Clears the value saved under `key`. If no `key` is given, all values associated with table will be cleared.
  11911. *
  11912. * __Note:__ The main reason behind using `persistentState` hooks rather than regular LocalStorage API is that it
  11913. * ensures separation of data stored by multiple Handsontable instances. In other words, if you have two (or more)
  11914. * instances of Handsontable on one page, data saved by one instance won't be accessible by the second instance.
  11915. * Those two instances can store data under the same key and no data would be overwritten.
  11916. *
  11917. * __Important:__ In order for the data separation to work properly, make sure that each instance of Handsontable has a unique `id`.
  11918. *
  11919. * @type {Boolean}
  11920. * @default false
  11921. */
  11922. persistentState: void 0,
  11923. /**
  11924. * Class name for all visible rows in the current selection.
  11925. *
  11926. * @type {String}
  11927. * @default undefined
  11928. * @example
  11929. * ```js
  11930. * currentRowClassName: 'currentRow' // This will add a 'currentRow' class name to appropriate table cells.
  11931. * ```
  11932. */
  11933. currentRowClassName: void 0,
  11934. /**
  11935. * Class name for all visible columns in the current selection.
  11936. *
  11937. * @type {String}
  11938. * @default undefined
  11939. * @example
  11940. * ```js
  11941. * currentColClassName: 'currentColumn' // This will add a 'currentColumn' class name to appropriate table cells.
  11942. * ```
  11943. */
  11944. currentColClassName: void 0,
  11945. /**
  11946. * Class name for all visible headers in current selection.
  11947. *
  11948. * @type {String}
  11949. * @since 0.27.0
  11950. * @default 'ht__highlight'
  11951. * @example
  11952. * ```js
  11953. * currentHeaderClassName: 'ht__highlight' // This will add a 'ht__highlight' class name to appropriate table headers.
  11954. * ```
  11955. */
  11956. currentHeaderClassName: 'ht__highlight',
  11957. /**
  11958. * Class name for the Handsontable container element.
  11959. *
  11960. * @type {String|Array}
  11961. * @default undefined
  11962. */
  11963. className: void 0,
  11964. /**
  11965. * Class name for all tables inside container element.
  11966. *
  11967. * @since 0.17.0
  11968. * @type {String|Array}
  11969. * @default undefined
  11970. */
  11971. tableClassName: void 0,
  11972. /**
  11973. * @description
  11974. * Defines how the columns react, when the declared table width is different than the calculated sum of all column widths.
  11975. * [See more](http://docs.handsontable.com/demo-stretching.html) mode. Possible values:
  11976. * * `'none'` Disable stretching
  11977. * * `'last'` Stretch only the last column
  11978. * * `'all'` Stretch all the columns evenly
  11979. *
  11980. * @type {String}
  11981. * @default 'none'
  11982. */
  11983. stretchH: 'none',
  11984. /**
  11985. * Lets you overwrite the default `isEmptyRow` method, which checks if row at the provided index is empty.
  11986. *
  11987. * @type {Function}
  11988. * @param {Number} row Visual row index.
  11989. * @returns {Boolean}
  11990. */
  11991. isEmptyRow: function isEmptyRow(row) {
  11992. var col, colLen, value, meta;
  11993. for (col = 0, colLen = this.countCols(); col < colLen; col++) {
  11994. value = this.getDataAtCell(row, col);
  11995. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  11996. if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {
  11997. meta = this.getCellMeta(row, col);
  11998. return (0, _object.isObjectEquals)(this.getSchema()[meta.prop], value);
  11999. }
  12000. return false;
  12001. }
  12002. }
  12003. return true;
  12004. },
  12005. /**
  12006. * Lets you overwrite the default `isEmptyCol` method, which checks if column at the provided index is empty.
  12007. *
  12008. * @type {Function}
  12009. * @param {Number} col Visual column index
  12010. * @returns {Boolean}
  12011. */
  12012. isEmptyCol: function isEmptyCol(col) {
  12013. var row, rowLen, value;
  12014. for (row = 0, rowLen = this.countRows(); row < rowLen; row++) {
  12015. value = this.getDataAtCell(row, col);
  12016. if (value !== '' && value !== null && (0, _mixed.isDefined)(value)) {
  12017. return false;
  12018. }
  12019. }
  12020. return true;
  12021. },
  12022. /**
  12023. * When set to `true`, the table is re-rendered when it is detected that it was made visible in DOM.
  12024. *
  12025. * @type {Boolean}
  12026. * @default true
  12027. */
  12028. observeDOMVisibility: true,
  12029. /**
  12030. * If set to `true`, Handsontable will accept values that were marked as invalid by the cell `validator`.
  12031. * It will result with *invalid* cells being treated as *valid* (will save the *invalid* value into the Handsontable data source).
  12032. * If set to `false`, Handsontable will *not* accept the invalid values and won't allow the user to close the editor.
  12033. * This option will be particularly useful when used with the Autocomplete's `strict` mode.
  12034. *
  12035. * @type {Boolean}
  12036. * @default true
  12037. * @since 0.9.5
  12038. */
  12039. allowInvalid: true,
  12040. /**
  12041. * If set to `true`, Handsontable will accept values that are empty (`null`, `undefined` or `''`).
  12042. * If set to `false`, Handsontable will *not* accept the empty values and mark cell as invalid.
  12043. *
  12044. * @example
  12045. * ```js
  12046. * ...
  12047. * allowEmpty: true // allow empty values for all cells (whole table)
  12048. * ...
  12049. * // or
  12050. * ...
  12051. * columns: [
  12052. * // allow empty values only for 'date' column
  12053. * {data: 'date', dateFormat: 'DD/MM/YYYY', allowEmpty: true}
  12054. * ]
  12055. * ...
  12056. * ```
  12057. *
  12058. * @type {Boolean}
  12059. * @default true
  12060. * @since 0.23.0
  12061. */
  12062. allowEmpty: true,
  12063. /**
  12064. * CSS class name for cells that did not pass validation.
  12065. *
  12066. * @type {String}
  12067. * @default 'htInvalid'
  12068. */
  12069. invalidCellClassName: 'htInvalid',
  12070. /**
  12071. * When set to an non-empty string, displayed as the cell content for empty cells. If a value of a different type is provided,
  12072. * it will be stringified and applied as a string.
  12073. *
  12074. * @type {Mixed}
  12075. * @default false
  12076. */
  12077. placeholder: false,
  12078. /**
  12079. * CSS class name for cells that have a placeholder in use.
  12080. *
  12081. * @type {String}
  12082. * @default 'htPlaceholder'
  12083. */
  12084. placeholderCellClassName: 'htPlaceholder',
  12085. /**
  12086. * CSS class name for read-only cells.
  12087. *
  12088. * @type {String}
  12089. * @default 'htDimmed'
  12090. */
  12091. readOnlyCellClassName: 'htDimmed',
  12092. /**
  12093. * @description
  12094. * If a string is provided, it may be one of the following predefined values:
  12095. * * `autocomplete`,
  12096. * * `checkbox`,
  12097. * * `html`,
  12098. * * `numeric`,
  12099. * * `password`.
  12100. * * `text`.
  12101. *
  12102. * Or you can [register](http://docs.handsontable.com/demo-custom-renderers.html) the custom renderer under specified name and use
  12103. * its name as an alias in your configuration.
  12104. *
  12105. * If a function is provided, it will receive the following arguments:
  12106. * ```js
  12107. * function(instance, TD, row, col, prop, value, cellProperties) {}
  12108. * ```
  12109. *
  12110. * You can read more about custom renderes [in the documentation](http://docs.handsontable.com/demo-custom-renderers.html).
  12111. *
  12112. * @example
  12113. * ```js
  12114. * ...
  12115. * Handsontable.renderers.registerRenderer('my.renderer', function(instance, TD, row, col, prop, value, cellProperties) {
  12116. * TD.innerHTML = value;
  12117. * });
  12118. * ...
  12119. * columns: [
  12120. * {
  12121. * editor: 'select',
  12122. * renderer: 'autocomplete' // as string
  12123. * },
  12124. * {
  12125. * renderer: 'my.renderer' // custom renderer as an alias
  12126. * },
  12127. * {
  12128. * // renderer as custom function
  12129. * renderer: function(hotInstance, TD, row, col, prop, value, cellProperties) {
  12130. * TD.style.color = 'blue';
  12131. * TD.innerHTML = value;
  12132. * }
  12133. * }
  12134. * ]
  12135. * ...
  12136. * ```
  12137. *
  12138. * @type {String|Function}
  12139. * @default undefined
  12140. */
  12141. renderer: void 0,
  12142. /**
  12143. * CSS class name added to the commented cells.
  12144. *
  12145. * @type {String}
  12146. * @default 'htCommentCell'
  12147. */
  12148. commentedCellClassName: 'htCommentCell',
  12149. /**
  12150. * 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.
  12151. * If set to `'cell'`, it enables the possibility of selecting a fragment of the text within a single cell's body.
  12152. *
  12153. * @type {Boolean|String}
  12154. * @default false
  12155. */
  12156. fragmentSelection: false,
  12157. /**
  12158. * @description
  12159. * Make cell [read only](http://docs.handsontable.com/demo-read-only.html).
  12160. *
  12161. * @type {Boolean}
  12162. * @default false
  12163. */
  12164. readOnly: false,
  12165. /**
  12166. * @description
  12167. * When added to a `column` property, it skips the column on paste and pastes the data on the next column to the right.
  12168. *
  12169. * @type {Boolean}
  12170. * @default false
  12171. */
  12172. skipColumnOnPaste: false,
  12173. /**
  12174. * @description
  12175. * Setting to true enables the search plugin (see [demo](http://docs.handsontable.com/demo-search-for-values.html)).
  12176. *
  12177. * @type {Boolean}
  12178. * @default false
  12179. */
  12180. search: false,
  12181. /**
  12182. * @description
  12183. * Shortcut to define the combination of the cell renderer, editor and validator for the column, cell or whole table.
  12184. *
  12185. * Possible values:
  12186. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  12187. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  12188. * * [date](http://docs.handsontable.com/demo-date.html)
  12189. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  12190. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  12191. * * [numeric](http://docs.handsontable.com/demo-numeric.html)
  12192. * * [password](http://docs.handsontable.com/demo-password.html)
  12193. * * text
  12194. * * [time](http://docs.handsontable.com/demo-time.html)
  12195. *
  12196. * Or you can register the custom cell type under specified name and use
  12197. * its name as an alias in your configuration.
  12198. *
  12199. * @example
  12200. * ```js
  12201. * ...
  12202. * Handsontable.cellTypes.registerCellType('my.type', {
  12203. * editor: MyEditorClass,
  12204. * renderer: function(hot, td, row, col, prop, value, cellProperties) {
  12205. * td.innerHTML = value;
  12206. * },
  12207. * validator: function(value, callback) {
  12208. * callback(value === 'foo' ? true : false);
  12209. * }
  12210. * });
  12211. * ...
  12212. * columns: [
  12213. * {
  12214. * type: 'text'
  12215. * },
  12216. * {
  12217. * type: 'my.type' // an alias to custom type
  12218. * },
  12219. * {
  12220. * type: 'checkbox'
  12221. * }
  12222. * ]
  12223. * ...
  12224. * ```
  12225. *
  12226. * @type {String}
  12227. * @default 'text'
  12228. */
  12229. type: 'text',
  12230. /**
  12231. * @description
  12232. * Make cell copyable (pressing <kbd>CTRL</kbd> + <kbd>C</kbd> on your keyboard moves its value to system clipboard).
  12233. *
  12234. * __Note:__ this setting is `false` by default for cells with type `password`.
  12235. *
  12236. * @type {Boolean}
  12237. * @default true
  12238. * @since 0.10.2
  12239. */
  12240. copyable: true,
  12241. /**
  12242. * Defines the editor for the table/column/cell.
  12243. *
  12244. * If a string is provided, it may be one of the following predefined values:
  12245. * * [autocomplete](http://docs.handsontable.com/demo-autocomplete.html)
  12246. * * [checkbox](http://docs.handsontable.com/demo-checkbox.html)
  12247. * * [date](http://docs.handsontable.com/demo-date.html)
  12248. * * [dropdown](http://docs.handsontable.com/demo-dropdown.html)
  12249. * * [handsontable](http://docs.handsontable.com/demo-handsontable.html)
  12250. * * [mobile](http://docs.handsontable.com/demo-mobiles-and-tablets.html)
  12251. * * [password](http://docs.handsontable.com/demo-password.html)
  12252. * * [select](http://docs.handsontable.com/demo-select.html)
  12253. * * text
  12254. *
  12255. * Or you can [register](http://docs.handsontable.com/tutorial-cell-editor.html#registering-an-editor) the custom editor under specified name and use
  12256. * its name as an alias in your configuration.
  12257. *
  12258. * To disable cell editing completely set `editor` property to `false`.
  12259. *
  12260. * @example
  12261. * ```js
  12262. * ...
  12263. * columns: [
  12264. * {
  12265. * editor: 'select'
  12266. * },
  12267. * {
  12268. * editor: false
  12269. * }
  12270. * ]
  12271. * ...
  12272. * ```
  12273. *
  12274. * @type {String|Function|Boolean}
  12275. * @default 'text'
  12276. */
  12277. editor: void 0,
  12278. /**
  12279. * @description
  12280. * Autocomplete definitions. See [autocomplete demo](http://docs.handsontable.com/demo-autocomplete.html) for examples and definitions.
  12281. *
  12282. * @type {Array}
  12283. * @default undefined
  12284. */
  12285. autoComplete: void 0,
  12286. /**
  12287. * Control number of choices for the autocomplete (or dropdown) typed cells. After exceeding it, a scrollbar for the dropdown list of choices will appear.
  12288. *
  12289. * @since 0.18.0
  12290. * @type {Number}
  12291. * @default 10
  12292. */
  12293. visibleRows: 10,
  12294. /**
  12295. * Makes autocomplete or dropdown width the same as the edited cell width. If `false` then editor will be scaled
  12296. * according to its content.
  12297. *
  12298. * @since 0.17.0
  12299. * @type {Boolean}
  12300. * @default true
  12301. */
  12302. trimDropdown: true,
  12303. /**
  12304. * Setting to true enables the debug mode, currently used to test the correctness of the row and column
  12305. * header fixed positioning on a layer above the master table.
  12306. *
  12307. * @type {Boolean}
  12308. * @default false
  12309. */
  12310. debug: false,
  12311. /**
  12312. * When set to `true`, the text of the cell content is wrapped if it does not fit in the fixed column width.
  12313. *
  12314. * @type {Boolean}
  12315. * @default true
  12316. * @since 0.11.0
  12317. */
  12318. wordWrap: true,
  12319. /**
  12320. * CSS class name added to cells with cell meta `wordWrap: false`.
  12321. *
  12322. * @type {String}
  12323. * @default 'htNoWrap'
  12324. * @since 0.11.0
  12325. */
  12326. noWordWrapClassName: 'htNoWrap',
  12327. /**
  12328. * @description
  12329. * Defines if the right-click context menu should be enabled. Context menu allows to create new row or
  12330. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  12331. * Possible values:
  12332. * * `true` (to enable default options),
  12333. * * `false` (to disable completely)
  12334. * * an array of [predefined options](https://docs.handsontable.com/demo-context-menu.html#page-specific),
  12335. * * an object [with defined structure](http://docs.handsontable.com/demo-context-menu.html#page-custom)
  12336. *
  12337. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  12338. *
  12339. * @example
  12340. * ```js
  12341. * ...
  12342. * // as a boolean
  12343. * contextMenu: true
  12344. * ...
  12345. * // as an array
  12346. * contextMenu: ['row_above', 'row_below', '--------', 'undo', 'redo']
  12347. * ...
  12348. * ```
  12349. * ...
  12350. * // as an object (`name` attribute is required in the custom keys)
  12351. * contextMenu: {
  12352. * items: {
  12353. * "option1": {
  12354. * name: "option1"
  12355. * },
  12356. * "option2": {
  12357. * name: "option2",
  12358. * submenu: {
  12359. * items: [
  12360. * {
  12361. * key: "option2:suboption1",
  12362. * name: "option2:suboption1",
  12363. * callback: function(key, options) {
  12364. * ...
  12365. * }
  12366. * },
  12367. * ...
  12368. * ]
  12369. * }
  12370. * }
  12371. * }
  12372. * }
  12373. * ...
  12374. * ```
  12375. * @type {Boolean|Array|Object}
  12376. * @default undefined
  12377. */
  12378. contextMenu: void 0,
  12379. /**
  12380. * @description
  12381. * Disable or enable the copy/paste functionality.
  12382. *
  12383. * @example
  12384. * ```js
  12385. * ...
  12386. * copyPaste: false,
  12387. * ...
  12388. * ```
  12389. *
  12390. * @type {Boolean}
  12391. * @default true
  12392. */
  12393. copyPaste: true,
  12394. /**
  12395. * If `true`, undo/redo functionality is enabled.
  12396. *
  12397. * @type {Boolean}
  12398. * @default undefined
  12399. */
  12400. undo: void 0,
  12401. /**
  12402. * @description
  12403. * Turns on [Column sorting](http://docs.handsontable.com/demo-sorting-data.html).
  12404. * Can be either a boolean (true/false) or an object with a declared sorting options. See the below example:
  12405. *
  12406. * @example
  12407. * ```js
  12408. * ...
  12409. * // as boolean
  12410. * columnSorting: true
  12411. * ...
  12412. * // as a object with initial order (sort ascending column at index 2)
  12413. * columnSorting: {
  12414. * column: 2,
  12415. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  12416. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  12417. * }
  12418. * ...
  12419. * ```
  12420. *
  12421. * @type {Boolean|Object}
  12422. * @default undefined
  12423. */
  12424. columnSorting: void 0,
  12425. /**
  12426. * @description
  12427. * Turns on [Manual column move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  12428. * column order, if set to an array of column indexes.
  12429. *
  12430. * @example
  12431. * ```js
  12432. * ...
  12433. * // as boolean
  12434. * manualColumnMove: true
  12435. * ...
  12436. * // as a array with initial order (move column index at 0 to 1 and move column index at 1 to 4)
  12437. * manualColumnMove: [1, 4]
  12438. * ...
  12439. * ```
  12440. *
  12441. * @type {Boolean|Array}
  12442. * @default undefined
  12443. */
  12444. manualColumnMove: void 0,
  12445. /**
  12446. * @description
  12447. * Turns on [Manual column resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  12448. * column resized widths, if set to an array of numbers.
  12449. *
  12450. * @example
  12451. * ```js
  12452. * ...
  12453. * // as boolean
  12454. * manualColumnResize: true
  12455. * ...
  12456. * // as a array with initial widths (column at 0 index has 40px and column at 1 index has 50px)
  12457. * manualColumnResize: [40, 50]
  12458. * ...
  12459. * ```
  12460. *
  12461. * @type {Boolean|Array}
  12462. * @default undefined
  12463. */
  12464. manualColumnResize: void 0,
  12465. /**
  12466. * @description
  12467. * Turns on [Manual row move](http://docs.handsontable.com/demo-moving-rows-and-columns.html), if set to a boolean or define initial
  12468. * row order, if set to an array of row indexes.
  12469. *
  12470. * @example
  12471. * ```js
  12472. * ...
  12473. * // as boolean
  12474. * manualRowMove: true
  12475. * ...
  12476. * // as a array with initial order (move row index at 0 to 1 and move row index at 1 to 4)
  12477. * manualRowMove: [1, 4]
  12478. * ...
  12479. * ```
  12480. *
  12481. * @type {Boolean|Array}
  12482. * @default undefined
  12483. * @since 0.11.0
  12484. */
  12485. manualRowMove: void 0,
  12486. /**
  12487. * @description
  12488. * Turns on [Manual row resize](http://docs.handsontable.com/demo-resizing.html), if set to a boolean or define initial
  12489. * row resized heights, if set to an array of numbers.
  12490. *
  12491. * @example
  12492. * ```js
  12493. * ...
  12494. * // as boolean
  12495. * manualRowResize: true
  12496. * ...
  12497. * // as a array with initial heights (row at 0 index has 40px and row at 1 index has 50px)
  12498. * manualRowResize: [40, 50]
  12499. * ...
  12500. * ```
  12501. *
  12502. * @type {Boolean|Array}
  12503. * @default undefined
  12504. * @since 0.11.0
  12505. */
  12506. manualRowResize: void 0,
  12507. /**
  12508. * @description
  12509. * 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).
  12510. * [More information on the demo page.](http://docs.handsontable.com/demo-merge-cells.html)
  12511. *
  12512. * @example
  12513. * ```js
  12514. * // enables the mergeCells plugin:
  12515. * margeCells: true
  12516. * ...
  12517. * // declares a list of merged sections:
  12518. * mergeCells: [
  12519. * {row: 1, col: 1, rowspan: 3, colspan: 3}, // rowspan and colspan properties declare the width and height of a merged section in cells
  12520. * {row: 3, col: 4, rowspan: 2, colspan: 2},
  12521. * {row: 5, col: 6, rowspan: 3, colspan: 3}
  12522. * ]
  12523. * ```
  12524. * @type {Boolean|Array}
  12525. * @default false
  12526. */
  12527. mergeCells: false,
  12528. /**
  12529. * Number of rows to be rendered outside of the visible part of the table.
  12530. * By default, it's set to `'auto'`, which makes Handsontable to attempt to calculate the best offset performance-wise.
  12531. *
  12532. * You may test out different values to find the best one that works for your specific implementation.
  12533. *
  12534. * @type {Number|String}
  12535. * @default 'auto'
  12536. */
  12537. viewportRowRenderingOffset: 'auto',
  12538. /**
  12539. * Number of columns to be rendered outside of the visible part of the table.
  12540. * By default, it's set to `'auto'`, which makes Handsontable try calculating the best offset performance-wise.
  12541. *
  12542. * You may experiment with the value to find the one that works best for your specific implementation.
  12543. *
  12544. * @type {Number|String}
  12545. * @default 'auto'
  12546. */
  12547. viewportColumnRenderingOffset: 'auto',
  12548. /**
  12549. * A function, regular expression or a string, which will be used in the process of cell validation.
  12550. * If a function is used, be sure to execute the callback argument with either `true` (`callback(true)`) if the validation passed
  12551. * or with `false` (`callback(false)`), if the validation failed.
  12552. * Note, that `this` in the function points to the `cellProperties` object.
  12553. *
  12554. * If a string is provided, it may be one of the following predefined values:
  12555. * * `autocomplete`,
  12556. * * `date`,
  12557. * * `numeric`,
  12558. * * `time`.
  12559. *
  12560. * Or you can [register](http://docs.handsontable.com/demo-data-validation.html) the validator function under specified name and use
  12561. * its name as an alias in your configuration.
  12562. *
  12563. * See more [in the demo](http://docs.handsontable.com/demo-data-validation.html).
  12564. *
  12565. * @example
  12566. * ```js
  12567. * // as a function
  12568. * columns: [
  12569. * {
  12570. * validator: function(value, callback) { // validation rules }
  12571. * }
  12572. * ]
  12573. * ...
  12574. * // as a regexp
  12575. * columns: [
  12576. * {
  12577. * validator: /^[0-9]$/ // regular expression
  12578. * }
  12579. * ]
  12580. * // as a string
  12581. * columns: [
  12582. * {
  12583. * validator: 'numeric'
  12584. * }
  12585. * ]
  12586. * ```
  12587. * @type {Function|RegExp|String}
  12588. * @default undefined
  12589. * @since 0.9.5
  12590. */
  12591. validator: void 0,
  12592. /**
  12593. * @description
  12594. * Disable visual cells selection.
  12595. *
  12596. * Possible values:
  12597. * * `true` - Disables any type of visual selection (current and area selection),
  12598. * * `false` - Enables any type of visual selection. This is default value.
  12599. * * `current` - Disables the selection of a currently selected cell, the area selection is still present.
  12600. * * `area` - Disables the area selection, the currently selected cell selection is still present.
  12601. *
  12602. * @type {Boolean|String|Array}
  12603. * @default false
  12604. * @since 0.13.2
  12605. * @example
  12606. * ```js
  12607. * ...
  12608. * // as boolean
  12609. * disableVisualSelection: true,
  12610. * ...
  12611. *
  12612. * ...
  12613. * // as string ('current' or 'area')
  12614. * disableVisualSelection: 'current',
  12615. * ...
  12616. *
  12617. * ...
  12618. * // as array
  12619. * disableVisualSelection: ['current', 'area'],
  12620. * ...
  12621. * ```
  12622. */
  12623. disableVisualSelection: false,
  12624. /**
  12625. * @description
  12626. * Set whether to display the current sorting order indicator (a triangle icon in the column header, specifying the sorting order).
  12627. *
  12628. * @type {Boolean}
  12629. * @default false
  12630. * @since 0.15.0-beta3
  12631. */
  12632. sortIndicator: void 0,
  12633. /**
  12634. * Disable or enable ManualColumnFreeze plugin.
  12635. *
  12636. * @type {Boolean}
  12637. * @default false
  12638. */
  12639. manualColumnFreeze: void 0,
  12640. /**
  12641. * @description
  12642. * Defines whether Handsontable should trim the whitespace at the beginning and the end of the cell contents.
  12643. *
  12644. * @type {Boolean}
  12645. * @default true
  12646. */
  12647. trimWhitespace: true,
  12648. settings: void 0,
  12649. /**
  12650. * @description
  12651. * Defines data source for Autocomplete or Dropdown cell types.
  12652. *
  12653. * @example
  12654. * ```js
  12655. * ...
  12656. * // source as a array
  12657. * columns: [{
  12658. * type: 'autocomplete',
  12659. * source: ['A', 'B', 'C', 'D']
  12660. * }]
  12661. * ...
  12662. * // source as a function
  12663. * columns: [{
  12664. * type: 'autocomplete',
  12665. * source: function(query, callback) {
  12666. * fetch('http://example.com/query?q=' + query, function(response) {
  12667. * callback(response.items);
  12668. * })
  12669. * }
  12670. * }]
  12671. * ...
  12672. * ```
  12673. *
  12674. * @type {Array|Function}
  12675. * @default undefined
  12676. */
  12677. source: void 0,
  12678. /**
  12679. * @description
  12680. * Defines the column header name.
  12681. *
  12682. * @example
  12683. * ```js
  12684. * ...
  12685. * columns: [{
  12686. * title: 'First name',
  12687. * type: 'text',
  12688. * },
  12689. * {
  12690. * title: 'Last name',
  12691. * type: 'text',
  12692. * }]
  12693. * ...
  12694. * ```
  12695. *
  12696. * @type {String}
  12697. * @default undefined
  12698. */
  12699. title: void 0,
  12700. /**
  12701. * Data template for `'checkbox'` type when checkbox is checked.
  12702. *
  12703. * @example
  12704. * ```js
  12705. * checkedTemplate: 'good'
  12706. *
  12707. * // if a checkbox-typed cell is checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  12708. * // will return 'good'.
  12709. * ```
  12710. * @type {Boolean|String}
  12711. * @default true
  12712. */
  12713. checkedTemplate: void 0,
  12714. /**
  12715. * Data template for `'checkbox'` type when checkbox is unchecked.
  12716. *
  12717. * @example
  12718. * ```js
  12719. * uncheckedTemplate: 'bad'
  12720. *
  12721. * // if a checkbox-typed cell is not checked, then getDataAtCell(x,y), where x and y are the coordinates of the cell
  12722. * // will return 'bad'.
  12723. * ```
  12724. * @type {Boolean|String}
  12725. * @default false
  12726. */
  12727. uncheckedTemplate: void 0,
  12728. /**
  12729. * @description
  12730. * Object which describes if renderer should create checkbox element with label element as a parent. Option desired for
  12731. * [checkbox](http://docs.handsontable.com/demo-checkbox.html)-typed cells.
  12732. *
  12733. * By default the [checkbox](http://docs.handsontable.com/demo-checkbox.html) renderer renders the checkbox without a label.
  12734. *
  12735. * Possible object properties:
  12736. * * `property` - Defines the property name of the data object, which will to be used as a label.
  12737. * (eg. `label: {property: 'name.last'}`). This option works only if data was passed as an array of objects.
  12738. * * `position` - String which describes where to place the label text (before or after checkbox element).
  12739. * Valid values are `'before'` and '`after`' (defaults to `'after'`).
  12740. * * `value` - String or a Function which will be used as label text.
  12741. *
  12742. * @example
  12743. * ```js
  12744. * ...
  12745. * columns: [{
  12746. * type: 'checkbox',
  12747. * label: {position: 'after', value: 'My label: '}
  12748. * }]
  12749. * ...
  12750. * ```
  12751. *
  12752. * @since 0.19.0
  12753. * @type {Object}
  12754. * @default undefined
  12755. */
  12756. label: void 0,
  12757. /**
  12758. * Display format. See [numbrojs](http://numbrojs.com). This option is desired for
  12759. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  12760. *
  12761. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  12762. *
  12763. * @example
  12764. * ```js
  12765. * ...
  12766. * columns: [{
  12767. * type: 'numeric',
  12768. * format: '0,00'
  12769. * }]
  12770. * ...
  12771. * ```
  12772. *
  12773. * @type {String}
  12774. * @default '0'
  12775. */
  12776. format: void 0,
  12777. /**
  12778. * Language display format. See [numbrojs](http://numbrojs.com/languages.html#supported-languages). This option is desired for
  12779. * [numeric](http://docs.handsontable.com/demo-numeric.html)-typed cells.
  12780. *
  12781. * Since 0.26.0 Handsontable uses [numbro](http://numbrojs.com/) as a main library for numbers formatting.
  12782. *
  12783. * @example
  12784. * ```js
  12785. * ...
  12786. * columns: [{
  12787. * type: 'numeric',
  12788. * language: 'en-US'
  12789. * }]
  12790. * ...
  12791. * ```
  12792. *
  12793. * @type {String}
  12794. * @default 'en-US'
  12795. */
  12796. language: void 0,
  12797. /**
  12798. * @description
  12799. * Data source for [select](http://docs.handsontable.com/demo-select.html)-typed cells.
  12800. *
  12801. * @example
  12802. * ```js
  12803. * ...
  12804. * columns: [{
  12805. * editor: 'select',
  12806. * selectOptions: ['A', 'B', 'C'],
  12807. * }]
  12808. * ...
  12809. * ```
  12810. *
  12811. * @type {Array}
  12812. */
  12813. selectOptions: void 0,
  12814. /**
  12815. * Enables or disables the autoColumnSize plugin. Default value is `undefined`, which has the same effect as `true`.
  12816. * Disabling this plugin can increase performance, as no size-related calculations would be done.
  12817. *
  12818. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  12819. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  12820. * block the browser UI.
  12821. *
  12822. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  12823. * `syncLimit` option is available since 0.16.0.
  12824. *
  12825. * You can also use the `useHeaders` option to take the column headers with into calculation.
  12826. *
  12827. * @example
  12828. * ```js
  12829. * ...
  12830. * // as a number (300 columns in sync, rest async)
  12831. * autoColumnSize: {syncLimit: 300},
  12832. * ...
  12833. *
  12834. * ...
  12835. * // as a string (percent)
  12836. * autoColumnSize: {syncLimit: '40%'},
  12837. * ...
  12838. *
  12839. * ...
  12840. * // use headers width while calculation the column width
  12841. * autoColumnSize: {useHeaders: true},
  12842. * ...
  12843. *
  12844. * ```
  12845. *
  12846. * @type {Object|Boolean}
  12847. * @default {syncLimit: 50}
  12848. */
  12849. autoColumnSize: void 0,
  12850. /**
  12851. * Enables or disables autoRowSize plugin. Default value is `undefined`, which has the same effect as `false` (disabled).
  12852. * Enabling this plugin can decrease performance, as size-related calculations would be performed.
  12853. *
  12854. * Row height calculations are divided into sync and async stages. Each of these stages has their own advantages and
  12855. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  12856. * block the browser UI.
  12857. *
  12858. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value.
  12859. * `syncLimit` options is available since 0.16.0.
  12860. *
  12861. * @example
  12862. * ```js
  12863. * ...
  12864. * // as number (300 columns in sync, rest async)
  12865. * autoRowSize: {syncLimit: 300},
  12866. * ...
  12867. *
  12868. * ...
  12869. * // as string (percent)
  12870. * autoRowSize: {syncLimit: '40%'},
  12871. * ...
  12872. * ```
  12873. * @type {Object|Boolean}
  12874. * @default {syncLimit: 1000}
  12875. */
  12876. autoRowSize: void 0,
  12877. /**
  12878. * Date validation format.
  12879. *
  12880. * Option desired for `'date'` - typed cells.
  12881. *
  12882. * @example
  12883. * ```js
  12884. * ...
  12885. * columns: [{
  12886. * type: 'date',
  12887. * dateFormat: 'MM/DD/YYYY'
  12888. * }]
  12889. * ...
  12890. * ```
  12891. *
  12892. * @type {String}
  12893. * @default 'DD/MM/YYYY'
  12894. */
  12895. dateFormat: void 0,
  12896. /**
  12897. * If `true` then dates will be automatically formatted to match the desired format.
  12898. *
  12899. * Option desired for `'date'`-typed typed cells.
  12900. *
  12901. * @example
  12902. * ```js
  12903. * ...
  12904. * columns: [{
  12905. * type: 'date',
  12906. * dateFormat: 'YYYY-MM-DD',
  12907. * correctFormat: true
  12908. * }]
  12909. * ...
  12910. * ```
  12911. *
  12912. * @type {Boolean}
  12913. * @default false
  12914. */
  12915. correctFormat: false,
  12916. /**
  12917. * Definition of default value which will fill the empty cells.
  12918. *
  12919. * Option desired for `'date'`-typed cells.
  12920. *
  12921. * @example
  12922. * ```js
  12923. * ...
  12924. * columns: [{
  12925. * type: 'date',
  12926. * defaultData: '2015-02-02'
  12927. * }]
  12928. * ...
  12929. * ```
  12930. *
  12931. * @type {String}
  12932. */
  12933. defaultDate: void 0,
  12934. /**
  12935. * If set to `true`, the value entered into the cell must match (case-sensitive) the autocomplete source. Otherwise, cell won't pass the validation.
  12936. * When filtering the autocomplete source list, the editor will be working in case-insensitive mode.
  12937. *
  12938. * Option desired for `autocomplete`-typed cells.
  12939. *
  12940. * @example
  12941. * ```js
  12942. * ...
  12943. * columns: [{
  12944. * type: 'autocomplete',
  12945. * source: ['A', 'B', 'C'],
  12946. * strict: true
  12947. * }]
  12948. * ...
  12949. * ```
  12950. *
  12951. * @type {Boolean}
  12952. */
  12953. strict: void 0,
  12954. /**
  12955. * @description
  12956. * If typed `true`, data defined in `source` of the autocomplete or dropdown cell will be treated as HTML.
  12957. *
  12958. * __Warning:__ Enabling this option can cause serious XSS vulnerabilities.
  12959. *
  12960. * Option desired for `'autocomplete'`-typed cells.
  12961. * @example
  12962. * ```js
  12963. * ...
  12964. * columns: [{
  12965. * type: 'autocomplete',
  12966. * allowHtml: true,
  12967. * source: ['<b>foo</b>', '<b>bar</b>']
  12968. * }]
  12969. * ...
  12970. * ```
  12971. * @type {Boolean}
  12972. * @default false
  12973. */
  12974. allowHtml: false,
  12975. /**
  12976. * If typed `true` then virtual rendering mechanism for handsontable will be disabled.
  12977. *
  12978. * @type {Boolean}
  12979. */
  12980. renderAllRows: void 0,
  12981. /**
  12982. * Prevents table to overlap outside the parent element. If `'horizontal'` option is chosen then table will appear horizontal
  12983. * scrollbar in case where parent's width is narrower then table's width.
  12984. *
  12985. * Possible values:
  12986. * * `false` - Disables functionality (Default option).
  12987. * * `horizontal` - Prevents horizontal overflow table.
  12988. * * `vertical` - Prevents vertical overflow table (Not implemented yet).
  12989. *
  12990. * @since 0.20.3
  12991. * @example
  12992. * ```js
  12993. * ...
  12994. * preventOverflow: 'horizontal'
  12995. * ...
  12996. * ```
  12997. *
  12998. * @type {String|Boolean}
  12999. */
  13000. preventOverflow: false,
  13001. /**
  13002. * @description
  13003. * Plugin allowing binding the table rows with their headers.
  13004. * If the plugin is enabled, the table row headers will "stick" to the rows, when they are hidden/moved. Basically, if at the initialization
  13005. * row 0 has a header titled "A", it will have it no matter what you do with the table.
  13006. *
  13007. * @pro
  13008. * @since 1.0.0-beta1
  13009. * @type {Boolean|String}
  13010. * @example
  13011. *
  13012. * ```js
  13013. * ...
  13014. * var hot = new Handsontable(document.getElementById('example'), {
  13015. * date: getData(),
  13016. * bindRowsWithHeaders: true
  13017. * });
  13018. * ...
  13019. * ```
  13020. *
  13021. */
  13022. bindRowsWithHeaders: void 0,
  13023. /**
  13024. * @description
  13025. * The CollapsibleColumns plugin allows collapsing of columns, covered by a header with the `colspan` property defined.
  13026. *
  13027. * Clicking the "collapse/expand" button collapses (or expands) all "child" headers except the first one.
  13028. *
  13029. * Setting the `collapsibleColumns` property to `true` will display a "collapse/expand" button in every header with a defined
  13030. * `colspan` property.
  13031. *
  13032. * To limit this functionality to a smaller group of headers, define the `collapsibleColumns` property as an array of objects, as in
  13033. * the example below.
  13034. *
  13035. * @pro
  13036. * @since 1.0.0-beta1
  13037. * @type {Boolean|Array}
  13038. * @example
  13039. * ```js
  13040. * ...
  13041. * collapsibleColumns: [
  13042. * {row: -4, col: 1, collapsible: true},
  13043. * {row: -3, col: 5, collapsible: true}
  13044. * ]
  13045. * ...
  13046. * // or
  13047. * ...
  13048. * collapsibleColumns: true
  13049. * ...
  13050. * ```
  13051. */
  13052. collapsibleColumns: void 0,
  13053. /**
  13054. * @description
  13055. * Allows making pre-defined calculations on the cell values and display the results within Handsontable.
  13056. * See the demo for more information.
  13057. *
  13058. * @pro
  13059. * @since 1.0.0-beta1
  13060. * @type {Object}
  13061. */
  13062. columnSummary: void 0,
  13063. /**
  13064. * This plugin allows adding a configurable dropdown menu to the table's column headers.
  13065. * The dropdown menu acts like the Context Menu, but is triggered by clicking the button in the header.
  13066. *
  13067. * @pro
  13068. * @since 1.0.0-beta1
  13069. * @type {Boolean|Object|Array}
  13070. */
  13071. dropdownMenu: void 0,
  13072. /**
  13073. * The filters plugin.
  13074. * It allows filtering the table data either by the built-in component or with the API.
  13075. *
  13076. * @pro
  13077. * @since 1.0.0-beta1
  13078. * @type {Boolean}
  13079. */
  13080. filters: void 0,
  13081. /**
  13082. * It allows Handsontable to process formula expressions defined in the provided data.
  13083. *
  13084. * @pro
  13085. * @since 1.7.0
  13086. * @type {Boolean}
  13087. */
  13088. formulas: void 0,
  13089. /**
  13090. * @description
  13091. * GanttChart plugin enables a possibility to create a Gantt chart using a Handsontable instance.
  13092. * In this case, the whole table becomes read-only.
  13093. *
  13094. * @pro
  13095. * @since 1.0.0-beta1
  13096. * @type {Object}
  13097. */
  13098. ganttChart: void 0,
  13099. /**
  13100. * @description
  13101. * Allows adding a tooltip to the table headers.
  13102. *
  13103. * Available options:
  13104. * * the `rows` property defines if tooltips should be added to row headers,
  13105. * * the `columns` property defines if tooltips should be added to column headers,
  13106. * * 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).
  13107. *
  13108. * @pro
  13109. * @since 1.0.0-beta1
  13110. * @type {Boolean|Object}
  13111. */
  13112. headerTooltips: void 0,
  13113. /**
  13114. * Plugin allowing hiding of certain columns.
  13115. *
  13116. * @pro
  13117. * @since 1.0.0-beta1
  13118. * @type {Boolean|Object}
  13119. */
  13120. hiddenColumns: void 0,
  13121. /**
  13122. * @description
  13123. * Plugin allowing hiding of certain rows.
  13124. *
  13125. * @pro
  13126. * @since 1.0.0-beta1
  13127. * @type {Boolean|Object}
  13128. */
  13129. hiddenRows: void 0,
  13130. /**
  13131. * @description
  13132. * Allows creating a nested header structure, using the HTML's colspan attribute.
  13133. *
  13134. * @pro
  13135. * @since 1.0.0-beta1
  13136. * @type {Array}
  13137. */
  13138. nestedHeaders: void 0,
  13139. /**
  13140. * @description
  13141. * Plugin allowing hiding of certain rows.
  13142. *
  13143. * @pro
  13144. * @since 1.0.0-beta1
  13145. * @type {Boolean|Array}
  13146. */
  13147. trimRows: void 0,
  13148. /**
  13149. * @description
  13150. * 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.
  13151. *
  13152. * @since 0.22.0
  13153. * @type {Number|Array}
  13154. */
  13155. rowHeaderWidth: void 0,
  13156. /**
  13157. * @description
  13158. * 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.
  13159. *
  13160. * @since 0.22.0
  13161. * @type {Number|Array}
  13162. */
  13163. columnHeaderHeight: void 0,
  13164. /**
  13165. * @description
  13166. * Enabling this plugin switches table into one-way data binding where changes are applied into data source (from outside table)
  13167. * will be automatically reflected in the table.
  13168. *
  13169. * For every data change [afterChangesObserved](Hooks.html#event:afterChangesObserved) hook will be fired.
  13170. *
  13171. * @type {Boolean}
  13172. * @default false
  13173. */
  13174. observeChanges: void 0,
  13175. /**
  13176. * @description
  13177. * When passed to the `column` property, allows specifying a custom sorting function for the desired column.
  13178. *
  13179. * @since 0.24.0
  13180. * @type {Function}
  13181. * @example
  13182. * ```js
  13183. * columns: [
  13184. * {
  13185. * sortFunction: function(sortOrder) {
  13186. * return function(a, b) {
  13187. * // sorting function body.
  13188. * //
  13189. * // Function parameters:
  13190. * // sortOrder: If true, the order is ascending, if false - descending. undefined = original order
  13191. * // a, b: Two compared elements. These are 2-element arrays, with the first element being the row index, the second - cell value.
  13192. * }
  13193. * }
  13194. * }
  13195. * ]
  13196. * ```
  13197. */
  13198. sortFunction: void 0,
  13199. /**
  13200. * 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).
  13201. *
  13202. * Option desired for cells of the `'autocomplete'` type.
  13203. *
  13204. * @type {Boolean}
  13205. * @default true
  13206. */
  13207. sortByRelevance: true,
  13208. /**
  13209. * If defined as 'true', when the user types into the input area the Autocomplete's suggestion list is updated to only
  13210. * include those choices starting with what has been typed; if defined as 'false' all suggestions remain shown, with
  13211. * those matching what has been typed marked in bold.
  13212. *
  13213. * @type {Boolean}
  13214. * @default true
  13215. */
  13216. filter: true,
  13217. /**
  13218. * If defined as 'true', filtering in the Autocomplete Editor will be case-sensitive.
  13219. *
  13220. * @type {Boolean}
  13221. * @default: false
  13222. */
  13223. filteringCaseSensitive: false
  13224. };
  13225. exports.default = DefaultSettings;
  13226. /***/ }),
  13227. /* 89 */
  13228. /***/ (function(module, exports, __webpack_require__) {
  13229. "use strict";
  13230. exports.__esModule = true;
  13231. exports.getNormalizedDate = getNormalizedDate;
  13232. /* eslint-disable import/prefer-default-export */
  13233. /**
  13234. * Get normalized Date object for the ISO formatted date strings.
  13235. * 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.
  13236. * See: Github issue #3338.
  13237. *
  13238. * @param {String} dateString String representing the date.
  13239. * @returns {Date} The proper Date object.
  13240. */
  13241. function getNormalizedDate(dateString) {
  13242. var nativeDate = new Date(dateString);
  13243. // NaN if dateString is not in ISO format
  13244. if (!isNaN(new Date(dateString + "T00:00").getDate())) {
  13245. // Compensate timezone offset
  13246. return new Date(nativeDate.getTime() + nativeDate.getTimezoneOffset() * 60000);
  13247. }
  13248. return nativeDate;
  13249. }
  13250. /***/ }),
  13251. /* 90 */
  13252. /***/ (function(module, exports, __webpack_require__) {
  13253. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  13254. var $export = __webpack_require__(3);
  13255. $export($export.P, 'Array', {copyWithin: __webpack_require__(277)});
  13256. __webpack_require__(37)('copyWithin');
  13257. /***/ }),
  13258. /* 91 */
  13259. /***/ (function(module, exports, __webpack_require__) {
  13260. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  13261. var $export = __webpack_require__(3);
  13262. $export($export.P, 'Array', {fill: __webpack_require__(278)});
  13263. __webpack_require__(37)('fill');
  13264. /***/ }),
  13265. /* 92 */
  13266. /***/ (function(module, exports, __webpack_require__) {
  13267. "use strict";
  13268. // 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
  13269. var $export = __webpack_require__(3)
  13270. , $find = __webpack_require__(52)(6)
  13271. , KEY = 'findIndex'
  13272. , forced = true;
  13273. // Shouldn't skip holes
  13274. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  13275. $export($export.P + $export.F * forced, 'Array', {
  13276. findIndex: function findIndex(callbackfn/*, that = undefined */){
  13277. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  13278. }
  13279. });
  13280. __webpack_require__(37)(KEY);
  13281. /***/ }),
  13282. /* 93 */
  13283. /***/ (function(module, exports, __webpack_require__) {
  13284. "use strict";
  13285. // 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
  13286. var $export = __webpack_require__(3)
  13287. , $find = __webpack_require__(52)(5)
  13288. , KEY = 'find'
  13289. , forced = true;
  13290. // Shouldn't skip holes
  13291. if(KEY in [])Array(1)[KEY](function(){ forced = false; });
  13292. $export($export.P + $export.F * forced, 'Array', {
  13293. find: function find(callbackfn/*, that = undefined */){
  13294. return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  13295. }
  13296. });
  13297. __webpack_require__(37)(KEY);
  13298. /***/ }),
  13299. /* 94 */
  13300. /***/ (function(module, exports, __webpack_require__) {
  13301. "use strict";
  13302. var ctx = __webpack_require__(29)
  13303. , $export = __webpack_require__(3)
  13304. , toObject = __webpack_require__(41)
  13305. , call = __webpack_require__(165)
  13306. , isArrayIter = __webpack_require__(161)
  13307. , toLength = __webpack_require__(24)
  13308. , createProperty = __webpack_require__(73)
  13309. , getIterFn = __webpack_require__(176);
  13310. $export($export.S + $export.F * !__webpack_require__(78)(function(iter){ Array.from(iter); }), 'Array', {
  13311. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  13312. from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  13313. var O = toObject(arrayLike)
  13314. , C = typeof this == 'function' ? this : Array
  13315. , aLen = arguments.length
  13316. , mapfn = aLen > 1 ? arguments[1] : undefined
  13317. , mapping = mapfn !== undefined
  13318. , index = 0
  13319. , iterFn = getIterFn(O)
  13320. , length, result, step, iterator;
  13321. if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  13322. // if object isn't iterable or it's array with default iterator - use simple case
  13323. if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
  13324. for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
  13325. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  13326. }
  13327. } else {
  13328. length = toLength(O.length);
  13329. for(result = new C(length); length > index; index++){
  13330. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  13331. }
  13332. }
  13333. result.length = index;
  13334. return result;
  13335. }
  13336. });
  13337. /***/ }),
  13338. /* 95 */
  13339. /***/ (function(module, exports, __webpack_require__) {
  13340. "use strict";
  13341. var $export = __webpack_require__(3)
  13342. , createProperty = __webpack_require__(73);
  13343. // WebKit Array.of isn't generic
  13344. $export($export.S + $export.F * __webpack_require__(31)(function(){
  13345. function F(){}
  13346. return !(Array.of.call(F) instanceof F);
  13347. }), 'Array', {
  13348. // 22.1.2.3 Array.of( ...items)
  13349. of: function of(/* ...args */){
  13350. var index = 0
  13351. , aLen = arguments.length
  13352. , result = new (typeof this == 'function' ? this : Array)(aLen);
  13353. while(aLen > index)createProperty(result, index, arguments[index++]);
  13354. result.length = aLen;
  13355. return result;
  13356. }
  13357. });
  13358. /***/ }),
  13359. /* 96 */
  13360. /***/ (function(module, exports, __webpack_require__) {
  13361. var dP = __webpack_require__(19).f
  13362. , createDesc = __webpack_require__(40)
  13363. , has = __webpack_require__(22)
  13364. , FProto = Function.prototype
  13365. , nameRE = /^\s*function ([^ (]*)/
  13366. , NAME = 'name';
  13367. var isExtensible = Object.isExtensible || function(){
  13368. return true;
  13369. };
  13370. // 19.2.4.2 name
  13371. NAME in FProto || __webpack_require__(21) && dP(FProto, NAME, {
  13372. configurable: true,
  13373. get: function(){
  13374. try {
  13375. var that = this
  13376. , name = ('' + that).match(nameRE)[1];
  13377. has(that, NAME) || !isExtensible(that) || dP(that, NAME, createDesc(5, name));
  13378. return name;
  13379. } catch(e){
  13380. return '';
  13381. }
  13382. }
  13383. });
  13384. /***/ }),
  13385. /* 97 */
  13386. /***/ (function(module, exports, __webpack_require__) {
  13387. "use strict";
  13388. var strong = __webpack_require__(157);
  13389. // 23.1 Map Objects
  13390. module.exports = __webpack_require__(53)('Map', function(get){
  13391. return function Map(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  13392. }, {
  13393. // 23.1.3.6 Map.prototype.get(key)
  13394. get: function get(key){
  13395. var entry = strong.getEntry(this, key);
  13396. return entry && entry.v;
  13397. },
  13398. // 23.1.3.9 Map.prototype.set(key, value)
  13399. set: function set(key, value){
  13400. return strong.def(this, key === 0 ? 0 : key, value);
  13401. }
  13402. }, strong, true);
  13403. /***/ }),
  13404. /* 98 */
  13405. /***/ (function(module, exports, __webpack_require__) {
  13406. // 20.1.2.1 Number.EPSILON
  13407. var $export = __webpack_require__(3);
  13408. $export($export.S, 'Number', {EPSILON: Math.pow(2, -52)});
  13409. /***/ }),
  13410. /* 99 */
  13411. /***/ (function(module, exports, __webpack_require__) {
  13412. // 20.1.2.2 Number.isFinite(number)
  13413. var $export = __webpack_require__(3)
  13414. , _isFinite = __webpack_require__(13).isFinite;
  13415. $export($export.S, 'Number', {
  13416. isFinite: function isFinite(it){
  13417. return typeof it == 'number' && _isFinite(it);
  13418. }
  13419. });
  13420. /***/ }),
  13421. /* 100 */
  13422. /***/ (function(module, exports, __webpack_require__) {
  13423. // 20.1.2.3 Number.isInteger(number)
  13424. var $export = __webpack_require__(3);
  13425. $export($export.S, 'Number', {isInteger: __webpack_require__(163)});
  13426. /***/ }),
  13427. /* 101 */
  13428. /***/ (function(module, exports, __webpack_require__) {
  13429. // 20.1.2.4 Number.isNaN(number)
  13430. var $export = __webpack_require__(3);
  13431. $export($export.S, 'Number', {
  13432. isNaN: function isNaN(number){
  13433. return number != number;
  13434. }
  13435. });
  13436. /***/ }),
  13437. /* 102 */
  13438. /***/ (function(module, exports, __webpack_require__) {
  13439. // 20.1.2.5 Number.isSafeInteger(number)
  13440. var $export = __webpack_require__(3)
  13441. , isInteger = __webpack_require__(163)
  13442. , abs = Math.abs;
  13443. $export($export.S, 'Number', {
  13444. isSafeInteger: function isSafeInteger(number){
  13445. return isInteger(number) && abs(number) <= 0x1fffffffffffff;
  13446. }
  13447. });
  13448. /***/ }),
  13449. /* 103 */
  13450. /***/ (function(module, exports, __webpack_require__) {
  13451. // 20.1.2.6 Number.MAX_SAFE_INTEGER
  13452. var $export = __webpack_require__(3);
  13453. $export($export.S, 'Number', {MAX_SAFE_INTEGER: 0x1fffffffffffff});
  13454. /***/ }),
  13455. /* 104 */
  13456. /***/ (function(module, exports, __webpack_require__) {
  13457. // 20.1.2.10 Number.MIN_SAFE_INTEGER
  13458. var $export = __webpack_require__(3);
  13459. $export($export.S, 'Number', {MIN_SAFE_INTEGER: -0x1fffffffffffff});
  13460. /***/ }),
  13461. /* 105 */
  13462. /***/ (function(module, exports, __webpack_require__) {
  13463. // 19.1.3.1 Object.assign(target, source)
  13464. var $export = __webpack_require__(3);
  13465. $export($export.S + $export.F, 'Object', {assign: __webpack_require__(168)});
  13466. /***/ }),
  13467. /* 106 */
  13468. /***/ (function(module, exports, __webpack_require__) {
  13469. // 19.1.3.10 Object.is(value1, value2)
  13470. var $export = __webpack_require__(3);
  13471. $export($export.S, 'Object', {is: __webpack_require__(292)});
  13472. /***/ }),
  13473. /* 107 */
  13474. /***/ (function(module, exports, __webpack_require__) {
  13475. // 19.1.3.19 Object.setPrototypeOf(O, proto)
  13476. var $export = __webpack_require__(3);
  13477. $export($export.S, 'Object', {setPrototypeOf: __webpack_require__(171).set});
  13478. /***/ }),
  13479. /* 108 */
  13480. /***/ (function(module, exports, __webpack_require__) {
  13481. "use strict";
  13482. var LIBRARY = __webpack_require__(56)
  13483. , global = __webpack_require__(13)
  13484. , ctx = __webpack_require__(29)
  13485. , classof = __webpack_require__(156)
  13486. , $export = __webpack_require__(3)
  13487. , isObject = __webpack_require__(15)
  13488. , aFunction = __webpack_require__(72)
  13489. , anInstance = __webpack_require__(51)
  13490. , forOf = __webpack_require__(55)
  13491. , speciesConstructor = __webpack_require__(293)
  13492. , task = __webpack_require__(85).set
  13493. , microtask = __webpack_require__(287)()
  13494. , PROMISE = 'Promise'
  13495. , TypeError = global.TypeError
  13496. , process = global.process
  13497. , $Promise = global[PROMISE]
  13498. , process = global.process
  13499. , isNode = classof(process) == 'process'
  13500. , empty = function(){ /* empty */ }
  13501. , Internal, GenericPromiseCapability, Wrapper;
  13502. var USE_NATIVE = !!function(){
  13503. try {
  13504. // correct subclassing with @@species support
  13505. var promise = $Promise.resolve(1)
  13506. , FakePromise = (promise.constructor = {})[__webpack_require__(10)('species')] = function(exec){ exec(empty, empty); };
  13507. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  13508. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  13509. } catch(e){ /* empty */ }
  13510. }();
  13511. // helpers
  13512. var sameConstructor = function(a, b){
  13513. // with library wrapper special case
  13514. return a === b || a === $Promise && b === Wrapper;
  13515. };
  13516. var isThenable = function(it){
  13517. var then;
  13518. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  13519. };
  13520. var newPromiseCapability = function(C){
  13521. return sameConstructor($Promise, C)
  13522. ? new PromiseCapability(C)
  13523. : new GenericPromiseCapability(C);
  13524. };
  13525. var PromiseCapability = GenericPromiseCapability = function(C){
  13526. var resolve, reject;
  13527. this.promise = new C(function($$resolve, $$reject){
  13528. if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
  13529. resolve = $$resolve;
  13530. reject = $$reject;
  13531. });
  13532. this.resolve = aFunction(resolve);
  13533. this.reject = aFunction(reject);
  13534. };
  13535. var perform = function(exec){
  13536. try {
  13537. exec();
  13538. } catch(e){
  13539. return {error: e};
  13540. }
  13541. };
  13542. var notify = function(promise, isReject){
  13543. if(promise._n)return;
  13544. promise._n = true;
  13545. var chain = promise._c;
  13546. microtask(function(){
  13547. var value = promise._v
  13548. , ok = promise._s == 1
  13549. , i = 0;
  13550. var run = function(reaction){
  13551. var handler = ok ? reaction.ok : reaction.fail
  13552. , resolve = reaction.resolve
  13553. , reject = reaction.reject
  13554. , domain = reaction.domain
  13555. , result, then;
  13556. try {
  13557. if(handler){
  13558. if(!ok){
  13559. if(promise._h == 2)onHandleUnhandled(promise);
  13560. promise._h = 1;
  13561. }
  13562. if(handler === true)result = value;
  13563. else {
  13564. if(domain)domain.enter();
  13565. result = handler(value);
  13566. if(domain)domain.exit();
  13567. }
  13568. if(result === reaction.promise){
  13569. reject(TypeError('Promise-chain cycle'));
  13570. } else if(then = isThenable(result)){
  13571. then.call(result, resolve, reject);
  13572. } else resolve(result);
  13573. } else reject(value);
  13574. } catch(e){
  13575. reject(e);
  13576. }
  13577. };
  13578. while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
  13579. promise._c = [];
  13580. promise._n = false;
  13581. if(isReject && !promise._h)onUnhandled(promise);
  13582. });
  13583. };
  13584. var onUnhandled = function(promise){
  13585. task.call(global, function(){
  13586. var value = promise._v
  13587. , abrupt, handler, console;
  13588. if(isUnhandled(promise)){
  13589. abrupt = perform(function(){
  13590. if(isNode){
  13591. process.emit('unhandledRejection', value, promise);
  13592. } else if(handler = global.onunhandledrejection){
  13593. handler({promise: promise, reason: value});
  13594. } else if((console = global.console) && console.error){
  13595. console.error('Unhandled promise rejection', value);
  13596. }
  13597. });
  13598. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  13599. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  13600. } promise._a = undefined;
  13601. if(abrupt)throw abrupt.error;
  13602. });
  13603. };
  13604. var isUnhandled = function(promise){
  13605. if(promise._h == 1)return false;
  13606. var chain = promise._a || promise._c
  13607. , i = 0
  13608. , reaction;
  13609. while(chain.length > i){
  13610. reaction = chain[i++];
  13611. if(reaction.fail || !isUnhandled(reaction.promise))return false;
  13612. } return true;
  13613. };
  13614. var onHandleUnhandled = function(promise){
  13615. task.call(global, function(){
  13616. var handler;
  13617. if(isNode){
  13618. process.emit('rejectionHandled', promise);
  13619. } else if(handler = global.onrejectionhandled){
  13620. handler({promise: promise, reason: promise._v});
  13621. }
  13622. });
  13623. };
  13624. var $reject = function(value){
  13625. var promise = this;
  13626. if(promise._d)return;
  13627. promise._d = true;
  13628. promise = promise._w || promise; // unwrap
  13629. promise._v = value;
  13630. promise._s = 2;
  13631. if(!promise._a)promise._a = promise._c.slice();
  13632. notify(promise, true);
  13633. };
  13634. var $resolve = function(value){
  13635. var promise = this
  13636. , then;
  13637. if(promise._d)return;
  13638. promise._d = true;
  13639. promise = promise._w || promise; // unwrap
  13640. try {
  13641. if(promise === value)throw TypeError("Promise can't be resolved itself");
  13642. if(then = isThenable(value)){
  13643. microtask(function(){
  13644. var wrapper = {_w: promise, _d: false}; // wrap
  13645. try {
  13646. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  13647. } catch(e){
  13648. $reject.call(wrapper, e);
  13649. }
  13650. });
  13651. } else {
  13652. promise._v = value;
  13653. promise._s = 1;
  13654. notify(promise, false);
  13655. }
  13656. } catch(e){
  13657. $reject.call({_w: promise, _d: false}, e); // wrap
  13658. }
  13659. };
  13660. // constructor polyfill
  13661. if(!USE_NATIVE){
  13662. // 25.4.3.1 Promise(executor)
  13663. $Promise = function Promise(executor){
  13664. anInstance(this, $Promise, PROMISE, '_h');
  13665. aFunction(executor);
  13666. Internal.call(this);
  13667. try {
  13668. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  13669. } catch(err){
  13670. $reject.call(this, err);
  13671. }
  13672. };
  13673. Internal = function Promise(executor){
  13674. this._c = []; // <- awaiting reactions
  13675. this._a = undefined; // <- checked in isUnhandled reactions
  13676. this._s = 0; // <- state
  13677. this._d = false; // <- done
  13678. this._v = undefined; // <- value
  13679. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  13680. this._n = false; // <- notify
  13681. };
  13682. Internal.prototype = __webpack_require__(58)($Promise.prototype, {
  13683. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  13684. then: function then(onFulfilled, onRejected){
  13685. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  13686. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  13687. reaction.fail = typeof onRejected == 'function' && onRejected;
  13688. reaction.domain = isNode ? process.domain : undefined;
  13689. this._c.push(reaction);
  13690. if(this._a)this._a.push(reaction);
  13691. if(this._s)notify(this, false);
  13692. return reaction.promise;
  13693. },
  13694. // 25.4.5.1 Promise.prototype.catch(onRejected)
  13695. 'catch': function(onRejected){
  13696. return this.then(undefined, onRejected);
  13697. }
  13698. });
  13699. PromiseCapability = function(){
  13700. var promise = new Internal;
  13701. this.promise = promise;
  13702. this.resolve = ctx($resolve, promise, 1);
  13703. this.reject = ctx($reject, promise, 1);
  13704. };
  13705. }
  13706. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
  13707. __webpack_require__(48)($Promise, PROMISE);
  13708. __webpack_require__(172)(PROMISE);
  13709. Wrapper = __webpack_require__(44)[PROMISE];
  13710. // statics
  13711. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  13712. // 25.4.4.5 Promise.reject(r)
  13713. reject: function reject(r){
  13714. var capability = newPromiseCapability(this)
  13715. , $$reject = capability.reject;
  13716. $$reject(r);
  13717. return capability.promise;
  13718. }
  13719. });
  13720. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  13721. // 25.4.4.6 Promise.resolve(x)
  13722. resolve: function resolve(x){
  13723. // instanceof instead of internal slot check because we should fix it without replacement native Promise core
  13724. if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
  13725. var capability = newPromiseCapability(this)
  13726. , $$resolve = capability.resolve;
  13727. $$resolve(x);
  13728. return capability.promise;
  13729. }
  13730. });
  13731. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(78)(function(iter){
  13732. $Promise.all(iter)['catch'](empty);
  13733. })), PROMISE, {
  13734. // 25.4.4.1 Promise.all(iterable)
  13735. all: function all(iterable){
  13736. var C = this
  13737. , capability = newPromiseCapability(C)
  13738. , resolve = capability.resolve
  13739. , reject = capability.reject;
  13740. var abrupt = perform(function(){
  13741. var values = []
  13742. , index = 0
  13743. , remaining = 1;
  13744. forOf(iterable, false, function(promise){
  13745. var $index = index++
  13746. , alreadyCalled = false;
  13747. values.push(undefined);
  13748. remaining++;
  13749. C.resolve(promise).then(function(value){
  13750. if(alreadyCalled)return;
  13751. alreadyCalled = true;
  13752. values[$index] = value;
  13753. --remaining || resolve(values);
  13754. }, reject);
  13755. });
  13756. --remaining || resolve(values);
  13757. });
  13758. if(abrupt)reject(abrupt.error);
  13759. return capability.promise;
  13760. },
  13761. // 25.4.4.4 Promise.race(iterable)
  13762. race: function race(iterable){
  13763. var C = this
  13764. , capability = newPromiseCapability(C)
  13765. , reject = capability.reject;
  13766. var abrupt = perform(function(){
  13767. forOf(iterable, false, function(promise){
  13768. C.resolve(promise).then(capability.resolve, reject);
  13769. });
  13770. });
  13771. if(abrupt)reject(abrupt.error);
  13772. return capability.promise;
  13773. }
  13774. });
  13775. /***/ }),
  13776. /* 109 */
  13777. /***/ (function(module, exports, __webpack_require__) {
  13778. // 21.2.5.3 get RegExp.prototype.flags()
  13779. if(__webpack_require__(21) && /./g.flags != 'g')__webpack_require__(19).f(RegExp.prototype, 'flags', {
  13780. configurable: true,
  13781. get: __webpack_require__(282)
  13782. });
  13783. /***/ }),
  13784. /* 110 */
  13785. /***/ (function(module, exports, __webpack_require__) {
  13786. // @@match logic
  13787. __webpack_require__(54)('match', 1, function(defined, MATCH, $match){
  13788. // 21.1.3.11 String.prototype.match(regexp)
  13789. return [function match(regexp){
  13790. 'use strict';
  13791. var O = defined(this)
  13792. , fn = regexp == undefined ? undefined : regexp[MATCH];
  13793. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  13794. }, $match];
  13795. });
  13796. /***/ }),
  13797. /* 111 */
  13798. /***/ (function(module, exports, __webpack_require__) {
  13799. // @@replace logic
  13800. __webpack_require__(54)('replace', 2, function(defined, REPLACE, $replace){
  13801. // 21.1.3.14 String.prototype.replace(searchValue, replaceValue)
  13802. return [function replace(searchValue, replaceValue){
  13803. 'use strict';
  13804. var O = defined(this)
  13805. , fn = searchValue == undefined ? undefined : searchValue[REPLACE];
  13806. return fn !== undefined
  13807. ? fn.call(searchValue, O, replaceValue)
  13808. : $replace.call(String(O), searchValue, replaceValue);
  13809. }, $replace];
  13810. });
  13811. /***/ }),
  13812. /* 112 */
  13813. /***/ (function(module, exports, __webpack_require__) {
  13814. // @@search logic
  13815. __webpack_require__(54)('search', 1, function(defined, SEARCH, $search){
  13816. // 21.1.3.15 String.prototype.search(regexp)
  13817. return [function search(regexp){
  13818. 'use strict';
  13819. var O = defined(this)
  13820. , fn = regexp == undefined ? undefined : regexp[SEARCH];
  13821. return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
  13822. }, $search];
  13823. });
  13824. /***/ }),
  13825. /* 113 */
  13826. /***/ (function(module, exports, __webpack_require__) {
  13827. // @@split logic
  13828. __webpack_require__(54)('split', 2, function(defined, SPLIT, $split){
  13829. 'use strict';
  13830. var isRegExp = __webpack_require__(164)
  13831. , _split = $split
  13832. , $push = [].push
  13833. , $SPLIT = 'split'
  13834. , LENGTH = 'length'
  13835. , LAST_INDEX = 'lastIndex';
  13836. if(
  13837. 'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
  13838. 'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
  13839. 'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
  13840. '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
  13841. '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
  13842. ''[$SPLIT](/.?/)[LENGTH]
  13843. ){
  13844. var NPCG = /()??/.exec('')[1] === undefined; // nonparticipating capturing group
  13845. // based on es5-shim implementation, need to rework it
  13846. $split = function(separator, limit){
  13847. var string = String(this);
  13848. if(separator === undefined && limit === 0)return [];
  13849. // If `separator` is not a regex, use native split
  13850. if(!isRegExp(separator))return _split.call(string, separator, limit);
  13851. var output = [];
  13852. var flags = (separator.ignoreCase ? 'i' : '') +
  13853. (separator.multiline ? 'm' : '') +
  13854. (separator.unicode ? 'u' : '') +
  13855. (separator.sticky ? 'y' : '');
  13856. var lastLastIndex = 0;
  13857. var splitLimit = limit === undefined ? 4294967295 : limit >>> 0;
  13858. // Make `global` and avoid `lastIndex` issues by working with a copy
  13859. var separatorCopy = new RegExp(separator.source, flags + 'g');
  13860. var separator2, match, lastIndex, lastLength, i;
  13861. // Doesn't need flags gy, but they don't hurt
  13862. if(!NPCG)separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  13863. while(match = separatorCopy.exec(string)){
  13864. // `separatorCopy.lastIndex` is not reliable cross-browser
  13865. lastIndex = match.index + match[0][LENGTH];
  13866. if(lastIndex > lastLastIndex){
  13867. output.push(string.slice(lastLastIndex, match.index));
  13868. // Fix browsers whose `exec` methods don't consistently return `undefined` for NPCG
  13869. if(!NPCG && match[LENGTH] > 1)match[0].replace(separator2, function(){
  13870. for(i = 1; i < arguments[LENGTH] - 2; i++)if(arguments[i] === undefined)match[i] = undefined;
  13871. });
  13872. if(match[LENGTH] > 1 && match.index < string[LENGTH])$push.apply(output, match.slice(1));
  13873. lastLength = match[0][LENGTH];
  13874. lastLastIndex = lastIndex;
  13875. if(output[LENGTH] >= splitLimit)break;
  13876. }
  13877. if(separatorCopy[LAST_INDEX] === match.index)separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
  13878. }
  13879. if(lastLastIndex === string[LENGTH]){
  13880. if(lastLength || !separatorCopy.test(''))output.push('');
  13881. } else output.push(string.slice(lastLastIndex));
  13882. return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
  13883. };
  13884. // Chakra, V8
  13885. } else if('0'[$SPLIT](undefined, 0)[LENGTH]){
  13886. $split = function(separator, limit){
  13887. return separator === undefined && limit === 0 ? [] : _split.call(this, separator, limit);
  13888. };
  13889. }
  13890. // 21.1.3.17 String.prototype.split(separator, limit)
  13891. return [function split(separator, limit){
  13892. var O = defined(this)
  13893. , fn = separator == undefined ? undefined : separator[SPLIT];
  13894. return fn !== undefined ? fn.call(separator, O, limit) : $split.call(String(O), separator, limit);
  13895. }, $split];
  13896. });
  13897. /***/ }),
  13898. /* 114 */
  13899. /***/ (function(module, exports, __webpack_require__) {
  13900. "use strict";
  13901. var strong = __webpack_require__(157);
  13902. // 23.2 Set Objects
  13903. module.exports = __webpack_require__(53)('Set', function(get){
  13904. return function Set(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  13905. }, {
  13906. // 23.2.3.1 Set.prototype.add(value)
  13907. add: function add(value){
  13908. return strong.def(this, value = value === 0 ? 0 : value, value);
  13909. }
  13910. }, strong);
  13911. /***/ }),
  13912. /* 115 */
  13913. /***/ (function(module, exports, __webpack_require__) {
  13914. "use strict";
  13915. var $export = __webpack_require__(3)
  13916. , $at = __webpack_require__(294)(false);
  13917. $export($export.P, 'String', {
  13918. // 21.1.3.3 String.prototype.codePointAt(pos)
  13919. codePointAt: function codePointAt(pos){
  13920. return $at(this, pos);
  13921. }
  13922. });
  13923. /***/ }),
  13924. /* 116 */
  13925. /***/ (function(module, exports, __webpack_require__) {
  13926. "use strict";
  13927. // 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
  13928. var $export = __webpack_require__(3)
  13929. , toLength = __webpack_require__(24)
  13930. , context = __webpack_require__(84)
  13931. , ENDS_WITH = 'endsWith'
  13932. , $endsWith = ''[ENDS_WITH];
  13933. $export($export.P + $export.F * __webpack_require__(76)(ENDS_WITH), 'String', {
  13934. endsWith: function endsWith(searchString /*, endPosition = @length */){
  13935. var that = context(this, searchString, ENDS_WITH)
  13936. , endPosition = arguments.length > 1 ? arguments[1] : undefined
  13937. , len = toLength(that.length)
  13938. , end = endPosition === undefined ? len : Math.min(toLength(endPosition), len)
  13939. , search = String(searchString);
  13940. return $endsWith
  13941. ? $endsWith.call(that, search, end)
  13942. : that.slice(end - search.length, end) === search;
  13943. }
  13944. });
  13945. /***/ }),
  13946. /* 117 */
  13947. /***/ (function(module, exports, __webpack_require__) {
  13948. var $export = __webpack_require__(3)
  13949. , toIndex = __webpack_require__(59)
  13950. , fromCharCode = String.fromCharCode
  13951. , $fromCodePoint = String.fromCodePoint;
  13952. // length should be 1, old FF problem
  13953. $export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
  13954. // 21.1.2.2 String.fromCodePoint(...codePoints)
  13955. fromCodePoint: function fromCodePoint(x){ // eslint-disable-line no-unused-vars
  13956. var res = []
  13957. , aLen = arguments.length
  13958. , i = 0
  13959. , code;
  13960. while(aLen > i){
  13961. code = +arguments[i++];
  13962. if(toIndex(code, 0x10ffff) !== code)throw RangeError(code + ' is not a valid code point');
  13963. res.push(code < 0x10000
  13964. ? fromCharCode(code)
  13965. : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
  13966. );
  13967. } return res.join('');
  13968. }
  13969. });
  13970. /***/ }),
  13971. /* 118 */
  13972. /***/ (function(module, exports, __webpack_require__) {
  13973. "use strict";
  13974. // 21.1.3.7 String.prototype.includes(searchString, position = 0)
  13975. var $export = __webpack_require__(3)
  13976. , context = __webpack_require__(84)
  13977. , INCLUDES = 'includes';
  13978. $export($export.P + $export.F * __webpack_require__(76)(INCLUDES), 'String', {
  13979. includes: function includes(searchString /*, position = 0 */){
  13980. return !!~context(this, searchString, INCLUDES)
  13981. .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
  13982. }
  13983. });
  13984. /***/ }),
  13985. /* 119 */
  13986. /***/ (function(module, exports, __webpack_require__) {
  13987. var $export = __webpack_require__(3)
  13988. , toIObject = __webpack_require__(23)
  13989. , toLength = __webpack_require__(24);
  13990. $export($export.S, 'String', {
  13991. // 21.1.2.4 String.raw(callSite, ...substitutions)
  13992. raw: function raw(callSite){
  13993. var tpl = toIObject(callSite.raw)
  13994. , len = toLength(tpl.length)
  13995. , aLen = arguments.length
  13996. , res = []
  13997. , i = 0;
  13998. while(len > i){
  13999. res.push(String(tpl[i++]));
  14000. if(i < aLen)res.push(String(arguments[i]));
  14001. } return res.join('');
  14002. }
  14003. });
  14004. /***/ }),
  14005. /* 120 */
  14006. /***/ (function(module, exports, __webpack_require__) {
  14007. var $export = __webpack_require__(3);
  14008. $export($export.P, 'String', {
  14009. // 21.1.3.13 String.prototype.repeat(count)
  14010. repeat: __webpack_require__(174)
  14011. });
  14012. /***/ }),
  14013. /* 121 */
  14014. /***/ (function(module, exports, __webpack_require__) {
  14015. "use strict";
  14016. // 21.1.3.18 String.prototype.startsWith(searchString [, position ])
  14017. var $export = __webpack_require__(3)
  14018. , toLength = __webpack_require__(24)
  14019. , context = __webpack_require__(84)
  14020. , STARTS_WITH = 'startsWith'
  14021. , $startsWith = ''[STARTS_WITH];
  14022. $export($export.P + $export.F * __webpack_require__(76)(STARTS_WITH), 'String', {
  14023. startsWith: function startsWith(searchString /*, position = 0 */){
  14024. var that = context(this, searchString, STARTS_WITH)
  14025. , index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length))
  14026. , search = String(searchString);
  14027. return $startsWith
  14028. ? $startsWith.call(that, search, index)
  14029. : that.slice(index, index + search.length) === search;
  14030. }
  14031. });
  14032. /***/ }),
  14033. /* 122 */
  14034. /***/ (function(module, exports, __webpack_require__) {
  14035. "use strict";
  14036. // ECMAScript 6 symbols shim
  14037. var global = __webpack_require__(13)
  14038. , has = __webpack_require__(22)
  14039. , DESCRIPTORS = __webpack_require__(21)
  14040. , $export = __webpack_require__(3)
  14041. , redefine = __webpack_require__(33)
  14042. , META = __webpack_require__(46).KEY
  14043. , $fails = __webpack_require__(31)
  14044. , shared = __webpack_require__(83)
  14045. , setToStringTag = __webpack_require__(48)
  14046. , uid = __webpack_require__(49)
  14047. , wks = __webpack_require__(10)
  14048. , wksExt = __webpack_require__(175)
  14049. , wksDefine = __webpack_require__(295)
  14050. , keyOf = __webpack_require__(286)
  14051. , enumKeys = __webpack_require__(281)
  14052. , isArray = __webpack_require__(162)
  14053. , anObject = __webpack_require__(18)
  14054. , toIObject = __webpack_require__(23)
  14055. , toPrimitive = __webpack_require__(86)
  14056. , createDesc = __webpack_require__(40)
  14057. , _create = __webpack_require__(79)
  14058. , gOPNExt = __webpack_require__(289)
  14059. , $GOPD = __webpack_require__(80)
  14060. , $DP = __webpack_require__(19)
  14061. , $keys = __webpack_require__(39)
  14062. , gOPD = $GOPD.f
  14063. , dP = $DP.f
  14064. , gOPN = gOPNExt.f
  14065. , $Symbol = global.Symbol
  14066. , $JSON = global.JSON
  14067. , _stringify = $JSON && $JSON.stringify
  14068. , PROTOTYPE = 'prototype'
  14069. , HIDDEN = wks('_hidden')
  14070. , TO_PRIMITIVE = wks('toPrimitive')
  14071. , isEnum = {}.propertyIsEnumerable
  14072. , SymbolRegistry = shared('symbol-registry')
  14073. , AllSymbols = shared('symbols')
  14074. , OPSymbols = shared('op-symbols')
  14075. , ObjectProto = Object[PROTOTYPE]
  14076. , USE_NATIVE = typeof $Symbol == 'function'
  14077. , QObject = global.QObject;
  14078. // Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
  14079. var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
  14080. // fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
  14081. var setSymbolDesc = DESCRIPTORS && $fails(function(){
  14082. return _create(dP({}, 'a', {
  14083. get: function(){ return dP(this, 'a', {value: 7}).a; }
  14084. })).a != 7;
  14085. }) ? function(it, key, D){
  14086. var protoDesc = gOPD(ObjectProto, key);
  14087. if(protoDesc)delete ObjectProto[key];
  14088. dP(it, key, D);
  14089. if(protoDesc && it !== ObjectProto)dP(ObjectProto, key, protoDesc);
  14090. } : dP;
  14091. var wrap = function(tag){
  14092. var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
  14093. sym._k = tag;
  14094. return sym;
  14095. };
  14096. var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function(it){
  14097. return typeof it == 'symbol';
  14098. } : function(it){
  14099. return it instanceof $Symbol;
  14100. };
  14101. var $defineProperty = function defineProperty(it, key, D){
  14102. if(it === ObjectProto)$defineProperty(OPSymbols, key, D);
  14103. anObject(it);
  14104. key = toPrimitive(key, true);
  14105. anObject(D);
  14106. if(has(AllSymbols, key)){
  14107. if(!D.enumerable){
  14108. if(!has(it, HIDDEN))dP(it, HIDDEN, createDesc(1, {}));
  14109. it[HIDDEN][key] = true;
  14110. } else {
  14111. if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
  14112. D = _create(D, {enumerable: createDesc(0, false)});
  14113. } return setSymbolDesc(it, key, D);
  14114. } return dP(it, key, D);
  14115. };
  14116. var $defineProperties = function defineProperties(it, P){
  14117. anObject(it);
  14118. var keys = enumKeys(P = toIObject(P))
  14119. , i = 0
  14120. , l = keys.length
  14121. , key;
  14122. while(l > i)$defineProperty(it, key = keys[i++], P[key]);
  14123. return it;
  14124. };
  14125. var $create = function create(it, P){
  14126. return P === undefined ? _create(it) : $defineProperties(_create(it), P);
  14127. };
  14128. var $propertyIsEnumerable = function propertyIsEnumerable(key){
  14129. var E = isEnum.call(this, key = toPrimitive(key, true));
  14130. if(this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return false;
  14131. return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
  14132. };
  14133. var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key){
  14134. it = toIObject(it);
  14135. key = toPrimitive(key, true);
  14136. if(it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key))return;
  14137. var D = gOPD(it, key);
  14138. if(D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key]))D.enumerable = true;
  14139. return D;
  14140. };
  14141. var $getOwnPropertyNames = function getOwnPropertyNames(it){
  14142. var names = gOPN(toIObject(it))
  14143. , result = []
  14144. , i = 0
  14145. , key;
  14146. while(names.length > i){
  14147. if(!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META)result.push(key);
  14148. } return result;
  14149. };
  14150. var $getOwnPropertySymbols = function getOwnPropertySymbols(it){
  14151. var IS_OP = it === ObjectProto
  14152. , names = gOPN(IS_OP ? OPSymbols : toIObject(it))
  14153. , result = []
  14154. , i = 0
  14155. , key;
  14156. while(names.length > i){
  14157. if(has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true))result.push(AllSymbols[key]);
  14158. } return result;
  14159. };
  14160. // 19.4.1.1 Symbol([description])
  14161. if(!USE_NATIVE){
  14162. $Symbol = function Symbol(){
  14163. if(this instanceof $Symbol)throw TypeError('Symbol is not a constructor!');
  14164. var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
  14165. var $set = function(value){
  14166. if(this === ObjectProto)$set.call(OPSymbols, value);
  14167. if(has(this, HIDDEN) && has(this[HIDDEN], tag))this[HIDDEN][tag] = false;
  14168. setSymbolDesc(this, tag, createDesc(1, value));
  14169. };
  14170. if(DESCRIPTORS && setter)setSymbolDesc(ObjectProto, tag, {configurable: true, set: $set});
  14171. return wrap(tag);
  14172. };
  14173. redefine($Symbol[PROTOTYPE], 'toString', function toString(){
  14174. return this._k;
  14175. });
  14176. $GOPD.f = $getOwnPropertyDescriptor;
  14177. $DP.f = $defineProperty;
  14178. __webpack_require__(81).f = gOPNExt.f = $getOwnPropertyNames;
  14179. __webpack_require__(47).f = $propertyIsEnumerable;
  14180. __webpack_require__(57).f = $getOwnPropertySymbols;
  14181. if(DESCRIPTORS && !__webpack_require__(56)){
  14182. redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
  14183. }
  14184. wksExt.f = function(name){
  14185. return wrap(wks(name));
  14186. }
  14187. }
  14188. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Symbol: $Symbol});
  14189. for(var symbols = (
  14190. // 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
  14191. 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
  14192. ).split(','), i = 0; symbols.length > i; )wks(symbols[i++]);
  14193. for(var symbols = $keys(wks.store), i = 0; symbols.length > i; )wksDefine(symbols[i++]);
  14194. $export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
  14195. // 19.4.2.1 Symbol.for(key)
  14196. 'for': function(key){
  14197. return has(SymbolRegistry, key += '')
  14198. ? SymbolRegistry[key]
  14199. : SymbolRegistry[key] = $Symbol(key);
  14200. },
  14201. // 19.4.2.5 Symbol.keyFor(sym)
  14202. keyFor: function keyFor(key){
  14203. if(isSymbol(key))return keyOf(SymbolRegistry, key);
  14204. throw TypeError(key + ' is not a symbol!');
  14205. },
  14206. useSetter: function(){ setter = true; },
  14207. useSimple: function(){ setter = false; }
  14208. });
  14209. $export($export.S + $export.F * !USE_NATIVE, 'Object', {
  14210. // 19.1.2.2 Object.create(O [, Properties])
  14211. create: $create,
  14212. // 19.1.2.4 Object.defineProperty(O, P, Attributes)
  14213. defineProperty: $defineProperty,
  14214. // 19.1.2.3 Object.defineProperties(O, Properties)
  14215. defineProperties: $defineProperties,
  14216. // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
  14217. getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
  14218. // 19.1.2.7 Object.getOwnPropertyNames(O)
  14219. getOwnPropertyNames: $getOwnPropertyNames,
  14220. // 19.1.2.8 Object.getOwnPropertySymbols(O)
  14221. getOwnPropertySymbols: $getOwnPropertySymbols
  14222. });
  14223. // 24.3.2 JSON.stringify(value [, replacer [, space]])
  14224. $JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function(){
  14225. var S = $Symbol();
  14226. // MS Edge converts symbol values to JSON as {}
  14227. // WebKit converts symbol values to JSON as null
  14228. // V8 throws on boxed symbols
  14229. return _stringify([S]) != '[null]' || _stringify({a: S}) != '{}' || _stringify(Object(S)) != '{}';
  14230. })), 'JSON', {
  14231. stringify: function stringify(it){
  14232. if(it === undefined || isSymbol(it))return; // IE8 returns string on undefined
  14233. var args = [it]
  14234. , i = 1
  14235. , replacer, $replacer;
  14236. while(arguments.length > i)args.push(arguments[i++]);
  14237. replacer = args[1];
  14238. if(typeof replacer == 'function')$replacer = replacer;
  14239. if($replacer || !isArray(replacer))replacer = function(key, value){
  14240. if($replacer)value = $replacer.call(this, key, value);
  14241. if(!isSymbol(value))return value;
  14242. };
  14243. args[1] = replacer;
  14244. return _stringify.apply($JSON, args);
  14245. }
  14246. });
  14247. // 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
  14248. $Symbol[PROTOTYPE][TO_PRIMITIVE] || __webpack_require__(32)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
  14249. // 19.4.3.5 Symbol.prototype[@@toStringTag]
  14250. setToStringTag($Symbol, 'Symbol');
  14251. // 20.2.1.9 Math[@@toStringTag]
  14252. setToStringTag(Math, 'Math', true);
  14253. // 24.3.3 JSON[@@toStringTag]
  14254. setToStringTag(global.JSON, 'JSON', true);
  14255. /***/ }),
  14256. /* 123 */
  14257. /***/ (function(module, exports, __webpack_require__) {
  14258. "use strict";
  14259. var each = __webpack_require__(52)(0)
  14260. , redefine = __webpack_require__(33)
  14261. , meta = __webpack_require__(46)
  14262. , assign = __webpack_require__(168)
  14263. , weak = __webpack_require__(158)
  14264. , isObject = __webpack_require__(15)
  14265. , getWeak = meta.getWeak
  14266. , isExtensible = Object.isExtensible
  14267. , uncaughtFrozenStore = weak.ufstore
  14268. , tmp = {}
  14269. , InternalMap;
  14270. var wrapper = function(get){
  14271. return function WeakMap(){
  14272. return get(this, arguments.length > 0 ? arguments[0] : undefined);
  14273. };
  14274. };
  14275. var methods = {
  14276. // 23.3.3.3 WeakMap.prototype.get(key)
  14277. get: function get(key){
  14278. if(isObject(key)){
  14279. var data = getWeak(key);
  14280. if(data === true)return uncaughtFrozenStore(this).get(key);
  14281. return data ? data[this._i] : undefined;
  14282. }
  14283. },
  14284. // 23.3.3.5 WeakMap.prototype.set(key, value)
  14285. set: function set(key, value){
  14286. return weak.def(this, key, value);
  14287. }
  14288. };
  14289. // 23.3 WeakMap Objects
  14290. var $WeakMap = module.exports = __webpack_require__(53)('WeakMap', wrapper, methods, weak, true, true);
  14291. // IE11 WeakMap frozen keys fix
  14292. if(new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7){
  14293. InternalMap = weak.getConstructor(wrapper);
  14294. assign(InternalMap.prototype, methods);
  14295. meta.NEED = true;
  14296. each(['delete', 'has', 'get', 'set'], function(key){
  14297. var proto = $WeakMap.prototype
  14298. , method = proto[key];
  14299. redefine(proto, key, function(a, b){
  14300. // store frozen objects on internal weakmap shim
  14301. if(isObject(a) && !isExtensible(a)){
  14302. if(!this._f)this._f = new InternalMap;
  14303. var result = this._f[key](a, b);
  14304. return key == 'set' ? this : result;
  14305. // store all the rest on native weakmap
  14306. } return method.call(this, a, b);
  14307. });
  14308. });
  14309. }
  14310. /***/ }),
  14311. /* 124 */
  14312. /***/ (function(module, exports, __webpack_require__) {
  14313. "use strict";
  14314. var weak = __webpack_require__(158);
  14315. // 23.4 WeakSet Objects
  14316. __webpack_require__(53)('WeakSet', function(get){
  14317. return function WeakSet(){ return get(this, arguments.length > 0 ? arguments[0] : undefined); };
  14318. }, {
  14319. // 23.4.3.1 WeakSet.prototype.add(value)
  14320. add: function add(value){
  14321. return weak.def(this, value, true);
  14322. }
  14323. }, weak, false, true);
  14324. /***/ }),
  14325. /* 125 */
  14326. /***/ (function(module, exports, __webpack_require__) {
  14327. "use strict";
  14328. // https://github.com/tc39/Array.prototype.includes
  14329. var $export = __webpack_require__(3)
  14330. , $includes = __webpack_require__(155)(true);
  14331. $export($export.P, 'Array', {
  14332. includes: function includes(el /*, fromIndex = 0 */){
  14333. return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
  14334. }
  14335. });
  14336. __webpack_require__(37)('includes');
  14337. /***/ }),
  14338. /* 126 */
  14339. /***/ (function(module, exports, __webpack_require__) {
  14340. // https://github.com/tc39/proposal-object-values-entries
  14341. var $export = __webpack_require__(3)
  14342. , $entries = __webpack_require__(170)(true);
  14343. $export($export.S, 'Object', {
  14344. entries: function entries(it){
  14345. return $entries(it);
  14346. }
  14347. });
  14348. /***/ }),
  14349. /* 127 */
  14350. /***/ (function(module, exports, __webpack_require__) {
  14351. // https://github.com/tc39/proposal-object-getownpropertydescriptors
  14352. var $export = __webpack_require__(3)
  14353. , ownKeys = __webpack_require__(291)
  14354. , toIObject = __webpack_require__(23)
  14355. , gOPD = __webpack_require__(80)
  14356. , createProperty = __webpack_require__(73);
  14357. $export($export.S, 'Object', {
  14358. getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object){
  14359. var O = toIObject(object)
  14360. , getDesc = gOPD.f
  14361. , keys = ownKeys(O)
  14362. , result = {}
  14363. , i = 0
  14364. , key;
  14365. while(keys.length > i)createProperty(result, key = keys[i++], getDesc(O, key));
  14366. return result;
  14367. }
  14368. });
  14369. /***/ }),
  14370. /* 128 */
  14371. /***/ (function(module, exports, __webpack_require__) {
  14372. // https://github.com/tc39/proposal-object-values-entries
  14373. var $export = __webpack_require__(3)
  14374. , $values = __webpack_require__(170)(false);
  14375. $export($export.S, 'Object', {
  14376. values: function values(it){
  14377. return $values(it);
  14378. }
  14379. });
  14380. /***/ }),
  14381. /* 129 */
  14382. /***/ (function(module, exports, __webpack_require__) {
  14383. "use strict";
  14384. // https://github.com/tc39/proposal-string-pad-start-end
  14385. var $export = __webpack_require__(3)
  14386. , $pad = __webpack_require__(173);
  14387. $export($export.P, 'String', {
  14388. padEnd: function padEnd(maxLength /*, fillString = ' ' */){
  14389. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
  14390. }
  14391. });
  14392. /***/ }),
  14393. /* 130 */
  14394. /***/ (function(module, exports, __webpack_require__) {
  14395. "use strict";
  14396. // https://github.com/tc39/proposal-string-pad-start-end
  14397. var $export = __webpack_require__(3)
  14398. , $pad = __webpack_require__(173);
  14399. $export($export.P, 'String', {
  14400. padStart: function padStart(maxLength /*, fillString = ' ' */){
  14401. return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
  14402. }
  14403. });
  14404. /***/ }),
  14405. /* 131 */
  14406. /***/ (function(module, exports, __webpack_require__) {
  14407. var $iterators = __webpack_require__(67)
  14408. , redefine = __webpack_require__(33)
  14409. , global = __webpack_require__(13)
  14410. , hide = __webpack_require__(32)
  14411. , Iterators = __webpack_require__(45)
  14412. , wks = __webpack_require__(10)
  14413. , ITERATOR = wks('iterator')
  14414. , TO_STRING_TAG = wks('toStringTag')
  14415. , ArrayValues = Iterators.Array;
  14416. for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
  14417. var NAME = collections[i]
  14418. , Collection = global[NAME]
  14419. , proto = Collection && Collection.prototype
  14420. , key;
  14421. if(proto){
  14422. if(!proto[ITERATOR])hide(proto, ITERATOR, ArrayValues);
  14423. if(!proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
  14424. Iterators[NAME] = ArrayValues;
  14425. for(key in $iterators)if(!proto[key])redefine(proto, key, $iterators[key], true);
  14426. }
  14427. }
  14428. /***/ }),
  14429. /* 132 */
  14430. /***/ (function(module, exports, __webpack_require__) {
  14431. var $export = __webpack_require__(3)
  14432. , $task = __webpack_require__(85);
  14433. $export($export.G + $export.B, {
  14434. setImmediate: $task.set,
  14435. clearImmediate: $task.clear
  14436. });
  14437. /***/ }),
  14438. /* 133 */
  14439. /***/ (function(module, exports, __webpack_require__) {
  14440. "use strict";
  14441. /**
  14442. * SheetClip - Spreadsheet Clipboard Parser
  14443. * version 0.2
  14444. *
  14445. * This tiny library transforms JavaScript arrays to strings that are pasteable by LibreOffice, OpenOffice,
  14446. * Google Docs and Microsoft Excel.
  14447. *
  14448. * Copyright 2012, Marcin Warpechowski
  14449. * Licensed under the MIT license.
  14450. * http://github.com/warpech/sheetclip/
  14451. */
  14452. /*jslint white: true*/
  14453. (function (global) {
  14454. "use strict";
  14455. function countQuotes(str) {
  14456. return str.split('"').length - 1;
  14457. }
  14458. var SheetClip = {
  14459. /**
  14460. * Decode spreadsheet string into array
  14461. *
  14462. * @param {String} str
  14463. * @returns {Array}
  14464. */
  14465. parse: function parse(str) {
  14466. var r,
  14467. rLen,
  14468. rows,
  14469. arr = [],
  14470. a = 0,
  14471. c,
  14472. cLen,
  14473. multiline,
  14474. last;
  14475. rows = str.split('\n');
  14476. if (rows.length > 1 && rows[rows.length - 1] === '') {
  14477. rows.pop();
  14478. }
  14479. for (r = 0, rLen = rows.length; r < rLen; r += 1) {
  14480. rows[r] = rows[r].split('\t');
  14481. for (c = 0, cLen = rows[r].length; c < cLen; c += 1) {
  14482. if (!arr[a]) {
  14483. arr[a] = [];
  14484. }
  14485. if (multiline && c === 0) {
  14486. last = arr[a].length - 1;
  14487. arr[a][last] = arr[a][last] + '\n' + rows[r][0];
  14488. if (multiline && countQuotes(rows[r][0]) & 1) {
  14489. //& 1 is a bitwise way of performing mod 2
  14490. multiline = false;
  14491. arr[a][last] = arr[a][last].substring(0, arr[a][last].length - 1).replace(/""/g, '"');
  14492. }
  14493. } else {
  14494. if (c === cLen - 1 && rows[r][c].indexOf('"') === 0 && countQuotes(rows[r][c]) & 1) {
  14495. arr[a].push(rows[r][c].substring(1).replace(/""/g, '"'));
  14496. multiline = true;
  14497. } else {
  14498. arr[a].push(rows[r][c].replace(/""/g, '"'));
  14499. multiline = false;
  14500. }
  14501. }
  14502. }
  14503. if (!multiline) {
  14504. a += 1;
  14505. }
  14506. }
  14507. return arr;
  14508. },
  14509. /**
  14510. * Encode array into valid spreadsheet string
  14511. *
  14512. * @param arr
  14513. * @returns {String}
  14514. */
  14515. stringify: function stringify(arr) {
  14516. var r,
  14517. rLen,
  14518. c,
  14519. cLen,
  14520. str = '',
  14521. val;
  14522. for (r = 0, rLen = arr.length; r < rLen; r += 1) {
  14523. cLen = arr[r].length;
  14524. for (c = 0; c < cLen; c += 1) {
  14525. if (c > 0) {
  14526. str += '\t';
  14527. }
  14528. val = arr[r][c];
  14529. if (typeof val === 'string') {
  14530. if (val.indexOf('\n') > -1) {
  14531. str += '"' + val.replace(/"/g, '""') + '"';
  14532. } else {
  14533. str += val;
  14534. }
  14535. } else if (val === null || val === void 0) {
  14536. // void 0 resolves to undefined
  14537. str += '';
  14538. } else {
  14539. str += val;
  14540. }
  14541. }
  14542. if (r !== rLen - 1) {
  14543. str += '\n';
  14544. }
  14545. }
  14546. return str;
  14547. }
  14548. };
  14549. if (true) {
  14550. exports.parse = SheetClip.parse;
  14551. exports.stringify = SheetClip.stringify;
  14552. } else {
  14553. global.SheetClip = SheetClip;
  14554. }
  14555. })(window);
  14556. /***/ }),
  14557. /* 134 */
  14558. /***/ (function(module, exports, __webpack_require__) {
  14559. "use strict";
  14560. 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; };
  14561. /*!
  14562. * https://github.com/Starcounter-Jack/JSON-Patch
  14563. * json-patch-duplex.js version: 0.5.7
  14564. * (c) 2013 Joachim Wester
  14565. * MIT license
  14566. */
  14567. var __extends = undefined && undefined.__extends || function (d, b) {
  14568. for (var p in b) {
  14569. if (b.hasOwnProperty(p)) d[p] = b[p];
  14570. }function __() {
  14571. this.constructor = d;
  14572. }
  14573. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14574. };
  14575. var OriginalError = Error;
  14576. var jsonpatch;
  14577. (function (jsonpatch) {
  14578. var _objectKeys = function _objectKeys(obj) {
  14579. if (_isArray(obj)) {
  14580. var keys = new Array(obj.length);
  14581. for (var k = 0; k < keys.length; k++) {
  14582. keys[k] = "" + k;
  14583. }
  14584. return keys;
  14585. }
  14586. if (Object.keys) {
  14587. return Object.keys(obj);
  14588. }
  14589. var keys = [];
  14590. for (var i in obj) {
  14591. if (obj.hasOwnProperty(i)) {
  14592. keys.push(i);
  14593. }
  14594. }
  14595. return keys;
  14596. };
  14597. function _equals(a, b) {
  14598. switch (typeof a === 'undefined' ? 'undefined' : _typeof(a)) {
  14599. case 'undefined': //backward compatibility, but really I think we should return false
  14600. case 'boolean':
  14601. case 'string':
  14602. case 'number':
  14603. return a === b;
  14604. case 'object':
  14605. if (a === null) return b === null;
  14606. if (_isArray(a)) {
  14607. if (!_isArray(b) || a.length !== b.length) return false;
  14608. for (var i = 0, l = a.length; i < l; i++) {
  14609. if (!_equals(a[i], b[i])) return false;
  14610. }return true;
  14611. }
  14612. var bKeys = _objectKeys(b);
  14613. var bLength = bKeys.length;
  14614. if (_objectKeys(a).length !== bLength) return false;
  14615. for (var i = 0; i < bLength; i++) {
  14616. if (!_equals(a[i], b[i])) return false;
  14617. }return true;
  14618. default:
  14619. return false;
  14620. }
  14621. }
  14622. /* We use a Javascript hash to store each
  14623. function. Each hash entry (property) uses
  14624. the operation identifiers specified in rfc6902.
  14625. In this way, we can map each patch operation
  14626. to its dedicated function in efficient way.
  14627. */
  14628. /* The operations applicable to an object */
  14629. var objOps = {
  14630. add: function add(obj, key) {
  14631. obj[key] = this.value;
  14632. return true;
  14633. },
  14634. remove: function remove(obj, key) {
  14635. delete obj[key];
  14636. return true;
  14637. },
  14638. replace: function replace(obj, key) {
  14639. obj[key] = this.value;
  14640. return true;
  14641. },
  14642. move: function move(obj, key, tree) {
  14643. var temp = { op: "_get", path: this.from };
  14644. apply(tree, [temp]);
  14645. apply(tree, [{ op: "remove", path: this.from }]);
  14646. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  14647. return true;
  14648. },
  14649. copy: function copy(obj, key, tree) {
  14650. var temp = { op: "_get", path: this.from };
  14651. apply(tree, [temp]);
  14652. apply(tree, [{ op: "add", path: this.path, value: temp.value }]);
  14653. return true;
  14654. },
  14655. test: function test(obj, key) {
  14656. return _equals(obj[key], this.value);
  14657. },
  14658. _get: function _get(obj, key) {
  14659. this.value = obj[key];
  14660. }
  14661. };
  14662. /* The operations applicable to an array. Many are the same as for the object */
  14663. var arrOps = {
  14664. add: function add(arr, i) {
  14665. arr.splice(i, 0, this.value);
  14666. return true;
  14667. },
  14668. remove: function remove(arr, i) {
  14669. arr.splice(i, 1);
  14670. return true;
  14671. },
  14672. replace: function replace(arr, i) {
  14673. arr[i] = this.value;
  14674. return true;
  14675. },
  14676. move: objOps.move,
  14677. copy: objOps.copy,
  14678. test: objOps.test,
  14679. _get: objOps._get
  14680. };
  14681. /* The operations applicable to object root. Many are the same as for the object */
  14682. var rootOps = {
  14683. add: function add(obj) {
  14684. rootOps.remove.call(this, obj);
  14685. for (var key in this.value) {
  14686. if (this.value.hasOwnProperty(key)) {
  14687. obj[key] = this.value[key];
  14688. }
  14689. }
  14690. return true;
  14691. },
  14692. remove: function remove(obj) {
  14693. for (var key in obj) {
  14694. if (obj.hasOwnProperty(key)) {
  14695. objOps.remove.call(this, obj, key);
  14696. }
  14697. }
  14698. return true;
  14699. },
  14700. replace: function replace(obj) {
  14701. apply(obj, [{ op: "remove", path: this.path }]);
  14702. apply(obj, [{ op: "add", path: this.path, value: this.value }]);
  14703. return true;
  14704. },
  14705. move: objOps.move,
  14706. copy: objOps.copy,
  14707. test: function test(obj) {
  14708. return JSON.stringify(obj) === JSON.stringify(this.value);
  14709. },
  14710. _get: function _get(obj) {
  14711. this.value = obj;
  14712. }
  14713. };
  14714. var observeOps = {
  14715. add: function add(patches, path) {
  14716. var patch = {
  14717. op: "add",
  14718. path: path + escapePathComponent(this.name),
  14719. value: this.object[this.name] };
  14720. patches.push(patch);
  14721. },
  14722. 'delete': function _delete(patches, path) {
  14723. var patch = {
  14724. op: "remove",
  14725. path: path + escapePathComponent(this.name)
  14726. };
  14727. patches.push(patch);
  14728. },
  14729. update: function update(patches, path) {
  14730. var patch = {
  14731. op: "replace",
  14732. path: path + escapePathComponent(this.name),
  14733. value: this.object[this.name]
  14734. };
  14735. patches.push(patch);
  14736. }
  14737. };
  14738. function escapePathComponent(str) {
  14739. if (str.indexOf('/') === -1 && str.indexOf('~') === -1) return str;
  14740. return str.replace(/~/g, '~0').replace(/\//g, '~1');
  14741. }
  14742. function _getPathRecursive(root, obj) {
  14743. var found;
  14744. for (var key in root) {
  14745. if (root.hasOwnProperty(key)) {
  14746. if (root[key] === obj) {
  14747. return escapePathComponent(key) + '/';
  14748. } else if (_typeof(root[key]) === 'object') {
  14749. found = _getPathRecursive(root[key], obj);
  14750. if (found != '') {
  14751. return escapePathComponent(key) + '/' + found;
  14752. }
  14753. }
  14754. }
  14755. }
  14756. return '';
  14757. }
  14758. function getPath(root, obj) {
  14759. if (root === obj) {
  14760. return '/';
  14761. }
  14762. var path = _getPathRecursive(root, obj);
  14763. if (path === '') {
  14764. throw new OriginalError("Object not found in root");
  14765. }
  14766. return '/' + path;
  14767. }
  14768. var beforeDict = [];
  14769. var Mirror = function () {
  14770. function Mirror(obj) {
  14771. this.observers = [];
  14772. this.obj = obj;
  14773. }
  14774. return Mirror;
  14775. }();
  14776. var ObserverInfo = function () {
  14777. function ObserverInfo(callback, observer) {
  14778. this.callback = callback;
  14779. this.observer = observer;
  14780. }
  14781. return ObserverInfo;
  14782. }();
  14783. function getMirror(obj) {
  14784. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  14785. if (beforeDict[i].obj === obj) {
  14786. return beforeDict[i];
  14787. }
  14788. }
  14789. }
  14790. function getObserverFromMirror(mirror, callback) {
  14791. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  14792. if (mirror.observers[j].callback === callback) {
  14793. return mirror.observers[j].observer;
  14794. }
  14795. }
  14796. }
  14797. function removeObserverFromMirror(mirror, observer) {
  14798. for (var j = 0, jlen = mirror.observers.length; j < jlen; j++) {
  14799. if (mirror.observers[j].observer === observer) {
  14800. mirror.observers.splice(j, 1);
  14801. return;
  14802. }
  14803. }
  14804. }
  14805. function unobserve(root, observer) {
  14806. observer.unobserve();
  14807. }
  14808. jsonpatch.unobserve = unobserve;
  14809. function deepClone(obj) {
  14810. if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === "object") {
  14811. return JSON.parse(JSON.stringify(obj)); //Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5
  14812. } else {
  14813. return obj; //no need to clone primitives
  14814. }
  14815. }
  14816. function observe(obj, callback) {
  14817. var patches = [];
  14818. var root = obj;
  14819. var observer;
  14820. var mirror = getMirror(obj);
  14821. if (!mirror) {
  14822. mirror = new Mirror(obj);
  14823. beforeDict.push(mirror);
  14824. } else {
  14825. observer = getObserverFromMirror(mirror, callback);
  14826. }
  14827. if (observer) {
  14828. return observer;
  14829. }
  14830. observer = {};
  14831. mirror.value = deepClone(obj);
  14832. if (callback) {
  14833. observer.callback = callback;
  14834. observer.next = null;
  14835. var intervals = this.intervals || [100, 1000, 10000, 60000];
  14836. if (intervals.push === void 0) {
  14837. throw new OriginalError("jsonpatch.intervals must be an array");
  14838. }
  14839. var currentInterval = 0;
  14840. var dirtyCheck = function dirtyCheck() {
  14841. generate(observer);
  14842. };
  14843. var fastCheck = function fastCheck() {
  14844. clearTimeout(observer.next);
  14845. observer.next = setTimeout(function () {
  14846. dirtyCheck();
  14847. currentInterval = 0;
  14848. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  14849. }, 0);
  14850. };
  14851. var slowCheck = function slowCheck() {
  14852. dirtyCheck();
  14853. if (currentInterval == intervals.length) currentInterval = intervals.length - 1;
  14854. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  14855. };
  14856. if (typeof window !== 'undefined') {
  14857. if (window.addEventListener) {
  14858. window.addEventListener('mousedown', fastCheck);
  14859. window.addEventListener('mouseup', fastCheck);
  14860. window.addEventListener('keydown', fastCheck);
  14861. } else {
  14862. document.documentElement.attachEvent('onmousedown', fastCheck);
  14863. document.documentElement.attachEvent('onmouseup', fastCheck);
  14864. document.documentElement.attachEvent('onkeydown', fastCheck);
  14865. }
  14866. }
  14867. observer.next = setTimeout(slowCheck, intervals[currentInterval++]);
  14868. }
  14869. observer.patches = patches;
  14870. observer.object = obj;
  14871. observer.unobserve = function () {
  14872. generate(observer);
  14873. clearTimeout(observer.next);
  14874. removeObserverFromMirror(mirror, observer);
  14875. if (typeof window !== 'undefined') {
  14876. if (window.removeEventListener) {
  14877. window.removeEventListener('mousedown', fastCheck);
  14878. window.removeEventListener('mouseup', fastCheck);
  14879. window.removeEventListener('keydown', fastCheck);
  14880. } else {
  14881. document.documentElement.detachEvent('onmousedown', fastCheck);
  14882. document.documentElement.detachEvent('onmouseup', fastCheck);
  14883. document.documentElement.detachEvent('onkeydown', fastCheck);
  14884. }
  14885. }
  14886. };
  14887. mirror.observers.push(new ObserverInfo(callback, observer));
  14888. return observer;
  14889. }
  14890. jsonpatch.observe = observe;
  14891. function generate(observer) {
  14892. var mirror;
  14893. for (var i = 0, ilen = beforeDict.length; i < ilen; i++) {
  14894. if (beforeDict[i].obj === observer.object) {
  14895. mirror = beforeDict[i];
  14896. break;
  14897. }
  14898. }
  14899. _generate(mirror.value, observer.object, observer.patches, "");
  14900. if (observer.patches.length) {
  14901. apply(mirror.value, observer.patches);
  14902. }
  14903. var temp = observer.patches;
  14904. if (temp.length > 0) {
  14905. observer.patches = [];
  14906. if (observer.callback) {
  14907. observer.callback(temp);
  14908. }
  14909. }
  14910. return temp;
  14911. }
  14912. jsonpatch.generate = generate;
  14913. // Dirty check if obj is different from mirror, generate patches and update mirror
  14914. function _generate(mirror, obj, patches, path) {
  14915. var newKeys = _objectKeys(obj);
  14916. var oldKeys = _objectKeys(mirror);
  14917. var changed = false;
  14918. var deleted = false;
  14919. //if ever "move" operation is implemented here, make sure this test runs OK: "should not generate the same patch twice (move)"
  14920. for (var t = oldKeys.length - 1; t >= 0; t--) {
  14921. var key = oldKeys[t];
  14922. var oldVal = mirror[key];
  14923. if (obj.hasOwnProperty(key)) {
  14924. var newVal = obj[key];
  14925. if ((typeof oldVal === 'undefined' ? 'undefined' : _typeof(oldVal)) == "object" && oldVal != null && (typeof newVal === 'undefined' ? 'undefined' : _typeof(newVal)) == "object" && newVal != null) {
  14926. _generate(oldVal, newVal, patches, path + "/" + escapePathComponent(key));
  14927. } else {
  14928. if (oldVal != newVal) {
  14929. changed = true;
  14930. patches.push({ op: "replace", path: path + "/" + escapePathComponent(key), value: deepClone(newVal) });
  14931. }
  14932. }
  14933. } else {
  14934. patches.push({ op: "remove", path: path + "/" + escapePathComponent(key) });
  14935. deleted = true; // property has been deleted
  14936. }
  14937. }
  14938. if (!deleted && newKeys.length == oldKeys.length) {
  14939. return;
  14940. }
  14941. for (var t = 0; t < newKeys.length; t++) {
  14942. var key = newKeys[t];
  14943. if (!mirror.hasOwnProperty(key)) {
  14944. patches.push({ op: "add", path: path + "/" + escapePathComponent(key), value: deepClone(obj[key]) });
  14945. }
  14946. }
  14947. }
  14948. var _isArray;
  14949. if (Array.isArray) {
  14950. _isArray = Array.isArray;
  14951. } else {
  14952. _isArray = function _isArray(obj) {
  14953. return obj.push && typeof obj.length === 'number';
  14954. };
  14955. }
  14956. //3x faster than cached /^\d+$/.test(str)
  14957. function isInteger(str) {
  14958. var i = 0;
  14959. var len = str.length;
  14960. var charCode;
  14961. while (i < len) {
  14962. charCode = str.charCodeAt(i);
  14963. if (charCode >= 48 && charCode <= 57) {
  14964. i++;
  14965. continue;
  14966. }
  14967. return false;
  14968. }
  14969. return true;
  14970. }
  14971. /// Apply a json-patch operation on an object tree
  14972. function apply(tree, patches, validate) {
  14973. var result = false,
  14974. p = 0,
  14975. plen = patches.length,
  14976. patch,
  14977. key;
  14978. while (p < plen) {
  14979. patch = patches[p];
  14980. p++;
  14981. // Find the object
  14982. var path = patch.path || "";
  14983. var keys = path.split('/');
  14984. var obj = tree;
  14985. var t = 1; //skip empty element - http://jsperf.com/to-shift-or-not-to-shift
  14986. var len = keys.length;
  14987. var existingPathFragment = undefined;
  14988. while (true) {
  14989. key = keys[t];
  14990. if (validate) {
  14991. if (existingPathFragment === undefined) {
  14992. if (obj[key] === undefined) {
  14993. existingPathFragment = keys.slice(0, t).join('/');
  14994. } else if (t == len - 1) {
  14995. existingPathFragment = patch.path;
  14996. }
  14997. if (existingPathFragment !== undefined) {
  14998. this.validator(patch, p - 1, tree, existingPathFragment);
  14999. }
  15000. }
  15001. }
  15002. t++;
  15003. if (key === undefined) {
  15004. if (t >= len) {
  15005. result = rootOps[patch.op].call(patch, obj, key, tree); // Apply patch
  15006. break;
  15007. }
  15008. }
  15009. if (_isArray(obj)) {
  15010. if (key === '-') {
  15011. key = obj.length;
  15012. } else {
  15013. if (validate && !isInteger(key)) {
  15014. 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);
  15015. }
  15016. key = parseInt(key, 10);
  15017. }
  15018. if (t >= len) {
  15019. if (validate && patch.op === "add" && key > obj.length) {
  15020. 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);
  15021. }
  15022. result = arrOps[patch.op].call(patch, obj, key, tree); // Apply patch
  15023. break;
  15024. }
  15025. } else {
  15026. if (key && key.indexOf('~') != -1) key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
  15027. if (t >= len) {
  15028. result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
  15029. break;
  15030. }
  15031. }
  15032. obj = obj[key];
  15033. }
  15034. }
  15035. return result;
  15036. }
  15037. jsonpatch.apply = apply;
  15038. function compare(tree1, tree2) {
  15039. var patches = [];
  15040. _generate(tree1, tree2, patches, '');
  15041. return patches;
  15042. }
  15043. jsonpatch.compare = compare;
  15044. var JsonPatchError = function (_super) {
  15045. __extends(JsonPatchError, _super);
  15046. function JsonPatchError(message, name, index, operation, tree) {
  15047. _super.call(this, message);
  15048. this.message = message;
  15049. this.name = name;
  15050. this.index = index;
  15051. this.operation = operation;
  15052. this.tree = tree;
  15053. }
  15054. return JsonPatchError;
  15055. }(OriginalError);
  15056. jsonpatch.JsonPatchError = JsonPatchError;
  15057. jsonpatch.Error = JsonPatchError;
  15058. /**
  15059. * Recursively checks whether an object has any undefined values inside.
  15060. */
  15061. function hasUndefined(obj) {
  15062. if (obj === undefined) {
  15063. return true;
  15064. }
  15065. if (typeof obj == "array" || (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == "object") {
  15066. for (var i in obj) {
  15067. if (hasUndefined(obj[i])) {
  15068. return true;
  15069. }
  15070. }
  15071. }
  15072. return false;
  15073. }
  15074. /**
  15075. * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.
  15076. * @param {object} operation - operation object (patch)
  15077. * @param {number} index - index of operation in the sequence
  15078. * @param {object} [tree] - object where the operation is supposed to be applied
  15079. * @param {string} [existingPathFragment] - comes along with `tree`
  15080. */
  15081. function validator(operation, index, tree, existingPathFragment) {
  15082. if ((typeof operation === 'undefined' ? 'undefined' : _typeof(operation)) !== 'object' || operation === null || _isArray(operation)) {
  15083. throw new JsonPatchError('Operation is not an object', 'OPERATION_NOT_AN_OBJECT', index, operation, tree);
  15084. } else if (!objOps[operation.op]) {
  15085. throw new JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, tree);
  15086. } else if (typeof operation.path !== 'string') {
  15087. throw new JsonPatchError('Operation `path` property is not a string', 'OPERATION_PATH_INVALID', index, operation, tree);
  15088. } else if ((operation.op === 'move' || operation.op === 'copy') && typeof operation.from !== 'string') {
  15089. throw new JsonPatchError('Operation `from` property is not present (applicable in `move` and `copy` operations)', 'OPERATION_FROM_REQUIRED', index, operation, tree);
  15090. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && operation.value === undefined) {
  15091. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_REQUIRED', index, operation, tree);
  15092. } else if ((operation.op === 'add' || operation.op === 'replace' || operation.op === 'test') && hasUndefined(operation.value)) {
  15093. throw new JsonPatchError('Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)', 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED', index, operation, tree);
  15094. } else if (tree) {
  15095. if (operation.op == "add") {
  15096. var pathLen = operation.path.split("/").length;
  15097. var existingPathLen = existingPathFragment.split("/").length;
  15098. if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) {
  15099. throw new JsonPatchError('Cannot perform an `add` operation at the desired path', 'OPERATION_PATH_CANNOT_ADD', index, operation, tree);
  15100. }
  15101. } else if (operation.op === 'replace' || operation.op === 'remove' || operation.op === '_get') {
  15102. if (operation.path !== existingPathFragment) {
  15103. throw new JsonPatchError('Cannot perform the operation at a path that does not exist', 'OPERATION_PATH_UNRESOLVABLE', index, operation, tree);
  15104. }
  15105. } else if (operation.op === 'move' || operation.op === 'copy') {
  15106. var existingValue = { op: "_get", path: operation.from, value: undefined };
  15107. var error = jsonpatch.validate([existingValue], tree);
  15108. if (error && error.name === 'OPERATION_PATH_UNRESOLVABLE') {
  15109. throw new JsonPatchError('Cannot perform the operation from a path that does not exist', 'OPERATION_FROM_UNRESOLVABLE', index, operation, tree);
  15110. }
  15111. }
  15112. }
  15113. }
  15114. jsonpatch.validator = validator;
  15115. /**
  15116. * Validates a sequence of operations. If `tree` parameter is provided, the sequence is additionally validated against the object tree.
  15117. * If error is encountered, returns a JsonPatchError object
  15118. * @param sequence
  15119. * @param tree
  15120. * @returns {JsonPatchError|undefined}
  15121. */
  15122. function validate(sequence, tree) {
  15123. try {
  15124. if (!_isArray(sequence)) {
  15125. throw new JsonPatchError('Patch sequence must be an array', 'SEQUENCE_NOT_AN_ARRAY');
  15126. }
  15127. if (tree) {
  15128. tree = JSON.parse(JSON.stringify(tree)); //clone tree so that we can safely try applying operations
  15129. apply.call(this, tree, sequence, true);
  15130. } else {
  15131. for (var i = 0; i < sequence.length; i++) {
  15132. this.validator(sequence[i], i);
  15133. }
  15134. }
  15135. } catch (e) {
  15136. if (e instanceof JsonPatchError) {
  15137. return e;
  15138. } else {
  15139. throw e;
  15140. }
  15141. }
  15142. }
  15143. jsonpatch.validate = validate;
  15144. })(jsonpatch || (jsonpatch = {}));
  15145. if (true) {
  15146. exports.apply = jsonpatch.apply;
  15147. exports.observe = jsonpatch.observe;
  15148. exports.unobserve = jsonpatch.unobserve;
  15149. exports.generate = jsonpatch.generate;
  15150. exports.compare = jsonpatch.compare;
  15151. exports.validate = jsonpatch.validate;
  15152. exports.validator = jsonpatch.validator;
  15153. exports.JsonPatchError = jsonpatch.JsonPatchError;
  15154. exports.Error = jsonpatch.Error;
  15155. }
  15156. /***/ }),
  15157. /* 135 */
  15158. /***/ (function(module, exports, __webpack_require__) {
  15159. "use strict";
  15160. exports.__esModule = true;
  15161. 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; }; }();
  15162. var _element = __webpack_require__(0);
  15163. var _event = __webpack_require__(7);
  15164. var _object = __webpack_require__(1);
  15165. var _browser = __webpack_require__(25);
  15166. var _eventManager = __webpack_require__(4);
  15167. var _eventManager2 = _interopRequireDefault(_eventManager);
  15168. var _coords = __webpack_require__(42);
  15169. var _coords2 = _interopRequireDefault(_coords);
  15170. var _base = __webpack_require__(28);
  15171. var _base2 = _interopRequireDefault(_base);
  15172. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  15173. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15174. /**
  15175. *
  15176. */
  15177. var Border = function () {
  15178. /**
  15179. * @param {Walkontable} wotInstance
  15180. * @param {Object} settings
  15181. */
  15182. function Border(wotInstance, settings) {
  15183. _classCallCheck(this, Border);
  15184. if (!settings) {
  15185. return;
  15186. }
  15187. this.eventManager = new _eventManager2.default(wotInstance);
  15188. this.instance = wotInstance;
  15189. this.wot = wotInstance;
  15190. this.settings = settings;
  15191. this.mouseDown = false;
  15192. this.main = null;
  15193. this.top = null;
  15194. this.left = null;
  15195. this.bottom = null;
  15196. this.right = null;
  15197. this.topStyle = null;
  15198. this.leftStyle = null;
  15199. this.bottomStyle = null;
  15200. this.rightStyle = null;
  15201. this.cornerDefaultStyle = {
  15202. width: '5px',
  15203. height: '5px',
  15204. borderWidth: '2px',
  15205. borderStyle: 'solid',
  15206. borderColor: '#FFF'
  15207. };
  15208. this.corner = null;
  15209. this.cornerStyle = null;
  15210. this.createBorders(settings);
  15211. this.registerListeners();
  15212. }
  15213. /**
  15214. * Register all necessary events
  15215. */
  15216. _createClass(Border, [{
  15217. key: 'registerListeners',
  15218. value: function registerListeners() {
  15219. var _this2 = this;
  15220. this.eventManager.addEventListener(document.body, 'mousedown', function () {
  15221. return _this2.onMouseDown();
  15222. });
  15223. this.eventManager.addEventListener(document.body, 'mouseup', function () {
  15224. return _this2.onMouseUp();
  15225. });
  15226. var _loop = function _loop(c, len) {
  15227. _this2.eventManager.addEventListener(_this2.main.childNodes[c], 'mouseenter', function (event) {
  15228. return _this2.onMouseEnter(event, _this2.main.childNodes[c]);
  15229. });
  15230. };
  15231. for (var c = 0, len = this.main.childNodes.length; c < len; c++) {
  15232. _loop(c, len);
  15233. }
  15234. }
  15235. /**
  15236. * Mouse down listener
  15237. *
  15238. * @private
  15239. */
  15240. }, {
  15241. key: 'onMouseDown',
  15242. value: function onMouseDown() {
  15243. this.mouseDown = true;
  15244. }
  15245. /**
  15246. * Mouse up listener
  15247. *
  15248. * @private
  15249. */
  15250. }, {
  15251. key: 'onMouseUp',
  15252. value: function onMouseUp() {
  15253. this.mouseDown = false;
  15254. }
  15255. /**
  15256. * Mouse enter listener for fragment selection functionality.
  15257. *
  15258. * @private
  15259. * @param {Event} event Dom event
  15260. * @param {HTMLElement} parentElement Part of border element.
  15261. */
  15262. }, {
  15263. key: 'onMouseEnter',
  15264. value: function onMouseEnter(event, parentElement) {
  15265. if (!this.mouseDown || !this.wot.getSetting('hideBorderOnMouseDownOver')) {
  15266. return;
  15267. }
  15268. event.preventDefault();
  15269. (0, _event.stopImmediatePropagation)(event);
  15270. var _this = this;
  15271. var bounds = parentElement.getBoundingClientRect();
  15272. // Hide border to prevents selection jumping when fragmentSelection is enabled.
  15273. parentElement.style.display = 'none';
  15274. function isOutside(event) {
  15275. if (event.clientY < Math.floor(bounds.top)) {
  15276. return true;
  15277. }
  15278. if (event.clientY > Math.ceil(bounds.top + bounds.height)) {
  15279. return true;
  15280. }
  15281. if (event.clientX < Math.floor(bounds.left)) {
  15282. return true;
  15283. }
  15284. if (event.clientX > Math.ceil(bounds.left + bounds.width)) {
  15285. return true;
  15286. }
  15287. }
  15288. function handler(event) {
  15289. if (isOutside(event)) {
  15290. _this.eventManager.removeEventListener(document.body, 'mousemove', handler);
  15291. parentElement.style.display = 'block';
  15292. }
  15293. }
  15294. this.eventManager.addEventListener(document.body, 'mousemove', handler);
  15295. }
  15296. /**
  15297. * Create border elements
  15298. *
  15299. * @param {Object} settings
  15300. */
  15301. }, {
  15302. key: 'createBorders',
  15303. value: function createBorders(settings) {
  15304. this.main = document.createElement('div');
  15305. var borderDivs = ['top', 'left', 'bottom', 'right', 'corner'];
  15306. var style = this.main.style;
  15307. style.position = 'absolute';
  15308. style.top = 0;
  15309. style.left = 0;
  15310. for (var i = 0; i < 5; i++) {
  15311. var position = borderDivs[i];
  15312. var div = document.createElement('div');
  15313. div.className = 'wtBorder ' + (this.settings.className || ''); // + borderDivs[i];
  15314. if (this.settings[position] && this.settings[position].hide) {
  15315. div.className += ' hidden';
  15316. }
  15317. style = div.style;
  15318. style.backgroundColor = this.settings[position] && this.settings[position].color ? this.settings[position].color : settings.border.color;
  15319. style.height = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  15320. style.width = this.settings[position] && this.settings[position].width ? this.settings[position].width + 'px' : settings.border.width + 'px';
  15321. this.main.appendChild(div);
  15322. }
  15323. this.top = this.main.childNodes[0];
  15324. this.left = this.main.childNodes[1];
  15325. this.bottom = this.main.childNodes[2];
  15326. this.right = this.main.childNodes[3];
  15327. this.topStyle = this.top.style;
  15328. this.leftStyle = this.left.style;
  15329. this.bottomStyle = this.bottom.style;
  15330. this.rightStyle = this.right.style;
  15331. this.corner = this.main.childNodes[4];
  15332. this.corner.className += ' corner';
  15333. this.cornerStyle = this.corner.style;
  15334. this.cornerStyle.width = this.cornerDefaultStyle.width;
  15335. this.cornerStyle.height = this.cornerDefaultStyle.height;
  15336. this.cornerStyle.border = [this.cornerDefaultStyle.borderWidth, this.cornerDefaultStyle.borderStyle, this.cornerDefaultStyle.borderColor].join(' ');
  15337. if ((0, _browser.isMobileBrowser)()) {
  15338. this.createMultipleSelectorHandles();
  15339. }
  15340. this.disappear();
  15341. if (!this.wot.wtTable.bordersHolder) {
  15342. this.wot.wtTable.bordersHolder = document.createElement('div');
  15343. this.wot.wtTable.bordersHolder.className = 'htBorders';
  15344. this.wot.wtTable.spreader.appendChild(this.wot.wtTable.bordersHolder);
  15345. }
  15346. this.wot.wtTable.bordersHolder.insertBefore(this.main, this.wot.wtTable.bordersHolder.firstChild);
  15347. }
  15348. /**
  15349. * Create multiple selector handler for mobile devices
  15350. */
  15351. }, {
  15352. key: 'createMultipleSelectorHandles',
  15353. value: function createMultipleSelectorHandles() {
  15354. this.selectionHandles = {
  15355. topLeft: document.createElement('DIV'),
  15356. topLeftHitArea: document.createElement('DIV'),
  15357. bottomRight: document.createElement('DIV'),
  15358. bottomRightHitArea: document.createElement('DIV')
  15359. };
  15360. var width = 10;
  15361. var hitAreaWidth = 40;
  15362. this.selectionHandles.topLeft.className = 'topLeftSelectionHandle';
  15363. this.selectionHandles.topLeftHitArea.className = 'topLeftSelectionHandle-HitArea';
  15364. this.selectionHandles.bottomRight.className = 'bottomRightSelectionHandle';
  15365. this.selectionHandles.bottomRightHitArea.className = 'bottomRightSelectionHandle-HitArea';
  15366. this.selectionHandles.styles = {
  15367. topLeft: this.selectionHandles.topLeft.style,
  15368. topLeftHitArea: this.selectionHandles.topLeftHitArea.style,
  15369. bottomRight: this.selectionHandles.bottomRight.style,
  15370. bottomRightHitArea: this.selectionHandles.bottomRightHitArea.style
  15371. };
  15372. var hitAreaStyle = {
  15373. position: 'absolute',
  15374. height: hitAreaWidth + 'px',
  15375. width: hitAreaWidth + 'px',
  15376. 'border-radius': parseInt(hitAreaWidth / 1.5, 10) + 'px'
  15377. };
  15378. for (var prop in hitAreaStyle) {
  15379. if ((0, _object.hasOwnProperty)(hitAreaStyle, prop)) {
  15380. this.selectionHandles.styles.bottomRightHitArea[prop] = hitAreaStyle[prop];
  15381. this.selectionHandles.styles.topLeftHitArea[prop] = hitAreaStyle[prop];
  15382. }
  15383. }
  15384. var handleStyle = {
  15385. position: 'absolute',
  15386. height: width + 'px',
  15387. width: width + 'px',
  15388. 'border-radius': parseInt(width / 1.5, 10) + 'px',
  15389. background: '#F5F5FF',
  15390. border: '1px solid #4285c8'
  15391. };
  15392. for (var _prop in handleStyle) {
  15393. if ((0, _object.hasOwnProperty)(handleStyle, _prop)) {
  15394. this.selectionHandles.styles.bottomRight[_prop] = handleStyle[_prop];
  15395. this.selectionHandles.styles.topLeft[_prop] = handleStyle[_prop];
  15396. }
  15397. }
  15398. this.main.appendChild(this.selectionHandles.topLeft);
  15399. this.main.appendChild(this.selectionHandles.bottomRight);
  15400. this.main.appendChild(this.selectionHandles.topLeftHitArea);
  15401. this.main.appendChild(this.selectionHandles.bottomRightHitArea);
  15402. }
  15403. }, {
  15404. key: 'isPartRange',
  15405. value: function isPartRange(row, col) {
  15406. if (this.wot.selections.area.cellRange) {
  15407. if (row != this.wot.selections.area.cellRange.to.row || col != this.wot.selections.area.cellRange.to.col) {
  15408. return true;
  15409. }
  15410. }
  15411. return false;
  15412. }
  15413. }, {
  15414. key: 'updateMultipleSelectionHandlesPosition',
  15415. value: function updateMultipleSelectionHandlesPosition(row, col, top, left, width, height) {
  15416. var handleWidth = parseInt(this.selectionHandles.styles.topLeft.width, 10);
  15417. var hitAreaWidth = parseInt(this.selectionHandles.styles.topLeftHitArea.width, 10);
  15418. this.selectionHandles.styles.topLeft.top = parseInt(top - handleWidth, 10) + 'px';
  15419. this.selectionHandles.styles.topLeft.left = parseInt(left - handleWidth, 10) + 'px';
  15420. this.selectionHandles.styles.topLeftHitArea.top = parseInt(top - hitAreaWidth / 4 * 3, 10) + 'px';
  15421. this.selectionHandles.styles.topLeftHitArea.left = parseInt(left - hitAreaWidth / 4 * 3, 10) + 'px';
  15422. this.selectionHandles.styles.bottomRight.top = parseInt(top + height, 10) + 'px';
  15423. this.selectionHandles.styles.bottomRight.left = parseInt(left + width, 10) + 'px';
  15424. this.selectionHandles.styles.bottomRightHitArea.top = parseInt(top + height - hitAreaWidth / 4, 10) + 'px';
  15425. this.selectionHandles.styles.bottomRightHitArea.left = parseInt(left + width - hitAreaWidth / 4, 10) + 'px';
  15426. if (this.settings.border.multipleSelectionHandlesVisible && this.settings.border.multipleSelectionHandlesVisible()) {
  15427. this.selectionHandles.styles.topLeft.display = 'block';
  15428. this.selectionHandles.styles.topLeftHitArea.display = 'block';
  15429. if (this.isPartRange(row, col)) {
  15430. this.selectionHandles.styles.bottomRight.display = 'none';
  15431. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  15432. } else {
  15433. this.selectionHandles.styles.bottomRight.display = 'block';
  15434. this.selectionHandles.styles.bottomRightHitArea.display = 'block';
  15435. }
  15436. } else {
  15437. this.selectionHandles.styles.topLeft.display = 'none';
  15438. this.selectionHandles.styles.bottomRight.display = 'none';
  15439. this.selectionHandles.styles.topLeftHitArea.display = 'none';
  15440. this.selectionHandles.styles.bottomRightHitArea.display = 'none';
  15441. }
  15442. if (row == this.wot.wtSettings.getSetting('fixedRowsTop') || col == this.wot.wtSettings.getSetting('fixedColumnsLeft')) {
  15443. this.selectionHandles.styles.topLeft.zIndex = '9999';
  15444. this.selectionHandles.styles.topLeftHitArea.zIndex = '9999';
  15445. } else {
  15446. this.selectionHandles.styles.topLeft.zIndex = '';
  15447. this.selectionHandles.styles.topLeftHitArea.zIndex = '';
  15448. }
  15449. }
  15450. /**
  15451. * Show border around one or many cells
  15452. *
  15453. * @param {Array} corners
  15454. */
  15455. }, {
  15456. key: 'appear',
  15457. value: function appear(corners) {
  15458. if (this.disabled) {
  15459. return;
  15460. }
  15461. var isMultiple, fromTD, toTD, fromOffset, toOffset, containerOffset, top, minTop, left, minLeft, height, width, fromRow, fromColumn, toRow, toColumn, trimmingContainer, cornerOverlappingContainer, ilen;
  15462. ilen = this.wot.wtTable.getRenderedRowsCount();
  15463. for (var i = 0; i < ilen; i++) {
  15464. var s = this.wot.wtTable.rowFilter.renderedToSource(i);
  15465. if (s >= corners[0] && s <= corners[2]) {
  15466. fromRow = s;
  15467. break;
  15468. }
  15469. }
  15470. for (var _i = ilen - 1; _i >= 0; _i--) {
  15471. var _s = this.wot.wtTable.rowFilter.renderedToSource(_i);
  15472. if (_s >= corners[0] && _s <= corners[2]) {
  15473. toRow = _s;
  15474. break;
  15475. }
  15476. }
  15477. ilen = this.wot.wtTable.getRenderedColumnsCount();
  15478. for (var _i2 = 0; _i2 < ilen; _i2++) {
  15479. var _s2 = this.wot.wtTable.columnFilter.renderedToSource(_i2);
  15480. if (_s2 >= corners[1] && _s2 <= corners[3]) {
  15481. fromColumn = _s2;
  15482. break;
  15483. }
  15484. }
  15485. for (var _i3 = ilen - 1; _i3 >= 0; _i3--) {
  15486. var _s3 = this.wot.wtTable.columnFilter.renderedToSource(_i3);
  15487. if (_s3 >= corners[1] && _s3 <= corners[3]) {
  15488. toColumn = _s3;
  15489. break;
  15490. }
  15491. }
  15492. if (fromRow === void 0 || fromColumn === void 0) {
  15493. this.disappear();
  15494. return;
  15495. }
  15496. isMultiple = fromRow !== toRow || fromColumn !== toColumn;
  15497. fromTD = this.wot.wtTable.getCell(new _coords2.default(fromRow, fromColumn));
  15498. toTD = isMultiple ? this.wot.wtTable.getCell(new _coords2.default(toRow, toColumn)) : fromTD;
  15499. fromOffset = (0, _element.offset)(fromTD);
  15500. toOffset = isMultiple ? (0, _element.offset)(toTD) : fromOffset;
  15501. containerOffset = (0, _element.offset)(this.wot.wtTable.TABLE);
  15502. minTop = fromOffset.top;
  15503. height = toOffset.top + (0, _element.outerHeight)(toTD) - minTop;
  15504. minLeft = fromOffset.left;
  15505. width = toOffset.left + (0, _element.outerWidth)(toTD) - minLeft;
  15506. top = minTop - containerOffset.top - 1;
  15507. left = minLeft - containerOffset.left - 1;
  15508. var style = (0, _element.getComputedStyle)(fromTD);
  15509. if (parseInt(style.borderTopWidth, 10) > 0) {
  15510. top += 1;
  15511. height = height > 0 ? height - 1 : 0;
  15512. }
  15513. if (parseInt(style.borderLeftWidth, 10) > 0) {
  15514. left += 1;
  15515. width = width > 0 ? width - 1 : 0;
  15516. }
  15517. this.topStyle.top = top + 'px';
  15518. this.topStyle.left = left + 'px';
  15519. this.topStyle.width = width + 'px';
  15520. this.topStyle.display = 'block';
  15521. this.leftStyle.top = top + 'px';
  15522. this.leftStyle.left = left + 'px';
  15523. this.leftStyle.height = height + 'px';
  15524. this.leftStyle.display = 'block';
  15525. var delta = Math.floor(this.settings.border.width / 2);
  15526. this.bottomStyle.top = top + height - delta + 'px';
  15527. this.bottomStyle.left = left + 'px';
  15528. this.bottomStyle.width = width + 'px';
  15529. this.bottomStyle.display = 'block';
  15530. this.rightStyle.top = top + 'px';
  15531. this.rightStyle.left = left + width - delta + 'px';
  15532. this.rightStyle.height = height + 1 + 'px';
  15533. this.rightStyle.display = 'block';
  15534. if ((0, _browser.isMobileBrowser)() || !this.hasSetting(this.settings.border.cornerVisible) || this.isPartRange(toRow, toColumn)) {
  15535. this.cornerStyle.display = 'none';
  15536. } else {
  15537. this.cornerStyle.top = top + height - 4 + 'px';
  15538. this.cornerStyle.left = left + width - 4 + 'px';
  15539. this.cornerStyle.borderRightWidth = this.cornerDefaultStyle.borderWidth;
  15540. this.cornerStyle.width = this.cornerDefaultStyle.width;
  15541. // Hide the fill handle, so the possible further adjustments won't force unneeded scrollbars.
  15542. this.cornerStyle.display = 'none';
  15543. trimmingContainer = (0, _element.getTrimmingContainer)(this.wot.wtTable.TABLE);
  15544. if (toColumn === this.wot.getSetting('totalColumns') - 1) {
  15545. cornerOverlappingContainer = toTD.offsetLeft + (0, _element.outerWidth)(toTD) + parseInt(this.cornerDefaultStyle.width, 10) / 2 >= (0, _element.innerWidth)(trimmingContainer);
  15546. if (cornerOverlappingContainer) {
  15547. this.cornerStyle.left = Math.floor(left + width - 3 - parseInt(this.cornerDefaultStyle.width, 10) / 2) + 'px';
  15548. this.cornerStyle.borderRightWidth = 0;
  15549. }
  15550. }
  15551. if (toRow === this.wot.getSetting('totalRows') - 1) {
  15552. cornerOverlappingContainer = toTD.offsetTop + (0, _element.outerHeight)(toTD) + parseInt(this.cornerDefaultStyle.height, 10) / 2 >= (0, _element.innerHeight)(trimmingContainer);
  15553. if (cornerOverlappingContainer) {
  15554. this.cornerStyle.top = Math.floor(top + height - 3 - parseInt(this.cornerDefaultStyle.height, 10) / 2) + 'px';
  15555. this.cornerStyle.borderBottomWidth = 0;
  15556. }
  15557. }
  15558. this.cornerStyle.display = 'block';
  15559. }
  15560. if ((0, _browser.isMobileBrowser)()) {
  15561. this.updateMultipleSelectionHandlesPosition(fromRow, fromColumn, top, left, width, height);
  15562. }
  15563. }
  15564. /**
  15565. * Hide border
  15566. */
  15567. }, {
  15568. key: 'disappear',
  15569. value: function disappear() {
  15570. this.topStyle.display = 'none';
  15571. this.leftStyle.display = 'none';
  15572. this.bottomStyle.display = 'none';
  15573. this.rightStyle.display = 'none';
  15574. this.cornerStyle.display = 'none';
  15575. if ((0, _browser.isMobileBrowser)()) {
  15576. this.selectionHandles.styles.topLeft.display = 'none';
  15577. this.selectionHandles.styles.bottomRight.display = 'none';
  15578. }
  15579. }
  15580. /**
  15581. * @param {Function} setting
  15582. * @returns {*}
  15583. */
  15584. }, {
  15585. key: 'hasSetting',
  15586. value: function hasSetting(setting) {
  15587. if (typeof setting === 'function') {
  15588. return setting();
  15589. }
  15590. return !!setting;
  15591. }
  15592. }]);
  15593. return Border;
  15594. }();
  15595. exports.default = Border;
  15596. /***/ }),
  15597. /* 136 */
  15598. /***/ (function(module, exports, __webpack_require__) {
  15599. "use strict";
  15600. exports.__esModule = true;
  15601. 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; }; }();
  15602. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15603. var privatePool = new WeakMap();
  15604. /**
  15605. * Calculates indexes of columns to render OR columns that are visible.
  15606. * To redo the calculation, you need to create a new calculator.
  15607. *
  15608. * @class ViewportColumnsCalculator
  15609. */
  15610. var ViewportColumnsCalculator = function () {
  15611. _createClass(ViewportColumnsCalculator, null, [{
  15612. key: 'DEFAULT_WIDTH',
  15613. /**
  15614. * Default column width
  15615. *
  15616. * @type {Number}
  15617. */
  15618. get: function get() {
  15619. return 50;
  15620. }
  15621. /**
  15622. * @param {Number} viewportWidth Width of the viewport
  15623. * @param {Number} scrollOffset Current horizontal scroll position of the viewport
  15624. * @param {Number} totalColumns Total number of rows
  15625. * @param {Function} columnWidthFn Function that returns the width of the column at a given index (in px)
  15626. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  15627. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  15628. * @param {Boolean} stretchH
  15629. * @param {Function} [stretchingColumnWidthFn] Function that returns the new width of the stretched column.
  15630. */
  15631. }]);
  15632. function ViewportColumnsCalculator(viewportWidth, scrollOffset, totalColumns, columnWidthFn, overrideFn, onlyFullyVisible, stretchH) {
  15633. var stretchingColumnWidthFn = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : function (width) {
  15634. return width;
  15635. };
  15636. _classCallCheck(this, ViewportColumnsCalculator);
  15637. privatePool.set(this, {
  15638. viewportWidth: viewportWidth,
  15639. scrollOffset: scrollOffset,
  15640. totalColumns: totalColumns,
  15641. columnWidthFn: columnWidthFn,
  15642. overrideFn: overrideFn,
  15643. onlyFullyVisible: onlyFullyVisible,
  15644. stretchingColumnWidthFn: stretchingColumnWidthFn
  15645. });
  15646. /**
  15647. * Number of rendered/visible columns
  15648. *
  15649. * @type {Number}
  15650. */
  15651. this.count = 0;
  15652. /**
  15653. * Index of the first rendered/visible column (can be overwritten using overrideFn)
  15654. *
  15655. * @type {Number|null}
  15656. */
  15657. this.startColumn = null;
  15658. /**
  15659. * Index of the last rendered/visible column (can be overwritten using overrideFn)
  15660. *
  15661. * @type {null}
  15662. */
  15663. this.endColumn = null;
  15664. /**
  15665. * Position of the first rendered/visible column (in px)
  15666. *
  15667. * @type {Number|null}
  15668. */
  15669. this.startPosition = null;
  15670. this.stretchAllRatio = 0;
  15671. this.stretchLastWidth = 0;
  15672. this.stretch = stretchH;
  15673. this.totalTargetWidth = 0;
  15674. this.needVerifyLastColumnWidth = true;
  15675. this.stretchAllColumnsWidth = [];
  15676. this.calculate();
  15677. }
  15678. /**
  15679. * Calculates viewport
  15680. */
  15681. _createClass(ViewportColumnsCalculator, [{
  15682. key: 'calculate',
  15683. value: function calculate() {
  15684. var sum = 0;
  15685. var needReverse = true;
  15686. var startPositions = [];
  15687. var columnWidth = void 0;
  15688. var priv = privatePool.get(this);
  15689. var onlyFullyVisible = priv.onlyFullyVisible;
  15690. var overrideFn = priv.overrideFn;
  15691. var scrollOffset = priv.scrollOffset;
  15692. var totalColumns = priv.totalColumns;
  15693. var viewportWidth = priv.viewportWidth;
  15694. for (var i = 0; i < totalColumns; i++) {
  15695. columnWidth = this._getColumnWidth(i);
  15696. if (sum <= scrollOffset && !onlyFullyVisible) {
  15697. this.startColumn = i;
  15698. }
  15699. // +1 pixel for row header width compensation for horizontal scroll > 0
  15700. var compensatedViewportWidth = scrollOffset > 0 ? viewportWidth + 1 : viewportWidth;
  15701. if (sum >= scrollOffset && sum + columnWidth <= scrollOffset + compensatedViewportWidth) {
  15702. if (this.startColumn == null) {
  15703. this.startColumn = i;
  15704. }
  15705. this.endColumn = i;
  15706. }
  15707. startPositions.push(sum);
  15708. sum += columnWidth;
  15709. if (!onlyFullyVisible) {
  15710. this.endColumn = i;
  15711. }
  15712. if (sum >= scrollOffset + viewportWidth) {
  15713. needReverse = false;
  15714. break;
  15715. }
  15716. }
  15717. if (this.endColumn === totalColumns - 1 && needReverse) {
  15718. this.startColumn = this.endColumn;
  15719. while (this.startColumn > 0) {
  15720. var viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
  15721. if (viewportSum <= viewportWidth || !onlyFullyVisible) {
  15722. this.startColumn--;
  15723. }
  15724. if (viewportSum > viewportWidth) {
  15725. break;
  15726. }
  15727. }
  15728. }
  15729. if (this.startColumn !== null && overrideFn) {
  15730. overrideFn(this);
  15731. }
  15732. this.startPosition = startPositions[this.startColumn];
  15733. if (this.startPosition == void 0) {
  15734. this.startPosition = null;
  15735. }
  15736. if (this.startColumn !== null) {
  15737. this.count = this.endColumn - this.startColumn + 1;
  15738. }
  15739. }
  15740. /**
  15741. * Recalculate columns stretching.
  15742. *
  15743. * @param {Number} totalWidth
  15744. */
  15745. }, {
  15746. key: 'refreshStretching',
  15747. value: function refreshStretching(totalWidth) {
  15748. if (this.stretch === 'none') {
  15749. return;
  15750. }
  15751. this.totalTargetWidth = totalWidth;
  15752. var priv = privatePool.get(this);
  15753. var totalColumns = priv.totalColumns;
  15754. var sumAll = 0;
  15755. for (var i = 0; i < totalColumns; i++) {
  15756. var columnWidth = this._getColumnWidth(i);
  15757. var permanentColumnWidth = priv.stretchingColumnWidthFn(void 0, i);
  15758. if (typeof permanentColumnWidth === 'number') {
  15759. totalWidth -= permanentColumnWidth;
  15760. } else {
  15761. sumAll += columnWidth;
  15762. }
  15763. }
  15764. var remainingSize = totalWidth - sumAll;
  15765. if (this.stretch === 'all' && remainingSize > 0) {
  15766. this.stretchAllRatio = totalWidth / sumAll;
  15767. this.stretchAllColumnsWidth = [];
  15768. this.needVerifyLastColumnWidth = true;
  15769. } else if (this.stretch === 'last' && totalWidth !== Infinity) {
  15770. var _columnWidth = this._getColumnWidth(totalColumns - 1);
  15771. var lastColumnWidth = remainingSize + _columnWidth;
  15772. this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : _columnWidth;
  15773. }
  15774. }
  15775. /**
  15776. * Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
  15777. *
  15778. * @param {Number} column
  15779. * @param {Number} baseWidth
  15780. * @returns {Number|null}
  15781. */
  15782. }, {
  15783. key: 'getStretchedColumnWidth',
  15784. value: function getStretchedColumnWidth(column, baseWidth) {
  15785. var result = null;
  15786. if (this.stretch === 'all' && this.stretchAllRatio !== 0) {
  15787. result = this._getStretchedAllColumnWidth(column, baseWidth);
  15788. } else if (this.stretch === 'last' && this.stretchLastWidth !== 0) {
  15789. result = this._getStretchedLastColumnWidth(column);
  15790. }
  15791. return result;
  15792. }
  15793. /**
  15794. * @param {Number} column
  15795. * @param {Number} baseWidth
  15796. * @returns {Number}
  15797. * @private
  15798. */
  15799. }, {
  15800. key: '_getStretchedAllColumnWidth',
  15801. value: function _getStretchedAllColumnWidth(column, baseWidth) {
  15802. var sumRatioWidth = 0;
  15803. var priv = privatePool.get(this);
  15804. var totalColumns = priv.totalColumns;
  15805. if (!this.stretchAllColumnsWidth[column]) {
  15806. var stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
  15807. var newStretchedWidth = priv.stretchingColumnWidthFn(stretchedWidth, column);
  15808. if (newStretchedWidth === void 0) {
  15809. this.stretchAllColumnsWidth[column] = stretchedWidth;
  15810. } else {
  15811. this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
  15812. }
  15813. }
  15814. if (this.stretchAllColumnsWidth.length === totalColumns && this.needVerifyLastColumnWidth) {
  15815. this.needVerifyLastColumnWidth = false;
  15816. for (var i = 0; i < this.stretchAllColumnsWidth.length; i++) {
  15817. sumRatioWidth += this.stretchAllColumnsWidth[i];
  15818. }
  15819. if (sumRatioWidth !== this.totalTargetWidth) {
  15820. this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += this.totalTargetWidth - sumRatioWidth;
  15821. }
  15822. }
  15823. return this.stretchAllColumnsWidth[column];
  15824. }
  15825. /**
  15826. * @param {Number} column
  15827. * @returns {Number|null}
  15828. * @private
  15829. */
  15830. }, {
  15831. key: '_getStretchedLastColumnWidth',
  15832. value: function _getStretchedLastColumnWidth(column) {
  15833. var priv = privatePool.get(this);
  15834. var totalColumns = priv.totalColumns;
  15835. if (column === totalColumns - 1) {
  15836. return this.stretchLastWidth;
  15837. }
  15838. return null;
  15839. }
  15840. /**
  15841. * @param {Number} column Column index.
  15842. * @returns {Number}
  15843. * @private
  15844. */
  15845. }, {
  15846. key: '_getColumnWidth',
  15847. value: function _getColumnWidth(column) {
  15848. var width = privatePool.get(this).columnWidthFn(column);
  15849. if (width === void 0) {
  15850. width = ViewportColumnsCalculator.DEFAULT_WIDTH;
  15851. }
  15852. return width;
  15853. }
  15854. }]);
  15855. return ViewportColumnsCalculator;
  15856. }();
  15857. exports.default = ViewportColumnsCalculator;
  15858. /***/ }),
  15859. /* 137 */
  15860. /***/ (function(module, exports, __webpack_require__) {
  15861. "use strict";
  15862. exports.__esModule = true;
  15863. 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; }; }();
  15864. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  15865. var privatePool = new WeakMap();
  15866. /**
  15867. * Calculates indexes of rows to render OR rows that are visible.
  15868. * To redo the calculation, you need to create a new calculator.
  15869. *
  15870. * @class ViewportRowsCalculator
  15871. */
  15872. var ViewportRowsCalculator = function () {
  15873. _createClass(ViewportRowsCalculator, null, [{
  15874. key: "DEFAULT_HEIGHT",
  15875. /**
  15876. * Default row height
  15877. *
  15878. * @type {Number}
  15879. */
  15880. get: function get() {
  15881. return 23;
  15882. }
  15883. /**
  15884. * @param {Number} viewportHeight Height of the viewport
  15885. * @param {Number} scrollOffset Current vertical scroll position of the viewport
  15886. * @param {Number} totalRows Total number of rows
  15887. * @param {Function} rowHeightFn Function that returns the height of the row at a given index (in px)
  15888. * @param {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by MergeCells plugin)
  15889. * @param {Boolean} onlyFullyVisible if `true`, only startRow and endRow will be indexes of rows that are fully in viewport
  15890. * @param {Number} horizontalScrollbarHeight
  15891. */
  15892. }]);
  15893. function ViewportRowsCalculator(viewportHeight, scrollOffset, totalRows, rowHeightFn, overrideFn, onlyFullyVisible, horizontalScrollbarHeight) {
  15894. _classCallCheck(this, ViewportRowsCalculator);
  15895. privatePool.set(this, {
  15896. viewportHeight: viewportHeight,
  15897. scrollOffset: scrollOffset,
  15898. totalRows: totalRows,
  15899. rowHeightFn: rowHeightFn,
  15900. overrideFn: overrideFn,
  15901. onlyFullyVisible: onlyFullyVisible,
  15902. horizontalScrollbarHeight: horizontalScrollbarHeight
  15903. });
  15904. /**
  15905. * Number of rendered/visible rows
  15906. *
  15907. * @type {Number}
  15908. */
  15909. this.count = 0;
  15910. /**
  15911. * Index of the first rendered/visible row (can be overwritten using overrideFn)
  15912. *
  15913. * @type {Number|null}
  15914. */
  15915. this.startRow = null;
  15916. /**
  15917. * Index of the last rendered/visible row (can be overwritten using overrideFn)
  15918. *
  15919. * @type {null}
  15920. */
  15921. this.endRow = null;
  15922. /**
  15923. * Position of the first rendered/visible row (in px)
  15924. *
  15925. * @type {Number|null}
  15926. */
  15927. this.startPosition = null;
  15928. this.calculate();
  15929. }
  15930. /**
  15931. * Calculates viewport
  15932. */
  15933. _createClass(ViewportRowsCalculator, [{
  15934. key: "calculate",
  15935. value: function calculate() {
  15936. var sum = 0;
  15937. var needReverse = true;
  15938. var startPositions = [];
  15939. var priv = privatePool.get(this);
  15940. var onlyFullyVisible = priv.onlyFullyVisible;
  15941. var overrideFn = priv.overrideFn;
  15942. var rowHeightFn = priv.rowHeightFn;
  15943. var scrollOffset = priv.scrollOffset;
  15944. var totalRows = priv.totalRows;
  15945. var viewportHeight = priv.viewportHeight;
  15946. var horizontalScrollbarHeight = priv.horizontalScrollbarHeight || 0;
  15947. var rowHeight = void 0;
  15948. // Calculate the number (start and end index) of rows needed
  15949. for (var i = 0; i < totalRows; i++) {
  15950. rowHeight = rowHeightFn(i);
  15951. if (rowHeight === undefined) {
  15952. rowHeight = ViewportRowsCalculator.DEFAULT_HEIGHT;
  15953. }
  15954. if (sum <= scrollOffset && !onlyFullyVisible) {
  15955. this.startRow = i;
  15956. }
  15957. // the row is within the "visible range"
  15958. if (sum >= scrollOffset && sum + rowHeight <= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  15959. if (this.startRow === null) {
  15960. this.startRow = i;
  15961. }
  15962. this.endRow = i;
  15963. }
  15964. startPositions.push(sum);
  15965. sum += rowHeight;
  15966. if (!onlyFullyVisible) {
  15967. this.endRow = i;
  15968. }
  15969. if (sum >= scrollOffset + viewportHeight - horizontalScrollbarHeight) {
  15970. needReverse = false;
  15971. break;
  15972. }
  15973. }
  15974. // If the estimation has reached the last row and there is still some space available in the viewport,
  15975. // we need to render in reverse in order to fill the whole viewport with rows
  15976. if (this.endRow === totalRows - 1 && needReverse) {
  15977. this.startRow = this.endRow;
  15978. while (this.startRow > 0) {
  15979. // rowHeight is the height of the last row
  15980. var viewportSum = startPositions[this.endRow] + rowHeight - startPositions[this.startRow - 1];
  15981. if (viewportSum <= viewportHeight - horizontalScrollbarHeight || !onlyFullyVisible) {
  15982. this.startRow--;
  15983. }
  15984. if (viewportSum >= viewportHeight - horizontalScrollbarHeight) {
  15985. break;
  15986. }
  15987. }
  15988. }
  15989. if (this.startRow !== null && overrideFn) {
  15990. overrideFn(this);
  15991. }
  15992. this.startPosition = startPositions[this.startRow];
  15993. if (this.startPosition == void 0) {
  15994. this.startPosition = null;
  15995. }
  15996. if (this.startRow !== null) {
  15997. this.count = this.endRow - this.startRow + 1;
  15998. }
  15999. }
  16000. }]);
  16001. return ViewportRowsCalculator;
  16002. }();
  16003. exports.default = ViewportRowsCalculator;
  16004. /***/ }),
  16005. /* 138 */
  16006. /***/ (function(module, exports, __webpack_require__) {
  16007. "use strict";
  16008. exports.__esModule = true;
  16009. 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; }; }();
  16010. var _element = __webpack_require__(0);
  16011. var _object = __webpack_require__(1);
  16012. var _string = __webpack_require__(27);
  16013. var _event = __webpack_require__(139);
  16014. var _event2 = _interopRequireDefault(_event);
  16015. var _overlays = __webpack_require__(142);
  16016. var _overlays2 = _interopRequireDefault(_overlays);
  16017. var _scroll = __webpack_require__(143);
  16018. var _scroll2 = _interopRequireDefault(_scroll);
  16019. var _settings = __webpack_require__(144);
  16020. var _settings2 = _interopRequireDefault(_settings);
  16021. var _table = __webpack_require__(145);
  16022. var _table2 = _interopRequireDefault(_table);
  16023. var _viewport = __webpack_require__(147);
  16024. var _viewport2 = _interopRequireDefault(_viewport);
  16025. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16026. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16027. /**
  16028. * @class Walkontable
  16029. */
  16030. var Walkontable = function () {
  16031. /**
  16032. * @param {Object} settings
  16033. */
  16034. function Walkontable(settings) {
  16035. _classCallCheck(this, Walkontable);
  16036. var originalHeaders = [];
  16037. // this is the namespace for global events
  16038. this.guid = 'wt_' + (0, _string.randomString)();
  16039. // bootstrap from settings
  16040. if (settings.cloneSource) {
  16041. this.cloneSource = settings.cloneSource;
  16042. this.cloneOverlay = settings.cloneOverlay;
  16043. this.wtSettings = settings.cloneSource.wtSettings;
  16044. this.wtTable = new _table2.default(this, settings.table, settings.wtRootElement);
  16045. this.wtScroll = new _scroll2.default(this);
  16046. this.wtViewport = settings.cloneSource.wtViewport;
  16047. this.wtEvent = new _event2.default(this);
  16048. this.selections = this.cloneSource.selections;
  16049. } else {
  16050. this.wtSettings = new _settings2.default(this, settings);
  16051. this.wtTable = new _table2.default(this, settings.table);
  16052. this.wtScroll = new _scroll2.default(this);
  16053. this.wtViewport = new _viewport2.default(this);
  16054. this.wtEvent = new _event2.default(this);
  16055. this.selections = this.getSetting('selections');
  16056. this.wtOverlays = new _overlays2.default(this);
  16057. this.exportSettingsAsClassNames();
  16058. }
  16059. // find original headers
  16060. if (this.wtTable.THEAD.childNodes.length && this.wtTable.THEAD.childNodes[0].childNodes.length) {
  16061. for (var c = 0, clen = this.wtTable.THEAD.childNodes[0].childNodes.length; c < clen; c++) {
  16062. originalHeaders.push(this.wtTable.THEAD.childNodes[0].childNodes[c].innerHTML);
  16063. }
  16064. if (!this.getSetting('columnHeaders').length) {
  16065. this.update('columnHeaders', [function (column, TH) {
  16066. (0, _element.fastInnerText)(TH, originalHeaders[column]);
  16067. }]);
  16068. }
  16069. }
  16070. this.drawn = false;
  16071. this.drawInterrupted = false;
  16072. }
  16073. /**
  16074. * Force rerender of Walkontable
  16075. *
  16076. * @param {Boolean} [fastDraw=false] When `true`, try to refresh only the positions of borders without rerendering
  16077. * the data. It will only work if Table.draw() does not force
  16078. * rendering anyway
  16079. * @returns {Walkontable}
  16080. */
  16081. _createClass(Walkontable, [{
  16082. key: 'draw',
  16083. value: function draw() {
  16084. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  16085. this.drawInterrupted = false;
  16086. if (!fastDraw && !(0, _element.isVisible)(this.wtTable.TABLE)) {
  16087. // draw interrupted because TABLE is not visible
  16088. this.drawInterrupted = true;
  16089. } else {
  16090. this.wtTable.draw(fastDraw);
  16091. }
  16092. return this;
  16093. }
  16094. /**
  16095. * Returns the TD at coords. If topmost is set to true, returns TD from the topmost overlay layer,
  16096. * if not set or set to false, returns TD from the master table.
  16097. *
  16098. * @param {CellCoords} coords
  16099. * @param {Boolean} [topmost=false]
  16100. * @returns {Object}
  16101. */
  16102. }, {
  16103. key: 'getCell',
  16104. value: function getCell(coords) {
  16105. var topmost = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  16106. if (!topmost) {
  16107. return this.wtTable.getCell(coords);
  16108. }
  16109. var totalRows = this.wtSettings.getSetting('totalRows');
  16110. var fixedRowsTop = this.wtSettings.getSetting('fixedRowsTop');
  16111. var fixedRowsBottom = this.wtSettings.getSetting('fixedRowsBottom');
  16112. var fixedColumns = this.wtSettings.getSetting('fixedColumnsLeft');
  16113. if (coords.row < fixedRowsTop && coords.col < fixedColumns) {
  16114. return this.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell(coords);
  16115. } else if (coords.row < fixedRowsTop) {
  16116. return this.wtOverlays.topOverlay.clone.wtTable.getCell(coords);
  16117. } else if (coords.col < fixedColumns && coords.row >= totalRows - fixedRowsBottom) {
  16118. if (this.wtOverlays.bottomLeftCornerOverlay && this.wtOverlays.bottomLeftCornerOverlay.clone) {
  16119. return this.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.getCell(coords);
  16120. }
  16121. } else if (coords.col < fixedColumns) {
  16122. return this.wtOverlays.leftOverlay.clone.wtTable.getCell(coords);
  16123. } else if (coords.row < totalRows && coords.row > totalRows - fixedRowsBottom) {
  16124. if (this.wtOverlays.bottomOverlay && this.wtOverlays.bottomOverlay.clone) {
  16125. return this.wtOverlays.bottomOverlay.clone.wtTable.getCell(coords);
  16126. }
  16127. }
  16128. return this.wtTable.getCell(coords);
  16129. }
  16130. /**
  16131. * @param {Object} settings
  16132. * @param {*} value
  16133. * @returns {Walkontable}
  16134. */
  16135. }, {
  16136. key: 'update',
  16137. value: function update(settings, value) {
  16138. return this.wtSettings.update(settings, value);
  16139. }
  16140. /**
  16141. * Scroll the viewport to a row at the given index in the data source
  16142. *
  16143. * @param {Number} row
  16144. * @returns {Walkontable}
  16145. */
  16146. }, {
  16147. key: 'scrollVertical',
  16148. value: function scrollVertical(row) {
  16149. this.wtOverlays.topOverlay.scrollTo(row);
  16150. this.getSetting('onScrollVertically');
  16151. return this;
  16152. }
  16153. /**
  16154. * Scroll the viewport to a column at the given index in the data source
  16155. *
  16156. * @param {Number} column
  16157. * @returns {Walkontable}
  16158. */
  16159. }, {
  16160. key: 'scrollHorizontal',
  16161. value: function scrollHorizontal(column) {
  16162. this.wtOverlays.leftOverlay.scrollTo(column);
  16163. this.getSetting('onScrollHorizontally');
  16164. return this;
  16165. }
  16166. /**
  16167. * Scrolls the viewport to a cell (rerenders if needed)
  16168. *
  16169. * @param {CellCoords} coords
  16170. * @returns {Walkontable}
  16171. */
  16172. }, {
  16173. key: 'scrollViewport',
  16174. value: function scrollViewport(coords) {
  16175. this.wtScroll.scrollViewport(coords);
  16176. return this;
  16177. }
  16178. /**
  16179. * @returns {Array}
  16180. */
  16181. }, {
  16182. key: 'getViewport',
  16183. value: function getViewport() {
  16184. return [this.wtTable.getFirstVisibleRow(), this.wtTable.getFirstVisibleColumn(), this.wtTable.getLastVisibleRow(), this.wtTable.getLastVisibleColumn()];
  16185. }
  16186. /**
  16187. * Get overlay name
  16188. *
  16189. * @returns {String}
  16190. */
  16191. }, {
  16192. key: 'getOverlayName',
  16193. value: function getOverlayName() {
  16194. return this.cloneOverlay ? this.cloneOverlay.type : 'master';
  16195. }
  16196. /**
  16197. * Check overlay type of this Walkontable instance.
  16198. *
  16199. * @param {String} name Clone type @see {Overlay.CLONE_TYPES}.
  16200. * @returns {Boolean}
  16201. */
  16202. }, {
  16203. key: 'isOverlayName',
  16204. value: function isOverlayName(name) {
  16205. if (this.cloneOverlay) {
  16206. return this.cloneOverlay.type === name;
  16207. }
  16208. return false;
  16209. }
  16210. /**
  16211. * Export settings as class names added to the parent element of the table.
  16212. */
  16213. }, {
  16214. key: 'exportSettingsAsClassNames',
  16215. value: function exportSettingsAsClassNames() {
  16216. var _this = this;
  16217. var toExport = {
  16218. rowHeaders: ['array'],
  16219. columnHeaders: ['array']
  16220. };
  16221. var allClassNames = [];
  16222. var newClassNames = [];
  16223. (0, _object.objectEach)(toExport, function (optionType, key) {
  16224. if (optionType.indexOf('array') > -1 && _this.getSetting(key).length) {
  16225. newClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  16226. }
  16227. allClassNames.push('ht' + (0, _string.toUpperCaseFirst)(key));
  16228. });
  16229. (0, _element.removeClass)(this.wtTable.wtRootElement.parentNode, allClassNames);
  16230. (0, _element.addClass)(this.wtTable.wtRootElement.parentNode, newClassNames);
  16231. }
  16232. /**
  16233. * Get/Set Walkontable instance setting
  16234. *
  16235. * @param {String} key
  16236. * @param {*} [param1]
  16237. * @param {*} [param2]
  16238. * @param {*} [param3]
  16239. * @param {*} [param4]
  16240. * @returns {*}
  16241. */
  16242. }, {
  16243. key: 'getSetting',
  16244. value: function getSetting(key, param1, param2, param3, param4) {
  16245. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  16246. return this.wtSettings.getSetting(key, param1, param2, param3, param4);
  16247. }
  16248. /**
  16249. * Checks if setting exists
  16250. *
  16251. * @param {String} key
  16252. * @returns {Boolean}
  16253. */
  16254. }, {
  16255. key: 'hasSetting',
  16256. value: function hasSetting(key) {
  16257. return this.wtSettings.has(key);
  16258. }
  16259. /**
  16260. * Destroy instance
  16261. */
  16262. }, {
  16263. key: 'destroy',
  16264. value: function destroy() {
  16265. this.wtOverlays.destroy();
  16266. this.wtEvent.destroy();
  16267. }
  16268. }]);
  16269. return Walkontable;
  16270. }();
  16271. exports.default = Walkontable;
  16272. /***/ }),
  16273. /* 139 */
  16274. /***/ (function(module, exports, __webpack_require__) {
  16275. "use strict";
  16276. exports.__esModule = true;
  16277. var _element = __webpack_require__(0);
  16278. var _function = __webpack_require__(35);
  16279. var _browser = __webpack_require__(25);
  16280. var _eventManager = __webpack_require__(4);
  16281. var _eventManager2 = _interopRequireDefault(_eventManager);
  16282. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16283. /**
  16284. *
  16285. */
  16286. function Event(instance) {
  16287. var that = this;
  16288. var eventManager = new _eventManager2.default(instance);
  16289. this.instance = instance;
  16290. var dblClickOrigin = [null, null];
  16291. this.dblClickTimeout = [null, null];
  16292. var onMouseDown = function onMouseDown(event) {
  16293. var activeElement = document.activeElement;
  16294. var getParentNode = (0, _function.partial)(_element.getParent, event.realTarget);
  16295. var realTarget = event.realTarget;
  16296. // ignore focusable element from mouse down processing (https://github.com/handsontable/handsontable/issues/3555)
  16297. if (realTarget === activeElement || getParentNode(0) === activeElement || getParentNode(1) === activeElement) {
  16298. return;
  16299. }
  16300. var cell = that.parentCell(realTarget);
  16301. if ((0, _element.hasClass)(realTarget, 'corner')) {
  16302. that.instance.getSetting('onCellCornerMouseDown', event, realTarget);
  16303. } else if (cell.TD) {
  16304. if (that.instance.hasSetting('onCellMouseDown')) {
  16305. that.instance.getSetting('onCellMouseDown', event, cell.coords, cell.TD, that.instance);
  16306. }
  16307. }
  16308. if (event.button !== 2) {
  16309. // if not right mouse button
  16310. if (cell.TD) {
  16311. dblClickOrigin[0] = cell.TD;
  16312. clearTimeout(that.dblClickTimeout[0]);
  16313. that.dblClickTimeout[0] = setTimeout(function () {
  16314. dblClickOrigin[0] = null;
  16315. }, 1000);
  16316. }
  16317. }
  16318. };
  16319. var onTouchMove = function onTouchMove(event) {
  16320. that.instance.touchMoving = true;
  16321. };
  16322. var longTouchTimeout;
  16323. var onTouchStart = function onTouchStart(event) {
  16324. var container = this;
  16325. eventManager.addEventListener(this, 'touchmove', onTouchMove);
  16326. // Prevent cell selection when scrolling with touch event - not the best solution performance-wise
  16327. that.checkIfTouchMove = setTimeout(function () {
  16328. if (that.instance.touchMoving === true) {
  16329. that.instance.touchMoving = void 0;
  16330. eventManager.removeEventListener('touchmove', onTouchMove, false);
  16331. }
  16332. onMouseDown(event);
  16333. }, 30);
  16334. };
  16335. var onMouseOver = function onMouseOver(event) {
  16336. var table, td, mainWOT;
  16337. if (that.instance.hasSetting('onCellMouseOver')) {
  16338. table = that.instance.wtTable.TABLE;
  16339. td = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  16340. mainWOT = that.instance.cloneSource || that.instance;
  16341. if (td && td !== mainWOT.lastMouseOver && (0, _element.isChildOf)(td, table)) {
  16342. mainWOT.lastMouseOver = td;
  16343. that.instance.getSetting('onCellMouseOver', event, that.instance.wtTable.getCoords(td), td, that.instance);
  16344. }
  16345. }
  16346. };
  16347. var onMouseOut = function onMouseOut(event) {
  16348. var table = void 0;
  16349. var lastTD = void 0;
  16350. var nextTD = void 0;
  16351. if (that.instance.hasSetting('onCellMouseOut')) {
  16352. table = that.instance.wtTable.TABLE;
  16353. lastTD = (0, _element.closestDown)(event.realTarget, ['TD', 'TH'], table);
  16354. nextTD = (0, _element.closestDown)(event.relatedTarget, ['TD', 'TH'], table);
  16355. if (lastTD && lastTD !== nextTD && (0, _element.isChildOf)(lastTD, table)) {
  16356. that.instance.getSetting('onCellMouseOut', event, that.instance.wtTable.getCoords(lastTD), lastTD, that.instance);
  16357. }
  16358. }
  16359. };
  16360. var onMouseUp = function onMouseUp(event) {
  16361. if (event.button !== 2) {
  16362. // if not right mouse button
  16363. var cell = that.parentCell(event.realTarget);
  16364. if (cell.TD === dblClickOrigin[0] && cell.TD === dblClickOrigin[1]) {
  16365. if ((0, _element.hasClass)(event.realTarget, 'corner')) {
  16366. that.instance.getSetting('onCellCornerDblClick', event, cell.coords, cell.TD, that.instance);
  16367. } else {
  16368. that.instance.getSetting('onCellDblClick', event, cell.coords, cell.TD, that.instance);
  16369. }
  16370. dblClickOrigin[0] = null;
  16371. dblClickOrigin[1] = null;
  16372. } else if (cell.TD === dblClickOrigin[0]) {
  16373. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  16374. dblClickOrigin[1] = cell.TD;
  16375. clearTimeout(that.dblClickTimeout[1]);
  16376. that.dblClickTimeout[1] = setTimeout(function () {
  16377. dblClickOrigin[1] = null;
  16378. }, 500);
  16379. } else if (cell.TD && that.instance.hasSetting('onCellMouseUp')) {
  16380. that.instance.getSetting('onCellMouseUp', event, cell.coords, cell.TD, that.instance);
  16381. }
  16382. }
  16383. };
  16384. var onTouchEnd = function onTouchEnd(event) {
  16385. clearTimeout(longTouchTimeout);
  16386. // that.instance.longTouch == void 0;
  16387. event.preventDefault();
  16388. onMouseUp(event);
  16389. // eventManager.removeEventListener(that.instance.wtTable.holder, "mouseup", onMouseUp);
  16390. };
  16391. eventManager.addEventListener(this.instance.wtTable.holder, 'mousedown', onMouseDown);
  16392. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseover', onMouseOver);
  16393. eventManager.addEventListener(this.instance.wtTable.TABLE, 'mouseout', onMouseOut);
  16394. eventManager.addEventListener(this.instance.wtTable.holder, 'mouseup', onMouseUp);
  16395. // check if full HOT instance, or detached WOT AND run on mobile device
  16396. if (this.instance.wtTable.holder.parentNode.parentNode && (0, _browser.isMobileBrowser)() && !that.instance.wtTable.isWorkingOnClone()) {
  16397. var classSelector = '.' + this.instance.wtTable.holder.parentNode.className.split(' ').join('.');
  16398. eventManager.addEventListener(this.instance.wtTable.holder, 'touchstart', function (event) {
  16399. that.instance.touchApplied = true;
  16400. if ((0, _element.isChildOf)(event.target, classSelector)) {
  16401. onTouchStart.call(event.target, event);
  16402. }
  16403. });
  16404. eventManager.addEventListener(this.instance.wtTable.holder, 'touchend', function (event) {
  16405. that.instance.touchApplied = false;
  16406. if ((0, _element.isChildOf)(event.target, classSelector)) {
  16407. onTouchEnd.call(event.target, event);
  16408. }
  16409. });
  16410. if (!that.instance.momentumScrolling) {
  16411. that.instance.momentumScrolling = {};
  16412. }
  16413. eventManager.addEventListener(this.instance.wtTable.holder, 'scroll', function (event) {
  16414. clearTimeout(that.instance.momentumScrolling._timeout);
  16415. if (!that.instance.momentumScrolling.ongoing) {
  16416. that.instance.getSetting('onBeforeTouchScroll');
  16417. }
  16418. that.instance.momentumScrolling.ongoing = true;
  16419. that.instance.momentumScrolling._timeout = setTimeout(function () {
  16420. if (!that.instance.touchApplied) {
  16421. that.instance.momentumScrolling.ongoing = false;
  16422. that.instance.getSetting('onAfterMomentumScroll');
  16423. }
  16424. }, 200);
  16425. });
  16426. }
  16427. eventManager.addEventListener(window, 'resize', function () {
  16428. if (that.instance.getSetting('stretchH') !== 'none') {
  16429. that.instance.draw();
  16430. }
  16431. });
  16432. this.destroy = function () {
  16433. clearTimeout(this.dblClickTimeout[0]);
  16434. clearTimeout(this.dblClickTimeout[1]);
  16435. eventManager.destroy();
  16436. };
  16437. }
  16438. Event.prototype.parentCell = function (elem) {
  16439. var cell = {};
  16440. var TABLE = this.instance.wtTable.TABLE;
  16441. var TD = (0, _element.closestDown)(elem, ['TD', 'TH'], TABLE);
  16442. if (TD) {
  16443. cell.coords = this.instance.wtTable.getCoords(TD);
  16444. cell.TD = TD;
  16445. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'current')) {
  16446. cell.coords = this.instance.selections.current.cellRange.highlight; // selections.current is current selected cell
  16447. cell.TD = this.instance.wtTable.getCell(cell.coords);
  16448. } else if ((0, _element.hasClass)(elem, 'wtBorder') && (0, _element.hasClass)(elem, 'area')) {
  16449. if (this.instance.selections.area.cellRange) {
  16450. cell.coords = this.instance.selections.area.cellRange.to; // selections.area is area selected cells
  16451. cell.TD = this.instance.wtTable.getCell(cell.coords);
  16452. }
  16453. }
  16454. return cell;
  16455. };
  16456. exports.default = Event;
  16457. /***/ }),
  16458. /* 140 */
  16459. /***/ (function(module, exports, __webpack_require__) {
  16460. "use strict";
  16461. exports.__esModule = true;
  16462. 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; }; }();
  16463. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16464. /**
  16465. * @class ColumnFilter
  16466. */
  16467. var ColumnFilter = function () {
  16468. /**
  16469. * @param {Number} offset
  16470. * @param {Number} total
  16471. * @param {Number} countTH
  16472. */
  16473. function ColumnFilter(offset, total, countTH) {
  16474. _classCallCheck(this, ColumnFilter);
  16475. this.offset = offset;
  16476. this.total = total;
  16477. this.countTH = countTH;
  16478. }
  16479. /**
  16480. * @param index
  16481. * @returns {Number}
  16482. */
  16483. _createClass(ColumnFilter, [{
  16484. key: "offsetted",
  16485. value: function offsetted(index) {
  16486. return index + this.offset;
  16487. }
  16488. /**
  16489. * @param index
  16490. * @returns {Number}
  16491. */
  16492. }, {
  16493. key: "unOffsetted",
  16494. value: function unOffsetted(index) {
  16495. return index - this.offset;
  16496. }
  16497. /**
  16498. * @param index
  16499. * @returns {Number}
  16500. */
  16501. }, {
  16502. key: "renderedToSource",
  16503. value: function renderedToSource(index) {
  16504. return this.offsetted(index);
  16505. }
  16506. /**
  16507. * @param index
  16508. * @returns {Number}
  16509. */
  16510. }, {
  16511. key: "sourceToRendered",
  16512. value: function sourceToRendered(index) {
  16513. return this.unOffsetted(index);
  16514. }
  16515. /**
  16516. * @param index
  16517. * @returns {Number}
  16518. */
  16519. }, {
  16520. key: "offsettedTH",
  16521. value: function offsettedTH(index) {
  16522. return index - this.countTH;
  16523. }
  16524. /**
  16525. * @param index
  16526. * @returns {Number}
  16527. */
  16528. }, {
  16529. key: "unOffsettedTH",
  16530. value: function unOffsettedTH(index) {
  16531. return index + this.countTH;
  16532. }
  16533. /**
  16534. * @param index
  16535. * @returns {Number}
  16536. */
  16537. }, {
  16538. key: "visibleRowHeadedColumnToSourceColumn",
  16539. value: function visibleRowHeadedColumnToSourceColumn(index) {
  16540. return this.renderedToSource(this.offsettedTH(index));
  16541. }
  16542. /**
  16543. * @param index
  16544. * @returns {Number}
  16545. */
  16546. }, {
  16547. key: "sourceColumnToVisibleRowHeadedColumn",
  16548. value: function sourceColumnToVisibleRowHeadedColumn(index) {
  16549. return this.unOffsettedTH(this.sourceToRendered(index));
  16550. }
  16551. }]);
  16552. return ColumnFilter;
  16553. }();
  16554. exports.default = ColumnFilter;
  16555. /***/ }),
  16556. /* 141 */
  16557. /***/ (function(module, exports, __webpack_require__) {
  16558. "use strict";
  16559. exports.__esModule = true;
  16560. 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; }; }();
  16561. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16562. /**
  16563. * @class RowFilter
  16564. */
  16565. var RowFilter = function () {
  16566. /**
  16567. * @param {Number} offset
  16568. * @param {Number} total
  16569. * @param {Number} countTH
  16570. */
  16571. function RowFilter(offset, total, countTH) {
  16572. _classCallCheck(this, RowFilter);
  16573. this.offset = offset;
  16574. this.total = total;
  16575. this.countTH = countTH;
  16576. }
  16577. /**
  16578. * @param index
  16579. * @returns {Number}
  16580. */
  16581. _createClass(RowFilter, [{
  16582. key: "offsetted",
  16583. value: function offsetted(index) {
  16584. return index + this.offset;
  16585. }
  16586. /**
  16587. * @param index
  16588. * @returns {Number}
  16589. */
  16590. }, {
  16591. key: "unOffsetted",
  16592. value: function unOffsetted(index) {
  16593. return index - this.offset;
  16594. }
  16595. /**
  16596. * @param index
  16597. * @returns {Number}
  16598. */
  16599. }, {
  16600. key: "renderedToSource",
  16601. value: function renderedToSource(index) {
  16602. return this.offsetted(index);
  16603. }
  16604. /**
  16605. * @param index
  16606. * @returns {Number}
  16607. */
  16608. }, {
  16609. key: "sourceToRendered",
  16610. value: function sourceToRendered(index) {
  16611. return this.unOffsetted(index);
  16612. }
  16613. /**
  16614. * @param index
  16615. * @returns {Number}
  16616. */
  16617. }, {
  16618. key: "offsettedTH",
  16619. value: function offsettedTH(index) {
  16620. return index - this.countTH;
  16621. }
  16622. /**
  16623. * @param index
  16624. * @returns {Number}
  16625. */
  16626. }, {
  16627. key: "unOffsettedTH",
  16628. value: function unOffsettedTH(index) {
  16629. return index + this.countTH;
  16630. }
  16631. /**
  16632. * @param index
  16633. * @returns {Number}
  16634. */
  16635. }, {
  16636. key: "visibleColHeadedRowToSourceRow",
  16637. value: function visibleColHeadedRowToSourceRow(index) {
  16638. return this.renderedToSource(this.offsettedTH(index));
  16639. }
  16640. /**
  16641. * @param index
  16642. * @returns {Number}
  16643. */
  16644. }, {
  16645. key: "sourceRowToVisibleColHeadedRow",
  16646. value: function sourceRowToVisibleColHeadedRow(index) {
  16647. return this.unOffsettedTH(this.sourceToRendered(index));
  16648. }
  16649. }]);
  16650. return RowFilter;
  16651. }();
  16652. exports.default = RowFilter;
  16653. /***/ }),
  16654. /* 142 */
  16655. /***/ (function(module, exports, __webpack_require__) {
  16656. "use strict";
  16657. exports.__esModule = true;
  16658. 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; }; }();
  16659. var _element = __webpack_require__(0);
  16660. var _array = __webpack_require__(2);
  16661. var _unicode = __webpack_require__(16);
  16662. var _browser = __webpack_require__(25);
  16663. var _eventManager = __webpack_require__(4);
  16664. var _eventManager2 = _interopRequireDefault(_eventManager);
  16665. var _base = __webpack_require__(28);
  16666. var _base2 = _interopRequireDefault(_base);
  16667. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16668. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16669. /**
  16670. * @class Overlays
  16671. */
  16672. var Overlays = function () {
  16673. /**
  16674. * @param {Walkontable} wotInstance
  16675. */
  16676. function Overlays(wotInstance) {
  16677. _classCallCheck(this, Overlays);
  16678. this.wot = wotInstance;
  16679. // legacy support
  16680. this.instance = this.wot;
  16681. this.eventManager = new _eventManager2.default(this.wot);
  16682. this.wot.update('scrollbarWidth', (0, _element.getScrollbarWidth)());
  16683. this.wot.update('scrollbarHeight', (0, _element.getScrollbarWidth)());
  16684. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  16685. this.prepareOverlays();
  16686. this.destroyed = false;
  16687. this.keyPressed = false;
  16688. this.spreaderLastSize = {
  16689. width: null,
  16690. height: null
  16691. };
  16692. this.overlayScrollPositions = {
  16693. master: {
  16694. top: 0,
  16695. left: 0
  16696. },
  16697. top: {
  16698. top: null,
  16699. left: 0
  16700. },
  16701. bottom: {
  16702. top: null,
  16703. left: 0
  16704. },
  16705. left: {
  16706. top: 0,
  16707. left: null
  16708. }
  16709. };
  16710. this.pendingScrollCallbacks = {
  16711. master: {
  16712. top: 0,
  16713. left: 0
  16714. },
  16715. top: {
  16716. left: 0
  16717. },
  16718. bottom: {
  16719. left: 0
  16720. },
  16721. left: {
  16722. top: 0
  16723. }
  16724. };
  16725. this.verticalScrolling = false;
  16726. this.horizontalScrolling = false;
  16727. this.delegatedScrollCallback = false;
  16728. this.registeredListeners = [];
  16729. this.registerListeners();
  16730. }
  16731. /**
  16732. * Prepare overlays based on user settings.
  16733. *
  16734. * @returns {Boolean} Returns `true` if changes applied to overlay needs scroll synchronization.
  16735. */
  16736. _createClass(Overlays, [{
  16737. key: 'prepareOverlays',
  16738. value: function prepareOverlays() {
  16739. var syncScroll = false;
  16740. if (this.topOverlay) {
  16741. syncScroll = this.topOverlay.updateStateOfRendering() || syncScroll;
  16742. } else {
  16743. this.topOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP, this.wot);
  16744. }
  16745. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM)) {
  16746. this.bottomOverlay = {
  16747. needFullRender: false,
  16748. updateStateOfRendering: function updateStateOfRendering() {
  16749. return false;
  16750. }
  16751. };
  16752. }
  16753. if (!_base2.default.hasOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  16754. this.bottomLeftCornerOverlay = {
  16755. needFullRender: false,
  16756. updateStateOfRendering: function updateStateOfRendering() {
  16757. return false;
  16758. }
  16759. };
  16760. }
  16761. if (this.bottomOverlay) {
  16762. syncScroll = this.bottomOverlay.updateStateOfRendering() || syncScroll;
  16763. } else {
  16764. this.bottomOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM, this.wot);
  16765. }
  16766. if (this.leftOverlay) {
  16767. syncScroll = this.leftOverlay.updateStateOfRendering() || syncScroll;
  16768. } else {
  16769. this.leftOverlay = _base2.default.createOverlay(_base2.default.CLONE_LEFT, this.wot);
  16770. }
  16771. if (this.topOverlay.needFullRender && this.leftOverlay.needFullRender) {
  16772. if (this.topLeftCornerOverlay) {
  16773. syncScroll = this.topLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  16774. } else {
  16775. this.topLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, this.wot);
  16776. }
  16777. }
  16778. if (this.bottomOverlay.needFullRender && this.leftOverlay.needFullRender) {
  16779. if (this.bottomLeftCornerOverlay) {
  16780. syncScroll = this.bottomLeftCornerOverlay.updateStateOfRendering() || syncScroll;
  16781. } else {
  16782. this.bottomLeftCornerOverlay = _base2.default.createOverlay(_base2.default.CLONE_BOTTOM_LEFT_CORNER, this.wot);
  16783. }
  16784. }
  16785. if (this.wot.getSetting('debug') && !this.debug) {
  16786. this.debug = _base2.default.createOverlay(_base2.default.CLONE_DEBUG, this.wot);
  16787. }
  16788. return syncScroll;
  16789. }
  16790. /**
  16791. * Refresh and redraw table
  16792. */
  16793. }, {
  16794. key: 'refreshAll',
  16795. value: function refreshAll() {
  16796. if (!this.wot.drawn) {
  16797. return;
  16798. }
  16799. if (!this.wot.wtTable.holder.parentNode) {
  16800. // Walkontable was detached from DOM, but this handler was not removed
  16801. this.destroy();
  16802. return;
  16803. }
  16804. this.wot.draw(true);
  16805. if (this.verticalScrolling) {
  16806. this.leftOverlay.onScroll();
  16807. }
  16808. if (this.horizontalScrolling) {
  16809. this.topOverlay.onScroll();
  16810. }
  16811. this.verticalScrolling = false;
  16812. this.horizontalScrolling = false;
  16813. }
  16814. /**
  16815. * Register all necessary event listeners.
  16816. */
  16817. }, {
  16818. key: 'registerListeners',
  16819. value: function registerListeners() {
  16820. var _this = this;
  16821. var topOverlayScrollable = this.topOverlay.mainTableScrollableElement;
  16822. var leftOverlayScrollable = this.leftOverlay.mainTableScrollableElement;
  16823. var listenersToRegister = [];
  16824. listenersToRegister.push([document.documentElement, 'keydown', function (event) {
  16825. return _this.onKeyDown(event);
  16826. }]);
  16827. listenersToRegister.push([document.documentElement, 'keyup', function () {
  16828. return _this.onKeyUp();
  16829. }]);
  16830. listenersToRegister.push([document, 'visibilitychange', function () {
  16831. return _this.onKeyUp();
  16832. }]);
  16833. listenersToRegister.push([topOverlayScrollable, 'scroll', function (event) {
  16834. return _this.onTableScroll(event);
  16835. }]);
  16836. if (topOverlayScrollable !== leftOverlayScrollable) {
  16837. listenersToRegister.push([leftOverlayScrollable, 'scroll', function (event) {
  16838. return _this.onTableScroll(event);
  16839. }]);
  16840. }
  16841. if (this.topOverlay.needFullRender) {
  16842. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'scroll', function (event) {
  16843. return _this.onTableScroll(event);
  16844. }]);
  16845. listenersToRegister.push([this.topOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16846. return _this.onTableScroll(event);
  16847. }]);
  16848. }
  16849. if (this.bottomOverlay.needFullRender) {
  16850. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'scroll', function (event) {
  16851. return _this.onTableScroll(event);
  16852. }]);
  16853. listenersToRegister.push([this.bottomOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16854. return _this.onTableScroll(event);
  16855. }]);
  16856. }
  16857. if (this.leftOverlay.needFullRender) {
  16858. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'scroll', function (event) {
  16859. return _this.onTableScroll(event);
  16860. }]);
  16861. listenersToRegister.push([this.leftOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16862. return _this.onTableScroll(event);
  16863. }]);
  16864. }
  16865. if (this.topLeftCornerOverlay && this.topLeftCornerOverlay.needFullRender) {
  16866. listenersToRegister.push([this.topLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16867. return _this.onTableScroll(event);
  16868. }]);
  16869. }
  16870. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.needFullRender) {
  16871. listenersToRegister.push([this.bottomLeftCornerOverlay.clone.wtTable.holder, 'wheel', function (event) {
  16872. return _this.onTableScroll(event);
  16873. }]);
  16874. }
  16875. if (this.topOverlay.trimmingContainer !== window && this.leftOverlay.trimmingContainer !== window) {
  16876. // This is necessary?
  16877. // eventManager.addEventListener(window, 'scroll', (event) => this.refreshAll(event));
  16878. listenersToRegister.push([window, 'wheel', function (event) {
  16879. var overlay = void 0;
  16880. var deltaY = event.wheelDeltaY || event.deltaY;
  16881. var deltaX = event.wheelDeltaX || event.deltaX;
  16882. if (_this.topOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16883. overlay = 'top';
  16884. } else if (_this.bottomOverlay.clone && _this.bottomOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16885. overlay = 'bottom';
  16886. } else if (_this.leftOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16887. overlay = 'left';
  16888. } else if (_this.topLeftCornerOverlay && _this.topLeftCornerOverlay.clone && _this.topLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16889. overlay = 'topLeft';
  16890. } else if (_this.bottomLeftCornerOverlay && _this.bottomLeftCornerOverlay.clone && _this.bottomLeftCornerOverlay.clone.wtTable.holder.contains(event.realTarget)) {
  16891. overlay = 'bottomLeft';
  16892. }
  16893. if (overlay == 'top' && deltaY !== 0 || overlay == 'left' && deltaX !== 0 || overlay == 'bottom' && deltaY !== 0 || (overlay === 'topLeft' || overlay === 'bottomLeft') && (deltaY !== 0 || deltaX !== 0)) {
  16894. event.preventDefault();
  16895. }
  16896. }]);
  16897. }
  16898. while (listenersToRegister.length) {
  16899. var listener = listenersToRegister.pop();
  16900. this.eventManager.addEventListener(listener[0], listener[1], listener[2]);
  16901. this.registeredListeners.push(listener);
  16902. }
  16903. }
  16904. /**
  16905. * Deregister all previously registered listeners.
  16906. */
  16907. }, {
  16908. key: 'deregisterListeners',
  16909. value: function deregisterListeners() {
  16910. while (this.registeredListeners.length) {
  16911. var listener = this.registeredListeners.pop();
  16912. this.eventManager.removeEventListener(listener[0], listener[1], listener[2]);
  16913. }
  16914. }
  16915. /**
  16916. * Scroll listener
  16917. *
  16918. * @param {Event} event
  16919. */
  16920. }, {
  16921. key: 'onTableScroll',
  16922. value: function onTableScroll(event) {
  16923. // if mobile browser, do not update scroll positions, as the overlays are hidden during the scroll
  16924. if ((0, _browser.isMobileBrowser)()) {
  16925. return;
  16926. }
  16927. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  16928. var masterVertical = this.topOverlay.mainTableScrollableElement;
  16929. var target = event.target;
  16930. // For key press, sync only master -> overlay position because while pressing Walkontable.render is triggered
  16931. // by hot.refreshBorder
  16932. if (this.keyPressed) {
  16933. if (masterVertical !== window && target !== window && !event.target.contains(masterVertical) || masterHorizontal !== window && target !== window && !event.target.contains(masterHorizontal)) {
  16934. return;
  16935. }
  16936. }
  16937. if (event.type === 'scroll') {
  16938. this.syncScrollPositions(event);
  16939. } else {
  16940. this.translateMouseWheelToScroll(event);
  16941. }
  16942. }
  16943. /**
  16944. * Key down listener
  16945. */
  16946. }, {
  16947. key: 'onKeyDown',
  16948. value: function onKeyDown(event) {
  16949. this.keyPressed = (0, _unicode.isKey)(event.keyCode, 'ARROW_UP|ARROW_RIGHT|ARROW_DOWN|ARROW_LEFT');
  16950. }
  16951. /**
  16952. * Key up listener
  16953. */
  16954. }, {
  16955. key: 'onKeyUp',
  16956. value: function onKeyUp() {
  16957. this.keyPressed = false;
  16958. }
  16959. /**
  16960. * Translate wheel event into scroll event and sync scroll overlays position
  16961. *
  16962. * @private
  16963. * @param {Event} event
  16964. * @returns {Boolean}
  16965. */
  16966. }, {
  16967. key: 'translateMouseWheelToScroll',
  16968. value: function translateMouseWheelToScroll(event) {
  16969. var topOverlay = this.topOverlay.clone.wtTable.holder;
  16970. var bottomOverlay = this.bottomOverlay.clone ? this.bottomOverlay.clone.wtTable.holder : null;
  16971. var leftOverlay = this.leftOverlay.clone.wtTable.holder;
  16972. var topLeftCornerOverlay = this.topLeftCornerOverlay && this.topLeftCornerOverlay.clone ? this.topLeftCornerOverlay.clone.wtTable.holder : null;
  16973. var bottomLeftCornerOverlay = this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone ? this.bottomLeftCornerOverlay.clone.wtTable.holder : null;
  16974. var mouseWheelSpeedRatio = -0.2;
  16975. var deltaY = event.wheelDeltaY || -1 * event.deltaY;
  16976. var deltaX = event.wheelDeltaX || -1 * event.deltaX;
  16977. var parentHolder = null;
  16978. var eventMockup = { type: 'wheel' };
  16979. var tempElem = event.target;
  16980. var delta = null;
  16981. // Fix for extremely slow header scrolling with a mousewheel on Firefox
  16982. if (event.deltaMode === 1) {
  16983. deltaY *= 120;
  16984. deltaX *= 120;
  16985. }
  16986. while (tempElem != document && tempElem != null) {
  16987. if (tempElem.className.indexOf('wtHolder') > -1) {
  16988. parentHolder = tempElem;
  16989. break;
  16990. }
  16991. tempElem = tempElem.parentNode;
  16992. }
  16993. eventMockup.target = parentHolder;
  16994. if (parentHolder === topLeftCornerOverlay || parentHolder === bottomLeftCornerOverlay) {
  16995. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaX, 'x');
  16996. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * deltaY, 'y');
  16997. } else {
  16998. if (parentHolder === topOverlay || parentHolder === bottomOverlay) {
  16999. delta = deltaY;
  17000. } else if (parentHolder === leftOverlay) {
  17001. delta = deltaX;
  17002. }
  17003. this.syncScrollPositions(eventMockup, mouseWheelSpeedRatio * delta);
  17004. }
  17005. return false;
  17006. }
  17007. /**
  17008. * Synchronize scroll position between master table and overlay table.
  17009. *
  17010. * @private
  17011. * @param {Event|Object} event
  17012. * @param {Number} [fakeScrollValue=null]
  17013. * @param {String} [fakeScrollDirection=null] `x` or `y`.
  17014. */
  17015. }, {
  17016. key: 'syncScrollPositions',
  17017. value: function syncScrollPositions(event) {
  17018. var fakeScrollValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  17019. var fakeScrollDirection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  17020. if (this.destroyed) {
  17021. return;
  17022. }
  17023. if (arguments.length === 0) {
  17024. this.syncScrollWithMaster();
  17025. return;
  17026. }
  17027. var masterHorizontal = this.leftOverlay.mainTableScrollableElement;
  17028. var masterVertical = this.topOverlay.mainTableScrollableElement;
  17029. var target = event.target;
  17030. var tempScrollValue = 0;
  17031. var scrollValueChanged = false;
  17032. var topOverlay = void 0;
  17033. var leftOverlay = void 0;
  17034. var topLeftCornerOverlay = void 0;
  17035. var bottomLeftCornerOverlay = void 0;
  17036. var bottomOverlay = void 0;
  17037. var delegatedScroll = false;
  17038. var preventOverflow = this.wot.getSetting('preventOverflow');
  17039. if (this.topOverlay.needFullRender) {
  17040. topOverlay = this.topOverlay.clone.wtTable.holder;
  17041. }
  17042. if (this.bottomOverlay.needFullRender) {
  17043. bottomOverlay = this.bottomOverlay.clone.wtTable.holder;
  17044. }
  17045. if (this.leftOverlay.needFullRender) {
  17046. leftOverlay = this.leftOverlay.clone.wtTable.holder;
  17047. }
  17048. if (this.leftOverlay.needFullRender && this.topOverlay.needFullRender) {
  17049. topLeftCornerOverlay = this.topLeftCornerOverlay.clone.wtTable.holder;
  17050. }
  17051. if (this.leftOverlay.needFullRender && this.bottomOverlay.needFullRender) {
  17052. bottomLeftCornerOverlay = this.bottomLeftCornerOverlay.clone.wtTable.holder;
  17053. }
  17054. if (target === document) {
  17055. target = window;
  17056. }
  17057. if (target === masterHorizontal || target === masterVertical) {
  17058. if (preventOverflow) {
  17059. tempScrollValue = (0, _element.getScrollLeft)(this.scrollableElement);
  17060. } else {
  17061. tempScrollValue = (0, _element.getScrollLeft)(target);
  17062. }
  17063. // if scrolling the master table - populate the scroll values to both top and left overlays
  17064. this.horizontalScrolling = true;
  17065. this.overlayScrollPositions.master.left = tempScrollValue;
  17066. scrollValueChanged = true;
  17067. if (this.pendingScrollCallbacks.master.left > 0) {
  17068. this.pendingScrollCallbacks.master.left--;
  17069. } else {
  17070. if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) {
  17071. if (fakeScrollValue == null) {
  17072. this.pendingScrollCallbacks.top.left++;
  17073. }
  17074. topOverlay.scrollLeft = tempScrollValue;
  17075. delegatedScroll = masterHorizontal !== window;
  17076. }
  17077. if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) {
  17078. if (fakeScrollValue == null) {
  17079. this.pendingScrollCallbacks.bottom.left++;
  17080. }
  17081. bottomOverlay.scrollLeft = tempScrollValue;
  17082. delegatedScroll = masterHorizontal !== window;
  17083. }
  17084. }
  17085. tempScrollValue = (0, _element.getScrollTop)(target);
  17086. this.verticalScrolling = true;
  17087. this.overlayScrollPositions.master.top = tempScrollValue;
  17088. scrollValueChanged = true;
  17089. if (this.pendingScrollCallbacks.master.top > 0) {
  17090. this.pendingScrollCallbacks.master.top--;
  17091. } else if (leftOverlay && leftOverlay.scrollTop !== tempScrollValue) {
  17092. if (fakeScrollValue == null) {
  17093. this.pendingScrollCallbacks.left.top++;
  17094. }
  17095. leftOverlay.scrollTop = tempScrollValue;
  17096. delegatedScroll = masterVertical !== window;
  17097. }
  17098. } else if (target === bottomOverlay) {
  17099. tempScrollValue = (0, _element.getScrollLeft)(target);
  17100. // if scrolling the bottom overlay - populate the horizontal scroll to the master table
  17101. this.horizontalScrolling = true;
  17102. this.overlayScrollPositions.bottom.left = tempScrollValue;
  17103. scrollValueChanged = true;
  17104. if (this.pendingScrollCallbacks.bottom.left > 0) {
  17105. this.pendingScrollCallbacks.bottom.left--;
  17106. } else {
  17107. if (fakeScrollValue == null) {
  17108. this.pendingScrollCallbacks.master.left++;
  17109. }
  17110. masterHorizontal.scrollLeft = tempScrollValue;
  17111. if (topOverlay && topOverlay.scrollLeft !== tempScrollValue) {
  17112. if (fakeScrollValue == null) {
  17113. this.pendingScrollCallbacks.top.left++;
  17114. }
  17115. topOverlay.scrollLeft = tempScrollValue;
  17116. delegatedScroll = masterVertical !== window;
  17117. }
  17118. }
  17119. // "fake" scroll value calculated from the mousewheel event
  17120. if (fakeScrollValue !== null) {
  17121. scrollValueChanged = true;
  17122. masterVertical.scrollTop += fakeScrollValue;
  17123. }
  17124. } else if (target === topOverlay) {
  17125. tempScrollValue = (0, _element.getScrollLeft)(target);
  17126. // if scrolling the top overlay - populate the horizontal scroll to the master table
  17127. this.horizontalScrolling = true;
  17128. this.overlayScrollPositions.top.left = tempScrollValue;
  17129. scrollValueChanged = true;
  17130. if (this.pendingScrollCallbacks.top.left > 0) {
  17131. this.pendingScrollCallbacks.top.left--;
  17132. } else {
  17133. if (fakeScrollValue == null) {
  17134. this.pendingScrollCallbacks.master.left++;
  17135. }
  17136. masterHorizontal.scrollLeft = tempScrollValue;
  17137. }
  17138. // "fake" scroll value calculated from the mousewheel event
  17139. if (fakeScrollValue !== null) {
  17140. scrollValueChanged = true;
  17141. masterVertical.scrollTop += fakeScrollValue;
  17142. }
  17143. if (bottomOverlay && bottomOverlay.scrollLeft !== tempScrollValue) {
  17144. if (fakeScrollValue == null) {
  17145. this.pendingScrollCallbacks.bottom.left++;
  17146. }
  17147. bottomOverlay.scrollLeft = tempScrollValue;
  17148. delegatedScroll = masterVertical !== window;
  17149. }
  17150. } else if (target === leftOverlay) {
  17151. tempScrollValue = (0, _element.getScrollTop)(target);
  17152. // if scrolling the left overlay - populate the vertical scroll to the master table
  17153. if (this.overlayScrollPositions.left.top !== tempScrollValue) {
  17154. this.verticalScrolling = true;
  17155. this.overlayScrollPositions.left.top = tempScrollValue;
  17156. scrollValueChanged = true;
  17157. if (this.pendingScrollCallbacks.left.top > 0) {
  17158. this.pendingScrollCallbacks.left.top--;
  17159. } else {
  17160. if (fakeScrollValue == null) {
  17161. this.pendingScrollCallbacks.master.top++;
  17162. }
  17163. masterVertical.scrollTop = tempScrollValue;
  17164. }
  17165. }
  17166. // "fake" scroll value calculated from the mousewheel event
  17167. if (fakeScrollValue !== null) {
  17168. scrollValueChanged = true;
  17169. masterVertical.scrollLeft += fakeScrollValue;
  17170. }
  17171. } else if (target === topLeftCornerOverlay || target === bottomLeftCornerOverlay) {
  17172. if (fakeScrollValue !== null) {
  17173. scrollValueChanged = true;
  17174. if (fakeScrollDirection === 'x') {
  17175. masterVertical.scrollLeft += fakeScrollValue;
  17176. } else if (fakeScrollDirection === 'y') {
  17177. masterVertical.scrollTop += fakeScrollValue;
  17178. }
  17179. }
  17180. }
  17181. if (!this.keyPressed && scrollValueChanged && event.type === 'scroll') {
  17182. if (this.delegatedScrollCallback) {
  17183. this.delegatedScrollCallback = false;
  17184. } else {
  17185. this.refreshAll();
  17186. }
  17187. if (delegatedScroll) {
  17188. this.delegatedScrollCallback = true;
  17189. }
  17190. }
  17191. }
  17192. /**
  17193. * Synchronize overlay scrollbars with the master scrollbar
  17194. */
  17195. }, {
  17196. key: 'syncScrollWithMaster',
  17197. value: function syncScrollWithMaster() {
  17198. var master = this.topOverlay.mainTableScrollableElement;
  17199. var scrollLeft = master.scrollLeft,
  17200. scrollTop = master.scrollTop;
  17201. if (this.topOverlay.needFullRender) {
  17202. this.topOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  17203. }
  17204. if (this.bottomOverlay.needFullRender) {
  17205. this.bottomOverlay.clone.wtTable.holder.scrollLeft = scrollLeft;
  17206. }
  17207. if (this.leftOverlay.needFullRender) {
  17208. this.leftOverlay.clone.wtTable.holder.scrollTop = scrollTop;
  17209. }
  17210. }
  17211. /**
  17212. * Update the main scrollable elements for all the overlays.
  17213. */
  17214. }, {
  17215. key: 'updateMainScrollableElements',
  17216. value: function updateMainScrollableElements() {
  17217. this.deregisterListeners();
  17218. this.leftOverlay.updateMainScrollableElement();
  17219. this.topOverlay.updateMainScrollableElement();
  17220. if (this.bottomOverlay.needFullRender) {
  17221. this.bottomOverlay.updateMainScrollableElement();
  17222. }
  17223. this.scrollableElement = (0, _element.getScrollableElement)(this.wot.wtTable.TABLE);
  17224. this.registerListeners();
  17225. }
  17226. /**
  17227. *
  17228. */
  17229. }, {
  17230. key: 'destroy',
  17231. value: function destroy() {
  17232. this.eventManager.destroy();
  17233. this.topOverlay.destroy();
  17234. if (this.bottomOverlay.clone) {
  17235. this.bottomOverlay.destroy();
  17236. }
  17237. this.leftOverlay.destroy();
  17238. if (this.topLeftCornerOverlay) {
  17239. this.topLeftCornerOverlay.destroy();
  17240. }
  17241. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  17242. this.bottomLeftCornerOverlay.destroy();
  17243. }
  17244. if (this.debug) {
  17245. this.debug.destroy();
  17246. }
  17247. this.destroyed = true;
  17248. }
  17249. /**
  17250. * @param {Boolean} [fastDraw=false]
  17251. */
  17252. }, {
  17253. key: 'refresh',
  17254. value: function refresh() {
  17255. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17256. if (this.topOverlay.areElementSizesAdjusted && this.leftOverlay.areElementSizesAdjusted) {
  17257. var container = this.wot.wtTable.wtRootElement.parentNode || this.wot.wtTable.wtRootElement;
  17258. var width = container.clientWidth;
  17259. var height = container.clientHeight;
  17260. if (width !== this.spreaderLastSize.width || height !== this.spreaderLastSize.height) {
  17261. this.spreaderLastSize.width = width;
  17262. this.spreaderLastSize.height = height;
  17263. this.adjustElementsSize();
  17264. }
  17265. }
  17266. if (this.bottomOverlay.clone) {
  17267. this.bottomOverlay.refresh(fastDraw);
  17268. }
  17269. this.leftOverlay.refresh(fastDraw);
  17270. this.topOverlay.refresh(fastDraw);
  17271. if (this.topLeftCornerOverlay) {
  17272. this.topLeftCornerOverlay.refresh(fastDraw);
  17273. }
  17274. if (this.bottomLeftCornerOverlay && this.bottomLeftCornerOverlay.clone) {
  17275. this.bottomLeftCornerOverlay.refresh(fastDraw);
  17276. }
  17277. if (this.debug) {
  17278. this.debug.refresh(fastDraw);
  17279. }
  17280. }
  17281. /**
  17282. * Adjust overlays elements size and master table size
  17283. *
  17284. * @param {Boolean} [force=false]
  17285. */
  17286. }, {
  17287. key: 'adjustElementsSize',
  17288. value: function adjustElementsSize() {
  17289. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17290. var totalColumns = this.wot.getSetting('totalColumns');
  17291. var totalRows = this.wot.getSetting('totalRows');
  17292. var headerRowSize = this.wot.wtViewport.getRowHeaderWidth();
  17293. var headerColumnSize = this.wot.wtViewport.getColumnHeaderHeight();
  17294. var hiderStyle = this.wot.wtTable.hider.style;
  17295. hiderStyle.width = headerRowSize + this.leftOverlay.sumCellSizes(0, totalColumns) + 'px';
  17296. hiderStyle.height = headerColumnSize + this.topOverlay.sumCellSizes(0, totalRows) + 1 + 'px';
  17297. this.topOverlay.adjustElementsSize(force);
  17298. this.leftOverlay.adjustElementsSize(force);
  17299. if (this.bottomOverlay.clone) {
  17300. this.bottomOverlay.adjustElementsSize(force);
  17301. }
  17302. }
  17303. /**
  17304. *
  17305. */
  17306. }, {
  17307. key: 'applyToDOM',
  17308. value: function applyToDOM() {
  17309. if (!this.topOverlay.areElementSizesAdjusted || !this.leftOverlay.areElementSizesAdjusted) {
  17310. this.adjustElementsSize();
  17311. }
  17312. this.topOverlay.applyToDOM();
  17313. if (this.bottomOverlay.clone) {
  17314. this.bottomOverlay.applyToDOM();
  17315. }
  17316. this.leftOverlay.applyToDOM();
  17317. }
  17318. /**
  17319. * Get the parent overlay of the provided element.
  17320. *
  17321. * @param {HTMLElement} element
  17322. * @returns {Object|null}
  17323. */
  17324. }, {
  17325. key: 'getParentOverlay',
  17326. value: function getParentOverlay(element) {
  17327. if (!element) {
  17328. return null;
  17329. }
  17330. var overlays = [this.topOverlay, this.leftOverlay, this.bottomOverlay, this.topLeftCornerOverlay, this.bottomLeftCornerOverlay];
  17331. var result = null;
  17332. (0, _array.arrayEach)(overlays, function (elem, i) {
  17333. if (!elem) {
  17334. return;
  17335. }
  17336. if (elem.clone && elem.clone.wtTable.TABLE.contains(element)) {
  17337. result = elem.clone;
  17338. }
  17339. });
  17340. return result;
  17341. }
  17342. }]);
  17343. return Overlays;
  17344. }();
  17345. exports.default = Overlays;
  17346. /***/ }),
  17347. /* 143 */
  17348. /***/ (function(module, exports, __webpack_require__) {
  17349. "use strict";
  17350. exports.__esModule = true;
  17351. 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; }; }();
  17352. var _element = __webpack_require__(0);
  17353. var _number = __webpack_require__(6);
  17354. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17355. /**
  17356. * @class Scroll
  17357. */
  17358. var Scroll = function () {
  17359. /**
  17360. * @param {Walkontable} wotInstance
  17361. */
  17362. function Scroll(wotInstance) {
  17363. _classCallCheck(this, Scroll);
  17364. this.wot = wotInstance;
  17365. // legacy support
  17366. this.instance = wotInstance;
  17367. }
  17368. /**
  17369. * Scrolls viewport to a cell by minimum number of cells
  17370. *
  17371. * @param {CellCoords} coords
  17372. */
  17373. _createClass(Scroll, [{
  17374. key: 'scrollViewport',
  17375. value: function scrollViewport(coords) {
  17376. if (!this.wot.drawn) {
  17377. return;
  17378. }
  17379. var _getVariables2 = this._getVariables(),
  17380. topOverlay = _getVariables2.topOverlay,
  17381. leftOverlay = _getVariables2.leftOverlay,
  17382. totalRows = _getVariables2.totalRows,
  17383. totalColumns = _getVariables2.totalColumns,
  17384. fixedRowsTop = _getVariables2.fixedRowsTop,
  17385. fixedRowsBottom = _getVariables2.fixedRowsBottom,
  17386. fixedColumnsLeft = _getVariables2.fixedColumnsLeft;
  17387. if (coords.row < 0 || coords.row > Math.max(totalRows - 1, 0)) {
  17388. throw new Error('row ' + coords.row + ' does not exist');
  17389. }
  17390. if (coords.col < 0 || coords.col > Math.max(totalColumns - 1, 0)) {
  17391. throw new Error('column ' + coords.col + ' does not exist');
  17392. }
  17393. if (coords.row >= fixedRowsTop && coords.row < this.getFirstVisibleRow()) {
  17394. topOverlay.scrollTo(coords.row);
  17395. } else if (coords.row > this.getLastVisibleRow() && coords.row < totalRows - fixedRowsBottom) {
  17396. topOverlay.scrollTo(coords.row, true);
  17397. }
  17398. if (coords.col >= fixedColumnsLeft && coords.col < this.getFirstVisibleColumn()) {
  17399. leftOverlay.scrollTo(coords.col);
  17400. } else if (coords.col > this.getLastVisibleColumn()) {
  17401. leftOverlay.scrollTo(coords.col, true);
  17402. }
  17403. }
  17404. /**
  17405. * Get first visible row based on virtual dom and how table is visible in browser window viewport.
  17406. *
  17407. * @returns {Number}
  17408. */
  17409. }, {
  17410. key: 'getFirstVisibleRow',
  17411. value: function getFirstVisibleRow() {
  17412. var _getVariables3 = this._getVariables(),
  17413. topOverlay = _getVariables3.topOverlay,
  17414. wtTable = _getVariables3.wtTable,
  17415. wtViewport = _getVariables3.wtViewport,
  17416. totalRows = _getVariables3.totalRows,
  17417. fixedRowsTop = _getVariables3.fixedRowsTop;
  17418. var firstVisibleRow = wtTable.getFirstVisibleRow();
  17419. if (topOverlay.mainTableScrollableElement === window) {
  17420. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  17421. var totalTableHeight = (0, _element.innerHeight)(wtTable.hider);
  17422. var windowHeight = (0, _element.innerHeight)(window);
  17423. var windowScrollTop = (0, _element.getScrollTop)(window);
  17424. // Only calculate firstVisibleRow when table didn't filled (from up) whole viewport space
  17425. if (rootElementOffset.top + totalTableHeight - windowHeight <= windowScrollTop) {
  17426. var rowsHeight = wtViewport.getColumnHeaderHeight();
  17427. rowsHeight += topOverlay.sumCellSizes(0, fixedRowsTop);
  17428. (0, _number.rangeEachReverse)(totalRows, 1, function (row) {
  17429. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  17430. if (rootElementOffset.top + totalTableHeight - rowsHeight <= windowScrollTop) {
  17431. // Return physical row + 1
  17432. firstVisibleRow = row;
  17433. return false;
  17434. }
  17435. });
  17436. }
  17437. }
  17438. return firstVisibleRow;
  17439. }
  17440. /**
  17441. * Get last visible row based on virtual dom and how table is visible in browser window viewport.
  17442. *
  17443. * @returns {Number}
  17444. */
  17445. }, {
  17446. key: 'getLastVisibleRow',
  17447. value: function getLastVisibleRow() {
  17448. var _getVariables4 = this._getVariables(),
  17449. topOverlay = _getVariables4.topOverlay,
  17450. wtTable = _getVariables4.wtTable,
  17451. wtViewport = _getVariables4.wtViewport,
  17452. totalRows = _getVariables4.totalRows;
  17453. var lastVisibleRow = wtTable.getLastVisibleRow();
  17454. if (topOverlay.mainTableScrollableElement === window) {
  17455. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  17456. var windowHeight = (0, _element.innerHeight)(window);
  17457. var windowScrollTop = (0, _element.getScrollTop)(window);
  17458. // Only calculate lastVisibleRow when table didn't filled (from bottom) whole viewport space
  17459. if (rootElementOffset.top > windowScrollTop) {
  17460. var rowsHeight = wtViewport.getColumnHeaderHeight();
  17461. (0, _number.rangeEach)(1, totalRows, function (row) {
  17462. rowsHeight += topOverlay.sumCellSizes(row - 1, row);
  17463. if (rootElementOffset.top + rowsHeight - windowScrollTop >= windowHeight) {
  17464. // Return physical row - 1 (-2 because rangeEach gives row index + 1 - sumCellSizes requirements)
  17465. lastVisibleRow = row - 2;
  17466. return false;
  17467. }
  17468. });
  17469. }
  17470. }
  17471. return lastVisibleRow;
  17472. }
  17473. /**
  17474. * Get first visible column based on virtual dom and how table is visible in browser window viewport.
  17475. *
  17476. * @returns {Number}
  17477. */
  17478. }, {
  17479. key: 'getFirstVisibleColumn',
  17480. value: function getFirstVisibleColumn() {
  17481. var _getVariables5 = this._getVariables(),
  17482. leftOverlay = _getVariables5.leftOverlay,
  17483. wtTable = _getVariables5.wtTable,
  17484. wtViewport = _getVariables5.wtViewport,
  17485. totalColumns = _getVariables5.totalColumns,
  17486. fixedColumnsLeft = _getVariables5.fixedColumnsLeft;
  17487. var firstVisibleColumn = wtTable.getFirstVisibleColumn();
  17488. if (leftOverlay.mainTableScrollableElement === window) {
  17489. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  17490. var totalTableWidth = (0, _element.innerWidth)(wtTable.hider);
  17491. var windowWidth = (0, _element.innerWidth)(window);
  17492. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  17493. // Only calculate firstVisibleColumn when table didn't filled (from left) whole viewport space
  17494. if (rootElementOffset.left + totalTableWidth - windowWidth <= windowScrollLeft) {
  17495. var columnsWidth = wtViewport.getRowHeaderWidth();
  17496. (0, _number.rangeEachReverse)(totalColumns, 1, function (column) {
  17497. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  17498. if (rootElementOffset.left + totalTableWidth - columnsWidth <= windowScrollLeft) {
  17499. // Return physical column + 1
  17500. firstVisibleColumn = column;
  17501. return false;
  17502. }
  17503. });
  17504. }
  17505. }
  17506. return firstVisibleColumn;
  17507. }
  17508. /**
  17509. * Get last visible column based on virtual dom and how table is visible in browser window viewport.
  17510. *
  17511. * @returns {Number}
  17512. */
  17513. }, {
  17514. key: 'getLastVisibleColumn',
  17515. value: function getLastVisibleColumn() {
  17516. var _getVariables6 = this._getVariables(),
  17517. leftOverlay = _getVariables6.leftOverlay,
  17518. wtTable = _getVariables6.wtTable,
  17519. wtViewport = _getVariables6.wtViewport,
  17520. totalColumns = _getVariables6.totalColumns;
  17521. var lastVisibleColumn = wtTable.getLastVisibleColumn();
  17522. if (leftOverlay.mainTableScrollableElement === window) {
  17523. var rootElementOffset = (0, _element.offset)(wtTable.wtRootElement);
  17524. var windowWidth = (0, _element.innerWidth)(window);
  17525. var windowScrollLeft = (0, _element.getScrollLeft)(window);
  17526. // Only calculate lastVisibleColumn when table didn't filled (from right) whole viewport space
  17527. if (rootElementOffset.left > windowScrollLeft) {
  17528. var columnsWidth = wtViewport.getRowHeaderWidth();
  17529. (0, _number.rangeEach)(1, totalColumns, function (column) {
  17530. columnsWidth += leftOverlay.sumCellSizes(column - 1, column);
  17531. if (rootElementOffset.left + columnsWidth - windowScrollLeft >= windowWidth) {
  17532. // Return physical column - 1 (-2 because rangeEach gives column index + 1 - sumCellSizes requirements)
  17533. lastVisibleColumn = column - 2;
  17534. return false;
  17535. }
  17536. });
  17537. }
  17538. }
  17539. return lastVisibleColumn;
  17540. }
  17541. /**
  17542. * Returns collection of variables used to rows and columns visibility calculations.
  17543. *
  17544. * @returns {Object}
  17545. * @private
  17546. */
  17547. }, {
  17548. key: '_getVariables',
  17549. value: function _getVariables() {
  17550. var wot = this.wot;
  17551. var topOverlay = wot.wtOverlays.topOverlay;
  17552. var leftOverlay = wot.wtOverlays.leftOverlay;
  17553. var wtTable = wot.wtTable;
  17554. var wtViewport = wot.wtViewport;
  17555. var totalRows = wot.getSetting('totalRows');
  17556. var totalColumns = wot.getSetting('totalColumns');
  17557. var fixedRowsTop = wot.getSetting('fixedRowsTop');
  17558. var fixedRowsBottom = wot.getSetting('fixedRowsBottom');
  17559. var fixedColumnsLeft = wot.getSetting('fixedColumnsLeft');
  17560. return {
  17561. topOverlay: topOverlay,
  17562. leftOverlay: leftOverlay,
  17563. wtTable: wtTable,
  17564. wtViewport: wtViewport,
  17565. totalRows: totalRows,
  17566. totalColumns: totalColumns,
  17567. fixedRowsTop: fixedRowsTop,
  17568. fixedRowsBottom: fixedRowsBottom,
  17569. fixedColumnsLeft: fixedColumnsLeft
  17570. };
  17571. }
  17572. }]);
  17573. return Scroll;
  17574. }();
  17575. exports.default = Scroll;
  17576. /***/ }),
  17577. /* 144 */
  17578. /***/ (function(module, exports, __webpack_require__) {
  17579. "use strict";
  17580. exports.__esModule = true;
  17581. 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; }; }();
  17582. var _element = __webpack_require__(0);
  17583. var _object = __webpack_require__(1);
  17584. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17585. /**
  17586. * @class Settings
  17587. */
  17588. var Settings = function () {
  17589. /**
  17590. * @param {Walkontable} wotInstance
  17591. * @param {Object} settings
  17592. */
  17593. function Settings(wotInstance, settings) {
  17594. var _this = this;
  17595. _classCallCheck(this, Settings);
  17596. this.wot = wotInstance;
  17597. // legacy support
  17598. this.instance = wotInstance;
  17599. // default settings. void 0 means it is required, null means it can be empty
  17600. this.defaults = {
  17601. table: void 0,
  17602. debug: false, // shows WalkontableDebugOverlay
  17603. // presentation mode
  17604. externalRowCalculator: false,
  17605. stretchH: 'none', // values: all, last, none
  17606. currentRowClassName: null,
  17607. currentColumnClassName: null,
  17608. preventOverflow: function preventOverflow() {
  17609. return false;
  17610. },
  17611. // data source
  17612. data: void 0,
  17613. freezeOverlays: false,
  17614. fixedColumnsLeft: 0,
  17615. fixedRowsTop: 0,
  17616. fixedRowsBottom: 0,
  17617. minSpareRows: 0,
  17618. // this must be array of functions: [function (row, TH) {}]
  17619. rowHeaders: function rowHeaders() {
  17620. return [];
  17621. },
  17622. // this must be array of functions: [function (column, TH) {}]
  17623. columnHeaders: function columnHeaders() {
  17624. return [];
  17625. },
  17626. totalRows: void 0,
  17627. totalColumns: void 0,
  17628. cellRenderer: function cellRenderer(row, column, TD) {
  17629. var cellData = _this.getSetting('data', row, column);
  17630. (0, _element.fastInnerText)(TD, cellData === void 0 || cellData === null ? '' : cellData);
  17631. },
  17632. // columnWidth: 50,
  17633. columnWidth: function columnWidth(col) {
  17634. // return undefined means use default size for the rendered cell content
  17635. },
  17636. rowHeight: function rowHeight(row) {
  17637. // return undefined means use default size for the rendered cell content
  17638. },
  17639. defaultRowHeight: 23,
  17640. defaultColumnWidth: 50,
  17641. selections: null,
  17642. hideBorderOnMouseDownOver: false,
  17643. viewportRowCalculatorOverride: null,
  17644. viewportColumnCalculatorOverride: null,
  17645. // callbacks
  17646. onCellMouseDown: null,
  17647. onCellMouseOver: null,
  17648. onCellMouseOut: null,
  17649. onCellMouseUp: null,
  17650. // onCellMouseOut: null,
  17651. onCellDblClick: null,
  17652. onCellCornerMouseDown: null,
  17653. onCellCornerDblClick: null,
  17654. beforeDraw: null,
  17655. onDraw: null,
  17656. onBeforeDrawBorders: null,
  17657. onScrollVertically: null,
  17658. onScrollHorizontally: null,
  17659. onBeforeTouchScroll: null,
  17660. onAfterMomentumScroll: null,
  17661. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(width) {
  17662. return width;
  17663. },
  17664. onModifyRowHeaderWidth: null,
  17665. // constants
  17666. scrollbarWidth: 10,
  17667. scrollbarHeight: 10,
  17668. renderAllRows: false,
  17669. groups: false,
  17670. rowHeaderWidth: null,
  17671. columnHeaderHeight: null,
  17672. headerClassName: null
  17673. };
  17674. // reference to settings
  17675. this.settings = {};
  17676. for (var i in this.defaults) {
  17677. if ((0, _object.hasOwnProperty)(this.defaults, i)) {
  17678. if (settings[i] !== void 0) {
  17679. this.settings[i] = settings[i];
  17680. } else if (this.defaults[i] === void 0) {
  17681. throw new Error('A required setting "' + i + '" was not provided');
  17682. } else {
  17683. this.settings[i] = this.defaults[i];
  17684. }
  17685. }
  17686. }
  17687. }
  17688. /**
  17689. * Update settings
  17690. *
  17691. * @param {Object} settings
  17692. * @param {*} value
  17693. * @returns {Walkontable}
  17694. */
  17695. _createClass(Settings, [{
  17696. key: 'update',
  17697. value: function update(settings, value) {
  17698. if (value === void 0) {
  17699. // settings is object
  17700. for (var i in settings) {
  17701. if ((0, _object.hasOwnProperty)(settings, i)) {
  17702. this.settings[i] = settings[i];
  17703. }
  17704. }
  17705. } else {
  17706. // if value is defined then settings is the key
  17707. this.settings[settings] = value;
  17708. }
  17709. return this.wot;
  17710. }
  17711. /**
  17712. * Get setting by name
  17713. *
  17714. * @param {String} key
  17715. * @param {*} param1
  17716. * @param {*} param2
  17717. * @param {*} param3
  17718. * @param {*} param4
  17719. * @returns {*}
  17720. */
  17721. }, {
  17722. key: 'getSetting',
  17723. value: function getSetting(key, param1, param2, param3, param4) {
  17724. if (typeof this.settings[key] === 'function') {
  17725. // this is faster than .apply - https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  17726. return this.settings[key](param1, param2, param3, param4);
  17727. } else if (param1 !== void 0 && Array.isArray(this.settings[key])) {
  17728. // perhaps this can be removed, it is only used in tests
  17729. return this.settings[key][param1];
  17730. }
  17731. return this.settings[key];
  17732. }
  17733. /**
  17734. * Checks if setting exists
  17735. *
  17736. * @param {Boolean} key
  17737. * @returns {Boolean}
  17738. */
  17739. }, {
  17740. key: 'has',
  17741. value: function has(key) {
  17742. return !!this.settings[key];
  17743. }
  17744. }]);
  17745. return Settings;
  17746. }();
  17747. exports.default = Settings;
  17748. /***/ }),
  17749. /* 145 */
  17750. /***/ (function(module, exports, __webpack_require__) {
  17751. "use strict";
  17752. exports.__esModule = true;
  17753. 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; };
  17754. 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; }; }();
  17755. var _element = __webpack_require__(0);
  17756. var _function = __webpack_require__(35);
  17757. var _coords = __webpack_require__(42);
  17758. var _coords2 = _interopRequireDefault(_coords);
  17759. var _range = __webpack_require__(68);
  17760. var _range2 = _interopRequireDefault(_range);
  17761. var _column = __webpack_require__(140);
  17762. var _column2 = _interopRequireDefault(_column);
  17763. var _row = __webpack_require__(141);
  17764. var _row2 = _interopRequireDefault(_row);
  17765. var _tableRenderer = __webpack_require__(146);
  17766. var _tableRenderer2 = _interopRequireDefault(_tableRenderer);
  17767. var _base = __webpack_require__(28);
  17768. var _base2 = _interopRequireDefault(_base);
  17769. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17770. 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); } }
  17771. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17772. /**
  17773. *
  17774. */
  17775. var Table = function () {
  17776. /**
  17777. * @param {Walkontable} wotInstance
  17778. * @param {HTMLTableElement} table
  17779. */
  17780. function Table(wotInstance, table) {
  17781. var _this = this;
  17782. _classCallCheck(this, Table);
  17783. this.wot = wotInstance;
  17784. // legacy support
  17785. this.instance = this.wot;
  17786. this.TABLE = table;
  17787. this.TBODY = null;
  17788. this.THEAD = null;
  17789. this.COLGROUP = null;
  17790. this.tableOffset = 0;
  17791. this.holderOffset = 0;
  17792. (0, _element.removeTextNodes)(this.TABLE);
  17793. this.spreader = this.createSpreader(this.TABLE);
  17794. this.hider = this.createHider(this.spreader);
  17795. this.holder = this.createHolder(this.hider);
  17796. this.wtRootElement = this.holder.parentNode;
  17797. this.alignOverlaysWithTrimmingContainer();
  17798. this.fixTableDomTree();
  17799. this.colgroupChildrenLength = this.COLGROUP.childNodes.length;
  17800. this.theadChildrenLength = this.THEAD.firstChild ? this.THEAD.firstChild.childNodes.length : 0;
  17801. this.tbodyChildrenLength = this.TBODY.childNodes.length;
  17802. this.rowFilter = null;
  17803. this.columnFilter = null;
  17804. this.correctHeaderWidth = false;
  17805. var origRowHeaderWidth = this.wot.wtSettings.settings.rowHeaderWidth;
  17806. // Fix for jumping row headers (https://github.com/handsontable/handsontable/issues/3850)
  17807. this.wot.wtSettings.settings.rowHeaderWidth = function () {
  17808. return _this._modifyRowHeaderWidth(origRowHeaderWidth);
  17809. };
  17810. }
  17811. /**
  17812. *
  17813. */
  17814. _createClass(Table, [{
  17815. key: 'fixTableDomTree',
  17816. value: function fixTableDomTree() {
  17817. this.TBODY = this.TABLE.querySelector('tbody');
  17818. if (!this.TBODY) {
  17819. this.TBODY = document.createElement('tbody');
  17820. this.TABLE.appendChild(this.TBODY);
  17821. }
  17822. this.THEAD = this.TABLE.querySelector('thead');
  17823. if (!this.THEAD) {
  17824. this.THEAD = document.createElement('thead');
  17825. this.TABLE.insertBefore(this.THEAD, this.TBODY);
  17826. }
  17827. this.COLGROUP = this.TABLE.querySelector('colgroup');
  17828. if (!this.COLGROUP) {
  17829. this.COLGROUP = document.createElement('colgroup');
  17830. this.TABLE.insertBefore(this.COLGROUP, this.THEAD);
  17831. }
  17832. if (this.wot.getSetting('columnHeaders').length && !this.THEAD.childNodes.length) {
  17833. this.THEAD.appendChild(document.createElement('TR'));
  17834. }
  17835. }
  17836. /**
  17837. * @param table
  17838. * @returns {HTMLElement}
  17839. */
  17840. }, {
  17841. key: 'createSpreader',
  17842. value: function createSpreader(table) {
  17843. var parent = table.parentNode;
  17844. var spreader = void 0;
  17845. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  17846. spreader = document.createElement('div');
  17847. spreader.className = 'wtSpreader';
  17848. if (parent) {
  17849. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  17850. parent.insertBefore(spreader, table);
  17851. }
  17852. spreader.appendChild(table);
  17853. }
  17854. spreader.style.position = 'relative';
  17855. return spreader;
  17856. }
  17857. /**
  17858. * @param spreader
  17859. * @returns {HTMLElement}
  17860. */
  17861. }, {
  17862. key: 'createHider',
  17863. value: function createHider(spreader) {
  17864. var parent = spreader.parentNode;
  17865. var hider = void 0;
  17866. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  17867. hider = document.createElement('div');
  17868. hider.className = 'wtHider';
  17869. if (parent) {
  17870. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  17871. parent.insertBefore(hider, spreader);
  17872. }
  17873. hider.appendChild(spreader);
  17874. }
  17875. return hider;
  17876. }
  17877. /**
  17878. *
  17879. * @param hider
  17880. * @returns {HTMLElement}
  17881. */
  17882. }, {
  17883. key: 'createHolder',
  17884. value: function createHolder(hider) {
  17885. var parent = hider.parentNode;
  17886. var holder = void 0;
  17887. if (!parent || parent.nodeType !== 1 || !(0, _element.hasClass)(parent, 'wtHolder')) {
  17888. holder = document.createElement('div');
  17889. holder.style.position = 'relative';
  17890. holder.className = 'wtHolder';
  17891. if (parent) {
  17892. // if TABLE is detached (e.g. in Jasmine test), it has no parentNode so we cannot attach holder to it
  17893. parent.insertBefore(holder, hider);
  17894. }
  17895. if (!this.isWorkingOnClone()) {
  17896. holder.parentNode.className += 'ht_master handsontable';
  17897. }
  17898. holder.appendChild(hider);
  17899. }
  17900. return holder;
  17901. }
  17902. }, {
  17903. key: 'alignOverlaysWithTrimmingContainer',
  17904. value: function alignOverlaysWithTrimmingContainer() {
  17905. var trimmingElement = (0, _element.getTrimmingContainer)(this.wtRootElement);
  17906. if (!this.isWorkingOnClone()) {
  17907. this.holder.parentNode.style.position = 'relative';
  17908. if (trimmingElement === window) {
  17909. var preventOverflow = this.wot.getSetting('preventOverflow');
  17910. if (!preventOverflow) {
  17911. this.holder.style.overflow = 'visible';
  17912. this.wtRootElement.style.overflow = 'visible';
  17913. }
  17914. } else {
  17915. this.holder.style.width = (0, _element.getStyle)(trimmingElement, 'width');
  17916. this.holder.style.height = (0, _element.getStyle)(trimmingElement, 'height');
  17917. this.holder.style.overflow = '';
  17918. }
  17919. }
  17920. }
  17921. }, {
  17922. key: 'isWorkingOnClone',
  17923. value: function isWorkingOnClone() {
  17924. return !!this.wot.cloneSource;
  17925. }
  17926. /**
  17927. * Redraws the table
  17928. *
  17929. * @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
  17930. * @returns {Table}
  17931. */
  17932. }, {
  17933. key: 'draw',
  17934. value: function draw(fastDraw) {
  17935. var _wot = this.wot,
  17936. wtOverlays = _wot.wtOverlays,
  17937. wtViewport = _wot.wtViewport;
  17938. var totalRows = this.instance.getSetting('totalRows');
  17939. var rowHeaders = this.wot.getSetting('rowHeaders').length;
  17940. var columnHeaders = this.wot.getSetting('columnHeaders').length;
  17941. var syncScroll = false;
  17942. if (!this.isWorkingOnClone()) {
  17943. this.holderOffset = (0, _element.offset)(this.holder);
  17944. fastDraw = wtViewport.createRenderCalculators(fastDraw);
  17945. if (rowHeaders && !this.wot.getSetting('fixedColumnsLeft')) {
  17946. var leftScrollPos = wtOverlays.leftOverlay.getScrollPosition();
  17947. var previousState = this.correctHeaderWidth;
  17948. this.correctHeaderWidth = leftScrollPos > 0;
  17949. if (previousState !== this.correctHeaderWidth) {
  17950. fastDraw = false;
  17951. }
  17952. }
  17953. }
  17954. if (!this.isWorkingOnClone()) {
  17955. syncScroll = wtOverlays.prepareOverlays();
  17956. }
  17957. if (fastDraw) {
  17958. if (!this.isWorkingOnClone()) {
  17959. // in case we only scrolled without redraw, update visible rows information in oldRowsCalculator
  17960. wtViewport.createVisibleCalculators();
  17961. }
  17962. if (wtOverlays) {
  17963. wtOverlays.refresh(true);
  17964. }
  17965. } else {
  17966. if (this.isWorkingOnClone()) {
  17967. this.tableOffset = this.wot.cloneSource.wtTable.tableOffset;
  17968. } else {
  17969. this.tableOffset = (0, _element.offset)(this.TABLE);
  17970. }
  17971. var startRow = void 0;
  17972. 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)) {
  17973. startRow = 0;
  17974. } else if (_base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.instance.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  17975. startRow = Math.max(totalRows - this.wot.getSetting('fixedRowsBottom'), 0);
  17976. } else {
  17977. startRow = wtViewport.rowsRenderCalculator.startRow;
  17978. }
  17979. var startColumn = void 0;
  17980. 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)) {
  17981. startColumn = 0;
  17982. } else {
  17983. startColumn = wtViewport.columnsRenderCalculator.startColumn;
  17984. }
  17985. this.rowFilter = new _row2.default(startRow, totalRows, columnHeaders);
  17986. this.columnFilter = new _column2.default(startColumn, this.wot.getSetting('totalColumns'), rowHeaders);
  17987. this.alignOverlaysWithTrimmingContainer();
  17988. this._doDraw(); // creates calculator after draw
  17989. }
  17990. this.refreshSelections(fastDraw);
  17991. if (!this.isWorkingOnClone()) {
  17992. wtOverlays.topOverlay.resetFixedPosition();
  17993. if (wtOverlays.bottomOverlay.clone) {
  17994. wtOverlays.bottomOverlay.resetFixedPosition();
  17995. }
  17996. wtOverlays.leftOverlay.resetFixedPosition();
  17997. if (wtOverlays.topLeftCornerOverlay) {
  17998. wtOverlays.topLeftCornerOverlay.resetFixedPosition();
  17999. }
  18000. if (wtOverlays.bottomLeftCornerOverlay && wtOverlays.bottomLeftCornerOverlay.clone) {
  18001. wtOverlays.bottomLeftCornerOverlay.resetFixedPosition();
  18002. }
  18003. }
  18004. if (syncScroll) {
  18005. wtOverlays.syncScrollWithMaster();
  18006. }
  18007. this.wot.drawn = true;
  18008. return this;
  18009. }
  18010. }, {
  18011. key: '_doDraw',
  18012. value: function _doDraw() {
  18013. var wtRenderer = new _tableRenderer2.default(this);
  18014. wtRenderer.render();
  18015. }
  18016. }, {
  18017. key: 'removeClassFromCells',
  18018. value: function removeClassFromCells(className) {
  18019. var nodes = this.TABLE.querySelectorAll('.' + className);
  18020. for (var i = 0, len = nodes.length; i < len; i++) {
  18021. (0, _element.removeClass)(nodes[i], className);
  18022. }
  18023. }
  18024. }, {
  18025. key: 'refreshSelections',
  18026. value: function refreshSelections(fastDraw) {
  18027. if (!this.wot.selections) {
  18028. return;
  18029. }
  18030. var len = this.wot.selections.length;
  18031. if (fastDraw) {
  18032. for (var i = 0; i < len; i++) {
  18033. // there was no rerender, so we need to remove classNames by ourselves
  18034. if (this.wot.selections[i].settings.className) {
  18035. this.removeClassFromCells(this.wot.selections[i].settings.className);
  18036. }
  18037. if (this.wot.selections[i].settings.highlightHeaderClassName) {
  18038. this.removeClassFromCells(this.wot.selections[i].settings.highlightHeaderClassName);
  18039. }
  18040. if (this.wot.selections[i].settings.highlightRowClassName) {
  18041. this.removeClassFromCells(this.wot.selections[i].settings.highlightRowClassName);
  18042. }
  18043. if (this.wot.selections[i].settings.highlightColumnClassName) {
  18044. this.removeClassFromCells(this.wot.selections[i].settings.highlightColumnClassName);
  18045. }
  18046. }
  18047. }
  18048. for (var _i = 0; _i < len; _i++) {
  18049. this.wot.selections[_i].draw(this.wot, fastDraw);
  18050. }
  18051. }
  18052. /**
  18053. * Get cell element at coords.
  18054. *
  18055. * @param {CellCoords} coords
  18056. * @returns {HTMLElement|Number} HTMLElement on success or Number one of the exit codes on error:
  18057. * -1 row before viewport
  18058. * -2 row after viewport
  18059. */
  18060. }, {
  18061. key: 'getCell',
  18062. value: function getCell(coords) {
  18063. if (this.isRowBeforeRenderedRows(coords.row)) {
  18064. // row before rendered rows
  18065. return -1;
  18066. } else if (this.isRowAfterRenderedRows(coords.row)) {
  18067. // row after rendered rows
  18068. return -2;
  18069. }
  18070. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(coords.row)];
  18071. if (TR) {
  18072. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(coords.col)];
  18073. }
  18074. }
  18075. /**
  18076. * getColumnHeader
  18077. *
  18078. * @param {Number} col Column index
  18079. * @param {Number} [level=0] Header level (0 = most distant to the table)
  18080. * @returns {Object} HTMLElement on success or undefined on error
  18081. */
  18082. }, {
  18083. key: 'getColumnHeader',
  18084. value: function getColumnHeader(col) {
  18085. var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  18086. var TR = this.THEAD.childNodes[level];
  18087. if (TR) {
  18088. return TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(col)];
  18089. }
  18090. }
  18091. /**
  18092. * getRowHeader
  18093. *
  18094. * @param {Number} row Row index
  18095. * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have row headers`
  18096. */
  18097. }, {
  18098. key: 'getRowHeader',
  18099. value: function getRowHeader(row) {
  18100. if (this.columnFilter.sourceColumnToVisibleRowHeadedColumn(0) === 0) {
  18101. return null;
  18102. }
  18103. var TR = this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  18104. if (TR) {
  18105. return TR.childNodes[0];
  18106. }
  18107. }
  18108. /**
  18109. * Returns cell coords object for a given TD (or a child element of a TD element).
  18110. *
  18111. * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one).
  18112. * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the provided element is not applicable.
  18113. */
  18114. }, {
  18115. key: 'getCoords',
  18116. value: function getCoords(TD) {
  18117. if (TD.nodeName !== 'TD' && TD.nodeName !== 'TH') {
  18118. TD = (0, _element.closest)(TD, ['TD', 'TH']);
  18119. }
  18120. if (TD === null) {
  18121. return null;
  18122. }
  18123. var TR = TD.parentNode;
  18124. var CONTAINER = TR.parentNode;
  18125. var row = (0, _element.index)(TR);
  18126. var col = TD.cellIndex;
  18127. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_TOP, TD)) {
  18128. if (CONTAINER.nodeName === 'THEAD') {
  18129. row -= CONTAINER.childNodes.length;
  18130. }
  18131. } else if (CONTAINER === this.THEAD) {
  18132. row = this.rowFilter.visibleColHeadedRowToSourceRow(row);
  18133. } else {
  18134. row = this.rowFilter.renderedToSource(row);
  18135. }
  18136. if ((0, _element.overlayContainsElement)(_base2.default.CLONE_TOP_LEFT_CORNER, TD) || (0, _element.overlayContainsElement)(_base2.default.CLONE_LEFT, TD)) {
  18137. col = this.columnFilter.offsettedTH(col);
  18138. } else {
  18139. col = this.columnFilter.visibleRowHeadedColumnToSourceColumn(col);
  18140. }
  18141. return new _coords2.default(row, col);
  18142. }
  18143. }, {
  18144. key: 'getTrForRow',
  18145. value: function getTrForRow(row) {
  18146. return this.TBODY.childNodes[this.rowFilter.sourceToRendered(row)];
  18147. }
  18148. }, {
  18149. key: 'getFirstRenderedRow',
  18150. value: function getFirstRenderedRow() {
  18151. return this.wot.wtViewport.rowsRenderCalculator.startRow;
  18152. }
  18153. }, {
  18154. key: 'getFirstVisibleRow',
  18155. value: function getFirstVisibleRow() {
  18156. return this.wot.wtViewport.rowsVisibleCalculator.startRow;
  18157. }
  18158. }, {
  18159. key: 'getFirstRenderedColumn',
  18160. value: function getFirstRenderedColumn() {
  18161. return this.wot.wtViewport.columnsRenderCalculator.startColumn;
  18162. }
  18163. /**
  18164. * @returns {Number} Returns -1 if no row is visible
  18165. */
  18166. }, {
  18167. key: 'getFirstVisibleColumn',
  18168. value: function getFirstVisibleColumn() {
  18169. return this.wot.wtViewport.columnsVisibleCalculator.startColumn;
  18170. }
  18171. /**
  18172. * @returns {Number} Returns -1 if no row is visible
  18173. */
  18174. }, {
  18175. key: 'getLastRenderedRow',
  18176. value: function getLastRenderedRow() {
  18177. return this.wot.wtViewport.rowsRenderCalculator.endRow;
  18178. }
  18179. }, {
  18180. key: 'getLastVisibleRow',
  18181. value: function getLastVisibleRow() {
  18182. return this.wot.wtViewport.rowsVisibleCalculator.endRow;
  18183. }
  18184. }, {
  18185. key: 'getLastRenderedColumn',
  18186. value: function getLastRenderedColumn() {
  18187. return this.wot.wtViewport.columnsRenderCalculator.endColumn;
  18188. }
  18189. /**
  18190. * @returns {Number} Returns -1 if no column is visible
  18191. */
  18192. }, {
  18193. key: 'getLastVisibleColumn',
  18194. value: function getLastVisibleColumn() {
  18195. return this.wot.wtViewport.columnsVisibleCalculator.endColumn;
  18196. }
  18197. }, {
  18198. key: 'isRowBeforeRenderedRows',
  18199. value: function isRowBeforeRenderedRows(row) {
  18200. return this.rowFilter && this.rowFilter.sourceToRendered(row) < 0 && row >= 0;
  18201. }
  18202. }, {
  18203. key: 'isRowAfterViewport',
  18204. value: function isRowAfterViewport(row) {
  18205. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastVisibleRow();
  18206. }
  18207. }, {
  18208. key: 'isRowAfterRenderedRows',
  18209. value: function isRowAfterRenderedRows(row) {
  18210. return this.rowFilter && this.rowFilter.sourceToRendered(row) > this.getLastRenderedRow();
  18211. }
  18212. }, {
  18213. key: 'isColumnBeforeViewport',
  18214. value: function isColumnBeforeViewport(column) {
  18215. return this.columnFilter && this.columnFilter.sourceToRendered(column) < 0 && column >= 0;
  18216. }
  18217. }, {
  18218. key: 'isColumnAfterViewport',
  18219. value: function isColumnAfterViewport(column) {
  18220. return this.columnFilter && this.columnFilter.sourceToRendered(column) > this.getLastVisibleColumn();
  18221. }
  18222. }, {
  18223. key: 'isLastRowFullyVisible',
  18224. value: function isLastRowFullyVisible() {
  18225. return this.getLastVisibleRow() === this.getLastRenderedRow();
  18226. }
  18227. }, {
  18228. key: 'isLastColumnFullyVisible',
  18229. value: function isLastColumnFullyVisible() {
  18230. return this.getLastVisibleColumn() === this.getLastRenderedColumn();
  18231. }
  18232. }, {
  18233. key: 'getRenderedColumnsCount',
  18234. value: function getRenderedColumnsCount() {
  18235. var columnsCount = this.wot.wtViewport.columnsRenderCalculator.count;
  18236. var totalColumns = this.wot.getSetting('totalColumns');
  18237. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  18238. columnsCount = totalColumns;
  18239. } 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)) {
  18240. return Math.min(this.wot.getSetting('fixedColumnsLeft'), totalColumns);
  18241. }
  18242. return columnsCount;
  18243. }
  18244. }, {
  18245. key: 'getRenderedRowsCount',
  18246. value: function getRenderedRowsCount() {
  18247. var rowsCount = this.wot.wtViewport.rowsRenderCalculator.count;
  18248. var totalRows = this.wot.getSetting('totalRows');
  18249. if (this.wot.isOverlayName(_base2.default.CLONE_DEBUG)) {
  18250. rowsCount = totalRows;
  18251. } else if (this.wot.isOverlayName(_base2.default.CLONE_TOP) || this.wot.isOverlayName(_base2.default.CLONE_TOP_LEFT_CORNER)) {
  18252. rowsCount = Math.min(this.wot.getSetting('fixedRowsTop'), totalRows);
  18253. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM) || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  18254. rowsCount = Math.min(this.wot.getSetting('fixedRowsBottom'), totalRows);
  18255. }
  18256. return rowsCount;
  18257. }
  18258. }, {
  18259. key: 'getVisibleRowsCount',
  18260. value: function getVisibleRowsCount() {
  18261. return this.wot.wtViewport.rowsVisibleCalculator.count;
  18262. }
  18263. }, {
  18264. key: 'allRowsInViewport',
  18265. value: function allRowsInViewport() {
  18266. return this.wot.getSetting('totalRows') == this.getVisibleRowsCount();
  18267. }
  18268. /**
  18269. * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height
  18270. *
  18271. * @param {Number} sourceRow
  18272. * @returns {Number}
  18273. */
  18274. }, {
  18275. key: 'getRowHeight',
  18276. value: function getRowHeight(sourceRow) {
  18277. var height = this.wot.wtSettings.settings.rowHeight(sourceRow);
  18278. var oversizedHeight = this.wot.wtViewport.oversizedRows[sourceRow];
  18279. if (oversizedHeight !== void 0) {
  18280. height = height === void 0 ? oversizedHeight : Math.max(height, oversizedHeight);
  18281. }
  18282. return height;
  18283. }
  18284. }, {
  18285. key: 'getColumnHeaderHeight',
  18286. value: function getColumnHeaderHeight(level) {
  18287. var height = this.wot.wtSettings.settings.defaultRowHeight;
  18288. var oversizedHeight = this.wot.wtViewport.oversizedColumnHeaders[level];
  18289. if (oversizedHeight !== void 0) {
  18290. height = height ? Math.max(height, oversizedHeight) : oversizedHeight;
  18291. }
  18292. return height;
  18293. }
  18294. }, {
  18295. key: 'getVisibleColumnsCount',
  18296. value: function getVisibleColumnsCount() {
  18297. return this.wot.wtViewport.columnsVisibleCalculator.count;
  18298. }
  18299. }, {
  18300. key: 'allColumnsInViewport',
  18301. value: function allColumnsInViewport() {
  18302. return this.wot.getSetting('totalColumns') == this.getVisibleColumnsCount();
  18303. }
  18304. }, {
  18305. key: 'getColumnWidth',
  18306. value: function getColumnWidth(sourceColumn) {
  18307. var width = this.wot.wtSettings.settings.columnWidth;
  18308. if (typeof width === 'function') {
  18309. width = width(sourceColumn);
  18310. } else if ((typeof width === 'undefined' ? 'undefined' : _typeof(width)) === 'object') {
  18311. width = width[sourceColumn];
  18312. }
  18313. return width || this.wot.wtSettings.settings.defaultColumnWidth;
  18314. }
  18315. }, {
  18316. key: 'getStretchedColumnWidth',
  18317. value: function getStretchedColumnWidth(sourceColumn) {
  18318. var columnWidth = this.getColumnWidth(sourceColumn);
  18319. var width = columnWidth == null ? this.instance.wtSettings.settings.defaultColumnWidth : columnWidth;
  18320. var calculator = this.wot.wtViewport.columnsRenderCalculator;
  18321. if (calculator) {
  18322. var stretchedWidth = calculator.getStretchedColumnWidth(sourceColumn, width);
  18323. if (stretchedWidth) {
  18324. width = stretchedWidth;
  18325. }
  18326. }
  18327. return width;
  18328. }
  18329. /**
  18330. * Modify row header widths provided by user in class contructor.
  18331. *
  18332. * @private
  18333. */
  18334. }, {
  18335. key: '_modifyRowHeaderWidth',
  18336. value: function _modifyRowHeaderWidth(rowHeaderWidthFactory) {
  18337. var widths = (0, _function.isFunction)(rowHeaderWidthFactory) ? rowHeaderWidthFactory() : null;
  18338. if (Array.isArray(widths)) {
  18339. widths = [].concat(_toConsumableArray(widths));
  18340. widths[widths.length - 1] = this._correctRowHeaderWidth(widths[widths.length - 1]);
  18341. } else {
  18342. widths = this._correctRowHeaderWidth(widths);
  18343. }
  18344. return widths;
  18345. }
  18346. /**
  18347. * Correct row header width if necessary.
  18348. *
  18349. * @private
  18350. */
  18351. }, {
  18352. key: '_correctRowHeaderWidth',
  18353. value: function _correctRowHeaderWidth(width) {
  18354. if (typeof width !== 'number') {
  18355. width = this.wot.getSetting('defaultColumnWidth');
  18356. }
  18357. if (this.correctHeaderWidth) {
  18358. width++;
  18359. }
  18360. return width;
  18361. }
  18362. }]);
  18363. return Table;
  18364. }();
  18365. exports.default = Table;
  18366. /***/ }),
  18367. /* 146 */
  18368. /***/ (function(module, exports, __webpack_require__) {
  18369. "use strict";
  18370. exports.__esModule = true;
  18371. 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; }; }();
  18372. var _element = __webpack_require__(0);
  18373. var _base = __webpack_require__(28);
  18374. var _base2 = _interopRequireDefault(_base);
  18375. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18376. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18377. var performanceWarningAppeared = false;
  18378. /**
  18379. * @class TableRenderer
  18380. */
  18381. var TableRenderer = function () {
  18382. /**
  18383. * @param {WalkontableTable} wtTable
  18384. */
  18385. function TableRenderer(wtTable) {
  18386. _classCallCheck(this, TableRenderer);
  18387. this.wtTable = wtTable;
  18388. this.wot = wtTable.instance;
  18389. // legacy support
  18390. this.instance = wtTable.instance;
  18391. this.rowFilter = wtTable.rowFilter;
  18392. this.columnFilter = wtTable.columnFilter;
  18393. this.TABLE = wtTable.TABLE;
  18394. this.THEAD = wtTable.THEAD;
  18395. this.TBODY = wtTable.TBODY;
  18396. this.COLGROUP = wtTable.COLGROUP;
  18397. this.rowHeaders = [];
  18398. this.rowHeaderCount = 0;
  18399. this.columnHeaders = [];
  18400. this.columnHeaderCount = 0;
  18401. this.fixedRowsTop = 0;
  18402. this.fixedRowsBottom = 0;
  18403. }
  18404. /**
  18405. *
  18406. */
  18407. _createClass(TableRenderer, [{
  18408. key: 'render',
  18409. value: function render() {
  18410. if (!this.wtTable.isWorkingOnClone()) {
  18411. var skipRender = {};
  18412. this.wot.getSetting('beforeDraw', true, skipRender);
  18413. if (skipRender.skipRender === true) {
  18414. return;
  18415. }
  18416. }
  18417. this.rowHeaders = this.wot.getSetting('rowHeaders');
  18418. this.rowHeaderCount = this.rowHeaders.length;
  18419. this.fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  18420. this.fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  18421. this.columnHeaders = this.wot.getSetting('columnHeaders');
  18422. this.columnHeaderCount = this.columnHeaders.length;
  18423. var columnsToRender = this.wtTable.getRenderedColumnsCount();
  18424. var rowsToRender = this.wtTable.getRenderedRowsCount();
  18425. var totalColumns = this.wot.getSetting('totalColumns');
  18426. var totalRows = this.wot.getSetting('totalRows');
  18427. var workspaceWidth = void 0;
  18428. var adjusted = false;
  18429. if (_base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM) || _base2.default.isOverlayTypeOf(this.wot.cloneOverlay, _base2.default.CLONE_BOTTOM_LEFT_CORNER)) {
  18430. // do NOT render headers on the bottom or bottom-left corner overlay
  18431. this.columnHeaders = [];
  18432. this.columnHeaderCount = 0;
  18433. }
  18434. if (totalColumns >= 0) {
  18435. // prepare COL and TH elements for rendering
  18436. this.adjustAvailableNodes();
  18437. adjusted = true;
  18438. // adjust column widths according to user widths settings
  18439. this.renderColumnHeaders();
  18440. // Render table rows
  18441. this.renderRows(totalRows, rowsToRender, columnsToRender);
  18442. if (!this.wtTable.isWorkingOnClone()) {
  18443. workspaceWidth = this.wot.wtViewport.getWorkspaceWidth();
  18444. this.wot.wtViewport.containerWidth = null;
  18445. }
  18446. this.adjustColumnWidths(columnsToRender);
  18447. this.markOversizedColumnHeaders();
  18448. this.adjustColumnHeaderHeights();
  18449. }
  18450. if (!adjusted) {
  18451. this.adjustAvailableNodes();
  18452. }
  18453. this.removeRedundantRows(rowsToRender);
  18454. if (!this.wtTable.isWorkingOnClone() || this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  18455. this.markOversizedRows();
  18456. }
  18457. if (!this.wtTable.isWorkingOnClone()) {
  18458. this.wot.wtViewport.createVisibleCalculators();
  18459. this.wot.wtOverlays.refresh(false);
  18460. this.wot.wtOverlays.applyToDOM();
  18461. var hiderWidth = (0, _element.outerWidth)(this.wtTable.hider);
  18462. var tableWidth = (0, _element.outerWidth)(this.wtTable.TABLE);
  18463. if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
  18464. // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
  18465. this.adjustColumnWidths(columnsToRender);
  18466. }
  18467. if (workspaceWidth !== this.wot.wtViewport.getWorkspaceWidth()) {
  18468. // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
  18469. this.wot.wtViewport.containerWidth = null;
  18470. var firstRendered = this.wtTable.getFirstRenderedColumn();
  18471. var lastRendered = this.wtTable.getLastRenderedColumn();
  18472. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  18473. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  18474. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  18475. if (rowHeaderWidthSetting != null) {
  18476. for (var i = 0; i < this.rowHeaderCount; i++) {
  18477. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  18478. width = width == null ? defaultColumnWidth : width;
  18479. this.COLGROUP.childNodes[i].style.width = width + 'px';
  18480. }
  18481. }
  18482. for (var _i = firstRendered; _i < lastRendered; _i++) {
  18483. var _width = this.wtTable.getStretchedColumnWidth(_i);
  18484. var renderedIndex = this.columnFilter.sourceToRendered(_i);
  18485. this.COLGROUP.childNodes[renderedIndex + this.rowHeaderCount].style.width = _width + 'px';
  18486. }
  18487. }
  18488. this.wot.getSetting('onDraw', true);
  18489. } else if (this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  18490. this.wot.cloneSource.wtOverlays.adjustElementsSize();
  18491. }
  18492. }
  18493. /**
  18494. * @param {Number} renderedRowsCount
  18495. */
  18496. }, {
  18497. key: 'removeRedundantRows',
  18498. value: function removeRedundantRows(renderedRowsCount) {
  18499. while (this.wtTable.tbodyChildrenLength > renderedRowsCount) {
  18500. this.TBODY.removeChild(this.TBODY.lastChild);
  18501. this.wtTable.tbodyChildrenLength--;
  18502. }
  18503. }
  18504. /**
  18505. * @param {Number} totalRows
  18506. * @param {Number} rowsToRender
  18507. * @param {Number} columnsToRender
  18508. */
  18509. }, {
  18510. key: 'renderRows',
  18511. value: function renderRows(totalRows, rowsToRender, columnsToRender) {
  18512. var lastTD = void 0,
  18513. TR = void 0;
  18514. var visibleRowIndex = 0;
  18515. var sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  18516. var isWorkingOnClone = this.wtTable.isWorkingOnClone();
  18517. while (sourceRowIndex < totalRows && sourceRowIndex >= 0) {
  18518. if (!performanceWarningAppeared && visibleRowIndex > 1000) {
  18519. performanceWarningAppeared = true;
  18520. 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.');
  18521. }
  18522. if (rowsToRender !== void 0 && visibleRowIndex === rowsToRender) {
  18523. // We have as much rows as needed for this clone
  18524. break;
  18525. }
  18526. TR = this.getOrCreateTrForRow(visibleRowIndex, TR);
  18527. // Render row headers
  18528. this.renderRowHeaders(sourceRowIndex, TR);
  18529. // Add and/or remove TDs to TR to match the desired number
  18530. this.adjustColumns(TR, columnsToRender + this.rowHeaderCount);
  18531. lastTD = this.renderCells(sourceRowIndex, TR, columnsToRender);
  18532. if (!isWorkingOnClone ||
  18533. // Necessary to refresh oversized row heights after editing cell in overlays
  18534. this.wot.isOverlayName(_base2.default.CLONE_BOTTOM)) {
  18535. // Reset the oversized row cache for this row
  18536. this.resetOversizedRow(sourceRowIndex);
  18537. }
  18538. if (TR.firstChild) {
  18539. // if I have 2 fixed columns with one-line content and the 3rd column has a multiline content, this is
  18540. // the way to make sure that the overlay will has same row height
  18541. var height = this.wot.wtTable.getRowHeight(sourceRowIndex);
  18542. if (height) {
  18543. // Decrease height. 1 pixel will be "replaced" by 1px border top
  18544. height--;
  18545. TR.firstChild.style.height = height + 'px';
  18546. } else {
  18547. TR.firstChild.style.height = '';
  18548. }
  18549. }
  18550. visibleRowIndex++;
  18551. sourceRowIndex = this.rowFilter.renderedToSource(visibleRowIndex);
  18552. }
  18553. }
  18554. /**
  18555. * Reset the oversized row cache for the provided index
  18556. *
  18557. * @param {Number} sourceRow Row index
  18558. */
  18559. }, {
  18560. key: 'resetOversizedRow',
  18561. value: function resetOversizedRow(sourceRow) {
  18562. if (this.wot.getSetting('externalRowCalculator')) {
  18563. return;
  18564. }
  18565. if (this.wot.wtViewport.oversizedRows && this.wot.wtViewport.oversizedRows[sourceRow]) {
  18566. this.wot.wtViewport.oversizedRows[sourceRow] = void 0;
  18567. }
  18568. }
  18569. /**
  18570. * Check if any of the rendered rows is higher than expected, and if so, cache them
  18571. */
  18572. }, {
  18573. key: 'markOversizedRows',
  18574. value: function markOversizedRows() {
  18575. if (this.wot.getSetting('externalRowCalculator')) {
  18576. return;
  18577. }
  18578. var rowCount = this.instance.wtTable.TBODY.childNodes.length;
  18579. var expectedTableHeight = rowCount * this.instance.wtSettings.settings.defaultRowHeight;
  18580. var actualTableHeight = (0, _element.innerHeight)(this.instance.wtTable.TBODY) - 1;
  18581. var previousRowHeight = void 0;
  18582. var rowInnerHeight = void 0;
  18583. var sourceRowIndex = void 0;
  18584. var currentTr = void 0;
  18585. var rowHeader = void 0;
  18586. var totalRows = this.instance.getSetting('totalRows');
  18587. if (expectedTableHeight === actualTableHeight && !this.instance.getSetting('fixedRowsBottom')) {
  18588. // If the actual table height equals rowCount * default single row height, no row is oversized -> no need to iterate over them
  18589. return;
  18590. }
  18591. while (rowCount) {
  18592. rowCount--;
  18593. sourceRowIndex = this.instance.wtTable.rowFilter.renderedToSource(rowCount);
  18594. previousRowHeight = this.instance.wtTable.getRowHeight(sourceRowIndex);
  18595. currentTr = this.instance.wtTable.getTrForRow(sourceRowIndex);
  18596. rowHeader = currentTr.querySelector('th');
  18597. if (rowHeader) {
  18598. rowInnerHeight = (0, _element.innerHeight)(rowHeader);
  18599. } else {
  18600. rowInnerHeight = (0, _element.innerHeight)(currentTr) - 1;
  18601. }
  18602. if (!previousRowHeight && this.instance.wtSettings.settings.defaultRowHeight < rowInnerHeight || previousRowHeight < rowInnerHeight) {
  18603. this.instance.wtViewport.oversizedRows[sourceRowIndex] = ++rowInnerHeight;
  18604. }
  18605. }
  18606. }
  18607. /**
  18608. * Check if any of the rendered columns is higher than expected, and if so, cache them.
  18609. */
  18610. }, {
  18611. key: 'markOversizedColumnHeaders',
  18612. value: function markOversizedColumnHeaders() {
  18613. var overlayName = this.wot.getOverlayName();
  18614. if (!this.columnHeaderCount || this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] || this.wtTable.isWorkingOnClone()) {
  18615. return;
  18616. }
  18617. var columnCount = this.wtTable.getRenderedColumnsCount();
  18618. for (var i = 0; i < this.columnHeaderCount; i++) {
  18619. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  18620. this.markIfOversizedColumnHeader(renderedColumnIndex);
  18621. }
  18622. }
  18623. this.wot.wtViewport.hasOversizedColumnHeadersMarked[overlayName] = true;
  18624. }
  18625. /**
  18626. *
  18627. */
  18628. }, {
  18629. key: 'adjustColumnHeaderHeights',
  18630. value: function adjustColumnHeaderHeights() {
  18631. var columnHeaders = this.wot.getSetting('columnHeaders');
  18632. var children = this.wot.wtTable.THEAD.childNodes;
  18633. var oversizedColumnHeaders = this.wot.wtViewport.oversizedColumnHeaders;
  18634. for (var i = 0, len = columnHeaders.length; i < len; i++) {
  18635. if (oversizedColumnHeaders[i]) {
  18636. if (!children[i] || children[i].childNodes.length === 0) {
  18637. return;
  18638. }
  18639. children[i].childNodes[0].style.height = oversizedColumnHeaders[i] + 'px';
  18640. }
  18641. }
  18642. }
  18643. /**
  18644. * Check if column header for the specified column is higher than expected, and if so, cache it
  18645. *
  18646. * @param {Number} col Index of column
  18647. */
  18648. }, {
  18649. key: 'markIfOversizedColumnHeader',
  18650. value: function markIfOversizedColumnHeader(col) {
  18651. var sourceColIndex = this.wot.wtTable.columnFilter.renderedToSource(col);
  18652. var level = this.columnHeaderCount;
  18653. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  18654. var previousColHeaderHeight = void 0;
  18655. var currentHeader = void 0;
  18656. var currentHeaderHeight = void 0;
  18657. var columnHeaderHeightSetting = this.wot.getSetting('columnHeaderHeight') || [];
  18658. while (level) {
  18659. level--;
  18660. previousColHeaderHeight = this.wot.wtTable.getColumnHeaderHeight(level);
  18661. currentHeader = this.wot.wtTable.getColumnHeader(sourceColIndex, level);
  18662. if (!currentHeader) {
  18663. /* eslint-disable no-continue */
  18664. continue;
  18665. }
  18666. currentHeaderHeight = (0, _element.innerHeight)(currentHeader);
  18667. if (!previousColHeaderHeight && defaultRowHeight < currentHeaderHeight || previousColHeaderHeight < currentHeaderHeight) {
  18668. this.wot.wtViewport.oversizedColumnHeaders[level] = currentHeaderHeight;
  18669. }
  18670. if (Array.isArray(columnHeaderHeightSetting)) {
  18671. if (columnHeaderHeightSetting[level] != null) {
  18672. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level];
  18673. }
  18674. } else if (!isNaN(columnHeaderHeightSetting)) {
  18675. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting;
  18676. }
  18677. if (this.wot.wtViewport.oversizedColumnHeaders[level] < (columnHeaderHeightSetting[level] || columnHeaderHeightSetting)) {
  18678. this.wot.wtViewport.oversizedColumnHeaders[level] = columnHeaderHeightSetting[level] || columnHeaderHeightSetting;
  18679. }
  18680. }
  18681. }
  18682. /**
  18683. * @param {Number} sourceRowIndex
  18684. * @param {HTMLTableRowElement} TR
  18685. * @param {Number} columnsToRender
  18686. * @returns {HTMLTableCellElement}
  18687. */
  18688. }, {
  18689. key: 'renderCells',
  18690. value: function renderCells(sourceRowIndex, TR, columnsToRender) {
  18691. var TD = void 0;
  18692. var sourceColIndex = void 0;
  18693. for (var visibleColIndex = 0; visibleColIndex < columnsToRender; visibleColIndex++) {
  18694. sourceColIndex = this.columnFilter.renderedToSource(visibleColIndex);
  18695. if (visibleColIndex === 0) {
  18696. TD = TR.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(sourceColIndex)];
  18697. } else {
  18698. TD = TD.nextSibling; // http://jsperf.com/nextsibling-vs-indexed-childnodes
  18699. }
  18700. // If the number of headers has been reduced, we need to replace excess TH with TD
  18701. if (TD.nodeName == 'TH') {
  18702. TD = replaceThWithTd(TD, TR);
  18703. }
  18704. if (!(0, _element.hasClass)(TD, 'hide')) {
  18705. TD.className = '';
  18706. }
  18707. TD.removeAttribute('style');
  18708. this.wot.wtSettings.settings.cellRenderer(sourceRowIndex, sourceColIndex, TD);
  18709. }
  18710. return TD;
  18711. }
  18712. /**
  18713. * @param {Number} columnsToRender Number of columns to render.
  18714. */
  18715. }, {
  18716. key: 'adjustColumnWidths',
  18717. value: function adjustColumnWidths(columnsToRender) {
  18718. var scrollbarCompensation = 0;
  18719. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  18720. var mainHolder = sourceInstance.wtTable.holder;
  18721. var defaultColumnWidth = this.wot.getSetting('defaultColumnWidth');
  18722. var rowHeaderWidthSetting = this.wot.getSetting('rowHeaderWidth');
  18723. if (mainHolder.offsetHeight < mainHolder.scrollHeight) {
  18724. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  18725. }
  18726. this.wot.wtViewport.columnsRenderCalculator.refreshStretching(this.wot.wtViewport.getViewportWidth() - scrollbarCompensation);
  18727. rowHeaderWidthSetting = this.instance.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
  18728. if (rowHeaderWidthSetting != null) {
  18729. for (var i = 0; i < this.rowHeaderCount; i++) {
  18730. var width = Array.isArray(rowHeaderWidthSetting) ? rowHeaderWidthSetting[i] : rowHeaderWidthSetting;
  18731. width = width == null ? defaultColumnWidth : width;
  18732. this.COLGROUP.childNodes[i].style.width = width + 'px';
  18733. }
  18734. }
  18735. for (var renderedColIndex = 0; renderedColIndex < columnsToRender; renderedColIndex++) {
  18736. var _width2 = this.wtTable.getStretchedColumnWidth(this.columnFilter.renderedToSource(renderedColIndex));
  18737. this.COLGROUP.childNodes[renderedColIndex + this.rowHeaderCount].style.width = _width2 + 'px';
  18738. }
  18739. }
  18740. /**
  18741. * @param {HTMLTableCellElement} TR
  18742. */
  18743. }, {
  18744. key: 'appendToTbody',
  18745. value: function appendToTbody(TR) {
  18746. this.TBODY.appendChild(TR);
  18747. this.wtTable.tbodyChildrenLength++;
  18748. }
  18749. /**
  18750. * @param {Number} rowIndex
  18751. * @param {HTMLTableRowElement} currentTr
  18752. * @returns {HTMLTableCellElement}
  18753. */
  18754. }, {
  18755. key: 'getOrCreateTrForRow',
  18756. value: function getOrCreateTrForRow(rowIndex, currentTr) {
  18757. var TR = void 0;
  18758. if (rowIndex >= this.wtTable.tbodyChildrenLength) {
  18759. TR = this.createRow();
  18760. this.appendToTbody(TR);
  18761. } else if (rowIndex === 0) {
  18762. TR = this.TBODY.firstChild;
  18763. } else {
  18764. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  18765. TR = currentTr.nextSibling;
  18766. }
  18767. if (TR.className) {
  18768. TR.removeAttribute('class');
  18769. }
  18770. return TR;
  18771. }
  18772. /**
  18773. * @returns {HTMLTableCellElement}
  18774. */
  18775. }, {
  18776. key: 'createRow',
  18777. value: function createRow() {
  18778. var TR = document.createElement('TR');
  18779. for (var visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  18780. TR.appendChild(document.createElement('TH'));
  18781. }
  18782. return TR;
  18783. }
  18784. /**
  18785. * @param {Number} row
  18786. * @param {Number} col
  18787. * @param {HTMLTableCellElement} TH
  18788. */
  18789. }, {
  18790. key: 'renderRowHeader',
  18791. value: function renderRowHeader(row, col, TH) {
  18792. TH.className = '';
  18793. TH.removeAttribute('style');
  18794. this.rowHeaders[col](row, TH, col);
  18795. }
  18796. /**
  18797. * @param {Number} row
  18798. * @param {HTMLTableCellElement} TR
  18799. */
  18800. }, {
  18801. key: 'renderRowHeaders',
  18802. value: function renderRowHeaders(row, TR) {
  18803. for (var TH = TR.firstChild, visibleColIndex = 0; visibleColIndex < this.rowHeaderCount; visibleColIndex++) {
  18804. // If the number of row headers increased we need to create TH or replace an existing TD node with TH
  18805. if (!TH) {
  18806. TH = document.createElement('TH');
  18807. TR.appendChild(TH);
  18808. } else if (TH.nodeName == 'TD') {
  18809. TH = replaceTdWithTh(TH, TR);
  18810. }
  18811. this.renderRowHeader(row, visibleColIndex, TH);
  18812. // http://jsperf.com/nextsibling-vs-indexed-childnodes
  18813. TH = TH.nextSibling;
  18814. }
  18815. }
  18816. /**
  18817. * Adjust the number of COL and TH elements to match the number of columns and headers that need to be rendered
  18818. */
  18819. }, {
  18820. key: 'adjustAvailableNodes',
  18821. value: function adjustAvailableNodes() {
  18822. this.adjustColGroups();
  18823. this.adjustThead();
  18824. }
  18825. /**
  18826. * Renders the column headers
  18827. */
  18828. }, {
  18829. key: 'renderColumnHeaders',
  18830. value: function renderColumnHeaders() {
  18831. if (!this.columnHeaderCount) {
  18832. return;
  18833. }
  18834. var columnCount = this.wtTable.getRenderedColumnsCount();
  18835. for (var i = 0; i < this.columnHeaderCount; i++) {
  18836. var TR = this.getTrForColumnHeaders(i);
  18837. for (var renderedColumnIndex = -1 * this.rowHeaderCount; renderedColumnIndex < columnCount; renderedColumnIndex++) {
  18838. var sourceCol = this.columnFilter.renderedToSource(renderedColumnIndex);
  18839. this.renderColumnHeader(i, sourceCol, TR.childNodes[renderedColumnIndex + this.rowHeaderCount]);
  18840. }
  18841. }
  18842. }
  18843. /**
  18844. * Adjusts the number of COL elements to match the number of columns that need to be rendered
  18845. */
  18846. }, {
  18847. key: 'adjustColGroups',
  18848. value: function adjustColGroups() {
  18849. var columnCount = this.wtTable.getRenderedColumnsCount();
  18850. while (this.wtTable.colgroupChildrenLength < columnCount + this.rowHeaderCount) {
  18851. this.COLGROUP.appendChild(document.createElement('COL'));
  18852. this.wtTable.colgroupChildrenLength++;
  18853. }
  18854. while (this.wtTable.colgroupChildrenLength > columnCount + this.rowHeaderCount) {
  18855. this.COLGROUP.removeChild(this.COLGROUP.lastChild);
  18856. this.wtTable.colgroupChildrenLength--;
  18857. }
  18858. if (this.rowHeaderCount) {
  18859. (0, _element.addClass)(this.COLGROUP.childNodes[0], 'rowHeader');
  18860. }
  18861. }
  18862. /**
  18863. * Adjusts the number of TH elements in THEAD to match the number of headers and columns that need to be rendered
  18864. */
  18865. }, {
  18866. key: 'adjustThead',
  18867. value: function adjustThead() {
  18868. var columnCount = this.wtTable.getRenderedColumnsCount();
  18869. var TR = this.THEAD.firstChild;
  18870. if (this.columnHeaders.length) {
  18871. for (var i = 0, len = this.columnHeaders.length; i < len; i++) {
  18872. TR = this.THEAD.childNodes[i];
  18873. if (!TR) {
  18874. TR = document.createElement('TR');
  18875. this.THEAD.appendChild(TR);
  18876. }
  18877. this.theadChildrenLength = TR.childNodes.length;
  18878. while (this.theadChildrenLength < columnCount + this.rowHeaderCount) {
  18879. TR.appendChild(document.createElement('TH'));
  18880. this.theadChildrenLength++;
  18881. }
  18882. while (this.theadChildrenLength > columnCount + this.rowHeaderCount) {
  18883. TR.removeChild(TR.lastChild);
  18884. this.theadChildrenLength--;
  18885. }
  18886. }
  18887. var theadChildrenLength = this.THEAD.childNodes.length;
  18888. if (theadChildrenLength > this.columnHeaders.length) {
  18889. for (var _i2 = this.columnHeaders.length; _i2 < theadChildrenLength; _i2++) {
  18890. this.THEAD.removeChild(this.THEAD.lastChild);
  18891. }
  18892. }
  18893. } else if (TR) {
  18894. (0, _element.empty)(TR);
  18895. }
  18896. }
  18897. /**
  18898. * @param {Number} index
  18899. * @returns {HTMLTableCellElement}
  18900. */
  18901. }, {
  18902. key: 'getTrForColumnHeaders',
  18903. value: function getTrForColumnHeaders(index) {
  18904. return this.THEAD.childNodes[index];
  18905. }
  18906. /**
  18907. * @param {Number} row
  18908. * @param {Number} col
  18909. * @param {HTMLTableCellElement} TH
  18910. * @returns {*}
  18911. */
  18912. }, {
  18913. key: 'renderColumnHeader',
  18914. value: function renderColumnHeader(row, col, TH) {
  18915. TH.className = '';
  18916. TH.removeAttribute('style');
  18917. return this.columnHeaders[row](col, TH, row);
  18918. }
  18919. /**
  18920. * Add and/or remove the TDs to match the desired number
  18921. *
  18922. * @param {HTMLTableCellElement} TR Table row in question
  18923. * @param {Number} desiredCount The desired number of TDs in the TR
  18924. */
  18925. }, {
  18926. key: 'adjustColumns',
  18927. value: function adjustColumns(TR, desiredCount) {
  18928. var count = TR.childNodes.length;
  18929. while (count < desiredCount) {
  18930. var TD = document.createElement('TD');
  18931. TR.appendChild(TD);
  18932. count++;
  18933. }
  18934. while (count > desiredCount) {
  18935. TR.removeChild(TR.lastChild);
  18936. count--;
  18937. }
  18938. }
  18939. /**
  18940. * @param {Number} columnsToRender
  18941. */
  18942. }, {
  18943. key: 'removeRedundantColumns',
  18944. value: function removeRedundantColumns(columnsToRender) {
  18945. while (this.wtTable.tbodyChildrenLength > columnsToRender) {
  18946. this.TBODY.removeChild(this.TBODY.lastChild);
  18947. this.wtTable.tbodyChildrenLength--;
  18948. }
  18949. }
  18950. }]);
  18951. return TableRenderer;
  18952. }();
  18953. function replaceTdWithTh(TD, TR) {
  18954. var TH = document.createElement('TH');
  18955. TR.insertBefore(TH, TD);
  18956. TR.removeChild(TD);
  18957. return TH;
  18958. }
  18959. function replaceThWithTd(TH, TR) {
  18960. var TD = document.createElement('TD');
  18961. TR.insertBefore(TD, TH);
  18962. TR.removeChild(TH);
  18963. return TD;
  18964. }
  18965. exports.default = TableRenderer;
  18966. /***/ }),
  18967. /* 147 */
  18968. /***/ (function(module, exports, __webpack_require__) {
  18969. "use strict";
  18970. exports.__esModule = true;
  18971. 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; }; }();
  18972. var _element = __webpack_require__(0);
  18973. var _object = __webpack_require__(1);
  18974. var _eventManager = __webpack_require__(4);
  18975. var _eventManager2 = _interopRequireDefault(_eventManager);
  18976. var _viewportColumns = __webpack_require__(136);
  18977. var _viewportColumns2 = _interopRequireDefault(_viewportColumns);
  18978. var _viewportRows = __webpack_require__(137);
  18979. var _viewportRows2 = _interopRequireDefault(_viewportRows);
  18980. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  18981. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18982. /**
  18983. * @class Viewport
  18984. */
  18985. var Viewport = function () {
  18986. /**
  18987. * @param wotInstance
  18988. */
  18989. function Viewport(wotInstance) {
  18990. var _this = this;
  18991. _classCallCheck(this, Viewport);
  18992. this.wot = wotInstance;
  18993. // legacy support
  18994. this.instance = this.wot;
  18995. this.oversizedRows = [];
  18996. this.oversizedColumnHeaders = [];
  18997. this.hasOversizedColumnHeadersMarked = {};
  18998. this.clientHeight = 0;
  18999. this.containerWidth = NaN;
  19000. this.rowHeaderWidth = NaN;
  19001. this.rowsVisibleCalculator = null;
  19002. this.columnsVisibleCalculator = null;
  19003. this.eventManager = new _eventManager2.default(this.wot);
  19004. this.eventManager.addEventListener(window, 'resize', function () {
  19005. _this.clientHeight = _this.getWorkspaceHeight();
  19006. });
  19007. }
  19008. /**
  19009. * @returns {number}
  19010. */
  19011. _createClass(Viewport, [{
  19012. key: 'getWorkspaceHeight',
  19013. value: function getWorkspaceHeight() {
  19014. var trimmingContainer = this.instance.wtOverlays.topOverlay.trimmingContainer;
  19015. var elemHeight = void 0;
  19016. var height = 0;
  19017. if (trimmingContainer === window) {
  19018. height = document.documentElement.clientHeight;
  19019. } else {
  19020. elemHeight = (0, _element.outerHeight)(trimmingContainer);
  19021. // returns height without DIV scrollbar
  19022. height = elemHeight > 0 && trimmingContainer.clientHeight > 0 ? trimmingContainer.clientHeight : Infinity;
  19023. }
  19024. return height;
  19025. }
  19026. }, {
  19027. key: 'getWorkspaceWidth',
  19028. value: function getWorkspaceWidth() {
  19029. var width = void 0;
  19030. var totalColumns = this.wot.getSetting('totalColumns');
  19031. var trimmingContainer = this.instance.wtOverlays.leftOverlay.trimmingContainer;
  19032. var overflow = void 0;
  19033. var stretchSetting = this.wot.getSetting('stretchH');
  19034. var docOffsetWidth = document.documentElement.offsetWidth;
  19035. var preventOverflow = this.wot.getSetting('preventOverflow');
  19036. if (preventOverflow) {
  19037. return (0, _element.outerWidth)(this.instance.wtTable.wtRootElement);
  19038. }
  19039. if (this.wot.getSetting('freezeOverlays')) {
  19040. width = Math.min(docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  19041. } else {
  19042. width = Math.min(this.getContainerFillWidth(), docOffsetWidth - this.getWorkspaceOffset().left, docOffsetWidth);
  19043. }
  19044. if (trimmingContainer === window && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
  19045. // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window
  19046. // otherwise continue below, which will allow stretching
  19047. // this is used in `scroll_window.html`
  19048. // TODO test me
  19049. return document.documentElement.clientWidth;
  19050. }
  19051. if (trimmingContainer !== window) {
  19052. overflow = (0, _element.getStyle)(this.instance.wtOverlays.leftOverlay.trimmingContainer, 'overflow');
  19053. if (overflow == 'scroll' || overflow == 'hidden' || overflow == 'auto') {
  19054. // this is used in `scroll.html`
  19055. // TODO test me
  19056. return Math.max(width, trimmingContainer.clientWidth);
  19057. }
  19058. }
  19059. if (stretchSetting === 'none' || !stretchSetting) {
  19060. // if no stretching is used, return the maximum used workspace width
  19061. return Math.max(width, (0, _element.outerWidth)(this.instance.wtTable.TABLE));
  19062. }
  19063. // if stretching is used, return the actual container width, so the columns can fit inside it
  19064. return width;
  19065. }
  19066. /**
  19067. * Checks if viewport has vertical scroll
  19068. *
  19069. * @returns {Boolean}
  19070. */
  19071. }, {
  19072. key: 'hasVerticalScroll',
  19073. value: function hasVerticalScroll() {
  19074. return this.getWorkspaceActualHeight() > this.getWorkspaceHeight();
  19075. }
  19076. /**
  19077. * Checks if viewport has horizontal scroll
  19078. *
  19079. * @returns {Boolean}
  19080. */
  19081. }, {
  19082. key: 'hasHorizontalScroll',
  19083. value: function hasHorizontalScroll() {
  19084. return this.getWorkspaceActualWidth() > this.getWorkspaceWidth();
  19085. }
  19086. /**
  19087. * @param from
  19088. * @param length
  19089. * @returns {Number}
  19090. */
  19091. }, {
  19092. key: 'sumColumnWidths',
  19093. value: function sumColumnWidths(from, length) {
  19094. var sum = 0;
  19095. while (from < length) {
  19096. sum += this.wot.wtTable.getColumnWidth(from);
  19097. from++;
  19098. }
  19099. return sum;
  19100. }
  19101. /**
  19102. * @returns {Number}
  19103. */
  19104. }, {
  19105. key: 'getContainerFillWidth',
  19106. value: function getContainerFillWidth() {
  19107. if (this.containerWidth) {
  19108. return this.containerWidth;
  19109. }
  19110. var mainContainer = this.instance.wtTable.holder;
  19111. var fillWidth = void 0;
  19112. var dummyElement = void 0;
  19113. dummyElement = document.createElement('div');
  19114. dummyElement.style.width = '100%';
  19115. dummyElement.style.height = '1px';
  19116. mainContainer.appendChild(dummyElement);
  19117. fillWidth = dummyElement.offsetWidth;
  19118. this.containerWidth = fillWidth;
  19119. mainContainer.removeChild(dummyElement);
  19120. return fillWidth;
  19121. }
  19122. /**
  19123. * @returns {Number}
  19124. */
  19125. }, {
  19126. key: 'getWorkspaceOffset',
  19127. value: function getWorkspaceOffset() {
  19128. return (0, _element.offset)(this.wot.wtTable.TABLE);
  19129. }
  19130. /**
  19131. * @returns {Number}
  19132. */
  19133. }, {
  19134. key: 'getWorkspaceActualHeight',
  19135. value: function getWorkspaceActualHeight() {
  19136. return (0, _element.outerHeight)(this.wot.wtTable.TABLE);
  19137. }
  19138. /**
  19139. * @returns {Number}
  19140. */
  19141. }, {
  19142. key: 'getWorkspaceActualWidth',
  19143. value: function getWorkspaceActualWidth() {
  19144. 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;
  19145. }
  19146. /**
  19147. * @returns {Number}
  19148. */
  19149. }, {
  19150. key: 'getColumnHeaderHeight',
  19151. value: function getColumnHeaderHeight() {
  19152. if (isNaN(this.columnHeaderHeight)) {
  19153. this.columnHeaderHeight = (0, _element.outerHeight)(this.wot.wtTable.THEAD);
  19154. }
  19155. return this.columnHeaderHeight;
  19156. }
  19157. /**
  19158. * @returns {Number}
  19159. */
  19160. }, {
  19161. key: 'getViewportHeight',
  19162. value: function getViewportHeight() {
  19163. var containerHeight = this.getWorkspaceHeight();
  19164. var columnHeaderHeight = void 0;
  19165. if (containerHeight === Infinity) {
  19166. return containerHeight;
  19167. }
  19168. columnHeaderHeight = this.getColumnHeaderHeight();
  19169. if (columnHeaderHeight > 0) {
  19170. containerHeight -= columnHeaderHeight;
  19171. }
  19172. return containerHeight;
  19173. }
  19174. /**
  19175. * @returns {Number}
  19176. */
  19177. }, {
  19178. key: 'getRowHeaderWidth',
  19179. value: function getRowHeaderWidth() {
  19180. var rowHeadersHeightSetting = this.instance.getSetting('rowHeaderWidth');
  19181. var rowHeaders = this.instance.getSetting('rowHeaders');
  19182. if (rowHeadersHeightSetting) {
  19183. this.rowHeaderWidth = 0;
  19184. for (var i = 0, len = rowHeaders.length; i < len; i++) {
  19185. this.rowHeaderWidth += rowHeadersHeightSetting[i] || rowHeadersHeightSetting;
  19186. }
  19187. }
  19188. if (this.wot.cloneSource) {
  19189. return this.wot.cloneSource.wtViewport.getRowHeaderWidth();
  19190. }
  19191. if (isNaN(this.rowHeaderWidth)) {
  19192. if (rowHeaders.length) {
  19193. var TH = this.instance.wtTable.TABLE.querySelector('TH');
  19194. this.rowHeaderWidth = 0;
  19195. for (var _i = 0, _len = rowHeaders.length; _i < _len; _i++) {
  19196. if (TH) {
  19197. this.rowHeaderWidth += (0, _element.outerWidth)(TH);
  19198. TH = TH.nextSibling;
  19199. } else {
  19200. // yes this is a cheat but it worked like that before, just taking assumption from CSS instead of measuring.
  19201. // TODO: proper fix
  19202. this.rowHeaderWidth += 50;
  19203. }
  19204. }
  19205. } else {
  19206. this.rowHeaderWidth = 0;
  19207. }
  19208. }
  19209. this.rowHeaderWidth = this.instance.getSetting('onModifyRowHeaderWidth', this.rowHeaderWidth) || this.rowHeaderWidth;
  19210. return this.rowHeaderWidth;
  19211. }
  19212. /**
  19213. * @returns {Number}
  19214. */
  19215. }, {
  19216. key: 'getViewportWidth',
  19217. value: function getViewportWidth() {
  19218. var containerWidth = this.getWorkspaceWidth();
  19219. var rowHeaderWidth = void 0;
  19220. if (containerWidth === Infinity) {
  19221. return containerWidth;
  19222. }
  19223. rowHeaderWidth = this.getRowHeaderWidth();
  19224. if (rowHeaderWidth > 0) {
  19225. return containerWidth - rowHeaderWidth;
  19226. }
  19227. return containerWidth;
  19228. }
  19229. /**
  19230. * Creates:
  19231. * - rowsRenderCalculator (before draw, to qualify rows for rendering)
  19232. * - rowsVisibleCalculator (after draw, to measure which rows are actually visible)
  19233. *
  19234. * @returns {ViewportRowsCalculator}
  19235. */
  19236. }, {
  19237. key: 'createRowsCalculator',
  19238. value: function createRowsCalculator() {
  19239. var _this2 = this;
  19240. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  19241. var height = void 0;
  19242. var pos = void 0;
  19243. var fixedRowsTop = void 0;
  19244. var scrollbarHeight = void 0;
  19245. var fixedRowsBottom = void 0;
  19246. var fixedRowsHeight = void 0;
  19247. var totalRows = void 0;
  19248. this.rowHeaderWidth = NaN;
  19249. if (this.wot.wtSettings.settings.renderAllRows) {
  19250. height = Infinity;
  19251. } else {
  19252. height = this.getViewportHeight();
  19253. }
  19254. pos = this.wot.wtOverlays.topOverlay.getScrollPosition() - this.wot.wtOverlays.topOverlay.getTableParentOffset();
  19255. if (pos < 0) {
  19256. pos = 0;
  19257. }
  19258. fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  19259. fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  19260. totalRows = this.wot.getSetting('totalRows');
  19261. if (fixedRowsTop) {
  19262. fixedRowsHeight = this.wot.wtOverlays.topOverlay.sumCellSizes(0, fixedRowsTop);
  19263. pos += fixedRowsHeight;
  19264. height -= fixedRowsHeight;
  19265. }
  19266. if (fixedRowsBottom && this.wot.wtOverlays.bottomOverlay.clone) {
  19267. fixedRowsHeight = this.wot.wtOverlays.bottomOverlay.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  19268. height -= fixedRowsHeight;
  19269. }
  19270. if (this.wot.wtTable.holder.clientHeight === this.wot.wtTable.holder.offsetHeight) {
  19271. scrollbarHeight = 0;
  19272. } else {
  19273. scrollbarHeight = (0, _element.getScrollbarWidth)();
  19274. }
  19275. return new _viewportRows2.default(height, pos, this.wot.getSetting('totalRows'), function (sourceRow) {
  19276. return _this2.wot.wtTable.getRowHeight(sourceRow);
  19277. }, visible ? null : this.wot.wtSettings.settings.viewportRowCalculatorOverride, visible, scrollbarHeight);
  19278. }
  19279. /**
  19280. * Creates:
  19281. * - columnsRenderCalculator (before draw, to qualify columns for rendering)
  19282. * - columnsVisibleCalculator (after draw, to measure which columns are actually visible)
  19283. *
  19284. * @returns {ViewportRowsCalculator}
  19285. */
  19286. }, {
  19287. key: 'createColumnsCalculator',
  19288. value: function createColumnsCalculator() {
  19289. var _this3 = this;
  19290. var visible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  19291. var width = this.getViewportWidth();
  19292. var pos = void 0;
  19293. var fixedColumnsLeft = void 0;
  19294. this.columnHeaderHeight = NaN;
  19295. pos = this.wot.wtOverlays.leftOverlay.getScrollPosition() - this.wot.wtOverlays.leftOverlay.getTableParentOffset();
  19296. if (pos < 0) {
  19297. pos = 0;
  19298. }
  19299. fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  19300. if (fixedColumnsLeft) {
  19301. var fixedColumnsWidth = this.wot.wtOverlays.leftOverlay.sumCellSizes(0, fixedColumnsLeft);
  19302. pos += fixedColumnsWidth;
  19303. width -= fixedColumnsWidth;
  19304. }
  19305. if (this.wot.wtTable.holder.clientWidth !== this.wot.wtTable.holder.offsetWidth) {
  19306. width -= (0, _element.getScrollbarWidth)();
  19307. }
  19308. return new _viewportColumns2.default(width, pos, this.wot.getSetting('totalColumns'), function (sourceCol) {
  19309. return _this3.wot.wtTable.getColumnWidth(sourceCol);
  19310. }, visible ? null : this.wot.wtSettings.settings.viewportColumnCalculatorOverride, visible, this.wot.getSetting('stretchH'), function (stretchedWidth, column) {
  19311. return _this3.wot.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column);
  19312. });
  19313. }
  19314. /**
  19315. * Creates rowsRenderCalculator and columnsRenderCalculator (before draw, to determine what rows and
  19316. * cols should be rendered)
  19317. *
  19318. * @param fastDraw {Boolean} If `true`, will try to avoid full redraw and only update the border positions.
  19319. * If `false` or `undefined`, will perform a full redraw
  19320. * @returns fastDraw {Boolean} The fastDraw value, possibly modified
  19321. */
  19322. }, {
  19323. key: 'createRenderCalculators',
  19324. value: function createRenderCalculators() {
  19325. var fastDraw = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  19326. if (fastDraw) {
  19327. var proposedRowsVisibleCalculator = this.createRowsCalculator(true);
  19328. var proposedColumnsVisibleCalculator = this.createColumnsCalculator(true);
  19329. if (!(this.areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) && this.areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator))) {
  19330. fastDraw = false;
  19331. }
  19332. }
  19333. if (!fastDraw) {
  19334. this.rowsRenderCalculator = this.createRowsCalculator();
  19335. this.columnsRenderCalculator = this.createColumnsCalculator();
  19336. }
  19337. // delete temporarily to make sure that renderers always use rowsRenderCalculator, not rowsVisibleCalculator
  19338. this.rowsVisibleCalculator = null;
  19339. this.columnsVisibleCalculator = null;
  19340. return fastDraw;
  19341. }
  19342. /**
  19343. * Creates rowsVisibleCalculator and columnsVisibleCalculator (after draw, to determine what are
  19344. * the actually visible rows and columns)
  19345. */
  19346. }, {
  19347. key: 'createVisibleCalculators',
  19348. value: function createVisibleCalculators() {
  19349. this.rowsVisibleCalculator = this.createRowsCalculator(true);
  19350. this.columnsVisibleCalculator = this.createColumnsCalculator(true);
  19351. }
  19352. /**
  19353. * Returns information whether proposedRowsVisibleCalculator viewport
  19354. * is contained inside rows rendered in previous draw (cached in rowsRenderCalculator)
  19355. *
  19356. * @param {Object} proposedRowsVisibleCalculator
  19357. * @returns {Boolean} Returns `true` if all proposed visible rows are already rendered (meaning: redraw is not needed).
  19358. * Returns `false` if at least one proposed visible row is not already rendered (meaning: redraw is needed)
  19359. */
  19360. }, {
  19361. key: 'areAllProposedVisibleRowsAlreadyRendered',
  19362. value: function areAllProposedVisibleRowsAlreadyRendered(proposedRowsVisibleCalculator) {
  19363. if (this.rowsVisibleCalculator) {
  19364. if (proposedRowsVisibleCalculator.startRow < this.rowsRenderCalculator.startRow || proposedRowsVisibleCalculator.startRow === this.rowsRenderCalculator.startRow && proposedRowsVisibleCalculator.startRow > 0) {
  19365. return false;
  19366. } else if (proposedRowsVisibleCalculator.endRow > this.rowsRenderCalculator.endRow || proposedRowsVisibleCalculator.endRow === this.rowsRenderCalculator.endRow && proposedRowsVisibleCalculator.endRow < this.wot.getSetting('totalRows') - 1) {
  19367. return false;
  19368. }
  19369. return true;
  19370. }
  19371. return false;
  19372. }
  19373. /**
  19374. * Returns information whether proposedColumnsVisibleCalculator viewport
  19375. * is contained inside column rendered in previous draw (cached in columnsRenderCalculator)
  19376. *
  19377. * @param {Object} proposedColumnsVisibleCalculator
  19378. * @returns {Boolean} Returns `true` if all proposed visible columns are already rendered (meaning: redraw is not needed).
  19379. * Returns `false` if at least one proposed visible column is not already rendered (meaning: redraw is needed)
  19380. */
  19381. }, {
  19382. key: 'areAllProposedVisibleColumnsAlreadyRendered',
  19383. value: function areAllProposedVisibleColumnsAlreadyRendered(proposedColumnsVisibleCalculator) {
  19384. if (this.columnsVisibleCalculator) {
  19385. if (proposedColumnsVisibleCalculator.startColumn < this.columnsRenderCalculator.startColumn || proposedColumnsVisibleCalculator.startColumn === this.columnsRenderCalculator.startColumn && proposedColumnsVisibleCalculator.startColumn > 0) {
  19386. return false;
  19387. } else if (proposedColumnsVisibleCalculator.endColumn > this.columnsRenderCalculator.endColumn || proposedColumnsVisibleCalculator.endColumn === this.columnsRenderCalculator.endColumn && proposedColumnsVisibleCalculator.endColumn < this.wot.getSetting('totalColumns') - 1) {
  19388. return false;
  19389. }
  19390. return true;
  19391. }
  19392. return false;
  19393. }
  19394. /**
  19395. * Resets values in keys of the hasOversizedColumnHeadersMarked object after updateSettings.
  19396. */
  19397. }, {
  19398. key: 'resetHasOversizedColumnHeadersMarked',
  19399. value: function resetHasOversizedColumnHeadersMarked() {
  19400. (0, _object.objectEach)(this.hasOversizedColumnHeadersMarked, function (value, key, object) {
  19401. object[key] = void 0;
  19402. });
  19403. }
  19404. }]);
  19405. return Viewport;
  19406. }();
  19407. exports.default = Viewport;
  19408. /***/ }),
  19409. /* 148 */
  19410. /***/ (function(module, exports, __webpack_require__) {
  19411. "use strict";
  19412. exports.__esModule = true;
  19413. var _unicode = __webpack_require__(16);
  19414. var _mixed = __webpack_require__(20);
  19415. var _string = __webpack_require__(27);
  19416. var _array = __webpack_require__(2);
  19417. var _element = __webpack_require__(0);
  19418. var _handsontableEditor = __webpack_require__(149);
  19419. var _handsontableEditor2 = _interopRequireDefault(_handsontableEditor);
  19420. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19421. var AutocompleteEditor = _handsontableEditor2.default.prototype.extend();
  19422. /**
  19423. * @private
  19424. * @editor AutocompleteEditor
  19425. * @class AutocompleteEditor
  19426. * @dependencies HandsontableEditor
  19427. */
  19428. AutocompleteEditor.prototype.init = function () {
  19429. _handsontableEditor2.default.prototype.init.apply(this, arguments);
  19430. this.query = null;
  19431. this.strippedChoices = [];
  19432. this.rawChoices = [];
  19433. };
  19434. AutocompleteEditor.prototype.getValue = function () {
  19435. var _this2 = this;
  19436. var selectedValue = this.rawChoices.find(function (value) {
  19437. var strippedValue = _this2.stripValueIfNeeded(value);
  19438. return strippedValue === _this2.TEXTAREA.value;
  19439. });
  19440. if ((0, _mixed.isDefined)(selectedValue)) {
  19441. return selectedValue;
  19442. }
  19443. return this.TEXTAREA.value;
  19444. };
  19445. AutocompleteEditor.prototype.createElements = function () {
  19446. _handsontableEditor2.default.prototype.createElements.apply(this, arguments);
  19447. (0, _element.addClass)(this.htContainer, 'autocompleteEditor');
  19448. (0, _element.addClass)(this.htContainer, window.navigator.platform.indexOf('Mac') === -1 ? '' : 'htMacScroll');
  19449. };
  19450. var skipOne = false;
  19451. function onBeforeKeyDown(event) {
  19452. skipOne = false;
  19453. var editor = this.getActiveEditor();
  19454. if ((0, _unicode.isPrintableChar)(event.keyCode) || event.keyCode === _unicode.KEY_CODES.BACKSPACE || event.keyCode === _unicode.KEY_CODES.DELETE || event.keyCode === _unicode.KEY_CODES.INSERT) {
  19455. var timeOffset = 0;
  19456. // on ctl+c / cmd+c don't update suggestion list
  19457. if (event.keyCode === _unicode.KEY_CODES.C && (event.ctrlKey || event.metaKey)) {
  19458. return;
  19459. }
  19460. if (!editor.isOpened()) {
  19461. timeOffset += 10;
  19462. }
  19463. if (editor.htEditor) {
  19464. editor.instance._registerTimeout(setTimeout(function () {
  19465. editor.queryChoices(editor.TEXTAREA.value);
  19466. skipOne = true;
  19467. }, timeOffset));
  19468. }
  19469. }
  19470. }
  19471. AutocompleteEditor.prototype.prepare = function () {
  19472. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  19473. _handsontableEditor2.default.prototype.prepare.apply(this, arguments);
  19474. };
  19475. AutocompleteEditor.prototype.open = function () {
  19476. // Ugly fix for handsontable which grab window object for autocomplete scroll listener instead table element.
  19477. this.TEXTAREA_PARENT.style.overflow = 'auto';
  19478. _handsontableEditor2.default.prototype.open.apply(this, arguments);
  19479. this.TEXTAREA_PARENT.style.overflow = '';
  19480. var choicesListHot = this.htEditor.getInstance();
  19481. var _this = this;
  19482. var trimDropdown = this.cellProperties.trimDropdown === void 0 ? true : this.cellProperties.trimDropdown;
  19483. this.TEXTAREA.style.visibility = 'visible';
  19484. this.focus();
  19485. choicesListHot.updateSettings({
  19486. colWidths: trimDropdown ? [(0, _element.outerWidth)(this.TEXTAREA) - 2] : void 0,
  19487. width: trimDropdown ? (0, _element.outerWidth)(this.TEXTAREA) + (0, _element.getScrollbarWidth)() + 2 : void 0,
  19488. afterRenderer: function afterRenderer(TD, row, col, prop, value, cellProperties) {
  19489. var _this$cellProperties = _this.cellProperties,
  19490. filteringCaseSensitive = _this$cellProperties.filteringCaseSensitive,
  19491. allowHtml = _this$cellProperties.allowHtml;
  19492. var indexOfMatch = void 0;
  19493. var match = void 0;
  19494. value = (0, _mixed.stringify)(value);
  19495. if (value && !allowHtml) {
  19496. indexOfMatch = filteringCaseSensitive === true ? value.indexOf(this.query) : value.toLowerCase().indexOf(_this.query.toLowerCase());
  19497. if (indexOfMatch !== -1) {
  19498. match = value.substr(indexOfMatch, _this.query.length);
  19499. value = value.replace(match, '<strong>' + match + '</strong>');
  19500. }
  19501. }
  19502. TD.innerHTML = value;
  19503. },
  19504. autoColumnSize: true,
  19505. modifyColWidth: function modifyColWidth(width, col) {
  19506. // workaround for <strong> text overlapping the dropdown, not really accurate
  19507. var autoWidths = this.getPlugin('autoColumnSize').widths;
  19508. if (autoWidths[col]) {
  19509. width = autoWidths[col];
  19510. }
  19511. return trimDropdown ? width : width + 15;
  19512. }
  19513. });
  19514. // Add additional space for autocomplete holder
  19515. this.htEditor.view.wt.wtTable.holder.parentNode.style['padding-right'] = (0, _element.getScrollbarWidth)() + 2 + 'px';
  19516. if (skipOne) {
  19517. skipOne = false;
  19518. }
  19519. _this.instance._registerTimeout(setTimeout(function () {
  19520. _this.queryChoices(_this.TEXTAREA.value);
  19521. }, 0));
  19522. };
  19523. AutocompleteEditor.prototype.close = function () {
  19524. _handsontableEditor2.default.prototype.close.apply(this, arguments);
  19525. };
  19526. AutocompleteEditor.prototype.queryChoices = function (query) {
  19527. var _this3 = this;
  19528. this.query = query;
  19529. var source = this.cellProperties.source;
  19530. if (typeof source == 'function') {
  19531. source.call(this.cellProperties, query, function (choices) {
  19532. _this3.rawChoices = choices;
  19533. _this3.updateChoicesList(_this3.stripValuesIfNeeded(choices));
  19534. });
  19535. } else if (Array.isArray(source)) {
  19536. this.rawChoices = source;
  19537. this.updateChoicesList(this.stripValuesIfNeeded(source));
  19538. } else {
  19539. this.updateChoicesList([]);
  19540. }
  19541. };
  19542. AutocompleteEditor.prototype.updateChoicesList = function (choices) {
  19543. var pos = (0, _element.getCaretPosition)(this.TEXTAREA);
  19544. var endPos = (0, _element.getSelectionEndPosition)(this.TEXTAREA);
  19545. var sortByRelevanceSetting = this.cellProperties.sortByRelevance;
  19546. var filterSetting = this.cellProperties.filter;
  19547. var orderByRelevance = null;
  19548. var highlightIndex = null;
  19549. if (sortByRelevanceSetting) {
  19550. orderByRelevance = AutocompleteEditor.sortByRelevance(this.stripValueIfNeeded(this.getValue()), choices, this.cellProperties.filteringCaseSensitive);
  19551. }
  19552. var orderByRelevanceLength = Array.isArray(orderByRelevance) ? orderByRelevance.length : 0;
  19553. if (filterSetting === false) {
  19554. if (orderByRelevanceLength) {
  19555. highlightIndex = orderByRelevance[0];
  19556. }
  19557. } else {
  19558. var sorted = [];
  19559. for (var i = 0, choicesCount = choices.length; i < choicesCount; i++) {
  19560. if (sortByRelevanceSetting && orderByRelevanceLength <= i) {
  19561. break;
  19562. }
  19563. if (orderByRelevanceLength) {
  19564. sorted.push(choices[orderByRelevance[i]]);
  19565. } else {
  19566. sorted.push(choices[i]);
  19567. }
  19568. }
  19569. highlightIndex = 0;
  19570. choices = sorted;
  19571. }
  19572. this.strippedChoices = choices;
  19573. this.htEditor.loadData((0, _array.pivot)([choices]));
  19574. this.updateDropdownHeight();
  19575. this.flipDropdownIfNeeded();
  19576. if (this.cellProperties.strict === true) {
  19577. this.highlightBestMatchingChoice(highlightIndex);
  19578. }
  19579. this.instance.listen();
  19580. this.TEXTAREA.focus();
  19581. (0, _element.setCaretPosition)(this.TEXTAREA, pos, pos === endPos ? void 0 : endPos);
  19582. };
  19583. AutocompleteEditor.prototype.flipDropdownIfNeeded = function () {
  19584. var textareaOffset = (0, _element.offset)(this.TEXTAREA);
  19585. var textareaHeight = (0, _element.outerHeight)(this.TEXTAREA);
  19586. var dropdownHeight = this.getDropdownHeight();
  19587. var trimmingContainer = (0, _element.getTrimmingContainer)(this.instance.view.wt.wtTable.TABLE);
  19588. var trimmingContainerScrollTop = trimmingContainer.scrollTop;
  19589. var headersHeight = (0, _element.outerHeight)(this.instance.view.wt.wtTable.THEAD);
  19590. var containerOffset = {
  19591. row: 0,
  19592. col: 0
  19593. };
  19594. if (trimmingContainer !== window) {
  19595. containerOffset = (0, _element.offset)(trimmingContainer);
  19596. }
  19597. var spaceAbove = textareaOffset.top - containerOffset.top - headersHeight + trimmingContainerScrollTop;
  19598. var spaceBelow = trimmingContainer.scrollHeight - spaceAbove - headersHeight - textareaHeight;
  19599. var flipNeeded = dropdownHeight > spaceBelow && spaceAbove > spaceBelow;
  19600. if (flipNeeded) {
  19601. this.flipDropdown(dropdownHeight);
  19602. } else {
  19603. this.unflipDropdown();
  19604. }
  19605. this.limitDropdownIfNeeded(flipNeeded ? spaceAbove : spaceBelow, dropdownHeight);
  19606. return flipNeeded;
  19607. };
  19608. AutocompleteEditor.prototype.limitDropdownIfNeeded = function (spaceAvailable, dropdownHeight) {
  19609. if (dropdownHeight > spaceAvailable) {
  19610. var tempHeight = 0;
  19611. var i = 0;
  19612. var lastRowHeight = 0;
  19613. var height = null;
  19614. do {
  19615. lastRowHeight = this.htEditor.getRowHeight(i) || this.htEditor.view.wt.wtSettings.settings.defaultRowHeight;
  19616. tempHeight += lastRowHeight;
  19617. i++;
  19618. } while (tempHeight < spaceAvailable);
  19619. height = tempHeight - lastRowHeight;
  19620. if (this.htEditor.flipped) {
  19621. this.htEditor.rootElement.style.top = parseInt(this.htEditor.rootElement.style.top, 10) + dropdownHeight - height + 'px';
  19622. }
  19623. this.setDropdownHeight(tempHeight - lastRowHeight);
  19624. }
  19625. };
  19626. AutocompleteEditor.prototype.flipDropdown = function (dropdownHeight) {
  19627. var dropdownStyle = this.htEditor.rootElement.style;
  19628. dropdownStyle.position = 'absolute';
  19629. dropdownStyle.top = -dropdownHeight + 'px';
  19630. this.htEditor.flipped = true;
  19631. };
  19632. AutocompleteEditor.prototype.unflipDropdown = function () {
  19633. var dropdownStyle = this.htEditor.rootElement.style;
  19634. if (dropdownStyle.position === 'absolute') {
  19635. dropdownStyle.position = '';
  19636. dropdownStyle.top = '';
  19637. }
  19638. this.htEditor.flipped = void 0;
  19639. };
  19640. AutocompleteEditor.prototype.updateDropdownHeight = function () {
  19641. var currentDropdownWidth = this.htEditor.getColWidth(0) + (0, _element.getScrollbarWidth)() + 2;
  19642. var trimDropdown = this.cellProperties.trimDropdown;
  19643. this.htEditor.updateSettings({
  19644. height: this.getDropdownHeight(),
  19645. width: trimDropdown ? void 0 : currentDropdownWidth
  19646. });
  19647. this.htEditor.view.wt.wtTable.alignOverlaysWithTrimmingContainer();
  19648. };
  19649. AutocompleteEditor.prototype.setDropdownHeight = function (height) {
  19650. this.htEditor.updateSettings({
  19651. height: height
  19652. });
  19653. };
  19654. AutocompleteEditor.prototype.finishEditing = function (restoreOriginalValue) {
  19655. if (!restoreOriginalValue) {
  19656. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  19657. }
  19658. _handsontableEditor2.default.prototype.finishEditing.apply(this, arguments);
  19659. };
  19660. AutocompleteEditor.prototype.highlightBestMatchingChoice = function (index) {
  19661. if (typeof index === 'number') {
  19662. this.htEditor.selectCell(index, 0);
  19663. } else {
  19664. this.htEditor.deselectCell();
  19665. }
  19666. };
  19667. /**
  19668. * Filters and sorts by relevance
  19669. * @param value
  19670. * @param choices
  19671. * @param caseSensitive
  19672. * @returns {Array} array of indexes in original choices array
  19673. */
  19674. AutocompleteEditor.sortByRelevance = function (value, choices, caseSensitive) {
  19675. var choicesRelevance = [];
  19676. var currentItem = void 0;
  19677. var valueLength = value.length;
  19678. var valueIndex = void 0;
  19679. var charsLeft = void 0;
  19680. var result = [];
  19681. var i = void 0;
  19682. var choicesCount = choices.length;
  19683. if (valueLength === 0) {
  19684. for (i = 0; i < choicesCount; i++) {
  19685. result.push(i);
  19686. }
  19687. return result;
  19688. }
  19689. for (i = 0; i < choicesCount; i++) {
  19690. currentItem = (0, _string.stripTags)((0, _mixed.stringify)(choices[i]));
  19691. if (caseSensitive) {
  19692. valueIndex = currentItem.indexOf(value);
  19693. } else {
  19694. valueIndex = currentItem.toLowerCase().indexOf(value.toLowerCase());
  19695. }
  19696. if (valueIndex !== -1) {
  19697. charsLeft = currentItem.length - valueIndex - valueLength;
  19698. choicesRelevance.push({
  19699. baseIndex: i,
  19700. index: valueIndex,
  19701. charsLeft: charsLeft,
  19702. value: currentItem
  19703. });
  19704. }
  19705. }
  19706. choicesRelevance.sort(function (a, b) {
  19707. if (b.index === -1) {
  19708. return -1;
  19709. }
  19710. if (a.index === -1) {
  19711. return 1;
  19712. }
  19713. if (a.index < b.index) {
  19714. return -1;
  19715. } else if (b.index < a.index) {
  19716. return 1;
  19717. } else if (a.index === b.index) {
  19718. if (a.charsLeft < b.charsLeft) {
  19719. return -1;
  19720. } else if (a.charsLeft > b.charsLeft) {
  19721. return 1;
  19722. }
  19723. }
  19724. return 0;
  19725. });
  19726. for (i = 0, choicesCount = choicesRelevance.length; i < choicesCount; i++) {
  19727. result.push(choicesRelevance[i].baseIndex);
  19728. }
  19729. return result;
  19730. };
  19731. AutocompleteEditor.prototype.getDropdownHeight = function () {
  19732. var firstRowHeight = this.htEditor.getInstance().getRowHeight(0) || 23;
  19733. var visibleRows = this.cellProperties.visibleRows;
  19734. return this.strippedChoices.length >= visibleRows ? visibleRows * firstRowHeight : this.strippedChoices.length * firstRowHeight + 8;
  19735. };
  19736. AutocompleteEditor.prototype.stripValueIfNeeded = function (value) {
  19737. return this.stripValuesIfNeeded([value])[0];
  19738. };
  19739. AutocompleteEditor.prototype.stripValuesIfNeeded = function (values) {
  19740. var allowHtml = this.cellProperties.allowHtml;
  19741. var stringifiedValues = (0, _array.arrayMap)(values, function (value) {
  19742. return (0, _mixed.stringify)(value);
  19743. });
  19744. var strippedValues = (0, _array.arrayMap)(stringifiedValues, function (value) {
  19745. return allowHtml ? value : (0, _string.stripTags)(value);
  19746. });
  19747. return strippedValues;
  19748. };
  19749. AutocompleteEditor.prototype.allowKeyEventPropagation = function (keyCode) {
  19750. var selected = { row: this.htEditor.getSelectedRange() ? this.htEditor.getSelectedRange().from.row : -1 };
  19751. var allowed = false;
  19752. if (keyCode === _unicode.KEY_CODES.ARROW_DOWN && selected.row > 0 && selected.row < this.htEditor.countRows() - 1) {
  19753. allowed = true;
  19754. }
  19755. if (keyCode === _unicode.KEY_CODES.ARROW_UP && selected.row > -1) {
  19756. allowed = true;
  19757. }
  19758. return allowed;
  19759. };
  19760. AutocompleteEditor.prototype.discardEditor = function (result) {
  19761. _handsontableEditor2.default.prototype.discardEditor.apply(this, arguments);
  19762. this.instance.view.render();
  19763. };
  19764. exports.default = AutocompleteEditor;
  19765. /***/ }),
  19766. /* 149 */
  19767. /***/ (function(module, exports, __webpack_require__) {
  19768. "use strict";
  19769. exports.__esModule = true;
  19770. var _unicode = __webpack_require__(16);
  19771. var _object = __webpack_require__(1);
  19772. var _element = __webpack_require__(0);
  19773. var _event = __webpack_require__(7);
  19774. var _textEditor = __webpack_require__(43);
  19775. var _textEditor2 = _interopRequireDefault(_textEditor);
  19776. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  19777. var HandsontableEditor = _textEditor2.default.prototype.extend();
  19778. /**
  19779. * @private
  19780. * @editor HandsontableEditor
  19781. * @class HandsontableEditor
  19782. * @dependencies TextEditor
  19783. */
  19784. HandsontableEditor.prototype.createElements = function () {
  19785. _textEditor2.default.prototype.createElements.apply(this, arguments);
  19786. var DIV = document.createElement('DIV');
  19787. DIV.className = 'handsontableEditor';
  19788. this.TEXTAREA_PARENT.appendChild(DIV);
  19789. this.htContainer = DIV;
  19790. this.assignHooks();
  19791. };
  19792. HandsontableEditor.prototype.prepare = function (td, row, col, prop, value, cellProperties) {
  19793. _textEditor2.default.prototype.prepare.apply(this, arguments);
  19794. var parent = this;
  19795. var options = {
  19796. startRows: 0,
  19797. startCols: 0,
  19798. minRows: 0,
  19799. minCols: 0,
  19800. className: 'listbox',
  19801. copyPaste: false,
  19802. autoColumnSize: false,
  19803. autoRowSize: false,
  19804. readOnly: true,
  19805. fillHandle: false,
  19806. afterOnCellMouseDown: function afterOnCellMouseDown(_, coords) {
  19807. var value = this.getSourceData(coords.row, coords.col);
  19808. // if the value is undefined then it means we don't want to set the value
  19809. if (value !== void 0) {
  19810. parent.setValue(value);
  19811. }
  19812. parent.instance.destroyEditor();
  19813. }
  19814. };
  19815. if (this.cellProperties.handsontable) {
  19816. (0, _object.extend)(options, cellProperties.handsontable);
  19817. }
  19818. this.htOptions = options;
  19819. };
  19820. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  19821. if ((0, _event.isImmediatePropagationStopped)(event)) {
  19822. return;
  19823. }
  19824. var editor = this.getActiveEditor();
  19825. var innerHOT = editor.htEditor.getInstance();
  19826. var rowToSelect;
  19827. var selectedRow;
  19828. if (event.keyCode == _unicode.KEY_CODES.ARROW_DOWN) {
  19829. if (!innerHOT.getSelected() && !innerHOT.flipped) {
  19830. rowToSelect = 0;
  19831. } else if (innerHOT.getSelected()) {
  19832. if (innerHOT.flipped) {
  19833. rowToSelect = innerHOT.getSelected()[0] + 1;
  19834. } else if (!innerHOT.flipped) {
  19835. selectedRow = innerHOT.getSelected()[0];
  19836. var lastRow = innerHOT.countRows() - 1;
  19837. rowToSelect = Math.min(lastRow, selectedRow + 1);
  19838. }
  19839. }
  19840. } else if (event.keyCode == _unicode.KEY_CODES.ARROW_UP) {
  19841. if (!innerHOT.getSelected() && innerHOT.flipped) {
  19842. rowToSelect = innerHOT.countRows() - 1;
  19843. } else if (innerHOT.getSelected()) {
  19844. if (innerHOT.flipped) {
  19845. selectedRow = innerHOT.getSelected()[0];
  19846. rowToSelect = Math.max(0, selectedRow - 1);
  19847. } else {
  19848. selectedRow = innerHOT.getSelected()[0];
  19849. rowToSelect = selectedRow - 1;
  19850. }
  19851. }
  19852. }
  19853. if (rowToSelect !== void 0) {
  19854. if (rowToSelect < 0 || innerHOT.flipped && rowToSelect > innerHOT.countRows() - 1) {
  19855. innerHOT.deselectCell();
  19856. } else {
  19857. innerHOT.selectCell(rowToSelect, 0);
  19858. }
  19859. if (innerHOT.getData().length) {
  19860. event.preventDefault();
  19861. (0, _event.stopImmediatePropagation)(event);
  19862. editor.instance.listen();
  19863. editor.TEXTAREA.focus();
  19864. }
  19865. }
  19866. };
  19867. HandsontableEditor.prototype.open = function () {
  19868. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  19869. _textEditor2.default.prototype.open.apply(this, arguments);
  19870. if (this.htEditor) {
  19871. this.htEditor.destroy();
  19872. }
  19873. // Construct and initialise a new Handsontable
  19874. this.htEditor = new this.instance.constructor(this.htContainer, this.htOptions);
  19875. this.htEditor.init();
  19876. if (this.cellProperties.strict) {
  19877. this.htEditor.selectCell(0, 0);
  19878. this.TEXTAREA.style.visibility = 'hidden';
  19879. } else {
  19880. this.htEditor.deselectCell();
  19881. this.TEXTAREA.style.visibility = 'visible';
  19882. }
  19883. (0, _element.setCaretPosition)(this.TEXTAREA, 0, this.TEXTAREA.value.length);
  19884. };
  19885. HandsontableEditor.prototype.close = function () {
  19886. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  19887. this.instance.listen();
  19888. _textEditor2.default.prototype.close.apply(this, arguments);
  19889. };
  19890. HandsontableEditor.prototype.focus = function () {
  19891. this.instance.listen();
  19892. _textEditor2.default.prototype.focus.apply(this, arguments);
  19893. };
  19894. HandsontableEditor.prototype.beginEditing = function (initialValue) {
  19895. var onBeginEditing = this.instance.getSettings().onBeginEditing;
  19896. if (onBeginEditing && onBeginEditing() === false) {
  19897. return;
  19898. }
  19899. _textEditor2.default.prototype.beginEditing.apply(this, arguments);
  19900. };
  19901. HandsontableEditor.prototype.finishEditing = function (isCancelled, ctrlDown) {
  19902. if (this.htEditor && this.htEditor.isListening()) {
  19903. // if focus is still in the HOT editor
  19904. this.instance.listen(); // return the focus to the parent HOT instance
  19905. }
  19906. if (this.htEditor && this.htEditor.getSelected()) {
  19907. var value = this.htEditor.getInstance().getValue();
  19908. if (value !== void 0) {
  19909. // if the value is undefined then it means we don't want to set the value
  19910. this.setValue(value);
  19911. }
  19912. }
  19913. return _textEditor2.default.prototype.finishEditing.apply(this, arguments);
  19914. };
  19915. HandsontableEditor.prototype.assignHooks = function () {
  19916. var _this = this;
  19917. this.instance.addHook('afterDestroy', function () {
  19918. if (_this.htEditor) {
  19919. _this.htEditor.destroy();
  19920. }
  19921. });
  19922. };
  19923. exports.default = HandsontableEditor;
  19924. /***/ }),
  19925. /* 150 */
  19926. /***/ (function(module, exports, __webpack_require__) {
  19927. "use strict";
  19928. exports.__esModule = true;
  19929. var _array = __webpack_require__(2);
  19930. var _object = __webpack_require__(1);
  19931. var _number = __webpack_require__(6);
  19932. var MIXIN_NAME = 'arrayMapper';
  19933. /**
  19934. * @type {Object}
  19935. */
  19936. var arrayMapper = {
  19937. _arrayMap: [],
  19938. /**
  19939. * Get value by map index.
  19940. *
  19941. * @param {Number} index Array index.
  19942. * @return {*} Returns value mapped to passed index.
  19943. */
  19944. getValueByIndex: function getValueByIndex(index) {
  19945. var value = void 0;
  19946. // eslint-disable-next-line no-cond-assign, no-return-assign
  19947. return (value = this._arrayMap[index]) === void 0 ? null : value;
  19948. },
  19949. /**
  19950. * Get map index by its value.
  19951. *
  19952. * @param {*} value Value to search.
  19953. * @returns {Number} Returns array index.
  19954. */
  19955. getIndexByValue: function getIndexByValue(value) {
  19956. var index = void 0;
  19957. // eslint-disable-next-line no-cond-assign, no-return-assign
  19958. return (index = this._arrayMap.indexOf(value)) === -1 ? null : index;
  19959. },
  19960. /**
  19961. * Insert new items to array mapper starting at passed index. New entries will be a continuation of last value in the array.
  19962. *
  19963. * @param {Number} index Array index.
  19964. * @param {Number} [amount=1] Defines how many items will be created to an array.
  19965. * @returns {Array} Returns added items.
  19966. */
  19967. insertItems: function insertItems(index) {
  19968. var _this = this;
  19969. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  19970. var newIndex = (0, _array.arrayMax)(this._arrayMap) + 1;
  19971. var addedItems = [];
  19972. (0, _number.rangeEach)(amount - 1, function (count) {
  19973. addedItems.push(_this._arrayMap.splice(index + count, 0, newIndex + count));
  19974. });
  19975. return addedItems;
  19976. },
  19977. /**
  19978. * Remove items from array mapper.
  19979. *
  19980. * @param {Number} index Array index.
  19981. * @param {Number} [amount=1] Defines how many items will be created to an array.
  19982. * @returns {Array} Returns removed items.
  19983. */
  19984. removeItems: function removeItems(index) {
  19985. var _this2 = this;
  19986. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  19987. var removedItems = [];
  19988. if (Array.isArray(index)) {
  19989. var mapCopy = [].concat(this._arrayMap);
  19990. // Sort descending
  19991. index.sort(function (a, b) {
  19992. return b - a;
  19993. });
  19994. removedItems = (0, _array.arrayReduce)(index, function (acc, item) {
  19995. _this2._arrayMap.splice(item, 1);
  19996. return acc.concat(mapCopy.slice(item, item + 1));
  19997. }, []);
  19998. } else {
  19999. removedItems = this._arrayMap.splice(index, amount);
  20000. }
  20001. return removedItems;
  20002. },
  20003. /**
  20004. * Unshift items (remove and shift chunk of array to the left).
  20005. *
  20006. * @param {Number|Array} index Array index or Array of indexes to unshift.
  20007. * @param {Number} [amount=1] Defines how many items will be removed from an array (when index is passed as number).
  20008. */
  20009. unshiftItems: function unshiftItems(index) {
  20010. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  20011. var removedItems = this.removeItems(index, amount);
  20012. function countRowShift(logicalRow) {
  20013. // Todo: compare perf between reduce vs sort->each->brake
  20014. return (0, _array.arrayReduce)(removedItems, function (count, removedLogicalRow) {
  20015. if (logicalRow > removedLogicalRow) {
  20016. count++;
  20017. }
  20018. return count;
  20019. }, 0);
  20020. }
  20021. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (logicalRow, physicalRow) {
  20022. var rowShift = countRowShift(logicalRow);
  20023. if (rowShift) {
  20024. logicalRow -= rowShift;
  20025. }
  20026. return logicalRow;
  20027. });
  20028. },
  20029. /**
  20030. * Shift (right shifting) items starting at passed index.
  20031. *
  20032. * @param {Number} index Array index.
  20033. * @param {Number} [amount=1] Defines how many items will be created to an array.
  20034. */
  20035. shiftItems: function shiftItems(index) {
  20036. var _this3 = this;
  20037. var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
  20038. this._arrayMap = (0, _array.arrayMap)(this._arrayMap, function (row) {
  20039. if (row >= index) {
  20040. row += amount;
  20041. }
  20042. return row;
  20043. });
  20044. (0, _number.rangeEach)(amount - 1, function (count) {
  20045. _this3._arrayMap.splice(index + count, 0, index + count);
  20046. });
  20047. },
  20048. /**
  20049. * Clear all stored index<->value information from an array.
  20050. */
  20051. clearMap: function clearMap() {
  20052. this._arrayMap.length = 0;
  20053. }
  20054. };
  20055. (0, _object.defineGetter)(arrayMapper, 'MIXIN_NAME', MIXIN_NAME, {
  20056. writable: false,
  20057. enumerable: false
  20058. });
  20059. exports.default = arrayMapper;
  20060. /***/ }),
  20061. /* 151 */
  20062. /***/ (function(module, exports, __webpack_require__) {
  20063. "use strict";
  20064. exports.__esModule = true;
  20065. 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; }; }();
  20066. var _number = __webpack_require__(6);
  20067. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20068. var STATE_INITIALIZED = 0;
  20069. var STATE_BUILT = 1;
  20070. var STATE_APPENDED = 2;
  20071. var UNIT = 'px';
  20072. /**
  20073. * @class
  20074. * @private
  20075. */
  20076. var BaseUI = function () {
  20077. function BaseUI(hotInstance) {
  20078. _classCallCheck(this, BaseUI);
  20079. /**
  20080. * Instance of Handsontable.
  20081. *
  20082. * @type {Core}
  20083. */
  20084. this.hot = hotInstance;
  20085. /**
  20086. * DOM element representing the ui element.
  20087. *
  20088. * @type {HTMLElement}
  20089. * @private
  20090. */
  20091. this._element = null;
  20092. /**
  20093. * Flag which determines build state of element.
  20094. *
  20095. * @type {Boolean}
  20096. */
  20097. this.state = STATE_INITIALIZED;
  20098. }
  20099. /**
  20100. * Add created UI elements to table.
  20101. *
  20102. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  20103. */
  20104. _createClass(BaseUI, [{
  20105. key: 'appendTo',
  20106. value: function appendTo(wrapper) {
  20107. wrapper.appendChild(this._element);
  20108. this.state = STATE_APPENDED;
  20109. }
  20110. /**
  20111. * Method for create UI element. Only create, without append to table.
  20112. */
  20113. }, {
  20114. key: 'build',
  20115. value: function build() {
  20116. this._element = document.createElement('div');
  20117. this.state = STATE_BUILT;
  20118. }
  20119. /**
  20120. * Method for remove UI element.
  20121. */
  20122. }, {
  20123. key: 'destroy',
  20124. value: function destroy() {
  20125. if (this.isAppended()) {
  20126. this._element.parentElement.removeChild(this._element);
  20127. }
  20128. this._element = null;
  20129. this.state = STATE_INITIALIZED;
  20130. }
  20131. /**
  20132. * Check if UI element are appended.
  20133. *
  20134. * @returns {Boolean}
  20135. */
  20136. }, {
  20137. key: 'isAppended',
  20138. value: function isAppended() {
  20139. return this.state === STATE_APPENDED;
  20140. }
  20141. /**
  20142. * Check if UI element are built.
  20143. *
  20144. * @returns {Boolean}
  20145. */
  20146. }, {
  20147. key: 'isBuilt',
  20148. value: function isBuilt() {
  20149. return this.state >= STATE_BUILT;
  20150. }
  20151. /**
  20152. * Setter for position.
  20153. *
  20154. * @param {Number} top New top position of the element.
  20155. * @param {Number} left New left position of the element.
  20156. */
  20157. }, {
  20158. key: 'setPosition',
  20159. value: function setPosition(top, left) {
  20160. if ((0, _number.isNumeric)(top)) {
  20161. this._element.style.top = top + UNIT;
  20162. }
  20163. if ((0, _number.isNumeric)(left)) {
  20164. this._element.style.left = left + UNIT;
  20165. }
  20166. }
  20167. /**
  20168. * Getter for the element position.
  20169. *
  20170. * @returns {Object} Object contains left and top position of the element.
  20171. */
  20172. }, {
  20173. key: 'getPosition',
  20174. value: function getPosition() {
  20175. return {
  20176. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  20177. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  20178. };
  20179. }
  20180. /**
  20181. * Setter for the element size.
  20182. *
  20183. * @param {Number} width New width of the element.
  20184. * @param {Number} height New height of the element.
  20185. */
  20186. }, {
  20187. key: 'setSize',
  20188. value: function setSize(width, height) {
  20189. if ((0, _number.isNumeric)(width)) {
  20190. this._element.style.width = width + UNIT;
  20191. }
  20192. if ((0, _number.isNumeric)(height)) {
  20193. this._element.style.height = height + UNIT;
  20194. }
  20195. }
  20196. /**
  20197. * Getter for the element position.
  20198. *
  20199. * @returns {Object} Object contains height and width of the element.
  20200. */
  20201. }, {
  20202. key: 'getSize',
  20203. value: function getSize() {
  20204. return {
  20205. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  20206. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  20207. };
  20208. }
  20209. /**
  20210. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  20211. *
  20212. * @param {Number} top New margin top of the element.
  20213. * @param {Number} left New margin left of the element.
  20214. */
  20215. }, {
  20216. key: 'setOffset',
  20217. value: function setOffset(top, left) {
  20218. if ((0, _number.isNumeric)(top)) {
  20219. this._element.style.marginTop = top + UNIT;
  20220. }
  20221. if ((0, _number.isNumeric)(left)) {
  20222. this._element.style.marginLeft = left + UNIT;
  20223. }
  20224. }
  20225. /**
  20226. * Getter for the element offset.
  20227. *
  20228. * @returns {Object} Object contains top and left offset of the element.
  20229. */
  20230. }, {
  20231. key: 'getOffset',
  20232. value: function getOffset() {
  20233. return {
  20234. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  20235. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  20236. };
  20237. }
  20238. }]);
  20239. return BaseUI;
  20240. }();
  20241. exports.default = BaseUI;
  20242. /***/ }),
  20243. /* 152 */
  20244. /***/ (function(module, exports, __webpack_require__) {
  20245. "use strict";
  20246. exports.__esModule = true;
  20247. 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; }; }();
  20248. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20249. var STATE_INITIALIZED = 0;
  20250. var STATE_BUILT = 1;
  20251. var STATE_APPENDED = 2;
  20252. var UNIT = 'px';
  20253. /**
  20254. * @class
  20255. * @private
  20256. */
  20257. var BaseUI = function () {
  20258. function BaseUI(hotInstance) {
  20259. _classCallCheck(this, BaseUI);
  20260. /**
  20261. * Instance of Handsontable.
  20262. *
  20263. * @type {Core}
  20264. */
  20265. this.hot = hotInstance;
  20266. /**
  20267. * DOM element representing the ui element.
  20268. *
  20269. * @type {HTMLElement}
  20270. * @private
  20271. */
  20272. this._element = null;
  20273. /**
  20274. * Flag which determines build state of element.
  20275. *
  20276. * @type {Boolean}
  20277. */
  20278. this.state = STATE_INITIALIZED;
  20279. }
  20280. /**
  20281. * Add created UI elements to table.
  20282. *
  20283. * @param {HTMLElement} wrapper Element which are parent for our UI element.
  20284. */
  20285. _createClass(BaseUI, [{
  20286. key: 'appendTo',
  20287. value: function appendTo(wrapper) {
  20288. wrapper.appendChild(this._element);
  20289. this.state = STATE_APPENDED;
  20290. }
  20291. /**
  20292. * Method for create UI element. Only create, without append to table.
  20293. */
  20294. }, {
  20295. key: 'build',
  20296. value: function build() {
  20297. this._element = document.createElement('div');
  20298. this.state = STATE_BUILT;
  20299. }
  20300. /**
  20301. * Method for remove UI element.
  20302. */
  20303. }, {
  20304. key: 'destroy',
  20305. value: function destroy() {
  20306. if (this.isAppended()) {
  20307. this._element.parentElement.removeChild(this._element);
  20308. }
  20309. this._element = null;
  20310. this.state = STATE_INITIALIZED;
  20311. }
  20312. /**
  20313. * Check if UI element are appended.
  20314. *
  20315. * @returns {Boolean}
  20316. */
  20317. }, {
  20318. key: 'isAppended',
  20319. value: function isAppended() {
  20320. return this.state === STATE_APPENDED;
  20321. }
  20322. /**
  20323. * Check if UI element are built.
  20324. *
  20325. * @returns {Boolean}
  20326. */
  20327. }, {
  20328. key: 'isBuilt',
  20329. value: function isBuilt() {
  20330. return this.state >= STATE_BUILT;
  20331. }
  20332. /**
  20333. * Setter for position.
  20334. *
  20335. * @param {Number} top New top position of the element.
  20336. * @param {Number} left New left position of the element.
  20337. */
  20338. }, {
  20339. key: 'setPosition',
  20340. value: function setPosition(top, left) {
  20341. if (top) {
  20342. this._element.style.top = top + UNIT;
  20343. }
  20344. if (left) {
  20345. this._element.style.left = left + UNIT;
  20346. }
  20347. }
  20348. /**
  20349. * Getter for the element position.
  20350. *
  20351. * @returns {Object} Object contains left and top position of the element.
  20352. */
  20353. }, {
  20354. key: 'getPosition',
  20355. value: function getPosition() {
  20356. return {
  20357. top: this._element.style.top ? parseInt(this._element.style.top, 10) : 0,
  20358. left: this._element.style.left ? parseInt(this._element.style.left, 10) : 0
  20359. };
  20360. }
  20361. /**
  20362. * Setter for the element size.
  20363. *
  20364. * @param {Number} width New width of the element.
  20365. * @param {Number} height New height of the element.
  20366. */
  20367. }, {
  20368. key: 'setSize',
  20369. value: function setSize(width, height) {
  20370. if (width) {
  20371. this._element.style.width = width + UNIT;
  20372. }
  20373. if (height) {
  20374. this._element.style.height = height + UNIT;
  20375. }
  20376. }
  20377. /**
  20378. * Getter for the element position.
  20379. *
  20380. * @returns {Object} Object contains height and width of the element.
  20381. */
  20382. }, {
  20383. key: 'getSize',
  20384. value: function getSize() {
  20385. return {
  20386. width: this._element.style.width ? parseInt(this._element.style.width, 10) : 0,
  20387. height: this._element.style.height ? parseInt(this._element.style.height, 10) : 0
  20388. };
  20389. }
  20390. /**
  20391. * Setter for the element offset. Offset means marginTop and marginLeft of the element.
  20392. *
  20393. * @param {Number} top New margin top of the element.
  20394. * @param {Number} left New margin left of the element.
  20395. */
  20396. }, {
  20397. key: 'setOffset',
  20398. value: function setOffset(top, left) {
  20399. if (top) {
  20400. this._element.style.marginTop = top + UNIT;
  20401. }
  20402. if (left) {
  20403. this._element.style.marginLeft = left + UNIT;
  20404. }
  20405. }
  20406. /**
  20407. * Getter for the element offset.
  20408. *
  20409. * @returns {Object} Object contains top and left offset of the element.
  20410. */
  20411. }, {
  20412. key: 'getOffset',
  20413. value: function getOffset() {
  20414. return {
  20415. top: this._element.style.marginTop ? parseInt(this._element.style.marginTop, 10) : 0,
  20416. left: this._element.style.marginLeft ? parseInt(this._element.style.marginLeft, 10) : 0
  20417. };
  20418. }
  20419. }]);
  20420. return BaseUI;
  20421. }();
  20422. exports.default = BaseUI;
  20423. /***/ }),
  20424. /* 153 */
  20425. /***/ (function(module, exports, __webpack_require__) {
  20426. "use strict";
  20427. exports.__esModule = true;
  20428. exports.RecordTranslator = undefined;
  20429. 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; }; }();
  20430. exports.registerIdentity = registerIdentity;
  20431. exports.getTranslator = getTranslator;
  20432. var _core = __webpack_require__(63);
  20433. var _core2 = _interopRequireDefault(_core);
  20434. var _object = __webpack_require__(1);
  20435. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  20436. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20437. /**
  20438. * @class RecordTranslator
  20439. * @util
  20440. */
  20441. var RecordTranslator = function () {
  20442. function RecordTranslator(hot) {
  20443. _classCallCheck(this, RecordTranslator);
  20444. this.hot = hot;
  20445. }
  20446. /**
  20447. * Translate physical row index into visual.
  20448. *
  20449. * @param {Number} row Physical row index.
  20450. * @returns {Number} Returns visual row index.
  20451. */
  20452. _createClass(RecordTranslator, [{
  20453. key: 'toVisualRow',
  20454. value: function toVisualRow(row) {
  20455. return this.hot.runHooks('unmodifyRow', row);
  20456. }
  20457. /**
  20458. * Translate physical column index into visual.
  20459. *
  20460. * @param {Number} column Physical column index.
  20461. * @returns {Number} Returns visual column index.
  20462. */
  20463. }, {
  20464. key: 'toVisualColumn',
  20465. value: function toVisualColumn(column) {
  20466. return this.hot.runHooks('unmodifyCol', column);
  20467. }
  20468. /**
  20469. * Translate physical coordinates into visual. Can be passed as separate 2 arguments (row, column) or as an object in first
  20470. * argument with `row` and `column` keys.
  20471. *
  20472. * @param {Number|Object} row Physical coordinates or row index.
  20473. * @param {Number} [column] Physical column index.
  20474. * @returns {Object|Array} Returns an object with visual records or an array if coordinates passed as separate arguments.
  20475. */
  20476. }, {
  20477. key: 'toVisual',
  20478. value: function toVisual(row, column) {
  20479. var result = void 0;
  20480. if ((0, _object.isObject)(row)) {
  20481. result = {
  20482. row: this.toVisualRow(row.row),
  20483. column: this.toVisualColumn(row.column)
  20484. };
  20485. } else {
  20486. result = [this.toVisualRow(row), this.toVisualColumn(column)];
  20487. }
  20488. return result;
  20489. }
  20490. /**
  20491. * Translate visual row index into physical.
  20492. *
  20493. * @param {Number} row Visual row index.
  20494. * @returns {Number} Returns physical row index.
  20495. */
  20496. }, {
  20497. key: 'toPhysicalRow',
  20498. value: function toPhysicalRow(row) {
  20499. return this.hot.runHooks('modifyRow', row);
  20500. }
  20501. /**
  20502. * Translate visual column index into physical.
  20503. *
  20504. * @param {Number} column Visual column index.
  20505. * @returns {Number} Returns physical column index.
  20506. */
  20507. }, {
  20508. key: 'toPhysicalColumn',
  20509. value: function toPhysicalColumn(column) {
  20510. return this.hot.runHooks('modifyCol', column);
  20511. }
  20512. /**
  20513. * Translate visual coordinates into physical. Can be passed as separate 2 arguments (row, column) or as an object in first
  20514. * argument with `row` and `column` keys.
  20515. *
  20516. * @param {Number|Object} row Visual coordinates or row index.
  20517. * @param {Number} [column] Visual column index.
  20518. * @returns {Object|Array} Returns an object with physical records or an array if coordinates passed as separate arguments.
  20519. */
  20520. }, {
  20521. key: 'toPhysical',
  20522. value: function toPhysical(row, column) {
  20523. var result = void 0;
  20524. if ((0, _object.isObject)(row)) {
  20525. result = {
  20526. row: this.toPhysicalRow(row.row),
  20527. column: this.toPhysicalColumn(row.column)
  20528. };
  20529. } else {
  20530. result = [this.toPhysicalRow(row), this.toPhysicalColumn(column)];
  20531. }
  20532. return result;
  20533. }
  20534. }]);
  20535. return RecordTranslator;
  20536. }();
  20537. exports.RecordTranslator = RecordTranslator;
  20538. var identities = new WeakMap();
  20539. var translatorSingletons = new WeakMap();
  20540. function registerIdentity(identity, hot) {
  20541. identities.set(identity, hot);
  20542. }
  20543. function getTranslator(identity) {
  20544. var singleton = void 0;
  20545. if (!(identity instanceof _core2.default)) {
  20546. if (!identities.has(identity)) {
  20547. throw Error('Record translator was not registered for this object identity');
  20548. }
  20549. identity = identities.get(identity);
  20550. }
  20551. if (translatorSingletons.has(identity)) {
  20552. singleton = translatorSingletons.get(identity);
  20553. } else {
  20554. singleton = new RecordTranslator(identity);
  20555. translatorSingletons.set(identity, singleton);
  20556. }
  20557. return singleton;
  20558. }
  20559. /***/ }),
  20560. /* 154 */
  20561. /***/ (function(module, exports, __webpack_require__) {
  20562. "use strict";
  20563. exports.__esModule = true;
  20564. 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; }; }();
  20565. var _object = __webpack_require__(1);
  20566. var _number = __webpack_require__(6);
  20567. var _mixed = __webpack_require__(20);
  20568. 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; }
  20569. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20570. /**
  20571. * @class SamplesGenerator
  20572. * @util
  20573. */
  20574. var SamplesGenerator = function () {
  20575. _createClass(SamplesGenerator, null, [{
  20576. key: 'SAMPLE_COUNT',
  20577. /**
  20578. * Number of samples to take of each value length.
  20579. *
  20580. * @type {Number}
  20581. */
  20582. get: function get() {
  20583. return 3;
  20584. }
  20585. }]);
  20586. function SamplesGenerator(dataFactory) {
  20587. _classCallCheck(this, SamplesGenerator);
  20588. /**
  20589. * Samples prepared for calculations.
  20590. *
  20591. * @type {Map}
  20592. * @default {null}
  20593. */
  20594. this.samples = null;
  20595. /**
  20596. * Function which give the data to collect samples.
  20597. *
  20598. * @type {Function}
  20599. */
  20600. this.dataFactory = dataFactory;
  20601. /**
  20602. * Custom number of samples to take of each value length.
  20603. *
  20604. * @type {Number}
  20605. * @default {null}
  20606. */
  20607. this.customSampleCount = null;
  20608. /**
  20609. * `true` if duplicate samples collection should be allowed, `false` otherwise.
  20610. *
  20611. * @type {Boolean}
  20612. * @default {false}
  20613. */
  20614. this.allowDuplicates = false;
  20615. }
  20616. /**
  20617. * Get the sample count for this instance.
  20618. *
  20619. * @returns {Number}
  20620. */
  20621. _createClass(SamplesGenerator, [{
  20622. key: 'getSampleCount',
  20623. value: function getSampleCount() {
  20624. if (this.customSampleCount) {
  20625. return this.customSampleCount;
  20626. }
  20627. return SamplesGenerator.SAMPLE_COUNT;
  20628. }
  20629. }, {
  20630. key: 'setSampleCount',
  20631. /**
  20632. * Set the sample count.
  20633. *
  20634. * @param {Number} sampleCount Number of samples to be collected.
  20635. */
  20636. value: function setSampleCount(sampleCount) {
  20637. this.customSampleCount = sampleCount;
  20638. }
  20639. /**
  20640. * Set if the generator should accept duplicate values.
  20641. *
  20642. * @param {Boolean} allowDuplicates `true` to allow duplicate values.
  20643. */
  20644. }, {
  20645. key: 'setAllowDuplicates',
  20646. value: function setAllowDuplicates(allowDuplicates) {
  20647. this.allowDuplicates = allowDuplicates;
  20648. }
  20649. /**
  20650. * Generate samples for row. You can control which area should be sampled by passing `rowRange` object and `colRange` object.
  20651. *
  20652. * @param {Object|Number} rowRange
  20653. * @param {Object} colRange
  20654. * @returns {Object}
  20655. */
  20656. }, {
  20657. key: 'generateRowSamples',
  20658. value: function generateRowSamples(rowRange, colRange) {
  20659. return this.generateSamples('row', colRange, rowRange);
  20660. }
  20661. /**
  20662. * Generate samples for column. You can control which area should be sampled by passing `colRange` object and `rowRange` object.
  20663. *
  20664. * @param {Object} colRange Column index.
  20665. * @param {Object} rowRange Column index.
  20666. * @returns {Object}
  20667. */
  20668. }, {
  20669. key: 'generateColumnSamples',
  20670. value: function generateColumnSamples(colRange, rowRange) {
  20671. return this.generateSamples('col', rowRange, colRange);
  20672. }
  20673. /**
  20674. * Generate collection of samples.
  20675. *
  20676. * @param {String} type Type to generate. Can be `col` or `row`.
  20677. * @param {Object} range
  20678. * @param {Object|Number} specifierRange
  20679. * @returns {Map}
  20680. */
  20681. }, {
  20682. key: 'generateSamples',
  20683. value: function generateSamples(type, range, specifierRange) {
  20684. var _this = this;
  20685. var samples = new Map();
  20686. if (typeof specifierRange === 'number') {
  20687. specifierRange = { from: specifierRange, to: specifierRange };
  20688. }
  20689. (0, _number.rangeEach)(specifierRange.from, specifierRange.to, function (index) {
  20690. var sample = _this.generateSample(type, range, index);
  20691. samples.set(index, sample);
  20692. });
  20693. return samples;
  20694. }
  20695. /**
  20696. * Generate sample for specified type (`row` or `col`).
  20697. *
  20698. * @param {String} type Samples type `row` or `col`.
  20699. * @param {Object} range
  20700. * @param {Number} specifierValue
  20701. * @returns {Map}
  20702. */
  20703. }, {
  20704. key: 'generateSample',
  20705. value: function generateSample(type, range, specifierValue) {
  20706. var _this2 = this;
  20707. var samples = new Map();
  20708. var sampledValues = [];
  20709. var length = void 0;
  20710. (0, _number.rangeEach)(range.from, range.to, function (index) {
  20711. var value = void 0;
  20712. if (type === 'row') {
  20713. value = _this2.dataFactory(specifierValue, index);
  20714. } else if (type === 'col') {
  20715. value = _this2.dataFactory(index, specifierValue);
  20716. } else {
  20717. throw new Error('Unsupported sample type');
  20718. }
  20719. if ((0, _object.isObject)(value)) {
  20720. length = Object.keys(value).length;
  20721. } else if (Array.isArray(value)) {
  20722. length = value.length;
  20723. } else {
  20724. length = (0, _mixed.stringify)(value).length;
  20725. }
  20726. if (!samples.has(length)) {
  20727. samples.set(length, {
  20728. needed: _this2.getSampleCount(),
  20729. strings: []
  20730. });
  20731. }
  20732. var sample = samples.get(length);
  20733. if (sample.needed) {
  20734. var duplicate = sampledValues.indexOf(value) > -1;
  20735. if (!duplicate || _this2.allowDuplicates) {
  20736. var computedKey = type === 'row' ? 'col' : 'row';
  20737. sample.strings.push(_defineProperty({ value: value }, computedKey, index));
  20738. sampledValues.push(value);
  20739. sample.needed--;
  20740. }
  20741. }
  20742. });
  20743. return samples;
  20744. }
  20745. }]);
  20746. return SamplesGenerator;
  20747. }();
  20748. exports.default = SamplesGenerator;
  20749. /***/ }),
  20750. /* 155 */
  20751. /***/ (function(module, exports, __webpack_require__) {
  20752. // false -> Array#indexOf
  20753. // true -> Array#includes
  20754. var toIObject = __webpack_require__(23)
  20755. , toLength = __webpack_require__(24)
  20756. , toIndex = __webpack_require__(59);
  20757. module.exports = function(IS_INCLUDES){
  20758. return function($this, el, fromIndex){
  20759. var O = toIObject($this)
  20760. , length = toLength(O.length)
  20761. , index = toIndex(fromIndex, length)
  20762. , value;
  20763. // Array#includes uses SameValueZero equality algorithm
  20764. if(IS_INCLUDES && el != el)while(length > index){
  20765. value = O[index++];
  20766. if(value != value)return true;
  20767. // Array#toIndex ignores holes, Array#includes - not
  20768. } else for(;length > index; index++)if(IS_INCLUDES || index in O){
  20769. if(O[index] === el)return IS_INCLUDES || index || 0;
  20770. } return !IS_INCLUDES && -1;
  20771. };
  20772. };
  20773. /***/ }),
  20774. /* 156 */
  20775. /***/ (function(module, exports, __webpack_require__) {
  20776. // getting tag from 19.1.3.6 Object.prototype.toString()
  20777. var cof = __webpack_require__(38)
  20778. , TAG = __webpack_require__(10)('toStringTag')
  20779. // ES3 wrong here
  20780. , ARG = cof(function(){ return arguments; }()) == 'Arguments';
  20781. // fallback for IE11 Script Access Denied error
  20782. var tryGet = function(it, key){
  20783. try {
  20784. return it[key];
  20785. } catch(e){ /* empty */ }
  20786. };
  20787. module.exports = function(it){
  20788. var O, T, B;
  20789. return it === undefined ? 'Undefined' : it === null ? 'Null'
  20790. // @@toStringTag case
  20791. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  20792. // builtinTag case
  20793. : ARG ? cof(O)
  20794. // ES3 arguments fallback
  20795. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  20796. };
  20797. /***/ }),
  20798. /* 157 */
  20799. /***/ (function(module, exports, __webpack_require__) {
  20800. "use strict";
  20801. var dP = __webpack_require__(19).f
  20802. , create = __webpack_require__(79)
  20803. , redefineAll = __webpack_require__(58)
  20804. , ctx = __webpack_require__(29)
  20805. , anInstance = __webpack_require__(51)
  20806. , defined = __webpack_require__(30)
  20807. , forOf = __webpack_require__(55)
  20808. , $iterDefine = __webpack_require__(166)
  20809. , step = __webpack_require__(167)
  20810. , setSpecies = __webpack_require__(172)
  20811. , DESCRIPTORS = __webpack_require__(21)
  20812. , fastKey = __webpack_require__(46).fastKey
  20813. , SIZE = DESCRIPTORS ? '_s' : 'size';
  20814. var getEntry = function(that, key){
  20815. // fast case
  20816. var index = fastKey(key), entry;
  20817. if(index !== 'F')return that._i[index];
  20818. // frozen object case
  20819. for(entry = that._f; entry; entry = entry.n){
  20820. if(entry.k == key)return entry;
  20821. }
  20822. };
  20823. module.exports = {
  20824. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  20825. var C = wrapper(function(that, iterable){
  20826. anInstance(that, C, NAME, '_i');
  20827. that._i = create(null); // index
  20828. that._f = undefined; // first entry
  20829. that._l = undefined; // last entry
  20830. that[SIZE] = 0; // size
  20831. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  20832. });
  20833. redefineAll(C.prototype, {
  20834. // 23.1.3.1 Map.prototype.clear()
  20835. // 23.2.3.2 Set.prototype.clear()
  20836. clear: function clear(){
  20837. for(var that = this, data = that._i, entry = that._f; entry; entry = entry.n){
  20838. entry.r = true;
  20839. if(entry.p)entry.p = entry.p.n = undefined;
  20840. delete data[entry.i];
  20841. }
  20842. that._f = that._l = undefined;
  20843. that[SIZE] = 0;
  20844. },
  20845. // 23.1.3.3 Map.prototype.delete(key)
  20846. // 23.2.3.4 Set.prototype.delete(value)
  20847. 'delete': function(key){
  20848. var that = this
  20849. , entry = getEntry(that, key);
  20850. if(entry){
  20851. var next = entry.n
  20852. , prev = entry.p;
  20853. delete that._i[entry.i];
  20854. entry.r = true;
  20855. if(prev)prev.n = next;
  20856. if(next)next.p = prev;
  20857. if(that._f == entry)that._f = next;
  20858. if(that._l == entry)that._l = prev;
  20859. that[SIZE]--;
  20860. } return !!entry;
  20861. },
  20862. // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
  20863. // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
  20864. forEach: function forEach(callbackfn /*, that = undefined */){
  20865. anInstance(this, C, 'forEach');
  20866. var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3)
  20867. , entry;
  20868. while(entry = entry ? entry.n : this._f){
  20869. f(entry.v, entry.k, this);
  20870. // revert to the last existing entry
  20871. while(entry && entry.r)entry = entry.p;
  20872. }
  20873. },
  20874. // 23.1.3.7 Map.prototype.has(key)
  20875. // 23.2.3.7 Set.prototype.has(value)
  20876. has: function has(key){
  20877. return !!getEntry(this, key);
  20878. }
  20879. });
  20880. if(DESCRIPTORS)dP(C.prototype, 'size', {
  20881. get: function(){
  20882. return defined(this[SIZE]);
  20883. }
  20884. });
  20885. return C;
  20886. },
  20887. def: function(that, key, value){
  20888. var entry = getEntry(that, key)
  20889. , prev, index;
  20890. // change existing entry
  20891. if(entry){
  20892. entry.v = value;
  20893. // create new entry
  20894. } else {
  20895. that._l = entry = {
  20896. i: index = fastKey(key, true), // <- index
  20897. k: key, // <- key
  20898. v: value, // <- value
  20899. p: prev = that._l, // <- previous entry
  20900. n: undefined, // <- next entry
  20901. r: false // <- removed
  20902. };
  20903. if(!that._f)that._f = entry;
  20904. if(prev)prev.n = entry;
  20905. that[SIZE]++;
  20906. // add to index
  20907. if(index !== 'F')that._i[index] = entry;
  20908. } return that;
  20909. },
  20910. getEntry: getEntry,
  20911. setStrong: function(C, NAME, IS_MAP){
  20912. // add .keys, .values, .entries, [@@iterator]
  20913. // 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
  20914. $iterDefine(C, NAME, function(iterated, kind){
  20915. this._t = iterated; // target
  20916. this._k = kind; // kind
  20917. this._l = undefined; // previous
  20918. }, function(){
  20919. var that = this
  20920. , kind = that._k
  20921. , entry = that._l;
  20922. // revert to the last existing entry
  20923. while(entry && entry.r)entry = entry.p;
  20924. // get next entry
  20925. if(!that._t || !(that._l = entry = entry ? entry.n : that._t._f)){
  20926. // or finish the iteration
  20927. that._t = undefined;
  20928. return step(1);
  20929. }
  20930. // return step by kind
  20931. if(kind == 'keys' )return step(0, entry.k);
  20932. if(kind == 'values')return step(0, entry.v);
  20933. return step(0, [entry.k, entry.v]);
  20934. }, IS_MAP ? 'entries' : 'values' , !IS_MAP, true);
  20935. // add [@@species], 23.1.2.2, 23.2.2.2
  20936. setSpecies(NAME);
  20937. }
  20938. };
  20939. /***/ }),
  20940. /* 158 */
  20941. /***/ (function(module, exports, __webpack_require__) {
  20942. "use strict";
  20943. var redefineAll = __webpack_require__(58)
  20944. , getWeak = __webpack_require__(46).getWeak
  20945. , anObject = __webpack_require__(18)
  20946. , isObject = __webpack_require__(15)
  20947. , anInstance = __webpack_require__(51)
  20948. , forOf = __webpack_require__(55)
  20949. , createArrayMethod = __webpack_require__(52)
  20950. , $has = __webpack_require__(22)
  20951. , arrayFind = createArrayMethod(5)
  20952. , arrayFindIndex = createArrayMethod(6)
  20953. , id = 0;
  20954. // fallback for uncaught frozen keys
  20955. var uncaughtFrozenStore = function(that){
  20956. return that._l || (that._l = new UncaughtFrozenStore);
  20957. };
  20958. var UncaughtFrozenStore = function(){
  20959. this.a = [];
  20960. };
  20961. var findUncaughtFrozen = function(store, key){
  20962. return arrayFind(store.a, function(it){
  20963. return it[0] === key;
  20964. });
  20965. };
  20966. UncaughtFrozenStore.prototype = {
  20967. get: function(key){
  20968. var entry = findUncaughtFrozen(this, key);
  20969. if(entry)return entry[1];
  20970. },
  20971. has: function(key){
  20972. return !!findUncaughtFrozen(this, key);
  20973. },
  20974. set: function(key, value){
  20975. var entry = findUncaughtFrozen(this, key);
  20976. if(entry)entry[1] = value;
  20977. else this.a.push([key, value]);
  20978. },
  20979. 'delete': function(key){
  20980. var index = arrayFindIndex(this.a, function(it){
  20981. return it[0] === key;
  20982. });
  20983. if(~index)this.a.splice(index, 1);
  20984. return !!~index;
  20985. }
  20986. };
  20987. module.exports = {
  20988. getConstructor: function(wrapper, NAME, IS_MAP, ADDER){
  20989. var C = wrapper(function(that, iterable){
  20990. anInstance(that, C, NAME, '_i');
  20991. that._i = id++; // collection id
  20992. that._l = undefined; // leak store for uncaught frozen objects
  20993. if(iterable != undefined)forOf(iterable, IS_MAP, that[ADDER], that);
  20994. });
  20995. redefineAll(C.prototype, {
  20996. // 23.3.3.2 WeakMap.prototype.delete(key)
  20997. // 23.4.3.3 WeakSet.prototype.delete(value)
  20998. 'delete': function(key){
  20999. if(!isObject(key))return false;
  21000. var data = getWeak(key);
  21001. if(data === true)return uncaughtFrozenStore(this)['delete'](key);
  21002. return data && $has(data, this._i) && delete data[this._i];
  21003. },
  21004. // 23.3.3.4 WeakMap.prototype.has(key)
  21005. // 23.4.3.4 WeakSet.prototype.has(value)
  21006. has: function has(key){
  21007. if(!isObject(key))return false;
  21008. var data = getWeak(key);
  21009. if(data === true)return uncaughtFrozenStore(this).has(key);
  21010. return data && $has(data, this._i);
  21011. }
  21012. });
  21013. return C;
  21014. },
  21015. def: function(that, key, value){
  21016. var data = getWeak(anObject(key), true);
  21017. if(data === true)uncaughtFrozenStore(that).set(key, value);
  21018. else data[that._i] = value;
  21019. return that;
  21020. },
  21021. ufstore: uncaughtFrozenStore
  21022. };
  21023. /***/ }),
  21024. /* 159 */
  21025. /***/ (function(module, exports, __webpack_require__) {
  21026. module.exports = __webpack_require__(13).document && document.documentElement;
  21027. /***/ }),
  21028. /* 160 */
  21029. /***/ (function(module, exports, __webpack_require__) {
  21030. module.exports = !__webpack_require__(21) && !__webpack_require__(31)(function(){
  21031. return Object.defineProperty(__webpack_require__(74)('div'), 'a', {get: function(){ return 7; }}).a != 7;
  21032. });
  21033. /***/ }),
  21034. /* 161 */
  21035. /***/ (function(module, exports, __webpack_require__) {
  21036. // check on default Array iterator
  21037. var Iterators = __webpack_require__(45)
  21038. , ITERATOR = __webpack_require__(10)('iterator')
  21039. , ArrayProto = Array.prototype;
  21040. module.exports = function(it){
  21041. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  21042. };
  21043. /***/ }),
  21044. /* 162 */
  21045. /***/ (function(module, exports, __webpack_require__) {
  21046. // 7.2.2 IsArray(argument)
  21047. var cof = __webpack_require__(38);
  21048. module.exports = Array.isArray || function isArray(arg){
  21049. return cof(arg) == 'Array';
  21050. };
  21051. /***/ }),
  21052. /* 163 */
  21053. /***/ (function(module, exports, __webpack_require__) {
  21054. // 20.1.2.3 Number.isInteger(number)
  21055. var isObject = __webpack_require__(15)
  21056. , floor = Math.floor;
  21057. module.exports = function isInteger(it){
  21058. return !isObject(it) && isFinite(it) && floor(it) === it;
  21059. };
  21060. /***/ }),
  21061. /* 164 */
  21062. /***/ (function(module, exports, __webpack_require__) {
  21063. // 7.2.8 IsRegExp(argument)
  21064. var isObject = __webpack_require__(15)
  21065. , cof = __webpack_require__(38)
  21066. , MATCH = __webpack_require__(10)('match');
  21067. module.exports = function(it){
  21068. var isRegExp;
  21069. return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
  21070. };
  21071. /***/ }),
  21072. /* 165 */
  21073. /***/ (function(module, exports, __webpack_require__) {
  21074. // call something on iterator step with safe closing on error
  21075. var anObject = __webpack_require__(18);
  21076. module.exports = function(iterator, fn, value, entries){
  21077. try {
  21078. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  21079. // 7.4.6 IteratorClose(iterator, completion)
  21080. } catch(e){
  21081. var ret = iterator['return'];
  21082. if(ret !== undefined)anObject(ret.call(iterator));
  21083. throw e;
  21084. }
  21085. };
  21086. /***/ }),
  21087. /* 166 */
  21088. /***/ (function(module, exports, __webpack_require__) {
  21089. "use strict";
  21090. var LIBRARY = __webpack_require__(56)
  21091. , $export = __webpack_require__(3)
  21092. , redefine = __webpack_require__(33)
  21093. , hide = __webpack_require__(32)
  21094. , has = __webpack_require__(22)
  21095. , Iterators = __webpack_require__(45)
  21096. , $iterCreate = __webpack_require__(285)
  21097. , setToStringTag = __webpack_require__(48)
  21098. , getPrototypeOf = __webpack_require__(290)
  21099. , ITERATOR = __webpack_require__(10)('iterator')
  21100. , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
  21101. , FF_ITERATOR = '@@iterator'
  21102. , KEYS = 'keys'
  21103. , VALUES = 'values';
  21104. var returnThis = function(){ return this; };
  21105. module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
  21106. $iterCreate(Constructor, NAME, next);
  21107. var getMethod = function(kind){
  21108. if(!BUGGY && kind in proto)return proto[kind];
  21109. switch(kind){
  21110. case KEYS: return function keys(){ return new Constructor(this, kind); };
  21111. case VALUES: return function values(){ return new Constructor(this, kind); };
  21112. } return function entries(){ return new Constructor(this, kind); };
  21113. };
  21114. var TAG = NAME + ' Iterator'
  21115. , DEF_VALUES = DEFAULT == VALUES
  21116. , VALUES_BUG = false
  21117. , proto = Base.prototype
  21118. , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
  21119. , $default = $native || getMethod(DEFAULT)
  21120. , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
  21121. , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
  21122. , methods, key, IteratorPrototype;
  21123. // Fix native
  21124. if($anyNative){
  21125. IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
  21126. if(IteratorPrototype !== Object.prototype){
  21127. // Set @@toStringTag to native iterators
  21128. setToStringTag(IteratorPrototype, TAG, true);
  21129. // fix for some old engines
  21130. if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
  21131. }
  21132. }
  21133. // fix Array#{values, @@iterator}.name in V8 / FF
  21134. if(DEF_VALUES && $native && $native.name !== VALUES){
  21135. VALUES_BUG = true;
  21136. $default = function values(){ return $native.call(this); };
  21137. }
  21138. // Define iterator
  21139. if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
  21140. hide(proto, ITERATOR, $default);
  21141. }
  21142. // Plug for library
  21143. Iterators[NAME] = $default;
  21144. Iterators[TAG] = returnThis;
  21145. if(DEFAULT){
  21146. methods = {
  21147. values: DEF_VALUES ? $default : getMethod(VALUES),
  21148. keys: IS_SET ? $default : getMethod(KEYS),
  21149. entries: $entries
  21150. };
  21151. if(FORCED)for(key in methods){
  21152. if(!(key in proto))redefine(proto, key, methods[key]);
  21153. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  21154. }
  21155. return methods;
  21156. };
  21157. /***/ }),
  21158. /* 167 */
  21159. /***/ (function(module, exports) {
  21160. module.exports = function(done, value){
  21161. return {value: value, done: !!done};
  21162. };
  21163. /***/ }),
  21164. /* 168 */
  21165. /***/ (function(module, exports, __webpack_require__) {
  21166. "use strict";
  21167. // 19.1.2.1 Object.assign(target, source, ...)
  21168. var getKeys = __webpack_require__(39)
  21169. , gOPS = __webpack_require__(57)
  21170. , pIE = __webpack_require__(47)
  21171. , toObject = __webpack_require__(41)
  21172. , IObject = __webpack_require__(77)
  21173. , $assign = Object.assign;
  21174. // should work with symbols and should have deterministic property order (V8 bug)
  21175. module.exports = !$assign || __webpack_require__(31)(function(){
  21176. var A = {}
  21177. , B = {}
  21178. , S = Symbol()
  21179. , K = 'abcdefghijklmnopqrst';
  21180. A[S] = 7;
  21181. K.split('').forEach(function(k){ B[k] = k; });
  21182. return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
  21183. }) ? function assign(target, source){ // eslint-disable-line no-unused-vars
  21184. var T = toObject(target)
  21185. , aLen = arguments.length
  21186. , index = 1
  21187. , getSymbols = gOPS.f
  21188. , isEnum = pIE.f;
  21189. while(aLen > index){
  21190. var S = IObject(arguments[index++])
  21191. , keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S)
  21192. , length = keys.length
  21193. , j = 0
  21194. , key;
  21195. while(length > j)if(isEnum.call(S, key = keys[j++]))T[key] = S[key];
  21196. } return T;
  21197. } : $assign;
  21198. /***/ }),
  21199. /* 169 */
  21200. /***/ (function(module, exports, __webpack_require__) {
  21201. var has = __webpack_require__(22)
  21202. , toIObject = __webpack_require__(23)
  21203. , arrayIndexOf = __webpack_require__(155)(false)
  21204. , IE_PROTO = __webpack_require__(82)('IE_PROTO');
  21205. module.exports = function(object, names){
  21206. var O = toIObject(object)
  21207. , i = 0
  21208. , result = []
  21209. , key;
  21210. for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
  21211. // Don't enum bug & hidden keys
  21212. while(names.length > i)if(has(O, key = names[i++])){
  21213. ~arrayIndexOf(result, key) || result.push(key);
  21214. }
  21215. return result;
  21216. };
  21217. /***/ }),
  21218. /* 170 */
  21219. /***/ (function(module, exports, __webpack_require__) {
  21220. var getKeys = __webpack_require__(39)
  21221. , toIObject = __webpack_require__(23)
  21222. , isEnum = __webpack_require__(47).f;
  21223. module.exports = function(isEntries){
  21224. return function(it){
  21225. var O = toIObject(it)
  21226. , keys = getKeys(O)
  21227. , length = keys.length
  21228. , i = 0
  21229. , result = []
  21230. , key;
  21231. while(length > i)if(isEnum.call(O, key = keys[i++])){
  21232. result.push(isEntries ? [key, O[key]] : O[key]);
  21233. } return result;
  21234. };
  21235. };
  21236. /***/ }),
  21237. /* 171 */
  21238. /***/ (function(module, exports, __webpack_require__) {
  21239. // Works with __proto__ only. Old v8 can't work with null proto objects.
  21240. /* eslint-disable no-proto */
  21241. var isObject = __webpack_require__(15)
  21242. , anObject = __webpack_require__(18);
  21243. var check = function(O, proto){
  21244. anObject(O);
  21245. if(!isObject(proto) && proto !== null)throw TypeError(proto + ": can't set as prototype!");
  21246. };
  21247. module.exports = {
  21248. set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
  21249. function(test, buggy, set){
  21250. try {
  21251. set = __webpack_require__(29)(Function.call, __webpack_require__(80).f(Object.prototype, '__proto__').set, 2);
  21252. set(test, []);
  21253. buggy = !(test instanceof Array);
  21254. } catch(e){ buggy = true; }
  21255. return function setPrototypeOf(O, proto){
  21256. check(O, proto);
  21257. if(buggy)O.__proto__ = proto;
  21258. else set(O, proto);
  21259. return O;
  21260. };
  21261. }({}, false) : undefined),
  21262. check: check
  21263. };
  21264. /***/ }),
  21265. /* 172 */
  21266. /***/ (function(module, exports, __webpack_require__) {
  21267. "use strict";
  21268. var global = __webpack_require__(13)
  21269. , dP = __webpack_require__(19)
  21270. , DESCRIPTORS = __webpack_require__(21)
  21271. , SPECIES = __webpack_require__(10)('species');
  21272. module.exports = function(KEY){
  21273. var C = global[KEY];
  21274. if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
  21275. configurable: true,
  21276. get: function(){ return this; }
  21277. });
  21278. };
  21279. /***/ }),
  21280. /* 173 */
  21281. /***/ (function(module, exports, __webpack_require__) {
  21282. // https://github.com/tc39/proposal-string-pad-start-end
  21283. var toLength = __webpack_require__(24)
  21284. , repeat = __webpack_require__(174)
  21285. , defined = __webpack_require__(30);
  21286. module.exports = function(that, maxLength, fillString, left){
  21287. var S = String(defined(that))
  21288. , stringLength = S.length
  21289. , fillStr = fillString === undefined ? ' ' : String(fillString)
  21290. , intMaxLength = toLength(maxLength);
  21291. if(intMaxLength <= stringLength || fillStr == '')return S;
  21292. var fillLen = intMaxLength - stringLength
  21293. , stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
  21294. if(stringFiller.length > fillLen)stringFiller = stringFiller.slice(0, fillLen);
  21295. return left ? stringFiller + S : S + stringFiller;
  21296. };
  21297. /***/ }),
  21298. /* 174 */
  21299. /***/ (function(module, exports, __webpack_require__) {
  21300. "use strict";
  21301. var toInteger = __webpack_require__(60)
  21302. , defined = __webpack_require__(30);
  21303. module.exports = function repeat(count){
  21304. var str = String(defined(this))
  21305. , res = ''
  21306. , n = toInteger(count);
  21307. if(n < 0 || n == Infinity)throw RangeError("Count can't be negative");
  21308. for(;n > 0; (n >>>= 1) && (str += str))if(n & 1)res += str;
  21309. return res;
  21310. };
  21311. /***/ }),
  21312. /* 175 */
  21313. /***/ (function(module, exports, __webpack_require__) {
  21314. exports.f = __webpack_require__(10);
  21315. /***/ }),
  21316. /* 176 */
  21317. /***/ (function(module, exports, __webpack_require__) {
  21318. var classof = __webpack_require__(156)
  21319. , ITERATOR = __webpack_require__(10)('iterator')
  21320. , Iterators = __webpack_require__(45);
  21321. module.exports = __webpack_require__(44).getIteratorMethod = function(it){
  21322. if(it != undefined)return it[ITERATOR]
  21323. || it['@@iterator']
  21324. || Iterators[classof(it)];
  21325. };
  21326. /***/ }),
  21327. /* 177 */
  21328. /***/ (function(module, exports, __webpack_require__) {
  21329. "use strict";
  21330. exports.__esModule = true;
  21331. exports.default = jQueryWrapper;
  21332. function jQueryWrapper(Handsontable) {
  21333. var jQuery = typeof window === 'undefined' ? false : window.jQuery;
  21334. if (!jQuery) {
  21335. return;
  21336. }
  21337. jQuery.fn.handsontable = function (action) {
  21338. var $this = this.first(); // Use only first element from list
  21339. var instance = $this.data('handsontable');
  21340. // Init case
  21341. if (typeof action !== 'string') {
  21342. var userSettings = action || {};
  21343. if (instance) {
  21344. instance.updateSettings(userSettings);
  21345. } else {
  21346. instance = new Handsontable.Core($this[0], userSettings);
  21347. $this.data('handsontable', instance);
  21348. instance.init();
  21349. }
  21350. return $this;
  21351. }
  21352. // Action case
  21353. var args = [];
  21354. var output = void 0;
  21355. if (arguments.length > 1) {
  21356. for (var i = 1, ilen = arguments.length; i < ilen; i++) {
  21357. args.push(arguments[i]);
  21358. }
  21359. }
  21360. if (instance) {
  21361. if (typeof instance[action] !== 'undefined') {
  21362. output = instance[action].apply(instance, args);
  21363. if (action === 'destroy') {
  21364. $this.removeData();
  21365. }
  21366. } else {
  21367. throw new Error('Handsontable do not provide action: ' + action);
  21368. }
  21369. }
  21370. return output;
  21371. };
  21372. };
  21373. /***/ }),
  21374. /* 178 */
  21375. /***/ (function(module, exports, __webpack_require__) {
  21376. "use strict";
  21377. exports.__esModule = true;
  21378. 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;
  21379. var _autoColumnSize = __webpack_require__(210);
  21380. var _autoColumnSize2 = _interopRequireDefault(_autoColumnSize);
  21381. var _autofill = __webpack_require__(212);
  21382. var _autofill2 = _interopRequireDefault(_autofill);
  21383. var _autoRowSize = __webpack_require__(211);
  21384. var _autoRowSize2 = _interopRequireDefault(_autoRowSize);
  21385. var _columnSorting = __webpack_require__(214);
  21386. var _columnSorting2 = _interopRequireDefault(_columnSorting);
  21387. var _comments = __webpack_require__(216);
  21388. var _comments2 = _interopRequireDefault(_comments);
  21389. var _contextMenu = __webpack_require__(219);
  21390. var _contextMenu2 = _interopRequireDefault(_contextMenu);
  21391. var _copyPaste = __webpack_require__(236);
  21392. var _copyPaste2 = _interopRequireDefault(_copyPaste);
  21393. var _customBorders = __webpack_require__(238);
  21394. var _customBorders2 = _interopRequireDefault(_customBorders);
  21395. var _dragToScroll = __webpack_require__(239);
  21396. var _dragToScroll2 = _interopRequireDefault(_dragToScroll);
  21397. var _manualColumnFreeze = __webpack_require__(242);
  21398. var _manualColumnFreeze2 = _interopRequireDefault(_manualColumnFreeze);
  21399. var _manualColumnMove = __webpack_require__(244);
  21400. var _manualColumnMove2 = _interopRequireDefault(_manualColumnMove);
  21401. var _manualColumnResize = __webpack_require__(247);
  21402. var _manualColumnResize2 = _interopRequireDefault(_manualColumnResize);
  21403. var _manualRowMove = __webpack_require__(248);
  21404. var _manualRowMove2 = _interopRequireDefault(_manualRowMove);
  21405. var _manualRowResize = __webpack_require__(252);
  21406. var _manualRowResize2 = _interopRequireDefault(_manualRowResize);
  21407. var _mergeCells = __webpack_require__(253);
  21408. var _mergeCells2 = _interopRequireDefault(_mergeCells);
  21409. var _multipleSelectionHandles = __webpack_require__(254);
  21410. var _multipleSelectionHandles2 = _interopRequireDefault(_multipleSelectionHandles);
  21411. var _observeChanges = __webpack_require__(256);
  21412. var _observeChanges2 = _interopRequireDefault(_observeChanges);
  21413. var _persistentState = __webpack_require__(258);
  21414. var _persistentState2 = _interopRequireDefault(_persistentState);
  21415. var _search = __webpack_require__(259);
  21416. var _search2 = _interopRequireDefault(_search);
  21417. var _touchScroll = __webpack_require__(260);
  21418. var _touchScroll2 = _interopRequireDefault(_touchScroll);
  21419. var _undoRedo = __webpack_require__(261);
  21420. var _undoRedo2 = _interopRequireDefault(_undoRedo);
  21421. var _base = __webpack_require__(12);
  21422. var _base2 = _interopRequireDefault(_base);
  21423. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21424. exports.AutoColumnSize = _autoColumnSize2.default;
  21425. exports.AutoFill = _autofill2.default;
  21426. exports.AutoRowSize = _autoRowSize2.default;
  21427. exports.ColumnSorting = _columnSorting2.default;
  21428. exports.Comments = _comments2.default;
  21429. exports.ContextMenu = _contextMenu2.default;
  21430. exports.CopyPaste = _copyPaste2.default;
  21431. exports.CustomBorders = _customBorders2.default;
  21432. exports.DragToScroll = _dragToScroll2.default;
  21433. exports.ManualColumnFreeze = _manualColumnFreeze2.default;
  21434. exports.ManualColumnMove = _manualColumnMove2.default;
  21435. exports.ManualColumnResize = _manualColumnResize2.default;
  21436. exports.ManualRowMove = _manualRowMove2.default;
  21437. exports.ManualRowResize = _manualRowResize2.default;
  21438. exports.MergeCells = _mergeCells2.default;
  21439. exports.MultipleSelectionHandles = _multipleSelectionHandles2.default;
  21440. exports.ObserveChanges = _observeChanges2.default;
  21441. exports.PersistentState = _persistentState2.default;
  21442. exports.Search = _search2.default;
  21443. exports.TouchScroll = _touchScroll2.default;
  21444. exports.UndoRedo = _undoRedo2.default;
  21445. exports.Base = _base2.default;
  21446. /***/ }),
  21447. /* 179 */
  21448. /***/ (function(module, exports) {
  21449. // removed by extract-text-webpack-plugin
  21450. /***/ }),
  21451. /* 180 */
  21452. /***/ (function(module, exports) {
  21453. // removed by extract-text-webpack-plugin
  21454. /***/ }),
  21455. /* 181 */
  21456. /***/ (function(module, exports) {
  21457. // removed by extract-text-webpack-plugin
  21458. /***/ }),
  21459. /* 182 */
  21460. /***/ (function(module, exports) {
  21461. /***/ }),
  21462. /* 183 */
  21463. /***/ (function(module, exports, __webpack_require__) {
  21464. "use strict";
  21465. /**
  21466. * autoResize - resizes a DOM element to the width and height of another DOM element
  21467. *
  21468. * Copyright 2014, Marcin Warpechowski
  21469. * Licensed under the MIT license
  21470. */
  21471. function autoResize() {
  21472. var defaults = {
  21473. minHeight: 200,
  21474. maxHeight: 300,
  21475. minWidth: 100,
  21476. maxWidth: 300
  21477. },
  21478. el,
  21479. body = document.body,
  21480. text = document.createTextNode(''),
  21481. span = document.createElement('SPAN'),
  21482. observe = function observe(element, event, handler) {
  21483. if (element.attachEvent) {
  21484. element.attachEvent('on' + event, handler);
  21485. } else {
  21486. element.addEventListener(event, handler, false);
  21487. }
  21488. },
  21489. _unObserve = function _unObserve(element, event, handler) {
  21490. if (element.removeEventListener) {
  21491. element.removeEventListener(event, handler, false);
  21492. } else {
  21493. element.detachEvent('on' + event, handler);
  21494. }
  21495. },
  21496. resize = function resize(newChar) {
  21497. var width, scrollHeight;
  21498. if (!newChar) {
  21499. newChar = "";
  21500. } else if (!/^[a-zA-Z \.,\\\/\|0-9]$/.test(newChar)) {
  21501. newChar = ".";
  21502. }
  21503. if (text.textContent !== void 0) {
  21504. text.textContent = el.value + newChar;
  21505. } else {
  21506. text.data = el.value + newChar; //IE8
  21507. }
  21508. span.style.fontSize = getComputedStyle(el).fontSize;
  21509. span.style.fontFamily = getComputedStyle(el).fontFamily;
  21510. span.style.whiteSpace = "pre";
  21511. body.appendChild(span);
  21512. width = span.clientWidth + 2;
  21513. body.removeChild(span);
  21514. el.style.height = defaults.minHeight + 'px';
  21515. if (defaults.minWidth > width) {
  21516. el.style.width = defaults.minWidth + 'px';
  21517. } else if (width > defaults.maxWidth) {
  21518. el.style.width = defaults.maxWidth + 'px';
  21519. } else {
  21520. el.style.width = width + 'px';
  21521. }
  21522. scrollHeight = el.scrollHeight ? el.scrollHeight - 1 : 0;
  21523. if (defaults.minHeight > scrollHeight) {
  21524. el.style.height = defaults.minHeight + 'px';
  21525. } else if (defaults.maxHeight < scrollHeight) {
  21526. el.style.height = defaults.maxHeight + 'px';
  21527. el.style.overflowY = 'visible';
  21528. } else {
  21529. el.style.height = scrollHeight + 'px';
  21530. }
  21531. },
  21532. delayedResize = function delayedResize() {
  21533. window.setTimeout(resize, 0);
  21534. },
  21535. extendDefaults = function extendDefaults(config) {
  21536. if (config && config.minHeight) {
  21537. if (config.minHeight == 'inherit') {
  21538. defaults.minHeight = el.clientHeight;
  21539. } else {
  21540. var minHeight = parseInt(config.minHeight);
  21541. if (!isNaN(minHeight)) {
  21542. defaults.minHeight = minHeight;
  21543. }
  21544. }
  21545. }
  21546. if (config && config.maxHeight) {
  21547. if (config.maxHeight == 'inherit') {
  21548. defaults.maxHeight = el.clientHeight;
  21549. } else {
  21550. var maxHeight = parseInt(config.maxHeight);
  21551. if (!isNaN(maxHeight)) {
  21552. defaults.maxHeight = maxHeight;
  21553. }
  21554. }
  21555. }
  21556. if (config && config.minWidth) {
  21557. if (config.minWidth == 'inherit') {
  21558. defaults.minWidth = el.clientWidth;
  21559. } else {
  21560. var minWidth = parseInt(config.minWidth);
  21561. if (!isNaN(minWidth)) {
  21562. defaults.minWidth = minWidth;
  21563. }
  21564. }
  21565. }
  21566. if (config && config.maxWidth) {
  21567. if (config.maxWidth == 'inherit') {
  21568. defaults.maxWidth = el.clientWidth;
  21569. } else {
  21570. var maxWidth = parseInt(config.maxWidth);
  21571. if (!isNaN(maxWidth)) {
  21572. defaults.maxWidth = maxWidth;
  21573. }
  21574. }
  21575. }
  21576. if (!span.firstChild) {
  21577. span.className = "autoResize";
  21578. span.style.display = 'inline-block';
  21579. span.appendChild(text);
  21580. }
  21581. },
  21582. _init = function _init(el_, config, doObserve) {
  21583. el = el_;
  21584. extendDefaults(config);
  21585. if (el.nodeName == 'TEXTAREA') {
  21586. el.style.resize = 'none';
  21587. el.style.overflowY = '';
  21588. el.style.height = defaults.minHeight + 'px';
  21589. el.style.minWidth = defaults.minWidth + 'px';
  21590. el.style.maxWidth = defaults.maxWidth + 'px';
  21591. el.style.overflowY = 'hidden';
  21592. }
  21593. if (doObserve) {
  21594. observe(el, 'change', resize);
  21595. observe(el, 'cut', delayedResize);
  21596. observe(el, 'paste', delayedResize);
  21597. observe(el, 'drop', delayedResize);
  21598. observe(el, 'keydown', delayedResize);
  21599. observe(el, 'focus', resize);
  21600. }
  21601. resize();
  21602. };
  21603. function getComputedStyle(element) {
  21604. return element.currentStyle || document.defaultView.getComputedStyle(element);
  21605. }
  21606. return {
  21607. init: function init(el_, config, doObserve) {
  21608. _init(el_, config, doObserve);
  21609. },
  21610. unObserve: function unObserve() {
  21611. _unObserve(el, 'change', resize);
  21612. _unObserve(el, 'cut', delayedResize);
  21613. _unObserve(el, 'paste', delayedResize);
  21614. _unObserve(el, 'drop', delayedResize);
  21615. _unObserve(el, 'keydown', delayedResize);
  21616. _unObserve(el, 'focus', resize);
  21617. },
  21618. resize: resize
  21619. };
  21620. }
  21621. if (true) {
  21622. module.exports = autoResize;
  21623. }
  21624. /***/ }),
  21625. /* 184 */
  21626. /***/ (function(module, exports, __webpack_require__) {
  21627. "use strict";
  21628. exports.__esModule = true;
  21629. var _element = __webpack_require__(0);
  21630. var _base = __webpack_require__(28);
  21631. var _base2 = _interopRequireDefault(_base);
  21632. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21633. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21634. 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; }
  21635. 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; }
  21636. /**
  21637. * A overlay that renders ALL available rows & columns positioned on top of the original Walkontable instance and all other overlays.
  21638. * Used for debugging purposes to see if the other overlays (that render only part of the rows & columns) are positioned correctly
  21639. *
  21640. * @class DebugOverlay
  21641. */
  21642. var DebugOverlay = function (_Overlay) {
  21643. _inherits(DebugOverlay, _Overlay);
  21644. /**
  21645. * @param {Walkontable} wotInstance
  21646. */
  21647. function DebugOverlay(wotInstance) {
  21648. _classCallCheck(this, DebugOverlay);
  21649. var _this = _possibleConstructorReturn(this, (DebugOverlay.__proto__ || Object.getPrototypeOf(DebugOverlay)).call(this, wotInstance));
  21650. _this.clone = _this.makeClone(_base2.default.CLONE_DEBUG);
  21651. _this.clone.wtTable.holder.style.opacity = 0.4;
  21652. _this.clone.wtTable.holder.style.textShadow = '0 0 2px #ff0000';
  21653. (0, _element.addClass)(_this.clone.wtTable.holder.parentNode, 'wtDebugVisible');
  21654. return _this;
  21655. }
  21656. return DebugOverlay;
  21657. }(_base2.default);
  21658. _base2.default.registerOverlay(_base2.default.CLONE_DEBUG, DebugOverlay);
  21659. exports.default = DebugOverlay;
  21660. /***/ }),
  21661. /* 185 */
  21662. /***/ (function(module, exports, __webpack_require__) {
  21663. "use strict";
  21664. exports.__esModule = true;
  21665. 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; }; }();
  21666. var _element = __webpack_require__(0);
  21667. var _base = __webpack_require__(28);
  21668. var _base2 = _interopRequireDefault(_base);
  21669. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21670. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21671. 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; }
  21672. 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; }
  21673. /**
  21674. * @class LeftOverlay
  21675. */
  21676. var LeftOverlay = function (_Overlay) {
  21677. _inherits(LeftOverlay, _Overlay);
  21678. /**
  21679. * @param {Walkontable} wotInstance
  21680. */
  21681. function LeftOverlay(wotInstance) {
  21682. _classCallCheck(this, LeftOverlay);
  21683. var _this = _possibleConstructorReturn(this, (LeftOverlay.__proto__ || Object.getPrototypeOf(LeftOverlay)).call(this, wotInstance));
  21684. _this.clone = _this.makeClone(_base2.default.CLONE_LEFT);
  21685. return _this;
  21686. }
  21687. /**
  21688. * Checks if overlay should be fully rendered
  21689. *
  21690. * @returns {Boolean}
  21691. */
  21692. _createClass(LeftOverlay, [{
  21693. key: 'shouldBeRendered',
  21694. value: function shouldBeRendered() {
  21695. return !!(this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length);
  21696. }
  21697. /**
  21698. * Updates the left overlay position
  21699. */
  21700. }, {
  21701. key: 'resetFixedPosition',
  21702. value: function resetFixedPosition() {
  21703. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  21704. // removed from DOM
  21705. return;
  21706. }
  21707. var overlayRoot = this.clone.wtTable.holder.parentNode;
  21708. var headerPosition = 0;
  21709. var preventOverflow = this.wot.getSetting('preventOverflow');
  21710. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'horizontal')) {
  21711. var box = this.wot.wtTable.hider.getBoundingClientRect();
  21712. var left = Math.ceil(box.left);
  21713. var right = Math.ceil(box.right);
  21714. var finalLeft = void 0;
  21715. var finalTop = void 0;
  21716. finalTop = this.wot.wtTable.hider.style.top;
  21717. finalTop = finalTop === '' ? 0 : finalTop;
  21718. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  21719. finalLeft = -left;
  21720. } else {
  21721. finalLeft = 0;
  21722. }
  21723. headerPosition = finalLeft;
  21724. finalLeft += 'px';
  21725. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  21726. } else {
  21727. headerPosition = this.getScrollPosition();
  21728. (0, _element.resetCssTransform)(overlayRoot);
  21729. }
  21730. this.adjustHeaderBordersPosition(headerPosition);
  21731. this.adjustElementsSize();
  21732. }
  21733. /**
  21734. * Sets the main overlay's horizontal scroll position
  21735. *
  21736. * @param {Number} pos
  21737. */
  21738. }, {
  21739. key: 'setScrollPosition',
  21740. value: function setScrollPosition(pos) {
  21741. if (this.mainTableScrollableElement === window) {
  21742. window.scrollTo(pos, (0, _element.getWindowScrollTop)());
  21743. } else {
  21744. this.mainTableScrollableElement.scrollLeft = pos;
  21745. }
  21746. }
  21747. /**
  21748. * Triggers onScroll hook callback
  21749. */
  21750. }, {
  21751. key: 'onScroll',
  21752. value: function onScroll() {
  21753. this.wot.getSetting('onScrollVertically');
  21754. }
  21755. /**
  21756. * Calculates total sum cells width
  21757. *
  21758. * @param {Number} from Column index which calculates started from
  21759. * @param {Number} to Column index where calculation is finished
  21760. * @returns {Number} Width sum
  21761. */
  21762. }, {
  21763. key: 'sumCellSizes',
  21764. value: function sumCellSizes(from, to) {
  21765. var sum = 0;
  21766. var defaultColumnWidth = this.wot.wtSettings.defaultColumnWidth;
  21767. while (from < to) {
  21768. sum += this.wot.wtTable.getStretchedColumnWidth(from) || defaultColumnWidth;
  21769. from++;
  21770. }
  21771. return sum;
  21772. }
  21773. /**
  21774. * Adjust overlay root element, childs and master table element sizes (width, height).
  21775. *
  21776. * @param {Boolean} [force=false]
  21777. */
  21778. }, {
  21779. key: 'adjustElementsSize',
  21780. value: function adjustElementsSize() {
  21781. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  21782. this.updateTrimmingContainer();
  21783. if (this.needFullRender || force) {
  21784. this.adjustRootElementSize();
  21785. this.adjustRootChildrenSize();
  21786. if (!force) {
  21787. this.areElementSizesAdjusted = true;
  21788. }
  21789. }
  21790. }
  21791. /**
  21792. * Adjust overlay root element size (width and height).
  21793. */
  21794. }, {
  21795. key: 'adjustRootElementSize',
  21796. value: function adjustRootElementSize() {
  21797. var masterHolder = this.wot.wtTable.holder;
  21798. var scrollbarHeight = masterHolder.clientHeight === masterHolder.offsetHeight ? 0 : (0, _element.getScrollbarWidth)();
  21799. var overlayRoot = this.clone.wtTable.holder.parentNode;
  21800. var overlayRootStyle = overlayRoot.style;
  21801. var preventOverflow = this.wot.getSetting('preventOverflow');
  21802. var tableWidth = void 0;
  21803. if (this.trimmingContainer !== window || preventOverflow === 'vertical') {
  21804. var height = this.wot.wtViewport.getWorkspaceHeight() - scrollbarHeight;
  21805. height = Math.min(height, (0, _element.innerHeight)(this.wot.wtTable.wtRootElement));
  21806. overlayRootStyle.height = height + 'px';
  21807. } else {
  21808. overlayRootStyle.height = '';
  21809. }
  21810. this.clone.wtTable.holder.style.height = overlayRootStyle.height;
  21811. tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  21812. overlayRootStyle.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  21813. }
  21814. /**
  21815. * Adjust overlay root childs size
  21816. */
  21817. }, {
  21818. key: 'adjustRootChildrenSize',
  21819. value: function adjustRootChildrenSize() {
  21820. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  21821. this.clone.wtTable.hider.style.height = this.hider.style.height;
  21822. this.clone.wtTable.holder.style.height = this.clone.wtTable.holder.parentNode.style.height;
  21823. if (scrollbarWidth === 0) {
  21824. scrollbarWidth = 30;
  21825. }
  21826. this.clone.wtTable.holder.style.width = parseInt(this.clone.wtTable.holder.parentNode.style.width, 10) + scrollbarWidth + 'px';
  21827. }
  21828. /**
  21829. * Adjust the overlay dimensions and position
  21830. */
  21831. }, {
  21832. key: 'applyToDOM',
  21833. value: function applyToDOM() {
  21834. var total = this.wot.getSetting('totalColumns');
  21835. if (!this.areElementSizesAdjusted) {
  21836. this.adjustElementsSize();
  21837. }
  21838. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  21839. this.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  21840. } else if (total === 0) {
  21841. this.spreader.style.left = '0';
  21842. } else {
  21843. throw new Error('Incorrect value of the columnsRenderCalculator');
  21844. }
  21845. this.spreader.style.right = '';
  21846. if (this.needFullRender) {
  21847. this.syncOverlayOffset();
  21848. }
  21849. }
  21850. /**
  21851. * Synchronize calculated top position to an element
  21852. */
  21853. }, {
  21854. key: 'syncOverlayOffset',
  21855. value: function syncOverlayOffset() {
  21856. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  21857. this.clone.wtTable.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  21858. } else {
  21859. this.clone.wtTable.spreader.style.top = '';
  21860. }
  21861. }
  21862. /**
  21863. * Scrolls horizontally to a column at the left edge of the viewport
  21864. *
  21865. * @param sourceCol {Number} Column index which you want to scroll to
  21866. * @param [beyondRendered=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  21867. */
  21868. }, {
  21869. key: 'scrollTo',
  21870. value: function scrollTo(sourceCol, beyondRendered) {
  21871. var newX = this.getTableParentOffset();
  21872. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  21873. var mainHolder = sourceInstance.wtTable.holder;
  21874. var scrollbarCompensation = 0;
  21875. if (beyondRendered && mainHolder.offsetWidth !== mainHolder.clientWidth) {
  21876. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  21877. }
  21878. if (beyondRendered) {
  21879. newX += this.sumCellSizes(0, sourceCol + 1);
  21880. newX -= this.wot.wtViewport.getViewportWidth();
  21881. } else {
  21882. newX += this.sumCellSizes(this.wot.getSetting('fixedColumnsLeft'), sourceCol);
  21883. }
  21884. newX += scrollbarCompensation;
  21885. this.setScrollPosition(newX);
  21886. }
  21887. /**
  21888. * Gets table parent left position
  21889. *
  21890. * @returns {Number}
  21891. */
  21892. }, {
  21893. key: 'getTableParentOffset',
  21894. value: function getTableParentOffset() {
  21895. var preventOverflow = this.wot.getSetting('preventOverflow');
  21896. var offset = 0;
  21897. if (!preventOverflow && this.trimmingContainer === window) {
  21898. offset = this.wot.wtTable.holderOffset.left;
  21899. }
  21900. return offset;
  21901. }
  21902. /**
  21903. * Gets the main overlay's horizontal scroll position
  21904. *
  21905. * @returns {Number} Main table's vertical scroll position
  21906. */
  21907. }, {
  21908. key: 'getScrollPosition',
  21909. value: function getScrollPosition() {
  21910. return (0, _element.getScrollLeft)(this.mainTableScrollableElement);
  21911. }
  21912. /**
  21913. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  21914. *
  21915. * @param {Number} position Header X position if trimming container is window or scroll top if not
  21916. */
  21917. }, {
  21918. key: 'adjustHeaderBordersPosition',
  21919. value: function adjustHeaderBordersPosition(position) {
  21920. var masterParent = this.wot.wtTable.holder.parentNode;
  21921. var rowHeaders = this.wot.getSetting('rowHeaders');
  21922. var fixedColumnsLeft = this.wot.getSetting('fixedColumnsLeft');
  21923. var totalRows = this.wot.getSetting('totalRows');
  21924. if (totalRows) {
  21925. (0, _element.removeClass)(masterParent, 'emptyRows');
  21926. } else {
  21927. (0, _element.addClass)(masterParent, 'emptyRows');
  21928. }
  21929. if (fixedColumnsLeft && !rowHeaders.length) {
  21930. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  21931. } else if (!fixedColumnsLeft && rowHeaders.length) {
  21932. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderLeft');
  21933. if (position) {
  21934. (0, _element.addClass)(masterParent, 'innerBorderLeft');
  21935. } else {
  21936. (0, _element.removeClass)(masterParent, 'innerBorderLeft');
  21937. }
  21938. if (!previousState && position || previousState && !position) {
  21939. this.wot.wtOverlays.adjustElementsSize();
  21940. }
  21941. }
  21942. }
  21943. }]);
  21944. return LeftOverlay;
  21945. }(_base2.default);
  21946. _base2.default.registerOverlay(_base2.default.CLONE_LEFT, LeftOverlay);
  21947. exports.default = LeftOverlay;
  21948. /***/ }),
  21949. /* 186 */
  21950. /***/ (function(module, exports, __webpack_require__) {
  21951. "use strict";
  21952. exports.__esModule = true;
  21953. 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; }; }();
  21954. var _element = __webpack_require__(0);
  21955. var _base = __webpack_require__(28);
  21956. var _base2 = _interopRequireDefault(_base);
  21957. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  21958. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  21959. 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; }
  21960. 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; }
  21961. /**
  21962. * @class TopOverlay
  21963. */
  21964. var TopOverlay = function (_Overlay) {
  21965. _inherits(TopOverlay, _Overlay);
  21966. /**
  21967. * @param {Walkontable} wotInstance
  21968. */
  21969. function TopOverlay(wotInstance) {
  21970. _classCallCheck(this, TopOverlay);
  21971. var _this = _possibleConstructorReturn(this, (TopOverlay.__proto__ || Object.getPrototypeOf(TopOverlay)).call(this, wotInstance));
  21972. _this.clone = _this.makeClone(_base2.default.CLONE_TOP);
  21973. return _this;
  21974. }
  21975. /**
  21976. * Checks if overlay should be fully rendered
  21977. *
  21978. * @returns {Boolean}
  21979. */
  21980. _createClass(TopOverlay, [{
  21981. key: 'shouldBeRendered',
  21982. value: function shouldBeRendered() {
  21983. return !!(this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length);
  21984. }
  21985. /**
  21986. * Updates the top overlay position
  21987. */
  21988. }, {
  21989. key: 'resetFixedPosition',
  21990. value: function resetFixedPosition() {
  21991. if (!this.needFullRender || !this.wot.wtTable.holder.parentNode) {
  21992. // removed from DOM
  21993. return;
  21994. }
  21995. var overlayRoot = this.clone.wtTable.holder.parentNode;
  21996. var headerPosition = 0;
  21997. var preventOverflow = this.wot.getSetting('preventOverflow');
  21998. if (this.trimmingContainer === window && (!preventOverflow || preventOverflow !== 'vertical')) {
  21999. var box = this.wot.wtTable.hider.getBoundingClientRect();
  22000. var top = Math.ceil(box.top);
  22001. var bottom = Math.ceil(box.bottom);
  22002. var finalLeft = void 0;
  22003. var finalTop = void 0;
  22004. finalLeft = this.wot.wtTable.hider.style.left;
  22005. finalLeft = finalLeft === '' ? 0 : finalLeft;
  22006. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  22007. finalTop = -top;
  22008. } else {
  22009. finalTop = 0;
  22010. }
  22011. headerPosition = finalTop;
  22012. finalTop += 'px';
  22013. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  22014. } else {
  22015. headerPosition = this.getScrollPosition();
  22016. (0, _element.resetCssTransform)(overlayRoot);
  22017. }
  22018. this.adjustHeaderBordersPosition(headerPosition);
  22019. this.adjustElementsSize();
  22020. }
  22021. /**
  22022. * Sets the main overlay's vertical scroll position
  22023. *
  22024. * @param {Number} pos
  22025. */
  22026. }, {
  22027. key: 'setScrollPosition',
  22028. value: function setScrollPosition(pos) {
  22029. if (this.mainTableScrollableElement === window) {
  22030. window.scrollTo((0, _element.getWindowScrollLeft)(), pos);
  22031. } else {
  22032. this.mainTableScrollableElement.scrollTop = pos;
  22033. }
  22034. }
  22035. /**
  22036. * Triggers onScroll hook callback
  22037. */
  22038. }, {
  22039. key: 'onScroll',
  22040. value: function onScroll() {
  22041. this.wot.getSetting('onScrollHorizontally');
  22042. }
  22043. /**
  22044. * Calculates total sum cells height
  22045. *
  22046. * @param {Number} from Row index which calculates started from
  22047. * @param {Number} to Row index where calculation is finished
  22048. * @returns {Number} Height sum
  22049. */
  22050. }, {
  22051. key: 'sumCellSizes',
  22052. value: function sumCellSizes(from, to) {
  22053. var sum = 0;
  22054. var defaultRowHeight = this.wot.wtSettings.settings.defaultRowHeight;
  22055. while (from < to) {
  22056. var height = this.wot.wtTable.getRowHeight(from);
  22057. sum += height === void 0 ? defaultRowHeight : height;
  22058. from++;
  22059. }
  22060. return sum;
  22061. }
  22062. /**
  22063. * Adjust overlay root element, childs and master table element sizes (width, height).
  22064. *
  22065. * @param {Boolean} [force=false]
  22066. */
  22067. }, {
  22068. key: 'adjustElementsSize',
  22069. value: function adjustElementsSize() {
  22070. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  22071. this.updateTrimmingContainer();
  22072. if (this.needFullRender || force) {
  22073. this.adjustRootElementSize();
  22074. this.adjustRootChildrenSize();
  22075. if (!force) {
  22076. this.areElementSizesAdjusted = true;
  22077. }
  22078. }
  22079. }
  22080. /**
  22081. * Adjust overlay root element size (width and height).
  22082. */
  22083. }, {
  22084. key: 'adjustRootElementSize',
  22085. value: function adjustRootElementSize() {
  22086. var masterHolder = this.wot.wtTable.holder;
  22087. var scrollbarWidth = masterHolder.clientWidth === masterHolder.offsetWidth ? 0 : (0, _element.getScrollbarWidth)();
  22088. var overlayRoot = this.clone.wtTable.holder.parentNode;
  22089. var overlayRootStyle = overlayRoot.style;
  22090. var preventOverflow = this.wot.getSetting('preventOverflow');
  22091. var tableHeight = void 0;
  22092. if (this.trimmingContainer !== window || preventOverflow === 'horizontal') {
  22093. var width = this.wot.wtViewport.getWorkspaceWidth() - scrollbarWidth;
  22094. width = Math.min(width, (0, _element.innerWidth)(this.wot.wtTable.wtRootElement));
  22095. overlayRootStyle.width = width + 'px';
  22096. } else {
  22097. overlayRootStyle.width = '';
  22098. }
  22099. this.clone.wtTable.holder.style.width = overlayRootStyle.width;
  22100. tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  22101. overlayRootStyle.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  22102. }
  22103. /**
  22104. * Adjust overlay root childs size
  22105. */
  22106. }, {
  22107. key: 'adjustRootChildrenSize',
  22108. value: function adjustRootChildrenSize() {
  22109. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  22110. this.clone.wtTable.hider.style.width = this.hider.style.width;
  22111. this.clone.wtTable.holder.style.width = this.clone.wtTable.holder.parentNode.style.width;
  22112. if (scrollbarWidth === 0) {
  22113. scrollbarWidth = 30;
  22114. }
  22115. this.clone.wtTable.holder.style.height = parseInt(this.clone.wtTable.holder.parentNode.style.height, 10) + scrollbarWidth + 'px';
  22116. }
  22117. /**
  22118. * Adjust the overlay dimensions and position
  22119. */
  22120. }, {
  22121. key: 'applyToDOM',
  22122. value: function applyToDOM() {
  22123. var total = this.wot.getSetting('totalRows');
  22124. if (!this.areElementSizesAdjusted) {
  22125. this.adjustElementsSize();
  22126. }
  22127. if (typeof this.wot.wtViewport.rowsRenderCalculator.startPosition === 'number') {
  22128. this.spreader.style.top = this.wot.wtViewport.rowsRenderCalculator.startPosition + 'px';
  22129. } else if (total === 0) {
  22130. // can happen if there are 0 rows
  22131. this.spreader.style.top = '0';
  22132. } else {
  22133. throw new Error('Incorrect value of the rowsRenderCalculator');
  22134. }
  22135. this.spreader.style.bottom = '';
  22136. if (this.needFullRender) {
  22137. this.syncOverlayOffset();
  22138. }
  22139. }
  22140. /**
  22141. * Synchronize calculated left position to an element
  22142. */
  22143. }, {
  22144. key: 'syncOverlayOffset',
  22145. value: function syncOverlayOffset() {
  22146. if (typeof this.wot.wtViewport.columnsRenderCalculator.startPosition === 'number') {
  22147. this.clone.wtTable.spreader.style.left = this.wot.wtViewport.columnsRenderCalculator.startPosition + 'px';
  22148. } else {
  22149. this.clone.wtTable.spreader.style.left = '';
  22150. }
  22151. }
  22152. /**
  22153. * Scrolls vertically to a row
  22154. *
  22155. * @param sourceRow {Number} Row index which you want to scroll to
  22156. * @param [bottomEdge=false] {Boolean} if `true`, scrolls according to the bottom edge (top edge is by default)
  22157. */
  22158. }, {
  22159. key: 'scrollTo',
  22160. value: function scrollTo(sourceRow, bottomEdge) {
  22161. var newY = this.getTableParentOffset();
  22162. var sourceInstance = this.wot.cloneSource ? this.wot.cloneSource : this.wot;
  22163. var mainHolder = sourceInstance.wtTable.holder;
  22164. var scrollbarCompensation = 0;
  22165. if (bottomEdge && mainHolder.offsetHeight !== mainHolder.clientHeight) {
  22166. scrollbarCompensation = (0, _element.getScrollbarWidth)();
  22167. }
  22168. if (bottomEdge) {
  22169. var fixedRowsBottom = this.wot.getSetting('fixedRowsBottom');
  22170. var fixedRowsTop = this.wot.getSetting('fixedRowsTop');
  22171. var totalRows = this.wot.getSetting('totalRows');
  22172. newY += this.sumCellSizes(0, sourceRow + 1);
  22173. newY -= this.wot.wtViewport.getViewportHeight() - this.sumCellSizes(totalRows - fixedRowsBottom, totalRows);
  22174. // Fix 1 pixel offset when cell is selected
  22175. newY += 1;
  22176. } else {
  22177. newY += this.sumCellSizes(this.wot.getSetting('fixedRowsTop'), sourceRow);
  22178. }
  22179. newY += scrollbarCompensation;
  22180. this.setScrollPosition(newY);
  22181. }
  22182. /**
  22183. * Gets table parent top position
  22184. *
  22185. * @returns {Number}
  22186. */
  22187. }, {
  22188. key: 'getTableParentOffset',
  22189. value: function getTableParentOffset() {
  22190. if (this.mainTableScrollableElement === window) {
  22191. return this.wot.wtTable.holderOffset.top;
  22192. }
  22193. return 0;
  22194. }
  22195. /**
  22196. * Gets the main overlay's vertical scroll position
  22197. *
  22198. * @returns {Number} Main table's vertical scroll position
  22199. */
  22200. }, {
  22201. key: 'getScrollPosition',
  22202. value: function getScrollPosition() {
  22203. return (0, _element.getScrollTop)(this.mainTableScrollableElement);
  22204. }
  22205. /**
  22206. * Redraw borders of selection
  22207. *
  22208. * @param {WalkontableSelection} selection Selection for redraw
  22209. */
  22210. }, {
  22211. key: 'redrawSelectionBorders',
  22212. value: function redrawSelectionBorders(selection) {
  22213. if (selection && selection.cellRange) {
  22214. var border = selection.getBorder(this.wot);
  22215. if (border) {
  22216. var corners = selection.getCorners();
  22217. border.disappear();
  22218. border.appear(corners);
  22219. }
  22220. }
  22221. }
  22222. /**
  22223. * Redrawing borders of all selections
  22224. */
  22225. }, {
  22226. key: 'redrawAllSelectionsBorders',
  22227. value: function redrawAllSelectionsBorders() {
  22228. var selections = this.wot.selections;
  22229. this.redrawSelectionBorders(selections.current);
  22230. this.redrawSelectionBorders(selections.area);
  22231. this.redrawSelectionBorders(selections.fill);
  22232. this.wot.wtTable.wot.wtOverlays.leftOverlay.refresh();
  22233. }
  22234. /**
  22235. * Adds css classes to hide the header border's header (cell-selection border hiding issue)
  22236. *
  22237. * @param {Number} position Header Y position if trimming container is window or scroll top if not
  22238. */
  22239. }, {
  22240. key: 'adjustHeaderBordersPosition',
  22241. value: function adjustHeaderBordersPosition(position) {
  22242. var masterParent = this.wot.wtTable.holder.parentNode;
  22243. var totalColumns = this.wot.getSetting('totalColumns');
  22244. if (totalColumns) {
  22245. (0, _element.removeClass)(masterParent, 'emptyColumns');
  22246. } else {
  22247. (0, _element.addClass)(masterParent, 'emptyColumns');
  22248. }
  22249. if (this.wot.getSetting('fixedRowsTop') === 0 && this.wot.getSetting('columnHeaders').length > 0) {
  22250. var previousState = (0, _element.hasClass)(masterParent, 'innerBorderTop');
  22251. if (position || this.wot.getSetting('totalRows') === 0) {
  22252. (0, _element.addClass)(masterParent, 'innerBorderTop');
  22253. } else {
  22254. (0, _element.removeClass)(masterParent, 'innerBorderTop');
  22255. }
  22256. if (!previousState && position || previousState && !position) {
  22257. this.wot.wtOverlays.adjustElementsSize();
  22258. // cell borders should be positioned once again,
  22259. // because we added / removed 1px border from table header
  22260. this.redrawAllSelectionsBorders();
  22261. }
  22262. }
  22263. // nasty workaround for double border in the header, TODO: find a pure-css solution
  22264. if (this.wot.getSetting('rowHeaders').length === 0) {
  22265. var secondHeaderCell = this.clone.wtTable.THEAD.querySelectorAll('th:nth-of-type(2)');
  22266. if (secondHeaderCell) {
  22267. for (var i = 0; i < secondHeaderCell.length; i++) {
  22268. secondHeaderCell[i].style['border-left-width'] = 0;
  22269. }
  22270. }
  22271. }
  22272. }
  22273. }]);
  22274. return TopOverlay;
  22275. }(_base2.default);
  22276. _base2.default.registerOverlay(_base2.default.CLONE_TOP, TopOverlay);
  22277. exports.default = TopOverlay;
  22278. /***/ }),
  22279. /* 187 */
  22280. /***/ (function(module, exports, __webpack_require__) {
  22281. "use strict";
  22282. exports.__esModule = true;
  22283. 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; }; }();
  22284. var _element = __webpack_require__(0);
  22285. var _base = __webpack_require__(28);
  22286. var _base2 = _interopRequireDefault(_base);
  22287. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22288. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22289. 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; }
  22290. 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; }
  22291. /**
  22292. * @class TopLeftCornerOverlay
  22293. */
  22294. var TopLeftCornerOverlay = function (_Overlay) {
  22295. _inherits(TopLeftCornerOverlay, _Overlay);
  22296. /**
  22297. * @param {Walkontable} wotInstance
  22298. */
  22299. function TopLeftCornerOverlay(wotInstance) {
  22300. _classCallCheck(this, TopLeftCornerOverlay);
  22301. var _this = _possibleConstructorReturn(this, (TopLeftCornerOverlay.__proto__ || Object.getPrototypeOf(TopLeftCornerOverlay)).call(this, wotInstance));
  22302. _this.clone = _this.makeClone(_base2.default.CLONE_TOP_LEFT_CORNER);
  22303. return _this;
  22304. }
  22305. /**
  22306. * Checks if overlay should be fully rendered
  22307. *
  22308. * @returns {Boolean}
  22309. */
  22310. _createClass(TopLeftCornerOverlay, [{
  22311. key: 'shouldBeRendered',
  22312. value: function shouldBeRendered() {
  22313. return !!((this.wot.getSetting('fixedRowsTop') || this.wot.getSetting('columnHeaders').length) && (this.wot.getSetting('fixedColumnsLeft') || this.wot.getSetting('rowHeaders').length));
  22314. }
  22315. /**
  22316. * Updates the corner overlay position
  22317. */
  22318. }, {
  22319. key: 'resetFixedPosition',
  22320. value: function resetFixedPosition() {
  22321. this.updateTrimmingContainer();
  22322. if (!this.wot.wtTable.holder.parentNode) {
  22323. // removed from DOM
  22324. return;
  22325. }
  22326. var overlayRoot = this.clone.wtTable.holder.parentNode;
  22327. var tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
  22328. var tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
  22329. var preventOverflow = this.wot.getSetting('preventOverflow');
  22330. if (this.trimmingContainer === window) {
  22331. var box = this.wot.wtTable.hider.getBoundingClientRect();
  22332. var top = Math.ceil(box.top);
  22333. var left = Math.ceil(box.left);
  22334. var bottom = Math.ceil(box.bottom);
  22335. var right = Math.ceil(box.right);
  22336. var finalLeft = '0';
  22337. var finalTop = '0';
  22338. if (!preventOverflow || preventOverflow === 'vertical') {
  22339. if (left < 0 && right - overlayRoot.offsetWidth > 0) {
  22340. finalLeft = -left + 'px';
  22341. }
  22342. }
  22343. if (!preventOverflow || preventOverflow === 'horizontal') {
  22344. if (top < 0 && bottom - overlayRoot.offsetHeight > 0) {
  22345. finalTop = -top + 'px';
  22346. }
  22347. }
  22348. (0, _element.setOverlayPosition)(overlayRoot, finalLeft, finalTop);
  22349. } else {
  22350. (0, _element.resetCssTransform)(overlayRoot);
  22351. }
  22352. overlayRoot.style.height = (tableHeight === 0 ? tableHeight : tableHeight + 4) + 'px';
  22353. overlayRoot.style.width = (tableWidth === 0 ? tableWidth : tableWidth + 4) + 'px';
  22354. }
  22355. }]);
  22356. return TopLeftCornerOverlay;
  22357. }(_base2.default);
  22358. _base2.default.registerOverlay(_base2.default.CLONE_TOP_LEFT_CORNER, TopLeftCornerOverlay);
  22359. exports.default = TopLeftCornerOverlay;
  22360. /***/ }),
  22361. /* 188 */
  22362. /***/ (function(module, exports, __webpack_require__) {
  22363. "use strict";
  22364. exports.__esModule = true;
  22365. 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; };
  22366. 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; }; }();
  22367. var _element = __webpack_require__(0);
  22368. var _border2 = __webpack_require__(135);
  22369. var _border3 = _interopRequireDefault(_border2);
  22370. var _coords = __webpack_require__(42);
  22371. var _coords2 = _interopRequireDefault(_coords);
  22372. var _range = __webpack_require__(68);
  22373. var _range2 = _interopRequireDefault(_range);
  22374. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22375. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  22376. /**
  22377. * @class Selection
  22378. */
  22379. var Selection = function () {
  22380. /**
  22381. * @param {Object} settings
  22382. * @param {CellRange} cellRange
  22383. */
  22384. function Selection(settings, cellRange) {
  22385. _classCallCheck(this, Selection);
  22386. this.settings = settings;
  22387. this.cellRange = cellRange || null;
  22388. this.instanceBorders = {};
  22389. }
  22390. /**
  22391. * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
  22392. * borders per instance
  22393. *
  22394. * @param {Walkontable} wotInstance
  22395. * @returns {Border}
  22396. */
  22397. _createClass(Selection, [{
  22398. key: 'getBorder',
  22399. value: function getBorder(wotInstance) {
  22400. if (this.instanceBorders[wotInstance.guid]) {
  22401. return this.instanceBorders[wotInstance.guid];
  22402. }
  22403. // where is this returned?
  22404. this.instanceBorders[wotInstance.guid] = new _border3.default(wotInstance, this.settings);
  22405. }
  22406. /**
  22407. * Checks if selection is empty
  22408. *
  22409. * @returns {Boolean}
  22410. */
  22411. }, {
  22412. key: 'isEmpty',
  22413. value: function isEmpty() {
  22414. return this.cellRange === null;
  22415. }
  22416. /**
  22417. * Adds a cell coords to the selection
  22418. *
  22419. * @param {CellCoords} coords
  22420. */
  22421. }, {
  22422. key: 'add',
  22423. value: function add(coords) {
  22424. if (this.isEmpty()) {
  22425. this.cellRange = new _range2.default(coords, coords, coords);
  22426. } else {
  22427. this.cellRange.expand(coords);
  22428. }
  22429. }
  22430. /**
  22431. * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
  22432. * information about success
  22433. *
  22434. * @param {CellCoords} oldCoords
  22435. * @param {CellCoords} newCoords
  22436. * @returns {Boolean}
  22437. */
  22438. }, {
  22439. key: 'replace',
  22440. value: function replace(oldCoords, newCoords) {
  22441. if (!this.isEmpty()) {
  22442. if (this.cellRange.from.isEqual(oldCoords)) {
  22443. this.cellRange.from = newCoords;
  22444. return true;
  22445. }
  22446. if (this.cellRange.to.isEqual(oldCoords)) {
  22447. this.cellRange.to = newCoords;
  22448. return true;
  22449. }
  22450. }
  22451. return false;
  22452. }
  22453. /**
  22454. * Clears selection
  22455. */
  22456. }, {
  22457. key: 'clear',
  22458. value: function clear() {
  22459. this.cellRange = null;
  22460. }
  22461. /**
  22462. * Returns the top left (TL) and bottom right (BR) selection coordinates
  22463. *
  22464. * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`
  22465. */
  22466. }, {
  22467. key: 'getCorners',
  22468. value: function getCorners() {
  22469. var topLeft = this.cellRange.getTopLeftCorner();
  22470. var bottomRight = this.cellRange.getBottomRightCorner();
  22471. return [topLeft.row, topLeft.col, bottomRight.row, bottomRight.col];
  22472. }
  22473. /**
  22474. * Adds class name to cell element at given coords
  22475. *
  22476. * @param {Walkontable} wotInstance Walkontable instance
  22477. * @param {Number} sourceRow Cell row coord
  22478. * @param {Number} sourceColumn Cell column coord
  22479. * @param {String} className Class name
  22480. */
  22481. }, {
  22482. key: 'addClassAtCoords',
  22483. value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
  22484. var TD = wotInstance.wtTable.getCell(new _coords2.default(sourceRow, sourceColumn));
  22485. if ((typeof TD === 'undefined' ? 'undefined' : _typeof(TD)) === 'object') {
  22486. (0, _element.addClass)(TD, className);
  22487. }
  22488. }
  22489. /**
  22490. * @param wotInstance
  22491. */
  22492. }, {
  22493. key: 'draw',
  22494. value: function draw(wotInstance) {
  22495. if (this.isEmpty()) {
  22496. if (this.settings.border) {
  22497. var border = this.getBorder(wotInstance);
  22498. if (border) {
  22499. border.disappear();
  22500. }
  22501. }
  22502. return;
  22503. }
  22504. var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
  22505. var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
  22506. var corners = this.getCorners();
  22507. var sourceRow = void 0,
  22508. sourceCol = void 0,
  22509. TH = void 0;
  22510. for (var column = 0; column < renderedColumns; column++) {
  22511. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
  22512. if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  22513. TH = wotInstance.wtTable.getColumnHeader(sourceCol);
  22514. if (TH) {
  22515. var newClasses = [];
  22516. if (this.settings.highlightHeaderClassName) {
  22517. newClasses.push(this.settings.highlightHeaderClassName);
  22518. }
  22519. if (this.settings.highlightColumnClassName) {
  22520. newClasses.push(this.settings.highlightColumnClassName);
  22521. }
  22522. (0, _element.addClass)(TH, newClasses);
  22523. }
  22524. }
  22525. }
  22526. for (var row = 0; row < renderedRows; row++) {
  22527. sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
  22528. if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  22529. TH = wotInstance.wtTable.getRowHeader(sourceRow);
  22530. if (TH) {
  22531. var _newClasses = [];
  22532. if (this.settings.highlightHeaderClassName) {
  22533. _newClasses.push(this.settings.highlightHeaderClassName);
  22534. }
  22535. if (this.settings.highlightRowClassName) {
  22536. _newClasses.push(this.settings.highlightRowClassName);
  22537. }
  22538. (0, _element.addClass)(TH, _newClasses);
  22539. }
  22540. }
  22541. for (var _column = 0; _column < renderedColumns; _column++) {
  22542. sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
  22543. if (sourceRow >= corners[0] && sourceRow <= corners[2] && sourceCol >= corners[1] && sourceCol <= corners[3]) {
  22544. // selected cell
  22545. if (this.settings.className) {
  22546. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.className);
  22547. }
  22548. } else if (sourceRow >= corners[0] && sourceRow <= corners[2]) {
  22549. // selection is in this row
  22550. if (this.settings.highlightRowClassName) {
  22551. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightRowClassName);
  22552. }
  22553. } else if (sourceCol >= corners[1] && sourceCol <= corners[3]) {
  22554. // selection is in this column
  22555. if (this.settings.highlightColumnClassName) {
  22556. this.addClassAtCoords(wotInstance, sourceRow, sourceCol, this.settings.highlightColumnClassName);
  22557. }
  22558. }
  22559. }
  22560. }
  22561. wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
  22562. if (this.settings.border) {
  22563. var _border = this.getBorder(wotInstance);
  22564. if (_border) {
  22565. // warning! border.appear modifies corners!
  22566. _border.appear(corners);
  22567. }
  22568. }
  22569. }
  22570. }]);
  22571. return Selection;
  22572. }();
  22573. exports.default = Selection;
  22574. /***/ }),
  22575. /* 189 */
  22576. /***/ (function(module, exports, __webpack_require__) {
  22577. "use strict";
  22578. exports.__esModule = true;
  22579. var _editors = __webpack_require__(14);
  22580. var _renderers = __webpack_require__(9);
  22581. var _validators = __webpack_require__(26);
  22582. var CELL_TYPE = 'autocomplete';
  22583. exports.default = {
  22584. editor: (0, _editors.getEditor)(CELL_TYPE),
  22585. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  22586. validator: (0, _validators.getValidator)(CELL_TYPE)
  22587. };
  22588. /***/ }),
  22589. /* 190 */
  22590. /***/ (function(module, exports, __webpack_require__) {
  22591. "use strict";
  22592. exports.__esModule = true;
  22593. var _editors = __webpack_require__(14);
  22594. var _renderers = __webpack_require__(9);
  22595. var CELL_TYPE = 'checkbox';
  22596. exports.default = {
  22597. editor: (0, _editors.getEditor)(CELL_TYPE),
  22598. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  22599. };
  22600. /***/ }),
  22601. /* 191 */
  22602. /***/ (function(module, exports, __webpack_require__) {
  22603. "use strict";
  22604. exports.__esModule = true;
  22605. var _editors = __webpack_require__(14);
  22606. var _renderers = __webpack_require__(9);
  22607. var _validators = __webpack_require__(26);
  22608. var CELL_TYPE = 'date';
  22609. exports.default = {
  22610. editor: (0, _editors.getEditor)(CELL_TYPE),
  22611. // displays small gray arrow on right side of the cell
  22612. renderer: (0, _renderers.getRenderer)('autocomplete'),
  22613. validator: (0, _validators.getValidator)(CELL_TYPE)
  22614. };
  22615. /***/ }),
  22616. /* 192 */
  22617. /***/ (function(module, exports, __webpack_require__) {
  22618. "use strict";
  22619. exports.__esModule = true;
  22620. var _editors = __webpack_require__(14);
  22621. var _renderers = __webpack_require__(9);
  22622. var _validators = __webpack_require__(26);
  22623. var CELL_TYPE = 'dropdown';
  22624. exports.default = {
  22625. editor: (0, _editors.getEditor)(CELL_TYPE),
  22626. // displays small gray arrow on right side of the cell
  22627. renderer: (0, _renderers.getRenderer)('autocomplete'),
  22628. validator: (0, _validators.getValidator)('autocomplete')
  22629. };
  22630. /***/ }),
  22631. /* 193 */
  22632. /***/ (function(module, exports, __webpack_require__) {
  22633. "use strict";
  22634. exports.__esModule = true;
  22635. var _editors = __webpack_require__(14);
  22636. var _renderers = __webpack_require__(9);
  22637. var CELL_TYPE = 'handsontable';
  22638. exports.default = {
  22639. editor: (0, _editors.getEditor)(CELL_TYPE),
  22640. // displays small gray arrow on right side of the cell
  22641. renderer: (0, _renderers.getRenderer)('autocomplete')
  22642. };
  22643. /***/ }),
  22644. /* 194 */
  22645. /***/ (function(module, exports, __webpack_require__) {
  22646. "use strict";
  22647. exports.__esModule = true;
  22648. var _editors = __webpack_require__(14);
  22649. var _renderers = __webpack_require__(9);
  22650. var _validators = __webpack_require__(26);
  22651. var CELL_TYPE = 'numeric';
  22652. exports.default = {
  22653. editor: (0, _editors.getEditor)(CELL_TYPE),
  22654. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  22655. validator: (0, _validators.getValidator)(CELL_TYPE),
  22656. dataType: 'number'
  22657. };
  22658. /***/ }),
  22659. /* 195 */
  22660. /***/ (function(module, exports, __webpack_require__) {
  22661. "use strict";
  22662. exports.__esModule = true;
  22663. var _editors = __webpack_require__(14);
  22664. var _renderers = __webpack_require__(9);
  22665. var _validators = __webpack_require__(26);
  22666. var CELL_TYPE = 'password';
  22667. exports.default = {
  22668. editor: (0, _editors.getEditor)(CELL_TYPE),
  22669. renderer: (0, _renderers.getRenderer)(CELL_TYPE),
  22670. copyable: false
  22671. };
  22672. /***/ }),
  22673. /* 196 */
  22674. /***/ (function(module, exports, __webpack_require__) {
  22675. "use strict";
  22676. exports.__esModule = true;
  22677. var _browser = __webpack_require__(25);
  22678. var _editors = __webpack_require__(14);
  22679. var _renderers = __webpack_require__(9);
  22680. var CELL_TYPE = 'text';
  22681. exports.default = {
  22682. editor: (0, _browser.isMobileBrowser)() ? (0, _editors.getEditor)('mobile') : (0, _editors.getEditor)(CELL_TYPE),
  22683. renderer: (0, _renderers.getRenderer)(CELL_TYPE)
  22684. };
  22685. /***/ }),
  22686. /* 197 */
  22687. /***/ (function(module, exports, __webpack_require__) {
  22688. "use strict";
  22689. exports.__esModule = true;
  22690. var _editors = __webpack_require__(14);
  22691. var _renderers = __webpack_require__(9);
  22692. var _validators = __webpack_require__(26);
  22693. var CELL_TYPE = 'time';
  22694. exports.default = {
  22695. editor: (0, _editors.getEditor)('text'),
  22696. // displays small gray arrow on right side of the cell
  22697. renderer: (0, _renderers.getRenderer)('text'),
  22698. validator: (0, _validators.getValidator)(CELL_TYPE)
  22699. };
  22700. /***/ }),
  22701. /* 198 */
  22702. /***/ (function(module, exports, __webpack_require__) {
  22703. "use strict";
  22704. exports.__esModule = true;
  22705. 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; };
  22706. var _SheetClip = __webpack_require__(133);
  22707. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  22708. var _data = __webpack_require__(64);
  22709. var _setting = __webpack_require__(65);
  22710. var _object = __webpack_require__(1);
  22711. var _array = __webpack_require__(2);
  22712. var _interval = __webpack_require__(271);
  22713. var _interval2 = _interopRequireDefault(_interval);
  22714. var _number = __webpack_require__(6);
  22715. var _multiMap = __webpack_require__(209);
  22716. var _multiMap2 = _interopRequireDefault(_multiMap);
  22717. var _pluginHooks = __webpack_require__(8);
  22718. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  22719. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  22720. /**
  22721. * Utility class that gets and saves data from/to the data source using mapping of columns numbers to object property names
  22722. * @todo refactor arguments of methods getRange, getText to be numbers (not objects)
  22723. * @todo remove priv, GridSettings from object constructor
  22724. *
  22725. * @param {Object} instance Instance of Handsontable
  22726. * @param {*} priv
  22727. * @param {*} GridSettings Grid settings
  22728. * @util
  22729. * @class DataMap
  22730. */
  22731. function DataMap(instance, priv, GridSettings) {
  22732. var _this = this;
  22733. this.instance = instance;
  22734. this.priv = priv;
  22735. this.GridSettings = GridSettings;
  22736. this.dataSource = this.instance.getSettings().data;
  22737. this.cachedLength = null;
  22738. this.skipCache = false;
  22739. this.latestSourceRowsCount = 0;
  22740. if (this.dataSource && this.dataSource[0]) {
  22741. this.duckSchema = this.recursiveDuckSchema(this.dataSource[0]);
  22742. } else {
  22743. this.duckSchema = {};
  22744. }
  22745. this.createMap();
  22746. this.interval = _interval2.default.create(function () {
  22747. return _this.clearLengthCache();
  22748. }, '15fps');
  22749. this.instance.addHook('skipLengthCache', function (delay) {
  22750. return _this.onSkipLengthCache(delay);
  22751. });
  22752. this.onSkipLengthCache(500);
  22753. }
  22754. DataMap.prototype.DESTINATION_RENDERER = 1;
  22755. DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR = 2;
  22756. /**
  22757. * @param {Object|Array} object
  22758. * @returns {Object|Array}
  22759. */
  22760. DataMap.prototype.recursiveDuckSchema = function (object) {
  22761. return (0, _object.duckSchema)(object);
  22762. };
  22763. /**
  22764. * @param {Object} schema
  22765. * @param {Number} lastCol
  22766. * @param {Number} parent
  22767. * @returns {Number}
  22768. */
  22769. DataMap.prototype.recursiveDuckColumns = function (schema, lastCol, parent) {
  22770. var prop, i;
  22771. if (typeof lastCol === 'undefined') {
  22772. lastCol = 0;
  22773. parent = '';
  22774. }
  22775. if ((typeof schema === 'undefined' ? 'undefined' : _typeof(schema)) === 'object' && !Array.isArray(schema)) {
  22776. for (i in schema) {
  22777. if ((0, _object.hasOwnProperty)(schema, i)) {
  22778. if (schema[i] === null) {
  22779. prop = parent + i;
  22780. this.colToPropCache.push(prop);
  22781. this.propToColCache.set(prop, lastCol);
  22782. lastCol++;
  22783. } else {
  22784. lastCol = this.recursiveDuckColumns(schema[i], lastCol, i + '.');
  22785. }
  22786. }
  22787. }
  22788. }
  22789. return lastCol;
  22790. };
  22791. DataMap.prototype.createMap = function () {
  22792. var i = void 0;
  22793. var schema = this.getSchema();
  22794. if (typeof schema === 'undefined') {
  22795. throw new Error('trying to create `columns` definition but you didn\'t provide `schema` nor `data`');
  22796. }
  22797. this.colToPropCache = [];
  22798. this.propToColCache = new _multiMap2.default();
  22799. var columns = this.instance.getSettings().columns;
  22800. if (columns) {
  22801. var maxCols = this.instance.getSettings().maxCols;
  22802. var columnsLen = Math.min(maxCols, columns.length);
  22803. var filteredIndex = 0;
  22804. var columnsAsFunc = false;
  22805. var schemaLen = (0, _object.deepObjectSize)(schema);
  22806. if (typeof columns === 'function') {
  22807. columnsLen = schemaLen > 0 ? schemaLen : this.instance.countSourceCols();
  22808. columnsAsFunc = true;
  22809. }
  22810. for (i = 0; i < columnsLen; i++) {
  22811. var column = columnsAsFunc ? columns(i) : columns[i];
  22812. if ((0, _object.isObject)(column)) {
  22813. if (typeof column.data !== 'undefined') {
  22814. var index = columnsAsFunc ? filteredIndex : i;
  22815. this.colToPropCache[index] = column.data;
  22816. this.propToColCache.set(column.data, index);
  22817. }
  22818. filteredIndex++;
  22819. }
  22820. }
  22821. } else {
  22822. this.recursiveDuckColumns(schema);
  22823. }
  22824. };
  22825. /**
  22826. * Returns property name that corresponds with the given column index.
  22827. *
  22828. * @param {Number} col Visual column index.
  22829. * @returns {Number} Physical column index.
  22830. */
  22831. DataMap.prototype.colToProp = function (col) {
  22832. col = this.instance.runHooks('modifyCol', col);
  22833. if (!isNaN(col) && this.colToPropCache && typeof this.colToPropCache[col] !== 'undefined') {
  22834. return this.colToPropCache[col];
  22835. }
  22836. return col;
  22837. };
  22838. /**
  22839. * @param {Object} prop
  22840. * @fires Hooks#modifyCol
  22841. * @returns {*}
  22842. */
  22843. DataMap.prototype.propToCol = function (prop) {
  22844. var col;
  22845. if (typeof this.propToColCache.get(prop) === 'undefined') {
  22846. col = prop;
  22847. } else {
  22848. col = this.propToColCache.get(prop);
  22849. }
  22850. col = this.instance.runHooks('unmodifyCol', col);
  22851. return col;
  22852. };
  22853. /**
  22854. * @returns {Object}
  22855. */
  22856. DataMap.prototype.getSchema = function () {
  22857. var schema = this.instance.getSettings().dataSchema;
  22858. if (schema) {
  22859. if (typeof schema === 'function') {
  22860. return schema();
  22861. }
  22862. return schema;
  22863. }
  22864. return this.duckSchema;
  22865. };
  22866. /**
  22867. * Creates row at the bottom of the data array.
  22868. *
  22869. * @param {Number} [index] Physical index of the row before which the new row will be inserted.
  22870. * @param {Number} [amount] An amount of rows to add.
  22871. * @param {String} [source] Source of method call.
  22872. * @fires Hooks#afterCreateRow
  22873. * @returns {Number} Returns number of created rows.
  22874. */
  22875. DataMap.prototype.createRow = function (index, amount, source) {
  22876. var row,
  22877. colCount = this.instance.countCols(),
  22878. numberOfCreatedRows = 0,
  22879. currentIndex;
  22880. if (!amount) {
  22881. amount = 1;
  22882. }
  22883. if (typeof index !== 'number' || index >= this.instance.countSourceRows()) {
  22884. index = this.instance.countSourceRows();
  22885. }
  22886. this.instance.runHooks('beforeCreateRow', index, amount, source);
  22887. currentIndex = index;
  22888. var maxRows = this.instance.getSettings().maxRows;
  22889. while (numberOfCreatedRows < amount && this.instance.countSourceRows() < maxRows) {
  22890. if (this.instance.dataType === 'array') {
  22891. if (this.instance.getSettings().dataSchema) {
  22892. // Clone template array
  22893. row = (0, _object.deepClone)(this.getSchema());
  22894. } else {
  22895. row = [];
  22896. /* eslint-disable no-loop-func */
  22897. (0, _number.rangeEach)(colCount - 1, function () {
  22898. return row.push(null);
  22899. });
  22900. }
  22901. } else if (this.instance.dataType === 'function') {
  22902. row = this.instance.getSettings().dataSchema(index);
  22903. } else {
  22904. row = {};
  22905. (0, _object.deepExtend)(row, this.getSchema());
  22906. }
  22907. if (index === this.instance.countSourceRows()) {
  22908. this.dataSource.push(row);
  22909. } else {
  22910. this.spliceData(index, 0, row);
  22911. }
  22912. numberOfCreatedRows++;
  22913. currentIndex++;
  22914. }
  22915. this.instance.runHooks('afterCreateRow', index, numberOfCreatedRows, source);
  22916. this.instance.forceFullRender = true; // used when data was changed
  22917. return numberOfCreatedRows;
  22918. };
  22919. /**
  22920. * Creates col at the right of the data array.
  22921. *
  22922. * @param {Number} [index] Visual index of the column before which the new column will be inserted
  22923. * @param {Number} [amount] An amount of columns to add.
  22924. * @param {String} [source] Source of method call.
  22925. * @fires Hooks#afterCreateCol
  22926. * @returns {Number} Returns number of created columns
  22927. */
  22928. DataMap.prototype.createCol = function (index, amount, source) {
  22929. if (!this.instance.isColumnModificationAllowed()) {
  22930. 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.');
  22931. }
  22932. var rlen = this.instance.countSourceRows(),
  22933. data = this.dataSource,
  22934. constructor,
  22935. numberOfCreatedCols = 0,
  22936. currentIndex;
  22937. if (!amount) {
  22938. amount = 1;
  22939. }
  22940. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  22941. index = this.instance.countCols();
  22942. }
  22943. this.instance.runHooks('beforeCreateCol', index, amount, source);
  22944. currentIndex = index;
  22945. var maxCols = this.instance.getSettings().maxCols;
  22946. while (numberOfCreatedCols < amount && this.instance.countCols() < maxCols) {
  22947. constructor = (0, _setting.columnFactory)(this.GridSettings, this.priv.columnsSettingConflicts);
  22948. if (typeof index !== 'number' || index >= this.instance.countCols()) {
  22949. if (rlen > 0) {
  22950. for (var r = 0; r < rlen; r++) {
  22951. if (typeof data[r] === 'undefined') {
  22952. data[r] = [];
  22953. }
  22954. data[r].push(null);
  22955. }
  22956. } else {
  22957. data.push([null]);
  22958. }
  22959. // Add new column constructor
  22960. this.priv.columnSettings.push(constructor);
  22961. } else {
  22962. for (var _r = 0; _r < rlen; _r++) {
  22963. data[_r].splice(currentIndex, 0, null);
  22964. }
  22965. // Add new column constructor at given index
  22966. this.priv.columnSettings.splice(currentIndex, 0, constructor);
  22967. }
  22968. numberOfCreatedCols++;
  22969. currentIndex++;
  22970. }
  22971. this.instance.runHooks('afterCreateCol', index, numberOfCreatedCols, source);
  22972. this.instance.forceFullRender = true; // used when data was changed
  22973. return numberOfCreatedCols;
  22974. };
  22975. /**
  22976. * Removes row from the data array.
  22977. *
  22978. * @param {Number} [index] Visual index of the row to be removed. If not provided, the last row will be removed
  22979. * @param {Number} [amount] Amount of the rows to be removed. If not provided, one row will be removed
  22980. * @param {String} [source] Source of method call.
  22981. * @fires Hooks#beforeRemoveRow
  22982. * @fires Hooks#afterRemoveRow
  22983. */
  22984. DataMap.prototype.removeRow = function (index, amount, source) {
  22985. if (!amount) {
  22986. amount = 1;
  22987. }
  22988. if (typeof index !== 'number') {
  22989. index = -amount;
  22990. }
  22991. amount = this.instance.runHooks('modifyRemovedAmount', amount, index);
  22992. index = (this.instance.countSourceRows() + index) % this.instance.countSourceRows();
  22993. var logicRows = this.visualRowsToPhysical(index, amount);
  22994. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveRow', index, amount, logicRows, source);
  22995. if (actionWasNotCancelled === false) {
  22996. return;
  22997. }
  22998. var data = this.dataSource;
  22999. var newData = void 0;
  23000. newData = this.filterData(index, amount);
  23001. if (newData) {
  23002. data.length = 0;
  23003. Array.prototype.push.apply(data, newData);
  23004. }
  23005. this.instance.runHooks('afterRemoveRow', index, amount, logicRows, source);
  23006. this.instance.forceFullRender = true; // used when data was changed
  23007. };
  23008. /**
  23009. * Removes column from the data array.
  23010. *
  23011. * @param {Number} [index] Visual index of the column to be removed. If not provided, the last column will be removed
  23012. * @param {Number} [amount] Amount of the columns to be removed. If not provided, one column will be removed
  23013. * @param {String} [source] Source of method call.
  23014. * @fires Hooks#beforeRemoveCol
  23015. * @fires Hooks#afterRemoveCol
  23016. */
  23017. DataMap.prototype.removeCol = function (index, amount, source) {
  23018. if (this.instance.dataType === 'object' || this.instance.getSettings().columns) {
  23019. throw new Error('cannot remove column with object data source or columns option specified');
  23020. }
  23021. if (!amount) {
  23022. amount = 1;
  23023. }
  23024. if (typeof index !== 'number') {
  23025. index = -amount;
  23026. }
  23027. index = (this.instance.countCols() + index) % this.instance.countCols();
  23028. var logicColumns = this.visualColumnsToPhysical(index, amount);
  23029. var descendingLogicColumns = logicColumns.slice(0).sort(function (a, b) {
  23030. return b - a;
  23031. });
  23032. var actionWasNotCancelled = this.instance.runHooks('beforeRemoveCol', index, amount, logicColumns, source);
  23033. if (actionWasNotCancelled === false) {
  23034. return;
  23035. }
  23036. var isTableUniform = true;
  23037. var removedColumnsCount = descendingLogicColumns.length;
  23038. var data = this.dataSource;
  23039. for (var c = 0; c < removedColumnsCount; c++) {
  23040. if (isTableUniform && logicColumns[0] !== logicColumns[c] - c) {
  23041. isTableUniform = false;
  23042. }
  23043. }
  23044. if (isTableUniform) {
  23045. for (var r = 0, rlen = this.instance.countSourceRows(); r < rlen; r++) {
  23046. data[r].splice(logicColumns[0], amount);
  23047. }
  23048. } else {
  23049. for (var _r2 = 0, _rlen = this.instance.countSourceRows(); _r2 < _rlen; _r2++) {
  23050. for (var _c = 0; _c < removedColumnsCount; _c++) {
  23051. data[_r2].splice(descendingLogicColumns[_c], 1);
  23052. }
  23053. }
  23054. for (var _c2 = 0; _c2 < removedColumnsCount; _c2++) {
  23055. this.priv.columnSettings.splice(logicColumns[_c2], 1);
  23056. }
  23057. }
  23058. this.instance.runHooks('afterRemoveCol', index, amount, logicColumns, source);
  23059. this.instance.forceFullRender = true; // used when data was changed
  23060. };
  23061. /**
  23062. * Add/Removes data from the column.
  23063. *
  23064. * @param {Number} col Physical index of column in which do you want to do splice
  23065. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end
  23066. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed
  23067. * @returns {Array} Returns removed portion of columns
  23068. */
  23069. DataMap.prototype.spliceCol = function (col, index, amount /* , elements... */) {
  23070. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  23071. var colData = this.instance.getDataAtCol(col);
  23072. var removed = colData.slice(index, index + amount);
  23073. var after = colData.slice(index + amount);
  23074. (0, _array.extendArray)(elements, after);
  23075. var i = 0;
  23076. while (i < amount) {
  23077. elements.push(null); // add null in place of removed elements
  23078. i++;
  23079. }
  23080. (0, _array.to2dArray)(elements);
  23081. this.instance.populateFromArray(index, col, elements, null, null, 'spliceCol');
  23082. return removed;
  23083. };
  23084. /**
  23085. * Add/Removes data from the row.
  23086. *
  23087. * @param {Number} row Physical index of row in which do you want to do splice
  23088. * @param {Number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
  23089. * @param {Number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
  23090. * @returns {Array} Returns removed portion of rows
  23091. */
  23092. DataMap.prototype.spliceRow = function (row, index, amount /* , elements... */) {
  23093. var elements = arguments.length >= 4 ? [].slice.call(arguments, 3) : [];
  23094. var rowData = this.instance.getSourceDataAtRow(row);
  23095. var removed = rowData.slice(index, index + amount);
  23096. var after = rowData.slice(index + amount);
  23097. (0, _array.extendArray)(elements, after);
  23098. var i = 0;
  23099. while (i < amount) {
  23100. elements.push(null); // add null in place of removed elements
  23101. i++;
  23102. }
  23103. this.instance.populateFromArray(row, index, [elements], null, null, 'spliceRow');
  23104. return removed;
  23105. };
  23106. /**
  23107. * Add/remove row(s) to/from the data source.
  23108. *
  23109. * @param {Number} index Physical index of the element to remove.
  23110. * @param {Number} amount Number of rows to add/remove.
  23111. * @param {Object} element Row to add.
  23112. */
  23113. DataMap.prototype.spliceData = function (index, amount, element) {
  23114. var continueSplicing = this.instance.runHooks('beforeDataSplice', index, amount, element);
  23115. if (continueSplicing !== false) {
  23116. this.dataSource.splice(index, amount, element);
  23117. }
  23118. };
  23119. /**
  23120. * Filter unwanted data elements from the data source.
  23121. *
  23122. * @param {Number} index Visual index of the element to remove.
  23123. * @param {Number} amount Number of rows to add/remove.
  23124. * @returns {Array}
  23125. */
  23126. DataMap.prototype.filterData = function (index, amount) {
  23127. var physicalRows = this.visualRowsToPhysical(index, amount);
  23128. var continueSplicing = this.instance.runHooks('beforeDataFilter', index, amount, physicalRows);
  23129. if (continueSplicing !== false) {
  23130. var newData = this.dataSource.filter(function (row, index) {
  23131. return physicalRows.indexOf(index) == -1;
  23132. });
  23133. return newData;
  23134. }
  23135. };
  23136. /**
  23137. * Returns single value from the data array.
  23138. *
  23139. * @param {Number} row Visual row index.
  23140. * @param {Number} prop
  23141. */
  23142. DataMap.prototype.get = function (row, prop) {
  23143. row = this.instance.runHooks('modifyRow', row);
  23144. var dataRow = this.dataSource[row];
  23145. // TODO: To remove, use 'modifyData' hook instead (see below)
  23146. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  23147. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  23148. //
  23149. var value = null;
  23150. // try to get value under property `prop` (includes dot)
  23151. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  23152. value = dataRow[prop];
  23153. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  23154. var sliced = prop.split('.');
  23155. var out = dataRow;
  23156. if (!out) {
  23157. return null;
  23158. }
  23159. for (var i = 0, ilen = sliced.length; i < ilen; i++) {
  23160. out = out[sliced[i]];
  23161. if (typeof out === 'undefined') {
  23162. return null;
  23163. }
  23164. }
  23165. value = out;
  23166. } else if (typeof prop === 'function') {
  23167. /**
  23168. * allows for interacting with complex structures, for example
  23169. * d3/jQuery getter/setter properties:
  23170. *
  23171. * {columns: [{
  23172. * data: function(row, value){
  23173. * if(arguments.length === 1){
  23174. * return row.property();
  23175. * }
  23176. * row.property(value);
  23177. * }
  23178. * }]}
  23179. */
  23180. value = prop(this.dataSource.slice(row, row + 1)[0]);
  23181. }
  23182. if (this.instance.hasHook('modifyData')) {
  23183. var valueHolder = (0, _object.createObjectPropListener)(value);
  23184. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'get');
  23185. if (valueHolder.isTouched()) {
  23186. value = valueHolder.value;
  23187. }
  23188. }
  23189. return value;
  23190. };
  23191. var copyableLookup = (0, _data.cellMethodLookupFactory)('copyable', false);
  23192. /**
  23193. * Returns single value from the data array (intended for clipboard copy to an external application).
  23194. *
  23195. * @param {Number} row Physical row index.
  23196. * @param {Number} prop
  23197. * @returns {String}
  23198. */
  23199. DataMap.prototype.getCopyable = function (row, prop) {
  23200. if (copyableLookup.call(this.instance, row, this.propToCol(prop))) {
  23201. return this.get(row, prop);
  23202. }
  23203. return '';
  23204. };
  23205. /**
  23206. * Saves single value to the data array.
  23207. *
  23208. * @param {Number} row Visual row index.
  23209. * @param {Number} prop
  23210. * @param {String} value
  23211. * @param {String} [source] Source of hook runner.
  23212. */
  23213. DataMap.prototype.set = function (row, prop, value, source) {
  23214. row = this.instance.runHooks('modifyRow', row, source || 'datamapGet');
  23215. var dataRow = this.dataSource[row];
  23216. // TODO: To remove, use 'modifyData' hook instead (see below)
  23217. var modifiedRowData = this.instance.runHooks('modifyRowData', row);
  23218. dataRow = isNaN(modifiedRowData) ? modifiedRowData : dataRow;
  23219. //
  23220. if (this.instance.hasHook('modifyData')) {
  23221. var valueHolder = (0, _object.createObjectPropListener)(value);
  23222. this.instance.runHooks('modifyData', row, this.propToCol(prop), valueHolder, 'set');
  23223. if (valueHolder.isTouched()) {
  23224. value = valueHolder.value;
  23225. }
  23226. }
  23227. // try to set value under property `prop` (includes dot)
  23228. if (dataRow && dataRow.hasOwnProperty && (0, _object.hasOwnProperty)(dataRow, prop)) {
  23229. dataRow[prop] = value;
  23230. } else if (typeof prop === 'string' && prop.indexOf('.') > -1) {
  23231. var sliced = prop.split('.');
  23232. var out = dataRow;
  23233. var i = 0;
  23234. var ilen = void 0;
  23235. for (i = 0, ilen = sliced.length - 1; i < ilen; i++) {
  23236. if (typeof out[sliced[i]] === 'undefined') {
  23237. out[sliced[i]] = {};
  23238. }
  23239. out = out[sliced[i]];
  23240. }
  23241. out[sliced[i]] = value;
  23242. } else if (typeof prop === 'function') {
  23243. /* see the `function` handler in `get` */
  23244. prop(this.dataSource.slice(row, row + 1)[0], value);
  23245. } else {
  23246. dataRow[prop] = value;
  23247. }
  23248. };
  23249. /**
  23250. * This ridiculous piece of code maps rows Id that are present in table data to those displayed for user.
  23251. * The trick is, the physical row id (stored in settings.data) is not necessary the same
  23252. * as the visual (displayed) row id (e.g. when sorting is applied).
  23253. *
  23254. * @param {Number} index Visual row index.
  23255. * @param {Number} amount
  23256. * @fires Hooks#modifyRow
  23257. * @returns {Number}
  23258. */
  23259. DataMap.prototype.visualRowsToPhysical = function (index, amount) {
  23260. var totalRows = this.instance.countSourceRows();
  23261. var physicRow = (totalRows + index) % totalRows;
  23262. var logicRows = [];
  23263. var rowsToRemove = amount;
  23264. var row;
  23265. while (physicRow < totalRows && rowsToRemove) {
  23266. row = this.instance.runHooks('modifyRow', physicRow);
  23267. logicRows.push(row);
  23268. rowsToRemove--;
  23269. physicRow++;
  23270. }
  23271. return logicRows;
  23272. };
  23273. /**
  23274. *
  23275. * @param index Visual column index.
  23276. * @param amount
  23277. * @returns {Array}
  23278. */
  23279. DataMap.prototype.visualColumnsToPhysical = function (index, amount) {
  23280. var totalCols = this.instance.countCols();
  23281. var physicalCol = (totalCols + index) % totalCols;
  23282. var visualCols = [];
  23283. var colsToRemove = amount;
  23284. while (physicalCol < totalCols && colsToRemove) {
  23285. var col = this.instance.runHooks('modifyCol', physicalCol);
  23286. visualCols.push(col);
  23287. colsToRemove--;
  23288. physicalCol++;
  23289. }
  23290. return visualCols;
  23291. };
  23292. /**
  23293. * Clears the data array.
  23294. */
  23295. DataMap.prototype.clear = function () {
  23296. for (var r = 0; r < this.instance.countSourceRows(); r++) {
  23297. for (var c = 0; c < this.instance.countCols(); c++) {
  23298. this.set(r, this.colToProp(c), '');
  23299. }
  23300. }
  23301. };
  23302. /**
  23303. * Clear cached data length.
  23304. */
  23305. DataMap.prototype.clearLengthCache = function () {
  23306. this.cachedLength = null;
  23307. };
  23308. /**
  23309. * Get data length.
  23310. *
  23311. * @returns {Number}
  23312. */
  23313. DataMap.prototype.getLength = function () {
  23314. var _this2 = this;
  23315. var maxRows = void 0,
  23316. maxRowsFromSettings = this.instance.getSettings().maxRows;
  23317. if (maxRowsFromSettings < 0 || maxRowsFromSettings === 0) {
  23318. maxRows = 0;
  23319. } else {
  23320. maxRows = maxRowsFromSettings || Infinity;
  23321. }
  23322. var length = this.instance.countSourceRows();
  23323. if (this.instance.hasHook('modifyRow')) {
  23324. var reValidate = this.skipCache;
  23325. this.interval.start();
  23326. if (length !== this.latestSourceRowsCount) {
  23327. reValidate = true;
  23328. }
  23329. this.latestSourceRowsCount = length;
  23330. if (this.cachedLength === null || reValidate) {
  23331. (0, _number.rangeEach)(length - 1, function (row) {
  23332. row = _this2.instance.runHooks('modifyRow', row);
  23333. if (row === null) {
  23334. --length;
  23335. }
  23336. });
  23337. this.cachedLength = length;
  23338. } else {
  23339. length = this.cachedLength;
  23340. }
  23341. } else {
  23342. this.interval.stop();
  23343. }
  23344. return Math.min(length, maxRows);
  23345. };
  23346. /**
  23347. * Returns the data array.
  23348. *
  23349. * @returns {Array}
  23350. */
  23351. DataMap.prototype.getAll = function () {
  23352. var start = {
  23353. row: 0,
  23354. col: 0
  23355. };
  23356. var end = {
  23357. row: Math.max(this.instance.countSourceRows() - 1, 0),
  23358. col: Math.max(this.instance.countCols() - 1, 0)
  23359. };
  23360. if (start.row - end.row === 0 && !this.instance.countSourceRows()) {
  23361. return [];
  23362. }
  23363. return this.getRange(start, end, DataMap.prototype.DESTINATION_RENDERER);
  23364. };
  23365. /**
  23366. * Returns data range as array.
  23367. *
  23368. * @param {Object} [start] Start selection position. Visual indexes.
  23369. * @param {Object} [end] End selection position. Visual indexes.
  23370. * @param {Number} destination Destination of datamap.get
  23371. * @returns {Array}
  23372. */
  23373. DataMap.prototype.getRange = function (start, end, destination) {
  23374. var r,
  23375. rlen,
  23376. c,
  23377. clen,
  23378. output = [],
  23379. row;
  23380. var maxRows = this.instance.getSettings().maxRows;
  23381. var maxCols = this.instance.getSettings().maxCols;
  23382. if (maxRows === 0 || maxCols === 0) {
  23383. return [];
  23384. }
  23385. var getFn = destination === this.DESTINATION_CLIPBOARD_GENERATOR ? this.getCopyable : this.get;
  23386. rlen = Math.min(Math.max(maxRows - 1, 0), Math.max(start.row, end.row));
  23387. clen = Math.min(Math.max(maxCols - 1, 0), Math.max(start.col, end.col));
  23388. for (r = Math.min(start.row, end.row); r <= rlen; r++) {
  23389. row = [];
  23390. var physicalRow = this.instance.runHooks('modifyRow', r);
  23391. for (c = Math.min(start.col, end.col); c <= clen; c++) {
  23392. if (physicalRow === null) {
  23393. break;
  23394. }
  23395. row.push(getFn.call(this, r, this.colToProp(c)));
  23396. }
  23397. if (physicalRow !== null) {
  23398. output.push(row);
  23399. }
  23400. }
  23401. return output;
  23402. };
  23403. /**
  23404. * Return data as text (tab separated columns).
  23405. *
  23406. * @param {Object} [start] Start selection position. Visual indexes.
  23407. * @param {Object} [end] End selection position. Visual indexes.
  23408. * @returns {String}
  23409. */
  23410. DataMap.prototype.getText = function (start, end) {
  23411. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_RENDERER));
  23412. };
  23413. /**
  23414. * Return data as copyable text (tab separated columns intended for clipboard copy to an external application).
  23415. *
  23416. * @param {Object} [start] Start selection position. Visual indexes.
  23417. * @param {Object} [end] End selection position. Visual indexes.
  23418. * @returns {String}
  23419. */
  23420. DataMap.prototype.getCopyableText = function (start, end) {
  23421. return _SheetClip2.default.stringify(this.getRange(start, end, this.DESTINATION_CLIPBOARD_GENERATOR));
  23422. };
  23423. /**
  23424. * `skipLengthCache` callback.
  23425. * @private
  23426. * @param {Number} delay Time of the delay in milliseconds.
  23427. */
  23428. DataMap.prototype.onSkipLengthCache = function (delay) {
  23429. var _this3 = this;
  23430. this.skipCache = true;
  23431. setTimeout(function () {
  23432. _this3.skipCache = false;
  23433. }, delay);
  23434. };
  23435. /**
  23436. * Destroy instance.
  23437. */
  23438. DataMap.prototype.destroy = function () {
  23439. this.interval.stop();
  23440. this.interval = null;
  23441. this.instance = null;
  23442. this.priv = null;
  23443. this.GridSettings = null;
  23444. this.dataSource = null;
  23445. this.cachedLength = null;
  23446. this.duckSchema = null;
  23447. };
  23448. exports.default = DataMap;
  23449. /***/ }),
  23450. /* 199 */
  23451. /***/ (function(module, exports, __webpack_require__) {
  23452. "use strict";
  23453. exports.__esModule = true;
  23454. 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; }; }();
  23455. var _object = __webpack_require__(1);
  23456. var _array = __webpack_require__(2);
  23457. var _number = __webpack_require__(6);
  23458. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  23459. /**
  23460. * @class DataSource
  23461. * @private
  23462. */
  23463. var DataSource = function () {
  23464. function DataSource(hotInstance) {
  23465. var dataSource = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  23466. _classCallCheck(this, DataSource);
  23467. /**
  23468. * Instance of Handsontable.
  23469. *
  23470. * @type {Handsontable}
  23471. */
  23472. this.hot = hotInstance;
  23473. /**
  23474. * Data source
  23475. *
  23476. * @type {Array}
  23477. */
  23478. this.data = dataSource;
  23479. /**
  23480. * Type of data source.
  23481. *
  23482. * @type {String}
  23483. * @default 'array'
  23484. */
  23485. this.dataType = 'array';
  23486. this.colToProp = function () {};
  23487. this.propToCol = function () {};
  23488. }
  23489. /**
  23490. * Get all data.
  23491. *
  23492. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  23493. * in another format.
  23494. * @returns {Array}
  23495. */
  23496. _createClass(DataSource, [{
  23497. key: 'getData',
  23498. value: function getData() {
  23499. var toArray = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  23500. var result = this.data;
  23501. if (toArray) {
  23502. result = this.getByRange({ row: 0, col: 0 }, { row: Math.max(this.countRows() - 1, 0), col: Math.max(this.countColumns() - 1, 0) }, true);
  23503. }
  23504. return result;
  23505. }
  23506. /**
  23507. * Set new data source.
  23508. *
  23509. * @param data {Array}
  23510. */
  23511. }, {
  23512. key: 'setData',
  23513. value: function setData(data) {
  23514. this.data = data;
  23515. }
  23516. /**
  23517. * Returns array of column values from the data source. `column` is the index of the row in the data source.
  23518. *
  23519. * @param {Number} column Visual column index.
  23520. * @returns {Array}
  23521. */
  23522. }, {
  23523. key: 'getAtColumn',
  23524. value: function getAtColumn(column) {
  23525. var _this = this;
  23526. var result = [];
  23527. (0, _array.arrayEach)(this.data, function (row) {
  23528. var property = _this.colToProp(column);
  23529. if (typeof property === 'string') {
  23530. row = (0, _object.getProperty)(row, property);
  23531. } else {
  23532. row = row[property];
  23533. }
  23534. result.push(row);
  23535. });
  23536. return result;
  23537. }
  23538. /**
  23539. * 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.
  23540. *
  23541. * @param {Number} row Physical row index.
  23542. * @returns {Array|Object}
  23543. */
  23544. }, {
  23545. key: 'getAtRow',
  23546. value: function getAtRow(row) {
  23547. return this.data[row];
  23548. }
  23549. /**
  23550. * Returns a single value from the data.
  23551. *
  23552. * @param {Number} row Physical row index.
  23553. * @param {Number} column Visual column index.
  23554. * @returns {*}
  23555. */
  23556. }, {
  23557. key: 'getAtCell',
  23558. value: function getAtCell(row, column) {
  23559. var result = null;
  23560. var modifyRowData = this.hot.runHooks('modifyRowData', row);
  23561. var dataRow = isNaN(modifyRowData) ? modifyRowData : this.data[row];
  23562. if (dataRow) {
  23563. var prop = this.colToProp(column);
  23564. if (typeof prop === 'string') {
  23565. result = (0, _object.getProperty)(dataRow, prop);
  23566. } else if (typeof prop === 'function') {
  23567. result = prop(this.data.slice(row, row + 1)[0]);
  23568. } else {
  23569. result = dataRow[prop];
  23570. }
  23571. }
  23572. return result;
  23573. }
  23574. /**
  23575. * Returns source data by passed range.
  23576. *
  23577. * @param {Object} start Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  23578. * @param {Object} end Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects).
  23579. * @param {Boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided
  23580. * in another format.
  23581. * @returns {Array}
  23582. */
  23583. }, {
  23584. key: 'getByRange',
  23585. value: function getByRange(start, end) {
  23586. var _this2 = this;
  23587. var toArray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  23588. var startRow = Math.min(start.row, end.row);
  23589. var startCol = Math.min(start.col, end.col);
  23590. var endRow = Math.max(start.row, end.row);
  23591. var endCol = Math.max(start.col, end.col);
  23592. var result = [];
  23593. (0, _number.rangeEach)(startRow, endRow, function (currentRow) {
  23594. var row = _this2.getAtRow(currentRow);
  23595. var newRow = void 0;
  23596. if (_this2.dataType === 'array') {
  23597. newRow = row.slice(startCol, endCol + 1);
  23598. } else if (_this2.dataType === 'object') {
  23599. newRow = toArray ? [] : {};
  23600. (0, _number.rangeEach)(startCol, endCol, function (column) {
  23601. var prop = _this2.colToProp(column);
  23602. if (toArray) {
  23603. newRow.push(row[prop]);
  23604. } else {
  23605. newRow[prop] = row[prop];
  23606. }
  23607. });
  23608. }
  23609. result.push(newRow);
  23610. });
  23611. return result;
  23612. }
  23613. /**
  23614. * Count number of rows.
  23615. *
  23616. * @returns {Number}
  23617. */
  23618. }, {
  23619. key: 'countRows',
  23620. value: function countRows() {
  23621. return Array.isArray(this.data) ? this.data.length : 0;
  23622. }
  23623. /**
  23624. * Count number of columns.
  23625. *
  23626. * @returns {Number}
  23627. */
  23628. }, {
  23629. key: 'countColumns',
  23630. value: function countColumns() {
  23631. var result = 0;
  23632. if (Array.isArray(this.data)) {
  23633. if (this.dataType === 'array') {
  23634. result = this.data[0].length;
  23635. } else if (this.dataType === 'object') {
  23636. result = Object.keys(this.data[0]).length;
  23637. }
  23638. }
  23639. return result;
  23640. }
  23641. /**
  23642. * Destroy instance.
  23643. */
  23644. }, {
  23645. key: 'destroy',
  23646. value: function destroy() {
  23647. this.data = null;
  23648. this.hot = null;
  23649. }
  23650. }]);
  23651. return DataSource;
  23652. }();
  23653. exports.default = DataSource;
  23654. /***/ }),
  23655. /* 200 */
  23656. /***/ (function(module, exports, __webpack_require__) {
  23657. "use strict";
  23658. exports.__esModule = true;
  23659. var _src = __webpack_require__(11);
  23660. var _unicode = __webpack_require__(16);
  23661. var _event = __webpack_require__(7);
  23662. var _editors = __webpack_require__(14);
  23663. var _eventManager = __webpack_require__(4);
  23664. var _eventManager2 = _interopRequireDefault(_eventManager);
  23665. var _baseEditor = __webpack_require__(36);
  23666. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  23667. function EditorManager(instance, priv, selection) {
  23668. var _this = this,
  23669. destroyed = false,
  23670. eventManager,
  23671. activeEditor;
  23672. eventManager = new _eventManager2.default(instance);
  23673. function moveSelectionAfterEnter(shiftKey) {
  23674. selection.setSelectedHeaders(false, false, false);
  23675. var enterMoves = typeof priv.settings.enterMoves === 'function' ? priv.settings.enterMoves(event) : priv.settings.enterMoves;
  23676. if (shiftKey) {
  23677. // move selection up
  23678. selection.transformStart(-enterMoves.row, -enterMoves.col);
  23679. } else {
  23680. // move selection down (add a new row if needed)
  23681. selection.transformStart(enterMoves.row, enterMoves.col, true);
  23682. }
  23683. }
  23684. function moveSelectionUp(shiftKey) {
  23685. if (shiftKey) {
  23686. if (selection.selectedHeader.cols) {
  23687. selection.setSelectedHeaders(selection.selectedHeader.rows, false, false);
  23688. }
  23689. selection.transformEnd(-1, 0);
  23690. } else {
  23691. selection.setSelectedHeaders(false, false, false);
  23692. selection.transformStart(-1, 0);
  23693. }
  23694. }
  23695. function moveSelectionDown(shiftKey) {
  23696. if (shiftKey) {
  23697. // expanding selection down with shift
  23698. selection.transformEnd(1, 0);
  23699. } else {
  23700. selection.setSelectedHeaders(false, false, false);
  23701. selection.transformStart(1, 0);
  23702. }
  23703. }
  23704. function moveSelectionRight(shiftKey) {
  23705. if (shiftKey) {
  23706. selection.transformEnd(0, 1);
  23707. } else {
  23708. selection.setSelectedHeaders(false, false, false);
  23709. selection.transformStart(0, 1);
  23710. }
  23711. }
  23712. function moveSelectionLeft(shiftKey) {
  23713. if (shiftKey) {
  23714. if (selection.selectedHeader.rows) {
  23715. selection.setSelectedHeaders(false, selection.selectedHeader.cols, false);
  23716. }
  23717. selection.transformEnd(0, -1);
  23718. } else {
  23719. selection.setSelectedHeaders(false, false, false);
  23720. selection.transformStart(0, -1);
  23721. }
  23722. }
  23723. function onKeyDown(event) {
  23724. var ctrlDown, rangeModifier;
  23725. if (!instance.isListening()) {
  23726. return;
  23727. }
  23728. instance.runHooks('beforeKeyDown', event);
  23729. if (destroyed) {
  23730. return;
  23731. }
  23732. if ((0, _event.isImmediatePropagationStopped)(event)) {
  23733. return;
  23734. }
  23735. priv.lastKeyCode = event.keyCode;
  23736. if (!selection.isSelected()) {
  23737. return;
  23738. }
  23739. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  23740. ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  23741. if (activeEditor && !activeEditor.isWaiting()) {
  23742. if (!(0, _unicode.isMetaKey)(event.keyCode) && !(0, _unicode.isCtrlKey)(event.keyCode) && !ctrlDown && !_this.isEditorOpened()) {
  23743. _this.openEditor('', event);
  23744. return;
  23745. }
  23746. }
  23747. rangeModifier = event.shiftKey ? selection.setRangeEnd : selection.setRangeStart;
  23748. switch (event.keyCode) {
  23749. case _unicode.KEY_CODES.A:
  23750. if (!_this.isEditorOpened() && ctrlDown) {
  23751. selection.selectAll();
  23752. event.preventDefault();
  23753. (0, _event.stopPropagation)(event);
  23754. }
  23755. break;
  23756. case _unicode.KEY_CODES.ARROW_UP:
  23757. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  23758. _this.closeEditorAndSaveChanges(ctrlDown);
  23759. }
  23760. moveSelectionUp(event.shiftKey);
  23761. event.preventDefault();
  23762. (0, _event.stopPropagation)(event);
  23763. break;
  23764. case _unicode.KEY_CODES.ARROW_DOWN:
  23765. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  23766. _this.closeEditorAndSaveChanges(ctrlDown);
  23767. }
  23768. moveSelectionDown(event.shiftKey);
  23769. event.preventDefault();
  23770. (0, _event.stopPropagation)(event);
  23771. break;
  23772. case _unicode.KEY_CODES.ARROW_RIGHT:
  23773. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  23774. _this.closeEditorAndSaveChanges(ctrlDown);
  23775. }
  23776. moveSelectionRight(event.shiftKey);
  23777. event.preventDefault();
  23778. (0, _event.stopPropagation)(event);
  23779. break;
  23780. case _unicode.KEY_CODES.ARROW_LEFT:
  23781. if (_this.isEditorOpened() && !activeEditor.isWaiting()) {
  23782. _this.closeEditorAndSaveChanges(ctrlDown);
  23783. }
  23784. moveSelectionLeft(event.shiftKey);
  23785. event.preventDefault();
  23786. (0, _event.stopPropagation)(event);
  23787. break;
  23788. case _unicode.KEY_CODES.TAB:
  23789. selection.setSelectedHeaders(false, false, false);
  23790. var tabMoves = typeof priv.settings.tabMoves === 'function' ? priv.settings.tabMoves(event) : priv.settings.tabMoves;
  23791. if (event.shiftKey) {
  23792. // move selection left
  23793. selection.transformStart(-tabMoves.row, -tabMoves.col);
  23794. } else {
  23795. // move selection right (add a new column if needed)
  23796. selection.transformStart(tabMoves.row, tabMoves.col, true);
  23797. }
  23798. event.preventDefault();
  23799. (0, _event.stopPropagation)(event);
  23800. break;
  23801. case _unicode.KEY_CODES.BACKSPACE:
  23802. case _unicode.KEY_CODES.DELETE:
  23803. selection.empty(event);
  23804. _this.prepareEditor();
  23805. event.preventDefault();
  23806. break;
  23807. case _unicode.KEY_CODES.F2:
  23808. /* F2 */
  23809. _this.openEditor(null, event);
  23810. if (activeEditor) {
  23811. activeEditor.enableFullEditMode();
  23812. }
  23813. event.preventDefault(); // prevent Opera from opening 'Go to Page dialog'
  23814. break;
  23815. case _unicode.KEY_CODES.ENTER:
  23816. /* return/enter */
  23817. if (_this.isEditorOpened()) {
  23818. if (activeEditor && activeEditor.state !== _baseEditor.EditorState.WAITING) {
  23819. _this.closeEditorAndSaveChanges(ctrlDown);
  23820. }
  23821. moveSelectionAfterEnter(event.shiftKey);
  23822. } else if (instance.getSettings().enterBeginsEditing) {
  23823. _this.openEditor(null, event);
  23824. if (activeEditor) {
  23825. activeEditor.enableFullEditMode();
  23826. }
  23827. } else {
  23828. moveSelectionAfterEnter(event.shiftKey);
  23829. }
  23830. event.preventDefault(); // don't add newline to field
  23831. (0, _event.stopImmediatePropagation)(event); // required by HandsontableEditor
  23832. break;
  23833. case _unicode.KEY_CODES.ESCAPE:
  23834. if (_this.isEditorOpened()) {
  23835. _this.closeEditorAndRestoreOriginalValue(ctrlDown);
  23836. }
  23837. event.preventDefault();
  23838. break;
  23839. case _unicode.KEY_CODES.HOME:
  23840. selection.setSelectedHeaders(false, false, false);
  23841. if (event.ctrlKey || event.metaKey) {
  23842. rangeModifier(new _src.CellCoords(0, priv.selRange.from.col));
  23843. } else {
  23844. rangeModifier(new _src.CellCoords(priv.selRange.from.row, 0));
  23845. }
  23846. event.preventDefault(); // don't scroll the window
  23847. (0, _event.stopPropagation)(event);
  23848. break;
  23849. case _unicode.KEY_CODES.END:
  23850. selection.setSelectedHeaders(false, false, false);
  23851. if (event.ctrlKey || event.metaKey) {
  23852. rangeModifier(new _src.CellCoords(instance.countRows() - 1, priv.selRange.from.col));
  23853. } else {
  23854. rangeModifier(new _src.CellCoords(priv.selRange.from.row, instance.countCols() - 1));
  23855. }
  23856. event.preventDefault(); // don't scroll the window
  23857. (0, _event.stopPropagation)(event);
  23858. break;
  23859. case _unicode.KEY_CODES.PAGE_UP:
  23860. selection.setSelectedHeaders(false, false, false);
  23861. selection.transformStart(-instance.countVisibleRows(), 0);
  23862. event.preventDefault(); // don't page up the window
  23863. (0, _event.stopPropagation)(event);
  23864. break;
  23865. case _unicode.KEY_CODES.PAGE_DOWN:
  23866. selection.setSelectedHeaders(false, false, false);
  23867. selection.transformStart(instance.countVisibleRows(), 0);
  23868. event.preventDefault(); // don't page down the window
  23869. (0, _event.stopPropagation)(event);
  23870. break;
  23871. default:
  23872. break;
  23873. }
  23874. }
  23875. function init() {
  23876. instance.addHook('afterDocumentKeyDown', onKeyDown);
  23877. eventManager.addEventListener(document.documentElement, 'keydown', function (event) {
  23878. if (!destroyed) {
  23879. instance.runHooks('afterDocumentKeyDown', event);
  23880. }
  23881. });
  23882. function onDblClick(event, coords, elem) {
  23883. // may be TD or TH
  23884. if (elem.nodeName == 'TD') {
  23885. _this.openEditor();
  23886. if (activeEditor) {
  23887. activeEditor.enableFullEditMode();
  23888. }
  23889. }
  23890. }
  23891. instance.view.wt.update('onCellDblClick', onDblClick);
  23892. instance.addHook('afterDestroy', function () {
  23893. destroyed = true;
  23894. });
  23895. }
  23896. /**
  23897. * Destroy current editor, if exists.
  23898. *
  23899. * @function destroyEditor
  23900. * @memberof! Handsontable.EditorManager#
  23901. * @param {Boolean} revertOriginal
  23902. */
  23903. this.destroyEditor = function (revertOriginal) {
  23904. this.closeEditor(revertOriginal);
  23905. };
  23906. /**
  23907. * Get active editor.
  23908. *
  23909. * @function getActiveEditor
  23910. * @memberof! Handsontable.EditorManager#
  23911. * @returns {*}
  23912. */
  23913. this.getActiveEditor = function () {
  23914. return activeEditor;
  23915. };
  23916. /**
  23917. * Prepare text input to be displayed at given grid cell.
  23918. *
  23919. * @function prepareEditor
  23920. * @memberof! Handsontable.EditorManager#
  23921. */
  23922. this.prepareEditor = function () {
  23923. var row, col, prop, td, originalValue, cellProperties, editorClass;
  23924. if (activeEditor && activeEditor.isWaiting()) {
  23925. this.closeEditor(false, false, function (dataSaved) {
  23926. if (dataSaved) {
  23927. _this.prepareEditor();
  23928. }
  23929. });
  23930. return;
  23931. }
  23932. row = priv.selRange.highlight.row;
  23933. col = priv.selRange.highlight.col;
  23934. prop = instance.colToProp(col);
  23935. td = instance.getCell(row, col);
  23936. originalValue = instance.getSourceDataAtCell(instance.runHooks('modifyRow', row), col);
  23937. cellProperties = instance.getCellMeta(row, col);
  23938. editorClass = instance.getCellEditor(cellProperties);
  23939. if (editorClass) {
  23940. activeEditor = (0, _editors.getEditorInstance)(editorClass, instance);
  23941. activeEditor.prepare(row, col, prop, td, originalValue, cellProperties);
  23942. } else {
  23943. activeEditor = void 0;
  23944. }
  23945. };
  23946. /**
  23947. * Check is editor is opened/showed.
  23948. *
  23949. * @function isEditorOpened
  23950. * @memberof! Handsontable.EditorManager#
  23951. * @returns {Boolean}
  23952. */
  23953. this.isEditorOpened = function () {
  23954. return activeEditor && activeEditor.isOpened();
  23955. };
  23956. /**
  23957. * Open editor with initial value.
  23958. *
  23959. * @function openEditor
  23960. * @memberof! Handsontable.EditorManager#
  23961. * @param {String} initialValue
  23962. * @param {DOMEvent} event
  23963. */
  23964. this.openEditor = function (initialValue, event) {
  23965. if (activeEditor && !activeEditor.cellProperties.readOnly) {
  23966. activeEditor.beginEditing(initialValue, event);
  23967. } else if (activeEditor && activeEditor.cellProperties.readOnly) {
  23968. // move the selection after opening the editor with ENTER key
  23969. if (event && event.keyCode === _unicode.KEY_CODES.ENTER) {
  23970. moveSelectionAfterEnter();
  23971. }
  23972. }
  23973. };
  23974. /**
  23975. * Close editor, finish editing cell.
  23976. *
  23977. * @function closeEditor
  23978. * @memberof! Handsontable.EditorManager#
  23979. * @param {Boolean} restoreOriginalValue
  23980. * @param {Boolean} [ctrlDown]
  23981. * @param {Function} [callback]
  23982. */
  23983. this.closeEditor = function (restoreOriginalValue, ctrlDown, callback) {
  23984. if (activeEditor) {
  23985. activeEditor.finishEditing(restoreOriginalValue, ctrlDown, callback);
  23986. } else if (callback) {
  23987. callback(false);
  23988. }
  23989. };
  23990. /**
  23991. * Close editor and save changes.
  23992. *
  23993. * @function closeEditorAndSaveChanges
  23994. * @memberof! Handsontable.EditorManager#
  23995. * @param {Boolean} ctrlDown
  23996. */
  23997. this.closeEditorAndSaveChanges = function (ctrlDown) {
  23998. return this.closeEditor(false, ctrlDown);
  23999. };
  24000. /**
  24001. * Close editor and restore original value.
  24002. *
  24003. * @function closeEditorAndRestoreOriginalValue
  24004. * @memberof! Handsontable.EditorManager#
  24005. * @param {Boolean} ctrlDown
  24006. */
  24007. this.closeEditorAndRestoreOriginalValue = function (ctrlDown) {
  24008. return this.closeEditor(true, ctrlDown);
  24009. };
  24010. init();
  24011. }
  24012. exports.default = EditorManager;
  24013. /***/ }),
  24014. /* 201 */
  24015. /***/ (function(module, exports, __webpack_require__) {
  24016. "use strict";
  24017. exports.__esModule = true;
  24018. 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; }; }();
  24019. var _baseEditor = __webpack_require__(36);
  24020. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  24021. var _element = __webpack_require__(0);
  24022. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24024. 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; }
  24025. 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; }
  24026. /**
  24027. * @private
  24028. * @editor CheckboxEditor
  24029. * @class CheckboxEditor
  24030. */
  24031. var CheckboxEditor = function (_BaseEditor) {
  24032. _inherits(CheckboxEditor, _BaseEditor);
  24033. function CheckboxEditor() {
  24034. _classCallCheck(this, CheckboxEditor);
  24035. return _possibleConstructorReturn(this, (CheckboxEditor.__proto__ || Object.getPrototypeOf(CheckboxEditor)).apply(this, arguments));
  24036. }
  24037. _createClass(CheckboxEditor, [{
  24038. key: 'beginEditing',
  24039. value: function beginEditing(initialValue, event) {
  24040. // editorManager return double click event as undefined
  24041. if (event === void 0) {
  24042. var checkbox = this.TD.querySelector('input[type="checkbox"]');
  24043. if (!(0, _element.hasClass)(checkbox, 'htBadValue')) {
  24044. checkbox.click();
  24045. }
  24046. }
  24047. }
  24048. }, {
  24049. key: 'finishEditing',
  24050. value: function finishEditing() {}
  24051. }, {
  24052. key: 'init',
  24053. value: function init() {}
  24054. }, {
  24055. key: 'open',
  24056. value: function open() {}
  24057. }, {
  24058. key: 'close',
  24059. value: function close() {}
  24060. }, {
  24061. key: 'getValue',
  24062. value: function getValue() {}
  24063. }, {
  24064. key: 'setValue',
  24065. value: function setValue() {}
  24066. }, {
  24067. key: 'focus',
  24068. value: function focus() {}
  24069. }]);
  24070. return CheckboxEditor;
  24071. }(_baseEditor2.default);
  24072. exports.default = CheckboxEditor;
  24073. /***/ }),
  24074. /* 202 */
  24075. /***/ (function(module, exports, __webpack_require__) {
  24076. "use strict";
  24077. exports.__esModule = true;
  24078. 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; }; }();
  24079. 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); } };
  24080. var _moment = __webpack_require__(61);
  24081. var _moment2 = _interopRequireDefault(_moment);
  24082. var _pikaday = __webpack_require__(302);
  24083. var _pikaday2 = _interopRequireDefault(_pikaday);
  24084. __webpack_require__(182);
  24085. var _element = __webpack_require__(0);
  24086. var _object = __webpack_require__(1);
  24087. var _eventManager = __webpack_require__(4);
  24088. var _eventManager2 = _interopRequireDefault(_eventManager);
  24089. var _unicode = __webpack_require__(16);
  24090. var _event = __webpack_require__(7);
  24091. var _textEditor = __webpack_require__(43);
  24092. var _textEditor2 = _interopRequireDefault(_textEditor);
  24093. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24094. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24095. 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; }
  24096. 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; }
  24097. /**
  24098. * @private
  24099. * @editor DateEditor
  24100. * @class DateEditor
  24101. * @dependencies TextEditor moment pikaday
  24102. */
  24103. var DateEditor = function (_TextEditor) {
  24104. _inherits(DateEditor, _TextEditor);
  24105. /**
  24106. * @param {Core} hotInstance Handsontable instance
  24107. * @private
  24108. */
  24109. function DateEditor(hotInstance) {
  24110. _classCallCheck(this, DateEditor);
  24111. // TODO: Move this option to general settings
  24112. var _this = _possibleConstructorReturn(this, (DateEditor.__proto__ || Object.getPrototypeOf(DateEditor)).call(this, hotInstance));
  24113. _this.defaultDateFormat = 'DD/MM/YYYY';
  24114. _this.isCellEdited = false;
  24115. _this.parentDestroyed = false;
  24116. return _this;
  24117. }
  24118. _createClass(DateEditor, [{
  24119. key: 'init',
  24120. value: function init() {
  24121. var _this2 = this;
  24122. if (typeof _moment2.default !== 'function') {
  24123. throw new Error('You need to include moment.js to your project.');
  24124. }
  24125. if (typeof _pikaday2.default !== 'function') {
  24126. throw new Error('You need to include Pikaday to your project.');
  24127. }
  24128. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'init', this).call(this);
  24129. this.instance.addHook('afterDestroy', function () {
  24130. _this2.parentDestroyed = true;
  24131. _this2.destroyElements();
  24132. });
  24133. }
  24134. /**
  24135. * Create data picker instance
  24136. */
  24137. }, {
  24138. key: 'createElements',
  24139. value: function createElements() {
  24140. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'createElements', this).call(this);
  24141. this.datePicker = document.createElement('DIV');
  24142. this.datePickerStyle = this.datePicker.style;
  24143. this.datePickerStyle.position = 'absolute';
  24144. this.datePickerStyle.top = 0;
  24145. this.datePickerStyle.left = 0;
  24146. this.datePickerStyle.zIndex = 9999;
  24147. (0, _element.addClass)(this.datePicker, 'htDatepickerHolder');
  24148. document.body.appendChild(this.datePicker);
  24149. this.$datePicker = new _pikaday2.default(this.getDatePickerConfig());
  24150. var eventManager = new _eventManager2.default(this);
  24151. /**
  24152. * Prevent recognizing clicking on datepicker as clicking outside of table
  24153. */
  24154. eventManager.addEventListener(this.datePicker, 'mousedown', function (event) {
  24155. return (0, _event.stopPropagation)(event);
  24156. });
  24157. this.hideDatepicker();
  24158. }
  24159. /**
  24160. * Destroy data picker instance
  24161. */
  24162. }, {
  24163. key: 'destroyElements',
  24164. value: function destroyElements() {
  24165. this.$datePicker.destroy();
  24166. }
  24167. /**
  24168. * Prepare editor to appear
  24169. *
  24170. * @param {Number} row Row index
  24171. * @param {Number} col Column index
  24172. * @param {String} prop Property name (passed when datasource is an array of objects)
  24173. * @param {HTMLTableCellElement} td Table cell element
  24174. * @param {*} originalValue Original value
  24175. * @param {Object} cellProperties Object with cell properties ({@see Core#getCellMeta})
  24176. */
  24177. }, {
  24178. key: 'prepare',
  24179. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  24180. this._opened = false;
  24181. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  24182. }
  24183. /**
  24184. * Open editor
  24185. *
  24186. * @param {Event} [event=null]
  24187. */
  24188. }, {
  24189. key: 'open',
  24190. value: function open() {
  24191. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  24192. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'open', this).call(this);
  24193. this.showDatepicker(event);
  24194. }
  24195. /**
  24196. * Close editor
  24197. */
  24198. }, {
  24199. key: 'close',
  24200. value: function close() {
  24201. var _this3 = this;
  24202. this._opened = false;
  24203. this.instance._registerTimeout(setTimeout(function () {
  24204. _this3.instance.selection.refreshBorders();
  24205. }, 0));
  24206. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'close', this).call(this);
  24207. }
  24208. /**
  24209. * @param {Boolean} [isCancelled=false]
  24210. * @param {Boolean} [ctrlDown=false]
  24211. */
  24212. }, {
  24213. key: 'finishEditing',
  24214. value: function finishEditing() {
  24215. var isCancelled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  24216. var ctrlDown = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  24217. if (isCancelled) {
  24218. // pressed ESC, restore original value
  24219. // var value = this.instance.getDataAtCell(this.row, this.col);
  24220. var value = this.originalValue;
  24221. if (value !== void 0) {
  24222. this.setValue(value);
  24223. }
  24224. }
  24225. this.hideDatepicker();
  24226. _get(DateEditor.prototype.__proto__ || Object.getPrototypeOf(DateEditor.prototype), 'finishEditing', this).call(this, isCancelled, ctrlDown);
  24227. }
  24228. /**
  24229. * Show data picker
  24230. *
  24231. * @param {Event} event
  24232. */
  24233. }, {
  24234. key: 'showDatepicker',
  24235. value: function showDatepicker(event) {
  24236. this.$datePicker.config(this.getDatePickerConfig());
  24237. var offset = this.TD.getBoundingClientRect();
  24238. var dateFormat = this.cellProperties.dateFormat || this.defaultDateFormat;
  24239. var datePickerConfig = this.$datePicker.config();
  24240. var dateStr = void 0;
  24241. var isMouseDown = this.instance.view.isMouseDown();
  24242. var isMeta = event ? (0, _unicode.isMetaKey)(event.keyCode) : false;
  24243. this.datePickerStyle.top = window.pageYOffset + offset.top + (0, _element.outerHeight)(this.TD) + 'px';
  24244. this.datePickerStyle.left = window.pageXOffset + offset.left + 'px';
  24245. this.$datePicker._onInputFocus = function () {};
  24246. datePickerConfig.format = dateFormat;
  24247. if (this.originalValue) {
  24248. dateStr = this.originalValue;
  24249. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  24250. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  24251. }
  24252. // workaround for date/time cells - pikaday resets the cell value to 12:00 AM by default, this will overwrite the value.
  24253. if (this.getValue() !== this.originalValue) {
  24254. this.setValue(this.originalValue);
  24255. }
  24256. if (!isMeta && !isMouseDown) {
  24257. this.setValue('');
  24258. }
  24259. } else if (this.cellProperties.defaultDate) {
  24260. dateStr = this.cellProperties.defaultDate;
  24261. datePickerConfig.defaultDate = dateStr;
  24262. if ((0, _moment2.default)(dateStr, dateFormat, true).isValid()) {
  24263. this.$datePicker.setMoment((0, _moment2.default)(dateStr, dateFormat), true);
  24264. }
  24265. if (!isMeta && !isMouseDown) {
  24266. this.setValue('');
  24267. }
  24268. } else {
  24269. // if a default date is not defined, set a soft-default-date: display the current day and month in the
  24270. // datepicker, but don't fill the editor input
  24271. this.$datePicker.gotoToday();
  24272. }
  24273. this.datePickerStyle.display = 'block';
  24274. this.$datePicker.show();
  24275. }
  24276. /**
  24277. * Hide data picker
  24278. */
  24279. }, {
  24280. key: 'hideDatepicker',
  24281. value: function hideDatepicker() {
  24282. this.datePickerStyle.display = 'none';
  24283. this.$datePicker.hide();
  24284. }
  24285. /**
  24286. * Get date picker options.
  24287. *
  24288. * @returns {Object}
  24289. */
  24290. }, {
  24291. key: 'getDatePickerConfig',
  24292. value: function getDatePickerConfig() {
  24293. var _this4 = this;
  24294. var htInput = this.TEXTAREA;
  24295. var options = {};
  24296. if (this.cellProperties && this.cellProperties.datePickerConfig) {
  24297. (0, _object.deepExtend)(options, this.cellProperties.datePickerConfig);
  24298. }
  24299. var origOnSelect = options.onSelect;
  24300. var origOnClose = options.onClose;
  24301. options.field = htInput;
  24302. options.trigger = htInput;
  24303. options.container = this.datePicker;
  24304. options.bound = false;
  24305. options.format = options.format || this.defaultDateFormat;
  24306. options.reposition = options.reposition || false;
  24307. options.onSelect = function (dateStr) {
  24308. if (!isNaN(dateStr.getTime())) {
  24309. dateStr = (0, _moment2.default)(dateStr).format(_this4.cellProperties.dateFormat || _this4.defaultDateFormat);
  24310. }
  24311. _this4.setValue(dateStr);
  24312. _this4.hideDatepicker();
  24313. if (origOnSelect) {
  24314. origOnSelect();
  24315. }
  24316. };
  24317. options.onClose = function () {
  24318. if (!_this4.parentDestroyed) {
  24319. _this4.finishEditing(false);
  24320. }
  24321. if (origOnClose) {
  24322. origOnClose();
  24323. }
  24324. };
  24325. return options;
  24326. }
  24327. }]);
  24328. return DateEditor;
  24329. }(_textEditor2.default);
  24330. exports.default = DateEditor;
  24331. /***/ }),
  24332. /* 203 */
  24333. /***/ (function(module, exports, __webpack_require__) {
  24334. "use strict";
  24335. exports.__esModule = true;
  24336. 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; }; }();
  24337. 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); } };
  24338. var _autocompleteEditor = __webpack_require__(148);
  24339. var _autocompleteEditor2 = _interopRequireDefault(_autocompleteEditor);
  24340. var _pluginHooks = __webpack_require__(8);
  24341. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  24342. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24343. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24344. 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; }
  24345. 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; }
  24346. /**
  24347. * @private
  24348. * @editor DropdownEditor
  24349. * @class DropdownEditor
  24350. * @dependencies AutocompleteEditor
  24351. */
  24352. var DropdownEditor = function (_AutocompleteEditor) {
  24353. _inherits(DropdownEditor, _AutocompleteEditor);
  24354. function DropdownEditor() {
  24355. _classCallCheck(this, DropdownEditor);
  24356. return _possibleConstructorReturn(this, (DropdownEditor.__proto__ || Object.getPrototypeOf(DropdownEditor)).apply(this, arguments));
  24357. }
  24358. _createClass(DropdownEditor, [{
  24359. key: 'prepare',
  24360. value: function prepare(row, col, prop, td, originalValue, cellProperties) {
  24361. _get(DropdownEditor.prototype.__proto__ || Object.getPrototypeOf(DropdownEditor.prototype), 'prepare', this).call(this, row, col, prop, td, originalValue, cellProperties);
  24362. this.cellProperties.filter = false;
  24363. this.cellProperties.strict = true;
  24364. }
  24365. }]);
  24366. return DropdownEditor;
  24367. }(_autocompleteEditor2.default);
  24368. _pluginHooks2.default.getSingleton().add('beforeValidate', function (value, row, col, source) {
  24369. var cellMeta = this.getCellMeta(row, this.propToCol(col));
  24370. if (cellMeta.editor === DropdownEditor) {
  24371. if (cellMeta.strict === void 0) {
  24372. cellMeta.filter = false;
  24373. cellMeta.strict = true;
  24374. }
  24375. }
  24376. });
  24377. exports.default = DropdownEditor;
  24378. /***/ }),
  24379. /* 204 */
  24380. /***/ (function(module, exports, __webpack_require__) {
  24381. "use strict";
  24382. exports.__esModule = true;
  24383. var _unicode = __webpack_require__(16);
  24384. var _event = __webpack_require__(7);
  24385. var _element = __webpack_require__(0);
  24386. var _baseEditor = __webpack_require__(36);
  24387. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  24388. var _eventManager = __webpack_require__(4);
  24389. var _eventManager2 = _interopRequireDefault(_eventManager);
  24390. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24391. var MobileTextEditor = _baseEditor2.default.prototype.extend();
  24392. var domDimensionsCache = {};
  24393. /**
  24394. * @private
  24395. * @editor MobileTextEditor
  24396. * @class MobileTextEditor
  24397. */
  24398. var createControls = function createControls() {
  24399. this.controls = {};
  24400. this.controls.leftButton = document.createElement('DIV');
  24401. this.controls.leftButton.className = 'leftButton';
  24402. this.controls.rightButton = document.createElement('DIV');
  24403. this.controls.rightButton.className = 'rightButton';
  24404. this.controls.upButton = document.createElement('DIV');
  24405. this.controls.upButton.className = 'upButton';
  24406. this.controls.downButton = document.createElement('DIV');
  24407. this.controls.downButton.className = 'downButton';
  24408. for (var button in this.controls) {
  24409. if (Object.prototype.hasOwnProperty.call(this.controls, button)) {
  24410. this.positionControls.appendChild(this.controls[button]);
  24411. }
  24412. }
  24413. };
  24414. MobileTextEditor.prototype.valueChanged = function () {
  24415. return this.initValue != this.getValue();
  24416. };
  24417. MobileTextEditor.prototype.init = function () {
  24418. var that = this;
  24419. this.eventManager = new _eventManager2.default(this.instance);
  24420. this.createElements();
  24421. this.bindEvents();
  24422. this.instance.addHook('afterDestroy', function () {
  24423. that.destroy();
  24424. });
  24425. };
  24426. MobileTextEditor.prototype.getValue = function () {
  24427. return this.TEXTAREA.value;
  24428. };
  24429. MobileTextEditor.prototype.setValue = function (newValue) {
  24430. this.initValue = newValue;
  24431. this.TEXTAREA.value = newValue;
  24432. };
  24433. MobileTextEditor.prototype.createElements = function () {
  24434. this.editorContainer = document.createElement('DIV');
  24435. this.editorContainer.className = 'htMobileEditorContainer';
  24436. this.cellPointer = document.createElement('DIV');
  24437. this.cellPointer.className = 'cellPointer';
  24438. this.moveHandle = document.createElement('DIV');
  24439. this.moveHandle.className = 'moveHandle';
  24440. this.inputPane = document.createElement('DIV');
  24441. this.inputPane.className = 'inputs';
  24442. this.positionControls = document.createElement('DIV');
  24443. this.positionControls.className = 'positionControls';
  24444. this.TEXTAREA = document.createElement('TEXTAREA');
  24445. (0, _element.addClass)(this.TEXTAREA, 'handsontableInput');
  24446. this.inputPane.appendChild(this.TEXTAREA);
  24447. this.editorContainer.appendChild(this.cellPointer);
  24448. this.editorContainer.appendChild(this.moveHandle);
  24449. this.editorContainer.appendChild(this.inputPane);
  24450. this.editorContainer.appendChild(this.positionControls);
  24451. createControls.call(this);
  24452. document.body.appendChild(this.editorContainer);
  24453. };
  24454. MobileTextEditor.prototype.onBeforeKeyDown = function (event) {
  24455. var instance = this;
  24456. var that = instance.getActiveEditor();
  24457. if (event.target !== that.TEXTAREA || (0, _event.isImmediatePropagationStopped)(event)) {
  24458. return;
  24459. }
  24460. switch (event.keyCode) {
  24461. case _unicode.KEY_CODES.ENTER:
  24462. that.close();
  24463. event.preventDefault(); // don't add newline to field
  24464. break;
  24465. case _unicode.KEY_CODES.BACKSPACE:
  24466. (0, _event.stopImmediatePropagation)(event); // backspace, delete, home, end should only work locally when cell is edited (not in table context)
  24467. break;
  24468. default:
  24469. break;
  24470. }
  24471. };
  24472. MobileTextEditor.prototype.open = function () {
  24473. this.instance.addHook('beforeKeyDown', this.onBeforeKeyDown);
  24474. (0, _element.addClass)(this.editorContainer, 'active');
  24475. (0, _element.removeClass)(this.cellPointer, 'hidden');
  24476. this.updateEditorPosition();
  24477. };
  24478. MobileTextEditor.prototype.focus = function () {
  24479. this.TEXTAREA.focus();
  24480. (0, _element.setCaretPosition)(this.TEXTAREA, this.TEXTAREA.value.length);
  24481. };
  24482. MobileTextEditor.prototype.close = function () {
  24483. this.TEXTAREA.blur();
  24484. this.instance.removeHook('beforeKeyDown', this.onBeforeKeyDown);
  24485. (0, _element.removeClass)(this.editorContainer, 'active');
  24486. };
  24487. MobileTextEditor.prototype.scrollToView = function () {
  24488. var coords = this.instance.getSelectedRange().highlight;
  24489. this.instance.view.scrollViewport(coords);
  24490. };
  24491. MobileTextEditor.prototype.hideCellPointer = function () {
  24492. if (!(0, _element.hasClass)(this.cellPointer, 'hidden')) {
  24493. (0, _element.addClass)(this.cellPointer, 'hidden');
  24494. }
  24495. };
  24496. MobileTextEditor.prototype.updateEditorPosition = function (x, y) {
  24497. if (x && y) {
  24498. x = parseInt(x, 10);
  24499. y = parseInt(y, 10);
  24500. this.editorContainer.style.top = y + 'px';
  24501. this.editorContainer.style.left = x + 'px';
  24502. } else {
  24503. var selection = this.instance.getSelected(),
  24504. selectedCell = this.instance.getCell(selection[0], selection[1]);
  24505. // cache sizes
  24506. if (!domDimensionsCache.cellPointer) {
  24507. domDimensionsCache.cellPointer = {
  24508. height: (0, _element.outerHeight)(this.cellPointer),
  24509. width: (0, _element.outerWidth)(this.cellPointer)
  24510. };
  24511. }
  24512. if (!domDimensionsCache.editorContainer) {
  24513. domDimensionsCache.editorContainer = {
  24514. width: (0, _element.outerWidth)(this.editorContainer)
  24515. };
  24516. }
  24517. if (selectedCell !== undefined) {
  24518. var scrollLeft = this.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollLeft)(this.instance.view.wt.wtOverlays.leftOverlay.holder);
  24519. var scrollTop = this.instance.view.wt.wtOverlays.topOverlay.trimmingContainer == window ? 0 : (0, _element.getScrollTop)(this.instance.view.wt.wtOverlays.topOverlay.holder);
  24520. var selectedCellOffset = (0, _element.offset)(selectedCell),
  24521. selectedCellWidth = (0, _element.outerWidth)(selectedCell),
  24522. currentScrollPosition = {
  24523. x: scrollLeft,
  24524. y: scrollTop
  24525. };
  24526. this.editorContainer.style.top = parseInt(selectedCellOffset.top + (0, _element.outerHeight)(selectedCell) - currentScrollPosition.y + domDimensionsCache.cellPointer.height, 10) + 'px';
  24527. this.editorContainer.style.left = parseInt(window.innerWidth / 2 - domDimensionsCache.editorContainer.width / 2, 10) + 'px';
  24528. if (selectedCellOffset.left + selectedCellWidth / 2 > parseInt(this.editorContainer.style.left, 10) + domDimensionsCache.editorContainer.width) {
  24529. this.editorContainer.style.left = window.innerWidth - domDimensionsCache.editorContainer.width + 'px';
  24530. } else if (selectedCellOffset.left + selectedCellWidth / 2 < parseInt(this.editorContainer.style.left, 10) + 20) {
  24531. this.editorContainer.style.left = 0 + 'px';
  24532. }
  24533. this.cellPointer.style.left = parseInt(selectedCellOffset.left - domDimensionsCache.cellPointer.width / 2 - (0, _element.offset)(this.editorContainer).left + selectedCellWidth / 2 - currentScrollPosition.x, 10) + 'px';
  24534. }
  24535. }
  24536. };
  24537. MobileTextEditor.prototype.updateEditorData = function () {
  24538. var selected = this.instance.getSelected(),
  24539. selectedValue = this.instance.getDataAtCell(selected[0], selected[1]);
  24540. this.row = selected[0];
  24541. this.col = selected[1];
  24542. this.setValue(selectedValue);
  24543. this.updateEditorPosition();
  24544. };
  24545. MobileTextEditor.prototype.prepareAndSave = function () {
  24546. var val;
  24547. if (!this.valueChanged()) {
  24548. return;
  24549. }
  24550. if (this.instance.getSettings().trimWhitespace) {
  24551. val = [[String.prototype.trim.call(this.getValue())]];
  24552. } else {
  24553. val = [[this.getValue()]];
  24554. }
  24555. this.saveValue(val);
  24556. };
  24557. MobileTextEditor.prototype.bindEvents = function () {
  24558. var that = this;
  24559. this.eventManager.addEventListener(this.controls.leftButton, 'touchend', function (event) {
  24560. that.prepareAndSave();
  24561. that.instance.selection.transformStart(0, -1, null, true);
  24562. that.updateEditorData();
  24563. event.preventDefault();
  24564. });
  24565. this.eventManager.addEventListener(this.controls.rightButton, 'touchend', function (event) {
  24566. that.prepareAndSave();
  24567. that.instance.selection.transformStart(0, 1, null, true);
  24568. that.updateEditorData();
  24569. event.preventDefault();
  24570. });
  24571. this.eventManager.addEventListener(this.controls.upButton, 'touchend', function (event) {
  24572. that.prepareAndSave();
  24573. that.instance.selection.transformStart(-1, 0, null, true);
  24574. that.updateEditorData();
  24575. event.preventDefault();
  24576. });
  24577. this.eventManager.addEventListener(this.controls.downButton, 'touchend', function (event) {
  24578. that.prepareAndSave();
  24579. that.instance.selection.transformStart(1, 0, null, true);
  24580. that.updateEditorData();
  24581. event.preventDefault();
  24582. });
  24583. this.eventManager.addEventListener(this.moveHandle, 'touchstart', function (event) {
  24584. if (event.touches.length == 1) {
  24585. var touch = event.touches[0];
  24586. var onTouchPosition = {
  24587. x: that.editorContainer.offsetLeft,
  24588. y: that.editorContainer.offsetTop
  24589. };
  24590. var onTouchOffset = {
  24591. x: touch.pageX - onTouchPosition.x,
  24592. y: touch.pageY - onTouchPosition.y
  24593. };
  24594. that.eventManager.addEventListener(this, 'touchmove', function (event) {
  24595. var touch = event.touches[0];
  24596. that.updateEditorPosition(touch.pageX - onTouchOffset.x, touch.pageY - onTouchOffset.y);
  24597. that.hideCellPointer();
  24598. event.preventDefault();
  24599. });
  24600. }
  24601. });
  24602. this.eventManager.addEventListener(document.body, 'touchend', function (event) {
  24603. if (!(0, _element.isChildOf)(event.target, that.editorContainer) && !(0, _element.isChildOf)(event.target, that.instance.rootElement)) {
  24604. that.close();
  24605. }
  24606. });
  24607. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.leftOverlay.holder, 'scroll', function (event) {
  24608. if (that.instance.view.wt.wtOverlays.leftOverlay.trimmingContainer != window) {
  24609. that.hideCellPointer();
  24610. }
  24611. });
  24612. this.eventManager.addEventListener(this.instance.view.wt.wtOverlays.topOverlay.holder, 'scroll', function (event) {
  24613. if (that.instance.view.wt.wtOverlays.topOverlay.trimmingContainer != window) {
  24614. that.hideCellPointer();
  24615. }
  24616. });
  24617. };
  24618. MobileTextEditor.prototype.destroy = function () {
  24619. this.eventManager.clear();
  24620. this.editorContainer.parentNode.removeChild(this.editorContainer);
  24621. };
  24622. exports.default = MobileTextEditor;
  24623. /***/ }),
  24624. /* 205 */
  24625. /***/ (function(module, exports, __webpack_require__) {
  24626. "use strict";
  24627. exports.__esModule = true;
  24628. 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; }; }();
  24629. 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); } };
  24630. var _numbro = __webpack_require__(87);
  24631. var _numbro2 = _interopRequireDefault(_numbro);
  24632. var _textEditor = __webpack_require__(43);
  24633. var _textEditor2 = _interopRequireDefault(_textEditor);
  24634. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24635. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24636. 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; }
  24637. 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; }
  24638. /**
  24639. * @private
  24640. * @editor NumericEditor
  24641. * @class NumericEditor
  24642. * @dependencies TextEditor numbro
  24643. */
  24644. var NumericEditor = function (_TextEditor) {
  24645. _inherits(NumericEditor, _TextEditor);
  24646. function NumericEditor() {
  24647. _classCallCheck(this, NumericEditor);
  24648. return _possibleConstructorReturn(this, (NumericEditor.__proto__ || Object.getPrototypeOf(NumericEditor)).apply(this, arguments));
  24649. }
  24650. _createClass(NumericEditor, [{
  24651. key: 'beginEditing',
  24652. /**
  24653. * @param {*} initialValue
  24654. */
  24655. value: function beginEditing(initialValue) {
  24656. if (typeof initialValue === 'undefined' && this.originalValue) {
  24657. if (typeof this.cellProperties.language !== 'undefined') {
  24658. _numbro2.default.culture(this.cellProperties.language);
  24659. }
  24660. var decimalDelimiter = _numbro2.default.cultureData().delimiters.decimal;
  24661. initialValue = ('' + this.originalValue).replace('.', decimalDelimiter);
  24662. }
  24663. _get(NumericEditor.prototype.__proto__ || Object.getPrototypeOf(NumericEditor.prototype), 'beginEditing', this).call(this, initialValue);
  24664. }
  24665. }]);
  24666. return NumericEditor;
  24667. }(_textEditor2.default);
  24668. exports.default = NumericEditor;
  24669. /***/ }),
  24670. /* 206 */
  24671. /***/ (function(module, exports, __webpack_require__) {
  24672. "use strict";
  24673. exports.__esModule = true;
  24674. 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; }; }();
  24675. 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); } };
  24676. var _element = __webpack_require__(0);
  24677. var _textEditor = __webpack_require__(43);
  24678. var _textEditor2 = _interopRequireDefault(_textEditor);
  24679. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24680. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  24681. 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; }
  24682. 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; }
  24683. /**
  24684. * @private
  24685. * @editor PasswordEditor
  24686. * @class PasswordEditor
  24687. * @dependencies TextEditor
  24688. */
  24689. var PasswordEditor = function (_TextEditor) {
  24690. _inherits(PasswordEditor, _TextEditor);
  24691. function PasswordEditor() {
  24692. _classCallCheck(this, PasswordEditor);
  24693. return _possibleConstructorReturn(this, (PasswordEditor.__proto__ || Object.getPrototypeOf(PasswordEditor)).apply(this, arguments));
  24694. }
  24695. _createClass(PasswordEditor, [{
  24696. key: 'createElements',
  24697. value: function createElements() {
  24698. _get(PasswordEditor.prototype.__proto__ || Object.getPrototypeOf(PasswordEditor.prototype), 'createElements', this).call(this);
  24699. this.TEXTAREA = document.createElement('input');
  24700. this.TEXTAREA.setAttribute('type', 'password');
  24701. this.TEXTAREA.className = 'handsontableInput';
  24702. this.textareaStyle = this.TEXTAREA.style;
  24703. this.textareaStyle.width = 0;
  24704. this.textareaStyle.height = 0;
  24705. (0, _element.empty)(this.TEXTAREA_PARENT);
  24706. this.TEXTAREA_PARENT.appendChild(this.TEXTAREA);
  24707. }
  24708. }]);
  24709. return PasswordEditor;
  24710. }(_textEditor2.default);
  24711. exports.default = PasswordEditor;
  24712. /***/ }),
  24713. /* 207 */
  24714. /***/ (function(module, exports, __webpack_require__) {
  24715. "use strict";
  24716. exports.__esModule = true;
  24717. 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; };
  24718. var _element = __webpack_require__(0);
  24719. var _event = __webpack_require__(7);
  24720. var _unicode = __webpack_require__(16);
  24721. var _baseEditor = __webpack_require__(36);
  24722. var _baseEditor2 = _interopRequireDefault(_baseEditor);
  24723. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  24724. var SelectEditor = _baseEditor2.default.prototype.extend();
  24725. /**
  24726. * @private
  24727. * @editor SelectEditor
  24728. * @class SelectEditor
  24729. */
  24730. SelectEditor.prototype.init = function () {
  24731. this.select = document.createElement('SELECT');
  24732. (0, _element.addClass)(this.select, 'htSelectEditor');
  24733. this.select.style.display = 'none';
  24734. this.instance.rootElement.appendChild(this.select);
  24735. this.registerHooks();
  24736. };
  24737. SelectEditor.prototype.registerHooks = function () {
  24738. var _this = this;
  24739. this.instance.addHook('afterScrollHorizontally', function () {
  24740. return _this.refreshDimensions();
  24741. });
  24742. this.instance.addHook('afterScrollVertically', function () {
  24743. return _this.refreshDimensions();
  24744. });
  24745. this.instance.addHook('afterColumnResize', function () {
  24746. return _this.refreshDimensions();
  24747. });
  24748. this.instance.addHook('afterRowResize', function () {
  24749. return _this.refreshDimensions();
  24750. });
  24751. };
  24752. SelectEditor.prototype.prepare = function () {
  24753. _baseEditor2.default.prototype.prepare.apply(this, arguments);
  24754. var selectOptions = this.cellProperties.selectOptions;
  24755. var options;
  24756. if (typeof selectOptions == 'function') {
  24757. options = this.prepareOptions(selectOptions(this.row, this.col, this.prop));
  24758. } else {
  24759. options = this.prepareOptions(selectOptions);
  24760. }
  24761. (0, _element.empty)(this.select);
  24762. for (var option in options) {
  24763. if (Object.prototype.hasOwnProperty.call(options, option)) {
  24764. var optionElement = document.createElement('OPTION');
  24765. optionElement.value = option;
  24766. (0, _element.fastInnerHTML)(optionElement, options[option]);
  24767. this.select.appendChild(optionElement);
  24768. }
  24769. }
  24770. };
  24771. SelectEditor.prototype.prepareOptions = function (optionsToPrepare) {
  24772. var preparedOptions = {};
  24773. if (Array.isArray(optionsToPrepare)) {
  24774. for (var i = 0, len = optionsToPrepare.length; i < len; i++) {
  24775. preparedOptions[optionsToPrepare[i]] = optionsToPrepare[i];
  24776. }
  24777. } else if ((typeof optionsToPrepare === 'undefined' ? 'undefined' : _typeof(optionsToPrepare)) == 'object') {
  24778. preparedOptions = optionsToPrepare;
  24779. }
  24780. return preparedOptions;
  24781. };
  24782. SelectEditor.prototype.getValue = function () {
  24783. return this.select.value;
  24784. };
  24785. SelectEditor.prototype.setValue = function (value) {
  24786. this.select.value = value;
  24787. };
  24788. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  24789. var instance = this;
  24790. var editor = instance.getActiveEditor();
  24791. switch (event.keyCode) {
  24792. case _unicode.KEY_CODES.ARROW_UP:
  24793. var previousOptionIndex = editor.select.selectedIndex - 1;
  24794. if (previousOptionIndex >= 0) {
  24795. editor.select[previousOptionIndex].selected = true;
  24796. }
  24797. (0, _event.stopImmediatePropagation)(event);
  24798. event.preventDefault();
  24799. break;
  24800. case _unicode.KEY_CODES.ARROW_DOWN:
  24801. var nextOptionIndex = editor.select.selectedIndex + 1;
  24802. if (nextOptionIndex <= editor.select.length - 1) {
  24803. editor.select[nextOptionIndex].selected = true;
  24804. }
  24805. (0, _event.stopImmediatePropagation)(event);
  24806. event.preventDefault();
  24807. break;
  24808. default:
  24809. break;
  24810. }
  24811. };
  24812. SelectEditor.prototype.open = function () {
  24813. this._opened = true;
  24814. this.refreshDimensions();
  24815. this.select.style.display = '';
  24816. this.instance.addHook('beforeKeyDown', onBeforeKeyDown);
  24817. };
  24818. SelectEditor.prototype.close = function () {
  24819. this._opened = false;
  24820. this.select.style.display = 'none';
  24821. this.instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  24822. };
  24823. SelectEditor.prototype.focus = function () {
  24824. this.select.focus();
  24825. };
  24826. SelectEditor.prototype.refreshValue = function () {
  24827. var sourceData = this.instance.getSourceDataAtCell(this.row, this.prop);
  24828. this.originalValue = sourceData;
  24829. this.setValue(sourceData);
  24830. this.refreshDimensions();
  24831. };
  24832. SelectEditor.prototype.refreshDimensions = function () {
  24833. if (this.state !== _baseEditor.EditorState.EDITING) {
  24834. return;
  24835. }
  24836. this.TD = this.getEditedCell();
  24837. // TD is outside of the viewport.
  24838. if (!this.TD) {
  24839. this.close();
  24840. return;
  24841. }
  24842. var width = (0, _element.outerWidth)(this.TD) + 1,
  24843. height = (0, _element.outerHeight)(this.TD) + 1,
  24844. currentOffset = (0, _element.offset)(this.TD),
  24845. containerOffset = (0, _element.offset)(this.instance.rootElement),
  24846. scrollableContainer = (0, _element.getScrollableElement)(this.TD),
  24847. editTop = currentOffset.top - containerOffset.top - 1 - (scrollableContainer.scrollTop || 0),
  24848. editLeft = currentOffset.left - containerOffset.left - 1 - (scrollableContainer.scrollLeft || 0),
  24849. editorSection = this.checkEditorSection(),
  24850. cssTransformOffset;
  24851. var settings = this.instance.getSettings();
  24852. var rowHeadersCount = settings.rowHeaders ? 1 : 0;
  24853. var colHeadersCount = settings.colHeaders ? 1 : 0;
  24854. switch (editorSection) {
  24855. case 'top':
  24856. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.holder.parentNode);
  24857. break;
  24858. case 'left':
  24859. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.holder.parentNode);
  24860. break;
  24861. case 'top-left-corner':
  24862. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  24863. break;
  24864. case 'bottom-left-corner':
  24865. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  24866. break;
  24867. case 'bottom':
  24868. cssTransformOffset = (0, _element.getCssTransform)(this.instance.view.wt.wtOverlays.bottomOverlay.clone.wtTable.holder.parentNode);
  24869. break;
  24870. default:
  24871. break;
  24872. }
  24873. if (this.instance.getSelected()[0] === 0) {
  24874. editTop += 1;
  24875. }
  24876. if (this.instance.getSelected()[1] === 0) {
  24877. editLeft += 1;
  24878. }
  24879. var selectStyle = this.select.style;
  24880. if (cssTransformOffset && cssTransformOffset != -1) {
  24881. selectStyle[cssTransformOffset[0]] = cssTransformOffset[1];
  24882. } else {
  24883. (0, _element.resetCssTransform)(this.select);
  24884. }
  24885. var cellComputedStyle = (0, _element.getComputedStyle)(this.TD);
  24886. if (parseInt(cellComputedStyle.borderTopWidth, 10) > 0) {
  24887. height -= 1;
  24888. }
  24889. if (parseInt(cellComputedStyle.borderLeftWidth, 10) > 0) {
  24890. width -= 1;
  24891. }
  24892. selectStyle.height = height + 'px';
  24893. selectStyle.minWidth = width + 'px';
  24894. selectStyle.top = editTop + 'px';
  24895. selectStyle.left = editLeft + 'px';
  24896. selectStyle.margin = '0px';
  24897. };
  24898. SelectEditor.prototype.getEditedCell = function () {
  24899. var editorSection = this.checkEditorSection(),
  24900. editedCell;
  24901. switch (editorSection) {
  24902. case 'top':
  24903. editedCell = this.instance.view.wt.wtOverlays.topOverlay.clone.wtTable.getCell({
  24904. row: this.row,
  24905. col: this.col
  24906. });
  24907. this.select.style.zIndex = 101;
  24908. break;
  24909. case 'corner':
  24910. editedCell = this.instance.view.wt.wtOverlays.topLeftCornerOverlay.clone.wtTable.getCell({
  24911. row: this.row,
  24912. col: this.col
  24913. });
  24914. this.select.style.zIndex = 103;
  24915. break;
  24916. case 'left':
  24917. editedCell = this.instance.view.wt.wtOverlays.leftOverlay.clone.wtTable.getCell({
  24918. row: this.row,
  24919. col: this.col
  24920. });
  24921. this.select.style.zIndex = 102;
  24922. break;
  24923. default:
  24924. editedCell = this.instance.getCell(this.row, this.col);
  24925. this.select.style.zIndex = '';
  24926. break;
  24927. }
  24928. return editedCell != -1 && editedCell != -2 ? editedCell : void 0;
  24929. };
  24930. exports.default = SelectEditor;
  24931. /***/ }),
  24932. /* 208 */
  24933. /***/ (function(module, exports, __webpack_require__) {
  24934. "use strict";
  24935. __webpack_require__(97);
  24936. __webpack_require__(114);
  24937. __webpack_require__(123);
  24938. __webpack_require__(124);
  24939. __webpack_require__(108);
  24940. __webpack_require__(122);
  24941. __webpack_require__(105);
  24942. __webpack_require__(106);
  24943. __webpack_require__(107);
  24944. __webpack_require__(96);
  24945. __webpack_require__(119);
  24946. __webpack_require__(117);
  24947. __webpack_require__(115);
  24948. __webpack_require__(120);
  24949. __webpack_require__(121);
  24950. __webpack_require__(116);
  24951. __webpack_require__(118);
  24952. __webpack_require__(109);
  24953. __webpack_require__(110);
  24954. __webpack_require__(111);
  24955. __webpack_require__(113);
  24956. __webpack_require__(112);
  24957. __webpack_require__(94);
  24958. __webpack_require__(95);
  24959. __webpack_require__(90);
  24960. __webpack_require__(93);
  24961. __webpack_require__(92);
  24962. __webpack_require__(91);
  24963. __webpack_require__(67);
  24964. __webpack_require__(99);
  24965. __webpack_require__(100);
  24966. __webpack_require__(102);
  24967. __webpack_require__(101);
  24968. __webpack_require__(98);
  24969. __webpack_require__(104);
  24970. __webpack_require__(103);
  24971. __webpack_require__(125);
  24972. __webpack_require__(128);
  24973. __webpack_require__(126);
  24974. __webpack_require__(127);
  24975. __webpack_require__(130);
  24976. __webpack_require__(129);
  24977. __webpack_require__(132);
  24978. __webpack_require__(131);
  24979. __webpack_require__(179);
  24980. __webpack_require__(180);
  24981. __webpack_require__(181);
  24982. var _editors = __webpack_require__(14);
  24983. var _renderers = __webpack_require__(9);
  24984. var _validators = __webpack_require__(26);
  24985. var _cellTypes = __webpack_require__(62);
  24986. var _core = __webpack_require__(63);
  24987. var _core2 = _interopRequireDefault(_core);
  24988. var _jquery = __webpack_require__(177);
  24989. var _jquery2 = _interopRequireDefault(_jquery);
  24990. var _eventManager = __webpack_require__(4);
  24991. var _eventManager2 = _interopRequireDefault(_eventManager);
  24992. var _pluginHooks = __webpack_require__(8);
  24993. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  24994. var _ghostTable = __webpack_require__(66);
  24995. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  24996. var _array = __webpack_require__(2);
  24997. var arrayHelpers = _interopRequireWildcard(_array);
  24998. var _browser = __webpack_require__(25);
  24999. var browserHelpers = _interopRequireWildcard(_browser);
  25000. var _data = __webpack_require__(64);
  25001. var dataHelpers = _interopRequireWildcard(_data);
  25002. var _date = __webpack_require__(89);
  25003. var dateHelpers = _interopRequireWildcard(_date);
  25004. var _feature = __webpack_require__(34);
  25005. var featureHelpers = _interopRequireWildcard(_feature);
  25006. var _function = __webpack_require__(35);
  25007. var functionHelpers = _interopRequireWildcard(_function);
  25008. var _mixed = __webpack_require__(20);
  25009. var mixedHelpers = _interopRequireWildcard(_mixed);
  25010. var _number = __webpack_require__(6);
  25011. var numberHelpers = _interopRequireWildcard(_number);
  25012. var _object = __webpack_require__(1);
  25013. var objectHelpers = _interopRequireWildcard(_object);
  25014. var _setting = __webpack_require__(65);
  25015. var settingHelpers = _interopRequireWildcard(_setting);
  25016. var _string = __webpack_require__(27);
  25017. var stringHelpers = _interopRequireWildcard(_string);
  25018. var _unicode = __webpack_require__(16);
  25019. var unicodeHelpers = _interopRequireWildcard(_unicode);
  25020. var _element = __webpack_require__(0);
  25021. var domHelpers = _interopRequireWildcard(_element);
  25022. var _event = __webpack_require__(7);
  25023. var domEventHelpers = _interopRequireWildcard(_event);
  25024. var _index = __webpack_require__(178);
  25025. var plugins = _interopRequireWildcard(_index);
  25026. var _plugins = __webpack_require__(5);
  25027. var _defaultSettings = __webpack_require__(88);
  25028. var _defaultSettings2 = _interopRequireDefault(_defaultSettings);
  25029. 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; } }
  25030. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25031. function Handsontable(rootElement, userSettings) {
  25032. var instance = new _core2.default(rootElement, userSettings || {});
  25033. instance.init();
  25034. return instance;
  25035. }
  25036. (0, _jquery2.default)(Handsontable);
  25037. Handsontable.Core = _core2.default;
  25038. Handsontable.DefaultSettings = _defaultSettings2.default;
  25039. Handsontable.EventManager = _eventManager2.default;
  25040. Handsontable._getListenersCounter = _eventManager.getListenersCounter; // For MemoryLeak tests
  25041. Handsontable.buildDate = "2017-07-27T11:34:25.509Z";
  25042. Handsontable.packageName = "handsontable";
  25043. Handsontable.version = "0.34.0";
  25044. var baseVersion = undefined;
  25045. if (baseVersion) {
  25046. Handsontable.baseVersion = baseVersion;
  25047. }
  25048. // Export Hooks singleton
  25049. Handsontable.hooks = _pluginHooks2.default.getSingleton();
  25050. // TODO: Remove this exports after rewrite tests about this module
  25051. Handsontable.__GhostTable = _ghostTable2.default;
  25052. //
  25053. // Export all helpers to the Handsontable object
  25054. var HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, settingHelpers, stringHelpers, unicodeHelpers];
  25055. var DOM = [domHelpers, domEventHelpers];
  25056. Handsontable.helper = {};
  25057. Handsontable.dom = {};
  25058. // Fill general helpers.
  25059. arrayHelpers.arrayEach(HELPERS, function (helper) {
  25060. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  25061. if (key.charAt(0) !== '_') {
  25062. Handsontable.helper[key] = helper[key];
  25063. }
  25064. });
  25065. });
  25066. // Fill DOM helpers.
  25067. arrayHelpers.arrayEach(DOM, function (helper) {
  25068. arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), function (key) {
  25069. if (key.charAt(0) !== '_') {
  25070. Handsontable.dom[key] = helper[key];
  25071. }
  25072. });
  25073. });
  25074. // Export cell types.
  25075. Handsontable.cellTypes = {};
  25076. arrayHelpers.arrayEach((0, _cellTypes.getRegisteredCellTypeNames)(), function (cellTypeName) {
  25077. Handsontable.cellTypes[cellTypeName] = (0, _cellTypes.getCellType)(cellTypeName);
  25078. });
  25079. Handsontable.cellTypes.registerCellType = _cellTypes.registerCellType;
  25080. Handsontable.cellTypes.getCellType = _cellTypes.getCellType;
  25081. // Export all registered editors from the Handsontable.
  25082. Handsontable.editors = {};
  25083. arrayHelpers.arrayEach((0, _editors.getRegisteredEditorNames)(), function (editorName) {
  25084. Handsontable.editors[stringHelpers.toUpperCaseFirst(editorName) + 'Editor'] = (0, _editors.getEditor)(editorName);
  25085. });
  25086. Handsontable.editors.registerEditor = _editors.registerEditor;
  25087. Handsontable.editors.getEditor = _editors.getEditor;
  25088. // Export all registered renderers from the Handsontable.
  25089. Handsontable.renderers = {};
  25090. arrayHelpers.arrayEach((0, _renderers.getRegisteredRendererNames)(), function (rendererName) {
  25091. var renderer = (0, _renderers.getRenderer)(rendererName);
  25092. if (rendererName === 'base') {
  25093. Handsontable.renderers.cellDecorator = renderer;
  25094. }
  25095. Handsontable.renderers[stringHelpers.toUpperCaseFirst(rendererName) + 'Renderer'] = renderer;
  25096. });
  25097. Handsontable.renderers.registerRenderer = _renderers.registerRenderer;
  25098. Handsontable.renderers.getRenderer = _renderers.getRenderer;
  25099. // Export all registered validators from the Handsontable.
  25100. Handsontable.validators = {};
  25101. arrayHelpers.arrayEach((0, _validators.getRegisteredValidatorNames)(), function (validatorName) {
  25102. Handsontable.validators[stringHelpers.toUpperCaseFirst(validatorName) + 'Validator'] = (0, _validators.getValidator)(validatorName);
  25103. });
  25104. Handsontable.validators.registerValidator = _validators.registerValidator;
  25105. Handsontable.validators.getValidator = _validators.getValidator;
  25106. // Export all registered plugins from the Handsontable.
  25107. Handsontable.plugins = {};
  25108. arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), function (pluginName) {
  25109. var plugin = plugins[pluginName];
  25110. if (pluginName === 'Base') {
  25111. Handsontable.plugins[pluginName + 'Plugin'] = plugin;
  25112. } else {
  25113. Handsontable.plugins[pluginName] = plugin;
  25114. }
  25115. });
  25116. Handsontable.plugins.registerPlugin = _plugins.registerPlugin;
  25117. // Export Handsontable
  25118. module.exports = Handsontable;
  25119. /***/ }),
  25120. /* 209 */
  25121. /***/ (function(module, exports, __webpack_require__) {
  25122. "use strict";
  25123. exports.__esModule = true;
  25124. 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; };
  25125. function MultiMap() {
  25126. var map = {
  25127. arrayMap: [],
  25128. weakMap: new WeakMap()
  25129. };
  25130. return {
  25131. get: function get(key) {
  25132. if (canBeAnArrayMapKey(key)) {
  25133. return map.arrayMap[key];
  25134. } else if (canBeAWeakMapKey(key)) {
  25135. return map.weakMap.get(key);
  25136. }
  25137. },
  25138. set: function set(key, value) {
  25139. if (canBeAnArrayMapKey(key)) {
  25140. map.arrayMap[key] = value;
  25141. } else if (canBeAWeakMapKey(key)) {
  25142. map.weakMap.set(key, value);
  25143. } else {
  25144. throw new Error('Invalid key type');
  25145. }
  25146. },
  25147. delete: function _delete(key) {
  25148. if (canBeAnArrayMapKey(key)) {
  25149. delete map.arrayMap[key];
  25150. } else if (canBeAWeakMapKey(key)) {
  25151. map.weakMap.delete(key);
  25152. }
  25153. }
  25154. };
  25155. function canBeAnArrayMapKey(obj) {
  25156. return obj !== null && !isNaNSymbol(obj) && (typeof obj == 'string' || typeof obj == 'number');
  25157. }
  25158. function canBeAWeakMapKey(obj) {
  25159. return obj !== null && ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == 'object' || typeof obj == 'function');
  25160. }
  25161. function isNaNSymbol(obj) {
  25162. /* eslint-disable no-self-compare */
  25163. return obj !== obj; // NaN === NaN is always false
  25164. }
  25165. }
  25166. exports.default = MultiMap;
  25167. /***/ }),
  25168. /* 210 */
  25169. /***/ (function(module, exports, __webpack_require__) {
  25170. "use strict";
  25171. exports.__esModule = true;
  25172. 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"); } }; }();
  25173. 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); } };
  25174. 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; }; }();
  25175. var _base = __webpack_require__(12);
  25176. var _base2 = _interopRequireDefault(_base);
  25177. var _array = __webpack_require__(2);
  25178. var _feature = __webpack_require__(34);
  25179. var _element = __webpack_require__(0);
  25180. var _ghostTable = __webpack_require__(66);
  25181. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  25182. var _object = __webpack_require__(1);
  25183. var _number = __webpack_require__(6);
  25184. var _plugins = __webpack_require__(5);
  25185. var _samplesGenerator = __webpack_require__(154);
  25186. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  25187. var _string = __webpack_require__(27);
  25188. var _src = __webpack_require__(11);
  25189. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25190. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25191. 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; }
  25192. 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; }
  25193. var privatePool = new WeakMap();
  25194. /**
  25195. * @plugin AutoColumnSize
  25196. *
  25197. * @description
  25198. * This plugin allows to set column widths based on their widest cells.
  25199. *
  25200. * By default, the plugin is declared as `undefined`, which makes it enabled (same as if it was declared as `true`).
  25201. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the widths of all cells to
  25202. * resize the columns accordingly.
  25203. * If you experience problems with the performance, try turning this feature off and declaring the column widths manually.
  25204. *
  25205. * Column width calculations are divided into sync and async part. Each of this parts has their own advantages and
  25206. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  25207. * block the browser UI.
  25208. *
  25209. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  25210. * ```js
  25211. * ...
  25212. * // as a number (300 columns in sync, rest async)
  25213. * autoColumnSize: {syncLimit: 300},
  25214. * ...
  25215. *
  25216. * ...
  25217. * // as a string (percent)
  25218. * autoColumnSize: {syncLimit: '40%'},
  25219. * ...
  25220. * ```
  25221. *
  25222. * To configure this plugin see {@link Options#autoColumnSize}.
  25223. *
  25224. * @example
  25225. * ```js
  25226. * ...
  25227. * var hot = new Handsontable(document.getElementById('example'), {
  25228. * date: getData(),
  25229. * autoColumnSize: true
  25230. * });
  25231. * // Access to plugin instance:
  25232. * var plugin = hot.getPlugin('autoColumnSize');
  25233. *
  25234. * plugin.getColumnWidth(4);
  25235. *
  25236. * if (plugin.isEnabled()) {
  25237. * // code...
  25238. * }
  25239. * ...
  25240. * ```
  25241. */
  25242. var AutoColumnSize = function (_BasePlugin) {
  25243. _inherits(AutoColumnSize, _BasePlugin);
  25244. _createClass(AutoColumnSize, null, [{
  25245. key: 'CALCULATION_STEP',
  25246. get: function get() {
  25247. return 50;
  25248. }
  25249. }, {
  25250. key: 'SYNC_CALCULATION_LIMIT',
  25251. get: function get() {
  25252. return 50;
  25253. }
  25254. }]);
  25255. function AutoColumnSize(hotInstance) {
  25256. _classCallCheck(this, AutoColumnSize);
  25257. var _this = _possibleConstructorReturn(this, (AutoColumnSize.__proto__ || Object.getPrototypeOf(AutoColumnSize)).call(this, hotInstance));
  25258. privatePool.set(_this, {
  25259. /**
  25260. * Cached column header names. It is used to diff current column headers with previous state and detect which
  25261. * columns width should be updated.
  25262. *
  25263. * @private
  25264. * @type {Array}
  25265. */
  25266. cachedColumnHeaders: []
  25267. });
  25268. /**
  25269. * Cached columns widths.
  25270. *
  25271. * @type {Array}
  25272. */
  25273. _this.widths = [];
  25274. /**
  25275. * Instance of {@link GhostTable} for rows and columns size calculations.
  25276. *
  25277. * @type {GhostTable}
  25278. */
  25279. _this.ghostTable = new _ghostTable2.default(_this.hot);
  25280. /**
  25281. * Instance of {@link SamplesGenerator} for generating samples necessary for columns width calculations.
  25282. *
  25283. * @type {SamplesGenerator}
  25284. */
  25285. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  25286. return _this.hot.getDataAtCell(row, col);
  25287. });
  25288. /**
  25289. * `true` only if the first calculation was performed
  25290. *
  25291. * @type {Boolean}
  25292. */
  25293. _this.firstCalculation = true;
  25294. /**
  25295. * `true` if the size calculation is in progress.
  25296. *
  25297. * @type {Boolean}
  25298. */
  25299. _this.inProgress = false;
  25300. // moved to constructor to allow auto-sizing the columns when the plugin is disabled
  25301. _this.addHook('beforeColumnResize', function (col, size, isDblClick) {
  25302. return _this.onBeforeColumnResize(col, size, isDblClick);
  25303. });
  25304. return _this;
  25305. }
  25306. /**
  25307. * Check if the plugin is enabled in the handsontable settings.
  25308. *
  25309. * @returns {Boolean}
  25310. */
  25311. _createClass(AutoColumnSize, [{
  25312. key: 'isEnabled',
  25313. value: function isEnabled() {
  25314. return this.hot.getSettings().autoColumnSize !== false && !this.hot.getSettings().colWidths;
  25315. }
  25316. /**
  25317. * Enable plugin for this Handsontable instance.
  25318. */
  25319. }, {
  25320. key: 'enablePlugin',
  25321. value: function enablePlugin() {
  25322. var _this2 = this;
  25323. if (this.enabled) {
  25324. return;
  25325. }
  25326. var setting = this.hot.getSettings().autoColumnSize;
  25327. if (setting && setting.useHeaders != null) {
  25328. this.ghostTable.setSetting('useHeaders', setting.useHeaders);
  25329. }
  25330. this.addHook('afterLoadData', function () {
  25331. return _this2.onAfterLoadData();
  25332. });
  25333. this.addHook('beforeChange', function (changes) {
  25334. return _this2.onBeforeChange(changes);
  25335. });
  25336. this.addHook('beforeRender', function (force) {
  25337. return _this2.onBeforeRender(force);
  25338. });
  25339. this.addHook('modifyColWidth', function (width, col) {
  25340. return _this2.getColumnWidth(col, width);
  25341. });
  25342. this.addHook('afterInit', function () {
  25343. return _this2.onAfterInit();
  25344. });
  25345. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'enablePlugin', this).call(this);
  25346. }
  25347. /**
  25348. * Update plugin state.
  25349. */
  25350. }, {
  25351. key: 'updatePlugin',
  25352. value: function updatePlugin() {
  25353. var changedColumns = this.findColumnsWhereHeaderWasChanged();
  25354. if (changedColumns.length) {
  25355. this.clearCache(changedColumns);
  25356. }
  25357. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'updatePlugin', this).call(this);
  25358. }
  25359. /**
  25360. * Disable plugin for this Handsontable instance.
  25361. */
  25362. }, {
  25363. key: 'disablePlugin',
  25364. value: function disablePlugin() {
  25365. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'disablePlugin', this).call(this);
  25366. }
  25367. /**
  25368. * Calculate a columns width.
  25369. *
  25370. * @param {Number|Object} colRange Column range object.
  25371. * @param {Number|Object} rowRange Row range object.
  25372. * @param {Boolean} [force=false] If `true` force calculate width even when value was cached earlier.
  25373. */
  25374. }, {
  25375. key: 'calculateColumnsWidth',
  25376. value: function calculateColumnsWidth() {
  25377. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  25378. var _this3 = this;
  25379. var rowRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countRows() - 1 };
  25380. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  25381. if (typeof colRange === 'number') {
  25382. colRange = { from: colRange, to: colRange };
  25383. }
  25384. if (typeof rowRange === 'number') {
  25385. rowRange = { from: rowRange, to: rowRange };
  25386. }
  25387. (0, _number.rangeEach)(colRange.from, colRange.to, function (col) {
  25388. if (force || _this3.widths[col] === void 0 && !_this3.hot._getColWidthFromSettings(col)) {
  25389. var samples = _this3.samplesGenerator.generateColumnSamples(col, rowRange);
  25390. samples.forEach(function (sample, col) {
  25391. return _this3.ghostTable.addColumn(col, sample);
  25392. });
  25393. }
  25394. });
  25395. if (this.ghostTable.columns.length) {
  25396. this.ghostTable.getWidths(function (col, width) {
  25397. _this3.widths[col] = width;
  25398. });
  25399. this.ghostTable.clean();
  25400. }
  25401. }
  25402. /**
  25403. * Calculate all columns width.
  25404. *
  25405. * @param {Object|Number} rowRange Row range object.
  25406. */
  25407. }, {
  25408. key: 'calculateAllColumnsWidth',
  25409. value: function calculateAllColumnsWidth() {
  25410. var _this4 = this;
  25411. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  25412. var current = 0;
  25413. var length = this.hot.countCols() - 1;
  25414. var timer = null;
  25415. this.inProgress = true;
  25416. var loop = function loop() {
  25417. // When hot was destroyed after calculating finished cancel frame
  25418. if (!_this4.hot) {
  25419. (0, _feature.cancelAnimationFrame)(timer);
  25420. _this4.inProgress = false;
  25421. return;
  25422. }
  25423. _this4.calculateColumnsWidth({
  25424. from: current,
  25425. to: Math.min(current + AutoColumnSize.CALCULATION_STEP, length)
  25426. }, rowRange);
  25427. current = current + AutoColumnSize.CALCULATION_STEP + 1;
  25428. if (current < length) {
  25429. timer = (0, _feature.requestAnimationFrame)(loop);
  25430. } else {
  25431. (0, _feature.cancelAnimationFrame)(timer);
  25432. _this4.inProgress = false;
  25433. // @TODO Should call once per render cycle, currently fired separately in different plugins
  25434. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  25435. // tmp
  25436. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  25437. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  25438. }
  25439. }
  25440. };
  25441. // sync
  25442. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  25443. this.calculateColumnsWidth({ from: 0, to: this.getSyncCalculationLimit() }, rowRange);
  25444. this.firstCalculation = false;
  25445. current = this.getSyncCalculationLimit() + 1;
  25446. }
  25447. // async
  25448. if (current < length) {
  25449. loop();
  25450. } else {
  25451. this.inProgress = false;
  25452. }
  25453. }
  25454. /**
  25455. * Set the sampling options.
  25456. *
  25457. * @private
  25458. */
  25459. }, {
  25460. key: 'setSamplingOptions',
  25461. value: function setSamplingOptions() {
  25462. var setting = this.hot.getSettings().autoColumnSize;
  25463. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoColumnSize.samplingRatio : void 0;
  25464. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoColumnSize.allowSampleDuplicates : void 0;
  25465. if (samplingRatio && !isNaN(samplingRatio)) {
  25466. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  25467. }
  25468. if (allowSampleDuplicates) {
  25469. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  25470. }
  25471. }
  25472. /**
  25473. * Recalculate all columns width (overwrite cache values).
  25474. */
  25475. }, {
  25476. key: 'recalculateAllColumnsWidth',
  25477. value: function recalculateAllColumnsWidth() {
  25478. if (this.hot.view && (0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  25479. this.clearCache();
  25480. this.calculateAllColumnsWidth();
  25481. }
  25482. }
  25483. /**
  25484. * Get value which tells how many columns should be calculated synchronously. Rest of the columns will be calculated asynchronously.
  25485. *
  25486. * @returns {Number}
  25487. */
  25488. }, {
  25489. key: 'getSyncCalculationLimit',
  25490. value: function getSyncCalculationLimit() {
  25491. /* eslint-disable no-bitwise */
  25492. var limit = AutoColumnSize.SYNC_CALCULATION_LIMIT;
  25493. var colsLimit = this.hot.countCols() - 1;
  25494. if ((0, _object.isObject)(this.hot.getSettings().autoColumnSize)) {
  25495. limit = this.hot.getSettings().autoColumnSize.syncLimit;
  25496. if ((0, _string.isPercentValue)(limit)) {
  25497. limit = (0, _number.valueAccordingPercent)(colsLimit, limit);
  25498. } else {
  25499. // Force to Number
  25500. limit >>= 0;
  25501. }
  25502. }
  25503. return Math.min(limit, colsLimit);
  25504. }
  25505. /**
  25506. * Get the calculated column width.
  25507. *
  25508. * @param {Number} col Column index.
  25509. * @param {Number} [defaultWidth] Default column width. It will be picked up if no calculated width found.
  25510. * @param {Boolean} [keepMinimum=true] If `true` then returned value won't be smaller then 50 (default column width).
  25511. * @returns {Number}
  25512. */
  25513. }, {
  25514. key: 'getColumnWidth',
  25515. value: function getColumnWidth(col) {
  25516. var defaultWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  25517. var keepMinimum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  25518. var width = defaultWidth;
  25519. if (width === void 0) {
  25520. width = this.widths[col];
  25521. if (keepMinimum && typeof width === 'number') {
  25522. width = Math.max(width, _src.ViewportColumnsCalculator.DEFAULT_WIDTH);
  25523. }
  25524. }
  25525. return width;
  25526. }
  25527. /**
  25528. * Get the first visible column.
  25529. *
  25530. * @returns {Number} Returns column index or -1 if table is not rendered.
  25531. */
  25532. }, {
  25533. key: 'getFirstVisibleColumn',
  25534. value: function getFirstVisibleColumn() {
  25535. var wot = this.hot.view.wt;
  25536. if (wot.wtViewport.columnsVisibleCalculator) {
  25537. return wot.wtTable.getFirstVisibleColumn();
  25538. }
  25539. if (wot.wtViewport.columnsRenderCalculator) {
  25540. return wot.wtTable.getFirstRenderedColumn();
  25541. }
  25542. return -1;
  25543. }
  25544. /**
  25545. * Get the last visible column.
  25546. *
  25547. * @returns {Number} Returns column index or -1 if table is not rendered.
  25548. */
  25549. }, {
  25550. key: 'getLastVisibleColumn',
  25551. value: function getLastVisibleColumn() {
  25552. var wot = this.hot.view.wt;
  25553. if (wot.wtViewport.columnsVisibleCalculator) {
  25554. return wot.wtTable.getLastVisibleColumn();
  25555. }
  25556. if (wot.wtViewport.columnsRenderCalculator) {
  25557. return wot.wtTable.getLastRenderedColumn();
  25558. }
  25559. return -1;
  25560. }
  25561. /**
  25562. * Collects all columns which titles has been changed in comparison to the previous state.
  25563. *
  25564. * @returns {Array} It returns an array of physical column indexes.
  25565. */
  25566. }, {
  25567. key: 'findColumnsWhereHeaderWasChanged',
  25568. value: function findColumnsWhereHeaderWasChanged() {
  25569. var columnHeaders = this.hot.getColHeader();
  25570. var _privatePool$get = privatePool.get(this),
  25571. cachedColumnHeaders = _privatePool$get.cachedColumnHeaders;
  25572. var changedColumns = (0, _array.arrayReduce)(columnHeaders, function (acc, columnTitle, physicalColumn) {
  25573. var cachedColumnsLength = cachedColumnHeaders.length;
  25574. if (cachedColumnsLength - 1 < physicalColumn || cachedColumnHeaders[physicalColumn] !== columnTitle) {
  25575. acc.push(physicalColumn);
  25576. }
  25577. if (cachedColumnsLength - 1 < physicalColumn) {
  25578. cachedColumnHeaders.push(columnTitle);
  25579. } else {
  25580. cachedColumnHeaders[physicalColumn] = columnTitle;
  25581. }
  25582. return acc;
  25583. }, []);
  25584. return changedColumns;
  25585. }
  25586. /**
  25587. * Clear cache of calculated column widths. If you want to clear only selected columns pass an array with their indexes.
  25588. * Otherwise whole cache will be cleared.
  25589. *
  25590. * @param {Array} [columns=[]] List of column indexes (physical indexes) to clear.
  25591. */
  25592. }, {
  25593. key: 'clearCache',
  25594. value: function clearCache() {
  25595. var _this5 = this;
  25596. var columns = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  25597. if (columns.length) {
  25598. (0, _array.arrayEach)(columns, function (physicalIndex) {
  25599. _this5.widths[physicalIndex] = void 0;
  25600. });
  25601. } else {
  25602. this.widths.length = 0;
  25603. }
  25604. }
  25605. /**
  25606. * Check if all widths were calculated. If not then return `true` (need recalculate).
  25607. *
  25608. * @returns {Boolean}
  25609. */
  25610. }, {
  25611. key: 'isNeedRecalculate',
  25612. value: function isNeedRecalculate() {
  25613. return !!(0, _array.arrayFilter)(this.widths, function (item) {
  25614. return item === void 0;
  25615. }).length;
  25616. }
  25617. /**
  25618. * On before render listener.
  25619. *
  25620. * @private
  25621. */
  25622. }, {
  25623. key: 'onBeforeRender',
  25624. value: function onBeforeRender() {
  25625. var force = this.hot.renderCall;
  25626. var rowsCount = this.hot.countRows();
  25627. // Keep last column widths unchanged for situation when all rows was deleted or trimmed (pro #6)
  25628. if (!rowsCount) {
  25629. return;
  25630. }
  25631. this.calculateColumnsWidth({ from: this.getFirstVisibleColumn(), to: this.getLastVisibleColumn() }, void 0, force);
  25632. if (this.isNeedRecalculate() && !this.inProgress) {
  25633. this.calculateAllColumnsWidth();
  25634. }
  25635. }
  25636. /**
  25637. * On after load data listener.
  25638. *
  25639. * @private
  25640. */
  25641. }, {
  25642. key: 'onAfterLoadData',
  25643. value: function onAfterLoadData() {
  25644. var _this6 = this;
  25645. if (this.hot.view) {
  25646. this.recalculateAllColumnsWidth();
  25647. } else {
  25648. // first load - initialization
  25649. setTimeout(function () {
  25650. if (_this6.hot) {
  25651. _this6.recalculateAllColumnsWidth();
  25652. }
  25653. }, 0);
  25654. }
  25655. }
  25656. /**
  25657. * On before change listener.
  25658. *
  25659. * @private
  25660. * @param {Array} changes
  25661. */
  25662. }, {
  25663. key: 'onBeforeChange',
  25664. value: function onBeforeChange(changes) {
  25665. var _this7 = this;
  25666. var changedColumns = (0, _array.arrayMap)(changes, function (_ref) {
  25667. var _ref2 = _slicedToArray(_ref, 2),
  25668. row = _ref2[0],
  25669. column = _ref2[1];
  25670. return _this7.hot.propToCol(column);
  25671. });
  25672. this.clearCache(changedColumns);
  25673. }
  25674. /**
  25675. * On before column resize listener.
  25676. *
  25677. * @private
  25678. * @param {Number} col
  25679. * @param {Number} size
  25680. * @param {Boolean} isDblClick
  25681. * @returns {Number}
  25682. */
  25683. }, {
  25684. key: 'onBeforeColumnResize',
  25685. value: function onBeforeColumnResize(col, size, isDblClick) {
  25686. if (isDblClick) {
  25687. this.calculateColumnsWidth(col, void 0, true);
  25688. size = this.getColumnWidth(col, void 0, false);
  25689. }
  25690. return size;
  25691. }
  25692. /**
  25693. * On after Handsontable init fill plugin with all necessary values.
  25694. *
  25695. * @private
  25696. */
  25697. }, {
  25698. key: 'onAfterInit',
  25699. value: function onAfterInit() {
  25700. privatePool.get(this).cachedColumnHeaders = this.hot.getColHeader();
  25701. }
  25702. /**
  25703. * Destroy plugin instance.
  25704. */
  25705. }, {
  25706. key: 'destroy',
  25707. value: function destroy() {
  25708. this.ghostTable.clean();
  25709. _get(AutoColumnSize.prototype.__proto__ || Object.getPrototypeOf(AutoColumnSize.prototype), 'destroy', this).call(this);
  25710. }
  25711. }]);
  25712. return AutoColumnSize;
  25713. }(_base2.default);
  25714. (0, _plugins.registerPlugin)('autoColumnSize', AutoColumnSize);
  25715. exports.default = AutoColumnSize;
  25716. /***/ }),
  25717. /* 211 */
  25718. /***/ (function(module, exports, __webpack_require__) {
  25719. "use strict";
  25720. exports.__esModule = true;
  25721. 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); } };
  25722. 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; }; }();
  25723. var _base = __webpack_require__(12);
  25724. var _base2 = _interopRequireDefault(_base);
  25725. var _array = __webpack_require__(2);
  25726. var _feature = __webpack_require__(34);
  25727. var _element = __webpack_require__(0);
  25728. var _ghostTable = __webpack_require__(66);
  25729. var _ghostTable2 = _interopRequireDefault(_ghostTable);
  25730. var _object = __webpack_require__(1);
  25731. var _number = __webpack_require__(6);
  25732. var _plugins = __webpack_require__(5);
  25733. var _samplesGenerator = __webpack_require__(154);
  25734. var _samplesGenerator2 = _interopRequireDefault(_samplesGenerator);
  25735. var _string = __webpack_require__(27);
  25736. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25737. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  25738. 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; }
  25739. 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; }
  25740. /**
  25741. * @plugin AutoRowSize
  25742. *
  25743. * @description
  25744. * This plugin allows to set row heights based on their highest cells.
  25745. *
  25746. * By default, the plugin is declared as `undefined`, which makes it disabled (same as if it was declared as `false`).
  25747. * Enabling this plugin may decrease the overall table performance, as it needs to calculate the heights of all cells to
  25748. * resize the rows accordingly.
  25749. * If you experience problems with the performance, try turning this feature off and declaring the row heights manually.
  25750. *
  25751. * Row height calculations are divided into sync and async part. Each of this parts has their own advantages and
  25752. * disadvantages. Synchronous calculations are faster but they block the browser UI, while the slower asynchronous operations don't
  25753. * block the browser UI.
  25754. *
  25755. * To configure the sync/async distribution, you can pass an absolute value (number of columns) or a percentage value to a config object:
  25756. * ```js
  25757. * ...
  25758. * // as a number (300 columns in sync, rest async)
  25759. * autoRowSize: {syncLimit: 300},
  25760. * ...
  25761. *
  25762. * ...
  25763. * // as a string (percent)
  25764. * autoRowSize: {syncLimit: '40%'},
  25765. * ...
  25766. * ```
  25767. *
  25768. * You can also use the `allowSampleDuplicates` option to allow sampling duplicate values when calculating the row height. Note, that this might have
  25769. * a negative impact on performance.
  25770. *
  25771. * To configure this plugin see {@link Options#autoRowSize}.
  25772. *
  25773. * @example
  25774. *
  25775. * ```js
  25776. * ...
  25777. * var hot = new Handsontable(document.getElementById('example'), {
  25778. * date: getData(),
  25779. * autoRowSize: true
  25780. * });
  25781. * // Access to plugin instance:
  25782. * var plugin = hot.getPlugin('autoRowSize');
  25783. *
  25784. * plugin.getRowHeight(4);
  25785. *
  25786. * if (plugin.isEnabled()) {
  25787. * // code...
  25788. * }
  25789. * ...
  25790. * ```
  25791. */
  25792. var AutoRowSize = function (_BasePlugin) {
  25793. _inherits(AutoRowSize, _BasePlugin);
  25794. _createClass(AutoRowSize, null, [{
  25795. key: 'CALCULATION_STEP',
  25796. get: function get() {
  25797. return 50;
  25798. }
  25799. }, {
  25800. key: 'SYNC_CALCULATION_LIMIT',
  25801. get: function get() {
  25802. return 500;
  25803. }
  25804. }]);
  25805. function AutoRowSize(hotInstance) {
  25806. _classCallCheck(this, AutoRowSize);
  25807. /**
  25808. * Cached rows heights.
  25809. *
  25810. * @type {Array}
  25811. */
  25812. var _this = _possibleConstructorReturn(this, (AutoRowSize.__proto__ || Object.getPrototypeOf(AutoRowSize)).call(this, hotInstance));
  25813. _this.heights = [];
  25814. /**
  25815. * Instance of {@link GhostTable} for rows and columns size calculations.
  25816. *
  25817. * @type {GhostTable}
  25818. */
  25819. _this.ghostTable = new _ghostTable2.default(_this.hot);
  25820. /**
  25821. * Instance of {@link SamplesGenerator} for generating samples necessary for rows height calculations.
  25822. *
  25823. * @type {SamplesGenerator}
  25824. */
  25825. _this.samplesGenerator = new _samplesGenerator2.default(function (row, col) {
  25826. if (row >= 0) {
  25827. return _this.hot.getDataAtCell(row, col);
  25828. } else if (row === -1) {
  25829. return _this.hot.getColHeader(col);
  25830. }
  25831. return null;
  25832. });
  25833. /**
  25834. * `true` if only the first calculation was performed.
  25835. *
  25836. * @type {Boolean}
  25837. */
  25838. _this.firstCalculation = true;
  25839. /**
  25840. * `true` if the size calculation is in progress.
  25841. *
  25842. * @type {Boolean}
  25843. */
  25844. _this.inProgress = false;
  25845. // moved to constructor to allow auto-sizing the rows when the plugin is disabled
  25846. _this.addHook('beforeRowResize', function (row, size, isDblClick) {
  25847. return _this.onBeforeRowResize(row, size, isDblClick);
  25848. });
  25849. return _this;
  25850. }
  25851. /**
  25852. * Check if the plugin is enabled in the Handsontable settings.
  25853. *
  25854. * @returns {Boolean}
  25855. */
  25856. _createClass(AutoRowSize, [{
  25857. key: 'isEnabled',
  25858. value: function isEnabled() {
  25859. return this.hot.getSettings().autoRowSize === true || (0, _object.isObject)(this.hot.getSettings().autoRowSize);
  25860. }
  25861. /**
  25862. * Enable plugin for this Handsontable instance.
  25863. */
  25864. }, {
  25865. key: 'enablePlugin',
  25866. value: function enablePlugin() {
  25867. var _this2 = this;
  25868. if (this.enabled) {
  25869. return;
  25870. }
  25871. this.setSamplingOptions();
  25872. this.addHook('afterLoadData', function () {
  25873. return _this2.onAfterLoadData();
  25874. });
  25875. this.addHook('beforeChange', function (changes) {
  25876. return _this2.onBeforeChange(changes);
  25877. });
  25878. this.addHook('beforeColumnMove', function () {
  25879. return _this2.recalculateAllRowsHeight();
  25880. });
  25881. this.addHook('beforeColumnResize', function () {
  25882. return _this2.recalculateAllRowsHeight();
  25883. });
  25884. this.addHook('beforeColumnSort', function () {
  25885. return _this2.clearCache();
  25886. });
  25887. this.addHook('beforeRender', function (force) {
  25888. return _this2.onBeforeRender(force);
  25889. });
  25890. this.addHook('beforeRowMove', function (rowStart, rowEnd) {
  25891. return _this2.onBeforeRowMove(rowStart, rowEnd);
  25892. });
  25893. this.addHook('modifyRowHeight', function (height, row) {
  25894. return _this2.getRowHeight(row, height);
  25895. });
  25896. this.addHook('modifyColumnHeaderHeight', function () {
  25897. return _this2.getColumnHeaderHeight();
  25898. });
  25899. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'enablePlugin', this).call(this);
  25900. }
  25901. /**
  25902. * Disable plugin for this Handsontable instance.
  25903. */
  25904. }, {
  25905. key: 'disablePlugin',
  25906. value: function disablePlugin() {
  25907. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'disablePlugin', this).call(this);
  25908. }
  25909. /**
  25910. * Calculate a given rows height.
  25911. *
  25912. * @param {Number|Object} rowRange Row range object.
  25913. * @param {Number|Object} colRange Column range object.
  25914. * @param {Boolean} [force=false] If `true` force calculate height even when value was cached earlier.
  25915. */
  25916. }, {
  25917. key: 'calculateRowsHeight',
  25918. value: function calculateRowsHeight() {
  25919. var rowRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countRows() - 1 };
  25920. var _this3 = this;
  25921. var colRange = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { from: 0, to: this.hot.countCols() - 1 };
  25922. var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  25923. if (typeof rowRange === 'number') {
  25924. rowRange = { from: rowRange, to: rowRange };
  25925. }
  25926. if (typeof colRange === 'number') {
  25927. colRange = { from: colRange, to: colRange };
  25928. }
  25929. if (this.hot.getColHeader(0) !== null) {
  25930. var samples = this.samplesGenerator.generateRowSamples(-1, colRange);
  25931. this.ghostTable.addColumnHeadersRow(samples.get(-1));
  25932. }
  25933. (0, _number.rangeEach)(rowRange.from, rowRange.to, function (row) {
  25934. // For rows we must calculate row height even when user had set height value manually.
  25935. // We can shrink column but cannot shrink rows!
  25936. if (force || _this3.heights[row] === void 0) {
  25937. var _samples = _this3.samplesGenerator.generateRowSamples(row, colRange);
  25938. _samples.forEach(function (sample, row) {
  25939. _this3.ghostTable.addRow(row, sample);
  25940. });
  25941. }
  25942. });
  25943. if (this.ghostTable.rows.length) {
  25944. this.ghostTable.getHeights(function (row, height) {
  25945. _this3.heights[row] = height;
  25946. });
  25947. this.ghostTable.clean();
  25948. }
  25949. }
  25950. /**
  25951. * Calculate the height of all the rows.
  25952. *
  25953. * @param {Object|Number} colRange Column range object.
  25954. */
  25955. }, {
  25956. key: 'calculateAllRowsHeight',
  25957. value: function calculateAllRowsHeight() {
  25958. var _this4 = this;
  25959. var colRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { from: 0, to: this.hot.countCols() - 1 };
  25960. var current = 0;
  25961. var length = this.hot.countRows() - 1;
  25962. var timer = null;
  25963. this.inProgress = true;
  25964. var loop = function loop() {
  25965. // When hot was destroyed after calculating finished cancel frame
  25966. if (!_this4.hot) {
  25967. (0, _feature.cancelAnimationFrame)(timer);
  25968. _this4.inProgress = false;
  25969. return;
  25970. }
  25971. _this4.calculateRowsHeight({ from: current, to: Math.min(current + AutoRowSize.CALCULATION_STEP, length) }, colRange);
  25972. current = current + AutoRowSize.CALCULATION_STEP + 1;
  25973. if (current < length) {
  25974. timer = (0, _feature.requestAnimationFrame)(loop);
  25975. } else {
  25976. (0, _feature.cancelAnimationFrame)(timer);
  25977. _this4.inProgress = false;
  25978. // @TODO Should call once per render cycle, currently fired separately in different plugins
  25979. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  25980. // tmp
  25981. if (_this4.hot.view.wt.wtOverlays.leftOverlay.needFullRender) {
  25982. _this4.hot.view.wt.wtOverlays.leftOverlay.clone.draw();
  25983. }
  25984. }
  25985. };
  25986. // sync
  25987. if (this.firstCalculation && this.getSyncCalculationLimit()) {
  25988. this.calculateRowsHeight({ from: 0, to: this.getSyncCalculationLimit() }, colRange);
  25989. this.firstCalculation = false;
  25990. current = this.getSyncCalculationLimit() + 1;
  25991. }
  25992. // async
  25993. if (current < length) {
  25994. loop();
  25995. } else {
  25996. this.inProgress = false;
  25997. this.hot.view.wt.wtOverlays.adjustElementsSize(false);
  25998. }
  25999. }
  26000. /**
  26001. * Set the sampling options.
  26002. *
  26003. * @private
  26004. */
  26005. }, {
  26006. key: 'setSamplingOptions',
  26007. value: function setSamplingOptions() {
  26008. var setting = this.hot.getSettings().autoRowSize;
  26009. var samplingRatio = setting && (0, _object.hasOwnProperty)(setting, 'samplingRatio') ? this.hot.getSettings().autoRowSize.samplingRatio : void 0;
  26010. var allowSampleDuplicates = setting && (0, _object.hasOwnProperty)(setting, 'allowSampleDuplicates') ? this.hot.getSettings().autoRowSize.allowSampleDuplicates : void 0;
  26011. if (samplingRatio && !isNaN(samplingRatio)) {
  26012. this.samplesGenerator.setSampleCount(parseInt(samplingRatio, 10));
  26013. }
  26014. if (allowSampleDuplicates) {
  26015. this.samplesGenerator.setAllowDuplicates(allowSampleDuplicates);
  26016. }
  26017. }
  26018. /**
  26019. * Recalculate all rows height (overwrite cache values).
  26020. */
  26021. }, {
  26022. key: 'recalculateAllRowsHeight',
  26023. value: function recalculateAllRowsHeight() {
  26024. if ((0, _element.isVisible)(this.hot.view.wt.wtTable.TABLE)) {
  26025. this.clearCache();
  26026. this.calculateAllRowsHeight();
  26027. }
  26028. }
  26029. /**
  26030. * Get value which tells how much rows will be calculated synchronously. Rest rows will be calculated asynchronously.
  26031. *
  26032. * @returns {Number}
  26033. */
  26034. }, {
  26035. key: 'getSyncCalculationLimit',
  26036. value: function getSyncCalculationLimit() {
  26037. /* eslint-disable no-bitwise */
  26038. var limit = AutoRowSize.SYNC_CALCULATION_LIMIT;
  26039. var rowsLimit = this.hot.countRows() - 1;
  26040. if ((0, _object.isObject)(this.hot.getSettings().autoRowSize)) {
  26041. limit = this.hot.getSettings().autoRowSize.syncLimit;
  26042. if ((0, _string.isPercentValue)(limit)) {
  26043. limit = (0, _number.valueAccordingPercent)(rowsLimit, limit);
  26044. } else {
  26045. // Force to Number
  26046. limit >>= 0;
  26047. }
  26048. }
  26049. return Math.min(limit, rowsLimit);
  26050. }
  26051. /**
  26052. * Get the calculated row height.
  26053. *
  26054. * @param {Number} row Visual row index.
  26055. * @param {Number} [defaultHeight] Default row height. It will be pick up if no calculated height found.
  26056. * @returns {Number}
  26057. */
  26058. }, {
  26059. key: 'getRowHeight',
  26060. value: function getRowHeight(row) {
  26061. var defaultHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
  26062. var height = defaultHeight;
  26063. if (this.heights[row] !== void 0 && this.heights[row] > (defaultHeight || 0)) {
  26064. height = this.heights[row];
  26065. }
  26066. return height;
  26067. }
  26068. /**
  26069. * Get the calculated column header height.
  26070. *
  26071. * @returns {Number|undefined}
  26072. */
  26073. }, {
  26074. key: 'getColumnHeaderHeight',
  26075. value: function getColumnHeaderHeight() {
  26076. return this.heights[-1];
  26077. }
  26078. /**
  26079. * Get the first visible row.
  26080. *
  26081. * @returns {Number} Returns row index or -1 if table is not rendered.
  26082. */
  26083. }, {
  26084. key: 'getFirstVisibleRow',
  26085. value: function getFirstVisibleRow() {
  26086. var wot = this.hot.view.wt;
  26087. if (wot.wtViewport.rowsVisibleCalculator) {
  26088. return wot.wtTable.getFirstVisibleRow();
  26089. }
  26090. if (wot.wtViewport.rowsRenderCalculator) {
  26091. return wot.wtTable.getFirstRenderedRow();
  26092. }
  26093. return -1;
  26094. }
  26095. /**
  26096. * Get the last visible row.
  26097. *
  26098. * @returns {Number} Returns row index or -1 if table is not rendered.
  26099. */
  26100. }, {
  26101. key: 'getLastVisibleRow',
  26102. value: function getLastVisibleRow() {
  26103. var wot = this.hot.view.wt;
  26104. if (wot.wtViewport.rowsVisibleCalculator) {
  26105. return wot.wtTable.getLastVisibleRow();
  26106. }
  26107. if (wot.wtViewport.rowsRenderCalculator) {
  26108. return wot.wtTable.getLastRenderedRow();
  26109. }
  26110. return -1;
  26111. }
  26112. /**
  26113. * Clear cached heights.
  26114. */
  26115. }, {
  26116. key: 'clearCache',
  26117. value: function clearCache() {
  26118. this.heights.length = 0;
  26119. this.heights[-1] = void 0;
  26120. }
  26121. /**
  26122. * Clear cache by range.
  26123. *
  26124. * @param {Object|Number} range Row range object.
  26125. */
  26126. }, {
  26127. key: 'clearCacheByRange',
  26128. value: function clearCacheByRange(range) {
  26129. var _this5 = this;
  26130. if (typeof range === 'number') {
  26131. range = { from: range, to: range };
  26132. }
  26133. (0, _number.rangeEach)(Math.min(range.from, range.to), Math.max(range.from, range.to), function (row) {
  26134. _this5.heights[row] = void 0;
  26135. });
  26136. }
  26137. /**
  26138. * @returns {Boolean}
  26139. */
  26140. }, {
  26141. key: 'isNeedRecalculate',
  26142. value: function isNeedRecalculate() {
  26143. return !!(0, _array.arrayFilter)(this.heights, function (item) {
  26144. return item === void 0;
  26145. }).length;
  26146. }
  26147. /**
  26148. * On before render listener.
  26149. *
  26150. * @private
  26151. */
  26152. }, {
  26153. key: 'onBeforeRender',
  26154. value: function onBeforeRender() {
  26155. var force = this.hot.renderCall;
  26156. this.calculateRowsHeight({ from: this.getFirstVisibleRow(), to: this.getLastVisibleRow() }, void 0, force);
  26157. var fixedRowsBottom = this.hot.getSettings().fixedRowsBottom;
  26158. // Calculate rows height synchronously for bottom overlay
  26159. if (fixedRowsBottom) {
  26160. var totalRows = this.hot.countRows() - 1;
  26161. this.calculateRowsHeight({ from: totalRows - fixedRowsBottom, to: totalRows });
  26162. }
  26163. if (this.isNeedRecalculate() && !this.inProgress) {
  26164. this.calculateAllRowsHeight();
  26165. }
  26166. }
  26167. /**
  26168. * On before row move listener.
  26169. *
  26170. * @private
  26171. * @param {Number} from Row index where was grabbed.
  26172. * @param {Number} to Destination row index.
  26173. */
  26174. }, {
  26175. key: 'onBeforeRowMove',
  26176. value: function onBeforeRowMove(from, to) {
  26177. this.clearCacheByRange({ from: from, to: to });
  26178. this.calculateAllRowsHeight();
  26179. }
  26180. /**
  26181. * On before row resize listener.
  26182. *
  26183. * @private
  26184. * @param {Number} row
  26185. * @param {Number} size
  26186. * @param {Boolean} isDblClick
  26187. * @returns {Number}
  26188. */
  26189. }, {
  26190. key: 'onBeforeRowResize',
  26191. value: function onBeforeRowResize(row, size, isDblClick) {
  26192. if (isDblClick) {
  26193. this.calculateRowsHeight(row, void 0, true);
  26194. size = this.getRowHeight(row);
  26195. }
  26196. return size;
  26197. }
  26198. /**
  26199. * On after load data listener.
  26200. *
  26201. * @private
  26202. */
  26203. }, {
  26204. key: 'onAfterLoadData',
  26205. value: function onAfterLoadData() {
  26206. var _this6 = this;
  26207. if (this.hot.view) {
  26208. this.recalculateAllRowsHeight();
  26209. } else {
  26210. // first load - initialization
  26211. setTimeout(function () {
  26212. if (_this6.hot) {
  26213. _this6.recalculateAllRowsHeight();
  26214. }
  26215. }, 0);
  26216. }
  26217. }
  26218. /**
  26219. * On before change listener.
  26220. *
  26221. * @private
  26222. * @param {Array} changes
  26223. */
  26224. }, {
  26225. key: 'onBeforeChange',
  26226. value: function onBeforeChange(changes) {
  26227. var range = null;
  26228. if (changes.length === 1) {
  26229. range = changes[0][0];
  26230. } else if (changes.length > 1) {
  26231. range = {
  26232. from: changes[0][0],
  26233. to: changes[changes.length - 1][0]
  26234. };
  26235. }
  26236. if (range !== null) {
  26237. this.clearCacheByRange(range);
  26238. }
  26239. }
  26240. /**
  26241. * Destroy plugin instance.
  26242. */
  26243. }, {
  26244. key: 'destroy',
  26245. value: function destroy() {
  26246. this.ghostTable.clean();
  26247. _get(AutoRowSize.prototype.__proto__ || Object.getPrototypeOf(AutoRowSize.prototype), 'destroy', this).call(this);
  26248. }
  26249. }]);
  26250. return AutoRowSize;
  26251. }(_base2.default);
  26252. (0, _plugins.registerPlugin)('autoRowSize', AutoRowSize);
  26253. exports.default = AutoRowSize;
  26254. /***/ }),
  26255. /* 212 */
  26256. /***/ (function(module, exports, __webpack_require__) {
  26257. "use strict";
  26258. exports.__esModule = true;
  26259. 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; }; }();
  26260. 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); } };
  26261. var _base = __webpack_require__(12);
  26262. var _base2 = _interopRequireDefault(_base);
  26263. var _pluginHooks = __webpack_require__(8);
  26264. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  26265. var _element = __webpack_require__(0);
  26266. var _eventManager = __webpack_require__(4);
  26267. var _eventManager2 = _interopRequireDefault(_eventManager);
  26268. var _plugins = __webpack_require__(5);
  26269. var _src = __webpack_require__(11);
  26270. var _utils = __webpack_require__(213);
  26271. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26272. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  26273. 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; }
  26274. 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; }
  26275. _pluginHooks2.default.getSingleton().register('modifyAutofillRange');
  26276. _pluginHooks2.default.getSingleton().register('beforeAutofill');
  26277. var INSERT_ROW_ALTER_ACTION_NAME = 'insert_row';
  26278. var INTERVAL_FOR_ADDING_ROW = 200;
  26279. /**
  26280. * This plugin provides "drag-down" and "copy-down" functionalities, both operated
  26281. * using the small square in the right bottom of the cell selection.
  26282. *
  26283. * "Drag-down" expands the value of the selected cells to the neighbouring
  26284. * cells when you drag the small square in the corner.
  26285. *
  26286. * "Copy-down" copies the value of the selection to all empty cells
  26287. * below when you double click the small square.
  26288. *
  26289. * @class Autofill
  26290. * @plugin Autofill
  26291. */
  26292. var Autofill = function (_BasePlugin) {
  26293. _inherits(Autofill, _BasePlugin);
  26294. function Autofill(hotInstance) {
  26295. _classCallCheck(this, Autofill);
  26296. /**
  26297. * Event manager
  26298. *
  26299. * @type {EventManager}
  26300. */
  26301. var _this = _possibleConstructorReturn(this, (Autofill.__proto__ || Object.getPrototypeOf(Autofill)).call(this, hotInstance));
  26302. _this.eventManager = new _eventManager2.default(_this);
  26303. /**
  26304. * Specifies if adding new row started.
  26305. *
  26306. * @type {Boolean}
  26307. */
  26308. _this.addingStarted = false;
  26309. /**
  26310. * Specifies if there was mouse down on the cell corner.
  26311. *
  26312. * @type {Boolean}
  26313. */
  26314. _this.mouseDownOnCellCorner = false;
  26315. /**
  26316. * Specifies if mouse was dragged outside Handsontable.
  26317. *
  26318. * @type {Boolean}
  26319. */
  26320. _this.mouseDragOutside = false;
  26321. /**
  26322. * Specifies how many cell levels were dragged using the handle.
  26323. *
  26324. * @type {Boolean}
  26325. */
  26326. _this.handleDraggedCells = 0;
  26327. /**
  26328. * Specifies allowed directions of drag.
  26329. *
  26330. * @type {Array}
  26331. */
  26332. _this.directions = [];
  26333. /**
  26334. * Specifies if can insert new rows if needed.
  26335. *
  26336. * @type {Boolean}
  26337. */
  26338. _this.autoInsertRow = false;
  26339. return _this;
  26340. }
  26341. /**
  26342. * Check if the plugin is enabled in the Handsontable settings.
  26343. *
  26344. * @returns {Boolean}
  26345. */
  26346. _createClass(Autofill, [{
  26347. key: 'isEnabled',
  26348. value: function isEnabled() {
  26349. return this.hot.getSettings().fillHandle;
  26350. }
  26351. /**
  26352. * Enable plugin for this Handsontable instance.
  26353. */
  26354. }, {
  26355. key: 'enablePlugin',
  26356. value: function enablePlugin() {
  26357. var _this2 = this;
  26358. if (this.enabled) {
  26359. return;
  26360. }
  26361. this.mapSettings();
  26362. this.registerEvents();
  26363. this.addHook('afterOnCellCornerMouseDown', function (event) {
  26364. return _this2.onAfterCellCornerMouseDown(event);
  26365. });
  26366. this.addHook('afterOnCellCornerDblClick', function (event) {
  26367. return _this2.onCellCornerDblClick(event);
  26368. });
  26369. this.addHook('beforeOnCellMouseOver', function (event, coords, TD) {
  26370. return _this2.onBeforeCellMouseOver(coords);
  26371. });
  26372. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'enablePlugin', this).call(this);
  26373. }
  26374. /**
  26375. * Update plugin for this Handsontable instance.
  26376. */
  26377. }, {
  26378. key: 'updatePlugin',
  26379. value: function updatePlugin() {
  26380. this.disablePlugin();
  26381. this.enablePlugin();
  26382. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'updatePlugin', this).call(this);
  26383. }
  26384. /**
  26385. * Disable plugin for this Handsontable instance.
  26386. */
  26387. }, {
  26388. key: 'disablePlugin',
  26389. value: function disablePlugin() {
  26390. this.clearMappedSettings();
  26391. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'disablePlugin', this).call(this);
  26392. }
  26393. /**
  26394. * Get selection data
  26395. *
  26396. * @private
  26397. * @returns {Array} Array with the data.
  26398. */
  26399. }, {
  26400. key: 'getSelectionData',
  26401. value: function getSelectionData() {
  26402. var selRange = {
  26403. from: this.hot.getSelectedRange().from,
  26404. to: this.hot.getSelectedRange().to
  26405. };
  26406. return this.hot.getData(selRange.from.row, selRange.from.col, selRange.to.row, selRange.to.col);
  26407. }
  26408. /**
  26409. * Try to apply fill values to the area in fill border, omitting the selection border.
  26410. *
  26411. * @private
  26412. * @returns {Boolean} reports if fill was applied.
  26413. */
  26414. }, {
  26415. key: 'fillIn',
  26416. value: function fillIn() {
  26417. if (this.hot.view.wt.selections.fill.isEmpty()) {
  26418. return false;
  26419. }
  26420. var cornersOfSelectionAndDragAreas = this.hot.view.wt.selections.fill.getCorners();
  26421. this.resetSelectionOfDraggedArea();
  26422. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  26423. var _getDragDirectionAndR = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas),
  26424. directionOfDrag = _getDragDirectionAndR.directionOfDrag,
  26425. startOfDragCoords = _getDragDirectionAndR.startOfDragCoords,
  26426. endOfDragCoords = _getDragDirectionAndR.endOfDragCoords;
  26427. this.hot.runHooks('modifyAutofillRange', cornersOfSelectedCells, cornersOfSelectionAndDragAreas);
  26428. if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
  26429. var selectionData = this.getSelectionData();
  26430. var deltas = (0, _utils.getDeltas)(startOfDragCoords, endOfDragCoords, selectionData, directionOfDrag);
  26431. var fillData = selectionData;
  26432. this.hot.runHooks('beforeAutofill', startOfDragCoords, endOfDragCoords, selectionData);
  26433. if (['up', 'left'].indexOf(directionOfDrag) > -1) {
  26434. fillData = [];
  26435. var dragLength = null;
  26436. var fillOffset = null;
  26437. if (directionOfDrag === 'up') {
  26438. dragLength = endOfDragCoords.row - startOfDragCoords.row + 1;
  26439. fillOffset = dragLength % selectionData.length;
  26440. for (var i = 0; i < dragLength; i++) {
  26441. fillData.push(selectionData[(i + (selectionData.length - fillOffset)) % selectionData.length]);
  26442. }
  26443. } else {
  26444. dragLength = endOfDragCoords.col - startOfDragCoords.col + 1;
  26445. fillOffset = dragLength % selectionData[0].length;
  26446. for (var _i = 0; _i < selectionData.length; _i++) {
  26447. fillData.push([]);
  26448. for (var j = 0; j < dragLength; j++) {
  26449. fillData[_i].push(selectionData[_i][(j + (selectionData[_i].length - fillOffset)) % selectionData[_i].length]);
  26450. }
  26451. }
  26452. }
  26453. }
  26454. this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, this.pluginName + '.fill', null, directionOfDrag, deltas);
  26455. this.setSelection(cornersOfSelectionAndDragAreas);
  26456. } else {
  26457. // reset to avoid some range bug
  26458. this.hot.selection.refreshBorders();
  26459. }
  26460. return true;
  26461. }
  26462. /**
  26463. * Reduce the selection area if the handle was dragged outside of the table or on headers.
  26464. *
  26465. * @private
  26466. * @param {CellCoords} coords indexes of selection corners.
  26467. * @returns {CellCoords}
  26468. */
  26469. }, {
  26470. key: 'reduceSelectionAreaIfNeeded',
  26471. value: function reduceSelectionAreaIfNeeded(coords) {
  26472. if (coords.row < 0) {
  26473. coords.row = 0;
  26474. }
  26475. if (coords.col < 0) {
  26476. coords.col = 0;
  26477. }
  26478. return coords;
  26479. }
  26480. /**
  26481. * Get the coordinates of the drag & drop borders.
  26482. *
  26483. * @private
  26484. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  26485. * @returns {Array}
  26486. */
  26487. }, {
  26488. key: 'getCoordsOfDragAndDropBorders',
  26489. value: function getCoordsOfDragAndDropBorders(coordsOfSelection) {
  26490. var topLeftCorner = this.hot.getSelectedRange().getTopLeftCorner();
  26491. var bottomRightCorner = this.hot.getSelectedRange().getBottomRightCorner();
  26492. var coords = void 0;
  26493. if (this.directions.includes(_utils.DIRECTIONS.vertical) && (bottomRightCorner.row < coordsOfSelection.row || topLeftCorner.row > coordsOfSelection.row)) {
  26494. coords = new _src.CellCoords(coordsOfSelection.row, bottomRightCorner.col);
  26495. } else if (this.directions.includes(_utils.DIRECTIONS.horizontal)) {
  26496. coords = new _src.CellCoords(bottomRightCorner.row, coordsOfSelection.col);
  26497. } else {
  26498. // wrong direction
  26499. return;
  26500. }
  26501. return this.reduceSelectionAreaIfNeeded(coords);
  26502. }
  26503. /**
  26504. * Show the fill border.
  26505. *
  26506. * @private
  26507. * @param {CellCoords} coordsOfSelection `CellCoords` coord object.
  26508. */
  26509. }, {
  26510. key: 'showBorder',
  26511. value: function showBorder(coordsOfSelection) {
  26512. var coordsOfDragAndDropBorders = this.getCoordsOfDragAndDropBorders(coordsOfSelection);
  26513. if (coordsOfDragAndDropBorders) {
  26514. this.redrawBorders(coordsOfDragAndDropBorders);
  26515. }
  26516. }
  26517. /**
  26518. * Add new row
  26519. *
  26520. * @private
  26521. */
  26522. }, {
  26523. key: 'addRow',
  26524. value: function addRow() {
  26525. var _this3 = this;
  26526. this.hot._registerTimeout(setTimeout(function () {
  26527. _this3.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, void 0, 1, _this3.pluginName + '.fill');
  26528. _this3.addingStarted = false;
  26529. }, INTERVAL_FOR_ADDING_ROW));
  26530. }
  26531. /**
  26532. * Add new rows if they are needed to continue auto-filling values.
  26533. *
  26534. * @private
  26535. */
  26536. }, {
  26537. key: 'addNewRowIfNeeded',
  26538. value: function addNewRowIfNeeded() {
  26539. if (this.hot.view.wt.selections.fill.cellRange && this.addingStarted === false && this.autoInsertRow) {
  26540. var cornersOfSelectedCells = this.hot.getSelected();
  26541. var cornersOfSelectedDragArea = this.hot.view.wt.selections.fill.getCorners();
  26542. var nrOfTableRows = this.hot.countRows();
  26543. if (cornersOfSelectedCells[2] < nrOfTableRows - 1 && cornersOfSelectedDragArea[2] === nrOfTableRows - 1) {
  26544. this.addingStarted = true;
  26545. this.addRow();
  26546. }
  26547. }
  26548. }
  26549. /**
  26550. * Get corners of selected cells.
  26551. *
  26552. * @private
  26553. * @returns {Array}
  26554. */
  26555. }, {
  26556. key: 'getCornersOfSelectedCells',
  26557. value: function getCornersOfSelectedCells() {
  26558. if (this.hot.selection.isMultiple()) {
  26559. return this.hot.view.wt.selections.area.getCorners();
  26560. }
  26561. return this.hot.view.wt.selections.current.getCorners();
  26562. }
  26563. /**
  26564. * Get index of last adjacent filled in row
  26565. *
  26566. * @private
  26567. * @param {Array} cornersOfSelectedCells indexes of selection corners.
  26568. * @returns {Number} gives number greater than or equal to zero when selection adjacent can be applied.
  26569. * or -1 when selection adjacent can't be applied
  26570. */
  26571. }, {
  26572. key: 'getIndexOfLastAdjacentFilledInRow',
  26573. value: function getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells) {
  26574. var data = this.hot.getData();
  26575. var nrOfTableRows = this.hot.countRows();
  26576. var lastFilledInRowIndex = void 0;
  26577. for (var rowIndex = cornersOfSelectedCells[2] + 1; rowIndex < nrOfTableRows; rowIndex++) {
  26578. for (var columnIndex = cornersOfSelectedCells[1]; columnIndex <= cornersOfSelectedCells[3]; columnIndex++) {
  26579. var dataInCell = data[rowIndex][columnIndex];
  26580. if (dataInCell) {
  26581. return -1;
  26582. }
  26583. }
  26584. var dataInNextLeftCell = data[rowIndex][cornersOfSelectedCells[1] - 1];
  26585. var dataInNextRightCell = data[rowIndex][cornersOfSelectedCells[3] + 1];
  26586. if (!!dataInNextLeftCell || !!dataInNextRightCell) {
  26587. lastFilledInRowIndex = rowIndex;
  26588. }
  26589. }
  26590. return lastFilledInRowIndex;
  26591. }
  26592. /**
  26593. * Add a selection from the start area to the specific row index.
  26594. *
  26595. * @private
  26596. * @param {Array} selectStartArea selection area from which we start to create more comprehensive selection.
  26597. * @param {Number} rowIndex
  26598. */
  26599. }, {
  26600. key: 'addSelectionFromStartAreaToSpecificRowIndex',
  26601. value: function addSelectionFromStartAreaToSpecificRowIndex(selectStartArea, rowIndex) {
  26602. this.hot.view.wt.selections.fill.clear();
  26603. this.hot.view.wt.selections.fill.add(new _src.CellCoords(selectStartArea[0], selectStartArea[1]));
  26604. this.hot.view.wt.selections.fill.add(new _src.CellCoords(rowIndex, selectStartArea[3]));
  26605. }
  26606. /**
  26607. * Set selection based on passed corners.
  26608. *
  26609. * @private
  26610. * @param {Array} cornersOfArea
  26611. */
  26612. }, {
  26613. key: 'setSelection',
  26614. value: function setSelection(cornersOfArea) {
  26615. this.hot.selection.setRangeStart(new _src.CellCoords(cornersOfArea[0], cornersOfArea[1]));
  26616. this.hot.selection.setRangeEnd(new _src.CellCoords(cornersOfArea[2], cornersOfArea[3]));
  26617. }
  26618. /**
  26619. * Try to select cells down to the last row in the left column and then returns if selection was applied.
  26620. *
  26621. * @private
  26622. * @returns {Boolean}
  26623. */
  26624. }, {
  26625. key: 'selectAdjacent',
  26626. value: function selectAdjacent() {
  26627. var cornersOfSelectedCells = this.getCornersOfSelectedCells();
  26628. var lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells);
  26629. if (lastFilledInRowIndex === -1) {
  26630. return false;
  26631. }
  26632. this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex);
  26633. return true;
  26634. }
  26635. /**
  26636. * Reset selection of dragged area.
  26637. *
  26638. * @private
  26639. */
  26640. }, {
  26641. key: 'resetSelectionOfDraggedArea',
  26642. value: function resetSelectionOfDraggedArea() {
  26643. this.handleDraggedCells = 0;
  26644. this.hot.view.wt.selections.fill.clear();
  26645. }
  26646. /**
  26647. * Redraw borders.
  26648. *
  26649. * @private
  26650. * @param {CellCoords} coords `CellCoords` coord object.
  26651. */
  26652. }, {
  26653. key: 'redrawBorders',
  26654. value: function redrawBorders(coords) {
  26655. this.hot.view.wt.selections.fill.clear();
  26656. this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().from);
  26657. this.hot.view.wt.selections.fill.add(this.hot.getSelectedRange().to);
  26658. this.hot.view.wt.selections.fill.add(coords);
  26659. this.hot.view.render();
  26660. }
  26661. /**
  26662. * Get if mouse was dragged outside.
  26663. *
  26664. * @private
  26665. * @param {MouseEvent} event `mousemove` event properties.
  26666. * @returns {Boolean}
  26667. */
  26668. }, {
  26669. key: 'getIfMouseWasDraggedOutside',
  26670. value: function getIfMouseWasDraggedOutside(event) {
  26671. var tableBottom = (0, _element.offset)(this.hot.table).top - (window.pageYOffset || document.documentElement.scrollTop) + (0, _element.outerHeight)(this.hot.table);
  26672. var tableRight = (0, _element.offset)(this.hot.table).left - (window.pageXOffset || document.documentElement.scrollLeft) + (0, _element.outerWidth)(this.hot.table);
  26673. return event.clientY > tableBottom && event.clientX <= tableRight;
  26674. }
  26675. /**
  26676. * Bind the events used by the plugin.
  26677. *
  26678. * @private
  26679. */
  26680. }, {
  26681. key: 'registerEvents',
  26682. value: function registerEvents() {
  26683. var _this4 = this;
  26684. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  26685. return _this4.onMouseUp();
  26686. });
  26687. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  26688. return _this4.onMouseMove(event);
  26689. });
  26690. }
  26691. /**
  26692. * On cell corner double click callback.
  26693. *
  26694. * @private
  26695. */
  26696. }, {
  26697. key: 'onCellCornerDblClick',
  26698. value: function onCellCornerDblClick() {
  26699. var selectionApplied = this.selectAdjacent();
  26700. if (selectionApplied) {
  26701. this.fillIn();
  26702. }
  26703. }
  26704. /**
  26705. * On after cell corner mouse down listener.
  26706. *
  26707. * @private
  26708. */
  26709. }, {
  26710. key: 'onAfterCellCornerMouseDown',
  26711. value: function onAfterCellCornerMouseDown() {
  26712. this.handleDraggedCells = 1;
  26713. this.mouseDownOnCellCorner = true;
  26714. }
  26715. /**
  26716. * On before cell mouse over listener.
  26717. *
  26718. * @private
  26719. * @param {CellCoords} coords `CellCoords` coord object.
  26720. */
  26721. }, {
  26722. key: 'onBeforeCellMouseOver',
  26723. value: function onBeforeCellMouseOver(coords) {
  26724. if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
  26725. this.handleDraggedCells++;
  26726. this.showBorder(coords);
  26727. this.addNewRowIfNeeded();
  26728. }
  26729. }
  26730. /**
  26731. * On mouse up listener.
  26732. *
  26733. * @private
  26734. */
  26735. }, {
  26736. key: 'onMouseUp',
  26737. value: function onMouseUp() {
  26738. if (this.handleDraggedCells) {
  26739. if (this.handleDraggedCells > 1) {
  26740. this.fillIn();
  26741. }
  26742. this.handleDraggedCells = 0;
  26743. this.mouseDownOnCellCorner = false;
  26744. }
  26745. }
  26746. /**
  26747. * On mouse move listener.
  26748. *
  26749. * @private
  26750. * @param {MouseEvent} event `mousemove` event properties.
  26751. */
  26752. }, {
  26753. key: 'onMouseMove',
  26754. value: function onMouseMove(event) {
  26755. var mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
  26756. if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
  26757. this.mouseDragOutside = true;
  26758. this.addingStarted = true;
  26759. } else {
  26760. this.mouseDragOutside = false;
  26761. }
  26762. if (this.mouseDragOutside && this.autoInsertRow) {
  26763. this.addRow();
  26764. }
  26765. }
  26766. /**
  26767. * Clear mapped settings.
  26768. *
  26769. * @private
  26770. */
  26771. }, {
  26772. key: 'clearMappedSettings',
  26773. value: function clearMappedSettings() {
  26774. this.directions.length = 0;
  26775. this.autoInsertRow = false;
  26776. }
  26777. /**
  26778. * Map settings.
  26779. *
  26780. * @private
  26781. */
  26782. }, {
  26783. key: 'mapSettings',
  26784. value: function mapSettings() {
  26785. var mappedSettings = (0, _utils.getMappedFillHandleSetting)(this.hot.getSettings().fillHandle);
  26786. this.directions = mappedSettings.directions;
  26787. this.autoInsertRow = mappedSettings.autoInsertRow;
  26788. }
  26789. /**
  26790. * Destroy plugin instance.
  26791. */
  26792. }, {
  26793. key: 'destroy',
  26794. value: function destroy() {
  26795. _get(Autofill.prototype.__proto__ || Object.getPrototypeOf(Autofill.prototype), 'destroy', this).call(this);
  26796. }
  26797. }]);
  26798. return Autofill;
  26799. }(_base2.default);
  26800. (0, _plugins.registerPlugin)('autofill', Autofill);
  26801. exports.default = Autofill;
  26802. /***/ }),
  26803. /* 213 */
  26804. /***/ (function(module, exports, __webpack_require__) {
  26805. "use strict";
  26806. exports.__esModule = true;
  26807. exports.DIRECTIONS = undefined;
  26808. exports.getDeltas = getDeltas;
  26809. exports.getDragDirectionAndRange = getDragDirectionAndRange;
  26810. exports.getMappedFillHandleSetting = getMappedFillHandleSetting;
  26811. var _object = __webpack_require__(1);
  26812. var _mixed = __webpack_require__(20);
  26813. var _src = __webpack_require__(11);
  26814. var DIRECTIONS = exports.DIRECTIONS = {
  26815. horizontal: 'horizontal',
  26816. vertical: 'vertical'
  26817. };
  26818. /**
  26819. * Get deltas array.
  26820. *
  26821. * @param {CellCoords} start
  26822. * @param {CellCoords} end
  26823. * @param {Array} data
  26824. * @param {String} direction
  26825. * @returns {Array}
  26826. */
  26827. function getDeltas(start, end, data, direction) {
  26828. var rowsLength = data.length;
  26829. var columnsLength = data ? data[0].length : 0;
  26830. var deltas = [];
  26831. var diffRow = end.row - start.row;
  26832. var diffCol = end.col - start.col;
  26833. if (['down', 'up'].indexOf(direction) !== -1) {
  26834. var arr = [];
  26835. for (var col = 0; col <= diffCol; col++) {
  26836. var startValue = parseInt(data[0][col], 10);
  26837. var endValue = parseInt(data[rowsLength - 1][col], 10);
  26838. var delta = (direction === 'down' ? endValue - startValue : startValue - endValue) / (rowsLength - 1) || 0;
  26839. arr.push(delta);
  26840. }
  26841. deltas.push(arr);
  26842. }
  26843. if (['right', 'left'].indexOf(direction) !== -1) {
  26844. for (var row = 0; row <= diffRow; row++) {
  26845. var _startValue = parseInt(data[row][0], 10);
  26846. var _endValue = parseInt(data[row][columnsLength - 1], 10);
  26847. var _delta = (direction === 'right' ? _endValue - _startValue : _startValue - _endValue) / (columnsLength - 1) || 0;
  26848. deltas.push([_delta]);
  26849. }
  26850. }
  26851. return deltas;
  26852. }
  26853. /**
  26854. * Get direction between positions and cords of selections difference (drag area)
  26855. *
  26856. * @param {Array} startSelection
  26857. * @param {Array} endSelection
  26858. * @returns {{direction: String, start: CellCoords, end: CellCoords}}
  26859. */
  26860. function getDragDirectionAndRange(startSelection, endSelection) {
  26861. var startOfDragCoords = void 0,
  26862. endOfDragCoords = void 0,
  26863. directionOfDrag = void 0;
  26864. if (endSelection[0] === startSelection[0] && endSelection[1] < startSelection[1]) {
  26865. directionOfDrag = 'left';
  26866. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  26867. endOfDragCoords = new _src.CellCoords(endSelection[2], startSelection[1] - 1);
  26868. } else if (endSelection[0] === startSelection[0] && endSelection[3] > startSelection[3]) {
  26869. directionOfDrag = 'right';
  26870. startOfDragCoords = new _src.CellCoords(endSelection[0], startSelection[3] + 1);
  26871. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  26872. } else if (endSelection[0] < startSelection[0] && endSelection[1] === startSelection[1]) {
  26873. directionOfDrag = 'up';
  26874. startOfDragCoords = new _src.CellCoords(endSelection[0], endSelection[1]);
  26875. endOfDragCoords = new _src.CellCoords(startSelection[0] - 1, endSelection[3]);
  26876. } else if (endSelection[2] > startSelection[2] && endSelection[1] === startSelection[1]) {
  26877. directionOfDrag = 'down';
  26878. startOfDragCoords = new _src.CellCoords(startSelection[2] + 1, endSelection[1]);
  26879. endOfDragCoords = new _src.CellCoords(endSelection[2], endSelection[3]);
  26880. }
  26881. return {
  26882. directionOfDrag: directionOfDrag,
  26883. startOfDragCoords: startOfDragCoords,
  26884. endOfDragCoords: endOfDragCoords
  26885. };
  26886. }
  26887. /**
  26888. * Get mapped FillHandle setting containing information about
  26889. * allowed FillHandle directions and if allowed is automatic insertion of rows on drag
  26890. *
  26891. * @param {Boolean|Object} fillHandle property of Handsontable settings
  26892. * @returns {{directions: Array, autoInsertRow: Boolean}} object allowing access to information
  26893. * about FillHandle in more useful way
  26894. */
  26895. function getMappedFillHandleSetting(fillHandle) {
  26896. var mappedSettings = {};
  26897. if (fillHandle === true) {
  26898. mappedSettings.directions = Object.keys(DIRECTIONS);
  26899. mappedSettings.autoInsertRow = true;
  26900. } else if ((0, _object.isObject)(fillHandle)) {
  26901. if ((0, _mixed.isDefined)(fillHandle.autoInsertRow)) {
  26902. // autoInsertRow for horizontal direction will be always false
  26903. if (fillHandle.direction === DIRECTIONS.horizontal) {
  26904. mappedSettings.autoInsertRow = false;
  26905. } else {
  26906. mappedSettings.autoInsertRow = fillHandle.autoInsertRow;
  26907. }
  26908. } else {
  26909. mappedSettings.autoInsertRow = false;
  26910. }
  26911. if ((0, _mixed.isDefined)(fillHandle.direction)) {
  26912. mappedSettings.directions = [fillHandle.direction];
  26913. } else {
  26914. mappedSettings.directions = Object.keys(DIRECTIONS);
  26915. }
  26916. } else if (typeof fillHandle === 'string') {
  26917. mappedSettings.directions = [fillHandle];
  26918. mappedSettings.autoInsertRow = true;
  26919. } else {
  26920. mappedSettings.directions = [];
  26921. mappedSettings.autoInsertRow = false;
  26922. }
  26923. return mappedSettings;
  26924. }
  26925. /***/ }),
  26926. /* 214 */
  26927. /***/ (function(module, exports, __webpack_require__) {
  26928. "use strict";
  26929. exports.__esModule = true;
  26930. 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; };
  26931. 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; }; }();
  26932. 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); } };
  26933. var _moment = __webpack_require__(61);
  26934. var _moment2 = _interopRequireDefault(_moment);
  26935. var _element = __webpack_require__(0);
  26936. var _array = __webpack_require__(2);
  26937. var _mixed = __webpack_require__(20);
  26938. var _object = __webpack_require__(1);
  26939. var _base = __webpack_require__(12);
  26940. var _base2 = _interopRequireDefault(_base);
  26941. var _plugins = __webpack_require__(5);
  26942. var _mergeSort = __webpack_require__(272);
  26943. var _mergeSort2 = _interopRequireDefault(_mergeSort);
  26944. var _pluginHooks = __webpack_require__(8);
  26945. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  26946. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  26947. 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); } }
  26948. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  26949. 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; }
  26950. 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; }
  26951. _pluginHooks2.default.getSingleton().register('beforeColumnSort');
  26952. _pluginHooks2.default.getSingleton().register('afterColumnSort');
  26953. // TODO: Implement mixin arrayMapper to ColumnSorting plugin.
  26954. /**
  26955. * @plugin ColumnSorting
  26956. *
  26957. * @description
  26958. * This plugin sorts the view by a column (but does not sort the data source!).
  26959. * To enable the plugin, set the `columnSorting` property to either:
  26960. * * a boolean value (`true`/`false`),
  26961. * * an object defining the initial sorting order (see the example below).
  26962. *
  26963. * @example
  26964. * ```js
  26965. * ...
  26966. * // as boolean
  26967. * columnSorting: true
  26968. * ...
  26969. * // as a object with initial order (sort ascending column at index 2)
  26970. * columnSorting: {
  26971. * column: 2,
  26972. * sortOrder: true, // true = ascending, false = descending, undefined = original order
  26973. * sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
  26974. * }
  26975. * ...
  26976. * ```
  26977. * @dependencies ObserveChanges
  26978. */
  26979. var ColumnSorting = function (_BasePlugin) {
  26980. _inherits(ColumnSorting, _BasePlugin);
  26981. function ColumnSorting(hotInstance) {
  26982. _classCallCheck(this, ColumnSorting);
  26983. var _this2 = _possibleConstructorReturn(this, (ColumnSorting.__proto__ || Object.getPrototypeOf(ColumnSorting)).call(this, hotInstance));
  26984. _this2.sortIndicators = [];
  26985. _this2.lastSortedColumn = null;
  26986. _this2.sortEmptyCells = false;
  26987. return _this2;
  26988. }
  26989. /**
  26990. * Check if the plugin is enabled in the handsontable settings.
  26991. *
  26992. * @returns {Boolean}
  26993. */
  26994. _createClass(ColumnSorting, [{
  26995. key: 'isEnabled',
  26996. value: function isEnabled() {
  26997. return !!this.hot.getSettings().columnSorting;
  26998. }
  26999. /**
  27000. * Enable plugin for this Handsontable instance.
  27001. */
  27002. }, {
  27003. key: 'enablePlugin',
  27004. value: function enablePlugin() {
  27005. var _this3 = this;
  27006. if (this.enabled) {
  27007. return;
  27008. }
  27009. this.setPluginOptions();
  27010. var _this = this;
  27011. this.hot.sortIndex = [];
  27012. this.hot.sort = function () {
  27013. var args = Array.prototype.slice.call(arguments);
  27014. return _this.sortByColumn.apply(_this, _toConsumableArray(args));
  27015. };
  27016. if (typeof this.hot.getSettings().observeChanges === 'undefined') {
  27017. this.enableObserveChangesPlugin();
  27018. }
  27019. this.addHook('afterTrimRow', function (row) {
  27020. return _this3.sort();
  27021. });
  27022. this.addHook('afterUntrimRow', function (row) {
  27023. return _this3.sort();
  27024. });
  27025. this.addHook('modifyRow', function (row) {
  27026. return _this3.translateRow(row);
  27027. });
  27028. this.addHook('unmodifyRow', function (row) {
  27029. return _this3.untranslateRow(row);
  27030. });
  27031. this.addHook('afterUpdateSettings', function () {
  27032. return _this3.onAfterUpdateSettings();
  27033. });
  27034. this.addHook('afterGetColHeader', function (col, TH) {
  27035. return _this3.getColHeader(col, TH);
  27036. });
  27037. this.addHook('afterOnCellMouseDown', function (event, target) {
  27038. return _this3.onAfterOnCellMouseDown(event, target);
  27039. });
  27040. this.addHook('afterCreateRow', function () {
  27041. _this.afterCreateRow.apply(_this, arguments);
  27042. });
  27043. this.addHook('afterRemoveRow', function () {
  27044. _this.afterRemoveRow.apply(_this, arguments);
  27045. });
  27046. this.addHook('afterInit', function () {
  27047. return _this3.sortBySettings();
  27048. });
  27049. this.addHook('afterLoadData', function () {
  27050. _this3.hot.sortIndex = [];
  27051. if (_this3.hot.view) {
  27052. _this3.sortBySettings();
  27053. }
  27054. });
  27055. if (this.hot.view) {
  27056. this.sortBySettings();
  27057. }
  27058. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'enablePlugin', this).call(this);
  27059. }
  27060. /**
  27061. * Disable plugin for this Handsontable instance.
  27062. */
  27063. }, {
  27064. key: 'disablePlugin',
  27065. value: function disablePlugin() {
  27066. this.hot.sort = void 0;
  27067. _get(ColumnSorting.prototype.__proto__ || Object.getPrototypeOf(ColumnSorting.prototype), 'disablePlugin', this).call(this);
  27068. }
  27069. /**
  27070. * afterUpdateSettings callback.
  27071. *
  27072. * @private
  27073. */
  27074. }, {
  27075. key: 'onAfterUpdateSettings',
  27076. value: function onAfterUpdateSettings() {
  27077. this.sortBySettings();
  27078. }
  27079. }, {
  27080. key: 'sortBySettings',
  27081. value: function sortBySettings() {
  27082. var sortingSettings = this.hot.getSettings().columnSorting;
  27083. var loadedSortingState = this.loadSortingState();
  27084. var sortingColumn = void 0;
  27085. var sortingOrder = void 0;
  27086. if (typeof loadedSortingState === 'undefined') {
  27087. sortingColumn = sortingSettings.column;
  27088. sortingOrder = sortingSettings.sortOrder;
  27089. } else {
  27090. sortingColumn = loadedSortingState.sortColumn;
  27091. sortingOrder = loadedSortingState.sortOrder;
  27092. }
  27093. if (typeof sortingColumn === 'number') {
  27094. this.lastSortedColumn = sortingColumn;
  27095. this.sortByColumn(sortingColumn, sortingOrder);
  27096. }
  27097. }
  27098. /**
  27099. * Set sorted column and order info
  27100. *
  27101. * @param {number} col Sorted visual column index.
  27102. * @param {boolean|undefined} order Sorting order (`true` for ascending, `false` for descending).
  27103. */
  27104. }, {
  27105. key: 'setSortingColumn',
  27106. value: function setSortingColumn(col, order) {
  27107. if (typeof col == 'undefined') {
  27108. this.hot.sortColumn = void 0;
  27109. this.hot.sortOrder = void 0;
  27110. return;
  27111. } else if (this.hot.sortColumn === col && typeof order == 'undefined') {
  27112. if (this.hot.sortOrder === false) {
  27113. this.hot.sortOrder = void 0;
  27114. } else {
  27115. this.hot.sortOrder = !this.hot.sortOrder;
  27116. }
  27117. } else {
  27118. this.hot.sortOrder = typeof order === 'undefined' ? true : order;
  27119. }
  27120. this.hot.sortColumn = col;
  27121. }
  27122. }, {
  27123. key: 'sortByColumn',
  27124. value: function sortByColumn(col, order) {
  27125. this.setSortingColumn(col, order);
  27126. if (typeof this.hot.sortColumn == 'undefined') {
  27127. return;
  27128. }
  27129. var allowSorting = this.hot.runHooks('beforeColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  27130. if (allowSorting !== false) {
  27131. this.sort();
  27132. }
  27133. this.updateOrderClass();
  27134. this.updateSortIndicator();
  27135. this.hot.runHooks('afterColumnSort', this.hot.sortColumn, this.hot.sortOrder);
  27136. this.hot.render();
  27137. this.saveSortingState();
  27138. }
  27139. /**
  27140. * Save the sorting state
  27141. */
  27142. }, {
  27143. key: 'saveSortingState',
  27144. value: function saveSortingState() {
  27145. var sortingState = {};
  27146. if (typeof this.hot.sortColumn != 'undefined') {
  27147. sortingState.sortColumn = this.hot.sortColumn;
  27148. }
  27149. if (typeof this.hot.sortOrder != 'undefined') {
  27150. sortingState.sortOrder = this.hot.sortOrder;
  27151. }
  27152. if ((0, _object.hasOwnProperty)(sortingState, 'sortColumn') || (0, _object.hasOwnProperty)(sortingState, 'sortOrder')) {
  27153. this.hot.runHooks('persistentStateSave', 'columnSorting', sortingState);
  27154. }
  27155. }
  27156. /**
  27157. * Load the sorting state.
  27158. *
  27159. * @returns {*} Previously saved sorting state.
  27160. */
  27161. }, {
  27162. key: 'loadSortingState',
  27163. value: function loadSortingState() {
  27164. var storedState = {};
  27165. this.hot.runHooks('persistentStateLoad', 'columnSorting', storedState);
  27166. return storedState.value;
  27167. }
  27168. /**
  27169. * Update sorting class name state.
  27170. */
  27171. }, {
  27172. key: 'updateOrderClass',
  27173. value: function updateOrderClass() {
  27174. var orderClass = void 0;
  27175. if (this.hot.sortOrder === true) {
  27176. orderClass = 'ascending';
  27177. } else if (this.hot.sortOrder === false) {
  27178. orderClass = 'descending';
  27179. }
  27180. this.sortOrderClass = orderClass;
  27181. }
  27182. }, {
  27183. key: 'enableObserveChangesPlugin',
  27184. value: function enableObserveChangesPlugin() {
  27185. var _this = this;
  27186. this.hot._registerTimeout(setTimeout(function () {
  27187. _this.hot.updateSettings({
  27188. observeChanges: true
  27189. });
  27190. }, 0));
  27191. }
  27192. /**
  27193. * Default sorting algorithm.
  27194. *
  27195. * @param {Boolean} sortOrder Sorting order - `true` for ascending, `false` for descending.
  27196. * @param {Object} columnMeta Column meta object.
  27197. * @returns {Function} The comparing function.
  27198. */
  27199. }, {
  27200. key: 'defaultSort',
  27201. value: function defaultSort(sortOrder, columnMeta) {
  27202. return function (a, b) {
  27203. if (typeof a[1] == 'string') {
  27204. a[1] = a[1].toLowerCase();
  27205. }
  27206. if (typeof b[1] == 'string') {
  27207. b[1] = b[1].toLowerCase();
  27208. }
  27209. if (a[1] === b[1]) {
  27210. return 0;
  27211. }
  27212. if ((0, _mixed.isEmpty)(a[1])) {
  27213. if ((0, _mixed.isEmpty)(b[1])) {
  27214. return 0;
  27215. }
  27216. if (columnMeta.columnSorting.sortEmptyCells) {
  27217. return sortOrder ? -1 : 1;
  27218. }
  27219. return 1;
  27220. }
  27221. if ((0, _mixed.isEmpty)(b[1])) {
  27222. if ((0, _mixed.isEmpty)(a[1])) {
  27223. return 0;
  27224. }
  27225. if (columnMeta.columnSorting.sortEmptyCells) {
  27226. return sortOrder ? 1 : -1;
  27227. }
  27228. return -1;
  27229. }
  27230. if (isNaN(a[1]) && !isNaN(b[1])) {
  27231. return sortOrder ? 1 : -1;
  27232. } else if (!isNaN(a[1]) && isNaN(b[1])) {
  27233. return sortOrder ? -1 : 1;
  27234. } else if (!(isNaN(a[1]) || isNaN(b[1]))) {
  27235. a[1] = parseFloat(a[1]);
  27236. b[1] = parseFloat(b[1]);
  27237. }
  27238. if (a[1] < b[1]) {
  27239. return sortOrder ? -1 : 1;
  27240. }
  27241. if (a[1] > b[1]) {
  27242. return sortOrder ? 1 : -1;
  27243. }
  27244. return 0;
  27245. };
  27246. }
  27247. /**
  27248. * Date sorting algorithm
  27249. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  27250. * @param {Object} columnMeta Column meta object.
  27251. * @returns {Function} The compare function.
  27252. */
  27253. }, {
  27254. key: 'dateSort',
  27255. value: function dateSort(sortOrder, columnMeta) {
  27256. return function (a, b) {
  27257. if (a[1] === b[1]) {
  27258. return 0;
  27259. }
  27260. if ((0, _mixed.isEmpty)(a[1])) {
  27261. if ((0, _mixed.isEmpty)(b[1])) {
  27262. return 0;
  27263. }
  27264. if (columnMeta.columnSorting.sortEmptyCells) {
  27265. return sortOrder ? -1 : 1;
  27266. }
  27267. return 1;
  27268. }
  27269. if ((0, _mixed.isEmpty)(b[1])) {
  27270. if ((0, _mixed.isEmpty)(a[1])) {
  27271. return 0;
  27272. }
  27273. if (columnMeta.columnSorting.sortEmptyCells) {
  27274. return sortOrder ? 1 : -1;
  27275. }
  27276. return -1;
  27277. }
  27278. var aDate = (0, _moment2.default)(a[1], columnMeta.dateFormat);
  27279. var bDate = (0, _moment2.default)(b[1], columnMeta.dateFormat);
  27280. if (!aDate.isValid()) {
  27281. return 1;
  27282. }
  27283. if (!bDate.isValid()) {
  27284. return -1;
  27285. }
  27286. if (bDate.isAfter(aDate)) {
  27287. return sortOrder ? -1 : 1;
  27288. }
  27289. if (bDate.isBefore(aDate)) {
  27290. return sortOrder ? 1 : -1;
  27291. }
  27292. return 0;
  27293. };
  27294. }
  27295. /**
  27296. * Numeric sorting algorithm.
  27297. *
  27298. * @param {Boolean} sortOrder Sorting order (`true` for ascending, `false` for descending).
  27299. * @param {Object} columnMeta Column meta object.
  27300. * @returns {Function} The compare function.
  27301. */
  27302. }, {
  27303. key: 'numericSort',
  27304. value: function numericSort(sortOrder, columnMeta) {
  27305. return function (a, b) {
  27306. var parsedA = parseFloat(a[1]);
  27307. var parsedB = parseFloat(b[1]);
  27308. // Watch out when changing this part of code!
  27309. // Check below returns 0 (as expected) when comparing empty string, null, undefined
  27310. if (parsedA === parsedB || isNaN(parsedA) && isNaN(parsedB)) {
  27311. return 0;
  27312. }
  27313. if (columnMeta.columnSorting.sortEmptyCells) {
  27314. if ((0, _mixed.isEmpty)(a[1])) {
  27315. return sortOrder ? -1 : 1;
  27316. }
  27317. if ((0, _mixed.isEmpty)(b[1])) {
  27318. return sortOrder ? 1 : -1;
  27319. }
  27320. }
  27321. if (isNaN(parsedA)) {
  27322. return 1;
  27323. }
  27324. if (isNaN(parsedB)) {
  27325. return -1;
  27326. }
  27327. if (parsedA < parsedB) {
  27328. return sortOrder ? -1 : 1;
  27329. } else if (parsedA > parsedB) {
  27330. return sortOrder ? 1 : -1;
  27331. }
  27332. return 0;
  27333. };
  27334. }
  27335. /**
  27336. * Perform the sorting.
  27337. */
  27338. }, {
  27339. key: 'sort',
  27340. value: function sort() {
  27341. if (typeof this.hot.sortOrder == 'undefined') {
  27342. this.hot.sortIndex.length = 0;
  27343. return;
  27344. }
  27345. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  27346. var emptyRows = this.hot.countEmptyRows();
  27347. var sortFunction = void 0;
  27348. var nrOfRows = void 0;
  27349. this.hot.sortingEnabled = false; // this is required by translateRow plugin hook
  27350. this.hot.sortIndex.length = 0;
  27351. if (typeof colMeta.columnSorting.sortEmptyCells === 'undefined') {
  27352. colMeta.columnSorting = { sortEmptyCells: this.sortEmptyCells };
  27353. }
  27354. if (this.hot.getSettings().maxRows === Number.POSITIVE_INFINITY) {
  27355. nrOfRows = this.hot.countRows() - this.hot.getSettings().minSpareRows;
  27356. } else {
  27357. nrOfRows = this.hot.countRows() - emptyRows;
  27358. }
  27359. for (var i = 0, ilen = nrOfRows; i < ilen; i++) {
  27360. this.hot.sortIndex.push([i, this.hot.getDataAtCell(i, this.hot.sortColumn)]);
  27361. }
  27362. if (colMeta.sortFunction) {
  27363. sortFunction = colMeta.sortFunction;
  27364. } else {
  27365. switch (colMeta.type) {
  27366. case 'date':
  27367. sortFunction = this.dateSort;
  27368. break;
  27369. case 'numeric':
  27370. sortFunction = this.numericSort;
  27371. break;
  27372. default:
  27373. sortFunction = this.defaultSort;
  27374. }
  27375. }
  27376. (0, _mergeSort2.default)(this.hot.sortIndex, sortFunction(this.hot.sortOrder, colMeta));
  27377. // Append spareRows
  27378. for (var _i = this.hot.sortIndex.length; _i < this.hot.countRows(); _i++) {
  27379. this.hot.sortIndex.push([_i, this.hot.getDataAtCell(_i, this.hot.sortColumn)]);
  27380. }
  27381. this.hot.sortingEnabled = true; // this is required by translateRow plugin hook
  27382. }
  27383. /**
  27384. * Update indicator states.
  27385. */
  27386. }, {
  27387. key: 'updateSortIndicator',
  27388. value: function updateSortIndicator() {
  27389. if (typeof this.hot.sortOrder == 'undefined') {
  27390. return;
  27391. }
  27392. var colMeta = this.hot.getCellMeta(0, this.hot.sortColumn);
  27393. this.sortIndicators[this.hot.sortColumn] = colMeta.sortIndicator;
  27394. }
  27395. /**
  27396. * `modifyRow` hook callback. Translates physical row index to the sorted row index.
  27397. *
  27398. * @param {Number} row Row index.
  27399. * @returns {Number} Sorted row index.
  27400. */
  27401. }, {
  27402. key: 'translateRow',
  27403. value: function translateRow(row) {
  27404. if (this.hot.sortingEnabled && typeof this.hot.sortOrder !== 'undefined' && this.hot.sortIndex && this.hot.sortIndex.length && this.hot.sortIndex[row]) {
  27405. return this.hot.sortIndex[row][0];
  27406. }
  27407. return row;
  27408. }
  27409. /**
  27410. * Translates sorted row index to physical row index.
  27411. *
  27412. * @param {Number} row Sorted (visual) row index.
  27413. * @returns {number} Physical row index.
  27414. */
  27415. }, {
  27416. key: 'untranslateRow',
  27417. value: function untranslateRow(row) {
  27418. if (this.hot.sortingEnabled && this.hot.sortIndex && this.hot.sortIndex.length) {
  27419. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  27420. if (this.hot.sortIndex[i][0] == row) {
  27421. return i;
  27422. }
  27423. }
  27424. }
  27425. }
  27426. /**
  27427. * `afterGetColHeader` callback. Adds column sorting css classes to clickable headers.
  27428. *
  27429. * @private
  27430. * @param {Number} col Visual column index.
  27431. * @param {Element} TH TH HTML element.
  27432. */
  27433. }, {
  27434. key: 'getColHeader',
  27435. value: function getColHeader(col, TH) {
  27436. if (col < 0 || !TH.parentNode) {
  27437. return false;
  27438. }
  27439. var headerLink = TH.querySelector('.colHeader');
  27440. var colspan = TH.getAttribute('colspan');
  27441. var TRs = TH.parentNode.parentNode.childNodes;
  27442. var headerLevel = Array.prototype.indexOf.call(TRs, TH.parentNode);
  27443. headerLevel -= TRs.length;
  27444. if (!headerLink) {
  27445. return;
  27446. }
  27447. if (this.hot.getSettings().columnSorting && col >= 0 && headerLevel === -1) {
  27448. (0, _element.addClass)(headerLink, 'columnSorting');
  27449. }
  27450. (0, _element.removeClass)(headerLink, 'descending');
  27451. (0, _element.removeClass)(headerLink, 'ascending');
  27452. if (this.sortIndicators[col]) {
  27453. if (col === this.hot.sortColumn) {
  27454. if (this.sortOrderClass === 'ascending') {
  27455. (0, _element.addClass)(headerLink, 'ascending');
  27456. } else if (this.sortOrderClass === 'descending') {
  27457. (0, _element.addClass)(headerLink, 'descending');
  27458. }
  27459. }
  27460. }
  27461. }
  27462. /**
  27463. * Check if any column is in a sorted state.
  27464. *
  27465. * @returns {Boolean}
  27466. */
  27467. }, {
  27468. key: 'isSorted',
  27469. value: function isSorted() {
  27470. return typeof this.hot.sortColumn != 'undefined';
  27471. }
  27472. /**
  27473. * `afterCreateRow` callback. Updates the sorting state after a row have been created.
  27474. *
  27475. * @private
  27476. * @param {Number} index Visual row index.
  27477. * @param {Number} amount
  27478. */
  27479. }, {
  27480. key: 'afterCreateRow',
  27481. value: function afterCreateRow(index, amount) {
  27482. if (!this.isSorted()) {
  27483. return;
  27484. }
  27485. for (var i = 0; i < this.hot.sortIndex.length; i++) {
  27486. if (this.hot.sortIndex[i][0] >= index) {
  27487. this.hot.sortIndex[i][0] += amount;
  27488. }
  27489. }
  27490. for (var _i2 = 0; _i2 < amount; _i2++) {
  27491. this.hot.sortIndex.splice(index + _i2, 0, [index + _i2, this.hot.getSourceData()[index + _i2][this.hot.sortColumn + this.hot.colOffset()]]);
  27492. }
  27493. this.saveSortingState();
  27494. }
  27495. /**
  27496. * `afterRemoveRow` hook callback.
  27497. *
  27498. * @private
  27499. * @param {Number} index Visual row index.
  27500. * @param {Number} amount
  27501. */
  27502. }, {
  27503. key: 'afterRemoveRow',
  27504. value: function afterRemoveRow(index, amount) {
  27505. if (!this.isSorted()) {
  27506. return;
  27507. }
  27508. var removedRows = this.hot.sortIndex.splice(index, amount);
  27509. removedRows = (0, _array.arrayMap)(removedRows, function (row) {
  27510. return row[0];
  27511. });
  27512. function countRowShift(logicalRow) {
  27513. // Todo: compare perf between reduce vs sort->each->brake
  27514. return (0, _array.arrayReduce)(removedRows, function (count, removedLogicalRow) {
  27515. if (logicalRow > removedLogicalRow) {
  27516. count++;
  27517. }
  27518. return count;
  27519. }, 0);
  27520. }
  27521. this.hot.sortIndex = (0, _array.arrayMap)(this.hot.sortIndex, function (logicalRow, physicalRow) {
  27522. var rowShift = countRowShift(logicalRow[0]);
  27523. if (rowShift) {
  27524. logicalRow[0] -= rowShift;
  27525. }
  27526. return logicalRow;
  27527. });
  27528. this.saveSortingState();
  27529. }
  27530. /**
  27531. * Set options by passed settings
  27532. *
  27533. * @private
  27534. */
  27535. }, {
  27536. key: 'setPluginOptions',
  27537. value: function setPluginOptions() {
  27538. var columnSorting = this.hot.getSettings().columnSorting;
  27539. if ((typeof columnSorting === 'undefined' ? 'undefined' : _typeof(columnSorting)) === 'object') {
  27540. this.sortEmptyCells = columnSorting.sortEmptyCells || false;
  27541. } else {
  27542. this.sortEmptyCells = false;
  27543. }
  27544. }
  27545. /**
  27546. * `onAfterOnCellMouseDown` hook callback.
  27547. *
  27548. * @private
  27549. * @param {Event} event Event which are provided by hook.
  27550. * @param {CellCoords} coords Visual coords of the selected cell.
  27551. */
  27552. }, {
  27553. key: 'onAfterOnCellMouseDown',
  27554. value: function onAfterOnCellMouseDown(event, coords) {
  27555. if (coords.row > -1) {
  27556. return;
  27557. }
  27558. if ((0, _element.hasClass)(event.realTarget, 'columnSorting')) {
  27559. // reset order state on every new column header click
  27560. if (coords.col !== this.lastSortedColumn) {
  27561. this.hot.sortOrder = true;
  27562. }
  27563. this.lastSortedColumn = coords.col;
  27564. this.sortByColumn(coords.col);
  27565. }
  27566. }
  27567. }]);
  27568. return ColumnSorting;
  27569. }(_base2.default);
  27570. (0, _plugins.registerPlugin)('columnSorting', ColumnSorting);
  27571. exports.default = ColumnSorting;
  27572. /***/ }),
  27573. /* 215 */
  27574. /***/ (function(module, exports, __webpack_require__) {
  27575. "use strict";
  27576. exports.__esModule = true;
  27577. 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; }; }();
  27578. var _element = __webpack_require__(0);
  27579. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27580. /**
  27581. * Comment editor for the Comments plugin.
  27582. *
  27583. * @class CommentEditor
  27584. * @plugin Comments
  27585. */
  27586. var CommentEditor = function () {
  27587. _createClass(CommentEditor, null, [{
  27588. key: 'CLASS_EDITOR_CONTAINER',
  27589. get: function get() {
  27590. return 'htCommentsContainer';
  27591. }
  27592. }, {
  27593. key: 'CLASS_EDITOR',
  27594. get: function get() {
  27595. return 'htComments';
  27596. }
  27597. }, {
  27598. key: 'CLASS_INPUT',
  27599. get: function get() {
  27600. return 'htCommentTextArea';
  27601. }
  27602. }, {
  27603. key: 'CLASS_CELL',
  27604. get: function get() {
  27605. return 'htCommentCell';
  27606. }
  27607. }]);
  27608. function CommentEditor() {
  27609. _classCallCheck(this, CommentEditor);
  27610. this.editor = this.createEditor();
  27611. this.editorStyle = this.editor.style;
  27612. this.hidden = true;
  27613. this.hide();
  27614. }
  27615. /**
  27616. * Set position of the comments editor according to the provided x and y coordinates.
  27617. *
  27618. * @param {Number} x X position (in pixels).
  27619. * @param {Number} y Y position (in pixels).
  27620. */
  27621. _createClass(CommentEditor, [{
  27622. key: 'setPosition',
  27623. value: function setPosition(x, y) {
  27624. this.editorStyle.left = x + 'px';
  27625. this.editorStyle.top = y + 'px';
  27626. }
  27627. /**
  27628. * Set the editor size according to the provided arguments.
  27629. *
  27630. * @param {Number} width Width in pixels.
  27631. * @param {Number} height Height in pixels.
  27632. */
  27633. }, {
  27634. key: 'setSize',
  27635. value: function setSize(width, height) {
  27636. if (width && height) {
  27637. var input = this.getInputElement();
  27638. input.style.width = width + 'px';
  27639. input.style.height = height + 'px';
  27640. }
  27641. }
  27642. /**
  27643. * Reset the editor size to its initial state.
  27644. */
  27645. }, {
  27646. key: 'resetSize',
  27647. value: function resetSize() {
  27648. var input = this.getInputElement();
  27649. input.style.width = '';
  27650. input.style.height = '';
  27651. }
  27652. /**
  27653. * Set the read-only state for the comments editor.
  27654. *
  27655. * @param {Boolean} state The new read only state.
  27656. */
  27657. }, {
  27658. key: 'setReadOnlyState',
  27659. value: function setReadOnlyState(state) {
  27660. var input = this.getInputElement();
  27661. input.readOnly = state;
  27662. }
  27663. /**
  27664. * Show the comments editor.
  27665. */
  27666. }, {
  27667. key: 'show',
  27668. value: function show() {
  27669. this.editorStyle.display = 'block';
  27670. this.hidden = false;
  27671. }
  27672. /**
  27673. * Hide the comments editor.
  27674. */
  27675. }, {
  27676. key: 'hide',
  27677. value: function hide() {
  27678. this.editorStyle.display = 'none';
  27679. this.hidden = true;
  27680. }
  27681. /**
  27682. * Checks if the editor is visible.
  27683. *
  27684. * @returns {Boolean}
  27685. */
  27686. }, {
  27687. key: 'isVisible',
  27688. value: function isVisible() {
  27689. return this.editorStyle.display === 'block';
  27690. }
  27691. /**
  27692. * Set the comment value.
  27693. *
  27694. * @param {String} [value] The value to use.
  27695. */
  27696. }, {
  27697. key: 'setValue',
  27698. value: function setValue() {
  27699. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  27700. value = value || '';
  27701. this.getInputElement().value = value;
  27702. }
  27703. /**
  27704. * Get the comment value.
  27705. *
  27706. * @returns {String}
  27707. */
  27708. }, {
  27709. key: 'getValue',
  27710. value: function getValue() {
  27711. return this.getInputElement().value;
  27712. }
  27713. /**
  27714. * Checks if the comment input element is focused.
  27715. *
  27716. * @returns {Boolean}
  27717. */
  27718. }, {
  27719. key: 'isFocused',
  27720. value: function isFocused() {
  27721. return document.activeElement === this.getInputElement();
  27722. }
  27723. /**
  27724. * Focus the comments input element.
  27725. */
  27726. }, {
  27727. key: 'focus',
  27728. value: function focus() {
  27729. this.getInputElement().focus();
  27730. }
  27731. /**
  27732. * Create the `textarea` to be used as a comments editor.
  27733. *
  27734. * @returns {HTMLElement}
  27735. */
  27736. }, {
  27737. key: 'createEditor',
  27738. value: function createEditor() {
  27739. var container = document.querySelector('.' + CommentEditor.CLASS_EDITOR_CONTAINER);
  27740. var editor = void 0;
  27741. var textArea = void 0;
  27742. if (!container) {
  27743. container = document.createElement('div');
  27744. (0, _element.addClass)(container, CommentEditor.CLASS_EDITOR_CONTAINER);
  27745. document.body.appendChild(container);
  27746. }
  27747. editor = document.createElement('div');
  27748. (0, _element.addClass)(editor, CommentEditor.CLASS_EDITOR);
  27749. textArea = document.createElement('textarea');
  27750. (0, _element.addClass)(textArea, CommentEditor.CLASS_INPUT);
  27751. editor.appendChild(textArea);
  27752. container.appendChild(editor);
  27753. return editor;
  27754. }
  27755. /**
  27756. * Get the input element.
  27757. *
  27758. * @returns {HTMLElement}
  27759. */
  27760. }, {
  27761. key: 'getInputElement',
  27762. value: function getInputElement() {
  27763. return this.editor.querySelector('.' + CommentEditor.CLASS_INPUT);
  27764. }
  27765. /**
  27766. * Destroy the comments editor.
  27767. */
  27768. }, {
  27769. key: 'destroy',
  27770. value: function destroy() {
  27771. this.editor.parentNode.removeChild(this.editor);
  27772. this.editor = null;
  27773. this.editorStyle = null;
  27774. }
  27775. }]);
  27776. return CommentEditor;
  27777. }();
  27778. exports.default = CommentEditor;
  27779. /***/ }),
  27780. /* 216 */
  27781. /***/ (function(module, exports, __webpack_require__) {
  27782. "use strict";
  27783. exports.__esModule = true;
  27784. 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; }; }();
  27785. 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); } };
  27786. var _element = __webpack_require__(0);
  27787. var _object = __webpack_require__(1);
  27788. var _eventManager = __webpack_require__(4);
  27789. var _eventManager2 = _interopRequireDefault(_eventManager);
  27790. var _src = __webpack_require__(11);
  27791. var _plugins = __webpack_require__(5);
  27792. var _base = __webpack_require__(12);
  27793. var _base2 = _interopRequireDefault(_base);
  27794. var _commentEditor = __webpack_require__(215);
  27795. var _commentEditor2 = _interopRequireDefault(_commentEditor);
  27796. var _utils = __webpack_require__(17);
  27797. var _displaySwitch = __webpack_require__(217);
  27798. var _displaySwitch2 = _interopRequireDefault(_displaySwitch);
  27799. __webpack_require__(296);
  27800. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  27801. 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; }
  27802. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  27803. 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; }
  27804. 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; }
  27805. var privatePool = new WeakMap();
  27806. var META_COMMENT = 'comment';
  27807. var META_COMMENT_VALUE = 'value';
  27808. var META_STYLE = 'style';
  27809. var META_READONLY = 'readOnly';
  27810. /**
  27811. * @plugin Comments
  27812. *
  27813. * @description
  27814. * This plugin allows setting and managing cell comments by either an option in the context menu or with the use of the API.
  27815. *
  27816. * To enable the plugin, you'll need to set the comments property of the config object to `true`:
  27817. * ```js
  27818. * ...
  27819. * comments: true
  27820. * ...
  27821. * ```
  27822. *
  27823. * or object with extra predefined plugin config:
  27824. *
  27825. * ```js
  27826. * ...
  27827. * comments: {
  27828. * displayDelay: 1000
  27829. * }
  27830. * ...
  27831. * ```
  27832. *
  27833. * To add comments at the table initialization, define the `comment` property in the `cell` config array as in an example below.
  27834. *
  27835. * @example
  27836. *
  27837. * ```js
  27838. * ...
  27839. * var hot = new Handsontable(document.getElementById('example'), {
  27840. * date: getData(),
  27841. * comments: true,
  27842. * cell: [
  27843. * {row: 1, col: 1, comment: {value: 'Foo'}},
  27844. * {row: 2, col: 2, comment: {value: 'Bar'}}
  27845. * ]
  27846. * });
  27847. *
  27848. * // Access to the Comments plugin instance:
  27849. * var commentsPlugin = hot.getPlugin('comments');
  27850. *
  27851. * // Manage comments programmatically:
  27852. * commentsPlugin.setCommentAtCell(1, 6, 'Comment contents');
  27853. * commentsPlugin.showAtCell(1, 6);
  27854. * commentsPlugin.removeCommentAtCell(1, 6);
  27855. *
  27856. * // You can also set range once and use proper methods:
  27857. * commentsPlugin.setRange({row: 1, col: 6});
  27858. * commentsPlugin.setComment('Comment contents');
  27859. * commentsPlugin.show();
  27860. * commentsPlugin.removeComment();
  27861. * ...
  27862. * ```
  27863. */
  27864. var Comments = function (_BasePlugin) {
  27865. _inherits(Comments, _BasePlugin);
  27866. function Comments(hotInstance) {
  27867. _classCallCheck(this, Comments);
  27868. /**
  27869. * Instance of {@link CommentEditor}.
  27870. *
  27871. * @type {CommentEditor}
  27872. */
  27873. var _this = _possibleConstructorReturn(this, (Comments.__proto__ || Object.getPrototypeOf(Comments)).call(this, hotInstance));
  27874. _this.editor = null;
  27875. /**
  27876. * Instance of {@link DisplaySwitch}.
  27877. *
  27878. * @type {DisplaySwitch}
  27879. */
  27880. _this.displaySwitch = null;
  27881. /**
  27882. * Instance of {@link EventManager}.
  27883. *
  27884. * @private
  27885. * @type {EventManager}
  27886. */
  27887. _this.eventManager = null;
  27888. /**
  27889. * Current cell range.
  27890. *
  27891. * @type {Object}
  27892. */
  27893. _this.range = {};
  27894. /**
  27895. * @private
  27896. * @type {Boolean}
  27897. */
  27898. _this.mouseDown = false;
  27899. /**
  27900. * @private
  27901. * @type {Boolean}
  27902. */
  27903. _this.contextMenuEvent = false;
  27904. /**
  27905. * @private
  27906. * @type {*}
  27907. */
  27908. _this.timer = null;
  27909. privatePool.set(_this, {
  27910. tempEditorDimensions: {},
  27911. cellBelowCursor: null
  27912. });
  27913. return _this;
  27914. }
  27915. /**
  27916. * Check if the plugin is enabled in the Handsontable settings.
  27917. *
  27918. * @returns {Boolean}
  27919. */
  27920. _createClass(Comments, [{
  27921. key: 'isEnabled',
  27922. value: function isEnabled() {
  27923. return !!this.hot.getSettings().comments;
  27924. }
  27925. /**
  27926. * Enable plugin for this Handsontable instance.
  27927. */
  27928. }, {
  27929. key: 'enablePlugin',
  27930. value: function enablePlugin() {
  27931. var _this2 = this;
  27932. if (this.enabled) {
  27933. return;
  27934. }
  27935. if (!this.editor) {
  27936. this.editor = new _commentEditor2.default();
  27937. }
  27938. if (!this.eventManager) {
  27939. this.eventManager = new _eventManager2.default(this);
  27940. }
  27941. if (!this.displaySwitch) {
  27942. this.displaySwitch = new _displaySwitch2.default(this.getDisplayDelaySetting());
  27943. }
  27944. this.addHook('afterContextMenuDefaultOptions', function (options) {
  27945. return _this2.addToContextMenu(options);
  27946. });
  27947. this.addHook('afterRenderer', function (TD, row, col, prop, value, cellProperties) {
  27948. return _this2.onAfterRenderer(TD, cellProperties);
  27949. });
  27950. this.addHook('afterScrollHorizontally', function () {
  27951. return _this2.hide();
  27952. });
  27953. this.addHook('afterScrollVertically', function () {
  27954. return _this2.hide();
  27955. });
  27956. this.addHook('afterBeginEditing', function (args) {
  27957. return _this2.onAfterBeginEditing(args);
  27958. });
  27959. this.displaySwitch.addLocalHook('hide', function () {
  27960. return _this2.hide();
  27961. });
  27962. this.displaySwitch.addLocalHook('show', function (row, col) {
  27963. return _this2.showAtCell(row, col);
  27964. });
  27965. this.registerListeners();
  27966. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'enablePlugin', this).call(this);
  27967. }
  27968. /**
  27969. * Update plugin for this Handsontable instance.
  27970. */
  27971. }, {
  27972. key: 'updatePlugin',
  27973. value: function updatePlugin() {
  27974. this.disablePlugin();
  27975. this.enablePlugin();
  27976. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'updatePlugin', this).call(this);
  27977. this.displaySwitch.updateDelay(this.getDisplayDelaySetting());
  27978. }
  27979. /**
  27980. * Disable plugin for this Handsontable instance.
  27981. */
  27982. }, {
  27983. key: 'disablePlugin',
  27984. value: function disablePlugin() {
  27985. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'disablePlugin', this).call(this);
  27986. }
  27987. /**
  27988. * Register all necessary DOM listeners.
  27989. *
  27990. * @private
  27991. */
  27992. }, {
  27993. key: 'registerListeners',
  27994. value: function registerListeners() {
  27995. var _this3 = this;
  27996. this.eventManager.addEventListener(document, 'mouseover', function (event) {
  27997. return _this3.onMouseOver(event);
  27998. });
  27999. this.eventManager.addEventListener(document, 'mousedown', function (event) {
  28000. return _this3.onMouseDown(event);
  28001. });
  28002. this.eventManager.addEventListener(document, 'mouseup', function (event) {
  28003. return _this3.onMouseUp(event);
  28004. });
  28005. this.eventManager.addEventListener(this.editor.getInputElement(), 'blur', function (event) {
  28006. return _this3.onEditorBlur(event);
  28007. });
  28008. this.eventManager.addEventListener(this.editor.getInputElement(), 'mousedown', function (event) {
  28009. return _this3.onEditorMouseDown(event);
  28010. });
  28011. this.eventManager.addEventListener(this.editor.getInputElement(), 'mouseup', function (event) {
  28012. return _this3.onEditorMouseUp(event);
  28013. });
  28014. }
  28015. /**
  28016. * Set current cell range to be able to use general methods like {@link Comments#setComment},
  28017. * {@link Comments#removeComment}, {@link Comments#show}.
  28018. *
  28019. * @param {Object} range Object with `from` and `to` properties, each with `row` and `col` properties.
  28020. */
  28021. }, {
  28022. key: 'setRange',
  28023. value: function setRange(range) {
  28024. this.range = range;
  28025. }
  28026. /**
  28027. * Clear the currently selected cell.
  28028. */
  28029. }, {
  28030. key: 'clearRange',
  28031. value: function clearRange() {
  28032. this.range = {};
  28033. }
  28034. /**
  28035. * Check if the event target is a cell containing a comment.
  28036. *
  28037. * @param {Event} event DOM event
  28038. * @returns {Boolean}
  28039. */
  28040. }, {
  28041. key: 'targetIsCellWithComment',
  28042. value: function targetIsCellWithComment(event) {
  28043. var closestCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  28044. return !!(closestCell && (0, _element.hasClass)(closestCell, 'htCommentCell') && (0, _element.closest)(closestCell, [this.hot.rootElement]));
  28045. }
  28046. /**
  28047. * Check if the event target is a comment textarea.
  28048. *
  28049. * @param {Event} event DOM event.
  28050. * @returns {Boolean}
  28051. */
  28052. }, {
  28053. key: 'targetIsCommentTextArea',
  28054. value: function targetIsCommentTextArea(event) {
  28055. return this.editor.getInputElement() === event.target;
  28056. }
  28057. /**
  28058. * Set a comment for a cell according to the previously set range (see {@link Comments#setRange}).
  28059. *
  28060. * @param {String} value Comment contents.
  28061. */
  28062. }, {
  28063. key: 'setComment',
  28064. value: function setComment(value) {
  28065. if (!this.range.from) {
  28066. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  28067. }
  28068. var editorValue = this.editor.getValue();
  28069. var comment = '';
  28070. if (value != null) {
  28071. comment = value;
  28072. } else if (editorValue != null) {
  28073. comment = editorValue;
  28074. }
  28075. var row = this.range.from.row;
  28076. var col = this.range.from.col;
  28077. this.updateCommentMeta(row, col, _defineProperty({}, META_COMMENT_VALUE, comment));
  28078. this.hot.render();
  28079. }
  28080. /**
  28081. * Set a comment for a cell.
  28082. *
  28083. * @param {Number} row Visual row index.
  28084. * @param {Number} col Visual column index.
  28085. * @param {String} value Comment contents.
  28086. */
  28087. }, {
  28088. key: 'setCommentAtCell',
  28089. value: function setCommentAtCell(row, col, value) {
  28090. this.setRange({
  28091. from: new _src.CellCoords(row, col)
  28092. });
  28093. this.setComment(value);
  28094. }
  28095. /**
  28096. * Remove a comment from a cell according to previously set range (see {@link Comments#setRange}).
  28097. *
  28098. * @param {Boolean} [forceRender = true] If set to `true`, the table will be re-rendered at the end of the operation.
  28099. */
  28100. }, {
  28101. key: 'removeComment',
  28102. value: function removeComment() {
  28103. var forceRender = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  28104. if (!this.range.from) {
  28105. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  28106. }
  28107. this.hot.setCellMeta(this.range.from.row, this.range.from.col, META_COMMENT, void 0);
  28108. if (forceRender) {
  28109. this.hot.render();
  28110. }
  28111. this.hide();
  28112. }
  28113. /**
  28114. * Remove comment from a cell.
  28115. *
  28116. * @param {Number} row Visual row index.
  28117. * @param {Number} col Visual column index.
  28118. * @param {Boolean} [forceRender = true] If `true`, the table will be re-rendered at the end of the operation.
  28119. */
  28120. }, {
  28121. key: 'removeCommentAtCell',
  28122. value: function removeCommentAtCell(row, col) {
  28123. var forceRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  28124. this.setRange({
  28125. from: new _src.CellCoords(row, col)
  28126. });
  28127. this.removeComment(forceRender);
  28128. }
  28129. /**
  28130. * Get comment from a cell at the predefined range.
  28131. */
  28132. }, {
  28133. key: 'getComment',
  28134. value: function getComment() {
  28135. var row = this.range.from.row;
  28136. var column = this.range.from.col;
  28137. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  28138. }
  28139. /**
  28140. * Get comment from a cell at the provided coordinates.
  28141. *
  28142. * @param {Number} row Visual row index.
  28143. * @param {Number} column Visual column index.
  28144. */
  28145. }, {
  28146. key: 'getCommentAtCell',
  28147. value: function getCommentAtCell(row, column) {
  28148. return this.getCommentMeta(row, column, META_COMMENT_VALUE);
  28149. }
  28150. /**
  28151. * Show the comment editor accordingly to the previously set range (see {@link Comments#setRange}).
  28152. *
  28153. * @returns {Boolean} Returns `true` if comment editor was shown.
  28154. */
  28155. }, {
  28156. key: 'show',
  28157. value: function show() {
  28158. if (!this.range.from) {
  28159. throw new Error('Before using this method, first set cell range (hot.getPlugin("comment").setRange())');
  28160. }
  28161. var meta = this.hot.getCellMeta(this.range.from.row, this.range.from.col);
  28162. this.refreshEditor(true);
  28163. this.editor.setValue(meta[META_COMMENT] ? meta[META_COMMENT][META_COMMENT_VALUE] : null || '');
  28164. if (this.editor.hidden) {
  28165. this.editor.show();
  28166. }
  28167. return true;
  28168. }
  28169. /**
  28170. * Show comment editor according to cell coordinates.
  28171. *
  28172. * @param {Number} row Visual row index.
  28173. * @param {Number} col Visual column index.
  28174. * @returns {Boolean} Returns `true` if comment editor was shown.
  28175. */
  28176. }, {
  28177. key: 'showAtCell',
  28178. value: function showAtCell(row, col) {
  28179. this.setRange({
  28180. from: new _src.CellCoords(row, col)
  28181. });
  28182. return this.show();
  28183. }
  28184. /**
  28185. * Hide the comment editor.
  28186. */
  28187. }, {
  28188. key: 'hide',
  28189. value: function hide() {
  28190. if (!this.editor.hidden) {
  28191. this.editor.hide();
  28192. }
  28193. }
  28194. /**
  28195. * Refresh comment editor position and styling.
  28196. *
  28197. * @param {Boolean} [force=false] If `true` then recalculation will be forced.
  28198. */
  28199. }, {
  28200. key: 'refreshEditor',
  28201. value: function refreshEditor() {
  28202. var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  28203. if (!force && (!this.range.from || !this.editor.isVisible())) {
  28204. return;
  28205. }
  28206. var scrollableElement = (0, _element.getScrollableElement)(this.hot.view.wt.wtTable.TABLE);
  28207. var TD = this.hot.view.wt.wtTable.getCell(this.range.from);
  28208. var row = this.range.from.row;
  28209. var column = this.range.from.col;
  28210. var cellOffset = (0, _element.offset)(TD);
  28211. var lastColWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(column);
  28212. var cellTopOffset = cellOffset.top < 0 ? 0 : cellOffset.top;
  28213. var cellLeftOffset = cellOffset.left;
  28214. if (this.hot.view.wt.wtViewport.hasVerticalScroll() && scrollableElement !== window) {
  28215. cellTopOffset -= this.hot.view.wt.wtOverlays.topOverlay.getScrollPosition();
  28216. }
  28217. if (this.hot.view.wt.wtViewport.hasHorizontalScroll() && scrollableElement !== window) {
  28218. cellLeftOffset -= this.hot.view.wt.wtOverlays.leftOverlay.getScrollPosition();
  28219. }
  28220. var x = cellLeftOffset + lastColWidth;
  28221. var y = cellTopOffset;
  28222. var commentStyle = this.getCommentMeta(row, column, META_STYLE);
  28223. var readOnly = this.getCommentMeta(row, column, META_READONLY);
  28224. if (commentStyle) {
  28225. this.editor.setSize(commentStyle.width, commentStyle.height);
  28226. } else {
  28227. this.editor.resetSize();
  28228. }
  28229. this.editor.setReadOnlyState(readOnly);
  28230. this.editor.setPosition(x, y);
  28231. }
  28232. /**
  28233. * Check if there is a comment for selected range.
  28234. *
  28235. * @private
  28236. * @returns {Boolean}
  28237. */
  28238. }, {
  28239. key: 'checkSelectionCommentsConsistency',
  28240. value: function checkSelectionCommentsConsistency() {
  28241. var selected = this.hot.getSelectedRange();
  28242. if (!selected) {
  28243. return false;
  28244. }
  28245. var hasComment = false;
  28246. var cell = selected.from; // IN EXCEL THERE IS COMMENT ONLY FOR TOP LEFT CELL IN SELECTION
  28247. if (this.getCommentMeta(cell.row, cell.col, META_COMMENT_VALUE)) {
  28248. hasComment = true;
  28249. }
  28250. return hasComment;
  28251. }
  28252. /**
  28253. * Set or update the comment-related cell meta.
  28254. *
  28255. * @param {Number} row Visual row index.
  28256. * @param {Number} column Visual column index.
  28257. * @param {Object} metaObject Object defining all the comment-related meta information.
  28258. */
  28259. }, {
  28260. key: 'updateCommentMeta',
  28261. value: function updateCommentMeta(row, column, metaObject) {
  28262. var oldComment = this.hot.getCellMeta(row, column)[META_COMMENT];
  28263. var newComment = void 0;
  28264. if (oldComment) {
  28265. newComment = (0, _object.deepClone)(oldComment);
  28266. (0, _object.deepExtend)(newComment, metaObject);
  28267. } else {
  28268. newComment = metaObject;
  28269. }
  28270. this.hot.setCellMeta(row, column, META_COMMENT, newComment);
  28271. }
  28272. /**
  28273. * Get the comment related meta information.
  28274. *
  28275. * @param {Number} row Visual row index.
  28276. * @param {Number} column Visual column index.
  28277. * @param {String} property Cell meta property.
  28278. * @returns {Mixed}
  28279. */
  28280. }, {
  28281. key: 'getCommentMeta',
  28282. value: function getCommentMeta(row, column, property) {
  28283. var cellMeta = this.hot.getCellMeta(row, column);
  28284. if (!cellMeta[META_COMMENT]) {
  28285. return void 0;
  28286. }
  28287. return cellMeta[META_COMMENT][property];
  28288. }
  28289. /**
  28290. * `mousedown` event callback.
  28291. *
  28292. * @private
  28293. * @param {MouseEvent} event The `mousedown` event.
  28294. */
  28295. }, {
  28296. key: 'onMouseDown',
  28297. value: function onMouseDown(event) {
  28298. this.mouseDown = true;
  28299. if (!this.hot.view || !this.hot.view.wt) {
  28300. return;
  28301. }
  28302. if (!this.contextMenuEvent && !this.targetIsCommentTextArea(event)) {
  28303. var eventCell = (0, _element.closest)(event.target, 'TD', 'TBODY');
  28304. var coordinates = null;
  28305. if (eventCell) {
  28306. coordinates = this.hot.view.wt.wtTable.getCoords(eventCell);
  28307. }
  28308. if (!eventCell || this.range.from && coordinates && (this.range.from.row !== coordinates.row || this.range.from.col !== coordinates.col)) {
  28309. this.hide();
  28310. }
  28311. }
  28312. this.contextMenuEvent = false;
  28313. }
  28314. /**
  28315. * `mouseover` event callback.
  28316. *
  28317. * @private
  28318. * @param {MouseEvent} event The `mouseover` event.
  28319. */
  28320. }, {
  28321. key: 'onMouseOver',
  28322. value: function onMouseOver(event) {
  28323. var priv = privatePool.get(this);
  28324. priv.cellBelowCursor = document.elementFromPoint(event.clientX, event.clientY);
  28325. if (this.mouseDown || this.editor.isFocused() || (0, _element.hasClass)(event.target, 'wtBorder') || priv.cellBelowCursor !== event.target || !this.editor) {
  28326. return;
  28327. }
  28328. if (this.targetIsCellWithComment(event)) {
  28329. var coordinates = this.hot.view.wt.wtTable.getCoords(event.target);
  28330. var range = {
  28331. from: new _src.CellCoords(coordinates.row, coordinates.col)
  28332. };
  28333. this.displaySwitch.show(range);
  28334. } else if ((0, _element.isChildOf)(event.target, document) && !this.targetIsCommentTextArea(event)) {
  28335. this.displaySwitch.hide();
  28336. }
  28337. }
  28338. /**
  28339. * `mouseup` event callback.
  28340. *
  28341. * @private
  28342. * @param {MouseEvent} event The `mouseup` event.
  28343. */
  28344. }, {
  28345. key: 'onMouseUp',
  28346. value: function onMouseUp(event) {
  28347. this.mouseDown = false;
  28348. }
  28349. /** *
  28350. * The `afterRenderer` hook callback..
  28351. *
  28352. * @private
  28353. * @param {HTMLTableCellElement} TD The rendered `TD` element.
  28354. * @param {Object} cellProperties The rendered cell's property object.
  28355. */
  28356. }, {
  28357. key: 'onAfterRenderer',
  28358. value: function onAfterRenderer(TD, cellProperties) {
  28359. if (cellProperties[META_COMMENT] && cellProperties[META_COMMENT][META_COMMENT_VALUE]) {
  28360. (0, _element.addClass)(TD, cellProperties.commentedCellClassName);
  28361. }
  28362. }
  28363. /**
  28364. * `blur` event callback for the comment editor.
  28365. *
  28366. * @private
  28367. * @param {Event} event The `blur` event.
  28368. */
  28369. }, {
  28370. key: 'onEditorBlur',
  28371. value: function onEditorBlur(event) {
  28372. this.setComment();
  28373. }
  28374. /**
  28375. * `mousedown` hook. Along with `onEditorMouseUp` used to simulate the textarea resizing event.
  28376. *
  28377. * @private
  28378. * @param {MouseEvent} event The `mousedown` event.
  28379. */
  28380. }, {
  28381. key: 'onEditorMouseDown',
  28382. value: function onEditorMouseDown(event) {
  28383. var priv = privatePool.get(this);
  28384. priv.tempEditorDimensions = {
  28385. width: (0, _element.outerWidth)(event.target),
  28386. height: (0, _element.outerHeight)(event.target)
  28387. };
  28388. }
  28389. /**
  28390. * `mouseup` hook. Along with `onEditorMouseDown` used to simulate the textarea resizing event.
  28391. *
  28392. * @private
  28393. * @param {MouseEvent} event The `mouseup` event.
  28394. */
  28395. }, {
  28396. key: 'onEditorMouseUp',
  28397. value: function onEditorMouseUp(event) {
  28398. var priv = privatePool.get(this);
  28399. var currentWidth = (0, _element.outerWidth)(event.target);
  28400. var currentHeight = (0, _element.outerHeight)(event.target);
  28401. if (currentWidth !== priv.tempEditorDimensions.width + 1 || currentHeight !== priv.tempEditorDimensions.height + 2) {
  28402. this.updateCommentMeta(this.range.from.row, this.range.from.col, _defineProperty({}, META_STYLE, {
  28403. width: currentWidth,
  28404. height: currentHeight
  28405. }));
  28406. }
  28407. }
  28408. /**
  28409. * Context Menu's "Add comment" callback. Results in showing the comment editor.
  28410. *
  28411. * @private
  28412. */
  28413. }, {
  28414. key: 'onContextMenuAddComment',
  28415. value: function onContextMenuAddComment() {
  28416. var _this4 = this;
  28417. this.displaySwitch.cancelHiding();
  28418. var coords = this.hot.getSelectedRange();
  28419. this.contextMenuEvent = true;
  28420. this.setRange({
  28421. from: coords.from
  28422. });
  28423. this.show();
  28424. setTimeout(function () {
  28425. if (_this4.hot) {
  28426. _this4.hot.deselectCell();
  28427. _this4.editor.focus();
  28428. }
  28429. }, 10);
  28430. }
  28431. /**
  28432. * Context Menu's "remove comment" callback.
  28433. *
  28434. * @private
  28435. * @param {Object} selection The current selection.
  28436. */
  28437. }, {
  28438. key: 'onContextMenuRemoveComment',
  28439. value: function onContextMenuRemoveComment(selection) {
  28440. this.contextMenuEvent = true;
  28441. for (var i = selection.start.row; i <= selection.end.row; i++) {
  28442. for (var j = selection.start.col; j <= selection.end.col; j++) {
  28443. this.removeCommentAtCell(i, j, false);
  28444. }
  28445. }
  28446. this.hot.render();
  28447. }
  28448. /**
  28449. * Context Menu's "make comment read-only" callback.
  28450. *
  28451. * @private
  28452. * @param {Object} selection The current selection.
  28453. */
  28454. }, {
  28455. key: 'onContextMenuMakeReadOnly',
  28456. value: function onContextMenuMakeReadOnly(selection) {
  28457. this.contextMenuEvent = true;
  28458. for (var i = selection.start.row; i <= selection.end.row; i++) {
  28459. for (var j = selection.start.col; j <= selection.end.col; j++) {
  28460. var currentState = !!this.getCommentMeta(i, j, META_READONLY);
  28461. this.updateCommentMeta(i, j, _defineProperty({}, META_READONLY, !currentState));
  28462. }
  28463. }
  28464. }
  28465. /**
  28466. * Add Comments plugin options to the Context Menu.
  28467. *
  28468. * @private
  28469. * @param {Object} defaultOptions
  28470. */
  28471. }, {
  28472. key: 'addToContextMenu',
  28473. value: function addToContextMenu(defaultOptions) {
  28474. var _this5 = this;
  28475. defaultOptions.items.push({
  28476. name: '---------'
  28477. }, {
  28478. key: 'commentsAddEdit',
  28479. name: function name() {
  28480. return _this5.checkSelectionCommentsConsistency() ? 'Edit comment' : 'Add comment';
  28481. },
  28482. callback: function callback() {
  28483. return _this5.onContextMenuAddComment();
  28484. },
  28485. disabled: function disabled() {
  28486. return !(this.getSelected() && !this.selection.selectedHeader.corner);
  28487. }
  28488. }, {
  28489. key: 'commentsRemove',
  28490. name: function name() {
  28491. return 'Delete comment';
  28492. },
  28493. callback: function callback(key, selection) {
  28494. return _this5.onContextMenuRemoveComment(selection);
  28495. },
  28496. disabled: function disabled() {
  28497. return _this5.hot.selection.selectedHeader.corner;
  28498. }
  28499. }, {
  28500. key: 'commentsReadOnly',
  28501. name: function name() {
  28502. var _this6 = this;
  28503. var label = 'Read only comment';
  28504. var hasProperty = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  28505. var readOnlyProperty = _this6.getCellMeta(row, col)[META_COMMENT];
  28506. if (readOnlyProperty) {
  28507. readOnlyProperty = readOnlyProperty[META_READONLY];
  28508. }
  28509. if (readOnlyProperty) {
  28510. return true;
  28511. }
  28512. });
  28513. if (hasProperty) {
  28514. label = (0, _utils.markLabelAsSelected)(label);
  28515. }
  28516. return label;
  28517. },
  28518. callback: function callback(key, selection) {
  28519. return _this5.onContextMenuMakeReadOnly(selection);
  28520. },
  28521. disabled: function disabled() {
  28522. return _this5.hot.selection.selectedHeader.corner || !_this5.checkSelectionCommentsConsistency();
  28523. }
  28524. });
  28525. }
  28526. /**
  28527. * Get `displayDelay` setting of comment plugin.
  28528. *
  28529. * @returns {Number|undefined}
  28530. */
  28531. }, {
  28532. key: 'getDisplayDelaySetting',
  28533. value: function getDisplayDelaySetting() {
  28534. var commentSetting = this.hot.getSettings().comments;
  28535. if ((0, _object.isObject)(commentSetting)) {
  28536. return commentSetting.displayDelay;
  28537. }
  28538. return void 0;
  28539. }
  28540. /**
  28541. * `afterBeginEditing` hook callback.
  28542. *
  28543. * @private
  28544. * @param {Number} row Visual row index of the currently edited cell.
  28545. * @param {Number} column Visual column index of the currently edited cell.
  28546. */
  28547. }, {
  28548. key: 'onAfterBeginEditing',
  28549. value: function onAfterBeginEditing(row, column) {
  28550. this.hide();
  28551. }
  28552. /**
  28553. * Destroy plugin instance.
  28554. */
  28555. }, {
  28556. key: 'destroy',
  28557. value: function destroy() {
  28558. if (this.editor) {
  28559. this.editor.destroy();
  28560. }
  28561. if (this.displaySwitch) {
  28562. this.displaySwitch.destroy();
  28563. }
  28564. _get(Comments.prototype.__proto__ || Object.getPrototypeOf(Comments.prototype), 'destroy', this).call(this);
  28565. }
  28566. }]);
  28567. return Comments;
  28568. }(_base2.default);
  28569. (0, _plugins.registerPlugin)('comments', Comments);
  28570. exports.default = Comments;
  28571. /***/ }),
  28572. /* 217 */
  28573. /***/ (function(module, exports, __webpack_require__) {
  28574. "use strict";
  28575. exports.__esModule = true;
  28576. 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; }; }();
  28577. var _function = __webpack_require__(35);
  28578. var _object = __webpack_require__(1);
  28579. var _localHooks = __webpack_require__(69);
  28580. var _localHooks2 = _interopRequireDefault(_localHooks);
  28581. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28582. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28583. var DEFAULT_DISPLAY_DELAY = 250;
  28584. var DEFAULT_HIDE_DELAY = 250;
  28585. /**
  28586. * Display switch for the Comments plugin. Manages the time of delayed displaying / hiding comments.
  28587. *
  28588. * @class DisplaySwitch
  28589. * @plugin Comments
  28590. */
  28591. var DisplaySwitch = function () {
  28592. function DisplaySwitch(displayDelay) {
  28593. _classCallCheck(this, DisplaySwitch);
  28594. /**
  28595. * Flag to determine if comment can be showed or hidden. State `true` mean that last performed action
  28596. * was an attempt to show comment element. State `false` mean that it was attempt to hide comment element.
  28597. *
  28598. * @type {Boolean}
  28599. */
  28600. this.wasLastActionShow = true;
  28601. /**
  28602. * Show comment after predefined delay. It keeps reference to immutable `debounce` function.
  28603. *
  28604. * @type {Function}
  28605. */
  28606. this.showDebounced = null;
  28607. /**
  28608. * Reference to timer, run by `setTimeout`, which is hiding comment
  28609. *
  28610. * @type {Number}
  28611. */
  28612. this.hidingTimer = null;
  28613. this.updateDelay(displayDelay);
  28614. }
  28615. /**
  28616. * Responsible for hiding comment after proper delay.
  28617. */
  28618. _createClass(DisplaySwitch, [{
  28619. key: 'hide',
  28620. value: function hide() {
  28621. var _this = this;
  28622. this.wasLastActionShow = false;
  28623. this.hidingTimer = setTimeout(function () {
  28624. if (_this.wasLastActionShow === false) {
  28625. _this.runLocalHooks('hide');
  28626. }
  28627. }, DEFAULT_HIDE_DELAY);
  28628. }
  28629. /**
  28630. * Responsible for showing comment after proper delay.
  28631. *
  28632. * @param {Object} range Coordinates of selected cell.
  28633. */
  28634. }, {
  28635. key: 'show',
  28636. value: function show(range) {
  28637. this.wasLastActionShow = true;
  28638. this.showDebounced(range);
  28639. }
  28640. }, {
  28641. key: 'cancelHiding',
  28642. /**
  28643. * Cancel hiding comment.
  28644. */
  28645. value: function cancelHiding() {
  28646. this.wasLastActionShow = true;
  28647. clearTimeout(this.hidingTimer);
  28648. this.hidingTimer = null;
  28649. }
  28650. /**
  28651. * Update the switch settings.
  28652. *
  28653. * @param {Number} displayDelay Delay of showing the comments (in milliseconds).
  28654. */
  28655. }, {
  28656. key: 'updateDelay',
  28657. value: function updateDelay() {
  28658. var _this2 = this;
  28659. var displayDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_DISPLAY_DELAY;
  28660. this.showDebounced = (0, _function.debounce)(function (range) {
  28661. if (_this2.wasLastActionShow) {
  28662. _this2.runLocalHooks('show', range.from.row, range.from.col);
  28663. }
  28664. }, displayDelay);
  28665. }
  28666. /**
  28667. * Destroy the switcher.
  28668. */
  28669. }, {
  28670. key: 'destroy',
  28671. value: function destroy() {
  28672. this.clearLocalHooks();
  28673. }
  28674. }]);
  28675. return DisplaySwitch;
  28676. }();
  28677. (0, _object.mixin)(DisplaySwitch, _localHooks2.default);
  28678. exports.default = DisplaySwitch;
  28679. /***/ }),
  28680. /* 218 */
  28681. /***/ (function(module, exports, __webpack_require__) {
  28682. "use strict";
  28683. exports.__esModule = true;
  28684. 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; }; }();
  28685. var _array = __webpack_require__(2);
  28686. var _object = __webpack_require__(1);
  28687. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28688. /**
  28689. * Command executor for ContextMenu.
  28690. *
  28691. * @class CommandExecutor
  28692. * @plugin ContextMenu
  28693. */
  28694. var CommandExecutor = function () {
  28695. function CommandExecutor(hotInstance) {
  28696. _classCallCheck(this, CommandExecutor);
  28697. this.hot = hotInstance;
  28698. this.commands = {};
  28699. this.commonCallback = null;
  28700. }
  28701. /**
  28702. * Register command.
  28703. *
  28704. * @param {String} name Command name.
  28705. * @param {Object} commandDescriptor Command descriptor object with properties like `key` (command id),
  28706. * `callback` (task to execute), `name` (command name), `disabled` (command availability).
  28707. */
  28708. _createClass(CommandExecutor, [{
  28709. key: 'registerCommand',
  28710. value: function registerCommand(name, commandDescriptor) {
  28711. this.commands[name] = commandDescriptor;
  28712. }
  28713. /**
  28714. * Set common callback which will be trigger on every executed command.
  28715. *
  28716. * @param {Function} callback Function which will be fired on every command execute.
  28717. */
  28718. }, {
  28719. key: 'setCommonCallback',
  28720. value: function setCommonCallback(callback) {
  28721. this.commonCallback = callback;
  28722. }
  28723. /**
  28724. * Execute command by its name.
  28725. *
  28726. * @param {String} commandName Command id.
  28727. * @param {*} params Arguments passed to command task.
  28728. */
  28729. }, {
  28730. key: 'execute',
  28731. value: function execute(commandName) {
  28732. var _this = this;
  28733. for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  28734. params[_key - 1] = arguments[_key];
  28735. }
  28736. var commandSplit = commandName.split(':');
  28737. commandName = commandSplit[0];
  28738. var subCommandName = commandSplit.length === 2 ? commandSplit[1] : null;
  28739. var command = this.commands[commandName];
  28740. if (!command) {
  28741. throw new Error('Menu command \'' + commandName + '\' not exists.');
  28742. }
  28743. if (subCommandName && command.submenu) {
  28744. command = findSubCommand(subCommandName, command.submenu.items);
  28745. }
  28746. if (command.disabled === true) {
  28747. return;
  28748. }
  28749. if (typeof command.disabled == 'function' && command.disabled.call(this.hot) === true) {
  28750. return;
  28751. }
  28752. if ((0, _object.hasOwnProperty)(command, 'submenu')) {
  28753. return;
  28754. }
  28755. var callbacks = [];
  28756. if (typeof command.callback === 'function') {
  28757. callbacks.push(command.callback);
  28758. }
  28759. if (typeof this.commonCallback === 'function') {
  28760. callbacks.push(this.commonCallback);
  28761. }
  28762. params.unshift(commandSplit.join(':'));
  28763. (0, _array.arrayEach)(callbacks, function (callback) {
  28764. return callback.apply(_this.hot, params);
  28765. });
  28766. }
  28767. }]);
  28768. return CommandExecutor;
  28769. }();
  28770. function findSubCommand(subCommandName, subCommands) {
  28771. var command = void 0;
  28772. (0, _array.arrayEach)(subCommands, function (cmd) {
  28773. var cmds = cmd.key ? cmd.key.split(':') : null;
  28774. if (Array.isArray(cmds) && cmds[1] === subCommandName) {
  28775. command = cmd;
  28776. return false;
  28777. }
  28778. });
  28779. return command;
  28780. }
  28781. exports.default = CommandExecutor;
  28782. /***/ }),
  28783. /* 219 */
  28784. /***/ (function(module, exports, __webpack_require__) {
  28785. "use strict";
  28786. exports.__esModule = true;
  28787. 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); } };
  28788. 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; }; }();
  28789. var _base = __webpack_require__(12);
  28790. var _base2 = _interopRequireDefault(_base);
  28791. var _pluginHooks = __webpack_require__(8);
  28792. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  28793. var _array = __webpack_require__(2);
  28794. var _commandExecutor = __webpack_require__(218);
  28795. var _commandExecutor2 = _interopRequireDefault(_commandExecutor);
  28796. var _eventManager = __webpack_require__(4);
  28797. var _eventManager2 = _interopRequireDefault(_eventManager);
  28798. var _itemsFactory = __webpack_require__(221);
  28799. var _itemsFactory2 = _interopRequireDefault(_itemsFactory);
  28800. var _menu = __webpack_require__(222);
  28801. var _menu2 = _interopRequireDefault(_menu);
  28802. var _plugins = __webpack_require__(5);
  28803. var _event = __webpack_require__(7);
  28804. var _element = __webpack_require__(0);
  28805. var _predefinedItems = __webpack_require__(70);
  28806. __webpack_require__(297);
  28807. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  28808. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  28809. 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; }
  28810. 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; }
  28811. _pluginHooks2.default.getSingleton().register('afterContextMenuDefaultOptions');
  28812. _pluginHooks2.default.getSingleton().register('afterContextMenuShow');
  28813. _pluginHooks2.default.getSingleton().register('afterContextMenuHide');
  28814. _pluginHooks2.default.getSingleton().register('afterContextMenuExecute');
  28815. /**
  28816. * @description
  28817. * This plugin creates the Handsontable Context Menu. It allows to create a new row or
  28818. * column at any place in the grid among [other features](http://docs.handsontable.com/demo-context-menu.html).
  28819. * Possible values:
  28820. * * `true` (to enable default options),
  28821. * * `false` (to disable completely)
  28822. *
  28823. * or array of any available strings:
  28824. * * `["row_above", "row_below", "col_left", "col_right",
  28825. * "remove_row", "remove_col", "---------", "undo", "redo"]`.
  28826. *
  28827. * See [the context menu demo](http://docs.handsontable.com/demo-context-menu.html) for examples.
  28828. *
  28829. * @example
  28830. * ```js
  28831. * ...
  28832. * // as a boolean
  28833. * contextMenu: true
  28834. * ...
  28835. * // as a array
  28836. * contextMenu: ['row_above', 'row_below', '---------', 'undo', 'redo']
  28837. * ...
  28838. * ```
  28839. *
  28840. * @plugin ContextMenu
  28841. */
  28842. var ContextMenu = function (_BasePlugin) {
  28843. _inherits(ContextMenu, _BasePlugin);
  28844. _createClass(ContextMenu, null, [{
  28845. key: 'DEFAULT_ITEMS',
  28846. /**
  28847. * Default menu items order when `contextMenu` is enabled by `true`.
  28848. *
  28849. * @returns {Array}
  28850. */
  28851. get: function get() {
  28852. 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];
  28853. }
  28854. }]);
  28855. function ContextMenu(hotInstance) {
  28856. _classCallCheck(this, ContextMenu);
  28857. /**
  28858. * Instance of {@link EventManager}.
  28859. *
  28860. * @type {EventManager}
  28861. */
  28862. var _this = _possibleConstructorReturn(this, (ContextMenu.__proto__ || Object.getPrototypeOf(ContextMenu)).call(this, hotInstance));
  28863. _this.eventManager = new _eventManager2.default(_this);
  28864. /**
  28865. * Instance of {@link CommandExecutor}.
  28866. *
  28867. * @type {CommandExecutor}
  28868. */
  28869. _this.commandExecutor = new _commandExecutor2.default(_this.hot);
  28870. /**
  28871. * Instance of {@link ItemsFactory}.
  28872. *
  28873. * @type {ItemsFactory}
  28874. */
  28875. _this.itemsFactory = null;
  28876. /**
  28877. * Instance of {@link Menu}.
  28878. *
  28879. * @type {Menu}
  28880. */
  28881. _this.menu = null;
  28882. return _this;
  28883. }
  28884. /**
  28885. * Check if the plugin is enabled in the Handsontable settings.
  28886. *
  28887. * @returns {Boolean}
  28888. */
  28889. _createClass(ContextMenu, [{
  28890. key: 'isEnabled',
  28891. value: function isEnabled() {
  28892. return this.hot.getSettings().contextMenu;
  28893. }
  28894. /**
  28895. * Enable plugin for this Handsontable instance.
  28896. */
  28897. }, {
  28898. key: 'enablePlugin',
  28899. value: function enablePlugin() {
  28900. var _this2 = this;
  28901. if (this.enabled) {
  28902. return;
  28903. }
  28904. this.itemsFactory = new _itemsFactory2.default(this.hot, ContextMenu.DEFAULT_ITEMS);
  28905. var settings = this.hot.getSettings().contextMenu;
  28906. var predefinedItems = {
  28907. items: this.itemsFactory.getItems(settings)
  28908. };
  28909. this.registerEvents();
  28910. if (typeof settings.callback === 'function') {
  28911. this.commandExecutor.setCommonCallback(settings.callback);
  28912. }
  28913. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'enablePlugin', this).call(this);
  28914. this.callOnPluginsReady(function () {
  28915. _this2.hot.runHooks('afterContextMenuDefaultOptions', predefinedItems);
  28916. _this2.itemsFactory.setPredefinedItems(predefinedItems.items);
  28917. var menuItems = _this2.itemsFactory.getItems(settings);
  28918. _this2.menu = new _menu2.default(_this2.hot, {
  28919. className: 'htContextMenu',
  28920. keepInViewport: true
  28921. });
  28922. _this2.hot.runHooks('beforeContextMenuSetItems', menuItems);
  28923. _this2.menu.setMenuItems(menuItems);
  28924. _this2.menu.addLocalHook('afterOpen', function () {
  28925. return _this2.onMenuAfterOpen();
  28926. });
  28927. _this2.menu.addLocalHook('afterClose', function () {
  28928. return _this2.onMenuAfterClose();
  28929. });
  28930. _this2.menu.addLocalHook('executeCommand', function () {
  28931. for (var _len = arguments.length, params = Array(_len), _key = 0; _key < _len; _key++) {
  28932. params[_key] = arguments[_key];
  28933. }
  28934. return _this2.executeCommand.apply(_this2, params);
  28935. });
  28936. // Register all commands. Predefined and added by user or by plugins
  28937. (0, _array.arrayEach)(menuItems, function (command) {
  28938. return _this2.commandExecutor.registerCommand(command.key, command);
  28939. });
  28940. });
  28941. }
  28942. /**
  28943. * Updates the plugin to use the latest options you have specified.
  28944. */
  28945. }, {
  28946. key: 'updatePlugin',
  28947. value: function updatePlugin() {
  28948. this.disablePlugin();
  28949. this.enablePlugin();
  28950. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'updatePlugin', this).call(this);
  28951. }
  28952. /**
  28953. * Disable plugin for this Handsontable instance.
  28954. */
  28955. }, {
  28956. key: 'disablePlugin',
  28957. value: function disablePlugin() {
  28958. this.close();
  28959. if (this.menu) {
  28960. this.menu.destroy();
  28961. this.menu = null;
  28962. }
  28963. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'disablePlugin', this).call(this);
  28964. }
  28965. /**
  28966. * Register dom listeners.
  28967. *
  28968. * @private
  28969. */
  28970. }, {
  28971. key: 'registerEvents',
  28972. value: function registerEvents() {
  28973. var _this3 = this;
  28974. this.eventManager.addEventListener(this.hot.rootElement, 'contextmenu', function (event) {
  28975. return _this3.onContextMenu(event);
  28976. });
  28977. }
  28978. /**
  28979. * Open menu and re-position it based on dom event object.
  28980. *
  28981. * @param {Event} event The event object.
  28982. */
  28983. }, {
  28984. key: 'open',
  28985. value: function open(event) {
  28986. if (!this.menu) {
  28987. return;
  28988. }
  28989. this.menu.open();
  28990. this.menu.setPosition({
  28991. top: parseInt((0, _event.pageY)(event), 10) - (0, _element.getWindowScrollTop)(),
  28992. left: parseInt((0, _event.pageX)(event), 10) - (0, _element.getWindowScrollLeft)()
  28993. });
  28994. // ContextMenu is not detected HotTableEnv correctly because is injected outside hot-table
  28995. this.menu.hotMenu.isHotTableEnv = this.hot.isHotTableEnv;
  28996. // Handsontable.eventManager.isHotTableEnv = this.hot.isHotTableEnv;
  28997. }
  28998. /**
  28999. * Close menu.
  29000. */
  29001. }, {
  29002. key: 'close',
  29003. value: function close() {
  29004. if (!this.menu) {
  29005. return;
  29006. }
  29007. this.menu.close();
  29008. }
  29009. /**
  29010. * Execute context menu command.
  29011. *
  29012. * You can execute all predefined commands:
  29013. * * `'row_above'` - Insert row above
  29014. * * `'row_below'` - Insert row below
  29015. * * `'col_left'` - Insert column on the left
  29016. * * `'col_right'` - Insert column on the right
  29017. * * `'clear_column'` - Clear selected column
  29018. * * `'remove_row'` - Remove row
  29019. * * `'remove_col'` - Remove column
  29020. * * `'undo'` - Undo last action
  29021. * * `'redo'` - Redo last action
  29022. * * `'make_read_only'` - Make cell read only
  29023. * * `'alignment:left'` - Alignment to the left
  29024. * * `'alignment:top'` - Alignment to the top
  29025. * * `'alignment:right'` - Alignment to the right
  29026. * * `'alignment:bottom'` - Alignment to the bottom
  29027. * * `'alignment:middle'` - Alignment to the middle
  29028. * * `'alignment:center'` - Alignment to the center (justify)
  29029. *
  29030. * Or you can execute command registered in settings where `key` is your command name.
  29031. *
  29032. * @param {String} commandName
  29033. * @param {*} params
  29034. */
  29035. }, {
  29036. key: 'executeCommand',
  29037. value: function executeCommand() {
  29038. for (var _len2 = arguments.length, params = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  29039. params[_key2] = arguments[_key2];
  29040. }
  29041. this.commandExecutor.execute.apply(this.commandExecutor, params);
  29042. }
  29043. /**
  29044. * On context menu listener.
  29045. *
  29046. * @private
  29047. * @param {Event} event
  29048. */
  29049. }, {
  29050. key: 'onContextMenu',
  29051. value: function onContextMenu(event) {
  29052. var settings = this.hot.getSettings();
  29053. var showRowHeaders = settings.rowHeaders;
  29054. var showColHeaders = settings.colHeaders;
  29055. function isValidElement(element) {
  29056. return element.nodeName === 'TD' || element.parentNode.nodeName === 'TD';
  29057. }
  29058. // if event is from hot-table we must get web component element not element inside him
  29059. var element = event.realTarget;
  29060. this.close();
  29061. if ((0, _element.hasClass)(element, 'handsontableInput')) {
  29062. return;
  29063. }
  29064. event.preventDefault();
  29065. (0, _event.stopPropagation)(event);
  29066. if (!(showRowHeaders || showColHeaders)) {
  29067. if (!isValidElement(element) && !((0, _element.hasClass)(element, 'current') && (0, _element.hasClass)(element, 'wtBorder'))) {
  29068. return;
  29069. }
  29070. }
  29071. this.open(event);
  29072. }
  29073. /**
  29074. * On menu after open listener.
  29075. *
  29076. * @private
  29077. */
  29078. }, {
  29079. key: 'onMenuAfterOpen',
  29080. value: function onMenuAfterOpen() {
  29081. this.hot.runHooks('afterContextMenuShow', this);
  29082. }
  29083. /**
  29084. * On menu after close listener.
  29085. *
  29086. * @private
  29087. */
  29088. }, {
  29089. key: 'onMenuAfterClose',
  29090. value: function onMenuAfterClose() {
  29091. this.hot.listen();
  29092. this.hot.runHooks('afterContextMenuHide', this);
  29093. }
  29094. /**
  29095. * Destroy instance.
  29096. */
  29097. }, {
  29098. key: 'destroy',
  29099. value: function destroy() {
  29100. this.close();
  29101. if (this.menu) {
  29102. this.menu.destroy();
  29103. }
  29104. _get(ContextMenu.prototype.__proto__ || Object.getPrototypeOf(ContextMenu.prototype), 'destroy', this).call(this);
  29105. }
  29106. }]);
  29107. return ContextMenu;
  29108. }(_base2.default);
  29109. ContextMenu.SEPARATOR = {
  29110. name: _predefinedItems.SEPARATOR
  29111. };
  29112. (0, _plugins.registerPlugin)('contextMenu', ContextMenu);
  29113. exports.default = ContextMenu;
  29114. /***/ }),
  29115. /* 220 */
  29116. /***/ (function(module, exports, __webpack_require__) {
  29117. "use strict";
  29118. exports.__esModule = true;
  29119. 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; }; }();
  29120. var _element = __webpack_require__(0);
  29121. var _event = __webpack_require__(7);
  29122. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29123. /**
  29124. * Helper class for checking if element will fit at the desired side of cursor.
  29125. *
  29126. * @class Cursor
  29127. * @plugin ContextMenu
  29128. */
  29129. var Cursor = function () {
  29130. function Cursor(object) {
  29131. _classCallCheck(this, Cursor);
  29132. var windowScrollTop = (0, _element.getWindowScrollTop)();
  29133. var windowScrollLeft = (0, _element.getWindowScrollLeft)();
  29134. var top = void 0,
  29135. topRelative = void 0;
  29136. var left = void 0,
  29137. leftRelative = void 0;
  29138. var cellHeight = void 0,
  29139. cellWidth = void 0;
  29140. this.type = this.getSourceType(object);
  29141. if (this.type === 'literal') {
  29142. top = parseInt(object.top, 10);
  29143. left = parseInt(object.left, 10);
  29144. cellHeight = object.height || 0;
  29145. cellWidth = object.width || 0;
  29146. topRelative = top;
  29147. leftRelative = left;
  29148. top += windowScrollTop;
  29149. left += windowScrollLeft;
  29150. } else if (this.type === 'event') {
  29151. top = parseInt((0, _event.pageY)(object), 10);
  29152. left = parseInt((0, _event.pageX)(object), 10);
  29153. cellHeight = object.target.clientHeight;
  29154. cellWidth = object.target.clientWidth;
  29155. topRelative = top - windowScrollTop;
  29156. leftRelative = left - windowScrollLeft;
  29157. }
  29158. this.top = top;
  29159. this.topRelative = topRelative;
  29160. this.left = left;
  29161. this.leftRelative = leftRelative;
  29162. this.scrollTop = windowScrollTop;
  29163. this.scrollLeft = windowScrollLeft;
  29164. this.cellHeight = cellHeight;
  29165. this.cellWidth = cellWidth;
  29166. }
  29167. /**
  29168. * Get source type name.
  29169. *
  29170. * @param {*} object Event or Object with coordinates.
  29171. * @returns {String} Returns one of this values: `'literal'`, `'event'`.
  29172. */
  29173. _createClass(Cursor, [{
  29174. key: 'getSourceType',
  29175. value: function getSourceType(object) {
  29176. var type = 'literal';
  29177. if (object instanceof Event) {
  29178. type = 'event';
  29179. }
  29180. return type;
  29181. }
  29182. /**
  29183. * Checks if element can be placed above the cursor.
  29184. *
  29185. * @param {HTMLElement} element Element to check if it's size will fit above the cursor.
  29186. * @returns {Boolean}
  29187. */
  29188. }, {
  29189. key: 'fitsAbove',
  29190. value: function fitsAbove(element) {
  29191. return this.topRelative >= element.offsetHeight;
  29192. }
  29193. /**
  29194. * Checks if element can be placed below the cursor.
  29195. *
  29196. * @param {HTMLElement} element Element to check if it's size will fit below the cursor.
  29197. * @param {Number} [viewportHeight] The viewport height.
  29198. * @returns {Boolean}
  29199. */
  29200. }, {
  29201. key: 'fitsBelow',
  29202. value: function fitsBelow(element) {
  29203. var viewportHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerHeight;
  29204. return this.topRelative + element.offsetHeight <= viewportHeight;
  29205. }
  29206. /**
  29207. * Checks if element can be placed on the right of the cursor.
  29208. *
  29209. * @param {HTMLElement} element Element to check if it's size will fit on the right of the cursor.
  29210. * @param {Number} [viewportWidth] The viewport width.
  29211. * @returns {Boolean}
  29212. */
  29213. }, {
  29214. key: 'fitsOnRight',
  29215. value: function fitsOnRight(element) {
  29216. var viewportWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.innerWidth;
  29217. return this.leftRelative + this.cellWidth + element.offsetWidth <= viewportWidth;
  29218. }
  29219. /**
  29220. * Checks if element can be placed on the left on the cursor.
  29221. *
  29222. * @param {HTMLElement} element Element to check if it's size will fit on the left of the cursor.
  29223. * @returns {Boolean}
  29224. */
  29225. }, {
  29226. key: 'fitsOnLeft',
  29227. value: function fitsOnLeft(element) {
  29228. return this.leftRelative >= element.offsetWidth;
  29229. }
  29230. }]);
  29231. return Cursor;
  29232. }();
  29233. exports.default = Cursor;
  29234. /***/ }),
  29235. /* 221 */
  29236. /***/ (function(module, exports, __webpack_require__) {
  29237. "use strict";
  29238. exports.__esModule = true;
  29239. 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; }; }();
  29240. var _object = __webpack_require__(1);
  29241. var _array = __webpack_require__(2);
  29242. var _predefinedItems = __webpack_require__(70);
  29243. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29244. /**
  29245. * Predefined items class factory for menu items.
  29246. *
  29247. * @class ItemsFactory
  29248. * @plugin ContextMenu
  29249. */
  29250. var ItemsFactory = function () {
  29251. function ItemsFactory(hotInstance) {
  29252. var orderPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  29253. _classCallCheck(this, ItemsFactory);
  29254. this.hot = hotInstance;
  29255. this.predefinedItems = (0, _predefinedItems.predefinedItems)();
  29256. this.defaultOrderPattern = orderPattern;
  29257. }
  29258. /**
  29259. * Set predefined items.
  29260. *
  29261. * @param {Array} predefinedItems Array of predefined items.
  29262. */
  29263. _createClass(ItemsFactory, [{
  29264. key: 'setPredefinedItems',
  29265. value: function setPredefinedItems(predefinedItems) {
  29266. var _this = this;
  29267. var items = {};
  29268. this.defaultOrderPattern.length = 0;
  29269. (0, _object.objectEach)(predefinedItems, function (value, key) {
  29270. var menuItemKey = '';
  29271. if (value.name === _predefinedItems.SEPARATOR) {
  29272. items[_predefinedItems.SEPARATOR] = value;
  29273. menuItemKey = _predefinedItems.SEPARATOR;
  29274. // Menu item added as a property to array
  29275. } else if (isNaN(parseInt(key, 10))) {
  29276. value.key = value.key === void 0 ? key : value.key;
  29277. items[key] = value;
  29278. menuItemKey = value.key;
  29279. } else {
  29280. items[value.key] = value;
  29281. menuItemKey = value.key;
  29282. }
  29283. _this.defaultOrderPattern.push(menuItemKey);
  29284. });
  29285. this.predefinedItems = items;
  29286. }
  29287. /**
  29288. * Get all menu items based on pattern.
  29289. *
  29290. * @param {Array|Object|Boolean} pattern Pattern which you can define by displaying menu items order. If `true` default
  29291. * pattern will be used.
  29292. * @returns {Array}
  29293. */
  29294. }, {
  29295. key: 'getItems',
  29296. value: function getItems() {
  29297. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  29298. return _getItems(pattern, this.defaultOrderPattern, this.predefinedItems);
  29299. }
  29300. }]);
  29301. return ItemsFactory;
  29302. }();
  29303. function _getItems() {
  29304. var pattern = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  29305. var defaultPattern = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  29306. var items = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  29307. var result = [];
  29308. if (pattern && pattern.items) {
  29309. pattern = pattern.items;
  29310. } else if (!Array.isArray(pattern)) {
  29311. pattern = defaultPattern;
  29312. }
  29313. if ((0, _object.isObject)(pattern)) {
  29314. (0, _object.objectEach)(pattern, function (value, key) {
  29315. var item = items[typeof value === 'string' ? value : key];
  29316. if (!item) {
  29317. item = value;
  29318. }
  29319. if ((0, _object.isObject)(value)) {
  29320. (0, _object.extend)(item, value);
  29321. } else if (typeof item === 'string') {
  29322. item = { name: item };
  29323. }
  29324. if (item.key === void 0) {
  29325. item.key = key;
  29326. }
  29327. result.push(item);
  29328. });
  29329. } else {
  29330. (0, _array.arrayEach)(pattern, function (name, key) {
  29331. var item = items[name];
  29332. // Item deleted from settings `allowInsertRow: false` etc.
  29333. if (!item && _predefinedItems.ITEMS.indexOf(name) >= 0) {
  29334. return;
  29335. }
  29336. if (!item) {
  29337. item = { name: name, key: '' + key };
  29338. }
  29339. if ((0, _object.isObject)(name)) {
  29340. (0, _object.extend)(item, name);
  29341. }
  29342. if (item.key === void 0) {
  29343. item.key = key;
  29344. }
  29345. result.push(item);
  29346. });
  29347. }
  29348. return result;
  29349. }
  29350. exports.default = ItemsFactory;
  29351. /***/ }),
  29352. /* 222 */
  29353. /***/ (function(module, exports, __webpack_require__) {
  29354. "use strict";
  29355. exports.__esModule = true;
  29356. 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; }; }();
  29357. var _core = __webpack_require__(63);
  29358. var _core2 = _interopRequireDefault(_core);
  29359. var _element = __webpack_require__(0);
  29360. var _array = __webpack_require__(2);
  29361. var _cursor = __webpack_require__(220);
  29362. var _cursor2 = _interopRequireDefault(_cursor);
  29363. var _eventManager = __webpack_require__(4);
  29364. var _eventManager2 = _interopRequireDefault(_eventManager);
  29365. var _object = __webpack_require__(1);
  29366. var _function = __webpack_require__(35);
  29367. var _utils = __webpack_require__(17);
  29368. var _unicode = __webpack_require__(16);
  29369. var _localHooks = __webpack_require__(69);
  29370. var _localHooks2 = _interopRequireDefault(_localHooks);
  29371. var _predefinedItems = __webpack_require__(70);
  29372. var _event = __webpack_require__(7);
  29373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  29374. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  29375. /**
  29376. * @class Menu
  29377. * @plugin ContextMenu
  29378. */
  29379. var Menu = function () {
  29380. function Menu(hotInstance, options) {
  29381. _classCallCheck(this, Menu);
  29382. this.hot = hotInstance;
  29383. this.options = options || {
  29384. parent: null,
  29385. name: null,
  29386. className: '',
  29387. keepInViewport: true,
  29388. standalone: false
  29389. };
  29390. this.eventManager = new _eventManager2.default(this);
  29391. this.container = this.createContainer(this.options.name);
  29392. this.hotMenu = null;
  29393. this.hotSubMenus = {};
  29394. this.parentMenu = this.options.parent || null;
  29395. this.menuItems = null;
  29396. this.origOutsideClickDeselects = null;
  29397. this.keyEvent = false;
  29398. this.offset = {
  29399. above: 0,
  29400. below: 0,
  29401. left: 0,
  29402. right: 0
  29403. };
  29404. this._afterScrollCallback = null;
  29405. this.registerEvents();
  29406. }
  29407. /**
  29408. * Register event listeners.
  29409. *
  29410. * @private
  29411. */
  29412. _createClass(Menu, [{
  29413. key: 'registerEvents',
  29414. value: function registerEvents() {
  29415. var _this = this;
  29416. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  29417. return _this.onDocumentMouseDown(event);
  29418. });
  29419. }
  29420. /**
  29421. * Set array of objects which defines menu items.
  29422. *
  29423. * @param {Array} menuItems Menu items to display.
  29424. */
  29425. }, {
  29426. key: 'setMenuItems',
  29427. value: function setMenuItems(menuItems) {
  29428. this.menuItems = menuItems;
  29429. }
  29430. /**
  29431. * Set offset menu position for specified area (`above`, `below`, `left` or `right`).
  29432. *
  29433. * @param {String} area Specified area name (`above`, `below`, `left` or `right`).
  29434. * @param {Number} offset Offset value.
  29435. */
  29436. }, {
  29437. key: 'setOffset',
  29438. value: function setOffset(area) {
  29439. var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  29440. this.offset[area] = offset;
  29441. }
  29442. /**
  29443. * Check if menu is using as sub-menu.
  29444. *
  29445. * @returns {Boolean}
  29446. */
  29447. }, {
  29448. key: 'isSubMenu',
  29449. value: function isSubMenu() {
  29450. return this.parentMenu !== null;
  29451. }
  29452. /**
  29453. * Open menu.
  29454. */
  29455. }, {
  29456. key: 'open',
  29457. value: function open() {
  29458. var _this2 = this;
  29459. this.container.removeAttribute('style');
  29460. this.container.style.display = 'block';
  29461. var delayedOpenSubMenu = (0, _function.debounce)(function (row) {
  29462. return _this2.openSubMenu(row);
  29463. }, 300);
  29464. var filteredItems = (0, _array.arrayFilter)(this.menuItems, function (item) {
  29465. return (0, _utils.isItemHidden)(item, _this2.hot);
  29466. });
  29467. filteredItems = (0, _utils.filterSeparators)(filteredItems, _predefinedItems.SEPARATOR);
  29468. var settings = {
  29469. data: filteredItems,
  29470. colHeaders: false,
  29471. colWidths: [200],
  29472. autoRowSize: false,
  29473. readOnly: true,
  29474. copyPaste: false,
  29475. columns: [{
  29476. data: 'name',
  29477. renderer: function renderer(hot, TD, row, col, prop, value) {
  29478. return _this2.menuItemRenderer(hot, TD, row, col, prop, value);
  29479. }
  29480. }],
  29481. renderAllRows: true,
  29482. fragmentSelection: 'cell',
  29483. disableVisualSelection: 'area',
  29484. beforeKeyDown: function beforeKeyDown(event) {
  29485. return _this2.onBeforeKeyDown(event);
  29486. },
  29487. afterOnCellMouseOver: function afterOnCellMouseOver(event, coords, TD) {
  29488. if (_this2.isAllSubMenusClosed()) {
  29489. delayedOpenSubMenu(coords.row);
  29490. } else {
  29491. _this2.openSubMenu(coords.row);
  29492. }
  29493. },
  29494. rowHeights: function rowHeights(row) {
  29495. return filteredItems[row].name === _predefinedItems.SEPARATOR ? 1 : 23;
  29496. }
  29497. };
  29498. this.origOutsideClickDeselects = this.hot.getSettings().outsideClickDeselects;
  29499. this.hot.getSettings().outsideClickDeselects = false;
  29500. this.hotMenu = new _core2.default(this.container, settings);
  29501. this.hotMenu.addHook('afterInit', function () {
  29502. return _this2.onAfterInit();
  29503. });
  29504. this.hotMenu.addHook('afterSelection', function (r, c, r2, c2, preventScrolling) {
  29505. return _this2.onAfterSelection(r, c, r2, c2, preventScrolling);
  29506. });
  29507. this.hotMenu.init();
  29508. this.hotMenu.listen();
  29509. this.blockMainTableCallbacks();
  29510. this.runLocalHooks('afterOpen');
  29511. }
  29512. /**
  29513. * Close menu.
  29514. *
  29515. * @param {Boolean} [closeParent=false] if `true` try to close parent menu if exists.
  29516. */
  29517. }, {
  29518. key: 'close',
  29519. value: function close() {
  29520. var closeParent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  29521. if (!this.isOpened()) {
  29522. return;
  29523. }
  29524. if (closeParent && this.parentMenu) {
  29525. this.parentMenu.close();
  29526. } else {
  29527. this.closeAllSubMenus();
  29528. this.container.style.display = 'none';
  29529. this.releaseMainTableCallbacks();
  29530. this.hotMenu.destroy();
  29531. this.hotMenu = null;
  29532. this.hot.getSettings().outsideClickDeselects = this.origOutsideClickDeselects;
  29533. this.runLocalHooks('afterClose');
  29534. if (this.parentMenu) {
  29535. this.parentMenu.hotMenu.listen();
  29536. }
  29537. }
  29538. }
  29539. /**
  29540. * Open sub menu at the provided row index.
  29541. *
  29542. * @param {Number} row Row index.
  29543. * @returns {Menu|Boolean} Returns created menu or `false` if no one menu was created.
  29544. */
  29545. }, {
  29546. key: 'openSubMenu',
  29547. value: function openSubMenu(row) {
  29548. if (!this.hotMenu) {
  29549. return false;
  29550. }
  29551. var cell = this.hotMenu.getCell(row, 0);
  29552. this.closeAllSubMenus();
  29553. if (!cell || !(0, _utils.hasSubMenu)(cell)) {
  29554. return false;
  29555. }
  29556. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  29557. var subMenu = new Menu(this.hot, {
  29558. parent: this,
  29559. name: dataItem.name,
  29560. className: this.options.className,
  29561. keepInViewport: true
  29562. });
  29563. subMenu.setMenuItems(dataItem.submenu.items);
  29564. subMenu.open();
  29565. subMenu.setPosition(cell.getBoundingClientRect());
  29566. this.hotSubMenus[dataItem.key] = subMenu;
  29567. return subMenu;
  29568. }
  29569. /**
  29570. * Close sub menu at row index.
  29571. *
  29572. * @param {Number} row Row index.
  29573. */
  29574. }, {
  29575. key: 'closeSubMenu',
  29576. value: function closeSubMenu(row) {
  29577. var dataItem = this.hotMenu.getSourceDataAtRow(row);
  29578. var menus = this.hotSubMenus[dataItem.key];
  29579. if (menus) {
  29580. menus.destroy();
  29581. delete this.hotSubMenus[dataItem.key];
  29582. }
  29583. }
  29584. /**
  29585. * Close all opened sub menus.
  29586. */
  29587. }, {
  29588. key: 'closeAllSubMenus',
  29589. value: function closeAllSubMenus() {
  29590. var _this3 = this;
  29591. (0, _array.arrayEach)(this.hotMenu.getData(), function (value, row) {
  29592. return _this3.closeSubMenu(row);
  29593. });
  29594. }
  29595. /**
  29596. * Checks if all created and opened sub menus are closed.
  29597. *
  29598. * @returns {Boolean}
  29599. */
  29600. }, {
  29601. key: 'isAllSubMenusClosed',
  29602. value: function isAllSubMenusClosed() {
  29603. return Object.keys(this.hotSubMenus).length === 0;
  29604. }
  29605. /**
  29606. * Destroy instance.
  29607. */
  29608. }, {
  29609. key: 'destroy',
  29610. value: function destroy() {
  29611. this.clearLocalHooks();
  29612. this.close();
  29613. this.parentMenu = null;
  29614. this.eventManager.destroy();
  29615. }
  29616. /**
  29617. * Checks if menu was opened.
  29618. *
  29619. * @returns {Boolean} Returns `true` if menu was opened.
  29620. */
  29621. }, {
  29622. key: 'isOpened',
  29623. value: function isOpened() {
  29624. return this.hotMenu !== null;
  29625. }
  29626. /**
  29627. * Execute menu command.
  29628. *
  29629. * @param {Event} [event]
  29630. */
  29631. }, {
  29632. key: 'executeCommand',
  29633. value: function executeCommand(event) {
  29634. if (!this.isOpened() || !this.hotMenu.getSelected()) {
  29635. return;
  29636. }
  29637. var selectedItem = this.hotMenu.getSourceDataAtRow(this.hotMenu.getSelected()[0]);
  29638. this.runLocalHooks('select', selectedItem, event);
  29639. if (selectedItem.isCommand === false || selectedItem.name === _predefinedItems.SEPARATOR) {
  29640. return;
  29641. }
  29642. var selRange = this.hot.getSelectedRange();
  29643. var normalizedSelection = selRange ? (0, _utils.normalizeSelection)(selRange) : {};
  29644. var autoClose = true;
  29645. // Don't close context menu if item is disabled or it has submenu
  29646. if (selectedItem.disabled === true || typeof selectedItem.disabled === 'function' && selectedItem.disabled.call(this.hot) === true || selectedItem.submenu) {
  29647. autoClose = false;
  29648. }
  29649. this.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  29650. if (this.isSubMenu()) {
  29651. this.parentMenu.runLocalHooks('executeCommand', selectedItem.key, normalizedSelection, event);
  29652. }
  29653. if (autoClose) {
  29654. this.close(true);
  29655. }
  29656. }
  29657. /**
  29658. * Set menu position based on dom event or based on literal object.
  29659. *
  29660. * @param {Event|Object} coords Event or literal Object with coordinates.
  29661. */
  29662. }, {
  29663. key: 'setPosition',
  29664. value: function setPosition(coords) {
  29665. var cursor = new _cursor2.default(coords);
  29666. if (this.options.keepInViewport) {
  29667. if (cursor.fitsBelow(this.container)) {
  29668. this.setPositionBelowCursor(cursor);
  29669. } else if (cursor.fitsAbove(this.container)) {
  29670. this.setPositionAboveCursor(cursor);
  29671. } else {
  29672. this.setPositionBelowCursor(cursor);
  29673. }
  29674. if (cursor.fitsOnRight(this.container)) {
  29675. this.setPositionOnRightOfCursor(cursor);
  29676. } else {
  29677. this.setPositionOnLeftOfCursor(cursor);
  29678. }
  29679. } else {
  29680. this.setPositionBelowCursor(cursor);
  29681. this.setPositionOnRightOfCursor(cursor);
  29682. }
  29683. }
  29684. /**
  29685. * Set menu position above cursor object.
  29686. *
  29687. * @param {Cursor} cursor `Cursor` object.
  29688. */
  29689. }, {
  29690. key: 'setPositionAboveCursor',
  29691. value: function setPositionAboveCursor(cursor) {
  29692. var top = this.offset.above + cursor.top - this.container.offsetHeight;
  29693. if (this.isSubMenu()) {
  29694. top = cursor.top + cursor.cellHeight - this.container.offsetHeight + 3;
  29695. }
  29696. this.container.style.top = top + 'px';
  29697. }
  29698. /**
  29699. * Set menu position below cursor object.
  29700. *
  29701. * @param {Cursor} cursor `Cursor` object.
  29702. */
  29703. }, {
  29704. key: 'setPositionBelowCursor',
  29705. value: function setPositionBelowCursor(cursor) {
  29706. var top = this.offset.below + cursor.top;
  29707. if (this.isSubMenu()) {
  29708. top = cursor.top - 1;
  29709. }
  29710. this.container.style.top = top + 'px';
  29711. }
  29712. /**
  29713. * Set menu position on the right of cursor object.
  29714. *
  29715. * @param {Cursor} cursor `Cursor` object.
  29716. */
  29717. }, {
  29718. key: 'setPositionOnRightOfCursor',
  29719. value: function setPositionOnRightOfCursor(cursor) {
  29720. var left = void 0;
  29721. if (this.isSubMenu()) {
  29722. left = 1 + cursor.left + cursor.cellWidth;
  29723. } else {
  29724. left = this.offset.right + 1 + cursor.left;
  29725. }
  29726. this.container.style.left = left + 'px';
  29727. }
  29728. /**
  29729. * Set menu position on the left of cursor object.
  29730. *
  29731. * @param {Cursor} cursor `Cursor` object.
  29732. */
  29733. }, {
  29734. key: 'setPositionOnLeftOfCursor',
  29735. value: function setPositionOnLeftOfCursor(cursor) {
  29736. var left = this.offset.left + cursor.left - this.container.offsetWidth + (0, _element.getScrollbarWidth)() + 4;
  29737. this.container.style.left = left + 'px';
  29738. }
  29739. /**
  29740. * Select first cell in opened menu.
  29741. */
  29742. }, {
  29743. key: 'selectFirstCell',
  29744. value: function selectFirstCell() {
  29745. var cell = this.hotMenu.getCell(0, 0);
  29746. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  29747. this.selectNextCell(0, 0);
  29748. } else {
  29749. this.hotMenu.selectCell(0, 0);
  29750. }
  29751. }
  29752. /**
  29753. * Select last cell in opened menu.
  29754. */
  29755. }, {
  29756. key: 'selectLastCell',
  29757. value: function selectLastCell() {
  29758. var lastRow = this.hotMenu.countRows() - 1;
  29759. var cell = this.hotMenu.getCell(lastRow, 0);
  29760. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  29761. this.selectPrevCell(lastRow, 0);
  29762. } else {
  29763. this.hotMenu.selectCell(lastRow, 0);
  29764. }
  29765. }
  29766. /**
  29767. * Select next cell in opened menu.
  29768. *
  29769. * @param {Number} row Row index.
  29770. * @param {Number} col Column index.
  29771. */
  29772. }, {
  29773. key: 'selectNextCell',
  29774. value: function selectNextCell(row, col) {
  29775. var nextRow = row + 1;
  29776. var cell = nextRow < this.hotMenu.countRows() ? this.hotMenu.getCell(nextRow, col) : null;
  29777. if (!cell) {
  29778. return;
  29779. }
  29780. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  29781. this.selectNextCell(nextRow, col);
  29782. } else {
  29783. this.hotMenu.selectCell(nextRow, col);
  29784. }
  29785. }
  29786. /**
  29787. * Select previous cell in opened menu.
  29788. *
  29789. * @param {Number} row Row index.
  29790. * @param {Number} col Column index.
  29791. */
  29792. }, {
  29793. key: 'selectPrevCell',
  29794. value: function selectPrevCell(row, col) {
  29795. var prevRow = row - 1;
  29796. var cell = prevRow >= 0 ? this.hotMenu.getCell(prevRow, col) : null;
  29797. if (!cell) {
  29798. return;
  29799. }
  29800. if ((0, _utils.isSeparator)(cell) || (0, _utils.isDisabled)(cell) || (0, _utils.isSelectionDisabled)(cell)) {
  29801. this.selectPrevCell(prevRow, col);
  29802. } else {
  29803. this.hotMenu.selectCell(prevRow, col);
  29804. }
  29805. }
  29806. /**
  29807. * Menu item renderer.
  29808. *
  29809. * @private
  29810. */
  29811. }, {
  29812. key: 'menuItemRenderer',
  29813. value: function menuItemRenderer(hot, TD, row, col, prop, value) {
  29814. var _this4 = this;
  29815. var item = hot.getSourceDataAtRow(row);
  29816. var wrapper = document.createElement('div');
  29817. var isSubMenu = function isSubMenu(item) {
  29818. return (0, _object.hasOwnProperty)(item, 'submenu');
  29819. };
  29820. var itemIsSeparator = function itemIsSeparator(item) {
  29821. return new RegExp(_predefinedItems.SEPARATOR, 'i').test(item.name);
  29822. };
  29823. var itemIsDisabled = function itemIsDisabled(item) {
  29824. return item.disabled === true || typeof item.disabled == 'function' && item.disabled.call(_this4.hot) === true;
  29825. };
  29826. var itemIsSelectionDisabled = function itemIsSelectionDisabled(item) {
  29827. return item.disableSelection;
  29828. };
  29829. if (typeof value === 'function') {
  29830. value = value.call(this.hot);
  29831. }
  29832. (0, _element.empty)(TD);
  29833. (0, _element.addClass)(wrapper, 'htItemWrapper');
  29834. TD.appendChild(wrapper);
  29835. if (itemIsSeparator(item)) {
  29836. (0, _element.addClass)(TD, 'htSeparator');
  29837. } else if (typeof item.renderer === 'function') {
  29838. (0, _element.addClass)(TD, 'htCustomMenuRenderer');
  29839. TD.appendChild(item.renderer(hot, wrapper, row, col, prop, value));
  29840. } else {
  29841. (0, _element.fastInnerHTML)(wrapper, value);
  29842. }
  29843. if (itemIsDisabled(item)) {
  29844. (0, _element.addClass)(TD, 'htDisabled');
  29845. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29846. return hot.deselectCell();
  29847. });
  29848. } else if (itemIsSelectionDisabled(item)) {
  29849. (0, _element.addClass)(TD, 'htSelectionDisabled');
  29850. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29851. return hot.deselectCell();
  29852. });
  29853. } else if (isSubMenu(item)) {
  29854. (0, _element.addClass)(TD, 'htSubmenu');
  29855. if (itemIsSelectionDisabled(item)) {
  29856. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29857. return hot.deselectCell();
  29858. });
  29859. } else {
  29860. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29861. return hot.selectCell(row, col, void 0, void 0, false, false);
  29862. });
  29863. }
  29864. } else {
  29865. (0, _element.removeClass)(TD, 'htSubmenu');
  29866. (0, _element.removeClass)(TD, 'htDisabled');
  29867. if (itemIsSelectionDisabled(item)) {
  29868. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29869. return hot.deselectCell();
  29870. });
  29871. } else {
  29872. this.eventManager.addEventListener(TD, 'mouseenter', function () {
  29873. return hot.selectCell(row, col, void 0, void 0, false, false);
  29874. });
  29875. }
  29876. }
  29877. }
  29878. /**
  29879. * Create container/wrapper for handsontable.
  29880. *
  29881. * @private
  29882. * @param {String} [name] Class name.
  29883. * @returns {HTMLElement}
  29884. */
  29885. }, {
  29886. key: 'createContainer',
  29887. value: function createContainer() {
  29888. var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  29889. if (name) {
  29890. name = name.replace(/[^A-z0-9]/g, '_');
  29891. name = this.options.className + 'Sub_' + name;
  29892. }
  29893. var container = void 0;
  29894. if (name) {
  29895. container = document.querySelector('.' + this.options.className + '.' + name);
  29896. } else {
  29897. container = document.querySelector('.' + this.options.className);
  29898. }
  29899. if (!container) {
  29900. container = document.createElement('div');
  29901. (0, _element.addClass)(container, 'htMenu ' + this.options.className);
  29902. if (name) {
  29903. (0, _element.addClass)(container, name);
  29904. }
  29905. document.getElementsByTagName('body')[0].appendChild(container);
  29906. }
  29907. return container;
  29908. }
  29909. /**
  29910. * @private
  29911. */
  29912. }, {
  29913. key: 'blockMainTableCallbacks',
  29914. value: function blockMainTableCallbacks() {
  29915. this._afterScrollCallback = function () {};
  29916. this.hot.addHook('afterScrollVertically', this._afterScrollCallback);
  29917. this.hot.addHook('afterScrollHorizontally', this._afterScrollCallback);
  29918. }
  29919. /**
  29920. * @private
  29921. */
  29922. }, {
  29923. key: 'releaseMainTableCallbacks',
  29924. value: function releaseMainTableCallbacks() {
  29925. if (this._afterScrollCallback) {
  29926. this.hot.removeHook('afterScrollVertically', this._afterScrollCallback);
  29927. this.hot.removeHook('afterScrollHorizontally', this._afterScrollCallback);
  29928. this._afterScrollCallback = null;
  29929. }
  29930. }
  29931. /**
  29932. * On before key down listener.
  29933. *
  29934. * @private
  29935. * @param {Event} event
  29936. */
  29937. }, {
  29938. key: 'onBeforeKeyDown',
  29939. value: function onBeforeKeyDown(event) {
  29940. var selection = this.hotMenu.getSelected();
  29941. var stopEvent = false;
  29942. this.keyEvent = true;
  29943. switch (event.keyCode) {
  29944. case _unicode.KEY_CODES.ESCAPE:
  29945. this.close();
  29946. stopEvent = true;
  29947. break;
  29948. case _unicode.KEY_CODES.ENTER:
  29949. if (selection) {
  29950. if (this.hotMenu.getSourceDataAtRow(selection[0]).submenu) {
  29951. stopEvent = true;
  29952. } else {
  29953. this.executeCommand(event);
  29954. this.close(true);
  29955. }
  29956. }
  29957. break;
  29958. case _unicode.KEY_CODES.ARROW_DOWN:
  29959. if (selection) {
  29960. this.selectNextCell(selection[0], selection[1]);
  29961. } else {
  29962. this.selectFirstCell();
  29963. }
  29964. stopEvent = true;
  29965. break;
  29966. case _unicode.KEY_CODES.ARROW_UP:
  29967. if (selection) {
  29968. this.selectPrevCell(selection[0], selection[1]);
  29969. } else {
  29970. this.selectLastCell();
  29971. }
  29972. stopEvent = true;
  29973. break;
  29974. case _unicode.KEY_CODES.ARROW_RIGHT:
  29975. if (selection) {
  29976. var menu = this.openSubMenu(selection[0]);
  29977. if (menu) {
  29978. menu.selectFirstCell();
  29979. }
  29980. }
  29981. stopEvent = true;
  29982. break;
  29983. case _unicode.KEY_CODES.ARROW_LEFT:
  29984. if (selection && this.isSubMenu()) {
  29985. this.close();
  29986. if (this.parentMenu) {
  29987. this.parentMenu.hotMenu.listen();
  29988. }
  29989. stopEvent = true;
  29990. }
  29991. break;
  29992. default:
  29993. break;
  29994. }
  29995. if (stopEvent) {
  29996. event.preventDefault();
  29997. (0, _event.stopImmediatePropagation)(event);
  29998. }
  29999. this.keyEvent = false;
  30000. }
  30001. /**
  30002. * On after init listener.
  30003. *
  30004. * @private
  30005. */
  30006. }, {
  30007. key: 'onAfterInit',
  30008. value: function onAfterInit() {
  30009. var data = this.hotMenu.getSettings().data;
  30010. var hiderStyle = this.hotMenu.view.wt.wtTable.hider.style;
  30011. var holderStyle = this.hotMenu.view.wt.wtTable.holder.style;
  30012. var currentHiderWidth = parseInt(hiderStyle.width, 10);
  30013. var realHeight = (0, _array.arrayReduce)(data, function (accumulator, value) {
  30014. return accumulator + (value.name === _predefinedItems.SEPARATOR ? 1 : 26);
  30015. }, 0);
  30016. holderStyle.width = currentHiderWidth + 22 + 'px';
  30017. holderStyle.height = realHeight + 4 + 'px';
  30018. hiderStyle.height = holderStyle.height;
  30019. }
  30020. /**
  30021. * On after selection listener.
  30022. *
  30023. * @param {Number} r Selection start row index.
  30024. * @param {Number} c Selection start column index.
  30025. * @param {Number} r2 Selection end row index.
  30026. * @param {Number} c2 Selection end column index.
  30027. * @param {Object} preventScrolling Object with `value` property where its value change will be observed.
  30028. */
  30029. }, {
  30030. key: 'onAfterSelection',
  30031. value: function onAfterSelection(r, c, r2, c2, preventScrolling) {
  30032. if (this.keyEvent === false) {
  30033. preventScrolling.value = true;
  30034. }
  30035. }
  30036. /**
  30037. * Document mouse down listener.
  30038. *
  30039. * @private
  30040. * @param {Event} event
  30041. */
  30042. }, {
  30043. key: 'onDocumentMouseDown',
  30044. value: function onDocumentMouseDown(event) {
  30045. if (!this.isOpened()) {
  30046. return;
  30047. }
  30048. if (this.container && (0, _element.isChildOf)(event.target, this.container)) {
  30049. this.executeCommand(event);
  30050. }
  30051. // Close menu when clicked element is not belongs to menu itself
  30052. if (this.options.standalone && this.hotMenu && !(0, _element.isChildOf)(event.target, this.hotMenu.rootElement)) {
  30053. this.close(true);
  30054. // Automatically close menu when clicked element is not belongs to menu or submenu (not necessarily to itself)
  30055. } else if ((this.isAllSubMenusClosed() || this.isSubMenu()) && !(0, _element.isChildOf)(event.target, '.htMenu') && (0, _element.isChildOf)(event.target, document)) {
  30056. this.close(true);
  30057. }
  30058. }
  30059. }]);
  30060. return Menu;
  30061. }();
  30062. (0, _object.mixin)(Menu, _localHooks2.default);
  30063. exports.default = Menu;
  30064. /***/ }),
  30065. /* 223 */
  30066. /***/ (function(module, exports, __webpack_require__) {
  30067. "use strict";
  30068. exports.__esModule = true;
  30069. exports.KEY = undefined;
  30070. exports.default = alignmentItem;
  30071. var _utils = __webpack_require__(17);
  30072. var _separator = __webpack_require__(71);
  30073. var KEY = exports.KEY = 'alignment';
  30074. function alignmentItem() {
  30075. return {
  30076. key: KEY,
  30077. name: 'Alignment',
  30078. disabled: function disabled() {
  30079. return !(this.getSelectedRange() && !this.selection.selectedHeader.corner);
  30080. },
  30081. submenu: {
  30082. items: [{
  30083. key: KEY + ':left',
  30084. name: function name() {
  30085. var _this = this;
  30086. var label = 'Left';
  30087. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30088. var className = _this.getCellMeta(row, col).className;
  30089. if (className && className.indexOf('htLeft') !== -1) {
  30090. return true;
  30091. }
  30092. });
  30093. if (hasClass) {
  30094. label = (0, _utils.markLabelAsSelected)(label);
  30095. }
  30096. return label;
  30097. },
  30098. callback: function callback() {
  30099. var _this2 = this;
  30100. var range = this.getSelectedRange();
  30101. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30102. return _this2.getCellMeta(row, col).className;
  30103. });
  30104. var type = 'horizontal';
  30105. var alignment = 'htLeft';
  30106. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30107. (0, _utils.align)(range, type, alignment, function (row, col) {
  30108. return _this2.getCellMeta(row, col);
  30109. }, function (row, col, key, value) {
  30110. return _this2.setCellMeta(row, col, key, value);
  30111. });
  30112. this.render();
  30113. },
  30114. disabled: false
  30115. }, {
  30116. key: KEY + ':center',
  30117. name: function name() {
  30118. var _this3 = this;
  30119. var label = 'Center';
  30120. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30121. var className = _this3.getCellMeta(row, col).className;
  30122. if (className && className.indexOf('htCenter') !== -1) {
  30123. return true;
  30124. }
  30125. });
  30126. if (hasClass) {
  30127. label = (0, _utils.markLabelAsSelected)(label);
  30128. }
  30129. return label;
  30130. },
  30131. callback: function callback() {
  30132. var _this4 = this;
  30133. var range = this.getSelectedRange();
  30134. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30135. return _this4.getCellMeta(row, col).className;
  30136. });
  30137. var type = 'horizontal';
  30138. var alignment = 'htCenter';
  30139. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30140. (0, _utils.align)(range, type, alignment, function (row, col) {
  30141. return _this4.getCellMeta(row, col);
  30142. }, function (row, col, key, value) {
  30143. return _this4.setCellMeta(row, col, key, value);
  30144. });
  30145. this.render();
  30146. },
  30147. disabled: false
  30148. }, {
  30149. key: KEY + ':right',
  30150. name: function name() {
  30151. var _this5 = this;
  30152. var label = 'Right';
  30153. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30154. var className = _this5.getCellMeta(row, col).className;
  30155. if (className && className.indexOf('htRight') !== -1) {
  30156. return true;
  30157. }
  30158. });
  30159. if (hasClass) {
  30160. label = (0, _utils.markLabelAsSelected)(label);
  30161. }
  30162. return label;
  30163. },
  30164. callback: function callback() {
  30165. var _this6 = this;
  30166. var range = this.getSelectedRange();
  30167. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30168. return _this6.getCellMeta(row, col).className;
  30169. });
  30170. var type = 'horizontal';
  30171. var alignment = 'htRight';
  30172. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30173. (0, _utils.align)(range, type, alignment, function (row, col) {
  30174. return _this6.getCellMeta(row, col);
  30175. }, function (row, col, key, value) {
  30176. return _this6.setCellMeta(row, col, key, value);
  30177. });
  30178. this.render();
  30179. },
  30180. disabled: false
  30181. }, {
  30182. key: KEY + ':justify',
  30183. name: function name() {
  30184. var _this7 = this;
  30185. var label = 'Justify';
  30186. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30187. var className = _this7.getCellMeta(row, col).className;
  30188. if (className && className.indexOf('htJustify') !== -1) {
  30189. return true;
  30190. }
  30191. });
  30192. if (hasClass) {
  30193. label = (0, _utils.markLabelAsSelected)(label);
  30194. }
  30195. return label;
  30196. },
  30197. callback: function callback() {
  30198. var _this8 = this;
  30199. var range = this.getSelectedRange();
  30200. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30201. return _this8.getCellMeta(row, col).className;
  30202. });
  30203. var type = 'horizontal';
  30204. var alignment = 'htJustify';
  30205. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30206. (0, _utils.align)(range, type, alignment, function (row, col) {
  30207. return _this8.getCellMeta(row, col);
  30208. }, function (row, col, key, value) {
  30209. return _this8.setCellMeta(row, col, key, value);
  30210. });
  30211. this.render();
  30212. },
  30213. disabled: false
  30214. }, {
  30215. name: _separator.KEY
  30216. }, {
  30217. key: KEY + ':top',
  30218. name: function name() {
  30219. var _this9 = this;
  30220. var label = 'Top';
  30221. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30222. var className = _this9.getCellMeta(row, col).className;
  30223. if (className && className.indexOf('htTop') !== -1) {
  30224. return true;
  30225. }
  30226. });
  30227. if (hasClass) {
  30228. label = (0, _utils.markLabelAsSelected)(label);
  30229. }
  30230. return label;
  30231. },
  30232. callback: function callback() {
  30233. var _this10 = this;
  30234. var range = this.getSelectedRange();
  30235. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30236. return _this10.getCellMeta(row, col).className;
  30237. });
  30238. var type = 'vertical';
  30239. var alignment = 'htTop';
  30240. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30241. (0, _utils.align)(range, type, alignment, function (row, col) {
  30242. return _this10.getCellMeta(row, col);
  30243. }, function (row, col, key, value) {
  30244. return _this10.setCellMeta(row, col, key, value);
  30245. });
  30246. this.render();
  30247. },
  30248. disabled: false
  30249. }, {
  30250. key: KEY + ':middle',
  30251. name: function name() {
  30252. var _this11 = this;
  30253. var label = 'Middle';
  30254. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30255. var className = _this11.getCellMeta(row, col).className;
  30256. if (className && className.indexOf('htMiddle') !== -1) {
  30257. return true;
  30258. }
  30259. });
  30260. if (hasClass) {
  30261. label = (0, _utils.markLabelAsSelected)(label);
  30262. }
  30263. return label;
  30264. },
  30265. callback: function callback() {
  30266. var _this12 = this;
  30267. var range = this.getSelectedRange();
  30268. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30269. return _this12.getCellMeta(row, col).className;
  30270. });
  30271. var type = 'vertical';
  30272. var alignment = 'htMiddle';
  30273. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30274. (0, _utils.align)(range, type, alignment, function (row, col) {
  30275. return _this12.getCellMeta(row, col);
  30276. }, function (row, col, key, value) {
  30277. return _this12.setCellMeta(row, col, key, value);
  30278. });
  30279. this.render();
  30280. },
  30281. disabled: false
  30282. }, {
  30283. key: KEY + ':bottom',
  30284. name: function name() {
  30285. var _this13 = this;
  30286. var label = 'Bottom';
  30287. var hasClass = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30288. var className = _this13.getCellMeta(row, col).className;
  30289. if (className && className.indexOf('htBottom') !== -1) {
  30290. return true;
  30291. }
  30292. });
  30293. if (hasClass) {
  30294. label = (0, _utils.markLabelAsSelected)(label);
  30295. }
  30296. return label;
  30297. },
  30298. callback: function callback() {
  30299. var _this14 = this;
  30300. var range = this.getSelectedRange();
  30301. var stateBefore = (0, _utils.getAlignmentClasses)(range, function (row, col) {
  30302. return _this14.getCellMeta(row, col).className;
  30303. });
  30304. var type = 'vertical';
  30305. var alignment = 'htBottom';
  30306. this.runHooks('beforeCellAlignment', stateBefore, range, type, alignment);
  30307. (0, _utils.align)(range, type, alignment, function (row, col) {
  30308. return _this14.getCellMeta(row, col);
  30309. }, function (row, col, key, value) {
  30310. return _this14.setCellMeta(row, col, key, value);
  30311. });
  30312. this.render();
  30313. },
  30314. disabled: false
  30315. }]
  30316. }
  30317. };
  30318. }
  30319. /***/ }),
  30320. /* 224 */
  30321. /***/ (function(module, exports, __webpack_require__) {
  30322. "use strict";
  30323. exports.__esModule = true;
  30324. exports.KEY = undefined;
  30325. exports.default = clearColumnItem;
  30326. var _utils = __webpack_require__(17);
  30327. var KEY = exports.KEY = 'clear_column';
  30328. function clearColumnItem() {
  30329. return {
  30330. key: KEY,
  30331. name: 'Clear column',
  30332. callback: function callback(key, selection) {
  30333. var column = selection.start.col;
  30334. if (this.countRows()) {
  30335. this.populateFromArray(0, column, [[null]], Math.max(selection.start.row, selection.end.row), column, 'ContextMenu.clearColumn');
  30336. }
  30337. },
  30338. disabled: function disabled() {
  30339. var selected = (0, _utils.getValidSelection)(this);
  30340. if (!selected) {
  30341. return true;
  30342. }
  30343. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  30344. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  30345. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || rowSelected;
  30346. }
  30347. };
  30348. }
  30349. /***/ }),
  30350. /* 225 */
  30351. /***/ (function(module, exports, __webpack_require__) {
  30352. "use strict";
  30353. exports.__esModule = true;
  30354. exports.KEY = undefined;
  30355. exports.default = columnLeftItem;
  30356. var _utils = __webpack_require__(17);
  30357. var KEY = exports.KEY = 'col_left';
  30358. function columnLeftItem() {
  30359. return {
  30360. key: KEY,
  30361. name: 'Insert column on the left',
  30362. callback: function callback(key, selection) {
  30363. this.alter('insert_col', selection.start.col, 1, 'ContextMenu.columnLeft');
  30364. },
  30365. disabled: function disabled() {
  30366. var selected = (0, _utils.getValidSelection)(this);
  30367. if (!selected) {
  30368. return true;
  30369. }
  30370. if (!this.isColumnModificationAllowed()) {
  30371. return true;
  30372. }
  30373. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  30374. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  30375. var onlyOneColumn = this.countCols() === 1;
  30376. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  30377. },
  30378. hidden: function hidden() {
  30379. return !this.getSettings().allowInsertColumn;
  30380. }
  30381. };
  30382. }
  30383. /***/ }),
  30384. /* 226 */
  30385. /***/ (function(module, exports, __webpack_require__) {
  30386. "use strict";
  30387. exports.__esModule = true;
  30388. exports.KEY = undefined;
  30389. exports.default = columnRightItem;
  30390. var _utils = __webpack_require__(17);
  30391. var KEY = exports.KEY = 'col_right';
  30392. function columnRightItem() {
  30393. return {
  30394. key: KEY,
  30395. name: 'Insert column on the right',
  30396. callback: function callback(key, selection) {
  30397. this.alter('insert_col', selection.end.col + 1, 1, 'ContextMenu.columnRight');
  30398. },
  30399. disabled: function disabled() {
  30400. var selected = (0, _utils.getValidSelection)(this);
  30401. if (!selected) {
  30402. return true;
  30403. }
  30404. if (!this.isColumnModificationAllowed()) {
  30405. return true;
  30406. }
  30407. var entireRowSelection = [selected[0], 0, selected[0], this.countCols() - 1];
  30408. var rowSelected = entireRowSelection.join(',') == selected.join(',');
  30409. var onlyOneColumn = this.countCols() === 1;
  30410. return selected[1] < 0 || this.countCols() >= this.getSettings().maxCols || !onlyOneColumn && rowSelected;
  30411. },
  30412. hidden: function hidden() {
  30413. return !this.getSettings().allowInsertColumn;
  30414. }
  30415. };
  30416. }
  30417. /***/ }),
  30418. /* 227 */
  30419. /***/ (function(module, exports, __webpack_require__) {
  30420. "use strict";
  30421. exports.__esModule = true;
  30422. exports.KEY = undefined;
  30423. exports.default = readOnlyItem;
  30424. var _utils = __webpack_require__(17);
  30425. var KEY = exports.KEY = 'make_read_only';
  30426. function readOnlyItem() {
  30427. return {
  30428. key: KEY,
  30429. name: function name() {
  30430. var _this = this;
  30431. var label = 'Read only';
  30432. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(this.getSelectedRange(), function (row, col) {
  30433. return _this.getCellMeta(row, col).readOnly;
  30434. });
  30435. if (atLeastOneReadOnly) {
  30436. label = (0, _utils.markLabelAsSelected)(label);
  30437. }
  30438. return label;
  30439. },
  30440. callback: function callback() {
  30441. var _this2 = this;
  30442. var range = this.getSelectedRange();
  30443. var atLeastOneReadOnly = (0, _utils.checkSelectionConsistency)(range, function (row, col) {
  30444. return _this2.getCellMeta(row, col).readOnly;
  30445. });
  30446. range.forAll(function (row, col) {
  30447. _this2.setCellMeta(row, col, 'readOnly', !atLeastOneReadOnly);
  30448. });
  30449. this.render();
  30450. },
  30451. disabled: function disabled() {
  30452. return !(this.getSelectedRange() && !this.selection.selectedHeader.corner);
  30453. }
  30454. };
  30455. }
  30456. /***/ }),
  30457. /* 228 */
  30458. /***/ (function(module, exports, __webpack_require__) {
  30459. "use strict";
  30460. exports.__esModule = true;
  30461. exports.default = redoItem;
  30462. var KEY = exports.KEY = 'redo';
  30463. function redoItem() {
  30464. return {
  30465. key: KEY,
  30466. name: 'Redo',
  30467. callback: function callback() {
  30468. this.redo();
  30469. },
  30470. disabled: function disabled() {
  30471. return this.undoRedo && !this.undoRedo.isRedoAvailable();
  30472. }
  30473. };
  30474. }
  30475. /***/ }),
  30476. /* 229 */
  30477. /***/ (function(module, exports, __webpack_require__) {
  30478. "use strict";
  30479. exports.__esModule = true;
  30480. exports.KEY = undefined;
  30481. exports.default = removeColumnItem;
  30482. var _utils = __webpack_require__(17);
  30483. var KEY = exports.KEY = 'remove_col';
  30484. function removeColumnItem() {
  30485. return {
  30486. key: KEY,
  30487. name: 'Remove column',
  30488. callback: function callback(key, selection) {
  30489. var amount = selection.end.col - selection.start.col + 1;
  30490. this.alter('remove_col', selection.start.col, amount, 'ContextMenu.removeColumn');
  30491. },
  30492. disabled: function disabled() {
  30493. var selected = (0, _utils.getValidSelection)(this);
  30494. var totalColumns = this.countCols();
  30495. return !selected || this.selection.selectedHeader.rows || this.selection.selectedHeader.corner || !this.isColumnModificationAllowed() || !totalColumns;
  30496. },
  30497. hidden: function hidden() {
  30498. return !this.getSettings().allowRemoveColumn;
  30499. }
  30500. };
  30501. }
  30502. /***/ }),
  30503. /* 230 */
  30504. /***/ (function(module, exports, __webpack_require__) {
  30505. "use strict";
  30506. exports.__esModule = true;
  30507. exports.KEY = undefined;
  30508. exports.default = removeRowItem;
  30509. var _utils = __webpack_require__(17);
  30510. var KEY = exports.KEY = 'remove_row';
  30511. function removeRowItem() {
  30512. return {
  30513. key: KEY,
  30514. name: 'Remove row',
  30515. callback: function callback(key, selection) {
  30516. var amount = selection.end.row - selection.start.row + 1;
  30517. this.alter('remove_row', selection.start.row, amount, 'ContextMenu.removeRow');
  30518. },
  30519. disabled: function disabled() {
  30520. var selected = (0, _utils.getValidSelection)(this);
  30521. var totalRows = this.countRows();
  30522. return !selected || this.selection.selectedHeader.cols || this.selection.selectedHeader.corner || !totalRows;
  30523. },
  30524. hidden: function hidden() {
  30525. return !this.getSettings().allowRemoveRow;
  30526. }
  30527. };
  30528. }
  30529. /***/ }),
  30530. /* 231 */
  30531. /***/ (function(module, exports, __webpack_require__) {
  30532. "use strict";
  30533. exports.__esModule = true;
  30534. exports.KEY = undefined;
  30535. exports.default = rowAboveItem;
  30536. var _utils = __webpack_require__(17);
  30537. var KEY = exports.KEY = 'row_above';
  30538. function rowAboveItem() {
  30539. return {
  30540. key: KEY,
  30541. name: 'Insert row above',
  30542. callback: function callback(key, selection) {
  30543. this.alter('insert_row', selection.start.row, 1, 'ContextMenu.rowAbove');
  30544. },
  30545. disabled: function disabled() {
  30546. var selected = (0, _utils.getValidSelection)(this);
  30547. return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows;
  30548. },
  30549. hidden: function hidden() {
  30550. return !this.getSettings().allowInsertRow;
  30551. }
  30552. };
  30553. }
  30554. /***/ }),
  30555. /* 232 */
  30556. /***/ (function(module, exports, __webpack_require__) {
  30557. "use strict";
  30558. exports.__esModule = true;
  30559. exports.KEY = undefined;
  30560. exports.default = rowBelowItem;
  30561. var _utils = __webpack_require__(17);
  30562. var KEY = exports.KEY = 'row_below';
  30563. function rowBelowItem() {
  30564. return {
  30565. key: KEY,
  30566. name: 'Insert row below',
  30567. callback: function callback(key, selection) {
  30568. this.alter('insert_row', selection.end.row + 1, 1, 'ContextMenu.rowBelow');
  30569. },
  30570. disabled: function disabled() {
  30571. var selected = (0, _utils.getValidSelection)(this);
  30572. return !selected || this.selection.selectedHeader.cols || this.countRows() >= this.getSettings().maxRows;
  30573. },
  30574. hidden: function hidden() {
  30575. return !this.getSettings().allowInsertRow;
  30576. }
  30577. };
  30578. }
  30579. /***/ }),
  30580. /* 233 */
  30581. /***/ (function(module, exports, __webpack_require__) {
  30582. "use strict";
  30583. exports.__esModule = true;
  30584. exports.default = undoItem;
  30585. var KEY = exports.KEY = 'undo';
  30586. function undoItem() {
  30587. return {
  30588. key: KEY,
  30589. name: 'Undo',
  30590. callback: function callback() {
  30591. this.undo();
  30592. },
  30593. disabled: function disabled() {
  30594. return this.undoRedo && !this.undoRedo.isUndoAvailable();
  30595. }
  30596. };
  30597. }
  30598. /***/ }),
  30599. /* 234 */
  30600. /***/ (function(module, exports, __webpack_require__) {
  30601. "use strict";
  30602. exports.__esModule = true;
  30603. exports.default = copyItem;
  30604. function copyItem(copyPastePlugin) {
  30605. return {
  30606. key: 'copy',
  30607. name: 'Copy',
  30608. callback: function callback() {
  30609. copyPastePlugin.setCopyableText();
  30610. copyPastePlugin.copy(true);
  30611. },
  30612. disabled: function disabled() {
  30613. return !copyPastePlugin.hot.getSelected();
  30614. },
  30615. hidden: false
  30616. };
  30617. }
  30618. /***/ }),
  30619. /* 235 */
  30620. /***/ (function(module, exports, __webpack_require__) {
  30621. "use strict";
  30622. exports.__esModule = true;
  30623. exports.default = cutItem;
  30624. function cutItem(copyPastePlugin) {
  30625. return {
  30626. key: 'cut',
  30627. name: 'Cut',
  30628. callback: function callback() {
  30629. copyPastePlugin.setCopyableText();
  30630. copyPastePlugin.cut(true);
  30631. },
  30632. disabled: function disabled() {
  30633. return !copyPastePlugin.hot.getSelected();
  30634. },
  30635. hidden: false
  30636. };
  30637. }
  30638. /***/ }),
  30639. /* 236 */
  30640. /***/ (function(module, exports, __webpack_require__) {
  30641. "use strict";
  30642. exports.__esModule = true;
  30643. 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; };
  30644. 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; }; }();
  30645. 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); } };
  30646. var _base = __webpack_require__(12);
  30647. var _base2 = _interopRequireDefault(_base);
  30648. var _pluginHooks = __webpack_require__(8);
  30649. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  30650. var _SheetClip = __webpack_require__(133);
  30651. var _SheetClip2 = _interopRequireDefault(_SheetClip);
  30652. var _src = __webpack_require__(11);
  30653. var _unicode = __webpack_require__(16);
  30654. var _element = __webpack_require__(0);
  30655. var _array = __webpack_require__(2);
  30656. var _number = __webpack_require__(6);
  30657. var _event = __webpack_require__(7);
  30658. var _plugins = __webpack_require__(5);
  30659. var _textarea = __webpack_require__(237);
  30660. var _textarea2 = _interopRequireDefault(_textarea);
  30661. var _copy = __webpack_require__(234);
  30662. var _copy2 = _interopRequireDefault(_copy);
  30663. var _cut = __webpack_require__(235);
  30664. var _cut2 = _interopRequireDefault(_cut);
  30665. var _eventManager = __webpack_require__(4);
  30666. var _eventManager2 = _interopRequireDefault(_eventManager);
  30667. __webpack_require__(298);
  30668. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  30669. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  30670. 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; }
  30671. 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; }
  30672. _pluginHooks2.default.getSingleton().register('afterCopyLimit');
  30673. _pluginHooks2.default.getSingleton().register('modifyCopyableRange');
  30674. _pluginHooks2.default.getSingleton().register('beforeCut');
  30675. _pluginHooks2.default.getSingleton().register('afterCut');
  30676. _pluginHooks2.default.getSingleton().register('beforePaste');
  30677. _pluginHooks2.default.getSingleton().register('afterPaste');
  30678. _pluginHooks2.default.getSingleton().register('beforeCopy');
  30679. _pluginHooks2.default.getSingleton().register('afterCopy');
  30680. var ROWS_LIMIT = 1000;
  30681. var COLUMNS_LIMIT = 1000;
  30682. var privatePool = new WeakMap();
  30683. /**
  30684. * @description
  30685. * This plugin enables the copy/paste functionality in the Handsontable.
  30686. *
  30687. * @example
  30688. * ```js
  30689. * ...
  30690. * copyPaste: true,
  30691. * ...
  30692. * ```
  30693. * @class CopyPaste
  30694. * @plugin CopyPaste
  30695. */
  30696. var CopyPaste = function (_BasePlugin) {
  30697. _inherits(CopyPaste, _BasePlugin);
  30698. function CopyPaste(hotInstance) {
  30699. _classCallCheck(this, CopyPaste);
  30700. /**
  30701. * Event manager
  30702. *
  30703. * @type {EventManager}
  30704. */
  30705. var _this = _possibleConstructorReturn(this, (CopyPaste.__proto__ || Object.getPrototypeOf(CopyPaste)).call(this, hotInstance));
  30706. _this.eventManager = new _eventManager2.default(_this);
  30707. /**
  30708. * Maximum number of columns than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  30709. *
  30710. * @private
  30711. * @type {Number}
  30712. * @default 1000
  30713. */
  30714. _this.columnsLimit = COLUMNS_LIMIT;
  30715. /**
  30716. * Ranges of the cells coordinates, which should be used to copy/cut/paste actions.
  30717. *
  30718. * @private
  30719. * @type {Array}
  30720. */
  30721. _this.copyableRanges = [];
  30722. /**
  30723. * Defines paste (<kbd>CTRL</kbd> + <kbd>V</kbd>) behavior.
  30724. * * Default value `"overwrite"` will paste clipboard value over current selection.
  30725. * * When set to `"shift_down"`, clipboard data will be pasted in place of current selection, while all selected cells are moved down.
  30726. * * When set to `"shift_right"`, clipboard data will be pasted in place of current selection, while all selected cells are moved right.
  30727. *
  30728. * @private
  30729. * @type {String}
  30730. * @default 'overwrite'
  30731. */
  30732. _this.pasteMode = 'overwrite';
  30733. /**
  30734. * Maximum number of rows than can be copied to clipboard using <kbd>CTRL</kbd> + <kbd>C</kbd>.
  30735. *
  30736. * @private
  30737. * @type {Number}
  30738. * @default 1000
  30739. */
  30740. _this.rowsLimit = ROWS_LIMIT;
  30741. /**
  30742. * The `textarea` element which is necessary to process copying, cutting off and pasting.
  30743. *
  30744. * @private
  30745. * @type {HTMLElement}
  30746. * @default undefined
  30747. */
  30748. _this.textarea = void 0;
  30749. privatePool.set(_this, {
  30750. isTriggeredByPaste: false
  30751. });
  30752. return _this;
  30753. }
  30754. /**
  30755. * Check if plugin is enabled.
  30756. *
  30757. * @returns {Boolean}
  30758. */
  30759. _createClass(CopyPaste, [{
  30760. key: 'isEnabled',
  30761. value: function isEnabled() {
  30762. return !!this.hot.getSettings().copyPaste;
  30763. }
  30764. /**
  30765. * Enable the plugin.
  30766. */
  30767. }, {
  30768. key: 'enablePlugin',
  30769. value: function enablePlugin() {
  30770. var _this2 = this;
  30771. if (this.enabled) {
  30772. return;
  30773. }
  30774. var settings = this.hot.getSettings();
  30775. this.textarea = _textarea2.default.getSingleton();
  30776. if (_typeof(settings.copyPaste) === 'object') {
  30777. this.pasteMode = settings.copyPaste.pasteMode || this.pasteMode;
  30778. this.rowsLimit = settings.copyPaste.rowsLimit || this.rowsLimit;
  30779. this.columnsLimit = settings.copyPaste.columnsLimit || this.columnsLimit;
  30780. }
  30781. this.addHook('afterContextMenuDefaultOptions', function (options) {
  30782. return _this2.onAfterContextMenuDefaultOptions(options);
  30783. });
  30784. this.addHook('beforeKeyDown', function (event) {
  30785. return _this2.onBeforeKeyDown(event);
  30786. });
  30787. this.registerEvents();
  30788. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'enablePlugin', this).call(this);
  30789. }
  30790. /**
  30791. * Updates the plugin to use the latest options you have specified.
  30792. */
  30793. }, {
  30794. key: 'updatePlugin',
  30795. value: function updatePlugin() {
  30796. this.disablePlugin();
  30797. this.enablePlugin();
  30798. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'updatePlugin', this).call(this);
  30799. }
  30800. /**
  30801. * Disable plugin for this Handsontable instance.
  30802. */
  30803. }, {
  30804. key: 'disablePlugin',
  30805. value: function disablePlugin() {
  30806. if (this.textarea) {
  30807. this.textarea.destroy();
  30808. }
  30809. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'disablePlugin', this).call(this);
  30810. }
  30811. /**
  30812. * Prepares copyable text from the cells selection in the invisible textarea.
  30813. *
  30814. * @function setCopyable
  30815. * @memberof CopyPaste#
  30816. */
  30817. }, {
  30818. key: 'setCopyableText',
  30819. value: function setCopyableText() {
  30820. var selRange = this.hot.getSelectedRange();
  30821. if (!selRange) {
  30822. return;
  30823. }
  30824. var topLeft = selRange.getTopLeftCorner();
  30825. var bottomRight = selRange.getBottomRightCorner();
  30826. var startRow = topLeft.row;
  30827. var startCol = topLeft.col;
  30828. var endRow = bottomRight.row;
  30829. var endCol = bottomRight.col;
  30830. var finalEndRow = Math.min(endRow, startRow + this.rowsLimit - 1);
  30831. var finalEndCol = Math.min(endCol, startCol + this.columnsLimit - 1);
  30832. this.copyableRanges.length = 0;
  30833. this.copyableRanges.push({
  30834. startRow: startRow,
  30835. startCol: startCol,
  30836. endRow: finalEndRow,
  30837. endCol: finalEndCol
  30838. });
  30839. this.copyableRanges = this.hot.runHooks('modifyCopyableRange', this.copyableRanges);
  30840. var copyableData = this.getRangedCopyableData(this.copyableRanges);
  30841. this.textarea.setValue(copyableData);
  30842. if (endRow !== finalEndRow || endCol !== finalEndCol) {
  30843. this.hot.runHooks('afterCopyLimit', endRow - startRow + 1, endCol - startCol + 1, this.rowsLimit, this.columnsLimit);
  30844. }
  30845. }
  30846. /**
  30847. * Create copyable text releated to range objects.
  30848. *
  30849. * @since 0.19.0
  30850. * @param {Array} ranges Array of Objects with properties `startRow`, `endRow`, `startCol` and `endCol`.
  30851. * @returns {String} Returns string which will be copied into clipboard.
  30852. */
  30853. }, {
  30854. key: 'getRangedCopyableData',
  30855. value: function getRangedCopyableData(ranges) {
  30856. var _this3 = this;
  30857. var dataSet = [];
  30858. var copyableRows = [];
  30859. var copyableColumns = [];
  30860. // Count all copyable rows and columns
  30861. (0, _array.arrayEach)(ranges, function (range) {
  30862. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  30863. if (copyableRows.indexOf(row) === -1) {
  30864. copyableRows.push(row);
  30865. }
  30866. });
  30867. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  30868. if (copyableColumns.indexOf(column) === -1) {
  30869. copyableColumns.push(column);
  30870. }
  30871. });
  30872. });
  30873. // Concat all rows and columns data defined in ranges into one copyable string
  30874. (0, _array.arrayEach)(copyableRows, function (row) {
  30875. var rowSet = [];
  30876. (0, _array.arrayEach)(copyableColumns, function (column) {
  30877. rowSet.push(_this3.hot.getCopyableData(row, column));
  30878. });
  30879. dataSet.push(rowSet);
  30880. });
  30881. return _SheetClip2.default.stringify(dataSet);
  30882. }
  30883. /**
  30884. * Create copyable text releated to range objects.
  30885. *
  30886. * @since 0.31.1
  30887. * @param {Array} ranges Array of Objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
  30888. * @returns {Array} Returns array of arrays which will be copied into clipboard.
  30889. */
  30890. }, {
  30891. key: 'getRangedData',
  30892. value: function getRangedData(ranges) {
  30893. var _this4 = this;
  30894. var dataSet = [];
  30895. var copyableRows = [];
  30896. var copyableColumns = [];
  30897. // Count all copyable rows and columns
  30898. (0, _array.arrayEach)(ranges, function (range) {
  30899. (0, _number.rangeEach)(range.startRow, range.endRow, function (row) {
  30900. if (copyableRows.indexOf(row) === -1) {
  30901. copyableRows.push(row);
  30902. }
  30903. });
  30904. (0, _number.rangeEach)(range.startCol, range.endCol, function (column) {
  30905. if (copyableColumns.indexOf(column) === -1) {
  30906. copyableColumns.push(column);
  30907. }
  30908. });
  30909. });
  30910. // Concat all rows and columns data defined in ranges into one copyable string
  30911. (0, _array.arrayEach)(copyableRows, function (row) {
  30912. var rowSet = [];
  30913. (0, _array.arrayEach)(copyableColumns, function (column) {
  30914. rowSet.push(_this4.hot.getCopyableData(row, column));
  30915. });
  30916. dataSet.push(rowSet);
  30917. });
  30918. return dataSet;
  30919. }
  30920. /**
  30921. * Copy action.
  30922. *
  30923. * @param {Boolean} isTriggeredByClick Flag to determine that copy action was executed by the mouse click.
  30924. */
  30925. }, {
  30926. key: 'copy',
  30927. value: function copy(isTriggeredByClick) {
  30928. var rangedData = this.getRangedData(this.copyableRanges);
  30929. var allowCopying = !!this.hot.runHooks('beforeCopy', rangedData, this.copyableRanges);
  30930. if (allowCopying) {
  30931. this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
  30932. this.textarea.select();
  30933. if (isTriggeredByClick) {
  30934. document.execCommand('copy');
  30935. }
  30936. this.hot.runHooks('afterCopy', rangedData, this.copyableRanges);
  30937. } else {
  30938. this.textarea.setValue('');
  30939. }
  30940. }
  30941. /**
  30942. * Cut action.
  30943. *
  30944. * @param {Boolean} isTriggeredByClick Flag to determine that cut action was executed by the mouse click.
  30945. */
  30946. }, {
  30947. key: 'cut',
  30948. value: function cut(isTriggeredByClick) {
  30949. var rangedData = this.getRangedData(this.copyableRanges);
  30950. var allowCuttingOut = !!this.hot.runHooks('beforeCut', rangedData, this.copyableRanges);
  30951. if (allowCuttingOut) {
  30952. this.textarea.setValue(_SheetClip2.default.stringify(rangedData));
  30953. this.hot.selection.empty();
  30954. this.textarea.select();
  30955. if (isTriggeredByClick) {
  30956. document.execCommand('cut');
  30957. }
  30958. this.hot.runHooks('afterCut', rangedData, this.copyableRanges);
  30959. } else {
  30960. this.textarea.setValue('');
  30961. }
  30962. }
  30963. /**
  30964. * Simulated paste action.
  30965. *
  30966. * @param {String} [value=''] New value, which should be `pasted`.
  30967. */
  30968. }, {
  30969. key: 'paste',
  30970. value: function paste() {
  30971. var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  30972. this.textarea.setValue(value);
  30973. this.onPaste();
  30974. this.onInput();
  30975. }
  30976. /**
  30977. * Register event listeners.
  30978. *
  30979. * @private
  30980. */
  30981. }, {
  30982. key: 'registerEvents',
  30983. value: function registerEvents() {
  30984. var _this5 = this;
  30985. this.eventManager.addEventListener(this.textarea.element, 'paste', function (event) {
  30986. return _this5.onPaste(event);
  30987. });
  30988. this.eventManager.addEventListener(this.textarea.element, 'input', function (event) {
  30989. return _this5.onInput(event);
  30990. });
  30991. }
  30992. /**
  30993. * Trigger to make possible observe `onInput` in textarea.
  30994. *
  30995. * @private
  30996. */
  30997. }, {
  30998. key: 'triggerPaste',
  30999. value: function triggerPaste() {
  31000. this.textarea.select();
  31001. this.onPaste();
  31002. }
  31003. /**
  31004. * `paste` event callback on textarea element.
  31005. *
  31006. * @private
  31007. */
  31008. }, {
  31009. key: 'onPaste',
  31010. value: function onPaste() {
  31011. var priv = privatePool.get(this);
  31012. priv.isTriggeredByPaste = true;
  31013. }
  31014. /**
  31015. * `input` event callback is called after `paste` event callback.
  31016. *
  31017. * @private
  31018. */
  31019. }, {
  31020. key: 'onInput',
  31021. value: function onInput() {
  31022. var _this6 = this;
  31023. var priv = privatePool.get(this);
  31024. if (!this.hot.isListening() || !priv.isTriggeredByPaste) {
  31025. return;
  31026. }
  31027. priv.isTriggeredByPaste = false;
  31028. var input = void 0,
  31029. inputArray = void 0,
  31030. selected = void 0,
  31031. coordsFrom = void 0,
  31032. coordsTo = void 0,
  31033. cellRange = void 0,
  31034. topLeftCorner = void 0,
  31035. bottomRightCorner = void 0,
  31036. areaStart = void 0,
  31037. areaEnd = void 0;
  31038. input = this.textarea.getValue();
  31039. inputArray = _SheetClip2.default.parse(input);
  31040. var allowPasting = !!this.hot.runHooks('beforePaste', inputArray, this.copyableRanges);
  31041. if (!allowPasting) {
  31042. return;
  31043. }
  31044. selected = this.hot.getSelected();
  31045. coordsFrom = new _src.CellCoords(selected[0], selected[1]);
  31046. coordsTo = new _src.CellCoords(selected[2], selected[3]);
  31047. cellRange = new _src.CellRange(coordsFrom, coordsFrom, coordsTo);
  31048. topLeftCorner = cellRange.getTopLeftCorner();
  31049. bottomRightCorner = cellRange.getBottomRightCorner();
  31050. areaStart = topLeftCorner;
  31051. areaEnd = new _src.CellCoords(Math.max(bottomRightCorner.row, inputArray.length - 1 + topLeftCorner.row), Math.max(bottomRightCorner.col, inputArray[0].length - 1 + topLeftCorner.col));
  31052. var isSelRowAreaCoverInputValue = coordsTo.row - coordsFrom.row >= inputArray.length - 1;
  31053. var isSelColAreaCoverInputValue = coordsTo.col - coordsFrom.col >= inputArray[0].length - 1;
  31054. this.hot.addHookOnce('afterChange', function (changes, source) {
  31055. var changesLength = changes ? changes.length : 0;
  31056. if (changesLength) {
  31057. var offset = { row: 0, col: 0 };
  31058. var highestColumnIndex = -1;
  31059. (0, _array.arrayEach)(changes, function (change, index) {
  31060. var nextChange = changesLength > index + 1 ? changes[index + 1] : null;
  31061. if (nextChange) {
  31062. if (!isSelRowAreaCoverInputValue) {
  31063. offset.row += Math.max(nextChange[0] - change[0] - 1, 0);
  31064. }
  31065. if (!isSelColAreaCoverInputValue && change[1] > highestColumnIndex) {
  31066. highestColumnIndex = change[1];
  31067. offset.col += Math.max(nextChange[1] - change[1] - 1, 0);
  31068. }
  31069. }
  31070. });
  31071. _this6.hot.selectCell(areaStart.row, areaStart.col, areaEnd.row + offset.row, areaEnd.col + offset.col);
  31072. }
  31073. });
  31074. this.hot.populateFromArray(areaStart.row, areaStart.col, inputArray, areaEnd.row, areaEnd.col, 'CopyPaste.paste', this.pasteMode);
  31075. this.hot.runHooks('afterPaste', inputArray, this.copyableRanges);
  31076. }
  31077. /**
  31078. * Add copy, cut and paste options to the Context Menu.
  31079. *
  31080. * @private
  31081. * @param {Object} options Contains default added options of the Context Menu.
  31082. */
  31083. }, {
  31084. key: 'onAfterContextMenuDefaultOptions',
  31085. value: function onAfterContextMenuDefaultOptions(options) {
  31086. options.items.push({
  31087. name: '---------'
  31088. }, (0, _copy2.default)(this), (0, _cut2.default)(this));
  31089. }
  31090. /**
  31091. * beforeKeyDown callback.
  31092. *
  31093. * @private
  31094. * @param {Event} event
  31095. */
  31096. }, {
  31097. key: 'onBeforeKeyDown',
  31098. value: function onBeforeKeyDown(event) {
  31099. var _this7 = this;
  31100. if (!this.hot.getSelected()) {
  31101. return;
  31102. }
  31103. if (this.hot.getActiveEditor() && this.hot.getActiveEditor().isOpened()) {
  31104. return;
  31105. }
  31106. if ((0, _event.isImmediatePropagationStopped)(event)) {
  31107. return;
  31108. }
  31109. if (!this.textarea.isActive() && (0, _element.getSelectionText)()) {
  31110. return;
  31111. }
  31112. if ((0, _unicode.isCtrlKey)(event.keyCode)) {
  31113. // When fragmentSelection is enabled and some text is selected then don't blur selection calling 'setCopyableText'
  31114. if (this.hot.getSettings().fragmentSelection && (0, _element.getSelectionText)()) {
  31115. return;
  31116. }
  31117. // when CTRL is pressed, prepare selectable text in textarea
  31118. this.setCopyableText();
  31119. (0, _event.stopImmediatePropagation)(event);
  31120. return;
  31121. }
  31122. // catch CTRL but not right ALT (which in some systems triggers ALT+CTRL)
  31123. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  31124. if (ctrlDown) {
  31125. if (event.keyCode == _unicode.KEY_CODES.A) {
  31126. setTimeout(function () {
  31127. _this7.setCopyableText();
  31128. }, 0);
  31129. }
  31130. if (event.keyCode == _unicode.KEY_CODES.X) {
  31131. this.cut();
  31132. }
  31133. if (event.keyCode == _unicode.KEY_CODES.C) {
  31134. this.copy();
  31135. }
  31136. if (event.keyCode == _unicode.KEY_CODES.V) {
  31137. this.triggerPaste();
  31138. }
  31139. }
  31140. }
  31141. /**
  31142. * Destroy plugin instance.
  31143. */
  31144. }, {
  31145. key: 'destroy',
  31146. value: function destroy() {
  31147. if (this.textarea) {
  31148. this.textarea.destroy();
  31149. }
  31150. _get(CopyPaste.prototype.__proto__ || Object.getPrototypeOf(CopyPaste.prototype), 'destroy', this).call(this);
  31151. }
  31152. }]);
  31153. return CopyPaste;
  31154. }(_base2.default);
  31155. (0, _plugins.registerPlugin)('CopyPaste', CopyPaste);
  31156. exports.default = CopyPaste;
  31157. /***/ }),
  31158. /* 237 */
  31159. /***/ (function(module, exports, __webpack_require__) {
  31160. "use strict";
  31161. exports.__esModule = true;
  31162. 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; }; }();
  31163. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31164. /**
  31165. * @class Textarea
  31166. *
  31167. * @plugin CopyPaste
  31168. */
  31169. var Textarea = function () {
  31170. _createClass(Textarea, null, [{
  31171. key: 'getSingleton',
  31172. value: function getSingleton() {
  31173. globalSingleton.append();
  31174. return globalSingleton;
  31175. }
  31176. }]);
  31177. function Textarea() {
  31178. _classCallCheck(this, Textarea);
  31179. /**
  31180. * Main textarea element.
  31181. *
  31182. * @type {HTMLElement}
  31183. */
  31184. this.element = void 0;
  31185. /**
  31186. * Store information about append to the document.body.
  31187. *
  31188. * @type {Boolean}
  31189. */
  31190. this.isAppended = false;
  31191. /**
  31192. * Reference counter.
  31193. *
  31194. * @type {Number}
  31195. */
  31196. this.refCounter = 0;
  31197. }
  31198. /**
  31199. * Apends textarea element to the `body`
  31200. */
  31201. _createClass(Textarea, [{
  31202. key: 'append',
  31203. value: function append() {
  31204. if (this.hasBeenDestroyed()) {
  31205. this.create();
  31206. }
  31207. this.refCounter++;
  31208. if (!this.isAppended && document.body) {
  31209. if (document.body) {
  31210. this.isAppended = true;
  31211. document.body.appendChild(this.element);
  31212. }
  31213. }
  31214. }
  31215. /**
  31216. * Prepares textarea element with proper attributes.
  31217. */
  31218. }, {
  31219. key: 'create',
  31220. value: function create() {
  31221. this.element = document.createElement('textarea');
  31222. this.element.id = 'HandsontableCopyPaste';
  31223. this.element.className = 'copyPaste';
  31224. this.element.tabIndex = -1;
  31225. this.element.autocomplete = 'off';
  31226. this.element.wrap = 'off';
  31227. }
  31228. /**
  31229. * Deselects textarea element if is active.
  31230. */
  31231. }, {
  31232. key: 'deselect',
  31233. value: function deselect() {
  31234. if (this.element === document.activeElement) {
  31235. document.activeElement.blur();
  31236. }
  31237. }
  31238. /**
  31239. * Destroy instance
  31240. */
  31241. }, {
  31242. key: 'destroy',
  31243. value: function destroy() {
  31244. this.refCounter--;
  31245. this.refCounter = this.refCounter < 0 ? 0 : this.refCounter;
  31246. if (this.hasBeenDestroyed() && this.element && this.element.parentNode) {
  31247. this.element.parentNode.removeChild(this.element);
  31248. this.element = null;
  31249. this.isAppended = false;
  31250. }
  31251. }
  31252. /**
  31253. * Getter for the element.
  31254. *
  31255. * @returns {String}
  31256. */
  31257. }, {
  31258. key: 'getValue',
  31259. value: function getValue() {
  31260. return this.element.value;
  31261. }
  31262. /**
  31263. * Check if instance has been destroyed
  31264. *
  31265. * @returns {Boolean}
  31266. */
  31267. }, {
  31268. key: 'hasBeenDestroyed',
  31269. value: function hasBeenDestroyed() {
  31270. return this.refCounter < 1;
  31271. }
  31272. /**
  31273. * Check if the element is an active element in frame.
  31274. *
  31275. * @returns {Boolean}
  31276. */
  31277. }, {
  31278. key: 'isActive',
  31279. value: function isActive() {
  31280. return this.element === document.activeElement;
  31281. }
  31282. /**
  31283. * Sets focus on the element and select content.
  31284. */
  31285. }, {
  31286. key: 'select',
  31287. value: function select() {
  31288. this.element.focus();
  31289. this.element.select();
  31290. }
  31291. /**
  31292. * Setter for the element.
  31293. *
  31294. * @param {String} data Value which should be insert into the element.
  31295. */
  31296. }, {
  31297. key: 'setValue',
  31298. value: function setValue(data) {
  31299. this.element.value = data;
  31300. }
  31301. }]);
  31302. return Textarea;
  31303. }();
  31304. var globalSingleton = new Textarea();
  31305. exports.default = Textarea;
  31306. /***/ }),
  31307. /* 238 */
  31308. /***/ (function(module, exports, __webpack_require__) {
  31309. "use strict";
  31310. 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; };
  31311. var _pluginHooks = __webpack_require__(8);
  31312. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  31313. var _plugins = __webpack_require__(5);
  31314. var _object = __webpack_require__(1);
  31315. var _src = __webpack_require__(11);
  31316. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31317. function CustomBorders() {}
  31318. /** *
  31319. * Current instance (table where borders should be placed)
  31320. */
  31321. var instance;
  31322. /**
  31323. * This plugin enables an option to apply custom borders through the context menu (configurable with context menu key `borders`).
  31324. *
  31325. * To initialize Handsontable with predefined custom borders, provide cell coordinates and border styles in a form of an array.
  31326. *
  31327. * See [Custom Borders](http://docs.handsontable.com/demo-custom-borders.html) demo for more examples.
  31328. *
  31329. * @example
  31330. * ```js
  31331. * ...
  31332. * customBorders: [
  31333. * {range: {
  31334. * from: {row: 1, col: 1},
  31335. * to: {row: 3, col: 4}},
  31336. * left: {},
  31337. * right: {},
  31338. * top: {},
  31339. * bottom: {}
  31340. * }
  31341. * ],
  31342. * ...
  31343. *
  31344. * // or
  31345. * ...
  31346. * customBorders: [
  31347. * {row: 2, col: 2, left: {width: 2, color: 'red'},
  31348. * right: {width: 1, color: 'green'}, top: '', bottom: ''}
  31349. * ],
  31350. * ...
  31351. * ```
  31352. * @private
  31353. * @class CustomBorders
  31354. * @plugin CustomBorders
  31355. */
  31356. /** *
  31357. * Check if plugin should be enabled.
  31358. */
  31359. var checkEnable = function checkEnable(customBorders) {
  31360. if (typeof customBorders === 'boolean') {
  31361. if (customBorders === true) {
  31362. return true;
  31363. }
  31364. }
  31365. if ((typeof customBorders === 'undefined' ? 'undefined' : _typeof(customBorders)) === 'object') {
  31366. if (customBorders.length > 0) {
  31367. return true;
  31368. }
  31369. }
  31370. return false;
  31371. };
  31372. /** *
  31373. * Initialize plugin.
  31374. */
  31375. var init = function init() {
  31376. if (checkEnable(this.getSettings().customBorders)) {
  31377. if (!this.customBorders) {
  31378. instance = this;
  31379. this.customBorders = new CustomBorders();
  31380. }
  31381. }
  31382. };
  31383. /** *
  31384. * Get index of border from the settings.
  31385. *
  31386. * @param {String} className
  31387. * @returns {Number}
  31388. */
  31389. var getSettingIndex = function getSettingIndex(className) {
  31390. for (var i = 0; i < instance.view.wt.selections.length; i++) {
  31391. if (instance.view.wt.selections[i].settings.className == className) {
  31392. return i;
  31393. }
  31394. }
  31395. return -1;
  31396. };
  31397. /** *
  31398. * Insert WalkontableSelection instance into Walkontable settings.
  31399. *
  31400. * @param border
  31401. */
  31402. var insertBorderIntoSettings = function insertBorderIntoSettings(border) {
  31403. var coordinates = {
  31404. row: border.row,
  31405. col: border.col
  31406. };
  31407. var selection = new _src.Selection(border, new _src.CellRange(coordinates, coordinates, coordinates));
  31408. var index = getSettingIndex(border.className);
  31409. if (index >= 0) {
  31410. instance.view.wt.selections[index] = selection;
  31411. } else {
  31412. instance.view.wt.selections.push(selection);
  31413. }
  31414. };
  31415. /** *
  31416. * Prepare borders from setting (single cell).
  31417. *
  31418. * @param {Number} row Visual row index.
  31419. * @param {Number} col Visual column index.
  31420. * @param borderObj
  31421. */
  31422. var prepareBorderFromCustomAdded = function prepareBorderFromCustomAdded(row, col, borderObj) {
  31423. var border = createEmptyBorders(row, col);
  31424. border = extendDefaultBorder(border, borderObj);
  31425. this.setCellMeta(row, col, 'borders', border);
  31426. insertBorderIntoSettings(border);
  31427. };
  31428. /** *
  31429. * Prepare borders from setting (object).
  31430. *
  31431. * @param {Object} rowObj
  31432. */
  31433. var prepareBorderFromCustomAddedRange = function prepareBorderFromCustomAddedRange(rowObj) {
  31434. var range = rowObj.range;
  31435. for (var row = range.from.row; row <= range.to.row; row++) {
  31436. for (var col = range.from.col; col <= range.to.col; col++) {
  31437. var border = createEmptyBorders(row, col);
  31438. var add = 0;
  31439. if (row == range.from.row) {
  31440. add++;
  31441. if ((0, _object.hasOwnProperty)(rowObj, 'top')) {
  31442. border.top = rowObj.top;
  31443. }
  31444. }
  31445. if (row == range.to.row) {
  31446. add++;
  31447. if ((0, _object.hasOwnProperty)(rowObj, 'bottom')) {
  31448. border.bottom = rowObj.bottom;
  31449. }
  31450. }
  31451. if (col == range.from.col) {
  31452. add++;
  31453. if ((0, _object.hasOwnProperty)(rowObj, 'left')) {
  31454. border.left = rowObj.left;
  31455. }
  31456. }
  31457. if (col == range.to.col) {
  31458. add++;
  31459. if ((0, _object.hasOwnProperty)(rowObj, 'right')) {
  31460. border.right = rowObj.right;
  31461. }
  31462. }
  31463. if (add > 0) {
  31464. this.setCellMeta(row, col, 'borders', border);
  31465. insertBorderIntoSettings(border);
  31466. }
  31467. }
  31468. }
  31469. };
  31470. /** *
  31471. * Create separated class name for borders for each cell.
  31472. *
  31473. * @param {Number} row Visual row index.
  31474. * @param {Number} col Visual column index.
  31475. * @returns {String}
  31476. */
  31477. var createClassName = function createClassName(row, col) {
  31478. return 'border_row' + row + 'col' + col;
  31479. };
  31480. /** *
  31481. * Create default single border for each position (top/right/bottom/left).
  31482. *
  31483. * @returns {Object} `{{width: number, color: string}}`
  31484. */
  31485. var createDefaultCustomBorder = function createDefaultCustomBorder() {
  31486. return {
  31487. width: 1,
  31488. color: '#000'
  31489. };
  31490. };
  31491. /** *
  31492. * Create default object for empty border.
  31493. *
  31494. * @returns {Object} `{{hide: boolean}}`
  31495. */
  31496. var createSingleEmptyBorder = function createSingleEmptyBorder() {
  31497. return {
  31498. hide: true
  31499. };
  31500. };
  31501. /** *
  31502. * Create default Handsontable border object.
  31503. *
  31504. * @returns {Object} `{{width: number, color: string, cornerVisible: boolean}}`
  31505. */
  31506. var createDefaultHtBorder = function createDefaultHtBorder() {
  31507. return {
  31508. width: 1,
  31509. color: '#000',
  31510. cornerVisible: false
  31511. };
  31512. };
  31513. /** *
  31514. * Prepare empty border for each cell with all custom borders hidden.
  31515. *
  31516. * @param {Number} row Visual row index.
  31517. * @param {Number} col Visual column index.
  31518. * @returns {Object} `{{className: *, border: *, row: *, col: *, top: {hide: boolean}, right: {hide: boolean}, bottom: {hide: boolean}, left: {hide: boolean}}}`
  31519. */
  31520. var createEmptyBorders = function createEmptyBorders(row, col) {
  31521. return {
  31522. className: createClassName(row, col),
  31523. border: createDefaultHtBorder(),
  31524. row: row,
  31525. col: col,
  31526. top: createSingleEmptyBorder(),
  31527. right: createSingleEmptyBorder(),
  31528. bottom: createSingleEmptyBorder(),
  31529. left: createSingleEmptyBorder()
  31530. };
  31531. };
  31532. var extendDefaultBorder = function extendDefaultBorder(defaultBorder, customBorder) {
  31533. if ((0, _object.hasOwnProperty)(customBorder, 'border')) {
  31534. defaultBorder.border = customBorder.border;
  31535. }
  31536. if ((0, _object.hasOwnProperty)(customBorder, 'top')) {
  31537. defaultBorder.top = customBorder.top;
  31538. }
  31539. if ((0, _object.hasOwnProperty)(customBorder, 'right')) {
  31540. defaultBorder.right = customBorder.right;
  31541. }
  31542. if ((0, _object.hasOwnProperty)(customBorder, 'bottom')) {
  31543. defaultBorder.bottom = customBorder.bottom;
  31544. }
  31545. if ((0, _object.hasOwnProperty)(customBorder, 'left')) {
  31546. defaultBorder.left = customBorder.left;
  31547. }
  31548. return defaultBorder;
  31549. };
  31550. /**
  31551. * Remove borders divs from DOM.
  31552. *
  31553. * @param borderClassName
  31554. */
  31555. var removeBordersFromDom = function removeBordersFromDom(borderClassName) {
  31556. var borders = document.querySelectorAll('.' + borderClassName);
  31557. for (var i = 0; i < borders.length; i++) {
  31558. if (borders[i]) {
  31559. if (borders[i].nodeName != 'TD') {
  31560. var parent = borders[i].parentNode;
  31561. if (parent.parentNode) {
  31562. parent.parentNode.removeChild(parent);
  31563. }
  31564. }
  31565. }
  31566. }
  31567. };
  31568. /** *
  31569. * Remove border (triggered from context menu).
  31570. *
  31571. * @param {Number} row Visual row index.
  31572. * @param {Number} col Visual column index.
  31573. */
  31574. var removeAllBorders = function removeAllBorders(row, col) {
  31575. var borderClassName = createClassName(row, col);
  31576. removeBordersFromDom(borderClassName);
  31577. this.removeCellMeta(row, col, 'borders');
  31578. };
  31579. /** *
  31580. * Set borders for each cell re. to border position
  31581. *
  31582. * @param row Visual row index.
  31583. * @param col Visual column index.
  31584. * @param place
  31585. * @param remove
  31586. */
  31587. var setBorder = function setBorder(row, col, place, remove) {
  31588. var bordersMeta = this.getCellMeta(row, col).borders;
  31589. if (!bordersMeta || bordersMeta.border == undefined) {
  31590. bordersMeta = createEmptyBorders(row, col);
  31591. }
  31592. if (remove) {
  31593. bordersMeta[place] = createSingleEmptyBorder();
  31594. } else {
  31595. bordersMeta[place] = createDefaultCustomBorder();
  31596. }
  31597. this.setCellMeta(row, col, 'borders', bordersMeta);
  31598. var borderClassName = createClassName(row, col);
  31599. removeBordersFromDom(borderClassName);
  31600. insertBorderIntoSettings(bordersMeta);
  31601. this.render();
  31602. };
  31603. /** *
  31604. * Prepare borders based on cell and border position
  31605. *
  31606. * @param range
  31607. * @param place
  31608. * @param remove
  31609. */
  31610. var prepareBorder = function prepareBorder(range, place, remove) {
  31611. if (range.from.row == range.to.row && range.from.col == range.to.col) {
  31612. if (place == 'noBorders') {
  31613. removeAllBorders.call(this, range.from.row, range.from.col);
  31614. } else {
  31615. setBorder.call(this, range.from.row, range.from.col, place, remove);
  31616. }
  31617. } else {
  31618. switch (place) {
  31619. case 'noBorders':
  31620. for (var column = range.from.col; column <= range.to.col; column++) {
  31621. for (var row = range.from.row; row <= range.to.row; row++) {
  31622. removeAllBorders.call(this, row, column);
  31623. }
  31624. }
  31625. break;
  31626. case 'top':
  31627. for (var topCol = range.from.col; topCol <= range.to.col; topCol++) {
  31628. setBorder.call(this, range.from.row, topCol, place, remove);
  31629. }
  31630. break;
  31631. case 'right':
  31632. for (var rowRight = range.from.row; rowRight <= range.to.row; rowRight++) {
  31633. setBorder.call(this, rowRight, range.to.col, place);
  31634. }
  31635. break;
  31636. case 'bottom':
  31637. for (var bottomCol = range.from.col; bottomCol <= range.to.col; bottomCol++) {
  31638. setBorder.call(this, range.to.row, bottomCol, place);
  31639. }
  31640. break;
  31641. case 'left':
  31642. for (var rowLeft = range.from.row; rowLeft <= range.to.row; rowLeft++) {
  31643. setBorder.call(this, rowLeft, range.from.col, place);
  31644. }
  31645. break;
  31646. default:
  31647. break;
  31648. }
  31649. }
  31650. };
  31651. /** *
  31652. * Check if selection has border by className
  31653. *
  31654. * @param hot
  31655. * @param direction
  31656. */
  31657. var checkSelectionBorders = function checkSelectionBorders(hot, direction) {
  31658. var atLeastOneHasBorder = false;
  31659. hot.getSelectedRange().forAll(function (r, c) {
  31660. var metaBorders = hot.getCellMeta(r, c).borders;
  31661. if (metaBorders) {
  31662. if (direction) {
  31663. if (!(0, _object.hasOwnProperty)(metaBorders[direction], 'hide')) {
  31664. atLeastOneHasBorder = true;
  31665. return false; // breaks forAll
  31666. }
  31667. } else {
  31668. atLeastOneHasBorder = true;
  31669. return false; // breaks forAll
  31670. }
  31671. }
  31672. });
  31673. return atLeastOneHasBorder;
  31674. };
  31675. /** *
  31676. * Mark label in contextMenu as selected
  31677. *
  31678. * @param label
  31679. * @returns {string}
  31680. */
  31681. var markSelected = function markSelected(label) {
  31682. return '<span class="selected">' + String.fromCharCode(10003) + '</span>' + label; // workaround for https://github.com/handsontable/handsontable/issues/1946
  31683. };
  31684. /** *
  31685. * Add border options to context menu
  31686. *
  31687. * @param defaultOptions
  31688. */
  31689. var addBordersOptionsToContextMenu = function addBordersOptionsToContextMenu(defaultOptions) {
  31690. if (!this.getSettings().customBorders) {
  31691. return;
  31692. }
  31693. defaultOptions.items.push({
  31694. name: '---------'
  31695. });
  31696. defaultOptions.items.push({
  31697. key: 'borders',
  31698. name: 'Borders',
  31699. disabled: function disabled() {
  31700. return this.selection.selectedHeader.corner;
  31701. },
  31702. submenu: {
  31703. items: [{
  31704. key: 'borders:top',
  31705. name: function name() {
  31706. var label = 'Top';
  31707. var hasBorder = checkSelectionBorders(this, 'top');
  31708. if (hasBorder) {
  31709. label = markSelected(label);
  31710. }
  31711. return label;
  31712. },
  31713. callback: function callback() {
  31714. var hasBorder = checkSelectionBorders(this, 'top');
  31715. prepareBorder.call(this, this.getSelectedRange(), 'top', hasBorder);
  31716. }
  31717. }, {
  31718. key: 'borders:right',
  31719. name: function name() {
  31720. var label = 'Right';
  31721. var hasBorder = checkSelectionBorders(this, 'right');
  31722. if (hasBorder) {
  31723. label = markSelected(label);
  31724. }
  31725. return label;
  31726. },
  31727. callback: function callback() {
  31728. var hasBorder = checkSelectionBorders(this, 'right');
  31729. prepareBorder.call(this, this.getSelectedRange(), 'right', hasBorder);
  31730. }
  31731. }, {
  31732. key: 'borders:bottom',
  31733. name: function name() {
  31734. var label = 'Bottom';
  31735. var hasBorder = checkSelectionBorders(this, 'bottom');
  31736. if (hasBorder) {
  31737. label = markSelected(label);
  31738. }
  31739. return label;
  31740. },
  31741. callback: function callback() {
  31742. var hasBorder = checkSelectionBorders(this, 'bottom');
  31743. prepareBorder.call(this, this.getSelectedRange(), 'bottom', hasBorder);
  31744. }
  31745. }, {
  31746. key: 'borders:left',
  31747. name: function name() {
  31748. var label = 'Left';
  31749. var hasBorder = checkSelectionBorders(this, 'left');
  31750. if (hasBorder) {
  31751. label = markSelected(label);
  31752. }
  31753. return label;
  31754. },
  31755. callback: function callback() {
  31756. var hasBorder = checkSelectionBorders(this, 'left');
  31757. prepareBorder.call(this, this.getSelectedRange(), 'left', hasBorder);
  31758. }
  31759. }, {
  31760. key: 'borders:no_borders',
  31761. name: 'Remove border(s)',
  31762. callback: function callback() {
  31763. prepareBorder.call(this, this.getSelectedRange(), 'noBorders');
  31764. },
  31765. disabled: function disabled() {
  31766. return !checkSelectionBorders(this);
  31767. }
  31768. }]
  31769. }
  31770. });
  31771. };
  31772. _pluginHooks2.default.getSingleton().add('beforeInit', init);
  31773. _pluginHooks2.default.getSingleton().add('afterContextMenuDefaultOptions', addBordersOptionsToContextMenu);
  31774. _pluginHooks2.default.getSingleton().add('afterInit', function () {
  31775. var customBorders = this.getSettings().customBorders;
  31776. if (customBorders) {
  31777. for (var i = 0; i < customBorders.length; i++) {
  31778. if (customBorders[i].range) {
  31779. prepareBorderFromCustomAddedRange.call(this, customBorders[i]);
  31780. } else {
  31781. prepareBorderFromCustomAdded.call(this, customBorders[i].row, customBorders[i].col, customBorders[i]);
  31782. }
  31783. }
  31784. this.render();
  31785. this.view.wt.draw(true);
  31786. }
  31787. });
  31788. /***/ }),
  31789. /* 239 */
  31790. /***/ (function(module, exports, __webpack_require__) {
  31791. "use strict";
  31792. exports.__esModule = true;
  31793. var _pluginHooks = __webpack_require__(8);
  31794. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  31795. var _eventManager = __webpack_require__(4);
  31796. var _eventManager2 = _interopRequireDefault(_eventManager);
  31797. var _plugins = __webpack_require__(5);
  31798. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31799. /**
  31800. * @description
  31801. * Plugin used to scroll Handsontable by selecting a cell and dragging outside of the visible viewport.
  31802. *
  31803. * @private
  31804. * @class DragToScroll
  31805. * @plugin DragToScroll
  31806. */
  31807. function DragToScroll() {
  31808. this.boundaries = null;
  31809. this.callback = null;
  31810. }
  31811. /**
  31812. * @param boundaries {Object} compatible with getBoundingClientRect
  31813. */
  31814. DragToScroll.prototype.setBoundaries = function (boundaries) {
  31815. this.boundaries = boundaries;
  31816. };
  31817. /**
  31818. * @param callback {Function}
  31819. */
  31820. DragToScroll.prototype.setCallback = function (callback) {
  31821. this.callback = callback;
  31822. };
  31823. /**
  31824. * Check if mouse position (x, y) is outside of the viewport
  31825. * @param x
  31826. * @param y
  31827. */
  31828. DragToScroll.prototype.check = function (x, y) {
  31829. var diffX = 0;
  31830. var diffY = 0;
  31831. if (y < this.boundaries.top) {
  31832. // y is less than top
  31833. diffY = y - this.boundaries.top;
  31834. } else if (y > this.boundaries.bottom) {
  31835. // y is more than bottom
  31836. diffY = y - this.boundaries.bottom;
  31837. }
  31838. if (x < this.boundaries.left) {
  31839. // x is less than left
  31840. diffX = x - this.boundaries.left;
  31841. } else if (x > this.boundaries.right) {
  31842. // x is more than right
  31843. diffX = x - this.boundaries.right;
  31844. }
  31845. this.callback(diffX, diffY);
  31846. };
  31847. var dragToScroll;
  31848. var instance;
  31849. var setupListening = function setupListening(instance) {
  31850. instance.dragToScrollListening = false;
  31851. var scrollHandler = instance.view.wt.wtTable.holder; // native scroll
  31852. dragToScroll = new DragToScroll();
  31853. if (scrollHandler === window) {
  31854. // not much we can do currently
  31855. return;
  31856. }
  31857. dragToScroll.setBoundaries(scrollHandler.getBoundingClientRect());
  31858. dragToScroll.setCallback(function (scrollX, scrollY) {
  31859. if (scrollX < 0) {
  31860. scrollHandler.scrollLeft -= 50;
  31861. } else if (scrollX > 0) {
  31862. scrollHandler.scrollLeft += 50;
  31863. }
  31864. if (scrollY < 0) {
  31865. scrollHandler.scrollTop -= 20;
  31866. } else if (scrollY > 0) {
  31867. scrollHandler.scrollTop += 20;
  31868. }
  31869. });
  31870. instance.dragToScrollListening = true;
  31871. };
  31872. _pluginHooks2.default.getSingleton().add('afterInit', function () {
  31873. var instance = this;
  31874. var eventManager = new _eventManager2.default(this);
  31875. eventManager.addEventListener(document, 'mouseup', function () {
  31876. instance.dragToScrollListening = false;
  31877. });
  31878. eventManager.addEventListener(document, 'mousemove', function (event) {
  31879. if (instance.dragToScrollListening) {
  31880. dragToScroll.check(event.clientX, event.clientY);
  31881. }
  31882. });
  31883. });
  31884. _pluginHooks2.default.getSingleton().add('afterDestroy', function () {
  31885. new _eventManager2.default(this).clear();
  31886. });
  31887. _pluginHooks2.default.getSingleton().add('afterOnCellMouseDown', function () {
  31888. setupListening(this);
  31889. });
  31890. _pluginHooks2.default.getSingleton().add('afterOnCellCornerMouseDown', function () {
  31891. setupListening(this);
  31892. });
  31893. exports.default = DragToScroll;
  31894. /***/ }),
  31895. /* 240 */
  31896. /***/ (function(module, exports, __webpack_require__) {
  31897. "use strict";
  31898. exports.__esModule = true;
  31899. exports.default = freezeColumnItem;
  31900. function freezeColumnItem(manualColumnFreezePlugin) {
  31901. return {
  31902. key: 'freeze_column',
  31903. name: 'Freeze this column',
  31904. callback: function callback() {
  31905. var selectedColumn = this.getSelectedRange().from.col;
  31906. manualColumnFreezePlugin.freezeColumn(selectedColumn);
  31907. this.render();
  31908. this.view.wt.wtOverlays.adjustElementsSize(true);
  31909. },
  31910. hidden: function hidden() {
  31911. var selection = this.getSelectedRange();
  31912. var hide = false;
  31913. if (selection === void 0) {
  31914. hide = true;
  31915. } else if (selection.from.col !== selection.to.col || selection.from.col <= this.getSettings().fixedColumnsLeft - 1) {
  31916. hide = true;
  31917. }
  31918. return hide;
  31919. }
  31920. };
  31921. }
  31922. /***/ }),
  31923. /* 241 */
  31924. /***/ (function(module, exports, __webpack_require__) {
  31925. "use strict";
  31926. exports.__esModule = true;
  31927. exports.default = unfreezeColumnItem;
  31928. function unfreezeColumnItem(manualColumnFreezePlugin) {
  31929. return {
  31930. key: 'unfreeze_column',
  31931. name: 'Unfreeze this column',
  31932. callback: function callback() {
  31933. var selectedColumn = this.getSelectedRange().from.col;
  31934. manualColumnFreezePlugin.unfreezeColumn(selectedColumn);
  31935. this.render();
  31936. this.view.wt.wtOverlays.adjustElementsSize(true);
  31937. },
  31938. hidden: function hidden() {
  31939. var selection = this.getSelectedRange();
  31940. var hide = false;
  31941. if (selection === void 0) {
  31942. hide = true;
  31943. } else if (selection.from.col !== selection.to.col || selection.from.col >= this.getSettings().fixedColumnsLeft) {
  31944. hide = true;
  31945. }
  31946. return hide;
  31947. }
  31948. };
  31949. }
  31950. /***/ }),
  31951. /* 242 */
  31952. /***/ (function(module, exports, __webpack_require__) {
  31953. "use strict";
  31954. exports.__esModule = true;
  31955. 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; }; }();
  31956. 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); } };
  31957. var _base = __webpack_require__(12);
  31958. var _base2 = _interopRequireDefault(_base);
  31959. var _plugins = __webpack_require__(5);
  31960. var _array = __webpack_require__(2);
  31961. var _freezeColumn = __webpack_require__(240);
  31962. var _freezeColumn2 = _interopRequireDefault(_freezeColumn);
  31963. var _unfreezeColumn = __webpack_require__(241);
  31964. var _unfreezeColumn2 = _interopRequireDefault(_unfreezeColumn);
  31965. __webpack_require__(299);
  31966. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31967. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31968. 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; }
  31969. 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; }
  31970. var privatePool = new WeakMap();
  31971. /**
  31972. * This plugin allows to manually "freeze" and "unfreeze" a column using an entry in the Context Menu.
  31973. * You can turn it on by setting a `manualColumnFreeze` property to `true`.
  31974. *
  31975. * @plugin ManualColumnFreeze
  31976. * @dependencies ManualColumnMove
  31977. */
  31978. var ManualColumnFreeze = function (_BasePlugin) {
  31979. _inherits(ManualColumnFreeze, _BasePlugin);
  31980. function ManualColumnFreeze(hotInstance) {
  31981. _classCallCheck(this, ManualColumnFreeze);
  31982. var _this = _possibleConstructorReturn(this, (ManualColumnFreeze.__proto__ || Object.getPrototypeOf(ManualColumnFreeze)).call(this, hotInstance));
  31983. privatePool.set(_this, {
  31984. moveByFreeze: false,
  31985. afterFirstUse: false
  31986. });
  31987. /**
  31988. * Original column positions
  31989. *
  31990. * @type {Array}
  31991. */
  31992. _this.frozenColumnsBasePositions = [];
  31993. /**
  31994. * Reference to the `ManualColumnMove` plugin.
  31995. */
  31996. _this.manualColumnMovePlugin = void 0;
  31997. return _this;
  31998. }
  31999. /**
  32000. * Check if the plugin is enabled in the Handsontable settings.
  32001. *
  32002. * @returns {Boolean}
  32003. */
  32004. _createClass(ManualColumnFreeze, [{
  32005. key: 'isEnabled',
  32006. value: function isEnabled() {
  32007. return !!this.hot.getSettings().manualColumnFreeze;
  32008. }
  32009. /**
  32010. * Enable plugin for this Handsontable instance.
  32011. */
  32012. }, {
  32013. key: 'enablePlugin',
  32014. value: function enablePlugin() {
  32015. var _this2 = this;
  32016. if (this.enabled) {
  32017. return;
  32018. }
  32019. this.addHook('afterContextMenuDefaultOptions', function (options) {
  32020. return _this2.addContextMenuEntry(options);
  32021. });
  32022. this.addHook('afterInit', function () {
  32023. return _this2.onAfterInit();
  32024. });
  32025. this.addHook('beforeColumnMove', function (rows, target) {
  32026. return _this2.onBeforeColumnMove(rows, target);
  32027. });
  32028. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'enablePlugin', this).call(this);
  32029. }
  32030. /**
  32031. * Disable plugin for this Handsontable instance.
  32032. */
  32033. }, {
  32034. key: 'disablePlugin',
  32035. value: function disablePlugin() {
  32036. var priv = privatePool.get(this);
  32037. priv.afterFirstUse = false;
  32038. priv.moveByFreeze = false;
  32039. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'disablePlugin', this).call(this);
  32040. }
  32041. /**
  32042. * Updates the plugin to use the latest options you have specified.
  32043. */
  32044. }, {
  32045. key: 'updatePlugin',
  32046. value: function updatePlugin() {
  32047. this.disablePlugin();
  32048. this.enablePlugin();
  32049. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'updatePlugin', this).call(this);
  32050. }
  32051. /**
  32052. * Freeze the given column (add it to fixed columns).
  32053. *
  32054. * @param {Number} column Visual column index.
  32055. */
  32056. }, {
  32057. key: 'freezeColumn',
  32058. value: function freezeColumn(column) {
  32059. var priv = privatePool.get(this);
  32060. var settings = this.hot.getSettings();
  32061. if (!priv.afterFirstUse) {
  32062. priv.afterFirstUse = true;
  32063. }
  32064. if (settings.fixedColumnsLeft === this.hot.countCols() || column <= settings.fixedColumnsLeft - 1) {
  32065. return; // already fixed
  32066. }
  32067. priv.moveByFreeze = true;
  32068. if (column !== this.getMovePlugin().columnsMapper.getValueByIndex(column)) {
  32069. this.frozenColumnsBasePositions[settings.fixedColumnsLeft] = column;
  32070. }
  32071. this.getMovePlugin().moveColumn(column, settings.fixedColumnsLeft++);
  32072. }
  32073. /**
  32074. * Unfreeze the given column (remove it from fixed columns and bring to it's previous position).
  32075. *
  32076. * @param {Number} column Visual column index.
  32077. */
  32078. }, {
  32079. key: 'unfreezeColumn',
  32080. value: function unfreezeColumn(column) {
  32081. var priv = privatePool.get(this);
  32082. var settings = this.hot.getSettings();
  32083. if (!priv.afterFirstUse) {
  32084. priv.afterFirstUse = true;
  32085. }
  32086. if (settings.fixedColumnsLeft <= 0 || column > settings.fixedColumnsLeft - 1) {
  32087. return; // not fixed
  32088. }
  32089. var returnCol = this.getBestColumnReturnPosition(column);
  32090. priv.moveByFreeze = true;
  32091. settings.fixedColumnsLeft--;
  32092. this.getMovePlugin().moveColumn(column, returnCol + 1);
  32093. }
  32094. /**
  32095. * Get the reference to the ManualColumnMove plugin.
  32096. *
  32097. * @private
  32098. * @returns {Object}
  32099. */
  32100. }, {
  32101. key: 'getMovePlugin',
  32102. value: function getMovePlugin() {
  32103. if (!this.manualColumnMovePlugin) {
  32104. this.manualColumnMovePlugin = this.hot.getPlugin('manualColumnMove');
  32105. }
  32106. return this.manualColumnMovePlugin;
  32107. }
  32108. /**
  32109. * Estimates the most fitting return position for unfrozen column.
  32110. *
  32111. * @private
  32112. * @param {Number} column Visual column index.
  32113. */
  32114. }, {
  32115. key: 'getBestColumnReturnPosition',
  32116. value: function getBestColumnReturnPosition(column) {
  32117. var movePlugin = this.getMovePlugin();
  32118. var settings = this.hot.getSettings();
  32119. var i = settings.fixedColumnsLeft;
  32120. var j = movePlugin.columnsMapper.getValueByIndex(i);
  32121. var initialCol = void 0;
  32122. if (this.frozenColumnsBasePositions[column] == null) {
  32123. initialCol = movePlugin.columnsMapper.getValueByIndex(column);
  32124. while (j < initialCol) {
  32125. i++;
  32126. j = movePlugin.columnsMapper.getValueByIndex(i);
  32127. }
  32128. } else {
  32129. initialCol = this.frozenColumnsBasePositions[column];
  32130. this.frozenColumnsBasePositions[column] = void 0;
  32131. while (j <= initialCol) {
  32132. i++;
  32133. j = movePlugin.columnsMapper.getValueByIndex(i);
  32134. }
  32135. i = j;
  32136. }
  32137. return i - 1;
  32138. }
  32139. /**
  32140. * Add the manualColumnFreeze context menu entries.
  32141. *
  32142. * @private
  32143. * @param {Object} options Context menu options.
  32144. */
  32145. }, {
  32146. key: 'addContextMenuEntry',
  32147. value: function addContextMenuEntry(options) {
  32148. options.items.push({ name: '---------' }, (0, _freezeColumn2.default)(this), (0, _unfreezeColumn2.default)(this));
  32149. }
  32150. /**
  32151. * Enabling `manualColumnMove` plugin on `afterInit` hook.
  32152. *
  32153. * @private
  32154. */
  32155. }, {
  32156. key: 'onAfterInit',
  32157. value: function onAfterInit() {
  32158. if (!this.getMovePlugin().isEnabled()) {
  32159. this.getMovePlugin().enablePlugin();
  32160. }
  32161. }
  32162. /**
  32163. * Prevent moving the rows from/to fixed area.
  32164. *
  32165. * @private
  32166. * @param {Array} rows
  32167. * @param {Number} target
  32168. */
  32169. }, {
  32170. key: 'onBeforeColumnMove',
  32171. value: function onBeforeColumnMove(rows, target) {
  32172. var priv = privatePool.get(this);
  32173. if (priv.afterFirstUse && !priv.moveByFreeze) {
  32174. var frozenLen = this.hot.getSettings().fixedColumnsLeft;
  32175. var disallowMoving = target < frozenLen;
  32176. if (!disallowMoving) {
  32177. (0, _array.arrayEach)(rows, function (value, index, array) {
  32178. if (value < frozenLen) {
  32179. disallowMoving = true;
  32180. return false;
  32181. }
  32182. });
  32183. }
  32184. if (disallowMoving) {
  32185. return false;
  32186. }
  32187. }
  32188. if (priv.moveByFreeze) {
  32189. priv.moveByFreeze = false;
  32190. }
  32191. }
  32192. /**
  32193. * Destroy plugin instance.
  32194. */
  32195. }, {
  32196. key: 'destroy',
  32197. value: function destroy() {
  32198. _get(ManualColumnFreeze.prototype.__proto__ || Object.getPrototypeOf(ManualColumnFreeze.prototype), 'destroy', this).call(this);
  32199. }
  32200. }]);
  32201. return ManualColumnFreeze;
  32202. }(_base2.default);
  32203. (0, _plugins.registerPlugin)('manualColumnFreeze', ManualColumnFreeze);
  32204. exports.default = ManualColumnFreeze;
  32205. /***/ }),
  32206. /* 243 */
  32207. /***/ (function(module, exports, __webpack_require__) {
  32208. "use strict";
  32209. exports.__esModule = true;
  32210. 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; }; }();
  32211. var _arrayMapper = __webpack_require__(150);
  32212. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  32213. var _array = __webpack_require__(2);
  32214. var _object = __webpack_require__(1);
  32215. var _number = __webpack_require__(6);
  32216. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32217. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32218. /**
  32219. * @class ColumnsMapper
  32220. * @plugin ManualColumnMove
  32221. */
  32222. var ColumnsMapper = function () {
  32223. function ColumnsMapper(manualColumnMove) {
  32224. _classCallCheck(this, ColumnsMapper);
  32225. /**
  32226. * Instance of ManualColumnMove plugin.
  32227. *
  32228. * @type {ManualColumnMove}
  32229. */
  32230. this.manualColumnMove = manualColumnMove;
  32231. }
  32232. /**
  32233. * Reset current map array and create new one.
  32234. *
  32235. * @param {Number} [length] Custom generated map length.
  32236. */
  32237. _createClass(ColumnsMapper, [{
  32238. key: 'createMap',
  32239. value: function createMap(length) {
  32240. var _this = this;
  32241. var originLength = length === void 0 ? this._arrayMap.length : length;
  32242. this._arrayMap.length = 0;
  32243. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  32244. _this._arrayMap[itemIndex] = itemIndex;
  32245. });
  32246. }
  32247. /**
  32248. * Destroy class.
  32249. */
  32250. }, {
  32251. key: 'destroy',
  32252. value: function destroy() {
  32253. this._arrayMap = null;
  32254. }
  32255. /**
  32256. * Moving elements in columnsMapper.
  32257. *
  32258. * @param {Number} from Column index to move.
  32259. * @param {Number} to Target index.
  32260. */
  32261. }, {
  32262. key: 'moveColumn',
  32263. value: function moveColumn(from, to) {
  32264. var indexToMove = this._arrayMap[from];
  32265. this._arrayMap[from] = null;
  32266. this._arrayMap.splice(to, 0, indexToMove);
  32267. }
  32268. /**
  32269. * Clearing arrayMap from `null` entries.
  32270. */
  32271. }, {
  32272. key: 'clearNull',
  32273. value: function clearNull() {
  32274. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  32275. return i !== null;
  32276. });
  32277. }
  32278. }]);
  32279. return ColumnsMapper;
  32280. }();
  32281. (0, _object.mixin)(ColumnsMapper, _arrayMapper2.default);
  32282. exports.default = ColumnsMapper;
  32283. /***/ }),
  32284. /* 244 */
  32285. /***/ (function(module, exports, __webpack_require__) {
  32286. "use strict";
  32287. exports.__esModule = true;
  32288. 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; }; }();
  32289. 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); } };
  32290. var _base = __webpack_require__(12);
  32291. var _base2 = _interopRequireDefault(_base);
  32292. var _pluginHooks = __webpack_require__(8);
  32293. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  32294. var _array = __webpack_require__(2);
  32295. var _element = __webpack_require__(0);
  32296. var _number = __webpack_require__(6);
  32297. var _eventManager = __webpack_require__(4);
  32298. var _eventManager2 = _interopRequireDefault(_eventManager);
  32299. var _plugins = __webpack_require__(5);
  32300. var _columnsMapper = __webpack_require__(243);
  32301. var _columnsMapper2 = _interopRequireDefault(_columnsMapper);
  32302. var _backlight = __webpack_require__(245);
  32303. var _backlight2 = _interopRequireDefault(_backlight);
  32304. var _guideline = __webpack_require__(246);
  32305. var _guideline2 = _interopRequireDefault(_guideline);
  32306. var _src = __webpack_require__(11);
  32307. __webpack_require__(300);
  32308. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32309. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32310. 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; }
  32311. 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; }
  32312. _pluginHooks2.default.getSingleton().register('beforeColumnMove');
  32313. _pluginHooks2.default.getSingleton().register('afterColumnMove');
  32314. _pluginHooks2.default.getSingleton().register('unmodifyCol');
  32315. var privatePool = new WeakMap();
  32316. var CSS_PLUGIN = 'ht__manualColumnMove';
  32317. var CSS_SHOW_UI = 'show-ui';
  32318. var CSS_ON_MOVING = 'on-moving--columns';
  32319. var CSS_AFTER_SELECTION = 'after-selection--columns';
  32320. /**
  32321. * @plugin ManualColumnMove
  32322. *
  32323. * @description
  32324. * This plugin allows to change columns order.
  32325. *
  32326. * API:
  32327. * - moveColumn - move single column to the new position.
  32328. * - moveColumns - move many columns (as an array of indexes) to the new position.
  32329. *
  32330. * If you want apply visual changes, you have to call manually the render() method on the instance of Handsontable.
  32331. *
  32332. * UI components:
  32333. * - backlight - highlight of selected columns.
  32334. * - guideline - line which shows where rows has been moved.
  32335. *
  32336. * @class ManualColumnMove
  32337. * @plugin ManualColumnMove
  32338. */
  32339. var ManualColumnMove = function (_BasePlugin) {
  32340. _inherits(ManualColumnMove, _BasePlugin);
  32341. function ManualColumnMove(hotInstance) {
  32342. _classCallCheck(this, ManualColumnMove);
  32343. /**
  32344. * Set up WeakMap of plugin to sharing private parameters;
  32345. */
  32346. var _this = _possibleConstructorReturn(this, (ManualColumnMove.__proto__ || Object.getPrototypeOf(ManualColumnMove)).call(this, hotInstance));
  32347. privatePool.set(_this, {
  32348. columnsToMove: [],
  32349. countCols: 0,
  32350. fixedColumns: 0,
  32351. pressed: void 0,
  32352. disallowMoving: void 0,
  32353. target: {
  32354. eventPageX: void 0,
  32355. coords: void 0,
  32356. TD: void 0,
  32357. col: void 0
  32358. }
  32359. });
  32360. /**
  32361. * List of last removed row indexes.
  32362. *
  32363. * @type {Array}
  32364. */
  32365. _this.removedColumns = [];
  32366. /**
  32367. * Object containing visual row indexes mapped to data source indexes.
  32368. *
  32369. * @type {RowsMapper}
  32370. */
  32371. _this.columnsMapper = new _columnsMapper2.default(_this);
  32372. /**
  32373. * Event Manager object.
  32374. *
  32375. * @type {Object}
  32376. */
  32377. _this.eventManager = new _eventManager2.default(_this);
  32378. /**
  32379. * Backlight UI object.
  32380. *
  32381. * @type {Object}
  32382. */
  32383. _this.backlight = new _backlight2.default(hotInstance);
  32384. /**
  32385. * Guideline UI object.
  32386. *
  32387. * @type {Object}
  32388. */
  32389. _this.guideline = new _guideline2.default(hotInstance);
  32390. return _this;
  32391. }
  32392. /**
  32393. * Check if plugin is enabled.
  32394. *
  32395. * @returns {Boolean}
  32396. */
  32397. _createClass(ManualColumnMove, [{
  32398. key: 'isEnabled',
  32399. value: function isEnabled() {
  32400. return !!this.hot.getSettings().manualColumnMove;
  32401. }
  32402. /**
  32403. * Enable the plugin.
  32404. */
  32405. }, {
  32406. key: 'enablePlugin',
  32407. value: function enablePlugin() {
  32408. var _this2 = this;
  32409. if (this.enabled) {
  32410. return;
  32411. }
  32412. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  32413. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  32414. });
  32415. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  32416. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  32417. });
  32418. this.addHook('afterScrollVertically', function () {
  32419. return _this2.onAfterScrollVertically();
  32420. });
  32421. this.addHook('modifyCol', function (row, source) {
  32422. return _this2.onModifyCol(row, source);
  32423. });
  32424. this.addHook('beforeRemoveCol', function (index, amount) {
  32425. return _this2.onBeforeRemoveCol(index, amount);
  32426. });
  32427. this.addHook('afterRemoveCol', function (index, amount) {
  32428. return _this2.onAfterRemoveCol(index, amount);
  32429. });
  32430. this.addHook('afterCreateCol', function (index, amount) {
  32431. return _this2.onAfterCreateCol(index, amount);
  32432. });
  32433. this.addHook('afterLoadData', function (firstTime) {
  32434. return _this2.onAfterLoadData(firstTime);
  32435. });
  32436. this.addHook('unmodifyCol', function (column) {
  32437. return _this2.onUnmodifyCol(column);
  32438. });
  32439. this.registerEvents();
  32440. // TODO: move adding plugin classname to BasePlugin.
  32441. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  32442. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'enablePlugin', this).call(this);
  32443. }
  32444. /**
  32445. * Updates the plugin to use the latest options you have specified.
  32446. */
  32447. }, {
  32448. key: 'updatePlugin',
  32449. value: function updatePlugin() {
  32450. this.disablePlugin();
  32451. this.enablePlugin();
  32452. this.onAfterPluginsInitialized();
  32453. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'updatePlugin', this).call(this);
  32454. }
  32455. /**
  32456. * Disable plugin for this Handsontable instance.
  32457. */
  32458. }, {
  32459. key: 'disablePlugin',
  32460. value: function disablePlugin() {
  32461. var pluginSettings = this.hot.getSettings().manualColumnMove;
  32462. if (Array.isArray(pluginSettings)) {
  32463. this.columnsMapper.clearMap();
  32464. }
  32465. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  32466. this.unregisterEvents();
  32467. this.backlight.destroy();
  32468. this.guideline.destroy();
  32469. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'disablePlugin', this).call(this);
  32470. }
  32471. /**
  32472. * Move a single column.
  32473. *
  32474. * @param {Number} column Visual column index to be moved.
  32475. * @param {Number} target Visual column index being a target for the moved column.
  32476. */
  32477. }, {
  32478. key: 'moveColumn',
  32479. value: function moveColumn(column, target) {
  32480. this.moveColumns([column], target);
  32481. }
  32482. /**
  32483. * Move multiple columns.
  32484. *
  32485. * @param {Array} columns Array of visual column indexes to be moved.
  32486. * @param {Number} target Visual column index being a target for the moved columns.
  32487. */
  32488. }, {
  32489. key: 'moveColumns',
  32490. value: function moveColumns(columns, target) {
  32491. var _this3 = this;
  32492. var priv = privatePool.get(this);
  32493. var beforeColumnHook = this.hot.runHooks('beforeColumnMove', columns, target);
  32494. priv.disallowMoving = !beforeColumnHook;
  32495. if (beforeColumnHook !== false) {
  32496. // first we need to rewrite an visual indexes to physical for save reference after move
  32497. (0, _array.arrayEach)(columns, function (column, index, array) {
  32498. array[index] = _this3.columnsMapper.getValueByIndex(column);
  32499. });
  32500. // next, when we have got an physical indexes, we can move columns
  32501. (0, _array.arrayEach)(columns, function (column, index) {
  32502. var actualPosition = _this3.columnsMapper.getIndexByValue(column);
  32503. if (actualPosition !== target) {
  32504. _this3.columnsMapper.moveColumn(actualPosition, target + index);
  32505. }
  32506. });
  32507. // after moving we have to clear columnsMapper from null entries
  32508. this.columnsMapper.clearNull();
  32509. }
  32510. this.hot.runHooks('afterColumnMove', columns, target);
  32511. }
  32512. /**
  32513. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  32514. * That means that changing the column order using the API won't correct the selection.
  32515. *
  32516. * @private
  32517. * @param {Number} startColumn Visual column index for the start of the selection.
  32518. * @param {Number} endColumn Visual column index for the end of the selection.
  32519. */
  32520. }, {
  32521. key: 'changeSelection',
  32522. value: function changeSelection(startColumn, endColumn) {
  32523. var selection = this.hot.selection;
  32524. var lastRowIndex = this.hot.countRows() - 1;
  32525. selection.setRangeStartOnly(new _src.CellCoords(0, startColumn));
  32526. selection.setRangeEnd(new _src.CellCoords(lastRowIndex, endColumn), false);
  32527. }
  32528. /**
  32529. * Get the sum of the widths of columns in the provided range.
  32530. *
  32531. * @private
  32532. * @param {Number} from Visual column index.
  32533. * @param {Number} to Visual column index.
  32534. * @returns {Number}
  32535. */
  32536. }, {
  32537. key: 'getColumnsWidth',
  32538. value: function getColumnsWidth(from, to) {
  32539. var width = 0;
  32540. for (var i = from; i < to; i++) {
  32541. var columnWidth = 0;
  32542. if (i < 0) {
  32543. columnWidth = this.hot.view.wt.wtTable.getColumnWidth(i) || 0;
  32544. } else {
  32545. columnWidth = this.hot.view.wt.wtTable.getStretchedColumnWidth(i) || 0;
  32546. }
  32547. width += columnWidth;
  32548. }
  32549. return width;
  32550. }
  32551. /**
  32552. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  32553. *
  32554. * @private
  32555. */
  32556. }, {
  32557. key: 'initialSettings',
  32558. value: function initialSettings() {
  32559. var pluginSettings = this.hot.getSettings().manualColumnMove;
  32560. if (Array.isArray(pluginSettings)) {
  32561. this.moveColumns(pluginSettings, 0);
  32562. } else if (pluginSettings !== void 0) {
  32563. this.persistentStateLoad();
  32564. }
  32565. }
  32566. /**
  32567. * Check if the provided column is in the fixedColumnsLeft section.
  32568. *
  32569. * @private
  32570. * @param {Number} column Visual column index to check.
  32571. * @returns {Boolean}
  32572. */
  32573. }, {
  32574. key: 'isFixedColumnsLeft',
  32575. value: function isFixedColumnsLeft(column) {
  32576. return column < this.hot.getSettings().fixedColumnsLeft;
  32577. }
  32578. /**
  32579. * Save the manual column positions to the persistent state.
  32580. *
  32581. * @private
  32582. */
  32583. }, {
  32584. key: 'persistentStateSave',
  32585. value: function persistentStateSave() {
  32586. this.hot.runHooks('persistentStateSave', 'manualColumnMove', this.columnsMapper._arrayMap);
  32587. }
  32588. /**
  32589. * Load the manual column positions from the persistent state.
  32590. *
  32591. * @private
  32592. */
  32593. }, {
  32594. key: 'persistentStateLoad',
  32595. value: function persistentStateLoad() {
  32596. var storedState = {};
  32597. this.hot.runHooks('persistentStateLoad', 'manualColumnMove', storedState);
  32598. if (storedState.value) {
  32599. this.columnsMapper._arrayMap = storedState.value;
  32600. }
  32601. }
  32602. /**
  32603. * Prepare array of indexes based on actual selection.
  32604. *
  32605. * @private
  32606. * @returns {Array}
  32607. */
  32608. }, {
  32609. key: 'prepareColumnsToMoving',
  32610. value: function prepareColumnsToMoving(start, end) {
  32611. var selectedColumns = [];
  32612. (0, _number.rangeEach)(start, end, function (i) {
  32613. selectedColumns.push(i);
  32614. });
  32615. return selectedColumns;
  32616. }
  32617. /**
  32618. * Update the UI visual position.
  32619. *
  32620. * @private
  32621. */
  32622. }, {
  32623. key: 'refreshPositions',
  32624. value: function refreshPositions() {
  32625. var priv = privatePool.get(this);
  32626. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleColumn();
  32627. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleColumn();
  32628. var wtTable = this.hot.view.wt.wtTable;
  32629. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  32630. var scrollLeft = typeof scrollableElement.scrollX === 'number' ? scrollableElement.scrollX : scrollableElement.scrollLeft;
  32631. var tdOffsetLeft = this.hot.view.THEAD.offsetLeft + this.getColumnsWidth(0, priv.coordsColumn);
  32632. var mouseOffsetLeft = priv.target.eventPageX - (priv.rootElementOffset - (scrollableElement.scrollX === void 0 ? scrollLeft : 0));
  32633. var hiderWidth = wtTable.hider.offsetWidth;
  32634. var tbodyOffsetLeft = wtTable.TBODY.offsetLeft;
  32635. var backlightElemMarginLeft = this.backlight.getOffset().left;
  32636. var backlightElemWidth = this.backlight.getSize().width;
  32637. var rowHeaderWidth = 0;
  32638. if (priv.rootElementOffset + wtTable.holder.offsetWidth + scrollLeft < priv.target.eventPageX) {
  32639. if (priv.coordsColumn < priv.countCols) {
  32640. priv.coordsColumn++;
  32641. }
  32642. }
  32643. if (priv.hasRowHeaders) {
  32644. rowHeaderWidth = this.hot.view.wt.wtOverlays.leftOverlay.clone.wtTable.getColumnHeader(-1).offsetWidth;
  32645. }
  32646. if (this.isFixedColumnsLeft(priv.coordsColumn)) {
  32647. tdOffsetLeft += scrollLeft;
  32648. }
  32649. tdOffsetLeft += rowHeaderWidth;
  32650. if (priv.coordsColumn < 0) {
  32651. // if hover on rowHeader
  32652. if (priv.fixedColumns > 0) {
  32653. priv.target.col = 0;
  32654. } else {
  32655. priv.target.col = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  32656. }
  32657. } else if (priv.target.TD.offsetWidth / 2 + tdOffsetLeft <= mouseOffsetLeft) {
  32658. var newCoordsCol = priv.coordsColumn >= priv.countCols ? priv.countCols - 1 : priv.coordsColumn;
  32659. // if hover on right part of TD
  32660. priv.target.col = newCoordsCol + 1;
  32661. // unfortunately first column is bigger than rest
  32662. tdOffsetLeft += priv.target.TD.offsetWidth;
  32663. if (priv.target.col > lastVisible) {
  32664. this.hot.scrollViewportTo(void 0, lastVisible + 1, void 0, true);
  32665. }
  32666. } else {
  32667. // elsewhere on table
  32668. priv.target.col = priv.coordsColumn;
  32669. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  32670. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  32671. }
  32672. }
  32673. if (priv.target.col <= firstVisible && priv.target.col >= priv.fixedColumns) {
  32674. this.hot.scrollViewportTo(void 0, firstVisible - 1);
  32675. }
  32676. var backlightLeft = mouseOffsetLeft;
  32677. var guidelineLeft = tdOffsetLeft;
  32678. if (mouseOffsetLeft + backlightElemWidth + backlightElemMarginLeft >= hiderWidth) {
  32679. // prevent display backlight on the right side of the table
  32680. backlightLeft = hiderWidth - backlightElemWidth - backlightElemMarginLeft;
  32681. } else if (mouseOffsetLeft + backlightElemMarginLeft < tbodyOffsetLeft + rowHeaderWidth) {
  32682. // prevent display backlight on the left side of the table
  32683. backlightLeft = tbodyOffsetLeft + rowHeaderWidth + Math.abs(backlightElemMarginLeft);
  32684. }
  32685. if (tdOffsetLeft >= hiderWidth - 1) {
  32686. // prevent display guideline outside the table
  32687. guidelineLeft = hiderWidth - 1;
  32688. } else if (guidelineLeft === 0) {
  32689. // guideline has got `margin-left: -1px` as default
  32690. guidelineLeft = 1;
  32691. } else if (scrollableElement.scrollX !== void 0 && priv.coordsColumn < priv.fixedColumns) {
  32692. guidelineLeft -= priv.rootElementOffset <= scrollableElement.scrollX ? priv.rootElementOffset : 0;
  32693. }
  32694. this.backlight.setPosition(null, backlightLeft);
  32695. this.guideline.setPosition(null, guidelineLeft);
  32696. }
  32697. /**
  32698. * This method checks arrayMap from columnsMapper and updates the columnsMapper if it's necessary.
  32699. *
  32700. * @private
  32701. */
  32702. }, {
  32703. key: 'updateColumnsMapper',
  32704. value: function updateColumnsMapper() {
  32705. var countCols = this.hot.countSourceCols();
  32706. var columnsMapperLen = this.columnsMapper._arrayMap.length;
  32707. if (columnsMapperLen === 0) {
  32708. this.columnsMapper.createMap(countCols || this.hot.getSettings().startCols);
  32709. } else if (columnsMapperLen < countCols) {
  32710. var diff = countCols - columnsMapperLen;
  32711. this.columnsMapper.insertItems(columnsMapperLen, diff);
  32712. } else if (columnsMapperLen > countCols) {
  32713. var maxIndex = countCols - 1;
  32714. var columnsToRemove = [];
  32715. (0, _array.arrayEach)(this.columnsMapper._arrayMap, function (value, index, array) {
  32716. if (value > maxIndex) {
  32717. columnsToRemove.push(index);
  32718. }
  32719. });
  32720. this.columnsMapper.removeItems(columnsToRemove);
  32721. }
  32722. }
  32723. /**
  32724. * Bind the events used by the plugin.
  32725. *
  32726. * @private
  32727. */
  32728. }, {
  32729. key: 'registerEvents',
  32730. value: function registerEvents() {
  32731. var _this4 = this;
  32732. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  32733. return _this4.onMouseMove(event);
  32734. });
  32735. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  32736. return _this4.onMouseUp();
  32737. });
  32738. }
  32739. /**
  32740. * Unbind the events used by the plugin.
  32741. *
  32742. * @private
  32743. */
  32744. }, {
  32745. key: 'unregisterEvents',
  32746. value: function unregisterEvents() {
  32747. this.eventManager.clear();
  32748. }
  32749. /**
  32750. * Change the behavior of selection / dragging.
  32751. *
  32752. * @private
  32753. * @param {MouseEvent} event `mousedown` event properties.
  32754. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  32755. * @param {HTMLElement} TD Cell represented as HTMLElement.
  32756. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  32757. */
  32758. }, {
  32759. key: 'onBeforeOnCellMouseDown',
  32760. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  32761. var wtTable = this.hot.view.wt.wtTable;
  32762. var isHeaderSelection = this.hot.selection.selectedHeader.cols;
  32763. var selection = this.hot.getSelectedRange();
  32764. var priv = privatePool.get(this);
  32765. var isSortingElement = event.realTarget.className.indexOf('columnSorting') > -1;
  32766. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0 || isSortingElement) {
  32767. priv.pressed = false;
  32768. priv.columnsToMove.length = 0;
  32769. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  32770. return;
  32771. }
  32772. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  32773. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  32774. if (guidelineIsNotReady && backlightIsNotReady) {
  32775. this.guideline.appendTo(wtTable.hider);
  32776. this.backlight.appendTo(wtTable.hider);
  32777. }
  32778. var from = selection.from,
  32779. to = selection.to;
  32780. var start = Math.min(from.col, to.col);
  32781. var end = Math.max(from.col, to.col);
  32782. if (coords.row < 0 && coords.col >= start && coords.col <= end) {
  32783. blockCalculations.column = true;
  32784. priv.pressed = true;
  32785. priv.target.eventPageX = event.pageX;
  32786. priv.coordsColumn = coords.col;
  32787. priv.target.TD = TD;
  32788. priv.target.col = coords.col;
  32789. priv.columnsToMove = this.prepareColumnsToMoving(start, end);
  32790. priv.hasRowHeaders = !!this.hot.getSettings().rowHeaders;
  32791. priv.countCols = this.hot.countCols();
  32792. priv.fixedColumns = this.hot.getSettings().fixedColumnsLeft;
  32793. priv.rootElementOffset = (0, _element.offset)(this.hot.rootElement).left;
  32794. var countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
  32795. var topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
  32796. var fixedColumns = coords.col < priv.fixedColumns;
  32797. var scrollableElement = this.hot.view.wt.wtOverlays.scrollableElement;
  32798. var wrapperIsWindow = scrollableElement.scrollX ? scrollableElement.scrollX - priv.rootElementOffset : 0;
  32799. var mouseOffset = event.layerX - (fixedColumns ? wrapperIsWindow : 0);
  32800. var leftOffset = Math.abs(this.getColumnsWidth(start, coords.col) + mouseOffset);
  32801. this.backlight.setPosition(topPos, this.getColumnsWidth(countColumnsFrom, start) + leftOffset);
  32802. this.backlight.setSize(this.getColumnsWidth(start, end + 1), wtTable.hider.offsetHeight - topPos);
  32803. this.backlight.setOffset(null, leftOffset * -1);
  32804. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  32805. } else {
  32806. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  32807. priv.pressed = false;
  32808. priv.columnsToMove.length = 0;
  32809. }
  32810. }
  32811. /**
  32812. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  32813. *
  32814. * @private
  32815. * @param {MouseEvent} event `mousemove` event properties.
  32816. */
  32817. }, {
  32818. key: 'onMouseMove',
  32819. value: function onMouseMove(event) {
  32820. var priv = privatePool.get(this);
  32821. if (!priv.pressed) {
  32822. return;
  32823. }
  32824. // callback for browser which doesn't supports CSS pointer-event: none
  32825. if (event.realTarget === this.backlight.element) {
  32826. var width = this.backlight.getSize().width;
  32827. this.backlight.setSize(0);
  32828. setTimeout(function () {
  32829. this.backlight.setPosition(width);
  32830. });
  32831. }
  32832. priv.target.eventPageX = event.pageX;
  32833. this.refreshPositions();
  32834. }
  32835. /**
  32836. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  32837. *
  32838. * @private
  32839. * @param {MouseEvent} event `mouseover` event properties.
  32840. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  32841. * @param {HTMLElement} TD Cell represented as HTMLElement.
  32842. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  32843. */
  32844. }, {
  32845. key: 'onBeforeOnCellMouseOver',
  32846. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  32847. var selectedRange = this.hot.getSelectedRange();
  32848. var priv = privatePool.get(this);
  32849. if (!selectedRange || !priv.pressed) {
  32850. return;
  32851. }
  32852. if (priv.columnsToMove.indexOf(coords.col) > -1) {
  32853. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  32854. } else {
  32855. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  32856. }
  32857. blockCalculations.row = true;
  32858. blockCalculations.column = true;
  32859. blockCalculations.cell = true;
  32860. priv.coordsColumn = coords.col;
  32861. priv.target.TD = TD;
  32862. }
  32863. /**
  32864. * `onMouseUp` hook callback.
  32865. *
  32866. * @private
  32867. */
  32868. }, {
  32869. key: 'onMouseUp',
  32870. value: function onMouseUp() {
  32871. var priv = privatePool.get(this);
  32872. priv.coordsColumn = void 0;
  32873. priv.pressed = false;
  32874. priv.backlightWidth = 0;
  32875. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  32876. if (this.hot.selection.selectedHeader.cols) {
  32877. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  32878. }
  32879. if (priv.columnsToMove.length < 1 || priv.target.col === void 0 || priv.columnsToMove.indexOf(priv.target.col) > -1) {
  32880. return;
  32881. }
  32882. this.moveColumns(priv.columnsToMove, priv.target.col);
  32883. this.persistentStateSave();
  32884. this.hot.render();
  32885. this.hot.view.wt.wtOverlays.adjustElementsSize(true);
  32886. if (!priv.disallowMoving) {
  32887. var selectionStart = this.columnsMapper.getIndexByValue(priv.columnsToMove[0]);
  32888. var selectionEnd = this.columnsMapper.getIndexByValue(priv.columnsToMove[priv.columnsToMove.length - 1]);
  32889. this.changeSelection(selectionStart, selectionEnd);
  32890. }
  32891. priv.columnsToMove.length = 0;
  32892. }
  32893. /**
  32894. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  32895. *
  32896. * @private
  32897. */
  32898. }, {
  32899. key: 'onAfterScrollVertically',
  32900. value: function onAfterScrollVertically() {
  32901. var wtTable = this.hot.view.wt.wtTable;
  32902. var headerHeight = wtTable.getColumnHeaderHeight(0) + 1;
  32903. var scrollTop = wtTable.holder.scrollTop;
  32904. var posTop = headerHeight + scrollTop;
  32905. this.backlight.setPosition(posTop);
  32906. this.backlight.setSize(null, wtTable.hider.offsetHeight - posTop);
  32907. }
  32908. /**
  32909. * `afterCreateCol` hook callback.
  32910. *
  32911. * @private
  32912. * @param {Number} index Visual index of the created column.
  32913. * @param {Number} amount Amount of created columns.
  32914. */
  32915. }, {
  32916. key: 'onAfterCreateCol',
  32917. value: function onAfterCreateCol(index, amount) {
  32918. this.columnsMapper.shiftItems(index, amount);
  32919. }
  32920. /**
  32921. * On before remove column listener.
  32922. *
  32923. * @private
  32924. * @param {Number} index Visual column index.
  32925. * @param {Number} amount Defines how many columns removed.
  32926. */
  32927. }, {
  32928. key: 'onBeforeRemoveCol',
  32929. value: function onBeforeRemoveCol(index, amount) {
  32930. var _this5 = this;
  32931. this.removedColumns.length = 0;
  32932. if (index !== false) {
  32933. // Collect physical row index.
  32934. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  32935. _this5.removedColumns.push(_this5.hot.runHooks('modifyCol', removedIndex, _this5.pluginName));
  32936. });
  32937. }
  32938. }
  32939. /**
  32940. * `afterRemoveCol` hook callback.
  32941. *
  32942. * @private
  32943. * @param {Number} index Visual column index of the removed column.
  32944. * @param {Number} amount Amount of removed columns.
  32945. */
  32946. }, {
  32947. key: 'onAfterRemoveCol',
  32948. value: function onAfterRemoveCol(index, amount) {
  32949. this.columnsMapper.unshiftItems(this.removedColumns);
  32950. }
  32951. /**
  32952. * `afterLoadData` hook callback.
  32953. *
  32954. * @private
  32955. * @param {Boolean} firstTime True if that was loading data during the initialization.
  32956. */
  32957. }, {
  32958. key: 'onAfterLoadData',
  32959. value: function onAfterLoadData(firstTime) {
  32960. this.updateColumnsMapper();
  32961. }
  32962. /**
  32963. * 'modifyRow' hook callback.
  32964. *
  32965. * @private
  32966. * @param {Number} column Visual column index.
  32967. * @returns {Number} Physical column index.
  32968. */
  32969. }, {
  32970. key: 'onModifyCol',
  32971. value: function onModifyCol(column, source) {
  32972. if (source !== this.pluginName) {
  32973. // ugly fix for try to insert new, needed columns after pasting data
  32974. var columnInMapper = this.columnsMapper.getValueByIndex(column);
  32975. column = columnInMapper === null ? column : columnInMapper;
  32976. }
  32977. return column;
  32978. }
  32979. /**
  32980. * 'unmodifyCol' hook callback.
  32981. *
  32982. * @private
  32983. * @param {Number} column Physical column index.
  32984. * @returns {Number} Visual column index.
  32985. */
  32986. }, {
  32987. key: 'onUnmodifyCol',
  32988. value: function onUnmodifyCol(column) {
  32989. var indexInMapper = this.columnsMapper.getIndexByValue(column);
  32990. return indexInMapper === null ? column : indexInMapper;
  32991. }
  32992. /**
  32993. * `afterPluginsInitialized` hook callback.
  32994. *
  32995. * @private
  32996. */
  32997. }, {
  32998. key: 'onAfterPluginsInitialized',
  32999. value: function onAfterPluginsInitialized() {
  33000. this.updateColumnsMapper();
  33001. this.initialSettings();
  33002. this.backlight.build();
  33003. this.guideline.build();
  33004. }
  33005. /**
  33006. * Destroy plugin instance.
  33007. */
  33008. }, {
  33009. key: 'destroy',
  33010. value: function destroy() {
  33011. this.backlight.destroy();
  33012. this.guideline.destroy();
  33013. _get(ManualColumnMove.prototype.__proto__ || Object.getPrototypeOf(ManualColumnMove.prototype), 'destroy', this).call(this);
  33014. }
  33015. }]);
  33016. return ManualColumnMove;
  33017. }(_base2.default);
  33018. (0, _plugins.registerPlugin)('ManualColumnMove', ManualColumnMove);
  33019. exports.default = ManualColumnMove;
  33020. /***/ }),
  33021. /* 245 */
  33022. /***/ (function(module, exports, __webpack_require__) {
  33023. "use strict";
  33024. exports.__esModule = true;
  33025. 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; }; }();
  33026. 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); } };
  33027. var _base = __webpack_require__(151);
  33028. var _base2 = _interopRequireDefault(_base);
  33029. var _element = __webpack_require__(0);
  33030. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33031. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33032. 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; }
  33033. 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; }
  33034. var CSS_CLASSNAME = 'ht__manualColumnMove--backlight';
  33035. /**
  33036. * @class BacklightUI
  33037. * @util
  33038. */
  33039. var BacklightUI = function (_BaseUI) {
  33040. _inherits(BacklightUI, _BaseUI);
  33041. function BacklightUI() {
  33042. _classCallCheck(this, BacklightUI);
  33043. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  33044. }
  33045. _createClass(BacklightUI, [{
  33046. key: 'build',
  33047. /**
  33048. * Custom className on build process.
  33049. */
  33050. value: function build() {
  33051. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  33052. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  33053. }
  33054. }]);
  33055. return BacklightUI;
  33056. }(_base2.default);
  33057. exports.default = BacklightUI;
  33058. /***/ }),
  33059. /* 246 */
  33060. /***/ (function(module, exports, __webpack_require__) {
  33061. "use strict";
  33062. exports.__esModule = true;
  33063. 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; }; }();
  33064. 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); } };
  33065. var _base = __webpack_require__(151);
  33066. var _base2 = _interopRequireDefault(_base);
  33067. var _element = __webpack_require__(0);
  33068. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33069. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33070. 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; }
  33071. 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; }
  33072. var CSS_CLASSNAME = 'ht__manualColumnMove--guideline';
  33073. /**
  33074. * @class GuidelineUI
  33075. * @util
  33076. */
  33077. var GuidelineUI = function (_BaseUI) {
  33078. _inherits(GuidelineUI, _BaseUI);
  33079. function GuidelineUI() {
  33080. _classCallCheck(this, GuidelineUI);
  33081. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  33082. }
  33083. _createClass(GuidelineUI, [{
  33084. key: 'build',
  33085. /**
  33086. * Custom className on build process.
  33087. */
  33088. value: function build() {
  33089. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  33090. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  33091. }
  33092. }]);
  33093. return GuidelineUI;
  33094. }(_base2.default);
  33095. exports.default = GuidelineUI;
  33096. /***/ }),
  33097. /* 247 */
  33098. /***/ (function(module, exports, __webpack_require__) {
  33099. "use strict";
  33100. exports.__esModule = true;
  33101. 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; }; }();
  33102. 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); } };
  33103. var _base = __webpack_require__(12);
  33104. var _base2 = _interopRequireDefault(_base);
  33105. var _element = __webpack_require__(0);
  33106. var _eventManager = __webpack_require__(4);
  33107. var _eventManager2 = _interopRequireDefault(_eventManager);
  33108. var _event = __webpack_require__(7);
  33109. var _array = __webpack_require__(2);
  33110. var _number = __webpack_require__(6);
  33111. var _plugins = __webpack_require__(5);
  33112. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33113. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33114. 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; }
  33115. 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; }
  33116. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  33117. /**
  33118. * @description
  33119. * ManualColumnResize Plugin.
  33120. *
  33121. * Has 2 UI components:
  33122. * - handle - the draggable element that sets the desired width of the column.
  33123. * - guide - the helper guide that shows the desired width as a vertical guide.
  33124. *
  33125. * @plugin ManualColumnResize
  33126. */
  33127. var ManualColumnResize = function (_BasePlugin) {
  33128. _inherits(ManualColumnResize, _BasePlugin);
  33129. function ManualColumnResize(hotInstance) {
  33130. _classCallCheck(this, ManualColumnResize);
  33131. var _this = _possibleConstructorReturn(this, (ManualColumnResize.__proto__ || Object.getPrototypeOf(ManualColumnResize)).call(this, hotInstance));
  33132. _this.currentTH = null;
  33133. _this.currentCol = null;
  33134. _this.selectedCols = [];
  33135. _this.currentWidth = null;
  33136. _this.newSize = null;
  33137. _this.startY = null;
  33138. _this.startWidth = null;
  33139. _this.startOffset = null;
  33140. _this.handle = document.createElement('DIV');
  33141. _this.guide = document.createElement('DIV');
  33142. _this.eventManager = new _eventManager2.default(_this);
  33143. _this.pressed = null;
  33144. _this.dblclick = 0;
  33145. _this.autoresizeTimeout = null;
  33146. _this.manualColumnWidths = [];
  33147. (0, _element.addClass)(_this.handle, 'manualColumnResizer');
  33148. (0, _element.addClass)(_this.guide, 'manualColumnResizerGuide');
  33149. return _this;
  33150. }
  33151. /**
  33152. * Check if the plugin is enabled in the handsontable settings.
  33153. *
  33154. * @returns {Boolean}
  33155. */
  33156. _createClass(ManualColumnResize, [{
  33157. key: 'isEnabled',
  33158. value: function isEnabled() {
  33159. return this.hot.getSettings().manualColumnResize;
  33160. }
  33161. /**
  33162. * Enable plugin for this Handsontable instance.
  33163. */
  33164. }, {
  33165. key: 'enablePlugin',
  33166. value: function enablePlugin() {
  33167. var _this2 = this;
  33168. if (this.enabled) {
  33169. return;
  33170. }
  33171. this.manualColumnWidths = [];
  33172. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  33173. var loadedManualColumnWidths = this.loadManualColumnWidths();
  33174. this.addHook('modifyColWidth', function (width, col) {
  33175. return _this2.onModifyColWidth(width, col);
  33176. });
  33177. this.addHook('beforeStretchingColumnWidth', function (stretchedWidth, column) {
  33178. return _this2.onBeforeStretchingColumnWidth(stretchedWidth, column);
  33179. });
  33180. this.addHook('beforeColumnResize', function (currentColumn, newSize, isDoubleClick) {
  33181. return _this2.onBeforeColumnResize(currentColumn, newSize, isDoubleClick);
  33182. });
  33183. if (typeof loadedManualColumnWidths != 'undefined') {
  33184. this.manualColumnWidths = loadedManualColumnWidths;
  33185. } else if (Array.isArray(initialColumnWidth)) {
  33186. this.manualColumnWidths = initialColumnWidth;
  33187. } else {
  33188. this.manualColumnWidths = [];
  33189. }
  33190. // Handsontable.hooks.register('beforeColumnResize');
  33191. // Handsontable.hooks.register('afterColumnResize');
  33192. this.bindEvents();
  33193. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'enablePlugin', this).call(this);
  33194. }
  33195. /**
  33196. * Updates the plugin to use the latest options you have specified.
  33197. */
  33198. }, {
  33199. key: 'updatePlugin',
  33200. value: function updatePlugin() {
  33201. var initialColumnWidth = this.hot.getSettings().manualColumnResize;
  33202. if (Array.isArray(initialColumnWidth)) {
  33203. this.manualColumnWidths = initialColumnWidth;
  33204. } else if (!initialColumnWidth) {
  33205. this.manualColumnWidths = [];
  33206. }
  33207. }
  33208. /**
  33209. * Disable plugin for this Handsontable instance.
  33210. */
  33211. }, {
  33212. key: 'disablePlugin',
  33213. value: function disablePlugin() {
  33214. _get(ManualColumnResize.prototype.__proto__ || Object.getPrototypeOf(ManualColumnResize.prototype), 'disablePlugin', this).call(this);
  33215. }
  33216. /**
  33217. * Save the current sizes using the persistentState plugin.
  33218. */
  33219. }, {
  33220. key: 'saveManualColumnWidths',
  33221. value: function saveManualColumnWidths() {
  33222. this.hot.runHooks('persistentStateSave', 'manualColumnWidths', this.manualColumnWidths);
  33223. }
  33224. /**
  33225. * Load the previously saved sizes using the persistentState plugin.
  33226. *
  33227. * @returns {Array}
  33228. */
  33229. }, {
  33230. key: 'loadManualColumnWidths',
  33231. value: function loadManualColumnWidths() {
  33232. var storedState = {};
  33233. this.hot.runHooks('persistentStateLoad', 'manualColumnWidths', storedState);
  33234. return storedState.value;
  33235. }
  33236. /**
  33237. * Set the resize handle position.
  33238. *
  33239. * @param {HTMLCellElement} TH TH HTML element.
  33240. */
  33241. }, {
  33242. key: 'setupHandlePosition',
  33243. value: function setupHandlePosition(TH) {
  33244. var _this3 = this;
  33245. if (!TH.parentNode) {
  33246. return false;
  33247. }
  33248. this.currentTH = TH;
  33249. var col = this.hot.view.wt.wtTable.getCoords(TH).col; // getCoords returns CellCoords
  33250. var headerHeight = (0, _element.outerHeight)(this.currentTH);
  33251. if (col >= 0) {
  33252. // if not col header
  33253. var box = this.currentTH.getBoundingClientRect();
  33254. this.currentCol = col;
  33255. this.selectedCols = [];
  33256. if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.cols) {
  33257. var _hot$getSelectedRange = this.hot.getSelectedRange(),
  33258. from = _hot$getSelectedRange.from,
  33259. to = _hot$getSelectedRange.to;
  33260. var start = from.col;
  33261. var end = to.col;
  33262. if (start >= end) {
  33263. start = to.col;
  33264. end = from.col;
  33265. }
  33266. if (this.currentCol >= start && this.currentCol <= end) {
  33267. (0, _number.rangeEach)(start, end, function (i) {
  33268. return _this3.selectedCols.push(i);
  33269. });
  33270. } else {
  33271. this.selectedCols.push(this.currentCol);
  33272. }
  33273. } else {
  33274. this.selectedCols.push(this.currentCol);
  33275. }
  33276. this.startOffset = box.left - 6;
  33277. this.startWidth = parseInt(box.width, 10);
  33278. this.handle.style.top = box.top + 'px';
  33279. this.handle.style.left = this.startOffset + this.startWidth + 'px';
  33280. this.handle.style.height = headerHeight + 'px';
  33281. this.hot.rootElement.appendChild(this.handle);
  33282. }
  33283. }
  33284. /**
  33285. * Refresh the resize handle position.
  33286. */
  33287. }, {
  33288. key: 'refreshHandlePosition',
  33289. value: function refreshHandlePosition() {
  33290. this.handle.style.left = this.startOffset + this.currentWidth + 'px';
  33291. }
  33292. /**
  33293. * Set the resize guide position.
  33294. */
  33295. }, {
  33296. key: 'setupGuidePosition',
  33297. value: function setupGuidePosition() {
  33298. var handleHeight = parseInt((0, _element.outerHeight)(this.handle), 10);
  33299. var handleBottomPosition = parseInt(this.handle.style.top, 10) + handleHeight;
  33300. var maximumVisibleElementHeight = parseInt(this.hot.view.maximumVisibleElementHeight(0), 10);
  33301. (0, _element.addClass)(this.handle, 'active');
  33302. (0, _element.addClass)(this.guide, 'active');
  33303. this.guide.style.top = handleBottomPosition + 'px';
  33304. this.guide.style.left = this.handle.style.left;
  33305. this.guide.style.height = maximumVisibleElementHeight - handleHeight + 'px';
  33306. this.hot.rootElement.appendChild(this.guide);
  33307. }
  33308. /**
  33309. * Refresh the resize guide position.
  33310. */
  33311. }, {
  33312. key: 'refreshGuidePosition',
  33313. value: function refreshGuidePosition() {
  33314. this.guide.style.left = this.handle.style.left;
  33315. }
  33316. /**
  33317. * Hide both the resize handle and resize guide.
  33318. */
  33319. }, {
  33320. key: 'hideHandleAndGuide',
  33321. value: function hideHandleAndGuide() {
  33322. (0, _element.removeClass)(this.handle, 'active');
  33323. (0, _element.removeClass)(this.guide, 'active');
  33324. }
  33325. /**
  33326. * Check if provided element is considered a column header.
  33327. *
  33328. * @param {HTMLElement} element HTML element.
  33329. * @returns {Boolean}
  33330. */
  33331. }, {
  33332. key: 'checkIfColumnHeader',
  33333. value: function checkIfColumnHeader(element) {
  33334. if (element != this.hot.rootElement) {
  33335. var parent = element.parentNode;
  33336. if (parent.tagName === 'THEAD') {
  33337. return true;
  33338. }
  33339. return this.checkIfColumnHeader(parent);
  33340. }
  33341. return false;
  33342. }
  33343. /**
  33344. * Get the TH element from the provided element.
  33345. *
  33346. * @param {HTMLElement} element HTML element.
  33347. * @returns {HTMLElement}
  33348. */
  33349. }, {
  33350. key: 'getTHFromTargetElement',
  33351. value: function getTHFromTargetElement(element) {
  33352. if (element.tagName != 'TABLE') {
  33353. if (element.tagName == 'TH') {
  33354. return element;
  33355. }
  33356. return this.getTHFromTargetElement(element.parentNode);
  33357. }
  33358. return null;
  33359. }
  33360. /**
  33361. * 'mouseover' event callback - set the handle position.
  33362. *
  33363. * @private
  33364. * @param {MouseEvent} event
  33365. */
  33366. }, {
  33367. key: 'onMouseOver',
  33368. value: function onMouseOver(event) {
  33369. if (this.checkIfColumnHeader(event.target)) {
  33370. var th = this.getTHFromTargetElement(event.target);
  33371. if (!th) {
  33372. return;
  33373. }
  33374. var colspan = th.getAttribute('colspan');
  33375. if (th && (colspan === null || colspan === 1)) {
  33376. if (!this.pressed) {
  33377. this.setupHandlePosition(th);
  33378. }
  33379. }
  33380. }
  33381. }
  33382. /**
  33383. * Auto-size row after doubleclick - callback.
  33384. *
  33385. * @private
  33386. */
  33387. }, {
  33388. key: 'afterMouseDownTimeout',
  33389. value: function afterMouseDownTimeout() {
  33390. var _this4 = this;
  33391. var render = function render() {
  33392. _this4.hot.forceFullRender = true;
  33393. _this4.hot.view.render(); // updates all
  33394. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  33395. };
  33396. var resize = function resize(selectedCol, forceRender) {
  33397. var hookNewSize = _this4.hot.runHooks('beforeColumnResize', selectedCol, _this4.newSize, true);
  33398. if (hookNewSize !== void 0) {
  33399. _this4.newSize = hookNewSize;
  33400. }
  33401. if (_this4.hot.getSettings().stretchH === 'all') {
  33402. _this4.clearManualSize(selectedCol);
  33403. } else {
  33404. _this4.setManualSize(selectedCol, _this4.newSize); // double click sets by auto row size plugin
  33405. }
  33406. if (forceRender) {
  33407. render();
  33408. }
  33409. _this4.saveManualColumnWidths();
  33410. _this4.hot.runHooks('afterColumnResize', selectedCol, _this4.newSize, true);
  33411. };
  33412. if (this.dblclick >= 2) {
  33413. var selectedColsLength = this.selectedCols.length;
  33414. if (selectedColsLength > 1) {
  33415. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  33416. resize(selectedCol);
  33417. });
  33418. render();
  33419. } else {
  33420. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  33421. resize(selectedCol, true);
  33422. });
  33423. }
  33424. }
  33425. this.dblclick = 0;
  33426. this.autoresizeTimeout = null;
  33427. }
  33428. /**
  33429. * 'mousedown' event callback.
  33430. *
  33431. * @private
  33432. * @param {MouseEvent} e
  33433. */
  33434. }, {
  33435. key: 'onMouseDown',
  33436. value: function onMouseDown(event) {
  33437. var _this5 = this;
  33438. if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
  33439. this.setupGuidePosition();
  33440. this.pressed = this.hot;
  33441. if (this.autoresizeTimeout === null) {
  33442. this.autoresizeTimeout = setTimeout(function () {
  33443. return _this5.afterMouseDownTimeout();
  33444. }, 500);
  33445. this.hot._registerTimeout(this.autoresizeTimeout);
  33446. }
  33447. this.dblclick++;
  33448. this.startX = (0, _event.pageX)(event);
  33449. this.newSize = this.startWidth;
  33450. }
  33451. }
  33452. /**
  33453. * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width.
  33454. *
  33455. * @private
  33456. * @param {MouseEvent} e
  33457. */
  33458. }, {
  33459. key: 'onMouseMove',
  33460. value: function onMouseMove(event) {
  33461. var _this6 = this;
  33462. if (this.pressed) {
  33463. this.currentWidth = this.startWidth + ((0, _event.pageX)(event) - this.startX);
  33464. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  33465. _this6.newSize = _this6.setManualSize(selectedCol, _this6.currentWidth);
  33466. });
  33467. this.refreshHandlePosition();
  33468. this.refreshGuidePosition();
  33469. }
  33470. }
  33471. /**
  33472. * 'mouseup' event callback - apply the column resizing.
  33473. *
  33474. * @private
  33475. * @param {MouseEvent} e
  33476. */
  33477. }, {
  33478. key: 'onMouseUp',
  33479. value: function onMouseUp(event) {
  33480. var _this7 = this;
  33481. var render = function render() {
  33482. _this7.hot.forceFullRender = true;
  33483. _this7.hot.view.render(); // updates all
  33484. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  33485. };
  33486. var resize = function resize(selectedCol, forceRender) {
  33487. _this7.hot.runHooks('beforeColumnResize', selectedCol, _this7.newSize);
  33488. if (forceRender) {
  33489. render();
  33490. }
  33491. _this7.saveManualColumnWidths();
  33492. _this7.hot.runHooks('afterColumnResize', selectedCol, _this7.newSize);
  33493. };
  33494. if (this.pressed) {
  33495. this.hideHandleAndGuide();
  33496. this.pressed = false;
  33497. if (this.newSize != this.startWidth) {
  33498. var selectedColsLength = this.selectedCols.length;
  33499. if (selectedColsLength > 1) {
  33500. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  33501. resize(selectedCol);
  33502. });
  33503. render();
  33504. } else {
  33505. (0, _array.arrayEach)(this.selectedCols, function (selectedCol) {
  33506. resize(selectedCol, true);
  33507. });
  33508. }
  33509. }
  33510. this.setupHandlePosition(this.currentTH);
  33511. }
  33512. }
  33513. /**
  33514. * Bind the mouse events.
  33515. *
  33516. * @private
  33517. */
  33518. }, {
  33519. key: 'bindEvents',
  33520. value: function bindEvents() {
  33521. var _this8 = this;
  33522. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  33523. return _this8.onMouseOver(e);
  33524. });
  33525. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  33526. return _this8.onMouseDown(e);
  33527. });
  33528. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  33529. return _this8.onMouseMove(e);
  33530. });
  33531. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  33532. return _this8.onMouseUp(e);
  33533. });
  33534. }
  33535. /**
  33536. * Cache the current column width.
  33537. *
  33538. * @param {Number} column Visual column index.
  33539. * @param {Number} width Column width.
  33540. * @returns {Number}
  33541. */
  33542. }, {
  33543. key: 'setManualSize',
  33544. value: function setManualSize(column, width) {
  33545. width = Math.max(width, 20);
  33546. /**
  33547. * We need to run col through modifyCol hook, in case the order of displayed columns is different than the order
  33548. * in data source. For instance, this order can be modified by manualColumnMove plugin.
  33549. */
  33550. column = this.hot.runHooks('modifyCol', column);
  33551. this.manualColumnWidths[column] = width;
  33552. return width;
  33553. }
  33554. /**
  33555. * Clear cache for the current column index.
  33556. *
  33557. * @param {Number} column Visual column index.
  33558. */
  33559. }, {
  33560. key: 'clearManualSize',
  33561. value: function clearManualSize(column) {
  33562. column = this.hot.runHooks('modifyCol', column);
  33563. this.manualColumnWidths[column] = void 0;
  33564. }
  33565. /**
  33566. * Modify the provided column width, based on the plugin settings
  33567. *
  33568. * @private
  33569. * @param {Number} width Column width.
  33570. * @param {Number} column Visual column index.
  33571. * @returns {Number}
  33572. */
  33573. }, {
  33574. key: 'onModifyColWidth',
  33575. value: function onModifyColWidth(width, column) {
  33576. if (this.enabled) {
  33577. column = this.hot.runHooks('modifyCol', column);
  33578. if (this.hot.getSettings().manualColumnResize && this.manualColumnWidths[column]) {
  33579. return this.manualColumnWidths[column];
  33580. }
  33581. }
  33582. return width;
  33583. }
  33584. /**
  33585. * Modify the provided column stretched width. This hook decides if specified column should be stretched or not.
  33586. *
  33587. * @private
  33588. * @param {Number} stretchedWidth Stretched width.
  33589. * @param {Number} column Physical column index.
  33590. * @returns {Number}
  33591. */
  33592. }, {
  33593. key: 'onBeforeStretchingColumnWidth',
  33594. value: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  33595. var width = this.manualColumnWidths[column];
  33596. if (width === void 0) {
  33597. width = stretchedWidth;
  33598. }
  33599. return width;
  33600. }
  33601. /**
  33602. * `beforeColumnResize` hook callback.
  33603. *
  33604. * @private
  33605. * @param {Number} currentColumn Index of the resized column.
  33606. * @param {Number} newSize Calculated new column width.
  33607. * @param {Boolean} isDoubleClick Flag that determines whether there was a double-click.
  33608. */
  33609. }, {
  33610. key: 'onBeforeColumnResize',
  33611. value: function onBeforeColumnResize() {
  33612. // clear the header height cache information
  33613. this.hot.view.wt.wtViewport.hasOversizedColumnHeadersMarked = {};
  33614. }
  33615. }]);
  33616. return ManualColumnResize;
  33617. }(_base2.default);
  33618. (0, _plugins.registerPlugin)('manualColumnResize', ManualColumnResize);
  33619. exports.default = ManualColumnResize;
  33620. /***/ }),
  33621. /* 248 */
  33622. /***/ (function(module, exports, __webpack_require__) {
  33623. "use strict";
  33624. exports.__esModule = true;
  33625. 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; }; }();
  33626. 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); } };
  33627. var _base = __webpack_require__(12);
  33628. var _base2 = _interopRequireDefault(_base);
  33629. var _pluginHooks = __webpack_require__(8);
  33630. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  33631. var _array = __webpack_require__(2);
  33632. var _element = __webpack_require__(0);
  33633. var _number = __webpack_require__(6);
  33634. var _eventManager = __webpack_require__(4);
  33635. var _eventManager2 = _interopRequireDefault(_eventManager);
  33636. var _plugins = __webpack_require__(5);
  33637. var _rowsMapper = __webpack_require__(249);
  33638. var _rowsMapper2 = _interopRequireDefault(_rowsMapper);
  33639. var _backlight = __webpack_require__(250);
  33640. var _backlight2 = _interopRequireDefault(_backlight);
  33641. var _guideline = __webpack_require__(251);
  33642. var _guideline2 = _interopRequireDefault(_guideline);
  33643. var _src = __webpack_require__(11);
  33644. __webpack_require__(301);
  33645. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  33646. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33647. 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; }
  33648. 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; }
  33649. _pluginHooks2.default.getSingleton().register('beforeRowMove');
  33650. _pluginHooks2.default.getSingleton().register('afterRowMove');
  33651. _pluginHooks2.default.getSingleton().register('unmodifyRow');
  33652. var privatePool = new WeakMap();
  33653. var CSS_PLUGIN = 'ht__manualRowMove';
  33654. var CSS_SHOW_UI = 'show-ui';
  33655. var CSS_ON_MOVING = 'on-moving--rows';
  33656. var CSS_AFTER_SELECTION = 'after-selection--rows';
  33657. /**
  33658. * @plugin ManualRowMove
  33659. *
  33660. * @description
  33661. * This plugin allows to change rows order.
  33662. *
  33663. * API:
  33664. * - moveRow - move single row to the new position.
  33665. * - moveRows - move many rows (as an array of indexes) to the new position.
  33666. *
  33667. * If you want apply visual changes, you have to call manually the render() method on the instance of handsontable.
  33668. *
  33669. * UI components:
  33670. * - backlight - highlight of selected rows.
  33671. * - guideline - line which shows where rows has been moved.
  33672. *
  33673. * @class ManualRowMove
  33674. * @plugin ManualRowMove
  33675. */
  33676. var ManualRowMove = function (_BasePlugin) {
  33677. _inherits(ManualRowMove, _BasePlugin);
  33678. function ManualRowMove(hotInstance) {
  33679. _classCallCheck(this, ManualRowMove);
  33680. /**
  33681. * Set up WeakMap of plugin to sharing private parameters;
  33682. */
  33683. var _this = _possibleConstructorReturn(this, (ManualRowMove.__proto__ || Object.getPrototypeOf(ManualRowMove)).call(this, hotInstance));
  33684. privatePool.set(_this, {
  33685. rowsToMove: [],
  33686. pressed: void 0,
  33687. disallowMoving: void 0,
  33688. target: {
  33689. eventPageY: void 0,
  33690. coords: void 0,
  33691. TD: void 0,
  33692. row: void 0
  33693. }
  33694. });
  33695. /**
  33696. * List of last removed row indexes.
  33697. *
  33698. * @type {Array}
  33699. */
  33700. _this.removedRows = [];
  33701. /**
  33702. * Object containing visual row indexes mapped to data source indexes.
  33703. *
  33704. * @type {RowsMapper}
  33705. */
  33706. _this.rowsMapper = new _rowsMapper2.default(_this);
  33707. /**
  33708. * Event Manager object.
  33709. *
  33710. * @type {Object}
  33711. */
  33712. _this.eventManager = new _eventManager2.default(_this);
  33713. /**
  33714. * Backlight UI object.
  33715. *
  33716. * @type {Object}
  33717. */
  33718. _this.backlight = new _backlight2.default(hotInstance);
  33719. /**
  33720. * Guideline UI object.
  33721. *
  33722. * @type {Object}
  33723. */
  33724. _this.guideline = new _guideline2.default(hotInstance);
  33725. return _this;
  33726. }
  33727. /**
  33728. * Check if plugin is enabled.
  33729. *
  33730. * @returns {Boolean}
  33731. */
  33732. _createClass(ManualRowMove, [{
  33733. key: 'isEnabled',
  33734. value: function isEnabled() {
  33735. return !!this.hot.getSettings().manualRowMove;
  33736. }
  33737. /**
  33738. * Enable the plugin.
  33739. */
  33740. }, {
  33741. key: 'enablePlugin',
  33742. value: function enablePlugin() {
  33743. var _this2 = this;
  33744. if (this.enabled) {
  33745. return;
  33746. }
  33747. this.addHook('beforeOnCellMouseDown', function (event, coords, TD, blockCalculations) {
  33748. return _this2.onBeforeOnCellMouseDown(event, coords, TD, blockCalculations);
  33749. });
  33750. this.addHook('beforeOnCellMouseOver', function (event, coords, TD, blockCalculations) {
  33751. return _this2.onBeforeOnCellMouseOver(event, coords, TD, blockCalculations);
  33752. });
  33753. this.addHook('afterScrollHorizontally', function () {
  33754. return _this2.onAfterScrollHorizontally();
  33755. });
  33756. this.addHook('modifyRow', function (row, source) {
  33757. return _this2.onModifyRow(row, source);
  33758. });
  33759. this.addHook('beforeRemoveRow', function (index, amount) {
  33760. return _this2.onBeforeRemoveRow(index, amount);
  33761. });
  33762. this.addHook('afterRemoveRow', function (index, amount) {
  33763. return _this2.onAfterRemoveRow(index, amount);
  33764. });
  33765. this.addHook('afterCreateRow', function (index, amount) {
  33766. return _this2.onAfterCreateRow(index, amount);
  33767. });
  33768. this.addHook('afterLoadData', function (firstTime) {
  33769. return _this2.onAfterLoadData(firstTime);
  33770. });
  33771. this.addHook('beforeColumnSort', function (column, order) {
  33772. return _this2.onBeforeColumnSort(column, order);
  33773. });
  33774. this.addHook('unmodifyRow', function (row) {
  33775. return _this2.onUnmodifyRow(row);
  33776. });
  33777. this.registerEvents();
  33778. // TODO: move adding plugin classname to BasePlugin.
  33779. (0, _element.addClass)(this.hot.rootElement, CSS_PLUGIN);
  33780. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'enablePlugin', this).call(this);
  33781. }
  33782. /**
  33783. * Updates the plugin to use the latest options you have specified.
  33784. */
  33785. }, {
  33786. key: 'updatePlugin',
  33787. value: function updatePlugin() {
  33788. this.disablePlugin();
  33789. this.enablePlugin();
  33790. this.onAfterPluginsInitialized();
  33791. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'updatePlugin', this).call(this);
  33792. }
  33793. /**
  33794. * Disable plugin for this Handsontable instance.
  33795. */
  33796. }, {
  33797. key: 'disablePlugin',
  33798. value: function disablePlugin() {
  33799. var pluginSettings = this.hot.getSettings().manualRowMove;
  33800. if (Array.isArray(pluginSettings)) {
  33801. this.rowsMapper.clearMap();
  33802. }
  33803. (0, _element.removeClass)(this.hot.rootElement, CSS_PLUGIN);
  33804. this.unregisterEvents();
  33805. this.backlight.destroy();
  33806. this.guideline.destroy();
  33807. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'disablePlugin', this).call(this);
  33808. }
  33809. /**
  33810. * Move a single row.
  33811. *
  33812. * @param {Number} row Visual row index to be moved.
  33813. * @param {Number} target Visual row index being a target for the moved row.
  33814. */
  33815. }, {
  33816. key: 'moveRow',
  33817. value: function moveRow(row, target) {
  33818. this.moveRows([row], target);
  33819. }
  33820. /**
  33821. * Move multiple rows.
  33822. *
  33823. * @param {Array} rows Array of visual row indexes to be moved.
  33824. * @param {Number} target Visual row index being a target for the moved rows.
  33825. */
  33826. }, {
  33827. key: 'moveRows',
  33828. value: function moveRows(rows, target) {
  33829. var _this3 = this;
  33830. var priv = privatePool.get(this);
  33831. var beforeMoveHook = this.hot.runHooks('beforeRowMove', rows, target);
  33832. priv.disallowMoving = beforeMoveHook === false;
  33833. if (!priv.disallowMoving) {
  33834. // first we need to rewrite an visual indexes to physical for save reference after move
  33835. (0, _array.arrayEach)(rows, function (row, index, array) {
  33836. array[index] = _this3.rowsMapper.getValueByIndex(row);
  33837. });
  33838. // next, when we have got an physical indexes, we can move rows
  33839. (0, _array.arrayEach)(rows, function (row, index) {
  33840. var actualPosition = _this3.rowsMapper.getIndexByValue(row);
  33841. if (actualPosition !== target) {
  33842. _this3.rowsMapper.moveRow(actualPosition, target + index);
  33843. }
  33844. });
  33845. // after moving we have to clear rowsMapper from null entries
  33846. this.rowsMapper.clearNull();
  33847. }
  33848. this.hot.runHooks('afterRowMove', rows, target);
  33849. }
  33850. /**
  33851. * Correct the cell selection after the move action. Fired only when action was made with a mouse.
  33852. * That means that changing the row order using the API won't correct the selection.
  33853. *
  33854. * @private
  33855. * @param {Number} startRow Visual row index for the start of the selection.
  33856. * @param {Number} endRow Visual row index for the end of the selection.
  33857. */
  33858. }, {
  33859. key: 'changeSelection',
  33860. value: function changeSelection(startRow, endRow) {
  33861. var selection = this.hot.selection;
  33862. var lastColIndex = this.hot.countCols() - 1;
  33863. selection.setRangeStartOnly(new _src.CellCoords(startRow, 0));
  33864. selection.setRangeEnd(new _src.CellCoords(endRow, lastColIndex), false);
  33865. }
  33866. /**
  33867. * Get the sum of the heights of rows in the provided range.
  33868. *
  33869. * @private
  33870. * @param {Number} from Visual row index.
  33871. * @param {Number} to Visual row index.
  33872. * @returns {Number}
  33873. */
  33874. }, {
  33875. key: 'getRowsHeight',
  33876. value: function getRowsHeight(from, to) {
  33877. var height = 0;
  33878. for (var i = from; i < to; i++) {
  33879. var rowHeight = this.hot.view.wt.wtTable.getRowHeight(i) || 23;
  33880. height += rowHeight;
  33881. }
  33882. return height;
  33883. }
  33884. /**
  33885. * Load initial settings when persistent state is saved or when plugin was initialized as an array.
  33886. *
  33887. * @private
  33888. */
  33889. }, {
  33890. key: 'initialSettings',
  33891. value: function initialSettings() {
  33892. var pluginSettings = this.hot.getSettings().manualRowMove;
  33893. if (Array.isArray(pluginSettings)) {
  33894. this.moveRows(pluginSettings, 0);
  33895. } else if (pluginSettings !== void 0) {
  33896. var persistentState = this.persistentStateLoad();
  33897. if (persistentState.length) {
  33898. this.moveRows(persistentState, 0);
  33899. }
  33900. }
  33901. }
  33902. /**
  33903. * Check if the provided row is in the fixedRowsTop section.
  33904. *
  33905. * @private
  33906. * @param {Number} row Visual row index to check.
  33907. * @returns {Boolean}
  33908. */
  33909. }, {
  33910. key: 'isFixedRowTop',
  33911. value: function isFixedRowTop(row) {
  33912. return row < this.hot.getSettings().fixedRowsTop;
  33913. }
  33914. /**
  33915. * Check if the provided row is in the fixedRowsBottom section.
  33916. *
  33917. * @private
  33918. * @param {Number} row Visual row index to check.
  33919. * @returns {Boolean}
  33920. */
  33921. }, {
  33922. key: 'isFixedRowBottom',
  33923. value: function isFixedRowBottom(row) {
  33924. return row > this.hot.getSettings().fixedRowsBottom;
  33925. }
  33926. /**
  33927. * Save the manual row positions to the persistent state.
  33928. *
  33929. * @private
  33930. */
  33931. }, {
  33932. key: 'persistentStateSave',
  33933. value: function persistentStateSave() {
  33934. this.hot.runHooks('persistentStateSave', 'manualRowMove', this.rowsMapper._arrayMap);
  33935. }
  33936. /**
  33937. * Load the manual row positions from the persistent state.
  33938. *
  33939. * @private
  33940. * @returns {Array} Stored state.
  33941. */
  33942. }, {
  33943. key: 'persistentStateLoad',
  33944. value: function persistentStateLoad() {
  33945. var storedState = {};
  33946. this.hot.runHooks('persistentStateLoad', 'manualRowMove', storedState);
  33947. return storedState.value ? storedState.value : [];
  33948. }
  33949. /**
  33950. * Prepare array of indexes based on actual selection.
  33951. *
  33952. * @private
  33953. * @returns {Array}
  33954. */
  33955. }, {
  33956. key: 'prepareRowsToMoving',
  33957. value: function prepareRowsToMoving() {
  33958. var selection = this.hot.getSelectedRange();
  33959. var selectedRows = [];
  33960. if (!selection) {
  33961. return selectedRows;
  33962. }
  33963. var from = selection.from,
  33964. to = selection.to;
  33965. var start = Math.min(from.row, to.row);
  33966. var end = Math.max(from.row, to.row);
  33967. (0, _number.rangeEach)(start, end, function (i) {
  33968. selectedRows.push(i);
  33969. });
  33970. return selectedRows;
  33971. }
  33972. /**
  33973. * Update the UI visual position.
  33974. *
  33975. * @private
  33976. */
  33977. }, {
  33978. key: 'refreshPositions',
  33979. value: function refreshPositions() {
  33980. var priv = privatePool.get(this);
  33981. var coords = priv.target.coords;
  33982. var firstVisible = this.hot.view.wt.wtTable.getFirstVisibleRow();
  33983. var lastVisible = this.hot.view.wt.wtTable.getLastVisibleRow();
  33984. var fixedRows = this.hot.getSettings().fixedRowsTop;
  33985. var countRows = this.hot.countRows();
  33986. if (coords.row < fixedRows && firstVisible > 0) {
  33987. this.hot.scrollViewportTo(firstVisible - 1);
  33988. }
  33989. if (coords.row >= lastVisible && lastVisible < countRows) {
  33990. this.hot.scrollViewportTo(lastVisible + 1, undefined, true);
  33991. }
  33992. var wtTable = this.hot.view.wt.wtTable;
  33993. var TD = priv.target.TD;
  33994. var rootElementOffset = (0, _element.offset)(this.hot.rootElement);
  33995. var tdOffsetTop = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row);
  33996. var mouseOffsetTop = priv.target.eventPageY - rootElementOffset.top + wtTable.holder.scrollTop;
  33997. var hiderHeight = wtTable.hider.offsetHeight;
  33998. var tbodyOffsetTop = wtTable.TBODY.offsetTop;
  33999. var backlightElemMarginTop = this.backlight.getOffset().top;
  34000. var backlightElemHeight = this.backlight.getSize().height;
  34001. if (rootElementOffset.top + wtTable.holder.offsetHeight < priv.target.eventPageY) {
  34002. priv.target.coords.row++;
  34003. }
  34004. if (this.isFixedRowTop(coords.row)) {
  34005. tdOffsetTop += wtTable.holder.scrollTop;
  34006. }
  34007. // todo: fixedRowsBottom
  34008. // if (this.isFixedRowBottom(coords.row)) {
  34009. //
  34010. // }
  34011. if (coords.row < 0) {
  34012. // if hover on colHeader
  34013. priv.target.row = firstVisible > 0 ? firstVisible - 1 : firstVisible;
  34014. } else if (TD.offsetHeight / 2 + tdOffsetTop <= mouseOffsetTop) {
  34015. // if hover on lower part of TD
  34016. priv.target.row = coords.row + 1;
  34017. // unfortunately first row is bigger than rest
  34018. tdOffsetTop += coords.row === 0 ? TD.offsetHeight - 1 : TD.offsetHeight;
  34019. } else {
  34020. // elsewhere on table
  34021. priv.target.row = coords.row;
  34022. }
  34023. var backlightTop = mouseOffsetTop;
  34024. var guidelineTop = tdOffsetTop;
  34025. if (mouseOffsetTop + backlightElemHeight + backlightElemMarginTop >= hiderHeight) {
  34026. // prevent display backlight below table
  34027. backlightTop = hiderHeight - backlightElemHeight - backlightElemMarginTop;
  34028. } else if (mouseOffsetTop + backlightElemMarginTop < tbodyOffsetTop) {
  34029. // prevent display above below table
  34030. backlightTop = tbodyOffsetTop + Math.abs(backlightElemMarginTop);
  34031. }
  34032. if (tdOffsetTop >= hiderHeight - 1) {
  34033. // prevent display guideline below table
  34034. guidelineTop = hiderHeight - 1;
  34035. }
  34036. var topOverlayHeight = 0;
  34037. if (this.hot.view.wt.wtOverlays.topOverlay) {
  34038. topOverlayHeight = this.hot.view.wt.wtOverlays.topOverlay.clone.wtTable.TABLE.offsetHeight;
  34039. }
  34040. if (coords.row >= fixedRows && guidelineTop - wtTable.holder.scrollTop < topOverlayHeight) {
  34041. this.hot.scrollViewportTo(coords.row);
  34042. }
  34043. this.backlight.setPosition(backlightTop);
  34044. this.guideline.setPosition(guidelineTop);
  34045. }
  34046. /**
  34047. * This method checks arrayMap from rowsMapper and updates the rowsMapper if it's necessary.
  34048. *
  34049. * @private
  34050. */
  34051. }, {
  34052. key: 'updateRowsMapper',
  34053. value: function updateRowsMapper() {
  34054. var countRows = this.hot.countSourceRows();
  34055. var rowsMapperLen = this.rowsMapper._arrayMap.length;
  34056. if (rowsMapperLen === 0) {
  34057. this.rowsMapper.createMap(countRows || this.hot.getSettings().startRows);
  34058. } else if (rowsMapperLen < countRows) {
  34059. var diff = countRows - rowsMapperLen;
  34060. this.rowsMapper.insertItems(rowsMapperLen, diff);
  34061. } else if (rowsMapperLen > countRows) {
  34062. var maxIndex = countRows - 1;
  34063. var rowsToRemove = [];
  34064. (0, _array.arrayEach)(this.rowsMapper._arrayMap, function (value, index, array) {
  34065. if (value > maxIndex) {
  34066. rowsToRemove.push(index);
  34067. }
  34068. });
  34069. this.rowsMapper.removeItems(rowsToRemove);
  34070. }
  34071. }
  34072. /**
  34073. * Bind the events used by the plugin.
  34074. *
  34075. * @private
  34076. */
  34077. }, {
  34078. key: 'registerEvents',
  34079. value: function registerEvents() {
  34080. var _this4 = this;
  34081. this.eventManager.addEventListener(document.documentElement, 'mousemove', function (event) {
  34082. return _this4.onMouseMove(event);
  34083. });
  34084. this.eventManager.addEventListener(document.documentElement, 'mouseup', function () {
  34085. return _this4.onMouseUp();
  34086. });
  34087. }
  34088. /**
  34089. * Unbind the events used by the plugin.
  34090. *
  34091. * @private
  34092. */
  34093. }, {
  34094. key: 'unregisterEvents',
  34095. value: function unregisterEvents() {
  34096. this.eventManager.clear();
  34097. }
  34098. /**
  34099. * `beforeColumnSort` hook callback. If user uses the sorting, manual row moving is disabled.
  34100. *
  34101. * @private
  34102. * @param {Number} column Column index where soring is present
  34103. * @param {*} order State of sorting. ASC/DESC/None
  34104. */
  34105. }, {
  34106. key: 'onBeforeColumnSort',
  34107. value: function onBeforeColumnSort(column, order) {
  34108. var priv = privatePool.get(this);
  34109. priv.disallowMoving = order !== void 0;
  34110. }
  34111. /**
  34112. * Change the behavior of selection / dragging.
  34113. *
  34114. * @private
  34115. * @param {MouseEvent} event
  34116. * @param {CellCoords} coords Visual coordinates.
  34117. * @param {HTMLElement} TD
  34118. * @param {Object} blockCalculations
  34119. */
  34120. }, {
  34121. key: 'onBeforeOnCellMouseDown',
  34122. value: function onBeforeOnCellMouseDown(event, coords, TD, blockCalculations) {
  34123. var wtTable = this.hot.view.wt.wtTable;
  34124. var isHeaderSelection = this.hot.selection.selectedHeader.rows;
  34125. var selection = this.hot.getSelectedRange();
  34126. var priv = privatePool.get(this);
  34127. if (!selection || !isHeaderSelection || priv.pressed || event.button !== 0) {
  34128. priv.pressed = false;
  34129. priv.rowsToMove.length = 0;
  34130. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI]);
  34131. return;
  34132. }
  34133. var guidelineIsNotReady = this.guideline.isBuilt() && !this.guideline.isAppended();
  34134. var backlightIsNotReady = this.backlight.isBuilt() && !this.backlight.isAppended();
  34135. if (guidelineIsNotReady && backlightIsNotReady) {
  34136. this.guideline.appendTo(wtTable.hider);
  34137. this.backlight.appendTo(wtTable.hider);
  34138. }
  34139. var from = selection.from,
  34140. to = selection.to;
  34141. var start = Math.min(from.row, to.row);
  34142. var end = Math.max(from.row, to.row);
  34143. if (coords.col < 0 && coords.row >= start && coords.row <= end) {
  34144. blockCalculations.row = true;
  34145. priv.pressed = true;
  34146. priv.target.eventPageY = event.pageY;
  34147. priv.target.coords = coords;
  34148. priv.target.TD = TD;
  34149. priv.rowsToMove = this.prepareRowsToMoving();
  34150. var leftPos = wtTable.holder.scrollLeft + wtTable.getColumnWidth(-1);
  34151. this.backlight.setPosition(null, leftPos);
  34152. this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end + 1));
  34153. this.backlight.setOffset((this.getRowsHeight(start, coords.row) + event.layerY) * -1, null);
  34154. (0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
  34155. this.refreshPositions();
  34156. } else {
  34157. (0, _element.removeClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  34158. priv.pressed = false;
  34159. priv.rowsToMove.length = 0;
  34160. }
  34161. }
  34162. /**
  34163. * 'mouseMove' event callback. Fired when pointer move on document.documentElement.
  34164. *
  34165. * @private
  34166. * @param {MouseEvent} event `mousemove` event properties.
  34167. */
  34168. }, {
  34169. key: 'onMouseMove',
  34170. value: function onMouseMove(event) {
  34171. var priv = privatePool.get(this);
  34172. if (!priv.pressed) {
  34173. return;
  34174. }
  34175. // callback for browser which doesn't supports CSS pointer-event: none
  34176. if (event.realTarget === this.backlight.element) {
  34177. var height = this.backlight.getSize().height;
  34178. this.backlight.setSize(null, 0);
  34179. setTimeout(function () {
  34180. this.backlight.setPosition(null, height);
  34181. });
  34182. }
  34183. priv.target.eventPageY = event.pageY;
  34184. this.refreshPositions();
  34185. }
  34186. /**
  34187. * 'beforeOnCellMouseOver' hook callback. Fired when pointer was over cell.
  34188. *
  34189. * @private
  34190. * @param {MouseEvent} event `mouseover` event properties.
  34191. * @param {CellCoords} coords Visual cell coordinates where was fired event.
  34192. * @param {HTMLElement} TD Cell represented as HTMLElement.
  34193. * @param {Object} blockCalculations Object which contains information about blockCalculation for row, column or cells.
  34194. */
  34195. }, {
  34196. key: 'onBeforeOnCellMouseOver',
  34197. value: function onBeforeOnCellMouseOver(event, coords, TD, blockCalculations) {
  34198. var selectedRange = this.hot.getSelectedRange();
  34199. var priv = privatePool.get(this);
  34200. if (!selectedRange || !priv.pressed) {
  34201. return;
  34202. }
  34203. if (priv.rowsToMove.indexOf(coords.row) > -1) {
  34204. (0, _element.removeClass)(this.hot.rootElement, CSS_SHOW_UI);
  34205. } else {
  34206. (0, _element.addClass)(this.hot.rootElement, CSS_SHOW_UI);
  34207. }
  34208. blockCalculations.row = true;
  34209. blockCalculations.column = true;
  34210. blockCalculations.cell = true;
  34211. priv.target.coords = coords;
  34212. priv.target.TD = TD;
  34213. }
  34214. /**
  34215. * `onMouseUp` hook callback.
  34216. *
  34217. * @private
  34218. */
  34219. }, {
  34220. key: 'onMouseUp',
  34221. value: function onMouseUp() {
  34222. var priv = privatePool.get(this);
  34223. var target = priv.target.row;
  34224. var rowsLen = priv.rowsToMove.length;
  34225. priv.pressed = false;
  34226. priv.backlightHeight = 0;
  34227. (0, _element.removeClass)(this.hot.rootElement, [CSS_ON_MOVING, CSS_SHOW_UI, CSS_AFTER_SELECTION]);
  34228. if (this.hot.selection.selectedHeader.rows) {
  34229. (0, _element.addClass)(this.hot.rootElement, CSS_AFTER_SELECTION);
  34230. }
  34231. if (rowsLen < 1 || target === void 0 || priv.rowsToMove.indexOf(target) > -1 || priv.rowsToMove[rowsLen - 1] === target - 1) {
  34232. return;
  34233. }
  34234. this.moveRows(priv.rowsToMove, target);
  34235. this.persistentStateSave();
  34236. this.hot.render();
  34237. if (!priv.disallowMoving) {
  34238. var selectionStart = this.rowsMapper.getIndexByValue(priv.rowsToMove[0]);
  34239. var selectionEnd = this.rowsMapper.getIndexByValue(priv.rowsToMove[rowsLen - 1]);
  34240. this.changeSelection(selectionStart, selectionEnd);
  34241. }
  34242. priv.rowsToMove.length = 0;
  34243. }
  34244. /**
  34245. * `afterScrollHorizontally` hook callback. Fired the table was scrolled horizontally.
  34246. *
  34247. * @private
  34248. */
  34249. }, {
  34250. key: 'onAfterScrollHorizontally',
  34251. value: function onAfterScrollHorizontally() {
  34252. var wtTable = this.hot.view.wt.wtTable;
  34253. var headerWidth = wtTable.getColumnWidth(-1);
  34254. var scrollLeft = wtTable.holder.scrollLeft;
  34255. var posLeft = headerWidth + scrollLeft;
  34256. this.backlight.setPosition(null, posLeft);
  34257. this.backlight.setSize(wtTable.hider.offsetWidth - posLeft);
  34258. }
  34259. /**
  34260. * `afterCreateRow` hook callback.
  34261. *
  34262. * @private
  34263. * @param {Number} index Visual index of the created row.
  34264. * @param {Number} amount Amount of created rows.
  34265. */
  34266. }, {
  34267. key: 'onAfterCreateRow',
  34268. value: function onAfterCreateRow(index, amount) {
  34269. this.rowsMapper.shiftItems(index, amount);
  34270. }
  34271. /**
  34272. * On before remove row listener.
  34273. *
  34274. * @private
  34275. * @param {Number} index Visual row index.
  34276. * @param {Number} amount Defines how many rows removed.
  34277. */
  34278. }, {
  34279. key: 'onBeforeRemoveRow',
  34280. value: function onBeforeRemoveRow(index, amount) {
  34281. var _this5 = this;
  34282. this.removedRows.length = 0;
  34283. if (index !== false) {
  34284. // Collect physical row index.
  34285. (0, _number.rangeEach)(index, index + amount - 1, function (removedIndex) {
  34286. _this5.removedRows.push(_this5.hot.runHooks('modifyRow', removedIndex, _this5.pluginName));
  34287. });
  34288. }
  34289. }
  34290. /**
  34291. * `afterRemoveRow` hook callback.
  34292. *
  34293. * @private
  34294. * @param {Number} index Visual index of the removed row.
  34295. * @param {Number} amount Amount of removed rows.
  34296. */
  34297. }, {
  34298. key: 'onAfterRemoveRow',
  34299. value: function onAfterRemoveRow(index, amount) {
  34300. this.rowsMapper.unshiftItems(this.removedRows);
  34301. }
  34302. /**
  34303. * `afterLoadData` hook callback.
  34304. *
  34305. * @private
  34306. * @param {Boolean} firstTime True if that was loading data during the initialization.
  34307. */
  34308. }, {
  34309. key: 'onAfterLoadData',
  34310. value: function onAfterLoadData(firstTime) {
  34311. this.updateRowsMapper();
  34312. }
  34313. /**
  34314. * 'modifyRow' hook callback.
  34315. *
  34316. * @private
  34317. * @param {Number} row Visual Row index.
  34318. * @returns {Number} Physical row index.
  34319. */
  34320. }, {
  34321. key: 'onModifyRow',
  34322. value: function onModifyRow(row, source) {
  34323. if (source !== this.pluginName) {
  34324. var rowInMapper = this.rowsMapper.getValueByIndex(row);
  34325. row = rowInMapper === null ? row : rowInMapper;
  34326. }
  34327. return row;
  34328. }
  34329. /**
  34330. * 'unmodifyRow' hook callback.
  34331. *
  34332. * @private
  34333. * @param {Number} row Physical row index.
  34334. * @returns {Number} Visual row index.
  34335. */
  34336. }, {
  34337. key: 'onUnmodifyRow',
  34338. value: function onUnmodifyRow(row) {
  34339. var indexInMapper = this.rowsMapper.getIndexByValue(row);
  34340. return indexInMapper === null ? row : indexInMapper;
  34341. }
  34342. /**
  34343. * `afterPluginsInitialized` hook callback.
  34344. *
  34345. * @private
  34346. */
  34347. }, {
  34348. key: 'onAfterPluginsInitialized',
  34349. value: function onAfterPluginsInitialized() {
  34350. this.updateRowsMapper();
  34351. this.initialSettings();
  34352. this.backlight.build();
  34353. this.guideline.build();
  34354. }
  34355. /**
  34356. * Destroy plugin instance.
  34357. */
  34358. }, {
  34359. key: 'destroy',
  34360. value: function destroy() {
  34361. this.backlight.destroy();
  34362. this.guideline.destroy();
  34363. _get(ManualRowMove.prototype.__proto__ || Object.getPrototypeOf(ManualRowMove.prototype), 'destroy', this).call(this);
  34364. }
  34365. }]);
  34366. return ManualRowMove;
  34367. }(_base2.default);
  34368. (0, _plugins.registerPlugin)('ManualRowMove', ManualRowMove);
  34369. exports.default = ManualRowMove;
  34370. /***/ }),
  34371. /* 249 */
  34372. /***/ (function(module, exports, __webpack_require__) {
  34373. "use strict";
  34374. exports.__esModule = true;
  34375. 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; }; }();
  34376. var _arrayMapper = __webpack_require__(150);
  34377. var _arrayMapper2 = _interopRequireDefault(_arrayMapper);
  34378. var _array = __webpack_require__(2);
  34379. var _object = __webpack_require__(1);
  34380. var _number = __webpack_require__(6);
  34381. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34382. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34383. /**
  34384. * @class RowsMapper
  34385. * @plugin ManualRowMove
  34386. */
  34387. var RowsMapper = function () {
  34388. function RowsMapper(manualRowMove) {
  34389. _classCallCheck(this, RowsMapper);
  34390. /**
  34391. * Instance of ManualRowMove plugin.
  34392. *
  34393. * @type {ManualRowMove}
  34394. */
  34395. this.manualRowMove = manualRowMove;
  34396. }
  34397. /**
  34398. * Reset current map array and create new one.
  34399. *
  34400. * @param {Number} [length] Custom generated map length.
  34401. */
  34402. _createClass(RowsMapper, [{
  34403. key: 'createMap',
  34404. value: function createMap(length) {
  34405. var _this = this;
  34406. var originLength = length === void 0 ? this._arrayMap.length : length;
  34407. this._arrayMap.length = 0;
  34408. (0, _number.rangeEach)(originLength - 1, function (itemIndex) {
  34409. _this._arrayMap[itemIndex] = itemIndex;
  34410. });
  34411. }
  34412. /**
  34413. * Destroy class.
  34414. */
  34415. }, {
  34416. key: 'destroy',
  34417. value: function destroy() {
  34418. this._arrayMap = null;
  34419. }
  34420. /**
  34421. * Moving elements in rowsMapper.
  34422. *
  34423. * @param {Number} from Row index to move.
  34424. * @param {Number} to Target index.
  34425. */
  34426. }, {
  34427. key: 'moveRow',
  34428. value: function moveRow(from, to) {
  34429. var indexToMove = this._arrayMap[from];
  34430. this._arrayMap[from] = null;
  34431. this._arrayMap.splice(to, 0, indexToMove);
  34432. }
  34433. /**
  34434. * Clearing arrayMap from `null` entries.
  34435. */
  34436. }, {
  34437. key: 'clearNull',
  34438. value: function clearNull() {
  34439. this._arrayMap = (0, _array.arrayFilter)(this._arrayMap, function (i) {
  34440. return i !== null;
  34441. });
  34442. }
  34443. }]);
  34444. return RowsMapper;
  34445. }();
  34446. (0, _object.mixin)(RowsMapper, _arrayMapper2.default);
  34447. exports.default = RowsMapper;
  34448. /***/ }),
  34449. /* 250 */
  34450. /***/ (function(module, exports, __webpack_require__) {
  34451. "use strict";
  34452. exports.__esModule = true;
  34453. 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; }; }();
  34454. 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); } };
  34455. var _base = __webpack_require__(152);
  34456. var _base2 = _interopRequireDefault(_base);
  34457. var _element = __webpack_require__(0);
  34458. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34459. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34460. 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; }
  34461. 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; }
  34462. var CSS_CLASSNAME = 'ht__manualRowMove--backlight';
  34463. /**
  34464. * @class BacklightUI
  34465. * @util
  34466. */
  34467. var BacklightUI = function (_BaseUI) {
  34468. _inherits(BacklightUI, _BaseUI);
  34469. function BacklightUI() {
  34470. _classCallCheck(this, BacklightUI);
  34471. return _possibleConstructorReturn(this, (BacklightUI.__proto__ || Object.getPrototypeOf(BacklightUI)).apply(this, arguments));
  34472. }
  34473. _createClass(BacklightUI, [{
  34474. key: 'build',
  34475. /**
  34476. * Custom className on build process.
  34477. */
  34478. value: function build() {
  34479. _get(BacklightUI.prototype.__proto__ || Object.getPrototypeOf(BacklightUI.prototype), 'build', this).call(this);
  34480. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  34481. }
  34482. }]);
  34483. return BacklightUI;
  34484. }(_base2.default);
  34485. exports.default = BacklightUI;
  34486. /***/ }),
  34487. /* 251 */
  34488. /***/ (function(module, exports, __webpack_require__) {
  34489. "use strict";
  34490. exports.__esModule = true;
  34491. 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; }; }();
  34492. 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); } };
  34493. var _base = __webpack_require__(152);
  34494. var _base2 = _interopRequireDefault(_base);
  34495. var _element = __webpack_require__(0);
  34496. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34497. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34498. 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; }
  34499. 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; }
  34500. var CSS_CLASSNAME = 'ht__manualRowMove--guideline';
  34501. /**
  34502. * @class GuidelineUI
  34503. * @util
  34504. */
  34505. var GuidelineUI = function (_BaseUI) {
  34506. _inherits(GuidelineUI, _BaseUI);
  34507. function GuidelineUI() {
  34508. _classCallCheck(this, GuidelineUI);
  34509. return _possibleConstructorReturn(this, (GuidelineUI.__proto__ || Object.getPrototypeOf(GuidelineUI)).apply(this, arguments));
  34510. }
  34511. _createClass(GuidelineUI, [{
  34512. key: 'build',
  34513. /**
  34514. * Custom className on build process.
  34515. */
  34516. value: function build() {
  34517. _get(GuidelineUI.prototype.__proto__ || Object.getPrototypeOf(GuidelineUI.prototype), 'build', this).call(this);
  34518. (0, _element.addClass)(this._element, CSS_CLASSNAME);
  34519. }
  34520. }]);
  34521. return GuidelineUI;
  34522. }(_base2.default);
  34523. exports.default = GuidelineUI;
  34524. /***/ }),
  34525. /* 252 */
  34526. /***/ (function(module, exports, __webpack_require__) {
  34527. "use strict";
  34528. exports.__esModule = true;
  34529. 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; }; }();
  34530. 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); } };
  34531. var _base = __webpack_require__(12);
  34532. var _base2 = _interopRequireDefault(_base);
  34533. var _element = __webpack_require__(0);
  34534. var _eventManager = __webpack_require__(4);
  34535. var _eventManager2 = _interopRequireDefault(_eventManager);
  34536. var _event = __webpack_require__(7);
  34537. var _array = __webpack_require__(2);
  34538. var _number = __webpack_require__(6);
  34539. var _plugins = __webpack_require__(5);
  34540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34541. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  34542. 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; }
  34543. 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; }
  34544. // Developer note! Whenever you make a change in this file, make an analogous change in manualRowResize.js
  34545. /**
  34546. * @description
  34547. * ManualRowResize Plugin.
  34548. *
  34549. * Has 2 UI components:
  34550. * - handle - the draggable element that sets the desired height of the row.
  34551. * - guide - the helper guide that shows the desired height as a horizontal guide.
  34552. *
  34553. * @plugin ManualRowResize
  34554. */
  34555. var ManualRowResize = function (_BasePlugin) {
  34556. _inherits(ManualRowResize, _BasePlugin);
  34557. function ManualRowResize(hotInstance) {
  34558. _classCallCheck(this, ManualRowResize);
  34559. var _this = _possibleConstructorReturn(this, (ManualRowResize.__proto__ || Object.getPrototypeOf(ManualRowResize)).call(this, hotInstance));
  34560. _this.currentTH = null;
  34561. _this.currentRow = null;
  34562. _this.selectedRows = [];
  34563. _this.currentHeight = null;
  34564. _this.newSize = null;
  34565. _this.startY = null;
  34566. _this.startHeight = null;
  34567. _this.startOffset = null;
  34568. _this.handle = document.createElement('DIV');
  34569. _this.guide = document.createElement('DIV');
  34570. _this.eventManager = new _eventManager2.default(_this);
  34571. _this.pressed = null;
  34572. _this.dblclick = 0;
  34573. _this.autoresizeTimeout = null;
  34574. _this.manualRowHeights = [];
  34575. (0, _element.addClass)(_this.handle, 'manualRowResizer');
  34576. (0, _element.addClass)(_this.guide, 'manualRowResizerGuide');
  34577. return _this;
  34578. }
  34579. /**
  34580. * Check if the plugin is enabled in the handsontable settings.
  34581. *
  34582. * @returns {Boolean}
  34583. */
  34584. _createClass(ManualRowResize, [{
  34585. key: 'isEnabled',
  34586. value: function isEnabled() {
  34587. return this.hot.getSettings().manualRowResize;
  34588. }
  34589. /**
  34590. * Enable plugin for this Handsontable instance.
  34591. */
  34592. }, {
  34593. key: 'enablePlugin',
  34594. value: function enablePlugin() {
  34595. var _this2 = this;
  34596. if (this.enabled) {
  34597. return;
  34598. }
  34599. this.manualRowHeights = [];
  34600. var initialRowHeights = this.hot.getSettings().manualRowResize;
  34601. var loadedManualRowHeights = this.loadManualRowHeights();
  34602. if (typeof loadedManualRowHeights != 'undefined') {
  34603. this.manualRowHeights = loadedManualRowHeights;
  34604. } else if (Array.isArray(initialRowHeights)) {
  34605. this.manualRowHeights = initialRowHeights;
  34606. } else {
  34607. this.manualRowHeights = [];
  34608. }
  34609. this.addHook('modifyRowHeight', function (height, row) {
  34610. return _this2.onModifyRowHeight(height, row);
  34611. });
  34612. // Handsontable.hooks.register('beforeRowResize');
  34613. // Handsontable.hooks.register('afterRowResize');
  34614. this.bindEvents();
  34615. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'enablePlugin', this).call(this);
  34616. }
  34617. /**
  34618. * Updates the plugin to use the latest options you have specified.
  34619. */
  34620. }, {
  34621. key: 'updatePlugin',
  34622. value: function updatePlugin() {
  34623. var initialRowHeights = this.hot.getSettings().manualRowResize;
  34624. if (Array.isArray(initialRowHeights)) {
  34625. this.manualRowHeights = initialRowHeights;
  34626. } else if (!initialRowHeights) {
  34627. this.manualRowHeights = [];
  34628. }
  34629. }
  34630. /**
  34631. * Disable plugin for this Handsontable instance.
  34632. */
  34633. }, {
  34634. key: 'disablePlugin',
  34635. value: function disablePlugin() {
  34636. _get(ManualRowResize.prototype.__proto__ || Object.getPrototypeOf(ManualRowResize.prototype), 'disablePlugin', this).call(this);
  34637. }
  34638. /**
  34639. * Save the current sizes using the persistentState plugin.
  34640. */
  34641. }, {
  34642. key: 'saveManualRowHeights',
  34643. value: function saveManualRowHeights() {
  34644. this.hot.runHooks('persistentStateSave', 'manualRowHeights', this.manualRowHeights);
  34645. }
  34646. /**
  34647. * Load the previously saved sizes using the persistentState plugin.
  34648. *
  34649. * @returns {Array}
  34650. */
  34651. }, {
  34652. key: 'loadManualRowHeights',
  34653. value: function loadManualRowHeights() {
  34654. var storedState = {};
  34655. this.hot.runHooks('persistentStateLoad', 'manualRowHeights', storedState);
  34656. return storedState.value;
  34657. }
  34658. /**
  34659. * Set the resize handle position.
  34660. *
  34661. * @param {HTMLCellElement} TH TH HTML element.
  34662. */
  34663. }, {
  34664. key: 'setupHandlePosition',
  34665. value: function setupHandlePosition(TH) {
  34666. var _this3 = this;
  34667. this.currentTH = TH;
  34668. var row = this.hot.view.wt.wtTable.getCoords(TH).row; // getCoords returns CellCoords
  34669. var headerWidth = (0, _element.outerWidth)(this.currentTH);
  34670. if (row >= 0) {
  34671. // if not col header
  34672. var box = this.currentTH.getBoundingClientRect();
  34673. this.currentRow = row;
  34674. this.selectedRows = [];
  34675. if (this.hot.selection.isSelected() && this.hot.selection.selectedHeader.rows) {
  34676. var _hot$getSelectedRange = this.hot.getSelectedRange(),
  34677. from = _hot$getSelectedRange.from,
  34678. to = _hot$getSelectedRange.to;
  34679. var start = from.row;
  34680. var end = to.row;
  34681. if (start >= end) {
  34682. start = to.row;
  34683. end = from.row;
  34684. }
  34685. if (this.currentRow >= start && this.currentRow <= end) {
  34686. (0, _number.rangeEach)(start, end, function (i) {
  34687. return _this3.selectedRows.push(i);
  34688. });
  34689. } else {
  34690. this.selectedRows.push(this.currentRow);
  34691. }
  34692. } else {
  34693. this.selectedRows.push(this.currentRow);
  34694. }
  34695. this.startOffset = box.top - 6;
  34696. this.startHeight = parseInt(box.height, 10);
  34697. this.handle.style.left = box.left + 'px';
  34698. this.handle.style.top = this.startOffset + this.startHeight + 'px';
  34699. this.handle.style.width = headerWidth + 'px';
  34700. this.hot.rootElement.appendChild(this.handle);
  34701. }
  34702. }
  34703. /**
  34704. * Refresh the resize handle position.
  34705. */
  34706. }, {
  34707. key: 'refreshHandlePosition',
  34708. value: function refreshHandlePosition() {
  34709. this.handle.style.top = this.startOffset + this.currentHeight + 'px';
  34710. }
  34711. /**
  34712. * Set the resize guide position.
  34713. */
  34714. }, {
  34715. key: 'setupGuidePosition',
  34716. value: function setupGuidePosition() {
  34717. var handleWidth = parseInt((0, _element.outerWidth)(this.handle), 10);
  34718. var handleRightPosition = parseInt(this.handle.style.left, 10) + handleWidth;
  34719. var maximumVisibleElementWidth = parseInt(this.hot.view.maximumVisibleElementWidth(0), 10);
  34720. (0, _element.addClass)(this.handle, 'active');
  34721. (0, _element.addClass)(this.guide, 'active');
  34722. this.guide.style.top = this.handle.style.top;
  34723. this.guide.style.left = handleRightPosition + 'px';
  34724. this.guide.style.width = maximumVisibleElementWidth - handleWidth + 'px';
  34725. this.hot.rootElement.appendChild(this.guide);
  34726. }
  34727. /**
  34728. * Refresh the resize guide position.
  34729. */
  34730. }, {
  34731. key: 'refreshGuidePosition',
  34732. value: function refreshGuidePosition() {
  34733. this.guide.style.top = this.handle.style.top;
  34734. }
  34735. /**
  34736. * Hide both the resize handle and resize guide.
  34737. */
  34738. }, {
  34739. key: 'hideHandleAndGuide',
  34740. value: function hideHandleAndGuide() {
  34741. (0, _element.removeClass)(this.handle, 'active');
  34742. (0, _element.removeClass)(this.guide, 'active');
  34743. }
  34744. /**
  34745. * Check if provided element is considered as a row header.
  34746. *
  34747. * @param {HTMLElement} element HTML element.
  34748. * @returns {Boolean}
  34749. */
  34750. }, {
  34751. key: 'checkIfRowHeader',
  34752. value: function checkIfRowHeader(element) {
  34753. if (element != this.hot.rootElement) {
  34754. var parent = element.parentNode;
  34755. if (parent.tagName === 'TBODY') {
  34756. return true;
  34757. }
  34758. return this.checkIfRowHeader(parent);
  34759. }
  34760. return false;
  34761. }
  34762. /**
  34763. * Get the TH element from the provided element.
  34764. *
  34765. * @param {HTMLElement} element HTML element.
  34766. * @returns {HTMLElement}
  34767. */
  34768. }, {
  34769. key: 'getTHFromTargetElement',
  34770. value: function getTHFromTargetElement(element) {
  34771. if (element.tagName != 'TABLE') {
  34772. if (element.tagName == 'TH') {
  34773. return element;
  34774. }
  34775. return this.getTHFromTargetElement(element.parentNode);
  34776. }
  34777. return null;
  34778. }
  34779. /**
  34780. * 'mouseover' event callback - set the handle position.
  34781. *
  34782. * @private
  34783. * @param {MouseEvent} event
  34784. */
  34785. }, {
  34786. key: 'onMouseOver',
  34787. value: function onMouseOver(event) {
  34788. if (this.checkIfRowHeader(event.target)) {
  34789. var th = this.getTHFromTargetElement(event.target);
  34790. if (th) {
  34791. if (!this.pressed) {
  34792. this.setupHandlePosition(th);
  34793. }
  34794. }
  34795. }
  34796. }
  34797. /**
  34798. * Auto-size row after doubleclick - callback.
  34799. *
  34800. * @private
  34801. */
  34802. }, {
  34803. key: 'afterMouseDownTimeout',
  34804. value: function afterMouseDownTimeout() {
  34805. var _this4 = this;
  34806. var render = function render() {
  34807. _this4.hot.forceFullRender = true;
  34808. _this4.hot.view.render(); // updates all
  34809. _this4.hot.view.wt.wtOverlays.adjustElementsSize(true);
  34810. };
  34811. var resize = function resize(selectedRow, forceRender) {
  34812. var hookNewSize = _this4.hot.runHooks('beforeRowResize', selectedRow, _this4.newSize, true);
  34813. if (hookNewSize !== void 0) {
  34814. _this4.newSize = hookNewSize;
  34815. }
  34816. _this4.setManualSize(selectedRow, _this4.newSize); // double click sets auto row size
  34817. if (forceRender) {
  34818. render();
  34819. }
  34820. _this4.hot.runHooks('afterRowResize', selectedRow, _this4.newSize, true);
  34821. };
  34822. if (this.dblclick >= 2) {
  34823. var selectedRowsLength = this.selectedRows.length;
  34824. if (selectedRowsLength > 1) {
  34825. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  34826. resize(selectedRow);
  34827. });
  34828. render();
  34829. } else {
  34830. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  34831. resize(selectedRow, true);
  34832. });
  34833. }
  34834. }
  34835. this.dblclick = 0;
  34836. this.autoresizeTimeout = null;
  34837. }
  34838. /**
  34839. * 'mousedown' event callback.
  34840. *
  34841. * @private
  34842. * @param {MouseEvent} event
  34843. */
  34844. }, {
  34845. key: 'onMouseDown',
  34846. value: function onMouseDown(event) {
  34847. var _this5 = this;
  34848. if ((0, _element.hasClass)(event.target, 'manualRowResizer')) {
  34849. this.setupGuidePosition();
  34850. this.pressed = this.hot;
  34851. if (this.autoresizeTimeout == null) {
  34852. this.autoresizeTimeout = setTimeout(function () {
  34853. return _this5.afterMouseDownTimeout();
  34854. }, 500);
  34855. this.hot._registerTimeout(this.autoresizeTimeout);
  34856. }
  34857. this.dblclick++;
  34858. this.startY = (0, _event.pageY)(event);
  34859. this.newSize = this.startHeight;
  34860. }
  34861. }
  34862. /**
  34863. * 'mousemove' event callback - refresh the handle and guide positions, cache the new row height.
  34864. *
  34865. * @private
  34866. * @param {MouseEvent} event
  34867. */
  34868. }, {
  34869. key: 'onMouseMove',
  34870. value: function onMouseMove(event) {
  34871. var _this6 = this;
  34872. if (this.pressed) {
  34873. this.currentHeight = this.startHeight + ((0, _event.pageY)(event) - this.startY);
  34874. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  34875. _this6.newSize = _this6.setManualSize(selectedRow, _this6.currentHeight);
  34876. });
  34877. this.refreshHandlePosition();
  34878. this.refreshGuidePosition();
  34879. }
  34880. }
  34881. /**
  34882. * 'mouseup' event callback - apply the row resizing.
  34883. *
  34884. * @private
  34885. * @param {MouseEvent} event
  34886. */
  34887. }, {
  34888. key: 'onMouseUp',
  34889. value: function onMouseUp(event) {
  34890. var _this7 = this;
  34891. var render = function render() {
  34892. _this7.hot.forceFullRender = true;
  34893. _this7.hot.view.render(); // updates all
  34894. _this7.hot.view.wt.wtOverlays.adjustElementsSize(true);
  34895. };
  34896. var runHooks = function runHooks(selectedRow, forceRender) {
  34897. _this7.hot.runHooks('beforeRowResize', selectedRow, _this7.newSize);
  34898. if (forceRender) {
  34899. render();
  34900. }
  34901. _this7.saveManualRowHeights();
  34902. _this7.hot.runHooks('afterRowResize', selectedRow, _this7.newSize);
  34903. };
  34904. if (this.pressed) {
  34905. this.hideHandleAndGuide();
  34906. this.pressed = false;
  34907. if (this.newSize != this.startHeight) {
  34908. var selectedRowsLength = this.selectedRows.length;
  34909. if (selectedRowsLength > 1) {
  34910. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  34911. runHooks(selectedRow);
  34912. });
  34913. render();
  34914. } else {
  34915. (0, _array.arrayEach)(this.selectedRows, function (selectedRow) {
  34916. runHooks(selectedRow, true);
  34917. });
  34918. }
  34919. }
  34920. this.setupHandlePosition(this.currentTH);
  34921. }
  34922. }
  34923. /**
  34924. * Bind the mouse events.
  34925. *
  34926. * @private
  34927. */
  34928. }, {
  34929. key: 'bindEvents',
  34930. value: function bindEvents() {
  34931. var _this8 = this;
  34932. this.eventManager.addEventListener(this.hot.rootElement, 'mouseover', function (e) {
  34933. return _this8.onMouseOver(e);
  34934. });
  34935. this.eventManager.addEventListener(this.hot.rootElement, 'mousedown', function (e) {
  34936. return _this8.onMouseDown(e);
  34937. });
  34938. this.eventManager.addEventListener(window, 'mousemove', function (e) {
  34939. return _this8.onMouseMove(e);
  34940. });
  34941. this.eventManager.addEventListener(window, 'mouseup', function (e) {
  34942. return _this8.onMouseUp(e);
  34943. });
  34944. }
  34945. /**
  34946. * Cache the current row height.
  34947. *
  34948. * @param {Number} row Visual row index.
  34949. * @param {Number} height Row height.
  34950. * @returns {Number}
  34951. */
  34952. }, {
  34953. key: 'setManualSize',
  34954. value: function setManualSize(row, height) {
  34955. row = this.hot.runHooks('modifyRow', row);
  34956. this.manualRowHeights[row] = height;
  34957. return height;
  34958. }
  34959. /**
  34960. * Modify the provided row height, based on the plugin settings.
  34961. *
  34962. * @private
  34963. * @param {Number} height Row height.
  34964. * @param {Number} row Visual row index.
  34965. * @returns {Number}
  34966. */
  34967. }, {
  34968. key: 'onModifyRowHeight',
  34969. value: function onModifyRowHeight(height, row) {
  34970. if (this.enabled) {
  34971. var autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
  34972. var autoRowHeightResult = autoRowSizePlugin ? autoRowSizePlugin.heights[row] : null;
  34973. row = this.hot.runHooks('modifyRow', row);
  34974. var manualRowHeight = this.manualRowHeights[row];
  34975. if (manualRowHeight !== void 0 && (manualRowHeight === autoRowHeightResult || manualRowHeight > (height || 0))) {
  34976. return manualRowHeight;
  34977. }
  34978. }
  34979. return height;
  34980. }
  34981. }]);
  34982. return ManualRowResize;
  34983. }(_base2.default);
  34984. (0, _plugins.registerPlugin)('manualRowResize', ManualRowResize);
  34985. exports.default = ManualRowResize;
  34986. /***/ }),
  34987. /* 253 */
  34988. /***/ (function(module, exports, __webpack_require__) {
  34989. "use strict";
  34990. exports.__esModule = true;
  34991. var _pluginHooks = __webpack_require__(8);
  34992. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  34993. var _plugins = __webpack_require__(5);
  34994. var _event = __webpack_require__(7);
  34995. var _src = __webpack_require__(11);
  34996. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  34997. function CellInfoCollection() {
  34998. var collection = [];
  34999. collection.getInfo = function (row, col) {
  35000. for (var i = 0, ilen = this.length; i < ilen; i++) {
  35001. 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) {
  35002. return this[i];
  35003. }
  35004. }
  35005. };
  35006. collection.setInfo = function (info) {
  35007. for (var i = 0, ilen = this.length; i < ilen; i++) {
  35008. if (this[i].row === info.row && this[i].col === info.col) {
  35009. this[i] = info;
  35010. return;
  35011. }
  35012. }
  35013. this.push(info);
  35014. };
  35015. collection.removeInfo = function (row, col) {
  35016. for (var i = 0, ilen = this.length; i < ilen; i++) {
  35017. if (this[i].row === row && this[i].col === col) {
  35018. this.splice(i, 1);
  35019. break;
  35020. }
  35021. }
  35022. };
  35023. return collection;
  35024. }
  35025. /**
  35026. * Plugin used to merge cells in Handsontable.
  35027. *
  35028. * @private
  35029. * @plugin MergeCells
  35030. * @class MergeCells
  35031. */
  35032. function MergeCells(mergeCellsSetting) {
  35033. this.mergedCellInfoCollection = new CellInfoCollection();
  35034. if (Array.isArray(mergeCellsSetting)) {
  35035. for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) {
  35036. this.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  35037. }
  35038. }
  35039. }
  35040. /**
  35041. * @param cellRange (CellRange)
  35042. */
  35043. MergeCells.prototype.canMergeRange = function (cellRange) {
  35044. // is more than one cell selected
  35045. return !cellRange.isSingle();
  35046. };
  35047. MergeCells.prototype.mergeRange = function (cellRange) {
  35048. if (!this.canMergeRange(cellRange)) {
  35049. return;
  35050. }
  35051. // normalize top left corner
  35052. var topLeft = cellRange.getTopLeftCorner();
  35053. var bottomRight = cellRange.getBottomRightCorner();
  35054. var mergeParent = {};
  35055. mergeParent.row = topLeft.row;
  35056. mergeParent.col = topLeft.col;
  35057. // TD has rowspan == 1 by default. rowspan == 2 means spread over 2 cells
  35058. mergeParent.rowspan = bottomRight.row - topLeft.row + 1;
  35059. mergeParent.colspan = bottomRight.col - topLeft.col + 1;
  35060. this.mergedCellInfoCollection.setInfo(mergeParent);
  35061. };
  35062. MergeCells.prototype.mergeOrUnmergeSelection = function (cellRange) {
  35063. var info = this.mergedCellInfoCollection.getInfo(cellRange.from.row, cellRange.from.col);
  35064. if (info) {
  35065. // unmerge
  35066. this.unmergeSelection(cellRange.from);
  35067. } else {
  35068. // merge
  35069. this.mergeSelection(cellRange);
  35070. }
  35071. };
  35072. MergeCells.prototype.mergeSelection = function (cellRange) {
  35073. this.mergeRange(cellRange);
  35074. };
  35075. MergeCells.prototype.unmergeSelection = function (cellRange) {
  35076. var info = this.mergedCellInfoCollection.getInfo(cellRange.row, cellRange.col);
  35077. this.mergedCellInfoCollection.removeInfo(info.row, info.col);
  35078. };
  35079. MergeCells.prototype.applySpanProperties = function (TD, row, col) {
  35080. var info = this.mergedCellInfoCollection.getInfo(row, col);
  35081. if (info) {
  35082. if (info.row === row && info.col === col) {
  35083. TD.setAttribute('rowspan', info.rowspan);
  35084. TD.setAttribute('colspan', info.colspan);
  35085. } else {
  35086. TD.removeAttribute('rowspan');
  35087. TD.removeAttribute('colspan');
  35088. TD.style.display = 'none';
  35089. }
  35090. } else {
  35091. TD.removeAttribute('rowspan');
  35092. TD.removeAttribute('colspan');
  35093. }
  35094. };
  35095. MergeCells.prototype.modifyTransform = function (hook, currentSelectedRange, delta) {
  35096. var sameRowspan = function sameRowspan(merged, coords) {
  35097. if (coords.row >= merged.row && coords.row <= merged.row + merged.rowspan - 1) {
  35098. return true;
  35099. }
  35100. return false;
  35101. },
  35102. sameColspan = function sameColspan(merged, coords) {
  35103. if (coords.col >= merged.col && coords.col <= merged.col + merged.colspan - 1) {
  35104. return true;
  35105. }
  35106. return false;
  35107. },
  35108. getNextPosition = function getNextPosition(newDelta) {
  35109. return new _src.CellCoords(currentSelectedRange.to.row + newDelta.row, currentSelectedRange.to.col + newDelta.col);
  35110. };
  35111. var newDelta = {
  35112. row: delta.row,
  35113. col: delta.col
  35114. };
  35115. if (hook == 'modifyTransformStart') {
  35116. /* eslint-disable block-scoped-var */
  35117. var nextPosition;
  35118. if (!this.lastDesiredCoords) {
  35119. this.lastDesiredCoords = new _src.CellCoords(null, null);
  35120. }
  35121. var currentPosition = new _src.CellCoords(currentSelectedRange.highlight.row, currentSelectedRange.highlight.col),
  35122. // if current position's parent is a merged range, returns it
  35123. mergedParent = this.mergedCellInfoCollection.getInfo(currentPosition.row, currentPosition.col),
  35124. currentRangeContainsMerge; // if current range contains a merged range
  35125. for (var i = 0, mergesLength = this.mergedCellInfoCollection.length; i < mergesLength; i++) {
  35126. var range = this.mergedCellInfoCollection[i];
  35127. range = new _src.CellCoords(range.row + range.rowspan - 1, range.col + range.colspan - 1);
  35128. if (currentSelectedRange.includes(range)) {
  35129. currentRangeContainsMerge = true;
  35130. break;
  35131. }
  35132. }
  35133. if (mergedParent) {
  35134. // only merge selected
  35135. var mergeTopLeft = new _src.CellCoords(mergedParent.row, mergedParent.col);
  35136. var mergeBottomRight = new _src.CellCoords(mergedParent.row + mergedParent.rowspan - 1, mergedParent.col + mergedParent.colspan - 1);
  35137. var mergeRange = new _src.CellRange(mergeTopLeft, mergeTopLeft, mergeBottomRight);
  35138. if (!mergeRange.includes(this.lastDesiredCoords)) {
  35139. this.lastDesiredCoords = new _src.CellCoords(null, null); // reset outdated version of lastDesiredCoords
  35140. }
  35141. newDelta.row = this.lastDesiredCoords.row ? this.lastDesiredCoords.row - currentPosition.row : newDelta.row;
  35142. newDelta.col = this.lastDesiredCoords.col ? this.lastDesiredCoords.col - currentPosition.col : newDelta.col;
  35143. if (delta.row > 0) {
  35144. // moving down
  35145. newDelta.row = mergedParent.row + mergedParent.rowspan - 1 - currentPosition.row + delta.row;
  35146. } else if (delta.row < 0) {
  35147. // moving up
  35148. newDelta.row = currentPosition.row - mergedParent.row + delta.row;
  35149. }
  35150. if (delta.col > 0) {
  35151. // moving right
  35152. newDelta.col = mergedParent.col + mergedParent.colspan - 1 - currentPosition.col + delta.col;
  35153. } else if (delta.col < 0) {
  35154. // moving left
  35155. newDelta.col = currentPosition.col - mergedParent.col + delta.col;
  35156. }
  35157. }
  35158. nextPosition = new _src.CellCoords(currentSelectedRange.highlight.row + newDelta.row, currentSelectedRange.highlight.col + newDelta.col);
  35159. var nextParentIsMerged = this.mergedCellInfoCollection.getInfo(nextPosition.row, nextPosition.col);
  35160. if (nextParentIsMerged) {
  35161. // skipping the invisible cells in the merge range
  35162. this.lastDesiredCoords = nextPosition;
  35163. newDelta = {
  35164. row: nextParentIsMerged.row - currentPosition.row,
  35165. col: nextParentIsMerged.col - currentPosition.col
  35166. };
  35167. }
  35168. } else if (hook == 'modifyTransformEnd') {
  35169. for (var _i = 0, _mergesLength = this.mergedCellInfoCollection.length; _i < _mergesLength; _i++) {
  35170. var currentMerge = this.mergedCellInfoCollection[_i];
  35171. var _mergeTopLeft = new _src.CellCoords(currentMerge.row, currentMerge.col);
  35172. var _mergeBottomRight = new _src.CellCoords(currentMerge.row + currentMerge.rowspan - 1, currentMerge.col + currentMerge.colspan - 1);
  35173. var mergedRange = new _src.CellRange(_mergeTopLeft, _mergeTopLeft, _mergeBottomRight);
  35174. var sharedBorders = currentSelectedRange.getBordersSharedWith(mergedRange);
  35175. if (mergedRange.isEqual(currentSelectedRange)) {
  35176. // only the merged range is selected
  35177. currentSelectedRange.setDirection('NW-SE');
  35178. } else if (sharedBorders.length > 0) {
  35179. var mergeHighlighted = currentSelectedRange.highlight.isEqual(mergedRange.from);
  35180. if (sharedBorders.indexOf('top') > -1) {
  35181. // if range shares a border with the merged section, change range direction accordingly
  35182. if (currentSelectedRange.to.isSouthEastOf(mergedRange.from) && mergeHighlighted) {
  35183. currentSelectedRange.setDirection('NW-SE');
  35184. } else if (currentSelectedRange.to.isSouthWestOf(mergedRange.from) && mergeHighlighted) {
  35185. currentSelectedRange.setDirection('NE-SW');
  35186. }
  35187. } else if (sharedBorders.indexOf('bottom') > -1) {
  35188. if (currentSelectedRange.to.isNorthEastOf(mergedRange.from) && mergeHighlighted) {
  35189. currentSelectedRange.setDirection('SW-NE');
  35190. } else if (currentSelectedRange.to.isNorthWestOf(mergedRange.from) && mergeHighlighted) {
  35191. currentSelectedRange.setDirection('SE-NW');
  35192. }
  35193. }
  35194. }
  35195. nextPosition = getNextPosition(newDelta);
  35196. var withinRowspan = sameRowspan(currentMerge, nextPosition),
  35197. withinColspan = sameColspan(currentMerge, nextPosition);
  35198. if (currentSelectedRange.includesRange(mergedRange) && (mergedRange.includes(nextPosition) || withinRowspan || withinColspan)) {
  35199. // if next step overlaps a merged range, jump past it
  35200. if (withinRowspan) {
  35201. if (newDelta.row < 0) {
  35202. newDelta.row -= currentMerge.rowspan - 1;
  35203. } else if (newDelta.row > 0) {
  35204. newDelta.row += currentMerge.rowspan - 1;
  35205. }
  35206. }
  35207. if (withinColspan) {
  35208. if (newDelta.col < 0) {
  35209. newDelta.col -= currentMerge.colspan - 1;
  35210. } else if (newDelta.col > 0) {
  35211. newDelta.col += currentMerge.colspan - 1;
  35212. }
  35213. }
  35214. }
  35215. }
  35216. }
  35217. if (newDelta.row !== 0) {
  35218. delta.row = newDelta.row;
  35219. }
  35220. if (newDelta.col !== 0) {
  35221. delta.col = newDelta.col;
  35222. }
  35223. };
  35224. MergeCells.prototype.shiftCollection = function (direction, index, count) {
  35225. var shiftVector = [0, 0];
  35226. switch (direction) {
  35227. case 'right':
  35228. shiftVector[0] += 1;
  35229. break;
  35230. case 'left':
  35231. shiftVector[0] -= 1;
  35232. break;
  35233. case 'down':
  35234. shiftVector[1] += 1;
  35235. break;
  35236. case 'up':
  35237. shiftVector[1] -= 1;
  35238. break;
  35239. default:
  35240. break;
  35241. }
  35242. for (var i = 0; i < this.mergedCellInfoCollection.length; i++) {
  35243. var currentMerge = this.mergedCellInfoCollection[i];
  35244. if (direction === 'right' || direction === 'left') {
  35245. if (index <= currentMerge.col) {
  35246. currentMerge.col += shiftVector[0];
  35247. }
  35248. } else if (index <= currentMerge.row) {
  35249. currentMerge.row += shiftVector[1];
  35250. }
  35251. }
  35252. };
  35253. var beforeInit = function beforeInit() {
  35254. var instance = this;
  35255. var mergeCellsSetting = instance.getSettings().mergeCells;
  35256. if (mergeCellsSetting) {
  35257. if (!instance.mergeCells) {
  35258. instance.mergeCells = new MergeCells(mergeCellsSetting);
  35259. }
  35260. }
  35261. };
  35262. var afterInit = function afterInit() {
  35263. var instance = this;
  35264. if (instance.mergeCells) {
  35265. /**
  35266. * Monkey patch Table.prototype.getCell to return TD for merged cell parent if asked for TD of a cell that is
  35267. * 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!
  35268. */
  35269. instance.view.wt.wtTable.getCell = function (coords) {
  35270. if (instance.getSettings().mergeCells) {
  35271. var mergeParent = instance.mergeCells.mergedCellInfoCollection.getInfo(coords.row, coords.col);
  35272. if (mergeParent) {
  35273. coords = mergeParent;
  35274. }
  35275. }
  35276. return _src.Table.prototype.getCell.call(this, coords);
  35277. };
  35278. }
  35279. };
  35280. var afterUpdateSettings = function afterUpdateSettings() {
  35281. var instance = this;
  35282. var mergeCellsSetting = instance.getSettings().mergeCells;
  35283. if (mergeCellsSetting) {
  35284. if (instance.mergeCells) {
  35285. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  35286. if (Array.isArray(mergeCellsSetting)) {
  35287. for (var i = 0, ilen = mergeCellsSetting.length; i < ilen; i++) {
  35288. instance.mergeCells.mergedCellInfoCollection.setInfo(mergeCellsSetting[i]);
  35289. }
  35290. }
  35291. } else {
  35292. instance.mergeCells = new MergeCells(mergeCellsSetting);
  35293. }
  35294. } else if (instance.mergeCells) {
  35295. // it doesn't actually turn off the plugin, just resets the settings. Need to refactor.
  35296. instance.mergeCells.mergedCellInfoCollection = new CellInfoCollection();
  35297. }
  35298. };
  35299. var onBeforeKeyDown = function onBeforeKeyDown(event) {
  35300. if (!this.mergeCells) {
  35301. return;
  35302. }
  35303. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  35304. if (ctrlDown) {
  35305. if (event.keyCode === 77) {
  35306. // CTRL + M
  35307. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  35308. this.render();
  35309. (0, _event.stopImmediatePropagation)(event);
  35310. }
  35311. }
  35312. };
  35313. var addMergeActionsToContextMenu = function addMergeActionsToContextMenu(defaultOptions) {
  35314. if (!this.getSettings().mergeCells) {
  35315. return;
  35316. }
  35317. defaultOptions.items.push({ name: '---------' });
  35318. defaultOptions.items.push({
  35319. key: 'mergeCells',
  35320. name: function name() {
  35321. var sel = this.getSelected();
  35322. var info = this.mergeCells.mergedCellInfoCollection.getInfo(sel[0], sel[1]);
  35323. if (info) {
  35324. return 'Unmerge cells';
  35325. }
  35326. return 'Merge cells';
  35327. },
  35328. callback: function callback() {
  35329. this.mergeCells.mergeOrUnmergeSelection(this.getSelectedRange());
  35330. this.render();
  35331. },
  35332. disabled: function disabled() {
  35333. return this.selection.selectedHeader.corner;
  35334. }
  35335. });
  35336. };
  35337. var afterRenderer = function afterRenderer(TD, row, col, prop, value, cellProperties) {
  35338. if (this.mergeCells) {
  35339. this.mergeCells.applySpanProperties(TD, row, col);
  35340. }
  35341. };
  35342. var modifyTransformFactory = function modifyTransformFactory(hook) {
  35343. return function (delta) {
  35344. var mergeCellsSetting = this.getSettings().mergeCells;
  35345. if (mergeCellsSetting) {
  35346. var currentSelectedRange = this.getSelectedRange();
  35347. this.mergeCells.modifyTransform(hook, currentSelectedRange, delta);
  35348. if (hook === 'modifyTransformEnd') {
  35349. // sanitize "from" (core.js will sanitize to)
  35350. var totalRows = this.countRows();
  35351. var totalCols = this.countCols();
  35352. if (currentSelectedRange.from.row < 0) {
  35353. currentSelectedRange.from.row = 0;
  35354. } else if (currentSelectedRange.from.row > 0 && currentSelectedRange.from.row >= totalRows) {
  35355. currentSelectedRange.from.row = currentSelectedRange.from - 1;
  35356. }
  35357. if (currentSelectedRange.from.col < 0) {
  35358. currentSelectedRange.from.col = 0;
  35359. } else if (currentSelectedRange.from.col > 0 && currentSelectedRange.from.col >= totalCols) {
  35360. currentSelectedRange.from.col = totalCols - 1;
  35361. }
  35362. }
  35363. }
  35364. };
  35365. };
  35366. /**
  35367. * While selecting cells with keyboard or mouse, make sure that rectangular area is expanded to the extent of the merged cell
  35368. * @param coords
  35369. */
  35370. var beforeSetRangeEnd = function beforeSetRangeEnd(coords) {
  35371. this.lastDesiredCoords = null; // unset lastDesiredCoords when selection is changed with mouse
  35372. var mergeCellsSetting = this.getSettings().mergeCells;
  35373. if (mergeCellsSetting) {
  35374. var selRange = this.getSelectedRange();
  35375. selRange.highlight = new _src.CellCoords(selRange.highlight.row, selRange.highlight.col); // clone in case we will modify its reference
  35376. selRange.to = coords;
  35377. var rangeExpanded = false;
  35378. do {
  35379. rangeExpanded = false;
  35380. for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  35381. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  35382. var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col);
  35383. var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  35384. var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  35385. if (selRange.expandByRange(mergedCellRange)) {
  35386. coords.row = selRange.to.row;
  35387. coords.col = selRange.to.col;
  35388. rangeExpanded = true;
  35389. }
  35390. }
  35391. } while (rangeExpanded);
  35392. }
  35393. };
  35394. /**
  35395. * Returns correct coordinates for merged start / end cells in selection for area borders
  35396. * @param corners
  35397. * @param className
  35398. */
  35399. var beforeDrawAreaBorders = function beforeDrawAreaBorders(corners, className) {
  35400. if (className && className == 'area') {
  35401. var mergeCellsSetting = this.getSettings().mergeCells;
  35402. if (mergeCellsSetting) {
  35403. var selRange = this.getSelectedRange();
  35404. var startRange = new _src.CellRange(selRange.from, selRange.from, selRange.from);
  35405. var stopRange = new _src.CellRange(selRange.to, selRange.to, selRange.to);
  35406. for (var i = 0, ilen = this.mergeCells.mergedCellInfoCollection.length; i < ilen; i++) {
  35407. var cellInfo = this.mergeCells.mergedCellInfoCollection[i];
  35408. var mergedCellTopLeft = new _src.CellCoords(cellInfo.row, cellInfo.col);
  35409. var mergedCellBottomRight = new _src.CellCoords(cellInfo.row + cellInfo.rowspan - 1, cellInfo.col + cellInfo.colspan - 1);
  35410. var mergedCellRange = new _src.CellRange(mergedCellTopLeft, mergedCellTopLeft, mergedCellBottomRight);
  35411. if (startRange.expandByRange(mergedCellRange)) {
  35412. corners[0] = startRange.from.row;
  35413. corners[1] = startRange.from.col;
  35414. }
  35415. if (stopRange.expandByRange(mergedCellRange)) {
  35416. corners[2] = stopRange.from.row;
  35417. corners[3] = stopRange.from.col;
  35418. }
  35419. }
  35420. }
  35421. }
  35422. };
  35423. var afterGetCellMeta = function afterGetCellMeta(row, col, cellProperties) {
  35424. var mergeCellsSetting = this.getSettings().mergeCells;
  35425. if (mergeCellsSetting) {
  35426. var mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(row, col);
  35427. if (mergeParent && (mergeParent.row != row || mergeParent.col != col)) {
  35428. cellProperties.copyable = false;
  35429. }
  35430. }
  35431. };
  35432. var afterViewportRowCalculatorOverride = function afterViewportRowCalculatorOverride(calc) {
  35433. var mergeCellsSetting = this.getSettings().mergeCells;
  35434. if (mergeCellsSetting) {
  35435. var colCount = this.countCols();
  35436. var mergeParent;
  35437. for (var c = 0; c < colCount; c++) {
  35438. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.startRow, c);
  35439. if (mergeParent) {
  35440. if (mergeParent.row < calc.startRow) {
  35441. calc.startRow = mergeParent.row;
  35442. return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards
  35443. }
  35444. }
  35445. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(calc.endRow, c);
  35446. if (mergeParent) {
  35447. var mergeEnd = mergeParent.row + mergeParent.rowspan - 1;
  35448. if (mergeEnd > calc.endRow) {
  35449. calc.endRow = mergeEnd;
  35450. return afterViewportRowCalculatorOverride.call(this, calc); // recursively search upwards
  35451. }
  35452. }
  35453. }
  35454. }
  35455. };
  35456. var afterViewportColumnCalculatorOverride = function afterViewportColumnCalculatorOverride(calc) {
  35457. var mergeCellsSetting = this.getSettings().mergeCells;
  35458. if (mergeCellsSetting) {
  35459. var rowCount = this.countRows();
  35460. var mergeParent;
  35461. for (var r = 0; r < rowCount; r++) {
  35462. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.startColumn);
  35463. if (mergeParent) {
  35464. if (mergeParent.col < calc.startColumn) {
  35465. calc.startColumn = mergeParent.col;
  35466. return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards
  35467. }
  35468. }
  35469. mergeParent = this.mergeCells.mergedCellInfoCollection.getInfo(r, calc.endColumn);
  35470. if (mergeParent) {
  35471. var mergeEnd = mergeParent.col + mergeParent.colspan - 1;
  35472. if (mergeEnd > calc.endColumn) {
  35473. calc.endColumn = mergeEnd;
  35474. return afterViewportColumnCalculatorOverride.call(this, calc); // recursively search upwards
  35475. }
  35476. }
  35477. }
  35478. }
  35479. };
  35480. var isMultipleSelection = function isMultipleSelection(isMultiple) {
  35481. if (isMultiple && this.mergeCells) {
  35482. var mergedCells = this.mergeCells.mergedCellInfoCollection,
  35483. selectionRange = this.getSelectedRange();
  35484. for (var group in mergedCells) {
  35485. 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) {
  35486. return false;
  35487. }
  35488. }
  35489. }
  35490. return isMultiple;
  35491. };
  35492. function modifyAutofillRange(select, drag) {
  35493. var mergeCellsSetting = this.getSettings().mergeCells;
  35494. if (!mergeCellsSetting || this.selection.isMultiple()) {
  35495. return;
  35496. }
  35497. var info = this.mergeCells.mergedCellInfoCollection.getInfo(select[0], select[1]);
  35498. if (info) {
  35499. select[0] = info.row;
  35500. select[1] = info.col;
  35501. select[2] = info.row + info.rowspan - 1;
  35502. select[3] = info.col + info.colspan - 1;
  35503. }
  35504. }
  35505. function onAfterCreateCol(col, count) {
  35506. if (this.mergeCells) {
  35507. this.mergeCells.shiftCollection('right', col, count);
  35508. }
  35509. }
  35510. function onAfterRemoveCol(col, count) {
  35511. if (this.mergeCells) {
  35512. this.mergeCells.shiftCollection('left', col, count);
  35513. }
  35514. }
  35515. function onAfterCreateRow(row, count) {
  35516. if (this.mergeCells) {
  35517. this.mergeCells.shiftCollection('down', row, count);
  35518. }
  35519. }
  35520. function onAfterRemoveRow(row, count) {
  35521. if (this.mergeCells) {
  35522. this.mergeCells.shiftCollection('up', row, count);
  35523. }
  35524. }
  35525. var hook = _pluginHooks2.default.getSingleton();
  35526. hook.add('beforeInit', beforeInit);
  35527. hook.add('afterInit', afterInit);
  35528. hook.add('afterUpdateSettings', afterUpdateSettings);
  35529. hook.add('beforeKeyDown', onBeforeKeyDown);
  35530. hook.add('modifyTransformStart', modifyTransformFactory('modifyTransformStart'));
  35531. hook.add('modifyTransformEnd', modifyTransformFactory('modifyTransformEnd'));
  35532. hook.add('beforeSetRangeEnd', beforeSetRangeEnd);
  35533. hook.add('beforeDrawBorders', beforeDrawAreaBorders);
  35534. hook.add('afterIsMultipleSelection', isMultipleSelection);
  35535. hook.add('afterRenderer', afterRenderer);
  35536. hook.add('afterContextMenuDefaultOptions', addMergeActionsToContextMenu);
  35537. hook.add('afterGetCellMeta', afterGetCellMeta);
  35538. hook.add('afterViewportRowCalculatorOverride', afterViewportRowCalculatorOverride);
  35539. hook.add('afterViewportColumnCalculatorOverride', afterViewportColumnCalculatorOverride);
  35540. hook.add('modifyAutofillRange', modifyAutofillRange);
  35541. hook.add('afterCreateCol', onAfterCreateCol);
  35542. hook.add('afterRemoveCol', onAfterRemoveCol);
  35543. hook.add('afterCreateRow', onAfterCreateRow);
  35544. hook.add('afterRemoveRow', onAfterRemoveRow);
  35545. exports.default = MergeCells;
  35546. /***/ }),
  35547. /* 254 */
  35548. /***/ (function(module, exports, __webpack_require__) {
  35549. "use strict";
  35550. exports.__esModule = true;
  35551. 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; }; }();
  35552. 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); } };
  35553. var _pluginHooks = __webpack_require__(8);
  35554. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  35555. var _element = __webpack_require__(0);
  35556. var _browser = __webpack_require__(25);
  35557. var _base = __webpack_require__(12);
  35558. var _base2 = _interopRequireDefault(_base);
  35559. var _eventManager = __webpack_require__(4);
  35560. var _eventManager2 = _interopRequireDefault(_eventManager);
  35561. var _plugins = __webpack_require__(5);
  35562. var _src = __webpack_require__(11);
  35563. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35564. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35565. 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; }
  35566. 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; }
  35567. /**
  35568. * @private
  35569. * @plugin MultipleSelectionHandles
  35570. */
  35571. var MultipleSelectionHandles = function (_BasePlugin) {
  35572. _inherits(MultipleSelectionHandles, _BasePlugin);
  35573. /**
  35574. * @param {Object} hotInstance
  35575. */
  35576. function MultipleSelectionHandles(hotInstance) {
  35577. _classCallCheck(this, MultipleSelectionHandles);
  35578. /**
  35579. * @type {Array}
  35580. */
  35581. var _this2 = _possibleConstructorReturn(this, (MultipleSelectionHandles.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles)).call(this, hotInstance));
  35582. _this2.dragged = [];
  35583. /**
  35584. * Instance of EventManager.
  35585. *
  35586. * @type {EventManager}
  35587. */
  35588. _this2.eventManager = null;
  35589. /**
  35590. * @type {null}
  35591. */
  35592. _this2.lastSetCell = null;
  35593. return _this2;
  35594. }
  35595. /**
  35596. * Check if the plugin is enabled in the handsontable settings.
  35597. *
  35598. * @returns {Boolean}
  35599. */
  35600. _createClass(MultipleSelectionHandles, [{
  35601. key: 'isEnabled',
  35602. value: function isEnabled() {
  35603. return (0, _browser.isMobileBrowser)();
  35604. }
  35605. /**
  35606. * Enable plugin for this Handsontable instance.
  35607. */
  35608. }, {
  35609. key: 'enablePlugin',
  35610. value: function enablePlugin() {
  35611. if (this.enabled) {
  35612. return;
  35613. }
  35614. if (!this.eventManager) {
  35615. this.eventManager = new _eventManager2.default(this);
  35616. }
  35617. this.registerListeners();
  35618. _get(MultipleSelectionHandles.prototype.__proto__ || Object.getPrototypeOf(MultipleSelectionHandles.prototype), 'enablePlugin', this).call(this);
  35619. }
  35620. /**
  35621. * Bind the touch events
  35622. * @private
  35623. */
  35624. }, {
  35625. key: 'registerListeners',
  35626. value: function registerListeners() {
  35627. var _this = this;
  35628. function removeFromDragged(query) {
  35629. if (_this.dragged.length === 1) {
  35630. // clear array
  35631. _this.dragged.splice(0, _this.dragged.length);
  35632. return true;
  35633. }
  35634. var entryPosition = _this.dragged.indexOf(query);
  35635. if (entryPosition == -1) {
  35636. return false;
  35637. } else if (entryPosition === 0) {
  35638. _this.dragged = _this.dragged.slice(0, 1);
  35639. } else if (entryPosition == 1) {
  35640. _this.dragged = _this.dragged.slice(-1);
  35641. }
  35642. }
  35643. this.eventManager.addEventListener(this.hot.rootElement, 'touchstart', function (event) {
  35644. var selectedRange = void 0;
  35645. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  35646. selectedRange = _this.hot.getSelectedRange();
  35647. _this.dragged.push('topLeft');
  35648. _this.touchStartRange = {
  35649. width: selectedRange.getWidth(),
  35650. height: selectedRange.getHeight(),
  35651. direction: selectedRange.getDirection()
  35652. };
  35653. event.preventDefault();
  35654. return false;
  35655. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  35656. selectedRange = _this.hot.getSelectedRange();
  35657. _this.dragged.push('bottomRight');
  35658. _this.touchStartRange = {
  35659. width: selectedRange.getWidth(),
  35660. height: selectedRange.getHeight(),
  35661. direction: selectedRange.getDirection()
  35662. };
  35663. event.preventDefault();
  35664. return false;
  35665. }
  35666. });
  35667. this.eventManager.addEventListener(this.hot.rootElement, 'touchend', function (event) {
  35668. if ((0, _element.hasClass)(event.target, 'topLeftSelectionHandle-HitArea')) {
  35669. removeFromDragged.call(_this, 'topLeft');
  35670. _this.touchStartRange = void 0;
  35671. event.preventDefault();
  35672. return false;
  35673. } else if ((0, _element.hasClass)(event.target, 'bottomRightSelectionHandle-HitArea')) {
  35674. removeFromDragged.call(_this, 'bottomRight');
  35675. _this.touchStartRange = void 0;
  35676. event.preventDefault();
  35677. return false;
  35678. }
  35679. });
  35680. this.eventManager.addEventListener(this.hot.rootElement, 'touchmove', function (event) {
  35681. var scrollTop = (0, _element.getWindowScrollTop)(),
  35682. scrollLeft = (0, _element.getWindowScrollLeft)(),
  35683. endTarget = void 0,
  35684. targetCoords = void 0,
  35685. selectedRange = void 0,
  35686. rangeWidth = void 0,
  35687. rangeHeight = void 0,
  35688. rangeDirection = void 0,
  35689. newRangeCoords = void 0;
  35690. if (_this.dragged.length === 0) {
  35691. return;
  35692. }
  35693. endTarget = document.elementFromPoint(event.touches[0].screenX - scrollLeft, event.touches[0].screenY - scrollTop);
  35694. if (!endTarget || endTarget === _this.lastSetCell) {
  35695. return;
  35696. }
  35697. if (endTarget.nodeName == 'TD' || endTarget.nodeName == 'TH') {
  35698. targetCoords = _this.hot.getCoords(endTarget);
  35699. if (targetCoords.col == -1) {
  35700. targetCoords.col = 0;
  35701. }
  35702. selectedRange = _this.hot.getSelectedRange();
  35703. rangeWidth = selectedRange.getWidth();
  35704. rangeHeight = selectedRange.getHeight();
  35705. rangeDirection = selectedRange.getDirection();
  35706. if (rangeWidth == 1 && rangeHeight == 1) {
  35707. _this.hot.selection.setRangeEnd(targetCoords);
  35708. }
  35709. newRangeCoords = _this.getCurrentRangeCoords(selectedRange, targetCoords, _this.touchStartRange.direction, rangeDirection, _this.dragged[0]);
  35710. if (newRangeCoords.start !== null) {
  35711. _this.hot.selection.setRangeStart(newRangeCoords.start);
  35712. }
  35713. _this.hot.selection.setRangeEnd(newRangeCoords.end);
  35714. _this.lastSetCell = endTarget;
  35715. }
  35716. event.preventDefault();
  35717. });
  35718. }
  35719. }, {
  35720. key: 'getCurrentRangeCoords',
  35721. value: function getCurrentRangeCoords(selectedRange, currentTouch, touchStartDirection, currentDirection, draggedHandle) {
  35722. var topLeftCorner = selectedRange.getTopLeftCorner(),
  35723. bottomRightCorner = selectedRange.getBottomRightCorner(),
  35724. bottomLeftCorner = selectedRange.getBottomLeftCorner(),
  35725. topRightCorner = selectedRange.getTopRightCorner();
  35726. var newCoords = {
  35727. start: null,
  35728. end: null
  35729. };
  35730. switch (touchStartDirection) {
  35731. case 'NE-SW':
  35732. switch (currentDirection) {
  35733. case 'NE-SW':
  35734. case 'NW-SE':
  35735. if (draggedHandle == 'topLeft') {
  35736. newCoords = {
  35737. start: new _src.CellCoords(currentTouch.row, selectedRange.highlight.col),
  35738. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  35739. };
  35740. } else {
  35741. newCoords = {
  35742. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  35743. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  35744. };
  35745. }
  35746. break;
  35747. case 'SE-NW':
  35748. if (draggedHandle == 'bottomRight') {
  35749. newCoords = {
  35750. start: new _src.CellCoords(bottomRightCorner.row, currentTouch.col),
  35751. end: new _src.CellCoords(currentTouch.row, topLeftCorner.col)
  35752. };
  35753. }
  35754. break;
  35755. default:
  35756. break;
  35757. }
  35758. break;
  35759. case 'NW-SE':
  35760. switch (currentDirection) {
  35761. case 'NE-SW':
  35762. if (draggedHandle == 'topLeft') {
  35763. newCoords = {
  35764. start: currentTouch,
  35765. end: bottomLeftCorner
  35766. };
  35767. } else {
  35768. newCoords.end = currentTouch;
  35769. }
  35770. break;
  35771. case 'NW-SE':
  35772. if (draggedHandle == 'topLeft') {
  35773. newCoords = {
  35774. start: currentTouch,
  35775. end: bottomRightCorner
  35776. };
  35777. } else {
  35778. newCoords.end = currentTouch;
  35779. }
  35780. break;
  35781. case 'SE-NW':
  35782. if (draggedHandle == 'topLeft') {
  35783. newCoords = {
  35784. start: currentTouch,
  35785. end: topLeftCorner
  35786. };
  35787. } else {
  35788. newCoords.end = currentTouch;
  35789. }
  35790. break;
  35791. case 'SW-NE':
  35792. if (draggedHandle == 'topLeft') {
  35793. newCoords = {
  35794. start: currentTouch,
  35795. end: topRightCorner
  35796. };
  35797. } else {
  35798. newCoords.end = currentTouch;
  35799. }
  35800. break;
  35801. default:
  35802. break;
  35803. }
  35804. break;
  35805. case 'SW-NE':
  35806. switch (currentDirection) {
  35807. case 'NW-SE':
  35808. if (draggedHandle == 'bottomRight') {
  35809. newCoords = {
  35810. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  35811. end: new _src.CellCoords(bottomLeftCorner.row, currentTouch.col)
  35812. };
  35813. } else {
  35814. newCoords = {
  35815. start: new _src.CellCoords(topLeftCorner.row, currentTouch.col),
  35816. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  35817. };
  35818. }
  35819. break;
  35820. // case 'NE-SW':
  35821. //
  35822. // break;
  35823. case 'SW-NE':
  35824. if (draggedHandle == 'topLeft') {
  35825. newCoords = {
  35826. start: new _src.CellCoords(selectedRange.highlight.row, currentTouch.col),
  35827. end: new _src.CellCoords(currentTouch.row, bottomRightCorner.col)
  35828. };
  35829. } else {
  35830. newCoords = {
  35831. start: new _src.CellCoords(currentTouch.row, topLeftCorner.col),
  35832. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  35833. };
  35834. }
  35835. break;
  35836. case 'SE-NW':
  35837. if (draggedHandle == 'bottomRight') {
  35838. newCoords = {
  35839. start: new _src.CellCoords(currentTouch.row, topRightCorner.col),
  35840. end: new _src.CellCoords(topLeftCorner.row, currentTouch.col)
  35841. };
  35842. } else if (draggedHandle == 'topLeft') {
  35843. newCoords = {
  35844. start: bottomLeftCorner,
  35845. end: currentTouch
  35846. };
  35847. }
  35848. break;
  35849. default:
  35850. break;
  35851. }
  35852. break;
  35853. case 'SE-NW':
  35854. switch (currentDirection) {
  35855. case 'NW-SE':
  35856. case 'NE-SW':
  35857. case 'SW-NE':
  35858. if (draggedHandle == 'topLeft') {
  35859. newCoords.end = currentTouch;
  35860. }
  35861. break;
  35862. case 'SE-NW':
  35863. if (draggedHandle == 'topLeft') {
  35864. newCoords.end = currentTouch;
  35865. } else {
  35866. newCoords = {
  35867. start: currentTouch,
  35868. end: topLeftCorner
  35869. };
  35870. }
  35871. break;
  35872. default:
  35873. break;
  35874. }
  35875. break;
  35876. default:
  35877. break;
  35878. }
  35879. return newCoords;
  35880. }
  35881. /**
  35882. * Check if user is currently dragging the handle.
  35883. *
  35884. * @returns {boolean} Dragging state
  35885. */
  35886. }, {
  35887. key: 'isDragged',
  35888. value: function isDragged() {
  35889. return this.dragged.length > 0;
  35890. }
  35891. }]);
  35892. return MultipleSelectionHandles;
  35893. }(_base2.default);
  35894. (0, _plugins.registerPlugin)('multipleSelectionHandles', MultipleSelectionHandles);
  35895. exports.default = MultipleSelectionHandles;
  35896. /***/ }),
  35897. /* 255 */
  35898. /***/ (function(module, exports, __webpack_require__) {
  35899. "use strict";
  35900. exports.__esModule = true;
  35901. 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; }; }();
  35902. var _jsonPatchDuplex = __webpack_require__(134);
  35903. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  35904. var _localHooks = __webpack_require__(69);
  35905. var _localHooks2 = _interopRequireDefault(_localHooks);
  35906. var _object = __webpack_require__(1);
  35907. var _utils = __webpack_require__(257);
  35908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  35909. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  35910. /**
  35911. * @class DataObserver
  35912. * @plugin ObserveChanges
  35913. */
  35914. var DataObserver = function () {
  35915. function DataObserver(observedData) {
  35916. _classCallCheck(this, DataObserver);
  35917. /**
  35918. * Observed source data.
  35919. *
  35920. * @type {Array}
  35921. */
  35922. this.observedData = null;
  35923. /**
  35924. * JsonPatch observer.
  35925. *
  35926. * @type {Object}
  35927. */
  35928. this.observer = null;
  35929. /**
  35930. * Flag which determines if observer is paused or not. Paused observer doesn't emit `change` hooks.
  35931. *
  35932. * @type {Boolean}
  35933. * @default false
  35934. */
  35935. this.paused = false;
  35936. this.setObservedData(observedData);
  35937. }
  35938. /**
  35939. * Set data to observe.
  35940. *
  35941. * @param {*} observedData
  35942. */
  35943. _createClass(DataObserver, [{
  35944. key: 'setObservedData',
  35945. value: function setObservedData(observedData) {
  35946. var _this = this;
  35947. if (this.observer) {
  35948. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  35949. }
  35950. this.observedData = observedData;
  35951. this.observer = _jsonPatchDuplex2.default.observe(this.observedData, function (patches) {
  35952. return _this.onChange(patches);
  35953. });
  35954. }
  35955. /**
  35956. * Check if observer was paused.
  35957. *
  35958. * @returns {Boolean}
  35959. */
  35960. }, {
  35961. key: 'isPaused',
  35962. value: function isPaused() {
  35963. return this.paused;
  35964. }
  35965. /**
  35966. * Pause observer (stop emitting all detected changes).
  35967. */
  35968. }, {
  35969. key: 'pause',
  35970. value: function pause() {
  35971. this.paused = true;
  35972. }
  35973. /**
  35974. * Resume observer (emit all detected changes).
  35975. */
  35976. }, {
  35977. key: 'resume',
  35978. value: function resume() {
  35979. this.paused = false;
  35980. }
  35981. /**
  35982. * JsonPatch on change listener.
  35983. *
  35984. * @private
  35985. * @param {Array} patches An array of object passed from jsonpatch.
  35986. */
  35987. }, {
  35988. key: 'onChange',
  35989. value: function onChange(patches) {
  35990. this.runLocalHooks('change', (0, _utils.cleanPatches)(patches));
  35991. }
  35992. /**
  35993. * Destroy observer instance.
  35994. */
  35995. }, {
  35996. key: 'destroy',
  35997. value: function destroy() {
  35998. _jsonPatchDuplex2.default.unobserve(this.observedData, this.observer);
  35999. this.observedData = null;
  36000. this.observer = null;
  36001. }
  36002. }]);
  36003. return DataObserver;
  36004. }();
  36005. (0, _object.mixin)(DataObserver, _localHooks2.default);
  36006. exports.default = DataObserver;
  36007. /***/ }),
  36008. /* 256 */
  36009. /***/ (function(module, exports, __webpack_require__) {
  36010. "use strict";
  36011. exports.__esModule = true;
  36012. 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; }; }();
  36013. 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); } };
  36014. var _base = __webpack_require__(12);
  36015. var _base2 = _interopRequireDefault(_base);
  36016. var _jsonPatchDuplex = __webpack_require__(134);
  36017. var _jsonPatchDuplex2 = _interopRequireDefault(_jsonPatchDuplex);
  36018. var _dataObserver = __webpack_require__(255);
  36019. var _dataObserver2 = _interopRequireDefault(_dataObserver);
  36020. var _array = __webpack_require__(2);
  36021. var _plugins = __webpack_require__(5);
  36022. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36024. 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; }
  36025. 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; }
  36026. // Handsontable.hooks.register('afterChangesObserved');
  36027. /**
  36028. * @plugin ObserveChanges
  36029. *
  36030. * @description
  36031. * This plugin allows to observe data source changes.
  36032. *
  36033. * By default, the plugin is declared as `undefined`, which makes it disabled.
  36034. * Enabling this plugin switches the table into one-way data binding where changes are applied into the data source (outside from the table)
  36035. * will be automatically reflected in the table.
  36036. *
  36037. * ```js
  36038. * ...
  36039. * // as a boolean
  36040. * observeChanges: true,
  36041. * ...
  36042. * ```
  36043. *
  36044. * To configure this plugin see {@link Options#observeChanges}.
  36045. */
  36046. var ObserveChanges = function (_BasePlugin) {
  36047. _inherits(ObserveChanges, _BasePlugin);
  36048. function ObserveChanges(hotInstance) {
  36049. _classCallCheck(this, ObserveChanges);
  36050. /**
  36051. * Instance of {@link DataObserver}.
  36052. *
  36053. * @type {DataObserver}
  36054. */
  36055. var _this = _possibleConstructorReturn(this, (ObserveChanges.__proto__ || Object.getPrototypeOf(ObserveChanges)).call(this, hotInstance));
  36056. _this.observer = null;
  36057. return _this;
  36058. }
  36059. /**
  36060. * Check if the plugin is enabled in the handsontable settings.
  36061. *
  36062. * @returns {Boolean}
  36063. */
  36064. _createClass(ObserveChanges, [{
  36065. key: 'isEnabled',
  36066. value: function isEnabled() {
  36067. return this.hot.getSettings().observeChanges;
  36068. }
  36069. /**
  36070. * Enable plugin for this Handsontable instance.
  36071. */
  36072. }, {
  36073. key: 'enablePlugin',
  36074. value: function enablePlugin() {
  36075. var _this2 = this;
  36076. if (this.enabled) {
  36077. return;
  36078. }
  36079. if (!this.observer) {
  36080. this.observer = new _dataObserver2.default(this.hot.getSourceData());
  36081. this._exposePublicApi();
  36082. }
  36083. this.observer.addLocalHook('change', function (patches) {
  36084. return _this2.onDataChange(patches);
  36085. });
  36086. this.addHook('afterCreateRow', function () {
  36087. return _this2.onAfterTableAlter();
  36088. });
  36089. this.addHook('afterRemoveRow', function () {
  36090. return _this2.onAfterTableAlter();
  36091. });
  36092. this.addHook('afterCreateCol', function () {
  36093. return _this2.onAfterTableAlter();
  36094. });
  36095. this.addHook('afterRemoveCol', function () {
  36096. return _this2.onAfterTableAlter();
  36097. });
  36098. this.addHook('afterChange', function (changes, source) {
  36099. return _this2.onAfterTableAlter(source);
  36100. });
  36101. this.addHook('afterLoadData', function (firstRun) {
  36102. return _this2.onAfterLoadData(firstRun);
  36103. });
  36104. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'enablePlugin', this).call(this);
  36105. }
  36106. /**
  36107. * Disable plugin for this Handsontable instance.
  36108. */
  36109. }, {
  36110. key: 'disablePlugin',
  36111. value: function disablePlugin() {
  36112. if (this.observer) {
  36113. this.observer.destroy();
  36114. this.observer = null;
  36115. this._deletePublicApi();
  36116. }
  36117. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'disablePlugin', this).call(this);
  36118. }
  36119. /**
  36120. * Data change observer.
  36121. *
  36122. * @private
  36123. * @param {Array} patches An array of objects which every item defines coordinates where data was changed.
  36124. */
  36125. }, {
  36126. key: 'onDataChange',
  36127. value: function onDataChange(patches) {
  36128. var _this3 = this;
  36129. if (!this.observer.isPaused()) {
  36130. var sourceName = this.pluginName + '.change';
  36131. var actions = {
  36132. add: function add(patch) {
  36133. if (isNaN(patch.col)) {
  36134. _this3.hot.runHooks('afterCreateRow', patch.row, 1, sourceName);
  36135. } else {
  36136. _this3.hot.runHooks('afterCreateCol', patch.col, 1, sourceName);
  36137. }
  36138. },
  36139. remove: function remove(patch) {
  36140. if (isNaN(patch.col)) {
  36141. _this3.hot.runHooks('afterRemoveRow', patch.row, 1, sourceName);
  36142. } else {
  36143. _this3.hot.runHooks('afterRemoveCol', patch.col, 1, sourceName);
  36144. }
  36145. },
  36146. replace: function replace(patch) {
  36147. _this3.hot.runHooks('afterChange', [patch.row, patch.col, null, patch.value], sourceName);
  36148. }
  36149. };
  36150. (0, _array.arrayEach)(patches, function (patch) {
  36151. if (actions[patch.op]) {
  36152. actions[patch.op](patch);
  36153. }
  36154. });
  36155. this.hot.render();
  36156. }
  36157. this.hot.runHooks('afterChangesObserved');
  36158. }
  36159. /**
  36160. * On after table alter listener. Prevents infinity loop between internal and external data changing.
  36161. *
  36162. * @private
  36163. * @param source
  36164. */
  36165. }, {
  36166. key: 'onAfterTableAlter',
  36167. value: function onAfterTableAlter(source) {
  36168. var _this4 = this;
  36169. if (source !== 'loadData') {
  36170. this.observer.pause();
  36171. this.hot.addHookOnce('afterChangesObserved', function () {
  36172. return _this4.observer.resume();
  36173. });
  36174. }
  36175. }
  36176. /**
  36177. * On after load data listener.
  36178. *
  36179. * @private
  36180. * @param {Boolean} firstRun `true` if event was fired first time.
  36181. */
  36182. }, {
  36183. key: 'onAfterLoadData',
  36184. value: function onAfterLoadData(firstRun) {
  36185. if (!firstRun) {
  36186. this.observer.setObservedData(this.hot.getSourceData());
  36187. }
  36188. }
  36189. /**
  36190. * Destroy plugin instance.
  36191. */
  36192. }, {
  36193. key: 'destroy',
  36194. value: function destroy() {
  36195. if (this.observer) {
  36196. this.observer.destroy();
  36197. this._deletePublicApi();
  36198. }
  36199. _get(ObserveChanges.prototype.__proto__ || Object.getPrototypeOf(ObserveChanges.prototype), 'destroy', this).call(this);
  36200. }
  36201. /**
  36202. * Expose plugins methods to the core.
  36203. *
  36204. * @private
  36205. */
  36206. }, {
  36207. key: '_exposePublicApi',
  36208. value: function _exposePublicApi() {
  36209. var _this5 = this;
  36210. var hot = this.hot;
  36211. hot.pauseObservingChanges = function () {
  36212. return _this5.observer.pause();
  36213. };
  36214. hot.resumeObservingChanges = function () {
  36215. return _this5.observer.resume();
  36216. };
  36217. hot.isPausedObservingChanges = function () {
  36218. return _this5.observer.isPaused();
  36219. };
  36220. }
  36221. /**
  36222. * Delete all previously exposed methods.
  36223. *
  36224. * @private
  36225. */
  36226. }, {
  36227. key: '_deletePublicApi',
  36228. value: function _deletePublicApi() {
  36229. var hot = this.hot;
  36230. delete hot.pauseObservingChanges;
  36231. delete hot.resumeObservingChanges;
  36232. delete hot.isPausedObservingChanges;
  36233. }
  36234. }]);
  36235. return ObserveChanges;
  36236. }(_base2.default);
  36237. exports.default = ObserveChanges;
  36238. (0, _plugins.registerPlugin)('observeChanges', ObserveChanges);
  36239. /***/ }),
  36240. /* 257 */
  36241. /***/ (function(module, exports, __webpack_require__) {
  36242. "use strict";
  36243. exports.__esModule = true;
  36244. 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"); } }; }();
  36245. exports.cleanPatches = cleanPatches;
  36246. exports.parsePath = parsePath;
  36247. var _array = __webpack_require__(2);
  36248. /**
  36249. * Clean and extend patches from jsonpatch observer.
  36250. *
  36251. * @param {Array} patches
  36252. * @returns {Array}
  36253. */
  36254. function cleanPatches(patches) {
  36255. var newOrRemovedColumns = [];
  36256. /**
  36257. * If observeChanges uses native Object.observe method, then it produces patches for length property. Filter them.
  36258. * If path can't be parsed. Filter it.
  36259. */
  36260. patches = (0, _array.arrayFilter)(patches, function (patch) {
  36261. if (/[/]length/ig.test(patch.path)) {
  36262. return false;
  36263. }
  36264. if (!parsePath(patch.path)) {
  36265. return false;
  36266. }
  36267. return true;
  36268. });
  36269. /**
  36270. * Extend patches with changed cells coords
  36271. */
  36272. patches = (0, _array.arrayMap)(patches, function (patch) {
  36273. var coords = parsePath(patch.path);
  36274. patch.row = coords.row;
  36275. patch.col = coords.col;
  36276. return patch;
  36277. });
  36278. /**
  36279. * Removing or adding column will produce one patch for each table row.
  36280. * Leaves only one patch for each column add/remove operation.
  36281. */
  36282. patches = (0, _array.arrayFilter)(patches, function (patch) {
  36283. if (['add', 'remove'].indexOf(patch.op) !== -1 && !isNaN(patch.col)) {
  36284. if (newOrRemovedColumns.indexOf(patch.col) !== -1) {
  36285. return false;
  36286. }
  36287. newOrRemovedColumns.push(patch.col);
  36288. }
  36289. return true;
  36290. });
  36291. newOrRemovedColumns.length = 0;
  36292. return patches;
  36293. }
  36294. /**
  36295. * Extract coordinates from path where data was changed.
  36296. *
  36297. * @param {String} path Path describing where data was changed.
  36298. * @returns {Object|null} Returns an object with `row` and `col` properties or `null` if path doesn't have necessary information.
  36299. */
  36300. function parsePath(path) {
  36301. var match = path.match(/^\/(\d+)\/?(.*)?$/);
  36302. if (!match) {
  36303. return null;
  36304. }
  36305. var _match = _slicedToArray(match, 3),
  36306. row = _match[1],
  36307. column = _match[2];
  36308. return {
  36309. row: parseInt(row, 10),
  36310. col: /^\d*$/.test(column) ? parseInt(column, 10) : column
  36311. };
  36312. }
  36313. /***/ }),
  36314. /* 258 */
  36315. /***/ (function(module, exports, __webpack_require__) {
  36316. "use strict";
  36317. exports.__esModule = true;
  36318. var _pluginHooks = __webpack_require__(8);
  36319. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36320. var _plugins = __webpack_require__(5);
  36321. var _object = __webpack_require__(1);
  36322. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36323. function Storage(prefix) {
  36324. var savedKeys;
  36325. var saveSavedKeys = function saveSavedKeys() {
  36326. window.localStorage[prefix + '__persistentStateKeys'] = JSON.stringify(savedKeys);
  36327. };
  36328. var loadSavedKeys = function loadSavedKeys() {
  36329. var keysJSON = window.localStorage[prefix + '__persistentStateKeys'];
  36330. var keys = typeof keysJSON == 'string' ? JSON.parse(keysJSON) : void 0;
  36331. savedKeys = keys ? keys : [];
  36332. };
  36333. var clearSavedKeys = function clearSavedKeys() {
  36334. savedKeys = [];
  36335. saveSavedKeys();
  36336. };
  36337. loadSavedKeys();
  36338. this.saveValue = function (key, value) {
  36339. window.localStorage[prefix + '_' + key] = JSON.stringify(value);
  36340. if (savedKeys.indexOf(key) == -1) {
  36341. savedKeys.push(key);
  36342. saveSavedKeys();
  36343. }
  36344. };
  36345. this.loadValue = function (key, defaultValue) {
  36346. key = typeof key === 'undefined' ? defaultValue : key;
  36347. var value = window.localStorage[prefix + '_' + key];
  36348. return typeof value == 'undefined' ? void 0 : JSON.parse(value);
  36349. };
  36350. this.reset = function (key) {
  36351. window.localStorage.removeItem(prefix + '_' + key);
  36352. };
  36353. this.resetAll = function () {
  36354. for (var index = 0; index < savedKeys.length; index++) {
  36355. window.localStorage.removeItem(prefix + '_' + savedKeys[index]);
  36356. }
  36357. clearSavedKeys();
  36358. };
  36359. }
  36360. /**
  36361. * @private
  36362. * @class PersistentState
  36363. * @plugin PersistentState
  36364. */
  36365. function HandsontablePersistentState() {
  36366. var plugin = this;
  36367. this.init = function () {
  36368. var instance = this,
  36369. pluginSettings = instance.getSettings().persistentState;
  36370. plugin.enabled = !!pluginSettings;
  36371. if (!plugin.enabled) {
  36372. removeHooks.call(instance);
  36373. return;
  36374. }
  36375. if (!instance.storage) {
  36376. instance.storage = new Storage(instance.rootElement.id);
  36377. }
  36378. instance.resetState = plugin.resetValue;
  36379. addHooks.call(instance);
  36380. };
  36381. this.saveValue = function (key, value) {
  36382. var instance = this;
  36383. instance.storage.saveValue(key, value);
  36384. };
  36385. this.loadValue = function (key, saveTo) {
  36386. var instance = this;
  36387. saveTo.value = instance.storage.loadValue(key);
  36388. };
  36389. this.resetValue = function (key) {
  36390. var instance = this;
  36391. if (typeof key === 'undefined') {
  36392. instance.storage.resetAll();
  36393. } else {
  36394. instance.storage.reset(key);
  36395. }
  36396. };
  36397. var hooks = {
  36398. persistentStateSave: plugin.saveValue,
  36399. persistentStateLoad: plugin.loadValue,
  36400. persistentStateReset: plugin.resetValue
  36401. };
  36402. for (var hookName in hooks) {
  36403. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  36404. _pluginHooks2.default.getSingleton().register(hookName);
  36405. }
  36406. }
  36407. function addHooks() {
  36408. var instance = this;
  36409. for (var hookName in hooks) {
  36410. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  36411. instance.addHook(hookName, hooks[hookName]);
  36412. }
  36413. }
  36414. }
  36415. function removeHooks() {
  36416. var instance = this;
  36417. for (var hookName in hooks) {
  36418. if ((0, _object.hasOwnProperty)(hooks, hookName)) {
  36419. instance.removeHook(hookName, hooks[hookName]);
  36420. }
  36421. }
  36422. }
  36423. }
  36424. var htPersistentState = new HandsontablePersistentState();
  36425. _pluginHooks2.default.getSingleton().add('beforeInit', htPersistentState.init);
  36426. _pluginHooks2.default.getSingleton().add('afterUpdateSettings', htPersistentState.init);
  36427. exports.default = HandsontablePersistentState;
  36428. /***/ }),
  36429. /* 259 */
  36430. /***/ (function(module, exports, __webpack_require__) {
  36431. "use strict";
  36432. exports.__esModule = true;
  36433. 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; };
  36434. var _pluginHooks = __webpack_require__(8);
  36435. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36436. var _element = __webpack_require__(0);
  36437. var _renderers = __webpack_require__(9);
  36438. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36439. /**
  36440. * @private
  36441. * @plugin Search
  36442. */
  36443. function Search(instance) {
  36444. this.query = function (queryStr, callback, queryMethod) {
  36445. var rowCount = instance.countRows();
  36446. var colCount = instance.countCols();
  36447. var queryResult = [];
  36448. if (!callback) {
  36449. callback = Search.global.getDefaultCallback();
  36450. }
  36451. if (!queryMethod) {
  36452. queryMethod = Search.global.getDefaultQueryMethod();
  36453. }
  36454. for (var rowIndex = 0; rowIndex < rowCount; rowIndex++) {
  36455. for (var colIndex = 0; colIndex < colCount; colIndex++) {
  36456. var cellData = instance.getDataAtCell(rowIndex, colIndex);
  36457. var cellProperties = instance.getCellMeta(rowIndex, colIndex);
  36458. var cellCallback = cellProperties.search.callback || callback;
  36459. var cellQueryMethod = cellProperties.search.queryMethod || queryMethod;
  36460. var testResult = cellQueryMethod(queryStr, cellData);
  36461. if (testResult) {
  36462. var singleResult = {
  36463. row: rowIndex,
  36464. col: colIndex,
  36465. data: cellData
  36466. };
  36467. queryResult.push(singleResult);
  36468. }
  36469. if (cellCallback) {
  36470. cellCallback(instance, rowIndex, colIndex, cellData, testResult);
  36471. }
  36472. }
  36473. }
  36474. return queryResult;
  36475. };
  36476. };
  36477. Search.DEFAULT_CALLBACK = function (instance, row, col, data, testResult) {
  36478. instance.getCellMeta(row, col).isSearchResult = testResult;
  36479. };
  36480. Search.DEFAULT_QUERY_METHOD = function (query, value) {
  36481. if (typeof query == 'undefined' || query == null || !query.toLowerCase || query.length === 0) {
  36482. return false;
  36483. }
  36484. if (typeof value == 'undefined' || value == null) {
  36485. return false;
  36486. }
  36487. return value.toString().toLowerCase().indexOf(query.toLowerCase()) != -1;
  36488. };
  36489. Search.DEFAULT_SEARCH_RESULT_CLASS = 'htSearchResult';
  36490. Search.global = function () {
  36491. var defaultCallback = Search.DEFAULT_CALLBACK;
  36492. var defaultQueryMethod = Search.DEFAULT_QUERY_METHOD;
  36493. var defaultSearchResultClass = Search.DEFAULT_SEARCH_RESULT_CLASS;
  36494. return {
  36495. getDefaultCallback: function getDefaultCallback() {
  36496. return defaultCallback;
  36497. },
  36498. setDefaultCallback: function setDefaultCallback(newDefaultCallback) {
  36499. defaultCallback = newDefaultCallback;
  36500. },
  36501. getDefaultQueryMethod: function getDefaultQueryMethod() {
  36502. return defaultQueryMethod;
  36503. },
  36504. setDefaultQueryMethod: function setDefaultQueryMethod(newDefaultQueryMethod) {
  36505. defaultQueryMethod = newDefaultQueryMethod;
  36506. },
  36507. getDefaultSearchResultClass: function getDefaultSearchResultClass() {
  36508. return defaultSearchResultClass;
  36509. },
  36510. setDefaultSearchResultClass: function setDefaultSearchResultClass(newSearchResultClass) {
  36511. defaultSearchResultClass = newSearchResultClass;
  36512. }
  36513. };
  36514. }();
  36515. function SearchCellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  36516. var searchResultClass = cellProperties.search !== null && _typeof(cellProperties.search) == 'object' && cellProperties.search.searchResultClass || Search.global.getDefaultSearchResultClass();
  36517. if (cellProperties.isSearchResult) {
  36518. (0, _element.addClass)(TD, searchResultClass);
  36519. } else {
  36520. (0, _element.removeClass)(TD, searchResultClass);
  36521. }
  36522. };
  36523. var originalBaseRenderer = (0, _renderers.getRenderer)('base');
  36524. (0, _renderers.registerRenderer)('base', function (instance, TD, row, col, prop, value, cellProperties) {
  36525. originalBaseRenderer.apply(this, arguments);
  36526. SearchCellDecorator.apply(this, arguments);
  36527. });
  36528. function init() {
  36529. var instance = this;
  36530. var pluginEnabled = !!instance.getSettings().search;
  36531. if (pluginEnabled) {
  36532. instance.search = new Search(instance);
  36533. } else {
  36534. delete instance.search;
  36535. }
  36536. }
  36537. _pluginHooks2.default.getSingleton().add('afterInit', init);
  36538. _pluginHooks2.default.getSingleton().add('afterUpdateSettings', init);
  36539. exports.default = Search;
  36540. /***/ }),
  36541. /* 260 */
  36542. /***/ (function(module, exports, __webpack_require__) {
  36543. "use strict";
  36544. exports.__esModule = true;
  36545. 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; }; }();
  36546. 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); } };
  36547. var _element = __webpack_require__(0);
  36548. var _array = __webpack_require__(2);
  36549. var _base = __webpack_require__(12);
  36550. var _base2 = _interopRequireDefault(_base);
  36551. var _plugins = __webpack_require__(5);
  36552. var _feature = __webpack_require__(34);
  36553. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36554. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  36555. 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; }
  36556. 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; }
  36557. /**
  36558. * @private
  36559. * @plugin TouchScroll
  36560. * @class TouchScroll
  36561. */
  36562. var TouchScroll = function (_BasePlugin) {
  36563. _inherits(TouchScroll, _BasePlugin);
  36564. function TouchScroll(hotInstance) {
  36565. _classCallCheck(this, TouchScroll);
  36566. /**
  36567. * Collection of scrollbars to update.
  36568. *
  36569. * @type {Array}
  36570. */
  36571. var _this = _possibleConstructorReturn(this, (TouchScroll.__proto__ || Object.getPrototypeOf(TouchScroll)).call(this, hotInstance));
  36572. _this.scrollbars = [];
  36573. /**
  36574. * Collection of overlays to update.
  36575. *
  36576. * @type {Array}
  36577. */
  36578. _this.clones = [];
  36579. /**
  36580. * Flag which determines if collection of overlays should be refilled on every table render.
  36581. *
  36582. * @type {Boolean}
  36583. * @default false
  36584. */
  36585. _this.lockedCollection = false;
  36586. /**
  36587. * Flag which determines if walkontable should freeze overlays while scrolling.
  36588. *
  36589. * @type {Boolean}
  36590. * @default false
  36591. */
  36592. _this.freezeOverlays = false;
  36593. return _this;
  36594. }
  36595. /**
  36596. * Check if plugin is enabled.
  36597. *
  36598. * @returns {Boolean}
  36599. */
  36600. _createClass(TouchScroll, [{
  36601. key: 'isEnabled',
  36602. value: function isEnabled() {
  36603. return (0, _feature.isTouchSupported)();
  36604. }
  36605. /**
  36606. * Enable the plugin.
  36607. */
  36608. }, {
  36609. key: 'enablePlugin',
  36610. value: function enablePlugin() {
  36611. var _this2 = this;
  36612. if (this.enabled) {
  36613. return;
  36614. }
  36615. this.addHook('afterRender', function () {
  36616. return _this2.onAfterRender();
  36617. });
  36618. this.registerEvents();
  36619. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'enablePlugin', this).call(this);
  36620. }
  36621. /**
  36622. * Updates the plugin to use the latest options you have specified.
  36623. */
  36624. }, {
  36625. key: 'updatePlugin',
  36626. value: function updatePlugin() {
  36627. this.lockedCollection = false;
  36628. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'updatePlugin', this).call(this);
  36629. }
  36630. /**
  36631. * Disable plugin for this Handsontable instance.
  36632. */
  36633. }, {
  36634. key: 'disablePlugin',
  36635. value: function disablePlugin() {
  36636. _get(TouchScroll.prototype.__proto__ || Object.getPrototypeOf(TouchScroll.prototype), 'disablePlugin', this).call(this);
  36637. }
  36638. /**
  36639. * Register all necessary events.
  36640. *
  36641. * @private
  36642. */
  36643. }, {
  36644. key: 'registerEvents',
  36645. value: function registerEvents() {
  36646. var _this3 = this;
  36647. this.addHook('beforeTouchScroll', function () {
  36648. return _this3.onBeforeTouchScroll();
  36649. });
  36650. this.addHook('afterMomentumScroll', function () {
  36651. return _this3.onAfterMomentumScroll();
  36652. });
  36653. }
  36654. /**
  36655. * After render listener.
  36656. *
  36657. * @private
  36658. */
  36659. }, {
  36660. key: 'onAfterRender',
  36661. value: function onAfterRender() {
  36662. if (this.lockedCollection) {
  36663. return;
  36664. }
  36665. var _hot$view$wt$wtOverla = this.hot.view.wt.wtOverlays,
  36666. topOverlay = _hot$view$wt$wtOverla.topOverlay,
  36667. bottomOverlay = _hot$view$wt$wtOverla.bottomOverlay,
  36668. leftOverlay = _hot$view$wt$wtOverla.leftOverlay,
  36669. topLeftCornerOverlay = _hot$view$wt$wtOverla.topLeftCornerOverlay,
  36670. bottomLeftCornerOverlay = _hot$view$wt$wtOverla.bottomLeftCornerOverlay;
  36671. this.lockedCollection = true;
  36672. this.scrollbars.length = 0;
  36673. this.scrollbars.push(topOverlay);
  36674. if (bottomOverlay.clone) {
  36675. this.scrollbars.push(bottomOverlay);
  36676. }
  36677. this.scrollbars.push(leftOverlay);
  36678. if (topLeftCornerOverlay) {
  36679. this.scrollbars.push(topLeftCornerOverlay);
  36680. }
  36681. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  36682. this.scrollbars.push(bottomLeftCornerOverlay);
  36683. }
  36684. this.clones.length = 0;
  36685. if (topOverlay.needFullRender) {
  36686. this.clones.push(topOverlay.clone.wtTable.holder.parentNode);
  36687. }
  36688. if (bottomOverlay.needFullRender) {
  36689. this.clones.push(bottomOverlay.clone.wtTable.holder.parentNode);
  36690. }
  36691. if (leftOverlay.needFullRender) {
  36692. this.clones.push(leftOverlay.clone.wtTable.holder.parentNode);
  36693. }
  36694. if (topLeftCornerOverlay) {
  36695. this.clones.push(topLeftCornerOverlay.clone.wtTable.holder.parentNode);
  36696. }
  36697. if (bottomLeftCornerOverlay && bottomLeftCornerOverlay.clone) {
  36698. this.clones.push(bottomLeftCornerOverlay.clone.wtTable.holder.parentNode);
  36699. }
  36700. }
  36701. /**
  36702. * Touch scroll listener.
  36703. *
  36704. * @private
  36705. */
  36706. }, {
  36707. key: 'onBeforeTouchScroll',
  36708. value: function onBeforeTouchScroll() {
  36709. this.freezeOverlays = true;
  36710. (0, _array.arrayEach)(this.clones, function (clone) {
  36711. (0, _element.addClass)(clone, 'hide-tween');
  36712. });
  36713. }
  36714. /**
  36715. * After momentum scroll listener.
  36716. *
  36717. * @private
  36718. */
  36719. }, {
  36720. key: 'onAfterMomentumScroll',
  36721. value: function onAfterMomentumScroll() {
  36722. var _this4 = this;
  36723. this.freezeOverlays = false;
  36724. (0, _array.arrayEach)(this.clones, function (clone) {
  36725. (0, _element.removeClass)(clone, 'hide-tween');
  36726. (0, _element.addClass)(clone, 'show-tween');
  36727. });
  36728. setTimeout(function () {
  36729. (0, _array.arrayEach)(_this4.clones, function (clone) {
  36730. (0, _element.removeClass)(clone, 'show-tween');
  36731. });
  36732. }, 400);
  36733. (0, _array.arrayEach)(this.scrollbars, function (scrollbar) {
  36734. scrollbar.refresh();
  36735. scrollbar.resetFixedPosition();
  36736. });
  36737. this.hot.view.wt.wtOverlays.syncScrollWithMaster();
  36738. }
  36739. }]);
  36740. return TouchScroll;
  36741. }(_base2.default);
  36742. (0, _plugins.registerPlugin)('touchScroll', TouchScroll);
  36743. exports.default = TouchScroll;
  36744. /***/ }),
  36745. /* 261 */
  36746. /***/ (function(module, exports, __webpack_require__) {
  36747. "use strict";
  36748. var _pluginHooks = __webpack_require__(8);
  36749. var _pluginHooks2 = _interopRequireDefault(_pluginHooks);
  36750. var _array = __webpack_require__(2);
  36751. var _number = __webpack_require__(6);
  36752. var _object = __webpack_require__(1);
  36753. var _event = __webpack_require__(7);
  36754. var _src = __webpack_require__(11);
  36755. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  36756. /**
  36757. * @description
  36758. * Handsontable UndoRedo plugin. It allows to undo and redo certain actions done in the table.
  36759. * Please note, that not all actions are currently undo-able.
  36760. *
  36761. * @example
  36762. * ```js
  36763. * ...
  36764. * undo: true
  36765. * ...
  36766. * ```
  36767. * @class UndoRedo
  36768. * @plugin UndoRedo
  36769. */
  36770. /**
  36771. * Handsontable UndoRedo class
  36772. */
  36773. function UndoRedo(instance) {
  36774. var plugin = this;
  36775. this.instance = instance;
  36776. this.doneActions = [];
  36777. this.undoneActions = [];
  36778. this.ignoreNewActions = false;
  36779. instance.addHook('afterChange', function (changes, source) {
  36780. if (changes && source !== 'UndoRedo.undo' && source !== 'UndoRedo.redo') {
  36781. plugin.done(new UndoRedo.ChangeAction(changes));
  36782. }
  36783. });
  36784. instance.addHook('afterCreateRow', function (index, amount, source) {
  36785. if (source === 'UndoRedo.undo' || source === 'UndoRedo.undo' || source === 'auto') {
  36786. return;
  36787. }
  36788. var action = new UndoRedo.CreateRowAction(index, amount);
  36789. plugin.done(action);
  36790. });
  36791. instance.addHook('beforeRemoveRow', function (index, amount, logicRows, source) {
  36792. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  36793. return;
  36794. }
  36795. var originalData = plugin.instance.getSourceDataArray();
  36796. index = (originalData.length + index) % originalData.length;
  36797. var removedData = (0, _object.deepClone)(originalData.slice(index, index + amount));
  36798. plugin.done(new UndoRedo.RemoveRowAction(index, removedData));
  36799. });
  36800. instance.addHook('afterCreateCol', function (index, amount, source) {
  36801. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  36802. return;
  36803. }
  36804. plugin.done(new UndoRedo.CreateColumnAction(index, amount));
  36805. });
  36806. instance.addHook('beforeRemoveCol', function (index, amount, logicColumns, source) {
  36807. if (source === 'UndoRedo.undo' || source === 'UndoRedo.redo' || source === 'auto') {
  36808. return;
  36809. }
  36810. var originalData = plugin.instance.getSourceDataArray();
  36811. index = (plugin.instance.countCols() + index) % plugin.instance.countCols();
  36812. var removedData = [];
  36813. var headers = [];
  36814. var indexes = [];
  36815. (0, _number.rangeEach)(originalData.length - 1, function (i) {
  36816. var column = [];
  36817. var origRow = originalData[i];
  36818. (0, _number.rangeEach)(index, index + (amount - 1), function (j) {
  36819. column.push(origRow[instance.runHooks('modifyCol', j)]);
  36820. });
  36821. removedData.push(column);
  36822. });
  36823. (0, _number.rangeEach)(amount - 1, function (i) {
  36824. indexes.push(instance.runHooks('modifyCol', index + i));
  36825. });
  36826. if (Array.isArray(instance.getSettings().colHeaders)) {
  36827. (0, _number.rangeEach)(amount - 1, function (i) {
  36828. headers.push(instance.getSettings().colHeaders[instance.runHooks('modifyCol', index + i)] || null);
  36829. });
  36830. }
  36831. var manualColumnMovePlugin = plugin.instance.getPlugin('manualColumnMove');
  36832. var columnsMap = manualColumnMovePlugin.isEnabled() ? manualColumnMovePlugin.columnsMapper.__arrayMap : [];
  36833. var action = new UndoRedo.RemoveColumnAction(index, indexes, removedData, headers, columnsMap);
  36834. plugin.done(action);
  36835. });
  36836. instance.addHook('beforeCellAlignment', function (stateBefore, range, type, alignment) {
  36837. var action = new UndoRedo.CellAlignmentAction(stateBefore, range, type, alignment);
  36838. plugin.done(action);
  36839. });
  36840. instance.addHook('beforeFilter', function (conditionsStack) {
  36841. plugin.done(new UndoRedo.FiltersAction(conditionsStack));
  36842. });
  36843. instance.addHook('beforeRowMove', function (movedRows, target) {
  36844. if (movedRows === false) {
  36845. return;
  36846. }
  36847. plugin.done(new UndoRedo.RowMoveAction(movedRows, target));
  36848. });
  36849. };
  36850. UndoRedo.prototype.done = function (action) {
  36851. if (!this.ignoreNewActions) {
  36852. this.doneActions.push(action);
  36853. this.undoneActions.length = 0;
  36854. }
  36855. };
  36856. /**
  36857. * Undo last edit.
  36858. *
  36859. * @function undo
  36860. * @memberof UndoRedo#
  36861. */
  36862. UndoRedo.prototype.undo = function () {
  36863. if (this.isUndoAvailable()) {
  36864. var action = this.doneActions.pop();
  36865. var actionClone = (0, _object.deepClone)(action);
  36866. var instance = this.instance;
  36867. var continueAction = instance.runHooks('beforeUndo', actionClone);
  36868. if (continueAction === false) {
  36869. return;
  36870. }
  36871. this.ignoreNewActions = true;
  36872. var that = this;
  36873. action.undo(this.instance, function () {
  36874. that.ignoreNewActions = false;
  36875. that.undoneActions.push(action);
  36876. });
  36877. instance.runHooks('afterUndo', actionClone);
  36878. }
  36879. };
  36880. /**
  36881. * Redo edit (used to reverse an undo).
  36882. *
  36883. * @function redo
  36884. * @memberof UndoRedo#
  36885. */
  36886. UndoRedo.prototype.redo = function () {
  36887. if (this.isRedoAvailable()) {
  36888. var action = this.undoneActions.pop();
  36889. var actionClone = (0, _object.deepClone)(action);
  36890. var instance = this.instance;
  36891. var continueAction = instance.runHooks('beforeRedo', actionClone);
  36892. if (continueAction === false) {
  36893. return;
  36894. }
  36895. this.ignoreNewActions = true;
  36896. var that = this;
  36897. action.redo(this.instance, function () {
  36898. that.ignoreNewActions = false;
  36899. that.doneActions.push(action);
  36900. });
  36901. instance.runHooks('afterRedo', actionClone);
  36902. }
  36903. };
  36904. /**
  36905. * Check if undo action is available.
  36906. *
  36907. * @function isUndoAvailable
  36908. * @memberof UndoRedo#
  36909. * @return {Boolean} Return `true` if undo can be performed, `false` otherwise
  36910. */
  36911. UndoRedo.prototype.isUndoAvailable = function () {
  36912. return this.doneActions.length > 0;
  36913. };
  36914. /**
  36915. * Check if redo action is available.
  36916. *
  36917. * @function isRedoAvailable
  36918. * @memberof UndoRedo#
  36919. * @return {Boolean} Return `true` if redo can be performed, `false` otherwise.
  36920. */
  36921. UndoRedo.prototype.isRedoAvailable = function () {
  36922. return this.undoneActions.length > 0;
  36923. };
  36924. /**
  36925. * Clears undo history.
  36926. *
  36927. * @function clear
  36928. * @memberof UndoRedo#
  36929. */
  36930. UndoRedo.prototype.clear = function () {
  36931. this.doneActions.length = 0;
  36932. this.undoneActions.length = 0;
  36933. };
  36934. UndoRedo.Action = function () {};
  36935. UndoRedo.Action.prototype.undo = function () {};
  36936. UndoRedo.Action.prototype.redo = function () {};
  36937. /**
  36938. * Change action.
  36939. */
  36940. UndoRedo.ChangeAction = function (changes) {
  36941. this.changes = changes;
  36942. this.actionType = 'change';
  36943. };
  36944. (0, _object.inherit)(UndoRedo.ChangeAction, UndoRedo.Action);
  36945. UndoRedo.ChangeAction.prototype.undo = function (instance, undoneCallback) {
  36946. var data = (0, _object.deepClone)(this.changes),
  36947. emptyRowsAtTheEnd = instance.countEmptyRows(true),
  36948. emptyColsAtTheEnd = instance.countEmptyCols(true);
  36949. for (var i = 0, len = data.length; i < len; i++) {
  36950. data[i].splice(3, 1);
  36951. }
  36952. instance.addHookOnce('afterChange', undoneCallback);
  36953. instance.setDataAtRowProp(data, null, null, 'UndoRedo.undo');
  36954. for (var _i = 0, _len = data.length; _i < _len; _i++) {
  36955. if (instance.getSettings().minSpareRows && data[_i][0] + 1 + instance.getSettings().minSpareRows === instance.countRows() && emptyRowsAtTheEnd == instance.getSettings().minSpareRows) {
  36956. instance.alter('remove_row', parseInt(data[_i][0] + 1, 10), instance.getSettings().minSpareRows);
  36957. instance.undoRedo.doneActions.pop();
  36958. }
  36959. if (instance.getSettings().minSpareCols && data[_i][1] + 1 + instance.getSettings().minSpareCols === instance.countCols() && emptyColsAtTheEnd == instance.getSettings().minSpareCols) {
  36960. instance.alter('remove_col', parseInt(data[_i][1] + 1, 10), instance.getSettings().minSpareCols);
  36961. instance.undoRedo.doneActions.pop();
  36962. }
  36963. }
  36964. };
  36965. UndoRedo.ChangeAction.prototype.redo = function (instance, onFinishCallback) {
  36966. var data = (0, _object.deepClone)(this.changes);
  36967. for (var i = 0, len = data.length; i < len; i++) {
  36968. data[i].splice(2, 1);
  36969. }
  36970. instance.addHookOnce('afterChange', onFinishCallback);
  36971. instance.setDataAtRowProp(data, null, null, 'UndoRedo.redo');
  36972. };
  36973. /**
  36974. * Create row action.
  36975. */
  36976. UndoRedo.CreateRowAction = function (index, amount) {
  36977. this.index = index;
  36978. this.amount = amount;
  36979. this.actionType = 'insert_row';
  36980. };
  36981. (0, _object.inherit)(UndoRedo.CreateRowAction, UndoRedo.Action);
  36982. UndoRedo.CreateRowAction.prototype.undo = function (instance, undoneCallback) {
  36983. var rowCount = instance.countRows(),
  36984. minSpareRows = instance.getSettings().minSpareRows;
  36985. if (this.index >= rowCount && this.index - minSpareRows < rowCount) {
  36986. this.index -= minSpareRows; // work around the situation where the needed row was removed due to an 'undo' of a made change
  36987. }
  36988. instance.addHookOnce('afterRemoveRow', undoneCallback);
  36989. instance.alter('remove_row', this.index, this.amount, 'UndoRedo.undo');
  36990. };
  36991. UndoRedo.CreateRowAction.prototype.redo = function (instance, redoneCallback) {
  36992. instance.addHookOnce('afterCreateRow', redoneCallback);
  36993. instance.alter('insert_row', this.index, this.amount, 'UndoRedo.redo');
  36994. };
  36995. /**
  36996. * Remove row action.
  36997. */
  36998. UndoRedo.RemoveRowAction = function (index, data) {
  36999. this.index = index;
  37000. this.data = data;
  37001. this.actionType = 'remove_row';
  37002. };
  37003. (0, _object.inherit)(UndoRedo.RemoveRowAction, UndoRedo.Action);
  37004. UndoRedo.RemoveRowAction.prototype.undo = function (instance, undoneCallback) {
  37005. instance.alter('insert_row', this.index, this.data.length, 'UndoRedo.undo');
  37006. instance.addHookOnce('afterRender', undoneCallback);
  37007. instance.populateFromArray(this.index, 0, this.data, void 0, void 0, 'UndoRedo.undo');
  37008. };
  37009. UndoRedo.RemoveRowAction.prototype.redo = function (instance, redoneCallback) {
  37010. instance.addHookOnce('afterRemoveRow', redoneCallback);
  37011. instance.alter('remove_row', this.index, this.data.length, 'UndoRedo.redo');
  37012. };
  37013. /**
  37014. * Create column action.
  37015. */
  37016. UndoRedo.CreateColumnAction = function (index, amount) {
  37017. this.index = index;
  37018. this.amount = amount;
  37019. this.actionType = 'insert_col';
  37020. };
  37021. (0, _object.inherit)(UndoRedo.CreateColumnAction, UndoRedo.Action);
  37022. UndoRedo.CreateColumnAction.prototype.undo = function (instance, undoneCallback) {
  37023. instance.addHookOnce('afterRemoveCol', undoneCallback);
  37024. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.undo');
  37025. };
  37026. UndoRedo.CreateColumnAction.prototype.redo = function (instance, redoneCallback) {
  37027. instance.addHookOnce('afterCreateCol', redoneCallback);
  37028. instance.alter('insert_col', this.index, this.amount, 'UndoRedo.redo');
  37029. };
  37030. /**
  37031. * Remove column action.
  37032. */
  37033. UndoRedo.RemoveColumnAction = function (index, indexes, data, headers, columnPositions) {
  37034. this.index = index;
  37035. this.indexes = indexes;
  37036. this.data = data;
  37037. this.amount = this.data[0].length;
  37038. this.headers = headers;
  37039. this.columnPositions = columnPositions.slice(0);
  37040. this.actionType = 'remove_col';
  37041. };
  37042. (0, _object.inherit)(UndoRedo.RemoveColumnAction, UndoRedo.Action);
  37043. UndoRedo.RemoveColumnAction.prototype.undo = function (instance, undoneCallback) {
  37044. var _this = this;
  37045. var row = void 0;
  37046. var ascendingIndexes = this.indexes.slice(0).sort();
  37047. var sortByIndexes = function sortByIndexes(elem, j, arr) {
  37048. return arr[_this.indexes.indexOf(ascendingIndexes[j])];
  37049. };
  37050. var sortedData = [];
  37051. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  37052. sortedData[i] = (0, _array.arrayMap)(_this.data[i], sortByIndexes);
  37053. });
  37054. var sortedHeaders = [];
  37055. sortedHeaders = (0, _array.arrayMap)(this.headers, sortByIndexes);
  37056. var changes = [];
  37057. // TODO: Temporary hook for undo/redo mess
  37058. instance.runHooks('beforeCreateCol', this.indexes[0], this.indexes[this.indexes.length - 1], 'UndoRedo.undo');
  37059. (0, _number.rangeEach)(this.data.length - 1, function (i) {
  37060. row = instance.getSourceDataAtRow(i);
  37061. (0, _number.rangeEach)(ascendingIndexes.length - 1, function (j) {
  37062. row.splice(ascendingIndexes[j], 0, sortedData[i][j]);
  37063. changes.push([i, ascendingIndexes[j], null, sortedData[i][j]]);
  37064. });
  37065. });
  37066. // TODO: Temporary hook for undo/redo mess
  37067. if (instance.getPlugin('formulas')) {
  37068. instance.getPlugin('formulas').onAfterSetDataAtCell(changes);
  37069. }
  37070. if (typeof this.headers !== 'undefined') {
  37071. (0, _number.rangeEach)(sortedHeaders.length - 1, function (j) {
  37072. instance.getSettings().colHeaders.splice(ascendingIndexes[j], 0, sortedHeaders[j]);
  37073. });
  37074. }
  37075. if (instance.getPlugin('manualColumnMove')) {
  37076. instance.getPlugin('manualColumnMove').columnsMapper.__arrayMap = this.columnPositions;
  37077. }
  37078. instance.addHookOnce('afterRender', undoneCallback);
  37079. // TODO: Temporary hook for undo/redo mess
  37080. instance.runHooks('afterCreateCol', this.indexes[0], this.indexes[this.indexes.length - 1], 'UndoRedo.undo');
  37081. if (instance.getPlugin('formulas')) {
  37082. instance.getPlugin('formulas').recalculateFull();
  37083. }
  37084. instance.render();
  37085. };
  37086. UndoRedo.RemoveColumnAction.prototype.redo = function (instance, redoneCallback) {
  37087. instance.addHookOnce('afterRemoveCol', redoneCallback);
  37088. instance.alter('remove_col', this.index, this.amount, 'UndoRedo.redo');
  37089. };
  37090. /**
  37091. * Cell alignment action.
  37092. */
  37093. UndoRedo.CellAlignmentAction = function (stateBefore, range, type, alignment) {
  37094. this.stateBefore = stateBefore;
  37095. this.range = range;
  37096. this.type = type;
  37097. this.alignment = alignment;
  37098. };
  37099. UndoRedo.CellAlignmentAction.prototype.undo = function (instance, undoneCallback) {
  37100. if (!instance.getPlugin('contextMenu').isEnabled()) {
  37101. return;
  37102. }
  37103. for (var row = this.range.from.row; row <= this.range.to.row; row++) {
  37104. for (var col = this.range.from.col; col <= this.range.to.col; col++) {
  37105. instance.setCellMeta(row, col, 'className', this.stateBefore[row][col] || ' htLeft');
  37106. }
  37107. }
  37108. instance.addHookOnce('afterRender', undoneCallback);
  37109. instance.render();
  37110. };
  37111. UndoRedo.CellAlignmentAction.prototype.redo = function (instance, undoneCallback) {
  37112. if (!instance.getPlugin('contextMenu').isEnabled()) {
  37113. return;
  37114. }
  37115. instance.selectCell(this.range.from.row, this.range.from.col, this.range.to.row, this.range.to.col);
  37116. instance.getPlugin('contextMenu').executeCommand('alignment:' + this.alignment.replace('ht', '').toLowerCase());
  37117. instance.addHookOnce('afterRender', undoneCallback);
  37118. instance.render();
  37119. };
  37120. /**
  37121. * Filters action.
  37122. */
  37123. UndoRedo.FiltersAction = function (conditionsStack) {
  37124. this.conditionsStack = conditionsStack;
  37125. this.actionType = 'filter';
  37126. };
  37127. (0, _object.inherit)(UndoRedo.FiltersAction, UndoRedo.Action);
  37128. UndoRedo.FiltersAction.prototype.undo = function (instance, undoneCallback) {
  37129. var filters = instance.getPlugin('filters');
  37130. instance.addHookOnce('afterRender', undoneCallback);
  37131. filters.conditionCollection.importAllConditions(this.conditionsStack.slice(0, this.conditionsStack.length - 1));
  37132. filters.filter();
  37133. };
  37134. UndoRedo.FiltersAction.prototype.redo = function (instance, redoneCallback) {
  37135. var filters = instance.getPlugin('filters');
  37136. instance.addHookOnce('afterRender', redoneCallback);
  37137. filters.conditionCollection.importAllConditions(this.conditionsStack);
  37138. filters.filter();
  37139. };
  37140. /**
  37141. * ManualRowMove action.
  37142. * @TODO: removeRow undo should works on logical index
  37143. */
  37144. UndoRedo.RowMoveAction = function (movedRows, target) {
  37145. this.rows = movedRows.slice();
  37146. this.target = target;
  37147. };
  37148. (0, _object.inherit)(UndoRedo.RowMoveAction, UndoRedo.Action);
  37149. UndoRedo.RowMoveAction.prototype.undo = function (instance, undoneCallback) {
  37150. var manualRowMove = instance.getPlugin('manualRowMove');
  37151. instance.addHookOnce('afterRender', undoneCallback);
  37152. var mod = this.rows[0] < this.target ? -1 * this.rows.length : 0;
  37153. var newTarget = this.rows[0] > this.target ? this.rows[0] + this.rows.length : this.rows[0];
  37154. var newRows = [];
  37155. var rowsLen = this.rows.length + mod;
  37156. for (var i = mod; i < rowsLen; i++) {
  37157. newRows.push(this.target + i);
  37158. }
  37159. manualRowMove.moveRows(newRows.slice(), newTarget);
  37160. instance.render();
  37161. instance.selection.setRangeStartOnly(new _src.CellCoords(this.rows[0], 0));
  37162. instance.selection.setRangeEnd(new _src.CellCoords(this.rows[this.rows.length - 1], instance.countCols() - 1));
  37163. };
  37164. UndoRedo.RowMoveAction.prototype.redo = function (instance, redoneCallback) {
  37165. var manualRowMove = instance.getPlugin('manualRowMove');
  37166. instance.addHookOnce('afterRender', redoneCallback);
  37167. manualRowMove.moveRows(this.rows.slice(), this.target);
  37168. instance.render();
  37169. var startSelection = this.rows[0] < this.target ? this.target - this.rows.length : this.target;
  37170. instance.selection.setRangeStartOnly(new _src.CellCoords(startSelection, 0));
  37171. instance.selection.setRangeEnd(new _src.CellCoords(startSelection + this.rows.length - 1, instance.countCols() - 1));
  37172. };
  37173. function init() {
  37174. var instance = this;
  37175. var pluginEnabled = typeof instance.getSettings().undo == 'undefined' || instance.getSettings().undo;
  37176. if (pluginEnabled) {
  37177. if (!instance.undoRedo) {
  37178. /**
  37179. * Instance of Handsontable.UndoRedo Plugin {@link Handsontable.UndoRedo}
  37180. *
  37181. * @alias undoRedo
  37182. * @memberof! Handsontable.Core#
  37183. * @type {UndoRedo}
  37184. */
  37185. instance.undoRedo = new UndoRedo(instance);
  37186. exposeUndoRedoMethods(instance);
  37187. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  37188. instance.addHook('afterChange', onAfterChange);
  37189. }
  37190. } else if (instance.undoRedo) {
  37191. delete instance.undoRedo;
  37192. removeExposedUndoRedoMethods(instance);
  37193. instance.removeHook('beforeKeyDown', onBeforeKeyDown);
  37194. instance.removeHook('afterChange', onAfterChange);
  37195. }
  37196. }
  37197. function onBeforeKeyDown(event) {
  37198. var instance = this;
  37199. var ctrlDown = (event.ctrlKey || event.metaKey) && !event.altKey;
  37200. if (ctrlDown) {
  37201. if (event.keyCode === 89 || event.shiftKey && event.keyCode === 90) {
  37202. // CTRL + Y or CTRL + SHIFT + Z
  37203. instance.undoRedo.redo();
  37204. (0, _event.stopImmediatePropagation)(event);
  37205. } else if (event.keyCode === 90) {
  37206. // CTRL + Z
  37207. instance.undoRedo.undo();
  37208. (0, _event.stopImmediatePropagation)(event);
  37209. }
  37210. }
  37211. }
  37212. function onAfterChange(changes, source) {
  37213. var instance = this;
  37214. if (source === 'loadData') {
  37215. return instance.undoRedo.clear();
  37216. }
  37217. }
  37218. function exposeUndoRedoMethods(instance) {
  37219. /**
  37220. * {@link UndoRedo#undo}
  37221. * @alias undo
  37222. * @memberof! Handsontable.Core#
  37223. */
  37224. instance.undo = function () {
  37225. return instance.undoRedo.undo();
  37226. };
  37227. /**
  37228. * {@link UndoRedo#redo}
  37229. * @alias redo
  37230. * @memberof! Handsontable.Core#
  37231. */
  37232. instance.redo = function () {
  37233. return instance.undoRedo.redo();
  37234. };
  37235. /**
  37236. * {@link UndoRedo#isUndoAvailable}
  37237. * @alias isUndoAvailable
  37238. * @memberof! Handsontable.Core#
  37239. */
  37240. instance.isUndoAvailable = function () {
  37241. return instance.undoRedo.isUndoAvailable();
  37242. };
  37243. /**
  37244. * {@link UndoRedo#isRedoAvailable}
  37245. * @alias isRedoAvailable
  37246. * @memberof! Handsontable.Core#
  37247. */
  37248. instance.isRedoAvailable = function () {
  37249. return instance.undoRedo.isRedoAvailable();
  37250. };
  37251. /**
  37252. * {@link UndoRedo#clear}
  37253. * @alias clearUndo
  37254. * @memberof! Handsontable.Core#
  37255. */
  37256. instance.clearUndo = function () {
  37257. return instance.undoRedo.clear();
  37258. };
  37259. }
  37260. function removeExposedUndoRedoMethods(instance) {
  37261. delete instance.undo;
  37262. delete instance.redo;
  37263. delete instance.isUndoAvailable;
  37264. delete instance.isRedoAvailable;
  37265. delete instance.clearUndo;
  37266. }
  37267. var hook = _pluginHooks2.default.getSingleton();
  37268. hook.add('afterInit', init);
  37269. hook.add('afterUpdateSettings', init);
  37270. hook.register('beforeUndo');
  37271. hook.register('afterUndo');
  37272. hook.register('beforeRedo');
  37273. hook.register('afterRedo');
  37274. /***/ }),
  37275. /* 262 */
  37276. /***/ (function(module, exports, __webpack_require__) {
  37277. "use strict";
  37278. exports.__esModule = true;
  37279. var _element = __webpack_require__(0);
  37280. function cellDecorator(instance, TD, row, col, prop, value, cellProperties) {
  37281. if (cellProperties.className) {
  37282. if (TD.className) {
  37283. TD.className = TD.className + ' ' + cellProperties.className;
  37284. } else {
  37285. TD.className = cellProperties.className;
  37286. }
  37287. }
  37288. if (cellProperties.readOnly) {
  37289. (0, _element.addClass)(TD, cellProperties.readOnlyCellClassName);
  37290. }
  37291. if (cellProperties.valid === false && cellProperties.invalidCellClassName) {
  37292. (0, _element.addClass)(TD, cellProperties.invalidCellClassName);
  37293. } else {
  37294. (0, _element.removeClass)(TD, cellProperties.invalidCellClassName);
  37295. }
  37296. if (cellProperties.wordWrap === false && cellProperties.noWordWrapClassName) {
  37297. (0, _element.addClass)(TD, cellProperties.noWordWrapClassName);
  37298. }
  37299. if (!value && cellProperties.placeholder) {
  37300. (0, _element.addClass)(TD, cellProperties.placeholderCellClassName);
  37301. }
  37302. } /**
  37303. * Adds appropriate CSS class to table cell, based on cellProperties
  37304. */
  37305. exports.default = cellDecorator;
  37306. /***/ }),
  37307. /* 263 */
  37308. /***/ (function(module, exports, __webpack_require__) {
  37309. "use strict";
  37310. exports.__esModule = true;
  37311. var _element = __webpack_require__(0);
  37312. var _eventManager = __webpack_require__(4);
  37313. var _eventManager2 = _interopRequireDefault(_eventManager);
  37314. var _src = __webpack_require__(11);
  37315. var _index = __webpack_require__(9);
  37316. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37317. var clonableWRAPPER = document.createElement('DIV');
  37318. clonableWRAPPER.className = 'htAutocompleteWrapper';
  37319. var clonableARROW = document.createElement('DIV');
  37320. clonableARROW.className = 'htAutocompleteArrow';
  37321. // workaround for https://github.com/handsontable/handsontable/issues/1946
  37322. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  37323. clonableARROW.appendChild(document.createTextNode(String.fromCharCode(9660)));
  37324. var wrapTdContentWithWrapper = function wrapTdContentWithWrapper(TD, WRAPPER) {
  37325. WRAPPER.innerHTML = TD.innerHTML;
  37326. (0, _element.empty)(TD);
  37327. TD.appendChild(WRAPPER);
  37328. };
  37329. /**
  37330. * Autocomplete renderer
  37331. *
  37332. * @private
  37333. * @renderer AutocompleteRenderer
  37334. * @param {Object} instance Handsontable instance
  37335. * @param {Element} TD Table cell where to render
  37336. * @param {Number} row
  37337. * @param {Number} col
  37338. * @param {String|Number} prop Row object property name
  37339. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  37340. * @param {Object} cellProperties Cell properites (shared by cell renderer and editor)
  37341. */
  37342. function autocompleteRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37343. var WRAPPER = clonableWRAPPER.cloneNode(true); // this is faster than createElement
  37344. var ARROW = clonableARROW.cloneNode(true); // this is faster than createElement
  37345. if (cellProperties.allowHtml) {
  37346. (0, _index.getRenderer)('html').apply(this, arguments);
  37347. } else {
  37348. (0, _index.getRenderer)('text').apply(this, arguments);
  37349. }
  37350. TD.appendChild(ARROW);
  37351. (0, _element.addClass)(TD, 'htAutocomplete');
  37352. if (!TD.firstChild) {
  37353. // http://jsperf.com/empty-node-if-needed
  37354. // otherwise empty fields appear borderless in demo/renderers.html (IE)
  37355. TD.appendChild(document.createTextNode(String.fromCharCode(160))); // workaround for https://github.com/handsontable/handsontable/issues/1946
  37356. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  37357. }
  37358. if (!instance.acArrowListener) {
  37359. var eventManager = new _eventManager2.default(instance);
  37360. // not very elegant but easy and fast
  37361. instance.acArrowListener = function (event) {
  37362. if ((0, _element.hasClass)(event.target, 'htAutocompleteArrow')) {
  37363. instance.view.wt.getSetting('onCellDblClick', null, new _src.CellCoords(row, col), TD);
  37364. }
  37365. };
  37366. eventManager.addEventListener(instance.rootElement, 'mousedown', instance.acArrowListener);
  37367. // We need to unbind the listener after the table has been destroyed
  37368. instance.addHookOnce('afterDestroy', function () {
  37369. eventManager.destroy();
  37370. });
  37371. }
  37372. }
  37373. exports.default = autocompleteRenderer;
  37374. /***/ }),
  37375. /* 264 */
  37376. /***/ (function(module, exports, __webpack_require__) {
  37377. "use strict";
  37378. exports.__esModule = true;
  37379. var _element = __webpack_require__(0);
  37380. var _string = __webpack_require__(27);
  37381. var _eventManager = __webpack_require__(4);
  37382. var _eventManager2 = _interopRequireDefault(_eventManager);
  37383. var _unicode = __webpack_require__(16);
  37384. var _function = __webpack_require__(35);
  37385. var _event = __webpack_require__(7);
  37386. var _index = __webpack_require__(9);
  37387. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37388. var isListeningKeyDownEvent = new WeakMap();
  37389. var isCheckboxListenerAdded = new WeakMap();
  37390. var BAD_VALUE_CLASS = 'htBadValue';
  37391. /**
  37392. * Checkbox renderer
  37393. *
  37394. * @private
  37395. * @param {Object} instance Handsontable instance
  37396. * @param {Element} TD Table cell where to render
  37397. * @param {Number} row
  37398. * @param {Number} col
  37399. * @param {String|Number} prop Row object property name
  37400. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  37401. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  37402. */
  37403. function checkboxRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37404. (0, _index.getRenderer)('base').apply(this, arguments);
  37405. var eventManager = registerEvents(instance);
  37406. var input = createInput();
  37407. var labelOptions = cellProperties.label;
  37408. var badValue = false;
  37409. if (typeof cellProperties.checkedTemplate === 'undefined') {
  37410. cellProperties.checkedTemplate = true;
  37411. }
  37412. if (typeof cellProperties.uncheckedTemplate === 'undefined') {
  37413. cellProperties.uncheckedTemplate = false;
  37414. }
  37415. (0, _element.empty)(TD); // TODO identify under what circumstances this line can be removed
  37416. if (value === cellProperties.checkedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.checkedTemplate)) {
  37417. input.checked = true;
  37418. } else if (value === cellProperties.uncheckedTemplate || (0, _string.equalsIgnoreCase)(value, cellProperties.uncheckedTemplate)) {
  37419. input.checked = false;
  37420. } else if (value === null) {
  37421. // default value
  37422. (0, _element.addClass)(input, 'noValue');
  37423. } else {
  37424. input.style.display = 'none';
  37425. (0, _element.addClass)(input, BAD_VALUE_CLASS);
  37426. badValue = true;
  37427. }
  37428. input.setAttribute('data-row', row);
  37429. input.setAttribute('data-col', col);
  37430. if (!badValue && labelOptions) {
  37431. var labelText = '';
  37432. if (labelOptions.value) {
  37433. labelText = typeof labelOptions.value === 'function' ? labelOptions.value.call(this, row, col, prop, value) : labelOptions.value;
  37434. } else if (labelOptions.property) {
  37435. labelText = instance.getDataAtRowProp(row, labelOptions.property);
  37436. }
  37437. var label = createLabel(labelText);
  37438. if (labelOptions.position === 'before') {
  37439. label.appendChild(input);
  37440. } else {
  37441. label.insertBefore(input, label.firstChild);
  37442. }
  37443. input = label;
  37444. }
  37445. TD.appendChild(input);
  37446. if (badValue) {
  37447. TD.appendChild(document.createTextNode('#bad-value#'));
  37448. }
  37449. if (!isListeningKeyDownEvent.has(instance)) {
  37450. isListeningKeyDownEvent.set(instance, true);
  37451. instance.addHook('beforeKeyDown', onBeforeKeyDown);
  37452. }
  37453. /**
  37454. * On before key down DOM listener.
  37455. *
  37456. * @private
  37457. * @param {Event} event
  37458. */
  37459. function onBeforeKeyDown(event) {
  37460. var toggleKeys = 'SPACE|ENTER';
  37461. var switchOffKeys = 'DELETE|BACKSPACE';
  37462. var isKeyCode = (0, _function.partial)(_unicode.isKey, event.keyCode);
  37463. if (isKeyCode(toggleKeys + '|' + switchOffKeys) && !(0, _event.isImmediatePropagationStopped)(event)) {
  37464. eachSelectedCheckboxCell(function () {
  37465. (0, _event.stopImmediatePropagation)(event);
  37466. event.preventDefault();
  37467. });
  37468. }
  37469. if (isKeyCode(toggleKeys)) {
  37470. changeSelectedCheckboxesState();
  37471. }
  37472. if (isKeyCode(switchOffKeys)) {
  37473. changeSelectedCheckboxesState(true);
  37474. }
  37475. }
  37476. /**
  37477. * Change checkbox checked property
  37478. *
  37479. * @private
  37480. * @param {Boolean} [uncheckCheckbox=false]
  37481. */
  37482. function changeSelectedCheckboxesState() {
  37483. var uncheckCheckbox = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  37484. var selRange = instance.getSelectedRange();
  37485. if (!selRange) {
  37486. return;
  37487. }
  37488. var topLeft = selRange.getTopLeftCorner();
  37489. var bottomRight = selRange.getBottomRightCorner();
  37490. var changes = [];
  37491. for (var _row = topLeft.row; _row <= bottomRight.row; _row += 1) {
  37492. for (var _col = topLeft.col; _col <= bottomRight.col; _col += 1) {
  37493. var _cellProperties = instance.getCellMeta(_row, _col);
  37494. if (_cellProperties.type !== 'checkbox') {
  37495. return;
  37496. }
  37497. /* eslint-disable no-continue */
  37498. if (_cellProperties.readOnly === true) {
  37499. continue;
  37500. }
  37501. if (typeof _cellProperties.checkedTemplate === 'undefined') {
  37502. _cellProperties.checkedTemplate = true;
  37503. }
  37504. if (typeof _cellProperties.uncheckedTemplate === 'undefined') {
  37505. _cellProperties.uncheckedTemplate = false;
  37506. }
  37507. var dataAtCell = instance.getDataAtCell(_row, _col);
  37508. if (uncheckCheckbox === false) {
  37509. if (dataAtCell === _cellProperties.checkedTemplate) {
  37510. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  37511. } else if ([_cellProperties.uncheckedTemplate, null, void 0].indexOf(dataAtCell) !== -1) {
  37512. changes.push([_row, _col, _cellProperties.checkedTemplate]);
  37513. }
  37514. } else {
  37515. changes.push([_row, _col, _cellProperties.uncheckedTemplate]);
  37516. }
  37517. }
  37518. }
  37519. if (changes.length > 0) {
  37520. instance.setDataAtCell(changes);
  37521. }
  37522. }
  37523. /**
  37524. * Call callback for each found selected cell with checkbox type.
  37525. *
  37526. * @private
  37527. * @param {Function} callback
  37528. */
  37529. function eachSelectedCheckboxCell(callback) {
  37530. var selRange = instance.getSelectedRange();
  37531. if (!selRange) {
  37532. return;
  37533. }
  37534. var topLeft = selRange.getTopLeftCorner();
  37535. var bottomRight = selRange.getBottomRightCorner();
  37536. for (var _row2 = topLeft.row; _row2 <= bottomRight.row; _row2++) {
  37537. for (var _col2 = topLeft.col; _col2 <= bottomRight.col; _col2++) {
  37538. var _cellProperties2 = instance.getCellMeta(_row2, _col2);
  37539. if (_cellProperties2.type !== 'checkbox') {
  37540. return;
  37541. }
  37542. var cell = instance.getCell(_row2, _col2);
  37543. if (cell == null) {
  37544. callback(_row2, _col2, _cellProperties2);
  37545. } else {
  37546. var checkboxes = cell.querySelectorAll('input[type=checkbox]');
  37547. if (checkboxes.length > 0 && !_cellProperties2.readOnly) {
  37548. callback(checkboxes);
  37549. }
  37550. }
  37551. }
  37552. }
  37553. }
  37554. }
  37555. /**
  37556. * Register checkbox listeners.
  37557. *
  37558. * @param {Handsontable} instance Handsontable instance.
  37559. * @returns {EventManager}
  37560. */
  37561. function registerEvents(instance) {
  37562. var eventManager = isCheckboxListenerAdded.get(instance);
  37563. if (!eventManager) {
  37564. eventManager = new _eventManager2.default(instance);
  37565. eventManager.addEventListener(instance.rootElement, 'click', function (event) {
  37566. return onClick(event, instance);
  37567. });
  37568. eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  37569. return onMouseUp(event, instance);
  37570. });
  37571. eventManager.addEventListener(instance.rootElement, 'change', function (event) {
  37572. return onChange(event, instance);
  37573. });
  37574. isCheckboxListenerAdded.set(instance, eventManager);
  37575. }
  37576. return eventManager;
  37577. }
  37578. /**
  37579. * Create input element.
  37580. *
  37581. * @returns {Node}
  37582. */
  37583. function createInput() {
  37584. var input = document.createElement('input');
  37585. input.className = 'htCheckboxRendererInput';
  37586. input.type = 'checkbox';
  37587. input.setAttribute('autocomplete', 'off');
  37588. input.setAttribute('tabindex', '-1');
  37589. return input.cloneNode(false);
  37590. }
  37591. /**
  37592. * Create label element.
  37593. *
  37594. * @returns {Node}
  37595. */
  37596. function createLabel(text) {
  37597. var label = document.createElement('label');
  37598. label.className = 'htCheckboxRendererLabel';
  37599. label.appendChild(document.createTextNode(text));
  37600. return label.cloneNode(true);
  37601. }
  37602. /**
  37603. * `mouseup` callback.
  37604. *
  37605. * @private
  37606. * @param {Event} event `mouseup` event.
  37607. * @param {Object} instance Handsontable instance.
  37608. */
  37609. function onMouseUp(event, instance) {
  37610. if (!isCheckboxInput(event.target)) {
  37611. return;
  37612. }
  37613. setTimeout(instance.listen, 10);
  37614. }
  37615. /**
  37616. * `click` callback.
  37617. *
  37618. * @private
  37619. * @param {Event} event `click` event.
  37620. * @param {Object} instance Handsontable instance.
  37621. */
  37622. function onClick(event, instance) {
  37623. if (!isCheckboxInput(event.target)) {
  37624. return false;
  37625. }
  37626. var row = parseInt(event.target.getAttribute('data-row'), 10);
  37627. var col = parseInt(event.target.getAttribute('data-col'), 10);
  37628. var cellProperties = instance.getCellMeta(row, col);
  37629. if (cellProperties.readOnly) {
  37630. event.preventDefault();
  37631. }
  37632. }
  37633. /**
  37634. * `change` callback.
  37635. *
  37636. * @param {Event} event `change` event.
  37637. * @param {Object} instance Handsontable instance.
  37638. * @param {Object} cellProperties Reference to cell properties.
  37639. * @returns {Boolean}
  37640. */
  37641. function onChange(event, instance) {
  37642. if (!isCheckboxInput(event.target)) {
  37643. return false;
  37644. }
  37645. var row = parseInt(event.target.getAttribute('data-row'), 10);
  37646. var col = parseInt(event.target.getAttribute('data-col'), 10);
  37647. var cellProperties = instance.getCellMeta(row, col);
  37648. if (!cellProperties.readOnly) {
  37649. var newCheckboxValue = null;
  37650. if (event.target.checked) {
  37651. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? true : cellProperties.checkedTemplate;
  37652. } else {
  37653. newCheckboxValue = cellProperties.uncheckedTemplate === void 0 ? false : cellProperties.uncheckedTemplate;
  37654. }
  37655. instance.setDataAtCell(row, col, newCheckboxValue);
  37656. }
  37657. }
  37658. /**
  37659. * Check if the provided element is the checkbox input.
  37660. *
  37661. * @private
  37662. * @param {HTMLElement} element The element in question.
  37663. * @returns {Boolean}
  37664. */
  37665. function isCheckboxInput(element) {
  37666. return element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox';
  37667. }
  37668. exports.default = checkboxRenderer;
  37669. /***/ }),
  37670. /* 265 */
  37671. /***/ (function(module, exports, __webpack_require__) {
  37672. "use strict";
  37673. exports.__esModule = true;
  37674. var _element = __webpack_require__(0);
  37675. var _index = __webpack_require__(9);
  37676. /**
  37677. * @private
  37678. * @renderer HtmlRenderer
  37679. * @param instance
  37680. * @param TD
  37681. * @param row
  37682. * @param col
  37683. * @param prop
  37684. * @param value
  37685. * @param cellProperties
  37686. */
  37687. function htmlRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37688. (0, _index.getRenderer)('base').apply(this, arguments);
  37689. if (value === null || value === void 0) {
  37690. value = '';
  37691. }
  37692. (0, _element.fastInnerHTML)(TD, value);
  37693. }
  37694. exports.default = htmlRenderer;
  37695. /***/ }),
  37696. /* 266 */
  37697. /***/ (function(module, exports, __webpack_require__) {
  37698. "use strict";
  37699. exports.__esModule = true;
  37700. var _numbro = __webpack_require__(87);
  37701. var _numbro2 = _interopRequireDefault(_numbro);
  37702. var _index = __webpack_require__(9);
  37703. var _number = __webpack_require__(6);
  37704. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37705. /**
  37706. * Numeric cell renderer
  37707. *
  37708. * @private
  37709. * @renderer NumericRenderer
  37710. * @dependencies numbro
  37711. * @param {Object} instance Handsontable instance
  37712. * @param {Element} TD Table cell where to render
  37713. * @param {Number} row
  37714. * @param {Number} col
  37715. * @param {String|Number} prop Row object property name
  37716. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  37717. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  37718. */
  37719. function numericRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37720. if ((0, _number.isNumeric)(value)) {
  37721. if (typeof cellProperties.language !== 'undefined') {
  37722. _numbro2.default.culture(cellProperties.language);
  37723. }
  37724. value = (0, _numbro2.default)(value).format(cellProperties.format || '0');
  37725. var className = cellProperties.className || '';
  37726. var classArr = className.length ? className.split(' ') : [];
  37727. if (classArr.indexOf('htLeft') < 0 && classArr.indexOf('htCenter') < 0 && classArr.indexOf('htRight') < 0 && classArr.indexOf('htJustify') < 0) {
  37728. classArr.push('htRight');
  37729. }
  37730. if (classArr.indexOf('htNumeric') < 0) {
  37731. classArr.push('htNumeric');
  37732. }
  37733. cellProperties.className = classArr.join(' ');
  37734. }
  37735. (0, _index.getRenderer)('text')(instance, TD, row, col, prop, value, cellProperties);
  37736. }
  37737. exports.default = numericRenderer;
  37738. /***/ }),
  37739. /* 267 */
  37740. /***/ (function(module, exports, __webpack_require__) {
  37741. "use strict";
  37742. exports.__esModule = true;
  37743. var _element = __webpack_require__(0);
  37744. var _index = __webpack_require__(9);
  37745. var _number = __webpack_require__(6);
  37746. /**
  37747. * @private
  37748. * @renderer PasswordRenderer
  37749. * @param instance
  37750. * @param TD
  37751. * @param row
  37752. * @param col
  37753. * @param prop
  37754. * @param value
  37755. * @param cellProperties
  37756. */
  37757. function passwordRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37758. (0, _index.getRenderer)('text').apply(this, arguments);
  37759. value = TD.innerHTML;
  37760. var hashLength = cellProperties.hashLength || value.length;
  37761. var hashSymbol = cellProperties.hashSymbol || '*';
  37762. var hash = '';
  37763. (0, _number.rangeEach)(hashLength - 1, function () {
  37764. hash += hashSymbol;
  37765. });
  37766. (0, _element.fastInnerHTML)(TD, hash);
  37767. }
  37768. exports.default = passwordRenderer;
  37769. /***/ }),
  37770. /* 268 */
  37771. /***/ (function(module, exports, __webpack_require__) {
  37772. "use strict";
  37773. exports.__esModule = true;
  37774. var _element = __webpack_require__(0);
  37775. var _mixed = __webpack_require__(20);
  37776. var _index = __webpack_require__(9);
  37777. /**
  37778. * Default text renderer
  37779. *
  37780. * @private
  37781. * @renderer TextRenderer
  37782. * @param {Object} instance Handsontable instance
  37783. * @param {Element} TD Table cell where to render
  37784. * @param {Number} row
  37785. * @param {Number} col
  37786. * @param {String|Number} prop Row object property name
  37787. * @param value Value to render (remember to escape unsafe HTML before inserting to DOM!)
  37788. * @param {Object} cellProperties Cell properties (shared by cell renderer and editor)
  37789. */
  37790. function textRenderer(instance, TD, row, col, prop, value, cellProperties) {
  37791. (0, _index.getRenderer)('base').apply(this, arguments);
  37792. if (!value && cellProperties.placeholder) {
  37793. value = cellProperties.placeholder;
  37794. }
  37795. var escaped = (0, _mixed.stringify)(value);
  37796. if (!instance.getSettings().trimWhitespace) {
  37797. escaped = escaped.replace(/ /g, String.fromCharCode(160));
  37798. }
  37799. if (cellProperties.rendererTemplate) {
  37800. (0, _element.empty)(TD);
  37801. var TEMPLATE = document.createElement('TEMPLATE');
  37802. TEMPLATE.setAttribute('bind', '{{}}');
  37803. TEMPLATE.innerHTML = cellProperties.rendererTemplate;
  37804. HTMLTemplateElement.decorate(TEMPLATE);
  37805. TEMPLATE.model = instance.getSourceDataAtRow(row);
  37806. TD.appendChild(TEMPLATE);
  37807. } else {
  37808. // this is faster than innerHTML. See: https://github.com/handsontable/handsontable/wiki/JavaScript-&-DOM-performance-tips
  37809. (0, _element.fastInnerText)(TD, escaped);
  37810. }
  37811. }
  37812. exports.default = textRenderer;
  37813. /***/ }),
  37814. /* 269 */
  37815. /***/ (function(module, exports, __webpack_require__) {
  37816. "use strict";
  37817. exports.__esModule = true;
  37818. 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"); } }; }();
  37819. var _element = __webpack_require__(0);
  37820. var _browser = __webpack_require__(25);
  37821. var _eventManager = __webpack_require__(4);
  37822. var _eventManager2 = _interopRequireDefault(_eventManager);
  37823. var _event = __webpack_require__(7);
  37824. var _src = __webpack_require__(11);
  37825. var _src2 = _interopRequireDefault(_src);
  37826. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  37827. /**
  37828. * Handsontable TableView constructor
  37829. * @param {Object} instance
  37830. */
  37831. function TableView(instance) {
  37832. var _this = this;
  37833. var that = this;
  37834. this.eventManager = new _eventManager2.default(instance);
  37835. this.instance = instance;
  37836. this.settings = instance.getSettings();
  37837. this.selectionMouseDown = false;
  37838. var originalStyle = instance.rootElement.getAttribute('style');
  37839. if (originalStyle) {
  37840. instance.rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
  37841. }
  37842. (0, _element.addClass)(instance.rootElement, 'handsontable');
  37843. var table = document.createElement('TABLE');
  37844. (0, _element.addClass)(table, 'htCore');
  37845. if (instance.getSettings().tableClassName) {
  37846. (0, _element.addClass)(table, instance.getSettings().tableClassName);
  37847. }
  37848. this.THEAD = document.createElement('THEAD');
  37849. table.appendChild(this.THEAD);
  37850. this.TBODY = document.createElement('TBODY');
  37851. table.appendChild(this.TBODY);
  37852. instance.table = table;
  37853. instance.container.insertBefore(table, instance.container.firstChild);
  37854. this.eventManager.addEventListener(instance.rootElement, 'mousedown', function (event) {
  37855. this.selectionMouseDown = true;
  37856. if (!that.isTextSelectionAllowed(event.target)) {
  37857. clearTextSelection();
  37858. event.preventDefault();
  37859. window.focus(); // make sure that window that contains HOT is active. Important when HOT is in iframe.
  37860. }
  37861. });
  37862. this.eventManager.addEventListener(instance.rootElement, 'mouseup', function (event) {
  37863. this.selectionMouseDown = false;
  37864. });
  37865. this.eventManager.addEventListener(instance.rootElement, 'mousemove', function (event) {
  37866. if (this.selectionMouseDown && !that.isTextSelectionAllowed(event.target)) {
  37867. clearTextSelection();
  37868. event.preventDefault();
  37869. }
  37870. });
  37871. this.eventManager.addEventListener(document.documentElement, 'keyup', function (event) {
  37872. if (instance.selection.isInProgress() && !event.shiftKey) {
  37873. instance.selection.finish();
  37874. }
  37875. });
  37876. var isMouseDown;
  37877. this.isMouseDown = function () {
  37878. return isMouseDown;
  37879. };
  37880. this.eventManager.addEventListener(document.documentElement, 'mouseup', function (event) {
  37881. if (instance.selection.isInProgress() && event.which === 1) {
  37882. // is left mouse button
  37883. instance.selection.finish();
  37884. }
  37885. isMouseDown = false;
  37886. if ((0, _element.isOutsideInput)(document.activeElement) || !instance.selection.isSelected()) {
  37887. instance.unlisten();
  37888. }
  37889. });
  37890. this.eventManager.addEventListener(document.documentElement, 'mousedown', function (event) {
  37891. var originalTarget = event.target;
  37892. var next = event.target;
  37893. var eventX = event.x || event.clientX;
  37894. var eventY = event.y || event.clientY;
  37895. if (isMouseDown || !instance.rootElement) {
  37896. return; // it must have been started in a cell
  37897. }
  37898. // immediate click on "holder" means click on the right side of vertical scrollbar
  37899. if (next === instance.view.wt.wtTable.holder) {
  37900. var scrollbarWidth = (0, _element.getScrollbarWidth)();
  37901. if (document.elementFromPoint(eventX + scrollbarWidth, eventY) !== instance.view.wt.wtTable.holder || document.elementFromPoint(eventX, eventY + scrollbarWidth) !== instance.view.wt.wtTable.holder) {
  37902. return;
  37903. }
  37904. } else {
  37905. while (next !== document.documentElement) {
  37906. if (next === null) {
  37907. if (event.isTargetWebComponent) {
  37908. break;
  37909. }
  37910. // click on something that was a row but now is detached (possibly because your click triggered a rerender)
  37911. return;
  37912. }
  37913. if (next === instance.rootElement) {
  37914. // click inside container
  37915. return;
  37916. }
  37917. next = next.parentNode;
  37918. }
  37919. }
  37920. // function did not return until here, we have an outside click!
  37921. var outsideClickDeselects = typeof that.settings.outsideClickDeselects === 'function' ? that.settings.outsideClickDeselects(originalTarget) : that.settings.outsideClickDeselects;
  37922. if (outsideClickDeselects) {
  37923. instance.deselectCell();
  37924. } else {
  37925. instance.destroyEditor();
  37926. }
  37927. });
  37928. this.eventManager.addEventListener(table, 'selectstart', function (event) {
  37929. if (that.settings.fragmentSelection || (0, _element.isInput)(event.target)) {
  37930. return;
  37931. }
  37932. // https://github.com/handsontable/handsontable/issues/160
  37933. // Prevent text from being selected when performing drag down.
  37934. event.preventDefault();
  37935. });
  37936. var clearTextSelection = function clearTextSelection() {
  37937. // http://stackoverflow.com/questions/3169786/clear-text-selection-with-javascript
  37938. if (window.getSelection) {
  37939. if (window.getSelection().empty) {
  37940. // Chrome
  37941. window.getSelection().empty();
  37942. } else if (window.getSelection().removeAllRanges) {
  37943. // Firefox
  37944. window.getSelection().removeAllRanges();
  37945. }
  37946. } else if (document.selection) {
  37947. // IE?
  37948. document.selection.empty();
  37949. }
  37950. };
  37951. var selections = [new _src.Selection({
  37952. className: 'current',
  37953. border: {
  37954. width: 2,
  37955. color: '#5292F7',
  37956. // style: 'solid', // not used
  37957. cornerVisible: function cornerVisible() {
  37958. return that.settings.fillHandle && !that.isCellEdited() && !instance.selection.isMultiple();
  37959. },
  37960. multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() {
  37961. return !that.isCellEdited() && !instance.selection.isMultiple();
  37962. }
  37963. }
  37964. }), new _src.Selection({
  37965. className: 'area',
  37966. border: {
  37967. width: 1,
  37968. color: '#89AFF9',
  37969. // style: 'solid', // not used
  37970. cornerVisible: function cornerVisible() {
  37971. return that.settings.fillHandle && !that.isCellEdited() && instance.selection.isMultiple();
  37972. },
  37973. multipleSelectionHandlesVisible: function multipleSelectionHandlesVisible() {
  37974. return !that.isCellEdited() && instance.selection.isMultiple();
  37975. }
  37976. }
  37977. }), new _src.Selection({
  37978. className: 'highlight',
  37979. highlightHeaderClassName: that.settings.currentHeaderClassName,
  37980. highlightRowClassName: that.settings.currentRowClassName,
  37981. highlightColumnClassName: that.settings.currentColClassName
  37982. }), new _src.Selection({
  37983. className: 'fill',
  37984. border: {
  37985. width: 1,
  37986. color: 'red'
  37987. // style: 'solid' // not used
  37988. }
  37989. })];
  37990. selections.current = selections[0];
  37991. selections.area = selections[1];
  37992. selections.highlight = selections[2];
  37993. selections.fill = selections[3];
  37994. var walkontableConfig = {
  37995. debug: function debug() {
  37996. return that.settings.debug;
  37997. },
  37998. externalRowCalculator: this.instance.getPlugin('autoRowSize') && this.instance.getPlugin('autoRowSize').isEnabled(),
  37999. table: table,
  38000. preventOverflow: function preventOverflow() {
  38001. return _this.settings.preventOverflow;
  38002. },
  38003. stretchH: function stretchH() {
  38004. return that.settings.stretchH;
  38005. },
  38006. data: instance.getDataAtCell,
  38007. totalRows: function totalRows() {
  38008. return instance.countRows();
  38009. },
  38010. totalColumns: function totalColumns() {
  38011. return instance.countCols();
  38012. },
  38013. fixedColumnsLeft: function fixedColumnsLeft() {
  38014. return that.settings.fixedColumnsLeft;
  38015. },
  38016. fixedRowsTop: function fixedRowsTop() {
  38017. return that.settings.fixedRowsTop;
  38018. },
  38019. fixedRowsBottom: function fixedRowsBottom() {
  38020. return that.settings.fixedRowsBottom;
  38021. },
  38022. minSpareRows: function minSpareRows() {
  38023. return that.settings.minSpareRows;
  38024. },
  38025. renderAllRows: that.settings.renderAllRows,
  38026. rowHeaders: function rowHeaders() {
  38027. var headerRenderers = [];
  38028. if (instance.hasRowHeaders()) {
  38029. headerRenderers.push(function (row, TH) {
  38030. that.appendRowHeader(row, TH);
  38031. });
  38032. }
  38033. instance.runHooks('afterGetRowHeaderRenderers', headerRenderers);
  38034. return headerRenderers;
  38035. },
  38036. columnHeaders: function columnHeaders() {
  38037. var headerRenderers = [];
  38038. if (instance.hasColHeaders()) {
  38039. headerRenderers.push(function (column, TH) {
  38040. that.appendColHeader(column, TH);
  38041. });
  38042. }
  38043. instance.runHooks('afterGetColumnHeaderRenderers', headerRenderers);
  38044. return headerRenderers;
  38045. },
  38046. columnWidth: instance.getColWidth,
  38047. rowHeight: instance.getRowHeight,
  38048. cellRenderer: function cellRenderer(row, col, TD) {
  38049. var cellProperties = that.instance.getCellMeta(row, col);
  38050. var prop = that.instance.colToProp(col);
  38051. var value = that.instance.getDataAtRowProp(row, prop);
  38052. if (that.instance.hasHook('beforeValueRender')) {
  38053. value = that.instance.runHooks('beforeValueRender', value);
  38054. }
  38055. that.instance.runHooks('beforeRenderer', TD, row, col, prop, value, cellProperties);
  38056. that.instance.getCellRenderer(cellProperties)(that.instance, TD, row, col, prop, value, cellProperties);
  38057. that.instance.runHooks('afterRenderer', TD, row, col, prop, value, cellProperties);
  38058. },
  38059. selections: selections,
  38060. hideBorderOnMouseDownOver: function hideBorderOnMouseDownOver() {
  38061. return that.settings.fragmentSelection;
  38062. },
  38063. onCellMouseDown: function onCellMouseDown(event, coords, TD, wt) {
  38064. var blockCalculations = {
  38065. row: false,
  38066. column: false,
  38067. cells: false
  38068. };
  38069. instance.listen();
  38070. that.activeWt = wt;
  38071. isMouseDown = true;
  38072. instance.runHooks('beforeOnCellMouseDown', event, coords, TD, blockCalculations);
  38073. if ((0, _event.isImmediatePropagationStopped)(event)) {
  38074. return;
  38075. }
  38076. var actualSelection = instance.getSelectedRange();
  38077. var selection = instance.selection;
  38078. var selectedHeader = selection.selectedHeader;
  38079. if (event.shiftKey && actualSelection) {
  38080. if (coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) {
  38081. selection.setSelectedHeaders(false, false);
  38082. selection.setRangeEnd(coords);
  38083. } else if ((selectedHeader.cols || selectedHeader.rows) && coords.row >= 0 && coords.col >= 0 && !blockCalculations.cells) {
  38084. selection.setSelectedHeaders(false, false);
  38085. selection.setRangeEnd(new _src.CellCoords(coords.row, coords.col));
  38086. } else if (selectedHeader.cols && coords.row < 0 && !blockCalculations.column) {
  38087. selection.setRangeEnd(new _src.CellCoords(actualSelection.to.row, coords.col));
  38088. } else if (selectedHeader.rows && coords.col < 0 && !blockCalculations.row) {
  38089. selection.setRangeEnd(new _src.CellCoords(coords.row, actualSelection.to.col));
  38090. } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.col < 0 || selectedHeader.cols && coords.col < 0) && !blockCalculations.row) {
  38091. selection.setSelectedHeaders(true, false);
  38092. selection.setRangeStartOnly(new _src.CellCoords(actualSelection.from.row, 0));
  38093. selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1));
  38094. } else if ((!selectedHeader.cols && !selectedHeader.rows && coords.row < 0 || selectedHeader.rows && coords.row < 0) && !blockCalculations.column) {
  38095. selection.setSelectedHeaders(false, true);
  38096. selection.setRangeStartOnly(new _src.CellCoords(0, actualSelection.from.col));
  38097. selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col));
  38098. }
  38099. } else {
  38100. var doNewSelection = true;
  38101. if (actualSelection) {
  38102. var from = actualSelection.from,
  38103. to = actualSelection.to;
  38104. var coordsNotInSelection = !selection.inInSelection(coords);
  38105. if (coords.row < 0 && selectedHeader.cols) {
  38106. var start = Math.min(from.col, to.col);
  38107. var end = Math.max(from.col, to.col);
  38108. doNewSelection = coords.col < start || coords.col > end;
  38109. } else if (coords.col < 0 && selectedHeader.rows) {
  38110. var _start = Math.min(from.row, to.row);
  38111. var _end = Math.max(from.row, to.row);
  38112. doNewSelection = coords.row < _start || coords.row > _end;
  38113. } else {
  38114. doNewSelection = coordsNotInSelection;
  38115. }
  38116. }
  38117. var rightClick = (0, _event.isRightClick)(event);
  38118. var leftClick = (0, _event.isLeftClick)(event) || event.type === 'touchstart';
  38119. // clicked row header and when some column was selected
  38120. if (coords.row < 0 && coords.col >= 0 && !blockCalculations.column) {
  38121. selection.setSelectedHeaders(false, true);
  38122. if (leftClick || rightClick && doNewSelection) {
  38123. selection.setRangeStartOnly(new _src.CellCoords(0, coords.col));
  38124. selection.setRangeEnd(new _src.CellCoords(Math.max(instance.countRows() - 1, 0), coords.col), false);
  38125. }
  38126. // clicked column header and when some row was selected
  38127. } else if (coords.col < 0 && coords.row >= 0 && !blockCalculations.row) {
  38128. selection.setSelectedHeaders(true, false);
  38129. if (leftClick || rightClick && doNewSelection) {
  38130. selection.setRangeStartOnly(new _src.CellCoords(coords.row, 0));
  38131. selection.setRangeEnd(new _src.CellCoords(coords.row, Math.max(instance.countCols() - 1, 0)), false);
  38132. }
  38133. } else if (coords.col >= 0 && coords.row >= 0 && !blockCalculations.cells) {
  38134. if (leftClick || rightClick && doNewSelection) {
  38135. selection.setSelectedHeaders(false, false);
  38136. selection.setRangeStart(coords);
  38137. }
  38138. } else if (coords.col < 0 && coords.row < 0) {
  38139. coords.row = 0;
  38140. coords.col = 0;
  38141. selection.setSelectedHeaders(false, false, true);
  38142. selection.setRangeStart(coords);
  38143. }
  38144. }
  38145. instance.runHooks('afterOnCellMouseDown', event, coords, TD);
  38146. that.activeWt = that.wt;
  38147. },
  38148. onCellMouseOut: function onCellMouseOut(event, coords, TD, wt) {
  38149. that.activeWt = wt;
  38150. instance.runHooks('beforeOnCellMouseOut', event, coords, TD);
  38151. if ((0, _event.isImmediatePropagationStopped)(event)) {
  38152. return;
  38153. }
  38154. instance.runHooks('afterOnCellMouseOut', event, coords, TD);
  38155. that.activeWt = that.wt;
  38156. },
  38157. onCellMouseOver: function onCellMouseOver(event, coords, TD, wt) {
  38158. var blockCalculations = {
  38159. row: false,
  38160. column: false,
  38161. cell: false
  38162. };
  38163. that.activeWt = wt;
  38164. instance.runHooks('beforeOnCellMouseOver', event, coords, TD, blockCalculations);
  38165. if ((0, _event.isImmediatePropagationStopped)(event)) {
  38166. return;
  38167. }
  38168. if (event.button === 0 && isMouseDown) {
  38169. if (coords.row >= 0 && coords.col >= 0) {
  38170. // is not a header
  38171. if (instance.selection.selectedHeader.cols && !blockCalculations.column) {
  38172. instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false);
  38173. } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) {
  38174. instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false);
  38175. } else if (!blockCalculations.cell) {
  38176. instance.selection.setRangeEnd(coords);
  38177. }
  38178. } else {
  38179. /* eslint-disable no-lonely-if */
  38180. if (instance.selection.selectedHeader.cols && !blockCalculations.column) {
  38181. instance.selection.setRangeEnd(new _src.CellCoords(instance.countRows() - 1, coords.col), false);
  38182. } else if (instance.selection.selectedHeader.rows && !blockCalculations.row) {
  38183. instance.selection.setRangeEnd(new _src.CellCoords(coords.row, instance.countCols() - 1), false);
  38184. } else if (!blockCalculations.cell) {
  38185. instance.selection.setRangeEnd(coords);
  38186. }
  38187. }
  38188. }
  38189. instance.runHooks('afterOnCellMouseOver', event, coords, TD);
  38190. that.activeWt = that.wt;
  38191. },
  38192. onCellMouseUp: function onCellMouseUp(event, coords, TD, wt) {
  38193. that.activeWt = wt;
  38194. instance.runHooks('beforeOnCellMouseUp', event, coords, TD);
  38195. instance.runHooks('afterOnCellMouseUp', event, coords, TD);
  38196. that.activeWt = that.wt;
  38197. },
  38198. onCellCornerMouseDown: function onCellCornerMouseDown(event) {
  38199. event.preventDefault();
  38200. instance.runHooks('afterOnCellCornerMouseDown', event);
  38201. },
  38202. onCellCornerDblClick: function onCellCornerDblClick(event) {
  38203. event.preventDefault();
  38204. instance.runHooks('afterOnCellCornerDblClick', event);
  38205. },
  38206. beforeDraw: function beforeDraw(force, skipRender) {
  38207. that.beforeRender(force, skipRender);
  38208. },
  38209. onDraw: function onDraw(force) {
  38210. that.onDraw(force);
  38211. },
  38212. onScrollVertically: function onScrollVertically() {
  38213. instance.runHooks('afterScrollVertically');
  38214. },
  38215. onScrollHorizontally: function onScrollHorizontally() {
  38216. instance.runHooks('afterScrollHorizontally');
  38217. },
  38218. onBeforeDrawBorders: function onBeforeDrawBorders(corners, borderClassName) {
  38219. instance.runHooks('beforeDrawBorders', corners, borderClassName);
  38220. },
  38221. onBeforeTouchScroll: function onBeforeTouchScroll() {
  38222. instance.runHooks('beforeTouchScroll');
  38223. },
  38224. onAfterMomentumScroll: function onAfterMomentumScroll() {
  38225. instance.runHooks('afterMomentumScroll');
  38226. },
  38227. onBeforeStretchingColumnWidth: function onBeforeStretchingColumnWidth(stretchedWidth, column) {
  38228. return instance.runHooks('beforeStretchingColumnWidth', stretchedWidth, column);
  38229. },
  38230. onModifyRowHeaderWidth: function onModifyRowHeaderWidth(rowHeaderWidth) {
  38231. return instance.runHooks('modifyRowHeaderWidth', rowHeaderWidth);
  38232. },
  38233. viewportRowCalculatorOverride: function viewportRowCalculatorOverride(calc) {
  38234. var rows = instance.countRows();
  38235. var viewportOffset = that.settings.viewportRowRenderingOffset;
  38236. if (viewportOffset === 'auto' && that.settings.fixedRowsTop) {
  38237. viewportOffset = 10;
  38238. }
  38239. if (typeof viewportOffset === 'number') {
  38240. calc.startRow = Math.max(calc.startRow - viewportOffset, 0);
  38241. calc.endRow = Math.min(calc.endRow + viewportOffset, rows - 1);
  38242. }
  38243. if (viewportOffset === 'auto') {
  38244. var center = calc.startRow + calc.endRow - calc.startRow;
  38245. var offset = Math.ceil(center / rows * 12);
  38246. calc.startRow = Math.max(calc.startRow - offset, 0);
  38247. calc.endRow = Math.min(calc.endRow + offset, rows - 1);
  38248. }
  38249. instance.runHooks('afterViewportRowCalculatorOverride', calc);
  38250. },
  38251. viewportColumnCalculatorOverride: function viewportColumnCalculatorOverride(calc) {
  38252. var cols = instance.countCols();
  38253. var viewportOffset = that.settings.viewportColumnRenderingOffset;
  38254. if (viewportOffset === 'auto' && that.settings.fixedColumnsLeft) {
  38255. viewportOffset = 10;
  38256. }
  38257. if (typeof viewportOffset === 'number') {
  38258. calc.startColumn = Math.max(calc.startColumn - viewportOffset, 0);
  38259. calc.endColumn = Math.min(calc.endColumn + viewportOffset, cols - 1);
  38260. }
  38261. if (viewportOffset === 'auto') {
  38262. var center = calc.startColumn + calc.endColumn - calc.startColumn;
  38263. var offset = Math.ceil(center / cols * 12);
  38264. calc.startRow = Math.max(calc.startColumn - offset, 0);
  38265. calc.endColumn = Math.min(calc.endColumn + offset, cols - 1);
  38266. }
  38267. instance.runHooks('afterViewportColumnCalculatorOverride', calc);
  38268. },
  38269. rowHeaderWidth: function rowHeaderWidth() {
  38270. return that.settings.rowHeaderWidth;
  38271. },
  38272. columnHeaderHeight: function columnHeaderHeight() {
  38273. var columnHeaderHeight = instance.runHooks('modifyColumnHeaderHeight');
  38274. return that.settings.columnHeaderHeight || columnHeaderHeight;
  38275. }
  38276. };
  38277. instance.runHooks('beforeInitWalkontable', walkontableConfig);
  38278. this.wt = new _src2.default(walkontableConfig);
  38279. this.activeWt = this.wt;
  38280. if (!(0, _browser.isChrome)() && !(0, _browser.isSafari)()) {
  38281. this.eventManager.addEventListener(instance.rootElement, 'wheel', function (event) {
  38282. event.preventDefault();
  38283. var lineHeight = parseInt((0, _element.getComputedStyle)(document.body)['font-size'], 10);
  38284. var holder = that.wt.wtOverlays.scrollableElement;
  38285. var deltaY = event.wheelDeltaY || event.deltaY;
  38286. var deltaX = event.wheelDeltaX || event.deltaX;
  38287. switch (event.deltaMode) {
  38288. case 0:
  38289. holder.scrollLeft += deltaX;
  38290. holder.scrollTop += deltaY;
  38291. break;
  38292. case 1:
  38293. holder.scrollLeft += deltaX * lineHeight;
  38294. holder.scrollTop += deltaY * lineHeight;
  38295. break;
  38296. default:
  38297. break;
  38298. }
  38299. });
  38300. }
  38301. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'mousedown', function (event) {
  38302. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  38303. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  38304. (0, _event.stopPropagation)(event);
  38305. }
  38306. });
  38307. this.eventManager.addEventListener(that.wt.wtTable.spreader, 'contextmenu', function (event) {
  38308. // right mouse button exactly on spreader means right click on the right hand side of vertical scrollbar
  38309. if (event.target === that.wt.wtTable.spreader && event.which === 3) {
  38310. (0, _event.stopPropagation)(event);
  38311. }
  38312. });
  38313. this.eventManager.addEventListener(document.documentElement, 'click', function () {
  38314. if (that.settings.observeDOMVisibility) {
  38315. if (that.wt.drawInterrupted) {
  38316. that.instance.forceFullRender = true;
  38317. that.render();
  38318. }
  38319. }
  38320. });
  38321. }
  38322. TableView.prototype.isTextSelectionAllowed = function (el) {
  38323. if ((0, _element.isInput)(el)) {
  38324. return true;
  38325. }
  38326. var isChildOfTableBody = (0, _element.isChildOf)(el, this.instance.view.wt.wtTable.spreader);
  38327. if (this.settings.fragmentSelection === true && isChildOfTableBody) {
  38328. return true;
  38329. }
  38330. if (this.settings.fragmentSelection === 'cell' && this.isSelectedOnlyCell() && isChildOfTableBody) {
  38331. return true;
  38332. }
  38333. if (!this.settings.fragmentSelection && this.isCellEdited() && this.isSelectedOnlyCell()) {
  38334. return true;
  38335. }
  38336. return false;
  38337. };
  38338. /**
  38339. * Check if selected only one cell.
  38340. *
  38341. * @returns {Boolean}
  38342. */
  38343. TableView.prototype.isSelectedOnlyCell = function () {
  38344. var _ref = this.instance.getSelected() || [],
  38345. _ref2 = _slicedToArray(_ref, 4),
  38346. row = _ref2[0],
  38347. col = _ref2[1],
  38348. rowEnd = _ref2[2],
  38349. colEnd = _ref2[3];
  38350. return row !== void 0 && row === rowEnd && col === colEnd;
  38351. };
  38352. TableView.prototype.isCellEdited = function () {
  38353. var activeEditor = this.instance.getActiveEditor();
  38354. return activeEditor && activeEditor.isOpened();
  38355. };
  38356. TableView.prototype.beforeRender = function (force, skipRender) {
  38357. if (force) {
  38358. // this.instance.forceFullRender = did Handsontable request full render?
  38359. this.instance.runHooks('beforeRender', this.instance.forceFullRender, skipRender);
  38360. }
  38361. };
  38362. TableView.prototype.onDraw = function (force) {
  38363. if (force) {
  38364. // this.instance.forceFullRender = did Handsontable request full render?
  38365. this.instance.runHooks('afterRender', this.instance.forceFullRender);
  38366. }
  38367. };
  38368. TableView.prototype.render = function () {
  38369. this.wt.draw(!this.instance.forceFullRender);
  38370. this.instance.forceFullRender = false;
  38371. this.instance.renderCall = false;
  38372. };
  38373. /**
  38374. * Returns td object given coordinates
  38375. *
  38376. * @param {CellCoords} coords
  38377. * @param {Boolean} topmost
  38378. */
  38379. TableView.prototype.getCellAtCoords = function (coords, topmost) {
  38380. var td = this.wt.getCell(coords, topmost);
  38381. if (td < 0) {
  38382. // there was an exit code (cell is out of bounds)
  38383. return null;
  38384. }
  38385. return td;
  38386. };
  38387. /**
  38388. * Scroll viewport to selection.
  38389. *
  38390. * @param {CellCoords} coords
  38391. */
  38392. TableView.prototype.scrollViewport = function (coords) {
  38393. this.wt.scrollViewport(coords);
  38394. };
  38395. /**
  38396. * Append row header to a TH element
  38397. * @param row
  38398. * @param TH
  38399. */
  38400. TableView.prototype.appendRowHeader = function (row, TH) {
  38401. if (TH.firstChild) {
  38402. var container = TH.firstChild;
  38403. if (!(0, _element.hasClass)(container, 'relative')) {
  38404. (0, _element.empty)(TH);
  38405. this.appendRowHeader(row, TH);
  38406. return;
  38407. }
  38408. this.updateCellHeader(container.querySelector('.rowHeader'), row, this.instance.getRowHeader);
  38409. } else {
  38410. var div = document.createElement('div');
  38411. var span = document.createElement('span');
  38412. div.className = 'relative';
  38413. span.className = 'rowHeader';
  38414. this.updateCellHeader(span, row, this.instance.getRowHeader);
  38415. div.appendChild(span);
  38416. TH.appendChild(div);
  38417. }
  38418. this.instance.runHooks('afterGetRowHeader', row, TH);
  38419. };
  38420. /**
  38421. * Append column header to a TH element
  38422. * @param col
  38423. * @param TH
  38424. */
  38425. TableView.prototype.appendColHeader = function (col, TH) {
  38426. if (TH.firstChild) {
  38427. var container = TH.firstChild;
  38428. if ((0, _element.hasClass)(container, 'relative')) {
  38429. this.updateCellHeader(container.querySelector('.colHeader'), col, this.instance.getColHeader);
  38430. } else {
  38431. (0, _element.empty)(TH);
  38432. this.appendColHeader(col, TH);
  38433. }
  38434. } else {
  38435. var div = document.createElement('div');
  38436. var span = document.createElement('span');
  38437. div.className = 'relative';
  38438. span.className = 'colHeader';
  38439. this.updateCellHeader(span, col, this.instance.getColHeader);
  38440. div.appendChild(span);
  38441. TH.appendChild(div);
  38442. }
  38443. this.instance.runHooks('afterGetColHeader', col, TH);
  38444. };
  38445. /**
  38446. * Update header cell content
  38447. *
  38448. * @since 0.15.0-beta4
  38449. * @param {HTMLElement} element Element to update
  38450. * @param {Number} index Row index or column index
  38451. * @param {Function} content Function which should be returns content for this cell
  38452. */
  38453. TableView.prototype.updateCellHeader = function (element, index, content) {
  38454. var renderedIndex = index;
  38455. var parentOverlay = this.wt.wtOverlays.getParentOverlay(element) || this.wt;
  38456. // prevent wrong calculations from SampleGenerator
  38457. if (element.parentNode) {
  38458. if ((0, _element.hasClass)(element, 'colHeader')) {
  38459. renderedIndex = parentOverlay.wtTable.columnFilter.sourceToRendered(index);
  38460. } else if ((0, _element.hasClass)(element, 'rowHeader')) {
  38461. renderedIndex = parentOverlay.wtTable.rowFilter.sourceToRendered(index);
  38462. }
  38463. }
  38464. if (renderedIndex > -1) {
  38465. (0, _element.fastInnerHTML)(element, content(index));
  38466. } else {
  38467. // workaround for https://github.com/handsontable/handsontable/issues/1946
  38468. (0, _element.fastInnerText)(element, String.fromCharCode(160));
  38469. (0, _element.addClass)(element, 'cornerHeader');
  38470. }
  38471. };
  38472. /**
  38473. * Given a element's left position relative to the viewport, returns maximum element width until the right
  38474. * edge of the viewport (before scrollbar)
  38475. *
  38476. * @param {Number} leftOffset
  38477. * @return {Number}
  38478. */
  38479. TableView.prototype.maximumVisibleElementWidth = function (leftOffset) {
  38480. var workspaceWidth = this.wt.wtViewport.getWorkspaceWidth();
  38481. var maxWidth = workspaceWidth - leftOffset;
  38482. return maxWidth > 0 ? maxWidth : 0;
  38483. };
  38484. /**
  38485. * Given a element's top position relative to the viewport, returns maximum element height until the bottom
  38486. * edge of the viewport (before scrollbar)
  38487. *
  38488. * @param {Number} topOffset
  38489. * @return {Number}
  38490. */
  38491. TableView.prototype.maximumVisibleElementHeight = function (topOffset) {
  38492. var workspaceHeight = this.wt.wtViewport.getWorkspaceHeight();
  38493. var maxHeight = workspaceHeight - topOffset;
  38494. return maxHeight > 0 ? maxHeight : 0;
  38495. };
  38496. TableView.prototype.mainViewIsActive = function () {
  38497. return this.wt === this.activeWt;
  38498. };
  38499. TableView.prototype.destroy = function () {
  38500. this.wt.destroy();
  38501. this.eventManager.destroy();
  38502. };
  38503. exports.default = TableView;
  38504. /***/ }),
  38505. /* 270 */
  38506. /***/ (function(module, exports, __webpack_require__) {
  38507. "use strict";
  38508. exports.__esModule = true;
  38509. 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; }; }();
  38510. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38511. /**
  38512. * Refactored implementation of LinkedList (part of javascript-algorithms project) by Github users:
  38513. * mgechev, AndriiHeonia, Microfed and Jakeh (part of javascript-algorithms project - all project contributors
  38514. * at repository website)
  38515. *
  38516. * Link to repository: https://github.com/mgechev/javascript-algorithms
  38517. */
  38518. /**
  38519. * Linked list node.
  38520. *
  38521. * @class NodeStructure
  38522. * @util
  38523. */
  38524. var NodeStructure = function NodeStructure(data) {
  38525. _classCallCheck(this, NodeStructure);
  38526. /**
  38527. * Data of the node.
  38528. * @member {Object}
  38529. */
  38530. this.data = data;
  38531. /**
  38532. * Next node.
  38533. * @member {NodeStructure}
  38534. */
  38535. this.next = null;
  38536. /**
  38537. * Previous node.
  38538. * @member {NodeStructure}
  38539. */
  38540. this.prev = null;
  38541. };
  38542. /**
  38543. * Linked list.
  38544. *
  38545. * @class LinkedList
  38546. * @util
  38547. */
  38548. var LinkedList = function () {
  38549. function LinkedList() {
  38550. _classCallCheck(this, LinkedList);
  38551. this.first = null;
  38552. this.last = null;
  38553. }
  38554. /**
  38555. * Add data to the end of linked list.
  38556. *
  38557. * @param {Object} data Data which should be added.
  38558. */
  38559. _createClass(LinkedList, [{
  38560. key: "push",
  38561. value: function push(data) {
  38562. var node = new NodeStructure(data);
  38563. if (this.first === null) {
  38564. this.first = node;
  38565. this.last = node;
  38566. } else {
  38567. var temp = this.last;
  38568. this.last = node;
  38569. node.prev = temp;
  38570. temp.next = node;
  38571. }
  38572. }
  38573. /**
  38574. * Add data to the beginning of linked list.
  38575. *
  38576. * @param {Object} data Data which should be added.
  38577. */
  38578. }, {
  38579. key: "unshift",
  38580. value: function unshift(data) {
  38581. var node = new NodeStructure(data);
  38582. if (this.first === null) {
  38583. this.first = node;
  38584. this.last = node;
  38585. } else {
  38586. var temp = this.first;
  38587. this.first = node;
  38588. node.next = temp;
  38589. temp.prev = node;
  38590. }
  38591. }
  38592. /**
  38593. * In order traversal of the linked list.
  38594. *
  38595. * @param {Function} callback Callback which should be executed on each node.
  38596. */
  38597. }, {
  38598. key: "inorder",
  38599. value: function inorder(callback) {
  38600. var temp = this.first;
  38601. while (temp) {
  38602. callback(temp);
  38603. temp = temp.next;
  38604. }
  38605. }
  38606. /**
  38607. * Remove data from the linked list.
  38608. *
  38609. * @param {Object} data Data which should be removed.
  38610. * @returns {Boolean} Returns true if data has been removed.
  38611. */
  38612. }, {
  38613. key: "remove",
  38614. value: function remove(data) {
  38615. if (this.first === null) {
  38616. return false;
  38617. }
  38618. var temp = this.first;
  38619. var next = void 0;
  38620. var prev = void 0;
  38621. while (temp) {
  38622. if (temp.data === data) {
  38623. next = temp.next;
  38624. prev = temp.prev;
  38625. if (next) {
  38626. next.prev = prev;
  38627. }
  38628. if (prev) {
  38629. prev.next = next;
  38630. }
  38631. if (temp === this.first) {
  38632. this.first = next;
  38633. }
  38634. if (temp === this.last) {
  38635. this.last = prev;
  38636. }
  38637. return true;
  38638. }
  38639. temp = temp.next;
  38640. }
  38641. return false;
  38642. }
  38643. /**
  38644. * Check if linked list contains cycle.
  38645. *
  38646. * @returns {Boolean} Returns true if linked list contains cycle.
  38647. */
  38648. }, {
  38649. key: "hasCycle",
  38650. value: function hasCycle() {
  38651. var fast = this.first;
  38652. var slow = this.first;
  38653. while (true) {
  38654. if (fast === null) {
  38655. return false;
  38656. }
  38657. fast = fast.next;
  38658. if (fast === null) {
  38659. return false;
  38660. }
  38661. fast = fast.next;
  38662. slow = slow.next;
  38663. if (fast === slow) {
  38664. return true;
  38665. }
  38666. }
  38667. }
  38668. }, {
  38669. key: "pop",
  38670. /**
  38671. * Return last node from the linked list.
  38672. *
  38673. * @returns {NodeStructure} Last node.
  38674. */
  38675. value: function pop() {
  38676. if (this.last === null) {
  38677. return null;
  38678. }
  38679. var temp = this.last;
  38680. this.last = this.last.prev;
  38681. return temp;
  38682. }
  38683. }, {
  38684. key: "shift",
  38685. /**
  38686. * Return first node from the linked list.
  38687. *
  38688. * @returns {NodeStructure} First node.
  38689. */
  38690. value: function shift() {
  38691. if (this.first === null) {
  38692. return null;
  38693. }
  38694. var temp = this.first;
  38695. this.first = this.first.next;
  38696. return temp;
  38697. }
  38698. }, {
  38699. key: "recursiveReverse",
  38700. /**
  38701. * Reverses the linked list recursively
  38702. */
  38703. value: function recursiveReverse() {
  38704. function inverse(current, next) {
  38705. if (!next) {
  38706. return;
  38707. }
  38708. inverse(next, next.next);
  38709. next.next = current;
  38710. }
  38711. if (!this.first) {
  38712. return;
  38713. }
  38714. inverse(this.first, this.first.next);
  38715. this.first.next = null;
  38716. var temp = this.first;
  38717. this.first = this.last;
  38718. this.last = temp;
  38719. }
  38720. }, {
  38721. key: "reverse",
  38722. /**
  38723. * Reverses the linked list iteratively
  38724. */
  38725. value: function reverse() {
  38726. if (!this.first || !this.first.next) {
  38727. return;
  38728. }
  38729. var current = this.first.next;
  38730. var prev = this.first;
  38731. var temp = void 0;
  38732. while (current) {
  38733. temp = current.next;
  38734. current.next = prev;
  38735. prev.prev = current;
  38736. prev = current;
  38737. current = temp;
  38738. }
  38739. this.first.next = null;
  38740. this.last.prev = null;
  38741. temp = this.first;
  38742. this.first = prev;
  38743. this.last = temp;
  38744. }
  38745. }]);
  38746. return LinkedList;
  38747. }();
  38748. ;
  38749. exports.NodeStructure = NodeStructure;
  38750. exports.default = LinkedList;
  38751. /***/ }),
  38752. /* 271 */
  38753. /***/ (function(module, exports, __webpack_require__) {
  38754. "use strict";
  38755. exports.__esModule = true;
  38756. 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; }; }();
  38757. exports.parseDelay = parseDelay;
  38758. var _feature = __webpack_require__(34);
  38759. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  38760. /**
  38761. * @class Interval
  38762. * @util
  38763. */
  38764. var Interval = function () {
  38765. _createClass(Interval, null, [{
  38766. key: 'create',
  38767. value: function create(func, delay) {
  38768. return new Interval(func, delay);
  38769. }
  38770. }]);
  38771. function Interval(func, delay) {
  38772. var _this = this;
  38773. _classCallCheck(this, Interval);
  38774. /**
  38775. * Animation frame request id.
  38776. *
  38777. * @type {Number}
  38778. */
  38779. this.timer = null;
  38780. /**
  38781. * Function to invoke repeatedly.
  38782. *
  38783. * @type {Function}
  38784. */
  38785. this.func = func;
  38786. /**
  38787. * Number of milliseconds that function should wait before next call.
  38788. */
  38789. this.delay = parseDelay(delay);
  38790. /**
  38791. * Flag which indicates if interval object was stopped.
  38792. *
  38793. * @type {Boolean}
  38794. * @default true
  38795. */
  38796. this.stopped = true;
  38797. /**
  38798. * Interval time (in milliseconds) of the last callback call.
  38799. *
  38800. * @private
  38801. * @type {Number}
  38802. */
  38803. this._then = null;
  38804. /**
  38805. * Bounded function `func`.
  38806. *
  38807. * @private
  38808. * @type {Function}
  38809. */
  38810. this._callback = function () {
  38811. return _this.__callback();
  38812. };
  38813. }
  38814. /**
  38815. * Start loop.
  38816. *
  38817. * @returns {Interval}
  38818. */
  38819. _createClass(Interval, [{
  38820. key: 'start',
  38821. value: function start() {
  38822. if (this.stopped) {
  38823. this._then = Date.now();
  38824. this.stopped = false;
  38825. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  38826. }
  38827. return this;
  38828. }
  38829. /**
  38830. * Stop looping.
  38831. *
  38832. * @returns {Interval}
  38833. */
  38834. }, {
  38835. key: 'stop',
  38836. value: function stop() {
  38837. if (!this.stopped) {
  38838. this.stopped = true;
  38839. (0, _feature.cancelAnimationFrame)(this.timer);
  38840. this.timer = null;
  38841. }
  38842. return this;
  38843. }
  38844. /**
  38845. * Loop callback, fired on every animation frame.
  38846. *
  38847. * @private
  38848. */
  38849. }, {
  38850. key: '__callback',
  38851. value: function __callback() {
  38852. this.timer = (0, _feature.requestAnimationFrame)(this._callback);
  38853. if (this.delay) {
  38854. var now = Date.now();
  38855. var elapsed = now - this._then;
  38856. if (elapsed > this.delay) {
  38857. this._then = now - elapsed % this.delay;
  38858. this.func();
  38859. }
  38860. } else {
  38861. this.func();
  38862. }
  38863. }
  38864. }]);
  38865. return Interval;
  38866. }();
  38867. exports.default = Interval;
  38868. function parseDelay(delay) {
  38869. if (typeof delay === 'string' && /fps$/.test(delay)) {
  38870. delay = 1000 / parseInt(delay.replace('fps', '') || 0, 10);
  38871. }
  38872. return delay;
  38873. }
  38874. /***/ }),
  38875. /* 272 */
  38876. /***/ (function(module, exports, __webpack_require__) {
  38877. "use strict";
  38878. exports.__esModule = true;
  38879. exports.default = mergeSort;
  38880. exports.merge = merge;
  38881. var _linkedList = __webpack_require__(270);
  38882. var _linkedList2 = _interopRequireDefault(_linkedList);
  38883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  38884. /**
  38885. * Refactored implementation of mergeSort (part of javascript-algorithms project) by Github users:
  38886. * mgechev, AndriiHeonia and lekkas (part of javascript-algorithms project - all project contributors
  38887. * at repository website)
  38888. *
  38889. * Link to repository: https://github.com/mgechev/javascript-algorithms
  38890. */
  38891. /**
  38892. * Specifies a function that defines the sort order. The array is sorted according to each
  38893. * character's Unicode code point value, according to the string conversion of each element.
  38894. *
  38895. * @param a {*} first compared element.
  38896. * @param b {*} second compared element.
  38897. * @returns {Number}
  38898. */
  38899. var defaultCompareFunction = function defaultCompareFunction(a, b) {
  38900. // sort lexically
  38901. var firstValue = a.toString();
  38902. var secondValue = b.toString();
  38903. if (firstValue === secondValue) {
  38904. return 0;
  38905. } else if (firstValue < secondValue) {
  38906. return -1;
  38907. }
  38908. return 1;
  38909. };
  38910. /**
  38911. * Mergesort method which is recursively called for sorting the input array.
  38912. *
  38913. * @param {Array} array The array which should be sorted.
  38914. * @param {Function} compareFunction Compares two items in an array. If compareFunction is not supplied,
  38915. * elements are sorted by converting them to strings and comparing strings in Unicode code point order.
  38916. * @param {Number} startIndex Left side of the subarray.
  38917. * @param {Number} endIndex Right side of the subarray.
  38918. * @returns {Array} Array with sorted subarray.
  38919. */
  38920. function mergeSort(array) {
  38921. var compareFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCompareFunction;
  38922. var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  38923. var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : array.length;
  38924. if (Math.abs(endIndex - startIndex) <= 1) {
  38925. return [];
  38926. }
  38927. var middleIndex = Math.ceil((startIndex + endIndex) / 2);
  38928. mergeSort(array, compareFunction, startIndex, middleIndex);
  38929. mergeSort(array, compareFunction, middleIndex, endIndex);
  38930. return merge(array, compareFunction, startIndex, middleIndex, endIndex);
  38931. }
  38932. /**
  38933. * Devides and sort merges two subarrays of given array
  38934. *
  38935. * @param {Array} array The array which subarrays should be sorted.
  38936. * @param {Number} startIndex The start of the first subarray.
  38937. * This subarray is with end middle - 1.
  38938. * @param {Number} middleIndex The start of the second array.
  38939. * @param {Number} endIndex end - 1 is the end of the second array.
  38940. * @returns {Array} The array with sorted subarray.
  38941. */
  38942. function merge(array, compareFunction, startIndex, middleIndex, endIndex) {
  38943. var leftElements = new _linkedList2.default();
  38944. var rightElements = new _linkedList2.default();
  38945. var leftSize = middleIndex - startIndex;
  38946. var rightSize = endIndex - middleIndex;
  38947. var maxSize = Math.max(leftSize, rightSize);
  38948. var size = endIndex - startIndex;
  38949. for (var _i = 0; _i < maxSize; _i += 1) {
  38950. if (_i < leftSize) {
  38951. leftElements.push(array[startIndex + _i]);
  38952. }
  38953. if (_i < rightSize) {
  38954. rightElements.push(array[middleIndex + _i]);
  38955. }
  38956. }
  38957. var i = 0;
  38958. while (i < size) {
  38959. if (leftElements.first && rightElements.first) {
  38960. if (compareFunction(leftElements.first.data, rightElements.first.data) > 0) {
  38961. array[startIndex + i] = rightElements.shift().data;
  38962. } else {
  38963. array[startIndex + i] = leftElements.shift().data;
  38964. }
  38965. } else if (leftElements.first) {
  38966. array[startIndex + i] = leftElements.shift().data;
  38967. } else {
  38968. array[startIndex + i] = rightElements.shift().data;
  38969. }
  38970. i += 1;
  38971. }
  38972. return array;
  38973. };
  38974. /***/ }),
  38975. /* 273 */
  38976. /***/ (function(module, exports, __webpack_require__) {
  38977. "use strict";
  38978. exports.__esModule = true;
  38979. exports.default = autocompleteValidator;
  38980. /**
  38981. * Autocomplete cell validator.
  38982. *
  38983. * @private
  38984. * @validator AutocompleteValidator
  38985. * @param {*} value - Value of edited cell
  38986. * @param {Function} callback - Callback called with validation result
  38987. */
  38988. function autocompleteValidator(value, callback) {
  38989. if (value == null) {
  38990. value = '';
  38991. }
  38992. if (this.allowEmpty && value === '') {
  38993. callback(true);
  38994. return;
  38995. }
  38996. if (this.strict && this.source) {
  38997. if (typeof this.source === 'function') {
  38998. this.source(value, process(value, callback));
  38999. } else {
  39000. process(value, callback)(this.source);
  39001. }
  39002. } else {
  39003. callback(true);
  39004. }
  39005. };
  39006. /**
  39007. * Function responsible for validation of autocomplete value.
  39008. *
  39009. * @param {*} value - Value of edited cell
  39010. * @param {Function} callback - Callback called with validation result
  39011. */
  39012. function process(value, callback) {
  39013. var originalVal = value;
  39014. return function (source) {
  39015. var found = false;
  39016. for (var s = 0, slen = source.length; s < slen; s++) {
  39017. if (originalVal === source[s]) {
  39018. found = true; // perfect match
  39019. break;
  39020. }
  39021. }
  39022. callback(found);
  39023. };
  39024. }
  39025. /***/ }),
  39026. /* 274 */
  39027. /***/ (function(module, exports, __webpack_require__) {
  39028. "use strict";
  39029. exports.__esModule = true;
  39030. exports.default = dateValidator;
  39031. exports.correctFormat = correctFormat;
  39032. var _moment = __webpack_require__(61);
  39033. var _moment2 = _interopRequireDefault(_moment);
  39034. var _date = __webpack_require__(89);
  39035. var _editors = __webpack_require__(14);
  39036. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39037. /**
  39038. * Date cell validator
  39039. *
  39040. * @private
  39041. * @validator DateValidator
  39042. * @dependencies moment
  39043. * @param {*} value - Value of edited cell
  39044. * @param {Function} callback - Callback called with validation result
  39045. */
  39046. function dateValidator(value, callback) {
  39047. var valid = true;
  39048. var dateEditor = (0, _editors.getEditorInstance)('date', this.instance);
  39049. if (value == null) {
  39050. value = '';
  39051. }
  39052. var isValidDate = (0, _moment2.default)(new Date(value)).isValid() || (0, _moment2.default)(value, dateEditor.defaultDateFormat).isValid();
  39053. // is it in the specified format
  39054. var isValidFormat = (0, _moment2.default)(value, this.dateFormat || dateEditor.defaultDateFormat, true).isValid();
  39055. if (this.allowEmpty && value === '') {
  39056. isValidDate = true;
  39057. isValidFormat = true;
  39058. }
  39059. if (!isValidDate) {
  39060. valid = false;
  39061. }
  39062. if (!isValidDate && isValidFormat) {
  39063. valid = true;
  39064. }
  39065. if (isValidDate && !isValidFormat) {
  39066. if (this.correctFormat === true) {
  39067. // if format correction is enabled
  39068. var correctedValue = correctFormat(value, this.dateFormat);
  39069. var row = this.instance.runHooks('unmodifyRow', this.row);
  39070. var column = this.instance.runHooks('unmodifyCol', this.col);
  39071. this.instance.setDataAtCell(row, column, correctedValue, 'dateValidator');
  39072. valid = true;
  39073. } else {
  39074. valid = false;
  39075. }
  39076. }
  39077. callback(valid);
  39078. };
  39079. /**
  39080. * Format the given string using moment.js' format feature
  39081. *
  39082. * @param {String} value
  39083. * @param {String} dateFormat
  39084. * @returns {String}
  39085. */
  39086. function correctFormat(value, dateFormat) {
  39087. var dateFromDate = (0, _moment2.default)((0, _date.getNormalizedDate)(value));
  39088. var dateFromMoment = (0, _moment2.default)(value, dateFormat);
  39089. var isAlphanumeric = value.search(/[A-z]/g) > -1;
  39090. var date = void 0;
  39091. if (dateFromDate.isValid() && dateFromDate.format('x') === dateFromMoment.format('x') || !dateFromMoment.isValid() || isAlphanumeric) {
  39092. date = dateFromDate;
  39093. } else {
  39094. date = dateFromMoment;
  39095. }
  39096. return date.format(dateFormat);
  39097. };
  39098. /***/ }),
  39099. /* 275 */
  39100. /***/ (function(module, exports, __webpack_require__) {
  39101. "use strict";
  39102. exports.__esModule = true;
  39103. exports.default = numericValidator;
  39104. /**
  39105. * Numeric cell validator
  39106. *
  39107. * @private
  39108. * @validator NumericValidator
  39109. * @param {*} value - Value of edited cell
  39110. * @param {*} callback - Callback called with validation result
  39111. */
  39112. function numericValidator(value, callback) {
  39113. if (value == null) {
  39114. value = '';
  39115. }
  39116. if (this.allowEmpty && value === '') {
  39117. callback(true);
  39118. } else if (value === '') {
  39119. callback(false);
  39120. } else {
  39121. callback(/^-?\d*(\.|,)?\d*$/.test(value));
  39122. }
  39123. };
  39124. /***/ }),
  39125. /* 276 */
  39126. /***/ (function(module, exports, __webpack_require__) {
  39127. "use strict";
  39128. exports.__esModule = true;
  39129. exports.default = timeValidator;
  39130. var _moment = __webpack_require__(61);
  39131. var _moment2 = _interopRequireDefault(_moment);
  39132. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  39133. // Formats which are correctly parsed to time (supported by momentjs)
  39134. var STRICT_FORMATS = ['YYYY-MM-DDTHH:mm:ss.SSSZ', 'X', // Unix timestamp
  39135. 'x' // Unix ms timestamp
  39136. ];
  39137. /**
  39138. * Time cell validator
  39139. *
  39140. * @private
  39141. * @validator TimeValidator
  39142. * @dependencies moment
  39143. * @param {*} value - Value of edited cell
  39144. * @param {Function} callback - Callback called with validation result
  39145. */
  39146. function timeValidator(value, callback) {
  39147. var valid = true;
  39148. var timeFormat = this.timeFormat || 'h:mm:ss a';
  39149. if (value === null) {
  39150. value = '';
  39151. }
  39152. value = /^\d{3,}$/.test(value) ? parseInt(value, 10) : value;
  39153. var twoDigitValue = /^\d{1,2}$/.test(value);
  39154. if (twoDigitValue) {
  39155. value += ':00';
  39156. }
  39157. var date = (0, _moment2.default)(value, STRICT_FORMATS, true).isValid() ? (0, _moment2.default)(value) : (0, _moment2.default)(value, timeFormat);
  39158. var isValidTime = date.isValid();
  39159. // is it in the specified format
  39160. var isValidFormat = (0, _moment2.default)(value, timeFormat, true).isValid() && !twoDigitValue;
  39161. if (this.allowEmpty && value === '') {
  39162. isValidTime = true;
  39163. isValidFormat = true;
  39164. }
  39165. if (!isValidTime) {
  39166. valid = false;
  39167. }
  39168. if (!isValidTime && isValidFormat) {
  39169. valid = true;
  39170. }
  39171. if (isValidTime && !isValidFormat) {
  39172. if (this.correctFormat === true) {
  39173. // if format correction is enabled
  39174. var correctedValue = date.format(timeFormat);
  39175. var row = this.instance.runHooks('unmodifyRow', this.row);
  39176. var column = this.instance.runHooks('unmodifyCol', this.col);
  39177. this.instance.setDataAtCell(row, column, correctedValue, 'timeValidator');
  39178. valid = true;
  39179. } else {
  39180. valid = false;
  39181. }
  39182. }
  39183. callback(valid);
  39184. };
  39185. /***/ }),
  39186. /* 277 */
  39187. /***/ (function(module, exports, __webpack_require__) {
  39188. "use strict";
  39189. // 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
  39190. var toObject = __webpack_require__(41)
  39191. , toIndex = __webpack_require__(59)
  39192. , toLength = __webpack_require__(24);
  39193. module.exports = [].copyWithin || function copyWithin(target/*= 0*/, start/*= 0, end = @length*/){
  39194. var O = toObject(this)
  39195. , len = toLength(O.length)
  39196. , to = toIndex(target, len)
  39197. , from = toIndex(start, len)
  39198. , end = arguments.length > 2 ? arguments[2] : undefined
  39199. , count = Math.min((end === undefined ? len : toIndex(end, len)) - from, len - to)
  39200. , inc = 1;
  39201. if(from < to && to < from + count){
  39202. inc = -1;
  39203. from += count - 1;
  39204. to += count - 1;
  39205. }
  39206. while(count-- > 0){
  39207. if(from in O)O[to] = O[from];
  39208. else delete O[to];
  39209. to += inc;
  39210. from += inc;
  39211. } return O;
  39212. };
  39213. /***/ }),
  39214. /* 278 */
  39215. /***/ (function(module, exports, __webpack_require__) {
  39216. "use strict";
  39217. // 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
  39218. var toObject = __webpack_require__(41)
  39219. , toIndex = __webpack_require__(59)
  39220. , toLength = __webpack_require__(24);
  39221. module.exports = function fill(value /*, start = 0, end = @length */){
  39222. var O = toObject(this)
  39223. , length = toLength(O.length)
  39224. , aLen = arguments.length
  39225. , index = toIndex(aLen > 1 ? arguments[1] : undefined, length)
  39226. , end = aLen > 2 ? arguments[2] : undefined
  39227. , endPos = end === undefined ? length : toIndex(end, length);
  39228. while(endPos > index)O[index++] = value;
  39229. return O;
  39230. };
  39231. /***/ }),
  39232. /* 279 */
  39233. /***/ (function(module, exports, __webpack_require__) {
  39234. var isObject = __webpack_require__(15)
  39235. , isArray = __webpack_require__(162)
  39236. , SPECIES = __webpack_require__(10)('species');
  39237. module.exports = function(original){
  39238. var C;
  39239. if(isArray(original)){
  39240. C = original.constructor;
  39241. // cross-realm fallback
  39242. if(typeof C == 'function' && (C === Array || isArray(C.prototype)))C = undefined;
  39243. if(isObject(C)){
  39244. C = C[SPECIES];
  39245. if(C === null)C = undefined;
  39246. }
  39247. } return C === undefined ? Array : C;
  39248. };
  39249. /***/ }),
  39250. /* 280 */
  39251. /***/ (function(module, exports, __webpack_require__) {
  39252. // 9.4.2.3 ArraySpeciesCreate(originalArray, length)
  39253. var speciesConstructor = __webpack_require__(279);
  39254. module.exports = function(original, length){
  39255. return new (speciesConstructor(original))(length);
  39256. };
  39257. /***/ }),
  39258. /* 281 */
  39259. /***/ (function(module, exports, __webpack_require__) {
  39260. // all enumerable object keys, includes symbols
  39261. var getKeys = __webpack_require__(39)
  39262. , gOPS = __webpack_require__(57)
  39263. , pIE = __webpack_require__(47);
  39264. module.exports = function(it){
  39265. var result = getKeys(it)
  39266. , getSymbols = gOPS.f;
  39267. if(getSymbols){
  39268. var symbols = getSymbols(it)
  39269. , isEnum = pIE.f
  39270. , i = 0
  39271. , key;
  39272. while(symbols.length > i)if(isEnum.call(it, key = symbols[i++]))result.push(key);
  39273. } return result;
  39274. };
  39275. /***/ }),
  39276. /* 282 */
  39277. /***/ (function(module, exports, __webpack_require__) {
  39278. "use strict";
  39279. // 21.2.5.3 get RegExp.prototype.flags
  39280. var anObject = __webpack_require__(18);
  39281. module.exports = function(){
  39282. var that = anObject(this)
  39283. , result = '';
  39284. if(that.global) result += 'g';
  39285. if(that.ignoreCase) result += 'i';
  39286. if(that.multiline) result += 'm';
  39287. if(that.unicode) result += 'u';
  39288. if(that.sticky) result += 'y';
  39289. return result;
  39290. };
  39291. /***/ }),
  39292. /* 283 */
  39293. /***/ (function(module, exports, __webpack_require__) {
  39294. var isObject = __webpack_require__(15)
  39295. , setPrototypeOf = __webpack_require__(171).set;
  39296. module.exports = function(that, target, C){
  39297. var P, S = target.constructor;
  39298. if(S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf){
  39299. setPrototypeOf(that, P);
  39300. } return that;
  39301. };
  39302. /***/ }),
  39303. /* 284 */
  39304. /***/ (function(module, exports) {
  39305. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  39306. module.exports = function(fn, args, that){
  39307. var un = that === undefined;
  39308. switch(args.length){
  39309. case 0: return un ? fn()
  39310. : fn.call(that);
  39311. case 1: return un ? fn(args[0])
  39312. : fn.call(that, args[0]);
  39313. case 2: return un ? fn(args[0], args[1])
  39314. : fn.call(that, args[0], args[1]);
  39315. case 3: return un ? fn(args[0], args[1], args[2])
  39316. : fn.call(that, args[0], args[1], args[2]);
  39317. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  39318. : fn.call(that, args[0], args[1], args[2], args[3]);
  39319. } return fn.apply(that, args);
  39320. };
  39321. /***/ }),
  39322. /* 285 */
  39323. /***/ (function(module, exports, __webpack_require__) {
  39324. "use strict";
  39325. var create = __webpack_require__(79)
  39326. , descriptor = __webpack_require__(40)
  39327. , setToStringTag = __webpack_require__(48)
  39328. , IteratorPrototype = {};
  39329. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  39330. __webpack_require__(32)(IteratorPrototype, __webpack_require__(10)('iterator'), function(){ return this; });
  39331. module.exports = function(Constructor, NAME, next){
  39332. Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
  39333. setToStringTag(Constructor, NAME + ' Iterator');
  39334. };
  39335. /***/ }),
  39336. /* 286 */
  39337. /***/ (function(module, exports, __webpack_require__) {
  39338. var getKeys = __webpack_require__(39)
  39339. , toIObject = __webpack_require__(23);
  39340. module.exports = function(object, el){
  39341. var O = toIObject(object)
  39342. , keys = getKeys(O)
  39343. , length = keys.length
  39344. , index = 0
  39345. , key;
  39346. while(length > index)if(O[key = keys[index++]] === el)return key;
  39347. };
  39348. /***/ }),
  39349. /* 287 */
  39350. /***/ (function(module, exports, __webpack_require__) {
  39351. var global = __webpack_require__(13)
  39352. , macrotask = __webpack_require__(85).set
  39353. , Observer = global.MutationObserver || global.WebKitMutationObserver
  39354. , process = global.process
  39355. , Promise = global.Promise
  39356. , isNode = __webpack_require__(38)(process) == 'process';
  39357. module.exports = function(){
  39358. var head, last, notify;
  39359. var flush = function(){
  39360. var parent, fn;
  39361. if(isNode && (parent = process.domain))parent.exit();
  39362. while(head){
  39363. fn = head.fn;
  39364. head = head.next;
  39365. try {
  39366. fn();
  39367. } catch(e){
  39368. if(head)notify();
  39369. else last = undefined;
  39370. throw e;
  39371. }
  39372. } last = undefined;
  39373. if(parent)parent.enter();
  39374. };
  39375. // Node.js
  39376. if(isNode){
  39377. notify = function(){
  39378. process.nextTick(flush);
  39379. };
  39380. // browsers with MutationObserver
  39381. } else if(Observer){
  39382. var toggle = true
  39383. , node = document.createTextNode('');
  39384. new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
  39385. notify = function(){
  39386. node.data = toggle = !toggle;
  39387. };
  39388. // environments with maybe non-completely correct, but existent Promise
  39389. } else if(Promise && Promise.resolve){
  39390. var promise = Promise.resolve();
  39391. notify = function(){
  39392. promise.then(flush);
  39393. };
  39394. // for other environments - macrotask based on:
  39395. // - setImmediate
  39396. // - MessageChannel
  39397. // - window.postMessag
  39398. // - onreadystatechange
  39399. // - setTimeout
  39400. } else {
  39401. notify = function(){
  39402. // strange IE + webpack dev server bug - use .call(global)
  39403. macrotask.call(global, flush);
  39404. };
  39405. }
  39406. return function(fn){
  39407. var task = {fn: fn, next: undefined};
  39408. if(last)last.next = task;
  39409. if(!head){
  39410. head = task;
  39411. notify();
  39412. } last = task;
  39413. };
  39414. };
  39415. /***/ }),
  39416. /* 288 */
  39417. /***/ (function(module, exports, __webpack_require__) {
  39418. var dP = __webpack_require__(19)
  39419. , anObject = __webpack_require__(18)
  39420. , getKeys = __webpack_require__(39);
  39421. module.exports = __webpack_require__(21) ? Object.defineProperties : function defineProperties(O, Properties){
  39422. anObject(O);
  39423. var keys = getKeys(Properties)
  39424. , length = keys.length
  39425. , i = 0
  39426. , P;
  39427. while(length > i)dP.f(O, P = keys[i++], Properties[P]);
  39428. return O;
  39429. };
  39430. /***/ }),
  39431. /* 289 */
  39432. /***/ (function(module, exports, __webpack_require__) {
  39433. // fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
  39434. var toIObject = __webpack_require__(23)
  39435. , gOPN = __webpack_require__(81).f
  39436. , toString = {}.toString;
  39437. var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
  39438. ? Object.getOwnPropertyNames(window) : [];
  39439. var getWindowNames = function(it){
  39440. try {
  39441. return gOPN(it);
  39442. } catch(e){
  39443. return windowNames.slice();
  39444. }
  39445. };
  39446. module.exports.f = function getOwnPropertyNames(it){
  39447. return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
  39448. };
  39449. /***/ }),
  39450. /* 290 */
  39451. /***/ (function(module, exports, __webpack_require__) {
  39452. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  39453. var has = __webpack_require__(22)
  39454. , toObject = __webpack_require__(41)
  39455. , IE_PROTO = __webpack_require__(82)('IE_PROTO')
  39456. , ObjectProto = Object.prototype;
  39457. module.exports = Object.getPrototypeOf || function(O){
  39458. O = toObject(O);
  39459. if(has(O, IE_PROTO))return O[IE_PROTO];
  39460. if(typeof O.constructor == 'function' && O instanceof O.constructor){
  39461. return O.constructor.prototype;
  39462. } return O instanceof Object ? ObjectProto : null;
  39463. };
  39464. /***/ }),
  39465. /* 291 */
  39466. /***/ (function(module, exports, __webpack_require__) {
  39467. // all object keys, includes non-enumerable and symbols
  39468. var gOPN = __webpack_require__(81)
  39469. , gOPS = __webpack_require__(57)
  39470. , anObject = __webpack_require__(18)
  39471. , Reflect = __webpack_require__(13).Reflect;
  39472. module.exports = Reflect && Reflect.ownKeys || function ownKeys(it){
  39473. var keys = gOPN.f(anObject(it))
  39474. , getSymbols = gOPS.f;
  39475. return getSymbols ? keys.concat(getSymbols(it)) : keys;
  39476. };
  39477. /***/ }),
  39478. /* 292 */
  39479. /***/ (function(module, exports) {
  39480. // 7.2.9 SameValue(x, y)
  39481. module.exports = Object.is || function is(x, y){
  39482. return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
  39483. };
  39484. /***/ }),
  39485. /* 293 */
  39486. /***/ (function(module, exports, __webpack_require__) {
  39487. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  39488. var anObject = __webpack_require__(18)
  39489. , aFunction = __webpack_require__(72)
  39490. , SPECIES = __webpack_require__(10)('species');
  39491. module.exports = function(O, D){
  39492. var C = anObject(O).constructor, S;
  39493. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  39494. };
  39495. /***/ }),
  39496. /* 294 */
  39497. /***/ (function(module, exports, __webpack_require__) {
  39498. var toInteger = __webpack_require__(60)
  39499. , defined = __webpack_require__(30);
  39500. // true -> String#at
  39501. // false -> String#codePointAt
  39502. module.exports = function(TO_STRING){
  39503. return function(that, pos){
  39504. var s = String(defined(that))
  39505. , i = toInteger(pos)
  39506. , l = s.length
  39507. , a, b;
  39508. if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
  39509. a = s.charCodeAt(i);
  39510. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  39511. ? TO_STRING ? s.charAt(i) : a
  39512. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  39513. };
  39514. };
  39515. /***/ }),
  39516. /* 295 */
  39517. /***/ (function(module, exports, __webpack_require__) {
  39518. var global = __webpack_require__(13)
  39519. , core = __webpack_require__(44)
  39520. , LIBRARY = __webpack_require__(56)
  39521. , wksExt = __webpack_require__(175)
  39522. , defineProperty = __webpack_require__(19).f;
  39523. module.exports = function(name){
  39524. var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
  39525. if(name.charAt(0) != '_' && !(name in $Symbol))defineProperty($Symbol, name, {value: wksExt.f(name)});
  39526. };
  39527. /***/ }),
  39528. /* 296 */
  39529. /***/ (function(module, exports) {
  39530. // removed by extract-text-webpack-plugin
  39531. /***/ }),
  39532. /* 297 */
  39533. /***/ (function(module, exports) {
  39534. // removed by extract-text-webpack-plugin
  39535. /***/ }),
  39536. /* 298 */
  39537. /***/ (function(module, exports) {
  39538. // removed by extract-text-webpack-plugin
  39539. /***/ }),
  39540. /* 299 */
  39541. /***/ (function(module, exports) {
  39542. // removed by extract-text-webpack-plugin
  39543. /***/ }),
  39544. /* 300 */
  39545. /***/ (function(module, exports) {
  39546. // removed by extract-text-webpack-plugin
  39547. /***/ }),
  39548. /* 301 */
  39549. /***/ (function(module, exports) {
  39550. // removed by extract-text-webpack-plugin
  39551. /***/ }),
  39552. /* 302 */
  39553. /***/ (function(module, exports) {
  39554. module.exports = __WEBPACK_EXTERNAL_MODULE_302__;
  39555. /***/ })
  39556. /******/ ]);
  39557. });
  39558. //# sourceMappingURL=handsontable.js.map