mirror of
https://github.com/langgenius/dify.git
synced 2026-05-01 22:47:15 +08:00
chore: clean up
This commit is contained in:
parent
5469f6c846
commit
496f87e028
@ -1,4 +1,4 @@
|
|||||||
import type { CSSProperties, ChangeEventHandler } from 'react'
|
import type { CSSProperties, ChangeEventHandler, FocusEventHandler } from 'react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiCloseCircleFill, RiErrorWarningLine, RiSearchLine } from '@remixicon/react'
|
import { RiCloseCircleFill, RiErrorWarningLine, RiSearchLine } from '@remixicon/react'
|
||||||
@ -61,7 +61,7 @@ const Input = ({
|
|||||||
}
|
}
|
||||||
onChange(e)
|
onChange(e)
|
||||||
}
|
}
|
||||||
const handleNumberCommit: React.FocusEventHandler<HTMLInputElement> = (e) => {
|
const handleNumberBlur: FocusEventHandler<HTMLInputElement> = (e) => {
|
||||||
// remove leading zeros
|
// remove leading zeros
|
||||||
const formattedValue = e.target.value.replace(/^(-?)0+(?=\d)/, '$1')
|
const formattedValue = e.target.value.replace(/^(-?)0+(?=\d)/, '$1')
|
||||||
if (e.target.value !== formattedValue) {
|
if (e.target.value !== formattedValue) {
|
||||||
@ -97,7 +97,7 @@ const Input = ({
|
|||||||
: (t('common.placeholder.input') || ''))}
|
: (t('common.placeholder.input') || ''))}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={props.type === 'number' ? handleNumberChange : onChange}
|
onChange={props.type === 'number' ? handleNumberChange : onChange}
|
||||||
onBlur={props.type === 'number' ? handleNumberCommit : onBlur}
|
onBlur={props.type === 'number' ? handleNumberBlur : onBlur}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user