@svadmin/ui 0.126.1 → 0.127.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 (111) hide show
  1. package/dist/app.css +505 -54
  2. package/dist/app.theme.css +505 -54
  3. package/dist/components/AbacPolicyMatrix.svelte +1 -1
  4. package/dist/components/AboutSettings.svelte +1 -1
  5. package/dist/components/ActionPalette.svelte +2 -2
  6. package/dist/components/ActivityFeed.svelte +1 -1
  7. package/dist/components/AdminApp.svelte +2 -2
  8. package/dist/components/AdminCopilotWidget.svelte +4 -4
  9. package/dist/components/AnimatedCounter.svelte +2 -1
  10. package/dist/components/ApiPlayground.svelte +2 -2
  11. package/dist/components/ApiSettings.svelte +3 -3
  12. package/dist/components/ApprovalActionCard.svelte +1 -1
  13. package/dist/components/AsyncExportModal.svelte +6 -6
  14. package/dist/components/AuditLogDrawer.svelte +1 -1
  15. package/dist/components/AuditLogViewer.svelte +3 -3
  16. package/dist/components/AuditTrailInspector.svelte +1 -1
  17. package/dist/components/AutoTable.svelte +2 -1
  18. package/dist/components/BatchEditModal.svelte +2 -2
  19. package/dist/components/BillingInvoiceDrawer.svelte +4 -3
  20. package/dist/components/CanvasAnnotation.svelte +1 -1
  21. package/dist/components/Cascader.svelte +3 -3
  22. package/dist/components/ColumnSettings.svelte +1 -1
  23. package/dist/components/ColumnVisibilityDrawer.svelte +2 -2
  24. package/dist/components/CommandPalette.svelte +1 -1
  25. package/dist/components/CommentThread.svelte +2 -1
  26. package/dist/components/ConcurrentConflictModal.svelte +3 -3
  27. package/dist/components/ConfirmDialog.svelte +2 -2
  28. package/dist/components/DashboardLayoutStorage.svelte +2 -2
  29. package/dist/components/DataFreshnessIndicator.svelte +1 -1
  30. package/dist/components/DataImportDropzone.svelte +1 -1
  31. package/dist/components/DrawerForm.svelte +1 -1
  32. package/dist/components/DualApprovalGate.svelte +2 -2
  33. package/dist/components/ExcelExportButton.svelte +1 -1
  34. package/dist/components/ExcelImportWizard.svelte +1 -1
  35. package/dist/components/FieldRenderer.svelte +4 -4
  36. package/dist/components/FilterDropdown.svelte +2 -2
  37. package/dist/components/FilterTagBar.svelte +1 -1
  38. package/dist/components/GlobalShortcuts.svelte +1 -1
  39. package/dist/components/HmacSignatureCalculator.svelte +2 -2
  40. package/dist/components/I18nLanguagePackEditor.svelte +1 -1
  41. package/dist/components/ImportPreviewValidator.svelte +1 -1
  42. package/dist/components/ImportWizard.svelte +2 -2
  43. package/dist/components/IncidentWarRoomDrawer.svelte +1 -1
  44. package/dist/components/InlineEdit.svelte +1 -1
  45. package/dist/components/JsonViewer.svelte +1 -1
  46. package/dist/components/KeyboardShortcutsModal.svelte +1 -1
  47. package/dist/components/KpiCard.svelte +2 -1
  48. package/dist/components/LazyPage.svelte +1 -1
  49. package/dist/components/LiveIndicator.svelte +1 -1
  50. package/dist/components/LiveStreamLogViewer.svelte +1 -1
  51. package/dist/components/LockScreen.svelte +4 -4
  52. package/dist/components/MasterDetailView.svelte +1 -1
  53. package/dist/components/MasterSubTableDrawer.svelte +1 -1
  54. package/dist/components/MentionsInput.svelte +1 -1
  55. package/dist/components/MicroAppFrame.svelte +1 -1
  56. package/dist/components/MicroAppSandbox.svelte +1 -1
  57. package/dist/components/MockDataInterceptor.svelte +1 -1
  58. package/dist/components/ModalForm.svelte +9 -9
  59. package/dist/components/NavigateToResource.svelte +1 -1
  60. package/dist/components/NotificationCenter.svelte +2 -1
  61. package/dist/components/OfflineSyncBanner.svelte +1 -1
  62. package/dist/components/OmnibarCommandPalette.svelte +1 -1
  63. package/dist/components/PivotDrilldownModal.svelte +1 -1
  64. package/dist/components/Popconfirm.svelte +62 -21
  65. package/dist/components/Popconfirm.svelte.d.ts +5 -0
  66. package/dist/components/QueryBuilder.svelte +1 -1
  67. package/dist/components/QuotaProgressBar.svelte +2 -1
  68. package/dist/components/RecordCompareModal.svelte +1 -1
  69. package/dist/components/RuleExpressionBuilder.svelte +1 -1
  70. package/dist/components/SafeDeleteConfirm.svelte +1 -1
  71. package/dist/components/ScheduledJobManager.svelte +1 -1
  72. package/dist/components/SchemaVisualModeler.svelte +1 -1
  73. package/dist/components/SecureDataExporter.svelte +1 -1
  74. package/dist/components/SecuritySettings.svelte +3 -3
  75. package/dist/components/SessionTimeoutGuard.svelte +1 -1
  76. package/dist/components/Statistic.svelte +2 -1
  77. package/dist/components/StepWizard.svelte +1 -1
  78. package/dist/components/SvarDataGrid.svelte +1 -1
  79. package/dist/components/SystemHealthCheckDashboard.svelte +2 -2
  80. package/dist/components/TableAggregationFooter.svelte +3 -1
  81. package/dist/components/TaskCenter.svelte +3 -2
  82. package/dist/components/TenantContextSwitcher.svelte +1 -1
  83. package/dist/components/ThreadedCommentDrawer.svelte +1 -1
  84. package/dist/components/Toast.svelte +7 -1
  85. package/dist/components/Toast.svelte.d.ts +4 -1
  86. package/dist/components/Transfer.svelte +2 -2
  87. package/dist/components/TreeSelect.svelte +2 -2
  88. package/dist/components/TreeTransferSelect.svelte +2 -2
  89. package/dist/components/VirtualTreeSelect.svelte +2 -2
  90. package/dist/components/WebhookSimulator.svelte +1 -1
  91. package/dist/components/WidgetContainer.svelte +2 -1
  92. package/dist/components/account/SettingsEnterprisePage.svelte +5 -4
  93. package/dist/components/charts/FunnelChart.svelte +2 -2
  94. package/dist/components/content/AuditTimeline.svelte +2 -1
  95. package/dist/components/content/ContentPageHeader.svelte +2 -2
  96. package/dist/components/fields/CopyField.svelte +1 -1
  97. package/dist/components/fields/DateRangeField.svelte +7 -13
  98. package/dist/components/svar-grid-interactions.js +9 -5
  99. package/dist/components/ui/alert/alert.svelte +1 -0
  100. package/dist/components/ui/command/command-list.svelte +2 -0
  101. package/dist/components/ui/command/command-loading.svelte +13 -7
  102. package/dist/components/ui/dialog/dialog-content.svelte +15 -1
  103. package/dist/components/ui/dialog/dialog-content.svelte.d.ts +6 -0
  104. package/dist/components/ui/input/input.svelte +82 -7
  105. package/dist/components/ui/input/input.svelte.d.ts +7 -2
  106. package/dist/copy-format.d.ts +2 -0
  107. package/dist/copy-format.js +1 -0
  108. package/dist/index.d.ts +3 -0
  109. package/dist/index.js +2 -0
  110. package/dist/page-chrome.css +5 -0
  111. package/package.json +4 -4
