Skip to content

Commit aa480c8

Browse files
author
PatrickSachs
committed
1 parent dd9e84f commit aa480c8

File tree

4 files changed

+68
-42
lines changed

4 files changed

+68
-42
lines changed

packages/bulma/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this library will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this library adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 2.0.1
8+
9+
* TextFields in `number` mode now return parsed floats if possible @PatrickSachs.
10+
* Removed core inputs, use normal ones instead @PatrickSachs.
11+
12+
## 2.0.0
13+
14+
* Updated core to version 2 @PatrickSachs.
15+
716
## 1.0.2
817

918
* TagLists have a new prop `limit` that determines the maximum amount of tags that can be added @PatrickSachs.

packages/bulma/package-lock.json

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

packages/bulma/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-formilicious/bulma",
3-
"version": "1.0.2",
3+
"version": "2.0.1",
44
"description": "react-formilicious for the Bulma CSS framework. 🎨",
55
"author": "PatrickSachs",
66
"license": "MIT",
@@ -14,7 +14,7 @@
1414
"pack": "create-react-prototype pack"
1515
},
1616
"peerDependencies": {
17-
"@react-formilicious/core": "^1.0.0",
17+
"@react-formilicious/core": "^2.0.0",
1818
"react": ">=16.2.0",
1919
"react-dom": ">=16.2.0"
2020
},

packages/bulma/src/TextField/index.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@ export default class TextField extends React.Component {
66
return "";
77
}
88

9+
constructor(p) {
10+
super(p);
11+
this.onChange = this.onChange.bind(this);
12+
}
13+
914
getType(mode) {
10-
switch(mode) {
15+
switch (mode) {
1116
case "datetime": return "datetime-local";
1217
case undefined: return "text";
1318
default: return mode;
1419
}
1520
}
1621

22+
onChange(e) {
23+
let value = e.target.value;
24+
if (this.props.mode === "number") {
25+
// Try to parse number
26+
const parsed = Number.parseFloat(value);
27+
if (!Number.isNaN(parsed)) {
28+
value = parsed;
29+
}
30+
}
31+
this.props.onChange(value);
32+
}
33+
1734
render() {
1835
const {
1936
name, mode, placeholder, step,
2037
field: { validated, message },
2138
system: { waiting },
22-
onChange, value
39+
value
2340
} = this.props;
2441

2542
return (
@@ -28,7 +45,7 @@ export default class TextField extends React.Component {
2845
<div className="contol">
2946
<input
3047
className="input"
31-
onChange={e => onChange(e.target.value)}
48+
onChange={this.onChange}
3249
type={this.getType(mode)}
3350
disabled={waiting}
3451
value={value}

0 commit comments

Comments
 (0)