@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
28 lines (27 loc) • 1.75 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _index = _interopRequireDefault(require("../String/index.js"));
var _useTranslation = _interopRequireDefault(require("../../hooks/useTranslation.js"));
var _index2 = require("../../hooks/index.js");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function PostalCodeAndCity(props) {
var _useValueProps$value, _useValueProps$value2, _props$value, _props$label;
const translations = (0, _useTranslation.default)().PostalCodeAndCity;
const cityValue = (_useValueProps$value = (0, _index2.useValueProps)((props === null || props === void 0 ? void 0 : props.city) || {}).value) !== null && _useValueProps$value !== void 0 ? _useValueProps$value : props.value;
const postalCodeValue = (_useValueProps$value2 = (0, _index2.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.default.createElement(_index.default, stringValueProps);
}
PostalCodeAndCity._supportsSpacingProps = true;
var _default = exports.default = PostalCodeAndCity;
//# sourceMappingURL=PostalCodeAndCity.js.map