ZoneFormFields.jsx 1.6 KB

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