@a11y-core/react 0.1.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -0
- package/dist/chunk-3WBTHTVK.js +41 -0
- package/dist/chunk-3WBTHTVK.js.map +1 -0
- package/dist/chunk-47MFBHV6.js +85 -0
- package/dist/chunk-47MFBHV6.js.map +1 -0
- package/dist/chunk-7A3IDIUB.cjs +89 -0
- package/dist/chunk-7A3IDIUB.cjs.map +1 -0
- package/dist/chunk-AZFZWGI6.cjs +383 -0
- package/dist/chunk-AZFZWGI6.cjs.map +1 -0
- package/dist/chunk-CTW5D77X.cjs +220 -0
- package/dist/chunk-CTW5D77X.cjs.map +1 -0
- package/dist/chunk-EY73HQNR.js +380 -0
- package/dist/chunk-EY73HQNR.js.map +1 -0
- package/dist/chunk-FJABCNFE.js +215 -0
- package/dist/chunk-FJABCNFE.js.map +1 -0
- package/dist/chunk-FTZ5KCOO.js +326 -0
- package/dist/chunk-FTZ5KCOO.js.map +1 -0
- package/dist/chunk-GS3H4T2O.cjs +106 -0
- package/dist/chunk-GS3H4T2O.cjs.map +1 -0
- package/dist/chunk-N6L4GLFC.cjs +45 -0
- package/dist/chunk-N6L4GLFC.cjs.map +1 -0
- package/dist/chunk-N774QCHE.js +234 -0
- package/dist/chunk-N774QCHE.js.map +1 -0
- package/dist/chunk-OSHIYZCZ.cjs +386 -0
- package/dist/chunk-OSHIYZCZ.cjs.map +1 -0
- package/dist/chunk-SRJSGDIA.js +373 -0
- package/dist/chunk-SRJSGDIA.js.map +1 -0
- package/dist/chunk-THB5U7YC.cjs +338 -0
- package/dist/chunk-THB5U7YC.cjs.map +1 -0
- package/dist/chunk-U6DUSMEA.js +99 -0
- package/dist/chunk-U6DUSMEA.js.map +1 -0
- package/dist/chunk-WDCYEMBO.cjs +245 -0
- package/dist/chunk-WDCYEMBO.cjs.map +1 -0
- package/dist/components/combobox/index.cjs +31 -0
- package/dist/components/combobox/index.cjs.map +1 -0
- package/dist/components/combobox/index.d.cts +55 -0
- package/dist/components/combobox/index.d.ts +55 -0
- package/dist/components/combobox/index.js +6 -0
- package/dist/components/combobox/index.js.map +1 -0
- package/dist/components/dialog/index.cjs +46 -0
- package/dist/components/dialog/index.cjs.map +1 -0
- package/dist/components/dialog/index.d.cts +84 -0
- package/dist/components/dialog/index.d.ts +84 -0
- package/dist/components/dialog/index.js +5 -0
- package/dist/components/dialog/index.js.map +1 -0
- package/dist/components/menu/index.cjs +46 -0
- package/dist/components/menu/index.cjs.map +1 -0
- package/dist/components/menu/index.d.cts +80 -0
- package/dist/components/menu/index.d.ts +80 -0
- package/dist/components/menu/index.js +5 -0
- package/dist/components/menu/index.js.map +1 -0
- package/dist/components/tabs/index.cjs +35 -0
- package/dist/components/tabs/index.cjs.map +1 -0
- package/dist/components/tabs/index.d.cts +65 -0
- package/dist/components/tabs/index.d.ts +65 -0
- package/dist/components/tabs/index.js +6 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/toast/index.cjs +24 -0
- package/dist/components/toast/index.cjs.map +1 -0
- package/dist/components/toast/index.d.cts +49 -0
- package/dist/components/toast/index.d.ts +49 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/index.js.map +1 -0
- package/dist/index.cjs +698 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +402 -0
- package/dist/index.d.ts +402 -0
- package/dist/index.js +426 -0
- package/dist/index.js.map +1 -0
- package/package.json +89 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { FocusTrapOptions, AnnouncerOptions, KeyboardHandlers } from '@a11y-core/core';
|
|
4
|
+
export { announce, announceAssertive, announceError, announcePolite, announceProgress, announceStatus, aria, buildAriaProps, checks, createComponentWarnings, hasAccessibleName, isAndroid, isBrowser, isIOS, isMac, mergeAriaIds, prefersDarkMode, prefersHighContrast, prefersReducedMotion, setWarningHandler, warn } from '@a11y-core/core';
|
|
5
|
+
export { DialogCompound as Dialog, DialogActions, DialogActionsProps, Dialog as DialogBase, DialogClose, DialogCloseProps, DialogContent, DialogContentProps, DialogContextValue, DialogDescription, DialogDescriptionProps, DialogProps, DialogTitle, DialogTitleProps, DialogTrigger, DialogTriggerProps, useDialogContext } from './components/dialog/index.js';
|
|
6
|
+
export { ActionMenuCompound as ActionMenu, ActionMenu as ActionMenuBase, ActionMenuContent, ActionMenuContentProps, ActionMenuContextValue, ActionMenuItem, ActionMenuItemProps, ActionMenuLabel, ActionMenuLabelProps, ActionMenuProps, ActionMenuSeparator, ActionMenuSeparatorProps, ActionMenuTrigger, ActionMenuTriggerProps, useActionMenuContext } from './components/menu/index.js';
|
|
7
|
+
export { Tab, TabList, TabListProps, TabPanel, TabPanelProps, TabProps, TabsCompound as Tabs, Tabs as TabsBase, TabsContextValue, TabsProps, useTabsContext } from './components/tabs/index.js';
|
|
8
|
+
export { Toast, ToastProvider, ToastProviderProps, ToastType, ToastViewport, ToastViewportProps, useToast, useToastHelpers } from './components/toast/index.js';
|
|
9
|
+
export { ComboboxCompound as Combobox, Combobox as ComboboxBase, ComboboxInput, ComboboxInputProps, ComboboxListbox, ComboboxListboxProps, ComboboxOption, ComboboxOptionProps, ComboboxOption as ComboboxOptionType, ComboboxProps } from './components/combobox/index.js';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate a unique ID for accessibility purposes
|
|
14
|
+
*
|
|
15
|
+
* Uses React's useId when available, with a fallback for SSR
|
|
16
|
+
*/
|
|
17
|
+
declare function useId(prefix?: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate multiple related IDs for a component
|
|
20
|
+
*/
|
|
21
|
+
declare function useIds<T extends readonly string[]>(parts: T, prefix?: string): Record<T[number], string>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a scoped ID generator for complex components
|
|
24
|
+
*/
|
|
25
|
+
declare function useIdScope(componentName: string): {
|
|
26
|
+
id: string;
|
|
27
|
+
generate: (suffix: string) => string;
|
|
28
|
+
generateMultiple: <T extends readonly string[]>(parts: T) => Record<T[number], string>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
interface UseFocusTrapOptions extends FocusTrapOptions {
|
|
32
|
+
/** Whether the focus trap is active */
|
|
33
|
+
active?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to create a focus trap for modals, dialogs, etc.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* function Modal({ isOpen, onClose }) {
|
|
41
|
+
* const trapRef = useFocusTrap({
|
|
42
|
+
* active: isOpen,
|
|
43
|
+
* onDeactivate: onClose,
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* return (
|
|
47
|
+
* <div ref={trapRef} role="dialog">
|
|
48
|
+
* <button>Close</button>
|
|
49
|
+
* </div>
|
|
50
|
+
* );
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare function useFocusTrap<T extends HTMLElement = HTMLDivElement>(options?: UseFocusTrapOptions): React.RefObject<T>;
|
|
55
|
+
/**
|
|
56
|
+
* Imperative focus trap controls
|
|
57
|
+
*/
|
|
58
|
+
declare function useFocusTrapControls<T extends HTMLElement = HTMLDivElement>(options?: Omit<FocusTrapOptions, 'onDeactivate'>): {
|
|
59
|
+
ref: React$1.MutableRefObject<T | null>;
|
|
60
|
+
activate: () => void;
|
|
61
|
+
deactivate: () => void;
|
|
62
|
+
pause: () => void;
|
|
63
|
+
unpause: () => void;
|
|
64
|
+
isActive: () => boolean;
|
|
65
|
+
isPaused: () => boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Hook for screen reader announcements
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```tsx
|
|
73
|
+
* function SearchResults({ results }) {
|
|
74
|
+
* const { announce } = useAnnouncer();
|
|
75
|
+
*
|
|
76
|
+
* useEffect(() => {
|
|
77
|
+
* announce(`Found ${results.length} results`);
|
|
78
|
+
* }, [results.length, announce]);
|
|
79
|
+
*
|
|
80
|
+
* return <ul>...</ul>;
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare function useAnnouncer(): {
|
|
85
|
+
announce: (message: string, options?: AnnouncerOptions) => void;
|
|
86
|
+
polite: (message: string, options?: Omit<AnnouncerOptions, "politeness">) => void;
|
|
87
|
+
assertive: (message: string, options?: Omit<AnnouncerOptions, "politeness">) => void;
|
|
88
|
+
queue: (message: string, options?: AnnouncerOptions & {
|
|
89
|
+
debounce?: number;
|
|
90
|
+
}) => void;
|
|
91
|
+
clear: () => void;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Announce a message when a value changes
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```tsx
|
|
98
|
+
* function Counter({ count }) {
|
|
99
|
+
* useAnnounceOnChange(count, (value) => `Count is now ${value}`);
|
|
100
|
+
* return <span>{count}</span>;
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
declare function useAnnounceOnChange<T>(value: T, getMessage: (value: T) => string, options?: AnnouncerOptions & {
|
|
105
|
+
skipInitial?: boolean;
|
|
106
|
+
}): void;
|
|
107
|
+
/**
|
|
108
|
+
* Announce loading states
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```tsx
|
|
112
|
+
* function DataList({ isLoading }) {
|
|
113
|
+
* useAnnounceLoading(isLoading, {
|
|
114
|
+
* loadingMessage: 'Loading data...',
|
|
115
|
+
* loadedMessage: 'Data loaded',
|
|
116
|
+
* });
|
|
117
|
+
*
|
|
118
|
+
* return <div>...</div>;
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare function useAnnounceLoading(isLoading: boolean, options?: {
|
|
123
|
+
loadingMessage?: string;
|
|
124
|
+
loadedMessage?: string;
|
|
125
|
+
errorMessage?: string;
|
|
126
|
+
error?: Error | null;
|
|
127
|
+
}): void;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Hook for keyboard event handling
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* function Menu({ items, onSelect }) {
|
|
135
|
+
* const keyboardProps = useKeyboard({
|
|
136
|
+
* ArrowDown: () => focusNext(),
|
|
137
|
+
* ArrowUp: () => focusPrevious(),
|
|
138
|
+
* Enter: () => onSelect(focused),
|
|
139
|
+
* Escape: () => close(),
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* return <ul {...keyboardProps}>...</ul>;
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function useKeyboard(handlers: KeyboardHandlers, options?: {
|
|
147
|
+
preventDefault?: boolean;
|
|
148
|
+
stopPropagation?: boolean;
|
|
149
|
+
disabled?: boolean;
|
|
150
|
+
}): {
|
|
151
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Pre-built keyboard patterns for common widgets
|
|
155
|
+
*/
|
|
156
|
+
declare function useMenuKeyboard(options: {
|
|
157
|
+
onUp?: () => void;
|
|
158
|
+
onDown?: () => void;
|
|
159
|
+
onEnter?: () => void;
|
|
160
|
+
onEscape?: () => void;
|
|
161
|
+
onHome?: () => void;
|
|
162
|
+
onEnd?: () => void;
|
|
163
|
+
disabled?: boolean;
|
|
164
|
+
}): {
|
|
165
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
166
|
+
};
|
|
167
|
+
declare function useTabsKeyboard(options: {
|
|
168
|
+
onLeft?: () => void;
|
|
169
|
+
onRight?: () => void;
|
|
170
|
+
onHome?: () => void;
|
|
171
|
+
onEnd?: () => void;
|
|
172
|
+
disabled?: boolean;
|
|
173
|
+
}): {
|
|
174
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
175
|
+
};
|
|
176
|
+
declare function useGridKeyboard(options: {
|
|
177
|
+
onUp?: () => void;
|
|
178
|
+
onDown?: () => void;
|
|
179
|
+
onLeft?: () => void;
|
|
180
|
+
onRight?: () => void;
|
|
181
|
+
onHome?: () => void;
|
|
182
|
+
onEnd?: () => void;
|
|
183
|
+
onCtrlHome?: () => void;
|
|
184
|
+
onCtrlEnd?: () => void;
|
|
185
|
+
disabled?: boolean;
|
|
186
|
+
}): {
|
|
187
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Hook for type-ahead search in menus/listboxes
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```tsx
|
|
194
|
+
* function Listbox({ items }) {
|
|
195
|
+
* const { onKeyDown, reset } = useTypeAhead(
|
|
196
|
+
* items.map(i => i.label),
|
|
197
|
+
* (match) => focusItem(match)
|
|
198
|
+
* );
|
|
199
|
+
*
|
|
200
|
+
* return <ul onKeyDown={onKeyDown}>...</ul>;
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function useTypeAhead(items: string[], onMatch: (match: string) => void, options?: {
|
|
205
|
+
timeout?: number;
|
|
206
|
+
disabled?: boolean;
|
|
207
|
+
}): {
|
|
208
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
209
|
+
reset: () => void;
|
|
210
|
+
getSearch: () => string;
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Hook for tracking which key is currently pressed
|
|
214
|
+
* Useful for showing keyboard shortcuts or modifier states
|
|
215
|
+
*/
|
|
216
|
+
declare function useKeyPressed(targetKey: string): boolean;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Hook to detect if focus should be visible (keyboard navigation)
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```tsx
|
|
223
|
+
* function Button({ children }) {
|
|
224
|
+
* const { isFocusVisible, focusProps } = useFocusVisible();
|
|
225
|
+
*
|
|
226
|
+
* return (
|
|
227
|
+
* <button
|
|
228
|
+
* {...focusProps}
|
|
229
|
+
* className={isFocusVisible ? 'focus-ring' : ''}
|
|
230
|
+
* >
|
|
231
|
+
* {children}
|
|
232
|
+
* </button>
|
|
233
|
+
* );
|
|
234
|
+
* }
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
declare function useFocusVisible(): {
|
|
238
|
+
isFocusVisible: boolean;
|
|
239
|
+
focusProps: {
|
|
240
|
+
onFocus: () => void;
|
|
241
|
+
onBlur: () => void;
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Hook for managing focus on a specific element
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```tsx
|
|
249
|
+
* function Combobox() {
|
|
250
|
+
* const inputRef = useFocusManager<HTMLInputElement>({
|
|
251
|
+
* autoFocus: true,
|
|
252
|
+
* });
|
|
253
|
+
*
|
|
254
|
+
* return <input ref={inputRef} />;
|
|
255
|
+
* }
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
declare function useFocusManager<T extends HTMLElement = HTMLElement>(options?: {
|
|
259
|
+
autoFocus?: boolean;
|
|
260
|
+
restoreFocus?: boolean;
|
|
261
|
+
focusVisible?: boolean;
|
|
262
|
+
}): (node: T | null) => void;
|
|
263
|
+
/**
|
|
264
|
+
* Focus an element programmatically with proper focus-visible handling
|
|
265
|
+
*/
|
|
266
|
+
declare function useFocusControl<T extends HTMLElement = HTMLElement>(): {
|
|
267
|
+
ref: (_node: T | null) => void;
|
|
268
|
+
focus: (options?: {
|
|
269
|
+
visible?: boolean;
|
|
270
|
+
}) => void;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Track if an element has focus
|
|
274
|
+
*/
|
|
275
|
+
declare function useFocusWithin<T extends HTMLElement = HTMLElement>(): {
|
|
276
|
+
ref: (instance: T | null) => void | React$1.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React$1.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES];
|
|
277
|
+
hasFocus: boolean;
|
|
278
|
+
focusWithinProps: {
|
|
279
|
+
onFocus: () => void;
|
|
280
|
+
onBlur: (event: React.FocusEvent) => void;
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
interface UseRovingTabindexOptions {
|
|
285
|
+
/** Initial active index */
|
|
286
|
+
initialIndex?: number;
|
|
287
|
+
/** Whether navigation wraps around */
|
|
288
|
+
wrap?: boolean;
|
|
289
|
+
/** Orientation for arrow keys */
|
|
290
|
+
orientation?: 'horizontal' | 'vertical' | 'both';
|
|
291
|
+
/** Called when active index changes */
|
|
292
|
+
onChange?: (index: number) => void;
|
|
293
|
+
}
|
|
294
|
+
interface RovingTabindexItem {
|
|
295
|
+
/** Props to spread on the item element */
|
|
296
|
+
props: {
|
|
297
|
+
tabIndex: number;
|
|
298
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
299
|
+
onFocus: () => void;
|
|
300
|
+
};
|
|
301
|
+
/** Whether this item is the active/focusable one */
|
|
302
|
+
isActive: boolean;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Hook for roving tabindex pattern
|
|
306
|
+
*
|
|
307
|
+
* @example
|
|
308
|
+
* ```tsx
|
|
309
|
+
* function Toolbar() {
|
|
310
|
+
* const { getItemProps, activeIndex } = useRovingTabindex({
|
|
311
|
+
* itemCount: 3,
|
|
312
|
+
* orientation: 'horizontal',
|
|
313
|
+
* });
|
|
314
|
+
*
|
|
315
|
+
* return (
|
|
316
|
+
* <div role="toolbar">
|
|
317
|
+
* <button {...getItemProps(0)}>Cut</button>
|
|
318
|
+
* <button {...getItemProps(1)}>Copy</button>
|
|
319
|
+
* <button {...getItemProps(2)}>Paste</button>
|
|
320
|
+
* </div>
|
|
321
|
+
* );
|
|
322
|
+
* }
|
|
323
|
+
* ```
|
|
324
|
+
*/
|
|
325
|
+
declare function useRovingTabindex(options: UseRovingTabindexOptions & {
|
|
326
|
+
itemCount: number;
|
|
327
|
+
}): {
|
|
328
|
+
activeIndex: number;
|
|
329
|
+
setActiveIndex: (index: number) => void;
|
|
330
|
+
getItemProps: (index: number) => {
|
|
331
|
+
ref: (el: HTMLElement | null) => void;
|
|
332
|
+
tabIndex: number;
|
|
333
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
334
|
+
onFocus: () => void;
|
|
335
|
+
};
|
|
336
|
+
first: () => void;
|
|
337
|
+
last: () => void;
|
|
338
|
+
next: () => void;
|
|
339
|
+
previous: () => void;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Simplified roving tabindex for items with known IDs
|
|
343
|
+
*/
|
|
344
|
+
declare function useRovingTabindexMap<T extends string>(ids: T[], options?: Omit<UseRovingTabindexOptions, 'itemCount'>): {
|
|
345
|
+
activeId: T | undefined;
|
|
346
|
+
getItemProps: (id: T) => {
|
|
347
|
+
ref: (el: HTMLElement | null) => void;
|
|
348
|
+
tabIndex: number;
|
|
349
|
+
onKeyDown: (event: React.KeyboardEvent) => void;
|
|
350
|
+
onFocus: () => void;
|
|
351
|
+
};
|
|
352
|
+
setActiveId: (id: T) => void;
|
|
353
|
+
activeIndex: number;
|
|
354
|
+
setActiveIndex: (index: number) => void;
|
|
355
|
+
first: () => void;
|
|
356
|
+
last: () => void;
|
|
357
|
+
next: () => void;
|
|
358
|
+
previous: () => void;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
interface SwitchProps extends Omit<React__default.ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'role'> {
|
|
362
|
+
/** Controlled checked state */
|
|
363
|
+
checked?: boolean;
|
|
364
|
+
/** Default checked state (uncontrolled) */
|
|
365
|
+
defaultChecked?: boolean;
|
|
366
|
+
/** Called when the switch state changes */
|
|
367
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
368
|
+
/** Accessible label for the switch (renders visible label next to switch) */
|
|
369
|
+
label?: string;
|
|
370
|
+
/** Whether the switch is disabled */
|
|
371
|
+
disabled?: boolean;
|
|
372
|
+
/** Remove default styles to allow full customization via className */
|
|
373
|
+
unstyled?: boolean;
|
|
374
|
+
/** Custom class name */
|
|
375
|
+
className?: string;
|
|
376
|
+
/** Size variant */
|
|
377
|
+
size?: 'sm' | 'md' | 'lg';
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Switch component - An accessible toggle switch (on/off control)
|
|
381
|
+
*
|
|
382
|
+
* Follows WAI-ARIA Switch pattern with proper keyboard support and screen reader announcements.
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* ```tsx
|
|
386
|
+
* // Uncontrolled
|
|
387
|
+
* <Switch defaultChecked={true} label="Enable notifications" />
|
|
388
|
+
*
|
|
389
|
+
* // Controlled
|
|
390
|
+
* <Switch
|
|
391
|
+
* checked={enabled}
|
|
392
|
+
* onCheckedChange={setEnabled}
|
|
393
|
+
* aria-label="Dark mode"
|
|
394
|
+
* />
|
|
395
|
+
*
|
|
396
|
+
* // With visible label
|
|
397
|
+
* <Switch checked={enabled} onCheckedChange={setEnabled} label="Dark mode" />
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
declare const Switch: React__default.ForwardRefExoticComponent<SwitchProps & React__default.RefAttributes<HTMLButtonElement>>;
|
|
401
|
+
|
|
402
|
+
export { type RovingTabindexItem, Switch, type SwitchProps, type UseFocusTrapOptions, type UseRovingTabindexOptions, useAnnounceLoading, useAnnounceOnChange, useAnnouncer, useFocusControl, useFocusManager, useFocusTrap, useFocusTrapControls, useFocusVisible, useFocusWithin, useGridKeyboard, useId, useIdScope, useIds, useKeyPressed, useKeyboard, useMenuKeyboard, useRovingTabindex, useRovingTabindexMap, useTabsKeyboard, useTypeAhead };
|