react-native-web-internals
Version:
React Native for Web
32 lines (31 loc) • 878 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import React from "react";
import { isLocaleRTL } from "./isLocaleRTL.native.js";
var defaultLocale = {
direction: "ltr",
locale: "en-US"
},
LocaleContext = /* @__PURE__ */React.createContext(defaultLocale);
function getLocaleDirection(locale) {
return isLocaleRTL(locale) ? "rtl" : "ltr";
}
function LocaleProvider(props) {
var {
direction,
locale,
children
} = props,
needsContext = direction || locale;
return needsContext ? /* @__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.native.js.map