UNPKG

@handsontable/vue

Version:

Best Data Grid for Vue with Spreadsheet Look and Feel.

1,293 lines (1,244 loc) • 55 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var Handsontable = require('handsontable/base'); var Vue = require('vue'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; } var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(Handsontable); var Vue__default = /*#__PURE__*/_interopDefaultCompat(Vue); function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", { writable: false }), e; } function _defineProperty$1(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: true, configurable: true } }), Object.defineProperty(t, "prototype", { writable: false }), e && _setPrototypeOf(t, e); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); } var unassignedPropSymbol = Symbol('unassigned'); var bulkComponentContainer = null; /** * Message for the warning thrown if the Handsontable instance has been destroyed. */ var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.'; /** * Private method to ensure the table is not calling `updateSettings` after editing cells. * @private */ function preventInternalEditWatch(component) { if (component.hotInstance) { component.hotInstance.addHook('beforeChange', function () { component.__internalEdit = true; }); component.hotInstance.addHook('beforeCreateRow', function () { component.__internalEdit = true; }); component.hotInstance.addHook('beforeCreateCol', function () { component.__internalEdit = true; }); component.hotInstance.addHook('beforeRemoveRow', function () { component.__internalEdit = true; }); component.hotInstance.addHook('beforeRemoveCol', function () { component.__internalEdit = true; }); } } /** * Generate an object containing all the available Handsontable properties and plugin hooks. * * @param {String} source Source for the factory (either 'HotTable' or 'HotColumn'). * @returns {Object} */ function propFactory(source) { var registeredHooks = Handsontable__default["default"].hooks.getRegistered(); var propSchema = {}; Object.assign(propSchema, Handsontable__default["default"].DefaultSettings); for (var prop in propSchema) { propSchema[prop] = { "default": unassignedPropSymbol }; } for (var i = 0; i < registeredHooks.length; i++) { propSchema[registeredHooks[i]] = { "default": unassignedPropSymbol }; } propSchema.settings = { "default": unassignedPropSymbol }; if (source === 'HotTable') { propSchema.id = { type: String, "default": 'hot-' + Math.random().toString(36).substring(5) }; propSchema.wrapperRendererCacheSize = { type: Number, "default": 3000 }; } return propSchema; } /** * Filter out all of the unassigned props, and return only the one passed to the component. * * @param {Object} props Object containing all the possible props. * @returns {Object} Object containing only used props. */ function filterPassedProps(props) { var filteredProps = {}; var columnSettingsProp = props['settings']; if (columnSettingsProp !== unassignedPropSymbol) { for (var propName in columnSettingsProp) { if (columnSettingsProp.hasOwnProperty(propName) && columnSettingsProp[propName] !== unassignedPropSymbol) { filteredProps[propName] = columnSettingsProp[propName]; } } } for (var _propName in props) { if (props.hasOwnProperty(_propName) && _propName !== 'settings' && props[_propName] !== unassignedPropSymbol) { filteredProps[_propName] = props[_propName]; } } return filteredProps; } /** * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component. * * @param {HotTableProps} props The props passed to the component. * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings. * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable. */ function prepareSettings(props, currentSettings) { var assignedProps = filterPassedProps(props); var hotSettingsInProps = props.settings ? props.settings : assignedProps; var additionalHotSettingsInProps = props.settings ? assignedProps : null; var newSettings = {}; for (var key in hotSettingsInProps) { if (hotSettingsInProps.hasOwnProperty(key) && hotSettingsInProps[key] !== void 0 && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) { newSettings[key] = hotSettingsInProps[key]; } } for (var _key in additionalHotSettingsInProps) { if (additionalHotSettingsInProps.hasOwnProperty(_key) && _key !== 'id' && _key !== 'settings' && _key !== 'wrapperRendererCacheSize' && additionalHotSettingsInProps[_key] !== void 0 && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) { newSettings[_key] = additionalHotSettingsInProps[_key]; } } return newSettings; } /** * Get the VNode element with the provided type attribute from the component slots. * * @param {Array} componentSlots Array of slots from a component. * @param {String} type Type of the child component. Either `hot-renderer` or `hot-editor`. * @returns {Object|null} The VNode of the child component (or `null` when nothing's found). */ function findVNodeByType(componentSlots, type) { var componentVNode = null; componentSlots.every(function (slot, index) { if (slot.data && slot.data.attrs && slot.data.attrs[type] !== void 0) { componentVNode = slot; return false; } return true; }); return componentVNode; } /** * Get all `hot-column` component instances from the provided children array. * * @param {Array} children Array of children from a component. * @returns {Array} Array of `hot-column` instances. */ function getHotColumnComponents(children) { return children.filter(function (child) { return child.$options.name === 'HotColumn'; }); } /** * Create an instance of the Vue Component based on the provided VNode. * * @param {Object} vNode VNode element to be turned into a component instance. * @param {Object} parent Instance of the component to be marked as a parent of the newly created instance. * @param {Object} props Props to be passed to the new instance. * @param {Object} data Data to be passed to the new instance. */ function createVueComponent(vNode, parent, props, data) { var ownerDocument = parent.$el ? parent.$el.ownerDocument : document; var settings = { propsData: props, parent: parent, data: data }; if (!bulkComponentContainer) { bulkComponentContainer = ownerDocument.createElement('DIV'); bulkComponentContainer.id = 'vueHotComponents'; ownerDocument.body.appendChild(bulkComponentContainer); } var componentContainer = ownerDocument.createElement('DIV'); bulkComponentContainer.appendChild(componentContainer); return new vNode.componentOptions.Ctor(settings).$mount(componentContainer); } /** * Compare two objects using `JSON.stringify`. * *Note: * As it's using the stringify function to compare objects, the property order in both objects is * important. It will return `false` for the same objects, if they're defined in a different order. * * @param {object} objectA First object to compare. * @param {object} objectB Second object to compare. * @returns {boolean} `true` if they're the same, `false` otherwise. */ function simpleEqual(objectA, objectB) { var stringifyToJSON = function stringifyToJSON(val) { var circularReplacer = function () { var seen = new WeakSet(); return function (key, value) { if (_typeof$1(value) === 'object' && value !== null) { if (seen.has(value)) return; seen.add(value); } return value; }; }(); return JSON.stringify(val, circularReplacer); }; if (typeof objectA === 'function' && typeof objectB === 'function') { return objectA.toString() === objectB.toString(); } else if (_typeof$1(objectA) !== _typeof$1(objectB)) { return false; } else { return stringifyToJSON(objectA) === stringifyToJSON(objectB); } } var version="16.0.1"; var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var lru = {}; (function (exports) { (function (g, f) { var e = exports ; f(e); })(commonjsGlobal, function (exports) { var NEWER = Symbol('newer'); var OLDER = Symbol('older'); function LRUMap(limit, entries) { if (typeof limit !== 'number') { // called as (entries) entries = limit; limit = 0; } this.size = 0; this.limit = limit; this.oldest = this.newest = undefined; this._keymap = new Map(); if (entries) { this.assign(entries); if (limit < 1) { this.limit = this.size; } } } exports.LRUMap = LRUMap; function Entry(key, value) { this.key = key; this.value = value; this[NEWER] = undefined; this[OLDER] = undefined; } LRUMap.prototype._markEntryAsUsed = function (entry) { if (entry === this.newest) { // Already the most recenlty used entry, so no need to update the list return; } // HEAD--------------TAIL // <.older .newer> // <--- add direction -- // A B C <D> E if (entry[NEWER]) { if (entry === this.oldest) { this.oldest = entry[NEWER]; } entry[NEWER][OLDER] = entry[OLDER]; // C <-- E. } if (entry[OLDER]) { entry[OLDER][NEWER] = entry[NEWER]; // C. --> E } entry[NEWER] = undefined; // D --x entry[OLDER] = this.newest; // D. --> E if (this.newest) { this.newest[NEWER] = entry; // E. <-- D } this.newest = entry; }; LRUMap.prototype.assign = function (entries) { var entry, limit = this.limit || Number.MAX_VALUE; this._keymap.clear(); var it = entries[Symbol.iterator](); for (var itv = it.next(); !itv.done; itv = it.next()) { var e = new Entry(itv.value[0], itv.value[1]); this._keymap.set(e.key, e); if (!entry) { this.oldest = e; } else { entry[NEWER] = e; e[OLDER] = entry; } entry = e; if (limit-- == 0) { throw new Error('overflow'); } } this.newest = entry; this.size = this._keymap.size; }; LRUMap.prototype.get = function (key) { // First, find our cache entry var entry = this._keymap.get(key); if (!entry) return; // Not cached. Sorry. // As <key> was found in the cache, register it as being requested recently this._markEntryAsUsed(entry); return entry.value; }; LRUMap.prototype.set = function (key, value) { var entry = this._keymap.get(key); if (entry) { // update existing entry.value = value; this._markEntryAsUsed(entry); return this; } // new entry this._keymap.set(key, entry = new Entry(key, value)); if (this.newest) { // link previous tail to the new tail (entry) this.newest[NEWER] = entry; entry[OLDER] = this.newest; } else { // we're first in -- yay this.oldest = entry; } // add new entry to the end of the linked list -- it's now the freshest entry. this.newest = entry; ++this.size; if (this.size > this.limit) { // we hit the limit -- remove the head this.shift(); } return this; }; LRUMap.prototype.shift = function () { // todo: handle special case when limit == 1 var entry = this.oldest; if (entry) { if (this.oldest[NEWER]) { // advance the list this.oldest = this.oldest[NEWER]; this.oldest[OLDER] = undefined; } else { // the cache is exhausted this.oldest = undefined; this.newest = undefined; } // Remove last strong reference to <entry> and remove links from the purged // entry being returned: entry[NEWER] = entry[OLDER] = undefined; this._keymap["delete"](entry.key); --this.size; return [entry.key, entry.value]; } }; // ---------------------------------------------------------------------------- // Following code is optional and can be removed without breaking the core // functionality. LRUMap.prototype.has = function (key) { return this._keymap.has(key); }; }); })(lru); var HotTable = { name: 'HotTable', props: propFactory('HotTable'), watch: { mergedHotSettings: function mergedHotSettings(value) { if (!this.hotInstance || value === void 0) { return; } if (value.data) { if (this.hotInstance.isColumnModificationAllowed() || !this.hotInstance.isColumnModificationAllowed() && this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns) { // If the dataset dimensions change, update the index mappers. this.matchHotMappersSize(); // Data is automatically synchronized by reference. delete value.data; } } // If there are another options changed, update the HOT settings, render the table otherwise. if (Object.keys(value).length) { this.hotInstance.updateSettings(value); } else { this.hotInstance.render(); } this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols(); } }, data: function data() { var thisComponent = this; var rendererCache = new lru.LRUMap(this.wrapperRendererCacheSize); // Make the LRU cache destroy each removed component rendererCache.shift = function () { var entry = lru.LRUMap.prototype.shift.call(this); entry[1].component.$destroy(); return entry; }; return { __internalEdit: false, miscCache: { currentSourceColumns: null }, __hotInstance: null, columnSettings: null, rendererCache: rendererCache, editorCache: new Map(), get hotInstance() { if (!thisComponent.__hotInstance || thisComponent.__hotInstance && !thisComponent.__hotInstance.isDestroyed) { // Will return the Handsontable instance or `null` if it's not yet been created. return thisComponent.__hotInstance; } else { console.warn(HOT_DESTROYED_WARNING); return null; } }, set hotInstance(hotInstance) { thisComponent.__hotInstance = hotInstance; } }; }, computed: { mergedHotSettings: function mergedHotSettings() { return prepareSettings(this.$props, this.hotInstance ? this.hotInstance.getSettings() : void 0); } }, methods: { /** * Initialize Handsontable. */ hotInit: function hotInit() { var globalRendererVNode = this.getGlobalRendererVNode(); var globalEditorVNode = this.getGlobalEditorVNode(); var newSettings = prepareSettings(this.$props); newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns; if (globalEditorVNode) { newSettings.editor = this.getEditorClass(globalEditorVNode, this); globalEditorVNode.child.$destroy(); } if (globalRendererVNode) { newSettings.renderer = this.getRendererWrapper(globalRendererVNode, this); globalRendererVNode.child.$destroy(); } this.hotInstance = new Handsontable__default["default"].Core(this.$el, newSettings); this.hotInstance.init(); preventInternalEditWatch(this); this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols(); }, matchHotMappersSize: function matchHotMappersSize() { var _this = this; if (!this.hotInstance) { return; } var data = this.hotInstance.getSourceData(); var rowsToRemove = []; var columnsToRemove = []; var indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes(); var isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed(); var indexMapperColumnCount = 0; if (data && data.length !== indexMapperRowCount) { if (data.length < indexMapperRowCount) { for (var r = data.length; r < indexMapperRowCount; r++) { rowsToRemove.push(r); } } } if (isColumnModificationAllowed) { var _data$; indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes(); if (data && data[0] && ((_data$ = data[0]) === null || _data$ === void 0 ? void 0 : _data$.length) !== indexMapperColumnCount) { if (data[0].length < indexMapperColumnCount) { for (var c = data[0].length; c < indexMapperColumnCount; c++) { columnsToRemove.push(c); } } } } this.hotInstance.batch(function () { if (rowsToRemove.length > 0) { _this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove); } else { _this.hotInstance.rowIndexMapper.insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount); } if (isColumnModificationAllowed && data.length !== 0) { if (columnsToRemove.length > 0) { _this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove); } else { _this.hotInstance.columnIndexMapper.insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount); } } }); }, getGlobalRendererVNode: function getGlobalRendererVNode() { var hotTableSlots = this.$slots["default"] || []; return findVNodeByType(hotTableSlots, 'hot-renderer'); }, getGlobalEditorVNode: function getGlobalEditorVNode() { var hotTableSlots = this.$slots["default"] || []; return findVNodeByType(hotTableSlots, 'hot-editor'); }, /** * Get settings for the columns provided in the `hot-column` components. */ getColumnSettings: function getColumnSettings() { var hotColumns = getHotColumnComponents(this.$children); var usesRendererComponent = false; var columnSettings = hotColumns.map(function (elem) { if (elem.usesRendererComponent) { usesRendererComponent = true; } return _objectSpread2({}, elem.columnSettings); }); if (usesRendererComponent && this.settings && (this.settings.autoColumnSize !== false || this.settings.autoRowSize) && (this.autoColumnSize !== false || this.autoRowSize)) { console.warn('Your `hot-table` configuration includes both `hot-column` and `autoRowSize`/`autoColumnSize`, which are not compatible with each other ' + 'in this version of `@handsontable/vue`. Disable `autoRowSize` and `autoColumnSize` to prevent row and column misalignment.'); } return columnSettings.length ? columnSettings : void 0; }, /** * Create the wrapper function for the provided renderer child component. * * @param {Object} vNode VNode of the renderer child component. * @param {Boolean} containerComponent Instance of the component, which will be treated as a parent for the newly created renderer component. * @returns {Function} The wrapper function used as the renderer. */ getRendererWrapper: function getRendererWrapper(vNode, containerComponent) { var $vm = this; return function (instance, TD, row, col, prop, value, cellProperties) { // Prevent caching and rendering of the GhostTable table cells if (TD && !TD.getAttribute('ghost-table')) { var rendererCache = $vm.rendererCache; var rendererArgs = { hotInstance: instance, TD: TD, row: row, col: col, prop: prop, value: value, cellProperties: cellProperties, isRenderer: true }; if (rendererCache && !rendererCache.has("".concat(row, "-").concat(col))) { var mountedComponent = createVueComponent(vNode, containerComponent, vNode.componentOptions.propsData, rendererArgs); rendererCache.set("".concat(row, "-").concat(col), { component: mountedComponent, lastUsedTD: null }); } var cachedEntry = rendererCache.get("".concat(row, "-").concat(col)); var cachedComponent = cachedEntry.component; var cachedTD = cachedEntry.lastUsedTD; Object.assign(cachedComponent.$data, rendererArgs); if (!cachedComponent.$el.parentElement || cachedTD !== TD) { // Clear the previous contents of a TD while (TD.firstChild) { TD.removeChild(TD.firstChild); } TD.appendChild(cachedComponent.$el); cachedEntry.lastUsedTD = TD; } } return TD; }; }, /** * Create a fresh class to be used as an editor, based on the editor component provided. * * @param {Object} vNode VNode for the editor child component. * @param {Boolean} containerComponent Instance of the component, which will be treated as a parent for the newly created editor component. * @returns {Class} The class used as an editor in Handsontable. */ getEditorClass: function getEditorClass(vNode, containerComponent) { var componentKey = vNode.key ? vNode.key.toString() : null; var componentName = vNode.componentOptions.Ctor.options.name; var componentCacheKey = componentKey ? "".concat(componentName, ":").concat(componentKey) : componentName; var editorCache = this.editorCache; var mountedComponent = null; if (!editorCache.has(componentCacheKey)) { mountedComponent = createVueComponent(vNode, containerComponent, vNode.componentOptions.propsData, { isEditor: true }); editorCache.set(componentCacheKey, mountedComponent); } else { mountedComponent = editorCache.get(componentCacheKey); } return mountedComponent.$data.hotCustomEditorClass; } }, mounted: function mounted() { this.columnSettings = this.getColumnSettings(); return this.hotInit(); }, beforeDestroy: function beforeDestroy() { if (this.hotInstance) { this.hotInstance.destroy(); } }, version: version }; function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { // Vue.extend constructor export interop. const options = typeof script === 'function' ? script.options : script; // render functions if (template && template.render) { options.render = template.render; options.staticRenderFns = template.staticRenderFns; options._compiled = true; // functional template if (isFunctionalTemplate) { options.functional = true; } } return script; } /* script */ var __vue_script__$2 = HotTable; /* template */ var __vue_render__ = function __vue_render__() { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c('div', { attrs: { "id": _vm.id } }, [_vm._t("default")], 2); }; var __vue_staticRenderFns__ = []; /* style */ var __vue_inject_styles__$2 = undefined; /* scoped */ var __vue_scope_id__$2 = undefined; /* functional template */ var __vue_is_functional_template__$2 = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__$2 = /*#__PURE__*/normalizeComponent({ render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__$2, __vue_script__$2, __vue_scope_id__$2, __vue_is_functional_template__$2); var HotColumn = { name: 'HotColumn', props: propFactory('HotColumn'), methods: { /** * Create the column settings based on the data provided to the `hot-column` component and it's child components. */ createColumnSettings: function createColumnSettings() { var hotColumnSlots = this.$slots["default"] || []; var rendererVNode = findVNodeByType(hotColumnSlots, 'hot-renderer'); var editorVNode = findVNodeByType(hotColumnSlots, 'hot-editor'); var assignedProps = filterPassedProps(this.$props); if (rendererVNode && this.usesRendererComponent === void 0) { this.usesRendererComponent = true; } this.columnSettings = _objectSpread2({}, assignedProps); if (rendererVNode !== null) { this.columnSettings.renderer = this.$parent.getRendererWrapper(rendererVNode, this); } else if (assignedProps.renderer) { this.columnSettings.renderer = assignedProps.renderer; } if (editorVNode !== null) { this.columnSettings.editor = this.$parent.getEditorClass(editorVNode, this); } else if (assignedProps.editor) { this.columnSettings.editor = assignedProps.editor; } } }, mounted: function mounted() { this.createColumnSettings(); }, render: function render() { return null; } }; /* script */ var __vue_script__$1 = HotColumn; /* template */ /* style */ var __vue_inject_styles__$1 = undefined; /* scoped */ var __vue_scope_id__$1 = undefined; /* functional template */ var __vue_is_functional_template__$1 = undefined; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ var __vue_component__$1 = /*#__PURE__*/normalizeComponent({}, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1); /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; function _typeof(obj) { if (typeof Symbol === "function" && _typeof$1(Symbol.iterator) === "symbol") { _typeof = function _typeof(obj) { return _typeof$1(obj); }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof$1(obj); }; } return _typeof(obj); } 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; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } // The rational behind the verbose Reflect-feature check below is the fact that there are polyfills // which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys. // Without this check consumers will encounter hard to track down runtime errors. function reflectionIsSupported() { return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys; } function copyReflectionMetadata(to, from) { forwardMetadata(to, from); Object.getOwnPropertyNames(from.prototype).forEach(function (key) { forwardMetadata(to.prototype, from.prototype, key); }); Object.getOwnPropertyNames(from).forEach(function (key) { forwardMetadata(to, from, key); }); } function forwardMetadata(to, from, propertyKey) { var metaKeys = propertyKey ? Reflect.getOwnMetadataKeys(from, propertyKey) : Reflect.getOwnMetadataKeys(from); metaKeys.forEach(function (metaKey) { var metadata = propertyKey ? Reflect.getOwnMetadata(metaKey, from, propertyKey) : Reflect.getOwnMetadata(metaKey, from); if (propertyKey) { Reflect.defineMetadata(metaKey, metadata, to, propertyKey); } else { Reflect.defineMetadata(metaKey, metadata, to); } }); } var fakeArray = { __proto__: [] }; var hasProto = fakeArray instanceof Array; function isPrimitive(value) { var type = _typeof(value); return value == null || type !== 'object' && type !== 'function'; } function collectDataFromConstructor(vm, Component) { // override _init to prevent to init as Vue instance var originalInit = Component.prototype._init; Component.prototype._init = function () { var _this = this; // proxy to actual vm var keys = Object.getOwnPropertyNames(vm); // 2.2.0 compat (props are no longer exposed as self properties) if (vm.$options.props) { for (var key in vm.$options.props) { if (!vm.hasOwnProperty(key)) { keys.push(key); } } } keys.forEach(function (key) { Object.defineProperty(_this, key, { get: function get() { return vm[key]; }, set: function set(value) { vm[key] = value; }, configurable: true }); }); }; // should be acquired class property values var data = new Component(); // restore original _init to avoid memory leak (#209) Component.prototype._init = originalInit; // create plain data object var plainData = {}; Object.keys(data).forEach(function (key) { if (data[key] !== undefined) { plainData[key] = data[key]; } }); return plainData; } var $internalHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeDestroy', 'destroyed', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch' // 2.6 ]; function componentFactory(Component) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; options.name = options.name || Component._componentTag || Component.name; // prototype props. var proto = Component.prototype; Object.getOwnPropertyNames(proto).forEach(function (key) { if (key === 'constructor') { return; } // hooks if ($internalHooks.indexOf(key) > -1) { options[key] = proto[key]; return; } var descriptor = Object.getOwnPropertyDescriptor(proto, key); if (descriptor.value !== void 0) { // methods if (typeof descriptor.value === 'function') { (options.methods || (options.methods = {}))[key] = descriptor.value; } else { // typescript decorated data (options.mixins || (options.mixins = [])).push({ data: function data() { return _defineProperty({}, key, descriptor.value); } }); } } else if (descriptor.get || descriptor.set) { // computed properties (options.computed || (options.computed = {}))[key] = { get: descriptor.get, set: descriptor.set }; } }); (options.mixins || (options.mixins = [])).push({ data: function data() { return collectDataFromConstructor(this, Component); } }); // decorate options var decorators = Component.__decorators__; if (decorators) { decorators.forEach(function (fn) { return fn(options); }); delete Component.__decorators__; } // find super var superProto = Object.getPrototypeOf(Component.prototype); var Super = superProto instanceof Vue__default["default"] ? superProto.constructor : Vue__default["default"]; var Extended = Super.extend(options); forwardStaticMembers(Extended, Component, Super); if (reflectionIsSupported()) { copyReflectionMetadata(Extended, Component); } return Extended; } var shouldIgnore = { prototype: true, arguments: true, callee: true, caller: true }; function forwardStaticMembers(Extended, Original, Super) { // We have to use getOwnPropertyNames since Babel registers methods as non-enumerable Object.getOwnPropertyNames(Original).forEach(function (key) { // Skip the properties that should not be overwritten if (shouldIgnore[key]) { return; } // Some browsers does not allow reconfigure built-in properties var extendedDescriptor = Object.getOwnPropertyDescriptor(Extended, key); if (extendedDescriptor && !extendedDescriptor.configurable) { return; } var descriptor = Object.getOwnPropertyDescriptor(Original, key); // If the user agent does not support `__proto__` or its family (IE <= 10), // the sub class properties may be inherited properties from the super class in TypeScript. // We need to exclude such properties to prevent to overwrite // the component options object which stored on the extended constructor (See #192). // If the value is a referenced value (object or function), // we can check equality of them and exclude it if they have the same reference. // If it is a primitive value, it will be forwarded for safety. if (!hasProto) { // Only `cid` is explicitly exluded from property forwarding // because we cannot detect whether it is a inherited property or not // on the no `__proto__` environment even though the property is reserved. if (key === 'cid') { return; } var superDescriptor = Object.getOwnPropertyDescriptor(Super, key); if (!isPrimitive(descriptor.value) && superDescriptor && superDescriptor.value === descriptor.value) { return; } } // Warn if the users manually declare reserved properties Object.defineProperty(Extended, key, descriptor); }); } function Component(options) { if (typeof options === 'function') { return componentFactory(options); } return function (Component) { return componentFactory(Component, options); }; } Component.registerHooks = function registerHooks(keys) { $internalHooks.push.apply($internalHooks, _toConsumableArray(keys)); }; var BaseEditorComponent = /*#__PURE__*/function (_Vue) { function BaseEditorComponent() { var _this2; _classCallCheck(this, BaseEditorComponent); _this2 = _callSuper(this, BaseEditorComponent, arguments); _this2.name = 'BaseEditorComponent'; _this2.instance = null; _this2.row = null; _this2.col = null; _this2.prop = null; _this2.TD = null; _this2.originalValue = null; _this2.cellProperties = null; _this2.state = null; _this2.hot = null; return _this2; } _inherits(BaseEditorComponent, _Vue); return _createClass(BaseEditorComponent, [{ key: "mounted", value: function mounted() { var _this = this; this.$data.hotCustomEditorClass = function () { var customEditorClass = /*#__PURE__*/function (_Handsontable$editors) { function CustomEditor(hotInstance) { var _this3; _classCallCheck(this, CustomEditor); _this3 = _callSuper(this, CustomEditor, [hotInstance]); _this.$data.hotCustomEditorInstance = _this3; return _this3; } _inherits(CustomEditor, _Handsontable$editors); return _createClass(CustomEditor, [{ key: "focus", value: function focus() {} }, { key: "getValue", value: function getValue() {} }, { key: "setValue", value: function setValue() {} }, { key: "open", value: function open() {} }, { key: "close", value: function close() {} }]); }(Handsontable__default["default"].editors.BaseEditor); // Fill with the rest of the BaseEditorComponent methods Object.getOwnPropertyNames(Handsontable__default["default"].editors.BaseEditor.prototype).forEach(function (propName) { if (propName === 'constructor') { return; } customEditorClass.prototype[propName] = function () { var _this$propName; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return (_this$propName = _this[propName]).call.apply(_this$propName, [this].concat(args)); }; }); return customEditorClass; }(); } // BaseEditorComponent methods: }, { key: "_fireCallbacks", value: function _fireCallbacks() { var _Handsontable$editors2; for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { args[_key2] = arguments[_key2]; } (_Handsontable$editors2 = Handsontable__default["default"].editors.BaseEditor.prototype._fireCallbacks).call.apply(_Handsontable$editors2, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "beginEditing", value: function beginEditing() { var _Handsontable$editors3; for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { args[_key3] = arguments[_key3]; } return (_Handsontable$editors3 = Handsontable__default["default"].editors.BaseEditor.prototype.beginEditing).call.apply(_Handsontable$editors3, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "cancelChanges", value: function cancelChanges() { var _Handsontable$editors4; for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { args[_key4] = arguments[_key4]; } return (_Handsontable$editors4 = Handsontable__default["default"].editors.BaseEditor.prototype.cancelChanges).call.apply(_Handsontable$editors4, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "checkEditorSection", value: function checkEditorSection() { var _Handsontable$editors5; for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { args[_key5] = arguments[_key5]; } return (_Handsontable$editors5 = Handsontable__default["default"].editors.BaseEditor.prototype.checkEditorSection).call.apply(_Handsontable$editors5, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "close", value: function close() { var _Handsontable$editors6; for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { args[_key6] = arguments[_key6]; } return (_Handsontable$editors6 = Handsontable__default["default"].editors.BaseEditor.prototype.close).call.apply(_Handsontable$editors6, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "discardEditor", value: function discardEditor() { var _Handsontable$editors7; for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) { args[_key7] = arguments[_key7]; } return (_Handsontable$editors7 = Handsontable__default["default"].editors.BaseEditor.prototype.discardEditor).call.apply(_Handsontable$editors7, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "enableFullEditMode", value: function enableFullEditMode() { var _Handsontable$editors8; for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) { args[_key8] = arguments[_key8]; } return (_Handsontable$editors8 = Handsontable__default["default"].editors.BaseEditor.prototype.enableFullEditMode).call.apply(_Handsontable$editors8, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "extend", value: function extend() { var _Handsontable$editors9; for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) { args[_key9] = arguments[_key9]; } return (_Handsontable$editors9 = Handsontable__default["default"].editors.BaseEditor.prototype.extend).call.apply(_Handsontable$editors9, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "finishEditing", value: function finishEditing() { var _Handsontable$editors0; for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) { args[_key0] = arguments[_key0]; } return (_Handsontable$editors0 = Handsontable__default["default"].editors.BaseEditor.prototype.finishEditing).call.apply(_Handsontable$editors0, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "focus", value: function focus() { var _Handsontable$editors1; for (var _len1 = arguments.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) { args[_key1] = arguments[_key1]; } return (_Handsontable$editors1 = Handsontable__default["default"].editors.BaseEditor.prototype.focus).call.apply(_Handsontable$editors1, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "getValue", value: function getValue() { var _Handsontable$editors10; for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) { args[_key10] = arguments[_key10]; } return (_Handsontable$editors10 = Handsontable__default["default"].editors.BaseEditor.prototype.getValue).call.apply(_Handsontable$editors10, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "init", value: function init() { var _Handsontable$editors11; for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) { args[_key11] = arguments[_key11]; } return (_Handsontable$editors11 = Handsontable__default["default"].editors.BaseEditor.prototype.init).call.apply(_Handsontable$editors11, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "isInFullEditMode", value: function isInFullEditMode() { var _Handsontable$editors12; for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) { args[_key12] = arguments[_key12]; } return (_Handsontable$editors12 = Handsontable__default["default"].editors.BaseEditor.prototype.isInFullEditMode).call.apply(_Handsontable$editors12, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "isOpened", value: function isOpened() { var _Handsontable$editors13; for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) { args[_key13] = arguments[_key13]; } return (_Handsontable$editors13 = Handsontable__default["default"].editors.BaseEditor.prototype.isOpened).call.apply(_Handsontable$editors13, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "isWaiting", value: function isWaiting() { var _Handsontable$editors14; for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) { args[_key14] = arguments[_key14]; } return (_Handsontable$editors14 = Handsontable__default["default"].editors.BaseEditor.prototype.isWaiting).call.apply(_Handsontable$editors14, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "open", value: function open() { var _Handsontable$editors15; for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) { args[_key15] = arguments[_key15]; } return (_Handsontable$editors15 = Handsontable__default["default"].editors.BaseEditor.prototype.open).call.apply(_Handsontable$editors15, [this.$data.hotCustomEditorInstance].concat(args)); } }, { key: "prepare", value: function prepare(row, col, prop, TD, originalValue, cellProperties) { this.$data.hotInstance = cellProperties.instance; this.$data.row = row; this.$data.col = col; this.$data.prop = prop; this.$data.TD = TD; this.$data.originalValue = originalValue; this.$data.cellProperties = cellProperties; return Handsontable__default["default"].editors.BaseEditor.prototype.prepare.call(this.$data.hotCustomEditorInstance, row, col, prop, TD, originalValue, cellProperties); } }, { key: "saveValue", value: function saveValue() { var _Handsontable$editors16; for (var _len16