import { EventEmitter, ComponentInterface } from '../../stencil-public-runtime'; import { BaseChoiceControl } from '../_shared/form/base-choice-control'; /** * @component BcmSwitch * @description * A form-associated toggle switch component representing a boolean choice. * It behaves like a checkbox and integrates with native HTML forms via ElementInternals. * * This component supports **three validation strategies** via `validation-mode`: * * - **`native`**: * - Uses native browser constraint validation. * - Sets the underlying input's `required` attribute. * - Browser may show the native validation bubble when the form calls `reportValidity()` / submit validation runs. * * - **`silent`**: * - Does **not** rely on native `required` (prevents the browser bubble). * - Computes the "missing required" state internally and exposes it via `error` + `caption`. * - UI errors are **gated**: they appear only after the control is touched or after a submit attempt. * * - **`none`**: * - Value-only mode (headless): participates in form value submission but never becomes invalid. * * ## UI error gating (silent mode) * To avoid showing errors on initial render, the component tracks: * - `touched`: set after the first user interaction * - `submitAttempted`: set when the parent form emits `submit` * * Only when `touched || submitAttempted` the component will show `error/caption` in `silent` mode. * * ## Value behavior * - When checked, the component submits its `value` (default: `"on"`). * - When unchecked, no value is submitted. * - When disabled, the component does not participate in submission or validity. * * @example Basic usage * * * @example Required with silent validation (no native bubble) *
* * * *
* * @example Native validation mode (may show native bubble) * * * @example Value-only mode (no validation) * * * @csspart base - Root container * @csspart switch-wrapper - Wrapper containing label + track * @csspart input - Hidden native input * @csspart label - Text label * @csspart dot-container - Switch track * @csspart dot - Switch knob * @csspart caption - Helper/error text */ export declare class BcmSwitch extends BaseChoiceControl implements ComponentInterface { el: HTMLElement; internals: ElementInternals; /** Unique id (optional). Generated by default. */ _id?: string; /** Visible label text */ label: string; /** Position of the label relative to the switch */ labelPosition: 'left' | 'right'; /** Visual error state (manual/external). In silent mode this can be auto-managed. */ error: boolean; /** Helper / error text shown under the switch */ caption?: string; /** Size variant */ size: 'small' | 'medium' | 'large'; /** Internal checked mirror for UI (kept to preserve old DOM/class behavior) */ internalChecked: boolean; /** Gate for silent-mode error UI */ private touched; /** Gate for silent-mode error UI */ private submitAttempted; /** Emitted when the switch toggles */ bcmSwitchChange: EventEmitter; private inputEl; componentWillLoad(): void; componentDidLoad(): void; disconnectedCallback(): void; private onFormSubmit; formResetCallback(): void; protected onBaseCheckedChange(newVal: boolean): void; private syncNativeInput; protected updateFormValueAndValidity(opts?: { setUi?: boolean; }): void; private toggleSwitch; private switchStyle; private switchClass; render(): any; }