UNPKG

@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.

37 lines (27 loc) 1.19 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.withDictionary = withDictionary; exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _Translate = require("../Translate"); var _DictionaryContext = _interopRequireDefault(require("./DictionaryContext")); const Dictionary = ({ values, children }) => /*#__PURE__*/React.createElement(_DictionaryContext.default.Provider, { value: values }, children); function withDictionary(Component) { return function DictionaryComponent(props) { return /*#__PURE__*/React.createElement(_DictionaryContext.default.Consumer, null, dictionary => /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({}, props, { translate: (tKey, values) => (0, _Translate.pureTranslate)(dictionary, tKey, values) }))); }; } var _default = Dictionary; exports.default = _default;