UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

27 lines 953 B
import React, { useCallback } from 'react'; import StringValue from "../String/index.js"; import { format } from "../../../../components/number-format/NumberUtils.js"; import useTranslation from "../../hooks/useTranslation.js"; import { isValueEmpty } from "../../ValueBlock/index.js"; 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.label; const toInput = useCallback(value => { if (isValueEmpty(value)) { return undefined; } return format(value, { phone: true }).toString(); }, []); const stringValueProps = { ...props, label, toInput }; return React.createElement(StringValue, stringValueProps); } PhoneNumber._supportsSpacingProps = true; export default PhoneNumber; //# sourceMappingURL=PhoneNumber.js.map