accessibility-plugin-react 2.6.0 → 2.7.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 +21 -21
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +471 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +458 -211
- package/dist/index.mjs.map +1 -1
- package/docs/API.md +3 -3
- package/docs/BUILD_AND_RELEASE_PLAN.md +1 -1
- package/docs/CONTRAST.md +73 -0
- package/docs/FEATURES.md +21 -20
- package/package.json +1 -1
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`, `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`.
|
|
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`.
|
|
56
56
|
|
|
57
57
|
Exported preference and profile utilities: `DEFAULT_PREFERENCES`, `PROFILE_DEFINITIONS`, `normalizePreferences`, `normalizePreferenceValue`, `resolveEffectivePreferences`, `preferencesReducer`, `createInitialPreferencesState`.
|
|
58
58
|
|
|
@@ -85,7 +85,7 @@ 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
|
-
- [
|
|
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
89
|
- [ ] [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.
|
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,27 @@
|
|
|
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
|
+
| 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. |
|
|
19
|
+
| 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. |
|
|
20
|
+
| 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. |
|
|
21
|
+
| HideVideosController / hideVideos | false; boolean | Hides video and recognized YouTube/Vimeo embed URL patterns. Does not hide unrelated iframe documents, pause video or mute audio. |
|
|
22
|
+
| 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. |
|
|
23
|
+
| ReadingMaskController / readingMask | false; boolean | Transparent 100px reading window; surrounding screen dimmed. Follows pointer or host focus. |
|
|
24
|
+
| ReadingGuideController / readingGuide | false; boolean | 4px blue line with white border follows pointer or host focus. Can coexist with mask. |
|
|
25
|
+
| ResetController | No feature state | Clears display settings including custom/unmounted controls, preserves widget placement; runs legacy reset callbacks; keeps panel open. |
|
|
25
26
|
|
|
26
27
|
## Accessible control primitives and UI states
|
|
27
28
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accessibility-plugin-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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",
|