@compa11y/core 0.1.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.
Files changed (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -0
  3. package/dist/announcer/index.cjs +49 -0
  4. package/dist/announcer/index.cjs.map +1 -0
  5. package/dist/announcer/index.d.cts +61 -0
  6. package/dist/announcer/index.d.ts +61 -0
  7. package/dist/announcer/index.js +4 -0
  8. package/dist/announcer/index.js.map +1 -0
  9. package/dist/aria/index.cjs +24 -0
  10. package/dist/aria/index.cjs.map +1 -0
  11. package/dist/aria/index.d.cts +176 -0
  12. package/dist/aria/index.d.ts +176 -0
  13. package/dist/aria/index.js +3 -0
  14. package/dist/aria/index.js.map +1 -0
  15. package/dist/chunk-24U5HHMC.js +309 -0
  16. package/dist/chunk-24U5HHMC.js.map +1 -0
  17. package/dist/chunk-2CQOLVQH.js +147 -0
  18. package/dist/chunk-2CQOLVQH.js.map +1 -0
  19. package/dist/chunk-2PUYKF2E.js +631 -0
  20. package/dist/chunk-2PUYKF2E.js.map +1 -0
  21. package/dist/chunk-2WF5Y6D7.js +175 -0
  22. package/dist/chunk-2WF5Y6D7.js.map +1 -0
  23. package/dist/chunk-CQXMBRLD.cjs +657 -0
  24. package/dist/chunk-CQXMBRLD.cjs.map +1 -0
  25. package/dist/chunk-HQOFVJFO.cjs +181 -0
  26. package/dist/chunk-HQOFVJFO.cjs.map +1 -0
  27. package/dist/chunk-NBGFFCIJ.cjs +314 -0
  28. package/dist/chunk-NBGFFCIJ.cjs.map +1 -0
  29. package/dist/chunk-V6TZIZZ4.cjs +158 -0
  30. package/dist/chunk-V6TZIZZ4.cjs.map +1 -0
  31. package/dist/chunk-XEGB27QF.cjs +78 -0
  32. package/dist/chunk-XEGB27QF.cjs.map +1 -0
  33. package/dist/chunk-Z7K2G6FX.js +66 -0
  34. package/dist/chunk-Z7K2G6FX.js.map +1 -0
  35. package/dist/focus/index.cjs +53 -0
  36. package/dist/focus/index.cjs.map +1 -0
  37. package/dist/focus/index.d.cts +139 -0
  38. package/dist/focus/index.d.ts +139 -0
  39. package/dist/focus/index.js +4 -0
  40. package/dist/focus/index.js.map +1 -0
  41. package/dist/index.cjs +573 -0
  42. package/dist/index.cjs.map +1 -0
  43. package/dist/index.d.cts +241 -0
  44. package/dist/index.d.ts +241 -0
  45. package/dist/index.js +343 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/keyboard/index.cjs +28 -0
  48. package/dist/keyboard/index.cjs.map +1 -0
  49. package/dist/keyboard/index.d.cts +102 -0
  50. package/dist/keyboard/index.d.ts +102 -0
  51. package/dist/keyboard/index.js +3 -0
  52. package/dist/keyboard/index.js.map +1 -0
  53. package/dist/types-DDSPmE8m.d.cts +52 -0
  54. package/dist/types-DDSPmE8m.d.ts +52 -0
  55. package/package.json +78 -0
@@ -0,0 +1,139 @@
1
+ import { F as FocusTrapOptions } from '../types-DDSPmE8m.js';
2
+
3
+ /**
4
+ * Focus Trap - Constrains focus within a container
5
+ *
6
+ * Essential for modals, dialogs, and other overlay components
7
+ */
8
+
9
+ interface FocusTrap {
10
+ activate: () => void;
11
+ deactivate: () => void;
12
+ /** Cleanup without calling onDeactivate - for use in effect cleanup */
13
+ destroy: () => void;
14
+ pause: () => void;
15
+ unpause: () => void;
16
+ isActive: () => boolean;
17
+ isPaused: () => boolean;
18
+ }
19
+ /**
20
+ * Create a focus trap for a container element
21
+ */
22
+ declare function createFocusTrap(container: HTMLElement, options?: FocusTrapOptions): FocusTrap;
23
+ /**
24
+ * Get the currently active focus trap
25
+ */
26
+ declare function getActiveFocusTrap(): FocusTrap | null;
27
+ /**
28
+ * Check if there's an active focus trap
29
+ */
30
+ declare function hasFocusTrap(): boolean;
31
+
32
+ /**
33
+ * Focus Visible Management
34
+ *
35
+ * Provides :focus-visible polyfill behavior and utilities
36
+ * for distinguishing keyboard focus from mouse/touch focus
37
+ */
38
+ type FocusSource = 'keyboard' | 'mouse' | 'touch' | 'unknown';
39
+ /**
40
+ * Initialize focus-visible tracking
41
+ * Call this once at app startup
42
+ */
43
+ declare function initFocusVisible(): () => void;
44
+ /**
45
+ * Check if current focus should be visible (keyboard-initiated)
46
+ */
47
+ declare function isFocusVisible(): boolean;
48
+ /**
49
+ * Check if an element has visible focus
50
+ */
51
+ declare function hasVisibleFocus(element: HTMLElement): boolean;
52
+ /**
53
+ * Get the source of the last focus event
54
+ */
55
+ declare function getLastFocusSource(): FocusSource;
56
+ /**
57
+ * Manually set focus as visible (useful for programmatic focus)
58
+ */
59
+ declare function setFocusVisible(element: HTMLElement, visible: boolean): void;
60
+ /**
61
+ * Focus an element with visible focus ring (keyboard-style)
62
+ */
63
+ declare function focusWithVisibleRing(element: HTMLElement, options?: FocusOptions): void;
64
+
65
+ /**
66
+ * Focus Scope Management
67
+ *
68
+ * Manages focus within a scope, supporting roving tabindex
69
+ * and programmatic focus control
70
+ */
71
+ interface FocusScopeOptions {
72
+ /** Whether to contain focus within the scope */
73
+ contain?: boolean;
74
+ /** Whether to restore focus when scope is destroyed */
75
+ restoreFocus?: boolean;
76
+ /** Whether to auto-focus the first element */
77
+ autoFocus?: boolean;
78
+ }
79
+ interface FocusScope {
80
+ /** Focus the first focusable element */
81
+ focusFirst: () => void;
82
+ /** Focus the last focusable element */
83
+ focusLast: () => void;
84
+ /** Focus the next focusable element */
85
+ focusNext: (options?: {
86
+ wrap?: boolean;
87
+ }) => void;
88
+ /** Focus the previous focusable element */
89
+ focusPrevious: (options?: {
90
+ wrap?: boolean;
91
+ }) => void;
92
+ /** Focus a specific element by index */
93
+ focusAt: (index: number) => void;
94
+ /** Get the currently focused element within scope */
95
+ getFocused: () => HTMLElement | null;
96
+ /** Get all focusable elements in the scope */
97
+ getElements: () => HTMLElement[];
98
+ /** Destroy the scope and cleanup */
99
+ destroy: () => void;
100
+ }
101
+ /**
102
+ * Create a focus scope for a container
103
+ */
104
+ declare function createFocusScope(container: HTMLElement, options?: FocusScopeOptions): FocusScope;
105
+ /**
106
+ * Roving Tabindex - Only one element is tabbable at a time
107
+ * Standard pattern for composite widgets like toolbars, menus, listboxes
108
+ */
109
+ interface RovingTabindexOptions {
110
+ /** Current active index */
111
+ initialIndex?: number;
112
+ /** Orientation for arrow key navigation */
113
+ orientation?: 'horizontal' | 'vertical' | 'both';
114
+ /** Whether to wrap around */
115
+ wrap?: boolean;
116
+ /** Called when selection changes */
117
+ onSelectionChange?: (index: number, element: HTMLElement) => void;
118
+ }
119
+ interface RovingTabindex {
120
+ /** Move to the next item */
121
+ next: () => void;
122
+ /** Move to the previous item */
123
+ previous: () => void;
124
+ /** Move to the first item */
125
+ first: () => void;
126
+ /** Move to the last item */
127
+ last: () => void;
128
+ /** Move to a specific index */
129
+ goto: (index: number) => void;
130
+ /** Get current index */
131
+ getIndex: () => number;
132
+ /** Update elements (call when DOM changes) */
133
+ update: () => void;
134
+ /** Cleanup */
135
+ destroy: () => void;
136
+ }
137
+ declare function createRovingTabindex(container: HTMLElement, selector: string, options?: RovingTabindexOptions): RovingTabindex;
138
+
139
+ export { type FocusScope, type FocusScopeOptions, type RovingTabindex, type RovingTabindexOptions, createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible };
@@ -0,0 +1,4 @@
1
+ export { createFocusScope, createFocusTrap, createRovingTabindex, focusWithVisibleRing, getActiveFocusTrap, getLastFocusSource, hasFocusTrap, hasVisibleFocus, initFocusVisible, isFocusVisible, setFocusVisible } from '../chunk-2PUYKF2E.js';
2
+ import '../chunk-Z7K2G6FX.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}