Skip to content

Commit

Permalink
rebuild docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Apr 11, 2016
1 parent 6d34e28 commit 198f4e1
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 56 deletions.
60 changes: 32 additions & 28 deletions dist/react-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -7829,8 +7829,6 @@ return /******/ (function(modules) { // webpackBootstrap
decimal = _localizers.number.decimalChar(null, props.culture),
format = getFormat(props);

this._beginningWithSign = false;

if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace('.', decimal) : _localizers.number.format(value, format, props.culture);

return {
Expand All @@ -7851,48 +7849,43 @@ return /******/ (function(modules) { // webpackBootstrap
className: 'rw-input',
onChange: this._change,
onBlur: this._finish,
onKeyPress: this._typing,
'aria-disabled': this.props.disabled,
'aria-readonly': this.props.readOnly,
disabled: this.props.disabled,
readOnly: this.props.readOnly,
placeholder: this.props.placeholder,
value: value }));
},
_typing: function _typing(e) {
var current = e.target.value,
newVal = e.key;

this._beginningWithSign = current.trim() === '' && this.isSign(newVal);

this.props.onKeyPress && this.props.onKeyPress(e);
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value),
atSign = this.isSign(val.trim()),
startingWithSign = this._beginningWithSign;
number = this._parse(e.target.value);

this._beginningWithSign = false;
var isIntermediate = this.isIntermediateValue(number, val);

if (val == null || val.trim() === '' || atSign && !startingWithSign) {
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}

if (this.isFlushable(number, val)) {
if (number !== this.props.value) return this.props.onChange(number);else this.setState(this.getDefaultState()); // 5. -> 5
if (!isIntermediate) {
if (number !== this.props.value) {
return this.props.onChange(number);
}
} else {
this.current(e.target.value);
}

if (number < this.props.min || atSign && startingWithSign || this.isAtDelimiter(number, val)) this.current(e.target.value);
},
_finish: function _finish() {
var str = this.state.stringValue,
number = this._parse(str);

// if number is below the min
// we need to flush low values and decimal stops, onBlur means i'm done inputing
if (!isNaN(number) && (number < this.props.min || this.isAtDelimiter(number, str))) {
if (this.isIntermediateValue(number, str)) {
if (isNaN(number)) {
number = null;
}
this.props.onChange(number);
}
},
Expand All @@ -7908,24 +7901,35 @@ return /******/ (function(modules) { // webpackBootstrap

return strVal;
},
isFlushable: function isFlushable(num, str) {
return this.isValid(num) && !this.isAtDelimiter(num, str) && !this.isSign(str);
isIntermediateValue: function isIntermediateValue(num, str) {
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str));
},
isSign: function isSign(val) {
return (val || '').trim() === '-';
},
isPaddedZeros: function isPaddedZeros(str) {
var localeChar = _localizers.number.decimalChar(null, this.props.culture);

var _str$split = str.split(localeChar);

var _ = _str$split[0];
var decimals = _str$split[1];


return !!(decimals && decimals.match(/0+$/));
},
isAtDelimiter: function isAtDelimiter(num, str) {
var props = arguments.length <= 2 || arguments[2] === undefined ? this.props : arguments[2];

var localeChar = _localizers.number.decimalChar(null, props.culture),
lastIndex = str.length - 1,
char;

if (str.length <= 1) return false;
if (str.length < 1) return false;

char = str[lastIndex];

return char === localeChar && str.indexOf(char) === lastIndex;
return !!(char === localeChar && str.indexOf(char) === lastIndex);
},
isValid: function isValid(num) {
if (typeof num !== 'number' || isNaN(num)) return false;
Expand All @@ -7934,8 +7938,8 @@ return /******/ (function(modules) { // webpackBootstrap


//this intermediate state is for when one runs into the decimal or are typing the number
current: function current(val) {
this.setState({ stringValue: val });
current: function current(stringValue) {
this.setState({ stringValue: stringValue });
}
});
module.exports = exports['default'];
Expand Down
70 changes: 70 additions & 0 deletions docs/public/docs.js

Large diffs are not rendered by default.

Binary file added docs/public/rw-widgets.eot
Binary file not shown.
18 changes: 18 additions & 0 deletions docs/public/rw-widgets.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/public/rw-widgets.ttf
Binary file not shown.
27 changes: 27 additions & 0 deletions docs/public/vendor.bundle.js

Large diffs are not rendered by default.

60 changes: 32 additions & 28 deletions lib/NumberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ exports.default = _react2.default.createClass({
decimal = _localizers.number.decimalChar(null, props.culture),
format = getFormat(props);

this._beginningWithSign = false;

if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace('.', decimal) : _localizers.number.format(value, format, props.culture);

return {
Expand All @@ -74,48 +72,43 @@ exports.default = _react2.default.createClass({
className: 'rw-input',
onChange: this._change,
onBlur: this._finish,
onKeyPress: this._typing,
'aria-disabled': this.props.disabled,
'aria-readonly': this.props.readOnly,
disabled: this.props.disabled,
readOnly: this.props.readOnly,
placeholder: this.props.placeholder,
value: value }));
},
_typing: function _typing(e) {
var current = e.target.value,
newVal = e.key;

this._beginningWithSign = current.trim() === '' && this.isSign(newVal);

this.props.onKeyPress && this.props.onKeyPress(e);
value: value
}));
},
_change: function _change(e) {
var val = e.target.value,
number = this._parse(e.target.value),
atSign = this.isSign(val.trim()),
startingWithSign = this._beginningWithSign;
number = this._parse(e.target.value);

this._beginningWithSign = false;
var isIntermediate = this.isIntermediateValue(number, val);

if (val == null || val.trim() === '' || atSign && !startingWithSign) {
if (val == null || val.trim() === '') {
this.current('');
return this.props.onChange(null);
}

if (this.isFlushable(number, val)) {
if (number !== this.props.value) return this.props.onChange(number);else this.setState(this.getDefaultState()); // 5. -> 5
if (!isIntermediate) {
if (number !== this.props.value) {
return this.props.onChange(number);
}
} else {
this.current(e.target.value);
}

if (number < this.props.min || atSign && startingWithSign || this.isAtDelimiter(number, val)) this.current(e.target.value);
},
_finish: function _finish() {
var str = this.state.stringValue,
number = this._parse(str);

// if number is below the min
// we need to flush low values and decimal stops, onBlur means i'm done inputing
if (!isNaN(number) && (number < this.props.min || this.isAtDelimiter(number, str))) {
if (this.isIntermediateValue(number, str)) {
if (isNaN(number)) {
number = null;
}
this.props.onChange(number);
}
},
Expand All @@ -131,24 +124,35 @@ exports.default = _react2.default.createClass({

return strVal;
},
isFlushable: function isFlushable(num, str) {
return this.isValid(num) && !this.isAtDelimiter(num, str) && !this.isSign(str);
isIntermediateValue: function isIntermediateValue(num, str) {
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str));
},
isSign: function isSign(val) {
return (val || '').trim() === '-';
},
isPaddedZeros: function isPaddedZeros(str) {
var localeChar = _localizers.number.decimalChar(null, this.props.culture);

var _str$split = str.split(localeChar);

var _ = _str$split[0];
var decimals = _str$split[1];


return !!(decimals && decimals.match(/0+$/));
},
isAtDelimiter: function isAtDelimiter(num, str) {
var props = arguments.length <= 2 || arguments[2] === undefined ? this.props : arguments[2];

var localeChar = _localizers.number.decimalChar(null, props.culture),
lastIndex = str.length - 1,
char;

if (str.length <= 1) return false;
if (str.length < 1) return false;

char = str[lastIndex];

return char === localeChar && str.indexOf(char) === lastIndex;
return !!(char === localeChar && str.indexOf(char) === lastIndex);
},
isValid: function isValid(num) {
if (typeof num !== 'number' || isNaN(num)) return false;
Expand All @@ -157,8 +161,8 @@ exports.default = _react2.default.createClass({


//this intermediate state is for when one runs into the decimal or are typing the number
current: function current(val) {
this.setState({ stringValue: val });
current: function current(stringValue) {
this.setState({ stringValue: stringValue });
}
});
module.exports = exports['default'];

0 comments on commit 198f4e1

Please sign in to comment.