@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
64 lines (60 loc) • 1.75 kB
text/typescript
import { ReactNode } from 'react';
type Level = 'assertive' | 'polite';
export interface CompoundProps {
announce: ScreenReaderAnnouncerAnnounce;
isRegistered: ScreenReaderAnnouncerIsRegistered;
}
type AnnounceOptions = {
/**
* A message to announce with a screen reader. It should not contain any element with an aria-live set to it.
*/
body: ReactNode;
/**
* The aria-live value for the announcement
* Defaults to "polite"
*/
level?: Level;
/**
* The time in ms between triggering an announcement, and the announcement being available in the DOM
* Avoids issues with browser compatibility (see https://patrickhlauke.github.io/aria/tests/live-regions/)
* Defaults to 150
*/
delay?: number;
/**
* The time in ms between the announcement being available in the DOM and it being removed
* Should be a large enough number for the entire announcement to be read out
* Defaults to 20,000
*/
timeout?: number;
};
type ScreenReaderAnnouncerAnnounce = (options: AnnounceOptions, announcerIdentity?: string) => void;
type ScreenReaderAnnouncerIsRegistered = (announcerIdentity: string) => boolean;
type Announce = (options: AnnounceOptions) => void;
type Clear = (options: { messageIdentity: string }) => void;
type Message = {
messageIdentity: string;
body: ReactNode;
level: Level;
delay: number;
timeout: number;
};
type AnnouncementProps = {
identity: string;
body: ReactNode;
level: Level;
delay: number;
timeout: number;
clear: Clear;
};
type AnnouncerProps = { identity?: string };
export type {
ScreenReaderAnnouncerAnnounce,
ScreenReaderAnnouncerIsRegistered,
Level,
AnnounceOptions,
Announce,
Clear,
Message,
AnnouncementProps,
AnnouncerProps,
};