@svadmin/ui 0.120.0 → 0.122.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.
Files changed (125) hide show
  1. package/dist/app.css +336 -7
  2. package/dist/app.theme.css +336 -7
  3. package/dist/components/AboutSettings.svelte +1 -1
  4. package/dist/components/AnnouncementBanner.svelte +314 -0
  5. package/dist/components/AnnouncementBanner.svelte.d.ts +45 -0
  6. package/dist/components/AsyncExportModal.svelte +551 -0
  7. package/dist/components/AsyncExportModal.svelte.d.ts +50 -0
  8. package/dist/components/AudioFeedbackProvider.svelte +131 -0
  9. package/dist/components/AudioFeedbackProvider.svelte.d.ts +11 -0
  10. package/dist/components/AuditLogViewer.svelte +1 -1
  11. package/dist/components/CanvasAnnotation.svelte +1 -1
  12. package/dist/components/ColumnFilterBuilder.svelte +135 -0
  13. package/dist/components/ColumnFilterBuilder.svelte.d.ts +20 -0
  14. package/dist/components/ColumnSettings.svelte +1 -1
  15. package/dist/components/ColumnVisibilityDrawer.svelte +541 -0
  16. package/dist/components/ColumnVisibilityDrawer.svelte.d.ts +16 -0
  17. package/dist/components/ConcurrentConflictModal.svelte +7 -7
  18. package/dist/components/ContextMenu.svelte +268 -0
  19. package/dist/components/ContextMenu.svelte.d.ts +22 -0
  20. package/dist/components/ConversionFunnel.svelte +154 -0
  21. package/dist/components/ConversionFunnel.svelte.d.ts +22 -0
  22. package/dist/components/CronExpressionBuilder.svelte +1 -1
  23. package/dist/components/DecisionTable.svelte +1 -1
  24. package/dist/components/DevTools.svelte +1 -1
  25. package/dist/components/DraggableRowTable.svelte +1 -1
  26. package/dist/components/DualApprovalGate.svelte +418 -0
  27. package/dist/components/DualApprovalGate.svelte.d.ts +39 -0
  28. package/dist/components/EditableTable.svelte +1 -1
  29. package/dist/components/ExcelImportWizard.svelte +2 -2
  30. package/dist/components/GlobalShortcuts.svelte +1 -1
  31. package/dist/components/ImageCropper.svelte +1 -1
  32. package/dist/components/ImportWizard.svelte +1 -1
  33. package/dist/components/JsonSchemaForm.svelte +1 -1
  34. package/dist/components/JsonViewer.svelte +323 -0
  35. package/dist/components/JsonViewer.svelte.d.ts +20 -0
  36. package/dist/components/KeyboardShortcutsModal.svelte +362 -0
  37. package/dist/components/KeyboardShortcutsModal.svelte.d.ts +22 -0
  38. package/dist/components/KpiCard.svelte +250 -0
  39. package/dist/components/KpiCard.svelte.d.ts +44 -0
  40. package/dist/components/MasterDetailView.svelte +1 -1
  41. package/dist/components/MetricGrid.svelte +2 -2
  42. package/dist/components/MicroAppBridge.svelte +59 -0
  43. package/dist/components/MicroAppBridge.svelte.d.ts +11 -0
  44. package/dist/components/OfflineSyncBanner.svelte +1 -1
  45. package/dist/components/OrgChart.svelte +1 -1
  46. package/dist/components/OrgTreePicker.svelte +1 -1
  47. package/dist/components/OtpInput.svelte +209 -0
  48. package/dist/components/OtpInput.svelte.d.ts +17 -0
  49. package/dist/components/PdfDocumentViewer.svelte +2 -2
  50. package/dist/components/PivotDrilldownModal.svelte +6 -6
  51. package/dist/components/PivotTable.svelte +1 -1
  52. package/dist/components/PricingCard.svelte +1 -1
  53. package/dist/components/PricingTable.svelte +1 -1
  54. package/dist/components/PrintableBill.svelte +2 -2
  55. package/dist/components/PrintableReportLayout.svelte +259 -0
  56. package/dist/components/PrintableReportLayout.svelte.d.ts +32 -0
  57. package/dist/components/ProSkeleton.svelte +6 -6
  58. package/dist/components/RecordCompareModal.svelte +428 -0
  59. package/dist/components/RecordCompareModal.svelte.d.ts +42 -0
  60. package/dist/components/ResultPage.svelte +166 -0
  61. package/dist/components/ResultPage.svelte.d.ts +28 -0
  62. package/dist/components/SafeDeleteConfirm.svelte +5 -5
  63. package/dist/components/SankeyChart.svelte +111 -0
  64. package/dist/components/SankeyChart.svelte.d.ts +22 -0
  65. package/dist/components/SchemaVisualModeler.svelte +336 -0
  66. package/dist/components/SchemaVisualModeler.svelte.d.ts +17 -0
  67. package/dist/components/SensitiveDataMask.svelte +81 -22
  68. package/dist/components/SensitiveDataMask.svelte.d.ts +15 -10
  69. package/dist/components/SessionTimeoutGuard.svelte +154 -0
  70. package/dist/components/SessionTimeoutGuard.svelte.d.ts +25 -0
  71. package/dist/components/SignaturePad.svelte +231 -67
  72. package/dist/components/SignaturePad.svelte.d.ts +6 -5
  73. package/dist/components/SliderCaptcha.svelte +1 -1
  74. package/dist/components/SplitPaneLayout.svelte +1 -1
  75. package/dist/components/SpreadsheetView.svelte +1 -1
  76. package/dist/components/StepForm.svelte +1 -1
  77. package/dist/components/StepWizard.svelte +513 -0
  78. package/dist/components/StepWizard.svelte.d.ts +49 -0
  79. package/dist/components/TableClipboardManager.svelte +307 -0
  80. package/dist/components/TableClipboardManager.svelte.d.ts +13 -0
  81. package/dist/components/TaskCenter.svelte +9 -9
  82. package/dist/components/TextDiffViewer.svelte +613 -0
  83. package/dist/components/TextDiffViewer.svelte.d.ts +39 -0
  84. package/dist/components/Tour.svelte +71 -13
  85. package/dist/components/Tour.svelte.d.ts +1 -1
  86. package/dist/components/TreeTransfer.svelte +1 -1
  87. package/dist/components/TrendIndicator.svelte +21 -13
  88. package/dist/components/TrendIndicator.svelte.d.ts +4 -2
  89. package/dist/components/UnsavedChangesGuard.svelte +138 -0
  90. package/dist/components/UnsavedChangesGuard.svelte.d.ts +32 -0
  91. package/dist/components/UsageCard.svelte +1 -1
  92. package/dist/components/VersionDiffViewer.svelte +1 -1
  93. package/dist/components/VirtualTable.svelte +1 -1
  94. package/dist/components/VirtualTreeSelect.svelte +1 -1
  95. package/dist/components/WatermarkContainer.svelte +196 -0
  96. package/dist/components/WatermarkContainer.svelte.d.ts +20 -0
  97. package/dist/components/WorkflowDesigner.svelte +3 -3
  98. package/dist/components/WorkflowProcessCard.svelte +1 -1
  99. package/dist/components/WorkflowStepper.svelte +250 -0
  100. package/dist/components/WorkflowStepper.svelte.d.ts +27 -0
  101. package/dist/components/charts/GaugeChart.svelte +1 -1
  102. package/dist/components/useAudioAlert.d.svelte.ts +1 -0
  103. package/dist/components/useAudioAlert.svelte.d.ts +13 -0
  104. package/dist/components/useAudioAlert.svelte.js +90 -0
  105. package/dist/components/useHotkeys.d.svelte.ts +1 -0
  106. package/dist/components/useHotkeys.svelte.d.ts +44 -0
  107. package/dist/components/useHotkeys.svelte.js +190 -0
  108. package/dist/components/useMicroAppEvent.d.svelte.ts +1 -0
  109. package/dist/components/useMicroAppEvent.svelte.d.ts +16 -0
  110. package/dist/components/useMicroAppEvent.svelte.js +61 -0
  111. package/dist/components/usePrintExport.d.svelte.ts +1 -0
  112. package/dist/components/usePrintExport.svelte.d.ts +11 -0
  113. package/dist/components/usePrintExport.svelte.js +45 -0
  114. package/dist/components/useSessionTimeout.d.svelte.ts +1 -0
  115. package/dist/components/useSessionTimeout.svelte.d.ts +28 -0
  116. package/dist/components/useSessionTimeout.svelte.js +182 -0
  117. package/dist/components/useTableClipboard.d.svelte.ts +1 -0
  118. package/dist/components/useTableClipboard.svelte.d.ts +28 -0
  119. package/dist/components/useTableClipboard.svelte.js +116 -0
  120. package/dist/components/useUnsavedChanges.d.svelte.ts +1 -0
  121. package/dist/components/useUnsavedChanges.svelte.d.ts +22 -0
  122. package/dist/components/useUnsavedChanges.svelte.js +105 -0
  123. package/dist/index.d.ts +47 -28
  124. package/dist/index.js +49 -2
  125. package/package.json +1 -1
