All Downloads are FREE. Search and download functionalities are using the official Maven repository.

a11y-basepackage.src.field-aria-controller.d.ts Maven / Gradle / Ivy

The newest version!
/**
 * @license
 * Copyright (c) 2021 - 2024 Vaadin Ltd.
 * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
 */

/**
 * A controller for managing ARIA attributes for a field element:
 * either the component itself or slotted `` element.
 */
export class FieldAriaController {
  /**
   * The controller host element.
   */
  host: HTMLElement;

  constructor(host: HTMLElement);

  /**
   * Sets a target element to which ARIA attributes are added.
   */
  setTarget(target: HTMLElement): void;

  /**
   * Toggles the `aria-required` attribute on the target element
   * if the target is the host component (e.g. a field group).
   * Otherwise, it does nothing.
   */
  setRequired(required: boolean): void;

  /**
   * Defines the `aria-label` attribute of the target element.
   *
   * To remove the attribute, pass `null` as `label`.
   */
  setAriaLabel(label: string | null): void;

  /**
   * Links the target element with a slotted label element
   * via the target's attribute `aria-labelledby`.
   *
   * To unlink the previous slotted label element, pass `null` as `labelId`.
   */
  setLabelId(labelId: string | null, fromUser: boolean | null): void;

  /**
   * Links the target element with a slotted error element via the target's attribute:
   * - `aria-labelledby` if the target is the host component (e.g a field group).
   * - `aria-describedby` otherwise.
   *
   * To unlink the previous slotted error element, pass `null` as `errorId`.
   */
  setErrorId(errorId: string | null): void;

  /**
   * Links the target element with a slotted helper element via the target's attribute:
   * - `aria-labelledby` if the target is the host component (e.g a field group).
   * - `aria-describedby` otherwise.
   *
   * To unlink the previous slotted helper element, pass `null` as `helperId`.
   */
  setHelperId(helperId: string | null): void;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy