diff --git a/web/app/components/base/select/index.tsx b/web/app/components/base/select/index.tsx index dee983690b..660899412b 100644 --- a/web/app/components/base/select/index.tsx +++ b/web/app/components/base/select/index.tsx @@ -24,7 +24,7 @@ const defaultItems = [ export type Item = { value: number | string name: string -} +} & Record export type ISelectProps = { className?: string @@ -38,6 +38,13 @@ export type ISelectProps = { placeholder?: string overlayClassName?: string optionClassName?: string + renderOption?: ({ + item, + selected, + }: { + item: Item + selected: boolean + }) => React.ReactNode } const Select: FC = ({ className, @@ -49,6 +56,7 @@ const Select: FC = ({ bgClassName = 'bg-gray-100', overlayClassName, optionClassName, + renderOption, }) => { const [query, setQuery] = useState('') const [open, setOpen] = useState(false) @@ -61,6 +69,7 @@ const Select: FC = ({ defaultSelect = existed setSelectedItem(defaultSelect) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [defaultValue]) const filteredItems: Item[] @@ -120,24 +129,30 @@ const Select: FC = ({ value={item} className={({ active }: { active: boolean }) => classNames( - optionClassName, 'relative cursor-default select-none py-2 pl-3 pr-9 rounded-lg hover:bg-gray-100 text-gray-700', active ? 'bg-gray-100' : '', + optionClassName, ) } > {({ /* active, */ selected }) => ( <> - {item.name} - {selected && ( - - - )} + {renderOption + ? renderOption({ item, selected }) + : ( + <> + {item.name} + {selected && ( + + + )} + + )} )} @@ -157,6 +172,8 @@ const SimpleSelect: FC = ({ disabled = false, onSelect, placeholder, + optionClassName, + renderOption, }) => { const { t } = useTranslation() const localPlaceholder = placeholder || t('common.placeholder.select') @@ -169,6 +186,7 @@ const SimpleSelect: FC = ({ defaultSelect = existed setSelectedItem(defaultSelect) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [defaultValue]) return ( @@ -218,24 +236,30 @@ const SimpleSelect: FC = ({ - `relative cursor-pointer select-none py-2 pl-3 pr-9 rounded-lg hover:bg-gray-100 text-gray-700 ${active ? 'bg-gray-100' : '' - }` + classNames( + `relative cursor-pointer select-none py-2 pl-3 pr-9 rounded-lg hover:bg-gray-100 text-gray-700 ${active ? 'bg-gray-100' : ''}`, + optionClassName, + ) } value={item} disabled={disabled} > {({ /* active, */ selected }) => ( <> - {item.name} - {selected && ( - + {item.name} + {selected && ( + + )} - > - - )} + )} )} diff --git a/web/app/components/workflow/nodes/list-filter/components/filter-condition.tsx b/web/app/components/workflow/nodes/list-filter/components/filter-condition.tsx new file mode 100644 index 0000000000..5fa89c566b --- /dev/null +++ b/web/app/components/workflow/nodes/list-filter/components/filter-condition.tsx @@ -0,0 +1,11 @@ +'use client' +import type { FC } from 'react' +import React from 'react' + +const FilterCondition: FC = () => { + return ( +
+
+ ) +} +export default React.memo(FilterCondition) diff --git a/web/app/components/workflow/nodes/list-filter/components/sub-variable-picker.tsx b/web/app/components/workflow/nodes/list-filter/components/sub-variable-picker.tsx new file mode 100644 index 0000000000..bb973bf799 --- /dev/null +++ b/web/app/components/workflow/nodes/list-filter/components/sub-variable-picker.tsx @@ -0,0 +1,36 @@ +'use client' +import type { FC } from 'react' +import React from 'react' +import { SimpleSelect as Select } from '@/app/components/base/select' +import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development' + +const SubVariablePicker: FC = () => { + const renderOption = ({ item }: { item: Record }) => { + return ( +
+
+ + {item.name} +
+ {item.type} +
+ ) + } + return ( +
+