1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Allow TextField to receive min and max attributes (#10656)

This commit is contained in:
David Walsh 2021-03-16 11:24:56 -05:00 committed by GitHub
parent b8900140ec
commit da90674f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 2 deletions

View File

@ -88,6 +88,8 @@ const getMaterialThemeInputProps = ({
dir,
classes: { materialLabel, materialFocused, materialError, materialUnderline },
startAdornment,
min,
max,
}) => ({
InputLabelProps: {
classes: {
@ -103,6 +105,8 @@ const getMaterialThemeInputProps = ({
},
inputProps: {
dir,
min,
max,
},
},
});
@ -116,6 +120,8 @@ const getMaterialWhitePaddedThemeInputProps = ({
materialWhitePaddedUnderline,
},
startAdornment,
min,
max,
}) => ({
InputProps: {
startAdornment,
@ -127,6 +133,8 @@ const getMaterialWhitePaddedThemeInputProps = ({
},
inputProps: {
dir,
min,
max,
},
},
});
@ -145,6 +153,8 @@ const getBorderedThemeInputProps = ({
},
largeLabel,
startAdornment,
min,
max,
}) => ({
InputLabelProps: {
shrink: true,
@ -165,6 +175,8 @@ const getBorderedThemeInputProps = ({
},
inputProps: {
dir,
min,
max,
},
},
});
@ -182,6 +194,8 @@ const TextField = ({
startAdornment,
largeLabel,
dir,
min,
max,
...textFieldProps
}) => {
const inputProps = themeToInputProps[theme]({
@ -189,6 +203,8 @@ const TextField = ({
startAdornment,
largeLabel,
dir,
min,
max,
});
return (
@ -214,6 +230,8 @@ TextField.propTypes = {
theme: PropTypes.oneOf(['bordered', 'material', 'material-white-padded']),
startAdornment: PropTypes.element,
largeLabel: PropTypes.bool,
min: PropTypes.number,
max: PropTypes.number,
};
export default withStyles(styles)(TextField);

View File

@ -13,6 +13,9 @@ import TokenSearch from './token-search';
const emptyAddr = '0x0000000000000000000000000000000000000000';
const MIN_DECIMAL_VALUE = 0;
const MAX_DECIMAL_VALUE = 36;
class AddToken extends Component {
static contextTypes = {
t: PropTypes.func,
@ -211,8 +214,8 @@ class AddToken extends Component {
const validDecimals =
customDecimals !== null &&
customDecimals !== '' &&
customDecimals >= 0 &&
customDecimals <= 36;
customDecimals >= MIN_DECIMAL_VALUE &&
customDecimals <= MAX_DECIMAL_VALUE;
let customDecimalsError = null;
if (!validDecimals) {
@ -282,6 +285,8 @@ class AddToken extends Component {
fullWidth
margin="normal"
disabled={autoFilled}
min={MIN_DECIMAL_VALUE}
max={MAX_DECIMAL_VALUE}
/>
</div>
);