Compare commits

...

3 Commits

10 changed files with 94 additions and 80 deletions

View File

@ -1,29 +1,25 @@
'use client' 'use client'
import React, { useState } from 'react' import React from 'react'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
type IRemoveIconProps = { type IRemoveIconProps = {
className?: string className?: string
isHoverStatus?: boolean
onClick: () => void onClick: () => void
} } & React.HTMLAttributes<HTMLDivElement>
const RemoveIcon = ({ const RemoveIcon = ({
className, className,
isHoverStatus,
onClick, onClick,
...props
}: IRemoveIconProps) => { }: IRemoveIconProps) => {
const [isHovered, setIsHovered] = useState(false)
const computedIsHovered = isHoverStatus || isHovered
return ( return (
<div <div
className={cn(className, computedIsHovered && 'bg-[#FEE4E2]', 'flex w-6 h-6 items-center justify-center rounded-md cursor-pointer hover:bg-[#FEE4E2]')} className={cn('flex w-6 h-6 items-center justify-center rounded-md cursor-pointer hover:bg-state-destructive-hover text-text-tertiary hover:text-text-destructive', className)}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
onClick={onClick} onClick={onClick}
{...props}
> >
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 6H14M6 8H18M16.6667 8L16.1991 15.0129C16.129 16.065 16.0939 16.5911 15.8667 16.99C15.6666 17.3412 15.3648 17.6235 15.0011 17.7998C14.588 18 14.0607 18 13.0062 18H10.9938C9.93927 18 9.41202 18 8.99889 17.7998C8.63517 17.6235 8.33339 17.3412 8.13332 16.99C7.90607 16.5911 7.871 16.065 7.80086 15.0129L7.33333 8M10.6667 11V14.3333M13.3333 11V14.3333" stroke={computedIsHovered ? '#D92D20' : '#667085'} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> <path d="M10 6H14M6 8H18M16.6667 8L16.1991 15.0129C16.129 16.065 16.0939 16.5911 15.8667 16.99C15.6666 17.3412 15.3648 17.6235 15.0011 17.7998C14.588 18 14.0607 18 13.0062 18H10.9938C9.93927 18 9.41202 18 8.99889 17.7998C8.63517 17.6235 8.33339 17.3412 8.13332 16.99C7.90607 16.5911 7.871 16.065 7.80086 15.0129L7.33333 8M10.6667 11V14.3333M13.3333 11V14.3333" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg> </svg>
</div> </div>
) )

View File

@ -1,12 +1,13 @@
'use client' 'use client'
import type { FC } from 'react' import type { FC } from 'react'
import React from 'react' import React, { useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { PlusIcon } from '@heroicons/react/24/outline' import { PlusIcon } from '@heroicons/react/24/outline'
import { ReactSortable } from 'react-sortablejs' import { ReactSortable } from 'react-sortablejs'
import RemoveIcon from '../../base/icons/remove-icon' import RemoveIcon from '../../base/icons/remove-icon'
import s from './style.module.css' import s from './style.module.css'
import cn from '@/utils/classnames'
export type Options = string[] export type Options = string[]
export type IConfigSelectProps = { export type IConfigSelectProps = {
@ -19,6 +20,8 @@ const ConfigSelect: FC<IConfigSelectProps> = ({
onChange, onChange,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
const [delBtnHoverIndex, setDelBtnHoverIndex] = useState(-1)
const [focusedIndex, setFocusedIndex] = useState(-1)
const optionList = options.map((content, index) => { const optionList = options.map((content, index) => {
return ({ return ({
@ -36,48 +39,62 @@ const ConfigSelect: FC<IConfigSelectProps> = ({
list={optionList} list={optionList}
setList={list => onChange(list.map(item => item.name))} setList={list => onChange(list.map(item => item.name))}
handle='.handle' handle='.handle'
ghostClass="opacity-50" ghostClass="opacity-30"
animation={150} animation={150}
> >
{options.map((o, index) => ( {options.map((o, index) => {
<div className={`${s.inputWrap} relative`} key={index}> const delBtnHover = delBtnHoverIndex === index
<div className='handle flex items-center justify-center w-4 h-4 cursor-grab'> const inputFocused = focusedIndex === index
<svg width="6" height="10" viewBox="0 0 6 10" fill="none" xmlns="http://www.w3.org/2000/svg"> return (
<path fillRule="evenodd" clipRule="evenodd" d="M1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2ZM1 6C1.55228 6 2 5.55228 2 5C2 4.44772 1.55228 4 1 4C0.447715 4 0 4.44772 0 5C0 5.55228 0.447715 6 1 6ZM6 1C6 1.55228 5.55228 2 5 2C4.44772 2 4 1.55228 4 1C4 0.447715 4.44772 0 5 0C5.55228 0 6 0.447715 6 1ZM5 6C5.55228 6 6 5.55228 6 5C6 4.44772 5.55228 4 5 4C4.44772 4 4 4.44772 4 5C4 5.55228 4.44772 6 5 6ZM2 9C2 9.55229 1.55228 10 1 10C0.447715 10 0 9.55229 0 9C0 8.44771 0.447715 8 1 8C1.55228 8 2 8.44771 2 9ZM5 10C5.55228 10 6 9.55229 6 9C6 8.44771 5.55228 8 5 8C4.44772 8 4 8.44771 4 9C4 9.55229 4.44772 10 5 10Z" fill="#98A2B3" /> <div
</svg> className={cn(
</div> `${s.inputWrap} relative border border-components-panel-border-subtle bg-components-panel-on-panel-item-bg`,
<input inputFocused && 'border-components-input-border-active bg-components-input-bg-active',
delBtnHover && 'bg-state-destructive-hover',
)}
key={index} key={index}
type="input" >
value={o || ''} <div className='handle flex items-center justify-center w-3.5 h-3.5 cursor-grab text-text-quaternary'>
onChange={(e) => { <svg width="6" height="10" viewBox="0 0 6 10" fill="none" xmlns="http://www.w3.org/2000/svg">
const value = e.target.value <path fillRule="evenodd" clipRule="evenodd" d="M1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2ZM1 6C1.55228 6 2 5.55228 2 5C2 4.44772 1.55228 4 1 4C0.447715 4 0 4.44772 0 5C0 5.55228 0.447715 6 1 6ZM6 1C6 1.55228 5.55228 2 5 2C4.44772 2 4 1.55228 4 1C4 0.447715 4.44772 0 5 0C5.55228 0 6 0.447715 6 1ZM5 6C5.55228 6 6 5.55228 6 5C6 4.44772 5.55228 4 5 4C4.44772 4 4 4.44772 4 5C4 5.55228 4.44772 6 5 6ZM2 9C2 9.55229 1.55228 10 1 10C0.447715 10 0 9.55229 0 9C0 8.44771 0.447715 8 1 8C1.55228 8 2 8.44771 2 9ZM5 10C5.55228 10 6 9.55229 6 9C6 8.44771 5.55228 8 5 8C4.44772 8 4 8.44771 4 9C4 9.55229 4.44772 10 5 10Z" fill="currentColor" />
onChange(options.map((item, i) => { </svg>
if (index === i) </div>
return value <input
key={index}
type="input"
value={o || ''}
onChange={(e) => {
const value = e.target.value
onChange(options.map((item, i) => {
if (index === i)
return value
return item return item
})) }))
}} }}
className={'w-full pl-1.5 pr-8 text-sm leading-9 text-gray-900 border-0 grow h-9 bg-transparent focus:outline-none cursor-pointer'} onFocus={() => { setFocusedIndex(index) }}
/> onBlur={() => { setFocusedIndex(-1) }}
<RemoveIcon className={'w-full pl-1 pr-8 system-sm-medium text-text-secondary border-0 grow h-8 bg-transparent group focus:outline-none cursor-pointer caret-[#295EFF]'}
className={`${s.deleteBtn} absolute top-1/2 translate-y-[-50%] right-1.5 items-center justify-center w-6 h-6 rounded-md cursor-pointer hover:bg-[#FEE4E2]`} />
onClick={() => { <RemoveIcon
onChange(options.filter((_, i) => index !== i)) className={`${s.deleteBtn} absolute top-1/2 translate-y-[-50%] right-1 items-center justify-center w-6 h-6 rounded-lg cursor-pointer`}
}} onClick={() => {
/> onChange(options.filter((_, i) => index !== i))
</div> }}
))} onMouseEnter={() => setDelBtnHoverIndex(index)}
onMouseLeave={() => setDelBtnHoverIndex(-1)}
/>
</div>)
})}
</ReactSortable> </ReactSortable>
</div> </div>
)} )}
<div <div
onClick={() => { onChange([...options, '']) }} onClick={() => { onChange([...options, '']) }}
className='flex items-center h-9 px-3 gap-2 rounded-lg cursor-pointer text-gray-400 bg-gray-100'> className='flex items-center h-8 px-2 gap-1 rounded-lg cursor-pointer bg-components-button-tertiary-bg'>
<PlusIcon width={16} height={16}></PlusIcon> <PlusIcon className='text-components-button-tertiary-text' width={16} height={16} />
<div className='text-gray-500 text-[13px]'>{t('appDebug.variableConfig.addOption')}</div> <div className='text-components-button-tertiary-text system-sm-medium'>{t('appDebug.variableConfig.addOption')}</div>
</div> </div>
</div> </div>
) )

View File

@ -2,7 +2,6 @@
display: flex; display: flex;
align-items: center; align-items: center;
border-radius: 8px; border-radius: 8px;
border: 1px solid #EAECF0;
padding-left: 10px; padding-left: 10px;
cursor: pointer; cursor: pointer;
} }

View File

@ -32,9 +32,9 @@ const SelectTypeItem: FC<ISelectTypeItemProps> = ({
onClick={onClick} onClick={onClick}
> >
<div className='shrink-0'> <div className='shrink-0'>
<InputVarTypeIcon type={type} className='w-5 h-5' /> <InputVarTypeIcon type={type} className='w-5 h-5 text-text-secondary' />
</div> </div>
<span>{typeName}</span> <span className='text-text-secondary'>{typeName}</span>
</div> </div>
) )
} }

View File

@ -82,7 +82,8 @@ const BlockIcon: FC<BlockIconProps> = ({
}) => { }) => {
return ( return (
<div className={` <div className={`
flex items-center justify-center border-[0.5px] border-white/2 text-white flex items-center justify-center border-[0.5px] border-divider-subtle
text-text-primary-on-surface shadow-md shadow-shadow-shadow-5
${ICON_CONTAINER_CLASSNAME_SIZE_MAP[size]} ${ICON_CONTAINER_CLASSNAME_SIZE_MAP[size]}
${ICON_CONTAINER_BG_COLOR_MAP[type]} ${ICON_CONTAINER_BG_COLOR_MAP[type]}
${toolIcon && '!shadow-none'} ${toolIcon && '!shadow-none'}

View File

@ -33,9 +33,10 @@ export const TitleInput = memo(({
value={localValue} value={localValue}
onChange={e => setLocalValue(e.target.value)} onChange={e => setLocalValue(e.target.value)}
className={` className={`
grow mr-2 px-1 h-6 text-base text-gray-900 font-semibold rounded-lg border border-transparent appearance-none outline-none grow mr-2 px-1 h-6 system-xl-semibold text-text-primary rounded-lg border border-transparent appearance-none outline-none
hover:bg-gray-50 placeholder:text-text-placeholder
focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF] bg-transparent hover:bg-state-base-hover
focus:border-components-input-border-active focus:shadow-xs shadow-shadow-shadow-3 focus:bg-components-input-active caret-[#295EFF]
min-w-0 min-w-0
`} `}
placeholder={t('workflow.common.addTitle') || ''} placeholder={t('workflow.common.addTitle') || ''}
@ -66,8 +67,8 @@ export const DescriptionInput = memo(({
<div <div
className={` className={`
group flex px-2 py-[5px] max-h-[60px] rounded-lg overflow-y-auto group flex px-2 py-[5px] max-h-[60px] rounded-lg overflow-y-auto
border border-transparent hover:bg-gray-50 leading-0 border border-transparent bg-transparent hover:bg-state-base-hover leading-0
${focus && '!border-gray-300 shadow-xs !bg-gray-50'} ${focus && '!border-components-input-border-active shadow-xs shadow-shadow-shadow-3 !bg-components-input-bg-active'}
`} `}
> >
<Textarea <Textarea
@ -77,9 +78,9 @@ export const DescriptionInput = memo(({
onFocus={handleFocus} onFocus={handleFocus}
onBlur={handleBlur} onBlur={handleBlur}
className={` className={`
w-full text-xs text-gray-900 leading-[18px] bg-transparent w-full text-xs text-text-primary leading-[18px] bg-transparent
appearance-none outline-none resize-none appearance-none outline-none resize-none
placeholder:text-gray-400 caret-[#295EFF] placeholder:text-text-placeholder caret-[#295EFF]
`} `}
placeholder={t('workflow.common.addDescription') || ''} placeholder={t('workflow.common.addDescription') || ''}
autoSize autoSize

View File

@ -5,11 +5,11 @@ import { useBoolean, useHover } from 'ahooks'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { import {
RiDeleteBinLine, RiDeleteBinLine,
RiEditLine,
} from '@remixicon/react' } from '@remixicon/react'
import InputVarTypeIcon from '../../_base/components/input-var-type-icon' import InputVarTypeIcon from '../../_base/components/input-var-type-icon'
import type { InputVar, MoreInfo } from '@/app/components/workflow/types' import type { InputVar, MoreInfo } from '@/app/components/workflow/types'
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
import { Edit03 } from '@/app/components/base/icons/src/vender/solid/general'
import Badge from '@/app/components/base/badge' import Badge from '@/app/components/base/badge'
import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal' import ConfigVarModal from '@/app/components/app/configuration/config-var/config-modal'
@ -46,12 +46,12 @@ const VarItem: FC<Props> = ({
hideEditVarModal() hideEditVarModal()
}, [onChange, hideEditVarModal]) }, [onChange, hideEditVarModal])
return ( return (
<div ref={ref} className='flex items-center h-8 justify-between px-2.5 bg-white rounded-lg border border-gray-200 shadow-xs cursor-pointer hover:shadow-md'> <div ref={ref} className='flex items-center h-8 justify-between px-2.5 bg-components-panel-on-panel-item-bg rounded-lg border border-components-panel-border-subtle shadow-xs cursor-pointer hover:shadow-md shadow-shadow-shadow-3'>
<div className='flex items-center space-x-1 grow w-0'> <div className='flex items-center space-x-1 grow w-0'>
<Variable02 className='w-3.5 h-3.5 text-primary-500' /> <Variable02 className='w-3.5 h-3.5 text-text-accent' />
<div title={payload.variable} className='shrink-0 max-w-[130px] truncate text-[13px] font-medium text-gray-700'>{payload.variable}</div> <div title={payload.variable} className='shrink-0 max-w-[130px] truncate system-sm-medium text-text-secondary'>{payload.variable}</div>
{payload.label && (<><div className='shrink-0 text-xs font-medium text-gray-400'>·</div> {payload.label && (<><div className='shrink-0 system-xs-regular text-text-quaternary'>·</div>
<div title={payload.label as string} className='max-w-[130px] truncate text-[13px] font-medium text-gray-500'>{payload.label as string}</div> <div title={payload.label as string} className='max-w-[130px] truncate system-xs-medium text-text-tertiary'>{payload.label as string}</div>
</>)} </>)}
{showLegacyBadge && ( {showLegacyBadge && (
<Badge <Badge
@ -66,18 +66,18 @@ const VarItem: FC<Props> = ({
? ( ? (
<> <>
{payload.required && ( {payload.required && (
<div className='mr-2 text-xs font-normal text-gray-500'>{t('workflow.nodes.start.required')}</div> <Badge className='mr-2' uppercase>{t('workflow.nodes.start.required')}</Badge>
)} )}
<InputVarTypeIcon type={payload.type} className='w-3.5 h-3.5 text-gray-500' /> <InputVarTypeIcon type={payload.type} className='w-3 h-3 text-text-tertiary' />
</> </>
) )
: (!readonly && ( : (!readonly && (
<> <>
<div onClick={showEditVarModal} className='mr-1 p-1 rounded-md cursor-pointer hover:bg-black/5'> <div onClick={showEditVarModal} className='mr-1 p-1 cursor-pointer'>
<Edit03 className='w-4 h-4 text-gray-500' /> <RiEditLine className='w-4 h-4 text-text-tertiary' />
</div> </div>
<div onClick={onRemove} className='p-1 rounded-md cursor-pointer hover:bg-black/5'> <div onClick={onRemove} className='p-1 cursor-pointer'>
<RiDeleteBinLine className='w-4 h-4 text-gray-500' /> <RiDeleteBinLine className='w-4 h-4 text-text-tertiary' />
</div> </div>
</> </>
))} ))}

View File

@ -46,7 +46,7 @@ const VarList: FC<Props> = ({
if (list.length === 0) { if (list.length === 0) {
return ( return (
<div className='flex rounded-md bg-gray-50 items-center h-[42px] justify-center leading-[18px] text-xs font-normal text-gray-500'> <div className='flex rounded-md bg-background-section items-center h-10 justify-center system-xs-regular text-text-tertiary'>
{t('workflow.nodes.start.noVarTip')} {t('workflow.nodes.start.noVarTip')}
</div> </div>
) )

View File

@ -20,15 +20,15 @@ const Node: FC<NodeProps<StartNodeType>> = ({
<div className='mb-1 px-3 py-1'> <div className='mb-1 px-3 py-1'>
<div className='space-y-0.5'> <div className='space-y-0.5'>
{variables.map(variable => ( {variables.map(variable => (
<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'> <div key={variable.variable} className='flex items-center h-6 justify-between bg-workflow-block-parma-bg rounded-md px-1 space-x-1'>
<div className='w-0 grow flex items-center space-x-1'> <div className='w-0 grow flex items-center space-x-1'>
<Variable02 className='shrink-0 w-3.5 h-3.5 text-primary-500' /> <Variable02 className='shrink-0 w-3.5 h-3.5 text-text-accent' />
<span className='w-0 grow truncate text-xs font-normal text-gray-700'>{variable.variable}</span> <span className='w-0 grow truncate system-xs-regular text-text-secondary'>{variable.variable}</span>
</div> </div>
<div className='ml-1 flex items-center space-x-1'> <div className='ml-1 flex items-center space-x-1'>
{variable.required && <span className='text-xs font-normal text-gray-500 uppercase'>{t(`${i18nPrefix}.required`)}</span>} {variable.required && <span className='system-2xs-regular-uppercase text-text-tertiary'>{t(`${i18nPrefix}.required`)}</span>}
<InputVarTypeIcon type={variable.type} className='w-3 h-3 text-gray-500' /> <InputVarTypeIcon type={variable.type} className='w-3 h-3 text-text-tertiary' />
</div> </div>
</div> </div>
))} ))}

View File

@ -64,7 +64,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.query', variable: 'sys.query',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }
@ -78,7 +78,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.files', variable: 'sys.files',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
Array[File] Array[File]
</div> </div>
} }
@ -92,7 +92,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.dialogue_count', variable: 'sys.dialogue_count',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
Number Number
</div> </div>
} }
@ -103,7 +103,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.conversation_id', variable: 'sys.conversation_id',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }
@ -117,7 +117,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.user_id', variable: 'sys.user_id',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }
@ -128,7 +128,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.app_id', variable: 'sys.app_id',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }
@ -139,7 +139,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.workflow_id', variable: 'sys.workflow_id',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }
@ -150,7 +150,7 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
variable: 'sys.workflow_run_id', variable: 'sys.workflow_run_id',
} as any} } as any}
rightContent={ rightContent={
<div className='text-xs font-normal text-gray-500'> <div className='system-xs-regular text-text-tertiary'>
String String
</div> </div>
} }