UNPKG

@kelvininc/ui-components

Version:
66 lines (62 loc) 2.54 kB
import { p as proxyCustomElement, H, d as createEvent, h, e as Host } from './p-D6GMjtmE.js'; import { b as EIconName } from './p-DBphUUgi.js'; import { d as defineCustomElement$1 } from './p-B41PGLQm.js'; const checkboxCss = ":host{--checkbox-size:16px;--checkbox-icon-size:16px;width:var(--checkbox-size);height:var(--checkbox-size);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;user-select:none}:host kv-icon{--icon-width:var(--checkbox-icon-size);--icon-height:var(--checkbox-icon-size)}:host(:hover:not(.disabled)){opacity:0.8}:host(.disabled){opacity:0.4;cursor:not-allowed}"; const KvCheckbox = /*@__PURE__*/ proxyCustomElement(class KvCheckbox extends H { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.clickCheckbox = createEvent(this, "clickCheckbox", 7); /** @inheritdoc */ this.checked = false; /** @inheritdoc */ this.disabled = false; /** @inheritdoc */ this.indeterminate = false; this.getIconName = () => { if (this.indeterminate) { return EIconName.IndeterminateState; } if (this.checked) { return EIconName.CheckState; } return EIconName.UncheckState; }; this.onClick = () => { if (!this.disabled) { this.clickCheckbox.emit(); } }; } render() { return (h(Host, { key: '2b2b58401e21f92a5512831b442141d7f441f195', onClick: this.onClick, class: { disabled: this.disabled } }, h("kv-icon", { key: '86c54b844519ccb8e64d0b966c2fc84f49e7ed46', name: this.getIconName(), part: "icon" }))); } static get style() { return checkboxCss; } }, [1, "kv-checkbox", { "checked": [516], "disabled": [516], "indeterminate": [516] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["kv-checkbox", "kv-icon"]; components.forEach(tagName => { switch (tagName) { case "kv-checkbox": if (!customElements.get(tagName)) { customElements.define(tagName, KvCheckbox); } break; case "kv-icon": if (!customElements.get(tagName)) { defineCustomElement$1(); } break; } }); } defineCustomElement(); export { KvCheckbox as K, defineCustomElement as d };