UNPKG

@mrii/react-table-builder

Version:
24 lines (21 loc) 880 B
import { jsx } from 'react/jsx-runtime'; import { createContext } from '../../utils/create-context.mjs'; import { useMemo } from 'react'; import { stringToLabel } from '../../utils/string-to-label/index.mjs'; const [Provider, useTranslation] = createContext(); const useGetLabel = (str)=>useTranslation((s)=>s.getFieldLabel)(str); const TranslationProvider = ({ translation , children })=>{ const value = useMemo(()=>({ getFieldLabel: (str, resolve)=>// eslint-disable-next-line @typescript-eslint/no-unsafe-return translation[str] ?? (resolve ? stringToLabel(str) : undefined), translation }), [ translation ]); return /*#__PURE__*/ jsx(Provider, { value: value, children: children }); }; export { TranslationProvider, useGetLabel, useTranslation }; //# sourceMappingURL=provider.mjs.map