Skip to content

Commit f7f689b

Browse files
committed
refactor: replace antd Input with @cherrystudio/ui Input across components
1 parent 3911ee2 commit f7f689b

File tree

93 files changed

+178
-99
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+178
-99
lines changed

packages/ui/src/components/composites/CollapsibleSearchBar/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Original path: src/renderer/src/components/CollapsibleSearchBar.tsx
2-
import type { InputRef } from 'antd'
3-
import { Input } from 'antd'
42
import { Search } from 'lucide-react'
53
import { motion } from 'motion/react'
64
import React, { memo, useCallback, useEffect, useRef, useState } from 'react'
75

6+
import { Input } from '../../primitives/input'
87
import { Tooltip } from '../../primitives/tooltip'
98

109
interface CollapsibleSearchBarProps {
@@ -30,7 +29,7 @@ const CollapsibleSearchBar = ({
3029
}: CollapsibleSearchBarProps) => {
3130
const [searchVisible, setSearchVisible] = useState(false)
3231
const [searchText, setSearchText] = useState('')
33-
const inputRef = useRef<InputRef>(null)
32+
const inputRef = useRef<HTMLInputElement>(null)
3433

3534
const handleTextChange = useCallback(
3635
(text: string) => {

packages/ui/src/components/primitives/input.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { cn } from '@cherrystudio/ui/utils'
2+
import { EyeIcon } from 'lucide-react'
23
import React, { useMemo } from 'react'
34

5+
import { Button } from './button'
6+
47
export interface InputProps extends React.ComponentPropsWithRef<'input'> {
58
startContent?: React.ReactNode
69
endContent?: React.ReactNode
710
label?: string
811
caption?: string
912
}
1013

11-
export function Input({ className, type, required, label, caption, ...props }: InputProps) {
14+
export function Input({ startContent, endContent, className, type, required, label, caption, ...props }: InputProps) {
1215
const id = React.useId()
1316

1417
const input = useMemo(() => {
@@ -35,11 +38,20 @@ export function Input({ className, type, required, label, caption, ...props }: I
3538
return (
3639
<div className="flex flex-col w-full">
3740
<label htmlFor={id}>{label}</label>
41+
<div>{startContent}</div>
3842
{input}
43+
<div>
44+
<Button>
45+
<EyeIcon />
46+
</Button>
47+
{endContent}
48+
</div>
3949
{caption && <div className="text-muted-foreground">{caption}</div>}
4050
</div>
4151
)
4252
}
4353

4454
return input
4555
}
56+
57+
function InputPassword() {}

src/renderer/src/components/CollapsibleSearchBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tooltip } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import i18n from '@renderer/i18n'
34
import type { InputRef } from 'antd'
4-
import { Input } from 'antd'
55
import { Search } from 'lucide-react'
66
import { motion } from 'motion/react'
77
import React, { memo, useCallback, useEffect, useRef, useState } from 'react'

src/renderer/src/components/LocalBackupModals.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Button } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import { loggerService } from '@logger'
34
import { backupToLocal } from '@renderer/services/BackupService'
4-
import { Input, Modal } from 'antd'
5+
import { Modal } from 'antd'
56
import dayjs from 'dayjs'
67
import { useCallback, useState } from 'react'
78
import { useTranslation } from 'react-i18next'

src/renderer/src/components/NutstorePathSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RowFlex } from '@cherrystudio/ui'
22
import { Button } from '@cherrystudio/ui'
3+
import { Input } from '@cherrystudio/ui'
34
import { loggerService } from '@logger'
45
import { FolderIcon as NutstoreFolderIcon } from '@renderer/components/Icons/NutstoreIcons'
5-
import { Input } from 'antd'
66
import { useCallback, useEffect, useState } from 'react'
77
import { useTranslation } from 'react-i18next'
88
import styled from 'styled-components'

src/renderer/src/components/ObsidianExportDialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Switch } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import { usePreference } from '@data/hooks/usePreference'
34
import { loggerService } from '@logger'
45
import i18n from '@renderer/i18n'
@@ -11,7 +12,7 @@ import {
1112
messageToMarkdownWithReasoning,
1213
topicToMarkdown
1314
} from '@renderer/utils/export'
14-
import { Alert, Empty, Form, Input, Modal, Select, Spin, TreeSelect } from 'antd'
15+
import { Alert, Empty, Form, Modal, Select, Spin, TreeSelect } from 'antd'
1516
import React, { useEffect, useState } from 'react'
1617
const logger = loggerService.withContext('ObsidianExportDialog')
1718

src/renderer/src/components/Popups/AddAssistantPopup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RowFlex } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import { TopView } from '@renderer/components/TopView'
34
import { useAssistants, useDefaultAssistant } from '@renderer/hooks/useAssistant'
45
import { useAssistantPresets } from '@renderer/hooks/useAssistantPresets'
@@ -9,7 +10,7 @@ import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
910
import type { Assistant, AssistantPreset } from '@renderer/types'
1011
import { uuid } from '@renderer/utils'
1112
import type { InputRef } from 'antd'
12-
import { Divider, Input, Modal, Tag } from 'antd'
13+
import { Divider, Modal, Tag } from 'antd'
1314
import { take } from 'lodash'
1415
import { Search } from 'lucide-react'
1516
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'

src/renderer/src/components/Popups/ApiKeyListPopup/item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Button, Flex, Tooltip } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import { type HealthResult, HealthStatusIndicator } from '@renderer/components/HealthStatusIndicator'
34
import { EditIcon } from '@renderer/components/Icons'
45
import { StreamlineGoodHealthAndWellBeing } from '@renderer/components/Icons/SVGIcon'
56
import type { ApiKeyWithStatus } from '@renderer/types/healthCheck'
67
import { maskApiKey } from '@renderer/utils/api'
78
import type { InputRef } from 'antd'
8-
import { Input, List, Popconfirm, Typography } from 'antd'
9+
import { List, Popconfirm, Typography } from 'antd'
910
import { Check, Minus, X } from 'lucide-react'
1011
import type { FC } from 'react'
1112
import { memo, useEffect, useRef, useState } from 'react'

src/renderer/src/components/Popups/PromptPopup.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Box } from '@cherrystudio/ui'
2-
import { Input, Modal } from 'antd'
2+
import { Input } from '@cherrystudio/ui'
3+
import { Modal } from 'antd'
34
import type { TextAreaProps } from 'antd/es/input'
45
import type { ReactNode } from 'react'
56
import { useRef, useState } from 'react'

src/renderer/src/components/Popups/SelectModelPopup/searchbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RowFlex } from '@cherrystudio/ui'
2+
import { Input } from '@cherrystudio/ui'
23
import type { InputRef } from 'antd'
3-
import { Input } from 'antd'
44
import { Search } from 'lucide-react'
55
import React, { memo, useCallback, useEffect, useRef, useState } from 'react'
66
import { useTranslation } from 'react-i18next'

0 commit comments

Comments
 (0)