@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
31 lines • 1.12 kB
JavaScript
import React, { useCallback } from 'react';
import StringValue from "../String/index.js";
import { formatPhoneNumber } 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 PhoneNumber(props) {
var _props$label;
const translations = useTranslation().PhoneNumber;
const label = (_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : props.inline ? undefined : translations.numberLabel;
const toInput = useCallback(value => {
if (isValueEmpty(value)) {
return undefined;
}
return formatPhoneNumber(value).toString();
}, []);
const stringValueProps = {
...props,
label,
toInput
};
return _jsx(StringValue, {
...stringValueProps
});
}
withComponentMarkers(PhoneNumber, {
_supportsSpacingProps: true
});
export default PhoneNumber;
//# sourceMappingURL=PhoneNumber.js.map