TermEditInner.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { useIntl } from "react-intl";
  2. import {
  3. ProForm,
  4. ProFormSelect,
  5. ProFormText,
  6. ProFormTextArea,
  7. } from "@ant-design/pro-components";
  8. import LangSelect from "../general/LangSelect";
  9. import { DefaultOptionType } from "antd/lib/select";
  10. interface IWidget {
  11. meaningList?: string[];
  12. channelList?: DefaultOptionType[];
  13. }
  14. const Widget = ({ meaningList, channelList }: IWidget) => {
  15. const intl = useIntl();
  16. return (
  17. <>
  18. <ProForm.Group>
  19. <ProFormText
  20. width="md"
  21. name="word"
  22. required
  23. label={intl.formatMessage({
  24. id: "term.fields.word.label",
  25. })}
  26. rules={[
  27. {
  28. required: true,
  29. message: intl.formatMessage({
  30. id: "term.message.meaning.required",
  31. }),
  32. },
  33. ]}
  34. fieldProps={{
  35. showCount: true,
  36. maxLength: 128,
  37. }}
  38. />
  39. <ProFormText
  40. width="md"
  41. name="tag"
  42. tooltip={intl.formatMessage({
  43. id: "term.fields.description.tooltip",
  44. })}
  45. label={intl.formatMessage({
  46. id: "term.fields.description.label",
  47. })}
  48. />
  49. </ProForm.Group>
  50. <ProForm.Group>
  51. <ProFormText
  52. width="md"
  53. name="meaning"
  54. tooltip={intl.formatMessage({
  55. id: "term.fields.meaning.tooltip",
  56. })}
  57. label={intl.formatMessage({
  58. id: "forms.fields.meaning.label",
  59. })}
  60. rules={[
  61. {
  62. required: true,
  63. message: intl.formatMessage({
  64. id: "forms.message.meaning.required",
  65. }),
  66. },
  67. ]}
  68. fieldProps={{
  69. showCount: true,
  70. maxLength: 128,
  71. }}
  72. />
  73. <ProFormSelect
  74. width="md"
  75. name="meaning2"
  76. label={intl.formatMessage({
  77. id: "term.fields.meaning2.label",
  78. })}
  79. options={meaningList}
  80. fieldProps={{
  81. mode: "tags",
  82. tokenSeparators: [",", ","],
  83. }}
  84. placeholder="Please select other meanings"
  85. rules={[
  86. {
  87. type: "array",
  88. },
  89. ]}
  90. />
  91. </ProForm.Group>
  92. <ProForm.Group>
  93. <ProFormText
  94. width="md"
  95. name="channel"
  96. tooltip={intl.formatMessage({
  97. id: "term.fields.channel.tooltip",
  98. })}
  99. label={intl.formatMessage({
  100. id: "term.fields.channel.label",
  101. })}
  102. />
  103. <LangSelect />
  104. </ProForm.Group>
  105. <ProForm.Group>
  106. <ProFormTextArea
  107. name="note"
  108. width="xl"
  109. label={intl.formatMessage({
  110. id: "forms.fields.note.label",
  111. })}
  112. />
  113. </ProForm.Group>
  114. </>
  115. );
  116. };
  117. export default Widget;