Skip to content

Commit 198f4e1

Browse files
committed
rebuild docs
1 parent 6d34e28 commit 198f4e1

7 files changed

Lines changed: 179 additions & 56 deletions

File tree

dist/react-widgets.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7829,8 +7829,6 @@ return /******/ (function(modules) { // webpackBootstrap
78297829
decimal = _localizers.number.decimalChar(null, props.culture),
78307830
format = getFormat(props);
78317831

7832-
this._beginningWithSign = false;
7833-
78347832
if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace('.', decimal) : _localizers.number.format(value, format, props.culture);
78357833

78367834
return {
@@ -7851,48 +7849,43 @@ return /******/ (function(modules) { // webpackBootstrap
78517849
className: 'rw-input',
78527850
onChange: this._change,
78537851
onBlur: this._finish,
7854-
onKeyPress: this._typing,
78557852
'aria-disabled': this.props.disabled,
78567853
'aria-readonly': this.props.readOnly,
78577854
disabled: this.props.disabled,
78587855
readOnly: this.props.readOnly,
78597856
placeholder: this.props.placeholder,
7860-
value: value }));
7861-
},
7862-
_typing: function _typing(e) {
7863-
var current = e.target.value,
7864-
newVal = e.key;
7865-
7866-
this._beginningWithSign = current.trim() === '' && this.isSign(newVal);
7867-
7868-
this.props.onKeyPress && this.props.onKeyPress(e);
7857+
value: value
7858+
}));
78697859
},
78707860
_change: function _change(e) {
78717861
var val = e.target.value,
7872-
number = this._parse(e.target.value),
7873-
atSign = this.isSign(val.trim()),
7874-
startingWithSign = this._beginningWithSign;
7862+
number = this._parse(e.target.value);
78757863

7876-
this._beginningWithSign = false;
7864+
var isIntermediate = this.isIntermediateValue(number, val);
78777865

7878-
if (val == null || val.trim() === '' || atSign && !startingWithSign) {
7866+
if (val == null || val.trim() === '') {
78797867
this.current('');
78807868
return this.props.onChange(null);
78817869
}
78827870

7883-
if (this.isFlushable(number, val)) {
7884-
if (number !== this.props.value) return this.props.onChange(number);else this.setState(this.getDefaultState()); // 5. -> 5
7871+
if (!isIntermediate) {
7872+
if (number !== this.props.value) {
7873+
return this.props.onChange(number);
7874+
}
7875+
} else {
7876+
this.current(e.target.value);
78857877
}
7886-
7887-
if (number < this.props.min || atSign && startingWithSign || this.isAtDelimiter(number, val)) this.current(e.target.value);
78887878
},
78897879
_finish: function _finish() {
78907880
var str = this.state.stringValue,
78917881
number = this._parse(str);
78927882

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

79097902
return strVal;
79107903
},
7911-
isFlushable: function isFlushable(num, str) {
7912-
return this.isValid(num) && !this.isAtDelimiter(num, str) && !this.isSign(str);
7904+
isIntermediateValue: function isIntermediateValue(num, str) {
7905+
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str));
79137906
},
79147907
isSign: function isSign(val) {
79157908
return (val || '').trim() === '-';
79167909
},
7910+
isPaddedZeros: function isPaddedZeros(str) {
7911+
var localeChar = _localizers.number.decimalChar(null, this.props.culture);
7912+
7913+
var _str$split = str.split(localeChar);
7914+
7915+
var _ = _str$split[0];
7916+
var decimals = _str$split[1];
7917+
7918+
7919+
return !!(decimals && decimals.match(/0+$/));
7920+
},
79177921
isAtDelimiter: function isAtDelimiter(num, str) {
79187922
var props = arguments.length <= 2 || arguments[2] === undefined ? this.props : arguments[2];
79197923

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

7924-
if (str.length <= 1) return false;
7928+
if (str.length < 1) return false;
79257929

79267930
char = str[lastIndex];
79277931

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

79357939

79367940
//this intermediate state is for when one runs into the decimal or are typing the number
7937-
current: function current(val) {
7938-
this.setState({ stringValue: val });
7941+
current: function current(stringValue) {
7942+
this.setState({ stringValue: stringValue });
79397943
}
79407944
});
79417945
module.exports = exports['default'];

docs/public/docs.js

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/public/rw-widgets.eot

5.68 KB
Binary file not shown.

docs/public/rw-widgets.svg

Lines changed: 18 additions & 0 deletions
Loading

docs/public/rw-widgets.ttf

5.51 KB
Binary file not shown.

docs/public/vendor.bundle.js

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/NumberInput.js

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ exports.default = _react2.default.createClass({
5252
decimal = _localizers.number.decimalChar(null, props.culture),
5353
format = getFormat(props);
5454

55-
this._beginningWithSign = false;
56-
5755
if (value == null || isNaN(props.value)) value = '';else value = props.editing ? ('' + value).replace('.', decimal) : _localizers.number.format(value, format, props.culture);
5856

5957
return {
@@ -74,48 +72,43 @@ exports.default = _react2.default.createClass({
7472
className: 'rw-input',
7573
onChange: this._change,
7674
onBlur: this._finish,
77-
onKeyPress: this._typing,
7875
'aria-disabled': this.props.disabled,
7976
'aria-readonly': this.props.readOnly,
8077
disabled: this.props.disabled,
8178
readOnly: this.props.readOnly,
8279
placeholder: this.props.placeholder,
83-
value: value }));
84-
},
85-
_typing: function _typing(e) {
86-
var current = e.target.value,
87-
newVal = e.key;
88-
89-
this._beginningWithSign = current.trim() === '' && this.isSign(newVal);
90-
91-
this.props.onKeyPress && this.props.onKeyPress(e);
80+
value: value
81+
}));
9282
},
9383
_change: function _change(e) {
9484
var val = e.target.value,
95-
number = this._parse(e.target.value),
96-
atSign = this.isSign(val.trim()),
97-
startingWithSign = this._beginningWithSign;
85+
number = this._parse(e.target.value);
9886

99-
this._beginningWithSign = false;
87+
var isIntermediate = this.isIntermediateValue(number, val);
10088

101-
if (val == null || val.trim() === '' || atSign && !startingWithSign) {
89+
if (val == null || val.trim() === '') {
10290
this.current('');
10391
return this.props.onChange(null);
10492
}
10593

106-
if (this.isFlushable(number, val)) {
107-
if (number !== this.props.value) return this.props.onChange(number);else this.setState(this.getDefaultState()); // 5. -> 5
94+
if (!isIntermediate) {
95+
if (number !== this.props.value) {
96+
return this.props.onChange(number);
97+
}
98+
} else {
99+
this.current(e.target.value);
108100
}
109-
110-
if (number < this.props.min || atSign && startingWithSign || this.isAtDelimiter(number, val)) this.current(e.target.value);
111101
},
112102
_finish: function _finish() {
113103
var str = this.state.stringValue,
114104
number = this._parse(str);
115105

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

132125
return strVal;
133126
},
134-
isFlushable: function isFlushable(num, str) {
135-
return this.isValid(num) && !this.isAtDelimiter(num, str) && !this.isSign(str);
127+
isIntermediateValue: function isIntermediateValue(num, str) {
128+
return !!(num < this.props.min || this.isSign(str) || this.isAtDelimiter(num, str) || this.isPaddedZeros(str));
136129
},
137130
isSign: function isSign(val) {
138131
return (val || '').trim() === '-';
139132
},
133+
isPaddedZeros: function isPaddedZeros(str) {
134+
var localeChar = _localizers.number.decimalChar(null, this.props.culture);
135+
136+
var _str$split = str.split(localeChar);
137+
138+
var _ = _str$split[0];
139+
var decimals = _str$split[1];
140+
141+
142+
return !!(decimals && decimals.match(/0+$/));
143+
},
140144
isAtDelimiter: function isAtDelimiter(num, str) {
141145
var props = arguments.length <= 2 || arguments[2] === undefined ? this.props : arguments[2];
142146

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

147-
if (str.length <= 1) return false;
151+
if (str.length < 1) return false;
148152

149153
char = str[lastIndex];
150154

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

158162

159163
//this intermediate state is for when one runs into the decimal or are typing the number
160-
current: function current(val) {
161-
this.setState({ stringValue: val });
164+
current: function current(stringValue) {
165+
this.setState({ stringValue: stringValue });
162166
}
163167
});
164168
module.exports = exports['default'];

0 commit comments

Comments
 (0)