UNPKG

react-native-a11y

Version:

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

32 lines (31 loc) 977 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useFocusStyle = void 0; var _react = require("react"); var _reactNative = require("react-native"); const useFocusStyle = (focusStyle, onFocusChange) => { const [focused, setFocusStatus] = (0, _react.useState)(false); const onFocusChangeHandler = event => { setFocusStatus(event.nativeEvent.isFocused); onFocusChange === null || onFocusChange === void 0 ? void 0 : onFocusChange(event); }; const fStyle = (0, _react.useMemo)(() => { if (!focusStyle) return focused ? styles.defaultHighlight : undefined; return typeof focusStyle === "function" ? focusStyle({ focused }) : focusStyle; }, [focused, focusStyle]); return { onFocusChangeHandler, fStyle }; }; exports.useFocusStyle = useFocusStyle; const styles = _reactNative.StyleSheet.create({ defaultHighlight: { backgroundColor: "#9999" } }); //# sourceMappingURL=useFocusStyle.js.map