Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
rc-input-number
Advanced tools
The rc-input-number package is a React component that provides an input field specifically designed for numeric values. It allows users to input numbers either by typing them directly or by using increment and decrement buttons. This package offers features such as precision control, keyboard navigation, and customizable styles.
Basic Numeric Input
This code sample demonstrates how to create a basic numeric input field with a default value, minimum, and maximum value.
import InputNumber from 'rc-input-number';
function App() {
return (
<InputNumber
defaultValue={3}
min={1}
max={10}
/>
);
}
Precision Control
This code sample shows how to set the step and precision for the numeric input, allowing users to increment or decrement by a specific value and control the number of digits after the decimal point.
import InputNumber from 'rc-input-number';
function App() {
return (
<InputNumber
defaultValue={3.5}
step={0.1}
precision={2}
/>
);
}
Keyboard Navigation
This code sample illustrates how to handle keyboard events, enabling users to navigate and modify the input value using their keyboard.
import InputNumber from 'rc-input-number';
function App() {
return (
<InputNumber
defaultValue={3}
onKeyDown={(e) => console.log('KeyDown', e)}
/>
);
}
Custom Styles
This code sample demonstrates how to apply custom styles to the numeric input component to match the design requirements of your application.
import InputNumber from 'rc-input-number';
function App() {
return (
<InputNumber
defaultValue={3}
style={{ width: 100 }}
/>
);
}
The react-numeric-input package is another React component that provides similar functionality to rc-input-number. It allows for numeric input with increment and decrement controls. It also supports keyboard navigation and can be styled using CSS. Compared to rc-input-number, it may offer different customization options or API design.
The react-number-input package is a lightweight React component for numeric input. It includes features like formatting and validation. While it provides similar functionality, the focus on formatting and validation might make it more suitable for use cases where these features are a priority.
The input-number package is a generic HTML5 number input component that can be used with or without a framework like React. It provides a simple way to input numbers with browser-native controls. Compared to rc-input-number, it might not offer as many customization options or React-specific features.
input number ui component for react (web & react-native)
web:
react-native:
var InputNumber = require('rc-input-number');
var React = require('react');
var ReactDOM = require('react-dom');
ReactDOM.render(<InputNumber defaultValue={19}/>, container);
npm install
npm start
http://127.0.0.1:8000/examples/
online example: http://react-component.github.io/input-number/examples/
./node_modules/rc-tools run react-native-init
react-native run-ios
name | type | default | description |
---|---|---|---|
min | Number | Specifies the minimum value | |
onClick | |||
placeholder | string | ||
max | Number | Specifies the maximum value | |
step | Number or String | 1 | Specifies the legal number intervals |
precision | Number | Specifies the precision length of value | |
disabled | Boolean | false | Specifies that an InputNumber should be disabled |
focusOnUpDown | Boolean | true | whether focus input when click up or down button |
autoFocus | Boolean | false | Specifies that an InputNumber should automatically get focus when the page loads |
readOnly | Boolean | false | Specifies that an InputNumber is read only |
name | String | Specifies the name of an InputNumber(`web only`) | |
id | String | Specifies the id of an InputNumber(`web only`) | |
value | Number | Specifies the value of an InputNumber | |
defaultValue | Number | Specifies the defaultValue of an InputNumber | |
onChange | Function | Called when value of an InputNumber changed | |
style | Object | root style. such as {width:100} | |
styles | ReactNative StyleSheet | component's stylesheet, can use lib/styles | |
upStyle | Object | up step wrap style. `react native only` | |
downStyle | Object | down step style. `react native only` | |
inputStyle | Object | input style. `react native only` | |
upHandler | React.Node | custom the up step element | |
downHandler | React.Node | custom the down step element | |
formatter | (value: number|string): displayValue: string | Specifies the format of the value presented | |
parser | (displayValue: string) => value: number | `input => input.replace(/[^\w\.-]*/g, '')` | Specifies the value extracted from formatter |
step
10 * step
0.1 * step
npm test
npm run chrome-test
npm run coverage
open coverage/ dir
rc-input-number is released under the MIT license.
FAQs
React input-number component
The npm package rc-input-number receives a total of 792,344 weekly downloads. As such, rc-input-number popularity was classified as popular.
We found that rc-input-number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.