'use client' import type { FC } from 'react' import React, { useCallback, useRef } from 'react' import { useBoolean, useHover } from 'ahooks' import { useTranslation } from 'react-i18next' import { RiDeleteBinLine, } from '@remixicon/react' import InputVarTypeIcon from '../../_base/components/input-var-type-icon' import type { InputVar, MoreInfo } from '@/app/components/workflow/types' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { Edit03 } from '@/app/components/base/icons/src/vender/solid/general' import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal' type Props = { readonly: boolean payload: InputVar onChange?: (item: InputVar, moreInfo?: MoreInfo) => void onRemove?: () => void rightContent?: JSX.Element varKeys?: string[] } const VarItem: FC = ({ readonly, payload, onChange = () => { }, onRemove = () => { }, rightContent, varKeys = [], }) => { const { t } = useTranslation() const ref = useRef(null) const isHovering = useHover(ref) const [isShowEditVarModal, { setTrue: showEditVarModal, setFalse: hideEditVarModal, }] = useBoolean(false) const handlePayloadChange = useCallback((payload: InputVar, moreInfo?: MoreInfo) => { onChange(payload, moreInfo) hideEditVarModal() }, [onChange, hideEditVarModal]) return (
{payload.variable}
{payload.label && (<>
ยท
{payload.label as string}
)}
{rightContent || (<> {(!isHovering || readonly) ? ( <> {payload.required && (
{t('workflow.nodes.start.required')}
)} ) : (!readonly && ( <>
))} )}
{ isShowEditVarModal && ( ) }
) } export default React.memo(VarItem)