Skip to content
Snippets Groups Projects
Unverified Commit acaff825 authored by TheTrueCaligari's avatar TheTrueCaligari Committed by GitHub
Browse files

Add a new number format (space-dot) (#995)

parent f913d99c
No related branches found
No related tags found
No related merge requests found
......@@ -64,4 +64,15 @@ describe('utility functions', () => {
formatter = getNumberFormat().formatter;
expect(formatter.format(Number('1234.56'))).toBe('1\xa0235');
});
test('number formatting works with space-dot format', () => {
setNumberFormat({ format: 'space-dot', hideFraction: false });
let formatter = getNumberFormat().formatter;
// grouping separator space char is a non-breaking space, or UTF-16 \xa0
expect(formatter.format(Number('1234.56'))).toBe('1\xa0234.56');
setNumberFormat({ format: 'space-dot', hideFraction: true });
formatter = getNumberFormat().formatter;
expect(formatter.format(Number('1234.56'))).toBe('1\xa0235');
});
});
......@@ -252,6 +252,7 @@ export let numberFormats = [
{ value: 'comma-dot', label: '1,000.33', labelNoFraction: '1,000' },
{ value: 'dot-comma', label: '1.000,33', labelNoFraction: '1.000' },
{ value: 'space-comma', label: '1 000,33', labelNoFraction: '1 000' },
{ value: 'space-dot', label: '1 000.33', labelNoFraction: '1 000' },
];
let numberFormat: {
......@@ -279,6 +280,11 @@ export function setNumberFormat({ format, hideFraction }) {
regex = /[^-0-9,]/g;
separator = ',';
break;
case 'space-dot':
locale = 'dje';
regex = /[^-0-9,]/g;
separator = '.';
break;
case 'comma-dot':
default:
locale = 'en-US';
......
---
category: Enhancements
authors: [TheTrueCaligari]
---
Number Format: Add a new option (space-dot) e.g. "1 234.56"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment