@vibe-forge/client 0.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/cli.cjs +6 -0
- package/index.html +27 -0
- package/package.json +42 -0
- package/src/App.tsx +174 -0
- package/src/api.ts +241 -0
- package/src/components/ArchiveView.scss +168 -0
- package/src/components/ArchiveView.tsx +299 -0
- package/src/components/AutomationView/AutomationView.scss +26 -0
- package/src/components/AutomationView/RuleFormPanel.scss +129 -0
- package/src/components/AutomationView/RuleFormPanel.tsx +257 -0
- package/src/components/AutomationView/RuleSidebar.scss +219 -0
- package/src/components/AutomationView/RuleSidebar.tsx +258 -0
- package/src/components/AutomationView/RunHistoryPanel.scss +286 -0
- package/src/components/AutomationView/RunHistoryPanel.tsx +320 -0
- package/src/components/AutomationView/TaskList.scss +128 -0
- package/src/components/AutomationView/TaskList.tsx +79 -0
- package/src/components/AutomationView/TriggerList.scss +153 -0
- package/src/components/AutomationView/TriggerList.tsx +217 -0
- package/src/components/AutomationView/index.tsx +228 -0
- package/src/components/AutomationView/types.ts +21 -0
- package/src/components/Chat.scss +89 -0
- package/src/components/Chat.tsx +92 -0
- package/src/components/ConfigView.scss +185 -0
- package/src/components/ConfigView.tsx +258 -0
- package/src/components/NavRail.scss +71 -0
- package/src/components/NavRail.tsx +188 -0
- package/src/components/Sidebar.scss +112 -0
- package/src/components/Sidebar.tsx +291 -0
- package/src/components/chat/ChatHeader.scss +401 -0
- package/src/components/chat/ChatHeader.tsx +342 -0
- package/src/components/chat/ChatHistoryView.tsx +122 -0
- package/src/components/chat/ChatSettingsView.tsx +22 -0
- package/src/components/chat/ChatTimelineView.scss +53 -0
- package/src/components/chat/ChatTimelineView.tsx +158 -0
- package/src/components/chat/CodeBlock.scss +87 -0
- package/src/components/chat/CodeBlock.tsx +179 -0
- package/src/components/chat/CompletionMenu.scss +70 -0
- package/src/components/chat/CompletionMenu.tsx +58 -0
- package/src/components/chat/CurrentTodoList.scss +217 -0
- package/src/components/chat/CurrentTodoList.tsx +103 -0
- package/src/components/chat/MarkdownContent.tsx +43 -0
- package/src/components/chat/MessageFooter.tsx +48 -0
- package/src/components/chat/MessageItem.scss +251 -0
- package/src/components/chat/MessageItem.tsx +78 -0
- package/src/components/chat/NewSessionGuide.scss +186 -0
- package/src/components/chat/NewSessionGuide.tsx +167 -0
- package/src/components/chat/Sender.scss +367 -0
- package/src/components/chat/Sender.tsx +541 -0
- package/src/components/chat/SessionTimelinePanel/EventList.scss +58 -0
- package/src/components/chat/SessionTimelinePanel/EventList.tsx +212 -0
- package/src/components/chat/SessionTimelinePanel/gantt.ts +177 -0
- package/src/components/chat/SessionTimelinePanel/git-graph.ts +518 -0
- package/src/components/chat/SessionTimelinePanel/index.scss +28 -0
- package/src/components/chat/SessionTimelinePanel/index.tsx +121 -0
- package/src/components/chat/SessionTimelinePanel/mermaid.ts +4 -0
- package/src/components/chat/SessionTimelinePanel/types.ts +64 -0
- package/src/components/chat/SessionTimelinePanel/utils.ts +20 -0
- package/src/components/chat/ThinkingStatus.scss +70 -0
- package/src/components/chat/ThinkingStatus.tsx +13 -0
- package/src/components/chat/ToolCallBox.scss +137 -0
- package/src/components/chat/ToolCallBox.tsx +55 -0
- package/src/components/chat/ToolGroup.scss +154 -0
- package/src/components/chat/ToolGroup.tsx +102 -0
- package/src/components/chat/ToolRenderer.tsx +45 -0
- package/src/components/chat/messageUtils.ts +171 -0
- package/src/components/chat/safeSerialize.ts +84 -0
- package/src/components/chat/tools/DefaultTool.tsx +63 -0
- package/src/components/chat/tools/adapter-claude/BashTool.scss +71 -0
- package/src/components/chat/tools/adapter-claude/BashTool.tsx +82 -0
- package/src/components/chat/tools/adapter-claude/GlobTool.scss +88 -0
- package/src/components/chat/tools/adapter-claude/GlobTool.tsx +85 -0
- package/src/components/chat/tools/adapter-claude/GrepTool.scss +96 -0
- package/src/components/chat/tools/adapter-claude/GrepTool.tsx +114 -0
- package/src/components/chat/tools/adapter-claude/LSTool.scss +85 -0
- package/src/components/chat/tools/adapter-claude/LSTool.tsx +94 -0
- package/src/components/chat/tools/adapter-claude/ReadTool.scss +57 -0
- package/src/components/chat/tools/adapter-claude/ReadTool.tsx +87 -0
- package/src/components/chat/tools/adapter-claude/TodoTool.scss +78 -0
- package/src/components/chat/tools/adapter-claude/TodoTool.tsx +60 -0
- package/src/components/chat/tools/adapter-claude/WriteTool.scss +92 -0
- package/src/components/chat/tools/adapter-claude/WriteTool.tsx +86 -0
- package/src/components/chat/tools/adapter-claude/components/FileList.scss +65 -0
- package/src/components/chat/tools/adapter-claude/components/FileList.tsx +185 -0
- package/src/components/chat/tools/adapter-claude/index.ts +28 -0
- package/src/components/chat/tools/defineToolRender.ts +28 -0
- package/src/components/chat/tools/task/GetTaskInfoTool.scss +50 -0
- package/src/components/chat/tools/task/GetTaskInfoTool.tsx +88 -0
- package/src/components/chat/tools/task/ListTasksTool.scss +56 -0
- package/src/components/chat/tools/task/ListTasksTool.tsx +83 -0
- package/src/components/chat/tools/task/StartTasksTool.scss +56 -0
- package/src/components/chat/tools/task/StartTasksTool.tsx +96 -0
- package/src/components/chat/tools/task/components/TaskToolCard.scss +127 -0
- package/src/components/chat/tools/task/components/TaskToolCard.tsx +177 -0
- package/src/components/chat/tools/task/index.ts +15 -0
- package/src/components/chat/useChatModels.tsx +206 -0
- package/src/components/chat/useChatSession.ts +370 -0
- package/src/components/config/ConfigAboutSection.scss +111 -0
- package/src/components/config/ConfigAboutSection.tsx +86 -0
- package/src/components/config/ConfigDisplayValue.scss +22 -0
- package/src/components/config/ConfigDisplayValue.tsx +62 -0
- package/src/components/config/ConfigEditors.scss +65 -0
- package/src/components/config/ConfigEditors.tsx +98 -0
- package/src/components/config/ConfigFieldRow.scss +97 -0
- package/src/components/config/ConfigFieldRow.tsx +36 -0
- package/src/components/config/ConfigSectionForm.scss +94 -0
- package/src/components/config/ConfigSectionForm.tsx +436 -0
- package/src/components/config/ConfigSectionPanel.tsx +67 -0
- package/src/components/config/ConfigShortcutInput.scss +11 -0
- package/src/components/config/ConfigShortcutInput.tsx +52 -0
- package/src/components/config/ConfigSourceSwitch.tsx +57 -0
- package/src/components/config/configSchema.ts +319 -0
- package/src/components/config/configUtils.ts +83 -0
- package/src/components/config/index.tsx +5 -0
- package/src/components/config/recordEditors/BooleanRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/BooleanRecordEditor.tsx +75 -0
- package/src/components/config/recordEditors/KeyValueEditor.scss +1 -0
- package/src/components/config/recordEditors/KeyValueEditor.tsx +97 -0
- package/src/components/config/recordEditors/McpServersRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/McpServersRecordEditor.tsx +258 -0
- package/src/components/config/recordEditors/ModelServicesRecordEditor.scss +1 -0
- package/src/components/config/recordEditors/ModelServicesRecordEditor.tsx +233 -0
- package/src/components/config/recordEditors/RecordEditors.scss +117 -0
- package/src/components/config/recordEditors/RecordJsonEditor.scss +1 -0
- package/src/components/config/recordEditors/RecordJsonEditor.tsx +113 -0
- package/src/components/config/recordEditors/index.tsx +5 -0
- package/src/components/knowledge-base/KnowledgeBaseView.scss +19 -0
- package/src/components/knowledge-base/KnowledgeBaseView.tsx +186 -0
- package/src/components/knowledge-base/components/ActionButton.scss +5 -0
- package/src/components/knowledge-base/components/ActionButton.tsx +9 -0
- package/src/components/knowledge-base/components/EmptyState.scss +19 -0
- package/src/components/knowledge-base/components/EmptyState.tsx +42 -0
- package/src/components/knowledge-base/components/EntitiesTab.scss +5 -0
- package/src/components/knowledge-base/components/EntitiesTab.tsx +80 -0
- package/src/components/knowledge-base/components/EntityItem.scss +82 -0
- package/src/components/knowledge-base/components/EntityItem.tsx +79 -0
- package/src/components/knowledge-base/components/EntityList.scss +5 -0
- package/src/components/knowledge-base/components/EntityList.tsx +70 -0
- package/src/components/knowledge-base/components/FilterBar.scss +21 -0
- package/src/components/knowledge-base/components/FilterBar.tsx +51 -0
- package/src/components/knowledge-base/components/FlowsTab.scss +5 -0
- package/src/components/knowledge-base/components/FlowsTab.tsx +80 -0
- package/src/components/knowledge-base/components/KnowledgeBaseHeader.scss +27 -0
- package/src/components/knowledge-base/components/KnowledgeBaseHeader.tsx +29 -0
- package/src/components/knowledge-base/components/KnowledgeList.scss +19 -0
- package/src/components/knowledge-base/components/KnowledgeList.tsx +19 -0
- package/src/components/knowledge-base/components/LoadingState.scss +5 -0
- package/src/components/knowledge-base/components/LoadingState.tsx +11 -0
- package/src/components/knowledge-base/components/MetaList.scss +19 -0
- package/src/components/knowledge-base/components/MetaList.tsx +18 -0
- package/src/components/knowledge-base/components/RulesTab.scss +5 -0
- package/src/components/knowledge-base/components/RulesTab.tsx +49 -0
- package/src/components/knowledge-base/components/SectionHeader.scss +22 -0
- package/src/components/knowledge-base/components/SectionHeader.tsx +21 -0
- package/src/components/knowledge-base/components/SkillsTab.scss +5 -0
- package/src/components/knowledge-base/components/SkillsTab.tsx +49 -0
- package/src/components/knowledge-base/components/SpecItem.scss +138 -0
- package/src/components/knowledge-base/components/SpecItem.tsx +131 -0
- package/src/components/knowledge-base/components/SpecList.scss +5 -0
- package/src/components/knowledge-base/components/SpecList.tsx +70 -0
- package/src/components/knowledge-base/components/TabContent.scss +8 -0
- package/src/components/knowledge-base/components/TabContent.tsx +17 -0
- package/src/components/knowledge-base/components/TabLabel.scss +10 -0
- package/src/components/knowledge-base/components/TabLabel.tsx +15 -0
- package/src/components/knowledge-base/index.tsx +1 -0
- package/src/components/sidebar/SessionItem.scss +256 -0
- package/src/components/sidebar/SessionItem.tsx +265 -0
- package/src/components/sidebar/SessionList.scss +92 -0
- package/src/components/sidebar/SessionList.tsx +166 -0
- package/src/components/sidebar/SidebarHeader.scss +79 -0
- package/src/components/sidebar/SidebarHeader.tsx +128 -0
- package/src/connectionManager.ts +172 -0
- package/src/hooks/useGlobalShortcut.ts +26 -0
- package/src/hooks/useQueryParams.ts +54 -0
- package/src/i18n.ts +22 -0
- package/src/main.tsx +41 -0
- package/src/resources/locales/en.json +765 -0
- package/src/resources/locales/zh.json +766 -0
- package/src/store/index.ts +23 -0
- package/src/styles/global.scss +100 -0
- package/src/utils/shortcutUtils.ts +88 -0
- package/src/vite-env.d.ts +12 -0
- package/src/ws.ts +33 -0
- package/vite.config.ts +26 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import './ConfigAboutSection.scss'
|
|
2
|
+
|
|
3
|
+
import type { AboutInfo } from '@vibe-forge/core'
|
|
4
|
+
import { useTranslation } from 'react-i18next'
|
|
5
|
+
|
|
6
|
+
export const AboutSection = ({ value }: { value?: AboutInfo }) => {
|
|
7
|
+
const { t } = useTranslation()
|
|
8
|
+
const aboutInfo = (value != null && typeof value === 'object')
|
|
9
|
+
? value
|
|
10
|
+
: undefined
|
|
11
|
+
const urls = aboutInfo?.urls
|
|
12
|
+
const version = aboutInfo?.version
|
|
13
|
+
const lastReleaseAt = aboutInfo?.lastReleaseAt
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className='config-about'>
|
|
17
|
+
<div className='config-about__card'>
|
|
18
|
+
<div className='config-about__app'>
|
|
19
|
+
<div className='config-about__app-icon'>
|
|
20
|
+
<span className='material-symbols-rounded'>auto_awesome</span>
|
|
21
|
+
</div>
|
|
22
|
+
<div className='config-about__app-info'>
|
|
23
|
+
<div className='config-about__app-title'>
|
|
24
|
+
{t('config.about.software')}
|
|
25
|
+
</div>
|
|
26
|
+
<div className='config-about__app-meta'>
|
|
27
|
+
<span className='config-about__app-version'>
|
|
28
|
+
{t('config.about.version')}: {version ?? t('config.about.unknown')}
|
|
29
|
+
</span>
|
|
30
|
+
<span className='config-about__app-date'>
|
|
31
|
+
{lastReleaseAt ?? t('config.about.unknown')}
|
|
32
|
+
</span>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
<a
|
|
37
|
+
className='config-about__primary'
|
|
38
|
+
href={urls?.releases ?? urls?.repo}
|
|
39
|
+
target='_blank'
|
|
40
|
+
rel='noreferrer'
|
|
41
|
+
>
|
|
42
|
+
{t('config.about.checkUpdate')}
|
|
43
|
+
</a>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div className='config-about__list'>
|
|
47
|
+
<a
|
|
48
|
+
className='config-about__item-row'
|
|
49
|
+
href={urls?.docs ?? urls?.repo}
|
|
50
|
+
target='_blank'
|
|
51
|
+
rel='noreferrer'
|
|
52
|
+
>
|
|
53
|
+
<span className='config-about__item-left'>
|
|
54
|
+
<span className='material-symbols-rounded config-about__item-icon'>menu_book</span>
|
|
55
|
+
<span>{t('config.about.docs')}</span>
|
|
56
|
+
</span>
|
|
57
|
+
<span className='material-symbols-rounded config-about__arrow'>open_in_new</span>
|
|
58
|
+
</a>
|
|
59
|
+
<a
|
|
60
|
+
className='config-about__item-row'
|
|
61
|
+
href={urls?.contact ?? urls?.repo}
|
|
62
|
+
target='_blank'
|
|
63
|
+
rel='noreferrer'
|
|
64
|
+
>
|
|
65
|
+
<span className='config-about__item-left'>
|
|
66
|
+
<span className='material-symbols-rounded config-about__item-icon'>mail</span>
|
|
67
|
+
<span>{t('config.about.contact')}</span>
|
|
68
|
+
</span>
|
|
69
|
+
<span className='material-symbols-rounded config-about__arrow'>open_in_new</span>
|
|
70
|
+
</a>
|
|
71
|
+
<a
|
|
72
|
+
className='config-about__item-row'
|
|
73
|
+
href={urls?.issues ?? urls?.repo}
|
|
74
|
+
target='_blank'
|
|
75
|
+
rel='noreferrer'
|
|
76
|
+
>
|
|
77
|
+
<span className='config-about__item-left'>
|
|
78
|
+
<span className='material-symbols-rounded config-about__item-icon'>bug_report</span>
|
|
79
|
+
<span>{t('config.about.feedback')}</span>
|
|
80
|
+
</span>
|
|
81
|
+
<span className='material-symbols-rounded config-about__arrow'>open_in_new</span>
|
|
82
|
+
</a>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.config-view__pill {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
height: 28px;
|
|
5
|
+
padding: 0 10px;
|
|
6
|
+
border-radius: 999px;
|
|
7
|
+
border: 1px solid var(--border-color);
|
|
8
|
+
background: var(--bg-color);
|
|
9
|
+
color: var(--text-color);
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.config-view__display-pill {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
gap: 6px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.config-view__field-list {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import './ConfigDisplayValue.scss'
|
|
2
|
+
|
|
3
|
+
import { Empty } from 'antd'
|
|
4
|
+
|
|
5
|
+
import { FieldRow } from './ConfigFieldRow'
|
|
6
|
+
import { getFieldDescription, getFieldLabel, getTypeIcon, getValueType, isEmptyValue } from './configUtils'
|
|
7
|
+
import type { TranslationFn } from './configUtils'
|
|
8
|
+
|
|
9
|
+
export const DisplayValue = ({
|
|
10
|
+
value,
|
|
11
|
+
sectionKey,
|
|
12
|
+
path = [],
|
|
13
|
+
t
|
|
14
|
+
}: {
|
|
15
|
+
value: unknown
|
|
16
|
+
sectionKey: string
|
|
17
|
+
path?: string[]
|
|
18
|
+
t: TranslationFn
|
|
19
|
+
}) => {
|
|
20
|
+
if (isEmptyValue(value)) {
|
|
21
|
+
return <Empty description={t('common.noData')} image={null} />
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
const hasObject = value.some(item => item != null && typeof item === 'object')
|
|
26
|
+
if (hasObject) {
|
|
27
|
+
return <span className='config-view__pill'>{t('config.editor.complexValue')}</span>
|
|
28
|
+
}
|
|
29
|
+
return (
|
|
30
|
+
<div className='config-view__display-pill'>
|
|
31
|
+
{value.map((item, index) => (
|
|
32
|
+
<span key={`${index}-${String(item)}`} className='config-view__pill'>
|
|
33
|
+
{String(item)}
|
|
34
|
+
</span>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (value != null && typeof value === 'object') {
|
|
41
|
+
return (
|
|
42
|
+
<div className='config-view__field-list'>
|
|
43
|
+
{Object.entries(value).map(([key, itemValue]) => {
|
|
44
|
+
const label = getFieldLabel(t, sectionKey, [...path, key], key)
|
|
45
|
+
const description = getFieldDescription(t, sectionKey, [...path, key])
|
|
46
|
+
return (
|
|
47
|
+
<FieldRow
|
|
48
|
+
key={key}
|
|
49
|
+
title={label}
|
|
50
|
+
description={description}
|
|
51
|
+
icon={getTypeIcon(getValueType(itemValue))}
|
|
52
|
+
>
|
|
53
|
+
<DisplayValue value={itemValue} sectionKey={sectionKey} path={[...path, key]} t={t} />
|
|
54
|
+
</FieldRow>
|
|
55
|
+
)
|
|
56
|
+
})}
|
|
57
|
+
</div>
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return <span className='config-view__pill'>{String(value)}</span>
|
|
62
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.config-view__array-list {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 8px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.config-view__array-item {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 8px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.config-view__complex-editor {
|
|
14
|
+
border-radius: 10px;
|
|
15
|
+
border: 1px solid var(--code-border);
|
|
16
|
+
background: var(--code-bg);
|
|
17
|
+
color: var(--text-color);
|
|
18
|
+
font-family:
|
|
19
|
+
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
|
|
20
|
+
'Courier New', monospace;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.config-view__complex-editor textarea {
|
|
24
|
+
background: transparent;
|
|
25
|
+
color: var(--text-color);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.config-view__icon-button {
|
|
29
|
+
width: 32px;
|
|
30
|
+
height: 32px;
|
|
31
|
+
min-width: 32px;
|
|
32
|
+
padding: 0;
|
|
33
|
+
display: inline-flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.config-view__icon-button--compact {
|
|
39
|
+
width: 28px;
|
|
40
|
+
height: 28px;
|
|
41
|
+
min-width: 28px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.config-view__icon-button--full {
|
|
45
|
+
width: 100%;
|
|
46
|
+
min-width: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.config-view__array-add {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 8px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.config-view__array-add-inputs {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: 8px;
|
|
59
|
+
flex: 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.config-view__array-add-inputs .ant-input,
|
|
63
|
+
.config-view__array-add-inputs .ant-input-affix-wrapper {
|
|
64
|
+
flex: 1;
|
|
65
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import './ConfigEditors.scss'
|
|
2
|
+
|
|
3
|
+
import { App, Button, Input, Tooltip } from 'antd'
|
|
4
|
+
import { useEffect, useState } from 'react'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
|
|
7
|
+
import type { TranslationFn } from './configUtils'
|
|
8
|
+
|
|
9
|
+
export const ComplexTextEditor = ({
|
|
10
|
+
value,
|
|
11
|
+
onChange
|
|
12
|
+
}: {
|
|
13
|
+
value: unknown
|
|
14
|
+
onChange?: (nextValue: unknown) => void
|
|
15
|
+
}) => {
|
|
16
|
+
const { message } = App.useApp()
|
|
17
|
+
const { t } = useTranslation()
|
|
18
|
+
const [textValue, setTextValue] = useState(() => JSON.stringify(value ?? {}, null, 2))
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setTextValue(JSON.stringify(value ?? {}, null, 2))
|
|
22
|
+
}, [value])
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Input.TextArea
|
|
26
|
+
className='config-view__complex-editor'
|
|
27
|
+
value={textValue}
|
|
28
|
+
onChange={(event) => {
|
|
29
|
+
setTextValue(event.target.value)
|
|
30
|
+
}}
|
|
31
|
+
onBlur={() => {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = JSON.parse(textValue) as unknown
|
|
34
|
+
onChange?.(parsed)
|
|
35
|
+
setTextValue(JSON.stringify(parsed ?? {}, null, 2))
|
|
36
|
+
} catch {
|
|
37
|
+
void message.error(t('config.invalidJson'))
|
|
38
|
+
setTextValue(JSON.stringify(value ?? {}, null, 2))
|
|
39
|
+
}
|
|
40
|
+
}}
|
|
41
|
+
placeholder={t('config.editor.complexPlaceholder')}
|
|
42
|
+
autoSize={{ minRows: 6 }}
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const StringArrayEditor = ({
|
|
48
|
+
value,
|
|
49
|
+
onChange,
|
|
50
|
+
t
|
|
51
|
+
}: {
|
|
52
|
+
value: string[]
|
|
53
|
+
onChange: (nextValue: string[]) => void
|
|
54
|
+
t: TranslationFn
|
|
55
|
+
}) => (
|
|
56
|
+
<div className='config-view__array-list'>
|
|
57
|
+
{value.map((item, index) => (
|
|
58
|
+
<div key={`${index}-${item}`} className='config-view__array-item'>
|
|
59
|
+
<Input
|
|
60
|
+
value={item}
|
|
61
|
+
placeholder={t('config.editor.itemPlaceholder')}
|
|
62
|
+
onChange={(event) => {
|
|
63
|
+
const updated = value.slice()
|
|
64
|
+
updated[index] = event.target.value
|
|
65
|
+
onChange(updated)
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
<Tooltip title={t('config.editor.remove')}>
|
|
69
|
+
<Button
|
|
70
|
+
size='small'
|
|
71
|
+
type='text'
|
|
72
|
+
danger
|
|
73
|
+
className='config-view__icon-button config-view__icon-button--compact'
|
|
74
|
+
aria-label={t('config.editor.remove')}
|
|
75
|
+
icon={<span className='material-symbols-rounded'>delete</span>}
|
|
76
|
+
onClick={() => {
|
|
77
|
+
const updated = value.slice()
|
|
78
|
+
updated.splice(index, 1)
|
|
79
|
+
onChange(updated)
|
|
80
|
+
}}
|
|
81
|
+
/>
|
|
82
|
+
</Tooltip>
|
|
83
|
+
</div>
|
|
84
|
+
))}
|
|
85
|
+
<Tooltip title={t('config.editor.addItem')}>
|
|
86
|
+
<Button
|
|
87
|
+
size='small'
|
|
88
|
+
type='primary'
|
|
89
|
+
className='config-view__icon-button config-view__icon-button--full'
|
|
90
|
+
aria-label={t('config.editor.addItem')}
|
|
91
|
+
icon={<span className='material-symbols-rounded'>add</span>}
|
|
92
|
+
onClick={() => {
|
|
93
|
+
onChange([...value, ''])
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
</Tooltip>
|
|
97
|
+
</div>
|
|
98
|
+
)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
.config-view__field-row {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: space-between;
|
|
5
|
+
gap: 16px;
|
|
6
|
+
padding: 12px 14px;
|
|
7
|
+
border-radius: 0;
|
|
8
|
+
border: 1px solid var(--border-color);
|
|
9
|
+
border-bottom: none;
|
|
10
|
+
background-color: var(--sub-bg-color);
|
|
11
|
+
&.config-view__collapse-group {
|
|
12
|
+
padding: 0;
|
|
13
|
+
gap: 0;
|
|
14
|
+
> .ant-collapse-item {
|
|
15
|
+
width: 100%;
|
|
16
|
+
border-bottom: 1px solid var(--border-color);
|
|
17
|
+
.ant-collapse-header-text {
|
|
18
|
+
flex-grow: 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.config-view__field-row:first-child {
|
|
24
|
+
border-top-left-radius: 8px;
|
|
25
|
+
border-top-right-radius: 8px;
|
|
26
|
+
}
|
|
27
|
+
.config-view__field-row:last-child {
|
|
28
|
+
border-bottom-left-radius: 8px;
|
|
29
|
+
border-bottom-right-radius: 8px;
|
|
30
|
+
border-bottom: 1px solid var(--border-color);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.config-view__field-row--stacked {
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: stretch;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.config-view__field-row--stacked .config-view__field-control {
|
|
39
|
+
justify-content: flex-start;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.config-view__field-row--stacked .config-view__field-control > * {
|
|
45
|
+
flex: 1 1 auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.config-view__field-meta {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
gap: 10px;
|
|
52
|
+
min-width: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.config-view__field-text {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 2px;
|
|
59
|
+
min-width: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.config-view__field-title {
|
|
63
|
+
font-size: 13px;
|
|
64
|
+
font-weight: 600;
|
|
65
|
+
color: var(--text-color);
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
text-overflow: ellipsis;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.config-view__field-desc {
|
|
72
|
+
font-size: 12px;
|
|
73
|
+
color: var(--sub-text-color);
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
text-overflow: ellipsis;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.config-view__field-control {
|
|
80
|
+
display: flex;
|
|
81
|
+
justify-content: flex-end;
|
|
82
|
+
gap: 8px;
|
|
83
|
+
min-width: 220px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.config-view__field-control .ant-select {
|
|
87
|
+
width: 100%;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.config-view__field-control .ant-input-textarea {
|
|
91
|
+
width: 100%;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.config-view__field-icon {
|
|
95
|
+
font-size: 16px;
|
|
96
|
+
color: var(--sub-text-color);
|
|
97
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import './ConfigFieldRow.scss'
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
export const FieldRow = ({
|
|
6
|
+
title,
|
|
7
|
+
description,
|
|
8
|
+
icon,
|
|
9
|
+
layout = 'inline',
|
|
10
|
+
children
|
|
11
|
+
}: {
|
|
12
|
+
title: string
|
|
13
|
+
description?: string
|
|
14
|
+
icon?: string
|
|
15
|
+
layout?: 'inline' | 'stacked'
|
|
16
|
+
children: ReactNode
|
|
17
|
+
}) => (
|
|
18
|
+
<div className={`config-view__field-row${layout === 'stacked' ? ' config-view__field-row--stacked' : ''}`}>
|
|
19
|
+
<div className='config-view__field-meta'>
|
|
20
|
+
{icon != null && (
|
|
21
|
+
<span className='material-symbols-rounded config-view__field-icon'>
|
|
22
|
+
{icon}
|
|
23
|
+
</span>
|
|
24
|
+
)}
|
|
25
|
+
<div className='config-view__field-text'>
|
|
26
|
+
<div className='config-view__field-title'>{title}</div>
|
|
27
|
+
{description != null && description !== '' && (
|
|
28
|
+
<div className='config-view__field-desc'>{description}</div>
|
|
29
|
+
)}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<div className='config-view__field-control'>
|
|
33
|
+
{children}
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
.config-view__field-stack {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 14px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.config-view__field-list {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.config-view__subsection {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.config-view__subsection-title {
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
font-weight: 600;
|
|
21
|
+
color: var(--sub-text-color);
|
|
22
|
+
text-transform: uppercase;
|
|
23
|
+
letter-spacing: .04em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.config-view__subsection-body {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.config-view__slider {
|
|
32
|
+
width: 240px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.config-view__collapse-group {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
gap: 12px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.config-view__collapse-group .ant-collapse-header {
|
|
42
|
+
padding: 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.config-view__collapse-header {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: space-between;
|
|
49
|
+
flex-direction: row;
|
|
50
|
+
gap: 6px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.config-view__collapse-header-main {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: 2px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.config-view__collapse-title {
|
|
60
|
+
font-size: 13px;
|
|
61
|
+
color: var(--text-color);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.config-view__collapse-desc {
|
|
65
|
+
font-size: 12px;
|
|
66
|
+
color: var(--sub-text-color);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.config-view__multiline {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 8px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.config-view__multiline-input {
|
|
76
|
+
width: 100%;
|
|
77
|
+
border-radius: 10px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.config-view__option {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
gap: 2px;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.config-view__option-title {
|
|
87
|
+
font-size: 13px;
|
|
88
|
+
color: var(--text-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.config-view__option-desc {
|
|
92
|
+
font-size: 12px;
|
|
93
|
+
color: var(--sub-text-color);
|
|
94
|
+
}
|