UNPKG

handsontable

Version:

Handsontable is a JavaScript Spreadsheet Component available for React, Angular and Vue.

1,801 lines (1,483 loc) 3.09 MB
/*! * Copyright (c) HANDSONCODE sp. z o. o. * * HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., * a Polish corporation, based in Gdynia, Poland, at 96/98 Aleja Zwycięstwa, * registered with the National Court Register under number 538651, * EU tax ID number: PL5862294002, share capital: PLN 62,800.00. * * This software is protected by applicable copyright laws, including * international treaties, and dual-licensed – depending on whether * your use is intended for or may result in commercial advantage * or monetary compensation (commercial purposes), or not. * * If your use involves only such purposes as research, private study, * evaluation and the like, you agree to be bound by the terms included * in the "handsontable-non-commercial-license.pdf" file, available * in the main directory of this software repository. * * By installing, copying, or otherwise using this software for * commercial purposes, you agree to be bound by the terms included * in the "handsontable-general-terms.pdf" file, available in the main * directory of this software repository. * * HANDSONCODE PROVIDES THIS SOFTWARE ON AN "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. IN NO EVENT * AND UNDER NO LEGAL THEORY, SHALL HANDSONCODE BE LIABLE * TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, * INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING * FROM USE OR INABILITY TO USE THIS SOFTWARE. * * Version: 8.3.2 * Release date: 16/03/2021 (built at 16/03/2021 11:26:09) */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("moment"), require("hot-formula-parser"), require("dompurify"), require("pikaday"), require("numbro")); else if(typeof define === 'function' && define.amd) define("Handsontable", ["moment", "hot-formula-parser", "dompurify", "pikaday", "numbro"], factory); else if(typeof exports === 'object') exports["Handsontable"] = factory(require("moment"), require("hot-formula-parser"), require("dompurify"), require("pikaday"), require("numbro")); else root["Handsontable"] = factory(root["moment"], root["formulaParser"], root["DOMPurify"], root["Pikaday"], root["numbro"]); })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE__79__, __WEBPACK_EXTERNAL_MODULE__138__, __WEBPACK_EXTERNAL_MODULE__349__, __WEBPACK_EXTERNAL_MODULE__430__, __WEBPACK_EXTERNAL_MODULE__444__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 325); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } module.exports = _interopRequireDefault; /***/ }), /* 1 */ /***/ (function(module, exports) { function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } module.exports = _classCallCheck; /***/ }), /* 2 */ /***/ (function(module, exports) { 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); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } module.exports = _createClass; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; __webpack_require__(18); __webpack_require__(46); __webpack_require__(40); __webpack_require__(24); __webpack_require__(16); __webpack_require__(11); __webpack_require__(30); __webpack_require__(8); __webpack_require__(27); __webpack_require__(62); __webpack_require__(33); __webpack_require__(10); __webpack_require__(52); __webpack_require__(12); exports.__esModule = true; exports.to2dArray = to2dArray; exports.extendArray = extendArray; exports.pivot = pivot; exports.arrayReduce = arrayReduce; exports.arrayFilter = arrayFilter; exports.arrayMap = arrayMap; exports.arrayEach = arrayEach; exports.arraySum = arraySum; exports.arrayMax = arrayMax; exports.arrayMin = arrayMin; exports.arrayAvg = arrayAvg; exports.arrayFlatten = arrayFlatten; exports.arrayUnique = arrayUnique; exports.getDifferenceOfArrays = getDifferenceOfArrays; exports.getIntersectionOfArrays = getIntersectionOfArrays; exports.getUnionOfArrays = getUnionOfArrays; exports.stringToArray = stringToArray; /** * @param {Array} arr An array to process. */ function to2dArray(arr) { var ilen = arr.length; var i = 0; while (i < ilen) { arr[i] = [arr[i]]; i += 1; } } /** * @param {Array} arr An array to extend. * @param {Array} extension The data to extend from. */ function extendArray(arr, extension) { var ilen = extension.length; var i = 0; while (i < ilen) { arr.push(extension[i]); i += 1; } } /** * @param {Array} arr An array to pivot. * @returns {Array} */ function pivot(arr) { var pivotedArr = []; if (!arr || arr.length === 0 || !arr[0] || arr[0].length === 0) { return pivotedArr; } var rowCount = arr.length; var colCount = arr[0].length; for (var i = 0; i < rowCount; i++) { for (var j = 0; j < colCount; j++) { if (!pivotedArr[j]) { pivotedArr[j] = []; } pivotedArr[j][i] = arr[i][j]; } } return pivotedArr; } /** * A specialized version of `.reduce` for arrays without support for callback * shorthands and `this` binding. * * {@link https://github.com/lodash/lodash/blob/master/lodash.js}. * * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. * @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value. * @returns {*} Returns the accumulated value. */ function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1; var iterable = array; var result = accumulator; if (!Array.isArray(array)) { iterable = Array.from(array); } var length = iterable.length; if (initFromArray && length) { index += 1; result = iterable[index]; } index += 1; while (index < length) { result = iteratee(result, iterable[index], index, iterable); index += 1; } return result; } /** * A specialized version of `.filter` for arrays without support for callback * shorthands and `this` binding. * * {@link https://github.com/lodash/lodash/blob/master/lodash.js}. * * @param {Array} array The array to iterate over. * @param {Function} predicate The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function arrayFilter(array, predicate) { var index = 0; var iterable = array; if (!Array.isArray(array)) { iterable = Array.from(array); } var length = iterable.length; var result = []; var resIndex = -1; while (index < length) { var value = iterable[index]; if (predicate(value, index, iterable)) { resIndex += 1; result[resIndex] = value; } index += 1; } return result; } /** * A specialized version of `.map` for arrays without support for callback * shorthands and `this` binding. * * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns the new filtered array. */ function arrayMap(array, iteratee) { var index = 0; var iterable = array; if (!Array.isArray(array)) { iterable = Array.from(array); } var length = iterable.length; var result = []; var resIndex = -1; while (index < length) { var value = iterable[index]; resIndex += 1; result[resIndex] = iteratee(value, index, iterable); index += 1; } return result; } /** * A specialized version of `.forEach` for arrays without support for callback * shorthands and `this` binding. * * {@link https://github.com/lodash/lodash/blob/master/lodash.js}. * * @param {Array|*} array The array to iterate over or an any element with implemented iterator protocol. * @param {Function} iteratee The function invoked per iteration. * @returns {Array} Returns `array`. */ function arrayEach(array, iteratee) { var index = 0; var iterable = array; if (!Array.isArray(array)) { iterable = Array.from(array); } var length = iterable.length; while (index < length) { if (iteratee(iterable[index], index, iterable) === false) { break; } index += 1; } return array; } /** * Calculate sum value for each item of the array. * * @param {Array} array The array to process. * @returns {number} Returns calculated sum value. */ function arraySum(array) { return arrayReduce(array, function (a, b) { return a + b; }, 0); } /** * Returns the highest value from an array. Can be array of numbers or array of strings. * NOTICE: Mixed values is not supported. * * @param {Array} array The array to process. * @returns {number} Returns the highest value from an array. */ function arrayMax(array) { return arrayReduce(array, function (a, b) { return a > b ? a : b; }, Array.isArray(array) ? array[0] : void 0); } /** * Returns the lowest value from an array. Can be array of numbers or array of strings. * NOTICE: Mixed values is not supported. * * @param {Array} array The array to process. * @returns {number} Returns the lowest value from an array. */ function arrayMin(array) { return arrayReduce(array, function (a, b) { return a < b ? a : b; }, Array.isArray(array) ? array[0] : void 0); } /** * Calculate average value for each item of the array. * * @param {Array} array The array to process. * @returns {number} Returns calculated average value. */ function arrayAvg(array) { if (!array.length) { return 0; } return arraySum(array) / array.length; } /** * Flatten multidimensional array. * * @param {Array} array Array of Arrays. * @returns {Array} */ function arrayFlatten(array) { return arrayReduce(array, function (initial, value) { return initial.concat(Array.isArray(value) ? arrayFlatten(value) : value); }, []); } /** * Unique values in the array. * * @param {Array} array The array to process. * @returns {Array} */ function arrayUnique(array) { var unique = []; arrayEach(array, function (value) { if (unique.indexOf(value) === -1) { unique.push(value); } }); return unique; } /** * Differences from two or more arrays. * * @param {...Array} arrays Array of strings or array of numbers. * @returns {Array} Returns the difference between arrays. */ function getDifferenceOfArrays() { for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) { arrays[_key] = arguments[_key]; } var _ref = [].concat(arrays), first = _ref[0], rest = _ref.slice(1); var filteredFirstArray = first; arrayEach(rest, function (array) { filteredFirstArray = filteredFirstArray.filter(function (value) { return !array.includes(value); }); }); return filteredFirstArray; } /** * Intersection of two or more arrays. * * @param {...Array} arrays Array of strings or array of numbers. * @returns {Array} Returns elements that exists in every array. */ function getIntersectionOfArrays() { for (var _len2 = arguments.length, arrays = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { arrays[_key2] = arguments[_key2]; } var _ref2 = [].concat(arrays), first = _ref2[0], rest = _ref2.slice(1); var filteredFirstArray = first; arrayEach(rest, function (array) { filteredFirstArray = filteredFirstArray.filter(function (value) { return array.includes(value); }); }); return filteredFirstArray; } /** * Union of two or more arrays. * * @param {...Array} arrays Array of strings or array of numbers. * @returns {Array} Returns the elements that exist in any of the arrays, without duplicates. */ function getUnionOfArrays() { for (var _len3 = arguments.length, arrays = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { arrays[_key3] = arguments[_key3]; } var _ref3 = [].concat(arrays), first = _ref3[0], rest = _ref3.slice(1); var set = new Set(first); arrayEach(rest, function (array) { arrayEach(array, function (value) { if (!set.has(value)) { set.add(value); } }); }); return Array.from(set); } /** * Convert a separated strings to an array of strings. * * @param {string} value A string of class name(s). * @param {string|RegExp} delimiter The pattern describing where each split should occur. * @returns {string[]} Returns array of string or empty array. */ function stringToArray(value) { var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' '; return value.split(delimiter); } /***/ }), /* 4 */ /***/ (function(module, exports) { function _getPrototypeOf(o) { module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } module.exports = _getPrototypeOf; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { var setPrototypeOf = __webpack_require__(255); function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) setPrototypeOf(subClass, superClass); } module.exports = _inherits; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { var _typeof = __webpack_require__(49); var assertThisInitialized = __webpack_require__(26); function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return assertThisInitialized(self); } module.exports = _possibleConstructorReturn; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _interopRequireDefault = __webpack_require__(0); __webpack_require__(57); __webpack_require__(24); __webpack_require__(8); __webpack_require__(27); __webpack_require__(43); __webpack_require__(33); __webpack_require__(52); __webpack_require__(58); exports.__esModule = true; exports.duckSchema = duckSchema; exports.inherit = inherit; exports.extend = extend; exports.deepExtend = deepExtend; exports.deepClone = deepClone; exports.clone = clone; exports.mixin = mixin; exports.isObjectEqual = isObjectEqual; exports.isObject = isObject; exports.defineGetter = defineGetter; exports.objectEach = objectEach; exports.getProperty = getProperty; exports.setProperty = setProperty; exports.deepObjectSize = deepObjectSize; exports.createObjectPropListener = createObjectPropListener; exports.hasOwnProperty = hasOwnProperty; var _defineProperty2 = _interopRequireDefault(__webpack_require__(31)); var _typeof2 = _interopRequireDefault(__webpack_require__(49)); var _array = __webpack_require__(3); /** * Generate schema for passed object. * * @param {Array|object} object An object to analyze. * @returns {Array|object} */ function duckSchema(object) { var schema; if (Array.isArray(object)) { schema = []; } else { schema = {}; objectEach(object, function (value, key) { if (key === '__children') { return; } if (value && (0, _typeof2.default)(value) === 'object' && !Array.isArray(value)) { schema[key] = duckSchema(value); } else if (Array.isArray(value)) { if (value.length && (0, _typeof2.default)(value[0]) === 'object' && !Array.isArray(value[0])) { schema[key] = [duckSchema(value[0])]; } else { schema[key] = []; } } else { schema[key] = null; } }); } return schema; } /** * Inherit without without calling parent constructor, and setting `Child.prototype.constructor` to `Child` instead of `Parent`. * Creates temporary dummy function to call it as constructor. * Described in ticket: https://github.com/handsontable/handsontable/pull/516. * * @param {object} Child The child class. * @param {object} Parent The parent class. * @returns {object} */ function inherit(Child, Parent) { Parent.prototype.constructor = Parent; Child.prototype = new Parent(); Child.prototype.constructor = Child; return Child; } /** * Perform shallow extend of a target object with extension's own properties. * * @param {object} target An object that will receive the new properties. * @param {object} extension An object containing additional properties to merge into the target. * @param {string[]} [writableKeys] An array of keys that are writable to target object. * @returns {object} */ function extend(target, extension, writableKeys) { var hasWritableKeys = Array.isArray(writableKeys); objectEach(extension, function (value, key) { if (hasWritableKeys === false || writableKeys.includes(key)) { target[key] = value; } }); return target; } /** * Perform deep extend of a target object with extension's own properties. * * @param {object} target An object that will receive the new properties. * @param {object} extension An object containing additional properties to merge into the target. */ function deepExtend(target, extension) { objectEach(extension, function (value, key) { if (extension[key] && (0, _typeof2.default)(extension[key]) === 'object') { if (!target[key]) { if (Array.isArray(extension[key])) { target[key] = []; } else if (Object.prototype.toString.call(extension[key]) === '[object Date]') { target[key] = extension[key]; } else { target[key] = {}; } } deepExtend(target[key], extension[key]); } else { target[key] = extension[key]; } }); } /** * Perform deep clone of an object. * WARNING! Only clones JSON properties. Will cause error when `obj` contains a function, Date, etc. * * @param {object} obj An object that will be cloned. * @returns {object} */ function deepClone(obj) { if ((0, _typeof2.default)(obj) === 'object') { return JSON.parse(JSON.stringify(obj)); } return obj; } /** * Shallow clone object. * * @param {object} object An object to clone. * @returns {object} */ function clone(object) { var result = {}; objectEach(object, function (value, key) { result[key] = value; }); return result; } /** * Extend the Base object (usually prototype) of the functionality the `mixins` objects. * * @param {object} Base Base object which will be extended. * @param {object} mixins The object of the functionality will be "copied". * @returns {object} */ function mixin(Base) { if (!Base.MIXINS) { Base.MIXINS = []; } for (var _len = arguments.length, mixins = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { mixins[_key - 1] = arguments[_key]; } (0, _array.arrayEach)(mixins, function (mixinItem) { Base.MIXINS.push(mixinItem.MIXIN_NAME); objectEach(mixinItem, function (value, key) { if (Base.prototype[key] !== void 0) { throw new Error("Mixin conflict. Property '".concat(key, "' already exist and cannot be overwritten.")); } if (typeof value === 'function') { Base.prototype[key] = value; } else { var getter = function _getter(property, initialValue) { var propertyName = "_".concat(property); var initValue = function initValue(newValue) { var result = newValue; if (Array.isArray(result) || isObject(result)) { result = deepClone(result); } return result; }; return function () { if (this[propertyName] === void 0) { this[propertyName] = initValue(initialValue); } return this[propertyName]; }; }; var setter = function _setter(property) { var propertyName = "_".concat(property); return function (newValue) { this[propertyName] = newValue; }; }; Object.defineProperty(Base.prototype, key, { get: getter(key, value), set: setter(key), configurable: true }); } }); }); return Base; } /** * Checks if two objects or arrays are (deep) equal. * * @param {object|Array} object1 The first object to compare. * @param {object|Array} object2 The second object to compare. * @returns {boolean} */ function isObjectEqual(object1, object2) { return JSON.stringify(object1) === JSON.stringify(object2); } /** * Determines whether given object is a plain Object. * Note: String and Array are not plain Objects. * * @param {*} object An object to check. * @returns {boolean} */ function isObject(object) { return Object.prototype.toString.call(object) === '[object Object]'; } /** * @param {object} object The object on which to define the property. * @param {string} property The name of the property to be defined or modified. * @param {*} value The value associated with the property. * @param {object} options The descriptor for the property being defined or modified. */ function defineGetter(object, property, value, options) { options.value = value; options.writable = options.writable !== false; options.enumerable = options.enumerable !== false; options.configurable = options.configurable !== false; Object.defineProperty(object, property, options); } /** * A specialized version of `.forEach` for objects. * * @param {object} object The object to iterate over. * @param {Function} iteratee The function invoked per iteration. * @returns {object} Returns `object`. */ function objectEach(object, iteratee) { // eslint-disable-next-line no-restricted-syntax for (var key in object) { if (!object.hasOwnProperty || object.hasOwnProperty && Object.prototype.hasOwnProperty.call(object, key)) { if (iteratee(object[key], key, object) === false) { break; } } } return object; } /** * Get object property by its name. Access to sub properties can be achieved by dot notation (e.q. `'foo.bar.baz'`). * * @param {object} object Object which value will be exported. * @param {string} name Object property name. * @returns {*} */ function getProperty(object, name) { var names = name.split('.'); var result = object; objectEach(names, function (nameItem) { result = result[nameItem]; if (result === void 0) { result = void 0; return false; } }); return result; } /** * Set a property value on the provided object. Works on nested object prop names as well (e.g. `first.name`). * * @param {object} object Object to work on. * @param {string} name Prop name. * @param {*} value Value to be assigned at the provided property. */ function setProperty(object, name, value) { var names = name.split('.'); var workingObject = object; names.forEach(function (propName, index) { if (index !== names.length - 1) { if (!hasOwnProperty(workingObject, propName)) { workingObject[propName] = {}; } workingObject = workingObject[propName]; } else { workingObject[propName] = value; } }); } /** * Return object length (recursively). * * @param {*} object Object for which we want get length. * @returns {number} */ function deepObjectSize(object) { if (!isObject(object)) { return 0; } var recursObjLen = function recursObjLen(obj) { var result = 0; if (isObject(obj)) { objectEach(obj, function (value, key) { if (key === '__children') { return; } result += recursObjLen(value); }); } else { result += 1; } return result; }; return recursObjLen(object); } /** * Create object with property where its value change will be observed. * * @param {*} [defaultValue=undefined] Default value. * @param {string} [propertyToListen='value'] Property to listen. * @returns {object} */ function createObjectPropListener(defaultValue) { var _holder; var propertyToListen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value'; var privateProperty = "_".concat(propertyToListen); var holder = (_holder = { _touched: false }, (0, _defineProperty2.default)(_holder, privateProperty, defaultValue), (0, _defineProperty2.default)(_holder, "isTouched", function isTouched() { return this._touched; }), _holder); Object.defineProperty(holder, propertyToListen, { get: function get() { return this[privateProperty]; }, set: function set(value) { this._touched = true; this[privateProperty] = value; }, enumerable: true, configurable: true }); return holder; } /** * Check if at specified `key` there is any value for `object`. * * @param {object} object Object to search value at specyfic key. * @param {string} key String key to check. * @returns {boolean} */ function hasOwnProperty(object, key) { return Object.prototype.hasOwnProperty.call(object, key); } /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { var TO_STRING_TAG_SUPPORT = __webpack_require__(174); var redefine = __webpack_require__(77); var toString = __webpack_require__(346); // `Object.prototype.toString` method // https://tc39.es/ecma262/#sec-object.prototype.tostring if (!TO_STRING_TAG_SUPPORT) { redefine(Object.prototype, 'toString', toString, { unsafe: true }); } /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var _interopRequireDefault = __webpack_require__(0); __webpack_require__(18); __webpack_require__(46); __webpack_require__(24); __webpack_require__(16); __webpack_require__(70); __webpack_require__(30); __webpack_require__(183); __webpack_require__(8); __webpack_require__(119); __webpack_require__(27); __webpack_require__(43); __webpack_require__(33); __webpack_require__(45); __webpack_require__(52); __webpack_require__(120); exports.__esModule = true; exports.getParent = getParent; exports.getFrameElement = getFrameElement; exports.getParentWindow = getParentWindow; exports.hasAccessToParentWindow = hasAccessToParentWindow; exports.closest = closest; exports.closestDown = closestDown; exports.isChildOf = isChildOf; exports.index = index; exports.overlayContainsElement = overlayContainsElement; exports.hasClass = hasClass; exports.addClass = addClass; exports.removeClass = removeClass; exports.removeTextNodes = removeTextNodes; exports.empty = empty; exports.fastInnerHTML = fastInnerHTML; exports.fastInnerText = fastInnerText; exports.isVisible = isVisible; exports.offset = offset; exports.getWindowScrollTop = getWindowScrollTop; exports.getWindowScrollLeft = getWindowScrollLeft; exports.getScrollTop = getScrollTop; exports.getScrollLeft = getScrollLeft; exports.getScrollableElement = getScrollableElement; exports.getTrimmingContainer = getTrimmingContainer; exports.getStyle = getStyle; exports.matchesCSSRules = matchesCSSRules; exports.getComputedStyle = getComputedStyle; exports.outerWidth = outerWidth; exports.outerHeight = outerHeight; exports.innerHeight = innerHeight; exports.innerWidth = innerWidth; exports.addEvent = addEvent; exports.removeEvent = removeEvent; exports.getCaretPosition = getCaretPosition; exports.getSelectionEndPosition = getSelectionEndPosition; exports.getSelectionText = getSelectionText; exports.clearTextSelection = clearTextSelection; exports.setCaretPosition = setCaretPosition; exports.getScrollbarWidth = getScrollbarWidth; exports.hasVerticalScrollbar = hasVerticalScrollbar; exports.hasHorizontalScrollbar = hasHorizontalScrollbar; exports.setOverlayPosition = setOverlayPosition; exports.getCssTransform = getCssTransform; exports.resetCssTransform = resetCssTransform; exports.isInput = isInput; exports.isOutsideInput = isOutsideInput; exports.selectElementIfAllowed = selectElementIfAllowed; exports.isDetached = isDetached; exports.HTML_CHARACTERS = void 0; var _toConsumableArray2 = _interopRequireDefault(__webpack_require__(23)); var _feature = __webpack_require__(89); var _browser = __webpack_require__(78); var _string = __webpack_require__(71); /** * Get the parent of the specified node in the DOM tree. * * @param {HTMLElement} element Element from which traversing is started. * @param {number} [level=0] Traversing deep level. * @returns {HTMLElement|null} */ function getParent(element) { var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; var iteration = -1; var parent = null; var elementToCheck = element; while (elementToCheck !== null) { if (iteration === level) { parent = elementToCheck; break; } if (elementToCheck.host && elementToCheck.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { elementToCheck = elementToCheck.host; } else { iteration += 1; elementToCheck = elementToCheck.parentNode; } } return parent; } /** * Gets `frameElement` of the specified frame. Returns null if it is a top frame or if script has no access to read property. * * @param {Window} frame Frame from which should be get frameElement in safe way. * @returns {HTMLIFrameElement|null} */ function getFrameElement(frame) { return Object.getPrototypeOf(frame.parent) && frame.frameElement; } /** * Gets parent frame of the specified frame. Returns null if it is a top frame or if script has no access to read property. * * @param {Window} frame Frame from which should be get frameElement in safe way. * @returns {Window|null} */ function getParentWindow(frame) { return getFrameElement(frame) && frame.parent; } /** * Checks if script has access to read from parent frame of specified frame. * * @param {Window} frame Frame from which should be get frameElement in safe way. * @returns {boolean} */ function hasAccessToParentWindow(frame) { return !!Object.getPrototypeOf(frame.parent); } /** * Goes up the DOM tree (including given element) until it finds an parent element that matches the nodes or nodes name. * This method goes up through web components. * * @param {Node} element Element from which traversing is started. * @param {Array<string|Node>} [nodes] Array of elements or Array of elements name (in uppercase form). * @param {Node} [until] The element until the traversing ends. * @returns {Node|null} */ function closest(element) { var nodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var until = arguments.length > 2 ? arguments[2] : undefined; var _Node = Node, ELEMENT_NODE = _Node.ELEMENT_NODE, DOCUMENT_FRAGMENT_NODE = _Node.DOCUMENT_FRAGMENT_NODE; var elementToCheck = element; while (elementToCheck !== null && elementToCheck !== void 0 && elementToCheck !== until) { var _elementToCheck = elementToCheck, nodeType = _elementToCheck.nodeType, nodeName = _elementToCheck.nodeName; if (nodeType === ELEMENT_NODE && (nodes.includes(nodeName) || nodes.includes(elementToCheck))) { return elementToCheck; } var _elementToCheck2 = elementToCheck, host = _elementToCheck2.host; if (host && nodeType === DOCUMENT_FRAGMENT_NODE) { elementToCheck = host; } else { elementToCheck = elementToCheck.parentNode; } } return null; } /** * Goes "down" the DOM tree (including given element) until it finds an element that matches the nodes or nodes name. * * @param {HTMLElement} element Element from which traversing is started. * @param {Array} nodes Array of elements or Array of elements name. * @param {HTMLElement} [until] The list of elements until the traversing ends. * @returns {HTMLElement|null} */ function closestDown(element, nodes, until) { var matched = []; var elementToCheck = element; while (elementToCheck) { elementToCheck = closest(elementToCheck, nodes, until); if (!elementToCheck || until && !until.contains(elementToCheck)) { break; } matched.push(elementToCheck); if (elementToCheck.host && elementToCheck.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { elementToCheck = elementToCheck.host; } else { elementToCheck = elementToCheck.parentNode; } } var length = matched.length; return length ? matched[length - 1] : null; } /** * Goes up the DOM tree and checks if element is child of another element. * * @param {HTMLElement} child Child element An element to check. * @param {object|string} parent Parent element OR selector of the parent element. * If string provided, function returns `true` for the first occurrence of element with that class. * @returns {boolean} */ function isChildOf(child, parent) { var node = child.parentNode; var queriedParents = []; if (typeof parent === 'string') { if (child.defaultView) { queriedParents = Array.prototype.slice.call(child.querySelectorAll(parent), 0); } else { queriedParents = Array.prototype.slice.call(child.ownerDocument.querySelectorAll(parent), 0); } } else { queriedParents.push(parent); } while (node !== null) { if (queriedParents.indexOf(node) > -1) { return true; } node = node.parentNode; } return false; } /** * Counts index of element within its parent. * WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true * for Walkotnable, otherwise would need to check for nodeType or use previousElementSibling. * * @see http://jsperf.com/sibling-index/10 * @param {Element} element The element to check. * @returns {number} */ function index(element) { var i = 0; var elementToCheck = element; if (elementToCheck.previousSibling) { /* eslint-disable no-cond-assign */ while (elementToCheck = elementToCheck.previousSibling) { i += 1; } } return i; } /** * Check if the provided overlay contains the provided element. * * @param {string} overlayType The type of the overlay. * @param {HTMLElement} element An element to check. * @param {HTMLElement} root The root element. * @returns {boolean} */ function overlayContainsElement(overlayType, element, root) { var overlayElement = root.parentElement.querySelector(".ht_clone_".concat(overlayType)); return overlayElement ? overlayElement.contains(element) : null; } var _hasClass; var _addClass; var _removeClass; /** * @param {string} classNames The element "class" attribute string. * @returns {string[]} */ function filterEmptyClassNames(classNames) { if (!classNames || !classNames.length) { return []; } return classNames.filter(function (x) { return !!x; }); } if ((0, _feature.isClassListSupported)()) { var isSupportMultipleClassesArg = function isSupportMultipleClassesArg(rootDocument) { var element = rootDocument.createElement('div'); element.classList.add('test', 'test2'); return element.classList.contains('test2'); }; _hasClass = function _hasClass(element, className) { if (element.classList === void 0 || typeof className !== 'string' || className === '') { return false; } return element.classList.contains(className); }; _addClass = function _addClass(element, classes) { var rootDocument = element.ownerDocument; var className = classes; if (typeof className === 'string') { className = className.split(' '); } className = filterEmptyClassNames(className); if (className.length > 0) { if (isSupportMultipleClassesArg(rootDocument)) { var _element$classList; (_element$classList = element.classList).add.apply(_element$classList, (0, _toConsumableArray2.default)(className)); } else { var len = 0; while (className && className[len]) { element.classList.add(className[len]); len += 1; } } } }; _removeClass = function _removeClass(element, classes) { var rootDocument = element.ownerDocument; var className = classes; if (typeof className === 'string') { className = className.split(' '); } className = filterEmptyClassNames(className); if (className.length > 0) { if (isSupportMultipleClassesArg(rootDocument)) { var _element$classList2; (_element$classList2 = element.classList).remove.apply(_element$classList2, (0, _toConsumableArray2.default)(className)); } else { var len = 0; while (className && className[len]) { element.classList.remove(className[len]); len += 1; } } } }; } else { var createClassNameRegExp = function createClassNameRegExp(className) { return new RegExp("(\\s|^)".concat(className, "(\\s|$)")); }; _hasClass = function _hasClass(element, className) { // http://snipplr.com/view/3561/addclass-removeclass-hasclass/ return element.className !== void 0 && createClassNameRegExp(className).test(element.className); }; _addClass = function _addClass(element, classes) { var _className = element.className; var className = classes; if (typeof className === 'string') { className = className.split(' '); } className = filterEmptyClassNames(className); if (_className === '') { _className = className.join(' '); } else { for (var len = 0; len < className.length; len++) { if (className[len] && !createClassNameRegExp(className[len]).test(_className)) { _className += " ".concat(className[len]); } } } element.className = _className; }; _removeClass = function _removeClass(element, classes) { var len = 0; var _className = element.className; var className = classes; if (typeof className === 'string') { className = className.split(' '); } className = filterEmptyClassNames(className); while (className && className[len]) { // String.prototype.trim is defined in polyfill.js _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim(); len += 1; } if (element.className !== _className) { element.className = _className; } }; } /** * Checks if element has class name. * * @param {HTMLElement} element An element to check. * @param {string} className Class name to check. * @returns {boolean} */ function hasClass(element, className) { return _hasClass(element, className); } /** * Add class name to an element. * * @param {HTMLElement} element An element to process. * @param {string|Array} className Class name as string or array of strings. */ function addClass(element, className) { _addClass(element, className); } /** * Remove class name from an element. * * @param {HTMLElement} element An element to process. * @param {string|Array} className Class name as string or array of strings. */ function removeClass(element, className) { _removeClass(element, className); } /** * @param {HTMLElement} element An element from the text is removed. */ function removeTextNodes(element) { if (element.nodeType === 3) { element.parentNode.removeChild(element); // bye text nodes! } else if (['TABLE', 'THEAD', 'TBODY', 'TFOOT', 'TR'].indexOf(element.nodeName) > -1) { var childs = element.childNodes; for (var i = childs.length - 1; i >= 0; i--) { removeTextNodes(childs[i], element); } } } /** * Remove childs function * WARNING - this doesn't unload events and data attached by jQuery * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/9 * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/11 - no siginificant improvement with Chrome remove() method. * * @param {HTMLElement} element An element to clear. */ function empty(element) { var child; /* eslint-disable no-cond-assign */ while (child = element.lastChild) { element.removeChild(child); } } var HTML_CHARACTERS = /(<(.*)>|&(.*);)/; /** * Insert content into element trying avoid innerHTML method. * * @param {HTMLElement} element An element to write into. * @param {string} content The text to write. * @param {boolean} [sanitizeContent=true] If `true`, the content will be sanitized before writing to the element. */ exports.HTML_CHARACTERS = HTML_CHARACTERS; function fastInnerHTML(element, content) { var sanitizeContent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; if (HTML_CHARACTERS.test(content)) { element.innerHTML = sanitizeContent ? (0, _string.sanitize)(content) : content; } else { fastInnerText(element, content); } } /** * Insert text content into element. * * @param {HTMLElement} element An element to write into. * @param {string} content The text to write. */ function fastInnerText(element, content) { var child = element.firstChild; if (child && child.nodeType === 3 && child.nextSibling === null) { // fast lane - replace existing text node if (_feature.isTextContentSupported) { // http://jsperf.com/replace-text-vs-reuse child.textContent = content; } else { // http://jsperf.com/replace-text-vs-reuse child.data = content; } } else { // slow lane - empty element and insert a text node empty(element); element.appendChild(element.ownerDocument.createTextNode(content)); } } /** * Returns true if element is attached to the DOM and visible, false otherwise. * * @param {HTMLElement} element An element to check. * @returns {boolean} */ function isVisible(element) { var documentElement = element.ownerDocument.documentElement; var next = element; while (next !== documentElement) { // until <html> reached if (next === null) { // parent detached from DOM return false; } else if (next.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { if (next.host) { // this is Web Components Shadow DOM // see: http://w3c.github.io/webcomponents/spec/shadow/#encapsulation // according to spec, should be if (next.ownerDocument !== window.document), but that doesn't work yet if (next.host.impl) { // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features disabled return isVisible(next.host.impl); } else if (next.host) { // Chrome 33.0.1723.0 canary (2013-11-29) Web Platform features enabled return isVisible(next.host); } throw new Error('Lost in Web Components world'); } else { return false; // this is a node detached from document in IE8 } } else if (next.style && next.style.display === 'none') { return false; } next = next.parentNode; } return true; } /** * Returns elements top and left offset relative to the document. Function is not compatible with jQuery offset. * * @param {HTMLElement} element An element to get the offset position from. * @returns {object} Returns object with `top` and `left` props. */ function offset(element) { var rootDocument = element.ownerDocument; var rootWindow = rootDocument.defaultView; var documentElement = rootDocument.documentElement; var elementToCheck = element; var offsetLeft; var offsetTop; var lastElem; var box; if ((0, _feature.hasCaptionProblem)() && elementToCheck.firstChild && elementToCheck.firstChild.nodeName === 'CAPTION') { // fixes problem with Firefox ignoring <caption> in TABLE offset (see also export outerHeight) // http://jsperf.com/offset-vs-getboundingclientrect/8 box = elementToCheck.getBoundingClientRect(); return { top: box.top + (rootWindow.pageYOffset || documentElement.scrollTop) - (documentElement.clientTop || 0), left: box.left + (rootWindow.pageXOffset || documentElement.scrollLeft) - (documentElement.clientLeft || 0) }; } offsetLeft = elementToCheck.offsetLeft; offsetTop = elementToCheck.offsetTop; lastElem = elementToCheck; /* eslint-disable no-cond-assign */ while (elementToCheck = elementToCheck.offsetParent) { // from my observation, document.body always has scrollLeft/scrollTop == 0 if (elementToCheck === rootDocument.body) { break; } offsetLeft += elementToCheck.offsetLeft; offsetTop += elementToCheck.offsetTop; lastElem = elementToCheck; } // slow - http://jsperf.com/offset-vs-getboundingclientrect/6 if (lastElem && lastElem.style.position === 'fixed') { // if(lastElem !== document.body) { //faster but does gives false positive in Firefox offsetLeft += rootWindow.pageXOffset || documentElement.scrollLeft; offsetTop += rootWindow.pageYOffset || documentElement.scrollTop; } return { left: offsetLeft, top: offsetTop }; } /** * Returns the document's scrollTop property. * * @param {Window} [rootWindow] The document window owner. * @returns {number} */ // eslint-disable-next-line no-restricted-globals function getWindowScrollTop() { var rootWindow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; var res = rootWindow.scrollY; if (res === void 0) { // IE8-11 res = rootWindow.document.documentElement.scrollTop; } return res; } /** * Returns the document's scrollLeft property. * * @param {Window} [rootWindow] The document window owner. * @returns {number} */ // eslint-disable-next-line no-restricted-globals function getWindowScrollLeft() { var rootWindow = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window; var res = rootWindow.scrollX; if (res === void 0) { // IE8-11 res = rootWindow.document.documentElement.scrollLeft; } return res; } /** * Returns the p