react-native-tvfocus
Version:
React Native tvOS and Android TV library to improve focus management with multiple screens.
25 lines (24 loc) • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Button = exports.TouchableWithoutFeedback = exports.TouchableNativeFeedback = exports.TouchableOpacity = exports.TouchableHighlight = exports.Pressable = exports.withFocusable = void 0;
const React = require("react");
const ReactNative = require("react-native");
const focusable_1 = require("./focusable");
function withFocusable(Component) {
var _a;
const wrapped = class Button extends focusable_1.default {
render() {
var _a;
return React.createElement(Component, Object.assign({}, this.props, { isTVSelectable: this.context.active && this.props.isTVSelectable, hasTVPreferredFocus: this.context.focus.shouldSetFocus(this, (_a = this.props.hasTVPreferredFocus) !== null && _a !== void 0 ? _a : false), onFocus: this.onFocus }));
}
};
wrapped.displayName = 'Focusable<' + ((_a = Component.displayName) !== null && _a !== void 0 ? _a : Component.name) + '>';
return wrapped;
}
exports.withFocusable = withFocusable;
exports.Pressable = withFocusable(ReactNative.Pressable);
exports.TouchableHighlight = withFocusable(ReactNative.TouchableHighlight);
exports.TouchableOpacity = withFocusable(ReactNative.TouchableOpacity);
exports.TouchableNativeFeedback = withFocusable(ReactNative.TouchableNativeFeedback);
exports.TouchableWithoutFeedback = withFocusable(ReactNative.TouchableWithoutFeedback);
exports.Button = withFocusable(ReactNative.Button);