react-native-web-internals
Version:
React Native for Web
31 lines (30 loc) • 805 B
JavaScript
import React from "react";
import { isLocaleRTL } from "./isLocaleRTL.mjs";
import { jsx } from "react/jsx-runtime";
const defaultLocale = {
direction: "ltr",
locale: "en-US"
},
LocaleContext = React.createContext(defaultLocale);
function getLocaleDirection(locale) {
return isLocaleRTL(locale) ? "rtl" : "ltr";
}
function LocaleProvider(props) {
const {
direction,
locale,
children
} = props;
return direction || locale ? /* @__PURE__ */jsx(LocaleContext.Provider, {
value: {
direction: locale ? getLocaleDirection(locale) : direction,
locale
},
children
}) : children;
}
function useLocaleContext() {
return React.useContext(LocaleContext);
}
export { LocaleProvider, getLocaleDirection, useLocaleContext };
//# sourceMappingURL=index.mjs.map