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