UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

37 lines 1.33 kB
import React, { useMemo } from 'react'; import StringField from "../String/index.js"; import useTranslation from "../../hooks/useTranslation.js"; import withComponentMarkers from "../../../../shared/helpers/withComponentMarkers.js"; import { jsx as _jsx } from "react/jsx-runtime"; const aText = `[A-Za-z0-9!#$%&'*+/=?^_\\x60{|}~\\u0080-\\uFFFF-]+`; export const pattern = `^${aText}(?:\\.${aText})*@` + `(?:` + `(?:` + `(?:xn--[A-Za-z0-9-]+|[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\\.)+` + `(?:[A-Za-z]{2,}|xn--[A-Za-z0-9-]{2,})` + `|` + `(?:xn--[A-Za-z0-9-]{2,})` + `|` + `\\[(?:` + `\\d{1,3}(?:\\.\\d{1,3}){3}` + `|` + `IPv6:[0-9A-Fa-f:]+` + `)\\]` + `)$`; function Email(props) { const { label, errorRequired, errorPattern } = useTranslation().Email; const errorMessages = useMemo(() => ({ 'Field.errorRequired': errorRequired, 'Field.errorPattern': errorPattern, ...props.errorMessages }), [errorPattern, errorRequired, props.errorMessages]); const StringFieldProps = { label, autoComplete: 'email', inputMode: 'email', maxLength: 254, pattern, trim: true, ...props, errorMessages }; return _jsx(StringField, { ...StringFieldProps }); } withComponentMarkers(Email, { _supportsSpacingProps: true }); export default Email; //# sourceMappingURL=Email.js.map