@svadmin/ui 0.121.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.
- package/dist/app.css +204 -11
- package/dist/app.theme.css +204 -11
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AnnouncementBanner.svelte +314 -0
- package/dist/components/AnnouncementBanner.svelte.d.ts +45 -0
- package/dist/components/AsyncExportModal.svelte +551 -0
- package/dist/components/AsyncExportModal.svelte.d.ts +50 -0
- package/dist/components/AudioFeedbackProvider.svelte +131 -0
- package/dist/components/AudioFeedbackProvider.svelte.d.ts +11 -0
- package/dist/components/AuditLogViewer.svelte +1 -1
- package/dist/components/CanvasAnnotation.svelte +1 -1
- package/dist/components/ColumnFilterBuilder.svelte +135 -0
- package/dist/components/ColumnFilterBuilder.svelte.d.ts +20 -0
- package/dist/components/ColumnSettings.svelte +1 -1
- package/dist/components/ColumnVisibilityDrawer.svelte +541 -0
- package/dist/components/ColumnVisibilityDrawer.svelte.d.ts +16 -0
- package/dist/components/ConcurrentConflictModal.svelte +7 -7
- package/dist/components/ConversionFunnel.svelte +154 -0
- package/dist/components/ConversionFunnel.svelte.d.ts +22 -0
- package/dist/components/CronExpressionBuilder.svelte +1 -1
- package/dist/components/DecisionTable.svelte +1 -1
- package/dist/components/DevTools.svelte +1 -1
- package/dist/components/DraggableRowTable.svelte +1 -1
- package/dist/components/DualApprovalGate.svelte +418 -0
- package/dist/components/DualApprovalGate.svelte.d.ts +39 -0
- package/dist/components/EditableTable.svelte +1 -1
- package/dist/components/ExcelImportWizard.svelte +2 -2
- package/dist/components/GlobalShortcuts.svelte +1 -1
- package/dist/components/ImageCropper.svelte +1 -1
- package/dist/components/ImportWizard.svelte +1 -1
- package/dist/components/JsonSchemaForm.svelte +1 -1
- package/dist/components/JsonViewer.svelte +11 -11
- package/dist/components/KeyboardShortcutsModal.svelte +362 -0
- package/dist/components/KeyboardShortcutsModal.svelte.d.ts +22 -0
- package/dist/components/KpiCard.svelte +5 -5
- package/dist/components/MasterDetailView.svelte +1 -1
- package/dist/components/MetricGrid.svelte +2 -2
- package/dist/components/MicroAppBridge.svelte +59 -0
- package/dist/components/MicroAppBridge.svelte.d.ts +11 -0
- package/dist/components/OfflineSyncBanner.svelte +1 -1
- package/dist/components/OrgChart.svelte +1 -1
- package/dist/components/OrgTreePicker.svelte +1 -1
- package/dist/components/OtpInput.svelte +5 -5
- package/dist/components/PdfDocumentViewer.svelte +2 -2
- package/dist/components/PivotDrilldownModal.svelte +6 -6
- package/dist/components/PivotTable.svelte +1 -1
- package/dist/components/PricingCard.svelte +1 -1
- package/dist/components/PricingTable.svelte +1 -1
- package/dist/components/PrintableBill.svelte +2 -2
- package/dist/components/PrintableReportLayout.svelte +259 -0
- package/dist/components/PrintableReportLayout.svelte.d.ts +32 -0
- package/dist/components/ProSkeleton.svelte +6 -6
- package/dist/components/ResultPage.svelte +2 -2
- package/dist/components/SafeDeleteConfirm.svelte +5 -5
- package/dist/components/SankeyChart.svelte +111 -0
- package/dist/components/SankeyChart.svelte.d.ts +22 -0
- package/dist/components/SchemaVisualModeler.svelte +336 -0
- package/dist/components/SchemaVisualModeler.svelte.d.ts +17 -0
- package/dist/components/SensitiveDataMask.svelte +81 -22
- package/dist/components/SensitiveDataMask.svelte.d.ts +15 -10
- package/dist/components/SessionTimeoutGuard.svelte +154 -0
- package/dist/components/SessionTimeoutGuard.svelte.d.ts +25 -0
- package/dist/components/SignaturePad.svelte +1 -1
- package/dist/components/SliderCaptcha.svelte +1 -1
- package/dist/components/SplitPaneLayout.svelte +1 -1
- package/dist/components/SpreadsheetView.svelte +1 -1
- package/dist/components/StepForm.svelte +1 -1
- package/dist/components/StepWizard.svelte +513 -0
- package/dist/components/StepWizard.svelte.d.ts +49 -0
- package/dist/components/TableClipboardManager.svelte +307 -0
- package/dist/components/TableClipboardManager.svelte.d.ts +13 -0
- package/dist/components/TaskCenter.svelte +9 -9
- package/dist/components/TextDiffViewer.svelte +613 -0
- package/dist/components/TextDiffViewer.svelte.d.ts +39 -0
- package/dist/components/TreeTransfer.svelte +1 -1
- package/dist/components/UnsavedChangesGuard.svelte +5 -5
- package/dist/components/UsageCard.svelte +1 -1
- package/dist/components/VersionDiffViewer.svelte +1 -1
- package/dist/components/VirtualTable.svelte +1 -1
- package/dist/components/VirtualTreeSelect.svelte +1 -1
- package/dist/components/WorkflowDesigner.svelte +3 -3
- package/dist/components/WorkflowProcessCard.svelte +1 -1
- package/dist/components/WorkflowStepper.svelte +250 -0
- package/dist/components/WorkflowStepper.svelte.d.ts +27 -0
- package/dist/components/charts/GaugeChart.svelte +1 -1
- package/dist/components/useAudioAlert.d.svelte.ts +1 -0
- package/dist/components/useAudioAlert.svelte.d.ts +13 -0
- package/dist/components/useAudioAlert.svelte.js +90 -0
- package/dist/components/useHotkeys.d.svelte.ts +1 -0
- package/dist/components/useHotkeys.svelte.d.ts +44 -0
- package/dist/components/useHotkeys.svelte.js +190 -0
- package/dist/components/useMicroAppEvent.d.svelte.ts +1 -0
- package/dist/components/useMicroAppEvent.svelte.d.ts +16 -0
- package/dist/components/useMicroAppEvent.svelte.js +61 -0
- package/dist/components/usePrintExport.d.svelte.ts +1 -0
- package/dist/components/usePrintExport.svelte.d.ts +11 -0
- package/dist/components/usePrintExport.svelte.js +45 -0
- package/dist/components/useSessionTimeout.d.svelte.ts +1 -0
- package/dist/components/useSessionTimeout.svelte.d.ts +28 -0
- package/dist/components/useSessionTimeout.svelte.js +182 -0
- package/dist/components/useTableClipboard.d.svelte.ts +1 -0
- package/dist/components/useTableClipboard.svelte.d.ts +28 -0
- package/dist/components/useTableClipboard.svelte.js +116 -0
- package/dist/index.d.ts +28 -9
- package/dist/index.js +35 -0
- package/package.json +1 -1
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
<div
|
|
267
267
|
data-svadmin-component="ExcelImportWizard"
|
|
268
268
|
class={cn(
|
|
269
|
-
'flex flex-col rounded-
|
|
269
|
+
'flex flex-col rounded-md border border-border bg-card text-card-foreground shadow-sm overflow-hidden',
|
|
270
270
|
className,
|
|
271
271
|
)}
|
|
272
272
|
>
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
<div class="flex flex-col items-center justify-center py-8">
|
|
338
338
|
<label
|
|
339
339
|
class={cn(
|
|
340
|
-
'flex flex-col items-center justify-center w-full max-w-lg h-60 border-2 border-dashed rounded-
|
|
340
|
+
'flex flex-col items-center justify-center w-full max-w-lg h-60 border-2 border-dashed rounded-md cursor-pointer transition-all',
|
|
341
341
|
isDragOver ? 'border-primary bg-primary/5' : 'border-border hover:border-primary/50 bg-background',
|
|
342
342
|
)}
|
|
343
343
|
ondragover={(e) => { e.preventDefault(); isDragOver = true; }}
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
>
|
|
147
147
|
<div
|
|
148
148
|
class={cn(
|
|
149
|
-
'relative flex flex-col w-full max-w-xl max-h-[85vh] rounded-
|
|
149
|
+
'relative flex flex-col w-full max-w-xl max-h-[85vh] rounded-md border border-border bg-card text-card-foreground shadow-[var(--shadow-overlay)] overflow-hidden',
|
|
150
150
|
className,
|
|
151
151
|
)}
|
|
152
152
|
>
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
}
|
|
57
57
|
</script>
|
|
58
58
|
|
|
59
|
-
<div class={cn('rounded-
|
|
59
|
+
<div class={cn('rounded-md border border-border bg-card p-4 shadow-xs space-y-4 text-xs', className)}>
|
|
60
60
|
<div class="flex items-center justify-between pb-2 border-b border-border/60">
|
|
61
61
|
<h4 class="font-semibold text-foreground flex items-center gap-1.5">
|
|
62
62
|
<Crop class="h-4 w-4 text-primary" />
|
|
@@ -747,7 +747,7 @@
|
|
|
747
747
|
<Button type="button" onclick={() => { open = false; }}>{i18n.t('common.close')}</Button>
|
|
748
748
|
{:else if currentStep === 1}
|
|
749
749
|
<div
|
|
750
|
-
class="border-2 border-dashed border-border/80 hover:border-primary/60 rounded-
|
|
750
|
+
class="border-2 border-dashed border-border/80 hover:border-primary/60 rounded-md p-8 text-center transition-colors cursor-pointer bg-muted/20"
|
|
751
751
|
ondragover={(e) => e.preventDefault()}
|
|
752
752
|
ondrop={handleDrop}
|
|
753
753
|
role="region"
|
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
bind:this={formElement}
|
|
478
478
|
aria-busy={isSubmitting}
|
|
479
479
|
onsubmit={handleSubmit}
|
|
480
|
-
class={cn('space-y-4 rounded-
|
|
480
|
+
class={cn('space-y-4 rounded-md border border-border bg-card p-6 shadow-xs text-xs', className)}
|
|
481
481
|
>
|
|
482
482
|
{#if resolvedSchema?.title}
|
|
483
483
|
<div class="pb-2 border-b border-border/60">
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
<div
|
|
118
118
|
data-svadmin-component="JsonViewer"
|
|
119
119
|
class={cn(
|
|
120
|
-
'rounded-
|
|
120
|
+
'rounded-md border border-border bg-card shadow-xs flex flex-col font-mono text-xs overflow-hidden',
|
|
121
121
|
className
|
|
122
122
|
)}
|
|
123
123
|
>
|
|
@@ -147,10 +147,10 @@
|
|
|
147
147
|
>
|
|
148
148
|
{#if copiedAll}
|
|
149
149
|
<Check class="h-3 w-3 text-success" />
|
|
150
|
-
<span class="text-success text-
|
|
150
|
+
<span class="text-success text-xs">已复制</span>
|
|
151
151
|
{:else}
|
|
152
152
|
<Copy class="h-3 w-3" />
|
|
153
|
-
<span class="text-
|
|
153
|
+
<span class="text-xs">复制 JSON</span>
|
|
154
154
|
{/if}
|
|
155
155
|
</button>
|
|
156
156
|
{/if}
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
{@const itemPath = `[${idx}]`}
|
|
173
173
|
{#if matchesSearch(String(idx), item)}
|
|
174
174
|
<div class="flex items-start gap-1 group py-0.5">
|
|
175
|
-
<span class="text-muted-foreground/60 select-none text-
|
|
175
|
+
<span class="text-muted-foreground/60 select-none text-xs w-5 text-right">{idx}:</span>
|
|
176
176
|
{#if isObject(item) || isArray(item)}
|
|
177
177
|
{@const collapsed = isPathCollapsed(itemPath, 1)}
|
|
178
178
|
<button
|
|
@@ -190,14 +190,14 @@
|
|
|
190
190
|
{#if collapsed}
|
|
191
191
|
<button
|
|
192
192
|
type="button"
|
|
193
|
-
class="text-muted-foreground text-
|
|
193
|
+
class="text-muted-foreground text-xs cursor-pointer hover:underline bg-transparent border-0 p-0 text-left font-mono"
|
|
194
194
|
onclick={() => handleToggle(itemPath, 1)}
|
|
195
195
|
>
|
|
196
196
|
{isArray(item) ? `Array(${item.length})` : `{...}`}
|
|
197
197
|
</button>
|
|
198
198
|
{:else}
|
|
199
199
|
<div class="flex-1">
|
|
200
|
-
<div class="text-muted-foreground text-
|
|
200
|
+
<div class="text-muted-foreground text-xs">{isArray(item) ? '[' : '{'}</div>
|
|
201
201
|
<div class="pl-4 border-l border-border/30 my-0.5 space-y-1">
|
|
202
202
|
{#each Object.entries(item) as [subKey, subVal] (subKey)}
|
|
203
203
|
<div class="flex items-baseline gap-1 py-0.5">
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
</div>
|
|
214
214
|
{/each}
|
|
215
215
|
</div>
|
|
216
|
-
<div class="text-muted-foreground text-
|
|
216
|
+
<div class="text-muted-foreground text-xs">{isArray(item) ? ']' : '}'}</div>
|
|
217
217
|
</div>
|
|
218
218
|
{/if}
|
|
219
219
|
{:else}
|
|
@@ -259,14 +259,14 @@
|
|
|
259
259
|
{#if collapsed}
|
|
260
260
|
<button
|
|
261
261
|
type="button"
|
|
262
|
-
class="text-muted-foreground text-
|
|
262
|
+
class="text-muted-foreground text-xs cursor-pointer hover:underline bg-transparent border-0 p-0 text-left font-mono"
|
|
263
263
|
onclick={() => handleToggle(nodePath, 1)}
|
|
264
264
|
>
|
|
265
265
|
{isArray(val) ? `Array(${val.length})` : `{...}`}
|
|
266
266
|
</button>
|
|
267
267
|
{:else}
|
|
268
268
|
<div class="flex-1">
|
|
269
|
-
<span class="text-muted-foreground text-
|
|
269
|
+
<span class="text-muted-foreground text-xs">{isArray(val) ? '[' : '{'}</span>
|
|
270
270
|
<div class="pl-4 border-l border-border/30 my-0.5 space-y-1">
|
|
271
271
|
{#each Object.entries(val) as [subK, subV] (subK)}
|
|
272
272
|
<div class="flex items-baseline gap-1 py-0.5">
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
</div>
|
|
283
283
|
{/each}
|
|
284
284
|
</div>
|
|
285
|
-
<span class="text-muted-foreground text-
|
|
285
|
+
<span class="text-muted-foreground text-xs">{isArray(val) ? ']' : '}'}</span>
|
|
286
286
|
</div>
|
|
287
287
|
{/if}
|
|
288
288
|
{:else}
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
<button
|
|
304
304
|
type="button"
|
|
305
305
|
onclick={() => copySinglePath(nodePath, val)}
|
|
306
|
-
class="opacity-
|
|
306
|
+
class="opacity-70 hover:opacity-100 transition-opacity p-0.5 text-muted-foreground hover:text-foreground cursor-pointer"
|
|
307
307
|
title={`复制路径: ${nodePath}`}
|
|
308
308
|
>
|
|
309
309
|
{#if copiedPath === nodePath}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onDestroy, onMount, tick } from 'svelte';
|
|
3
|
+
import { Keyboard, Search, X, Command } from '@lucide/svelte';
|
|
4
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
5
|
+
import { cn } from '../utils.js';
|
|
6
|
+
import { getRegisteredHotkeys, isMac, useHotkeys } from './useHotkeys.svelte.js';
|
|
7
|
+
|
|
8
|
+
export interface KeyboardShortcutEntry {
|
|
9
|
+
id: string;
|
|
10
|
+
category: 'navigation' | 'table' | 'action' | 'view' | 'system' | string;
|
|
11
|
+
label: string;
|
|
12
|
+
keys: string[];
|
|
13
|
+
description?: string | undefined;
|
|
14
|
+
action?: (() => void) | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface KeyboardShortcutsModalProps {
|
|
18
|
+
open?: boolean | undefined;
|
|
19
|
+
shortcuts?: KeyboardShortcutEntry[] | undefined;
|
|
20
|
+
includeBuiltins?: boolean | undefined;
|
|
21
|
+
includeRegistered?: boolean | undefined;
|
|
22
|
+
enableGlobalTrigger?: boolean | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
subtitle?: string | undefined;
|
|
25
|
+
class?: string | undefined;
|
|
26
|
+
onAction?: ((shortcutId: string) => void) | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
open = $bindable(false),
|
|
31
|
+
shortcuts = [],
|
|
32
|
+
includeBuiltins = true,
|
|
33
|
+
includeRegistered = true,
|
|
34
|
+
enableGlobalTrigger = true,
|
|
35
|
+
title,
|
|
36
|
+
subtitle,
|
|
37
|
+
class: className = '',
|
|
38
|
+
onAction,
|
|
39
|
+
}: KeyboardShortcutsModalProps = $props();
|
|
40
|
+
|
|
41
|
+
const i18n = useTranslation();
|
|
42
|
+
const chinese = $derived(i18n.locale.startsWith('zh'));
|
|
43
|
+
const mac = $derived(isMac());
|
|
44
|
+
const modSymbol = $derived(mac ? '⌘' : 'Ctrl');
|
|
45
|
+
|
|
46
|
+
let query = $state('');
|
|
47
|
+
let searchInputRef = $state<HTMLInputElement | null>(null);
|
|
48
|
+
let registeredSnapshot = $state<KeyboardShortcutEntry[]>([]);
|
|
49
|
+
|
|
50
|
+
const builtinShortcuts = $derived<KeyboardShortcutEntry[]>([
|
|
51
|
+
{
|
|
52
|
+
id: 'command-palette',
|
|
53
|
+
category: 'navigation',
|
|
54
|
+
label: chinese ? '全局搜索 / 命令面板' : 'Command Palette / Global Search',
|
|
55
|
+
keys: [modSymbol, 'K'],
|
|
56
|
+
description: chinese ? '快速跳转资源、菜单与动作' : 'Quickly jump to resources, pages, and actions',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'shortcuts-help',
|
|
60
|
+
category: 'system',
|
|
61
|
+
label: chinese ? '打开快捷键总览' : 'Keyboard Shortcuts Matrix',
|
|
62
|
+
keys: ['?'],
|
|
63
|
+
description: chinese ? '显示或隐藏当前快捷键帮助矩阵' : 'Toggle the keyboard shortcuts overview modal',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'form-save',
|
|
67
|
+
category: 'action',
|
|
68
|
+
label: chinese ? '保存当前表单' : 'Save Current Form',
|
|
69
|
+
keys: [modSymbol, 'S'],
|
|
70
|
+
description: chinese ? '在创建或编辑页面触发提交保存' : 'Submit or save active edit/create form',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'table-next-row',
|
|
74
|
+
category: 'table',
|
|
75
|
+
label: chinese ? '表格下一行' : 'Next Table Row',
|
|
76
|
+
keys: ['J'],
|
|
77
|
+
description: chinese ? '在数据表格中向下移动行焦点' : 'Move row selection down in tables',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'table-prev-row',
|
|
81
|
+
category: 'table',
|
|
82
|
+
label: chinese ? '表格上一行' : 'Previous Table Row',
|
|
83
|
+
keys: ['K'],
|
|
84
|
+
description: chinese ? '在数据表格中向上移动行焦点' : 'Move row selection up in tables',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'table-search',
|
|
88
|
+
category: 'table',
|
|
89
|
+
label: chinese ? '聚焦表格筛选' : 'Focus Table Filter',
|
|
90
|
+
keys: [modSymbol, 'F'],
|
|
91
|
+
description: chinese ? '快速将光标定位至列表过滤搜索框' : 'Focus list search or filter input',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'toggle-theme',
|
|
95
|
+
category: 'view',
|
|
96
|
+
label: chinese ? '切换浅色 / 深色模式' : 'Toggle Dark Mode',
|
|
97
|
+
keys: [modSymbol, 'D'],
|
|
98
|
+
description: chinese ? '在亮色与暗色主题外观间切换' : 'Switch between light and dark appearance',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'toggle-fullscreen',
|
|
102
|
+
category: 'view',
|
|
103
|
+
label: chinese ? '全屏工作区切换' : 'Toggle Fullscreen',
|
|
104
|
+
keys: ['F11'],
|
|
105
|
+
description: chinese ? '沉浸式全屏展开或恢复' : 'Enter or exit fullscreen workspace mode',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'cancel-close',
|
|
109
|
+
category: 'system',
|
|
110
|
+
label: chinese ? '取消 / 关闭浮层' : 'Cancel / Close Dialog',
|
|
111
|
+
keys: ['Esc'],
|
|
112
|
+
description: chinese ? '关闭当前抽屉、弹窗或取消编辑' : 'Close active modal, drawer, or cancel edit',
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
function refreshRegistered() {
|
|
117
|
+
if (!includeRegistered) {
|
|
118
|
+
registeredSnapshot = [];
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
registeredSnapshot = getRegisteredHotkeys().map((item) => ({
|
|
122
|
+
id: item.id,
|
|
123
|
+
category: item.category ?? 'action',
|
|
124
|
+
label: item.label ?? item.combo,
|
|
125
|
+
keys: item.keys,
|
|
126
|
+
description: item.description,
|
|
127
|
+
action: item.action,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
$effect(() => {
|
|
132
|
+
if (open) {
|
|
133
|
+
refreshRegistered();
|
|
134
|
+
void tick().then(() => {
|
|
135
|
+
searchInputRef?.focus();
|
|
136
|
+
});
|
|
137
|
+
} else {
|
|
138
|
+
query = '';
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const allShortcuts = $derived.by(() => {
|
|
143
|
+
const merged: KeyboardShortcutEntry[] = [];
|
|
144
|
+
if (includeBuiltins) merged.push(...builtinShortcuts);
|
|
145
|
+
if (includeRegistered) merged.push(...registeredSnapshot);
|
|
146
|
+
merged.push(...shortcuts);
|
|
147
|
+
return merged;
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
const filteredShortcuts = $derived.by(() => {
|
|
151
|
+
const q = query.trim().toLowerCase();
|
|
152
|
+
if (!q) return allShortcuts;
|
|
153
|
+
return allShortcuts.filter(
|
|
154
|
+
(item) =>
|
|
155
|
+
item.label.toLowerCase().includes(q) ||
|
|
156
|
+
item.description?.toLowerCase().includes(q) ||
|
|
157
|
+
item.category.toLowerCase().includes(q) ||
|
|
158
|
+
item.keys.some((k) => k.toLowerCase().includes(q)),
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const categoryLabels = $derived<Record<string, string>>({
|
|
163
|
+
navigation: chinese ? '导航与检索' : 'Navigation',
|
|
164
|
+
table: chinese ? '表格与列表' : 'Table & List',
|
|
165
|
+
action: chinese ? '编辑与操作' : 'Editing & Actions',
|
|
166
|
+
view: chinese ? '视图与外观' : 'View & Theme',
|
|
167
|
+
system: chinese ? '系统与安全' : 'System & Safety',
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const groupedShortcuts = $derived.by(() => {
|
|
171
|
+
const groups: Record<string, KeyboardShortcutEntry[]> = {};
|
|
172
|
+
for (const item of filteredShortcuts) {
|
|
173
|
+
const cat = item.category || 'action';
|
|
174
|
+
const bucket = groups[cat] ?? (groups[cat] = []);
|
|
175
|
+
bucket.push(item);
|
|
176
|
+
}
|
|
177
|
+
return groups;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
function triggerItem(item: KeyboardShortcutEntry) {
|
|
181
|
+
item.action?.();
|
|
182
|
+
onAction?.(item.id);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let cleanupTrigger: (() => void) | undefined;
|
|
186
|
+
let cleanupEsc: (() => void) | undefined;
|
|
187
|
+
|
|
188
|
+
onMount(() => {
|
|
189
|
+
if (enableGlobalTrigger) {
|
|
190
|
+
const h1 = useHotkeys(
|
|
191
|
+
['?', 'Shift+?', 'Mod+/'],
|
|
192
|
+
() => {
|
|
193
|
+
open = !open;
|
|
194
|
+
},
|
|
195
|
+
{ preventDefault: true },
|
|
196
|
+
);
|
|
197
|
+
cleanupTrigger = h1.destroy;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const h2 = useHotkeys(
|
|
201
|
+
'Escape',
|
|
202
|
+
() => {
|
|
203
|
+
if (open) open = false;
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
enabled: () => open,
|
|
207
|
+
enableOnInputs: true,
|
|
208
|
+
preventDefault: true,
|
|
209
|
+
},
|
|
210
|
+
);
|
|
211
|
+
cleanupEsc = h2.destroy;
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
onDestroy(() => {
|
|
215
|
+
cleanupTrigger?.();
|
|
216
|
+
cleanupEsc?.();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
const resolvedTitle = $derived(
|
|
220
|
+
title ?? (chinese ? '全局快捷键总览' : 'Keyboard Shortcuts'),
|
|
221
|
+
);
|
|
222
|
+
const resolvedSubtitle = $derived(
|
|
223
|
+
subtitle ??
|
|
224
|
+
(chinese
|
|
225
|
+
? 'Linear / macOS 风格企业级高效键盘导航矩阵'
|
|
226
|
+
: 'Productivity-first keyboard matrix across workspace navigation and forms'),
|
|
227
|
+
);
|
|
228
|
+
</script>
|
|
229
|
+
|
|
230
|
+
{#if open}
|
|
231
|
+
<div
|
|
232
|
+
data-svadmin-component="KeyboardShortcutsModal"
|
|
233
|
+
class="fixed inset-0 z-50 flex items-center justify-center bg-background/80 p-4 backdrop-blur-sm select-none"
|
|
234
|
+
role="dialog"
|
|
235
|
+
aria-modal="true"
|
|
236
|
+
aria-label={resolvedTitle}
|
|
237
|
+
>
|
|
238
|
+
<!-- Backdrop click to close -->
|
|
239
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
240
|
+
<div
|
|
241
|
+
role="button"
|
|
242
|
+
tabindex="-1"
|
|
243
|
+
class="fixed inset-0"
|
|
244
|
+
onclick={() => (open = false)}
|
|
245
|
+
aria-label="Close shortcuts modal"
|
|
246
|
+
></div>
|
|
247
|
+
|
|
248
|
+
<div
|
|
249
|
+
class={cn(
|
|
250
|
+
'relative z-10 flex flex-col w-full max-w-3xl max-h-[85vh] rounded-md border border-border bg-card text-card-foreground shadow-[var(--shadow-overlay)] overflow-hidden',
|
|
251
|
+
className,
|
|
252
|
+
)}
|
|
253
|
+
>
|
|
254
|
+
<!-- Header -->
|
|
255
|
+
<div class="flex items-start justify-between border-b border-border px-6 py-4 bg-card">
|
|
256
|
+
<div class="flex items-center gap-3">
|
|
257
|
+
<div class="flex h-9 w-9 items-center justify-center rounded-sm bg-primary/10 text-primary border border-primary/20">
|
|
258
|
+
<Keyboard class="h-5 w-5" />
|
|
259
|
+
</div>
|
|
260
|
+
<div>
|
|
261
|
+
<h2 class="text-base font-semibold text-foreground">{resolvedTitle}</h2>
|
|
262
|
+
<p class="text-xs text-muted-foreground mt-0.5">{resolvedSubtitle}</p>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
<button
|
|
266
|
+
type="button"
|
|
267
|
+
class="flex h-7 w-7 items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground transition-colors"
|
|
268
|
+
onclick={() => (open = false)}
|
|
269
|
+
aria-label="Close"
|
|
270
|
+
>
|
|
271
|
+
<X class="h-4 w-4" />
|
|
272
|
+
</button>
|
|
273
|
+
</div>
|
|
274
|
+
|
|
275
|
+
<!-- Search Filter Bar -->
|
|
276
|
+
<div class="px-6 py-3 border-b border-border/60 bg-muted/30">
|
|
277
|
+
<div class="relative flex items-center">
|
|
278
|
+
<Search class="absolute left-3 h-4 w-4 text-muted-foreground pointer-events-none" />
|
|
279
|
+
<input
|
|
280
|
+
bind:this={searchInputRef}
|
|
281
|
+
type="text"
|
|
282
|
+
bind:value={query}
|
|
283
|
+
placeholder={chinese ? '搜索快捷键名称、描述或按键 (如 Mod+S, J/K)...' : 'Search shortcuts by action, category, or key...'}
|
|
284
|
+
class="flex h-9 w-full rounded-lg border border-input bg-background pl-9 pr-3 py-1 text-sm shadow-2xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
|
|
285
|
+
/>
|
|
286
|
+
{#if query}
|
|
287
|
+
<button
|
|
288
|
+
type="button"
|
|
289
|
+
onclick={() => (query = '')}
|
|
290
|
+
class="absolute right-2.5 text-muted-foreground hover:text-foreground"
|
|
291
|
+
aria-label="Clear search"
|
|
292
|
+
>
|
|
293
|
+
<X class="h-3.5 w-3.5" />
|
|
294
|
+
</button>
|
|
295
|
+
{/if}
|
|
296
|
+
</div>
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<!-- Categorized Matrix Grid -->
|
|
300
|
+
<div class="flex-1 overflow-y-auto px-6 py-5">
|
|
301
|
+
{#if filteredShortcuts.length > 0}
|
|
302
|
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
303
|
+
{#each Object.entries(groupedShortcuts) as [categoryKey, items] (categoryKey)}
|
|
304
|
+
<div class="space-y-2.5">
|
|
305
|
+
<div class="flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider px-1">
|
|
306
|
+
<Command class="h-3 w-3 text-primary/70" />
|
|
307
|
+
<span>{categoryLabels[categoryKey] ?? categoryKey}</span>
|
|
308
|
+
</div>
|
|
309
|
+
<div class="rounded-md border border-border/70 bg-muted/15 divide-y divide-border/50 overflow-hidden">
|
|
310
|
+
{#each items as item (item.id)}
|
|
311
|
+
<div
|
|
312
|
+
class="flex items-center justify-between gap-3 px-3.5 py-2.5 text-sm transition-colors hover:bg-accent/50 cursor-pointer"
|
|
313
|
+
onclick={() => triggerItem(item)}
|
|
314
|
+
role="button"
|
|
315
|
+
tabindex="0"
|
|
316
|
+
onkeydown={(e) => e.key === 'Enter' && triggerItem(item)}
|
|
317
|
+
>
|
|
318
|
+
<div class="min-w-0 flex-1">
|
|
319
|
+
<div class="font-medium text-foreground text-xs truncate">{item.label}</div>
|
|
320
|
+
{#if item.description}
|
|
321
|
+
<div class="text-[11px] text-muted-foreground truncate mt-0.5">{item.description}</div>
|
|
322
|
+
{/if}
|
|
323
|
+
</div>
|
|
324
|
+
<div class="flex items-center gap-1 shrink-0">
|
|
325
|
+
{#each item.keys as key, keyIdx (keyIdx)}
|
|
326
|
+
<kbd class="inline-flex min-w-6 h-6 items-center justify-center rounded-md border border-border bg-background px-1.5 text-[11px] font-mono font-medium text-foreground shadow-2xs">
|
|
327
|
+
{key}
|
|
328
|
+
</kbd>
|
|
329
|
+
{/each}
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
{/each}
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
{/each}
|
|
336
|
+
</div>
|
|
337
|
+
{:else}
|
|
338
|
+
<div class="text-center py-12 text-sm text-muted-foreground">
|
|
339
|
+
{chinese ? '未找到匹配的快捷键' : 'No matching keyboard shortcuts found'}
|
|
340
|
+
</div>
|
|
341
|
+
{/if}
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<!-- Footer Hint -->
|
|
345
|
+
<div class="border-t border-border px-6 py-3 bg-muted/20 text-xs text-muted-foreground flex items-center justify-between">
|
|
346
|
+
<span>
|
|
347
|
+
{chinese ? '在输入框内仅屏蔽单字符热键,组合键 (如 ⌘S) 始终生效' : 'Bare single-key shortcuts pause in inputs; modifier combos remain active'}
|
|
348
|
+
</span>
|
|
349
|
+
<div class="flex items-center gap-3">
|
|
350
|
+
<span>
|
|
351
|
+
<kbd class="px-1.5 py-0.5 rounded bg-background border border-border text-xs font-mono">?</kbd>
|
|
352
|
+
{chinese ? ' 呼出' : ' Toggle'}
|
|
353
|
+
</span>
|
|
354
|
+
<span>
|
|
355
|
+
<kbd class="px-1.5 py-0.5 rounded bg-background border border-border text-xs font-mono">Esc</kbd>
|
|
356
|
+
{chinese ? ' 关闭' : ' Close'}
|
|
357
|
+
</span>
|
|
358
|
+
</div>
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
</div>
|
|
362
|
+
{/if}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface KeyboardShortcutEntry {
|
|
2
|
+
id: string;
|
|
3
|
+
category: 'navigation' | 'table' | 'action' | 'view' | 'system' | string;
|
|
4
|
+
label: string;
|
|
5
|
+
keys: string[];
|
|
6
|
+
description?: string | undefined;
|
|
7
|
+
action?: (() => void) | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface KeyboardShortcutsModalProps {
|
|
10
|
+
open?: boolean | undefined;
|
|
11
|
+
shortcuts?: KeyboardShortcutEntry[] | undefined;
|
|
12
|
+
includeBuiltins?: boolean | undefined;
|
|
13
|
+
includeRegistered?: boolean | undefined;
|
|
14
|
+
enableGlobalTrigger?: boolean | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
subtitle?: string | undefined;
|
|
17
|
+
class?: string | undefined;
|
|
18
|
+
onAction?: ((shortcutId: string) => void) | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare const KeyboardShortcutsModal: import("svelte").Component<KeyboardShortcutsModalProps, {}, "open">;
|
|
21
|
+
type KeyboardShortcutsModal = ReturnType<typeof KeyboardShortcutsModal>;
|
|
22
|
+
export default KeyboardShortcutsModal;
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
<div
|
|
122
122
|
data-svadmin-component="KpiCard"
|
|
123
123
|
class={cn(
|
|
124
|
-
'relative flex flex-col justify-between rounded-
|
|
124
|
+
'relative flex flex-col justify-between rounded-md border p-5 shadow-xs transition-all hover:shadow-sm',
|
|
125
125
|
alertClasses,
|
|
126
126
|
className
|
|
127
127
|
)}
|
|
@@ -143,13 +143,13 @@
|
|
|
143
143
|
<div class="flex items-center gap-2">
|
|
144
144
|
<span class="text-xs font-medium text-muted-foreground tracking-wide">{title}</span>
|
|
145
145
|
{#if badge}
|
|
146
|
-
<span class="rounded-
|
|
146
|
+
<span class="rounded-sm bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-xs font-medium text-primary">
|
|
147
147
|
{badge}
|
|
148
148
|
</span>
|
|
149
149
|
{/if}
|
|
150
150
|
</div>
|
|
151
151
|
{#if subtitle}
|
|
152
|
-
<p class="text-
|
|
152
|
+
<p class="text-xs text-muted-foreground">{subtitle}</p>
|
|
153
153
|
{/if}
|
|
154
154
|
</div>
|
|
155
155
|
|
|
@@ -201,14 +201,14 @@
|
|
|
201
201
|
variant="badge"
|
|
202
202
|
size="sm"
|
|
203
203
|
/>
|
|
204
|
-
<span class="text-
|
|
204
|
+
<span class="text-xs text-muted-foreground">对比上一周期</span>
|
|
205
205
|
</div>
|
|
206
206
|
{/if}
|
|
207
207
|
|
|
208
208
|
<!-- Target Completion Progress Bar -->
|
|
209
209
|
{#if targetProgress}
|
|
210
210
|
<div class="space-y-1">
|
|
211
|
-
<div class="flex items-center justify-between text-
|
|
211
|
+
<div class="flex items-center justify-between text-xs text-muted-foreground font-mono">
|
|
212
212
|
<span>{targetProgress.label ?? '目标达成'}</span>
|
|
213
213
|
<span class="font-semibold text-foreground">{progressPercent}%</span>
|
|
214
214
|
</div>
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
);
|
|
47
47
|
</script>
|
|
48
48
|
|
|
49
|
-
<div class={cn('flex h-full min-h-[420px] rounded-
|
|
49
|
+
<div class={cn('flex h-full min-h-[420px] rounded-md border border-border bg-card shadow-xs overflow-hidden text-xs', className)}>
|
|
50
50
|
<!-- Master List Panel -->
|
|
51
51
|
<div class={cn('flex flex-col border-r border-border/60 bg-muted/15 shrink-0', listWidth)}>
|
|
52
52
|
<!-- Search Bar -->
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
>
|
|
126
126
|
{#each Array(skeletonCount) as _, i (i)}
|
|
127
127
|
<div
|
|
128
|
-
class="flex flex-col justify-between rounded-
|
|
128
|
+
class="flex flex-col justify-between rounded-md border border-border bg-card p-5 shadow-sm space-y-3"
|
|
129
129
|
>
|
|
130
130
|
<div class="flex items-center justify-between">
|
|
131
131
|
<Skeleton class="h-4 w-28" />
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
{:else}
|
|
148
148
|
<div
|
|
149
149
|
data-slot="metric-grid-empty"
|
|
150
|
-
class="flex flex-col items-center justify-center rounded-
|
|
150
|
+
class="flex flex-col items-center justify-center rounded-md border border-dashed border-border bg-card/50 p-8 text-center text-muted-foreground"
|
|
151
151
|
>
|
|
152
152
|
<p class="text-sm font-medium">{emptyMessage}</p>
|
|
153
153
|
</div>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack, type Snippet } from 'svelte';
|
|
3
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { useMicroAppEvent } from './useMicroAppEvent.svelte.js';
|
|
6
|
+
|
|
7
|
+
export interface MicroAppBridgeProps {
|
|
8
|
+
channel?: string | undefined;
|
|
9
|
+
allowedOrigins?: string[] | undefined;
|
|
10
|
+
appId?: string | undefined;
|
|
11
|
+
class?: string | undefined;
|
|
12
|
+
children?: Snippet | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
channel = 'svadmin_microapp',
|
|
17
|
+
allowedOrigins = ['*'],
|
|
18
|
+
appId = 'main-bridge',
|
|
19
|
+
class: className = '',
|
|
20
|
+
children,
|
|
21
|
+
}: MicroAppBridgeProps = $props();
|
|
22
|
+
|
|
23
|
+
const i18n = useTranslation();
|
|
24
|
+
|
|
25
|
+
const bridge = useMicroAppEvent({
|
|
26
|
+
channel: untrack(() => channel),
|
|
27
|
+
allowedOrigins: untrack(() => allowedOrigins),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
bridge.on('PING', (_, event) => {
|
|
31
|
+
if (event.source && typeof (event.source as Window).postMessage === 'function') {
|
|
32
|
+
bridge.emit('PONG', { appId, status: 'ready' }, event.source as Window);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
bridge.on('SYNC_REQUEST', (_, event) => {
|
|
37
|
+
if (event.source && typeof (event.source as Window).postMessage === 'function') {
|
|
38
|
+
bridge.emit(
|
|
39
|
+
'SYNC_RESPONSE',
|
|
40
|
+
{
|
|
41
|
+
locale: i18n.locale,
|
|
42
|
+
timestamp: Date.now(),
|
|
43
|
+
},
|
|
44
|
+
event.source as Window,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div
|
|
51
|
+
data-svadmin-component="MicroAppBridge"
|
|
52
|
+
data-app-id={appId}
|
|
53
|
+
data-channel={channel}
|
|
54
|
+
class={cn('relative w-full', className)}
|
|
55
|
+
>
|
|
56
|
+
{#if children}
|
|
57
|
+
{@render children()}
|
|
58
|
+
{/if}
|
|
59
|
+
</div>
|