accessibility-plugin-react 2.0.1 → 2.2.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/README.md +7 -7
- package/dist/index.d.mts +135 -4
- package/dist/index.d.ts +135 -4
- package/dist/index.js +538 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +527 -51
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +110 -0
- package/docs/API.md +2 -2
- package/docs/BASELINE_AUDIT.md +219 -0
- package/docs/BUILD_AND_RELEASE_PLAN.md +456 -0
- package/docs/DEVELOPMENT.md +1 -1
- package/docs/INSTALLATION.md +1 -3
- package/docs/PROJECT_STATUS.md +3 -4
- package/docs/RELEASE.md +21 -16
- package/docs/TROUBLESHOOTING.md +21 -21
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
|
+
// #style-inject:#style-inject
|
|
5
|
+
function styleInject(css, { insertAt } = {}) {
|
|
6
|
+
if (!css || typeof document === "undefined") return;
|
|
7
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
8
|
+
const style = document.createElement("style");
|
|
9
|
+
style.type = "text/css";
|
|
10
|
+
if (insertAt === "top") {
|
|
11
|
+
if (head.firstChild) {
|
|
12
|
+
head.insertBefore(style, head.firstChild);
|
|
13
|
+
} else {
|
|
14
|
+
head.appendChild(style);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
head.appendChild(style);
|
|
18
|
+
}
|
|
19
|
+
if (style.styleSheet) {
|
|
20
|
+
style.styleSheet.cssText = css;
|
|
21
|
+
} else {
|
|
22
|
+
style.appendChild(document.createTextNode(css));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/styles/tailwind.css
|
|
27
|
+
styleInject('.arap-root {\n --arap-surface: #fff;\n --arap-text: #111827;\n --arap-muted: #475569;\n --arap-border: #cbd5e1;\n --arap-divider: #e2e8f0;\n --arap-accent: #1d4ed8;\n --arap-accent-hover: #1e40af;\n --arap-selected: #eff6ff;\n --arap-control: #f8fafc;\n color-scheme: light;\n font: 15px/1.5 system-ui, sans-serif;\n color: var(--arap-text);\n text-align: left;\n letter-spacing: normal;\n}\n.arap-root *,\n.arap-root *::before,\n.arap-root *::after {\n box-sizing: border-box;\n}\n.arap-root button {\n font: inherit;\n cursor: pointer;\n color: inherit;\n text-transform: none;\n letter-spacing: normal;\n transition: background-color 0.15s, border-color 0.15s;\n}\n.arap-root button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n.arap-root button:focus-visible,\n.arap-panel:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 3px;\n}\n.arap-root .arap-btn {\n position: fixed;\n z-index: 2147483001;\n bottom: max(16px, env(safe-area-inset-bottom));\n right: max(16px, env(safe-area-inset-right));\n width: 56px;\n height: 56px;\n padding: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n border: 2px solid var(--arap-surface);\n border-radius: 50%;\n background: var(--arap-accent);\n color: #fff;\n box-shadow: 0 4px 12px #0f172a26, 0 10px 24px #0f172a14;\n}\n.arap-root .arap-btn:hover {\n background: var(--arap-accent-hover);\n}\n.arap-root .arap-btn[data-position=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-btn[data-position=top] {\n bottom: auto;\n top: max(16px, env(safe-area-inset-top));\n}\n.arap-root .arap-panel {\n position: fixed;\n z-index: 2147483000;\n bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));\n right: max(16px, env(safe-area-inset-right));\n width: min(400px, calc(100vw - 32px));\n max-height: calc(100vh - 120px);\n max-height: calc(100dvh - 120px - env(safe-area-inset-bottom));\n overflow: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: var(--arap-border) transparent;\n padding: 20px;\n border: 1px solid var(--arap-divider);\n border-radius: 16px;\n background: var(--arap-surface);\n box-shadow: 0 8px 16px #0f172a0d, 0 20px 48px #0f172a1a;\n}\n.arap-root .arap-panel[hidden] {\n display: none !important;\n}\n.arap-root .arap-panel[data-position=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-panel[data-position=top] {\n bottom: auto;\n top: max(88px, calc(env(safe-area-inset-top) + 72px));\n}\n.arap-heading {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n gap: 8px;\n padding-bottom: 18px;\n border-bottom: 1px solid var(--arap-divider);\n}\n.arap-heading-copy {\n min-width: 0;\n}\n.arap-heading h2 {\n margin: 0;\n font: 700 22px/1.3 system-ui, sans-serif;\n letter-spacing: -0.025em;\n color: var(--arap-text);\n overflow-wrap: anywhere;\n}\n.arap-description {\n margin: 6px 0 0;\n color: var(--arap-muted);\n font: 14px/1.5 system-ui, sans-serif;\n overflow-wrap: anywhere;\n}\n.arap-heading button {\n flex: none;\n width: 44px;\n height: 44px;\n margin-top: -6px;\n border: 1px solid transparent;\n border-radius: 8px;\n background: transparent;\n color: var(--arap-muted);\n font-size: 28px;\n line-height: 1;\n}\n.arap-heading button:hover {\n background: var(--arap-control);\n border-color: var(--arap-border);\n}\n.arap-feature {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n align-items: center;\n gap: 10px 12px;\n padding: 18px 0;\n border-bottom: 1px solid var(--arap-divider);\n}\n.arap-feature:last-child {\n border: 0;\n padding-bottom: 0;\n}\n.arap-label {\n display: flex;\n align-items: center;\n gap: 10px;\n font-weight: 500;\n min-width: 0;\n overflow-wrap: anywhere;\n}\n.arap-icon {\n flex: none;\n width: 22px;\n height: 22px;\n display: inline-block;\n vertical-align: middle;\n}\n.arap-controls {\n display: flex;\n align-items: stretch;\n border: 1px solid var(--arap-border);\n border-radius: 9px;\n overflow: hidden;\n background: var(--arap-control);\n}\n.arap-root .arap-btn-sm {\n flex: none;\n width: 44px;\n height: 44px;\n border: 0;\n border-radius: 0;\n background: transparent;\n font-size: 22px;\n}\n.arap-root .arap-btn-sm:hover:not(:disabled) {\n background: var(--arap-selected);\n color: var(--arap-accent);\n}\n.arap-root .arap-controls button:focus-visible {\n outline-offset: -4px;\n}\n.arap-value {\n display: flex;\n align-items: center;\n justify-content: center;\n min-width: 56px;\n padding: 0 6px;\n text-align: center;\n font-weight: 600;\n border-inline: 1px solid var(--arap-divider);\n background: var(--arap-surface);\n}\n.arap-segmented {\n grid-column: 1 / -1;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n.arap-root .arap-segment {\n flex: 1 1 auto;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 5px;\n min-width: 44px;\n min-height: 44px;\n padding: 8px 10px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n background: var(--arap-control);\n color: var(--arap-muted);\n overflow-wrap: anywhere;\n}\n.arap-root .arap-segment:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n.arap-root .arap-segment-active {\n background: var(--arap-accent);\n color: #fff;\n border-color: var(--arap-accent);\n font-weight: 600;\n}\n.arap-root .arap-segment-active:hover {\n background: var(--arap-accent-hover);\n color: #fff;\n}\n.arap-check {\n flex: none;\n font-size: 15px;\n line-height: 1;\n}\n.arap-root .arap-toggle {\n position: relative;\n width: 56px;\n height: 44px;\n padding: 0;\n border: 0;\n border-radius: 10px;\n background: transparent;\n}\n.arap-toggle::before {\n content: "";\n position: absolute;\n inset: 6px 0;\n border: 2px solid #64748b;\n border-radius: 20px;\n background: #e2e8f0;\n}\n.arap-toggle-knob {\n position: absolute;\n top: 10px;\n left: 4px;\n width: 24px;\n height: 24px;\n border-radius: 50%;\n background: #475569;\n pointer-events: none;\n transition: transform 0.15s;\n}\n.arap-toggle-active::before {\n background: var(--arap-accent);\n border-color: var(--arap-accent);\n}\n.arap-toggle-active .arap-toggle-knob {\n transform: translateX(24px);\n background: #fff;\n}\n.arap-toggle-active .arap-toggle-knob::after {\n content: "\\2713";\n display: block;\n color: var(--arap-accent);\n font-size: 16px;\n font-weight: 700;\n line-height: 24px;\n text-align: center;\n}\n.arap-root .arap-toggle:hover::before {\n border-color: var(--arap-accent);\n}\n.arap-feature-reset {\n display: block;\n}\n.arap-root .arap-reset-btn {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 10px;\n width: 100%;\n min-height: 48px;\n padding: 10px;\n border: 1px solid var(--arap-border);\n border-radius: 10px;\n background: var(--arap-control);\n color: var(--arap-accent);\n font-weight: 600;\n}\n.arap-root .arap-reset-btn:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n@media (max-width: 380px) {\n .arap-root .arap-panel {\n padding: 16px;\n }\n .arap-heading h2 {\n font-size: 20px;\n }\n .arap-feature-stepper {\n grid-template-columns: minmax(0, 1fr);\n }\n .arap-controls {\n width: 100%;\n }\n .arap-value {\n flex: 1;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .arap-root *,\n .arap-root *::before,\n .arap-root *::after {\n transition: none !important;\n animation: none !important;\n }\n}\n@media (forced-colors: active) {\n .arap-root {\n --arap-surface: Canvas;\n --arap-text: CanvasText;\n --arap-muted: CanvasText;\n --arap-border: ButtonText;\n --arap-divider: ButtonText;\n --arap-accent: Highlight;\n --arap-control: Canvas;\n --arap-selected: Canvas;\n }\n .arap-root button[aria-pressed=true] {\n outline: 2px solid Highlight;\n outline-offset: -4px;\n }\n .arap-root .arap-segment-active {\n color: HighlightText;\n background: Highlight;\n }\n .arap-toggle::before {\n border-color: ButtonText;\n background: Canvas;\n }\n .arap-toggle-knob {\n background: ButtonText;\n }\n .arap-toggle-active .arap-toggle-knob {\n background: Highlight;\n }\n .arap-toggle-active .arap-toggle-knob::after {\n color: HighlightText;\n }\n}\n.arap-root .arap-panel {\n display: flex;\n flex-direction: column;\n overflow: visible;\n}\n.arap-heading {\n flex: none;\n}\n.arap-tools {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n overscroll-behavior: contain;\n scrollbar-width: thin;\n scrollbar-color: var(--arap-border) transparent;\n padding: 0 3px;\n margin: 0 -3px;\n}\n.arap-tools:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: -3px;\n}\n.arap-quick-actions {\n position: relative;\n flex: none;\n display: flex;\n align-items: center;\n gap: 8px;\n padding-top: 14px;\n margin-top: 8px;\n border-top: 1px solid var(--arap-divider);\n}\n.arap-actions {\n flex: 1;\n min-width: 0;\n}\n.arap-actions:empty {\n display: none;\n}\n.arap-actions .arap-feature-reset {\n padding: 0;\n margin: 0;\n border: 0;\n}\n.arap-root .arap-position-button,\n.arap-root .arap-position-default,\n.arap-root .arap-position-arrows button {\n min-width: 44px;\n min-height: 44px;\n padding: 8px 10px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n background: var(--arap-control);\n color: var(--arap-accent);\n}\n.arap-root .arap-position-button:hover,\n.arap-root .arap-position-default:hover,\n.arap-root .arap-position-arrows button:hover {\n background: var(--arap-selected);\n border-color: var(--arap-accent);\n}\n.arap-position-popover {\n position: absolute;\n z-index: 1;\n bottom: calc(100% + 8px);\n left: 0;\n width: 100%;\n max-height: calc(100dvh - 160px);\n overflow: auto;\n padding: 14px;\n border: 1px solid var(--arap-border);\n border-radius: 12px;\n background: var(--arap-surface);\n box-shadow: 0 8px 24px #0f172a26;\n}\n.arap-position-popover[hidden] {\n display: none !important;\n}\n.arap-position-label {\n display: block;\n margin-bottom: 6px;\n font-weight: 600;\n}\n.arap-position-popover select {\n width: 100%;\n min-height: 44px;\n padding: 8px;\n border: 1px solid var(--arap-border);\n border-radius: 8px;\n font: inherit;\n color: var(--arap-text);\n background: var(--arap-surface);\n}\n.arap-position-popover select:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 2px;\n}\n.arap-position-arrows {\n display: flex;\n justify-content: space-between;\n gap: 6px;\n margin-top: 10px;\n}\n.arap-position-default {\n width: 100%;\n margin-top: 8px;\n}\n.arap-root .arap-btn[data-draggable=true] {\n touch-action: none;\n user-select: none;\n cursor: grab;\n}\n.arap-root .arap-btn[data-dragging=true] {\n cursor: grabbing;\n}\n.arap-root .arap-btn[data-corner$=left],\n.arap-root .arap-panel[data-corner$=left] {\n right: auto;\n left: max(16px, env(safe-area-inset-left));\n}\n.arap-root .arap-btn[data-corner$=right],\n.arap-root .arap-panel[data-corner$=right] {\n left: auto;\n right: max(16px, env(safe-area-inset-right));\n}\n.arap-root .arap-btn[data-corner^=top] {\n bottom: auto;\n top: max(16px, env(safe-area-inset-top));\n}\n.arap-root .arap-btn[data-corner^=bottom] {\n top: auto;\n bottom: max(16px, env(safe-area-inset-bottom));\n}\n.arap-root .arap-panel[data-corner^=top] {\n bottom: auto;\n top: max(88px, calc(env(safe-area-inset-top) + 72px));\n}\n.arap-root .arap-panel[data-corner^=bottom] {\n top: auto;\n bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));\n}\n.arap-sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n}\n.arap-root .arap-skip-actions {\n position: absolute;\n top: 12px;\n left: 20px;\n width: 44px;\n height: 44px;\n clip-path: inset(50%);\n overflow: hidden;\n pointer-events: none;\n}\n.arap-root .arap-skip-actions:focus-visible {\n right: 20px;\n width: auto;\n height: auto;\n min-height: 44px;\n clip-path: none;\n pointer-events: auto;\n z-index: 2;\n padding: 8px;\n border: 1px solid var(--arap-accent);\n border-radius: 8px;\n background: var(--arap-surface);\n color: var(--arap-accent);\n}\n@media (max-height: 480px) {\n .arap-root .arap-panel {\n top: max(16px, env(safe-area-inset-top)) !important;\n bottom: max(16px, env(safe-area-inset-bottom)) !important;\n max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;\n padding: 8px;\n }\n .arap-heading {\n padding-bottom: 8px;\n }\n .arap-heading h2 {\n font-size: 18px;\n }\n .arap-heading button {\n margin-top: 0;\n }\n .arap-description {\n display: none;\n }\n .arap-quick-actions {\n padding-top: 8px;\n margin-top: 0;\n }\n .arap-root .arap-reset-btn {\n min-height: 44px;\n }\n .arap-root .arap-btn[data-open=true] {\n visibility: hidden;\n }\n .arap-position-popover {\n max-height: calc(100dvh - 96px);\n }\n}\n.arap-statement {\n flex: none;\n padding-top: 10px;\n text-align: center;\n}\n.arap-statement-link {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-height: 44px;\n padding: 6px 12px;\n color: var(--arap-accent);\n text-decoration: underline;\n text-underline-offset: 4px;\n font-size: 14px;\n font-weight: 500;\n border-radius: 8px;\n}\n.arap-statement-link:hover {\n color: var(--arap-accent-hover);\n background: var(--arap-selected);\n}\n.arap-statement-link:focus-visible {\n outline: 3px solid var(--arap-accent);\n outline-offset: 2px;\n}\n.arap-root .arap-btn[data-large-controls=true] {\n width: 64px;\n height: 64px;\n min-width: 48px;\n min-height: 48px;\n}\n.arap-root .arap-panel[data-large-controls=true] {\n width: min(440px, calc(100vw - 32px));\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-heading button {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n font-size: 32px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-btn-sm {\n width: 48px;\n height: 48px;\n min-width: 48px;\n min-height: 48px;\n font-size: 24px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-value {\n min-width: 64px;\n font-size: 16px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-segment {\n min-width: 48px;\n min-height: 48px;\n padding: 10px 14px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle {\n width: 64px;\n height: 48px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle::before {\n inset: 8px 0;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle-knob {\n top: 12px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-toggle-active .arap-toggle-knob {\n transform: translateX(28px);\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-reset-btn {\n min-height: 52px;\n font-size: 16px;\n padding: 12px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-position-button,\n.arap-root .arap-panel[data-large-controls=true] .arap-position-default,\n.arap-root .arap-panel[data-large-controls=true] .arap-position-arrows button {\n min-width: 48px;\n min-height: 48px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-position-popover select {\n min-height: 48px;\n font-size: 15px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-statement-link {\n min-height: 48px;\n font-size: 15px;\n padding: 10px 16px;\n}\n.arap-root .arap-panel[data-large-controls=true] .arap-skip-actions {\n min-width: 48px;\n min-height: 48px;\n}\n');
|
|
28
|
+
|
|
4
29
|
// src/core/AccessibilityPlugin.tsx
|
|
5
30
|
import {
|
|
6
31
|
useCallback as useCallback2,
|
|
@@ -114,9 +139,19 @@ function validKey(key) {
|
|
|
114
139
|
function isRecord(value) {
|
|
115
140
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
116
141
|
}
|
|
117
|
-
function
|
|
142
|
+
function getStorage(mode = "local") {
|
|
143
|
+
if (mode === "none" || typeof window === "undefined") return null;
|
|
144
|
+
try {
|
|
145
|
+
return mode === "session" ? window.sessionStorage : window.localStorage;
|
|
146
|
+
} catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function loadState(key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
151
|
+
const storage = getStorage(mode);
|
|
152
|
+
if (!storage) return null;
|
|
118
153
|
try {
|
|
119
|
-
const raw = JSON.parse(
|
|
154
|
+
const raw = JSON.parse(storage.getItem(key) || "null");
|
|
120
155
|
if (!isRecord(raw)) return null;
|
|
121
156
|
const features = "version" in raw ? raw.version === 1 ? raw.features : null : raw;
|
|
122
157
|
if (!isRecord(features)) return null;
|
|
@@ -127,19 +162,23 @@ function loadState(key = DEFAULT_STORAGE_KEY) {
|
|
|
127
162
|
return null;
|
|
128
163
|
}
|
|
129
164
|
}
|
|
130
|
-
function saveState(state, key = DEFAULT_STORAGE_KEY) {
|
|
165
|
+
function saveState(state, key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
166
|
+
const storage = getStorage(mode);
|
|
167
|
+
if (!storage) return;
|
|
131
168
|
try {
|
|
132
|
-
|
|
169
|
+
storage.setItem(key, JSON.stringify({ version: 1, features: state }));
|
|
133
170
|
} catch {
|
|
134
171
|
}
|
|
135
172
|
}
|
|
136
|
-
function clearState(key = DEFAULT_STORAGE_KEY) {
|
|
173
|
+
function clearState(key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
174
|
+
const storage = getStorage(mode);
|
|
175
|
+
if (!storage) return;
|
|
137
176
|
try {
|
|
138
|
-
|
|
177
|
+
storage.removeItem(key);
|
|
139
178
|
} catch {
|
|
140
179
|
}
|
|
141
180
|
}
|
|
142
|
-
function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
181
|
+
function createStorageWriter(key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
143
182
|
let timer;
|
|
144
183
|
let pending;
|
|
145
184
|
const cancel = () => {
|
|
@@ -150,7 +189,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
150
189
|
const flush = () => {
|
|
151
190
|
const next = pending;
|
|
152
191
|
cancel();
|
|
153
|
-
if (next) saveState(next, key);
|
|
192
|
+
if (next) saveState(next, key, mode);
|
|
154
193
|
};
|
|
155
194
|
return {
|
|
156
195
|
schedule(state) {
|
|
@@ -160,7 +199,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
160
199
|
},
|
|
161
200
|
clear() {
|
|
162
201
|
cancel();
|
|
163
|
-
clearState(key);
|
|
202
|
+
clearState(key, mode);
|
|
164
203
|
},
|
|
165
204
|
cancel,
|
|
166
205
|
flush
|
|
@@ -168,13 +207,14 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
168
207
|
}
|
|
169
208
|
|
|
170
209
|
// src/core/preferenceStore.ts
|
|
171
|
-
function createPreferenceStore(key, persist) {
|
|
172
|
-
const
|
|
210
|
+
function createPreferenceStore(key, persist, storageMode) {
|
|
211
|
+
const resolvedMode = storageMode ?? (persist ? "local" : "none");
|
|
212
|
+
const writer = createStorageWriter(key, resolvedMode);
|
|
173
213
|
const empty = {};
|
|
174
214
|
let snapshot2;
|
|
175
215
|
const listeners = /* @__PURE__ */ new Set();
|
|
176
216
|
const getSnapshot = () => {
|
|
177
|
-
snapshot2 ?? (snapshot2 =
|
|
217
|
+
snapshot2 ?? (snapshot2 = resolvedMode !== "none" ? loadState(key, resolvedMode) ?? {} : {});
|
|
178
218
|
return snapshot2;
|
|
179
219
|
};
|
|
180
220
|
return {
|
|
@@ -188,7 +228,7 @@ function createPreferenceStore(key, persist) {
|
|
|
188
228
|
},
|
|
189
229
|
update(update) {
|
|
190
230
|
snapshot2 = update(getSnapshot());
|
|
191
|
-
if (
|
|
231
|
+
if (resolvedMode !== "none") {
|
|
192
232
|
if (Object.keys(snapshot2).length) writer.schedule(snapshot2);
|
|
193
233
|
else writer.clear();
|
|
194
234
|
}
|
|
@@ -439,11 +479,15 @@ function AccessibilityPlugin({
|
|
|
439
479
|
children,
|
|
440
480
|
position = "right",
|
|
441
481
|
persistenceKey,
|
|
442
|
-
persist = true
|
|
482
|
+
persist = true,
|
|
483
|
+
storage,
|
|
484
|
+
locale,
|
|
485
|
+
statementUrl,
|
|
486
|
+
largeControls
|
|
443
487
|
}) {
|
|
444
488
|
const [isOpen, setIsOpen] = useState(false);
|
|
445
489
|
const [store] = useState(
|
|
446
|
-
() => createPreferenceStore(persistenceKey, persist)
|
|
490
|
+
() => createPreferenceStore(persistenceKey, persist, storage)
|
|
447
491
|
);
|
|
448
492
|
const features = useSyncExternalStore2(
|
|
449
493
|
store.subscribe,
|
|
@@ -557,7 +601,10 @@ function AccessibilityPlugin({
|
|
|
557
601
|
registerFeature,
|
|
558
602
|
resetAll,
|
|
559
603
|
registerReset,
|
|
560
|
-
unregisterReset
|
|
604
|
+
unregisterReset,
|
|
605
|
+
locale,
|
|
606
|
+
statementUrl,
|
|
607
|
+
largeControls
|
|
561
608
|
}),
|
|
562
609
|
[
|
|
563
610
|
isOpen,
|
|
@@ -573,7 +620,10 @@ function AccessibilityPlugin({
|
|
|
573
620
|
registerFeature,
|
|
574
621
|
resetAll,
|
|
575
622
|
registerReset,
|
|
576
|
-
unregisterReset
|
|
623
|
+
unregisterReset,
|
|
624
|
+
locale,
|
|
625
|
+
statementUrl,
|
|
626
|
+
largeControls
|
|
577
627
|
]
|
|
578
628
|
);
|
|
579
629
|
return /* @__PURE__ */ jsxs(AccessibilityContext.Provider, { value, children: [
|
|
@@ -612,21 +662,93 @@ function WidgetPortal({ children }) {
|
|
|
612
662
|
) : null;
|
|
613
663
|
}
|
|
614
664
|
|
|
665
|
+
// src/core/i18n/en.ts
|
|
666
|
+
var enLocale = Object.freeze({
|
|
667
|
+
title: "Accessibility settings",
|
|
668
|
+
description: "Adjust your reading experience",
|
|
669
|
+
closeLabel: "Close accessibility settings",
|
|
670
|
+
skipToActions: "Jump to quick actions",
|
|
671
|
+
toolsLabel: "Accessibility tools",
|
|
672
|
+
quickActionsLabel: "Quick actions",
|
|
673
|
+
resetLabel: "Reset all accessibility settings",
|
|
674
|
+
resetAll: "Reset All",
|
|
675
|
+
statementLink: "Accessibility Statement",
|
|
676
|
+
openInNewTab: "opens in a new tab",
|
|
677
|
+
buttonTitle: "Accessibility",
|
|
678
|
+
dragHelp: "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls.",
|
|
679
|
+
positionLabel: "Button position",
|
|
680
|
+
moveButton: "Move button",
|
|
681
|
+
moveButtonLabel: "Move accessibility button",
|
|
682
|
+
buttonPositionSelectLabel: "Accessibility button position",
|
|
683
|
+
customPosition: "Custom position",
|
|
684
|
+
resetPosition: "Reset button position",
|
|
685
|
+
doneMoving: "Done moving",
|
|
686
|
+
moveLeft: "Move accessibility button left",
|
|
687
|
+
moveUp: "Move accessibility button up",
|
|
688
|
+
moveDown: "Move accessibility button down",
|
|
689
|
+
moveRight: "Move accessibility button right",
|
|
690
|
+
largeControlsLabel: "Oversized widget controls",
|
|
691
|
+
formatPointPosition: (x, y) => `Button position: ${Math.round(x * 100)}% horizontally, ${Math.round(y * 100)}% vertically.`,
|
|
692
|
+
formatCornerPosition: (corner) => `Button position: ${corner.split("-").join(" ")}.`
|
|
693
|
+
});
|
|
694
|
+
|
|
695
|
+
// src/core/i18n/index.ts
|
|
696
|
+
var dictionaries = {
|
|
697
|
+
en: enLocale
|
|
698
|
+
};
|
|
699
|
+
var RTL_LOCALES = /* @__PURE__ */ new Set([
|
|
700
|
+
"ar",
|
|
701
|
+
"arc",
|
|
702
|
+
"dv",
|
|
703
|
+
"fa",
|
|
704
|
+
"ha",
|
|
705
|
+
"he",
|
|
706
|
+
"khw",
|
|
707
|
+
"ks",
|
|
708
|
+
"ku",
|
|
709
|
+
"ps",
|
|
710
|
+
"ur",
|
|
711
|
+
"yi"
|
|
712
|
+
]);
|
|
713
|
+
function registerLocale(code, strings) {
|
|
714
|
+
dictionaries[code.toLowerCase()] = strings;
|
|
715
|
+
}
|
|
716
|
+
function isRtlLocale(localeProp) {
|
|
717
|
+
if (!localeProp) return false;
|
|
718
|
+
const base = localeProp.toLowerCase().split("-")[0];
|
|
719
|
+
return RTL_LOCALES.has(base);
|
|
720
|
+
}
|
|
721
|
+
function resolveLocaleStrings(localeProp) {
|
|
722
|
+
const normalized = (localeProp || (typeof document !== "undefined" ? document.documentElement.lang : "en") || "en").trim().toLowerCase();
|
|
723
|
+
if (dictionaries[normalized]) {
|
|
724
|
+
return dictionaries[normalized];
|
|
725
|
+
}
|
|
726
|
+
const base = normalized.split("-")[0];
|
|
727
|
+
if (dictionaries[base]) {
|
|
728
|
+
return dictionaries[base];
|
|
729
|
+
}
|
|
730
|
+
return enLocale;
|
|
731
|
+
}
|
|
732
|
+
|
|
615
733
|
// src/core/AccessibilityButton.tsx
|
|
616
734
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
617
735
|
function AccessibilityButton({
|
|
618
736
|
icon,
|
|
619
737
|
draggable = true,
|
|
620
|
-
title
|
|
738
|
+
title,
|
|
621
739
|
description,
|
|
622
740
|
className = "",
|
|
623
|
-
style
|
|
741
|
+
style,
|
|
742
|
+
largeControls
|
|
624
743
|
}) {
|
|
625
744
|
const ctx = useContext(AccessibilityContext);
|
|
626
745
|
if (!ctx)
|
|
627
746
|
throw new Error(
|
|
628
747
|
"AccessibilityButton must be used within an <AccessibilityPlugin> provider."
|
|
629
748
|
);
|
|
749
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
750
|
+
const buttonTitle = title ?? strings.buttonTitle;
|
|
751
|
+
const isLarge = largeControls ?? ctx.largeControls ?? false;
|
|
630
752
|
const viewport = useViewport();
|
|
631
753
|
const triggerSize = useTriggerSize(`${ctx.panelId}-trigger`);
|
|
632
754
|
const [preview, setPreview] = useState2(null);
|
|
@@ -647,6 +769,7 @@ function AccessibilityButton({
|
|
|
647
769
|
"data-dragging": !!preview,
|
|
648
770
|
"data-open": ctx.isOpen,
|
|
649
771
|
"data-position": ctx.position,
|
|
772
|
+
"data-large-controls": isLarge,
|
|
650
773
|
onPointerDown: (event) => {
|
|
651
774
|
suppressClick.current = false;
|
|
652
775
|
if (!draggable || !event.isPrimary || event.button !== 0) return;
|
|
@@ -726,7 +849,7 @@ function AccessibilityButton({
|
|
|
726
849
|
);
|
|
727
850
|
}
|
|
728
851
|
},
|
|
729
|
-
"aria-label":
|
|
852
|
+
"aria-label": buttonTitle,
|
|
730
853
|
"aria-keyshortcuts": draggable ? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight" : void 0,
|
|
731
854
|
"aria-describedby": description || draggable ? `${ctx.panelId}-trigger-description` : void 0,
|
|
732
855
|
"aria-expanded": ctx.isOpen,
|
|
@@ -748,14 +871,16 @@ function AccessibilityButton({
|
|
|
748
871
|
}
|
|
749
872
|
) }),
|
|
750
873
|
(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."
|
|
874
|
+
description ? `${description} ` : "",
|
|
875
|
+
draggable && strings.dragHelp
|
|
754
876
|
] })
|
|
755
877
|
]
|
|
756
878
|
}
|
|
757
879
|
),
|
|
758
|
-
/* @__PURE__ */ jsx3("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ?
|
|
880
|
+
/* @__PURE__ */ jsx3("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ? strings.formatPointPosition ? strings.formatPointPosition(
|
|
881
|
+
ctx.widgetPlacement.x,
|
|
882
|
+
ctx.widgetPlacement.y
|
|
883
|
+
) : `Button position: ${Math.round(ctx.widgetPlacement.x * 100)}% horizontally, ${Math.round(ctx.widgetPlacement.y * 100)}% vertically.` : strings.formatCornerPosition ? strings.formatCornerPosition(corner) : `Button position: ${corner.split("-").join(" ")}.` })
|
|
759
884
|
] });
|
|
760
885
|
}
|
|
761
886
|
|
|
@@ -771,6 +896,7 @@ import { useContext as useContext2, useEffect as useEffect3, useRef as useRef3,
|
|
|
771
896
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
772
897
|
function PositionControls() {
|
|
773
898
|
const ctx = useContext2(AccessibilityContext);
|
|
899
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
774
900
|
const [open, setOpen] = useState3(false);
|
|
775
901
|
const select = useRef3(null);
|
|
776
902
|
const opener = useRef3(null);
|
|
@@ -802,7 +928,7 @@ function PositionControls() {
|
|
|
802
928
|
event.currentTarget.focus();
|
|
803
929
|
setOpen(!open);
|
|
804
930
|
},
|
|
805
|
-
children:
|
|
931
|
+
children: strings.moveButton
|
|
806
932
|
}
|
|
807
933
|
),
|
|
808
934
|
/* @__PURE__ */ jsxs3(
|
|
@@ -812,7 +938,7 @@ function PositionControls() {
|
|
|
812
938
|
className: "arap-position-popover",
|
|
813
939
|
hidden: !open,
|
|
814
940
|
role: "group",
|
|
815
|
-
"aria-label":
|
|
941
|
+
"aria-label": strings.moveButtonLabel,
|
|
816
942
|
onKeyDown: (event) => {
|
|
817
943
|
if (event.key === "Escape") {
|
|
818
944
|
event.stopPropagation();
|
|
@@ -825,7 +951,7 @@ function PositionControls() {
|
|
|
825
951
|
{
|
|
826
952
|
className: "arap-position-label",
|
|
827
953
|
htmlFor: `${ctx.panelId}-corner`,
|
|
828
|
-
children:
|
|
954
|
+
children: strings.positionLabel
|
|
829
955
|
}
|
|
830
956
|
),
|
|
831
957
|
/* @__PURE__ */ jsxs3(
|
|
@@ -833,33 +959,33 @@ function PositionControls() {
|
|
|
833
959
|
{
|
|
834
960
|
ref: select,
|
|
835
961
|
id: `${ctx.panelId}-corner`,
|
|
836
|
-
"aria-label":
|
|
962
|
+
"aria-label": strings.buttonPositionSelectLabel,
|
|
837
963
|
value: ctx.widgetPlacement?.kind === "point" ? "custom" : ctx.widgetPlacement?.corner ?? defaultCorner(ctx.position),
|
|
838
964
|
onChange: (event) => ctx.setWidgetPlacement({
|
|
839
965
|
kind: "corner",
|
|
840
966
|
corner: event.target.value
|
|
841
967
|
}),
|
|
842
968
|
children: [
|
|
843
|
-
/* @__PURE__ */ jsx4("option", { value: "custom", disabled: true, children:
|
|
969
|
+
/* @__PURE__ */ jsx4("option", { value: "custom", disabled: true, children: strings.customPosition }),
|
|
844
970
|
corners.map((corner) => /* @__PURE__ */ jsx4("option", { value: corner, children: corner.split("-").join(" ") }, corner))
|
|
845
971
|
]
|
|
846
972
|
}
|
|
847
973
|
),
|
|
848
974
|
/* @__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(
|
|
975
|
+
["left", -20, 0, "\u2190", strings.moveLeft],
|
|
976
|
+
["up", 0, -20, "\u2191", strings.moveUp],
|
|
977
|
+
["down", 0, 20, "\u2193", strings.moveDown],
|
|
978
|
+
["right", 20, 0, "\u2192", strings.moveRight]
|
|
979
|
+
].map(([direction, dx, dy, arrowChar, label]) => /* @__PURE__ */ jsx4(
|
|
854
980
|
"button",
|
|
855
981
|
{
|
|
856
982
|
type: "button",
|
|
857
|
-
"aria-label":
|
|
983
|
+
"aria-label": label,
|
|
858
984
|
onClick: (event) => {
|
|
859
985
|
event.currentTarget.focus();
|
|
860
986
|
move(dx, dy);
|
|
861
987
|
},
|
|
862
|
-
children:
|
|
988
|
+
children: arrowChar
|
|
863
989
|
},
|
|
864
990
|
direction
|
|
865
991
|
)) }),
|
|
@@ -872,10 +998,10 @@ function PositionControls() {
|
|
|
872
998
|
event.currentTarget.focus();
|
|
873
999
|
ctx.setWidgetPlacement(null);
|
|
874
1000
|
},
|
|
875
|
-
children:
|
|
1001
|
+
children: strings.resetPosition
|
|
876
1002
|
}
|
|
877
1003
|
),
|
|
878
|
-
/* @__PURE__ */ jsx4("button", { className: "arap-position-default", type: "button", onClick: close, children:
|
|
1004
|
+
/* @__PURE__ */ jsx4("button", { className: "arap-position-default", type: "button", onClick: close, children: strings.doneMoving })
|
|
879
1005
|
]
|
|
880
1006
|
}
|
|
881
1007
|
)
|
|
@@ -889,11 +1015,22 @@ function Panel({
|
|
|
889
1015
|
footer,
|
|
890
1016
|
className = "",
|
|
891
1017
|
style,
|
|
892
|
-
title
|
|
893
|
-
description
|
|
894
|
-
closeLabel
|
|
1018
|
+
title,
|
|
1019
|
+
description,
|
|
1020
|
+
closeLabel,
|
|
1021
|
+
statementUrl,
|
|
1022
|
+
largeControls,
|
|
1023
|
+
locale
|
|
895
1024
|
}) {
|
|
896
1025
|
const ctx = useContext3(AccessibilityContext);
|
|
1026
|
+
const effectiveLocale = locale ?? ctx.locale;
|
|
1027
|
+
const strings = resolveLocaleStrings(effectiveLocale);
|
|
1028
|
+
const panelTitle = title ?? strings.title;
|
|
1029
|
+
const panelDescription = description === void 0 ? strings.description : description;
|
|
1030
|
+
const panelCloseLabel = closeLabel ?? strings.closeLabel;
|
|
1031
|
+
const effectiveStatementUrl = statementUrl ?? ctx.statementUrl;
|
|
1032
|
+
const isLarge = largeControls ?? ctx.largeControls ?? false;
|
|
1033
|
+
const isRtl = isRtlLocale(effectiveLocale);
|
|
897
1034
|
const panel = useRef4(null);
|
|
898
1035
|
const [actions, setActions] = useState4(null);
|
|
899
1036
|
const viewport = useViewport();
|
|
@@ -927,10 +1064,14 @@ function Panel({
|
|
|
927
1064
|
},
|
|
928
1065
|
"data-corner": corner,
|
|
929
1066
|
"data-position": ctx.position,
|
|
1067
|
+
"data-large-controls": isLarge,
|
|
1068
|
+
lang: effectiveLocale ?? "en",
|
|
1069
|
+
dir: isRtl ? "rtl" : "ltr",
|
|
1070
|
+
translate: "no",
|
|
930
1071
|
hidden: !ctx.isOpen,
|
|
931
1072
|
role: "region",
|
|
932
|
-
"aria-label":
|
|
933
|
-
"aria-describedby":
|
|
1073
|
+
"aria-label": panelTitle,
|
|
1074
|
+
"aria-describedby": panelDescription ? `${ctx.panelId}-description` : void 0,
|
|
934
1075
|
tabIndex: -1,
|
|
935
1076
|
onKeyDown: (event) => {
|
|
936
1077
|
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
@@ -941,10 +1082,18 @@ function Panel({
|
|
|
941
1082
|
children: [
|
|
942
1083
|
/* @__PURE__ */ jsxs4("div", { className: "arap-heading", children: [
|
|
943
1084
|
/* @__PURE__ */ jsxs4("div", { className: "arap-heading-copy", children: [
|
|
944
|
-
/* @__PURE__ */ jsx5("h2", { children:
|
|
945
|
-
|
|
1085
|
+
/* @__PURE__ */ jsx5("h2", { children: panelTitle }),
|
|
1086
|
+
panelDescription && /* @__PURE__ */ jsx5("p", { id: `${ctx.panelId}-description`, className: "arap-description", children: panelDescription })
|
|
946
1087
|
] }),
|
|
947
|
-
/* @__PURE__ */ jsx5(
|
|
1088
|
+
/* @__PURE__ */ jsx5(
|
|
1089
|
+
"button",
|
|
1090
|
+
{
|
|
1091
|
+
type: "button",
|
|
1092
|
+
"aria-label": panelCloseLabel,
|
|
1093
|
+
onClick: ctx.closeMenu,
|
|
1094
|
+
children: "\xD7"
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
948
1097
|
] }),
|
|
949
1098
|
/* @__PURE__ */ jsx5(
|
|
950
1099
|
"button",
|
|
@@ -957,7 +1106,7 @@ function Panel({
|
|
|
957
1106
|
);
|
|
958
1107
|
target?.focus();
|
|
959
1108
|
},
|
|
960
|
-
children:
|
|
1109
|
+
children: strings.skipToActions
|
|
961
1110
|
}
|
|
962
1111
|
),
|
|
963
1112
|
/* @__PURE__ */ jsx5(PanelActionsContext.Provider, { value: actions, children: /* @__PURE__ */ jsx5(
|
|
@@ -966,7 +1115,7 @@ function Panel({
|
|
|
966
1115
|
className: "arap-tools",
|
|
967
1116
|
role: "group",
|
|
968
1117
|
tabIndex: 0,
|
|
969
|
-
"aria-label":
|
|
1118
|
+
"aria-label": strings.toolsLabel,
|
|
970
1119
|
children
|
|
971
1120
|
}
|
|
972
1121
|
) }),
|
|
@@ -975,13 +1124,30 @@ function Panel({
|
|
|
975
1124
|
{
|
|
976
1125
|
className: "arap-quick-actions",
|
|
977
1126
|
role: "group",
|
|
978
|
-
"aria-label":
|
|
1127
|
+
"aria-label": strings.quickActionsLabel,
|
|
979
1128
|
children: [
|
|
980
1129
|
/* @__PURE__ */ jsx5(PositionControls, {}, ctx.isOpen ? "open" : "closed"),
|
|
981
1130
|
/* @__PURE__ */ jsx5("div", { className: "arap-actions", ref: setActions, children: footer })
|
|
982
1131
|
]
|
|
983
1132
|
}
|
|
984
|
-
)
|
|
1133
|
+
),
|
|
1134
|
+
effectiveStatementUrl && /* @__PURE__ */ jsx5("div", { className: "arap-statement", children: /* @__PURE__ */ jsxs4(
|
|
1135
|
+
"a",
|
|
1136
|
+
{
|
|
1137
|
+
href: effectiveStatementUrl,
|
|
1138
|
+
className: "arap-statement-link",
|
|
1139
|
+
target: "_blank",
|
|
1140
|
+
rel: "noopener noreferrer",
|
|
1141
|
+
children: [
|
|
1142
|
+
strings.statementLink,
|
|
1143
|
+
/* @__PURE__ */ jsxs4("span", { className: "arap-sr-only", children: [
|
|
1144
|
+
" (",
|
|
1145
|
+
strings.openInNewTab,
|
|
1146
|
+
")"
|
|
1147
|
+
] })
|
|
1148
|
+
]
|
|
1149
|
+
}
|
|
1150
|
+
) })
|
|
985
1151
|
]
|
|
986
1152
|
}
|
|
987
1153
|
);
|
|
@@ -1033,6 +1199,304 @@ function useAccessibility(featureKey, defaultValue, options) {
|
|
|
1033
1199
|
return { value, setValue, reset };
|
|
1034
1200
|
}
|
|
1035
1201
|
|
|
1202
|
+
// src/core/preferences/defaults.ts
|
|
1203
|
+
var DEFAULT_PREFERENCES = Object.freeze({
|
|
1204
|
+
fontScale: 1,
|
|
1205
|
+
lineHeight: null,
|
|
1206
|
+
letterSpacingEm: null,
|
|
1207
|
+
wordSpacingEm: null,
|
|
1208
|
+
paragraphSpacingEm: null,
|
|
1209
|
+
textAlign: "original",
|
|
1210
|
+
contrastMode: "off",
|
|
1211
|
+
highlightLinks: false,
|
|
1212
|
+
highlightFocus: false,
|
|
1213
|
+
reduceMotion: false,
|
|
1214
|
+
hideDecorativeImages: false,
|
|
1215
|
+
fontFamily: "original",
|
|
1216
|
+
cursorSize: "original",
|
|
1217
|
+
readerMode: "off",
|
|
1218
|
+
saturation: "original",
|
|
1219
|
+
tooltips: false
|
|
1220
|
+
});
|
|
1221
|
+
var PROFILE_DEFINITIONS = {
|
|
1222
|
+
motor: {
|
|
1223
|
+
id: "motor",
|
|
1224
|
+
label: "Motor Impaired",
|
|
1225
|
+
description: "Enhanced focus rings, richer tooltips, and reduced motion.",
|
|
1226
|
+
settings: {
|
|
1227
|
+
reduceMotion: true,
|
|
1228
|
+
highlightFocus: true,
|
|
1229
|
+
tooltips: true
|
|
1230
|
+
}
|
|
1231
|
+
},
|
|
1232
|
+
blind: {
|
|
1233
|
+
id: "blind",
|
|
1234
|
+
label: "Blind & Screen Reader",
|
|
1235
|
+
description: "Semantic assistance and accessible authored descriptions.",
|
|
1236
|
+
settings: {
|
|
1237
|
+
tooltips: true
|
|
1238
|
+
}
|
|
1239
|
+
},
|
|
1240
|
+
"color-blind": {
|
|
1241
|
+
id: "color-blind",
|
|
1242
|
+
label: "Color Blind",
|
|
1243
|
+
description: "High contrast accents and non-color-only link indicators.",
|
|
1244
|
+
settings: {
|
|
1245
|
+
contrastMode: "high",
|
|
1246
|
+
highlightLinks: true
|
|
1247
|
+
}
|
|
1248
|
+
},
|
|
1249
|
+
dyslexia: {
|
|
1250
|
+
id: "dyslexia",
|
|
1251
|
+
label: "Dyslexia Friendly",
|
|
1252
|
+
description: "Legible typeface, reading guide line, and reduced motion.",
|
|
1253
|
+
settings: {
|
|
1254
|
+
fontFamily: "dyslexia-option",
|
|
1255
|
+
readerMode: "guide",
|
|
1256
|
+
reduceMotion: true
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1259
|
+
"low-vision": {
|
|
1260
|
+
id: "low-vision",
|
|
1261
|
+
label: "Low Vision",
|
|
1262
|
+
description: "Enlarged text, large cursor pointer, and high-visibility focus.",
|
|
1263
|
+
settings: {
|
|
1264
|
+
fontScale: 1.25,
|
|
1265
|
+
cursorSize: "large",
|
|
1266
|
+
highlightFocus: true,
|
|
1267
|
+
tooltips: true
|
|
1268
|
+
}
|
|
1269
|
+
},
|
|
1270
|
+
cognitive: {
|
|
1271
|
+
id: "cognitive",
|
|
1272
|
+
label: "Cognitive & Learning",
|
|
1273
|
+
description: "Mild text scaling, reading guide line, and distraction reduction.",
|
|
1274
|
+
settings: {
|
|
1275
|
+
fontScale: 1.125,
|
|
1276
|
+
readerMode: "guide",
|
|
1277
|
+
reduceMotion: true,
|
|
1278
|
+
tooltips: true
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
seizure: {
|
|
1282
|
+
id: "seizure",
|
|
1283
|
+
label: "Seizure & Epileptic",
|
|
1284
|
+
description: "Pauses nonessential motion and reduces transition flashes.",
|
|
1285
|
+
settings: {
|
|
1286
|
+
reduceMotion: true
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
adhd: {
|
|
1290
|
+
id: "adhd",
|
|
1291
|
+
label: "ADHD / Focus",
|
|
1292
|
+
description: "Reading mask spotlight and reduced animation distraction.",
|
|
1293
|
+
settings: {
|
|
1294
|
+
readerMode: "mask",
|
|
1295
|
+
reduceMotion: true
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
|
|
1300
|
+
// src/core/preferences/registry.ts
|
|
1301
|
+
var VALID_CONTRAST_MODES = /* @__PURE__ */ new Set([
|
|
1302
|
+
"off",
|
|
1303
|
+
"light",
|
|
1304
|
+
"dark",
|
|
1305
|
+
"high",
|
|
1306
|
+
"invert"
|
|
1307
|
+
]);
|
|
1308
|
+
var VALID_READER_MODES = /* @__PURE__ */ new Set([
|
|
1309
|
+
"off",
|
|
1310
|
+
"guide",
|
|
1311
|
+
"mask"
|
|
1312
|
+
]);
|
|
1313
|
+
var VALID_TEXT_ALIGNS = /* @__PURE__ */ new Set([
|
|
1314
|
+
"original",
|
|
1315
|
+
"left",
|
|
1316
|
+
"right",
|
|
1317
|
+
"center",
|
|
1318
|
+
"justify"
|
|
1319
|
+
]);
|
|
1320
|
+
var VALID_FONT_FAMILIES = /* @__PURE__ */ new Set([
|
|
1321
|
+
"original",
|
|
1322
|
+
"legible",
|
|
1323
|
+
"dyslexia-option"
|
|
1324
|
+
]);
|
|
1325
|
+
var VALID_CURSOR_SIZES = /* @__PURE__ */ new Set([
|
|
1326
|
+
"original",
|
|
1327
|
+
"large"
|
|
1328
|
+
]);
|
|
1329
|
+
var VALID_SATURATIONS = /* @__PURE__ */ new Set([
|
|
1330
|
+
"original",
|
|
1331
|
+
"low",
|
|
1332
|
+
"high",
|
|
1333
|
+
"grayscale"
|
|
1334
|
+
]);
|
|
1335
|
+
function clamp(value, min, max) {
|
|
1336
|
+
if (Number.isNaN(value) || !Number.isFinite(value)) return min;
|
|
1337
|
+
return Math.min(Math.max(value, min), max);
|
|
1338
|
+
}
|
|
1339
|
+
function normalizePreferenceValue(key, value) {
|
|
1340
|
+
switch (key) {
|
|
1341
|
+
case "fontScale":
|
|
1342
|
+
return typeof value === "number" ? clamp(value, 0.5, 2) : 1;
|
|
1343
|
+
case "lineHeight":
|
|
1344
|
+
if (value === null || value === void 0)
|
|
1345
|
+
return null;
|
|
1346
|
+
return typeof value === "number" ? clamp(value, 0.5, 2) : null;
|
|
1347
|
+
case "letterSpacingEm":
|
|
1348
|
+
if (value === null || value === void 0)
|
|
1349
|
+
return null;
|
|
1350
|
+
return typeof value === "number" ? clamp(value, 0, 0.5) : null;
|
|
1351
|
+
case "wordSpacingEm":
|
|
1352
|
+
if (value === null || value === void 0)
|
|
1353
|
+
return null;
|
|
1354
|
+
return typeof value === "number" ? clamp(value, 0, 0.5) : null;
|
|
1355
|
+
case "paragraphSpacingEm":
|
|
1356
|
+
if (value === null || value === void 0)
|
|
1357
|
+
return null;
|
|
1358
|
+
return typeof value === "number" ? clamp(value, 0, 1) : null;
|
|
1359
|
+
case "textAlign":
|
|
1360
|
+
return typeof value === "string" && VALID_TEXT_ALIGNS.has(value) ? value : "original";
|
|
1361
|
+
case "contrastMode":
|
|
1362
|
+
return typeof value === "string" && VALID_CONTRAST_MODES.has(value) ? value : "off";
|
|
1363
|
+
case "fontFamily":
|
|
1364
|
+
return typeof value === "string" && VALID_FONT_FAMILIES.has(value) ? value : "original";
|
|
1365
|
+
case "cursorSize":
|
|
1366
|
+
return typeof value === "string" && VALID_CURSOR_SIZES.has(value) ? value : "original";
|
|
1367
|
+
case "readerMode":
|
|
1368
|
+
return typeof value === "string" && VALID_READER_MODES.has(value) ? value : "off";
|
|
1369
|
+
case "saturation":
|
|
1370
|
+
return typeof value === "string" && VALID_SATURATIONS.has(value) ? value : "original";
|
|
1371
|
+
case "highlightLinks":
|
|
1372
|
+
case "highlightFocus":
|
|
1373
|
+
case "reduceMotion":
|
|
1374
|
+
case "hideDecorativeImages":
|
|
1375
|
+
case "tooltips":
|
|
1376
|
+
return Boolean(value);
|
|
1377
|
+
default:
|
|
1378
|
+
return value;
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function normalizePreferences(input) {
|
|
1382
|
+
const result = { ...DEFAULT_PREFERENCES };
|
|
1383
|
+
if (!input || typeof input !== "object") return result;
|
|
1384
|
+
for (const k of Object.keys(DEFAULT_PREFERENCES)) {
|
|
1385
|
+
if (k in input && input[k] !== void 0) {
|
|
1386
|
+
result[k] = normalizePreferenceValue(k, input[k]);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return result;
|
|
1390
|
+
}
|
|
1391
|
+
function resolveEffectivePreferences(base, profileSnapshot, overrides) {
|
|
1392
|
+
const merged = {
|
|
1393
|
+
...DEFAULT_PREFERENCES,
|
|
1394
|
+
...base,
|
|
1395
|
+
...profileSnapshot ?? {},
|
|
1396
|
+
...overrides
|
|
1397
|
+
};
|
|
1398
|
+
return normalizePreferences(merged);
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
// src/core/preferences/reducer.ts
|
|
1402
|
+
function createInitialPreferencesState(initial) {
|
|
1403
|
+
const base = normalizePreferences(initial);
|
|
1404
|
+
return {
|
|
1405
|
+
base,
|
|
1406
|
+
activeProfileId: null,
|
|
1407
|
+
profileSnapshot: null,
|
|
1408
|
+
overrides: {},
|
|
1409
|
+
effective: { ...base }
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
function preferencesReducer(state, action) {
|
|
1413
|
+
switch (action.type) {
|
|
1414
|
+
case "SET_PREFERENCE": {
|
|
1415
|
+
const normalizedValue = normalizePreferenceValue(
|
|
1416
|
+
action.key,
|
|
1417
|
+
action.value
|
|
1418
|
+
);
|
|
1419
|
+
if (state.activeProfileId) {
|
|
1420
|
+
const nextOverrides = {
|
|
1421
|
+
...state.overrides,
|
|
1422
|
+
[action.key]: normalizedValue
|
|
1423
|
+
};
|
|
1424
|
+
return {
|
|
1425
|
+
...state,
|
|
1426
|
+
overrides: nextOverrides,
|
|
1427
|
+
effective: resolveEffectivePreferences(
|
|
1428
|
+
state.base,
|
|
1429
|
+
state.profileSnapshot,
|
|
1430
|
+
nextOverrides
|
|
1431
|
+
)
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
const nextBase = {
|
|
1435
|
+
...state.base,
|
|
1436
|
+
[action.key]: normalizedValue
|
|
1437
|
+
};
|
|
1438
|
+
return {
|
|
1439
|
+
...state,
|
|
1440
|
+
base: nextBase,
|
|
1441
|
+
effective: resolveEffectivePreferences(nextBase, null, state.overrides)
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
case "APPLY_PROFILE": {
|
|
1445
|
+
const profile = PROFILE_DEFINITIONS[action.profileId];
|
|
1446
|
+
const settings = action.settings || profile?.settings || {};
|
|
1447
|
+
const profileSnapshot = { ...settings };
|
|
1448
|
+
const nextOverrides = {};
|
|
1449
|
+
return {
|
|
1450
|
+
...state,
|
|
1451
|
+
activeProfileId: action.profileId,
|
|
1452
|
+
profileSnapshot,
|
|
1453
|
+
overrides: nextOverrides,
|
|
1454
|
+
effective: resolveEffectivePreferences(
|
|
1455
|
+
state.base,
|
|
1456
|
+
profileSnapshot,
|
|
1457
|
+
nextOverrides
|
|
1458
|
+
)
|
|
1459
|
+
};
|
|
1460
|
+
}
|
|
1461
|
+
case "CLEAR_PROFILE": {
|
|
1462
|
+
const nextBase = {
|
|
1463
|
+
...state.base,
|
|
1464
|
+
...state.overrides
|
|
1465
|
+
};
|
|
1466
|
+
return {
|
|
1467
|
+
...state,
|
|
1468
|
+
activeProfileId: null,
|
|
1469
|
+
profileSnapshot: null,
|
|
1470
|
+
overrides: {},
|
|
1471
|
+
effective: normalizePreferences(nextBase),
|
|
1472
|
+
base: nextBase
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
case "RESET_ALL": {
|
|
1476
|
+
const cleanBase = { ...DEFAULT_PREFERENCES };
|
|
1477
|
+
return {
|
|
1478
|
+
base: cleanBase,
|
|
1479
|
+
activeProfileId: null,
|
|
1480
|
+
profileSnapshot: null,
|
|
1481
|
+
overrides: {},
|
|
1482
|
+
effective: cleanBase
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
case "IMPORT_PREFERENCES": {
|
|
1486
|
+
const cleanBase = normalizePreferences(action.preferences);
|
|
1487
|
+
return {
|
|
1488
|
+
base: cleanBase,
|
|
1489
|
+
activeProfileId: null,
|
|
1490
|
+
profileSnapshot: null,
|
|
1491
|
+
overrides: {},
|
|
1492
|
+
effective: cleanBase
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
default:
|
|
1496
|
+
return state;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1036
1500
|
// src/core/FeatureIcon.tsx
|
|
1037
1501
|
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1038
1502
|
var drawings = {
|
|
@@ -1626,9 +2090,10 @@ function ResetController() {
|
|
|
1626
2090
|
}
|
|
1627
2091
|
const actionHost = useContext5(PanelActionsContext);
|
|
1628
2092
|
const { resetAll } = ctx;
|
|
2093
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
1629
2094
|
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
2095
|
/* @__PURE__ */ jsx21(FeatureIcon, { name: "reset" }),
|
|
1631
|
-
|
|
2096
|
+
strings.resetAll
|
|
1632
2097
|
] }) });
|
|
1633
2098
|
return actionHost ? createPortal2(button, actionHost) : button;
|
|
1634
2099
|
}
|
|
@@ -1639,6 +2104,7 @@ export {
|
|
|
1639
2104
|
AccessibilityPlugin,
|
|
1640
2105
|
BigCursorController,
|
|
1641
2106
|
ContrastController,
|
|
2107
|
+
DEFAULT_PREFERENCES,
|
|
1642
2108
|
FontSizeController,
|
|
1643
2109
|
GrayscaleController,
|
|
1644
2110
|
HideImagesController,
|
|
@@ -1647,11 +2113,21 @@ export {
|
|
|
1647
2113
|
LetterSpacingController,
|
|
1648
2114
|
LineHeightController,
|
|
1649
2115
|
LinkHighlightController,
|
|
2116
|
+
PROFILE_DEFINITIONS,
|
|
1650
2117
|
ReadingGuideController,
|
|
1651
2118
|
ReadingMaskController,
|
|
1652
2119
|
ResetController,
|
|
1653
2120
|
SaturationController,
|
|
1654
2121
|
TextAlignController,
|
|
2122
|
+
createInitialPreferencesState,
|
|
2123
|
+
enLocale,
|
|
2124
|
+
isRtlLocale,
|
|
2125
|
+
normalizePreferenceValue,
|
|
2126
|
+
normalizePreferences,
|
|
2127
|
+
preferencesReducer,
|
|
2128
|
+
registerLocale,
|
|
2129
|
+
resolveEffectivePreferences,
|
|
2130
|
+
resolveLocaleStrings,
|
|
1655
2131
|
useAccessibility
|
|
1656
2132
|
};
|
|
1657
2133
|
//# sourceMappingURL=index.mjs.map
|