@@ -0,0 +1,196 @@
1
+ <script lang="ts">
2
+ import { onMount, onDestroy, type Snippet } from 'svelte';
3
+ import { cn } from '../utils.js';
4
+
5
+ export interface WatermarkContainerProps {
6
+ content?: string | string[];
7
+ image?: string;
8
+ width?: number;
9
+ height?: number;
10
+ rotate?: number;
11
+ fontSize?: number;
12
+ fontFamily?: string;
13
+ color?: string;
14
+ gapX?: number;
15
+ gapY?: number;
16
+ zIndex?: number;
17
+ antiTamper?: boolean;
18
+ class?: string;
19
+ children?: Snippet;
20
+ }
21
+
22
+ let {
23
+ content = 'CONFIDENTIAL',
24
+ image,
25
+ width = 240,
26
+ height = 140,
27
+ rotate = -22,
28
+ fontSize = 14,
29
+ fontFamily = 'sans-serif',
30
+ color = 'rgba(128, 128, 128, 0.18)',
31
+ gapX = 48,
32
+ gapY = 48,
33
+ zIndex = 9999,
34
+ antiTamper = true,
35
+ class: className = '',
36
+ children,
37
+ }: WatermarkContainerProps = $props();
38
+
39
+ let containerEl = $state<HTMLDivElement | null>(null);
40
+ let overlayEl = $state<HTMLDivElement | null>(null);
41
+ let watermarkDataUrl = $state<string>('');
42
+
43
+ let observer: MutationObserver | null = null;
44
+
45
+ function renderWatermarkCanvas(): string {
46
+ if (typeof document === 'undefined') return '';
47
+
48
+ try {
49
+ const canvas = document.createElement('canvas');
50
+ const totalWidth = width + gapX;
51
+ const totalHeight = height + gapY;
52
+
53
+ const dpr = typeof window !== 'undefined' ? (window.devicePixelRatio || 1) : 1;
54
+ canvas.width = totalWidth * dpr;
55
+ canvas.height = totalHeight * dpr;
56
+
57
+ const ctx = canvas.getContext('2d');
58
+ if (!ctx) return '';
59
+
60
+ ctx.scale(dpr, dpr);
61
+ ctx.translate(totalWidth / 2, totalHeight / 2);
62
+ ctx.rotate((rotate * Math.PI) / 180);
63
+
64
+ if (image) {
65
+ const img = new Image();
66
+ img.crossOrigin = 'anonymous';
67
+ img.src = image;
68
+ ctx.drawImage(img, -width / 2, -height / 2, width, height);
69
+ return typeof canvas.toDataURL === 'function' ? canvas.toDataURL() : '';
70
+ }
71
+
72
+ const lines = Array.isArray(content) ? content : [content];
73
+ ctx.font = `${fontSize}px ${fontFamily}`;
74
+ ctx.fillStyle = color;
75
+ ctx.textAlign = 'center';
76
+ ctx.textBaseline = 'middle';
77
+
78
+ const lineHeight = fontSize * 1.4;
79
+ const initialY = -((lines.length - 1) * lineHeight) / 2;
80
+
81
+ lines.forEach((line, index) => {
82
+ ctx.fillText(line, 0, initialY + index * lineHeight);
83
+ });
84
+
85
+ return typeof canvas.toDataURL === 'function' ? canvas.toDataURL() : '';
86
+ } catch {
87
+ return '';
88
+ }
89
+ }
90
+
91
+ function applyOverlayStyle() {
92
+ if (!overlayEl) return;
93
+ overlayEl.style.position = 'absolute';
94
+ overlayEl.style.top = '0';
95
+ overlayEl.style.left = '0';
96
+ overlayEl.style.width = '100%';
97
+ overlayEl.style.height = '100%';
98
+ overlayEl.style.pointerEvents = 'none';
99
+ overlayEl.style.zIndex = String(zIndex);
100
+ overlayEl.style.backgroundRepeat = 'repeat';
101
+ overlayEl.style.display = 'block';
102
+ overlayEl.style.visibility = 'visible';
103
+ overlayEl.style.opacity = '1';
104
+ if (watermarkDataUrl) {
105
+ overlayEl.style.backgroundImage = `url("${watermarkDataUrl}")`;
106
+ overlayEl.style.backgroundSize = `${width + gapX}px ${height + gapY}px`;
107
+ }
108
+ }
109
+
110
+ function reobserve() {
111
+ if (!observer || !containerEl || !overlayEl) return;
112
+ observer.observe(containerEl, {
113
+ childList: true,
114
+ subtree: false,
115
+ });
116
+ observer.observe(overlayEl, {
117
+ attributes: true,
118
+ attributeFilter: ['style', 'class', 'hidden'],
119
+ });
120
+ }
121
+
122
+ function setupAntiTamper() {
123
+ if (!antiTamper || typeof MutationObserver === 'undefined' || !containerEl || !overlayEl) return;
124
+
125
+ observer?.disconnect();
126
+ observer = new MutationObserver((mutations) => {
127
+ if (!containerEl || !overlayEl) return;
128
+
129
+ let needRestore = false;
130
+
131
+ for (const m of mutations) {
132
+ if (m.type === 'childList') {
133
+ if (!containerEl.contains(overlayEl)) {
134
+ needRestore = true;
135
+ break;
136
+ }
137
+ } else if (m.type === 'attributes' && m.target === overlayEl) {
138
+ const style = overlayEl.getAttribute('style') || '';
139
+ if (
140
+ style.includes('display: none') ||
141
+ style.includes('visibility: hidden') ||
142
+ style.includes('opacity: 0') ||
143
+ !style.includes('pointer-events: none')
144
+ ) {
145
+ needRestore = true;
146
+ break;
147
+ }
148
+ }
149
+ }
150
+
151
+ if (needRestore) {
152
+ observer?.disconnect();
153
+ if (!containerEl.contains(overlayEl)) {
154
+ // eslint-disable-next-line svelte/no-dom-manipulating -- Anti-tamper security restores overlay when removed by client
155
+ containerEl.appendChild(overlayEl);
156
+ }
157
+ applyOverlayStyle();
158
+ reobserve();
159
+ }
160
+ });
161
+
162
+ reobserve();
163
+ }
164
+
165
+ $effect(() => {
166
+ // Access props to track reactivity
167
+ void [content, image, width, height, rotate, fontSize, fontFamily, color, gapX, gapY];
168
+ watermarkDataUrl = renderWatermarkCanvas();
169
+ applyOverlayStyle();
170
+ });
171
+
172
+ onMount(() => {
173
+ watermarkDataUrl = renderWatermarkCanvas();
174
+ applyOverlayStyle();
175
+ setupAntiTamper();
176
+ });
177
+
178
+ onDestroy(() => {
179
+ observer?.disconnect();
180
+ observer = null;
181
+ });
182
+ </script>
183
+
184
+ <div
185
+ bind:this={containerEl}
186
+ class={cn('relative overflow-hidden', className)}
187
+ data-svadmin-component="WatermarkContainer"
188
+ >
189
+ {@render children?.()}
190
+ <div
191
+ bind:this={overlayEl}
192
+ class="pointer-events-none absolute inset-0 select-none"
193
+ data-svadmin-watermark-overlay="true"
194
+ aria-hidden="true"
195
+ ></div>
196
+ </div>
@@ -0,0 +1,20 @@
1
+ import { type Snippet } from 'svelte';
2
+ export interface WatermarkContainerProps {
3
+ content?: string | string[];
4
+ image?: string;
5
+ width?: number;
6
+ height?: number;
7
+ rotate?: number;
8
+ fontSize?: number;
9
+ fontFamily?: string;
10
+ color?: string;
11
+ gapX?: number;
12
+ gapY?: number;
13
+ zIndex?: number;
14
+ antiTamper?: boolean;
15
+ class?: string;
16
+ children?: Snippet;
17
+ }
18
+ declare const WatermarkContainer: import("svelte").Component<WatermarkContainerProps, {}, "">;
19
+ type WatermarkContainer = ReturnType<typeof WatermarkContainer>;
20
+ export default WatermarkContainer;
@@ -168,7 +168,7 @@
168
168
 
