import { checkbox_styles_default } from "./chunk.BCIBWPWZ.js"; import { defaultValue, l } from "./chunk.YA5FISEV.js"; import { form_control_styles_default } from "./chunk.VGK3WMAH.js"; import { FormControlController } from "./chunk.E5624Z63.js"; import { o } from "./chunk.ZTHCIXLL.js"; import { HasSlotController } from "./chunk.NYIIDP5N.js"; import { SlIcon } from "./chunk.AGWHFEOF.js"; import { e } from "./chunk.3RBSSBZT.js"; import { watch } from "./chunk.JMZM2TDT.js"; import { component_styles_default } from "./chunk.INZSKSLC.js"; import { ShoelaceElement, e as e2, n, r } from "./chunk.OGQ452CI.js"; import { x } from "./chunk.OOP2EFQH.js"; import { __decorateClass } from "./chunk.W27M6RDR.js"; // src/components/checkbox/checkbox.component.ts var SlCheckbox = class extends ShoelaceElement { constructor() { super(...arguments); this.formControlController = new FormControlController(this, { value: (control) => control.checked ? control.value || "on" : void 0, defaultValue: (control) => control.defaultChecked, setValue: (control, checked) => control.checked = checked }); this.hasSlotController = new HasSlotController(this, "help-text"); this.hasFocus = false; this.title = ""; this.name = ""; this.size = "medium"; this.disabled = false; this.checked = false; this.indeterminate = false; this.defaultChecked = false; this.form = ""; this.required = false; this.helpText = ""; } /** Gets the validity state object */ get validity() { return this.input.validity; } /** Gets the validation message */ get validationMessage() { return this.input.validationMessage; } firstUpdated() { this.formControlController.updateValidity(); } handleClick() { this.checked = !this.checked; this.indeterminate = false; this.emit("sl-change"); } handleBlur() { this.hasFocus = false; this.emit("sl-blur"); } handleInput() { this.emit("sl-input"); } handleInvalid(event) { this.formControlController.setValidity(false); this.formControlController.emitInvalidEvent(event); } handleFocus() { this.hasFocus = true; this.emit("sl-focus"); } handleDisabledChange() { this.formControlController.setValidity(this.disabled); } handleStateChange() { this.input.checked = this.checked; this.input.indeterminate = this.indeterminate; this.formControlController.updateValidity(); } /** Simulates a click on the checkbox. */ click() { this.input.click(); } /** Sets focus on the checkbox. */ focus(options) { this.input.focus(options); } /** Removes focus from the checkbox. */ blur() { this.input.blur(); } /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */ checkValidity() { return this.input.checkValidity(); } /** Gets the associated form, if one exists. */ getForm() { return this.formControlController.getForm(); } /** Checks for validity and shows the browser's validation message if the control is invalid. */ reportValidity() { return this.input.reportValidity(); } /** * Sets a custom validation message. The value provided will be shown to the user when the form is submitted. To clear * the custom validation message, call this method with an empty string. */ setCustomValidity(message) { this.input.setCustomValidity(message); this.formControlController.updateValidity(); } render() { const hasHelpTextSlot = this.hasSlotController.test("help-text"); const hasHelpText = this.helpText ? true : !!hasHelpTextSlot; return x`