ZoneFormFields.jsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import React from "react";
  2. import { useTranslation } from "react-i18next";
  3. import { Field } from "react-final-form";
  4. import Label from "../../components/ui/formUtils/Label";
  5. import Hint from "../../components/ui/formUtils/Hint";
  6. import ActionsField from "./ActionsField";
  7. import actionMap from "../actionMap";
  8. const interactions = ["reveal", "hide", "revealSelf", "stack"];
  9. const Form = ({ initialValues }) => {
  10. const { t } = useTranslation();
  11. return (
  12. <>
  13. <Label>
  14. {t("Label")}
  15. <Field
  16. name="label"
  17. component="input"
  18. initialValue={initialValues.label}
  19. />
  20. </Label>
  21. <Label>
  22. {t("Width")}
  23. <Field
  24. name="width"
  25. component="input"
  26. initialValue={initialValues.width}
  27. >
  28. {(props) => <input {...props.input} type="number" />}
  29. </Field>
  30. </Label>
  31. <Label>
  32. {t("Height")}
  33. <Field
  34. name="height"
  35. component="input"
  36. initialValue={initialValues.height}
  37. >
  38. {(props) => <input {...props.input} type="number" />}
  39. </Field>
  40. </Label>
  41. <h3>{t("Interactions")}</h3>
  42. <Hint>{t("Interaction help")}</Hint>
  43. <Label>
  44. <Field name="onItem" initialValue={initialValues.onItem}>
  45. {({ input: { onChange, value } }) => (
  46. <ActionsField
  47. onChange={onChange}
  48. value={value}
  49. availableActions={interactions}
  50. actionMap={actionMap}
  51. />
  52. )}
  53. </Field>
  54. </Label>
  55. </>
  56. );
  57. };
  58. export default Form;