redux-form-react-submitbutton
A submit button for redux-form that dynamically changes based on the current redux-form state.
Demo
https://deedmob.github.io/redux-form-react-submitbutton/example/
Installing
yarn add redux-form-react-submitbutton
npm install redux-form-react-submitbutton
Example usage
@reduxForm({
form: 'account'
})
class AccountForm extends React.Component {
render(){
<form>
<Field name="email" component={TextInput} />
<SubmitButton />
</form>
}
}
Props
There are no required props
static defaultProps = {
className: 'btn',
disabledClassName: 'btn-outline',
successClassName: 'btn-success',
errorClassName: 'btn-danger',
okClassName: 'btn-primary',
submittingClassName: 'btn-default',
invalidClassName: 'btn-warning',
syncErrorClassName: 'alert alert-danger',
labelErrorAlert: 'Please double-check that these fields are correct and try again',
buttonStyles: {},
translateKeys: key => key,
showErrors: true,
asyncStatusDuration: 2000,
type: 'Submit',
labelSubmitting: '...Submitting',
labelSubmitFailed: 'Submission error',
labelSubmitSucceeded: 'Success!',
labelInvalid: 'Invalid',
labelSubmit: 'Submit',
labelUpdate: 'Save Changes',
labelPost: 'Post',
labelCreate: 'Create',
iconStyles: { marginRight: '5px' },
showIcons: true,
iconSubmit: 'fa fa-paper-plane-o',
iconUpdate: 'fa fa-floppy-o',
iconPost: 'fa fa-rocket',
iconCreate: 'fa fa-plus',
iconError: 'fa fa-times',
iconWarning: 'fa fa-warning',
iconSubmitting: 'fa fa-spinner fa-pulse fa-fw',
iconSuccess: 'fa fa-check'
}
static propTypes = {
asyncStatusDuration: PropTypes.number,
type: PropTypes.oneOf(['Create', 'Post', 'Update', 'Submit']),
showIcons: PropTypes.bool,
iconSubmit: PropTypes.string,
iconUpdate: PropTypes.string,
iconPost: PropTypes.string,
iconCreate: PropTypes.string,
iconError: PropTypes.string,
iconWarning: PropTypes.string,
iconSubmitting: PropTypes.string,
iconSuccess: PropTypes.string,
translateKeys: PropTypes.func,
labelErrorAlert: PropTypes.string,
showErrors: PropTypes.bool,
className: PropTypes.string,
syncErrorClassName: PropTypes.string,
disabledClassName: PropTypes.string,
successClassName: PropTypes.string,
errorClassName: PropTypes.string,
okClassName: PropTypes.string,
invalidClassName: PropTypes.string,
submittingClassName: PropTypes.string,
buttonStyles: PropTypes.object,
iconStyles: PropTypes.object,
syncErrors: PropTypes.object.isRequired,
syncWarnings: PropTypes.object.isRequired,
submitting: PropTypes.bool.isRequired,
submitFailed: PropTypes.bool.isRequired,
submitSucceeded: PropTypes.bool.isRequired,
invalid: PropTypes.bool.isRequired,
pristine: PropTypes.bool.isRequired,
labelSubmitting: PropTypes.string,
labelSubmit: PropTypes.string,
labelUpdate: PropTypes.string,
labelPost: PropTypes.string,
labelCreate: PropTypes.string,
labelInvalid: PropTypes.string,
labelSubmitFailed: PropTypes.string,
labelSubmitSucceeded: PropTypes.string
}
Testing
yarn run test
TODOS
Suggested usage
Import this library and create your own React Component that wraps it, and passes in your configuration options or internationalization library. Then export that Component and use the new Component in all your forms.