169
169
  <div class="flex items-center gap-1">
170
170
  {#if node.status}
171
- <span class={cn('rounded-[2px] border px-1.5 py-0.2 text-[10px] font-normal leading-tight', getStatusTone(node.status))}>
171
+ <span class={cn('rounded-[2px] border px-1.5 py-0.2 text-xs font-normal leading-tight', getStatusTone(node.status))}>
172
172
  {node.status}
173
173
  </span>
174
174
  {/if}
@@ -205,7 +205,7 @@
205
205
  {#if node.assignees && node.assignees.length > 0}
206
206
  <div class="mt-2 flex flex-wrap gap-1">
207
207
  {#each node.assignees as assignee (assignee)}
208
- <span class="rounded-[2px] bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground">
208
+ <span class="rounded-[2px] bg-muted px-1.5 py-0.5 text-xs text-muted-foreground">
209
209
  {assignee}
210
210
  </span>
211
211
  {/each}
@@ -213,7 +213,7 @@
213
213
  {/if}
214
214
 
215
215
  {#if node.error}
216
- <span class="mt-1 text-[11px] text-destructive">
216
+ <span class="mt-1 text-xs text-destructive">
217
217
  {node.error}
218
218
  </span>
219
219
  {/if}
@@ -49,7 +49,7 @@
49
49
  <div
50
50
  data-svadmin-component="WorkflowProcessCard"
51
51
  class={cn(
52
- 'rounded-xl border border-border bg-card p-6 text-card-foreground shadow-sm transition-all space-y-6',
52
+ 'rounded-md border border-border bg-card p-6 text-card-foreground shadow-sm transition-all space-y-6',
53
53
  className,
54
54
  )}
55
55
  >
@@ -0,0 +1,250 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import {
4
+ AlertTriangle,
5
+ Check,
6
+ Clock,
7
+ Loader2,
8
+ RotateCcw,
9
+ SkipForward,
10
+ XCircle,
11
+ } from '@lucide/svelte';
12
+ import { useTranslation } from '@svadmin/core/i18n';
13
+ import { cn } from '../utils.js';
14
+ import { Button } from './ui/button/index.js';
15
+ import { Progress } from './ui/progress/index.js';
16
+
17
+ export type WorkflowStepStatus =
18
+ | 'wait'
19
+ | 'pending'
20
+ | 'process'
21
+ | 'running'
22
+ | 'finish'
23
+ | 'completed'
24
+ | 'error'
25
+ | 'failed'
26
+ | 'blocked'
27
+ | 'skipped';
28
+
29
+ export interface WorkflowStepItem {
30
+ id: string;
31
+ label: string;
32
+ description?: string | undefined;
33
+ status: WorkflowStepStatus;
34
+ durationMs?: number | undefined;
35
+ startedAt?: string | undefined;
36
+ errorMessage?: string | undefined;
37
+ retryable?: boolean | undefined;
38
+ meta?: Record<string, string | number> | undefined;
39
+ }
40
+
41
+ export interface WorkflowStepperProps {
42
+ steps: WorkflowStepItem[];
43
+ activeId?: string | undefined;
44
+ direction?: 'horizontal' | 'vertical' | undefined;
45
+ title?: string | undefined;
46
+ showProgress?: boolean | undefined;
47
+ onSelect?: ((step: WorkflowStepItem) => void) | undefined;
48
+ onRetry?: ((step: WorkflowStepItem) => void) | undefined;
49
+ stepDetail?: Snippet<[WorkflowStepItem]> | undefined;
50
+ class?: string | undefined;
51
+ }
52
+
53
+ let {
54
+ steps,
55
+ activeId = $bindable<string | undefined>(undefined),
56
+ direction = 'vertical',
57
+ title,
58
+ showProgress = true,
59
+ onSelect,
60
+ onRetry,
61
+ stepDetail,
62
+ class: className = '',
63
+ }: WorkflowStepperProps = $props();
64
+
65
+ const i18n = useTranslation();
66
+ const chinese = $derived(i18n.locale.startsWith('zh'));
67
+
68
+ type NormalizedState = 'wait' | 'process' | 'finish' | 'error' | 'blocked' | 'skipped';
69
+
70
+ function normalizeState(status: WorkflowStepStatus): NormalizedState {
71
+ switch (status) {
72
+ case 'finish':
73
+ case 'completed':
74
+ return 'finish';
75
+ case 'process':
76
+ case 'running':
77
+ return 'process';
78
+ case 'error':
79
+ case 'failed':
80
+ return 'error';
81
+ case 'blocked':
82
+ return 'blocked';
83
+ case 'skipped':
84
+ return 'skipped';
85
+ default:
86
+ return 'wait';
87
+ }
88
+ }
89
+
90
+ function formatDuration(ms: number | undefined): string | null {
91
+ if (ms === undefined || !Number.isFinite(ms)) return null;
92
+ if (ms < 1000) return `${ms}ms`;
93
+ return `${(ms / 1000).toFixed(1)}s`;
94
+ }
95
+
96
+ const completedCount = $derived(
97
+ steps.filter((s) => {
98
+ const n = normalizeState(s.status);
99
+ return n === 'finish' || n === 'skipped';
100
+ }).length,
101
+ );
102
+
103
+ const progressPercentage = $derived(
104
+ steps.length > 0 ? Math.round((completedCount / steps.length) * 100) : 0,
105
+ );
106
+
107
+ function selectStep(step: WorkflowStepItem) {
108
+ activeId = step.id;
109
+ onSelect?.(step);
110
+ }
111
+ </script>
112
+
113
+ <div
114
+ data-svadmin-component="WorkflowStepper"
115
+ data-direction={direction}
116
+ class={cn(
117
+ 'rounded-xl border border-border bg-card text-card-foreground shadow-xs p-5 space-y-4',
118
+ className,
119
+ )}
120
+ >
121
+ {#if title || showProgress}
122
+ <div class="space-y-2 border-b border-border/60 pb-3">
123
+ <div class="flex items-center justify-between gap-2">
124
+ {#if title}
125
+ <h3 class="text-sm font-semibold text-foreground">{title}</h3>
126
+ {:else}
127
+ <span class="text-xs font-medium text-muted-foreground">
128
+ {chinese ? '任务执行进度' : 'Workflow Progress'}
129
+ </span>
130
+ {/if}
131
+ <span class="text-xs font-mono text-muted-foreground">
132
+ {completedCount}/{steps.length} ({progressPercentage}%)
133
+ </span>
134
+ </div>
135
+ {#if showProgress}
136
+ <Progress value={progressPercentage} class="h-1.5" />
137
+ {/if}
138
+ </div>
139
+ {/if}
140
+
141
+ <ol
142
+ class={cn(
143
+ 'flex m-0 p-0 list-none',
144
+ direction === 'vertical' ? 'flex-col gap-3' : 'flex-row gap-2 overflow-x-auto pb-2',
145
+ )}
146
+ >
147
+ {#each steps as step, index (step.id)}
148
+ {@const state = normalizeState(step.status)}
149
+ {@const duration = formatDuration(step.durationMs)}
150
+ {@const isSelected = activeId === step.id}
151
+ <li
152
+ data-step-id={step.id}
153
+ data-step-status={state}
154
+ class={cn(
155
+ 'relative flex',
156
+ direction === 'vertical' ? 'flex-col' : 'flex-1 min-w-44 items-start gap-2',
157
+ )}
158
+ >
159
+ <div
160
+ class={cn(
161
+ 'flex items-start justify-between gap-3 rounded-lg border p-3 transition-all',
162
+ isSelected ? 'border-primary bg-primary/5 ring-1 ring-primary/20' : 'border-border/60 bg-background hover:bg-muted/30',
163
+ direction === 'horizontal' && 'w-full',
164
+ )}
165
+ >
166
+ <button
167
+ type="button"
168
+ onclick={() => selectStep(step)}
169
+ aria-current={state === 'process' ? 'step' : undefined}
170
+ class="flex items-start gap-3 text-left flex-1 min-w-0 bg-transparent border-0 p-0 cursor-pointer"
171
+ >
172
+ <span
173
+ class={cn(
174
+ 'flex h-7 w-7 shrink-0 items-center justify-center rounded-full border mt-0.5',
175
+ state === 'finish' && 'border-success/30 bg-success/15 text-success',
176
+ state === 'process' && 'border-primary/40 bg-primary/15 text-primary',
177
+ state === 'error' && 'border-destructive/30 bg-destructive/15 text-destructive',
178
+ state === 'blocked' && 'border-warning/40 bg-warning/15 text-warning',
179
+ state === 'skipped' && 'border-border bg-muted text-muted-foreground',
180
+ state === 'wait' && 'border-border bg-card text-muted-foreground',
181
+ )}
182
+ >
183
+ {#if state === 'finish'}
184
+ <Check class="h-3.5 w-3.5" />
185
+ {:else if state === 'process'}
186
+ <Loader2 class="h-3.5 w-3.5 animate-spin" />
187
+ {:else if state === 'error'}
188
+ <XCircle class="h-3.5 w-3.5" />
189
+ {:else if state === 'blocked'}
190
+ <AlertTriangle class="h-3.5 w-3.5" />
191
+ {:else if state === 'skipped'}
192
+ <SkipForward class="h-3.5 w-3.5" />
193
+ {:else}
194
+ <Clock class="h-3.5 w-3.5" />
195
+ {/if}
196
+ </span>
197
+
198
+ <div class="min-w-0 flex-1 space-y-0.5">
199
+ <div class="flex items-center gap-2">
200
+ <span class="text-xs font-semibold text-foreground truncate">{step.label}</span>
201
+ {#if duration}
202
+ <span class="text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded">
203
+ {duration}
204
+ </span>
205
+ {/if}
206
+ </div>
207
+
208
+ {#if step.description}
209
+ <p class="text-[11px] text-muted-foreground line-clamp-2">{step.description}</p>
210
+ {/if}
211
+
212
+ {#if step.errorMessage && state === 'error'}
213
+ <p class="text-[11px] text-destructive mt-1 font-medium">{step.errorMessage}</p>
214
+ {/if}
215
+
216
+ {#if stepDetail}
217
+ <div class="pt-1.5">
218
+ {@render stepDetail(step)}
219
+ </div>
220
+ {/if}
221
+ </div>
222
+ </button>
223
+
224
+ {#if state === 'error' && step.retryable !== false && onRetry}
225
+ <Button
226
+ type="button"
227
+ variant="outline"
228
+ size="sm"
229
+ class="h-7 px-2 text-[11px] gap-1 shrink-0"
230
+ onclick={() => onRetry(step)}
231
+ >
232
+ <RotateCcw class="h-3 w-3" />
233
+ {chinese ? '重试' : 'Retry'}
234
+ </Button>
235
+ {/if}
236
+ </div>
237
+
238
+ {#if direction === 'vertical' && index < steps.length - 1}
239
+ <div
240
+ class={cn(
241
+ 'ml-6 my-1 w-0.5 h-3 rounded-full',
242
+ state === 'finish' ? 'bg-success/60' : 'bg-border',
243
+ )}
244
+ aria-hidden="true"
245
+ ></div>
246
+ {/if}
247
+ </li>
248
+ {/each}
249
+ </ol>
250
+ </div>
@@ -0,0 +1,27 @@
1
+ import type { Snippet } from 'svelte';
2
+ export type WorkflowStepStatus = 'wait' | 'pending' | 'process' | 'running' | 'finish' | 'completed' | 'error' | 'failed' | 'blocked' | 'skipped';
3
+ export interface WorkflowStepItem {
4
+ id: string;
5
+ label: string;
6
+ description?: string | undefined;
7
+ status: WorkflowStepStatus;
8
+ durationMs?: number | undefined;
9
+ startedAt?: string | undefined;
10
+ errorMessage?: string | undefined;
11
+ retryable?: boolean | undefined;
12
+ meta?: Record<string, string | number> | undefined;
13
+ }
14
+ export interface WorkflowStepperProps {
15
+ steps: WorkflowStepItem[];
16
+ activeId?: string | undefined;
17
+ direction?: 'horizontal' | 'vertical' | undefined;
18
+ title?: string | undefined;
19
+ showProgress?: boolean | undefined;
20
+ onSelect?: ((step: WorkflowStepItem) => void) | undefined;
21
+ onRetry?: ((step: WorkflowStepItem) => void) | undefined;
22
+ stepDetail?: Snippet<[WorkflowStepItem]> | undefined;
23
+ class?: string | undefined;
24
+ }
25
+ declare const WorkflowStepper: import("svelte").Component<WorkflowStepperProps, {}, "activeId">;
26
+ type WorkflowStepper = ReturnType<typeof WorkflowStepper>;
27
+ export default WorkflowStepper;
@@ -303,7 +303,7 @@
303
303
  data-tone={activeTone}
304
304
  data-gauge-type={type}
305
305
  class={cn(
306
- 'relative flex flex-col items-center justify-between rounded-xl border border-border bg-card p-4 text-card-foreground shadow-sm transition-all',
306
+ 'relative flex flex-col items-center justify-between rounded-md border border-border bg-card p-4 text-card-foreground shadow-sm transition-all',
307
307
  className,
308
308
  )}
309
309
  style="width: {widthPx}px;"
@@ -0,0 +1 @@
1
+ export * from './useAudioAlert.svelte.js';
@@ -0,0 +1,13 @@
1
+ export type AudioAlertType = 'success' | 'error' | 'warning' | 'beep' | 'notify';
2
+ export interface AudioAlertOptions {
3
+ volume?: number | undefined;
4
+ muted?: boolean | undefined;
5
+ }
6
+ export declare function playAudioAlert(alertType: AudioAlertType): void;
7
+ export declare function useAudioAlert(options?: AudioAlertOptions): {
8
+ readonly isMuted: boolean;
9
+ readonly volume: number;
10
+ setMuted: (val: boolean) => void;
11
+ setVolume: (val: number) => void;
12
+ play: (type: AudioAlertType) => void;
13
+ };
@@ -0,0 +1,90 @@
1
+ // Global singleton audio state shared across the app
2
+ let globalAudioCtx = null;
3
+ let isMutedState = false;
4
+ let globalVolume = 0.7;
5
+ function getAudioContext() {
6
+ if (typeof window === 'undefined')
7
+ return null;
8
+ const AudioCtx = window.AudioContext || window.webkitAudioContext;
9
+ if (!AudioCtx)
10
+ return null;
11
+ if (!globalAudioCtx) {
12
+ globalAudioCtx = new AudioCtx();
13
+ }
14
+ if (globalAudioCtx.state === 'suspended') {
15
+ void globalAudioCtx.resume().catch(() => { });
16
+ }
17
+ return globalAudioCtx;
18
+ }
19
+ function playTone(freqs, durationSeconds, type = 'sine', gainPeak = 0.3) {
20
+ if (isMutedState || globalVolume <= 0)
21
+ return;
22
+ const ctx = getAudioContext();
23
+ if (!ctx)
24
+ return;
25
+ const now = ctx.currentTime;
26
+ const masterGain = ctx.createGain();
27
+ masterGain.gain.setValueAtTime(globalVolume * gainPeak, now);
28
+ masterGain.connect(ctx.destination);
29
+ freqs.forEach((freq, idx) => {
30
+ const osc = ctx.createOscillator();
31
+ const noteGain = ctx.createGain();
32
+ osc.type = type;
33
+ osc.frequency.setValueAtTime(freq, now + idx * 0.08);
34
+ noteGain.gain.setValueAtTime(1, now + idx * 0.08);
35
+ noteGain.gain.exponentialRampToValueAtTime(0.001, now + idx * 0.08 + durationSeconds);
36
+ osc.connect(noteGain);
37
+ noteGain.connect(masterGain);
38
+ osc.start(now + idx * 0.08);
39
+ osc.stop(now + idx * 0.08 + durationSeconds);
40
+ });
41
+ }
42
+ export function playAudioAlert(alertType) {
43
+ switch (alertType) {
44
+ case 'success':
45
+ // C5 (523.25Hz) -> E5 (659.25Hz) -> G5 (783.99Hz)
46
+ playTone([523.25, 659.25, 783.99], 0.22, 'sine', 0.25);
47
+ break;
48
+ case 'error':
49
+ // Low punchy buzz: 180Hz -> 130Hz sawtooth
50
+ playTone([180, 130], 0.18, 'sawtooth', 0.3);
51
+ break;
52
+ case 'warning':
53
+ // Double pulse: 440Hz -> 880Hz
54
+ playTone([440, 880], 0.15, 'triangle', 0.25);
55
+ break;
56
+ case 'beep':
57
+ // Standard 1000Hz scanner chirp (80ms)
58
+ playTone([1000], 0.08, 'sine', 0.2);
59
+ break;
60
+ case 'notify':
61
+ // Gentle marimba chord: 880Hz -> 1174.66Hz (A5 -> D6)
62
+ playTone([880, 1174.66], 0.18, 'sine', 0.2);
63
+ break;
64
+ }
65
+ }
66
+ export function useAudioAlert(options = {}) {
67
+ let muted = $state(options.muted ?? false);
68
+ let volume = $state(options.volume ?? 0.7);
69
+ isMutedState = options.muted ?? false;
70
+ globalVolume = options.volume ?? 0.7;
71
+ return {
72
+ get isMuted() {
73
+ return muted;
74
+ },
75
+ get volume() {
76
+ return volume;
77
+ },
78
+ setMuted: (val) => {
79
+ muted = val;
80
+ isMutedState = val;
81
+ },
82
+ setVolume: (val) => {
83
+ volume = Math.max(0, Math.min(1, val));
84
+ globalVolume = volume;
85
+ },
86
+ play: (type) => {
87
+ playAudioAlert(type);
88
+ },
89
+ };
90
+ }
@@ -0,0 +1 @@
1
+ export * from './useHotkeys.svelte.js';