accessibility-plugin-react 1.0.0 → 2.0.1
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/LICENSE +15 -0
- package/README.md +249 -37
- package/dist/index.d.mts +114 -0
- package/dist/index.d.ts +114 -1
- package/dist/index.js +1694 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1657 -0
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +593 -0
- package/docs/API.md +89 -0
- package/docs/ARCHITECTURE.md +43 -0
- package/docs/BASELINE.md +48 -0
- package/docs/CUSTOM_FEATURES.md +101 -0
- package/docs/DESIGN.md +39 -0
- package/docs/DEVELOPMENT.md +91 -0
- package/docs/FEATURES.md +49 -0
- package/docs/HANDOVER.md +143 -0
- package/docs/INSTALLATION.md +96 -0
- package/docs/MIGRATION.md +40 -0
- package/docs/PROJECT_STATUS.md +106 -0
- package/docs/RELEASE.md +148 -0
- package/docs/ROADMAP.md +31 -0
- package/docs/TROUBLESHOOTING.md +25 -0
- package/docs/assets/clean-light-desktop.png +0 -0
- package/docs/assets/clean-light-mobile.png +0 -0
- package/docs/assets/movable-desktop.png +0 -0
- package/docs/assets/position-menu.png +0 -0
- package/docs/assets/quick-actions-mobile.png +0 -0
- package/docs/assets/widget-desktop.png +0 -0
- package/docs/assets/widget-mobile.png +0 -0
- package/package.json +86 -48
- package/dist/index.es.js +0 -8354
- package/dist/index.umd.js +0 -14
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Praboth Charith
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,281 @@
|
|
|
1
|
-
#
|
|
1
|
+
# accessibility-plugin-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Composable React controls for display preferences and reading assistance. Choose
|
|
4
|
+
the controls in JSX, keep the widget outside your application layout, and let
|
|
5
|
+
the provider own state, persistence, effects, focus behavior, and cleanup.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
The `2.0.1` patch release updates the published v2 documentation without
|
|
8
|
+
changing the runtime API. It supports React 18.3.1 and React 19.x, ships ESM,
|
|
9
|
+
CommonJS, TypeScript declarations, and scoped plain CSS, and has no runtime
|
|
10
|
+
dependency other than React and React DOM.
|
|
6
11
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **Reset**: Easily reset all settings to default.
|
|
12
|
+
> This library improves the presentation of your content. It cannot repair
|
|
13
|
+
> inaccessible application markup or certify WCAG conformance. Human
|
|
14
|
+
> screen-reader, physical-device, actual-zoom, forced-colors, and host
|
|
15
|
+
> integration checks remain part of your application's accessibility process.
|
|
16
|
+
|
|
17
|
+

