Fixed #1522 - InputNumber: issues with decimal separator for some locales, 0s are added to input
parent
999022caca
commit
f5226f6803
|
@ -184,10 +184,10 @@ export default {
|
||||||
const numerals = [...new Intl.NumberFormat(this.locale, {useGrouping: false}).format(9876543210)].reverse();
|
const numerals = [...new Intl.NumberFormat(this.locale, {useGrouping: false}).format(9876543210)].reverse();
|
||||||
const index = new Map(numerals.map((d, i) => [d, i]));
|
const index = new Map(numerals.map((d, i) => [d, i]));
|
||||||
this._numeral = new RegExp(`[${numerals.join('')}]`, 'g');
|
this._numeral = new RegExp(`[${numerals.join('')}]`, 'g');
|
||||||
this._decimal = this.getDecimalExpression();
|
|
||||||
this._group = this.getGroupingExpression();
|
this._group = this.getGroupingExpression();
|
||||||
this._minusSign = this.getMinusSignExpression();
|
this._minusSign = this.getMinusSignExpression();
|
||||||
this._currency = this.getCurrencyExpression();
|
this._currency = this.getCurrencyExpression();
|
||||||
|
this._decimal = this.getDecimalExpression();
|
||||||
this._suffix = this.getSuffixExpression();
|
this._suffix = this.getSuffixExpression();
|
||||||
this._prefix = this.getPrefixExpression();
|
this._prefix = this.getPrefixExpression();
|
||||||
this._index = d => index.get(d);
|
this._index = d => index.get(d);
|
||||||
|
@ -201,8 +201,8 @@ export default {
|
||||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||||
},
|
},
|
||||||
getDecimalExpression() {
|
getDecimalExpression() {
|
||||||
const formatter = new Intl.NumberFormat(this.locale, {useGrouping: false});
|
const formatter = new Intl.NumberFormat(this.locale, {...this.getOptions(), useGrouping: false});
|
||||||
return new RegExp(`[${formatter.format(1.1).trim().replace(this._numeral, '')}]`, 'g');
|
return new RegExp(`[${formatter.format(1.1).replace(this._currency, '').trim().replace(this._numeral, '')}]`, 'g');
|
||||||
},
|
},
|
||||||
getGroupingExpression() {
|
getGroupingExpression() {
|
||||||
const formatter = new Intl.NumberFormat(this.locale, {useGrouping: true});
|
const formatter = new Intl.NumberFormat(this.locale, {useGrouping: true});
|
||||||
|
@ -215,8 +215,9 @@ export default {
|
||||||
},
|
},
|
||||||
getCurrencyExpression() {
|
getCurrencyExpression() {
|
||||||
if (this.currency) {
|
if (this.currency) {
|
||||||
const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay});
|
const formatter = new Intl.NumberFormat(this.locale, {style: 'currency', currency: this.currency, currencyDisplay: this.currencyDisplay,
|
||||||
return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._decimal, '').replace(this._group, '')}]`, 'g');
|
minimumFractionDigits: 0, maximumFractionDigits: 0});
|
||||||
|
return new RegExp(`[${formatter.format(1).replace(/\s/g, '').replace(this._numeral, '').replace(this._group, '')}]`, 'g');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new RegExp(`[]`,'g');
|
return new RegExp(`[]`,'g');
|
||||||
|
|
Loading…
Reference in New Issue