wwf
2025-05-20 938c3e5a587ce950a94964ea509b9e7f8834dfae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import {
  memo,
  useCallback,
  useState,
} from 'react'
import Textarea from 'react-textarea-autosize'
import { useTranslation } from 'react-i18next'
 
type TitleInputProps = {
  value: string
  onBlur: (value: string) => void
}
 
export const TitleInput = memo(({
  value,
  onBlur,
}: TitleInputProps) => {
  const { t } = useTranslation()
  const [localValue, setLocalValue] = useState(value)
 
  const handleBlur = () => {
    if (!localValue) {
      setLocalValue(value)
      onBlur(value)
      return
    }
 
    onBlur(localValue)
  }
 
  return (
    <input
      value={localValue}
      onChange={e => setLocalValue(e.target.value)}
      className={`
        system-xl-semibold mr-2 h-7 min-w-0 grow appearance-none rounded-md border border-transparent bg-transparent px-1 text-text-primary
        outline-none focus:shadow-xs
      `}
      placeholder={t('workflow.common.addTitle') || ''}
      onBlur={handleBlur}
    />
  )
})
TitleInput.displayName = 'TitleInput'
 
type DescriptionInputProps = {
  value: string
  onChange: (value: string) => void
}
export const DescriptionInput = memo(({
  value,
  onChange,
}: DescriptionInputProps) => {
  const { t } = useTranslation()
  const [focus, setFocus] = useState(false)
  const handleFocus = useCallback(() => {
    setFocus(true)
  }, [])
  const handleBlur = useCallback(() => {
    setFocus(false)
  }, [])
 
  return (
    <div
      className={`
        leading-0 group flex max-h-[60px] overflow-y-auto rounded-lg bg-components-panel-bg
        px-2 py-[5px]
        ${focus && '!shadow-xs'}
      `}
    >
      <Textarea
        value={value}
        onChange={e => onChange(e.target.value)}
        minRows={1}
        onFocus={handleFocus}
        onBlur={handleBlur}
        className={`
          w-full resize-none appearance-none bg-transparent text-xs
          leading-[18px] text-text-primary caret-[#295EFF]
          outline-none placeholder:text-text-quaternary
        `}
        placeholder={t('workflow.common.addDescription') || ''}
      />
    </div>
  )
})
DescriptionInput.displayName = 'DescriptionInput'