|
|
14
18
|
|
|
15
19
|
## Installation
|
|
16
20
|
|
|
17
|
-
```
|
|
18
|
-
npm install accessibility-plugin
|
|
19
|
-
# or
|
|
20
|
-
yarn add accessibility-plugin
|
|
21
|
+
```sh
|
|
22
|
+
npm install accessibility-plugin-react
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
React and React DOM are peer dependencies and must use the same major/minor
|
|
26
|
+
line. The package requires Node.js 22.13 or newer for development and builds.
|
|
27
|
+
The widget itself does not require an API key, backend, environment variable,
|
|
28
|
+
Tailwind, Motion, or an icon library.
|
|
24
29
|
|
|
25
|
-
##
|
|
30
|
+
## Quick start
|
|
26
31
|
|
|
27
|
-
|
|
32
|
+
Import the stylesheet once and mount one provider per document, preferably
|
|
33
|
+
above route changes or in the persistent application layout:
|
|
28
34
|
|
|
29
35
|
```tsx
|
|
30
|
-
import {
|
|
31
|
-
|
|
36
|
+
import {
|
|
37
|
+
AccessibilityPlugin,
|
|
38
|
+
AccessibilityButton,
|
|
39
|
+
AccessibilityList,
|
|
40
|
+
FontSizeController,
|
|
41
|
+
ContrastController,
|
|
42
|
+
GrayscaleController,
|
|
43
|
+
ResetController,
|
|
44
|
+
} from "accessibility-plugin-react";
|
|
45
|
+
import "accessibility-plugin-react/style.css";
|
|
32
46
|
|
|
33
|
-
function
|
|
47
|
+
export function AccessibilitySettings() {
|
|
34
48
|
return (
|
|
35
|
-
<AccessibilityPlugin>
|
|
36
|
-
<
|
|
49
|
+
<AccessibilityPlugin position="right">
|
|
50
|
+
<AccessibilityButton description="Adjust display preferences" />
|
|
51
|
+
<AccessibilityList>
|
|
52
|
+
<FontSizeController />
|
|
53
|
+
<ContrastController />
|
|
54
|
+
<GrayscaleController />
|
|
55
|
+
<ResetController />
|
|
56
|
+
</AccessibilityList>
|
|
37
57
|
</AccessibilityPlugin>
|
|
38
58
|
);
|
|
39
59
|
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The button and panel are non-modal body portals. The application remains
|
|
63
|
+
interactive while the panel is open. Opening moves focus to the named region;
|
|
64
|
+
Escape and Close return focus to the trigger. Focus is not trapped.
|
|
40
65
|
|
|
41
|
-
|
|
66
|
+
`AccessibilityPlugin` can be rendered next to application content:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
export function App() {
|
|
70
|
+
return (
|
|
71
|
+
<>
|
|
72
|
+
<main>{/* application routes and content */}</main>
|
|
73
|
+
<AccessibilitySettings />
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
42
77
|
```
|
|
43
78
|
|
|
44
|
-
|
|
79
|
+
## Built-in controllers
|
|
80
|
+
|
|
81
|
+
Every controller is opt-in. Add only the controls that make sense for your
|
|
82
|
+
site, and choose their order in JSX.
|
|
83
|
+
|
|
84
|
+
| Controller | Effect |
|
|
85
|
+
| ------------------------- | --------------------------------------------------------------------------------- |
|
|
86
|
+
| `FontSizeController` | Scales eligible HTML text from 50% to 200%. |
|
|
87
|
+
| `LineHeightController` | Scales computed line height from 50% to 200%. |
|
|
88
|
+
| `LetterSpacingController` | Applies 0–10px letter spacing. |
|
|
89
|
+
| `ContrastController` | Turns contrast off, reduces it, increases it, or selects a named palette. |
|
|
90
|
+
| `SaturationController` | Reduces or increases saturation. |
|
|
91
|
+
| `InvertColorsController` | Inverts eligible page content. |
|
|
92
|
+
| `GrayscaleController` | Removes color while preserving the selected saturation value for later. |
|
|
93
|
+
| `LinkHighlightController` | Highlights links or selects a link palette. |
|
|
94
|
+
| `TextAlignController` | Restores the host alignment or forces left, center, right, or justified text. |
|
|
95
|
+
| `HideImagesController` | Hides images and CSS background images while retaining layout. |
|
|
96
|
+
| `HideVideosController` | Hides video elements and recognized YouTube/Vimeo embeds visually. |
|
|
97
|
+
| `BigCursorController` | Applies a larger high-contrast cursor where supported. |
|
|
98
|
+
| `ReadingMaskController` | Dims the page around a transparent reading window. |
|
|
99
|
+
| `ReadingGuideController` | Follows pointer/focus with a reading guide line. |
|
|
100
|
+
| `ResetController` | Resets display features and custom registered features without moving the widget. |
|
|
101
|
+
|
|
102
|
+
Effects compose where appropriate. For example, contrast, saturation, invert,
|
|
103
|
+
and grayscale are applied in a deterministic order. Defaults leave host styles
|
|
104
|
+
unchanged, and the provider restores host inline values and priorities when an
|
|
105
|
+
effect is disabled or the provider is removed.
|
|
45
106
|
|
|
46
|
-
|
|
107
|
+
## Custom features
|
|
108
|
+
|
|
109
|
+
Use the two-argument hook for simple state, or provide validation and a
|
|
110
|
+
provider-owned effect for a feature that changes the page:
|
|
47
111
|
|
|
48
112
|
```tsx
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
113
|
+
import { useAccessibility } from "accessibility-plugin-react";
|
|
114
|
+
|
|
115
|
+
export function OutlineFeature() {
|
|
116
|
+
const { value, setValue } = useAccessibility("site:outline", false, {
|
|
117
|
+
apply(enabled) {
|
|
118
|
+
if (!enabled) return;
|
|
119
|
+
|
|
120
|
+
const previous = document.body.style.outline;
|
|
121
|
+
document.body.style.outline = "3px solid #1e40af";
|
|
122
|
+
return () => {
|
|
123
|
+
document.body.style.outline = previous;
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<button type="button" aria-pressed={value} onClick={() => setValue(!value)}>
|
|
130
|
+
Outline page
|
|
53
131
|
</button>
|
|
54
|
-
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Place the feature inside `AccessibilityList`:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<AccessibilityList>
|
|
140
|
+
<FontSizeController />
|
|
141
|
+
<OutlineFeature />
|
|
142
|
+
<ResetController />
|
|
143
|
+
</AccessibilityList>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The provider owns the effect lifetime, so it continues when the panel closes or
|
|
147
|
+
the control temporarily unmounts. Cleanup runs before reapplication and when
|
|
148
|
+
the provider unmounts. Custom state is JSON-compatible; supply `validate` for
|
|
149
|
+
arrays and objects. Feature keys must be stable and cannot use reserved
|
|
150
|
+
prototype names or built-in keys. See [custom feature details](docs/CUSTOM_FEATURES.md).
|
|
151
|
+
|
|
152
|
+
## Persistence and movement
|
|
153
|
+
|
|
154
|
+
Preferences are stored in a versioned local-storage record under
|
|
155
|
+
`react-accessibility-plugin:state` by default. Writes are debounced and flushed
|
|
156
|
+
when the page is hidden or the provider is removed. Invalid saved values fall
|
|
157
|
+
back to defaults; storage failures do not make the widget unusable.
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
<AccessibilityPlugin
|
|
161
|
+
persistenceKey="my-site:accessibility"
|
|
162
|
+
persist={true}
|
|
163
|
+
position="left"
|
|
55
164
|
>
|
|
56
|
-
|
|
165
|
+
{/* button, list, and selected controllers */}
|
|
57
166
|
</AccessibilityPlugin>
|
|
58
167
|
```
|
|
59
168
|
|
|
60
|
-
|
|
169
|
+
Persistence options are fixed for the provider lifetime. Remount with a React
|
|
170
|
+
`key` when changing the storage identity. Use one provider per document.
|
|
171
|
+
|
|
172
|
+
The trigger is draggable by default. Movement also works with Alt+Arrow keys
|
|
173
|
+
and the panel's explicit corner and arrow controls. Drag activation has an
|
|
174
|
+
8px threshold, cancelled drags do not open the panel, and placement is clamped
|
|
175
|
+
on resize. `ResetController` preserves placement; the panel's separate
|
|
176
|
+
position reset removes it. Set `draggable={false}` when only the non-drag
|
|
177
|
+
controls should be available.
|
|
178
|
+
|
|
179
|
+
## Styling and framework integration
|
|
180
|
+
|
|
181
|
+
The stylesheet is scoped to `.arap-root` and does not add a global reset,
|
|
182
|
+
Tailwind preflight, or host theme variables. Load it once, then put consumer
|
|
183
|
+
overrides after it:
|
|
61
184
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
185
|
+
```css
|
|
186
|
+
.arap-root {
|
|
187
|
+
--arap-accent: #1e40af;
|
|
188
|
+
--arap-accent-hover: #1e3a8a;
|
|
189
|
+
--arap-selected: #eff6ff;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.arap-root .my-trigger {
|
|
193
|
+
border-radius: 999px;
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Use `className`, `style`, `title`, `description`, and `closeLabel` to adapt
|
|
198
|
+
the widget to your product language and layout. Preserve visible focus,
|
|
199
|
+
pressed states, contrast, and the library's 44px minimum interactive targets
|
|
200
|
+
when overriding styles.
|
|
201
|
+
|
|
202
|
+
For Next.js App Router, put the provider and custom controls in a Client
|
|
203
|
+
Component, import the CSS from the root layout, and render the provider in the
|
|
204
|
+
persistent layout rather than once per route:
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
// app/accessibility-settings.tsx
|
|
208
|
+
"use client";
|
|
209
|
+
|
|
210
|
+
import {
|
|
211
|
+
AccessibilityPlugin,
|
|
212
|
+
AccessibilityButton,
|
|
213
|
+
AccessibilityList,
|
|
214
|
+
FontSizeController,
|
|
215
|
+
ResetController,
|
|
216
|
+
} from "accessibility-plugin-react";
|
|
217
|
+
|
|
218
|
+
export function AccessibilitySettings() {
|
|
219
|
+
return (
|
|
220
|
+
<AccessibilityPlugin>
|
|
221
|
+
<AccessibilityButton />
|
|
222
|
+
<AccessibilityList>
|
|
223
|
+
<FontSizeController />
|
|
224
|
+
<ResetController />
|
|
225
|
+
</AccessibilityList>
|
|
226
|
+
</AccessibilityPlugin>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
See [installation and Next.js](docs/INSTALLATION.md) for App Router and Pages
|
|
232
|
+
Router examples.
|
|
233
|
+
|
|
234
|
+
## API and limitations
|
|
235
|
+
|
|
236
|
+
- Public components, props, exported types, placement, persistence, custom
|
|
237
|
+
features, and CSS variables are documented in [API.md](docs/API.md).
|
|
238
|
+
- Detailed per-feature defaults, bounds, and host behavior are in
|
|
239
|
+
[FEATURES.md](docs/FEATURES.md).
|
|
240
|
+
- Filters can create stacking contexts and containing blocks for fixed host
|
|
241
|
+
descendants. Test sticky headers, overlays, and third-party widgets in the
|
|
242
|
+
real application.
|
|
243
|
+
- Text measurement covers the current document's eligible HTML elements.
|
|
244
|
+
Shadow DOM, iframe interiors, SVG/canvas text, pseudo-elements, and raw text
|
|
245
|
+
nodes directly under `body` are outside scope.
|
|
246
|
+
- Image/video hiding is visual; video playback is not paused or muted.
|
|
247
|
+
- Reading aids are pointer-transparent overlays and do not replace semantic
|
|
248
|
+
reading structure.
|
|
249
|
+
- There is no live cross-tab synchronization or server-side preference sync.
|
|
250
|
+
- `persist={false}` disables both display and placement persistence.
|
|
251
|
+
|
|
252
|
+
See [troubleshooting](docs/TROUBLESHOOTING.md) before filing an issue.
|
|
253
|
+
|
|
254
|
+
## Documentation and examples
|
|
255
|
+
|
|
256
|
+
- [API reference](docs/API.md)
|
|
257
|
+
- [Feature behavior and bounds](docs/FEATURES.md)
|
|
258
|
+
- [Installation and Next.js](docs/INSTALLATION.md)
|
|
259
|
+
- [Custom features](docs/CUSTOM_FEATURES.md)
|
|
260
|
+
- [Migration from v1 and development baselines](docs/MIGRATION.md)
|
|
261
|
+
- [Architecture and lifecycle decisions](docs/ARCHITECTURE.md)
|
|
262
|
+
- [Development and testing](docs/DEVELOPMENT.md)
|
|
263
|
+
- [Design foundation](docs/DESIGN.md)
|
|
264
|
+
- [Troubleshooting](docs/TROUBLESHOOTING.md)
|
|
265
|
+
- [Project status and verification evidence](docs/PROJECT_STATUS.md)
|
|
266
|
+
- [Release procedure](docs/RELEASE.md)
|
|
267
|
+
- [Changelog](CHANGELOG.md)
|
|
268
|
+
|
|
269
|
+
Runnable package-consumer examples are in [`examples/`](examples/):
|
|
270
|
+
|
|
271
|
+
```sh
|
|
272
|
+
npm ci
|
|
273
|
+
npm run build
|
|
274
|
+
npm run example
|
|
275
|
+
```
|
|
66
276
|
|
|
67
277
|
## License
|
|
68
278
|
|
|
69
|
-
|
|
279
|
+
This package is available under the [ISC license](LICENSE). The original
|
|
280
|
+
vanilla JavaScript project is maintained separately at
|
|
281
|
+
[prabothcharith/accessibility-plugin](https://github.com/prabothcharith/accessibility-plugin).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
interface AccessibilityState {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
features: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface FeatureOptions<T> {
|
|
9
|
+
/** Validate restored and programmatic values. Required for structured custom state. */
|
|
10
|
+
validate?: (value: unknown) => value is T;
|
|
11
|
+
/** Owned by the provider, including while the control is unmounted. Return cleanup. */
|
|
12
|
+
apply?: (value: T) => void | (() => void);
|
|
13
|
+
}
|
|
14
|
+
interface FeatureRegistration extends FeatureOptions<unknown> {
|
|
15
|
+
defaultValue: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface AccessibilityContextValue {
|
|
18
|
+
state: AccessibilityState;
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
panelId: string;
|
|
21
|
+
position: PluginPosition;
|
|
22
|
+
widgetPlacement: WidgetPlacement | null;
|
|
23
|
+
setWidgetPlacement: (next: WidgetPlacement | null) => void;
|
|
24
|
+
toggleOpen: () => void;
|
|
25
|
+
closeMenu: () => void;
|
|
26
|
+
getFeatureState: <T>(key: string, defaultValue: T) => T;
|
|
27
|
+
setFeatureState: <T>(key: string, value: T) => void;
|
|
28
|
+
registerFeature: (key: string, definition: FeatureRegistration) => void;
|
|
29
|
+
resetAll: () => void;
|
|
30
|
+
registerReset: (key: string, resetFn: () => void) => void;
|
|
31
|
+
unregisterReset: (key: string) => void;
|
|
32
|
+
}
|
|
33
|
+
type WidgetPlacement = {
|
|
34
|
+
kind: "corner";
|
|
35
|
+
corner: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
36
|
+
} | {
|
|
37
|
+
kind: "point";
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
type PluginPosition = "left" | "right" | "top" | "bottom";
|
|
42
|
+
interface AccessibilityPluginProps {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
position?: PluginPosition;
|
|
45
|
+
persistenceKey?: string;
|
|
46
|
+
/** Disable storage completely. */
|
|
47
|
+
persist?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface AccessibilityButtonProps {
|
|
50
|
+
/** Pointer dragging and Alt+Arrow movement. Defaults to true. */
|
|
51
|
+
draggable?: boolean;
|
|
52
|
+
icon?: ReactNode;
|
|
53
|
+
title?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
className?: string;
|
|
56
|
+
style?: CSSProperties;
|
|
57
|
+
}
|
|
58
|
+
interface AccessibilityListProps {
|
|
59
|
+
/** Additional always-visible actions next to ResetController. */
|
|
60
|
+
footer?: ReactNode;
|
|
61
|
+
/** Supporting panel text. Pass an empty string to omit it. */
|
|
62
|
+
description?: string;
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
className?: string;
|
|
65
|
+
style?: CSSProperties;
|
|
66
|
+
title?: string;
|
|
67
|
+
closeLabel?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare function AccessibilityPlugin({ children, position, persistenceKey, persist, }: AccessibilityPluginProps): react.JSX.Element;
|
|
71
|
+
|
|
72
|
+
declare function AccessibilityButton({ icon, draggable, title, description, className, style, }: AccessibilityButtonProps): react.JSX.Element;
|
|
73
|
+
|
|
74
|
+
declare function AccessibilityList(props: AccessibilityListProps): react.JSX.Element;
|
|
75
|
+
|
|
76
|
+
declare function useAccessibility<T>(featureKey: string, defaultValue: T, options?: FeatureOptions<T>): {
|
|
77
|
+
value: T;
|
|
78
|
+
setValue: (next: T) => void;
|
|
79
|
+
reset: () => void;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare const AccessibilityContext: react.Context<AccessibilityContextValue | null>;
|
|
83
|
+
|
|
84
|
+
declare function FontSizeController(): react.JSX.Element;
|
|
85
|
+
|
|
86
|
+
declare function LineHeightController(): react.JSX.Element;
|
|
87
|
+
|
|
88
|
+
declare function LetterSpacingController(): react.JSX.Element;
|
|
89
|
+
|
|
90
|
+
declare function ContrastController(): react.JSX.Element;
|
|
91
|
+
|
|
92
|
+
declare function SaturationController(): react.JSX.Element;
|
|
93
|
+
|
|
94
|
+
declare function InvertColorsController(): react.JSX.Element;
|
|
95
|
+
|
|
96
|
+
declare function GrayscaleController(): react.JSX.Element;
|
|
97
|
+
|
|
98
|
+
declare function LinkHighlightController(): react.JSX.Element;
|
|
99
|
+
|
|
100
|
+
declare function TextAlignController(): react.JSX.Element;
|
|
101
|
+
|
|
102
|
+
declare function HideImagesController(): react.JSX.Element;
|
|
103
|
+
|
|
104
|
+
declare function HideVideosController(): react.JSX.Element;
|
|
105
|
+
|
|
106
|
+
declare function BigCursorController(): react.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare function ReadingMaskController(): react.JSX.Element;
|
|
109
|
+
|
|
110
|
+
declare function ReadingGuideController(): react.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare function ResetController(): react.JSX.Element;
|
|
113
|
+
|
|
114
|
+
export { AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityState, BigCursorController, ContrastController, type FeatureOptions, type FeatureRegistration, FontSizeController, GrayscaleController, HideImagesController, HideVideosController, InvertColorsController, LetterSpacingController, LineHeightController, LinkHighlightController, type PluginPosition, ReadingGuideController, ReadingMaskController, ResetController, SaturationController, TextAlignController, type WidgetPlacement, useAccessibility };
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,114 @@
|
|
|
1
|
-
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
interface AccessibilityState {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
features: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface FeatureOptions<T> {
|
|
9
|
+
/** Validate restored and programmatic values. Required for structured custom state. */
|
|
10
|
+
validate?: (value: unknown) => value is T;
|
|
11
|
+
/** Owned by the provider, including while the control is unmounted. Return cleanup. */
|
|
12
|
+
apply?: (value: T) => void | (() => void);
|
|
13
|
+
}
|
|
14
|
+
interface FeatureRegistration extends FeatureOptions<unknown> {
|
|
15
|
+
defaultValue: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface AccessibilityContextValue {
|
|
18
|
+
state: AccessibilityState;
|
|
19
|
+
isOpen: boolean;
|
|
20
|
+
panelId: string;
|
|
21
|
+
position: PluginPosition;
|
|
22
|
+
widgetPlacement: WidgetPlacement | null;
|
|
23
|
+
setWidgetPlacement: (next: WidgetPlacement | null) => void;
|
|
24
|
+
toggleOpen: () => void;
|
|
25
|
+
closeMenu: () => void;
|
|
26
|
+
getFeatureState: <T>(key: string, defaultValue: T) => T;
|
|
27
|
+
setFeatureState: <T>(key: string, value: T) => void;
|
|
28
|
+
registerFeature: (key: string, definition: FeatureRegistration) => void;
|
|
29
|
+
resetAll: () => void;
|
|
30
|
+
registerReset: (key: string, resetFn: () => void) => void;
|
|
31
|
+
unregisterReset: (key: string) => void;
|
|
32
|
+
}
|
|
33
|
+
type WidgetPlacement = {
|
|
34
|
+
kind: "corner";
|
|
35
|
+
corner: "bottom-right" | "bottom-left" | "top-right" | "top-left";
|
|
36
|
+
} | {
|
|
37
|
+
kind: "point";
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
};
|
|
41
|
+
type PluginPosition = "left" | "right" | "top" | "bottom";
|
|
42
|
+
interface AccessibilityPluginProps {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
position?: PluginPosition;
|
|
45
|
+
persistenceKey?: string;
|
|
46
|
+
/** Disable storage completely. */
|
|
47
|
+
persist?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface AccessibilityButtonProps {
|
|
50
|
+
/** Pointer dragging and Alt+Arrow movement. Defaults to true. */
|
|
51
|
+
draggable?: boolean;
|
|
52
|
+
icon?: ReactNode;
|
|
53
|
+
title?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
className?: string;
|
|
56
|
+
style?: CSSProperties;
|
|
57
|
+
}
|
|
58
|
+
interface AccessibilityListProps {
|
|
59
|
+
/** Additional always-visible actions next to ResetController. */
|
|
60
|
+
footer?: ReactNode;
|
|
61
|
+
/** Supporting panel text. Pass an empty string to omit it. */
|
|
62
|
+
description?: string;
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
className?: string;
|
|
65
|
+
style?: CSSProperties;
|
|
66
|
+
title?: string;
|
|
67
|
+
closeLabel?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
declare function AccessibilityPlugin({ children, position, persistenceKey, persist, }: AccessibilityPluginProps): react.JSX.Element;
|
|
71
|
+
|
|
72
|
+
declare function AccessibilityButton({ icon, draggable, title, description, className, style, }: AccessibilityButtonProps): react.JSX.Element;
|
|
73
|
+
|
|
74
|
+
declare function AccessibilityList(props: AccessibilityListProps): react.JSX.Element;
|
|
75
|
+
|
|
76
|
+
declare function useAccessibility<T>(featureKey: string, defaultValue: T, options?: FeatureOptions<T>): {
|
|
77
|
+
value: T;
|
|
78
|
+
setValue: (next: T) => void;
|
|
79
|
+
reset: () => void;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
declare const AccessibilityContext: react.Context<AccessibilityContextValue | null>;
|
|
83
|
+
|
|
84
|
+
declare function FontSizeController(): react.JSX.Element;
|
|
85
|
+
|
|
86
|
+
declare function LineHeightController(): react.JSX.Element;
|
|
87
|
+
|
|
88
|
+
declare function LetterSpacingController(): react.JSX.Element;
|
|
89
|
+
|
|
90
|
+
declare function ContrastController(): react.JSX.Element;
|
|
91
|
+
|
|
92
|
+
declare function SaturationController(): react.JSX.Element;
|
|
93
|
+
|
|
94
|
+
declare function InvertColorsController(): react.JSX.Element;
|
|
95
|
+
|
|
96
|
+
declare function GrayscaleController(): react.JSX.Element;
|
|
97
|
+
|
|
98
|
+
declare function LinkHighlightController(): react.JSX.Element;
|
|
99
|
+
|
|
100
|
+
declare function TextAlignController(): react.JSX.Element;
|
|
101
|
+
|
|
102
|
+
declare function HideImagesController(): react.JSX.Element;
|
|
103
|
+
|
|
104
|
+
declare function HideVideosController(): react.JSX.Element;
|
|
105
|
+
|
|
106
|
+
declare function BigCursorController(): react.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare function ReadingMaskController(): react.JSX.Element;
|
|
109
|
+
|
|
110
|
+
declare function ReadingGuideController(): react.JSX.Element;
|
|
111
|
+
|
|
112
|
+
declare function ResetController(): react.JSX.Element;
|
|
113
|
+
|
|
114
|
+
export { AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityState, BigCursorController, ContrastController, type FeatureOptions, type FeatureRegistration, FontSizeController, GrayscaleController, HideImagesController, HideVideosController, InvertColorsController, LetterSpacingController, LineHeightController, LinkHighlightController, type PluginPosition, ReadingGuideController, ReadingMaskController, ResetController, SaturationController, TextAlignController, type WidgetPlacement, useAccessibility };
|