UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

36 lines (35 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatNationalIdentityNumber = void 0; var _helpers = require("../../../shared/helpers.js"); var _constants = require("./constants.js"); var _formatCore = require("./formatCore.js"); const formatNationalIdentityNumberParts = (number, locale = null) => { if ((0, _constants.isAbsent)(number)) { return { number: _constants.ABSENT_VALUE_FORMAT, aria: _constants.ABSENT_VALUE_FORMAT }; } const num = String(number).replace(/[^0-9]/g, ''); let display = num; let aria = null; 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(_helpers.IS_WIN ? '. ' : ' '); } } if (aria === null) { aria = display; } return { number: display, aria }; }; const formatNationalIdentityNumber = exports.formatNationalIdentityNumber = (0, _formatCore.formatWith)('nin', formatNationalIdentityNumberParts); //# sourceMappingURL=formatNationalIdentityNumber.js.map