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