| | |
| | | } from '../../types' |
| | | import { comparisonOperatorNotRequireValue, getOperators } from '../../utils' |
| | | import ConditionNumberInput from '../condition-number-input' |
| | | import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../../constants' |
| | | import { FILE_TYPE_OPTIONS, SUB_VARIABLES, TRANSFER_METHOD } from '../../default' |
| | | import ConditionWrap from '../condition-wrap' |
| | | import ConditionOperator from './condition-operator' |
| | | import ConditionInput from './condition-input' |
| | |
| | | value: isArrayValue ? [value] : value, |
| | | } |
| | | doUpdateCondition(newCondition) |
| | | }, [condition, doUpdateCondition, isArrayValue]) |
| | | }, [condition, doUpdateCondition, fileAttr]) |
| | | |
| | | const isSelect = condition.comparison_operator && [ComparisonOperator.in, ComparisonOperator.notIn].includes(condition.comparison_operator) |
| | | const selectOptions = useMemo(() => { |
| | |
| | | }, [condition, doUpdateCondition]) |
| | | |
| | | return ( |
| | | <div className={cn('mb-1 flex last-of-type:mb-0', className)}> |
| | | <div className={cn('flex mb-1 last-of-type:mb-0', className)}> |
| | | <div className={cn( |
| | | 'grow rounded-lg bg-components-input-bg-normal', |
| | | 'grow bg-components-input-bg-normal rounded-lg', |
| | | isHovered && 'bg-state-destructive-hover', |
| | | )}> |
| | | <div className='flex items-center p-1'> |
| | | <div className='w-0 grow'> |
| | | <div className='grow w-0'> |
| | | {isSubVarSelect |
| | | ? ( |
| | | <Select |
| | |
| | | onSelect={item => handleSubVarKeyChange(item.value as string)} |
| | | renderTrigger={item => ( |
| | | item |
| | | ? <div className='flex cursor-pointer justify-start'> |
| | | <div className='inline-flex h-6 max-w-full items-center rounded-md border-[0.5px] border-components-panel-border-subtle bg-components-badge-white-to-dark px-1.5 text-text-accent shadow-xs'> |
| | | <Variable02 className='h-3.5 w-3.5 shrink-0 text-text-accent' /> |
| | | <div className='system-xs-medium ml-0.5 truncate'>{item?.name}</div> |
| | | ? <div className='flex justify-start cursor-pointer'> |
| | | <div className='inline-flex max-w-full px-1.5 items-center h-6 rounded-md border-[0.5px] border-components-panel-border-subtle bg-components-badge-white-to-dark shadow-xs text-text-accent'> |
| | | <Variable02 className='shrink-0 w-3.5 h-3.5 text-text-accent' /> |
| | | <div className='ml-0.5 truncate system-xs-medium'>{item?.name}</div> |
| | | </div> |
| | | </div> |
| | | : <div className='system-sm-regular text-left text-components-input-text-placeholder'>{t('common.placeholder.select')}</div> |
| | | : <div className='text-left text-components-input-text-placeholder system-sm-regular'>{t('common.placeholder.select')}</div> |
| | | )} |
| | | hideChecked |
| | | /> |
| | |
| | | )} |
| | | |
| | | </div> |
| | | <div className='mx-1 h-3 w-[1px] bg-divider-regular'></div> |
| | | <div className='mx-1 w-[1px] h-3 bg-divider-regular'></div> |
| | | <ConditionOperator |
| | | disabled={!canChooseOperator} |
| | | varType={condition.varType} |
| | |
| | | </div> |
| | | { |
| | | !comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType !== VarType.number && ( |
| | | <div className='max-h-[100px] overflow-y-auto border-t border-t-divider-subtle px-2 py-1'> |
| | | <div className='px-2 py-1 max-h-[100px] border-t border-t-divider-subtle overflow-y-auto'> |
| | | <ConditionInput |
| | | disabled={disabled} |
| | | value={condition.value as string} |
| | |
| | | } |
| | | { |
| | | !comparisonOperatorNotRequireValue(condition.comparison_operator) && !isNotInput && condition.varType === VarType.number && ( |
| | | <div className='border-t border-t-divider-subtle px-2 py-1 pt-[3px]'> |
| | | <div className='px-2 py-1 pt-[3px] border-t border-t-divider-subtle'> |
| | | <ConditionNumberInput |
| | | numberVarType={condition.numberVarType} |
| | | onNumberVarTypeChange={handleUpdateConditionNumberVarType} |
| | |
| | | <div className='border-t border-t-divider-subtle'> |
| | | <Select |
| | | wrapperClassName='h-8' |
| | | className='rounded-t-none px-2 text-xs' |
| | | className='px-2 text-xs rounded-t-none' |
| | | defaultValue={isArrayValue ? (condition.value as string[])?.[0] : (condition.value as string)} |
| | | items={selectOptions} |
| | | onSelect={item => handleUpdateConditionValue(item.value as string)} |
| | |
| | | } |
| | | </div> |
| | | <div |
| | | className='ml-1 mt-1 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-lg text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive' |
| | | className='shrink-0 flex items-center justify-center ml-1 mt-1 w-6 h-6 rounded-lg cursor-pointer hover:bg-state-destructive-hover text-text-tertiary hover:text-text-destructive' |
| | | onMouseEnter={() => setIsHovered(true)} |
| | | onMouseLeave={() => setIsHovered(false)} |
| | | onClick={doRemoveCondition} |
| | | > |
| | | <RiDeleteBinLine className='h-4 w-4' /> |
| | | <RiDeleteBinLine className='w-4 h-4' /> |
| | | </div> |
| | | </div> |
| | | ) |