UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

27 lines 911 B
import { IS_WIN } from "../../../shared/helpers.js"; import { ABSENT_VALUE_FORMAT, isAbsent } from "./constants.js"; import { formatWith } from "./formatCore.js"; const formatNationalIdentityNumberParts = (number, locale = null) => { if (isAbsent(number)) { return { number: ABSENT_VALUE_FORMAT, aria: ABSENT_VALUE_FORMAT }; } const num = String(number).replace(/[^0-9]/g, ''); let display; let aria; switch (locale) { default: { display = num.split(/([0-9]{6})/).filter(s => s).join(' '); aria = display.split(/([0-9]{2})([0-9]{2})([0-9]{2}) ([0-9]{1})([0-9]{1})([0-9]{1})([0-9]{1})([0-9]{1})/).filter(s => s).join(IS_WIN ? '. ' : ' '); } } return { number: display, aria }; }; export const formatNationalIdentityNumber = formatWith('nin', formatNationalIdentityNumberParts); //# sourceMappingURL=formatNationalIdentityNumber.js.map