input.tsx 742 B

123456789101112131415161718192021
  1. import { IFlowNodeParameter } from '@/types/flow';
  2. import { convertKeysToCamelCase } from '@/utils/flow';
  3. import * as Icons from '@ant-design/icons';
  4. import { Input } from 'antd';
  5. const getIconComponent = (iconString: string) => {
  6. const match = iconString.match(/^icon:(\w+)$/);
  7. if (match) {
  8. const iconName = match[1] as keyof typeof Icons;
  9. const IconComponent = Icons[iconName];
  10. return IconComponent ? <IconComponent /> : null;
  11. }
  12. return null;
  13. };
  14. export const renderInput = (data: IFlowNodeParameter) => {
  15. const attr = convertKeysToCamelCase(data.ui?.attr || {});
  16. attr.prefix = getIconComponent(data.ui?.attr?.prefix || '');
  17. return <Input {...attr} className='w-full' placeholder='please input' allowClear />;
  18. };