UNPKG

react-native-a11y

Version:

Improvements of a11y for ReactNative, this library improve work with reader and keyboard focus and reader in general.

48 lines 2.39 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import { AccessibilityInfo, findNodeHandle, InteractionManager, NativeEventEmitter } from "react-native"; import { noop } from "../../utils"; import { KEYBOARD_STATUS_EVENT } from "./A11yModule.conts"; import * as RCA11yModule from "./RCA11yModule"; class A11yAndroidImpl { constructor() { _defineProperty(this, "isKeyboardConnected", RCA11yModule.isKeyboardConnected); _defineProperty(this, "keyboardStatusListener", callback => { const eventEmitter = new NativeEventEmitter(); const eventListener = eventEmitter.addListener(KEYBOARD_STATUS_EVENT, callback); return () => eventListener.remove(); }); _defineProperty(this, "focusFirstInteractiveElement", this.setA11yFocus); _defineProperty(this, "setPreferredKeyboardFocus", noop); _defineProperty(this, "setA11yElementsOrder", ({ views }) => { var _RCA11yModule$setA11y; const tags = views.map(view => findNodeHandle(view)).filter(view => Boolean(view)); (_RCA11yModule$setA11y = RCA11yModule.setA11yOrder) === null || _RCA11yModule$setA11y === void 0 || _RCA11yModule$setA11y.call(RCA11yModule, tags, 0); }); } announceForAccessibility(announcement) { AccessibilityInfo.announceForAccessibility(announcement); } setKeyboardFocus(ref) { const tag = findNodeHandle(ref.current); if (tag) { InteractionManager.runAfterInteractions(() => { RCA11yModule.setKeyboardFocus(tag); }); } } announceScreenChange(announcement) { RCA11yModule.announceScreenChange(announcement); } setA11yFocus(ref) { const tag = findNodeHandle(ref.current); if (tag) { AccessibilityInfo.setAccessibilityFocus(tag); } } } export const A11yModule = new A11yAndroidImpl(); //# sourceMappingURL=A11yModule.android.js.map