import { AssociatedLabelInterface } from '@justeattakeaway/pie-webc-core'; import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core'; import { CSSResult } from 'lit'; import { FormControlInterface } from '@justeattakeaway/pie-webc-core'; import { GenericConstructor } from '@justeattakeaway/pie-webc-core'; import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement'; import { PIEInputElement } from '@justeattakeaway/pie-webc-core'; import { PropertyValues } from 'lit'; import * as React_2 from 'react'; import { TemplateResult } from 'lit-html'; declare type AriaProps = { label?: string; describedBy?: string; }; export declare type DefaultProps = ComponentDefaultProps>; export declare const defaultProps: DefaultProps; export declare const labelPlacements: readonly ["leading", "trailing"]; /** * Event name for when the switch checked state is changed. * * @constant */ export declare const ON_SWITCH_CHANGED_EVENT = "change"; export declare const PieSwitch: React_2.ForwardRefExoticComponent, "children">> & React_2.RefAttributes & PieSwitchEvents & ReactBaseType>; /** * @tagname pie-switch * @event {CustomEvent} change - when the switch checked state is changed. */ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInputElement { label: SwitchProps['label']; labelPlacement: "leading" | "trailing"; aria: SwitchProps['aria']; checked: boolean; defaultChecked: boolean; required: boolean; value: string; name: SwitchProps['name']; disabled: boolean; private _contextAria?; private input; private switchBody; focusTarget: HTMLElement; private _abortController; private _isAnimationAllowed; protected firstUpdated(changedProperties: PropertyValues): void; connectedCallback(): void; disconnectedCallback(): void; protected updated(): void; static styles: CSSResult; /** * Ensures that the form value and validation state are in sync with the component. */ private handleFormAssociation; /** * The handleChange function updates the checkbox state and emits an event for consumers. * @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`. */ private handleChange; /** * Returns a boolean value which indicates validity of the value of the component. If the value is invalid, this method also fires the invalid event on the component. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity * @returns boolean */ checkValidity(): boolean; /** * If the value is invalid, this method also fires the invalid event on the element, and (if the event isn't canceled) reports the problem to the user. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity * @returns boolean */ reportValidity(): boolean; /** * Allows a consumer to set a custom validation message on the switch. An empty string counts as valid. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity */ setCustomValidity(message: string): void; /** * Called when the containing form is reset. * Resets checked state back to defaultChecked and emits a change event when needed. */ formResetCallback(): void; /** * (Read-only) returns a ValidityState with the validity states that this element is in. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity */ get validity(): ValidityState; /** * (Read-only) Returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any). * This string is empty if the component is valid. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage */ get validationMessage(): string; private renderAriaDescription; private renderSwitchLabel; render(): TemplateResult; } declare const PieSwitch_base: GenericConstructor & GenericConstructor & typeof PieElement; declare type PieSwitchEvents = { onInvalid?: (event: Event) => void; onChange?: (event: CustomEvent) => void; }; declare type ReactBaseType = Omit, 'onChange'>; export declare interface SwitchProps { /** * The ARIA labels used for the switch. */ aria?: AriaProps; /** * Same as the HTML checked attribute - indicates whether the switch is on or off */ checked?: boolean; /** * The default checked state of the switch (not necessarily the same as the current checked state). * Used when the switch is part of a form that is reset. */ defaultChecked?: boolean; /** * Same as the HTML required attribute - indicates whether the switch must be turned or not */ required?: boolean; /** * Same as the HTML disabled attribute - indicates whether the switch is disabled or not */ disabled?: boolean; /** * The label value of the component */ label?: string; /** * The placement of the label such as leading or trailing */ labelPlacement?: typeof labelPlacements[number]; /** * Same as the HTML name attribute - indicates the name of the switch (for use with forms) */ name?: string; /** * Same as the HTML value attribute - indicates the value of the switch (for use with forms). Defaults to 'on'. */ value?: string; } export { }