@ordojs/accessibility
Version:
Comprehensive accessibility system for OrdoJS with ARIA generation, automated testing, and screen reader support
413 lines (411 loc) • 10.8 kB
TypeScript
/**
* @fileoverview OrdoJS Accessibility - Shared Types
*
* Common types and interfaces used across all accessibility modules.
*/
/**
* Accessibility configuration
*/
interface AccessibilityConfig {
/** Enable ARIA generation */
enableARIA: boolean;
/** Enable automated testing */
enableTesting: boolean;
/** Enable focus management */
enableFocusManagement: boolean;
/** Enable screen reader support */
enableScreenReader: boolean;
/** Enable keyboard navigation */
enableKeyboardNavigation: boolean;
/** Enable color contrast checking */
enableColorContrast: boolean;
/** Enable semantic HTML generation */
enableSemanticHTML: boolean;
/** Enable live region management */
enableLiveRegions: boolean;
/** Enable skip links */
enableSkipLinks: boolean;
/** Enable focus indicators */
enableFocusIndicators: boolean;
/** WCAG compliance level */
wcagLevel: 'A' | 'AA' | 'AAA';
/** Custom ARIA rules */
customARIA: Record<string, any>;
/** Testing configuration */
testing: TestingConfig;
/** Focus configuration */
focus: FocusConfig;
/** Screen reader configuration */
screenReader: ScreenReaderConfig;
}
/**
* Testing configuration
*/
interface TestingConfig {
/** Enable automated testing */
enabled: boolean;
/** Testing framework */
framework: 'axe-core' | 'puppeteer' | 'jsdom';
/** Test rules */
rules: string[];
/** Ignore rules */
ignoreRules: string[];
/** Test timeout */
timeout: number;
/** Test retries */
retries: number;
/** Generate reports */
generateReports: boolean;
/** Report format */
reportFormat: 'json' | 'html' | 'csv';
/** Report directory */
reportDir: string;
}
/**
* Focus configuration
*/
interface FocusConfig {
/** Enable focus management */
enabled: boolean;
/** Focus trap enabled */
focusTrap: boolean;
/** Focus indicators */
focusIndicators: boolean;
/** Skip links */
skipLinks: boolean;
/** Focus order */
focusOrder: 'tab' | 'logical' | 'custom';
/** Focus restoration */
focusRestoration: boolean;
/** Focus delegation */
focusDelegation: boolean;
}
/**
* Screen reader configuration
*/
interface ScreenReaderConfig {
/** Enable screen reader support */
enabled: boolean;
/** Announcements */
announcements: boolean;
/** Live regions */
liveRegions: boolean;
/** ARIA labels */
ariaLabels: boolean;
/** ARIA descriptions */
ariaDescriptions: boolean;
/** ARIA landmarks */
ariaLandmarks: boolean;
/** ARIA roles */
ariaRoles: boolean;
/** ARIA states */
ariaStates: boolean;
/** ARIA properties */
ariaProperties: boolean;
}
/**
* ARIA attribute information
*/
interface ARIAAttribute {
/** Attribute name */
name: string;
/** Attribute value */
value: string;
/** Attribute type */
type: 'string' | 'boolean' | 'number' | 'token' | 'tokenlist' | 'idref' | 'idrefs';
/** Required */
required: boolean;
/** Default value */
defaultValue?: string;
/** Allowed values */
allowedValues?: string[];
/** Description */
description: string;
}
/**
* ARIA role information
*/
interface ARIARole {
/** Role name */
name: string;
/** Role type */
type: 'abstract' | 'widget' | 'document' | 'landmark' | 'window';
/** Required attributes */
requiredAttributes: string[];
/** Supported attributes */
supportedAttributes: string[];
/** Required owned elements */
requiredOwnedElements: string[];
/** Required context roles */
requiredContextRoles: string[];
/** Prohibited attributes */
prohibitedAttributes: string[];
/** Description */
description: string;
/** Examples */
examples: string[];
}
/**
* Accessibility violation
*/
interface AccessibilityViolation {
/** Violation ID */
id: string;
/** Violation type */
type: 'error' | 'warning' | 'info';
/** Violation message */
message: string;
/** Violation impact */
impact: 'minor' | 'moderate' | 'serious' | 'critical';
/** WCAG criteria */
wcagCriteria: string[];
/** Element selector */
element: string;
/** Line number */
line?: number;
/** Column number */
column?: number;
/** File path */
file?: string;
/** Help text */
help: string;
/** Help URL */
helpUrl?: string;
/** Tags */
tags: string[];
/** Fix suggestions */
fixes: string[];
}
/**
* Accessibility test result
*/
interface AccessibilityTestResult {
/** Test ID */
id: string;
/** Test name */
name: string;
/** Test status */
status: 'pass' | 'fail' | 'inapplicable' | 'cantTell';
/** Test description */
description: string;
/** Test impact */
impact: 'minor' | 'moderate' | 'serious' | 'critical';
/** Test violations */
violations: AccessibilityViolation[];
/** Test passes */
passes: any[];
/** Test inapplicable */
inapplicable: any[];
/** Test timestamp */
timestamp: Date;
/** Test duration */
duration: number;
/** Test URL */
url?: string;
/** Test metadata */
metadata: Record<string, any>;
}
/**
* Focus management information
*/
interface FocusInfo {
/** Element selector */
element: string;
/** Tab index */
tabIndex: number;
/** Focus order */
focusOrder: number;
/** Is focusable */
focusable: boolean;
/** Is focused */
focused: boolean;
/** Focus trap */
focusTrap: boolean;
/** Skip link */
skipLink: boolean;
/** ARIA label */
ariaLabel?: string;
/** ARIA description */
ariaDescription?: string;
/** ARIA role */
ariaRole?: string;
/** ARIA state */
ariaState?: Record<string, any>;
/** ARIA property */
ariaProperty?: Record<string, any>;
}
/**
* Screen reader announcement
*/
interface ScreenReaderAnnouncement {
/** Announcement ID */
id: string;
/** Announcement message */
message: string;
/** Announcement priority */
priority: 'polite' | 'assertive';
/** Announcement type */
type: 'status' | 'alert' | 'log' | 'timer' | 'marquee' | 'progressbar';
/** Announcement timestamp */
timestamp: Date;
/** Announcement duration */
duration?: number;
/** Announcement element */
element?: string;
/** Announcement context */
context?: string;
}
/**
* Live region information
*/
interface LiveRegion {
/** Region ID */
id: string;
/** Region type */
type: 'status' | 'alert' | 'log' | 'timer' | 'marquee' | 'progressbar';
/** Region priority */
priority: 'polite' | 'assertive';
/** Region element */
element: string;
/** Region content */
content: string;
/** Region atomic */
atomic: boolean;
/** Region relevant */
relevant: 'additions' | 'removals' | 'text' | 'all';
/** Region busy */
busy: boolean;
/** Region expanded */
expanded?: boolean;
/** Region controls */
controls?: string;
/** Region described by */
describedBy?: string;
/** Region label */
label?: string;
}
/**
* Keyboard navigation information
*/
interface KeyboardNavigation {
/** Navigation ID */
id: string;
/** Navigation type */
type: 'tab' | 'arrow' | 'enter' | 'space' | 'escape' | 'custom';
/** Navigation key */
key: string;
/** Navigation key code */
keyCode: number;
/** Navigation target */
target: string;
/** Navigation action */
action: string;
/** Navigation description */
description: string;
/** Navigation enabled */
enabled: boolean;
/** Navigation visible */
visible: boolean;
/** Navigation context */
context?: string;
}
/**
* Color contrast information
*/
interface ColorContrast {
/** Foreground color */
foreground: string;
/** Background color */
background: string;
/** Contrast ratio */
ratio: number;
/** WCAG AA compliance */
wcagAA: boolean;
/** WCAG AAA compliance */
wcagAAA: boolean;
/** Large text compliance */
largeText: boolean;
/** UI component compliance */
uiComponent: boolean;
/** Description */
description: string;
/** Suggestions */
suggestions: string[];
}
/**
* Semantic HTML element
*/
interface SemanticElement {
/** Element tag */
tag: string;
/** Element attributes */
attributes: Record<string, string>;
/** Element content */
content: string;
/** Element role */
role?: string;
/** Element ARIA attributes */
ariaAttributes: Record<string, string>;
/** Element accessibility */
accessibility: {
/** Is semantic */
semantic: boolean;
/** Is accessible */
accessible: boolean;
/** Has proper heading structure */
headingStructure: boolean;
/** Has proper list structure */
listStructure: boolean;
/** Has proper table structure */
tableStructure: boolean;
/** Has proper form structure */
formStructure: boolean;
/** Has proper landmark structure */
landmarkStructure: boolean;
};
/** Element suggestions */
suggestions: string[];
}
/**
* Accessibility audit result
*/
interface AccessibilityAudit {
/** Audit ID */
id: string;
/** Audit timestamp */
timestamp: Date;
/** Audit URL */
url?: string;
/** Audit violations */
violations: AccessibilityViolation[];
/** Audit passes */
passes: any[];
/** Audit inapplicable */
inapplicable: any[];
/** Audit score */
score: number;
/** Audit level */
level: 'A' | 'AA' | 'AAA';
/** Audit compliant */
compliant: boolean;
/** Audit summary */
summary: {
/** Total violations */
totalViolations: number;
/** Critical violations */
criticalViolations: number;
/** Serious violations */
seriousViolations: number;
/** Moderate violations */
moderateViolations: number;
/** Minor violations */
minorViolations: number;
/** Total passes */
totalPasses: number;
/** Total inapplicable */
totalInapplicable: number;
};
/** Audit metadata */
metadata: Record<string, any>;
}
export type { AccessibilityConfig as A, ColorContrast as C, FocusConfig as F, KeyboardNavigation as K, LiveRegion as L, ScreenReaderConfig as S, TestingConfig as T, AccessibilityAudit as a, ARIAAttribute as b, ARIARole as c, AccessibilityViolation as d, AccessibilityTestResult as e, FocusInfo as f, ScreenReaderAnnouncement as g, SemanticElement as h };