@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
23 lines • 2.2 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import React from 'react';
import StringValue from '../String';
import useTranslation from '../../hooks/useTranslation';
import { useValueProps } from '../../hooks';
function PostalCodeAndCity(props) {
var _useValueProps$value, _useValueProps$value2, _props$value, _props$label;
const translations = useTranslation().PostalCodeAndCity;
const cityValue = (_useValueProps$value = useValueProps((props === null || props === void 0 ? void 0 : props.city) || {}).value) !== null && _useValueProps$value !== void 0 ? _useValueProps$value : props.value;
const postalCodeValue = (_useValueProps$value2 = useValueProps((props === null || props === void 0 ? void 0 : props.postalCode) || {}).value) !== null && _useValueProps$value2 !== void 0 ? _useValueProps$value2 : props.value;
const value = (_props$value = props.value) !== null && _props$value !== void 0 ? _props$value : (postalCodeValue || cityValue ? [postalCodeValue, cityValue].filter(Boolean).join(' ') : undefined) || undefined;
const label = (_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : props.inline ? undefined : translations.label;
const stringValueProps = _objectSpread(_objectSpread({}, props), {}, {
value,
label
});
return React.createElement(StringValue, stringValueProps);
}
PostalCodeAndCity._supportsSpacingProps = true;
export default PostalCodeAndCity;
//# sourceMappingURL=PostalCodeAndCity.js.map