mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 01:09:05 +08:00
chore: some select style
This commit is contained in:
parent
23ae150298
commit
d361675159
@ -108,7 +108,7 @@ const Select: FC<ISelectProps> = ({
|
|||||||
if (!disabled)
|
if (!disabled)
|
||||||
setOpen(!open)
|
setOpen(!open)
|
||||||
}
|
}
|
||||||
} className={classNames(optionClassName, `flex items-center h-9 w-full rounded-lg border-0 ${bgClassName} py-1.5 pl-3 pr-10 shadow-sm sm:text-sm sm:leading-6 focus-visible:outline-none focus-visible:bg-gray-200 group-hover:bg-gray-200`)}>
|
} className={classNames(`flex items-center h-9 w-full rounded-lg border-0 ${bgClassName} py-1.5 pl-3 pr-10 shadow-sm sm:text-sm sm:leading-6 focus-visible:outline-none focus-visible:bg-gray-200 group-hover:bg-gray-200`, optionClassName)}>
|
||||||
<div className='w-0 grow text-left truncate' title={selectedItem?.name}>{selectedItem?.name}</div>
|
<div className='w-0 grow text-left truncate' title={selectedItem?.name}>{selectedItem?.name}</div>
|
||||||
</Combobox.Button>}
|
</Combobox.Button>}
|
||||||
<Combobox.Button className="absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none group-hover:bg-gray-200" onClick={
|
<Combobox.Button className="absolute inset-y-0 right-0 flex items-center rounded-r-md px-2 focus:outline-none group-hover:bg-gray-200" onClick={
|
||||||
@ -200,7 +200,7 @@ const SimpleSelect: FC<ISelectProps> = ({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className={classNames('relative h-9', wrapperClassName)}>
|
<div className={classNames('relative h-9', wrapperClassName)}>
|
||||||
<Listbox.Button className={`w-full h-full rounded-lg border-0 bg-gray-100 py-1.5 pl-3 pr-10 sm:text-sm sm:leading-6 focus-visible:outline-none focus-visible:bg-gray-200 group-hover:bg-gray-200 ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'} ${className}`}>
|
<Listbox.Button className={`flex items-center w-full h-full rounded-lg border-0 bg-gray-100 pl-3 pr-10 sm:text-sm sm:leading-6 focus-visible:outline-none focus-visible:bg-gray-200 group-hover:bg-gray-200 ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'} ${className}`}>
|
||||||
<span className={classNames('block truncate text-left', !selectedItem?.name && 'text-gray-400')}>{selectedItem?.name ?? localPlaceholder}</span>
|
<span className={classNames('block truncate text-left', !selectedItem?.name && 'text-gray-400')}>{selectedItem?.name ?? localPlaceholder}</span>
|
||||||
<span className="absolute inset-y-0 right-0 flex items-center pr-2">
|
<span className="absolute inset-y-0 right-0 flex items-center pr-2">
|
||||||
{selectedItem
|
{selectedItem
|
||||||
|
@ -5,19 +5,26 @@ import SubVariablePicker from './sub-variable-picker'
|
|||||||
import { SimpleSelect as Select } from '@/app/components/base/select'
|
import { SimpleSelect as Select } from '@/app/components/base/select'
|
||||||
import Input from '@/app/components/base/input'
|
import Input from '@/app/components/base/input'
|
||||||
|
|
||||||
const FilterCondition: FC = () => {
|
type Props = {
|
||||||
|
hasSubVariable: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const FilterCondition: FC<Props> = ({
|
||||||
|
hasSubVariable,
|
||||||
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SubVariablePicker />
|
{hasSubVariable && <SubVariablePicker className="mb-2" />}
|
||||||
<div className='mt-2 flex space-x-1'>
|
<div className='flex space-x-1'>
|
||||||
<Select
|
<Select
|
||||||
wrapperClassName='shrink-0 h-8'
|
wrapperClassName='shrink-0 h-8'
|
||||||
|
className='!text-[13px]'
|
||||||
items={[
|
items={[
|
||||||
{ value: '1', name: 'include', type: '' },
|
{ value: '1', name: 'include', type: '' },
|
||||||
]}
|
]}
|
||||||
onSelect={() => { }}
|
onSelect={() => { }}
|
||||||
/>
|
/>
|
||||||
<Input className='grow h-8' />
|
<Input className='grow h-8 text-components-input-text-filled system-sm-regular !text-[13px]' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -3,8 +3,15 @@ import type { FC } from 'react'
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { SimpleSelect as Select } from '@/app/components/base/select'
|
import { SimpleSelect as Select } from '@/app/components/base/select'
|
||||||
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
const SubVariablePicker: FC = () => {
|
type Props = {
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const SubVariablePicker: FC<Props> = ({
|
||||||
|
className,
|
||||||
|
}) => {
|
||||||
const renderOption = ({ item }: { item: Record<string, any> }) => {
|
const renderOption = ({ item }: { item: Record<string, any> }) => {
|
||||||
return (
|
return (
|
||||||
<div className='flex items-center h-6 justify-between'>
|
<div className='flex items-center h-6 justify-between'>
|
||||||
@ -17,7 +24,7 @@ const SubVariablePicker: FC = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={cn(className)}>
|
||||||
<Select
|
<Select
|
||||||
items={[
|
items={[
|
||||||
{ value: '1', name: 'name', type: 'string' },
|
{ value: '1', name: 'name', type: 'string' },
|
||||||
@ -25,6 +32,7 @@ const SubVariablePicker: FC = () => {
|
|||||||
]}
|
]}
|
||||||
defaultValue={'1'}
|
defaultValue={'1'}
|
||||||
onSelect={() => { }}
|
onSelect={() => { }}
|
||||||
|
className='!text-[13px]'
|
||||||
placeholder='Select sub variable key'
|
placeholder='Select sub variable key'
|
||||||
optionClassName='pl-4 pr-5 py-0'
|
optionClassName='pl-4 pr-5 py-0'
|
||||||
renderOption={renderOption}
|
renderOption={renderOption}
|
||||||
|
@ -25,6 +25,7 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
|
|||||||
const {
|
const {
|
||||||
readOnly,
|
readOnly,
|
||||||
inputs,
|
inputs,
|
||||||
|
hasSubVariable,
|
||||||
handleVarChanges,
|
handleVarChanges,
|
||||||
filterVar,
|
filterVar,
|
||||||
handleLimitChange,
|
handleLimitChange,
|
||||||
@ -52,7 +53,7 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
|
|||||||
title={t(`${i18nPrefix}.filterCondition`)}
|
title={t(`${i18nPrefix}.filterCondition`)}
|
||||||
isSubTitle
|
isSubTitle
|
||||||
>
|
>
|
||||||
<FilterCondition />
|
<FilterCondition hasSubVariable={hasSubVariable} />
|
||||||
</Field>
|
</Field>
|
||||||
<Split />
|
<Split />
|
||||||
<Field
|
<Field
|
||||||
@ -69,8 +70,10 @@ const Panel: FC<NodePanelProps<ListFilterNodeType>> = ({
|
|||||||
{inputs.orderBy?.enabled
|
{inputs.orderBy?.enabled
|
||||||
? (
|
? (
|
||||||
<div className='flex items-center justify-between'>
|
<div className='flex items-center justify-between'>
|
||||||
<div className='grow mr-2'><SubVariablePicker /></div>
|
{hasSubVariable && (
|
||||||
<div className='shrink-0 flex space-x-1'>
|
<div className='grow mr-2'><SubVariablePicker /></div>
|
||||||
|
)}
|
||||||
|
<div className={!hasSubVariable ? 'w-full grid grid-cols-2 gap-1' : 'shrink-0 flex space-x-1'}>
|
||||||
<OptionCard
|
<OptionCard
|
||||||
title={t(`${i18nPrefix}.asc`)}
|
title={t(`${i18nPrefix}.asc`)}
|
||||||
onSelect={handleOrderByTypeChange(OrderBy.ASC)}
|
onSelect={handleOrderByTypeChange(OrderBy.ASC)}
|
||||||
|
@ -1,18 +1,47 @@
|
|||||||
import { useCallback } from 'react'
|
import { useCallback, useMemo } from 'react'
|
||||||
import produce from 'immer'
|
import produce from 'immer'
|
||||||
|
import { useStoreApi } from 'reactflow'
|
||||||
import type { ValueSelector, Var } from '../../types'
|
import type { ValueSelector, Var } from '../../types'
|
||||||
import { VarType } from '../../types'
|
import { VarType } from '../../types'
|
||||||
import type { Limit, ListFilterNodeType, OrderBy } from './types'
|
import type { Limit, ListFilterNodeType, OrderBy } from './types'
|
||||||
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
|
||||||
import {
|
import {
|
||||||
|
useIsChatMode,
|
||||||
useNodesReadOnly,
|
useNodesReadOnly,
|
||||||
|
useWorkflow,
|
||||||
|
useWorkflowVariables,
|
||||||
} from '@/app/components/workflow/hooks'
|
} from '@/app/components/workflow/hooks'
|
||||||
|
|
||||||
const useConfig = (id: string, payload: ListFilterNodeType) => {
|
const useConfig = (id: string, payload: ListFilterNodeType) => {
|
||||||
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
const { nodesReadOnly: readOnly } = useNodesReadOnly()
|
||||||
|
const isChatMode = useIsChatMode()
|
||||||
|
|
||||||
|
const store = useStoreApi()
|
||||||
|
const { getBeforeNodesInSameBranch } = useWorkflow()
|
||||||
|
|
||||||
|
const {
|
||||||
|
getNodes,
|
||||||
|
} = store.getState()
|
||||||
|
const currentNode = getNodes().find(n => n.id === id)
|
||||||
|
const isInIteration = payload.isInIteration
|
||||||
|
const iterationNode = isInIteration ? getNodes().find(n => n.id === currentNode!.parentId) : null
|
||||||
|
const availableNodes = useMemo(() => {
|
||||||
|
return getBeforeNodesInSameBranch(id)
|
||||||
|
}, [getBeforeNodesInSameBranch, id])
|
||||||
|
|
||||||
const { inputs, setInputs } = useNodeCrud<ListFilterNodeType>(id, payload)
|
const { inputs, setInputs } = useNodeCrud<ListFilterNodeType>(id, payload)
|
||||||
|
|
||||||
|
const { getCurrentVariableType } = useWorkflowVariables()
|
||||||
|
const varType = getCurrentVariableType({
|
||||||
|
parentNode: iterationNode,
|
||||||
|
valueSelector: inputs.variable || [],
|
||||||
|
availableNodes,
|
||||||
|
isChatMode,
|
||||||
|
isConstant: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
const hasSubVariable = [VarType.arrayFile, VarType.arrayObject].includes(varType)
|
||||||
|
|
||||||
const handleVarChanges = useCallback((variable: ValueSelector | string) => {
|
const handleVarChanges = useCallback((variable: ValueSelector | string) => {
|
||||||
const newInputs = produce(inputs, (draft) => {
|
const newInputs = produce(inputs, (draft) => {
|
||||||
draft.variable = variable as ValueSelector
|
draft.variable = variable as ValueSelector
|
||||||
@ -51,6 +80,7 @@ const useConfig = (id: string, payload: ListFilterNodeType) => {
|
|||||||
readOnly,
|
readOnly,
|
||||||
inputs,
|
inputs,
|
||||||
filterVar,
|
filterVar,
|
||||||
|
hasSubVariable,
|
||||||
handleVarChanges,
|
handleVarChanges,
|
||||||
handleLimitChange,
|
handleLimitChange,
|
||||||
handleOrderByEnabledChange,
|
handleOrderByEnabledChange,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user