UNPKG

@dnb/eufemia

Version:

DNB Eufemia Design System UI Library

38 lines (37 loc) 959 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.currencyPositionFormatter = void 0; const currencyPositionFormatter = (existingFormatter, callback, position = null) => { let count = 0; let countCurrency = -1; return item => { if (typeof existingFormatter === 'function') { item = existingFormatter(item); } count++; switch (item.type) { case 'currency': { if (position === 'after' || position === 'before' && count > 2) { countCurrency = count; callback(item); item.value = ''; } return item; } case 'literal': { if (count === countCurrency + 1) { item.value = ''; } return item; } default: return item; } }; }; exports.currencyPositionFormatter = currencyPositionFormatter; //# sourceMappingURL=currencyPosition.js.map