Skip to content

Commit ca315d4

Browse files
committed
Working Release v1.0.4
1 parent 3ef8b58 commit ca315d4

7 files changed

Lines changed: 143 additions & 7 deletions

File tree

dist/ReactstrapFormikInput.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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; }
2+
3+
import React from 'react';
4+
import { FormFeedback, FormGroup, Input, Label } from "reactstrap";
5+
6+
var ReactstarpFormikInput = function ReactstarpFormikInput(_ref) {
7+
var fields = _objectWithoutProperties(_ref.field, []),
8+
_ref$form = _ref.form,
9+
touched = _ref$form.touched,
10+
errors = _ref$form.errors,
11+
rest = _objectWithoutProperties(_ref$form, ["touched", "errors"]),
12+
props = _objectWithoutProperties(_ref, ["field", "form"]);
13+
14+
return React.createElement(
15+
FormGroup,
16+
null,
17+
React.createElement(
18+
Label,
19+
{ "for": fields.name, className: "label-color" },
20+
props.label
21+
),
22+
React.createElement(Input, Object.assign({}, props, fields, { invalid: Boolean(touched[fields.name] && errors[fields.name]) })),
23+
touched[fields.name] && errors[fields.name] ? React.createElement(
24+
FormFeedback,
25+
null,
26+
errors[fields.name]
27+
) : ''
28+
);
29+
};
30+
export default ReactstarpFormikInput;

dist/ReactstrapRadioInput.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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; }
2+
3+
import * as React from 'react';
4+
import { FormGroup, Input, Label } from "reactstrap";
5+
6+
var ReactstrapRadioInput = function ReactstrapRadioInput(_ref) {
7+
var field = _ref.field,
8+
_ref$form = _ref.form,
9+
isSubmitting = _ref$form.isSubmitting,
10+
setFieldValue = _ref$form.setFieldValue,
11+
touched = _ref$form.touched,
12+
errors = _ref$form.errors,
13+
values = _ref$form.values,
14+
_ref$disabled = _ref.disabled,
15+
disabled = _ref$disabled === undefined ? false : _ref$disabled,
16+
props = _objectWithoutProperties(_ref, ["field", "form", "disabled"]);
17+
18+
return React.createElement(
19+
FormGroup,
20+
{ check: true, inline: true },
21+
React.createElement(
22+
Label,
23+
{ "for": "inp" },
24+
React.createElement(Input, { type: "radio", name: field.name, checked: values[field.name] === field.value, value: field.value,
25+
onChange: function onChange(event, value) {
26+
return setFieldValue(field.name, field.value);
27+
} }),
28+
props.label
29+
)
30+
);
31+
};
32+
33+
export default ReactstrapRadioInput;

dist/ReactstrapSelectInput.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
var _this = this;
2+
3+
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; }
4+
5+
import * as React from 'react';
6+
import { FormGroup, Input, Label } from "reactstrap";
7+
8+
var handleBlur = function handleBlur(event) {
9+
if (_this.ignoreNextBlur === true) {
10+
// The parent components are relying on the bubbling of the event.
11+
event.stopPropagation();
12+
_this.ignoreNextBlur = false;
13+
event.target.name = _this.props.name;
14+
return;
15+
}
16+
};
17+
18+
var ReactstrapSelectInput = function ReactstrapSelectInput(_ref) {
19+
var field = _ref.field,
20+
_ref$form = _ref.form,
21+
isSubmitting = _ref$form.isSubmitting,
22+
touched = _ref$form.touched,
23+
errors = _ref$form.errors,
24+
_ref$disabled = _ref.disabled,
25+
disabled = _ref$disabled === undefined ? false : _ref$disabled,
26+
props = _objectWithoutProperties(_ref, ["field", "form", "disabled"]);
27+
28+
var error = errors[field.name];
29+
var touch = touched[field.name];
30+
return React.createElement(
31+
FormGroup,
32+
null,
33+
React.createElement(
34+
Label,
35+
{ "for": field.name, className: "label-color" },
36+
props.inputprops.label
37+
),
38+
React.createElement(
39+
Input,
40+
Object.assign({}, field, props, { type: "select", invalid: Boolean(touched[field.name] && errors[field.name]),
41+
onBlur: handleBlur(), placeholder: "Test" }),
42+
React.createElement(
43+
"option",
44+
{ value: "" },
45+
props.inputprops.label
46+
),
47+
props.inputprops.options.map(function (option, index) {
48+
if (option.name) return React.createElement(
49+
"option",
50+
{ value: option.id, key: index },
51+
option.name
52+
);
53+
return React.createElement(
54+
"option",
55+
{ value: option, key: index },
56+
option
57+
);
58+
})
59+
),
60+
touch && error && React.createElement(
61+
"p",
62+
null,
63+
error
64+
)
65+
);
66+
};
67+
68+
export default ReactstrapSelectInput;

dist/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import ReactstrapInput from './ReactstrapFormikInput';
2+
import ReactstrapRadio from './ReactstrapRadioInput';
3+
import ReactstrapSelect from './ReactstrapSelectInput';
4+
5+
export { ReactstrapInput, ReactstrapRadio, ReactstrapSelect };

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactstrap-formik",
3-
"version": "1.0.1",
3+
"version": "1.0.4",
44
"dependencies": {
55
"bootstrap": "^4.1.3",
66
"formik": "^1.3.0",

src/components/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import ReactstrapInput from './ReactstrapFormikInput';
2+
import ReactstrapRadio from './ReactstrapRadioInput';
3+
import ReactstrapSelect from './ReactstrapSelectInput';
4+
5+
6+
export {ReactstrapInput, ReactstrapRadio, ReactstrapSelect};

src/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)