declarations.ts 887 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import type { Dispatch, SetStateAction } from 'react'
  2. export enum ValidatedStatus {
  3. Success = 'success',
  4. Error = 'error',
  5. Exceed = 'exceed',
  6. }
  7. export type ValidatedStatusState = {
  8. status?: ValidatedStatus
  9. message?: string
  10. }
  11. export type Status = 'add' | 'fail' | 'success'
  12. export type ValidateValue = Record<string, any>
  13. export type ValidateCallback = {
  14. before: (v?: ValidateValue) => boolean | undefined
  15. run?: (v?: ValidateValue) => Promise<ValidatedStatusState>
  16. }
  17. export type Form = {
  18. key: string
  19. title: string
  20. placeholder: string
  21. value?: string
  22. validate?: ValidateCallback
  23. handleFocus?: (v: ValidateValue, dispatch: Dispatch<SetStateAction<ValidateValue>>) => void
  24. }
  25. export type KeyFrom = {
  26. text: string
  27. link: string
  28. }
  29. export type KeyValidatorProps = {
  30. type: string
  31. title: React.ReactNode
  32. status: Status
  33. forms: Form[]
  34. keyFrom: KeyFrom
  35. }