mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 09:28:04 +08:00
feat(web): base-ui slider (#34064)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -11,9 +11,9 @@ vi.mock('../../hooks', () => ({
|
||||
useLanguage: () => 'en_US',
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/base/slider', () => ({
|
||||
default: ({ onChange }: { onChange: (v: number) => void }) => (
|
||||
<button onClick={() => onChange(2)} data-testid="slider-btn">Slide 2</button>
|
||||
vi.mock('@/app/components/base/ui/slider', () => ({
|
||||
Slider: ({ onValueChange }: { onValueChange: (v: number) => void }) => (
|
||||
<button onClick={() => onValueChange(2)} data-testid="slider-btn">Slide 2</button>
|
||||
),
|
||||
}))
|
||||
|
||||
|
||||
@ -7,10 +7,10 @@ import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import PromptEditor from '@/app/components/base/prompt-editor'
|
||||
import Radio from '@/app/components/base/radio'
|
||||
import Slider from '@/app/components/base/slider'
|
||||
import Switch from '@/app/components/base/switch'
|
||||
import TagInput from '@/app/components/base/tag-input'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/app/components/base/ui/select'
|
||||
import { Slider } from '@/app/components/base/ui/slider'
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/app/components/base/ui/tooltip'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { cn } from '@/utils/classnames'
|
||||
@ -78,6 +78,7 @@ function ParameterItem({
|
||||
}
|
||||
|
||||
const renderValue = value ?? localValue ?? getDefaultValue()
|
||||
const sliderLabel = parameterRule.label[language] || parameterRule.label.en_US
|
||||
|
||||
const handleInputChange = (newValue: ParameterValue) => {
|
||||
setLocalValue(newValue)
|
||||
@ -170,7 +171,8 @@ function ParameterItem({
|
||||
min={parameterRule.min}
|
||||
max={parameterRule.max}
|
||||
step={step}
|
||||
onChange={handleSlideChange}
|
||||
onValueChange={handleSlideChange}
|
||||
aria-label={sliderLabel}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
@ -197,7 +199,8 @@ function ParameterItem({
|
||||
min={parameterRule.min}
|
||||
max={parameterRule.max}
|
||||
step={0.1}
|
||||
onChange={handleSlideChange}
|
||||
onValueChange={handleSlideChange}
|
||||
aria-label={sliderLabel}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
@ -337,9 +340,9 @@ function ParameterItem({
|
||||
}
|
||||
<div
|
||||
className="mr-0.5 truncate text-text-secondary system-xs-regular"
|
||||
title={parameterRule.label[language] || parameterRule.label.en_US}
|
||||
title={sliderLabel}
|
||||
>
|
||||
{parameterRule.label[language] || parameterRule.label.en_US}
|
||||
{sliderLabel}
|
||||
</div>
|
||||
{
|
||||
parameterRule.help && (
|
||||
|
||||
Reference in New Issue
Block a user