node-variable-item.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { memo } from 'react'
  2. import cn from 'classnames'
  3. import { VarBlockIcon } from '@/app/components/workflow/block-icon'
  4. import { Line3 } from '@/app/components/base/icons/src/public/common'
  5. import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
  6. import type { Node } from '@/app/components/workflow/types'
  7. import { BlockEnum } from '@/app/components/workflow/types'
  8. type NodeVariableItemProps = {
  9. node: Node
  10. varName: string
  11. showBorder?: boolean
  12. }
  13. const NodeVariableItem = ({
  14. node,
  15. varName,
  16. showBorder,
  17. }: NodeVariableItemProps) => {
  18. return (
  19. <div className={cn(
  20. 'relative flex items-center mt-0.5 h-6 bg-gray-100 rounded-md px-1 text-xs font-normal text-gray-700',
  21. showBorder && '!bg-black/[0.02]',
  22. )}>
  23. <div className='flex items-center'>
  24. <div className='p-[1px]'>
  25. <VarBlockIcon
  26. className='!text-gray-900'
  27. type={node?.data.type || BlockEnum.Start}
  28. />
  29. </div>
  30. <div className='max-w-[85px] truncate mx-0.5 text-xs font-medium text-gray-700' title={node?.data.title}>{node?.data.title}</div>
  31. <Line3 className='mr-0.5'></Line3>
  32. </div>
  33. <div className='flex items-center text-primary-600'>
  34. <Variable02 className='w-3.5 h-3.5' />
  35. <div className='max-w-[75px] truncate ml-0.5 text-xs font-medium' title={varName}>{varName}</div>
  36. </div>
  37. </div>
  38. )
  39. }
  40. export default memo(NodeVariableItem)