Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import React from "react";
  2. import fp from "lodash/fp";
  3. import { bool, func, node, number, object, string } from "prop-types";
  4. import { Field } from "redux-form";
  5. import { TextField } from "material-ui";
  6.  
  7. TextFieldComponent.propTypes = {
  8. meta: object,
  9. input: object,
  10. parseOnBlur: func
  11. };
  12. TextFieldComponent.defaultProps = { parseOnBlur: fp.identity };
  13.  
  14. export function TextFieldComponent({ input, meta, parseOnBlur, ...custom }) {
  15. return (
  16. <TextField
  17. {...input}
  18. {...custom}
  19. errorText={!meta.active && meta.touched && meta.error}
  20. onBlur={fp.flow(fp.get("target.value"), parseOnBlur, input.onBlur)}
  21. />
  22. );
  23. }
  24.  
  25. FormTextField.propTypes = {
  26. parse: func,
  27. format: func,
  28. validate: func,
  29. parseOnBlur: func,
  30. name: string.isRequired,
  31.  
  32. type: string,
  33. readOnly: bool,
  34. disabled: bool,
  35.  
  36. fullWidth: bool,
  37. multiLine: bool,
  38.  
  39. hintText: node,
  40. floatingLabelText: node,
  41. rows: number,
  42. rowsMax: number
  43. };
  44.  
  45. export default function FormTextField(props) {
  46. return <Field {...props} component={TextFieldComponent} />;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement