node.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import type { FC } from 'react'
  2. import React from 'react'
  3. import { useTranslation } from 'react-i18next'
  4. import InputVarTypeIcon from '../_base/components/input-var-type-icon'
  5. import type { StartNodeType } from './types'
  6. import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
  7. import type { NodeProps } from '@/app/components/workflow/types'
  8. const i18nPrefix = 'workflow.nodes.start'
  9. const Node: FC<NodeProps<StartNodeType>> = ({
  10. data,
  11. }) => {
  12. const { t } = useTranslation()
  13. const { variables } = data
  14. if (!variables.length)
  15. return null
  16. return (
  17. <div className='mb-1 px-3 py-1'>
  18. <div className='space-y-0.5'>
  19. {variables.map(variable => (
  20. <div key={variable.variable} className='flex items-center h-6 justify-between bg-gray-100 rounded-md px-1 space-x-1 text-xs font-normal text-gray-700'>
  21. <div className='w-0 grow flex items-center space-x-1'>
  22. <Variable02 className='shrink-0 w-3.5 h-3.5 text-primary-500' />
  23. <span className='w-0 grow truncate text-xs font-normal text-gray-700'>{variable.variable}</span>
  24. </div>
  25. <div className='ml-1 flex items-center space-x-1'>
  26. {variable.required && <span className='text-xs font-normal text-gray-500 uppercase'>{t(`${i18nPrefix}.required`)}</span>}
  27. <InputVarTypeIcon type={variable.type} className='w-3 h-3 text-gray-500' />
  28. </div>
  29. </div>
  30. ))}
  31. </div>
  32. </div>
  33. )
  34. }
  35. export default React.memo(Node)