Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
material-ui-number-input
Advanced tools
The better TextField for number inputs.
Check Change log for changes.
Name | Type | Default | TextField | Description |
---|---|---|---|---|
children | node | ✓ | ||
className | string | ✓ | The css class name of the root element. | |
disabled | bool | false | ✓ | Disables the input field if set to true. |
floatingLabelFixed | bool | false | ✓ | If true, the floating label will float even when there is no value. |
id | string | ✓ | The id prop for the input field. | |
name | string | ✓ | Name applied to the input. | |
fullWidth | bool | false | ✓ | If true, the field receives the property width 100%. |
underlineShow | bool | true | ✓ | If true, shows the underline for the input field. |
defaultValue | number | ✓ | The number to use for the default value. Must be in range [min, max] if any is setted. | |
strategy | 'ignore' | 'warn' | 'allow' | 'allow' | ❌ | Strategy to use when user presses key and when value prop change it's value. |
min | number | ❌ | The number used as minimum value limit. Must be less than max. | |
max | number | ❌ | The number used as maximum value limit. Must be greater than min. | |
required | bool | false | ❌ | If true and if input is left empty than instead of 'clean', 'required' error will be emited throughout onError handler if useStrategy is not 'ignore'. |
value | string | ✓ | The value of the input field. | |
onChange | function | ✓ | Callback function that is fired when input filed must change it's value. Signature: function(event: React.FormEvent<HTMLInputElement>, value: string) => void . | |
onError | function | ❌ | Callback function that is fired when input error status changes and strategy is not 'ignore'. Signature: `function(error: 'none' | |
onValid | function | ❌ | Callback function that is fired when input's value is a valid number. Signature: function(value: number) => void | |
onRequestValue* | function | ❌ | Callback function that is fired when strategy is 'warn' or 'ignore', input is controlled and an invalid number value is passed. It provides valid number value which needs to be setted. Signature: function(value: string) => void | |
errorText | node | ✓ | The error content to display. | |
errorStyle | object | ✓ | The style object to use to override error styles. | |
floatingLabelFocusStyle | object | ✓ | The style object to use to override floating label styles when focused. | |
floatingLabelStyle | object | ✓ | The style object to use to override floating label styles. | |
floatingLabelText | node | ✓ | The content to use for the floating label element. | |
hintStyle | object | ✓ | Override the inline-styles of the TextField's hint text element. | |
hintText | node | ✓ | The hint content to display. | |
inputStyle | object | ✓ | Override the inline-styles of the TextField's input element. When multiLine is false: define the style of the input element. When multiLine is true: define the style of the container of the textarea. | |
style | object | ✓ | Override the inline-styles of the root element. | |
underlineDisabledStyle | object | ✓ | Override the inline-styles of the TextField's underline element when disabled. | |
underlineFocusStyle | object | ✓ | Override the inline-styles of the TextField's underline element when focussed. | |
underlineStyle | object | ✓ | Override the inline-styles of the TextField's underline element. |
* onRequestValue is required when strategy is 'warn' or 'ignore' and input is controlled in order to ensure correct strategy behaviour.
strategy | onError fired | onRequestValue fired |
---|---|---|
'allow' | ✓ | |
'warn' | ✓ | ✓* |
'ignore' | ✓* |
* Fired when input is controlled (value
is provided). If input is not controlled it's value will be automaticlly corrected when it get's invalid number value.
Fired when input's value is valid (there is no error).
Fired when required
prop is true
and user leaves empty the input or it gets cleared.
Fired when required
prop is false
and user leaves empty the input or it gets cleared.
Fired when user enters none special key which is different than -
,.
,[0-9]
.
Fired wehn user enters -
as first char in the input or when user enters the first .
.
Fired when user enters -
not as a first char.
Fired when user enters .
and there is already one entered.
Fired when user has entered 0
as first char and enters a digit key.
Fired when user enters number less than min
prop value.
Fired when user enters number greater than max
prop value.
NumberInput
re-exposes public method getInputNode(): HTMLInputElement
from TextField
.
TextField
methods: blur
, focus
, select
and getValue
are not exposed as they and getInputNode
will be removed in material-ui 0.16 and replaced with public member input
which is public and now but getInputNode
is prefered until 0.16 is released. If you want to use any of those methods call them on input retunrned from getInputNode
with the excpetion of getValue
instead use value
property.
import * as React from 'react';
import NumberInput from 'material-ui-number-input';
class Demo extends React.Component {
constructor(props) {
super(props);
this.onKeyDown = (event) => {
console.log(`onKeyDown ${event.key}`);
};
this.onChange = (event, value) => {
const e = event;
console.log(`onChange ${e.target.value}, ${value}`);
};
this.onError = (error) => {
let errorText;
console.log(error);
switch (error) {
case 'required':
errorText = 'This field is required';
break;
case 'invalidSymbol':
errorText = 'You are tring to enter none number symbol';
break;
case 'incompleteNumber':
errorText = 'Number is incomplete';
break;
case 'singleMinus':
errorText = 'Minus can be use only for negativity';
break;
case 'singleFloatingPoint':
errorText = 'There is already a floating point';
break;
case 'singleZero':
errorText = 'Floating point is expected';
break;
case 'min':
errorText = 'You are tring to enter number less than -10';
break;
case 'max':
errorText = 'You are tring to enter number greater than 12';
break;
}
this.setState({ errorText: errorText });
};
this.onValid = (value) => {
console.debug(`${value} is a valid number`);
};
this.onRequestValue = (value) => {
console.log(`request ${JSON.stringify(value)}`);
this.setState({ value: value })
}
}
render() {
const { state, onChange, onError, onKeyDown, onValid, onRequestValue } = this;
return (
<NumberInput
id="num"
value={state.value}
required
defaultValue={9}
min={-10}
max={12}
strategy="warn"
errorText={state.errorText}
onValid={onValid}
onChange={onChange}
onError={onError}
onRequestValue={onRequestValue}
onKeyDown={onKeyDown} />
);
}
}
npm install
npm run typings
npm start
http://localhost:3000
FAQs
The better TextField for number inputs.
The npm package material-ui-number-input receives a total of 82 weekly downloads. As such, material-ui-number-input popularity was classified as not popular.
We found that material-ui-number-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.