/** * Copyright 2023 schukai GmbH * SPDX-License-Identifier: AGPL-3.0 */ import { CustomElement, assembleMethodSymbol, } from "../../dom/customelement.mjs"; import { Datasource as DatasourceBase } from "../../data/datasource.mjs"; import { instanceSymbol } from "../../constants.mjs"; export { Datasource, dataSourceSymbol }; /** * @private * @type {symbol} */ const dataSourceSymbol = Symbol.for( "@schukai/monster/components/datasource@@datasource", ); /** * The Datasource component is a basic class for the datatable component. * * <img src="./images/datasource.png"> * * Dependencies: the system uses functions of the [monsterjs](https://monsterjs.org/) library * * @startuml datasource.png * skinparam monochrome true * skinparam shadowing false * HTMLElement <|-- CustomElement * CustomElement <|-- Datasource * @enduml * * @copyright schukai GmbH * @memberOf Monster.Components.Datatable * @summary A abstract datasource */ class Datasource extends CustomElement { /** * the constructor of the class */ constructor() { super(); this[dataSourceSymbol] = new DatasourceBase(); } /** * This method is called by the `instanceof` operator. * @returns {symbol} */ static get [instanceSymbol]() { return Symbol.for("@schukai/monster/components/datasource@@instance"); } /** * To set the options via the html tag the attribute `data-monster-options` must be used. * @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control} * * The individual configuration values can be found in the table. * * @property {Object} templates Template definitions * @property {string} templates.main Main template */ get defaults() { return Object.assign({}, super.defaults, {}); } /** * * @return {Monster.Components.Form.Form} */ [assembleMethodSymbol]() { super[assembleMethodSymbol](); } /** * Get the data, without proxy * @returns {Object} */ get data() { return this[dataSourceSymbol].get(); } /** * set the data * @param {Object} data */ set data(data) { this[dataSourceSymbol].set(data); } /** * Get the datasource * @returns {Monster.Data.Datasource} */ get datasource() { return this[dataSourceSymbol]; } }