react-polymorph
Advanced tools
Comparing version 0.2.6 to 0.2.7
Changelog | ||
========= | ||
## 0.2.7 | ||
### Fixes | ||
- fixed storybook webpack config | ||
- fixed caret position logic in numeric input | ||
- fixed selection stealing bug found in Daedalus | ||
## 0.2.6 | ||
@@ -5,0 +13,0 @@ |
@@ -68,3 +68,4 @@ 'use strict'; | ||
if (disabled) return; | ||
if (onChange) onChange(_this._processValue(event.target.value, event.target.selectionStart, {}), event); | ||
var processedValue = _this._processValue(event.target.value, event.target.selectionStart, {}); | ||
if (onChange) onChange(processedValue, event); | ||
}, _this.focus = function () { | ||
@@ -78,3 +79,3 @@ return _this.skinParts[NumericInput.SKIN_PARTS.INPUT].focus(); | ||
_createClass(NumericInput, [{ | ||
key: 'componentWillReceiveProps', | ||
key: 'componentDidMount', | ||
@@ -84,3 +85,3 @@ | ||
value: function componentWillReceiveProps(nextProps) { | ||
value: function componentDidMount() { | ||
// Set last input caret position on updates | ||
@@ -94,2 +95,3 @@ var input = this.skinParts[NumericInput.SKIN_PARTS.INPUT]; | ||
var input = this.skinParts[NumericInput.SKIN_PARTS.INPUT]; | ||
if (input !== document.activeElement) return; | ||
@@ -142,6 +144,6 @@ // caret position calculation after separators injection | ||
var splitedOldValue = lastValidValue.split('.'); | ||
if (splitedOldValue[0].length <= splitedValue[0].length) { | ||
var beforeDot = splitedValue[0] + splitedValue[1]; | ||
if (splitedOldValue[0].length < beforeDot.length) { | ||
// dot is in decimal part | ||
position = position - 1; | ||
var beforeDot = splitedValue[0] + splitedValue[1]; | ||
position -= 1; | ||
handledValue = beforeDot + '.' + splitedValue[2]; | ||
@@ -155,2 +157,6 @@ beforeDot = beforeDot.replace(/,/g, ''); | ||
handledValue = splitedValue[0] + '.' + splitedValue[1] + splitedValue[2]; | ||
// Second dot was entered after current one -> stay in same position (swallow dot) | ||
if (position > beforeDot.length + 1) { | ||
position -= 1; | ||
} | ||
} | ||
@@ -276,3 +282,4 @@ } else if (splitedValue.length === 2 && splitedValue[0] === '' && splitedValue[1] === '') { | ||
var separatedValue = splitedValue[0].replace(/,/g, '').split('').reverse().join('').replace(/(\d{3}\B)/g, '$1,').split('').reverse().join(''); | ||
this.setState({ separatorsCount: (separatedValue.match(/,/g) || []).length }); | ||
var newSeparatorsCount = (separatedValue.match(/,/g) || []).length; | ||
this.setState({ separatorsCount: newSeparatorsCount }); | ||
return separatedValue + '.' + splitedValue[1]; | ||
@@ -279,0 +286,0 @@ } |
{ | ||
"name": "react-polymorph", | ||
"description": "React components with highly customizable logic, markup and styles.", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"author": { | ||
@@ -91,4 +91,4 @@ "name": "Dominik Guzei", | ||
"scripts": { | ||
"js": "babel source --no-babelrc -d lib -s --presets=env,react --plugins=transform-flow-strip-types,transform-decorators-legacy,transform-class-properties,lodash", | ||
"build": "cross-env npm run js && npm run sass", | ||
"js": "babel source -d lib -s --no-babelrc --presets=env,react --plugins=transform-flow-strip-types,transform-decorators-legacy,transform-class-properties,lodash", | ||
"build": "cross-env npm run clean && npm run js && npm run sass", | ||
"clean": "rimraf ./lib", | ||
@@ -95,0 +95,0 @@ "prebuild": "npm run clean", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
264858
79
1893