handsontable
Version:
Handsontable is a JavaScript Data Grid available for React, Angular and Vue.
92 lines (88 loc) • 3.22 kB
JavaScript
import "core-js/modules/es.error.cause.js";
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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 || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { extend } from "../../../helpers/object.mjs";
import { extendByMetaType } from "../utils.mjs";
import metaSchemaFactory from "../metaSchema.mjs";
/**
* @typedef {Options} TableMeta
*/
/**
* @returns {TableMeta} Returns an empty object. The holder for global meta object.
*/
function createTableMetaEmptyClass() {
return class TableMeta {};
}
/**
* The global meta object is a root of all default settings, which are recognizable by Handsontable.
* Other layers are inherited from this object. Adding, removing, or changing property in that
* object has a direct reflection to all layers such as: TableMeta, ColumnMeta, or CellMeta layers.
*
* +-------------+.
* │ GlobalMeta │
* │ (prototype) │
* +-------------+\
* │ \
* │ \
* \│/ _\|
* +-------------+ +-------------+.
* │ TableMeta │ │ ColumnMeta │
* │ (instance) │ │ (prototype) │
* +-------------+ +-------------+.
* │
* │
* \│/
* +-------------+.
* │ CellMeta │
* │ (instance) │
* +-------------+.
*/
export default class GlobalMeta {
constructor(hot) {
/**
* An alias for the constructor. Necessary for inheritance for creating new layers.
*
* @type {TableMeta}
*/
_defineProperty(this, "metaCtor", createTableMetaEmptyClass());
/**
* Main object (prototype of the internal TableMeta class), holder for all default settings.
*
* @type {object}
*/
_defineProperty(this, "meta", void 0);
this.meta = this.metaCtor.prototype;
extend(this.meta, metaSchemaFactory());
this.meta.instance = hot;
}
/**
* Gets constructor of the global meta object. Necessary for inheritance for creating the next meta layers.
*
* @returns {Function}
*/
getMetaConstructor() {
return this.metaCtor;
}
/**
* Gets settings object for this layer.
*
* @returns {object}
*/
getMeta() {
return this.meta;
}
/**
* Updates global settings object by merging settings with the current state.
*
* @param {object} settings An object to merge with.
*/
updateMeta(settings) {
var _settings$type;
extend(this.meta, settings);
extendByMetaType(this.meta, {
...settings,
type: (_settings$type = settings.type) !== null && _settings$type !== void 0 ? _settings$type : this.meta.type
}, settings);
}
}