@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
33 lines (32 loc) • 1.11 kB
JavaScript
;
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;
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(_helpers.IS_WIN ? '. ' : ' ');
}
}
return {
number: display,
aria
};
};
const formatNationalIdentityNumber = exports.formatNationalIdentityNumber = (0, _formatCore.formatWith)('nin', formatNationalIdentityNumberParts);
//# sourceMappingURL=formatNationalIdentityNumber.js.map