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.

42 lines (32 loc) 1.32 kB
"use strict"; var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 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")); var Dictionary = function Dictionary(_ref) { var values = _ref.values, children = _ref.children; return /*#__PURE__*/React.createElement(_DictionaryContext.default.Provider, { value: values }, children); }; function withDictionary(Component) { return function DictionaryComponent(props) { return /*#__PURE__*/React.createElement(_DictionaryContext.default.Consumer, null, function (dictionary) { return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({}, props, { translate: function translate(tKey, values) { return (0, _Translate.pureTranslate)(dictionary, tKey, values); } })); }); }; } var _default = Dictionary; exports.default = _default;