Refactored Accessibility module that delegates to the unified GenAccessibilityServer.
This module provides the same API as the original Accessibility module but uses a supervised GenServer instead of the Process dictionary for state management.
Migration Notice
This module is a drop-in replacement for Raxol.Core.Accessibility.
All functions maintain backward compatibility while providing improved
fault tolerance and functional programming patterns.
Benefits over Process Dictionary
- Unified state management across all accessibility features
- Supervised state with fault tolerance
- Pure functional transformations
- Announcement queuing with priority
- Better debugging and testing capabilities
- No global state pollution
Consolidated Modules
This refactored version consolidates functionality from:
Summary
Functions
Make an announcement for screen readers.
Make an announcement with user preferences (behaviour callback).
Announce component activation.
Announce with synchronous confirmation.
Announce value change.
Check if any accessibility feature is active.
Clear announcement history.
Clear all announcements (behaviour callback).
Disable accessibility features.
Enable accessibility features with the given options.
Check if accessibility features are enabled.
Ensures the Accessibility server is started.
Get announcement history.
Get accessibility metadata for a component.
Get all accessibility preferences.
Handle focus change event.
Check if high contrast mode is enabled.
Initialize accessibility with the given options.
Check if large text mode is enabled.
Check if reduced motion mode is enabled.
Remove metadata for a component.
Reset all accessibility settings to defaults.
Check if screen reader support is enabled.
Set announcement callback function.
Set high contrast mode.
Set keyboard focus indicators.
Set large text mode.
Set large text mode with user preferences (behaviour callback).
Set accessibility metadata for a component.
Set reduced motion mode.
Set screen reader support.
Subscribe to announcement events. Returns :ok.
The subscriber will receive {:announcement_added, ref, message} messages.
Unsubscribe from announcement events.
Update a specific metadata field for a component.
Functions
Make an announcement for screen readers.
Options
:priority- Priority level (:high, :medium, :low) default: :medium:interrupt- Whether to interrupt current announcement default: false:language- Language for the announcement
Make an announcement with user preferences (behaviour callback).
@spec announce_activation(term()) :: :ok
Announce component activation.
Announce with synchronous confirmation.
Announce value change.
@spec any_feature_active?() :: boolean()
Check if any accessibility feature is active.
@spec clear_announcement_history() :: :ok
Clear announcement history.
Clear all announcements (behaviour callback).
Disable accessibility features.
Enable accessibility features with the given options.
Options
:high_contrast- Enable high contrast mode (default:false):reduced_motion- Enable reduced motion (default:false):large_text- Enable large text (default:false):screen_reader- Enable screen reader support (default:true):keyboard_focus- Enable keyboard focus indicators (default:true):silence_announcements- Silence screen reader announcements (default:false)
Check if accessibility features are enabled.
@spec ensure_started() :: :ok
Ensures the Accessibility server is started.
@spec get_announcement_history(non_neg_integer() | nil) :: [map()]
Get announcement history.
Get accessibility metadata for a component.
@spec get_preferences() :: map()
Get all accessibility preferences.
Handle focus change event.
@spec high_contrast?() :: boolean()
Check if high contrast mode is enabled.
@spec init(keyword()) :: :ok
Initialize accessibility with the given options.
@spec large_text?() :: boolean()
Check if large text mode is enabled.
@spec reduced_motion?() :: boolean()
Check if reduced motion mode is enabled.
@spec remove_metadata(term()) :: :ok
Remove metadata for a component.
@spec reset() :: :ok
Reset all accessibility settings to defaults.
@spec screen_reader?() :: boolean()
Check if screen reader support is enabled.
Set announcement callback function.
@spec set_enabled(boolean()) :: :ok
@spec set_high_contrast(boolean()) :: :ok
Set high contrast mode.
@spec set_keyboard_focus(boolean()) :: :ok
Set keyboard focus indicators.
@spec set_large_text(boolean()) :: :ok
Set large text mode.
Set large text mode with user preferences (behaviour callback).
Set accessibility metadata for a component.
Metadata fields
:label- Accessible label for the component:role- ARIA role (button, navigation, etc.):description- Extended description:hint- Usage hint for screen readers:state- Current state (expanded, selected, etc.)
@spec set_reduced_motion(boolean()) :: :ok
Set reduced motion mode.
@spec set_screen_reader(boolean()) :: :ok
Set screen reader support.
@spec subscribe_to_announcements(reference()) :: :ok
Subscribe to announcement events. Returns :ok.
The subscriber will receive {:announcement_added, ref, message} messages.
@spec unsubscribe_from_announcements(reference()) :: :ok
Unsubscribe from announcement events.
Update a specific metadata field for a component.