UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

37 lines 1.2 kB
import React from 'react'; import NumberFormatBase from "./NumberFormatBase.js"; import { formatPhoneNumber } from "./utils/index.js"; import withComponentMarkers from "../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx } from "react/jsx-runtime"; function NumberFormatPhoneNumber({ link, className, ...rest }) { var _rest$value; if (!link) { return _jsx(NumberFormatBase, { ...rest, className: className, __format: formatPhoneNumber }); } const scheme = link === true ? 'tel' : link; const sanitizedValue = String((_rest$value = rest.value) !== null && _rest$value !== void 0 ? _rest$value : '').replace(/[^\d+]/g, ''); const href = `${scheme}:${sanitizedValue}`; const anchorClassName = ['dnb-anchor', className].filter(Boolean).join(' '); return _jsx("a", { href: href, className: anchorClassName, children: _jsx(NumberFormatBase, { ...rest, __format: formatPhoneNumber }) }); } NumberFormatPhoneNumber.displayName = 'NumberFormat.PhoneNumber'; withComponentMarkers(NumberFormatPhoneNumber, { _supportsSpacingProps: true }); export default NumberFormatPhoneNumber; //# sourceMappingURL=PhoneNumber.js.map