@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
25 lines (23 loc) • 852 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import * as React from "react";
import { pureTranslate } from "../Translate";
import DictionaryContext from "./DictionaryContext";
var Dictionary = function Dictionary(_ref) {
var values = _ref.values,
children = _ref.children;
return /*#__PURE__*/React.createElement(DictionaryContext.Provider, {
value: values
}, children);
};
export function withDictionary(Component) {
return function DictionaryComponent(props) {
return /*#__PURE__*/React.createElement(DictionaryContext.Consumer, null, function (dictionary) {
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
translate: function translate(tKey, values) {
return pureTranslate(dictionary, tKey, values);
}
}));
});
};
}
export default Dictionary;