node-variable-item.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { memo } from 'react'
  2. import cn from '@/utils/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 { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others'
  7. import type { Node } from '@/app/components/workflow/types'
  8. import { BlockEnum } from '@/app/components/workflow/types'
  9. type NodeVariableItemProps = {
  10. isEnv: boolean
  11. isChatVar: boolean
  12. node: Node
  13. varName: string
  14. showBorder?: boolean
  15. className?: string
  16. }
  17. const NodeVariableItem = ({
  18. isEnv,
  19. isChatVar,
  20. node,
  21. varName,
  22. showBorder,
  23. className,
  24. }: NodeVariableItemProps) => {
  25. return (
  26. <div className={cn(
  27. 'relative flex items-center mt-0.5 h-6 bg-gray-100 rounded-md px-1 text-xs font-normal text-gray-700',
  28. showBorder && '!bg-black/[0.02]',
  29. className,
  30. )}>
  31. {!isEnv && !isChatVar && (
  32. <div className='flex items-center'>
  33. <div className='p-[1px]'>
  34. <VarBlockIcon
  35. className='!text-gray-900'
  36. type={node?.data.type || BlockEnum.Start}
  37. />
  38. </div>
  39. <div className='max-w-[85px] truncate mx-0.5 text-xs font-medium text-gray-700' title={node?.data.title}>{node?.data.title}</div>
  40. <Line3 className='mr-0.5'></Line3>
  41. </div>
  42. )}
  43. <div className='flex items-center text-primary-600'>
  44. {!isEnv && !isChatVar && <Variable02 className='shrink-0 w-3.5 h-3.5 text-primary-500' />}
  45. {isEnv && <Env className='shrink-0 w-3.5 h-3.5 text-util-colors-violet-violet-600' />}
  46. {isChatVar && <BubbleX className='w-3.5 h-3.5 text-util-colors-teal-teal-700' />}
  47. <div className={cn('max-w-[75px] truncate ml-0.5 text-xs font-medium', (isEnv || isChatVar) && 'text-gray-900')} title={varName}>{varName}</div>
  48. </div>
  49. </div>
  50. )
  51. }
  52. export default memo(NodeVariableItem)