react-native-web-internals
Version:
React Native for Web
33 lines (32 loc) • 809 B
JavaScript
import React from "react";
import { isLocaleRTL } from "./isLocaleRTL";
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.js.map