accessibility-plugin-react 2.6.0 → 2.8.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 +24 -21
- package/dist/index.d.mts +46 -2
- package/dist/index.d.ts +46 -2
- package/dist/index.js +811 -398
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +728 -325
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +54 -0
- package/docs/API.md +3 -3
- package/docs/BUILD_AND_RELEASE_PLAN.md +2 -2
- package/docs/CONTRAST.md +73 -0
- package/docs/FEATURES.md +24 -20
- package/docs/LINKS_AND_FOCUS.md +65 -0
- package/package.json +1 -1
package/dist/style.css
CHANGED
|
@@ -556,6 +556,60 @@
|
|
|
556
556
|
background: var(--arap-surface);
|
|
557
557
|
color: var(--arap-accent);
|
|
558
558
|
}
|
|
559
|
+
.arap-skip-to-main {
|
|
560
|
+
position: fixed;
|
|
561
|
+
top: 12px;
|
|
562
|
+
left: 16px;
|
|
563
|
+
z-index: 2147483647;
|
|
564
|
+
width: 1px;
|
|
565
|
+
height: 1px;
|
|
566
|
+
margin: -1px;
|
|
567
|
+
padding: 0;
|
|
568
|
+
overflow: hidden;
|
|
569
|
+
clip-path: inset(50%);
|
|
570
|
+
white-space: nowrap;
|
|
571
|
+
border: 0;
|
|
572
|
+
pointer-events: none;
|
|
573
|
+
font-family: inherit;
|
|
574
|
+
font-size: 0.9375rem;
|
|
575
|
+
font-weight: 600;
|
|
576
|
+
text-decoration: none;
|
|
577
|
+
color: var(--arap-accent, #008060);
|
|
578
|
+
background: var(--arap-surface, #ffffff);
|
|
579
|
+
border-radius: 8px;
|
|
580
|
+
box-shadow:
|
|
581
|
+
0 10px 15px -3px rgba(0, 0, 0, 0.1),
|
|
582
|
+
0 4px 6px -4px rgba(0, 0, 0, 0.1);
|
|
583
|
+
}
|
|
584
|
+
.arap-skip-to-main:focus,
|
|
585
|
+
.arap-skip-to-main:focus-visible {
|
|
586
|
+
width: auto;
|
|
587
|
+
height: auto;
|
|
588
|
+
min-height: 44px;
|
|
589
|
+
margin: 0;
|
|
590
|
+
padding: 10px 18px;
|
|
591
|
+
clip-path: none;
|
|
592
|
+
overflow: visible;
|
|
593
|
+
white-space: normal;
|
|
594
|
+
pointer-events: auto;
|
|
595
|
+
border: 2px solid var(--arap-accent, #008060);
|
|
596
|
+
outline: 3px solid var(--arap-accent, #008060);
|
|
597
|
+
outline-offset: 3px;
|
|
598
|
+
display: inline-flex;
|
|
599
|
+
align-items: center;
|
|
600
|
+
justify-content: center;
|
|
601
|
+
}
|
|
602
|
+
@media (forced-colors: active) {
|
|
603
|
+
.arap-skip-to-main {
|
|
604
|
+
background: Canvas;
|
|
605
|
+
color: CanvasText;
|
|
606
|
+
border-color: Highlight;
|
|
607
|
+
}
|
|
608
|
+
.arap-skip-to-main:focus,
|
|
609
|
+
.arap-skip-to-main:focus-visible {
|
|
610
|
+
outline: 3px solid Highlight;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
559
613
|
@media (max-height: 480px) {
|
|
560
614
|
.arap-root .arap-panel {
|
|
561
615
|
top: max(16px, env(safe-area-inset-top)) !important;
|
package/docs/API.md
CHANGED
|
@@ -48,11 +48,11 @@ Definitions/defaults are immutable for the provider lifetime; the first register
|
|
|
48
48
|
|
|
49
49
|
`FeatureRegistration` is `FeatureOptions<unknown>` plus `defaultValue: unknown`. Use the generic hook instead of manually casting callbacks. Legacy `registerReset(key, fn)` / `unregisterReset(key)` remain available; callbacks run before global state is cleared. They are not the primary effect lifecycle API. Callback owners must unregister their callback on teardown.
|
|
50
50
|
|
|
51
|
-
Exported types: `AccessibilityPluginProps`, `AccessibilityButtonProps`, `AccessibilityListProps`, `AccessibilityState`, `AccessibilityContextValue`, `PluginPosition`, `WidgetPlacement`, `FeatureOptions<T>`, `FeatureRegistration`, `ToggleControlProps`, `ChoiceControlProps`, `ChoiceOption<T>`, `ChoiceGroup<T>`, `StepperControlProps`, `FeatureCardProps`, `FeatureStatus`, `SearchCountProps`, `EmptyStateProps`, `ErrorStateProps`, `ProfilePreviewCardProps`, `FontSizeControllerProps`, `TextScaleControllerProps`, `TextScaleStep`, `FontFamilyPreset`, `LineHeightControllerProps`, `LetterSpacingControllerProps`, `WordSpacingControllerProps`, `ParagraphSpacingControllerProps`, `ScriptSpacingConstraints`, `AccessibilityPreferences`, `ContrastMode`, `CursorSizePreference`, `FontFamilyPreference`, `ProfileDefinition`, `ProfilePresetId`, `ReaderMode`, `SaturationPreference`, `StorageMode`, `TextAlignPreference`, `LocaleStrings`.
|
|
51
|
+
Exported types: `AccessibilityPluginProps`, `AccessibilityButtonProps`, `AccessibilityListProps`, `AccessibilityState`, `AccessibilityContextValue`, `PluginPosition`, `WidgetPlacement`, `FeatureOptions<T>`, `FeatureRegistration`, `ToggleControlProps`, `ChoiceControlProps`, `ChoiceOption<T>`, `ChoiceGroup<T>`, `StepperControlProps`, `FeatureCardProps`, `FeatureStatus`, `SearchCountProps`, `EmptyStateProps`, `ErrorStateProps`, `ProfilePreviewCardProps`, `FontSizeControllerProps`, `TextScaleControllerProps`, `TextScaleStep`, `FontFamilyPreset`, `ContrastModeValue`, `ContrastPalette`, `LineHeightControllerProps`, `LetterSpacingControllerProps`, `WordSpacingControllerProps`, `ParagraphSpacingControllerProps`, `ScriptSpacingConstraints`, `SkipToMainLinkProps`, `AccessibilityPreferences`, `ContrastMode`, `CursorSizePreference`, `FontFamilyPreference`, `ProfileDefinition`, `ProfilePresetId`, `ReaderMode`, `SaturationPreference`, `StorageMode`, `TextAlignPreference`, `LocaleStrings`.
|
|
52
52
|
|
|
53
|
-
Exported control components: `ToggleControl`, `ChoiceControl`, `StepperControl`, `FeatureCard`, `SearchCount`, `EmptyState`, `ErrorState`, `ProfilePreviewCard`, `FontSizeController`, `TextScaleController`, `LineHeightController`, `LetterSpacingController`, `WordSpacingController`, `ParagraphSpacingController`, `FontFamilyController`, `TextAlignController`.
|
|
53
|
+
Exported control components: `ToggleControl`, `ChoiceControl`, `StepperControl`, `FeatureCard`, `SearchCount`, `EmptyState`, `ErrorState`, `ProfilePreviewCard`, `FontSizeController`, `TextScaleController`, `LineHeightController`, `LetterSpacingController`, `WordSpacingController`, `ParagraphSpacingController`, `FontFamilyController`, `TextAlignController`, `ContrastController`, `ContrastModeController`, `LinkHighlightController`, `HighlightFocusController`, `FocusHighlightController`, `SkipToMainLink`.
|
|
54
54
|
|
|
55
|
-
Exported typography and reflow utilities: `TEXT_SCALE_STEPS`, `TEXT_SCALE_PROTECTED_SELECTOR`, `isProtectedFromTextScale`, `LINE_HEIGHT_STEPS`, `LINE_HEIGHT_RATIOS`, `TEXT_SPACING_EXCLUDED_SELECTOR`, `isProtectedFromTextSpacing`, `getScriptSpacingConstraints`, `FONT_FAMILY_PRESETS`, `LEGIBLE_FONT_STACK`, `DYSLEXIA_FONT_STACK`, `FONT_FAMILY_PROTECTED_SELECTOR`, `isProtectedFromFontFamily`, `TEXT_ALIGN_BLOCK_SELECTOR`, `isProtectedFromTextAlign`.
|
|
55
|
+
Exported typography, contrast, and reflow utilities: `TEXT_SCALE_STEPS`, `TEXT_SCALE_PROTECTED_SELECTOR`, `isProtectedFromTextScale`, `LINE_HEIGHT_STEPS`, `LINE_HEIGHT_RATIOS`, `TEXT_SPACING_EXCLUDED_SELECTOR`, `isProtectedFromTextSpacing`, `getScriptSpacingConstraints`, `FONT_FAMILY_PRESETS`, `LEGIBLE_FONT_STACK`, `DYSLEXIA_FONT_STACK`, `FONT_FAMILY_PROTECTED_SELECTOR`, `isProtectedFromFontFamily`, `TEXT_ALIGN_BLOCK_SELECTOR`, `isProtectedFromTextAlign`, `CONTRAST_MODES`, `isForcedColorsActive`, `CONTRAST_PROTECTED_SELECTOR`, `isProtectedFromContrast`, `CONTRAST_PALETTES`, `findMainLandmark`.
|
|
56
56
|
|
|
57
57
|
Exported preference and profile utilities: `DEFAULT_PREFERENCES`, `PROFILE_DEFINITIONS`, `normalizePreferences`, `normalizePreferenceValue`, `resolveEffectivePreferences`, `preferencesReducer`, `createInitialPreferencesState`.
|
|
58
58
|
|
|
@@ -85,8 +85,8 @@ completed. Closing a child issue does not replace the milestone exit review.
|
|
|
85
85
|
- [x] [A11Y-201 — Bigger text and reflow-safe scaling #41](https://github.com/prabothcharith/accessibility-react/issues/41) — Add stepwise 1x–2x text scaling through reflow-safe scoped styles without nested compounding, clipping or changes to protected controls.
|
|
86
86
|
- [x] [A11Y-202 — Letter, word, paragraph spacing and line height #42](https://github.com/prabothcharith/accessibility-react/issues/42) — Add independent letter, word and paragraph spacing plus line-height options with script-aware limits and restoration tests.
|
|
87
87
|
- [x] [A11Y-203 — Text alignment, legible fonts and language fallback #43](https://github.com/prabothcharith/accessibility-react/issues/43) — Add scoped text alignment and legally distributable readable font choices with Sinhala/Tamil fallbacks while protecting icons, code and symbols.
|
|
88
|
-
- [
|
|
89
|
-
- [
|
|
88
|
+
- [x] [A11Y-204 — Contrast modes and native forced-color protection #44](https://github.com/prabothcharith/accessibility-react/issues/44) — Add targeted original/light/dark/high/invert contrast modes that preserve host content and respect forced colors and other native settings.
|
|
89
|
+
- [x] [A11Y-205 — Link highlighting and focus visibility #45](https://github.com/prabothcharith/accessibility-react/issues/45) — Add non-color-only link cues and stronger focus visibility without removing native indicators or creating unsafe skip links.
|
|
90
90
|
- [ ] [A11Y-206 — Reduce motion and best-effort media controls #46](https://github.com/prabothcharith/accessibility-react/issues/46) — Add reduced-motion CSS, tracked Web Animations pausing and explicit media controls while documenting GIF and cross-origin limitations.
|
|
91
91
|
- [ ] [A11Y-207 — Decorative image handling #47](https://github.com/prabothcharith/accessibility-react/issues/47) — Hide only eligible decorative imagery and keep functional, meaningful, CAPTCHA, chart, map and QR content available.
|
|
92
92
|
- [ ] [A11Y-208 — Visual regression and performance sweep #48](https://github.com/prabothcharith/accessibility-react/issues/48) — Run cross-feature visual, restoration, repeated-toggle, route, zoom, forced-color, reduced-motion and performance regression sweeps.
|
package/docs/CONTRAST.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Contrast Modes, Semantic Tokens and Native Forced-Colors Protection
|
|
2
|
+
|
|
3
|
+
This document details the contrast architecture, semantic tokens, element and state protections, and native operating system forced-colors integration in `accessibility-plugin-react`.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Contrast Modes and Semantic Tokens
|
|
8
|
+
|
|
9
|
+
The library provides five semantic contrast modes, configurable via `ContrastModeController` or `ContrastController`:
|
|
10
|
+
|
|
11
|
+
| Mode | Key | Description | Semantic Palette |
|
|
12
|
+
| :----------------- | :----------------------- | :---------------------------------------------- | :------------------------------------------------------------------------- |
|
|
13
|
+
| **Original / Off** | `off` / `original` / `0` | Restores original host styles without injection | N/A |
|
|
14
|
+
| **Light** | `light` | Crisp, high-clarity light theme | Background: `#ffffff`, Text: `#0f172a`, Border: `#94a3b8`, Link: `#0284c7` |
|
|
15
|
+
| **Dark** | `dark` | Deep dark mode with legible ink tones | Background: `#0f172a`, Text: `#f8fafc`, Border: `#475569`, Link: `#38bdf8` |
|
|
16
|
+
| **High Contrast** | `high` | Strict WCAG AAA (>= 7:1) high contrast | Background: `#000000`, Text: `#ffffff`, Border: `#ffffff`, Link: `#93c5fd` |
|
|
17
|
+
| **Invert** | `invert` | Luminance inversion with media preservation | Outer: `invert(1)`, Media: counter-inverted `invert(1)` |
|
|
18
|
+
|
|
19
|
+
In addition to semantic tokens, historical custom palettes (`yellow-on-black`, `white-on-black`, `blue-on-yellow`, `black-on-white`) and continuous filter multipliers (`reduced` 0.5×, `low` 1.25×, `high` 1.5×, `extra` 2.0×) are preserved for full backward compatibility.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Element & State Protections
|
|
24
|
+
|
|
25
|
+
Indiscriminate CSS filters or universal background overrides destroy non-text elements, chart visualizations, and critical interactive state cues. `isProtectedFromContrast(element)` strictly protects the following:
|
|
26
|
+
|
|
27
|
+
1. **Images & Media**:
|
|
28
|
+
- `img`, `picture`, `picture *`, `video`, `canvas`
|
|
29
|
+
- Opaque background colors are never forced onto images or videos.
|
|
30
|
+
2. **Graphics, SVGs & Charts**:
|
|
31
|
+
- `svg`, `svg *`, `[role="img"]`, `[role="graphics-document"]`, `[role="graphics-symbol"]`
|
|
32
|
+
- Data visualizations, vector diagrams, and charts remain clear and undistorted.
|
|
33
|
+
3. **Icon Fonts & Glyph Elements**:
|
|
34
|
+
- `[data-icon]`, `i[class*="icon"]`, `span[class*="icon"]`, `i[class*="fa-"]`, `i[class*="material-symbols"]`, `i[class*="lucide"]`
|
|
35
|
+
4. **Form Validation Error States**:
|
|
36
|
+
- `[aria-invalid="true"]`, `:invalid`, `.is-invalid`, `.invalid-feedback`, `[role="alert"]`
|
|
37
|
+
- Critical validation indicator colors (such as error red outlines, borders, and error copy) are never stripped or replaced with plain black/white text.
|
|
38
|
+
5. **Disabled Control States**:
|
|
39
|
+
- `:disabled`, `[aria-disabled="true"]`, `[disabled]`
|
|
40
|
+
- Form buttons and inputs retain their disabled opacity and cues, preventing confusion between active and disabled controls.
|
|
41
|
+
6. **Widget Isolation**:
|
|
42
|
+
- `.arap-root` and `[data-arap-ui]` remain completely isolated from page contrast overrides.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 3. Media Preservation in Invert Mode
|
|
47
|
+
|
|
48
|
+
When page-level inversion (`invert(1)`) is enabled, photographs, artwork, and video streams normally become unsightly "negatives".
|
|
49
|
+
|
|
50
|
+
To protect user experience and visual accessibility:
|
|
51
|
+
|
|
52
|
+
- The library automatically queries all `img, video, canvas, picture, [role="img"]` within the inverted scope.
|
|
53
|
+
- It applies a counter-inversion (`filter: invert(1)`), which mathematical inversion cancels out (`invert(invert(X)) = X`).
|
|
54
|
+
- Photos, streaming video, and charts display with their true, natural photographic colors.
|
|
55
|
+
- When invert mode is disabled or reset, the counter-inversion filter is cleanly removed.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 4. Operating System Forced-Colors Protection
|
|
60
|
+
|
|
61
|
+
Windows High Contrast Mode and operating systems supporting CSS `@media (forced-colors: active)` enforce system-level high-contrast palettes using keywords such as `Canvas`, `CanvasText`, `Highlight`, and `ButtonText`.
|
|
62
|
+
|
|
63
|
+
If an application forcibly applies inline colors or `contrast()` / `invert()` CSS filters while `forced-colors: active` is enabled, it interferes with user-configured system themes.
|
|
64
|
+
|
|
65
|
+
The library implements native forced-colors protection:
|
|
66
|
+
|
|
67
|
+
1. **Detection**: `isForcedColorsActive()` inspects `window.matchMedia("(forced-colors: active)").matches`.
|
|
68
|
+
2. **Non-Interference**: If forced-colors is active:
|
|
69
|
+
- `composeFilter()` yields `""`, suppressing CSS filter injections.
|
|
70
|
+
- Page inline background and color overrides are bypassed.
|
|
71
|
+
- Operating system high-contrast theme keywords remain in full control.
|
|
72
|
+
3. **User Transparency**: `ContrastController` and `ContrastModeController` render an accessible notice:
|
|
73
|
+
> _Operating system high contrast (forced colors) is active._
|
package/docs/FEATURES.md
CHANGED
|
@@ -2,26 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
All features are opt-in via controllers, use native buttons, support Enter/Space and ordinary Tab order, and expose pressed/disabled state or a polite numeric output. Defaults leave the host unchanged. Values persist once changed and return to defaults on Reset All. Effects persist when controls/panel disappear and are cleaned on provider removal. Widget portals are excluded. The engine restores prior inline properties and priorities instead of simply deleting them.
|
|
4
4
|
|
|
5
|
-
| Controller / key | Default; states and bounds
|
|
6
|
-
| --------------------------------------------- |
|
|
7
|
-
| TextScaleController / fontScale | 1.0; 1.0, 1.125, 1.25, 1.5, 2.0 (stepwise)
|
|
8
|
-
| FontSizeController / fontSize | 100; 50–200%, step 10 or stepwise
|
|
9
|
-
| LineHeightController / lineHeight | 100; 50–200%, step 10 or stepwise presets
|
|
10
|
-
| LetterSpacingController / letterSpacing | 0; 0–10px, step 1
|
|
11
|
-
| WordSpacingController / wordSpacing | 0; 0–10px, step 1
|
|
12
|
-
| ParagraphSpacingController / paragraphSpacing | 0; 0–32px, step 4
|
|
13
|
-
| ContrastController / contrast | 0; 0/1/2/3,
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
|
|
|
5
|
+
| Controller / key | Default; states and bounds | Host behavior / edge cases |
|
|
6
|
+
| --------------------------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| TextScaleController / fontScale | 1.0; 1.0, 1.125, 1.25, 1.5, 2.0 (stepwise) | Reflow-safe stepwise text enlargement without CSS transforms or compounding. Protects forms, labels, code, icons, widget, and exempt content. |
|
|
8
|
+
| FontSizeController / fontSize | 100; 50–200%, step 10 or stepwise | Scales computed font size and line height together. Supports optional `stepScale` / `steps` props; protects forms, labels, code blocks, icons, and widget UI. |
|
|
9
|
+
| LineHeightController / lineHeight | 100; 50–200%, step 10 or stepwise presets | Scales computed line height. Supports `stepPresets` (100%, 150%, 175%, 200% / 1.0x, 1.5x, 1.75x, 2.0x) and custom `steps`. Excludes tables, code blocks, controls, and widget UI. |
|
|
10
|
+
| LetterSpacingController / letterSpacing | 0; 0–10px, step 1 | Sets letter spacing on content elements. Protects cursive/Arabic/RTL scripts (disabled) and Indic/Sinhala/Tamil scripts (clamped <=1px). Excludes tables, code, and controls. |
|
|
11
|
+
| WordSpacingController / wordSpacing | 0; 0–10px, step 1 | Sets word spacing on content elements while protecting tables, code, controls, and widget UI. |
|
|
12
|
+
| ParagraphSpacingController / paragraphSpacing | 0; 0–32px, step 4 | Increases paragraph bottom margin (`p`, `[role="paragraph"]`) while protecting tables, code, and controls. |
|
|
13
|
+
| ContrastController / contrast | 0; 0/1/2/3, light, dark, high, invert, reduced, named palettes | Off, 1.25×, 1.5×, 2×; reduced=0.5×. Semantic light, dark, high contrast, and invert tokens protect images/video/SVG/charts and validation states. Bypasses overrides when OS forced-colors is active. |
|
|
14
|
+
| ContrastModeController / contrastMode | off; off/light/dark/high/invert | Semantic light, dark, high contrast, and media-safe invert modes. Preserves images, charts, and validation errors. Native forced-colors protection. See docs/CONTRAST.md. |
|
|
15
|
+
| SaturationController / saturation | 0; 0/1/2 | Off, 0.2×, 2× saturation. Composes with other filters. |
|
|
16
|
+
| InvertColorsController / invertColors | false; boolean | Adds invert(1), includes content images. |
|
|
17
|
+
| GrayscaleController / grayscale | false; boolean | Adds grayscale(1); saturation cannot restore color while this is active. |
|
|
18
|
+
| LinkHighlightController / linkHighlight | false; false/true/underline/palettes | Non-color underline cues (2px thickness, 3px offset) and high-contrast palettes. Preserves disabled links and system LinkText in forced colors. See docs/LINKS_AND_FOCUS.md. |
|
|
19
|
+
| HighlightFocusController / highlightFocus | false; boolean | High-visibility dual-ring focus outline (3px blue + 5px white halo) with forced-colors Highlight support. Preserves disabled controls. See docs/LINKS_AND_FOCUS.md. |
|
|
20
|
+
| SkipToMainLink / findMainLandmark | Dynamic helper / link | Authentic skip-to-main landmark link. Only renders when a real `<main>` or `[role="main"]` exists. Transfers focus and scrolls into view. See docs/LINKS_AND_FOCUS.md. |
|
|
21
|
+
| TextAlignController / textAlign | default; default/left/center/right/justify | Scoped strictly to logical text blocks (p, headings, lists, blockquotes); excludes tables, form controls, and code. Justification displays an accessible WCAG SC 1.4.8 advisory warning. |
|
|
22
|
+
| FontFamilyController / fontFamily | default; default/legible/dyslexia-option | Applies clean system-ui or OpenDyslexic with Sinhala/Tamil fallbacks. Code blocks, icons, and SVGs are protected. See docs/FONTS.md. |
|
|
23
|
+
| HideImagesController / hideImages | false; boolean | Hides img/picture with visibility:hidden and removes CSS background images from HTML elements. Layout retained. SVG/canvas/pseudo-element imagery not hidden. |
|
|
24
|
+
| HideVideosController / hideVideos | false; boolean | Hides video and recognized YouTube/Vimeo embed URL patterns. Does not hide unrelated iframe documents, pause video or mute audio. |
|
|
25
|
+
| BigCursorController / bigCursor | false; boolean | 40px high-contrast pointer via SVG cursor with native fallback. Host CSS cursor effects are restored. No effect on touch-only hardware. |
|
|
26
|
+
| ReadingMaskController / readingMask | false; boolean | Transparent 100px reading window; surrounding screen dimmed. Follows pointer or host focus. |
|
|
27
|
+
| ReadingGuideController / readingGuide | false; boolean | 4px blue line with white border follows pointer or host focus. Can coexist with mask. |
|
|
28
|
+
| ResetController | No feature state | Clears display settings including custom/unmounted controls, preserves widget placement; runs legacy reset callbacks; keeps panel open. |
|
|
25
29
|
|
|
26
30
|
## Accessible control primitives and UI states
|
|
27
31
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Link Highlighting, Focus Visibility, and Landmark Skip Links
|
|
2
|
+
|
|
3
|
+
This document outlines the architecture, WCAG 2.2 alignment, and behavioral guarantees for link highlighting, focus visibility, and the skip-to-main landmark link implemented under **[A11Y-205]**.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. Non-Color-Only Link Highlighting
|
|
8
|
+
|
|
9
|
+
### The Problem
|
|
10
|
+
|
|
11
|
+
WCAG SC 1.4.1 (Use of Color) requires that color is not used as the sole visual means of conveying information or distinguishing interactive elements. Many websites style hyperlinks with custom colors that lack underlines or sufficient contrast against surrounding text.
|
|
12
|
+
|
|
13
|
+
### Implementation
|
|
14
|
+
|
|
15
|
+
- **Non-Color Cues**: Active link highlighting applies an unmistakable visual underline:
|
|
16
|
+
```css
|
|
17
|
+
text-decoration: underline !important;
|
|
18
|
+
text-decoration-thickness: 2px !important;
|
|
19
|
+
text-underline-offset: 3px !important;
|
|
20
|
+
```
|
|
21
|
+
- **High-Contrast Palettes**: Users can select high-contrast badge/background styles (`yellow-on-black`, `blue-on-yellow`, `black-on-white`), or standard high-contrast underlining.
|
|
22
|
+
- **Forced-Colors Support**: Under Windows High Contrast Mode or `@media (forced-colors: active)`, links preserve the operating system's `LinkText` system keyword without conflicting hardcoded backgrounds.
|
|
23
|
+
- **Disabled Semantics Preservation**: Inactive, unlinked, or disabled anchors (`a:not([href])`, `a[aria-disabled="true"]`, `a.disabled`) are explicitly skipped, ensuring screen reader and keyboard users are not misled into attempting navigation on disabled links.
|
|
24
|
+
- **Widget Boundary Protection**: Elements matching `[data-arap-ui] *` are excluded from host mutations.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 2. Enhanced Focus Visibility (`HighlightFocusController`)
|
|
29
|
+
|
|
30
|
+
### The Problem
|
|
31
|
+
|
|
32
|
+
WCAG SC 2.4.7 (Focus Visible) and SC 2.4.11 (Focus Appearance - AAA) require clear, high-contrast visual indicators for keyboard navigation. Native browser focus rings often disappear against complex backgrounds or are suppressed by host stylesheets (`outline: none`).
|
|
33
|
+
|
|
34
|
+
### Implementation
|
|
35
|
+
|
|
36
|
+
- **Dual-Ring High Contrast**: When enabled, an accessible high-contrast outline is applied to all active interactive controls (`button`, `a`, `input`, `select`, `textarea`, `[tabindex]`):
|
|
37
|
+
```css
|
|
38
|
+
*:not([data-arap-ui]):not([data-arap-ui] *):focus-visible {
|
|
39
|
+
outline: 3px solid #2563eb !important;
|
|
40
|
+
outline-offset: 3px !important;
|
|
41
|
+
box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.9) !important;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
The primary 3px blue ring coupled with the outer 5px white halo ensures visibility on both light and dark backgrounds.
|
|
45
|
+
- **Forced-Colors Mode**: Under `@media (forced-colors: active)`, the ring yields to the system `Highlight` keyword with `box-shadow: none`, adhering to the active OS high-contrast theme.
|
|
46
|
+
- **Disabled Semantics**: Disabled elements (`*:disabled:focus-visible`, `*[aria-disabled="true"]:focus-visible`) have outlines suppressed (`outline: none !important`), preventing disabled controls from showing active focus rings.
|
|
47
|
+
- **Clean Teardown**: Upon reset or disabling, the injected style element is immediately removed, restoring host and UA defaults.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 3. Authentic Skip-To-Main Landmark Link (`SkipToMainLink`)
|
|
52
|
+
|
|
53
|
+
### The Problem
|
|
54
|
+
|
|
55
|
+
WCAG SC 2.4.1 (Bypass Blocks) requires a mechanism to bypass repetitive navigation blocks directly to the main content. However, rendering a skip-to-main link when no `<main>` landmark exists results in broken navigation and false promises to assistive technology users.
|
|
56
|
+
|
|
57
|
+
### Implementation
|
|
58
|
+
|
|
59
|
+
- **Authentic Landmark Verification**: `findMainLandmark()` checks for a valid native `<main>` element or element with explicit `role="main"`.
|
|
60
|
+
- **Conditional Rendering**: `SkipToMainLink` renders **only when an authentic main landmark exists**. If no landmark is found, it renders `null`.
|
|
61
|
+
- **Dynamic Mutation Handling**: Uses `useSyncExternalStore` to monitor DOM mutations via `MutationObserver`. If a client-side route transition inserts or removes a `<main>` element, the skip link updates automatically without unnecessary re-renders.
|
|
62
|
+
- **Accessible Interaction**:
|
|
63
|
+
- Hidden off-screen using `clip-path: inset(50%)` until focused via keyboard Tab.
|
|
64
|
+
- On focus, slides into the top-left viewport meeting the minimum 44px touch/click target size.
|
|
65
|
+
- On activation, assigns `tabindex="-1"` if needed, programmatically transfers focus to the landmark, and smoothly scrolls it into view.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accessibility-plugin-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "A composable React display-preference widget with a clean light design, persistent settings and movable accessible controls.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|