@schukai/monster
Version:
Monster is a simple library for creating fast, robust and lightweight websites.
106 lines (95 loc) • 2.76 kB
JavaScript
/**
* Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
* Node module: @schukai/monster
*
* This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
* The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
*
* For those who do not wish to adhere to the AGPLv3, a commercial license is available.
* Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
* For more information about purchasing a commercial license, please contact schukai GmbH.
*/
import { instanceSymbol } from "../../constants.mjs";
import { CustomElement } from "../../dom/customelement.mjs";
import {
assembleMethodSymbol,
registerCustomElement,
} from "../../dom/customelement.mjs";
import { InputGroupStyleSheet } from "./stylesheet/input-group.mjs";
export { InputGroup };
/**
* @private
* @type {symbol}
*/
export const inputGroupElementSymbol = Symbol("inputGroupElement");
/**
* A InputGroup
*
* @fragments /fragments/components/form/input-group/
*
* @example /examples/components/form/input-group-simple
*
* @since 3.89.0
* @copyright schukai GmbH
* @summary A beautiful InputGroup that can make your life easier and also looks good.
*/
class InputGroup extends CustomElement {
/**
* This method is called by the `instanceof` operator.
* @returns {symbol}
*/
static get [instanceSymbol]() {
return Symbol.for("@schukai/monster/components/form/input-group@@instance");
}
/**
* @return {Components.Form.InputGroup
*/
[assembleMethodSymbol]() {
super[assembleMethodSymbol]();
return this;
}
/**
* 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
* @property {boolean} disabled=false Disabled state
*/
get defaults() {
return Object.assign({}, super.defaults, {
templates: {
main: getTemplate(),
},
disabled: false,
});
}
/**
* @return {string}
*/
static getTag() {
return "monster-input-group";
}
/**
* @return {CSSStyleSheet[]}
*/
static getCSSStyleSheet() {
return [InputGroupStyleSheet];
}
}
/**
* @private
* @return {string}
*/
function getTemplate() {
// language=HTML
return `
<div data-monster-role="control" part="control">
<slot name="prefix" part="prefix"></slot>
<slot part="main"></slot>
<slot name="suffix" part="suffix"></slot>
</div>`;
}
registerCustomElement(InputGroup);