UNPKG

4.19 kBTypeScriptView Raw
1import type { AriaAttributes } from 'react';
2import { ActionMeta, GroupBase, InitialInputFocusedActionMeta, OnChangeValue, Options, OptionsOrGroups } from '../types';
3export declare type OptionContext = 'menu' | 'value';
4export declare type GuidanceContext = 'menu' | 'input' | 'value';
5export declare type AriaSelection<Option, IsMulti extends boolean> = InitialInputFocusedActionMeta<Option, IsMulti> | (ActionMeta<Option> & {
6 value: OnChangeValue<Option, IsMulti>;
7 option?: Option;
8 options?: Options<Option>;
9});
10export interface AriaGuidanceProps {
11 /** String value of selectProp aria-label */
12 'aria-label': AriaAttributes['aria-label'];
13 /** String indicating user's current context and available keyboard interactivity */
14 context: GuidanceContext;
15 /** Boolean value of selectProp isSearchable */
16 isSearchable: boolean;
17 /** Boolean value of selectProp isMulti */
18 isMulti: boolean;
19 /** Boolean value of selectProp isDisabled */
20 isDisabled: boolean | null;
21 /** Boolean value of selectProp tabSelectsValue */
22 tabSelectsValue: boolean;
23 /** Boolean value indicating if user focused the input for the first time */
24 isInitialFocus: boolean;
25}
26export declare type AriaOnChangeProps<Option, IsMulti extends boolean> = AriaSelection<Option, IsMulti> & {
27 /** String derived label from selected or removed option/value */
28 label: string;
29 /** Array of labels derived from multiple selected or cleared options */
30 labels: string[];
31 /** Boolean indicating if the selected menu option is disabled */
32 isDisabled: boolean | null;
33};
34export interface AriaOnFilterProps {
35 /** String indicating current inputValue of the input */
36 inputValue: string;
37 /** String derived from selectProp screenReaderStatus */
38 resultsMessage: string;
39}
40export interface AriaOnFocusProps<Option, Group extends GroupBase<Option>> {
41 /** String indicating whether the option was focused in the menu or as (multi-) value */
42 context: OptionContext;
43 /** Option that is being focused */
44 focused: Option;
45 /** Boolean indicating whether focused menu option has been disabled */
46 isDisabled: boolean;
47 /** Boolean indicating whether focused menu option is an already selected option */
48 isSelected: boolean;
49 /** String derived label from focused option/value */
50 label: string;
51 /** Options provided as props to Select used to determine indexing */
52 options: OptionsOrGroups<Option, Group>;
53 /** selected option(s) of the Select */
54 selectValue: Options<Option>;
55 /** Boolean indicating whether user uses Apple device */
56 isAppleDevice: boolean;
57}
58export declare type AriaGuidance = (props: AriaGuidanceProps) => string;
59export declare type AriaOnChange<Option, IsMulti extends boolean> = (props: AriaOnChangeProps<Option, IsMulti>) => string;
60export declare type AriaOnFilter = (props: AriaOnFilterProps) => string;
61export declare type AriaOnFocus<Option, Group extends GroupBase<Option> = GroupBase<Option>> = (props: AriaOnFocusProps<Option, Group>) => string;
62export interface AriaLiveMessages<Option, IsMulti extends boolean, Group extends GroupBase<Option>> {
63 /** Guidance message used to convey component state and specific keyboard interactivity */
64 guidance?: (props: AriaGuidanceProps) => string;
65 /** OnChange message used to convey changes to value but also called when user selects disabled option */
66 onChange?: (props: AriaOnChangeProps<Option, IsMulti>) => string;
67 /** OnFilter message used to convey information about filtered results displayed in the menu */
68 onFilter?: (props: AriaOnFilterProps) => string;
69 /** OnFocus message used to convey information about the currently focused option or value */
70 onFocus?: (props: AriaOnFocusProps<Option, Group>) => string;
71}
72export declare const defaultAriaLiveMessages: {
73 guidance: (props: AriaGuidanceProps) => string;
74 onChange: <Option, IsMulti extends boolean>(props: AriaOnChangeProps<Option, IsMulti>) => string;
75 onFocus: <Option_1, Group extends GroupBase<Option_1>>(props: AriaOnFocusProps<Option_1, Group>) => string;
76 onFilter: (props: AriaOnFilterProps) => string;
77};