accessibility-plugin-react 1.0.0 → 2.0.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/LICENSE +15 -0
- package/README.md +77 -45
- 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 +92 -0
- package/docs/MIGRATION.md +40 -0
- package/docs/PROJECT_STATUS.md +95 -0
- package/docs/RELEASE.md +107 -0
- package/docs/ROADMAP.md +29 -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/dist/index.mjs
ADDED
|
@@ -0,0 +1,1657 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/core/AccessibilityPlugin.tsx
|
|
5
|
+
import {
|
|
6
|
+
useCallback as useCallback2,
|
|
7
|
+
useEffect as useEffect2,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo,
|
|
10
|
+
useRef,
|
|
11
|
+
useState,
|
|
12
|
+
useSyncExternalStore as useSyncExternalStore2
|
|
13
|
+
} from "react";
|
|
14
|
+
|
|
15
|
+
// src/core/AccessibilityContext.ts
|
|
16
|
+
import { createContext } from "react";
|
|
17
|
+
var AccessibilityContext = createContext(null);
|
|
18
|
+
|
|
19
|
+
// src/core/widgetPlacement.ts
|
|
20
|
+
import { useCallback, useSyncExternalStore } from "react";
|
|
21
|
+
var PLACEMENT_KEY = "__arap_widget_placement";
|
|
22
|
+
var corners = [
|
|
23
|
+
"bottom-right",
|
|
24
|
+
"bottom-left",
|
|
25
|
+
"top-right",
|
|
26
|
+
"top-left"
|
|
27
|
+
];
|
|
28
|
+
function validPlacement(value) {
|
|
29
|
+
if (!value || typeof value !== "object") return false;
|
|
30
|
+
const p = value;
|
|
31
|
+
return p.kind === "corner" ? corners.some((corner) => corner === p.corner) : p.kind === "point" && typeof p.x === "number" && typeof p.y === "number" && Number.isFinite(p.x) && Number.isFinite(p.y) && p.x >= 0 && p.x <= 1 && p.y >= 0 && p.y <= 1;
|
|
32
|
+
}
|
|
33
|
+
function defaultCorner(position) {
|
|
34
|
+
return position === "left" ? "bottom-left" : position === "top" ? "top-right" : "bottom-right";
|
|
35
|
+
}
|
|
36
|
+
var subscribe = (listener) => {
|
|
37
|
+
window.addEventListener("resize", listener);
|
|
38
|
+
return () => window.removeEventListener("resize", listener);
|
|
39
|
+
};
|
|
40
|
+
var snapshot = () => `${window.innerWidth},${window.innerHeight}`;
|
|
41
|
+
function useViewport() {
|
|
42
|
+
return useSyncExternalStore(subscribe, snapshot, () => "0,0").split(",").map(Number);
|
|
43
|
+
}
|
|
44
|
+
function pointFromPixels(left, top, width = 56, height = 56) {
|
|
45
|
+
return {
|
|
46
|
+
kind: "point",
|
|
47
|
+
x: Math.max(0, Math.min(1, left / Math.max(1, window.innerWidth - width))),
|
|
48
|
+
y: Math.max(0, Math.min(1, top / Math.max(1, window.innerHeight - height)))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function useTriggerSize(id) {
|
|
52
|
+
const subscribeSize = useCallback(
|
|
53
|
+
(listener) => {
|
|
54
|
+
const element = document.getElementById(id);
|
|
55
|
+
if (typeof ResizeObserver === "undefined" || !element)
|
|
56
|
+
return subscribe(listener);
|
|
57
|
+
const observer = new ResizeObserver(listener);
|
|
58
|
+
observer.observe(element);
|
|
59
|
+
return () => observer.disconnect();
|
|
60
|
+
},
|
|
61
|
+
[id]
|
|
62
|
+
);
|
|
63
|
+
const getSize = useCallback(() => {
|
|
64
|
+
const rect = document.getElementById(id)?.getBoundingClientRect();
|
|
65
|
+
return `${rect?.width || 56},${rect?.height || 56}`;
|
|
66
|
+
}, [id]);
|
|
67
|
+
return useSyncExternalStore(subscribeSize, getSize, () => "56,56").split(",").map(Number);
|
|
68
|
+
}
|
|
69
|
+
function pointCoordinates(p, viewport, size) {
|
|
70
|
+
return [
|
|
71
|
+
Math.max(
|
|
72
|
+
16,
|
|
73
|
+
Math.min(viewport[0] - size[0] - 16, p.x * (viewport[0] - size[0]))
|
|
74
|
+
),
|
|
75
|
+
Math.max(
|
|
76
|
+
16,
|
|
77
|
+
Math.min(viewport[1] - size[1] - 16, p.y * (viewport[1] - size[1]))
|
|
78
|
+
)
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
function pointStyle(p, viewport, size = [56, 56]) {
|
|
82
|
+
if (p?.kind !== "point") return void 0;
|
|
83
|
+
const [left, top] = pointCoordinates(p, viewport, size);
|
|
84
|
+
return {
|
|
85
|
+
left: `clamp(max(16px, env(safe-area-inset-left)), ${left}px, max(16px, calc(100vw - ${size[0]}px - max(16px, env(safe-area-inset-right)))))`,
|
|
86
|
+
top: `clamp(max(16px, env(safe-area-inset-top)), ${top}px, max(16px, calc(100dvh - ${size[1]}px - max(16px, env(safe-area-inset-bottom)))))`,
|
|
87
|
+
right: "auto",
|
|
88
|
+
bottom: "auto"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function panelStyle(p, viewport, size = [56, 56]) {
|
|
92
|
+
if (p?.kind !== "point") return void 0;
|
|
93
|
+
const [width, height] = viewport;
|
|
94
|
+
const [left, top] = pointCoordinates(p, viewport, size);
|
|
95
|
+
const below = top < (height - size[1]) / 2;
|
|
96
|
+
const offset = below ? top + size[1] + 12 : height - top + 12;
|
|
97
|
+
const side = below ? "top" : "bottom", opposite = below ? "bottom" : "top";
|
|
98
|
+
const offsetCss = `max(${offset}px, calc(max(16px, env(safe-area-inset-${side})) + ${size[1] + 12}px))`;
|
|
99
|
+
return {
|
|
100
|
+
left: `clamp(max(16px, env(safe-area-inset-left)), ${left}px, max(16px, calc(100vw - ${Math.min(400, width - 32)}px - max(16px, env(safe-area-inset-right)))))`,
|
|
101
|
+
right: "auto",
|
|
102
|
+
top: below ? offsetCss : "auto",
|
|
103
|
+
bottom: below ? "auto" : offsetCss,
|
|
104
|
+
maxHeight: `max(0px, calc(100dvh - ${offsetCss} - max(16px, env(safe-area-inset-${opposite}))))`
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/core/storage.ts
|
|
109
|
+
var DEFAULT_STORAGE_KEY = "react-accessibility-plugin:state";
|
|
110
|
+
var forbidden = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
111
|
+
function validKey(key) {
|
|
112
|
+
return typeof key === "string" && key.length > 0 && !forbidden.has(key);
|
|
113
|
+
}
|
|
114
|
+
function isRecord(value) {
|
|
115
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
116
|
+
}
|
|
117
|
+
function loadState(key = DEFAULT_STORAGE_KEY) {
|
|
118
|
+
try {
|
|
119
|
+
const raw = JSON.parse(localStorage.getItem(key) || "null");
|
|
120
|
+
if (!isRecord(raw)) return null;
|
|
121
|
+
const features = "version" in raw ? raw.version === 1 ? raw.features : null : raw;
|
|
122
|
+
if (!isRecord(features)) return null;
|
|
123
|
+
return Object.fromEntries(
|
|
124
|
+
Object.entries(features).filter(([name]) => validKey(name))
|
|
125
|
+
);
|
|
126
|
+
} catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function saveState(state, key = DEFAULT_STORAGE_KEY) {
|
|
131
|
+
try {
|
|
132
|
+
localStorage.setItem(key, JSON.stringify({ version: 1, features: state }));
|
|
133
|
+
} catch {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function clearState(key = DEFAULT_STORAGE_KEY) {
|
|
137
|
+
try {
|
|
138
|
+
localStorage.removeItem(key);
|
|
139
|
+
} catch {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
143
|
+
let timer;
|
|
144
|
+
let pending;
|
|
145
|
+
const cancel = () => {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = void 0;
|
|
148
|
+
pending = void 0;
|
|
149
|
+
};
|
|
150
|
+
const flush = () => {
|
|
151
|
+
const next = pending;
|
|
152
|
+
cancel();
|
|
153
|
+
if (next) saveState(next, key);
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
schedule(state) {
|
|
157
|
+
cancel();
|
|
158
|
+
pending = state;
|
|
159
|
+
timer = setTimeout(flush, 200);
|
|
160
|
+
},
|
|
161
|
+
clear() {
|
|
162
|
+
cancel();
|
|
163
|
+
clearState(key);
|
|
164
|
+
},
|
|
165
|
+
cancel,
|
|
166
|
+
flush
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/core/preferenceStore.ts
|
|
171
|
+
function createPreferenceStore(key, persist) {
|
|
172
|
+
const writer = createStorageWriter(key);
|
|
173
|
+
const empty = {};
|
|
174
|
+
let snapshot2;
|
|
175
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
176
|
+
const getSnapshot = () => {
|
|
177
|
+
snapshot2 ?? (snapshot2 = persist ? loadState(key) ?? {} : {});
|
|
178
|
+
return snapshot2;
|
|
179
|
+
};
|
|
180
|
+
return {
|
|
181
|
+
getSnapshot,
|
|
182
|
+
getServerSnapshot: () => empty,
|
|
183
|
+
subscribe(listener) {
|
|
184
|
+
listeners.add(listener);
|
|
185
|
+
return () => {
|
|
186
|
+
listeners.delete(listener);
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
update(update) {
|
|
190
|
+
snapshot2 = update(getSnapshot());
|
|
191
|
+
if (persist) {
|
|
192
|
+
if (Object.keys(snapshot2).length) writer.schedule(snapshot2);
|
|
193
|
+
else writer.clear();
|
|
194
|
+
}
|
|
195
|
+
listeners.forEach((listener) => listener());
|
|
196
|
+
},
|
|
197
|
+
flush: writer.flush
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/core/featureSchema.ts
|
|
202
|
+
var numberIn = (min, max) => (v) => typeof v === "number" && Number.isFinite(v) && v >= min && v <= max;
|
|
203
|
+
var oneOf = (...values) => (v) => values.includes(v);
|
|
204
|
+
var builtins = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
205
|
+
fontSize: { defaultValue: 100, validate: numberIn(50, 200) },
|
|
206
|
+
lineHeight: { defaultValue: 100, validate: numberIn(50, 200) },
|
|
207
|
+
letterSpacing: { defaultValue: 0, validate: numberIn(0, 10) },
|
|
208
|
+
contrast: {
|
|
209
|
+
defaultValue: 0,
|
|
210
|
+
validate: oneOf(
|
|
211
|
+
0,
|
|
212
|
+
1,
|
|
213
|
+
2,
|
|
214
|
+
3,
|
|
215
|
+
"reduced",
|
|
216
|
+
"yellow-on-black",
|
|
217
|
+
"white-on-black",
|
|
218
|
+
"blue-on-yellow"
|
|
219
|
+
)
|
|
220
|
+
},
|
|
221
|
+
saturation: { defaultValue: 0, validate: oneOf(0, 1, 2) },
|
|
222
|
+
textAlign: {
|
|
223
|
+
defaultValue: "default",
|
|
224
|
+
validate: oneOf("default", "left", "center", "right", "justify")
|
|
225
|
+
},
|
|
226
|
+
linkHighlight: {
|
|
227
|
+
defaultValue: false,
|
|
228
|
+
validate: oneOf(
|
|
229
|
+
false,
|
|
230
|
+
true,
|
|
231
|
+
"yellow-on-black",
|
|
232
|
+
"blue-on-yellow",
|
|
233
|
+
"black-on-white"
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
for (const key of [
|
|
238
|
+
"invertColors",
|
|
239
|
+
"grayscale",
|
|
240
|
+
"hideImages",
|
|
241
|
+
"hideVideos",
|
|
242
|
+
"bigCursor",
|
|
243
|
+
"readingMask",
|
|
244
|
+
"readingGuide"
|
|
245
|
+
]) {
|
|
246
|
+
builtins[key] = {
|
|
247
|
+
defaultValue: false,
|
|
248
|
+
validate: (v) => typeof v === "boolean"
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function validValue(key, value, fallback, validate) {
|
|
252
|
+
if (builtins[key]) return builtins[key].validate(value);
|
|
253
|
+
if (validate) {
|
|
254
|
+
try {
|
|
255
|
+
return validate(value);
|
|
256
|
+
} catch {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return value === null ? fallback === null : typeof value === typeof fallback && (typeof value !== "number" || Number.isFinite(value)) && (typeof value !== "object" || Array.isArray(value) === Array.isArray(fallback));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/core/effects.ts
|
|
264
|
+
import { useEffect } from "react";
|
|
265
|
+
var EXCLUDED = "[data-arap-ui], [data-arap-ui] *, script, style, link, meta";
|
|
266
|
+
var cursor = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M4 2v32l9-9 7 13 6-3-7-12h14z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 4 2, auto`;
|
|
267
|
+
var palette = {
|
|
268
|
+
"yellow-on-black": ["#ffff00", "#000000"],
|
|
269
|
+
"white-on-black": ["#ffffff", "#000000"],
|
|
270
|
+
"blue-on-yellow": ["#005a9c", "#ffd740"],
|
|
271
|
+
"black-on-white": ["#000000", "#ffffff"]
|
|
272
|
+
};
|
|
273
|
+
function composeFilter(values) {
|
|
274
|
+
const contrast = values.contrast === "reduced" ? 0.5 : [1, 1.25, 1.5, 2][Number(values.contrast)] ?? 1;
|
|
275
|
+
return [
|
|
276
|
+
contrast !== 1 && `contrast(${contrast})`,
|
|
277
|
+
values.saturation === 1 && "saturate(0.2)",
|
|
278
|
+
values.saturation === 2 && "saturate(2)",
|
|
279
|
+
values.invertColors && "invert(1)",
|
|
280
|
+
values.grayscale && "grayscale(1)"
|
|
281
|
+
].filter(Boolean).join(" ");
|
|
282
|
+
}
|
|
283
|
+
function applyPage(values) {
|
|
284
|
+
const undo = [];
|
|
285
|
+
function set(element, property, value) {
|
|
286
|
+
const previous = element.style.getPropertyValue(property);
|
|
287
|
+
const priority = element.style.getPropertyPriority(property);
|
|
288
|
+
element.style.setProperty(property, value, "important");
|
|
289
|
+
const applied = element.style.getPropertyValue(property);
|
|
290
|
+
undo.push(() => {
|
|
291
|
+
if (element.style.getPropertyValue(property) !== applied || element.style.getPropertyPriority(property) !== "important")
|
|
292
|
+
return;
|
|
293
|
+
if (previous) element.style.setProperty(property, previous, priority);
|
|
294
|
+
else element.style.removeProperty(property);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
const elements = Array.from(
|
|
298
|
+
document.body.querySelectorAll("*")
|
|
299
|
+
).filter((el) => el instanceof HTMLElement && !el.matches(EXCLUDED));
|
|
300
|
+
const font = Number(values.fontSize ?? 100) / 100;
|
|
301
|
+
const line = Number(values.lineHeight ?? 100) / 100;
|
|
302
|
+
const measurements = font !== 1 || line !== 1 ? elements.map((el) => {
|
|
303
|
+
const computed = getComputedStyle(el);
|
|
304
|
+
return {
|
|
305
|
+
el,
|
|
306
|
+
font: parseFloat(computed.fontSize) || 16,
|
|
307
|
+
line: parseFloat(computed.lineHeight) || (parseFloat(computed.fontSize) || 16) * 1.2
|
|
308
|
+
};
|
|
309
|
+
}) : [];
|
|
310
|
+
for (const measured of measurements) {
|
|
311
|
+
if (font !== 1) set(measured.el, "font-size", `${measured.font * font}px`);
|
|
312
|
+
if (line !== 1 || font !== 1)
|
|
313
|
+
set(measured.el, "line-height", `${measured.line * line * font}px`);
|
|
314
|
+
}
|
|
315
|
+
const filter = composeFilter(values);
|
|
316
|
+
for (const el of Array.from(document.body.children)) {
|
|
317
|
+
if (!(el instanceof HTMLElement) || el.matches(EXCLUDED) || !filter)
|
|
318
|
+
continue;
|
|
319
|
+
const computed = getComputedStyle(el);
|
|
320
|
+
if (computed.backgroundColor === "rgba(0, 0, 0, 0)" || computed.backgroundColor === "transparent") {
|
|
321
|
+
const bodyColor = getComputedStyle(document.body).backgroundColor;
|
|
322
|
+
set(
|
|
323
|
+
el,
|
|
324
|
+
"background-color",
|
|
325
|
+
bodyColor && bodyColor !== "rgba(0, 0, 0, 0)" && bodyColor !== "transparent" ? bodyColor : "#ffffff"
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
const base = computed.filter;
|
|
329
|
+
set(el, "filter", `${base && base !== "none" ? base + " " : ""}${filter}`);
|
|
330
|
+
}
|
|
331
|
+
for (const el of elements) {
|
|
332
|
+
if (Number(values.letterSpacing) > 0)
|
|
333
|
+
set(el, "letter-spacing", `${values.letterSpacing}px`);
|
|
334
|
+
if (values.textAlign && values.textAlign !== "default")
|
|
335
|
+
set(el, "text-align", String(values.textAlign));
|
|
336
|
+
if (values.bigCursor) set(el, "cursor", cursor);
|
|
337
|
+
if (values.hideImages) {
|
|
338
|
+
if (el.matches("img, picture")) set(el, "visibility", "hidden");
|
|
339
|
+
set(el, "background-image", "none");
|
|
340
|
+
}
|
|
341
|
+
if (values.hideVideos && el.matches(
|
|
342
|
+
'video, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="player.vimeo.com/video/"]'
|
|
343
|
+
))
|
|
344
|
+
set(el, "visibility", "hidden");
|
|
345
|
+
const colors = palette[String(values.contrast)];
|
|
346
|
+
if (colors) {
|
|
347
|
+
set(el, "color", colors[0]);
|
|
348
|
+
set(el, "background-color", colors[1]);
|
|
349
|
+
}
|
|
350
|
+
if (values.linkHighlight && el.matches("a[href]")) {
|
|
351
|
+
const colors2 = palette[String(values.linkHighlight)] ?? [
|
|
352
|
+
"#111827",
|
|
353
|
+
"#fef08a"
|
|
354
|
+
];
|
|
355
|
+
set(el, "color", colors2[0]);
|
|
356
|
+
set(el, "background-color", colors2[1]);
|
|
357
|
+
set(el, "text-decoration", "underline");
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return () => {
|
|
361
|
+
for (const restore of undo.reverse()) restore();
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function readingAid(mask) {
|
|
365
|
+
const el = document.createElement("div");
|
|
366
|
+
el.dataset.arapUi = "";
|
|
367
|
+
el.className = mask ? "arap-reading-mask" : "arap-reading-guide";
|
|
368
|
+
el.setAttribute("aria-hidden", "true");
|
|
369
|
+
el.style.cssText = `position:fixed;left:0;right:0;top:50%;height:${mask ? "100px" : "4px"};pointer-events:none;z-index:2147482999;${mask ? "background:transparent;box-shadow:0 0 0 200vmax rgba(0,0,0,.65)" : "background:#2563eb;border:1px solid white"}`;
|
|
370
|
+
document.body.appendChild(el);
|
|
371
|
+
const move = (y) => {
|
|
372
|
+
el.style.top = `${Math.max(0, y - (mask ? 50 : 0))}px`;
|
|
373
|
+
};
|
|
374
|
+
const pointer = (event) => move(event.clientY);
|
|
375
|
+
const focus = (event) => {
|
|
376
|
+
if (event.target instanceof HTMLElement && !event.target.closest("[data-arap-ui]")) {
|
|
377
|
+
const rect = event.target.getBoundingClientRect();
|
|
378
|
+
move(rect.top + rect.height / 2);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
document.addEventListener("pointermove", pointer, { passive: true });
|
|
382
|
+
document.addEventListener("focusin", focus);
|
|
383
|
+
return () => {
|
|
384
|
+
document.removeEventListener("pointermove", pointer);
|
|
385
|
+
document.removeEventListener("focusin", focus);
|
|
386
|
+
el.remove();
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
function useBuiltinEffects(values) {
|
|
390
|
+
useEffect(() => {
|
|
391
|
+
if (!Object.entries(values).some(
|
|
392
|
+
([key, value]) => key in builtins && value !== builtins[key].defaultValue
|
|
393
|
+
))
|
|
394
|
+
return;
|
|
395
|
+
let undo = applyPage(values);
|
|
396
|
+
const observer = new MutationObserver((records) => {
|
|
397
|
+
if (!records.some(
|
|
398
|
+
(record) => record.target instanceof Element && !record.target.closest("[data-arap-ui]") && [...record.addedNodes, ...record.removedNodes].some(
|
|
399
|
+
(node) => node instanceof Element && !node.matches("[data-arap-ui]")
|
|
400
|
+
)
|
|
401
|
+
))
|
|
402
|
+
return;
|
|
403
|
+
undo();
|
|
404
|
+
undo = applyPage(values);
|
|
405
|
+
});
|
|
406
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
407
|
+
const resize = () => {
|
|
408
|
+
undo();
|
|
409
|
+
undo = applyPage(values);
|
|
410
|
+
};
|
|
411
|
+
window.addEventListener("resize", resize);
|
|
412
|
+
return () => {
|
|
413
|
+
observer.disconnect();
|
|
414
|
+
window.removeEventListener("resize", resize);
|
|
415
|
+
undo();
|
|
416
|
+
};
|
|
417
|
+
}, [values]);
|
|
418
|
+
useEffect(
|
|
419
|
+
() => values.readingMask ? readingAid(true) : void 0,
|
|
420
|
+
[values.readingMask]
|
|
421
|
+
);
|
|
422
|
+
useEffect(
|
|
423
|
+
() => values.readingGuide ? readingAid(false) : void 0,
|
|
424
|
+
[values.readingGuide]
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
function CustomEffect({
|
|
428
|
+
definition,
|
|
429
|
+
value
|
|
430
|
+
}) {
|
|
431
|
+
useEffect(() => definition.apply?.(value), [definition, value]);
|
|
432
|
+
return null;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/core/AccessibilityPlugin.tsx
|
|
436
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
437
|
+
var owners = /* @__PURE__ */ new WeakMap();
|
|
438
|
+
function AccessibilityPlugin({
|
|
439
|
+
children,
|
|
440
|
+
position = "right",
|
|
441
|
+
persistenceKey,
|
|
442
|
+
persist = true
|
|
443
|
+
}) {
|
|
444
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
445
|
+
const [store] = useState(
|
|
446
|
+
() => createPreferenceStore(persistenceKey, persist)
|
|
447
|
+
);
|
|
448
|
+
const features = useSyncExternalStore2(
|
|
449
|
+
store.subscribe,
|
|
450
|
+
store.getSnapshot,
|
|
451
|
+
store.getServerSnapshot
|
|
452
|
+
);
|
|
453
|
+
const setFeatures = store.update;
|
|
454
|
+
const widgetPlacement = validPlacement(features[PLACEMENT_KEY]) ? features[PLACEMENT_KEY] : null;
|
|
455
|
+
const setWidgetPlacement = useCallback2(
|
|
456
|
+
(next) => {
|
|
457
|
+
if (next !== null && !validPlacement(next))
|
|
458
|
+
throw new Error("Invalid widget placement.");
|
|
459
|
+
setFeatures((previous) => {
|
|
460
|
+
const copy = { ...previous };
|
|
461
|
+
if (next) copy[PLACEMENT_KEY] = next;
|
|
462
|
+
else delete copy[PLACEMENT_KEY];
|
|
463
|
+
return copy;
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
[setFeatures]
|
|
467
|
+
);
|
|
468
|
+
const registrations = useRef(/* @__PURE__ */ new Map());
|
|
469
|
+
const [definitions, setDefinitions] = useState({});
|
|
470
|
+
const panelId = `arap-${useId()}`;
|
|
471
|
+
const owner = useRef({});
|
|
472
|
+
const [initialKey] = useState(persistenceKey);
|
|
473
|
+
const [initialPersist] = useState(persist);
|
|
474
|
+
if (initialKey !== persistenceKey || initialPersist !== persist)
|
|
475
|
+
throw new Error(
|
|
476
|
+
"Remount AccessibilityPlugin with a React key to change persistence configuration."
|
|
477
|
+
);
|
|
478
|
+
const resetFns = useRef(/* @__PURE__ */ new Map());
|
|
479
|
+
useEffect2(() => {
|
|
480
|
+
if (owners.has(document))
|
|
481
|
+
throw new Error(
|
|
482
|
+
"Only one AccessibilityPlugin may own a document. Mount it above your routes."
|
|
483
|
+
);
|
|
484
|
+
const token = owner.current;
|
|
485
|
+
owners.set(document, token);
|
|
486
|
+
const flush = () => store.flush();
|
|
487
|
+
window.addEventListener("pagehide", flush);
|
|
488
|
+
return () => {
|
|
489
|
+
window.removeEventListener("pagehide", flush);
|
|
490
|
+
store.flush();
|
|
491
|
+
if (owners.get(document) === token) owners.delete(document);
|
|
492
|
+
};
|
|
493
|
+
}, [store]);
|
|
494
|
+
const registerFeature = useCallback2(
|
|
495
|
+
(key, definition) => {
|
|
496
|
+
if (!validKey(key) || key === PLACEMENT_KEY)
|
|
497
|
+
throw new Error("Invalid feature key.");
|
|
498
|
+
if (registrations.current.has(key)) return;
|
|
499
|
+
registrations.current.set(key, definition);
|
|
500
|
+
setDefinitions((previous) => ({ ...previous, [key]: definition }));
|
|
501
|
+
},
|
|
502
|
+
[]
|
|
503
|
+
);
|
|
504
|
+
const getFeatureState = useCallback2(
|
|
505
|
+
(key, fallback) => {
|
|
506
|
+
const definition = Object.prototype.hasOwnProperty.call(definitions, key) ? definitions[key] : void 0;
|
|
507
|
+
const value2 = features[key];
|
|
508
|
+
return Object.prototype.hasOwnProperty.call(features, key) && validValue(key, value2, fallback, definition?.validate) ? value2 : fallback;
|
|
509
|
+
},
|
|
510
|
+
[features, definitions]
|
|
511
|
+
);
|
|
512
|
+
const setFeatureState = useCallback2(
|
|
513
|
+
(key, value2) => {
|
|
514
|
+
const definition = registrations.current.get(key);
|
|
515
|
+
if (!validKey(key) || !definition || !validValue(key, value2, definition.defaultValue, definition.validate))
|
|
516
|
+
throw new Error(`Invalid value or unregistered feature: ${key}`);
|
|
517
|
+
setFeatures((previous) => ({ ...previous, [key]: value2 }));
|
|
518
|
+
},
|
|
519
|
+
[setFeatures]
|
|
520
|
+
);
|
|
521
|
+
const resetAll = useCallback2(() => {
|
|
522
|
+
resetFns.current.forEach((fn) => fn());
|
|
523
|
+
setFeatures(
|
|
524
|
+
(previous) => validPlacement(previous[PLACEMENT_KEY]) ? { [PLACEMENT_KEY]: previous[PLACEMENT_KEY] } : {}
|
|
525
|
+
);
|
|
526
|
+
}, [setFeatures]);
|
|
527
|
+
const registerReset = useCallback2((key, fn) => {
|
|
528
|
+
resetFns.current.set(key, fn);
|
|
529
|
+
}, []);
|
|
530
|
+
const unregisterReset = useCallback2((key) => {
|
|
531
|
+
resetFns.current.delete(key);
|
|
532
|
+
}, []);
|
|
533
|
+
const toggleOpen = useCallback2(() => setIsOpen((previous) => !previous), []);
|
|
534
|
+
const closeMenu = useCallback2(() => setIsOpen(false), []);
|
|
535
|
+
const active = useMemo(
|
|
536
|
+
() => Object.fromEntries(
|
|
537
|
+
Object.entries(definitions).filter(([key]) => key in builtins).map(([key]) => [
|
|
538
|
+
key,
|
|
539
|
+
getFeatureState(key, builtins[key].defaultValue)
|
|
540
|
+
])
|
|
541
|
+
),
|
|
542
|
+
[definitions, getFeatureState]
|
|
543
|
+
);
|
|
544
|
+
useBuiltinEffects(active);
|
|
545
|
+
const value = useMemo(
|
|
546
|
+
() => ({
|
|
547
|
+
state: { isOpen, features },
|
|
548
|
+
isOpen,
|
|
549
|
+
panelId,
|
|
550
|
+
position,
|
|
551
|
+
widgetPlacement,
|
|
552
|
+
setWidgetPlacement,
|
|
553
|
+
toggleOpen,
|
|
554
|
+
closeMenu,
|
|
555
|
+
getFeatureState,
|
|
556
|
+
setFeatureState,
|
|
557
|
+
registerFeature,
|
|
558
|
+
resetAll,
|
|
559
|
+
registerReset,
|
|
560
|
+
unregisterReset
|
|
561
|
+
}),
|
|
562
|
+
[
|
|
563
|
+
isOpen,
|
|
564
|
+
features,
|
|
565
|
+
panelId,
|
|
566
|
+
position,
|
|
567
|
+
widgetPlacement,
|
|
568
|
+
setWidgetPlacement,
|
|
569
|
+
toggleOpen,
|
|
570
|
+
closeMenu,
|
|
571
|
+
getFeatureState,
|
|
572
|
+
setFeatureState,
|
|
573
|
+
registerFeature,
|
|
574
|
+
resetAll,
|
|
575
|
+
registerReset,
|
|
576
|
+
unregisterReset
|
|
577
|
+
]
|
|
578
|
+
);
|
|
579
|
+
return /* @__PURE__ */ jsxs(AccessibilityContext.Provider, { value, children: [
|
|
580
|
+
children,
|
|
581
|
+
Object.entries(definitions).filter(([, definition]) => definition.apply).map(([key, definition]) => /* @__PURE__ */ jsx(
|
|
582
|
+
CustomEffect,
|
|
583
|
+
{
|
|
584
|
+
definition,
|
|
585
|
+
value: getFeatureState(key, definition.defaultValue)
|
|
586
|
+
},
|
|
587
|
+
key
|
|
588
|
+
))
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// src/core/AccessibilityButton.tsx
|
|
593
|
+
import { useContext, useRef as useRef2, useState as useState2 } from "react";
|
|
594
|
+
|
|
595
|
+
// src/core/WidgetPortal.tsx
|
|
596
|
+
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
597
|
+
import { createPortal } from "react-dom";
|
|
598
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
599
|
+
var subscribe2 = () => () => {
|
|
600
|
+
};
|
|
601
|
+
var clientSnapshot = () => true;
|
|
602
|
+
var serverSnapshot = () => false;
|
|
603
|
+
function WidgetPortal({ children }) {
|
|
604
|
+
const mounted = useSyncExternalStore3(
|
|
605
|
+
subscribe2,
|
|
606
|
+
clientSnapshot,
|
|
607
|
+
serverSnapshot
|
|
608
|
+
);
|
|
609
|
+
return mounted ? createPortal(
|
|
610
|
+
/* @__PURE__ */ jsx2("div", { "data-arap-ui": "", className: "arap-root", children }),
|
|
611
|
+
document.body
|
|
612
|
+
) : null;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/core/AccessibilityButton.tsx
|
|
616
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
617
|
+
function AccessibilityButton({
|
|
618
|
+
icon,
|
|
619
|
+
draggable = true,
|
|
620
|
+
title = "Accessibility",
|
|
621
|
+
description,
|
|
622
|
+
className = "",
|
|
623
|
+
style
|
|
624
|
+
}) {
|
|
625
|
+
const ctx = useContext(AccessibilityContext);
|
|
626
|
+
if (!ctx)
|
|
627
|
+
throw new Error(
|
|
628
|
+
"AccessibilityButton must be used within an <AccessibilityPlugin> provider."
|
|
629
|
+
);
|
|
630
|
+
const viewport = useViewport();
|
|
631
|
+
const triggerSize = useTriggerSize(`${ctx.panelId}-trigger`);
|
|
632
|
+
const [preview, setPreview] = useState2(null);
|
|
633
|
+
const drag = useRef2(null);
|
|
634
|
+
const suppressClick = useRef2(false);
|
|
635
|
+
const placement = preview ?? ctx.widgetPlacement;
|
|
636
|
+
const corner = placement?.kind === "corner" ? placement.corner : defaultCorner(ctx.position);
|
|
637
|
+
return /* @__PURE__ */ jsxs2(WidgetPortal, { children: [
|
|
638
|
+
/* @__PURE__ */ jsxs2(
|
|
639
|
+
"button",
|
|
640
|
+
{
|
|
641
|
+
type: "button",
|
|
642
|
+
className: `arap-btn ${className}`,
|
|
643
|
+
id: `${ctx.panelId}-trigger`,
|
|
644
|
+
style: { ...pointStyle(placement, viewport, triggerSize), ...style },
|
|
645
|
+
"data-corner": corner,
|
|
646
|
+
"data-draggable": draggable,
|
|
647
|
+
"data-dragging": !!preview,
|
|
648
|
+
"data-open": ctx.isOpen,
|
|
649
|
+
"data-position": ctx.position,
|
|
650
|
+
onPointerDown: (event) => {
|
|
651
|
+
suppressClick.current = false;
|
|
652
|
+
if (!draggable || !event.isPrimary || event.button !== 0) return;
|
|
653
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
654
|
+
drag.current = {
|
|
655
|
+
id: event.pointerId,
|
|
656
|
+
startX: event.clientX,
|
|
657
|
+
startY: event.clientY,
|
|
658
|
+
left: bounds.left,
|
|
659
|
+
top: bounds.top,
|
|
660
|
+
width: bounds.width,
|
|
661
|
+
height: bounds.height,
|
|
662
|
+
moved: false,
|
|
663
|
+
next: null
|
|
664
|
+
};
|
|
665
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
666
|
+
},
|
|
667
|
+
onPointerMove: (event) => {
|
|
668
|
+
const current = drag.current;
|
|
669
|
+
if (!current || current.id !== event.pointerId) return;
|
|
670
|
+
const dx = event.clientX - current.startX, dy = event.clientY - current.startY;
|
|
671
|
+
if (!current.moved && Math.hypot(dx, dy) < 8) return;
|
|
672
|
+
current.moved = true;
|
|
673
|
+
current.next = pointFromPixels(
|
|
674
|
+
current.left + dx,
|
|
675
|
+
current.top + dy,
|
|
676
|
+
current.width,
|
|
677
|
+
current.height
|
|
678
|
+
);
|
|
679
|
+
setPreview(current.next);
|
|
680
|
+
},
|
|
681
|
+
onPointerUp: (event) => {
|
|
682
|
+
const current = drag.current;
|
|
683
|
+
if (!current || current.id !== event.pointerId) return;
|
|
684
|
+
drag.current = null;
|
|
685
|
+
suppressClick.current = current.moved;
|
|
686
|
+
if (current.next) ctx.setWidgetPlacement(current.next);
|
|
687
|
+
setPreview(null);
|
|
688
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId))
|
|
689
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
690
|
+
},
|
|
691
|
+
onPointerCancel: () => {
|
|
692
|
+
suppressClick.current = !!drag.current?.moved;
|
|
693
|
+
drag.current = null;
|
|
694
|
+
setPreview(null);
|
|
695
|
+
},
|
|
696
|
+
onLostPointerCapture: () => {
|
|
697
|
+
if (drag.current) {
|
|
698
|
+
suppressClick.current = drag.current.moved;
|
|
699
|
+
drag.current = null;
|
|
700
|
+
setPreview(null);
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
onClick: (event) => {
|
|
704
|
+
if (suppressClick.current && event.detail !== 0) {
|
|
705
|
+
suppressClick.current = false;
|
|
706
|
+
event.preventDefault();
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
event.currentTarget.focus();
|
|
710
|
+
ctx.toggleOpen();
|
|
711
|
+
},
|
|
712
|
+
onKeyDown: (event) => {
|
|
713
|
+
if (event.key === "Escape") ctx.closeMenu();
|
|
714
|
+
if (draggable && event.altKey && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(
|
|
715
|
+
event.key
|
|
716
|
+
)) {
|
|
717
|
+
event.preventDefault();
|
|
718
|
+
const bounds = event.currentTarget.getBoundingClientRect();
|
|
719
|
+
ctx.setWidgetPlacement(
|
|
720
|
+
pointFromPixels(
|
|
721
|
+
bounds.left + (event.key === "ArrowLeft" ? -20 : event.key === "ArrowRight" ? 20 : 0),
|
|
722
|
+
bounds.top + (event.key === "ArrowUp" ? -20 : event.key === "ArrowDown" ? 20 : 0),
|
|
723
|
+
bounds.width,
|
|
724
|
+
bounds.height
|
|
725
|
+
)
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
"aria-label": title,
|
|
730
|
+
"aria-keyshortcuts": draggable ? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight" : void 0,
|
|
731
|
+
"aria-describedby": description || draggable ? `${ctx.panelId}-trigger-description` : void 0,
|
|
732
|
+
"aria-expanded": ctx.isOpen,
|
|
733
|
+
"aria-controls": ctx.panelId,
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ jsx3("span", { "aria-hidden": "true", children: icon ?? /* @__PURE__ */ jsxs2(
|
|
736
|
+
"svg",
|
|
737
|
+
{
|
|
738
|
+
width: "28",
|
|
739
|
+
height: "28",
|
|
740
|
+
viewBox: "0 0 24 24",
|
|
741
|
+
fill: "none",
|
|
742
|
+
stroke: "currentColor",
|
|
743
|
+
strokeWidth: "2",
|
|
744
|
+
children: [
|
|
745
|
+
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "4", r: "2" }),
|
|
746
|
+
/* @__PURE__ */ jsx3("path", { d: "M4 9l8 2 8-2M12 11v5m0 0-5 6m5-6 5 6" })
|
|
747
|
+
]
|
|
748
|
+
}
|
|
749
|
+
) }),
|
|
750
|
+
(description || draggable) && /* @__PURE__ */ jsxs2("span", { id: `${ctx.panelId}-trigger-description`, hidden: true, children: [
|
|
751
|
+
description,
|
|
752
|
+
" ",
|
|
753
|
+
draggable && "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls."
|
|
754
|
+
] })
|
|
755
|
+
]
|
|
756
|
+
}
|
|
757
|
+
),
|
|
758
|
+
/* @__PURE__ */ jsx3("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ? `Button position: ${Math.round(ctx.widgetPlacement.x * 100)}% horizontally, ${Math.round(ctx.widgetPlacement.y * 100)}% vertically.` : `Button position: ${corner.split("-").join(" ")}.` })
|
|
759
|
+
] });
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
// src/core/AccessibilityList.tsx
|
|
763
|
+
import { useContext as useContext3, useEffect as useEffect4, useRef as useRef4, useState as useState4 } from "react";
|
|
764
|
+
|
|
765
|
+
// src/core/PanelActionsContext.ts
|
|
766
|
+
import { createContext as createContext2 } from "react";
|
|
767
|
+
var PanelActionsContext = createContext2(null);
|
|
768
|
+
|
|
769
|
+
// src/core/PositionControls.tsx
|
|
770
|
+
import { useContext as useContext2, useEffect as useEffect3, useRef as useRef3, useState as useState3 } from "react";
|
|
771
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
772
|
+
function PositionControls() {
|
|
773
|
+
const ctx = useContext2(AccessibilityContext);
|
|
774
|
+
const [open, setOpen] = useState3(false);
|
|
775
|
+
const select = useRef3(null);
|
|
776
|
+
const opener = useRef3(null);
|
|
777
|
+
useEffect3(() => {
|
|
778
|
+
if (open) select.current?.focus();
|
|
779
|
+
}, [open]);
|
|
780
|
+
const close = () => {
|
|
781
|
+
setOpen(false);
|
|
782
|
+
opener.current?.focus();
|
|
783
|
+
};
|
|
784
|
+
const move = (dx, dy) => {
|
|
785
|
+
const trigger = document.getElementById(`${ctx.panelId}-trigger`);
|
|
786
|
+
if (!trigger) return;
|
|
787
|
+
const rect = trigger.getBoundingClientRect();
|
|
788
|
+
ctx.setWidgetPlacement(
|
|
789
|
+
pointFromPixels(rect.left + dx, rect.top + dy, rect.width, rect.height)
|
|
790
|
+
);
|
|
791
|
+
};
|
|
792
|
+
return /* @__PURE__ */ jsxs3("div", { className: "arap-position-tools", children: [
|
|
793
|
+
/* @__PURE__ */ jsx4(
|
|
794
|
+
"button",
|
|
795
|
+
{
|
|
796
|
+
ref: opener,
|
|
797
|
+
className: "arap-position-button",
|
|
798
|
+
type: "button",
|
|
799
|
+
"aria-expanded": open,
|
|
800
|
+
"aria-controls": `${ctx.panelId}-position`,
|
|
801
|
+
onClick: (event) => {
|
|
802
|
+
event.currentTarget.focus();
|
|
803
|
+
setOpen(!open);
|
|
804
|
+
},
|
|
805
|
+
children: "Move button"
|
|
806
|
+
}
|
|
807
|
+
),
|
|
808
|
+
/* @__PURE__ */ jsxs3(
|
|
809
|
+
"div",
|
|
810
|
+
{
|
|
811
|
+
id: `${ctx.panelId}-position`,
|
|
812
|
+
className: "arap-position-popover",
|
|
813
|
+
hidden: !open,
|
|
814
|
+
role: "group",
|
|
815
|
+
"aria-label": "Move accessibility button",
|
|
816
|
+
onKeyDown: (event) => {
|
|
817
|
+
if (event.key === "Escape") {
|
|
818
|
+
event.stopPropagation();
|
|
819
|
+
close();
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
children: [
|
|
823
|
+
/* @__PURE__ */ jsx4(
|
|
824
|
+
"label",
|
|
825
|
+
{
|
|
826
|
+
className: "arap-position-label",
|
|
827
|
+
htmlFor: `${ctx.panelId}-corner`,
|
|
828
|
+
children: "Button position"
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
/* @__PURE__ */ jsxs3(
|
|
832
|
+
"select",
|
|
833
|
+
{
|
|
834
|
+
ref: select,
|
|
835
|
+
id: `${ctx.panelId}-corner`,
|
|
836
|
+
"aria-label": "Accessibility button position",
|
|
837
|
+
value: ctx.widgetPlacement?.kind === "point" ? "custom" : ctx.widgetPlacement?.corner ?? defaultCorner(ctx.position),
|
|
838
|
+
onChange: (event) => ctx.setWidgetPlacement({
|
|
839
|
+
kind: "corner",
|
|
840
|
+
corner: event.target.value
|
|
841
|
+
}),
|
|
842
|
+
children: [
|
|
843
|
+
/* @__PURE__ */ jsx4("option", { value: "custom", disabled: true, children: "Custom position" }),
|
|
844
|
+
corners.map((corner) => /* @__PURE__ */ jsx4("option", { value: corner, children: corner.split("-").join(" ") }, corner))
|
|
845
|
+
]
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ jsx4("div", { className: "arap-position-arrows", children: [
|
|
849
|
+
["left", -20, 0, "\u2190"],
|
|
850
|
+
["up", 0, -20, "\u2191"],
|
|
851
|
+
["down", 0, 20, "\u2193"],
|
|
852
|
+
["right", 20, 0, "\u2192"]
|
|
853
|
+
].map(([direction, dx, dy, label]) => /* @__PURE__ */ jsx4(
|
|
854
|
+
"button",
|
|
855
|
+
{
|
|
856
|
+
type: "button",
|
|
857
|
+
"aria-label": `Move accessibility button ${direction}`,
|
|
858
|
+
onClick: (event) => {
|
|
859
|
+
event.currentTarget.focus();
|
|
860
|
+
move(dx, dy);
|
|
861
|
+
},
|
|
862
|
+
children: label
|
|
863
|
+
},
|
|
864
|
+
direction
|
|
865
|
+
)) }),
|
|
866
|
+
/* @__PURE__ */ jsx4(
|
|
867
|
+
"button",
|
|
868
|
+
{
|
|
869
|
+
className: "arap-position-default",
|
|
870
|
+
type: "button",
|
|
871
|
+
onClick: (event) => {
|
|
872
|
+
event.currentTarget.focus();
|
|
873
|
+
ctx.setWidgetPlacement(null);
|
|
874
|
+
},
|
|
875
|
+
children: "Reset button position"
|
|
876
|
+
}
|
|
877
|
+
),
|
|
878
|
+
/* @__PURE__ */ jsx4("button", { className: "arap-position-default", type: "button", onClick: close, children: "Done moving" })
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
)
|
|
882
|
+
] });
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// src/core/AccessibilityList.tsx
|
|
886
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
887
|
+
function Panel({
|
|
888
|
+
children,
|
|
889
|
+
footer,
|
|
890
|
+
className = "",
|
|
891
|
+
style,
|
|
892
|
+
title = "Accessibility settings",
|
|
893
|
+
description = "Adjust your reading experience",
|
|
894
|
+
closeLabel = "Close accessibility settings"
|
|
895
|
+
}) {
|
|
896
|
+
const ctx = useContext3(AccessibilityContext);
|
|
897
|
+
const panel = useRef4(null);
|
|
898
|
+
const [actions, setActions] = useState4(null);
|
|
899
|
+
const viewport = useViewport();
|
|
900
|
+
const triggerSize = useTriggerSize(`${ctx.panelId}-trigger`);
|
|
901
|
+
const corner = ctx.widgetPlacement?.kind === "corner" ? ctx.widgetPlacement.corner : defaultCorner(ctx.position);
|
|
902
|
+
const previous = useRef4(null);
|
|
903
|
+
useEffect4(() => {
|
|
904
|
+
if (ctx.isOpen) {
|
|
905
|
+
previous.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
906
|
+
panel.current?.focus();
|
|
907
|
+
} else if (previous.current) {
|
|
908
|
+
previous.current.focus();
|
|
909
|
+
previous.current = null;
|
|
910
|
+
}
|
|
911
|
+
}, [ctx.isOpen]);
|
|
912
|
+
useEffect4(
|
|
913
|
+
() => () => {
|
|
914
|
+
if (previous.current?.isConnected) previous.current.focus();
|
|
915
|
+
},
|
|
916
|
+
[]
|
|
917
|
+
);
|
|
918
|
+
return /* @__PURE__ */ jsxs4(
|
|
919
|
+
"div",
|
|
920
|
+
{
|
|
921
|
+
ref: panel,
|
|
922
|
+
id: ctx.panelId,
|
|
923
|
+
className: `arap-panel ${className}`,
|
|
924
|
+
style: {
|
|
925
|
+
...panelStyle(ctx.widgetPlacement, viewport, triggerSize),
|
|
926
|
+
...style
|
|
927
|
+
},
|
|
928
|
+
"data-corner": corner,
|
|
929
|
+
"data-position": ctx.position,
|
|
930
|
+
hidden: !ctx.isOpen,
|
|
931
|
+
role: "region",
|
|
932
|
+
"aria-label": title,
|
|
933
|
+
"aria-describedby": description ? `${ctx.panelId}-description` : void 0,
|
|
934
|
+
tabIndex: -1,
|
|
935
|
+
onKeyDown: (event) => {
|
|
936
|
+
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
937
|
+
event.stopPropagation();
|
|
938
|
+
ctx.closeMenu();
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
children: [
|
|
942
|
+
/* @__PURE__ */ jsxs4("div", { className: "arap-heading", children: [
|
|
943
|
+
/* @__PURE__ */ jsxs4("div", { className: "arap-heading-copy", children: [
|
|
944
|
+
/* @__PURE__ */ jsx5("h2", { children: title }),
|
|
945
|
+
description && /* @__PURE__ */ jsx5("p", { id: `${ctx.panelId}-description`, className: "arap-description", children: description })
|
|
946
|
+
] }),
|
|
947
|
+
/* @__PURE__ */ jsx5("button", { type: "button", "aria-label": closeLabel, onClick: ctx.closeMenu, children: "\xD7" })
|
|
948
|
+
] }),
|
|
949
|
+
/* @__PURE__ */ jsx5(
|
|
950
|
+
"button",
|
|
951
|
+
{
|
|
952
|
+
type: "button",
|
|
953
|
+
className: "arap-skip-actions",
|
|
954
|
+
onClick: () => {
|
|
955
|
+
const target = actions?.querySelector("button") ?? panel.current?.querySelector(
|
|
956
|
+
".arap-position-button"
|
|
957
|
+
);
|
|
958
|
+
target?.focus();
|
|
959
|
+
},
|
|
960
|
+
children: "Jump to quick actions"
|
|
961
|
+
}
|
|
962
|
+
),
|
|
963
|
+
/* @__PURE__ */ jsx5(PanelActionsContext.Provider, { value: actions, children: /* @__PURE__ */ jsx5(
|
|
964
|
+
"div",
|
|
965
|
+
{
|
|
966
|
+
className: "arap-tools",
|
|
967
|
+
role: "group",
|
|
968
|
+
tabIndex: 0,
|
|
969
|
+
"aria-label": "Accessibility tools",
|
|
970
|
+
children
|
|
971
|
+
}
|
|
972
|
+
) }),
|
|
973
|
+
/* @__PURE__ */ jsxs4(
|
|
974
|
+
"div",
|
|
975
|
+
{
|
|
976
|
+
className: "arap-quick-actions",
|
|
977
|
+
role: "group",
|
|
978
|
+
"aria-label": "Quick actions",
|
|
979
|
+
children: [
|
|
980
|
+
/* @__PURE__ */ jsx5(PositionControls, {}, ctx.isOpen ? "open" : "closed"),
|
|
981
|
+
/* @__PURE__ */ jsx5("div", { className: "arap-actions", ref: setActions, children: footer })
|
|
982
|
+
]
|
|
983
|
+
}
|
|
984
|
+
)
|
|
985
|
+
]
|
|
986
|
+
}
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
function AccessibilityList(props) {
|
|
990
|
+
const ctx = useContext3(AccessibilityContext);
|
|
991
|
+
if (!ctx)
|
|
992
|
+
throw new Error(
|
|
993
|
+
"AccessibilityList must be used within an <AccessibilityPlugin> provider."
|
|
994
|
+
);
|
|
995
|
+
return /* @__PURE__ */ jsx5(WidgetPortal, { children: /* @__PURE__ */ jsx5(Panel, { ...props }) });
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// src/core/useAccessibility.ts
|
|
999
|
+
import { useCallback as useCallback3, useContext as useContext4, useEffect as useEffect5, useState as useState5 } from "react";
|
|
1000
|
+
function useAccessibility(featureKey, defaultValue, options) {
|
|
1001
|
+
const ctx = useContext4(AccessibilityContext);
|
|
1002
|
+
if (!ctx)
|
|
1003
|
+
throw new Error(
|
|
1004
|
+
"useAccessibility must be used within an <AccessibilityPlugin> provider."
|
|
1005
|
+
);
|
|
1006
|
+
if (!validKey(featureKey) || featureKey === PLACEMENT_KEY)
|
|
1007
|
+
throw new Error(
|
|
1008
|
+
"Feature keys must be nonempty and cannot be prototype keys."
|
|
1009
|
+
);
|
|
1010
|
+
const [definition] = useState5({ defaultValue, ...options });
|
|
1011
|
+
const { registerFeature, setFeatureState } = ctx;
|
|
1012
|
+
useEffect5(() => {
|
|
1013
|
+
registerFeature(featureKey, definition);
|
|
1014
|
+
}, [featureKey, registerFeature, definition]);
|
|
1015
|
+
const setValue = useCallback3(
|
|
1016
|
+
(next) => setFeatureState(featureKey, next),
|
|
1017
|
+
[featureKey, setFeatureState]
|
|
1018
|
+
);
|
|
1019
|
+
const reset = useCallback3(
|
|
1020
|
+
() => setFeatureState(featureKey, definition.defaultValue),
|
|
1021
|
+
[featureKey, setFeatureState, definition]
|
|
1022
|
+
);
|
|
1023
|
+
const stored = Object.prototype.hasOwnProperty.call(
|
|
1024
|
+
ctx.state.features,
|
|
1025
|
+
featureKey
|
|
1026
|
+
) ? ctx.state.features[featureKey] : definition.defaultValue;
|
|
1027
|
+
const value = validValue(
|
|
1028
|
+
featureKey,
|
|
1029
|
+
stored,
|
|
1030
|
+
definition.defaultValue,
|
|
1031
|
+
definition.validate
|
|
1032
|
+
) ? stored : definition.defaultValue;
|
|
1033
|
+
return { value, setValue, reset };
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// src/core/FeatureIcon.tsx
|
|
1037
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1038
|
+
var drawings = {
|
|
1039
|
+
fontSize: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "M3 18 8 5l5 13M5 13h6M15 18l3-8 3 8M16 15h4" }) }),
|
|
1040
|
+
lineHeight: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "M9 6h12M9 12h9M9 18h12M4 4v16m-2-2 2 2 2-2M2 6l2-2 2 2" }) }),
|
|
1041
|
+
letterSpacing: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "M3 13 7 3l4 10M4.5 9h5M14 13l4-10 4 10m-6.5-4h5M3 19h18m-3-2 3 2-3 2M6 17l-3 2 3 2" }) }),
|
|
1042
|
+
contrast: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1043
|
+
/* @__PURE__ */ jsx6("circle", { cx: "12", cy: "12", r: "9" }),
|
|
1044
|
+
/* @__PURE__ */ jsx6("path", { d: "M12 3a9 9 0 0 1 0 18Z", fill: "currentColor", stroke: "none" })
|
|
1045
|
+
] }),
|
|
1046
|
+
saturation: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1047
|
+
/* @__PURE__ */ jsx6("path", { d: "M12 3c-2 4-7 8-7 12a7 7 0 0 0 14 0c0-4-5-8-7-12Z" }),
|
|
1048
|
+
/* @__PURE__ */ jsx6("path", { d: "M8 15a4 4 0 0 0 4 4" })
|
|
1049
|
+
] }),
|
|
1050
|
+
invertColors: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1051
|
+
/* @__PURE__ */ jsx6("path", { d: "M12 3c-2 4-7 8-7 12a7 7 0 0 0 14 0c0-4-5-8-7-12Z" }),
|
|
1052
|
+
/* @__PURE__ */ jsx6("path", { d: "M12 3v19" })
|
|
1053
|
+
] }),
|
|
1054
|
+
grayscale: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1055
|
+
/* @__PURE__ */ jsx6("circle", { cx: "8", cy: "12", r: "5" }),
|
|
1056
|
+
/* @__PURE__ */ jsx6("circle", { cx: "16", cy: "12", r: "5" }),
|
|
1057
|
+
/* @__PURE__ */ jsx6("path", { d: "M8 7v10M16 7v10" })
|
|
1058
|
+
] }),
|
|
1059
|
+
linkHighlight: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "m10 14 4-4M8 16l-1 1a4 4 0 0 1-6-6l4-4a4 4 0 0 1 6 0M16 8l1-1a4 4 0 0 1 6 6l-4 4a4 4 0 0 1-6 0" }) }),
|
|
1060
|
+
textAlign: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "M3 5h18M3 10h12M3 15h18M3 20h12" }) }),
|
|
1061
|
+
hideImages: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1062
|
+
/* @__PURE__ */ jsx6("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }),
|
|
1063
|
+
/* @__PURE__ */ jsx6("circle", { cx: "8", cy: "9", r: "1" }),
|
|
1064
|
+
/* @__PURE__ */ jsx6("path", { d: "m3 17 5-5 4 4 3-3 6 5M2 2l20 20" })
|
|
1065
|
+
] }),
|
|
1066
|
+
hideVideos: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1067
|
+
/* @__PURE__ */ jsx6("rect", { x: "3", y: "5", width: "13", height: "14", rx: "2" }),
|
|
1068
|
+
/* @__PURE__ */ jsx6("path", { d: "m16 10 5-3v10l-5-3M2 2l20 20" })
|
|
1069
|
+
] }),
|
|
1070
|
+
bigCursor: /* @__PURE__ */ jsx6("path", { d: "m5 3 14 11-7 1-3 6Z" }),
|
|
1071
|
+
readingMask: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1072
|
+
/* @__PURE__ */ jsx6("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }),
|
|
1073
|
+
/* @__PURE__ */ jsx6("path", { d: "M3 9h18M3 15h18" }),
|
|
1074
|
+
/* @__PURE__ */ jsx6("path", { d: "M6 12h12" })
|
|
1075
|
+
] }),
|
|
1076
|
+
readingGuide: /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1077
|
+
/* @__PURE__ */ jsx6("path", { d: "M3 5h18M3 10h12M3 19h18" }),
|
|
1078
|
+
/* @__PURE__ */ jsx6("path", { d: "M2 15h20", strokeWidth: "3" })
|
|
1079
|
+
] }),
|
|
1080
|
+
reset: /* @__PURE__ */ jsx6(Fragment, { children: /* @__PURE__ */ jsx6("path", { d: "M3 10a9 9 0 1 1 1 7M3 4v6h6" }) })
|
|
1081
|
+
};
|
|
1082
|
+
function FeatureIcon({ name }) {
|
|
1083
|
+
return /* @__PURE__ */ jsx6(
|
|
1084
|
+
"svg",
|
|
1085
|
+
{
|
|
1086
|
+
className: "arap-icon",
|
|
1087
|
+
viewBox: "0 0 24 24",
|
|
1088
|
+
fill: "none",
|
|
1089
|
+
stroke: "currentColor",
|
|
1090
|
+
strokeWidth: "1.7",
|
|
1091
|
+
strokeLinecap: "round",
|
|
1092
|
+
strokeLinejoin: "round",
|
|
1093
|
+
"aria-hidden": "true",
|
|
1094
|
+
focusable: "false",
|
|
1095
|
+
children: drawings[name]
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// src/features/FontSizeController.tsx
|
|
1101
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1102
|
+
var FEATURE_KEY = "fontSize";
|
|
1103
|
+
var DEFAULT_VALUE = 100;
|
|
1104
|
+
var MIN = 50;
|
|
1105
|
+
var MAX = 200;
|
|
1106
|
+
var STEP = 10;
|
|
1107
|
+
function FontSizeController() {
|
|
1108
|
+
const { value, setValue } = useAccessibility(
|
|
1109
|
+
FEATURE_KEY,
|
|
1110
|
+
DEFAULT_VALUE
|
|
1111
|
+
);
|
|
1112
|
+
return /* @__PURE__ */ jsxs6(
|
|
1113
|
+
"div",
|
|
1114
|
+
{
|
|
1115
|
+
className: "arap-feature arap-feature-stepper",
|
|
1116
|
+
role: "group",
|
|
1117
|
+
"aria-label": "Font Size",
|
|
1118
|
+
children: [
|
|
1119
|
+
/* @__PURE__ */ jsxs6("span", { className: "arap-label", children: [
|
|
1120
|
+
/* @__PURE__ */ jsx7(FeatureIcon, { name: FEATURE_KEY }),
|
|
1121
|
+
/* @__PURE__ */ jsx7("span", { children: "Font Size" })
|
|
1122
|
+
] }),
|
|
1123
|
+
/* @__PURE__ */ jsxs6("div", { className: "arap-controls", children: [
|
|
1124
|
+
/* @__PURE__ */ jsx7(
|
|
1125
|
+
"button",
|
|
1126
|
+
{
|
|
1127
|
+
className: "arap-btn-sm",
|
|
1128
|
+
onClick: () => setValue(Math.max(MIN, value - STEP)),
|
|
1129
|
+
disabled: value <= MIN,
|
|
1130
|
+
"aria-label": "Decrease font size",
|
|
1131
|
+
type: "button",
|
|
1132
|
+
children: "\u2212"
|
|
1133
|
+
}
|
|
1134
|
+
),
|
|
1135
|
+
/* @__PURE__ */ jsxs6("output", { className: "arap-value", "aria-live": "polite", children: [
|
|
1136
|
+
value,
|
|
1137
|
+
"%"
|
|
1138
|
+
] }),
|
|
1139
|
+
/* @__PURE__ */ jsx7(
|
|
1140
|
+
"button",
|
|
1141
|
+
{
|
|
1142
|
+
className: "arap-btn-sm",
|
|
1143
|
+
onClick: () => setValue(Math.min(MAX, value + STEP)),
|
|
1144
|
+
disabled: value >= MAX,
|
|
1145
|
+
"aria-label": "Increase font size",
|
|
1146
|
+
type: "button",
|
|
1147
|
+
children: "+"
|
|
1148
|
+
}
|
|
1149
|
+
)
|
|
1150
|
+
] })
|
|
1151
|
+
]
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// src/features/LineHeightController.tsx
|
|
1157
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1158
|
+
var FEATURE_KEY2 = "lineHeight";
|
|
1159
|
+
var DEFAULT_VALUE2 = 100;
|
|
1160
|
+
var MIN2 = 50;
|
|
1161
|
+
var MAX2 = 200;
|
|
1162
|
+
var STEP2 = 10;
|
|
1163
|
+
function LineHeightController() {
|
|
1164
|
+
const { value, setValue } = useAccessibility(
|
|
1165
|
+
FEATURE_KEY2,
|
|
1166
|
+
DEFAULT_VALUE2
|
|
1167
|
+
);
|
|
1168
|
+
return /* @__PURE__ */ jsxs7(
|
|
1169
|
+
"div",
|
|
1170
|
+
{
|
|
1171
|
+
className: "arap-feature arap-feature-stepper",
|
|
1172
|
+
role: "group",
|
|
1173
|
+
"aria-label": "Line Height",
|
|
1174
|
+
children: [
|
|
1175
|
+
/* @__PURE__ */ jsxs7("span", { className: "arap-label", children: [
|
|
1176
|
+
/* @__PURE__ */ jsx8(FeatureIcon, { name: FEATURE_KEY2 }),
|
|
1177
|
+
/* @__PURE__ */ jsx8("span", { children: "Line Height" })
|
|
1178
|
+
] }),
|
|
1179
|
+
/* @__PURE__ */ jsxs7("div", { className: "arap-controls", children: [
|
|
1180
|
+
/* @__PURE__ */ jsx8(
|
|
1181
|
+
"button",
|
|
1182
|
+
{
|
|
1183
|
+
className: "arap-btn-sm",
|
|
1184
|
+
onClick: () => setValue(Math.max(MIN2, value - STEP2)),
|
|
1185
|
+
disabled: value <= MIN2,
|
|
1186
|
+
"aria-label": "Decrease line height",
|
|
1187
|
+
type: "button",
|
|
1188
|
+
children: "\u2212"
|
|
1189
|
+
}
|
|
1190
|
+
),
|
|
1191
|
+
/* @__PURE__ */ jsxs7("output", { className: "arap-value", "aria-live": "polite", children: [
|
|
1192
|
+
value,
|
|
1193
|
+
"%"
|
|
1194
|
+
] }),
|
|
1195
|
+
/* @__PURE__ */ jsx8(
|
|
1196
|
+
"button",
|
|
1197
|
+
{
|
|
1198
|
+
className: "arap-btn-sm",
|
|
1199
|
+
onClick: () => setValue(Math.min(MAX2, value + STEP2)),
|
|
1200
|
+
disabled: value >= MAX2,
|
|
1201
|
+
"aria-label": "Increase line height",
|
|
1202
|
+
type: "button",
|
|
1203
|
+
children: "+"
|
|
1204
|
+
}
|
|
1205
|
+
)
|
|
1206
|
+
] })
|
|
1207
|
+
]
|
|
1208
|
+
}
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// src/features/LetterSpacingController.tsx
|
|
1213
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1214
|
+
var FEATURE_KEY3 = "letterSpacing";
|
|
1215
|
+
var DEFAULT_VALUE3 = 0;
|
|
1216
|
+
var MIN3 = 0;
|
|
1217
|
+
var MAX3 = 10;
|
|
1218
|
+
var STEP3 = 1;
|
|
1219
|
+
function LetterSpacingController() {
|
|
1220
|
+
const { value, setValue } = useAccessibility(
|
|
1221
|
+
FEATURE_KEY3,
|
|
1222
|
+
DEFAULT_VALUE3
|
|
1223
|
+
);
|
|
1224
|
+
return /* @__PURE__ */ jsxs8(
|
|
1225
|
+
"div",
|
|
1226
|
+
{
|
|
1227
|
+
className: "arap-feature arap-feature-stepper",
|
|
1228
|
+
role: "group",
|
|
1229
|
+
"aria-label": "Letter Spacing",
|
|
1230
|
+
children: [
|
|
1231
|
+
/* @__PURE__ */ jsxs8("span", { className: "arap-label", children: [
|
|
1232
|
+
/* @__PURE__ */ jsx9(FeatureIcon, { name: FEATURE_KEY3 }),
|
|
1233
|
+
/* @__PURE__ */ jsx9("span", { children: "Letter Spacing" })
|
|
1234
|
+
] }),
|
|
1235
|
+
/* @__PURE__ */ jsxs8("div", { className: "arap-controls", children: [
|
|
1236
|
+
/* @__PURE__ */ jsx9(
|
|
1237
|
+
"button",
|
|
1238
|
+
{
|
|
1239
|
+
className: "arap-btn-sm",
|
|
1240
|
+
onClick: () => setValue(Math.max(MIN3, value - STEP3)),
|
|
1241
|
+
disabled: value <= MIN3,
|
|
1242
|
+
"aria-label": "Decrease letter spacing",
|
|
1243
|
+
type: "button",
|
|
1244
|
+
children: "\u2212"
|
|
1245
|
+
}
|
|
1246
|
+
),
|
|
1247
|
+
/* @__PURE__ */ jsxs8("output", { className: "arap-value", "aria-live": "polite", children: [
|
|
1248
|
+
value,
|
|
1249
|
+
"px"
|
|
1250
|
+
] }),
|
|
1251
|
+
/* @__PURE__ */ jsx9(
|
|
1252
|
+
"button",
|
|
1253
|
+
{
|
|
1254
|
+
className: "arap-btn-sm",
|
|
1255
|
+
onClick: () => setValue(Math.min(MAX3, value + STEP3)),
|
|
1256
|
+
disabled: value >= MAX3,
|
|
1257
|
+
"aria-label": "Increase letter spacing",
|
|
1258
|
+
type: "button",
|
|
1259
|
+
children: "+"
|
|
1260
|
+
}
|
|
1261
|
+
)
|
|
1262
|
+
] })
|
|
1263
|
+
]
|
|
1264
|
+
}
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// src/features/ContrastController.tsx
|
|
1269
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1270
|
+
var FEATURE_KEY4 = "contrast";
|
|
1271
|
+
var DEFAULT_VALUE4 = 0;
|
|
1272
|
+
var LEVELS = [
|
|
1273
|
+
{ label: "Off", value: 0 },
|
|
1274
|
+
{ label: "Reduced", value: "reduced" },
|
|
1275
|
+
{ label: "Low", value: 1 },
|
|
1276
|
+
{ label: "High", value: 2 },
|
|
1277
|
+
{ label: "Extra", value: 3 },
|
|
1278
|
+
{ label: "Yellow on black", value: "yellow-on-black" },
|
|
1279
|
+
{ label: "White on black", value: "white-on-black" },
|
|
1280
|
+
{ label: "Blue on yellow", value: "blue-on-yellow" }
|
|
1281
|
+
];
|
|
1282
|
+
function ContrastController() {
|
|
1283
|
+
const { value, setValue } = useAccessibility(
|
|
1284
|
+
FEATURE_KEY4,
|
|
1285
|
+
DEFAULT_VALUE4
|
|
1286
|
+
);
|
|
1287
|
+
return /* @__PURE__ */ jsxs9("div", { className: "arap-feature", role: "group", "aria-label": "Contrast", children: [
|
|
1288
|
+
/* @__PURE__ */ jsxs9("span", { className: "arap-label", children: [
|
|
1289
|
+
/* @__PURE__ */ jsx10(FeatureIcon, { name: FEATURE_KEY4 }),
|
|
1290
|
+
/* @__PURE__ */ jsx10("span", { children: "Contrast" })
|
|
1291
|
+
] }),
|
|
1292
|
+
/* @__PURE__ */ jsx10("div", { className: "arap-segmented", children: LEVELS.map((level) => /* @__PURE__ */ jsxs9(
|
|
1293
|
+
"button",
|
|
1294
|
+
{
|
|
1295
|
+
className: `arap-segment ${value === level.value ? "arap-segment-active" : ""}`,
|
|
1296
|
+
onClick: () => setValue(level.value),
|
|
1297
|
+
"aria-pressed": value === level.value,
|
|
1298
|
+
type: "button",
|
|
1299
|
+
children: [
|
|
1300
|
+
value === level.value && /* @__PURE__ */ jsx10("span", { className: "arap-check", "aria-hidden": "true", children: "\u2713" }),
|
|
1301
|
+
level.label
|
|
1302
|
+
]
|
|
1303
|
+
},
|
|
1304
|
+
level.value
|
|
1305
|
+
)) })
|
|
1306
|
+
] });
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
// src/features/SaturationController.tsx
|
|
1310
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1311
|
+
var FEATURE_KEY5 = "saturation";
|
|
1312
|
+
var DEFAULT_VALUE5 = 0;
|
|
1313
|
+
var LEVELS2 = [
|
|
1314
|
+
{ label: "Off", value: 0 },
|
|
1315
|
+
{ label: "Low", value: 1 },
|
|
1316
|
+
{ label: "High", value: 2 }
|
|
1317
|
+
];
|
|
1318
|
+
function SaturationController() {
|
|
1319
|
+
const { value, setValue } = useAccessibility(
|
|
1320
|
+
FEATURE_KEY5,
|
|
1321
|
+
DEFAULT_VALUE5
|
|
1322
|
+
);
|
|
1323
|
+
return /* @__PURE__ */ jsxs10("div", { className: "arap-feature", role: "group", "aria-label": "Saturation", children: [
|
|
1324
|
+
/* @__PURE__ */ jsxs10("span", { className: "arap-label", children: [
|
|
1325
|
+
/* @__PURE__ */ jsx11(FeatureIcon, { name: FEATURE_KEY5 }),
|
|
1326
|
+
/* @__PURE__ */ jsx11("span", { children: "Saturation" })
|
|
1327
|
+
] }),
|
|
1328
|
+
/* @__PURE__ */ jsx11("div", { className: "arap-segmented", children: LEVELS2.map((level) => /* @__PURE__ */ jsxs10(
|
|
1329
|
+
"button",
|
|
1330
|
+
{
|
|
1331
|
+
className: `arap-segment ${value === level.value ? "arap-segment-active" : ""}`,
|
|
1332
|
+
onClick: () => setValue(level.value),
|
|
1333
|
+
"aria-pressed": value === level.value,
|
|
1334
|
+
type: "button",
|
|
1335
|
+
children: [
|
|
1336
|
+
value === level.value && /* @__PURE__ */ jsx11("span", { className: "arap-check", "aria-hidden": "true", children: "\u2713" }),
|
|
1337
|
+
level.label
|
|
1338
|
+
]
|
|
1339
|
+
},
|
|
1340
|
+
level.value
|
|
1341
|
+
)) })
|
|
1342
|
+
] });
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// src/features/InvertColorsController.tsx
|
|
1346
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1347
|
+
var FEATURE_KEY6 = "invertColors";
|
|
1348
|
+
var DEFAULT_VALUE6 = false;
|
|
1349
|
+
function InvertColorsController() {
|
|
1350
|
+
const { value, setValue } = useAccessibility(
|
|
1351
|
+
FEATURE_KEY6,
|
|
1352
|
+
DEFAULT_VALUE6
|
|
1353
|
+
);
|
|
1354
|
+
return /* @__PURE__ */ jsxs11("div", { className: "arap-feature", role: "group", "aria-label": "Invert Colors", children: [
|
|
1355
|
+
/* @__PURE__ */ jsxs11("span", { className: "arap-label", children: [
|
|
1356
|
+
/* @__PURE__ */ jsx12(FeatureIcon, { name: FEATURE_KEY6 }),
|
|
1357
|
+
/* @__PURE__ */ jsx12("span", { children: "Invert Colors" })
|
|
1358
|
+
] }),
|
|
1359
|
+
/* @__PURE__ */ jsx12(
|
|
1360
|
+
"button",
|
|
1361
|
+
{
|
|
1362
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1363
|
+
onClick: () => setValue(!value),
|
|
1364
|
+
"aria-label": "Invert Colors",
|
|
1365
|
+
"aria-pressed": value,
|
|
1366
|
+
type: "button",
|
|
1367
|
+
children: /* @__PURE__ */ jsx12("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1368
|
+
}
|
|
1369
|
+
)
|
|
1370
|
+
] });
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
// src/features/GrayscaleController.tsx
|
|
1374
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1375
|
+
var FEATURE_KEY7 = "grayscale";
|
|
1376
|
+
var DEFAULT_VALUE7 = false;
|
|
1377
|
+
function GrayscaleController() {
|
|
1378
|
+
const { value, setValue } = useAccessibility(
|
|
1379
|
+
FEATURE_KEY7,
|
|
1380
|
+
DEFAULT_VALUE7
|
|
1381
|
+
);
|
|
1382
|
+
return /* @__PURE__ */ jsxs12("div", { className: "arap-feature", role: "group", "aria-label": "Grayscale", children: [
|
|
1383
|
+
/* @__PURE__ */ jsxs12("span", { className: "arap-label", children: [
|
|
1384
|
+
/* @__PURE__ */ jsx13(FeatureIcon, { name: FEATURE_KEY7 }),
|
|
1385
|
+
/* @__PURE__ */ jsx13("span", { children: "Grayscale" })
|
|
1386
|
+
] }),
|
|
1387
|
+
/* @__PURE__ */ jsx13(
|
|
1388
|
+
"button",
|
|
1389
|
+
{
|
|
1390
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1391
|
+
onClick: () => setValue(!value),
|
|
1392
|
+
"aria-label": "Grayscale",
|
|
1393
|
+
"aria-pressed": value,
|
|
1394
|
+
type: "button",
|
|
1395
|
+
children: /* @__PURE__ */ jsx13("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1396
|
+
}
|
|
1397
|
+
)
|
|
1398
|
+
] });
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/features/LinkHighlightController.tsx
|
|
1402
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1403
|
+
var FEATURE_KEY8 = "linkHighlight";
|
|
1404
|
+
var DEFAULT_VALUE8 = false;
|
|
1405
|
+
function LinkHighlightController() {
|
|
1406
|
+
const { value, setValue } = useAccessibility(
|
|
1407
|
+
FEATURE_KEY8,
|
|
1408
|
+
DEFAULT_VALUE8
|
|
1409
|
+
);
|
|
1410
|
+
return /* @__PURE__ */ jsxs13("div", { className: "arap-feature", role: "group", "aria-label": "Link Highlight", children: [
|
|
1411
|
+
/* @__PURE__ */ jsxs13("span", { className: "arap-label", children: [
|
|
1412
|
+
/* @__PURE__ */ jsx14(FeatureIcon, { name: FEATURE_KEY8 }),
|
|
1413
|
+
/* @__PURE__ */ jsx14("span", { children: "Link Highlight" })
|
|
1414
|
+
] }),
|
|
1415
|
+
/* @__PURE__ */ jsx14(
|
|
1416
|
+
"button",
|
|
1417
|
+
{
|
|
1418
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1419
|
+
onClick: () => setValue(!value),
|
|
1420
|
+
"aria-label": "Link Highlight",
|
|
1421
|
+
"aria-pressed": !!value,
|
|
1422
|
+
type: "button",
|
|
1423
|
+
children: /* @__PURE__ */ jsx14("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1424
|
+
}
|
|
1425
|
+
),
|
|
1426
|
+
/* @__PURE__ */ jsx14("div", { className: "arap-segmented", children: ["yellow-on-black", "blue-on-yellow", "black-on-white"].map((mode) => /* @__PURE__ */ jsxs13(
|
|
1427
|
+
"button",
|
|
1428
|
+
{
|
|
1429
|
+
type: "button",
|
|
1430
|
+
className: `arap-segment ${value === mode ? "arap-segment-active" : ""}`,
|
|
1431
|
+
"aria-pressed": value === mode,
|
|
1432
|
+
onClick: () => setValue(mode),
|
|
1433
|
+
children: [
|
|
1434
|
+
value === mode && /* @__PURE__ */ jsx14("span", { className: "arap-check", "aria-hidden": "true", children: "\u2713" }),
|
|
1435
|
+
mode.split("-").join(" ")
|
|
1436
|
+
]
|
|
1437
|
+
},
|
|
1438
|
+
mode
|
|
1439
|
+
)) })
|
|
1440
|
+
] });
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
// src/features/TextAlignController.tsx
|
|
1444
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1445
|
+
var FEATURE_KEY9 = "textAlign";
|
|
1446
|
+
var DEFAULT_VALUE9 = "default";
|
|
1447
|
+
var OPTIONS = ["default", "left", "center", "right", "justify"];
|
|
1448
|
+
function TextAlignController() {
|
|
1449
|
+
const { value, setValue } = useAccessibility(
|
|
1450
|
+
FEATURE_KEY9,
|
|
1451
|
+
DEFAULT_VALUE9
|
|
1452
|
+
);
|
|
1453
|
+
return /* @__PURE__ */ jsxs14("div", { className: "arap-feature", role: "group", "aria-label": "Text Alignment", children: [
|
|
1454
|
+
/* @__PURE__ */ jsxs14("span", { className: "arap-label", children: [
|
|
1455
|
+
/* @__PURE__ */ jsx15(FeatureIcon, { name: FEATURE_KEY9 }),
|
|
1456
|
+
/* @__PURE__ */ jsx15("span", { children: "Text Alignment" })
|
|
1457
|
+
] }),
|
|
1458
|
+
/* @__PURE__ */ jsx15("div", { className: "arap-segmented", children: OPTIONS.map((option) => /* @__PURE__ */ jsxs14(
|
|
1459
|
+
"button",
|
|
1460
|
+
{
|
|
1461
|
+
className: `arap-segment ${value === option ? "arap-segment-active" : ""}`,
|
|
1462
|
+
onClick: () => setValue(option),
|
|
1463
|
+
"aria-pressed": value === option,
|
|
1464
|
+
type: "button",
|
|
1465
|
+
style: { textTransform: "capitalize" },
|
|
1466
|
+
children: [
|
|
1467
|
+
value === option && /* @__PURE__ */ jsx15("span", { className: "arap-check", "aria-hidden": "true", children: "\u2713" }),
|
|
1468
|
+
option
|
|
1469
|
+
]
|
|
1470
|
+
},
|
|
1471
|
+
option
|
|
1472
|
+
)) })
|
|
1473
|
+
] });
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
// src/features/HideImagesController.tsx
|
|
1477
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1478
|
+
var FEATURE_KEY10 = "hideImages";
|
|
1479
|
+
var DEFAULT_VALUE10 = false;
|
|
1480
|
+
function HideImagesController() {
|
|
1481
|
+
const { value, setValue } = useAccessibility(
|
|
1482
|
+
FEATURE_KEY10,
|
|
1483
|
+
DEFAULT_VALUE10
|
|
1484
|
+
);
|
|
1485
|
+
return /* @__PURE__ */ jsxs15("div", { className: "arap-feature", role: "group", "aria-label": "Hide Images", children: [
|
|
1486
|
+
/* @__PURE__ */ jsxs15("span", { className: "arap-label", children: [
|
|
1487
|
+
/* @__PURE__ */ jsx16(FeatureIcon, { name: FEATURE_KEY10 }),
|
|
1488
|
+
/* @__PURE__ */ jsx16("span", { children: "Hide Images" })
|
|
1489
|
+
] }),
|
|
1490
|
+
/* @__PURE__ */ jsx16(
|
|
1491
|
+
"button",
|
|
1492
|
+
{
|
|
1493
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1494
|
+
onClick: () => setValue(!value),
|
|
1495
|
+
"aria-label": "Hide Images",
|
|
1496
|
+
"aria-pressed": value,
|
|
1497
|
+
type: "button",
|
|
1498
|
+
children: /* @__PURE__ */ jsx16("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1499
|
+
}
|
|
1500
|
+
)
|
|
1501
|
+
] });
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// src/features/HideVideosController.tsx
|
|
1505
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1506
|
+
var FEATURE_KEY11 = "hideVideos";
|
|
1507
|
+
var DEFAULT_VALUE11 = false;
|
|
1508
|
+
function HideVideosController() {
|
|
1509
|
+
const { value, setValue } = useAccessibility(
|
|
1510
|
+
FEATURE_KEY11,
|
|
1511
|
+
DEFAULT_VALUE11
|
|
1512
|
+
);
|
|
1513
|
+
return /* @__PURE__ */ jsxs16("div", { className: "arap-feature", role: "group", "aria-label": "Hide Videos", children: [
|
|
1514
|
+
/* @__PURE__ */ jsxs16("span", { className: "arap-label", children: [
|
|
1515
|
+
/* @__PURE__ */ jsx17(FeatureIcon, { name: FEATURE_KEY11 }),
|
|
1516
|
+
/* @__PURE__ */ jsx17("span", { children: "Hide Videos" })
|
|
1517
|
+
] }),
|
|
1518
|
+
/* @__PURE__ */ jsx17(
|
|
1519
|
+
"button",
|
|
1520
|
+
{
|
|
1521
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1522
|
+
onClick: () => setValue(!value),
|
|
1523
|
+
"aria-label": "Hide Videos",
|
|
1524
|
+
"aria-pressed": value,
|
|
1525
|
+
type: "button",
|
|
1526
|
+
children: /* @__PURE__ */ jsx17("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1527
|
+
}
|
|
1528
|
+
)
|
|
1529
|
+
] });
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
// src/features/BigCursorController.tsx
|
|
1533
|
+
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1534
|
+
var FEATURE_KEY12 = "bigCursor";
|
|
1535
|
+
var DEFAULT_VALUE12 = false;
|
|
1536
|
+
function BigCursorController() {
|
|
1537
|
+
const { value, setValue } = useAccessibility(
|
|
1538
|
+
FEATURE_KEY12,
|
|
1539
|
+
DEFAULT_VALUE12
|
|
1540
|
+
);
|
|
1541
|
+
return /* @__PURE__ */ jsxs17("div", { className: "arap-feature", role: "group", "aria-label": "Big Cursor", children: [
|
|
1542
|
+
/* @__PURE__ */ jsxs17("span", { className: "arap-label", children: [
|
|
1543
|
+
/* @__PURE__ */ jsx18(FeatureIcon, { name: FEATURE_KEY12 }),
|
|
1544
|
+
/* @__PURE__ */ jsx18("span", { children: "Big Cursor" })
|
|
1545
|
+
] }),
|
|
1546
|
+
/* @__PURE__ */ jsx18(
|
|
1547
|
+
"button",
|
|
1548
|
+
{
|
|
1549
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1550
|
+
onClick: () => setValue(!value),
|
|
1551
|
+
"aria-label": "Big Cursor",
|
|
1552
|
+
"aria-pressed": value,
|
|
1553
|
+
type: "button",
|
|
1554
|
+
children: /* @__PURE__ */ jsx18("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1555
|
+
}
|
|
1556
|
+
)
|
|
1557
|
+
] });
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
// src/features/ReadingMaskController.tsx
|
|
1561
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1562
|
+
var FEATURE_KEY13 = "readingMask";
|
|
1563
|
+
var DEFAULT_VALUE13 = false;
|
|
1564
|
+
function ReadingMaskController() {
|
|
1565
|
+
const { value, setValue } = useAccessibility(
|
|
1566
|
+
FEATURE_KEY13,
|
|
1567
|
+
DEFAULT_VALUE13
|
|
1568
|
+
);
|
|
1569
|
+
return /* @__PURE__ */ jsxs18("div", { className: "arap-feature", role: "group", "aria-label": "Reading Mask", children: [
|
|
1570
|
+
/* @__PURE__ */ jsxs18("span", { className: "arap-label", children: [
|
|
1571
|
+
/* @__PURE__ */ jsx19(FeatureIcon, { name: FEATURE_KEY13 }),
|
|
1572
|
+
/* @__PURE__ */ jsx19("span", { children: "Reading Mask" })
|
|
1573
|
+
] }),
|
|
1574
|
+
/* @__PURE__ */ jsx19(
|
|
1575
|
+
"button",
|
|
1576
|
+
{
|
|
1577
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1578
|
+
onClick: () => setValue(!value),
|
|
1579
|
+
"aria-label": "Reading Mask",
|
|
1580
|
+
"aria-pressed": value,
|
|
1581
|
+
type: "button",
|
|
1582
|
+
children: /* @__PURE__ */ jsx19("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1583
|
+
}
|
|
1584
|
+
)
|
|
1585
|
+
] });
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
// src/features/ReadingGuideController.tsx
|
|
1589
|
+
import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1590
|
+
var FEATURE_KEY14 = "readingGuide";
|
|
1591
|
+
var DEFAULT_VALUE14 = false;
|
|
1592
|
+
function ReadingGuideController() {
|
|
1593
|
+
const { value, setValue } = useAccessibility(
|
|
1594
|
+
FEATURE_KEY14,
|
|
1595
|
+
DEFAULT_VALUE14
|
|
1596
|
+
);
|
|
1597
|
+
return /* @__PURE__ */ jsxs19("div", { className: "arap-feature", role: "group", "aria-label": "Reading Guide", children: [
|
|
1598
|
+
/* @__PURE__ */ jsxs19("span", { className: "arap-label", children: [
|
|
1599
|
+
/* @__PURE__ */ jsx20(FeatureIcon, { name: FEATURE_KEY14 }),
|
|
1600
|
+
/* @__PURE__ */ jsx20("span", { children: "Reading Guide" })
|
|
1601
|
+
] }),
|
|
1602
|
+
/* @__PURE__ */ jsx20(
|
|
1603
|
+
"button",
|
|
1604
|
+
{
|
|
1605
|
+
className: `arap-toggle ${value ? "arap-toggle-active" : ""}`,
|
|
1606
|
+
onClick: () => setValue(!value),
|
|
1607
|
+
"aria-label": "Reading Guide",
|
|
1608
|
+
"aria-pressed": value,
|
|
1609
|
+
type: "button",
|
|
1610
|
+
children: /* @__PURE__ */ jsx20("span", { className: "arap-toggle-knob", "aria-hidden": "true" })
|
|
1611
|
+
}
|
|
1612
|
+
)
|
|
1613
|
+
] });
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
// src/features/ResetController.tsx
|
|
1617
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
1618
|
+
import { useContext as useContext5 } from "react";
|
|
1619
|
+
import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1620
|
+
function ResetController() {
|
|
1621
|
+
const ctx = useContext5(AccessibilityContext);
|
|
1622
|
+
if (!ctx) {
|
|
1623
|
+
throw new Error(
|
|
1624
|
+
"ResetController must be used within an <AccessibilityPlugin> provider."
|
|
1625
|
+
);
|
|
1626
|
+
}
|
|
1627
|
+
const actionHost = useContext5(PanelActionsContext);
|
|
1628
|
+
const { resetAll } = ctx;
|
|
1629
|
+
const button = /* @__PURE__ */ jsx21("div", { className: "arap-feature arap-feature-reset", children: /* @__PURE__ */ jsxs20("button", { className: "arap-reset-btn", onClick: resetAll, type: "button", children: [
|
|
1630
|
+
/* @__PURE__ */ jsx21(FeatureIcon, { name: "reset" }),
|
|
1631
|
+
"Reset All"
|
|
1632
|
+
] }) });
|
|
1633
|
+
return actionHost ? createPortal2(button, actionHost) : button;
|
|
1634
|
+
}
|
|
1635
|
+
export {
|
|
1636
|
+
AccessibilityButton,
|
|
1637
|
+
AccessibilityContext,
|
|
1638
|
+
AccessibilityList,
|
|
1639
|
+
AccessibilityPlugin,
|
|
1640
|
+
BigCursorController,
|
|
1641
|
+
ContrastController,
|
|
1642
|
+
FontSizeController,
|
|
1643
|
+
GrayscaleController,
|
|
1644
|
+
HideImagesController,
|
|
1645
|
+
HideVideosController,
|
|
1646
|
+
InvertColorsController,
|
|
1647
|
+
LetterSpacingController,
|
|
1648
|
+
LineHeightController,
|
|
1649
|
+
LinkHighlightController,
|
|
1650
|
+
ReadingGuideController,
|
|
1651
|
+
ReadingMaskController,
|
|
1652
|
+
ResetController,
|
|
1653
|
+
SaturationController,
|
|
1654
|
+
TextAlignController,
|
|
1655
|
+
useAccessibility
|
|
1656
|
+
};
|
|
1657
|
+
//# sourceMappingURL=index.mjs.map
|