Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rc-input-number

Package Overview
Dependencies
Maintainers
2
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-input-number - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

assets/index.less

126

lib/InputNumber.js

@@ -11,3 +11,4 @@ 'use strict';

function isValueNumber(value) {
return /^-?\d+?$/.test(value + '');
return (/^-?\d+?$/.test(value + '')
);
}

@@ -22,4 +23,8 @@

propTypes: {
onChange: React.PropTypes.func
},
getInitialState: function getInitialState() {
var value;
var value = undefined;
var props = this.props;

@@ -43,2 +48,3 @@ if ('value' in props) {

style: {},
defaultValue: '',
onChange: noop

@@ -56,38 +62,2 @@ };

setValue: function setValue(v, callback) {
this.setState({
value: v
}, callback);
this.props.onChange(v);
},
step: function step(type, e, callback) {
var _this = this;
if (e) {
e.preventDefault();
}
var props = this.props;
if (props.disabled) {
return;
}
var value = this.state.value;
if (isNaN(value)) {
return;
}
var stepNum = props.step || 1;
var val = value;
if (type === 'down') {
val -= stepNum;
} else if (type === 'up') {
val += stepNum;
}
if (val > props.max || val < props.min) {
return;
}
this.setValue(val, function () {
React.findDOMNode(_this.refs.input).focus();
});
},
onChange: function onChange(event) {

@@ -114,11 +84,3 @@ var props = this.props;

down: function down(e) {
this.step('down', e);
},
up: function up(e) {
this.step('up', e);
},
handleKeyDown: function handleKeyDown(e) {
onKeyDown: function onKeyDown(e) {
if (e.keyCode === 38) {

@@ -131,3 +93,3 @@ this.up(e);

handleFocus: function handleFocus() {
onFocus: function onFocus() {
this.setState({

@@ -138,3 +100,3 @@ focused: true

handleBlur: function handleBlur() {
onBlur: function onBlur() {
this.setState({

@@ -175,8 +137,8 @@ focused: false

'div',
{ unselectable: "unselectable",
ref: "up",
{ unselectable: 'unselectable',
ref: 'up',
onClick: upDisabledClass ? noop : this.up,
onMouseDown: preventDefault,
className: prefixCls + '-handler ' + prefixCls + '-handler-up ' + upDisabledClass },
React.createElement('a', { unselectable: "unselectable", className: prefixCls + '-handler-up-inner', href: "#",
React.createElement('a', { unselectable: 'unselectable', className: prefixCls + '-handler-up-inner', href: '#',
onClick: preventDefault })

@@ -186,8 +148,8 @@ ),

'div',
{ unselectable: "unselectable",
ref: "down",
{ unselectable: 'unselectable',
ref: 'down',
onMouseDown: preventDefault,
onClick: downDisabledClass ? noop : this.down,
className: prefixCls + '-handler ' + prefixCls + '-handler-down ' + downDisabledClass },
React.createElement('a', { unselectable: "unselectable", className: prefixCls + '-handler-down-inner', href: "#",
React.createElement('a', { unselectable: 'unselectable', className: prefixCls + '-handler-down-inner', href: '#',
onClick: preventDefault })

@@ -200,6 +162,6 @@ )

React.createElement('input', { className: prefixCls + '-input',
autoComplete: "off",
onFocus: this.handleFocus,
onBlur: this.handleBlur,
onKeyDown: this.handleKeyDown,
autoComplete: 'off',
onFocus: this.onFocus,
onBlur: this.onBlur,
onKeyDown: this.onKeyDown,
autoFocus: props.autoFocus,

@@ -212,6 +174,50 @@ readOnly: props.readOnly,

onChange: this.onChange,
ref: "input",
ref: 'input',
value: this.state.value })
)
);
},
setValue: function setValue(v, callback) {
this.setState({
value: v
}, callback);
this.props.onChange(v);
},
step: function step(type, e) {
var _this = this;
if (e) {
e.preventDefault();
}
var props = this.props;
if (props.disabled) {
return;
}
var value = this.state.value;
if (isNaN(value)) {
return;
}
var stepNum = props.step || 1;
var val = value;
if (type === 'down') {
val -= stepNum;
} else if (type === 'up') {
val += stepNum;
}
if (val > props.max || val < props.min) {
return;
}
this.setValue(val, function () {
React.findDOMNode(_this.refs.input).focus();
});
},
down: function down(e) {
this.step('down', e);
},
up: function up(e) {
this.step('up', e);
}

@@ -218,0 +224,0 @@ });

{
"name": "rc-input-number",
"version": "2.0.3",
"version": "2.0.4",
"description": "input-number ui component for react",

@@ -11,2 +11,6 @@ "keywords": [

],
"files": [
"lib",
"assets"
],
"main": "lib/index",

@@ -28,14 +32,11 @@ "homepage": "https://github.com/react-component/input-number",

"build": "rc-tools run build",
"precommit": "rc-tools run precommit",
"less": "rc-tools run less",
"gh-pages": "rc-tools run gh-pages",
"history": "rc-tools run history",
"start": "node --harmony node_modules/.bin/rc-server",
"publish": "rc-tools run tag",
"start": "rc-server",
"pub": "rc-tools run pub",
"lint": "rc-tools run lint",
"saucelabs": "node --harmony node_modules/.bin/rc-tools run saucelabs",
"browser-test": "node --harmony node_modules/.bin/rc-tools run browser-test",
"browser-test-cover": "node --harmony node_modules/.bin/rc-tools run browser-test-cover"
"karma": "rc-tools run karma",
"saucelabs": "rc-tools run saucelabs",
"browser-test": "rc-tools run browser-test",
"browser-test-cover": "rc-tools run browser-test-cover"
},
"devDependencies": {

@@ -45,3 +46,3 @@ "expect.js": "~0.3.1",

"rc-server": "3.x",
"rc-tools": "3.x",
"rc-tools": "4.x",
"react": "~0.13.0"

@@ -53,4 +54,4 @@ },

"precommit": [
"precommit"
"lint"
]
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc