import { ReactiveController } from 'lit'; import { Cre8FormElement } from '../cre8-form-element'; type FormElement = Cre8FormElement & { form: HTMLFormElement; name?: string; checked?: boolean; }; /** * This Controller handles the special radio button logic. * * - Handle clicks and key presses, which involves * - Unchecking other select-tile's when this one is checked, if they are in the same form. * - Changing focus between `0` and `-1`, and moving focus correctly on key press * - checking/unchecking on spacebar * * See also https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radio_role * and https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radiogroup_role * * Also see https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-autonomous-drawbacks * * This started out as a copy of radio-field-item.ts. * * Part of the reason I extracted this was to see if I could share this logic with radio-field-item, * but that would be separate refactor. * * It might also be good for the "checkbox" mode of select-tile. * * And it might also just be a cleaner separation of concerns. */ export declare class SelectTileRadioController implements ReactiveController { private host; constructor(host: FormElement); hostConnected(): void; hostDisconnected(): void; hostUpdate(): void; /** * Find all elements that are in the same "radio button group", following the HTML 5 spec, * except that we're looking at `[role="radio"]` instead of `input[type="radio"]`. * * - They have the attribute role="radio" set * - They have the same form owner, or both have no form owner * - They're in the same tree (same document, don't look at shadow dom) * - They both have non-empty name attributes, and the names are the same * */ findAllElementsInSameRadioButtonGroup({ excludeDisabled }?: { excludeDisabled?: boolean; }): Element[]; /** * Remove checked * 1) Reset the form field to not checked * 2) Remove checked property from all items and set tabindex to -1 */ removeChecked(): void; /** * Handle clicking on the radio button * @see _checkAndFocus */ private _clickHandler; /** * Set the element to `checked` * 1) Remove `checked` and set tabindex to -1 on all elements in our radio group * 2) Set us to checked. * 3) Set our tabindex to 0 */ private _checkAndFocus; /** * Handle keydown * 1) If left or up arrow key is struck and radio field item exists before current item, * remove checked from all items and add it to the next item * 2) If right or down arrow key is struck and radio field item exists after current item, * remove checked from all items and add checked to the next item. * Focus on this item and set tabindex for when focusing out of radio field and back onto checked item. * 3) If the element is in focused, then for event emission the * current focues element should be clicked to emit event. * 4) If the Enter key is pressed, then check the radio if no other radio items are checked */ private _handleKeyDown; private _handleArrowKeys; /** * Handle Enter and Space * @see _checkAndFocus */ private _handleEnterSpace; } export default SelectTileRadioController; //# sourceMappingURL=select-tile-radio-controller.d.ts.map