File size: 2,111 Bytes
a8b3f00 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import { memo, useState } from 'react'
import { capitalize } from 'lodash-es'
import { RiDeleteBinLine, RiEditLine } from '@remixicon/react'
import { BubbleX } from '@/app/components/base/icons/src/vender/line/others'
import type { ConversationVariable } from '@/app/components/workflow/types'
import cn from '@/utils/classnames'
type VariableItemProps = {
item: ConversationVariable
onEdit: (item: ConversationVariable) => void
onDelete: (item: ConversationVariable) => void
}
const VariableItem = ({
item,
onEdit,
onDelete,
}: VariableItemProps) => {
const [destructive, setDestructive] = useState(false)
return (
<div className={cn(
'mb-1 px-2.5 py-2 bg-components-panel-on-panel-item-bg radius-md border border-components-panel-border-subtle shadow-xs hover:bg-components-panel-on-panel-item-bg-hover',
destructive && 'border-state-destructive-border hover:bg-state-destructive-hover',
)}>
<div className='flex items-center justify-between'>
<div className='grow flex gap-1 items-center'>
<BubbleX className='w-4 h-4 text-util-colors-teal-teal-700' />
<div className='text-text-primary system-sm-medium'>{item.name}</div>
<div className='text-text-tertiary system-xs-medium'>{capitalize(item.value_type)}</div>
</div>
<div className='shrink-0 flex gap-1 items-center text-text-tertiary'>
<div className='p-1 radius-md cursor-pointer hover:bg-state-base-hover hover:text-text-secondary'>
<RiEditLine className='w-4 h-4' onClick={() => onEdit(item)}/>
</div>
<div
className='p-1 radius-md cursor-pointer hover:bg-state-destructive-hover hover:text-text-destructive'
onMouseOver={() => setDestructive(true)}
onMouseOut={() => setDestructive(false)}
>
<RiDeleteBinLine className='w-4 h-4' onClick={() => onDelete(item)}/>
</div>
</div>
</div>
<div className='text-text-tertiary system-xs-regular truncate'>{item.description}</div>
</div>
)
}
export default memo(VariableItem)
|