mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-13 20:28:16 +08:00

Co-authored-by: StyleZhang <jasonapring2015@outlook.com> Co-authored-by: Garfield Dai <dai.hai@foxmail.com> Co-authored-by: chenhe <guchenhe@gmail.com> Co-authored-by: jyong <jyong@dify.ai> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
44 lines
887 B
TypeScript
44 lines
887 B
TypeScript
import type { Dispatch, SetStateAction } from 'react'
|
|
|
|
export enum ValidatedStatus {
|
|
Success = 'success',
|
|
Error = 'error',
|
|
Exceed = 'exceed',
|
|
}
|
|
|
|
export type ValidatedStatusState = {
|
|
status?: ValidatedStatus
|
|
message?: string
|
|
}
|
|
|
|
export type Status = 'add' | 'fail' | 'success'
|
|
|
|
export type ValidateValue = Record<string, any>
|
|
|
|
export type ValidateCallback = {
|
|
before: (v?: ValidateValue) => boolean | undefined
|
|
run?: (v?: ValidateValue) => Promise<ValidatedStatusState>
|
|
}
|
|
|
|
export type Form = {
|
|
key: string
|
|
title: string
|
|
placeholder: string
|
|
value?: string
|
|
validate?: ValidateCallback
|
|
handleFocus?: (v: ValidateValue, dispatch: Dispatch<SetStateAction<ValidateValue>>) => void
|
|
}
|
|
|
|
export type KeyFrom = {
|
|
text: string
|
|
link: string
|
|
}
|
|
|
|
export type KeyValidatorProps = {
|
|
type: string
|
|
title: React.ReactNode
|
|
status: Status
|
|
forms: Form[]
|
|
keyFrom: KeyFrom
|
|
}
|