Override locale seperator consistently (#3253)
This commit is contained in:
parent
f1a38db2d4
commit
ddebfec73e
@ -3,7 +3,6 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<meta http-equiv="X-Frame-Options" content="deny">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="shortcut icon" href="favicon.ico">
|
||||
<title><%= htmlWebpackPlugin.options.PAGE_TITLE %></title>
|
||||
|
||||
@ -52,10 +52,10 @@ interface Props {
|
||||
withEllipsis?: boolean;
|
||||
}
|
||||
|
||||
// Find decimal separator used in current locale
|
||||
const getDecimalSeparator = (): string => 1.1
|
||||
.toLocaleString()
|
||||
.replace(/\d/g, '');
|
||||
// // Find decimal separator used in current locale
|
||||
// const getDecimalSeparator = (): string => 1.1
|
||||
// .toLocaleString()
|
||||
// .replace(/\d/g, '');
|
||||
|
||||
// note: KeyboardEvent.keyCode and KeyboardEvent.which are deprecated
|
||||
const KEYS = {
|
||||
@ -67,7 +67,7 @@ const KEYS = {
|
||||
C: 'c',
|
||||
CMD: 'Meta',
|
||||
CTRL: 'Control',
|
||||
DECIMAL: getDecimalSeparator(),
|
||||
// DECIMAL: getDecimalSeparator(),
|
||||
ENTER: 'Enter',
|
||||
ESCAPE: 'Escape',
|
||||
TAB: 'Tab',
|
||||
|
||||
@ -13,7 +13,7 @@ import { BN_ZERO, BN_TEN, formatBalance, isBn } from '@polkadot/util';
|
||||
import { classes } from './util';
|
||||
import { BitLengthOption } from './constants';
|
||||
import Dropdown from './Dropdown';
|
||||
import Input, { KEYS, KEYS_PRE } from './Input';
|
||||
import Input, { KEYS_PRE } from './Input';
|
||||
import { useTranslation } from './translate';
|
||||
|
||||
interface Props {
|
||||
@ -59,9 +59,11 @@ function getGlobalMaxValue (bitLength?: number): BN {
|
||||
}
|
||||
|
||||
function getRegex (isDecimal: boolean): RegExp {
|
||||
const decimal = '.';
|
||||
|
||||
return new RegExp(
|
||||
isDecimal
|
||||
? `^(0|[1-9]\\d*)(\\${KEYS.DECIMAL}\\d*)?$`
|
||||
? `^(0|[1-9]\\d*)(\\${decimal}\\d*)?$`
|
||||
: '^(0|[1-9]\\d*)$'
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user