index.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import { createSchemaField } from '@formily/react';
  2. import { FormGrid, FormItem, Input } from '@formily/antd';
  3. import type { ISchema } from '@formily/json-schema';
  4. const BooleanParam = () => {
  5. const SchemaField = createSchemaField({
  6. components: {
  7. FormItem,
  8. Input,
  9. FormGrid,
  10. },
  11. });
  12. const schema: ISchema = {
  13. type: 'object',
  14. properties: {
  15. config: {
  16. 'x-component': 'FormGrid',
  17. 'x-component-props': {
  18. maxColumns: 2,
  19. minColumns: 2,
  20. },
  21. type: 'void',
  22. properties: {
  23. trueText: {
  24. 'x-decorator': 'FormItem',
  25. 'x-component': 'Input',
  26. default: '是',
  27. 'x-decorator-props': {
  28. gridSpan: 1,
  29. },
  30. 'x-component-props': {
  31. placeholder: 'trueText',
  32. },
  33. },
  34. trueValue: {
  35. title: '-',
  36. 'x-decorator': 'FormItem',
  37. 'x-component': 'Input',
  38. default: true,
  39. 'x-decorator-props': {
  40. gridSpan: 1,
  41. colon: false,
  42. },
  43. 'x-component-props': {
  44. placeholder: 'trueValue',
  45. },
  46. },
  47. falseText: {
  48. 'x-decorator': 'FormItem',
  49. 'x-component': 'Input',
  50. default: '否',
  51. 'x-decorator-props': {
  52. gridSpan: 1,
  53. },
  54. 'x-component-props': {
  55. placeholder: 'falseText',
  56. },
  57. },
  58. falseValue: {
  59. 'x-decorator': 'FormItem',
  60. 'x-component': 'Input',
  61. default: false,
  62. title: '-',
  63. 'x-decorator-props': {
  64. gridSpan: 1,
  65. colon: false,
  66. },
  67. 'x-component-props': {
  68. placeholder: 'falseValue',
  69. },
  70. },
  71. },
  72. },
  73. },
  74. };
  75. return <SchemaField schema={schema} />;
  76. };
  77. export default BooleanParam;