@mrii/react-table-builder
Version:
library to easily build tables using MUI grid
24 lines (21 loc) • 880 B
JavaScript
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