@@ -109,7 +109,7 @@
109
109
  type="text"
110
110
  class="w-full bg-transparent outline-none text-foreground text-xs"
111
111
  bind:value={secretKey}
112
- placeholder="请输入密钥..."
112
+ placeholder="请输入密钥…"
113
113
  />
114
114
  </div>
115
115
  </div>
@@ -178,7 +178,7 @@
178
178
  type="text"
179
179
  class="flex-1 rounded-md border border-input bg-background px-3 py-1.5 text-xs text-foreground outline-none focus:ring-1 focus:ring-primary"
180
180
  bind:value={expectedSignature}
181
- placeholder="例如粘贴 X-Svadmin-Signature 标头值..."
181
+ placeholder="例如粘贴 X-Svadmin-Signature 标头值…"
182
182
  />
183
183
 
184
184
  {#if isMatched !== null}
@@ -165,7 +165,7 @@
165
165
  <input
166
166
  type="text"
167
167
  bind:value={query}
168
- placeholder={chinese ? '检索词条 Key 或文本...' : 'Search keys or text...'}
168
+ placeholder={chinese ? '检索词条 Key 或文本…' : 'Search keys or text…'}
169
169
  class="h-7.5 w-full rounded-md border border-input bg-background pl-8 pr-2.5 text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
170
170
  />
171
171
  </div>
@@ -229,7 +229,7 @@
229
229
  >
230
230
  {#if isSubmitting}
231
231
  <Loader2 class="h-3.5 w-3.5 animate-spin" />
232
- <span>正在入库提交...</span>
232
+ <span>正在入库提交…</span>
233
233
  {:else}
234
234
  <span>确认导入 ({validCount} 条正常数据)</span>
235
235
  <ArrowRight class="h-3.5 w-3.5" />
@@ -854,7 +854,7 @@
854
854
  <div class="space-y-5 py-2">
855
855
  <div class="space-y-2">
856
856
  <div class="flex items-center justify-between text-xs">
857
- <span class="text-muted-foreground">{cancelled ? i18n.t('import.stopped') : isImporting ? i18n.t('common.importing', { defaultValue: 'Importing...' }) : importError ? i18n.t('common.operationFailed', { defaultValue: 'Import failed' }) : i18n.t('common.completed', { defaultValue: 'Completed' })}</span>
857
+ <span class="text-muted-foreground">{cancelled ? i18n.t('import.stopped') : isImporting ? i18n.t('common.importing', { defaultValue: 'Importing…' }) : importError ? i18n.t('common.operationFailed', { defaultValue: 'Import failed' }) : i18n.t('common.completed', { defaultValue: 'Completed' })}</span>
858
858
  {#if !cancelled}<span class="font-semibold text-foreground tabular-nums">{progressPercent}%</span>{/if}
859
859
  </div>
860
860
  {#if !cancelled}<Progress value={progressPercent} class="h-2" />{/if}
@@ -904,7 +904,7 @@
904
904
  <Button variant="outline" size="sm" onclick={cancelImport}>{i18n.t('common.cancel')}</Button>
905
905
  <Button size="sm" disabled class="gap-2">
906
906
  <Loader2 class="h-3.5 w-3.5 animate-spin" />
907
- {i18n.t('common.processing', { defaultValue: 'Processing...' })}
907
+ {i18n.t('common.processing', { defaultValue: 'Processing…' })}
908
908
  </Button>
909
909
  {/if}
910
910
  </div>
@@ -181,7 +181,7 @@
181
181
  <input
182
182
  type="text"
183
183
  bind:value={newNoteText}
184
- placeholder={chinese ? '同步应急进展或处置备注...' : 'Add progress note...'}
184
+ placeholder={chinese ? '同步应急进展或处置备注…' : 'Add progress note…'}
185
185
  class="h-8.5 flex-1 rounded-md border border-input bg-background px-3 text-xs focus-visible:outline-none"
186
186
  />
187
187
  <Button size="sm" onclick={handleSendNote} disabled={!newNoteText.trim()} class="h-8.5 px-3 gap-1">
@@ -149,7 +149,7 @@
149
149
  <Button type="button" variant="ghost" size="icon-sm" disabled={saving} title={i18n.t('common.save')}
150
150
  aria-label={i18n.t('common.save')} aria-busy={saving} onclick={save}>
151
151
  {#if saving}
152
- <Loader2 class="h-4 w-4 animate-spin" role="status" aria-label="Saving..." />
152
+ <Loader2 class="h-4 w-4 animate-spin" role="status" aria-label="Saving…" />
153
153
  {:else}
154
154
  <Check class="h-4 w-4" />
155
155
  {/if}
@@ -130,7 +130,7 @@
130
130
  <input
131
131
  type="text"
132
132
  bind:value={searchQuery}
133
- placeholder="搜索 Key 或 Value..."
133
+ placeholder="搜索 Key 或 Value…"
134
134
  class="w-full pl-8 pr-2.5 py-1 text-xs rounded-md border border-border bg-background text-foreground placeholder:text-muted-foreground focus:outline-2 focus:outline-primary"
135
135
  />
136
136
  </div>
@@ -280,7 +280,7 @@
280
280
  bind:this={searchInputRef}
281
281
  type="text"
282
282
  bind:value={query}
283
- placeholder={chinese ? '搜索快捷键名称、描述或按键 (如 Mod+S, J/K)...' : 'Search shortcuts by action, category, or key...'}
283
+ placeholder={chinese ? '搜索快捷键名称、描述或按键 (如 Mod+S, J/K)…' : 'Search shortcuts by action, category, or key…'}
284
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
285
  />
286
286
  {#if query}
@@ -2,6 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
  import { AlertTriangle, AlertCircle } from '@lucide/svelte';
4
4
  import TrendIndicator from './TrendIndicator.svelte';
5
+ import { formatAdminNumber } from '@svadmin/core';
5
6
  import { cn } from '../utils.js';
6
7
 
7
8
  export interface KpiCardProps {
@@ -64,7 +65,7 @@
64
65
 
65
66
  const formattedValue = $derived.by(() => {
66
67
  if (typeof value === 'number') {
67
- return value.toLocaleString('en-US');
68
+ return formatAdminNumber(value, 'en-US');
68
69
  }
69
70
  return String(value);
70
71
  });
@@ -35,7 +35,7 @@
35
35
 
36
36
  {#await pagePromise}
37
37
  <div class="flex min-h-40 items-center justify-center" role="status" aria-live="polite">
38
- <span class="text-sm text-muted-foreground">Loading...</span>
38
+ <span class="text-sm text-muted-foreground">Loading…</span>
39
39
  </div>
40
40
  {:then pageModule}
41
41
  {@const Page = pageModule.default as unknown as Component<Record<string, unknown>>}
@@ -17,7 +17,7 @@
17
17
 
18
18
  const statusConfigs = {
19
19
  connected: { variant: 'default' as const, dotClass: 'bg-success', label: 'Live', icon: Wifi },
20
- connecting: { variant: 'secondary' as const, dotClass: 'bg-warning', label: 'Connecting...', icon: Loader2 as typeof Wifi },
20
+ connecting: { variant: 'secondary' as const, dotClass: 'bg-warning', label: 'Connecting…', icon: Loader2 as typeof Wifi },
21
21
  disconnected: { variant: 'destructive' as const, dotClass: 'bg-destructive', label: 'Offline', icon: WifiOff },
22
22
  } as const;
23
23
  type StatusKey = 'connected' | 'connecting' | 'disconnected';
@@ -108,7 +108,7 @@
108
108
  <Search class="h-3 w-3 absolute left-2 text-muted-foreground pointer-events-none" />
109
109
  <input
110
110
  type="text"
111
- placeholder="关键词匹配..."
111
+ placeholder="关键词匹配…"
112
112
  bind:value={searchQuery}
113
113
  class="h-7 w-32 md:w-44 rounded-md border border-border bg-background pl-6 pr-2 text-xs text-foreground outline-none focus:border-primary"
114
114
  />
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { onMount, onDestroy, type Snippet } from 'svelte';
3
3
  import { Lock, Unlock, Eye, EyeOff, ShieldCheck, Clock } from '@lucide/svelte';
4
- import { useTranslation } from '@svadmin/core';
4
+ import { formatAdminDate, useTranslation } from '@svadmin/core';
5
5
  import { cn } from '../utils.js';
6
6
  import MediaThumbnail from './content/MediaThumbnail.svelte';
7
7
 
@@ -54,12 +54,12 @@
54
54
  const seconds = String(now.getSeconds()).padStart(2, '0');
55
55
  currentTime = `${hours}:${minutes}:${seconds}`;
56
56
 
57
- const options: Intl.DateTimeFormatOptions = {
57
+ currentDate = formatAdminDate(now, {
58
+ locale: i18n.locale === 'zh-CN' ? 'zh-CN' : 'en-US',
58
59
  month: 'long',
59
60
  day: 'numeric',
60
61
  weekday: 'long',
61
- };
62
- currentDate = now.toLocaleDateString(i18n.locale === 'zh-CN' ? 'zh-CN' : 'en-US', options);
62
+ });
63
63
  }
64
64
 
65
65
  // 自动空闲超时检测
@@ -56,7 +56,7 @@
56
56
  <input
57
57
  type="text"
58
58
  bind:value={searchQuery}
59
- placeholder="Search items..."
59
+ placeholder="Search items…"
60
60
  class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-2 text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
61
61
  />
62
62
  </div>
@@ -137,7 +137,7 @@
137
137
  <input
138
138
  type="text"
139
139
  bind:value={searchQuery}
140
- placeholder={chinese ? '筛选明细...' : 'Search items...'}
140
+ placeholder={chinese ? '筛选明细…' : 'Search items…'}
141
141
  class="h-7 w-40 rounded border border-input bg-background pl-7.5 pr-2 text-xs focus-visible:outline-none"
142
142
  />
143
143
  </div>
@@ -25,7 +25,7 @@
25
25
 
26
26
  let {
27
27
  value = $bindable(''),
28
- placeholder = 'Type @ to mention team members, or # to link tags...',
28
+ placeholder = 'Type @ to mention team members, or # to link tags…',
29
29
  triggers = ['@', '#'],
30
30
  users = [],
31
31
  tags = [],
@@ -245,7 +245,7 @@
245
245
  data-svadmin-frame-loading="true"
246
246
  >
247
247
  <Loader2 class="h-7 w-7 animate-spin text-primary mb-2" />
248
- <span class="text-xs text-muted-foreground font-medium">Connecting micro application...</span>
248
+ <span class="text-xs text-muted-foreground font-medium">Connecting micro application…</span>
249
249
  </div>
250
250
  {/if}
251
251
 
@@ -149,7 +149,7 @@
149
149
  <!-- 加载过渡态骨架 -->
150
150
  <div class="p-6 flex flex-col items-center justify-center gap-3 text-muted-foreground">
151
151
  <Activity class="w-8 h-8 text-primary animate-spin" />
152
- <div class="text-xs">正在向子应用注入登录令牌与安全样式表...</div>
152
+ <div class="text-xs">正在向子应用注入登录令牌与安全样式表…</div>
153
153
  </div>
154
154
  {:else if status === 'error'}
155
155
  <!-- 异常崩溃容灾降级面板 -->
@@ -269,7 +269,7 @@
269
269
  class="w-full rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50"
270
270
  onclick={() => runTest(currentRule)}
271
271
  >
272
- {isTesting ? '正在模拟请求与网络延迟...' : '立即发起模拟请求验证'}
272
+ {isTesting ? '正在模拟请求与网络延迟…' : '立即发起模拟请求验证'}
273
273
  </button>
274
274
 
275
275
  {#if testStatus !== null}
@@ -35,7 +35,7 @@
35
35
  triggerSize = 'sm',
36
36
  submitText = 'Confirm',
37
37
  cancelText = 'Cancel',
38
- widthClass = 'sm:max-w-lg',
38
+ widthClass = '',
39
39
  isSubmitting = false,
40
40
  disabled = false,
41
41
  onsubmit,
@@ -106,7 +106,8 @@
106
106
  open = false;
107
107
  } catch {
108
108
  if (!isCurrentRequest(token)) return;
109
- submitError = i18n.t('common.operationFailed');
109
+ // 失败原因用固定文案,不把异常原文写进界面。
110
+ submitError = i18n.t('common.submitRejected');
110
111
  } finally {
111
112
  if (activeRequest === token) {
112
113
  activeRequest = undefined;
@@ -153,8 +154,8 @@
153
154
  </Dialog.Trigger>
154
155
  {/if}
155
156
 
156
- <Dialog.Content class={cn(widthClass, 'max-h-[90vh] overflow-y-auto', className)}>
157
- <form bind:this={formElement} onsubmit={handleSubmit} aria-busy={busy} class="space-y-4">
157
+ <Dialog.Content closeOnOverlayClick={false} size="md" loading={busy} class={cn('svadmin-dialog-form', widthClass, className)}>
158
+ <form bind:this={formElement} onsubmit={handleSubmit} aria-busy={busy} class="svadmin-dialog-form__body">
158
159
  <Dialog.Header>
159
160
  <Dialog.Title>{title}</Dialog.Title>
160
161
  {#if description}
@@ -162,11 +163,10 @@
162
163
  {/if}
163
164
  </Dialog.Header>
164
165
 
165
- {#if submitError}
166
- <FeedbackNotice tone="danger" message={submitError} />
167
- {/if}
168
-
169
- <div class="py-2 text-sm text-foreground">
166
+ <div class="svadmin-dialog-body">
167
+ {#if submitError}
168
+ <FeedbackNotice tone="danger" message={submitError} />
169
+ {/if}
170
170
  {#if children}
171
171
  {@render children()}
172
172
  {/if}
@@ -18,6 +18,6 @@
18
18
  <div class="flex h-screen w-screen items-center justify-center p-4 text-muted-foreground">
19
19
  <div class="text-center">
20
20
  <div class="mb-4 inline-block h-8 w-8 animate-spin rounded-full border-4 border-primary border-r-transparent"></div>
21
- <p>Navigating to default resource...</p>
21
+ <p>Navigating to default resource…</p>
22
22
  </div>
23
23
  </div>
@@ -3,6 +3,7 @@
3
3
  import { Bell, CheckCheck } from '@lucide/svelte';
4
4
  import { Button } from './ui/button/index.js';
5
5
  import * as Popover from './ui/popover/index.js';
6
+ import { formatAdminTime } from '@svadmin/core';
6
7
  import { cn } from '../utils.js';
7
8
 
8
9
  export interface NotificationItem {
@@ -69,7 +70,7 @@
69
70
  if (!value) return '';
70
71
  const date = value instanceof Date ? value : new Date(value);
71
72
  if (Number.isNaN(date.getTime())) return String(value);
72
- return new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date);
73
+ return formatAdminTime(date, { dateStyle: 'medium', seconds: false });
73
74
  }
74
75
 
75
76
  async function read(item: NotificationItem): Promise<void> {
@@ -127,7 +127,7 @@
127
127
  onclick={triggerSync}
128
128
  >
129
129
  <RefreshCw class={cn('h-3 w-3', isSyncing ? 'animate-spin' : '')} />
130
- {isSyncing ? 'Syncing...' : 'Sync Now'}
130
+ {isSyncing ? 'Syncing…' : 'Sync Now'}
131
131
  </Button>
132
132
  {/if}
133
133
  </div>
@@ -40,7 +40,7 @@
40
40
  let {
41
41
  open = $bindable(false),
42
42
  shortcutKey = 'k',
43
- placeholder = '输入命令、查找页面或搜索实体资源... (⌘K)',
43
+ placeholder = '输入命令、查找页面或搜索实体资源… (⌘K)',
44
44
  emptyText = '未找到匹配的命令或资源',
45
45
  items = [
46
46
  { id: 'nav-dashboard', title: '运营与财务仪表盘', category: 'navigation', categoryLabel: '系统导航', description: '高管大屏与实时多维指标看板', shortcut: 'G D' },
@@ -154,7 +154,7 @@
154
154
  <input
155
155
  type="text"
156
156
  bind:value={searchQuery}
157
- placeholder="搜索明细内容..."
157
+ placeholder="搜索明细内容…"
158
158
  class="h-8 w-full rounded-md border border-input bg-background pl-8 pr-3 text-xs placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring"
159
159
  />
160
160
  </div>
@@ -3,12 +3,14 @@
3
3
  import { CircleAlert } from "@lucide/svelte";
4
4
  import Button from "./ui/button/button.svelte";
5
5
  import * as Popover from "./ui/popover/index.js";
6
+ import * as Dialog from "./ui/dialog/index.js";
6
7
 
7
8
  let {
8
9
  title,
9
10
  okText = "确定",
10
11
  cancelText = "取消",
11
12
  okType = "primary",
13
+ risk = "light",
12
14
  icon,
13
15
  onConfirm,
14
16
  children,
@@ -17,32 +19,71 @@
17
19
  okText?: string;
18
20
  cancelText?: string;
19
21
  okType?: "primary" | "danger";
22
+ /**
23
+ * light:频繁的轻确认,仍用气泡,宽度不超过 320px。
24
+ * irreversible:有风险或不可逆,改成对话框,不再弹出气泡。
25
+ */
26
+ risk?: "light" | "irreversible";
20
27
  icon?: Snippet;
21
28
  onConfirm?: () => void;
22
29
  children: Snippet;
23
30
  } = $props();
24
31
 
25
32
  let open = $state(false);
33
+
34
+ function confirm() {
35
+ onConfirm?.();
36
+ open = false;
37
+ }
26
38
  </script>
27
39
 
28
- <Popover.Root bind:open>
29
- <Popover.Trigger>
30
- {#snippet child({ props })}
31
- <span class="svadmin-popconfirm__trigger" {...props}>{@render children()}</span>
32
- {/snippet}
33
- </Popover.Trigger>
34
- <Popover.Content class="svadmin-popconfirm" sideOffset={8}>
35
- <div class="flex items-start gap-2">
36
- {#if icon}
37
- {@render icon()}
38
- {:else}
39
- <CircleAlert class="mt-0.5 size-4 shrink-0 text-warning" aria-hidden="true" />
40
- {/if}
41
- <p class="svadmin-popconfirm__title leading-5">{title}</p>
42
- </div>
43
- <div class="svadmin-popconfirm__actions">
44
- <Button type="button" variant="outline" size="xs" onclick={() => (open = false)}>{cancelText}</Button>
45
- <Button type="button" variant={okType === "danger" ? "destructive" : "default"} size="xs" onclick={() => { onConfirm?.(); open = false; }}>{okText}</Button>
46
- </div>
47
- </Popover.Content>
48
- </Popover.Root>
40
+ {#if risk === "irreversible"}
41
+ <Dialog.Root bind:open>
42
+ <Dialog.Trigger>
43
+ {#snippet child({ props })}
44
+ <span class="svadmin-popconfirm__trigger" {...props}>{@render children()}</span>
45
+ {/snippet}
46
+ </Dialog.Trigger>
47
+ <Dialog.Content size="sm" closeOnOverlayClick={true} data-confirm-weight="irreversible">
48
+ <Dialog.Header>
49
+ <Dialog.Title>{title}</Dialog.Title>
50
+ </Dialog.Header>
51
+ <div class="svadmin-dialog-body">
52
+ <div class="flex items-start gap-2">
53
+ {#if icon}
54
+ {@render icon()}
55
+ {:else}
56
+ <CircleAlert class="mt-0.5 size-4 shrink-0 text-warning" aria-hidden="true" />
57
+ {/if}
58
+ <p class="leading-5">{title}</p>
59
+ </div>
60
+ </div>
61
+ <Dialog.Footer>
62
+ <Button type="button" variant="outline" size="sm" onclick={() => (open = false)}>{cancelText}</Button>
63
+ <Button type="button" variant={okType === "danger" ? "destructive" : "default"} size="sm" onclick={confirm}>{okText}</Button>
64
+ </Dialog.Footer>
65
+ </Dialog.Content>
66
+ </Dialog.Root>
67
+ {:else}
68
+ <Popover.Root bind:open>
69
+ <Popover.Trigger>
70
+ {#snippet child({ props })}
71
+ <span class="svadmin-popconfirm__trigger" {...props}>{@render children()}</span>
72
+ {/snippet}
73
+ </Popover.Trigger>
74
+ <Popover.Content class="svadmin-popconfirm" data-confirm-weight="light" sideOffset={8}>
75
+ <div class="flex items-start gap-2">
76
+ {#if icon}
77
+ {@render icon()}
78
+ {:else}
79
+ <CircleAlert class="mt-0.5 size-4 shrink-0 text-warning" aria-hidden="true" />
80
+ {/if}
81
+ <p class="svadmin-popconfirm__title leading-5">{title}</p>
82
+ </div>
83
+ <div class="svadmin-popconfirm__actions">
84
+ <Button type="button" variant="outline" size="xs" onclick={() => (open = false)}>{cancelText}</Button>
85
+ <Button type="button" variant={okType === "danger" ? "destructive" : "default"} size="xs" onclick={confirm}>{okText}</Button>
86
+ </div>
87
+ </Popover.Content>
88
+ </Popover.Root>
89
+ {/if}
@@ -4,6 +4,11 @@ type $$ComponentProps = {
4
4
  okText?: string;
5
5
  cancelText?: string;
6
6
  okType?: "primary" | "danger";
7
+ /**
8
+ * light:频繁的轻确认,仍用气泡,宽度不超过 320px。
9
+ * irreversible:有风险或不可逆,改成对话框,不再弹出气泡。
10
+ */
11
+ risk?: "light" | "irreversible";
7
12
  icon?: Snippet;
8
13
  onConfirm?: () => void;
9
14
  children: Snippet;
@@ -427,7 +427,7 @@
427
427
  class="rounded border border-input bg-background px-2.5 py-1 text-xs text-foreground focus:ring-1 focus:ring-primary min-w-[160px] flex-1"
428
428
  bind:value={item.value}
429
429
  oninput={notifyChange}
430
- placeholder="输入匹配内容..."
430
+ placeholder="输入匹配内容…"
431
431
  disabled={readOnly}
432
432
  />
433
433
  {/if}
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { formatAdminNumber } from '@svadmin/core';
2
3
  import { cn } from '../utils.js';
3
4
 
4
5
  export interface QuotaProgressBarProps {
@@ -34,7 +35,7 @@
34
35
  warningThreshold = 0.8,
35
36
  criticalThreshold = 0.95,
36
37
  showPercent = true,
37
- formatter = (val) => val.toLocaleString(),
38
+ formatter = (val) => formatAdminNumber(val, { locale: null }),
38
39
  description,
39
40
  compact = false,
40
41
  class: className = '',
@@ -240,7 +240,7 @@
240
240
  <input
241
241
  type="text"
242
242
  bind:value={searchQuery}
243
- placeholder="Filter attributes..."
243
+ placeholder="Filter attributes…"
244
244
  class="h-8 w-full rounded-sm border border-input bg-background pl-8 pr-3 text-xs placeholder:text-muted-foreground focus:border-primary focus:outline-none"
245
245
  />
246
246
  </div>
@@ -294,7 +294,7 @@
294
294
  type="text"
295
295
  bind:value={child.value}
296
296
  oninput={notify}
297
- placeholder={chinese ? '输入比较值...' : 'Value...'}
297
+ placeholder={chinese ? '输入比较值…' : 'Value…'}
298
298
  class="h-7 flex-1 rounded border border-input bg-background px-2 text-xs font-mono focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
299
299
  />
300
300
 
@@ -287,7 +287,7 @@
287
287
  >
288
288
  {#if loading || isSubmitting}
289
289
  <Loader2 class="h-3.5 w-3.5 animate-spin" />
290
- <span>{t('common.processing', '处理中...')}</span>
290
+ <span>{t('common.processing', '处理中…')}</span>
291
291
  {:else}
292
292
  <span>{resolvedConfirmText}</span>
293
293
  {#if isCooldown}
@@ -82,7 +82,7 @@
82
82
  const statusLabels = $derived<Record<ScheduledJobStatus, string>>({
83
83
  active: chinese ? '计划运行中' : 'Active',
84
84
  paused: chinese ? '已暂停调度' : 'Paused',
85
- running: chinese ? '执行中...' : 'Running...',
85
+ running: chinese ? '执行中…' : 'Running…',
86
86
  failed: chinese ? '上次异常' : 'Failed',
87
87
  });
88
88
 
@@ -298,7 +298,7 @@
298
298
  <textarea
299
299
  id="json-sample"
300
300
  bind:value={rawImportText}
301
- placeholder="输入或粘贴 JSON 数据样例..."
301
+ placeholder="输入或粘贴 JSON 数据样例…"
302
302
  rows="8"
303
303
  class="w-full rounded-lg border border-input bg-muted/20 p-3 font-mono text-xs focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
304
304
  ></textarea>
@@ -251,7 +251,7 @@
251
251
  id="export-reason-input"
252
252
  bind:value={exportReason}
253
253
  rows="3"
254
- placeholder={chinese ? '请如实填写导出用途 (如: 2026Q4 财务清算审计)...' : 'State reason for export for compliance audit...'}
254
+ placeholder={chinese ? '请如实填写导出用途 (如: 2026Q4 财务清算审计)…' : 'State reason for export for compliance audit…'}
255
255
  class="w-full rounded-lg border border-input bg-background p-2.5 text-xs text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
256
256
  ></textarea>
257
257
  </div>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts">
2
- import { captureAdminContext, notifyWithProvider, type SessionInfo } from '@svadmin/core';
2
+ import { captureAdminContext, formatAdminTime, notifyWithProvider, type SessionInfo } from '@svadmin/core';
3
3
  import { useTranslation } from '@svadmin/core/i18n';
4
4
  import { AlertTriangle, Monitor, Smartphone, Trash2 } from '@lucide/svelte';
5
5
  import * as Alert from './ui/alert/index.js';
@@ -213,7 +213,7 @@
213
213
  <PasswordInput id={`${controlId}-security-new-password`} label={i18n.t('profile.newPassword')} bind:value={newPassword} autocomplete="new-password" showStrength disabled={!authProvider?.updatePassword || changingPassword} />
214
214
  <PasswordInput id={`${controlId}-security-confirm-password`} label={i18n.t('auth.confirmPassword')} bind:value={confirmPassword} autocomplete="new-password" disabled={!authProvider?.updatePassword || changingPassword} />
215
215
  {#if passwordChangedRecently}<p class="text-xs text-muted-foreground">{i18n.t('profile.passwordChangedRecently')}</p>{/if}
216
- <Button type="submit" disabled={!authProvider?.updatePassword || changingPassword}>{changingPassword ? (isZh ? '更新中...' : 'Updating...') : i18n.t('profile.updatePassword')}</Button>
216
+ <Button type="submit" disabled={!authProvider?.updatePassword || changingPassword}>{changingPassword ? (isZh ? '更新中…' : 'Updating…') : i18n.t('profile.updatePassword')}</Button>
217
217
  </form>
218
218
  </SettingsGroup>
219
219
  <SettingsGroup title={i18n.t('security.activeSessions')} description={i18n.t('security.sessionsDescription')} headingLevel={headingLevel === 'h1' ? 'h2' : 'h3'}>
@@ -228,7 +228,7 @@
228
228
  <div class="divide-y">
229
229
  {#each sessions as session (session.id)}
230
230
  <div class="flex items-center justify-between gap-4 py-3">
231
- <div class="flex min-w-0 items-center gap-3"><div class="rounded-lg bg-muted p-2 text-muted-foreground">{#if (session.os ?? '').toLowerCase().includes('ios') || (session.os ?? '').toLowerCase().includes('android')}<Smartphone class="h-5 w-5" />{:else}<Monitor class="h-5 w-5" />{/if}</div><div class="min-w-0 space-y-1"><div class="flex flex-wrap items-center gap-2"><span class="text-sm font-medium">{session.os ?? (isZh ? '未知系统' : 'Unknown OS')} - {session.browser ?? (isZh ? '未知浏览器' : 'Unknown browser')}</span>{#if session.current}<span class="rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary">{i18n.t('security.currentSession')}</span>{/if}</div><div class="flex flex-wrap items-center gap-2 text-xs text-muted-foreground"><span>{session.ipAddress ?? '-'}</span><span>{session.lastActiveAt ? new Date(session.lastActiveAt).toLocaleString() : '-'}</span></div></div></div>
231
+ <div class="flex min-w-0 items-center gap-3"><div class="rounded-lg bg-muted p-2 text-muted-foreground">{#if (session.os ?? '').toLowerCase().includes('ios') || (session.os ?? '').toLowerCase().includes('android')}<Smartphone class="h-5 w-5" />{:else}<Monitor class="h-5 w-5" />{/if}</div><div class="min-w-0 space-y-1"><div class="flex flex-wrap items-center gap-2"><span class="text-sm font-medium">{session.os ?? (isZh ? '未知系统' : 'Unknown OS')} - {session.browser ?? (isZh ? '未知浏览器' : 'Unknown browser')}</span>{#if session.current}<span class="rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary">{i18n.t('security.currentSession')}</span>{/if}</div><div class="flex flex-wrap items-center gap-2 text-xs text-muted-foreground"><span>{session.ipAddress ?? '-'}</span><span>{session.lastActiveAt ? formatAdminTime(session.lastActiveAt, { dateStyle: 'medium' }) : '-'}</span></div></div></div>
232
232
  {#if !session.current}<Button variant="ghost" size="icon-sm" disabled={revoking !== null} onclick={() => revokeSession(session.id)} title={i18n.t('security.revokeSession')}><Trash2 class="h-4 w-4" /></Button>{/if}
233
233
  </div>
234
234
  {/each}
@@ -61,7 +61,7 @@
61
61
  const resolvedDesc = $derived(
62
62
  description ??
63
63
  (chinese
64
- ? '为了您的账户与数据安全,系统检测到您已长时间未进行操作。倒计时结束后将自动锁定会话。'
64
+ ? '为了账户与数据安全,检测到长时间没有操作。倒计时结束后将锁定会话。'
65
65
  : 'For your security, your session will automatically lock due to inactivity.'),
66
66
  );
67
67
 
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
+ import { formatAdminNumber } from '@svadmin/core';
3
4
  import { cn } from '../utils.js';
4
5
 
5
6
  interface Props {
@@ -30,7 +31,7 @@
30
31
 
31
32
  const display = $derived(
32
33
  typeof value === 'number'
33
- ? new Intl.NumberFormat(undefined, { minimumFractionDigits: precision, maximumFractionDigits: precision }).format(value)
34
+ ? formatAdminNumber(value, { locale: null, minimumFractionDigits: precision, maximumFractionDigits: precision })
34
35
  : value,
35
36
  );
36
37
  </script>
@@ -497,7 +497,7 @@
497
497
  >
498
498
  {#if isValidating || isSubmitting}
499
499
  <Loader2 class="h-4 w-4 animate-spin" />
500
- <span>{chinese ? '校验处理中...' : 'Processing...'}</span>
500
+ <span>{chinese ? '校验处理中…' : 'Processing…'}</span>
501
501
  {:else if isLastStep}
502
502
  <Check class="h-4 w-4" />
503
503
  <span>{resolvedSubmitText}</span>