ngp-accessibility 1.0.6 → 1.0.7
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 +1 -15
- package/dist/AccessibilityContext.d.ts +0 -2
- package/dist/AccessibilityToolbar.d.ts +0 -1
- package/dist/index.esm.js +5 -63
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -63
- package/dist/index.js.map +1 -1
- package/dist/translations.d.ts +0 -3
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NGP Accessibility
|
|
2
2
|
|
|
3
|
-
React accessibility package with translation, text sizing, contrast modes, and
|
|
3
|
+
React accessibility package with translation, text sizing, contrast modes, and more.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -12,7 +12,6 @@ React accessibility package with translation, text sizing, contrast modes, and v
|
|
|
12
12
|
- 💡 Light background mode
|
|
13
13
|
- 🔗 Links underline toggle
|
|
14
14
|
- 📖 Readable font mode
|
|
15
|
-
- 🎤 Voice command support
|
|
16
15
|
- ✅ TypeScript & JavaScript compatible
|
|
17
16
|
- 📦 Zero dependencies (peer: React)
|
|
18
17
|
|
|
@@ -65,18 +64,6 @@ function App() {
|
|
|
65
64
|
}
|
|
66
65
|
```
|
|
67
66
|
|
|
68
|
-
## Voice Commands
|
|
69
|
-
|
|
70
|
-
When voice command is enabled, you can use:
|
|
71
|
-
|
|
72
|
-
- "increase text" / "palakihin"
|
|
73
|
-
- "decrease text" / "paliitin"
|
|
74
|
-
- "high contrast" / "mataas"
|
|
75
|
-
- "negative contrast" / "negatibo"
|
|
76
|
-
- "light background" / "maliwanag"
|
|
77
|
-
- "underline" / "guhit"
|
|
78
|
-
- "readable font" / "madaling"
|
|
79
|
-
|
|
80
67
|
## API
|
|
81
68
|
|
|
82
69
|
### AccessibilityProvider
|
|
@@ -185,7 +172,6 @@ Hook that returns:
|
|
|
185
172
|
- `lightBackground`, `toggleLightBackground()`
|
|
186
173
|
- `underlineLinks`, `toggleUnderlineLinks()`
|
|
187
174
|
- `readableFont`, `toggleReadableFont()`
|
|
188
|
-
- `voiceEnabled`, `toggleVoice()`
|
|
189
175
|
- `translate(key)` - Get translated package UI text with English fallback
|
|
190
176
|
- `t(key)` - Get your app-specific manual text for the current language, then fall back to English, then the raw key
|
|
191
177
|
|
|
@@ -13,7 +13,6 @@ interface AccessibilityState {
|
|
|
13
13
|
underlineLinks: boolean;
|
|
14
14
|
highlightTitles: boolean;
|
|
15
15
|
readableFont: boolean;
|
|
16
|
-
voiceEnabled: boolean;
|
|
17
16
|
readAloud: boolean;
|
|
18
17
|
colorBlindMode: ColorBlindMode;
|
|
19
18
|
focusIndicator: boolean;
|
|
@@ -31,7 +30,6 @@ interface AccessibilityContextType extends AccessibilityState {
|
|
|
31
30
|
toggleUnderlineLinks: () => void;
|
|
32
31
|
toggleHighlightTitles: () => void;
|
|
33
32
|
toggleReadableFont: () => void;
|
|
34
|
-
toggleVoice: () => void;
|
|
35
33
|
toggleReadAloud: () => void;
|
|
36
34
|
setColorBlindMode: (mode: ColorBlindMode) => void;
|
|
37
35
|
toggleFocusIndicator: () => void;
|
package/dist/index.esm.js
CHANGED
|
@@ -14,7 +14,6 @@ const translations = {
|
|
|
14
14
|
readableFont: "Readable Font",
|
|
15
15
|
pauseAnimations: "Pause Animations",
|
|
16
16
|
readingGuide: "Reading Guide",
|
|
17
|
-
voiceCommand: "Voice Command",
|
|
18
17
|
readAloud: "Read Aloud",
|
|
19
18
|
colorBlindMode: "Color Blind Mode",
|
|
20
19
|
focusIndicator: "Focus Indicator",
|
|
@@ -32,7 +31,6 @@ const translations = {
|
|
|
32
31
|
readableFont: "Madaling Basahin na Font",
|
|
33
32
|
pauseAnimations: "I-pause ang mga Animation",
|
|
34
33
|
readingGuide: "Reading Guide",
|
|
35
|
-
voiceCommand: "Voice Command",
|
|
36
34
|
readAloud: "Basahin nang Malakas",
|
|
37
35
|
colorBlindMode: "Color Blind Mode",
|
|
38
36
|
focusIndicator: "Focus Indicator",
|
|
@@ -50,7 +48,6 @@ const translations = {
|
|
|
50
48
|
readableFont: "Sayon Basahon nga Font",
|
|
51
49
|
pauseAnimations: "Ihunong ang mga Animation",
|
|
52
50
|
readingGuide: "Reading Guide",
|
|
53
|
-
voiceCommand: "Voice Command",
|
|
54
51
|
readAloud: "Basaha og Kusog",
|
|
55
52
|
colorBlindMode: "Color Blind Mode",
|
|
56
53
|
focusIndicator: "Focus Indicator",
|
|
@@ -117,7 +114,6 @@ const AccessibilityProvider = ({ children, translations: customTranslations, goo
|
|
|
117
114
|
underlineLinks: false,
|
|
118
115
|
highlightTitles: false,
|
|
119
116
|
readableFont: false,
|
|
120
|
-
voiceEnabled: false,
|
|
121
117
|
readAloud: false,
|
|
122
118
|
colorBlindMode: "none",
|
|
123
119
|
focusIndicator: false,
|
|
@@ -438,54 +434,6 @@ const AccessibilityProvider = ({ children, translations: customTranslations, goo
|
|
|
438
434
|
tooltip.remove();
|
|
439
435
|
};
|
|
440
436
|
}, [state.textMagnifier]);
|
|
441
|
-
useEffect(() => {
|
|
442
|
-
if (!state.voiceEnabled ||
|
|
443
|
-
!("webkitSpeechRecognition" in window || "SpeechRecognition" in window))
|
|
444
|
-
return;
|
|
445
|
-
const SpeechRecognition = window.SpeechRecognition ||
|
|
446
|
-
window.webkitSpeechRecognition;
|
|
447
|
-
const recognition = new SpeechRecognition();
|
|
448
|
-
recognition.continuous = true;
|
|
449
|
-
recognition.lang =
|
|
450
|
-
state.language === "tl"
|
|
451
|
-
? "tl-PH"
|
|
452
|
-
: state.language === "ceb"
|
|
453
|
-
? "ceb-PH"
|
|
454
|
-
: "en-US";
|
|
455
|
-
recognition.onresult = (event) => {
|
|
456
|
-
const transcript = event.results[event.results.length - 1][0].transcript.toLowerCase();
|
|
457
|
-
if (transcript.includes("increase text") ||
|
|
458
|
-
transcript.includes("palakihin"))
|
|
459
|
-
increaseText();
|
|
460
|
-
if (transcript.includes("decrease text") ||
|
|
461
|
-
transcript.includes("paliitin"))
|
|
462
|
-
decreaseText();
|
|
463
|
-
if (transcript.includes("high contrast") || transcript.includes("mataas"))
|
|
464
|
-
toggleHighContrast();
|
|
465
|
-
if (transcript.includes("negative contrast") ||
|
|
466
|
-
transcript.includes("negatibo"))
|
|
467
|
-
toggleNegativeContrast();
|
|
468
|
-
if (transcript.includes("light background") ||
|
|
469
|
-
transcript.includes("maliwanag"))
|
|
470
|
-
toggleLightBackground();
|
|
471
|
-
if (transcript.includes("underline") || transcript.includes("guhit"))
|
|
472
|
-
toggleUnderlineLinks();
|
|
473
|
-
if (transcript.includes("highlight titles") ||
|
|
474
|
-
transcript.includes("title highlight"))
|
|
475
|
-
toggleHighlightTitles();
|
|
476
|
-
if (transcript.includes("pause animations") ||
|
|
477
|
-
transcript.includes("stop animations"))
|
|
478
|
-
togglePauseAnimations();
|
|
479
|
-
if (transcript.includes("reading guide") ||
|
|
480
|
-
transcript.includes("reading line"))
|
|
481
|
-
toggleReadingGuide();
|
|
482
|
-
if (transcript.includes("readable font") ||
|
|
483
|
-
transcript.includes("madaling"))
|
|
484
|
-
toggleReadableFont();
|
|
485
|
-
};
|
|
486
|
-
recognition.start();
|
|
487
|
-
return () => recognition.stop();
|
|
488
|
-
}, [state.voiceEnabled, state.language]);
|
|
489
437
|
const setLanguage = (lang) => setState((s) => (Object.assign(Object.assign({}, s), { language: lang })));
|
|
490
438
|
const increaseText = () => setState((s) => (Object.assign(Object.assign({}, s), { textSize: Math.min(s.textSize + 10, 200) })));
|
|
491
439
|
const decreaseText = () => setState((s) => (Object.assign(Object.assign({}, s), { textSize: Math.max(s.textSize - 10, 80) })));
|
|
@@ -498,7 +446,6 @@ const AccessibilityProvider = ({ children, translations: customTranslations, goo
|
|
|
498
446
|
const toggleUnderlineLinks = () => setState((s) => (Object.assign(Object.assign({}, s), { underlineLinks: !s.underlineLinks })));
|
|
499
447
|
const toggleHighlightTitles = () => setState((s) => (Object.assign(Object.assign({}, s), { highlightTitles: !s.highlightTitles })));
|
|
500
448
|
const toggleReadableFont = () => setState((s) => (Object.assign(Object.assign({}, s), { readableFont: !s.readableFont })));
|
|
501
|
-
const toggleVoice = () => setState((s) => (Object.assign(Object.assign({}, s), { voiceEnabled: !s.voiceEnabled })));
|
|
502
449
|
const toggleReadAloud = () => setState((s) => (Object.assign(Object.assign({}, s), { readAloud: !s.readAloud })));
|
|
503
450
|
const setColorBlindMode = (mode) => setState((s) => (Object.assign(Object.assign({}, s), { colorBlindMode: mode })));
|
|
504
451
|
const toggleFocusIndicator = () => setState((s) => (Object.assign(Object.assign({}, s), { focusIndicator: !s.focusIndicator })));
|
|
@@ -586,7 +533,6 @@ const AccessibilityProvider = ({ children, translations: customTranslations, goo
|
|
|
586
533
|
toggleUnderlineLinks,
|
|
587
534
|
toggleHighlightTitles,
|
|
588
535
|
toggleReadableFont,
|
|
589
|
-
toggleVoice,
|
|
590
536
|
toggleReadAloud,
|
|
591
537
|
setColorBlindMode,
|
|
592
538
|
toggleFocusIndicator,
|
|
@@ -603,9 +549,9 @@ const useAccessibility = () => {
|
|
|
603
549
|
|
|
604
550
|
const cn$1 = (...parts) => parts.filter(Boolean).join(" ");
|
|
605
551
|
const AccessibilityToolbar = ({ className, style, classes, }) => {
|
|
606
|
-
const { language, setLanguage, increaseText, decreaseText, toggleTextMagnifier, togglePauseAnimations, toggleReadingGuide, toggleHighContrast, toggleNegativeContrast, toggleLightBackground, toggleUnderlineLinks, toggleHighlightTitles, toggleReadableFont,
|
|
552
|
+
const { language, setLanguage, increaseText, decreaseText, toggleTextMagnifier, togglePauseAnimations, toggleReadingGuide, toggleHighContrast, toggleNegativeContrast, toggleLightBackground, toggleUnderlineLinks, toggleHighlightTitles, toggleReadableFont, toggleReadAloud, setColorBlindMode, toggleFocusIndicator, translate, textMagnifier, pauseAnimations, readingGuide, highContrast, negativeContrast, lightBackground, underlineLinks, highlightTitles, readableFont, readAloud, colorBlindMode, focusIndicator, } = useAccessibility();
|
|
607
553
|
return (React.createElement("div", { className: cn$1("accessibility-toolbar notranslate", classes === null || classes === void 0 ? void 0 : classes.root, className), style: style, translate: "no" },
|
|
608
|
-
React.createElement("select", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.select), value: language, onChange: (e) => setLanguage(e.target.value) },
|
|
554
|
+
React.createElement("select", { className: cn$1("notranslate", classes === null || classes === void 0 ? void 0 : classes.select), value: language, onChange: (e) => setLanguage(e.target.value), translate: "no" },
|
|
609
555
|
React.createElement("option", { value: "en" }, "English"),
|
|
610
556
|
React.createElement("option", { value: "tl" }, "Tagalog"),
|
|
611
557
|
React.createElement("option", { value: "ceb" }, "Cebuano")),
|
|
@@ -624,9 +570,6 @@ const AccessibilityToolbar = ({ className, style, classes, }) => {
|
|
|
624
570
|
React.createElement("button", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.button, readableFont && "active", readableFont && (classes === null || classes === void 0 ? void 0 : classes.activeButton)), "data-active": readableFont, onClick: toggleReadableFont }, translate("readableFont")),
|
|
625
571
|
React.createElement("button", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.button, pauseAnimations && "active", pauseAnimations && (classes === null || classes === void 0 ? void 0 : classes.activeButton)), "data-active": pauseAnimations, onClick: togglePauseAnimations }, translate("pauseAnimations")),
|
|
626
572
|
React.createElement("button", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.button, readingGuide && "active", readingGuide && (classes === null || classes === void 0 ? void 0 : classes.activeButton)), "data-active": readingGuide, onClick: toggleReadingGuide }, translate("readingGuide")),
|
|
627
|
-
React.createElement("button", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.button, classes === null || classes === void 0 ? void 0 : classes.voiceButton, voiceEnabled && "active", voiceEnabled && (classes === null || classes === void 0 ? void 0 : classes.activeButton)), "data-active": voiceEnabled, onClick: toggleVoice },
|
|
628
|
-
"\uD83C\uDFA4 ",
|
|
629
|
-
translate("voiceCommand")),
|
|
630
573
|
React.createElement("button", { className: cn$1(classes === null || classes === void 0 ? void 0 : classes.button, readAloud && "active", readAloud && (classes === null || classes === void 0 ? void 0 : classes.activeButton)), "data-active": readAloud, onClick: toggleReadAloud },
|
|
631
574
|
"\uD83D\uDD0A ",
|
|
632
575
|
translate("readAloud")),
|
|
@@ -641,7 +584,7 @@ const AccessibilityToolbar = ({ className, style, classes, }) => {
|
|
|
641
584
|
const cn = (...parts) => parts.filter(Boolean).join(" ");
|
|
642
585
|
const AccessibilityDropdown = ({ className, style, classes, triggerLabel = "♿ Accessibility", renderTrigger, }) => {
|
|
643
586
|
const [isOpen, setIsOpen] = useState(false);
|
|
644
|
-
const { language, setLanguage, textSize, increaseText, decreaseText, toggleTextMagnifier, togglePauseAnimations, toggleReadingGuide, toggleHighContrast, toggleNegativeContrast, toggleLightBackground, toggleUnderlineLinks, toggleHighlightTitles, toggleReadableFont,
|
|
587
|
+
const { language, setLanguage, textSize, increaseText, decreaseText, toggleTextMagnifier, togglePauseAnimations, toggleReadingGuide, toggleHighContrast, toggleNegativeContrast, toggleLightBackground, toggleUnderlineLinks, toggleHighlightTitles, toggleReadableFont, translate, textMagnifier, pauseAnimations, readingGuide, highContrast, negativeContrast, lightBackground, underlineLinks, highlightTitles, readableFont, } = useAccessibility();
|
|
645
588
|
const toggle = () => setIsOpen(!isOpen);
|
|
646
589
|
const closePanel = () => setIsOpen(false);
|
|
647
590
|
const textScaleDelta = textSize - 100;
|
|
@@ -662,7 +605,7 @@ const AccessibilityDropdown = ({ className, style, classes, triggerLabel = "♿
|
|
|
662
605
|
React.createElement("button", { type: "button", className: cn("a11y-panel-close", classes === null || classes === void 0 ? void 0 : classes.closeButton), onClick: closePanel, "aria-label": "Close accessibility panel" }, "\u00D7")),
|
|
663
606
|
React.createElement("div", { className: cn("a11y-language", classes === null || classes === void 0 ? void 0 : classes.section) },
|
|
664
607
|
React.createElement("label", { htmlFor: "a11y-language-select", className: cn("a11y-language-label", classes === null || classes === void 0 ? void 0 : classes.title) }, translate("language")),
|
|
665
|
-
React.createElement("select", { id: "a11y-language-select", value: language, onChange: (e) => setLanguage(e.target.value) },
|
|
608
|
+
React.createElement("select", { id: "a11y-language-select", className: "notranslate", value: language, onChange: (e) => setLanguage(e.target.value), translate: "no" },
|
|
666
609
|
React.createElement("option", { value: "en" }, "English"),
|
|
667
610
|
React.createElement("option", { value: "tl" }, "Tagalog"),
|
|
668
611
|
React.createElement("option", { value: "ceb" }, "Cebuano"),
|
|
@@ -695,8 +638,7 @@ const AccessibilityDropdown = ({ className, style, classes, triggerLabel = "♿
|
|
|
695
638
|
React.createElement("h3", { className: cn("a11y-section-title", classes === null || classes === void 0 ? void 0 : classes.title) }, "Accessibility Tools"),
|
|
696
639
|
React.createElement("div", { className: cn("a11y-grid", classes === null || classes === void 0 ? void 0 : classes.section) },
|
|
697
640
|
React.createElement("button", { className: cn("a11y-card", pauseAnimations && "active", classes === null || classes === void 0 ? void 0 : classes.button), onClick: togglePauseAnimations }, translate("pauseAnimations")),
|
|
698
|
-
React.createElement("button", { className: cn("a11y-card", readingGuide && "active", classes === null || classes === void 0 ? void 0 : classes.button), onClick: toggleReadingGuide }, translate("readingGuide"))
|
|
699
|
-
React.createElement("button", { className: cn("a11y-card", voiceEnabled && "active", classes === null || classes === void 0 ? void 0 : classes.button), onClick: toggleVoice }, translate("voiceCommand"))))))));
|
|
641
|
+
React.createElement("button", { className: cn("a11y-card", readingGuide && "active", classes === null || classes === void 0 ? void 0 : classes.button), onClick: toggleReadingGuide }, translate("readingGuide"))))))));
|
|
700
642
|
};
|
|
701
643
|
|
|
702
644
|
const T = ({ k, children }) => {
|