@svadmin/ui 0.122.0 → 0.126.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 +581 -4
- package/dist/app.theme.css +581 -4
- package/dist/components/AbacPolicyMatrix.svelte +356 -0
- package/dist/components/AbacPolicyMatrix.svelte.d.ts +30 -0
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/ActionPalette.svelte +272 -0
- package/dist/components/ActionPalette.svelte.d.ts +23 -0
- package/dist/components/AdminCopilotWidget.svelte +316 -0
- package/dist/components/AdminCopilotWidget.svelte.d.ts +33 -0
- package/dist/components/AnnouncementBanner.svelte +12 -1
- package/dist/components/AnnouncementBanner.svelte.d.ts +4 -0
- package/dist/components/ApiPlayground.svelte +255 -0
- package/dist/components/ApiPlayground.svelte.d.ts +24 -0
- package/dist/components/ApiSettings.svelte +1 -1
- package/dist/components/AppearanceSettings.svelte +1 -1
- package/dist/components/ApprovalChainBuilder.svelte +262 -0
- package/dist/components/ApprovalChainBuilder.svelte.d.ts +20 -0
- package/dist/components/ApprovalTimeline.svelte +8 -1
- package/dist/components/AsyncExportModal.svelte +1 -1
- package/dist/components/AudioFeedbackProvider.svelte +1 -1
- package/dist/components/AuditLogDrawer.svelte +2 -2
- package/dist/components/AuditTrailInspector.svelte +448 -0
- package/dist/components/AuditTrailInspector.svelte.d.ts +44 -0
- package/dist/components/AutoTable.svelte +20 -1
- package/dist/components/AutoTable.svelte.d.ts +2 -0
- package/dist/components/BatchEditModal.svelte +266 -0
- package/dist/components/BatchEditModal.svelte.d.ts +27 -0
- package/dist/components/BillingInvoiceDrawer.svelte +206 -0
- package/dist/components/BillingInvoiceDrawer.svelte.d.ts +30 -0
- package/dist/components/ChartAnnotationOverlay.svelte +228 -0
- package/dist/components/ChartAnnotationOverlay.svelte.d.ts +21 -0
- package/dist/components/CheckCard.svelte +1 -1
- package/dist/components/ClusterTopologyGraph.svelte +317 -0
- package/dist/components/ClusterTopologyGraph.svelte.d.ts +31 -0
- package/dist/components/ColumnHeaderFilter.svelte +6 -6
- package/dist/components/ColumnMappingTable.svelte +174 -0
- package/dist/components/ColumnMappingTable.svelte.d.ts +23 -0
- package/dist/components/ConversionFunnel.svelte +1 -1
- package/dist/components/CursorListFooter.svelte +67 -0
- package/dist/components/CursorListFooter.svelte.d.ts +17 -0
- package/dist/components/DashboardGridLayout.svelte +309 -0
- package/dist/components/DashboardGridLayout.svelte.d.ts +30 -0
- package/dist/components/DashboardLayoutStorage.svelte +278 -0
- package/dist/components/DashboardLayoutStorage.svelte.d.ts +23 -0
- package/dist/components/DataFreshnessIndicator.svelte +149 -0
- package/dist/components/DataFreshnessIndicator.svelte.d.ts +20 -0
- package/dist/components/DataImportDropzone.svelte +215 -0
- package/dist/components/DataImportDropzone.svelte.d.ts +24 -0
- package/dist/components/DataLineageGraph.svelte +203 -0
- package/dist/components/DataLineageGraph.svelte.d.ts +26 -0
- package/dist/components/DataMaskPolicyEngine.svelte +291 -0
- package/dist/components/DataMaskPolicyEngine.svelte.d.ts +25 -0
- package/dist/components/DataScopeRuleEditor.svelte +142 -0
- package/dist/components/DataScopeRuleEditor.svelte.d.ts +19 -0
- package/dist/components/DataScreenContainer.svelte +160 -0
- package/dist/components/DataScreenContainer.svelte.d.ts +15 -0
- package/dist/components/DevTools.svelte +3 -3
- package/dist/components/DualApprovalGate.svelte +132 -65
- package/dist/components/DualApprovalGate.svelte.d.ts +20 -1
- package/dist/components/EditableTable.svelte +2 -2
- package/dist/components/ElectronicSealStamp.svelte +102 -0
- package/dist/components/ElectronicSealStamp.svelte.d.ts +14 -0
- package/dist/components/EnvVariableEditor.svelte +284 -0
- package/dist/components/EnvVariableEditor.svelte.d.ts +17 -0
- package/dist/components/ExcelImportWizard.svelte +2 -2
- package/dist/components/FeatureAnnouncementModal.svelte +173 -0
- package/dist/components/FeatureAnnouncementModal.svelte.d.ts +21 -0
- package/dist/components/FieldRenderer.svelte +1 -1
- package/dist/components/FilterTagBar.svelte +210 -0
- package/dist/components/FilterTagBar.svelte.d.ts +23 -0
- package/dist/components/FormulaField.svelte +149 -0
- package/dist/components/FormulaField.svelte.d.ts +18 -0
- package/dist/components/GeoScatterMap.svelte +225 -0
- package/dist/components/GeoScatterMap.svelte.d.ts +22 -0
- package/dist/components/HmacSignatureCalculator.svelte +199 -0
- package/dist/components/HmacSignatureCalculator.svelte.d.ts +10 -0
- package/dist/components/I18nLanguagePackEditor.svelte +208 -0
- package/dist/components/I18nLanguagePackEditor.svelte.d.ts +17 -0
- package/dist/components/ImportPreviewValidator.svelte +239 -0
- package/dist/components/ImportPreviewValidator.svelte.d.ts +26 -0
- package/dist/components/ImportWizard.svelte +2 -2
- package/dist/components/IncidentWarRoomDrawer.svelte +194 -0
- package/dist/components/IncidentWarRoomDrawer.svelte.d.ts +24 -0
- package/dist/components/InputGroup.svelte +133 -0
- package/dist/components/InputGroup.svelte.d.ts +16 -0
- package/dist/components/JsonSchemaForm.svelte +4 -4
- package/dist/components/LightFilter.svelte +2 -2
- package/dist/components/ListPagination.svelte +39 -3
- package/dist/components/LiveStreamLogViewer.svelte +185 -0
- package/dist/components/LiveStreamLogViewer.svelte.d.ts +21 -0
- package/dist/components/MasterSubTableDrawer.svelte +223 -0
- package/dist/components/MasterSubTableDrawer.svelte.d.ts +25 -0
- package/dist/components/MicroAppRouteSync.svelte +185 -0
- package/dist/components/MicroAppRouteSync.svelte.d.ts +12 -0
- package/dist/components/MicroAppSandbox.svelte +200 -0
- package/dist/components/MicroAppSandbox.svelte.d.ts +16 -0
- package/dist/components/MicroAppStateBusIndicator.svelte +159 -0
- package/dist/components/MicroAppStateBusIndicator.svelte.d.ts +12 -0
- package/dist/components/MockDataInterceptor.svelte +292 -0
- package/dist/components/MockDataInterceptor.svelte.d.ts +27 -0
- package/dist/components/OmnibarCommandPalette.svelte +320 -0
- package/dist/components/OmnibarCommandPalette.svelte.d.ts +27 -0
- package/dist/components/PageSkeleton.svelte +19 -5
- package/dist/components/PageSkeleton.svelte.d.ts +5 -3
- package/dist/components/PeriodComparisonCard.svelte +142 -0
- package/dist/components/PeriodComparisonCard.svelte.d.ts +16 -0
- package/dist/components/PermissionMatrix.svelte +1 -1
- package/dist/components/PermissionSimulator.svelte +319 -0
- package/dist/components/PermissionSimulator.svelte.d.ts +34 -0
- package/dist/components/PivotMatrix.svelte +271 -0
- package/dist/components/PivotMatrix.svelte.d.ts +32 -0
- package/dist/components/PlanUsageQuotaBar.svelte +154 -0
- package/dist/components/PlanUsageQuotaBar.svelte.d.ts +26 -0
- package/dist/components/Popconfirm.svelte +20 -8
- package/dist/components/Popconfirm.svelte.d.ts +3 -1
- package/dist/components/ProSkeleton.svelte +4 -0
- package/dist/components/ProSkeleton.svelte.d.ts +2 -0
- package/dist/components/QueryAiExplainer.svelte +148 -0
- package/dist/components/QueryAiExplainer.svelte.d.ts +16 -0
- package/dist/components/QueryBuilder.svelte +456 -0
- package/dist/components/QueryBuilder.svelte.d.ts +33 -0
- package/dist/components/Rate.svelte +19 -2
- package/dist/components/Result.svelte +36 -4
- package/dist/components/Result.svelte.d.ts +4 -2
- package/dist/components/RolePermissionComparator.svelte +273 -0
- package/dist/components/RolePermissionComparator.svelte.d.ts +28 -0
- package/dist/components/RuleExpressionBuilder.svelte +380 -0
- package/dist/components/RuleExpressionBuilder.svelte.d.ts +31 -0
- package/dist/components/ScheduledJobManager.svelte +225 -0
- package/dist/components/ScheduledJobManager.svelte.d.ts +23 -0
- package/dist/components/SchemaVisualModeler.svelte +2 -2
- package/dist/components/ScreenAntiLeakGuard.svelte +88 -0
- package/dist/components/ScreenAntiLeakGuard.svelte.d.ts +12 -0
- package/dist/components/SecureDataExporter.svelte +296 -0
- package/dist/components/SecureDataExporter.svelte.d.ts +29 -0
- package/dist/components/ServerStatusGrid.svelte +179 -0
- package/dist/components/ServerStatusGrid.svelte.d.ts +21 -0
- package/dist/components/SnapshotTimelineReplay.svelte +219 -0
- package/dist/components/SnapshotTimelineReplay.svelte.d.ts +19 -0
- package/dist/components/Spin.svelte +33 -11
- package/dist/components/Spin.svelte.d.ts +7 -4
- package/dist/components/SqlConsole.svelte +247 -0
- package/dist/components/SqlConsole.svelte.d.ts +20 -0
- package/dist/components/StepWizard.svelte +1 -1
- package/dist/components/Steps.svelte +44 -3
- package/dist/components/SystemCapacityForecastCard.svelte +132 -0
- package/dist/components/SystemCapacityForecastCard.svelte.d.ts +19 -0
- package/dist/components/SystemHealthCheckDashboard.svelte +306 -0
- package/dist/components/SystemHealthCheckDashboard.svelte.d.ts +24 -0
- package/dist/components/TableAggregationFooter.svelte +173 -0
- package/dist/components/TableAggregationFooter.svelte.d.ts +22 -0
- package/dist/components/TaskCenter.svelte +37 -29
- package/dist/components/TenantContextSwitcher.svelte +314 -0
- package/dist/components/TenantContextSwitcher.svelte.d.ts +35 -0
- package/dist/components/TenantQuotasMatrix.svelte +229 -0
- package/dist/components/TenantQuotasMatrix.svelte.d.ts +22 -0
- package/dist/components/ThemeSettingsDrawer.svelte +6 -14
- package/dist/components/ThreadedCommentDrawer.svelte +246 -0
- package/dist/components/ThreadedCommentDrawer.svelte.d.ts +26 -0
- package/dist/components/TierFeatureComparison.svelte +147 -0
- package/dist/components/TierFeatureComparison.svelte.d.ts +28 -0
- package/dist/components/Timeline.svelte +12 -3
- package/dist/components/Timeline.svelte.d.ts +2 -0
- package/dist/components/TreeTransferSelect.svelte +333 -0
- package/dist/components/TreeTransferSelect.svelte.d.ts +18 -0
- package/dist/components/VirtualCardGrid.svelte +180 -0
- package/dist/components/VirtualCardGrid.svelte.d.ts +65 -0
- package/dist/components/WebhookSimulator.svelte +263 -0
- package/dist/components/WebhookSimulator.svelte.d.ts +26 -0
- package/dist/components/WidgetContainer.svelte +204 -0
- package/dist/components/WidgetContainer.svelte.d.ts +31 -0
- package/dist/components/WorkflowExecutionTracker.svelte +131 -0
- package/dist/components/WorkflowExecutionTracker.svelte.d.ts +19 -0
- package/dist/components/WorkflowGraphDesigner.svelte +202 -0
- package/dist/components/WorkflowGraphDesigner.svelte.d.ts +24 -0
- package/dist/components/WorkflowNodeInspector.svelte +217 -0
- package/dist/components/WorkflowNodeInspector.svelte.d.ts +24 -0
- package/dist/components/WorkflowStepper.svelte +1 -1
- package/dist/components/list-i18n.d.ts +7 -0
- package/dist/components/list-i18n.js +14 -0
- package/dist/components/ui/badge/badge.svelte +3 -3
- package/dist/components/ui/button/button.svelte +3 -1
- package/dist/components/ui/button/button.svelte.d.ts +1 -0
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/components/useDynamicLocale.d.svelte.ts +1 -0
- package/dist/components/useDynamicLocale.svelte.d.ts +10 -0
- package/dist/components/useDynamicLocale.svelte.js +40 -0
- package/dist/components/useFormulaEngine.d.svelte.ts +1 -0
- package/dist/components/useFormulaEngine.svelte.d.ts +9 -0
- package/dist/components/useFormulaEngine.svelte.js +209 -0
- package/dist/components/useMicroAppState.d.svelte.ts +1 -0
- package/dist/components/useMicroAppState.svelte.d.ts +17 -0
- package/dist/components/useMicroAppState.svelte.js +38 -0
- package/dist/components/useStorageCache.d.svelte.ts +1 -0
- package/dist/components/useStorageCache.svelte.d.ts +49 -0
- package/dist/components/useStorageCache.svelte.js +229 -0
- package/dist/components.css +5 -1
- package/dist/index.d.ts +75 -3
- package/dist/index.js +118 -2
- package/package.json +4 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { Bookmark, BookmarkPlus, X, Trash2, Check, Filter } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
export interface FilterTagItem {
|
|
7
|
+
id: string;
|
|
8
|
+
field: string;
|
|
9
|
+
label: string;
|
|
10
|
+
operatorLabel?: string | undefined;
|
|
11
|
+
valueLabel: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SavedPresetView {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
filters: FilterTagItem[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface FilterTagBarProps {
|
|
21
|
+
filters: FilterTagItem[];
|
|
22
|
+
storageKey?: string | undefined;
|
|
23
|
+
onremove?: ((filterId: string) => void) | undefined;
|
|
24
|
+
onclear?: (() => void) | undefined;
|
|
25
|
+
onapplypreset?: ((preset: SavedPresetView) => void) | undefined;
|
|
26
|
+
class?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
filters = [],
|
|
31
|
+
storageKey = 'svadmin_saved_filter_views',
|
|
32
|
+
onremove,
|
|
33
|
+
onclear,
|
|
34
|
+
onapplypreset,
|
|
35
|
+
class: className = '',
|
|
36
|
+
}: FilterTagBarProps = $props();
|
|
37
|
+
|
|
38
|
+
let isSavingView = $state(false);
|
|
39
|
+
let newViewName = $state('');
|
|
40
|
+
let savedPresets = $state<SavedPresetView[]>([]);
|
|
41
|
+
let activePresetId = $state<string | null>(null);
|
|
42
|
+
|
|
43
|
+
function loadPresets() {
|
|
44
|
+
if (typeof window === 'undefined' || !window.localStorage) return;
|
|
45
|
+
try {
|
|
46
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
47
|
+
if (raw) {
|
|
48
|
+
savedPresets = JSON.parse(raw) as SavedPresetView[];
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
// Ignore
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function persistPresets(list: SavedPresetView[]) {
|
|
56
|
+
savedPresets = list;
|
|
57
|
+
if (typeof window === 'undefined' || !window.localStorage) return;
|
|
58
|
+
try {
|
|
59
|
+
window.localStorage.setItem(storageKey, JSON.stringify(list));
|
|
60
|
+
} catch {
|
|
61
|
+
// Ignore
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function saveCurrentView() {
|
|
66
|
+
const name = newViewName.trim();
|
|
67
|
+
if (!name || filters.length === 0) return;
|
|
68
|
+
const newPreset: SavedPresetView = {
|
|
69
|
+
id: Math.random().toString(36).substring(2, 9),
|
|
70
|
+
name,
|
|
71
|
+
filters: $state.snapshot(filters),
|
|
72
|
+
};
|
|
73
|
+
persistPresets([...savedPresets, newPreset]);
|
|
74
|
+
activePresetId = newPreset.id;
|
|
75
|
+
newViewName = '';
|
|
76
|
+
isSavingView = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function deletePreset(id: string) {
|
|
80
|
+
persistPresets(savedPresets.filter((p) => p.id !== id));
|
|
81
|
+
if (activePresetId === id) activePresetId = null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function applyPreset(preset: SavedPresetView) {
|
|
85
|
+
activePresetId = preset.id;
|
|
86
|
+
onapplypreset?.(preset);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onMount(() => {
|
|
90
|
+
loadPresets();
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<div
|
|
95
|
+
class={cn('flex flex-wrap items-center justify-between gap-2.5 rounded-lg border border-border bg-card p-2.5 text-xs text-card-foreground shadow-2xs', className)}
|
|
96
|
+
data-svadmin-component="FilterTagBar"
|
|
97
|
+
>
|
|
98
|
+
<!-- Left: Filter Icon & Tags List -->
|
|
99
|
+
<div class="flex flex-wrap items-center gap-1.5 min-w-0 flex-1">
|
|
100
|
+
<div class="flex items-center gap-1 text-muted-foreground mr-1 shrink-0 font-medium select-none">
|
|
101
|
+
<Filter class="h-3.5 w-3.5 text-primary" />
|
|
102
|
+
<span>已生效筛选 ({filters.length})</span>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{#if filters.length === 0}
|
|
106
|
+
<span class="text-muted-foreground italic select-none">当前无筛选条件,展示全部数据</span>
|
|
107
|
+
{:else}
|
|
108
|
+
{#each filters as item (item.id)}
|
|
109
|
+
<span
|
|
110
|
+
class="inline-flex items-center gap-1 rounded-md border border-primary/20 bg-primary/10 px-2 py-0.5 text-foreground font-medium select-none"
|
|
111
|
+
data-filter-tag={item.id}
|
|
112
|
+
>
|
|
113
|
+
<span class="text-muted-foreground">{item.label}</span>
|
|
114
|
+
{#if item.operatorLabel}
|
|
115
|
+
<span class="font-mono text-xs text-primary">{item.operatorLabel}</span>
|
|
116
|
+
{/if}
|
|
117
|
+
<span class="font-semibold">{item.valueLabel}</span>
|
|
118
|
+
<button
|
|
119
|
+
type="button"
|
|
120
|
+
class="rounded-full p-0.5 text-muted-foreground hover:bg-primary/20 hover:text-primary transition-colors cursor-pointer"
|
|
121
|
+
onclick={() => onremove?.(item.id)}
|
|
122
|
+
aria-label="Remove filter"
|
|
123
|
+
>
|
|
124
|
+
<X class="h-3 w-3" />
|
|
125
|
+
</button>
|
|
126
|
+
</span>
|
|
127
|
+
{/each}
|
|
128
|
+
|
|
129
|
+
<button
|
|
130
|
+
type="button"
|
|
131
|
+
class="text-muted-foreground hover:text-destructive underline transition-colors cursor-pointer ml-1 font-medium select-none"
|
|
132
|
+
onclick={onclear}
|
|
133
|
+
>
|
|
134
|
+
清空全部
|
|
135
|
+
</button>
|
|
136
|
+
{/if}
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<!-- Right: Preset Views & Save Action -->
|
|
140
|
+
<div class="flex items-center gap-2 shrink-0 select-none">
|
|
141
|
+
{#if savedPresets.length > 0}
|
|
142
|
+
<div class="flex items-center gap-1">
|
|
143
|
+
<Bookmark class="h-3.5 w-3.5 text-muted-foreground" />
|
|
144
|
+
<select data-size="compact"
|
|
145
|
+
class="svadmin-select svadmin-select--inline"
|
|
146
|
+
value={activePresetId ?? ''}
|
|
147
|
+
onchange={(e) => {
|
|
148
|
+
const target = e.currentTarget as HTMLSelectElement;
|
|
149
|
+
const preset = savedPresets.find((p) => p.id === target.value);
|
|
150
|
+
if (preset) applyPreset(preset);
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
<option value="">常用视图预设...</option>
|
|
154
|
+
{#each savedPresets as p (p.id)}
|
|
155
|
+
<option value={p.id}>{p.name} ({p.filters.length} 项)</option>
|
|
156
|
+
{/each}
|
|
157
|
+
</select>
|
|
158
|
+
{#if activePresetId}
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
class="p-1 text-muted-foreground hover:text-destructive transition-colors cursor-pointer"
|
|
162
|
+
onclick={() => activePresetId && deletePreset(activePresetId)}
|
|
163
|
+
title="删除此预设"
|
|
164
|
+
aria-label="Delete active preset"
|
|
165
|
+
>
|
|
166
|
+
<Trash2 class="h-3 w-3" />
|
|
167
|
+
</button>
|
|
168
|
+
{/if}
|
|
169
|
+
</div>
|
|
170
|
+
{/if}
|
|
171
|
+
|
|
172
|
+
{#if isSavingView}
|
|
173
|
+
<div class="flex items-center gap-1 rounded border border-border bg-background p-0.5">
|
|
174
|
+
<input
|
|
175
|
+
type="text"
|
|
176
|
+
class="bg-transparent px-2 py-0.5 text-xs text-foreground outline-none w-28"
|
|
177
|
+
bind:value={newViewName}
|
|
178
|
+
placeholder="预设视图名称"
|
|
179
|
+
onkeydown={(e) => e.key === 'Enter' && saveCurrentView()}
|
|
180
|
+
/>
|
|
181
|
+
<button
|
|
182
|
+
type="button"
|
|
183
|
+
class="rounded p-1 text-success hover:bg-success/10 transition-colors cursor-pointer"
|
|
184
|
+
onclick={saveCurrentView}
|
|
185
|
+
disabled={!newViewName.trim()}
|
|
186
|
+
title="确认保存"
|
|
187
|
+
>
|
|
188
|
+
<Check class="h-3.5 w-3.5" />
|
|
189
|
+
</button>
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
class="rounded p-1 text-muted-foreground hover:bg-muted transition-colors cursor-pointer"
|
|
193
|
+
onclick={() => (isSavingView = false)}
|
|
194
|
+
title="取消"
|
|
195
|
+
>
|
|
196
|
+
<X class="h-3.5 w-3.5" />
|
|
197
|
+
</button>
|
|
198
|
+
</div>
|
|
199
|
+
{:else if filters.length > 0}
|
|
200
|
+
<button
|
|
201
|
+
type="button"
|
|
202
|
+
class="inline-flex items-center gap-1 rounded border border-border bg-background px-2 py-1 text-muted-foreground hover:text-foreground transition-colors cursor-pointer font-medium"
|
|
203
|
+
onclick={() => (isSavingView = true)}
|
|
204
|
+
>
|
|
205
|
+
<BookmarkPlus class="h-3.5 w-3.5 text-primary" />
|
|
206
|
+
<span>存为常用视图</span>
|
|
207
|
+
</button>
|
|
208
|
+
{/if}
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface FilterTagItem {
|
|
2
|
+
id: string;
|
|
3
|
+
field: string;
|
|
4
|
+
label: string;
|
|
5
|
+
operatorLabel?: string | undefined;
|
|
6
|
+
valueLabel: string;
|
|
7
|
+
}
|
|
8
|
+
export interface SavedPresetView {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
filters: FilterTagItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface FilterTagBarProps {
|
|
14
|
+
filters: FilterTagItem[];
|
|
15
|
+
storageKey?: string | undefined;
|
|
16
|
+
onremove?: ((filterId: string) => void) | undefined;
|
|
17
|
+
onclear?: (() => void) | undefined;
|
|
18
|
+
onapplypreset?: ((preset: SavedPresetView) => void) | undefined;
|
|
19
|
+
class?: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
declare const FilterTagBar: import("svelte").Component<FilterTagBarProps, {}, "">;
|
|
22
|
+
type FilterTagBar = ReturnType<typeof FilterTagBar>;
|
|
23
|
+
export default FilterTagBar;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calculator, Edit3, Lock } from '@lucide/svelte';
|
|
3
|
+
import { useTranslation } from '@svadmin/core/i18n';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
import { evaluateFormula, type FormulaScope } from './useFormulaEngine.svelte.js';
|
|
6
|
+
|
|
7
|
+
export interface FormulaFieldProps {
|
|
8
|
+
label?: string | undefined;
|
|
9
|
+
formula: string;
|
|
10
|
+
scope?: FormulaScope | undefined;
|
|
11
|
+
precision?: number | undefined;
|
|
12
|
+
prefix?: string | undefined;
|
|
13
|
+
suffix?: string | undefined;
|
|
14
|
+
placeholder?: string | undefined;
|
|
15
|
+
showFormulaTooltip?: boolean | undefined;
|
|
16
|
+
allowManualOverride?: boolean | undefined;
|
|
17
|
+
manualValue?: (number | string) | undefined;
|
|
18
|
+
class?: string | undefined;
|
|
19
|
+
onchange?: ((computedValue: number | null, isManual: boolean) => void) | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
label,
|
|
24
|
+
formula,
|
|
25
|
+
scope = {},
|
|
26
|
+
precision = 2,
|
|
27
|
+
prefix = '',
|
|
28
|
+
suffix = '',
|
|
29
|
+
placeholder = '0.00',
|
|
30
|
+
showFormulaTooltip = true,
|
|
31
|
+
allowManualOverride = false,
|
|
32
|
+
manualValue = $bindable(undefined),
|
|
33
|
+
class: className = '',
|
|
34
|
+
onchange,
|
|
35
|
+
}: FormulaFieldProps = $props();
|
|
36
|
+
|
|
37
|
+
const i18n = useTranslation();
|
|
38
|
+
const chinese = $derived(i18n.locale.startsWith('zh'));
|
|
39
|
+
|
|
40
|
+
let isManualMode = $state(false);
|
|
41
|
+
|
|
42
|
+
const computedValue = $derived.by(() => {
|
|
43
|
+
const raw = evaluateFormula(formula, scope);
|
|
44
|
+
if (raw === null || !Number.isFinite(raw)) return null;
|
|
45
|
+
if (precision !== undefined) {
|
|
46
|
+
const factor = Math.pow(10, precision);
|
|
47
|
+
return Math.round(raw * factor) / factor;
|
|
48
|
+
}
|
|
49
|
+
return raw;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const displayValue = $derived.by(() => {
|
|
53
|
+
if (isManualMode && manualValue !== undefined) {
|
|
54
|
+
return String(manualValue);
|
|
55
|
+
}
|
|
56
|
+
if (computedValue === null) return '';
|
|
57
|
+
return computedValue.toLocaleString(undefined, {
|
|
58
|
+
minimumFractionDigits: precision,
|
|
59
|
+
maximumFractionDigits: precision,
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
$effect(() => {
|
|
64
|
+
onchange?.(computedValue, isManualMode);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function toggleManual() {
|
|
68
|
+
isManualMode = !isManualMode;
|
|
69
|
+
if (!isManualMode) {
|
|
70
|
+
manualValue = undefined;
|
|
71
|
+
} else if (computedValue !== null) {
|
|
72
|
+
manualValue = computedValue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const resolvedLabel = $derived(label ?? (chinese ? '公式自动计算字段' : 'Formula Field'));
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div
|
|
80
|
+
data-svadmin-component="FormulaField"
|
|
81
|
+
data-manual={isManualMode ? 'true' : 'false'}
|
|
82
|
+
class={cn('space-y-1.5 text-xs', className)}
|
|
83
|
+
>
|
|
84
|
+
<!-- Label & Formula Badge Bar -->
|
|
85
|
+
<div class="flex items-center justify-between">
|
|
86
|
+
<label class="flex items-center gap-1.5 font-medium text-foreground">
|
|
87
|
+
<Calculator class="h-3.5 w-3.5 text-primary" />
|
|
88
|
+
<span>{resolvedLabel}</span>
|
|
89
|
+
</label>
|
|
90
|
+
|
|
91
|
+
<div class="flex items-center gap-1.5 text-[11px]">
|
|
92
|
+
{#if showFormulaTooltip}
|
|
93
|
+
<span
|
|
94
|
+
class="inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 font-mono text-primary font-semibold"
|
|
95
|
+
title={chinese ? `计算公式: ${formula}` : `Formula: ${formula}`}
|
|
96
|
+
>
|
|
97
|
+
<span>f(x):</span>
|
|
98
|
+
<span class="max-w-32 truncate">{formula}</span>
|
|
99
|
+
</span>
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
{#if allowManualOverride}
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onclick={toggleManual}
|
|
106
|
+
class="inline-flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors"
|
|
107
|
+
title={isManualMode ? (chinese ? '切回公式自动计算' : 'Switch to Auto') : (chinese ? '手动修改覆盖' : 'Override')}
|
|
108
|
+
>
|
|
109
|
+
{#if isManualMode}
|
|
110
|
+
<Lock class="h-3 w-3 text-warning" />
|
|
111
|
+
<span class="text-warning font-medium">{chinese ? '已手动覆盖' : 'Overridden'}</span>
|
|
112
|
+
{:else}
|
|
113
|
+
<Edit3 class="h-3 w-3" />
|
|
114
|
+
<span>{chinese ? '手动覆盖' : 'Override'}</span>
|
|
115
|
+
{/if}
|
|
116
|
+
</button>
|
|
117
|
+
{/if}
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- Formatted Display Input -->
|
|
122
|
+
<div class="relative flex items-center">
|
|
123
|
+
{#if prefix}
|
|
124
|
+
<span class="absolute left-2.5 font-mono text-muted-foreground select-none">
|
|
125
|
+
{prefix}
|
|
126
|
+
</span>
|
|
127
|
+
{/if}
|
|
128
|
+
|
|
129
|
+
<input
|
|
130
|
+
type="text"
|
|
131
|
+
readonly={!isManualMode}
|
|
132
|
+
value={displayValue}
|
|
133
|
+
oninput={(e) => (manualValue = (e.target as HTMLInputElement).value)}
|
|
134
|
+
{placeholder}
|
|
135
|
+
class={cn(
|
|
136
|
+
'h-8.5 w-full rounded-md border font-mono text-xs shadow-2xs transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
|
|
137
|
+
isManualMode ? 'bg-background border-warning text-foreground' : 'bg-muted/40 border-input text-foreground font-semibold cursor-default',
|
|
138
|
+
prefix ? 'pl-7' : 'pl-3',
|
|
139
|
+
suffix ? 'pr-7' : 'pr-3',
|
|
140
|
+
)}
|
|
141
|
+
/>
|
|
142
|
+
|
|
143
|
+
{#if suffix}
|
|
144
|
+
<span class="absolute right-2.5 font-mono text-muted-foreground select-none">
|
|
145
|
+
{suffix}
|
|
146
|
+
</span>
|
|
147
|
+
{/if}
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FormulaScope } from './useFormulaEngine.svelte.js';
|
|
2
|
+
export interface FormulaFieldProps {
|
|
3
|
+
label?: string | undefined;
|
|
4
|
+
formula: string;
|
|
5
|
+
scope?: FormulaScope | undefined;
|
|
6
|
+
precision?: number | undefined;
|
|
7
|
+
prefix?: string | undefined;
|
|
8
|
+
suffix?: string | undefined;
|
|
9
|
+
placeholder?: string | undefined;
|
|
10
|
+
showFormulaTooltip?: boolean | undefined;
|
|
11
|
+
allowManualOverride?: boolean | undefined;
|
|
12
|
+
manualValue?: (number | string) | undefined;
|
|
13
|
+
class?: string | undefined;
|
|
14
|
+
onchange?: ((computedValue: number | null, isManual: boolean) => void) | undefined;
|
|
15
|
+
}
|
|
16
|
+
declare const FormulaField: import("svelte").Component<FormulaFieldProps, {}, "manualValue">;
|
|
17
|
+
type FormulaField = ReturnType<typeof FormulaField>;
|
|
18
|
+
export default FormulaField;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
|
|
4
|
+
export interface GeoRegionData {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
value: number;
|
|
8
|
+
subtext?: string | undefined;
|
|
9
|
+
status?: 'normal' | 'warning' | 'critical' | 'highlight' | undefined;
|
|
10
|
+
x?: number | undefined;
|
|
11
|
+
y?: number | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface GeoScatterMapProps {
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
subtitle?: string | undefined;
|
|
17
|
+
regions?: GeoRegionData[] | undefined;
|
|
18
|
+
metricLabel?: string | undefined;
|
|
19
|
+
selectedRegionId?: string | undefined;
|
|
20
|
+
showBubbles?: boolean | undefined;
|
|
21
|
+
class?: string | undefined;
|
|
22
|
+
onSelectRegion?: ((region: GeoRegionData) => void) | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const defaultRegions: GeoRegionData[] = [
|
|
26
|
+
{ id: 'east', name: '华东大区 (上海/江浙)', value: 4820, x: 78, y: 58, status: 'highlight', subtext: '含5个超级算力中心' },
|
|
27
|
+
{ id: 'south', name: '华南大区 (广深/港澳)', value: 3650, x: 68, y: 82, status: 'normal', subtext: '跨境核心中继集群' },
|
|
28
|
+
{ id: 'north', name: '华北大区 (京津冀)', value: 4120, x: 72, y: 35, status: 'normal', subtext: '主核心控制节点' },
|
|
29
|
+
{ id: 'central', name: '华中大区 (两湖/河南)', value: 2450, x: 60, y: 60, status: 'normal', subtext: '灾备冷备存储仓' },
|
|
30
|
+
{ id: 'southwest', name: '西南大区 (成渝/云贵)', value: 3100, x: 42, y: 68, status: 'warning', subtext: '水冷水电高能效算力' },
|
|
31
|
+
{ id: 'northwest', name: '西北大区 (陕甘宁青新)', value: 1850, x: 30, y: 38, status: 'normal', subtext: '西数东算绿色基地' },
|
|
32
|
+
{ id: 'northeast', name: '东北大区 (黑吉辽)', value: 1280, x: 86, y: 22, status: 'normal', subtext: '北方边缘缓存池' }
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
title = '业务地域空间分布拓扑图',
|
|
37
|
+
subtitle = '轻量原生 SVG 矢量区划与散点热力分布',
|
|
38
|
+
regions = defaultRegions,
|
|
39
|
+
metricLabel = '并发连接数',
|
|
40
|
+
selectedRegionId = undefined,
|
|
41
|
+
showBubbles = true,
|
|
42
|
+
class: className = '',
|
|
43
|
+
onSelectRegion = undefined
|
|
44
|
+
}: GeoScatterMapProps = $props();
|
|
45
|
+
|
|
46
|
+
let activeRegionId = $state<string | undefined>(untrack(() => selectedRegionId ?? regions[0]?.id));
|
|
47
|
+
|
|
48
|
+
const sortedRegions = $derived(
|
|
49
|
+
[...regions].sort((a, b) => b.value - a.value)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const maxValue = $derived(
|
|
53
|
+
Math.max(...regions.map(r => r.value), 1)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const currentActiveRegion = $derived(
|
|
57
|
+
regions.find(r => r.id === activeRegionId) ?? regions[0]
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
function handleSelect(region: GeoRegionData) {
|
|
61
|
+
activeRegionId = region.id;
|
|
62
|
+
onSelectRegion?.(region);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getStatusBadge(status?: string): { label: string; class: string } {
|
|
66
|
+
switch (status) {
|
|
67
|
+
case 'highlight':
|
|
68
|
+
return { label: '重点区域', class: 'bg-primary/10 text-primary border-primary/20' };
|
|
69
|
+
case 'warning':
|
|
70
|
+
return { label: '算力预警', class: 'bg-warning/10 text-warning border-warning/20' };
|
|
71
|
+
case 'critical':
|
|
72
|
+
return { label: '负载超限', class: 'bg-destructive/10 text-destructive border-destructive/20' };
|
|
73
|
+
default:
|
|
74
|
+
return { label: '运行正常', class: 'bg-success/10 text-success border-success/20' };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<div
|
|
80
|
+
class="flex flex-col gap-4 rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm {className}"
|
|
81
|
+
data-svadmin-component="GeoScatterMap"
|
|
82
|
+
>
|
|
83
|
+
<div class="flex flex-wrap items-center justify-between gap-3 border-b border-border pb-3">
|
|
84
|
+
<div class="flex items-center gap-2.5">
|
|
85
|
+
<div class="flex h-8 w-8 items-center justify-center rounded-md bg-primary/10 text-primary">
|
|
86
|
+
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
87
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3.055 11H5a2 2 0 012 2v1a2 2 0 002 2 2 2 0 012 2v2.945M8 3.935V5.5A2.5 2.5 0 0010.5 8h.5a2 2 0 012 2 2 2 0 104 0 2 2 0 012-2h1.064M15 20.488V18a2 2 0 012-2h3.064M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
88
|
+
</svg>
|
|
89
|
+
</div>
|
|
90
|
+
<div>
|
|
91
|
+
<h3 class="text-sm font-medium text-foreground">{title}</h3>
|
|
92
|
+
<p class="text-xs text-muted-foreground">{subtitle}</p>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
<div class="flex items-center gap-2">
|
|
96
|
+
<span class="inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2.5 py-0.5 text-xs font-medium text-muted-foreground">
|
|
97
|
+
<span class="h-1.5 w-1.5 rounded-full bg-success"></span>
|
|
98
|
+
实时动态心跳
|
|
99
|
+
</span>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
|
104
|
+
<div class="lg:col-span-2 relative min-h-[320px] rounded-md border border-border bg-muted/20 p-4 flex flex-col justify-between overflow-hidden">
|
|
105
|
+
<svg class="absolute inset-0 h-full w-full opacity-10 pointer-events-none" xmlns="http://www.w3.org/2000/svg">
|
|
106
|
+
<defs>
|
|
107
|
+
<pattern id="grid" width="24" height="24" patternUnits="userSpaceOnUse">
|
|
108
|
+
<path d="M 24 0 L 0 0 0 24" fill="none" stroke="currentColor" stroke-width="0.5" />
|
|
109
|
+
</pattern>
|
|
110
|
+
</defs>
|
|
111
|
+
<rect width="100%" height="100%" fill="url(#grid)" />
|
|
112
|
+
</svg>
|
|
113
|
+
|
|
114
|
+
<div class="relative h-full w-full min-h-[280px]">
|
|
115
|
+
{#each regions as region (region.id)}
|
|
116
|
+
{@const x = region.x ?? 50}
|
|
117
|
+
{@const y = region.y ?? 50}
|
|
118
|
+
{@const radius = Math.max(14, Math.min(36, (region.value / maxValue) * 36))}
|
|
119
|
+
{@const isSelected = activeRegionId === region.id}
|
|
120
|
+
|
|
121
|
+
<div
|
|
122
|
+
class="absolute -translate-x-1/2 -translate-y-1/2 cursor-pointer transition-all duration-200 group"
|
|
123
|
+
style="left: {x}%; top: {y}%;"
|
|
124
|
+
onclick={() => handleSelect(region)}
|
|
125
|
+
onkeydown={(e) => { if (e.key === 'Enter') handleSelect(region); }}
|
|
126
|
+
role="button"
|
|
127
|
+
tabindex="0"
|
|
128
|
+
>
|
|
129
|
+
{#if showBubbles}
|
|
130
|
+
<div
|
|
131
|
+
class="absolute -translate-x-1/2 -translate-y-1/2 rounded-full transition-transform group-hover:scale-125 {isSelected ? 'bg-primary/20 ring-2 ring-primary' : 'bg-primary/10'}"
|
|
132
|
+
style="width: {radius * 2}px; height: {radius * 2}px; left: 50%; top: 50%;"
|
|
133
|
+
></div>
|
|
134
|
+
{/if}
|
|
135
|
+
|
|
136
|
+
<div
|
|
137
|
+
class="relative z-10 flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium shadow-sm transition-all {isSelected ? 'border-primary bg-primary text-primary-foreground scale-105' : 'border-border bg-card text-card-foreground hover:border-primary/50'}"
|
|
138
|
+
>
|
|
139
|
+
<span class="h-2 w-2 rounded-full {region.status === 'warning' ? 'bg-warning' : region.status === 'critical' ? 'bg-destructive' : 'bg-primary'}"></span>
|
|
140
|
+
<span class="font-medium whitespace-nowrap">{region.name.split(' ')[0]}</span>
|
|
141
|
+
<span class="opacity-80 text-[10px]">{region.value}</span>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
{/each}
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<div class="relative z-10 mt-2 flex flex-wrap items-center justify-between text-xs text-muted-foreground border-t border-border/50 pt-2">
|
|
148
|
+
<div class="flex items-center gap-3">
|
|
149
|
+
<span class="flex items-center gap-1">
|
|
150
|
+
<span class="h-2 w-2 rounded-full bg-primary"></span> 核心大区
|
|
151
|
+
</span>
|
|
152
|
+
<span class="flex items-center gap-1">
|
|
153
|
+
<span class="h-2 w-2 rounded-full bg-warning"></span> 高峰载荷
|
|
154
|
+
</span>
|
|
155
|
+
<span class="flex items-center gap-1">
|
|
156
|
+
<span class="h-2 w-2 rounded-full bg-success"></span> 稳定低延时
|
|
157
|
+
</span>
|
|
158
|
+
</div>
|
|
159
|
+
<div>
|
|
160
|
+
<span>散点权重基准: {metricLabel}</span>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<div class="flex flex-col gap-3">
|
|
166
|
+
{#if currentActiveRegion}
|
|
167
|
+
{@const badge = getStatusBadge(currentActiveRegion.status)}
|
|
168
|
+
<div class="rounded-md border border-border bg-muted/30 p-3 flex flex-col gap-2">
|
|
169
|
+
<div class="flex items-center justify-between">
|
|
170
|
+
<span class="text-xs font-semibold text-foreground">{currentActiveRegion.name}</span>
|
|
171
|
+
<span class="rounded border px-1.5 py-0.5 text-[10px] font-medium {badge.class}">
|
|
172
|
+
{badge.label}
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="flex items-baseline gap-2">
|
|
176
|
+
<span class="text-2xl font-bold tracking-tight text-primary">
|
|
177
|
+
{currentActiveRegion.value.toLocaleString()}
|
|
178
|
+
</span>
|
|
179
|
+
<span class="text-xs text-muted-foreground">{metricLabel}</span>
|
|
180
|
+
</div>
|
|
181
|
+
{#if currentActiveRegion.subtext}
|
|
182
|
+
<p class="text-xs text-muted-foreground border-t border-border/40 pt-1.5">
|
|
183
|
+
{currentActiveRegion.subtext}
|
|
184
|
+
</p>
|
|
185
|
+
{/if}
|
|
186
|
+
</div>
|
|
187
|
+
{/if}
|
|
188
|
+
|
|
189
|
+
<div class="rounded-md border border-border bg-card p-3 flex-1 flex flex-col gap-2">
|
|
190
|
+
<div class="flex items-center justify-between border-b border-border pb-2">
|
|
191
|
+
<span class="text-xs font-medium text-foreground">各区域综合负载排行</span>
|
|
192
|
+
<span class="text-[10px] text-muted-foreground">TOP {sortedRegions.length}</span>
|
|
193
|
+
</div>
|
|
194
|
+
<div class="flex flex-col gap-2 overflow-y-auto max-h-[220px] pr-1">
|
|
195
|
+
{#each sortedRegions as r, idx (r.id)}
|
|
196
|
+
{@const percent = Math.round((r.value / maxValue) * 100)}
|
|
197
|
+
<div
|
|
198
|
+
class="flex flex-col gap-1 cursor-pointer rounded p-1.5 transition-colors hover:bg-muted/50 {activeRegionId === r.id ? 'bg-muted/60 ring-1 ring-primary/40' : ''}"
|
|
199
|
+
onclick={() => handleSelect(r)}
|
|
200
|
+
onkeydown={(e) => { if (e.key === 'Enter') handleSelect(r); }}
|
|
201
|
+
role="button"
|
|
202
|
+
tabindex="0"
|
|
203
|
+
>
|
|
204
|
+
<div class="flex items-center justify-between text-xs">
|
|
205
|
+
<div class="flex items-center gap-1.5">
|
|
206
|
+
<span class="inline-flex h-4 w-4 items-center justify-center rounded text-[10px] font-bold {idx === 0 ? 'bg-primary text-primary-foreground' : idx < 3 ? 'bg-muted text-foreground' : 'text-muted-foreground'}">
|
|
207
|
+
{idx + 1}
|
|
208
|
+
</span>
|
|
209
|
+
<span class="font-medium text-foreground">{r.name}</span>
|
|
210
|
+
</div>
|
|
211
|
+
<span class="font-semibold text-foreground">{r.value}</span>
|
|
212
|
+
</div>
|
|
213
|
+
<div class="h-1.5 w-full rounded-full bg-muted overflow-hidden">
|
|
214
|
+
<div
|
|
215
|
+
class="h-full rounded-full bg-primary transition-all duration-300"
|
|
216
|
+
style="width: {percent}%"
|
|
217
|
+
></div>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
{/each}
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface GeoRegionData {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
value: number;
|
|
5
|
+
subtext?: string | undefined;
|
|
6
|
+
status?: 'normal' | 'warning' | 'critical' | 'highlight' | undefined;
|
|
7
|
+
x?: number | undefined;
|
|
8
|
+
y?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface GeoScatterMapProps {
|
|
11
|
+
title?: string | undefined;
|
|
12
|
+
subtitle?: string | undefined;
|
|
13
|
+
regions?: GeoRegionData[] | undefined;
|
|
14
|
+
metricLabel?: string | undefined;
|
|
15
|
+
selectedRegionId?: string | undefined;
|
|
16
|
+
showBubbles?: boolean | undefined;
|
|
17
|
+
class?: string | undefined;
|
|
18
|
+
onSelectRegion?: ((region: GeoRegionData) => void) | undefined;
|
|
19
|
+
}
|
|
20
|
+
declare const GeoScatterMap: import("svelte").Component<GeoScatterMapProps, {}, "">;
|
|
21
|
+
type GeoScatterMap = ReturnType<typeof GeoScatterMap>;
|
|
22
|
+
export default GeoScatterMap;
|