@handsontable/vue3
Advanced tools
Comparing version 12.1.3 to 12.2.0
@@ -16,3 +16,2 @@ 'use strict'; | ||
*/ | ||
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.'; | ||
@@ -26,3 +25,2 @@ /** | ||
*/ | ||
function hasOwnProperty(object, key) { | ||
@@ -37,8 +35,7 @@ return Object.prototype.hasOwnProperty.call(object, key); | ||
*/ | ||
function propFactory(source) { | ||
var registeredHooks = Handsontable__default["default"].hooks.getRegistered(); | ||
var propSchema = {}; | ||
Object.assign(propSchema, Handsontable__default["default"].DefaultSettings); // eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
Object.assign(propSchema, Handsontable__default["default"].DefaultSettings); | ||
// eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
for (var prop in propSchema) { | ||
@@ -49,3 +46,2 @@ propSchema[prop] = { | ||
} | ||
for (var i = 0; i < registeredHooks.length; i++) { | ||
@@ -56,7 +52,5 @@ propSchema[registeredHooks[i]] = { | ||
} | ||
propSchema.settings = { | ||
"default": unassignedPropSymbol | ||
}; | ||
if (source === 'HotTable') { | ||
@@ -68,3 +62,2 @@ propSchema.id = { | ||
} | ||
return propSchema; | ||
@@ -78,7 +71,5 @@ } | ||
*/ | ||
function filterPassedProps(props) { | ||
var filteredProps = {}; | ||
var columnSettingsProp = props.settings; | ||
if (columnSettingsProp !== unassignedPropSymbol) { | ||
@@ -91,5 +82,4 @@ // eslint-disable-next-line no-restricted-syntax | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _propName in props) { | ||
@@ -100,3 +90,2 @@ if (hasOwnProperty(props, _propName) && _propName !== 'settings' && props[_propName] !== unassignedPropSymbol) { | ||
} | ||
return filteredProps; | ||
@@ -111,3 +100,2 @@ } | ||
*/ | ||
function prepareSettings(props, currentSettings) { | ||
@@ -117,4 +105,4 @@ var assignedProps = filterPassedProps(props); | ||
var additionalHotSettingsInProps = props.settings ? assignedProps : null; | ||
var newSettings = {}; // eslint-disable-next-line no-restricted-syntax | ||
var newSettings = {}; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var key in hotSettingsInProps) { | ||
@@ -124,5 +112,4 @@ if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== void 0 && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) { | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _key in additionalHotSettingsInProps) { | ||
@@ -133,3 +120,2 @@ if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== void 0 && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) { | ||
} | ||
return newSettings; | ||
@@ -146,3 +132,2 @@ } | ||
*/ | ||
function simpleEqual(objectA, objectB) { | ||
@@ -152,3 +137,3 @@ return JSON.stringify(objectA) === JSON.stringify(objectB); | ||
var version="12.1.3"; | ||
var version="12.2.0"; | ||
@@ -167,17 +152,14 @@ var HotTable = vue.defineComponent({ | ||
var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0); | ||
if (!this.hotInstance || settings === void 0) { | ||
return; | ||
} | ||
if (settings.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. | ||
this.matchHotMappersSize(); | ||
// Data is automatically synchronized by reference. | ||
delete settings.data; | ||
} | ||
} // If there are another options changed, update the HOT settings, render the table otherwise. | ||
} | ||
// If there are another options changed, update the HOT settings, render the table otherwise. | ||
if (Object.keys(settings).length) { | ||
@@ -188,3 +170,2 @@ this.hotInstance.updateSettings(settings); | ||
} | ||
this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols(); | ||
@@ -200,3 +181,2 @@ }, | ||
__hotInstance: null, | ||
/* eslint-enable vue/no-reserved-keys */ | ||
@@ -208,3 +188,2 @@ miscCache: { | ||
columnsCache: new Map(), | ||
get hotInstance() { | ||
@@ -220,7 +199,5 @@ if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) { | ||
}, | ||
set hotInstance(hotInstance) { | ||
this.__hotInstance = hotInstance; | ||
} | ||
}; | ||
@@ -231,4 +208,3 @@ }, | ||
* Initialize Handsontable. | ||
*/ | ||
hotInit: function hotInit() { | ||
*/hotInit: function hotInit() { | ||
var newSettings = prepareSettings(this.$props); | ||
@@ -242,7 +218,5 @@ newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns; | ||
var _this = this; | ||
if (!this.hotInstance) { | ||
return; | ||
} | ||
var data = this.hotInstance.getSourceData(); | ||
@@ -254,3 +228,2 @@ var rowsToRemove = []; | ||
var indexMapperColumnCount = 0; | ||
if (data && data.length !== indexMapperRowCount) { | ||
@@ -263,8 +236,5 @@ if (data.length < indexMapperRowCount) { | ||
} | ||
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) { | ||
@@ -278,3 +248,2 @@ if (data[0].length < indexMapperColumnCount) { | ||
} | ||
this.hotInstance.batch(function () { | ||
@@ -286,3 +255,2 @@ if (rowsToRemove.length > 0) { | ||
} | ||
if (isColumnModificationAllowed && data.length !== 0) { | ||
@@ -297,3 +265,2 @@ if (columnsToRemove.length > 0) { | ||
}, | ||
/** | ||
@@ -303,4 +270,3 @@ * Get settings for the columns provided in the `hot-column` components. | ||
* @returns {HotTableProps[] | undefined} | ||
*/ | ||
getColumnSettings: function getColumnSettings() { | ||
*/getColumnSettings: function getColumnSettings() { | ||
var columnSettings = Array.from(this.columnsCache.values()); | ||
@@ -326,5 +292,3 @@ return columnSettings.length ? columnSettings : void 0; | ||
id: _ctx.id | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 8 | ||
/* PROPS */ | ||
, _hoisted_1); | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1); | ||
} | ||
@@ -337,3 +301,2 @@ | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -345,6 +308,4 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
@@ -359,6 +320,4 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -375,3 +334,2 @@ if (key in obj) { | ||
} | ||
return obj; | ||
@@ -388,16 +346,11 @@ } | ||
* component and it's child components. | ||
*/ | ||
createColumnSettings: function createColumnSettings() { | ||
*/createColumnSettings: function createColumnSettings() { | ||
var assignedProps = filterPassedProps(this.$props); | ||
var columnSettings = _objectSpread2({}, assignedProps); | ||
if (assignedProps.renderer) { | ||
columnSettings.renderer = assignedProps.renderer; | ||
} | ||
if (assignedProps.editor) { | ||
columnSettings.editor = assignedProps.editor; | ||
} | ||
this.columnsCache.set(this, columnSettings); | ||
@@ -404,0 +357,0 @@ } |
@@ -28,3 +28,3 @@ /*! | ||
* | ||
* Version: 12.1.3 (built at Thu Sep 22 2022 09:55:51 GMT+0200 (Central European Summer Time)) | ||
* Version: 12.2.0 (built at Tue Oct 25 2022 12:06:12 GMT+0200 (Central European Summer Time)) | ||
*/ | ||
@@ -45,3 +45,2 @@ (function (global, factory) { | ||
*/ | ||
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.'; | ||
@@ -55,3 +54,2 @@ /** | ||
*/ | ||
function hasOwnProperty(object, key) { | ||
@@ -66,8 +64,7 @@ return Object.prototype.hasOwnProperty.call(object, key); | ||
*/ | ||
function propFactory(source) { | ||
var registeredHooks = Handsontable__default["default"].hooks.getRegistered(); | ||
var propSchema = {}; | ||
Object.assign(propSchema, Handsontable__default["default"].DefaultSettings); // eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
Object.assign(propSchema, Handsontable__default["default"].DefaultSettings); | ||
// eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
for (var prop in propSchema) { | ||
@@ -78,3 +75,2 @@ propSchema[prop] = { | ||
} | ||
for (var i = 0; i < registeredHooks.length; i++) { | ||
@@ -85,7 +81,5 @@ propSchema[registeredHooks[i]] = { | ||
} | ||
propSchema.settings = { | ||
"default": unassignedPropSymbol | ||
}; | ||
if (source === 'HotTable') { | ||
@@ -97,3 +91,2 @@ propSchema.id = { | ||
} | ||
return propSchema; | ||
@@ -107,7 +100,5 @@ } | ||
*/ | ||
function filterPassedProps(props) { | ||
var filteredProps = {}; | ||
var columnSettingsProp = props.settings; | ||
if (columnSettingsProp !== unassignedPropSymbol) { | ||
@@ -120,5 +111,4 @@ // eslint-disable-next-line no-restricted-syntax | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _propName in props) { | ||
@@ -129,3 +119,2 @@ if (hasOwnProperty(props, _propName) && _propName !== 'settings' && props[_propName] !== unassignedPropSymbol) { | ||
} | ||
return filteredProps; | ||
@@ -140,3 +129,2 @@ } | ||
*/ | ||
function prepareSettings(props, currentSettings) { | ||
@@ -146,4 +134,4 @@ var assignedProps = filterPassedProps(props); | ||
var additionalHotSettingsInProps = props.settings ? assignedProps : null; | ||
var newSettings = {}; // eslint-disable-next-line no-restricted-syntax | ||
var newSettings = {}; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var key in hotSettingsInProps) { | ||
@@ -153,5 +141,4 @@ if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== void 0 && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) { | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _key in additionalHotSettingsInProps) { | ||
@@ -162,3 +149,2 @@ if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== void 0 && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) { | ||
} | ||
return newSettings; | ||
@@ -175,3 +161,2 @@ } | ||
*/ | ||
function simpleEqual(objectA, objectB) { | ||
@@ -181,3 +166,3 @@ return JSON.stringify(objectA) === JSON.stringify(objectB); | ||
var version="12.1.3"; | ||
var version="12.2.0"; | ||
@@ -196,17 +181,14 @@ var HotTable = vue.defineComponent({ | ||
var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0); | ||
if (!this.hotInstance || settings === void 0) { | ||
return; | ||
} | ||
if (settings.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. | ||
this.matchHotMappersSize(); | ||
// Data is automatically synchronized by reference. | ||
delete settings.data; | ||
} | ||
} // If there are another options changed, update the HOT settings, render the table otherwise. | ||
} | ||
// If there are another options changed, update the HOT settings, render the table otherwise. | ||
if (Object.keys(settings).length) { | ||
@@ -217,3 +199,2 @@ this.hotInstance.updateSettings(settings); | ||
} | ||
this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols(); | ||
@@ -229,3 +210,2 @@ }, | ||
__hotInstance: null, | ||
/* eslint-enable vue/no-reserved-keys */ | ||
@@ -237,3 +217,2 @@ miscCache: { | ||
columnsCache: new Map(), | ||
get hotInstance() { | ||
@@ -249,7 +228,5 @@ if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) { | ||
}, | ||
set hotInstance(hotInstance) { | ||
this.__hotInstance = hotInstance; | ||
} | ||
}; | ||
@@ -260,4 +237,3 @@ }, | ||
* Initialize Handsontable. | ||
*/ | ||
hotInit: function hotInit() { | ||
*/hotInit: function hotInit() { | ||
var newSettings = prepareSettings(this.$props); | ||
@@ -271,7 +247,5 @@ newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns; | ||
var _this = this; | ||
if (!this.hotInstance) { | ||
return; | ||
} | ||
var data = this.hotInstance.getSourceData(); | ||
@@ -283,3 +257,2 @@ var rowsToRemove = []; | ||
var indexMapperColumnCount = 0; | ||
if (data && data.length !== indexMapperRowCount) { | ||
@@ -292,8 +265,5 @@ if (data.length < indexMapperRowCount) { | ||
} | ||
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) { | ||
@@ -307,3 +277,2 @@ if (data[0].length < indexMapperColumnCount) { | ||
} | ||
this.hotInstance.batch(function () { | ||
@@ -315,3 +284,2 @@ if (rowsToRemove.length > 0) { | ||
} | ||
if (isColumnModificationAllowed && data.length !== 0) { | ||
@@ -326,3 +294,2 @@ if (columnsToRemove.length > 0) { | ||
}, | ||
/** | ||
@@ -332,4 +299,3 @@ * Get settings for the columns provided in the `hot-column` components. | ||
* @returns {HotTableProps[] | undefined} | ||
*/ | ||
getColumnSettings: function getColumnSettings() { | ||
*/getColumnSettings: function getColumnSettings() { | ||
var columnSettings = Array.from(this.columnsCache.values()); | ||
@@ -355,5 +321,3 @@ return columnSettings.length ? columnSettings : void 0; | ||
id: _ctx.id | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 8 | ||
/* PROPS */ | ||
, _hoisted_1); | ||
}, [vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1); | ||
} | ||
@@ -366,3 +330,2 @@ | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -374,6 +337,4 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
@@ -388,6 +349,4 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -404,3 +363,2 @@ if (key in obj) { | ||
} | ||
return obj; | ||
@@ -417,16 +375,11 @@ } | ||
* component and it's child components. | ||
*/ | ||
createColumnSettings: function createColumnSettings() { | ||
*/createColumnSettings: function createColumnSettings() { | ||
var assignedProps = filterPassedProps(this.$props); | ||
var columnSettings = _objectSpread2({}, assignedProps); | ||
if (assignedProps.renderer) { | ||
columnSettings.renderer = assignedProps.renderer; | ||
} | ||
if (assignedProps.editor) { | ||
columnSettings.editor = assignedProps.editor; | ||
} | ||
this.columnsCache.set(this, columnSettings); | ||
@@ -433,0 +386,0 @@ } |
@@ -28,5 +28,5 @@ /*! | ||
* | ||
* Version: 12.1.3 (built at Thu Sep 22 2022 09:55:53 GMT+0200 (Central European Summer Time)) | ||
* Version: 12.2.0 (built at Tue Oct 25 2022 12:06:20 GMT+0200 (Central European Summer Time)) | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("handsontable/base")):"function"==typeof define&&define.amd?define(["exports","vue","handsontable/base"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Handsontable=t.Handsontable||{},t.Handsontable.vue={}),t.Vue,t.Handsontable)}(this,(function(t,e,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=o(n),r=Symbol("unassigned");function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function a(t){var e=s.default.hooks.getRegistered(),n={};for(var o in Object.assign(n,s.default.DefaultSettings),n)n[o]={default:r};for(var i=0;e.length>i;i++)n[e[i]]={default:r};return n.settings={default:r},"HotTable"===t&&(n.id={type:String,default:"hot-".concat(Math.random().toString(36).substring(5))}),n}function c(t){var e={},n=t.settings;if(n!==r)for(var o in n)i(n,o)&&n[o]!==r&&(e[o]=n[o]);for(var s in t)i(t,s)&&"settings"!==s&&t[s]!==r&&(e[s]=t[s]);return e}function u(t,e){var n=c(t),o=t.settings?t.settings:n,s=t.settings?n:null,r={};for(var a in o)!i(o,a)||void 0===o[a]||e&&"data"!==a&&l(e[a],o[a])||(r[a]=o[a]);for(var u in s)!i(s,u)||"id"===u||"settings"===u||void 0===s[u]||e&&"data"!==u&&l(e[u],s[u])||(r[u]=s[u]);return r}function l(t,e){return JSON.stringify(t)===JSON.stringify(e)}var h=e.defineComponent({name:"HotTable",props:a("HotTable"),provide:function(){return{columnsCache:this.columnsCache}},watch:{$props:{handler:function(t){var e=u(t,this.hotInstance?this.hotInstance.getSettings():void 0);this.hotInstance&&void 0!==e&&(e.data&&(this.hotInstance.isColumnModificationAllowed()||!this.hotInstance.isColumnModificationAllowed()&&this.hotInstance.countSourceCols()===this.miscCache.currentSourceColumns)&&(this.matchHotMappersSize(),delete e.data),Object.keys(e).length?this.hotInstance.updateSettings(e):this.hotInstance.render(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols())},deep:!0,immediate:!0}},data:function(){return{__hotInstance:null,miscCache:{currentSourceColumns:null},columnSettings:null,columnsCache:new Map,get hotInstance(){return!this.__hotInstance||this.__hotInstance&&!this.__hotInstance.isDestroyed?this.__hotInstance:(console.warn("The Handsontable instance bound to this component was destroyed and cannot be used properly."),null)},set hotInstance(t){this.__hotInstance=t}}},methods:{hotInit:function(){var t=u(this.$props);t.columns=this.columnSettings?this.columnSettings:t.columns,this.hotInstance=e.markRaw(new s.default.Core(this.$el,t)),this.hotInstance.init(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols()},matchHotMappersSize:function(){var t=this;if(this.hotInstance){var e,n=this.hotInstance.getSourceData(),o=[],s=[],r=this.hotInstance.rowIndexMapper.getNumberOfIndexes(),i=this.hotInstance.isColumnModificationAllowed(),a=0;if(n&&n.length!==r&&r>n.length)for(var c=n.length;r>c;c++)o.push(c);if(i)if(a=this.hotInstance.columnIndexMapper.getNumberOfIndexes(),n&&n[0]&&(null===(e=n[0])||void 0===e?void 0:e.length)!==a&&a>n[0].length)for(var u=n[0].length;a>u;u++)s.push(u);this.hotInstance.batch((function(){o.length>0?t.hotInstance.rowIndexMapper.removeIndexes(o):t.hotInstance.rowIndexMapper.insertIndexes(r-1,n.length-r),i&&0!==n.length&&(s.length>0?t.hotInstance.columnIndexMapper.removeIndexes(s):t.hotInstance.columnIndexMapper.insertIndexes(a-1,n[0].length-a))}))}},getColumnSettings:function(){var t=Array.from(this.columnsCache.values());return t.length?t:void 0}},mounted:function(){this.columnSettings=this.getColumnSettings(),this.hotInit()},beforeUnmount:function(){this.hotInstance&&this.hotInstance.destroy()},version:"12.1.3"}),d=["id"];function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}h.render=function(t,n,o,s,r,i){return e.openBlock(),e.createElementBlock("div",{id:t.id},[e.renderSlot(t.$slots,"default")],8,d)},h.__file="src/HotTable.vue";var m=e.defineComponent({name:"HotColumn",props:a("HotColumn"),inject:["columnsCache"],methods:{createColumnSettings:function(){var t=c(this.$props),e=function(t){for(var e=1;arguments.length>e;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?f(Object(n),!0).forEach((function(e){p(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},t);t.renderer&&(e.renderer=t.renderer),t.editor&&(e.editor=t.editor),this.columnsCache.set(this,e)}},mounted:function(){this.createColumnSettings()},unmounted:function(){this.columnsCache.delete(this)},render:function(){return null}});m.__file="src/HotColumn.vue",t.HotColumn=m,t.HotTable=h,t.default=h,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("handsontable/base")):"function"==typeof define&&define.amd?define(["exports","vue","handsontable/base"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Handsontable=t.Handsontable||{},t.Handsontable.vue={}),t.Vue,t.Handsontable)}(this,(function(t,e,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=o(n),r=Symbol("unassigned");function i(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function a(t){var e=s.default.hooks.getRegistered(),n={};for(var o in Object.assign(n,s.default.DefaultSettings),n)n[o]={default:r};for(var i=0;e.length>i;i++)n[e[i]]={default:r};return n.settings={default:r},"HotTable"===t&&(n.id={type:String,default:"hot-".concat(Math.random().toString(36).substring(5))}),n}function c(t){var e={},n=t.settings;if(n!==r)for(var o in n)i(n,o)&&n[o]!==r&&(e[o]=n[o]);for(var s in t)i(t,s)&&"settings"!==s&&t[s]!==r&&(e[s]=t[s]);return e}function u(t,e){var n=c(t),o=t.settings?t.settings:n,s=t.settings?n:null,r={};for(var a in o)!i(o,a)||void 0===o[a]||e&&"data"!==a&&l(e[a],o[a])||(r[a]=o[a]);for(var u in s)!i(s,u)||"id"===u||"settings"===u||void 0===s[u]||e&&"data"!==u&&l(e[u],s[u])||(r[u]=s[u]);return r}function l(t,e){return JSON.stringify(t)===JSON.stringify(e)}var h=e.defineComponent({name:"HotTable",props:a("HotTable"),provide:function(){return{columnsCache:this.columnsCache}},watch:{$props:{handler:function(t){var e=u(t,this.hotInstance?this.hotInstance.getSettings():void 0);this.hotInstance&&void 0!==e&&(e.data&&(this.hotInstance.isColumnModificationAllowed()||!this.hotInstance.isColumnModificationAllowed()&&this.hotInstance.countSourceCols()===this.miscCache.currentSourceColumns)&&(this.matchHotMappersSize(),delete e.data),Object.keys(e).length?this.hotInstance.updateSettings(e):this.hotInstance.render(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols())},deep:!0,immediate:!0}},data:function(){return{__hotInstance:null,miscCache:{currentSourceColumns:null},columnSettings:null,columnsCache:new Map,get hotInstance(){return!this.__hotInstance||this.__hotInstance&&!this.__hotInstance.isDestroyed?this.__hotInstance:(console.warn("The Handsontable instance bound to this component was destroyed and cannot be used properly."),null)},set hotInstance(t){this.__hotInstance=t}}},methods:{hotInit:function(){var t=u(this.$props);t.columns=this.columnSettings?this.columnSettings:t.columns,this.hotInstance=e.markRaw(new s.default.Core(this.$el,t)),this.hotInstance.init(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols()},matchHotMappersSize:function(){var t=this;if(this.hotInstance){var e,n=this.hotInstance.getSourceData(),o=[],s=[],r=this.hotInstance.rowIndexMapper.getNumberOfIndexes(),i=this.hotInstance.isColumnModificationAllowed(),a=0;if(n&&n.length!==r&&r>n.length)for(var c=n.length;r>c;c++)o.push(c);if(i)if(a=this.hotInstance.columnIndexMapper.getNumberOfIndexes(),n&&n[0]&&(null===(e=n[0])||void 0===e?void 0:e.length)!==a&&a>n[0].length)for(var u=n[0].length;a>u;u++)s.push(u);this.hotInstance.batch((function(){o.length>0?t.hotInstance.rowIndexMapper.removeIndexes(o):t.hotInstance.rowIndexMapper.insertIndexes(r-1,n.length-r),i&&0!==n.length&&(s.length>0?t.hotInstance.columnIndexMapper.removeIndexes(s):t.hotInstance.columnIndexMapper.insertIndexes(a-1,n[0].length-a))}))}},getColumnSettings:function(){var t=Array.from(this.columnsCache.values());return t.length?t:void 0}},mounted:function(){this.columnSettings=this.getColumnSettings(),this.hotInit()},beforeUnmount:function(){this.hotInstance&&this.hotInstance.destroy()},version:"12.2.0"}),d=["id"];function f(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function p(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}h.render=function(t,n,o,s,r,i){return e.openBlock(),e.createElementBlock("div",{id:t.id},[e.renderSlot(t.$slots,"default")],8,d)},h.__file="src/HotTable.vue";var m=e.defineComponent({name:"HotColumn",props:a("HotColumn"),inject:["columnsCache"],methods:{createColumnSettings:function(){var t=c(this.$props),e=function(t){for(var e=1;arguments.length>e;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?f(Object(n),!0).forEach((function(e){p(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},t);t.renderer&&(e.renderer=t.renderer),t.editor&&(e.editor=t.editor),this.columnsCache.set(this,e)}},mounted:function(){this.createColumnSettings()},unmounted:function(){this.columnsCache.delete(this)},render:function(){return null}});m.__file="src/HotColumn.vue",t.HotColumn=m,t.HotTable=h,t.default=h,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=vue-handsontable.min.js.map |
@@ -8,3 +8,2 @@ import { defineComponent, markRaw, openBlock, createElementBlock, renderSlot } from 'vue'; | ||
*/ | ||
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.'; | ||
@@ -18,3 +17,2 @@ /** | ||
*/ | ||
function hasOwnProperty(object, key) { | ||
@@ -29,8 +27,7 @@ return Object.prototype.hasOwnProperty.call(object, key); | ||
*/ | ||
function propFactory(source) { | ||
var registeredHooks = Handsontable.hooks.getRegistered(); | ||
var propSchema = {}; | ||
Object.assign(propSchema, Handsontable.DefaultSettings); // eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
Object.assign(propSchema, Handsontable.DefaultSettings); | ||
// eslint-disable-next-line no-restricted-syntax, guard-for-in | ||
for (var prop in propSchema) { | ||
@@ -41,3 +38,2 @@ propSchema[prop] = { | ||
} | ||
for (var i = 0; i < registeredHooks.length; i++) { | ||
@@ -48,7 +44,5 @@ propSchema[registeredHooks[i]] = { | ||
} | ||
propSchema.settings = { | ||
"default": unassignedPropSymbol | ||
}; | ||
if (source === 'HotTable') { | ||
@@ -60,3 +54,2 @@ propSchema.id = { | ||
} | ||
return propSchema; | ||
@@ -70,7 +63,5 @@ } | ||
*/ | ||
function filterPassedProps(props) { | ||
var filteredProps = {}; | ||
var columnSettingsProp = props.settings; | ||
if (columnSettingsProp !== unassignedPropSymbol) { | ||
@@ -83,5 +74,4 @@ // eslint-disable-next-line no-restricted-syntax | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _propName in props) { | ||
@@ -92,3 +82,2 @@ if (hasOwnProperty(props, _propName) && _propName !== 'settings' && props[_propName] !== unassignedPropSymbol) { | ||
} | ||
return filteredProps; | ||
@@ -103,3 +92,2 @@ } | ||
*/ | ||
function prepareSettings(props, currentSettings) { | ||
@@ -109,4 +97,4 @@ var assignedProps = filterPassedProps(props); | ||
var additionalHotSettingsInProps = props.settings ? assignedProps : null; | ||
var newSettings = {}; // eslint-disable-next-line no-restricted-syntax | ||
var newSettings = {}; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var key in hotSettingsInProps) { | ||
@@ -116,5 +104,4 @@ if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== void 0 && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) { | ||
} | ||
} // eslint-disable-next-line no-restricted-syntax | ||
} | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (var _key in additionalHotSettingsInProps) { | ||
@@ -125,3 +112,2 @@ if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== void 0 && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) { | ||
} | ||
return newSettings; | ||
@@ -138,3 +124,2 @@ } | ||
*/ | ||
function simpleEqual(objectA, objectB) { | ||
@@ -144,3 +129,3 @@ return JSON.stringify(objectA) === JSON.stringify(objectB); | ||
var version="12.1.3"; | ||
var version="12.2.0"; | ||
@@ -159,17 +144,14 @@ var HotTable = defineComponent({ | ||
var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0); | ||
if (!this.hotInstance || settings === void 0) { | ||
return; | ||
} | ||
if (settings.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. | ||
this.matchHotMappersSize(); | ||
// Data is automatically synchronized by reference. | ||
delete settings.data; | ||
} | ||
} // If there are another options changed, update the HOT settings, render the table otherwise. | ||
} | ||
// If there are another options changed, update the HOT settings, render the table otherwise. | ||
if (Object.keys(settings).length) { | ||
@@ -180,3 +162,2 @@ this.hotInstance.updateSettings(settings); | ||
} | ||
this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols(); | ||
@@ -192,3 +173,2 @@ }, | ||
__hotInstance: null, | ||
/* eslint-enable vue/no-reserved-keys */ | ||
@@ -200,3 +180,2 @@ miscCache: { | ||
columnsCache: new Map(), | ||
get hotInstance() { | ||
@@ -212,7 +191,5 @@ if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) { | ||
}, | ||
set hotInstance(hotInstance) { | ||
this.__hotInstance = hotInstance; | ||
} | ||
}; | ||
@@ -223,4 +200,3 @@ }, | ||
* Initialize Handsontable. | ||
*/ | ||
hotInit: function hotInit() { | ||
*/hotInit: function hotInit() { | ||
var newSettings = prepareSettings(this.$props); | ||
@@ -234,7 +210,5 @@ newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns; | ||
var _this = this; | ||
if (!this.hotInstance) { | ||
return; | ||
} | ||
var data = this.hotInstance.getSourceData(); | ||
@@ -246,3 +220,2 @@ var rowsToRemove = []; | ||
var indexMapperColumnCount = 0; | ||
if (data && data.length !== indexMapperRowCount) { | ||
@@ -255,8 +228,5 @@ if (data.length < indexMapperRowCount) { | ||
} | ||
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) { | ||
@@ -270,3 +240,2 @@ if (data[0].length < indexMapperColumnCount) { | ||
} | ||
this.hotInstance.batch(function () { | ||
@@ -278,3 +247,2 @@ if (rowsToRemove.length > 0) { | ||
} | ||
if (isColumnModificationAllowed && data.length !== 0) { | ||
@@ -289,3 +257,2 @@ if (columnsToRemove.length > 0) { | ||
}, | ||
/** | ||
@@ -295,4 +262,3 @@ * Get settings for the columns provided in the `hot-column` components. | ||
* @returns {HotTableProps[] | undefined} | ||
*/ | ||
getColumnSettings: function getColumnSettings() { | ||
*/getColumnSettings: function getColumnSettings() { | ||
var columnSettings = Array.from(this.columnsCache.values()); | ||
@@ -318,5 +284,3 @@ return columnSettings.length ? columnSettings : void 0; | ||
id: _ctx.id | ||
}, [renderSlot(_ctx.$slots, "default")], 8 | ||
/* PROPS */ | ||
, _hoisted_1); | ||
}, [renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1); | ||
} | ||
@@ -329,3 +293,2 @@ | ||
var keys = Object.keys(object); | ||
if (Object.getOwnPropertySymbols) { | ||
@@ -337,6 +300,4 @@ var symbols = Object.getOwnPropertySymbols(object); | ||
} | ||
return keys; | ||
} | ||
function _objectSpread2(target) { | ||
@@ -351,6 +312,4 @@ for (var i = 1; i < arguments.length; i++) { | ||
} | ||
return target; | ||
} | ||
function _defineProperty(obj, key, value) { | ||
@@ -367,3 +326,2 @@ if (key in obj) { | ||
} | ||
return obj; | ||
@@ -380,16 +338,11 @@ } | ||
* component and it's child components. | ||
*/ | ||
createColumnSettings: function createColumnSettings() { | ||
*/createColumnSettings: function createColumnSettings() { | ||
var assignedProps = filterPassedProps(this.$props); | ||
var columnSettings = _objectSpread2({}, assignedProps); | ||
if (assignedProps.renderer) { | ||
columnSettings.renderer = assignedProps.renderer; | ||
} | ||
if (assignedProps.editor) { | ||
columnSettings.editor = assignedProps.editor; | ||
} | ||
this.columnsCache.set(this, columnSettings); | ||
@@ -396,0 +349,0 @@ } |
{ | ||
"name": "@handsontable/vue3", | ||
"version": "12.1.3", | ||
"version": "12.2.0", | ||
"description": "Best Data Grid for Vue with Spreadsheet Look and Feel.", | ||
@@ -5,0 +5,0 @@ "author": "Handsoncode <hello@handsoncode.net> (https://handsoncode.net)", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1331
343786