Skip to content

Commit d1c551d

Browse files
committed
Updated release to v1.0.8 with fix for Input labels mapping to input id.
1 parent 8e2205e commit d1c551d

6 files changed

Lines changed: 22 additions & 10 deletions

File tree

dist/ReactstrapFormikInput.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
1+
function _objectWithoutProperties(obj, keys) {
2+
var target = {};
3+
for (var i in obj) {
4+
if (keys.indexOf(i) >= 0) continue;
5+
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
6+
target[i] = obj[i];
7+
}
8+
return target;
9+
}
210

311
import React from 'react';
4-
import { FormFeedback, FormGroup, Input, Label } from "reactstrap";
12+
import {FormFeedback, FormGroup, Input, Label} from "reactstrap";
513

614
var ReactstarpFormikInput = function ReactstarpFormikInput(_ref) {
715
var fields = _objectWithoutProperties(_ref.field, []),
@@ -16,7 +24,7 @@ var ReactstarpFormikInput = function ReactstarpFormikInput(_ref) {
1624
null,
1725
React.createElement(
1826
Label,
19-
{ "for": fields.name, className: "label-color" },
27+
{"for": props.id, className: "label-color"},
2028
props.label
2129
),
2230
React.createElement(Input, Object.assign({}, props, fields, { invalid: Boolean(touched[fields.name] && errors[fields.name]) })),

dist/ReactstrapSelectInput.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ var ReactstrapSelectInput = function ReactstrapSelectInput(_ref) {
3838
null,
3939
React.createElement(
4040
Label,
41-
{ "for": field.name, className: "label-color" },
41+
{"for": props.inputprops.id, className: "label-color"},
4242
props.label
4343
),
4444
React.createElement(
4545
Input,
46-
Object.assign({}, field, props, { type: "select", invalid: Boolean(touched[field.name] && errors[field.name]),
46+
Object.assign({id: props.inputprops.id}, field, props, {
47+
type: "select", invalid: Boolean(touched[field.name] && errors[field.name]),
4748
placeholder: "Test" }),
4849
React.createElement(
4950
"option",

src/components/ReactstrapFormikInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const ReactstarpFormikInput = (
88
...props
99
}) => (
1010
<FormGroup>
11-
<Label for={fields.name} className={"label-color"}>{props.label}</Label>
11+
<Label for={props.id} className={"label-color"}>{props.label}</Label>
1212
<Input {...props} {...fields} invalid={Boolean(touched[fields.name] && errors[fields.name])}/>
1313
{touched[fields.name] && errors[fields.name] ? <FormFeedback>{errors[fields.name]}</FormFeedback> : ''}
1414
</FormGroup>

src/components/ReactstrapSelectInput.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ const ReactstrapSelectInput = ({
2121
let touch = touched[field.name];
2222
return (
2323
<FormGroup>
24-
<Label for={field.name} className={"label-color"}>{props.label}</Label>
25-
<Input {...field} {...props} type="select" invalid={Boolean(touched[field.name] && errors[field.name])}
24+
<Label for={props.inputprops.id} className={"label-color"}>{props.label}</Label>
25+
<Input id={props.inputprops.id} {...field} {...props} type="select"
26+
invalid={Boolean(touched[field.name] && errors[field.name])}
2627
placeholder="Test">
2728
<option value="">{props.inputprops.defaultOption}</option>
2829
{props.inputprops.options.map((option, index) => {

src/stories/InputStory.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default () => (
3939
label="Email"
4040
name="email"
4141
component={TextField}
42+
id="email"
4243
/>
4344
</Col>
4445
<Col xs="12">
@@ -47,6 +48,7 @@ export default () => (
4748
label="Password"
4849
name="password"
4950
component={TextField}
51+
id="password"
5052
/>
5153
</Col>
5254
<Col xs="12">

src/stories/SelectStory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export default () => (
4848
name="prefilled_country"
4949
component={SelectInput}
5050
inputprops={{
51-
name: 'country',
52-
id: 'country',
51+
name: 'prefilled_country',
52+
id: 'prefilled_country',
5353
options: ['India', 'USA', 'UK', 'Saudi Arabia'],
5454
defaultOption: "Country"
5555
}}>

0 commit comments

Comments
 (0)