@lokvis/ui-react 0.2.0 → 0.2.2
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/dist/components/AssetPanel.d.ts.map +1 -1
- package/dist/components/AssetPanel.js +14 -14
- package/dist/components/AssetPanel.js.map +1 -1
- package/dist/components/Canvas.d.ts +4 -4
- package/dist/components/Canvas.d.ts.map +1 -1
- package/dist/components/Canvas.js +8 -8
- package/dist/components/Canvas.js.map +1 -1
- package/dist/components/CommandPalette.d.ts +7 -7
- package/dist/components/CommandPalette.d.ts.map +1 -1
- package/dist/components/CommandPalette.js +10 -10
- package/dist/components/CommandPalette.js.map +1 -1
- package/dist/components/CompareSlider.d.ts +6 -6
- package/dist/components/CompareSlider.d.ts.map +1 -1
- package/dist/components/CompareSlider.js +7 -7
- package/dist/components/CompareSlider.js.map +1 -1
- package/dist/components/DownloadPanel.d.ts +3 -3
- package/dist/components/DownloadPanel.d.ts.map +1 -1
- package/dist/components/DownloadPanel.js +9 -9
- package/dist/components/DownloadPanel.js.map +1 -1
- package/dist/components/ErrorBanner.d.ts +2 -2
- package/dist/components/ErrorBanner.d.ts.map +1 -1
- package/dist/components/ErrorBanner.js +3 -3
- package/dist/components/ErrorBanner.js.map +1 -1
- package/dist/components/ExifPanel.d.ts +1 -1
- package/dist/components/ExifPanel.d.ts.map +1 -1
- package/dist/components/ExifPanel.js +2 -2
- package/dist/components/ExifPanel.js.map +1 -1
- package/dist/components/GlobalDropzone.d.ts +5 -5
- package/dist/components/GlobalDropzone.d.ts.map +1 -1
- package/dist/components/GlobalDropzone.js +6 -6
- package/dist/components/GlobalDropzone.js.map +1 -1
- package/dist/components/HistoryPanel.d.ts +2 -2
- package/dist/components/HistoryPanel.d.ts.map +1 -1
- package/dist/components/HistoryPanel.js +23 -23
- package/dist/components/HistoryPanel.js.map +1 -1
- package/dist/components/Inspector.d.ts.map +1 -1
- package/dist/components/Inspector.js +6 -6
- package/dist/components/Inspector.js.map +1 -1
- package/dist/components/ParamForm.d.ts.map +1 -1
- package/dist/components/ParamForm.js +7 -7
- package/dist/components/ParamForm.js.map +1 -1
- package/dist/components/PipelineBar.d.ts.map +1 -1
- package/dist/components/PipelineBar.js +13 -13
- package/dist/components/PipelineBar.js.map +1 -1
- package/dist/components/ProgressBar.d.ts +4 -4
- package/dist/components/ProgressBar.d.ts.map +1 -1
- package/dist/components/ProgressBar.js +8 -8
- package/dist/components/ProgressBar.js.map +1 -1
- package/dist/components/StatusBar.d.ts +3 -3
- package/dist/components/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar.js +11 -11
- package/dist/components/StatusBar.js.map +1 -1
- package/dist/components/ThemeToggle.d.ts +4 -4
- package/dist/components/ThemeToggle.d.ts.map +1 -1
- package/dist/components/ThemeToggle.js +7 -7
- package/dist/components/ThemeToggle.js.map +1 -1
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +2 -2
- package/dist/components/Toolbar.js.map +1 -1
- package/dist/components/WorkflowEditor.d.ts +6 -6
- package/dist/components/WorkflowEditor.d.ts.map +1 -1
- package/dist/components/WorkflowEditor.js +25 -25
- package/dist/components/WorkflowEditor.js.map +1 -1
- package/dist/components/WorkflowTemplates.d.ts +2 -2
- package/dist/components/WorkflowTemplates.d.ts.map +1 -1
- package/dist/components/WorkflowTemplates.js +3 -3
- package/dist/components/WorkflowTemplates.js.map +1 -1
- package/dist/components/Workspace.d.ts +22 -22
- package/dist/components/Workspace.d.ts.map +1 -1
- package/dist/components/Workspace.js +30 -30
- package/dist/components/Workspace.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/AssetPanel.tsx +263 -263
- package/src/components/Canvas.tsx +174 -174
- package/src/components/CommandPalette.tsx +242 -242
- package/src/components/CompareSlider.tsx +163 -163
- package/src/components/DownloadPanel.tsx +203 -203
- package/src/components/ErrorBanner.tsx +64 -64
- package/src/components/ExifPanel.tsx +154 -154
- package/src/components/GlobalDropzone.tsx +170 -170
- package/src/components/HistoryPanel.tsx +219 -219
- package/src/components/Inspector.tsx +136 -136
- package/src/components/ParamForm.tsx +136 -136
- package/src/components/PipelineBar.tsx +98 -98
- package/src/components/ProgressBar.tsx +78 -78
- package/src/components/StatusBar.tsx +148 -148
- package/src/components/ThemeToggle.tsx +98 -98
- package/src/components/Toolbar.tsx +65 -65
- package/src/components/WorkflowEditor.tsx +321 -321
- package/src/components/WorkflowTemplates.tsx +77 -77
- package/src/components/Workspace.tsx +223 -223
- package/src/css-modules.d.ts +3 -0
- package/src/index.ts +4 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* 适合新用户快速上手,无需从零编排。
|
|
6
6
|
*
|
|
7
7
|
* 集成位置:
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* - 可作为独立组件渲染(如在 Inspector 底部或 Command Palette 中)
|
|
9
|
+
* - Workspace 默认不渲染;由消费方按需挂载
|
|
10
10
|
*
|
|
11
11
|
* @module WorkflowTemplates
|
|
12
12
|
*/
|
|
@@ -17,85 +17,85 @@ import { useWorkspaceStore } from '../store/index.js';
|
|
|
17
17
|
import { WORKFLOW_TEMPLATES, type WorkflowTemplate } from '../data/workflow-templates.js';
|
|
18
18
|
|
|
19
19
|
export interface WorkflowTemplatesProps {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
className?: string;
|
|
21
|
+
/** 应用模板前是否需要确认(当前有节点时默认 true) */
|
|
22
|
+
confirmIfNotEmpty?: boolean;
|
|
23
|
+
/** 模板应用后的回调 */
|
|
24
|
+
onApply?: (template: WorkflowTemplate) => void;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function WorkflowTemplates({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
className = '',
|
|
29
|
+
confirmIfNotEmpty = true,
|
|
30
|
+
onApply,
|
|
31
31
|
}: WorkflowTemplatesProps) {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const loadWorkflowTemplate = useWorkspaceStore((s) => s.loadWorkflowTemplate);
|
|
33
|
+
const nodes = useWorkspaceStore((s) => s.nodes);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const handleApply = (tpl: WorkflowTemplate) => {
|
|
36
|
+
if (confirmIfNotEmpty && nodes.length > 0) {
|
|
37
|
+
if (!window.confirm(`应用模板「${tpl.name}」将替换当前 ${nodes.length} 个节点,继续?`)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
loadWorkflowTemplate(
|
|
42
|
+
tpl.nodes.map((n) => ({ capability: n.capability, params: n.params }))
|
|
43
|
+
);
|
|
44
|
+
onApply?.(tpl);
|
|
45
|
+
};
|
|
46
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
className={`flex flex-col ${className}`}
|
|
50
|
+
role="region"
|
|
51
|
+
aria-label="工作流模板"
|
|
52
|
+
>
|
|
53
|
+
<div className="flex items-center justify-between px-3 py-2 border-b border-[var(--lokvis-border)]">
|
|
54
|
+
<span className="text-[11px] font-semibold uppercase tracking-wider text-[var(--lokvis-fg-subtle)]">
|
|
55
|
+
Templates
|
|
56
|
+
</span>
|
|
57
|
+
<span className="text-[10px] text-[var(--lokvis-fg-subtle)]">{WORKFLOW_TEMPLATES.length} 内置</span>
|
|
58
|
+
</div>
|
|
59
|
+
<div className="grid grid-cols-1 gap-1.5 p-2">
|
|
60
|
+
{WORKFLOW_TEMPLATES.map((tpl) => (
|
|
61
|
+
<button
|
|
62
|
+
key={tpl.id}
|
|
63
|
+
type="button"
|
|
64
|
+
onClick={() => handleApply(tpl)}
|
|
65
|
+
className="group flex items-start gap-2 rounded-md border border-[var(--lokvis-border)] bg-[var(--lokvis-surface)] px-2.5 py-2 text-left transition-all hover:border-[var(--lokvis-primary)]/50 hover:bg-[var(--lokvis-primary)]/10/50"
|
|
66
|
+
>
|
|
67
|
+
<span className="mt-0.5 text-base leading-none">{tpl.icon}</span>
|
|
68
|
+
<div className="flex-1 min-w-0">
|
|
69
|
+
<div className="flex items-center justify-between gap-1">
|
|
70
|
+
<span className="truncate text-[11px] font-medium text-[var(--lokvis-fg-muted)]">
|
|
71
|
+
{tpl.name}
|
|
72
|
+
</span>
|
|
73
|
+
<span className="shrink-0 rounded bg-[var(--lokvis-surface-muted)] px-1 py-0.5 text-[9px] font-medium uppercase text-[var(--lokvis-fg-muted)]">
|
|
74
|
+
{tpl.nodes.length} 步
|
|
75
|
+
</span>
|
|
76
|
+
</div>
|
|
77
|
+
<p className="mt-0.5 truncate text-[10px] text-[var(--lokvis-fg-muted)]">
|
|
78
|
+
{tpl.description}
|
|
79
|
+
</p>
|
|
80
|
+
{/* 节点链预览 */}
|
|
81
|
+
<div className="mt-1 flex flex-wrap items-center gap-0.5">
|
|
82
|
+
{tpl.nodes.map((n, i) => (
|
|
83
|
+
<React.Fragment key={i}>
|
|
84
|
+
{i > 0 && (
|
|
85
|
+
<Icon size={8} className="text-[var(--lokvis-fg-subtle)]">
|
|
86
|
+
<path d="m5 5 5 5-5 5" />
|
|
87
|
+
</Icon>
|
|
88
|
+
)}
|
|
89
|
+
<code className="rounded bg-[var(--lokvis-surface-muted)] px-1 py-0.5 text-[9px] text-[var(--lokvis-fg-muted)]">
|
|
90
|
+
{n.capability}
|
|
91
|
+
</code>
|
|
92
|
+
</React.Fragment>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</button>
|
|
97
|
+
))}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
101
|
}
|