@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
21 lines • 1.42 kB
JavaScript
import React from 'react';
import StringValue from "../String/index.js";
import useTranslation from "../../hooks/useTranslation.js";
import { useValueProps } from "../../hooks/index.js";
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 = {
...props,
value,
label
};
return React.createElement(StringValue, stringValueProps);
}
PostalCodeAndCity._supportsSpacingProps = true;
export default PostalCodeAndCity;
//# sourceMappingURL=PostalCodeAndCity.js.map