accessibility-plugin-react 2.0.2 → 2.2.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/dist/index.d.mts +135 -4
- package/dist/index.d.ts +135 -4
- package/dist/index.js +540 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +529 -59
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +110 -0
- package/docs/BASELINE_AUDIT.md +219 -0
- package/docs/RELEASE.md +2 -2
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ function styleInject(css, { insertAt } = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
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');
|
|
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
28
|
|
|
29
29
|
// src/core/AccessibilityPlugin.tsx
|
|
30
30
|
import {
|
|
@@ -139,9 +139,19 @@ function validKey(key) {
|
|
|
139
139
|
function isRecord(value) {
|
|
140
140
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function getStorage(mode = "local") {
|
|
143
|
+
if (mode === "none" || typeof window === "undefined") return null;
|
|
143
144
|
try {
|
|
144
|
-
|
|
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;
|
|
153
|
+
try {
|
|
154
|
+
const raw = JSON.parse(storage.getItem(key) || "null");
|
|
145
155
|
if (!isRecord(raw)) return null;
|
|
146
156
|
const features = "version" in raw ? raw.version === 1 ? raw.features : null : raw;
|
|
147
157
|
if (!isRecord(features)) return null;
|
|
@@ -152,19 +162,23 @@ function loadState(key = DEFAULT_STORAGE_KEY) {
|
|
|
152
162
|
return null;
|
|
153
163
|
}
|
|
154
164
|
}
|
|
155
|
-
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;
|
|
156
168
|
try {
|
|
157
|
-
|
|
169
|
+
storage.setItem(key, JSON.stringify({ version: 1, features: state }));
|
|
158
170
|
} catch {
|
|
159
171
|
}
|
|
160
172
|
}
|
|
161
|
-
function clearState(key = DEFAULT_STORAGE_KEY) {
|
|
173
|
+
function clearState(key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
174
|
+
const storage = getStorage(mode);
|
|
175
|
+
if (!storage) return;
|
|
162
176
|
try {
|
|
163
|
-
|
|
177
|
+
storage.removeItem(key);
|
|
164
178
|
} catch {
|
|
165
179
|
}
|
|
166
180
|
}
|
|
167
|
-
function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
181
|
+
function createStorageWriter(key = DEFAULT_STORAGE_KEY, mode = "local") {
|
|
168
182
|
let timer;
|
|
169
183
|
let pending;
|
|
170
184
|
const cancel = () => {
|
|
@@ -175,7 +189,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
175
189
|
const flush = () => {
|
|
176
190
|
const next = pending;
|
|
177
191
|
cancel();
|
|
178
|
-
if (next) saveState(next, key);
|
|
192
|
+
if (next) saveState(next, key, mode);
|
|
179
193
|
};
|
|
180
194
|
return {
|
|
181
195
|
schedule(state) {
|
|
@@ -185,7 +199,7 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
185
199
|
},
|
|
186
200
|
clear() {
|
|
187
201
|
cancel();
|
|
188
|
-
clearState(key);
|
|
202
|
+
clearState(key, mode);
|
|
189
203
|
},
|
|
190
204
|
cancel,
|
|
191
205
|
flush
|
|
@@ -193,13 +207,14 @@ function createStorageWriter(key = DEFAULT_STORAGE_KEY) {
|
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
// src/core/preferenceStore.ts
|
|
196
|
-
function createPreferenceStore(key, persist) {
|
|
197
|
-
const
|
|
210
|
+
function createPreferenceStore(key, persist, storageMode) {
|
|
211
|
+
const resolvedMode = storageMode ?? (persist ? "local" : "none");
|
|
212
|
+
const writer = createStorageWriter(key, resolvedMode);
|
|
198
213
|
const empty = {};
|
|
199
214
|
let snapshot2;
|
|
200
215
|
const listeners = /* @__PURE__ */ new Set();
|
|
201
216
|
const getSnapshot = () => {
|
|
202
|
-
snapshot2 ?? (snapshot2 =
|
|
217
|
+
snapshot2 ?? (snapshot2 = resolvedMode !== "none" ? loadState(key, resolvedMode) ?? {} : {});
|
|
203
218
|
return snapshot2;
|
|
204
219
|
};
|
|
205
220
|
return {
|
|
@@ -213,7 +228,7 @@ function createPreferenceStore(key, persist) {
|
|
|
213
228
|
},
|
|
214
229
|
update(update) {
|
|
215
230
|
snapshot2 = update(getSnapshot());
|
|
216
|
-
if (
|
|
231
|
+
if (resolvedMode !== "none") {
|
|
217
232
|
if (Object.keys(snapshot2).length) writer.schedule(snapshot2);
|
|
218
233
|
else writer.clear();
|
|
219
234
|
}
|
|
@@ -287,7 +302,8 @@ function validValue(key, value, fallback, validate) {
|
|
|
287
302
|
|
|
288
303
|
// src/core/effects.ts
|
|
289
304
|
import { useEffect } from "react";
|
|
290
|
-
var EXCLUDED = "[data-arap-ui], [data-arap-ui] *, script, style, link, meta";
|
|
305
|
+
var EXCLUDED = "[data-arap-ui], [data-arap-ui] *, script, style, link, meta, noscript, template";
|
|
306
|
+
var MAX_HOST_ELEMENTS = 4e3;
|
|
291
307
|
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`;
|
|
292
308
|
var palette = {
|
|
293
309
|
"yellow-on-black": ["#ffff00", "#000000"],
|
|
@@ -319,9 +335,10 @@ function applyPage(values) {
|
|
|
319
335
|
else element.style.removeProperty(property);
|
|
320
336
|
});
|
|
321
337
|
}
|
|
322
|
-
const
|
|
338
|
+
const allElements = Array.from(
|
|
323
339
|
document.body.querySelectorAll("*")
|
|
324
340
|
).filter((el) => el instanceof HTMLElement && !el.matches(EXCLUDED));
|
|
341
|
+
const elements = allElements.length > MAX_HOST_ELEMENTS ? allElements.slice(0, MAX_HOST_ELEMENTS) : allElements;
|
|
325
342
|
const font = Number(values.fontSize ?? 100) / 100;
|
|
326
343
|
const line = Number(values.lineHeight ?? 100) / 100;
|
|
327
344
|
const measurements = font !== 1 || line !== 1 ? elements.map((el) => {
|
|
@@ -387,6 +404,10 @@ function applyPage(values) {
|
|
|
387
404
|
};
|
|
388
405
|
}
|
|
389
406
|
function readingAid(mask) {
|
|
407
|
+
const existing = document.body.querySelectorAll(
|
|
408
|
+
mask ? ".arap-reading-mask" : ".arap-reading-guide"
|
|
409
|
+
);
|
|
410
|
+
existing.forEach((node) => node.remove());
|
|
390
411
|
const el = document.createElement("div");
|
|
391
412
|
el.dataset.arapUi = "";
|
|
392
413
|
el.className = mask ? "arap-reading-mask" : "arap-reading-guide";
|
|
@@ -418,6 +439,8 @@ function useBuiltinEffects(values) {
|
|
|
418
439
|
))
|
|
419
440
|
return;
|
|
420
441
|
let undo = applyPage(values);
|
|
442
|
+
let mutationTimer = null;
|
|
443
|
+
let resizeTimer = null;
|
|
421
444
|
const observer = new MutationObserver((records) => {
|
|
422
445
|
if (!records.some(
|
|
423
446
|
(record) => record.target instanceof Element && !record.target.closest("[data-arap-ui]") && [...record.addedNodes, ...record.removedNodes].some(
|
|
@@ -425,16 +448,24 @@ function useBuiltinEffects(values) {
|
|
|
425
448
|
)
|
|
426
449
|
))
|
|
427
450
|
return;
|
|
428
|
-
|
|
429
|
-
|
|
451
|
+
if (mutationTimer) clearTimeout(mutationTimer);
|
|
452
|
+
mutationTimer = setTimeout(() => {
|
|
453
|
+
undo();
|
|
454
|
+
undo = applyPage(values);
|
|
455
|
+
}, 16);
|
|
430
456
|
});
|
|
431
457
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
432
458
|
const resize = () => {
|
|
433
|
-
|
|
434
|
-
|
|
459
|
+
if (resizeTimer) clearTimeout(resizeTimer);
|
|
460
|
+
resizeTimer = setTimeout(() => {
|
|
461
|
+
undo();
|
|
462
|
+
undo = applyPage(values);
|
|
463
|
+
}, 50);
|
|
435
464
|
};
|
|
436
465
|
window.addEventListener("resize", resize);
|
|
437
466
|
return () => {
|
|
467
|
+
if (mutationTimer) clearTimeout(mutationTimer);
|
|
468
|
+
if (resizeTimer) clearTimeout(resizeTimer);
|
|
438
469
|
observer.disconnect();
|
|
439
470
|
window.removeEventListener("resize", resize);
|
|
440
471
|
undo();
|
|
@@ -453,7 +484,10 @@ function CustomEffect({
|
|
|
453
484
|
definition,
|
|
454
485
|
value
|
|
455
486
|
}) {
|
|
456
|
-
useEffect(() =>
|
|
487
|
+
useEffect(() => {
|
|
488
|
+
const cleanup = definition.apply?.(value);
|
|
489
|
+
return typeof cleanup === "function" ? cleanup : void 0;
|
|
490
|
+
}, [definition, value]);
|
|
457
491
|
return null;
|
|
458
492
|
}
|
|
459
493
|
|
|
@@ -464,11 +498,15 @@ function AccessibilityPlugin({
|
|
|
464
498
|
children,
|
|
465
499
|
position = "right",
|
|
466
500
|
persistenceKey,
|
|
467
|
-
persist = true
|
|
501
|
+
persist = true,
|
|
502
|
+
storage,
|
|
503
|
+
locale,
|
|
504
|
+
statementUrl,
|
|
505
|
+
largeControls
|
|
468
506
|
}) {
|
|
469
507
|
const [isOpen, setIsOpen] = useState(false);
|
|
470
508
|
const [store] = useState(
|
|
471
|
-
() => createPreferenceStore(persistenceKey, persist)
|
|
509
|
+
() => createPreferenceStore(persistenceKey, persist, storage)
|
|
472
510
|
);
|
|
473
511
|
const features = useSyncExternalStore2(
|
|
474
512
|
store.subscribe,
|
|
@@ -582,7 +620,10 @@ function AccessibilityPlugin({
|
|
|
582
620
|
registerFeature,
|
|
583
621
|
resetAll,
|
|
584
622
|
registerReset,
|
|
585
|
-
unregisterReset
|
|
623
|
+
unregisterReset,
|
|
624
|
+
locale,
|
|
625
|
+
statementUrl,
|
|
626
|
+
largeControls
|
|
586
627
|
}),
|
|
587
628
|
[
|
|
588
629
|
isOpen,
|
|
@@ -598,7 +639,10 @@ function AccessibilityPlugin({
|
|
|
598
639
|
registerFeature,
|
|
599
640
|
resetAll,
|
|
600
641
|
registerReset,
|
|
601
|
-
unregisterReset
|
|
642
|
+
unregisterReset,
|
|
643
|
+
locale,
|
|
644
|
+
statementUrl,
|
|
645
|
+
largeControls
|
|
602
646
|
]
|
|
603
647
|
);
|
|
604
648
|
return /* @__PURE__ */ jsxs(AccessibilityContext.Provider, { value, children: [
|
|
@@ -637,21 +681,93 @@ function WidgetPortal({ children }) {
|
|
|
637
681
|
) : null;
|
|
638
682
|
}
|
|
639
683
|
|
|
684
|
+
// src/core/i18n/en.ts
|
|
685
|
+
var enLocale = Object.freeze({
|
|
686
|
+
title: "Accessibility settings",
|
|
687
|
+
description: "Adjust your reading experience",
|
|
688
|
+
closeLabel: "Close accessibility settings",
|
|
689
|
+
skipToActions: "Jump to quick actions",
|
|
690
|
+
toolsLabel: "Accessibility tools",
|
|
691
|
+
quickActionsLabel: "Quick actions",
|
|
692
|
+
resetLabel: "Reset all accessibility settings",
|
|
693
|
+
resetAll: "Reset All",
|
|
694
|
+
statementLink: "Accessibility Statement",
|
|
695
|
+
openInNewTab: "opens in a new tab",
|
|
696
|
+
buttonTitle: "Accessibility",
|
|
697
|
+
dragHelp: "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls.",
|
|
698
|
+
positionLabel: "Button position",
|
|
699
|
+
moveButton: "Move button",
|
|
700
|
+
moveButtonLabel: "Move accessibility button",
|
|
701
|
+
buttonPositionSelectLabel: "Accessibility button position",
|
|
702
|
+
customPosition: "Custom position",
|
|
703
|
+
resetPosition: "Reset button position",
|
|
704
|
+
doneMoving: "Done moving",
|
|
705
|
+
moveLeft: "Move accessibility button left",
|
|
706
|
+
moveUp: "Move accessibility button up",
|
|
707
|
+
moveDown: "Move accessibility button down",
|
|
708
|
+
moveRight: "Move accessibility button right",
|
|
709
|
+
largeControlsLabel: "Oversized widget controls",
|
|
710
|
+
formatPointPosition: (x, y) => `Button position: ${Math.round(x * 100)}% horizontally, ${Math.round(y * 100)}% vertically.`,
|
|
711
|
+
formatCornerPosition: (corner) => `Button position: ${corner.split("-").join(" ")}.`
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
// src/core/i18n/index.ts
|
|
715
|
+
var dictionaries = {
|
|
716
|
+
en: enLocale
|
|
717
|
+
};
|
|
718
|
+
var RTL_LOCALES = /* @__PURE__ */ new Set([
|
|
719
|
+
"ar",
|
|
720
|
+
"arc",
|
|
721
|
+
"dv",
|
|
722
|
+
"fa",
|
|
723
|
+
"ha",
|
|
724
|
+
"he",
|
|
725
|
+
"khw",
|
|
726
|
+
"ks",
|
|
727
|
+
"ku",
|
|
728
|
+
"ps",
|
|
729
|
+
"ur",
|
|
730
|
+
"yi"
|
|
731
|
+
]);
|
|
732
|
+
function registerLocale(code, strings) {
|
|
733
|
+
dictionaries[code.toLowerCase()] = strings;
|
|
734
|
+
}
|
|
735
|
+
function isRtlLocale(localeProp) {
|
|
736
|
+
if (!localeProp) return false;
|
|
737
|
+
const base = localeProp.toLowerCase().split("-")[0];
|
|
738
|
+
return RTL_LOCALES.has(base);
|
|
739
|
+
}
|
|
740
|
+
function resolveLocaleStrings(localeProp) {
|
|
741
|
+
const normalized = (localeProp || (typeof document !== "undefined" ? document.documentElement.lang : "en") || "en").trim().toLowerCase();
|
|
742
|
+
if (dictionaries[normalized]) {
|
|
743
|
+
return dictionaries[normalized];
|
|
744
|
+
}
|
|
745
|
+
const base = normalized.split("-")[0];
|
|
746
|
+
if (dictionaries[base]) {
|
|
747
|
+
return dictionaries[base];
|
|
748
|
+
}
|
|
749
|
+
return enLocale;
|
|
750
|
+
}
|
|
751
|
+
|
|
640
752
|
// src/core/AccessibilityButton.tsx
|
|
641
753
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
642
754
|
function AccessibilityButton({
|
|
643
755
|
icon,
|
|
644
756
|
draggable = true,
|
|
645
|
-
title
|
|
757
|
+
title,
|
|
646
758
|
description,
|
|
647
759
|
className = "",
|
|
648
|
-
style
|
|
760
|
+
style,
|
|
761
|
+
largeControls
|
|
649
762
|
}) {
|
|
650
763
|
const ctx = useContext(AccessibilityContext);
|
|
651
764
|
if (!ctx)
|
|
652
765
|
throw new Error(
|
|
653
766
|
"AccessibilityButton must be used within an <AccessibilityPlugin> provider."
|
|
654
767
|
);
|
|
768
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
769
|
+
const buttonTitle = title ?? strings.buttonTitle;
|
|
770
|
+
const isLarge = largeControls ?? ctx.largeControls ?? false;
|
|
655
771
|
const viewport = useViewport();
|
|
656
772
|
const triggerSize = useTriggerSize(`${ctx.panelId}-trigger`);
|
|
657
773
|
const [preview, setPreview] = useState2(null);
|
|
@@ -672,6 +788,7 @@ function AccessibilityButton({
|
|
|
672
788
|
"data-dragging": !!preview,
|
|
673
789
|
"data-open": ctx.isOpen,
|
|
674
790
|
"data-position": ctx.position,
|
|
791
|
+
"data-large-controls": isLarge,
|
|
675
792
|
onPointerDown: (event) => {
|
|
676
793
|
suppressClick.current = false;
|
|
677
794
|
if (!draggable || !event.isPrimary || event.button !== 0) return;
|
|
@@ -751,7 +868,7 @@ function AccessibilityButton({
|
|
|
751
868
|
);
|
|
752
869
|
}
|
|
753
870
|
},
|
|
754
|
-
"aria-label":
|
|
871
|
+
"aria-label": buttonTitle,
|
|
755
872
|
"aria-keyshortcuts": draggable ? "Alt+ArrowUp Alt+ArrowDown Alt+ArrowLeft Alt+ArrowRight" : void 0,
|
|
756
873
|
"aria-describedby": description || draggable ? `${ctx.panelId}-trigger-description` : void 0,
|
|
757
874
|
"aria-expanded": ctx.isOpen,
|
|
@@ -773,14 +890,16 @@ function AccessibilityButton({
|
|
|
773
890
|
}
|
|
774
891
|
) }),
|
|
775
892
|
(description || draggable) && /* @__PURE__ */ jsxs2("span", { id: `${ctx.panelId}-trigger-description`, hidden: true, children: [
|
|
776
|
-
description,
|
|
777
|
-
|
|
778
|
-
draggable && "Drag to move, or use Alt and arrow keys. The Move button menu offers click and keyboard controls."
|
|
893
|
+
description ? `${description} ` : "",
|
|
894
|
+
draggable && strings.dragHelp
|
|
779
895
|
] })
|
|
780
896
|
]
|
|
781
897
|
}
|
|
782
898
|
),
|
|
783
|
-
/* @__PURE__ */ jsx3("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ?
|
|
899
|
+
/* @__PURE__ */ jsx3("span", { className: "arap-sr-only", role: "status", children: ctx.widgetPlacement?.kind === "point" ? strings.formatPointPosition ? strings.formatPointPosition(
|
|
900
|
+
ctx.widgetPlacement.x,
|
|
901
|
+
ctx.widgetPlacement.y
|
|
902
|
+
) : `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(" ")}.` })
|
|
784
903
|
] });
|
|
785
904
|
}
|
|
786
905
|
|
|
@@ -796,6 +915,7 @@ import { useContext as useContext2, useEffect as useEffect3, useRef as useRef3,
|
|
|
796
915
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
797
916
|
function PositionControls() {
|
|
798
917
|
const ctx = useContext2(AccessibilityContext);
|
|
918
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
799
919
|
const [open, setOpen] = useState3(false);
|
|
800
920
|
const select = useRef3(null);
|
|
801
921
|
const opener = useRef3(null);
|
|
@@ -827,7 +947,7 @@ function PositionControls() {
|
|
|
827
947
|
event.currentTarget.focus();
|
|
828
948
|
setOpen(!open);
|
|
829
949
|
},
|
|
830
|
-
children:
|
|
950
|
+
children: strings.moveButton
|
|
831
951
|
}
|
|
832
952
|
),
|
|
833
953
|
/* @__PURE__ */ jsxs3(
|
|
@@ -837,7 +957,7 @@ function PositionControls() {
|
|
|
837
957
|
className: "arap-position-popover",
|
|
838
958
|
hidden: !open,
|
|
839
959
|
role: "group",
|
|
840
|
-
"aria-label":
|
|
960
|
+
"aria-label": strings.moveButtonLabel,
|
|
841
961
|
onKeyDown: (event) => {
|
|
842
962
|
if (event.key === "Escape") {
|
|
843
963
|
event.stopPropagation();
|
|
@@ -850,7 +970,7 @@ function PositionControls() {
|
|
|
850
970
|
{
|
|
851
971
|
className: "arap-position-label",
|
|
852
972
|
htmlFor: `${ctx.panelId}-corner`,
|
|
853
|
-
children:
|
|
973
|
+
children: strings.positionLabel
|
|
854
974
|
}
|
|
855
975
|
),
|
|
856
976
|
/* @__PURE__ */ jsxs3(
|
|
@@ -858,33 +978,33 @@ function PositionControls() {
|
|
|
858
978
|
{
|
|
859
979
|
ref: select,
|
|
860
980
|
id: `${ctx.panelId}-corner`,
|
|
861
|
-
"aria-label":
|
|
981
|
+
"aria-label": strings.buttonPositionSelectLabel,
|
|
862
982
|
value: ctx.widgetPlacement?.kind === "point" ? "custom" : ctx.widgetPlacement?.corner ?? defaultCorner(ctx.position),
|
|
863
983
|
onChange: (event) => ctx.setWidgetPlacement({
|
|
864
984
|
kind: "corner",
|
|
865
985
|
corner: event.target.value
|
|
866
986
|
}),
|
|
867
987
|
children: [
|
|
868
|
-
/* @__PURE__ */ jsx4("option", { value: "custom", disabled: true, children:
|
|
988
|
+
/* @__PURE__ */ jsx4("option", { value: "custom", disabled: true, children: strings.customPosition }),
|
|
869
989
|
corners.map((corner) => /* @__PURE__ */ jsx4("option", { value: corner, children: corner.split("-").join(" ") }, corner))
|
|
870
990
|
]
|
|
871
991
|
}
|
|
872
992
|
),
|
|
873
993
|
/* @__PURE__ */ jsx4("div", { className: "arap-position-arrows", children: [
|
|
874
|
-
["left", -20, 0, "\u2190"],
|
|
875
|
-
["up", 0, -20, "\u2191"],
|
|
876
|
-
["down", 0, 20, "\u2193"],
|
|
877
|
-
["right", 20, 0, "\u2192"]
|
|
878
|
-
].map(([direction, dx, dy, label]) => /* @__PURE__ */ jsx4(
|
|
994
|
+
["left", -20, 0, "\u2190", strings.moveLeft],
|
|
995
|
+
["up", 0, -20, "\u2191", strings.moveUp],
|
|
996
|
+
["down", 0, 20, "\u2193", strings.moveDown],
|
|
997
|
+
["right", 20, 0, "\u2192", strings.moveRight]
|
|
998
|
+
].map(([direction, dx, dy, arrowChar, label]) => /* @__PURE__ */ jsx4(
|
|
879
999
|
"button",
|
|
880
1000
|
{
|
|
881
1001
|
type: "button",
|
|
882
|
-
"aria-label":
|
|
1002
|
+
"aria-label": label,
|
|
883
1003
|
onClick: (event) => {
|
|
884
1004
|
event.currentTarget.focus();
|
|
885
1005
|
move(dx, dy);
|
|
886
1006
|
},
|
|
887
|
-
children:
|
|
1007
|
+
children: arrowChar
|
|
888
1008
|
},
|
|
889
1009
|
direction
|
|
890
1010
|
)) }),
|
|
@@ -897,10 +1017,10 @@ function PositionControls() {
|
|
|
897
1017
|
event.currentTarget.focus();
|
|
898
1018
|
ctx.setWidgetPlacement(null);
|
|
899
1019
|
},
|
|
900
|
-
children:
|
|
1020
|
+
children: strings.resetPosition
|
|
901
1021
|
}
|
|
902
1022
|
),
|
|
903
|
-
/* @__PURE__ */ jsx4("button", { className: "arap-position-default", type: "button", onClick: close, children:
|
|
1023
|
+
/* @__PURE__ */ jsx4("button", { className: "arap-position-default", type: "button", onClick: close, children: strings.doneMoving })
|
|
904
1024
|
]
|
|
905
1025
|
}
|
|
906
1026
|
)
|
|
@@ -914,11 +1034,22 @@ function Panel({
|
|
|
914
1034
|
footer,
|
|
915
1035
|
className = "",
|
|
916
1036
|
style,
|
|
917
|
-
title
|
|
918
|
-
description
|
|
919
|
-
closeLabel
|
|
1037
|
+
title,
|
|
1038
|
+
description,
|
|
1039
|
+
closeLabel,
|
|
1040
|
+
statementUrl,
|
|
1041
|
+
largeControls,
|
|
1042
|
+
locale
|
|
920
1043
|
}) {
|
|
921
1044
|
const ctx = useContext3(AccessibilityContext);
|
|
1045
|
+
const effectiveLocale = locale ?? ctx.locale;
|
|
1046
|
+
const strings = resolveLocaleStrings(effectiveLocale);
|
|
1047
|
+
const panelTitle = title ?? strings.title;
|
|
1048
|
+
const panelDescription = description === void 0 ? strings.description : description;
|
|
1049
|
+
const panelCloseLabel = closeLabel ?? strings.closeLabel;
|
|
1050
|
+
const effectiveStatementUrl = statementUrl ?? ctx.statementUrl;
|
|
1051
|
+
const isLarge = largeControls ?? ctx.largeControls ?? false;
|
|
1052
|
+
const isRtl = isRtlLocale(effectiveLocale);
|
|
922
1053
|
const panel = useRef4(null);
|
|
923
1054
|
const [actions, setActions] = useState4(null);
|
|
924
1055
|
const viewport = useViewport();
|
|
@@ -952,10 +1083,14 @@ function Panel({
|
|
|
952
1083
|
},
|
|
953
1084
|
"data-corner": corner,
|
|
954
1085
|
"data-position": ctx.position,
|
|
1086
|
+
"data-large-controls": isLarge,
|
|
1087
|
+
lang: effectiveLocale ?? "en",
|
|
1088
|
+
dir: isRtl ? "rtl" : "ltr",
|
|
1089
|
+
translate: "no",
|
|
955
1090
|
hidden: !ctx.isOpen,
|
|
956
1091
|
role: "region",
|
|
957
|
-
"aria-label":
|
|
958
|
-
"aria-describedby":
|
|
1092
|
+
"aria-label": panelTitle,
|
|
1093
|
+
"aria-describedby": panelDescription ? `${ctx.panelId}-description` : void 0,
|
|
959
1094
|
tabIndex: -1,
|
|
960
1095
|
onKeyDown: (event) => {
|
|
961
1096
|
if (event.key === "Escape" && !event.defaultPrevented) {
|
|
@@ -966,10 +1101,18 @@ function Panel({
|
|
|
966
1101
|
children: [
|
|
967
1102
|
/* @__PURE__ */ jsxs4("div", { className: "arap-heading", children: [
|
|
968
1103
|
/* @__PURE__ */ jsxs4("div", { className: "arap-heading-copy", children: [
|
|
969
|
-
/* @__PURE__ */ jsx5("h2", { children:
|
|
970
|
-
|
|
1104
|
+
/* @__PURE__ */ jsx5("h2", { children: panelTitle }),
|
|
1105
|
+
panelDescription && /* @__PURE__ */ jsx5("p", { id: `${ctx.panelId}-description`, className: "arap-description", children: panelDescription })
|
|
971
1106
|
] }),
|
|
972
|
-
/* @__PURE__ */ jsx5(
|
|
1107
|
+
/* @__PURE__ */ jsx5(
|
|
1108
|
+
"button",
|
|
1109
|
+
{
|
|
1110
|
+
type: "button",
|
|
1111
|
+
"aria-label": panelCloseLabel,
|
|
1112
|
+
onClick: ctx.closeMenu,
|
|
1113
|
+
children: "\xD7"
|
|
1114
|
+
}
|
|
1115
|
+
)
|
|
973
1116
|
] }),
|
|
974
1117
|
/* @__PURE__ */ jsx5(
|
|
975
1118
|
"button",
|
|
@@ -982,7 +1125,7 @@ function Panel({
|
|
|
982
1125
|
);
|
|
983
1126
|
target?.focus();
|
|
984
1127
|
},
|
|
985
|
-
children:
|
|
1128
|
+
children: strings.skipToActions
|
|
986
1129
|
}
|
|
987
1130
|
),
|
|
988
1131
|
/* @__PURE__ */ jsx5(PanelActionsContext.Provider, { value: actions, children: /* @__PURE__ */ jsx5(
|
|
@@ -991,7 +1134,7 @@ function Panel({
|
|
|
991
1134
|
className: "arap-tools",
|
|
992
1135
|
role: "group",
|
|
993
1136
|
tabIndex: 0,
|
|
994
|
-
"aria-label":
|
|
1137
|
+
"aria-label": strings.toolsLabel,
|
|
995
1138
|
children
|
|
996
1139
|
}
|
|
997
1140
|
) }),
|
|
@@ -1000,13 +1143,30 @@ function Panel({
|
|
|
1000
1143
|
{
|
|
1001
1144
|
className: "arap-quick-actions",
|
|
1002
1145
|
role: "group",
|
|
1003
|
-
"aria-label":
|
|
1146
|
+
"aria-label": strings.quickActionsLabel,
|
|
1004
1147
|
children: [
|
|
1005
1148
|
/* @__PURE__ */ jsx5(PositionControls, {}, ctx.isOpen ? "open" : "closed"),
|
|
1006
1149
|
/* @__PURE__ */ jsx5("div", { className: "arap-actions", ref: setActions, children: footer })
|
|
1007
1150
|
]
|
|
1008
1151
|
}
|
|
1009
|
-
)
|
|
1152
|
+
),
|
|
1153
|
+
effectiveStatementUrl && /* @__PURE__ */ jsx5("div", { className: "arap-statement", children: /* @__PURE__ */ jsxs4(
|
|
1154
|
+
"a",
|
|
1155
|
+
{
|
|
1156
|
+
href: effectiveStatementUrl,
|
|
1157
|
+
className: "arap-statement-link",
|
|
1158
|
+
target: "_blank",
|
|
1159
|
+
rel: "noopener noreferrer",
|
|
1160
|
+
children: [
|
|
1161
|
+
strings.statementLink,
|
|
1162
|
+
/* @__PURE__ */ jsxs4("span", { className: "arap-sr-only", children: [
|
|
1163
|
+
" (",
|
|
1164
|
+
strings.openInNewTab,
|
|
1165
|
+
")"
|
|
1166
|
+
] })
|
|
1167
|
+
]
|
|
1168
|
+
}
|
|
1169
|
+
) })
|
|
1010
1170
|
]
|
|
1011
1171
|
}
|
|
1012
1172
|
);
|
|
@@ -1058,6 +1218,304 @@ function useAccessibility(featureKey, defaultValue, options) {
|
|
|
1058
1218
|
return { value, setValue, reset };
|
|
1059
1219
|
}
|
|
1060
1220
|
|
|
1221
|
+
// src/core/preferences/defaults.ts
|
|
1222
|
+
var DEFAULT_PREFERENCES = Object.freeze({
|
|
1223
|
+
fontScale: 1,
|
|
1224
|
+
lineHeight: null,
|
|
1225
|
+
letterSpacingEm: null,
|
|
1226
|
+
wordSpacingEm: null,
|
|
1227
|
+
paragraphSpacingEm: null,
|
|
1228
|
+
textAlign: "original",
|
|
1229
|
+
contrastMode: "off",
|
|
1230
|
+
highlightLinks: false,
|
|
1231
|
+
highlightFocus: false,
|
|
1232
|
+
reduceMotion: false,
|
|
1233
|
+
hideDecorativeImages: false,
|
|
1234
|
+
fontFamily: "original",
|
|
1235
|
+
cursorSize: "original",
|
|
1236
|
+
readerMode: "off",
|
|
1237
|
+
saturation: "original",
|
|
1238
|
+
tooltips: false
|
|
1239
|
+
});
|
|
1240
|
+
var PROFILE_DEFINITIONS = {
|
|
1241
|
+
motor: {
|
|
1242
|
+
id: "motor",
|
|
1243
|
+
label: "Motor Impaired",
|
|
1244
|
+
description: "Enhanced focus rings, richer tooltips, and reduced motion.",
|
|
1245
|
+
settings: {
|
|
1246
|
+
reduceMotion: true,
|
|
1247
|
+
highlightFocus: true,
|
|
1248
|
+
tooltips: true
|
|
1249
|
+
}
|
|
1250
|
+
},
|
|
1251
|
+
blind: {
|
|
1252
|
+
id: "blind",
|
|
1253
|
+
label: "Blind & Screen Reader",
|
|
1254
|
+
description: "Semantic assistance and accessible authored descriptions.",
|
|
1255
|
+
settings: {
|
|
1256
|
+
tooltips: true
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1259
|
+
"color-blind": {
|
|
1260
|
+
id: "color-blind",
|
|
1261
|
+
label: "Color Blind",
|
|
1262
|
+
description: "High contrast accents and non-color-only link indicators.",
|
|
1263
|
+
settings: {
|
|
1264
|
+
contrastMode: "high",
|
|
1265
|
+
highlightLinks: true
|
|
1266
|
+
}
|
|
1267
|
+
},
|
|
1268
|
+
dyslexia: {
|
|
1269
|
+
id: "dyslexia",
|
|
1270
|
+
label: "Dyslexia Friendly",
|
|
1271
|
+
description: "Legible typeface, reading guide line, and reduced motion.",
|
|
1272
|
+
settings: {
|
|
1273
|
+
fontFamily: "dyslexia-option",
|
|
1274
|
+
readerMode: "guide",
|
|
1275
|
+
reduceMotion: true
|
|
1276
|
+
}
|
|
1277
|
+
},
|
|
1278
|
+
"low-vision": {
|
|
1279
|
+
id: "low-vision",
|
|
1280
|
+
label: "Low Vision",
|
|
1281
|
+
description: "Enlarged text, large cursor pointer, and high-visibility focus.",
|
|
1282
|
+
settings: {
|
|
1283
|
+
fontScale: 1.25,
|
|
1284
|
+
cursorSize: "large",
|
|
1285
|
+
highlightFocus: true,
|
|
1286
|
+
tooltips: true
|
|
1287
|
+
}
|
|
1288
|
+
},
|
|
1289
|
+
cognitive: {
|
|
1290
|
+
id: "cognitive",
|
|
1291
|
+
label: "Cognitive & Learning",
|
|
1292
|
+
description: "Mild text scaling, reading guide line, and distraction reduction.",
|
|
1293
|
+
settings: {
|
|
1294
|
+
fontScale: 1.125,
|
|
1295
|
+
readerMode: "guide",
|
|
1296
|
+
reduceMotion: true,
|
|
1297
|
+
tooltips: true
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1300
|
+
seizure: {
|
|
1301
|
+
id: "seizure",
|
|
1302
|
+
label: "Seizure & Epileptic",
|
|
1303
|
+
description: "Pauses nonessential motion and reduces transition flashes.",
|
|
1304
|
+
settings: {
|
|
1305
|
+
reduceMotion: true
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
adhd: {
|
|
1309
|
+
id: "adhd",
|
|
1310
|
+
label: "ADHD / Focus",
|
|
1311
|
+
description: "Reading mask spotlight and reduced animation distraction.",
|
|
1312
|
+
settings: {
|
|
1313
|
+
readerMode: "mask",
|
|
1314
|
+
reduceMotion: true
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
// src/core/preferences/registry.ts
|
|
1320
|
+
var VALID_CONTRAST_MODES = /* @__PURE__ */ new Set([
|
|
1321
|
+
"off",
|
|
1322
|
+
"light",
|
|
1323
|
+
"dark",
|
|
1324
|
+
"high",
|
|
1325
|
+
"invert"
|
|
1326
|
+
]);
|
|
1327
|
+
var VALID_READER_MODES = /* @__PURE__ */ new Set([
|
|
1328
|
+
"off",
|
|
1329
|
+
"guide",
|
|
1330
|
+
"mask"
|
|
1331
|
+
]);
|
|
1332
|
+
var VALID_TEXT_ALIGNS = /* @__PURE__ */ new Set([
|
|
1333
|
+
"original",
|
|
1334
|
+
"left",
|
|
1335
|
+
"right",
|
|
1336
|
+
"center",
|
|
1337
|
+
"justify"
|
|
1338
|
+
]);
|
|
1339
|
+
var VALID_FONT_FAMILIES = /* @__PURE__ */ new Set([
|
|
1340
|
+
"original",
|
|
1341
|
+
"legible",
|
|
1342
|
+
"dyslexia-option"
|
|
1343
|
+
]);
|
|
1344
|
+
var VALID_CURSOR_SIZES = /* @__PURE__ */ new Set([
|
|
1345
|
+
"original",
|
|
1346
|
+
"large"
|
|
1347
|
+
]);
|
|
1348
|
+
var VALID_SATURATIONS = /* @__PURE__ */ new Set([
|
|
1349
|
+
"original",
|
|
1350
|
+
"low",
|
|
1351
|
+
"high",
|
|
1352
|
+
"grayscale"
|
|
1353
|
+
]);
|
|
1354
|
+
function clamp(value, min, max) {
|
|
1355
|
+
if (Number.isNaN(value) || !Number.isFinite(value)) return min;
|
|
1356
|
+
return Math.min(Math.max(value, min), max);
|
|
1357
|
+
}
|
|
1358
|
+
function normalizePreferenceValue(key, value) {
|
|
1359
|
+
switch (key) {
|
|
1360
|
+
case "fontScale":
|
|
1361
|
+
return typeof value === "number" ? clamp(value, 0.5, 2) : 1;
|
|
1362
|
+
case "lineHeight":
|
|
1363
|
+
if (value === null || value === void 0)
|
|
1364
|
+
return null;
|
|
1365
|
+
return typeof value === "number" ? clamp(value, 0.5, 2) : null;
|
|
1366
|
+
case "letterSpacingEm":
|
|
1367
|
+
if (value === null || value === void 0)
|
|
1368
|
+
return null;
|
|
1369
|
+
return typeof value === "number" ? clamp(value, 0, 0.5) : null;
|
|
1370
|
+
case "wordSpacingEm":
|
|
1371
|
+
if (value === null || value === void 0)
|
|
1372
|
+
return null;
|
|
1373
|
+
return typeof value === "number" ? clamp(value, 0, 0.5) : null;
|
|
1374
|
+
case "paragraphSpacingEm":
|
|
1375
|
+
if (value === null || value === void 0)
|
|
1376
|
+
return null;
|
|
1377
|
+
return typeof value === "number" ? clamp(value, 0, 1) : null;
|
|
1378
|
+
case "textAlign":
|
|
1379
|
+
return typeof value === "string" && VALID_TEXT_ALIGNS.has(value) ? value : "original";
|
|
1380
|
+
case "contrastMode":
|
|
1381
|
+
return typeof value === "string" && VALID_CONTRAST_MODES.has(value) ? value : "off";
|
|
1382
|
+
case "fontFamily":
|
|
1383
|
+
return typeof value === "string" && VALID_FONT_FAMILIES.has(value) ? value : "original";
|
|
1384
|
+
case "cursorSize":
|
|
1385
|
+
return typeof value === "string" && VALID_CURSOR_SIZES.has(value) ? value : "original";
|
|
1386
|
+
case "readerMode":
|
|
1387
|
+
return typeof value === "string" && VALID_READER_MODES.has(value) ? value : "off";
|
|
1388
|
+
case "saturation":
|
|
1389
|
+
return typeof value === "string" && VALID_SATURATIONS.has(value) ? value : "original";
|
|
1390
|
+
case "highlightLinks":
|
|
1391
|
+
case "highlightFocus":
|
|
1392
|
+
case "reduceMotion":
|
|
1393
|
+
case "hideDecorativeImages":
|
|
1394
|
+
case "tooltips":
|
|
1395
|
+
return Boolean(value);
|
|
1396
|
+
default:
|
|
1397
|
+
return value;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
function normalizePreferences(input) {
|
|
1401
|
+
const result = { ...DEFAULT_PREFERENCES };
|
|
1402
|
+
if (!input || typeof input !== "object") return result;
|
|
1403
|
+
for (const k of Object.keys(DEFAULT_PREFERENCES)) {
|
|
1404
|
+
if (k in input && input[k] !== void 0) {
|
|
1405
|
+
result[k] = normalizePreferenceValue(k, input[k]);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
return result;
|
|
1409
|
+
}
|
|
1410
|
+
function resolveEffectivePreferences(base, profileSnapshot, overrides) {
|
|
1411
|
+
const merged = {
|
|
1412
|
+
...DEFAULT_PREFERENCES,
|
|
1413
|
+
...base,
|
|
1414
|
+
...profileSnapshot ?? {},
|
|
1415
|
+
...overrides
|
|
1416
|
+
};
|
|
1417
|
+
return normalizePreferences(merged);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
// src/core/preferences/reducer.ts
|
|
1421
|
+
function createInitialPreferencesState(initial) {
|
|
1422
|
+
const base = normalizePreferences(initial);
|
|
1423
|
+
return {
|
|
1424
|
+
base,
|
|
1425
|
+
activeProfileId: null,
|
|
1426
|
+
profileSnapshot: null,
|
|
1427
|
+
overrides: {},
|
|
1428
|
+
effective: { ...base }
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
function preferencesReducer(state, action) {
|
|
1432
|
+
switch (action.type) {
|
|
1433
|
+
case "SET_PREFERENCE": {
|
|
1434
|
+
const normalizedValue = normalizePreferenceValue(
|
|
1435
|
+
action.key,
|
|
1436
|
+
action.value
|
|
1437
|
+
);
|
|
1438
|
+
if (state.activeProfileId) {
|
|
1439
|
+
const nextOverrides = {
|
|
1440
|
+
...state.overrides,
|
|
1441
|
+
[action.key]: normalizedValue
|
|
1442
|
+
};
|
|
1443
|
+
return {
|
|
1444
|
+
...state,
|
|
1445
|
+
overrides: nextOverrides,
|
|
1446
|
+
effective: resolveEffectivePreferences(
|
|
1447
|
+
state.base,
|
|
1448
|
+
state.profileSnapshot,
|
|
1449
|
+
nextOverrides
|
|
1450
|
+
)
|
|
1451
|
+
};
|
|
1452
|
+
}
|
|
1453
|
+
const nextBase = {
|
|
1454
|
+
...state.base,
|
|
1455
|
+
[action.key]: normalizedValue
|
|
1456
|
+
};
|
|
1457
|
+
return {
|
|
1458
|
+
...state,
|
|
1459
|
+
base: nextBase,
|
|
1460
|
+
effective: resolveEffectivePreferences(nextBase, null, state.overrides)
|
|
1461
|
+
};
|
|
1462
|
+
}
|
|
1463
|
+
case "APPLY_PROFILE": {
|
|
1464
|
+
const profile = PROFILE_DEFINITIONS[action.profileId];
|
|
1465
|
+
const settings = action.settings || profile?.settings || {};
|
|
1466
|
+
const profileSnapshot = { ...settings };
|
|
1467
|
+
const nextOverrides = {};
|
|
1468
|
+
return {
|
|
1469
|
+
...state,
|
|
1470
|
+
activeProfileId: action.profileId,
|
|
1471
|
+
profileSnapshot,
|
|
1472
|
+
overrides: nextOverrides,
|
|
1473
|
+
effective: resolveEffectivePreferences(
|
|
1474
|
+
state.base,
|
|
1475
|
+
profileSnapshot,
|
|
1476
|
+
nextOverrides
|
|
1477
|
+
)
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
case "CLEAR_PROFILE": {
|
|
1481
|
+
const nextBase = {
|
|
1482
|
+
...state.base,
|
|
1483
|
+
...state.overrides
|
|
1484
|
+
};
|
|
1485
|
+
return {
|
|
1486
|
+
...state,
|
|
1487
|
+
activeProfileId: null,
|
|
1488
|
+
profileSnapshot: null,
|
|
1489
|
+
overrides: {},
|
|
1490
|
+
effective: normalizePreferences(nextBase),
|
|
1491
|
+
base: nextBase
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
case "RESET_ALL": {
|
|
1495
|
+
const cleanBase = { ...DEFAULT_PREFERENCES };
|
|
1496
|
+
return {
|
|
1497
|
+
base: cleanBase,
|
|
1498
|
+
activeProfileId: null,
|
|
1499
|
+
profileSnapshot: null,
|
|
1500
|
+
overrides: {},
|
|
1501
|
+
effective: cleanBase
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
case "IMPORT_PREFERENCES": {
|
|
1505
|
+
const cleanBase = normalizePreferences(action.preferences);
|
|
1506
|
+
return {
|
|
1507
|
+
base: cleanBase,
|
|
1508
|
+
activeProfileId: null,
|
|
1509
|
+
profileSnapshot: null,
|
|
1510
|
+
overrides: {},
|
|
1511
|
+
effective: cleanBase
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
default:
|
|
1515
|
+
return state;
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1061
1519
|
// src/core/FeatureIcon.tsx
|
|
1062
1520
|
import { Fragment, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1063
1521
|
var drawings = {
|
|
@@ -1651,9 +2109,10 @@ function ResetController() {
|
|
|
1651
2109
|
}
|
|
1652
2110
|
const actionHost = useContext5(PanelActionsContext);
|
|
1653
2111
|
const { resetAll } = ctx;
|
|
2112
|
+
const strings = resolveLocaleStrings(ctx.locale);
|
|
1654
2113
|
const button = /* @__PURE__ */ jsx21("div", { className: "arap-feature arap-feature-reset", children: /* @__PURE__ */ jsxs20("button", { className: "arap-reset-btn", onClick: resetAll, type: "button", children: [
|
|
1655
2114
|
/* @__PURE__ */ jsx21(FeatureIcon, { name: "reset" }),
|
|
1656
|
-
|
|
2115
|
+
strings.resetAll
|
|
1657
2116
|
] }) });
|
|
1658
2117
|
return actionHost ? createPortal2(button, actionHost) : button;
|
|
1659
2118
|
}
|
|
@@ -1664,6 +2123,7 @@ export {
|
|
|
1664
2123
|
AccessibilityPlugin,
|
|
1665
2124
|
BigCursorController,
|
|
1666
2125
|
ContrastController,
|
|
2126
|
+
DEFAULT_PREFERENCES,
|
|
1667
2127
|
FontSizeController,
|
|
1668
2128
|
GrayscaleController,
|
|
1669
2129
|
HideImagesController,
|
|
@@ -1672,11 +2132,21 @@ export {
|
|
|
1672
2132
|
LetterSpacingController,
|
|
1673
2133
|
LineHeightController,
|
|
1674
2134
|
LinkHighlightController,
|
|
2135
|
+
PROFILE_DEFINITIONS,
|
|
1675
2136
|
ReadingGuideController,
|
|
1676
2137
|
ReadingMaskController,
|
|
1677
2138
|
ResetController,
|
|
1678
2139
|
SaturationController,
|
|
1679
2140
|
TextAlignController,
|
|
2141
|
+
createInitialPreferencesState,
|
|
2142
|
+
enLocale,
|
|
2143
|
+
isRtlLocale,
|
|
2144
|
+
normalizePreferenceValue,
|
|
2145
|
+
normalizePreferences,
|
|
2146
|
+
preferencesReducer,
|
|
2147
|
+
registerLocale,
|
|
2148
|
+
resolveEffectivePreferences,
|
|
2149
|
+
resolveLocaleStrings,
|
|
1680
2150
|
useAccessibility
|
|
1681
2151
|
};
|
|
1682
2152
|
//# sourceMappingURL=index.mjs.map
|