AnchorFormFields.jsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. import Hint from "../../ui/formUtils/Hint";
  7. const Form = ({ initialValues }) => {
  8. const { t } = useTranslation();
  9. return (
  10. <>
  11. <Label>
  12. {t("Label")}
  13. <Field
  14. name="text"
  15. component="input"
  16. initialValue={initialValues.text}
  17. />
  18. </Label>
  19. <Label>
  20. {t("Snap families")}
  21. <Field
  22. name="families"
  23. component="input"
  24. format={(val) => val && val.join(",")}
  25. parse={(val) => val && val.split(",").map((v) => v.trim())}
  26. initialValue={initialValues.families || []}
  27. />
  28. <Hint>
  29. {t(
  30. "Let this field empty to snap all items, " +
  31. "or set a comma separated list of families that will be snapped."
  32. )}
  33. </Hint>
  34. </Label>
  35. <Label>
  36. {t("Color")}
  37. <Field
  38. name="color"
  39. component="input"
  40. initialValue={initialValues.color || "#CCC"}
  41. >
  42. {({ input: { onChange, value } }) => (
  43. <ColorPicker value={value} onChange={onChange} />
  44. )}
  45. </Field>
  46. </Label>
  47. </>
  48. );
  49. };
  50. export default Form;