CubeFormFields.jsx 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from "react";
  2. import { useTranslation } from "react-i18next";
  3. import { Field } from "react-final-form";
  4. import Label from "../../../ui/formUtils/Label";
  5. import ColorPicker from "../../../ui/formUtils/ColorPicker";
  6. const Form = ({ initialValues }) => {
  7. const { t } = useTranslation();
  8. return (
  9. <>
  10. <Label>
  11. {t("Label")}
  12. <Field
  13. name="label"
  14. component="input"
  15. initialValue={initialValues.label}
  16. />
  17. </Label>
  18. <Label>
  19. {t("Size")}
  20. <Field name="size" component="input" initialValue={initialValues.size}>
  21. {(props) => <input {...props.input} type="number" />}
  22. </Field>
  23. </Label>
  24. <Label>
  25. {t("Color")}
  26. <Field
  27. name="color"
  28. component="input"
  29. initialValue={initialValues.color}
  30. >
  31. {({ input: { onChange, value } }) => (
  32. <ColorPicker value={value} onChange={onChange} />
  33. )}
  34. </Field>
  35. </Label>
  36. </>
  37. );
  38. };
  39. export default Form;