UNPKG

@weston/react-world-flags

Version:
38 lines (34 loc) 1.32 kB
import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js'; import React from '../node_modules/react/index.js'; import { getAlphaTwoCode } from './country.js'; var _excluded = ["code", "fallback"]; var Flag = function Flag(flags) { return function (props) { var code = props.code, _props$fallback = props.fallback, fallback = _props$fallback === void 0 ? null : _props$fallback, rest = _objectWithoutProperties(props, _excluded); if (!code) return fallback; var alphaTwo = getAlphaTwoCode(code); var flag = flags['flag_' + alphaTwo.replace('-', '_')]; return flag ? /*#__PURE__*/React.createElement("img", _extends({}, rest, { src: flag })) : fallback; }; }; var CountryFlag = function CountryFlag(flag) { return function (props) { return flag ? /*#__PURE__*/React.createElement("img", _extends({}, props, { src: flag })) : /*#__PURE__*/React.createElement(React.Fragment, null); }; }; var RasterFlag = function RasterFlag(flags, height) { return function (props) { return Flag(flags)(Object.assign({ height: height }, props !== null && props !== void 0 ? props : {})); }; }; export { CountryFlag, Flag, RasterFlag }; //# sourceMappingURL=Flag.js.map