import { EventEmitter } from '../../stencil-public-runtime'; import { CheckboxOption } from './checkbox-option.interface'; import { Checkboxes } from './checkboxes.interface'; import { HintExpander } from '../ontario-hint-expander/hint-expander.interface'; import { Hint } from '../../utils/common/common.interface'; import { Caption } from '../../utils/common/input-caption/caption.interface'; import { Language } from '../../utils/common/language-types'; import { InputFocusBlurEvent, RadioAndCheckboxChangeEvent } from '../../utils/events/event-handler.interface'; import { HeaderLanguageToggleEventDetails } from '../../utils/events/common-events.interface'; /** * Ontario Checkboxes collects one or more selections from a defined option set. * * This component intentionally does not expose group-level `readOnly` or `disabled` props. * * To support accessible and understandable form completion: * - keep options and submission actions available * - use validation and error messaging to guide corrections * * For component guidance, see: * - https://designsystem.ontario.ca/components/detail/checkboxes.html * - https://designsystem.ontario.ca/developer-docs/components/ontario-checkboxes/ * * Disabled/read-only policy source: * - https://designsystem.ontario.ca/components/detail/buttons.html#disabled-buttons */ export declare class OntarioCheckboxes implements Checkboxes { element: HTMLElement; internals: ElementInternals; hintTextRef: HTMLOntarioHintTextElement | undefined; private isSyncingValue; /** * The text to display for the checkbox legend. * * @example * * */ hintExpander?: HintExpander | string; /** * The currently selected checkbox option values. * * The component keeps the host `value` in sync as users interact with the checkbox group. * If `value` is provided, it takes precedence over any `checked` flags passed through `options`. * * In HTML, pass `value` as a JSON string array. * * @example * * */ value?: string[] | string; /** * The options for the checkbox group. * * Each property will be passed in through an object in the options array. * This can either be passed in as an object directly (if using react), or as a string in HTML. * If there are multiple checkboxes in a fieldset, each checkbox will be displayed as an option. * * In the example below, the options are being passed in as a string and there are two checkboxes to be displayed in the fieldset. * * @example * * */ options: CheckboxOption[] | string; /** * This is used to determine whether the checkbox is required or not. * This prop also gets passed to the InputCaption utility to display either an optional or required flag in the label. * If no prop is set, it will default to false (optional). */ required?: boolean; /** * Set this to display an error message */ errorMessage?: string; /** * Used to add a custom function to the checkbox onChange event. */ customOnChange?: (event: globalThis.Event) => void; /** * Used to add a custom function to the checkbox onBlur event. */ customOnBlur?: (event: globalThis.Event) => void; /** * Used to add a custom function to the checkbox onFocus event. */ customOnFocus?: (event: globalThis.Event) => void; /** * Used for the `aria-describedby` value of the checkbox fieldset. This will match with the id of the hint text. */ hintTextId: string | null | undefined; /** * Instantiate an InputCaption object for internal logic use */ private captionState; /** * The hint text options are re-assigned to the internalHintText array. */ private internalHintText; /** * The hint expander options are re-assigned to the internalHintExpander array. */ private internalHintExpander; /** * The options are re-assigned to the internalOptions array. */ private internalOptions; /** * Emitted when a keyboard input or mouse event occurs when a checkbox option has been changed. */ checkboxOnChange: EventEmitter; /** * Emitted when a keyboard input event occurs when a checkbox option has lost focus. */ checkboxOnBlur: EventEmitter; /** * Emitted when a keyboard input event occurs when a checkbox option has gained focus. */ checkboxOnFocus: EventEmitter; /** * Emitted when an error message is reported to the component. */ inputErrorOccurred: EventEmitter<{ errorMessage: string; }>; /** * This listens for the `setAppLanguage` event sent from the test language toggler when it is is connected to the DOM. It is used for the initial language when the input component loads. */ handleSetAppLanguage(event: CustomEvent): void; /** * Handles an update to the language should the user request a language update from the language toggle. * @param {CustomEvent} - The language that has been selected. */ handleHeaderLanguageToggled(event: CustomEvent): void; /** * Watch for changes to the `hintText` prop. * * If a `hintText` prop is passed, the `constructHintTextObject` function will convert it to the correct format, and set the result to the `internalHintText` state. */ private parseHintText; /** * Watch for changes to the `hintExpander` prop. * * If a `hintExpander` prop is passed, it will be parsed (if it is a string), * and the result will be set to the `internalHintExpander` state. * Includes error handling for invalid JSON strings. */ private parseHintExpander; /** * Watch for changes to the `options` prop. * * If an `options` prop is passed, it will be parsed (if it is a string), and the result will be set to the `internalOptions` state. The result will be run through a validation function. * Includes error handling for invalid JSON strings */ parseOptions(): void; syncValueFromValueProp(): void; /** * Validate the `options` and make sure the `options` prop has a value. * Log a warning if user doesn't input a value for the `options`. * * @param newValue object to be validated */ validateOptions(newValue: object): void; validateName(newValue: string): void; /** * Watch for changes to the `caption` prop. * * The caption will be run through the InputCaption constructor to convert it to the correct format, and set the result to the `captionState` state. * @param newValue: Caption | string */ updateCaptionState(newValue: Caption | string): void; /** * Watch for changes to the `language` prop to render either the English or French translations */ updateLanguage(): void; broadcastInputErrorOccurredEvent(): void; /** * Function to handle checkbox events and the information pertaining to the checkbox to emit. */ private handleEvent; private emitHostValueEvent; private updateHostValue; private setFormValue; private getSelectedValues; private normalizeValue; private syncValueFromOptions; /** * If a `hintText` prop is passed, the id generated from it will be set to the internal `hintTextId` state to match with the fieldset `aria-describedBy` attribute. */ componentDidLoad(): Promise; componentWillLoad(): void; render(): any; }