UNPKG

@neu-ui/web-components

Version:

A Neumorphic web component library built with @microsoft/fast-element and Vite using javascript

28 lines (27 loc) 970 B
import { FASTElement as s } from "@microsoft/fast-element"; import { LabelDefinition as r } from "./label.definition.es.js"; class o extends s { constructor() { super(), this.disabled = !1, this.required = !1, this.for = "", this.size; } attributeChangedCallback(e, t, i) { e === "disabled" && (this.disabled = i !== null), e === "required" && (this.required = i !== null), e === "for" && (this.for = i), e === "size" && (this.size = i), super.attributeChangedCallback(e, t, i); } handleClick() { if (this.for && !this.disabled) { const e = this.closest('[class*="wrapper"]') || this.parentElement; if (e && e.shadowRoot) { const t = e.shadowRoot.querySelector( `#${this.for}` ); t && t.type === "checkbox" ? (t.checked = !t.checked, t.dispatchEvent( new Event("change", { bubbles: !0, composed: !1 }) )) : t && t.focus(); } } } } s.define(o, r); export { o as Label };