@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
30 lines • 1.2 kB
JavaScript
import React, { useCallback } from 'react';
import StringValue from "../String/index.js";
import { formatNationalIdentityNumber, cleanNumber } from "../../../../components/number-format/NumberUtils.js";
import useTranslation from "../../hooks/useTranslation.js";
import { isValueEmpty } from "../../ValueBlock/index.js";
import withComponentMarkers from "../../../../shared/helpers/withComponentMarkers.js";
import { jsx as _jsx } from "react/jsx-runtime";
function NationalIdentityNumber(props) {
var _props$label;
const translations = useTranslation().NationalIdentityNumber;
const toInput = useCallback(value => {
if (isValueEmpty(value)) {
return undefined;
}
return formatNationalIdentityNumber(cleanNumber(value)).toString();
}, []);
const stringValueProps = {
...props,
label: (_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : props.inline ? undefined : translations.label,
toInput
};
return _jsx(StringValue, {
...stringValueProps
});
}
withComponentMarkers(NationalIdentityNumber, {
_supportsSpacingProps: true
});
export default NationalIdentityNumber;
//# sourceMappingURL=NationalIdentityNumber.js.map