@a.nemreen/a11y 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.
@@ -0,0 +1,228 @@
1
+ /** One-tap accessibility presets (compose primitives + settings). */
2
+ type A11yBundle = 'epilepsy-safe' | 'visually-impaired' | 'cognitive-disability' | 'motor-impaired' | 'colorblind' | 'dyslexia-friendly' | 'adhd-friendly';
3
+ /** Primitive toggles stamped on `data-a11y`. */
4
+ type A11yMode = 'reduce-motion' | 'highlight-links' | 'highlight-titles' | 'high-contrast' | 'dyslexia' | 'reading-mask' | 'motor-targets' | A11yBundle;
5
+ type A11yVisualFilter = 'none' | 'boost-contrast' | 'monochrome' | 'high-contrast' | 'high-saturation' | 'low-saturation' | 'deuteranopia';
6
+ type A11yTextAlign = 'default' | 'start' | 'end' | 'justify';
7
+ type A11yLineHeight = 'normal' | '1.6' | '1.8' | '2.0';
8
+ type A11yLetterSpacing = '0' | '0.04em' | '0.08em' | '0.12em';
9
+ type A11yWordSpacing = '0' | '0.16em' | '0.32em' | '0.48em';
10
+ type A11yLocale = 'ar' | 'en';
11
+ type A11yPosition = 'end' | 'start' | 'left' | 'right';
12
+ interface A11yMountOptions {
13
+ /** FAB edge. Default: `end`. */
14
+ position?: A11yPosition;
15
+ /** 0-based FAB dock slot (bottom → top). Default: `0`. */
16
+ stack?: number;
17
+ /** UI locale. Default: `auto` (from `<html lang>` / `data-locale`). */
18
+ locale?: A11yLocale | 'auto';
19
+ /** localStorage key. Default: `dga-a11y`. */
20
+ storageKey?: string;
21
+ /** Mount root. Default: `document.body`. */
22
+ root?: HTMLElement;
23
+ /** Skip injecting the floating FAB/panel (controller-only). */
24
+ headless?: boolean;
25
+ }
26
+ interface A11yPersisted {
27
+ modes?: A11yMode[];
28
+ visualFilter?: A11yVisualFilter;
29
+ fontStep?: number;
30
+ textAlign?: A11yTextAlign;
31
+ lineHeight?: A11yLineHeight;
32
+ letterSpacing?: A11yLetterSpacing;
33
+ wordSpacing?: A11yWordSpacing;
34
+ maskBand?: number;
35
+ maskY?: number;
36
+ }
37
+ type A11yListener = () => void;
38
+
39
+ declare const A11Y_BUNDLES: A11yBundle[];
40
+ declare const BUNDLE_PRIMITIVES: Record<A11yBundle, A11yMode[]>;
41
+ declare class A11yController {
42
+ private readonly doc;
43
+ private readonly storageKey;
44
+ private readonly listeners;
45
+ private liveRegion;
46
+ private opener;
47
+ private mqMotion;
48
+ private mqContrast;
49
+ private localeObserver;
50
+ private localeOverride;
51
+ private destroyed;
52
+ isOpen: boolean;
53
+ modes: Set<A11yMode>;
54
+ visualFilter: A11yVisualFilter;
55
+ fontStep: number;
56
+ textAlign: A11yTextAlign;
57
+ lineHeight: A11yLineHeight;
58
+ letterSpacing: A11yLetterSpacing;
59
+ wordSpacing: A11yWordSpacing;
60
+ maskBand: number;
61
+ maskY: number;
62
+ locale: A11yLocale;
63
+ constructor(options?: {
64
+ storageKey?: string;
65
+ locale?: A11yLocale | 'auto';
66
+ document?: Document;
67
+ });
68
+ subscribe(listener: A11yListener): () => void;
69
+ private emit;
70
+ private notify;
71
+ effectiveModes(): Set<A11yMode>;
72
+ hasEffectiveMode(mode: A11yMode): boolean;
73
+ open(opener?: HTMLElement | null): void;
74
+ close(): void;
75
+ toggle(opener?: HTMLElement | null): void;
76
+ hasMode(mode: A11yMode): boolean;
77
+ isBundle(mode: A11yMode): mode is A11yBundle;
78
+ toggleMode(mode: A11yMode): void;
79
+ setMode(mode: A11yMode, enabled: boolean): void;
80
+ setVisualFilter(filter: A11yVisualFilter): void;
81
+ stepFontStep(delta: number): void;
82
+ stepTextAlign(delta: number): void;
83
+ stepLineHeight(delta: number): void;
84
+ stepLetterSpacing(delta: number): void;
85
+ stepWordSpacing(delta: number): void;
86
+ adjustMaskBand(delta: number): void;
87
+ setMaskY(y: number): void;
88
+ reset(): void;
89
+ announce(msg: string): void;
90
+ toggleLocale(): A11yLocale;
91
+ activeModeCount(section: 'modes' | 'readable' | 'visual'): number;
92
+ activeSettingCount(): number;
93
+ destroy(): void;
94
+ private applyBundleExtras;
95
+ private ensureDyslexiaFont;
96
+ private applyToDocument;
97
+ private persist;
98
+ private hydrate;
99
+ private onOsChange;
100
+ private bindOsPreferences;
101
+ private readDomLocale;
102
+ private bindLocaleObserver;
103
+ private ensureLiveRegion;
104
+ }
105
+
106
+ interface SkipLinkOptions {
107
+ href?: string;
108
+ label?: string;
109
+ root?: HTMLElement;
110
+ }
111
+ /** Visually hidden until focused — first tab stop for keyboard users. */
112
+ declare function createSkipLink(options?: SkipLinkOptions): HTMLAnchorElement;
113
+
114
+ interface A11yWidgetOptions {
115
+ position?: A11yPosition;
116
+ stack?: number;
117
+ root?: HTMLElement;
118
+ }
119
+ declare class A11yWidget {
120
+ private readonly ctrl;
121
+ private readonly position;
122
+ private readonly stack;
123
+ private readonly mountRoot;
124
+ private rootEl;
125
+ private unsub;
126
+ private resetArmed;
127
+ private resetTimer;
128
+ private draggingMask;
129
+ private onKeyDown;
130
+ private onPointerMove;
131
+ private onPointerUp;
132
+ constructor(ctrl: A11yController, options?: A11yWidgetOptions);
133
+ mount(): void;
134
+ destroy(): void;
135
+ private copy;
136
+ private fabBottom;
137
+ private activeChips;
138
+ private render;
139
+ private renderPanel;
140
+ private renderSteppers;
141
+ private renderMask;
142
+ private bindEvents;
143
+ private onReset;
144
+ private handleKey;
145
+ }
146
+
147
+ interface A11yCopy {
148
+ open: string;
149
+ close: string;
150
+ panelLabel: string;
151
+ title: string;
152
+ sectionActive: string;
153
+ sectionProfiles: string;
154
+ sectionAdjust: string;
155
+ sectionFilters: string;
156
+ profilesHint: string;
157
+ chipJump: string;
158
+ stepDecrease: string;
159
+ stepIncrease: string;
160
+ reset: string;
161
+ resetConfirm: string;
162
+ announcedReset: string;
163
+ fontSize: string;
164
+ dyslexia: string;
165
+ highlightTitles: string;
166
+ highlightLinks: string;
167
+ readingMask: string;
168
+ reduceMotion: string;
169
+ textAlign: string;
170
+ lineHeight: string;
171
+ letterSpacing: string;
172
+ wordSpacing: string;
173
+ filterBoost: string;
174
+ filterMono: string;
175
+ filterHigh: string;
176
+ filterHighSat: string;
177
+ filterLowSat: string;
178
+ filterDeutan: string;
179
+ maskToolbar: string;
180
+ maskSmaller: string;
181
+ maskLarger: string;
182
+ maskDrag: string;
183
+ maskClose: string;
184
+ stateOn: string;
185
+ stateOff: string;
186
+ defaultValue: string;
187
+ fontLevels: string[];
188
+ alignLevels: string[];
189
+ lineLevels: string[];
190
+ letterLevels: string[];
191
+ wordLevels: string[];
192
+ bundles: Record<A11yBundle, {
193
+ label: string;
194
+ desc: string;
195
+ }>;
196
+ }
197
+ declare function getCopy(locale: A11yLocale): A11yCopy;
198
+
199
+ interface AccessibilityInstance {
200
+ controller: A11yController;
201
+ widget: A11yWidget | null;
202
+ open: () => void;
203
+ close: () => void;
204
+ toggle: () => void;
205
+ toggleMode: A11yController['toggleMode'];
206
+ setMode: A11yController['setMode'];
207
+ setVisualFilter: A11yController['setVisualFilter'];
208
+ reset: () => void;
209
+ announce: A11yController['announce'];
210
+ toggleLocale: A11yController['toggleLocale'];
211
+ destroy: () => void;
212
+ }
213
+ /**
214
+ * Mount the accessibility tools widget (or headless controller).
215
+ * Safe to call once; subsequent calls return the existing instance.
216
+ */
217
+ declare function mount(options?: A11yMountOptions): AccessibilityInstance;
218
+ declare function getInstance(): AccessibilityInstance | null;
219
+ declare function destroy(): void;
220
+ /** Convenience namespace matching the plan API. */
221
+ declare const Accessibility: {
222
+ mount: typeof mount;
223
+ destroy: typeof destroy;
224
+ getInstance: typeof getInstance;
225
+ createSkipLink: typeof createSkipLink;
226
+ };
227
+
228
+ export { A11Y_BUNDLES, type A11yBundle, A11yController, type A11yLetterSpacing, type A11yLineHeight, type A11yLocale, type A11yMode, type A11yMountOptions, type A11yPersisted, type A11yPosition, type A11yTextAlign, type A11yVisualFilter, A11yWidget, type A11yWordSpacing, Accessibility, type AccessibilityInstance, BUNDLE_PRIMITIVES, createSkipLink, destroy, getCopy, getInstance, mount };
@@ -0,0 +1,228 @@
1
+ /** One-tap accessibility presets (compose primitives + settings). */
2
+ type A11yBundle = 'epilepsy-safe' | 'visually-impaired' | 'cognitive-disability' | 'motor-impaired' | 'colorblind' | 'dyslexia-friendly' | 'adhd-friendly';
3
+ /** Primitive toggles stamped on `data-a11y`. */
4
+ type A11yMode = 'reduce-motion' | 'highlight-links' | 'highlight-titles' | 'high-contrast' | 'dyslexia' | 'reading-mask' | 'motor-targets' | A11yBundle;
5
+ type A11yVisualFilter = 'none' | 'boost-contrast' | 'monochrome' | 'high-contrast' | 'high-saturation' | 'low-saturation' | 'deuteranopia';
6
+ type A11yTextAlign = 'default' | 'start' | 'end' | 'justify';
7
+ type A11yLineHeight = 'normal' | '1.6' | '1.8' | '2.0';
8
+ type A11yLetterSpacing = '0' | '0.04em' | '0.08em' | '0.12em';
9
+ type A11yWordSpacing = '0' | '0.16em' | '0.32em' | '0.48em';
10
+ type A11yLocale = 'ar' | 'en';
11
+ type A11yPosition = 'end' | 'start' | 'left' | 'right';
12
+ interface A11yMountOptions {
13
+ /** FAB edge. Default: `end`. */
14
+ position?: A11yPosition;
15
+ /** 0-based FAB dock slot (bottom → top). Default: `0`. */
16
+ stack?: number;
17
+ /** UI locale. Default: `auto` (from `<html lang>` / `data-locale`). */
18
+ locale?: A11yLocale | 'auto';
19
+ /** localStorage key. Default: `dga-a11y`. */
20
+ storageKey?: string;
21
+ /** Mount root. Default: `document.body`. */
22
+ root?: HTMLElement;
23
+ /** Skip injecting the floating FAB/panel (controller-only). */
24
+ headless?: boolean;
25
+ }
26
+ interface A11yPersisted {
27
+ modes?: A11yMode[];
28
+ visualFilter?: A11yVisualFilter;
29
+ fontStep?: number;
30
+ textAlign?: A11yTextAlign;
31
+ lineHeight?: A11yLineHeight;
32
+ letterSpacing?: A11yLetterSpacing;
33
+ wordSpacing?: A11yWordSpacing;
34
+ maskBand?: number;
35
+ maskY?: number;
36
+ }
37
+ type A11yListener = () => void;
38
+
39
+ declare const A11Y_BUNDLES: A11yBundle[];
40
+ declare const BUNDLE_PRIMITIVES: Record<A11yBundle, A11yMode[]>;
41
+ declare class A11yController {
42
+ private readonly doc;
43
+ private readonly storageKey;
44
+ private readonly listeners;
45
+ private liveRegion;
46
+ private opener;
47
+ private mqMotion;
48
+ private mqContrast;
49
+ private localeObserver;
50
+ private localeOverride;
51
+ private destroyed;
52
+ isOpen: boolean;
53
+ modes: Set<A11yMode>;
54
+ visualFilter: A11yVisualFilter;
55
+ fontStep: number;
56
+ textAlign: A11yTextAlign;
57
+ lineHeight: A11yLineHeight;
58
+ letterSpacing: A11yLetterSpacing;
59
+ wordSpacing: A11yWordSpacing;
60
+ maskBand: number;
61
+ maskY: number;
62
+ locale: A11yLocale;
63
+ constructor(options?: {
64
+ storageKey?: string;
65
+ locale?: A11yLocale | 'auto';
66
+ document?: Document;
67
+ });
68
+ subscribe(listener: A11yListener): () => void;
69
+ private emit;
70
+ private notify;
71
+ effectiveModes(): Set<A11yMode>;
72
+ hasEffectiveMode(mode: A11yMode): boolean;
73
+ open(opener?: HTMLElement | null): void;
74
+ close(): void;
75
+ toggle(opener?: HTMLElement | null): void;
76
+ hasMode(mode: A11yMode): boolean;
77
+ isBundle(mode: A11yMode): mode is A11yBundle;
78
+ toggleMode(mode: A11yMode): void;
79
+ setMode(mode: A11yMode, enabled: boolean): void;
80
+ setVisualFilter(filter: A11yVisualFilter): void;
81
+ stepFontStep(delta: number): void;
82
+ stepTextAlign(delta: number): void;
83
+ stepLineHeight(delta: number): void;
84
+ stepLetterSpacing(delta: number): void;
85
+ stepWordSpacing(delta: number): void;
86
+ adjustMaskBand(delta: number): void;
87
+ setMaskY(y: number): void;
88
+ reset(): void;
89
+ announce(msg: string): void;
90
+ toggleLocale(): A11yLocale;
91
+ activeModeCount(section: 'modes' | 'readable' | 'visual'): number;
92
+ activeSettingCount(): number;
93
+ destroy(): void;
94
+ private applyBundleExtras;
95
+ private ensureDyslexiaFont;
96
+ private applyToDocument;
97
+ private persist;
98
+ private hydrate;
99
+ private onOsChange;
100
+ private bindOsPreferences;
101
+ private readDomLocale;
102
+ private bindLocaleObserver;
103
+ private ensureLiveRegion;
104
+ }
105
+
106
+ interface SkipLinkOptions {
107
+ href?: string;
108
+ label?: string;
109
+ root?: HTMLElement;
110
+ }
111
+ /** Visually hidden until focused — first tab stop for keyboard users. */
112
+ declare function createSkipLink(options?: SkipLinkOptions): HTMLAnchorElement;
113
+
114
+ interface A11yWidgetOptions {
115
+ position?: A11yPosition;
116
+ stack?: number;
117
+ root?: HTMLElement;
118
+ }
119
+ declare class A11yWidget {
120
+ private readonly ctrl;
121
+ private readonly position;
122
+ private readonly stack;
123
+ private readonly mountRoot;
124
+ private rootEl;
125
+ private unsub;
126
+ private resetArmed;
127
+ private resetTimer;
128
+ private draggingMask;
129
+ private onKeyDown;
130
+ private onPointerMove;
131
+ private onPointerUp;
132
+ constructor(ctrl: A11yController, options?: A11yWidgetOptions);
133
+ mount(): void;
134
+ destroy(): void;
135
+ private copy;
136
+ private fabBottom;
137
+ private activeChips;
138
+ private render;
139
+ private renderPanel;
140
+ private renderSteppers;
141
+ private renderMask;
142
+ private bindEvents;
143
+ private onReset;
144
+ private handleKey;
145
+ }
146
+
147
+ interface A11yCopy {
148
+ open: string;
149
+ close: string;
150
+ panelLabel: string;
151
+ title: string;
152
+ sectionActive: string;
153
+ sectionProfiles: string;
154
+ sectionAdjust: string;
155
+ sectionFilters: string;
156
+ profilesHint: string;
157
+ chipJump: string;
158
+ stepDecrease: string;
159
+ stepIncrease: string;
160
+ reset: string;
161
+ resetConfirm: string;
162
+ announcedReset: string;
163
+ fontSize: string;
164
+ dyslexia: string;
165
+ highlightTitles: string;
166
+ highlightLinks: string;
167
+ readingMask: string;
168
+ reduceMotion: string;
169
+ textAlign: string;
170
+ lineHeight: string;
171
+ letterSpacing: string;
172
+ wordSpacing: string;
173
+ filterBoost: string;
174
+ filterMono: string;
175
+ filterHigh: string;
176
+ filterHighSat: string;
177
+ filterLowSat: string;
178
+ filterDeutan: string;
179
+ maskToolbar: string;
180
+ maskSmaller: string;
181
+ maskLarger: string;
182
+ maskDrag: string;
183
+ maskClose: string;
184
+ stateOn: string;
185
+ stateOff: string;
186
+ defaultValue: string;
187
+ fontLevels: string[];
188
+ alignLevels: string[];
189
+ lineLevels: string[];
190
+ letterLevels: string[];
191
+ wordLevels: string[];
192
+ bundles: Record<A11yBundle, {
193
+ label: string;
194
+ desc: string;
195
+ }>;
196
+ }
197
+ declare function getCopy(locale: A11yLocale): A11yCopy;
198
+
199
+ interface AccessibilityInstance {
200
+ controller: A11yController;
201
+ widget: A11yWidget | null;
202
+ open: () => void;
203
+ close: () => void;
204
+ toggle: () => void;
205
+ toggleMode: A11yController['toggleMode'];
206
+ setMode: A11yController['setMode'];
207
+ setVisualFilter: A11yController['setVisualFilter'];
208
+ reset: () => void;
209
+ announce: A11yController['announce'];
210
+ toggleLocale: A11yController['toggleLocale'];
211
+ destroy: () => void;
212
+ }
213
+ /**
214
+ * Mount the accessibility tools widget (or headless controller).
215
+ * Safe to call once; subsequent calls return the existing instance.
216
+ */
217
+ declare function mount(options?: A11yMountOptions): AccessibilityInstance;
218
+ declare function getInstance(): AccessibilityInstance | null;
219
+ declare function destroy(): void;
220
+ /** Convenience namespace matching the plan API. */
221
+ declare const Accessibility: {
222
+ mount: typeof mount;
223
+ destroy: typeof destroy;
224
+ getInstance: typeof getInstance;
225
+ createSkipLink: typeof createSkipLink;
226
+ };
227
+
228
+ export { A11Y_BUNDLES, type A11yBundle, A11yController, type A11yLetterSpacing, type A11yLineHeight, type A11yLocale, type A11yMode, type A11yMountOptions, type A11yPersisted, type A11yPosition, type A11yTextAlign, type A11yVisualFilter, A11yWidget, type A11yWordSpacing, Accessibility, type AccessibilityInstance, BUNDLE_PRIMITIVES, createSkipLink, destroy, getCopy, getInstance, mount };