@svadmin/ui 0.115.0 → 0.117.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 +260 -26
- package/dist/app.theme.css +260 -26
- package/dist/components/AboutSettings.svelte +1 -1
- package/dist/components/AppearanceSettings.svelte +70 -1
- package/dist/components/CheckCard.svelte +149 -0
- package/dist/components/CheckCard.svelte.d.ts +31 -0
- package/dist/components/CopyableText.svelte +90 -0
- package/dist/components/CopyableText.svelte.d.ts +13 -0
- package/dist/components/Divider.svelte +89 -0
- package/dist/components/Divider.svelte.d.ts +19 -0
- package/dist/components/EllipsisText.svelte +78 -0
- package/dist/components/EllipsisText.svelte.d.ts +15 -0
- package/dist/components/FullscreenButton.svelte +88 -0
- package/dist/components/FullscreenButton.svelte.d.ts +10 -0
- package/dist/components/GlobalShortcuts.svelte +229 -0
- package/dist/components/GlobalShortcuts.svelte.d.ts +18 -0
- package/dist/components/Header.svelte +17 -1
- package/dist/components/Header.svelte.d.ts +3 -0
- package/dist/components/Layout.svelte +51 -4
- package/dist/components/Layout.svelte.d.ts +1 -0
- package/dist/components/LightFilter.svelte +281 -0
- package/dist/components/LightFilter.svelte.d.ts +36 -0
- package/dist/components/LockScreen.svelte +295 -0
- package/dist/components/LockScreen.svelte.d.ts +21 -0
- package/dist/components/PricingCard.svelte +158 -0
- package/dist/components/PricingCard.svelte.d.ts +42 -0
- package/dist/components/PricingTable.svelte +185 -0
- package/dist/components/PricingTable.svelte.d.ts +40 -0
- package/dist/components/ProCard.svelte +267 -0
- package/dist/components/ProCard.svelte.d.ts +56 -0
- package/dist/components/QuotaProgressBar.svelte +139 -0
- package/dist/components/QuotaProgressBar.svelte.d.ts +27 -0
- package/dist/components/StatisticCard.svelte +167 -0
- package/dist/components/StatisticCard.svelte.d.ts +41 -0
- package/dist/components/TypographyEllipsis.svelte +12 -9
- package/dist/components/TypographyEllipsis.svelte.d.ts +9 -8
- package/dist/components/TypographyText.svelte +41 -3
- package/dist/components/TypographyText.svelte.d.ts +10 -2
- package/dist/components/UsageCard.svelte +97 -0
- package/dist/components/UsageCard.svelte.d.ts +26 -0
- package/dist/components/ui/badge/badge.svelte +156 -12
- package/dist/components/ui/badge/badge.svelte.d.ts +9 -0
- package/dist/components/ui/badge/index.d.ts +1 -1
- package/dist/index.d.ts +34 -3
- package/dist/index.js +24 -2
- package/package.json +5 -5
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
export interface ProCardTab {
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ProCardProps {
|
|
8
|
+
/** Title of the card header */
|
|
9
|
+
title?: string | Snippet;
|
|
10
|
+
/** Subtitle or secondary description */
|
|
11
|
+
subTitle?: string | Snippet;
|
|
12
|
+
/** Information tooltip description displayed next to the title */
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
/** Extra actions or elements in the top right of the header */
|
|
15
|
+
extra?: Snippet;
|
|
16
|
+
/** Bottom actions slot */
|
|
17
|
+
actions?: Snippet;
|
|
18
|
+
/** Whether the card has an outer border */
|
|
19
|
+
bordered?: boolean;
|
|
20
|
+
/** Whether the card elevates on hover */
|
|
21
|
+
hoverable?: boolean;
|
|
22
|
+
/** Ghost mode: removes background, border, and padding for seamless grid nesting */
|
|
23
|
+
ghost?: boolean;
|
|
24
|
+
/** Whether the card can be collapsed */
|
|
25
|
+
collapsible?: boolean;
|
|
26
|
+
/** Controlled collapsed state */
|
|
27
|
+
collapsed?: boolean;
|
|
28
|
+
/** Initial default collapsed state */
|
|
29
|
+
defaultCollapsed?: boolean;
|
|
30
|
+
/** Callback when collapsed state toggles */
|
|
31
|
+
oncollapse?: (collapsed: boolean) => void;
|
|
32
|
+
/** Split layout for child elements */
|
|
33
|
+
split?: 'vertical' | 'horizontal';
|
|
34
|
+
/** Tab items displayed in the card header */
|
|
35
|
+
tabs?: ProCardTab[];
|
|
36
|
+
/** Controlled active tab key */
|
|
37
|
+
activeTabKey?: string;
|
|
38
|
+
/** Callback when active tab changes */
|
|
39
|
+
ontabchange?: (key: string) => void;
|
|
40
|
+
/** Size tier of the card */
|
|
41
|
+
size?: 'default' | 'small';
|
|
42
|
+
/** Loading indicator */
|
|
43
|
+
loading?: boolean;
|
|
44
|
+
/** Additional class names for header */
|
|
45
|
+
headerClass?: string;
|
|
46
|
+
/** Additional class names for card body */
|
|
47
|
+
bodyClass?: string;
|
|
48
|
+
/** Additional root class names */
|
|
49
|
+
class?: string;
|
|
50
|
+
/** Body content slot */
|
|
51
|
+
children?: Snippet;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
declare const ProCard: import("svelte").Component<ProCardProps, {}, "activeTabKey">;
|
|
55
|
+
type ProCard = ReturnType<typeof ProCard>;
|
|
56
|
+
export default ProCard;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
|
|
4
|
+
export interface QuotaProgressBarProps {
|
|
5
|
+
/** Usage metric label (e.g., 'API Requests', 'Storage') */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Current used amount */
|
|
8
|
+
used: number;
|
|
9
|
+
/** Total allocated quota limit */
|
|
10
|
+
total: number;
|
|
11
|
+
/** Metric unit suffix (e.g. 'GB', 'calls', 'seats') */
|
|
12
|
+
unit?: string | undefined;
|
|
13
|
+
/** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
|
|
14
|
+
warningThreshold?: number | undefined;
|
|
15
|
+
/** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
|
|
16
|
+
criticalThreshold?: number | undefined;
|
|
17
|
+
/** Whether to display the percentage badge. Defaults to true */
|
|
18
|
+
showPercent?: boolean | undefined;
|
|
19
|
+
/** Optional custom number formatter */
|
|
20
|
+
formatter?: ((val: number) => string) | undefined;
|
|
21
|
+
/** Optional extra description or action */
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
/** Compact inline single-line display */
|
|
24
|
+
compact?: boolean | undefined;
|
|
25
|
+
/** Additional CSS classes */
|
|
26
|
+
class?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let {
|
|
30
|
+
label,
|
|
31
|
+
used,
|
|
32
|
+
total,
|
|
33
|
+
unit = '',
|
|
34
|
+
warningThreshold = 0.8,
|
|
35
|
+
criticalThreshold = 0.95,
|
|
36
|
+
showPercent = true,
|
|
37
|
+
formatter = (val) => val.toLocaleString(),
|
|
38
|
+
description,
|
|
39
|
+
compact = false,
|
|
40
|
+
class: className = '',
|
|
41
|
+
}: QuotaProgressBarProps = $props();
|
|
42
|
+
|
|
43
|
+
const ratio = $derived(total > 0 ? Math.min(1, Math.max(0, used / total)) : 0);
|
|
44
|
+
const boundedUsed = $derived(total > 0 ? Math.min(total, Math.max(0, used)) : 0);
|
|
45
|
+
const percent = $derived(Math.round(ratio * 100));
|
|
46
|
+
|
|
47
|
+
const status = $derived(
|
|
48
|
+
ratio >= criticalThreshold
|
|
49
|
+
? 'critical'
|
|
50
|
+
: ratio >= warningThreshold
|
|
51
|
+
? 'warning'
|
|
52
|
+
: 'normal',
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const statusColorClass = $derived(
|
|
56
|
+
status === 'critical'
|
|
57
|
+
? 'bg-destructive'
|
|
58
|
+
: status === 'warning'
|
|
59
|
+
? 'bg-warning'
|
|
60
|
+
: 'bg-primary',
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const statusBadgeColorClass = $derived(
|
|
64
|
+
status === 'critical'
|
|
65
|
+
? 'bg-destructive/10 text-destructive'
|
|
66
|
+
: status === 'warning'
|
|
67
|
+
? 'bg-warning/10 text-warning'
|
|
68
|
+
: 'bg-primary/10 text-primary',
|
|
69
|
+
);
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
class={cn('w-full rounded-lg border border-border bg-card p-4 text-card-foreground', className)}
|
|
74
|
+
data-svadmin-component="QuotaProgressBar"
|
|
75
|
+
data-status={status}
|
|
76
|
+
>
|
|
77
|
+
{#if compact}
|
|
78
|
+
<div class="flex items-center justify-between gap-4 text-sm">
|
|
79
|
+
<div class="flex items-center gap-2 truncate">
|
|
80
|
+
<span class="font-medium text-foreground">{label}</span>
|
|
81
|
+
<span class="text-xs text-muted-foreground">
|
|
82
|
+
{formatter(used)}{unit ? ` ${unit}` : ''} / {formatter(total)}{unit ? ` ${unit}` : ''}
|
|
83
|
+
</span>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="flex items-center gap-3">
|
|
86
|
+
<div class="h-2 w-32 overflow-hidden rounded-full bg-secondary">
|
|
87
|
+
<div
|
|
88
|
+
class={cn('h-full transition-all duration-300', statusColorClass)}
|
|
89
|
+
style="width: {percent}%"
|
|
90
|
+
role="progressbar"
|
|
91
|
+
aria-valuenow={boundedUsed}
|
|
92
|
+
aria-valuemin={0}
|
|
93
|
+
aria-valuemax={total}
|
|
94
|
+
aria-label={label}
|
|
95
|
+
></div>
|
|
96
|
+
</div>
|
|
97
|
+
{#if showPercent}
|
|
98
|
+
<span class={cn('rounded px-1.5 py-0.5 text-xs font-semibold', statusBadgeColorClass)}>
|
|
99
|
+
{percent}%
|
|
100
|
+
</span>
|
|
101
|
+
{/if}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
{:else}
|
|
105
|
+
<div class="flex items-center justify-between gap-2">
|
|
106
|
+
<div class="flex items-center gap-2">
|
|
107
|
+
<span class="text-sm font-semibold text-foreground">{label}</span>
|
|
108
|
+
{#if showPercent}
|
|
109
|
+
<span class={cn('rounded-full px-2 py-0.5 text-xs font-semibold', statusBadgeColorClass)}>
|
|
110
|
+
{percent}%
|
|
111
|
+
</span>
|
|
112
|
+
{/if}
|
|
113
|
+
</div>
|
|
114
|
+
<div class="text-sm font-medium text-muted-foreground">
|
|
115
|
+
<span class="text-foreground font-semibold">{formatter(used)}</span>
|
|
116
|
+
{#if unit} <span class="text-xs">{unit}</span>{/if}
|
|
117
|
+
<span class="mx-1">/</span>
|
|
118
|
+
<span>{formatter(total)}</span>
|
|
119
|
+
{#if unit} <span class="text-xs">{unit}</span>{/if}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div class="mt-2.5 h-2.5 w-full overflow-hidden rounded-full bg-secondary">
|
|
124
|
+
<div
|
|
125
|
+
class={cn('h-full transition-all duration-300', statusColorClass)}
|
|
126
|
+
style="width: {percent}%"
|
|
127
|
+
role="progressbar"
|
|
128
|
+
aria-valuenow={boundedUsed}
|
|
129
|
+
aria-valuemin={0}
|
|
130
|
+
aria-valuemax={total}
|
|
131
|
+
aria-label={label}
|
|
132
|
+
></div>
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
{#if description}
|
|
136
|
+
<p class="mt-2 text-xs text-muted-foreground">{description}</p>
|
|
137
|
+
{/if}
|
|
138
|
+
{/if}
|
|
139
|
+
</div>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface QuotaProgressBarProps {
|
|
2
|
+
/** Usage metric label (e.g., 'API Requests', 'Storage') */
|
|
3
|
+
label: string;
|
|
4
|
+
/** Current used amount */
|
|
5
|
+
used: number;
|
|
6
|
+
/** Total allocated quota limit */
|
|
7
|
+
total: number;
|
|
8
|
+
/** Metric unit suffix (e.g. 'GB', 'calls', 'seats') */
|
|
9
|
+
unit?: string | undefined;
|
|
10
|
+
/** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
|
|
11
|
+
warningThreshold?: number | undefined;
|
|
12
|
+
/** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
|
|
13
|
+
criticalThreshold?: number | undefined;
|
|
14
|
+
/** Whether to display the percentage badge. Defaults to true */
|
|
15
|
+
showPercent?: boolean | undefined;
|
|
16
|
+
/** Optional custom number formatter */
|
|
17
|
+
formatter?: ((val: number) => string) | undefined;
|
|
18
|
+
/** Optional extra description or action */
|
|
19
|
+
description?: string | undefined;
|
|
20
|
+
/** Compact inline single-line display */
|
|
21
|
+
compact?: boolean | undefined;
|
|
22
|
+
/** Additional CSS classes */
|
|
23
|
+
class?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
declare const QuotaProgressBar: import("svelte").Component<QuotaProgressBarProps, {}, "">;
|
|
26
|
+
type QuotaProgressBar = ReturnType<typeof QuotaProgressBar>;
|
|
27
|
+
export default QuotaProgressBar;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { cn } from '../utils.js';
|
|
4
|
+
|
|
5
|
+
export interface StatisticTrendItem {
|
|
6
|
+
/** Label of the trend (e.g. '周同比', '日环比') */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Trend value (e.g. '12.5%', 18.2) */
|
|
9
|
+
value: string | number;
|
|
10
|
+
/** Trend direction */
|
|
11
|
+
direction: 'up' | 'down';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface StatisticCardProps {
|
|
15
|
+
/** Card title */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Tooltip explanation text */
|
|
18
|
+
tip?: string;
|
|
19
|
+
/** Main numerical value */
|
|
20
|
+
value?: string | number;
|
|
21
|
+
/** Prefix symbol (e.g. '¥', '$') */
|
|
22
|
+
prefix?: string;
|
|
23
|
+
/** Suffix symbol (e.g. '%', '人', '单') */
|
|
24
|
+
suffix?: string;
|
|
25
|
+
/** Decimal precision */
|
|
26
|
+
precision?: number;
|
|
27
|
+
/** Array of trend comparisons (e.g. YoY / MoM) */
|
|
28
|
+
trends?: StatisticTrendItem[];
|
|
29
|
+
/** Custom extra action in header */
|
|
30
|
+
extra?: Snippet;
|
|
31
|
+
/** Embedded chart or sparkline slot */
|
|
32
|
+
chart?: Snippet;
|
|
33
|
+
/** Bottom footer summary slot */
|
|
34
|
+
footer?: Snippet;
|
|
35
|
+
/** Card content slot */
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
/** Card size */
|
|
38
|
+
size?: 'default' | 'small';
|
|
39
|
+
/** Additional CSS classes */
|
|
40
|
+
class?: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let {
|
|
45
|
+
title,
|
|
46
|
+
tip,
|
|
47
|
+
value = 0,
|
|
48
|
+
prefix,
|
|
49
|
+
suffix,
|
|
50
|
+
precision,
|
|
51
|
+
trends = [],
|
|
52
|
+
extra,
|
|
53
|
+
chart,
|
|
54
|
+
footer,
|
|
55
|
+
children,
|
|
56
|
+
size = 'default',
|
|
57
|
+
class: className = '',
|
|
58
|
+
...restProps
|
|
59
|
+
}: StatisticCardProps = $props();
|
|
60
|
+
|
|
61
|
+
const formattedValue = $derived.by(() => {
|
|
62
|
+
if (typeof value === 'number' && precision !== undefined) {
|
|
63
|
+
return value.toFixed(precision);
|
|
64
|
+
}
|
|
65
|
+
return String(value);
|
|
66
|
+
});
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
data-svadmin-component="StatisticCard"
|
|
71
|
+
class={cn(
|
|
72
|
+
'svadmin-statistic-card flex flex-col justify-between rounded-[4px] border border-border bg-card text-card-foreground shadow-sm hover:border-primary/40 transition-colors',
|
|
73
|
+
size === 'small' ? 'p-3 text-xs' : 'p-4 text-sm',
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
{...restProps}
|
|
77
|
+
>
|
|
78
|
+
<!-- Card Header -->
|
|
79
|
+
{#if title || extra}
|
|
80
|
+
<div class="flex items-center justify-between pb-2 border-b border-border/60">
|
|
81
|
+
<div class="flex items-center gap-1.5 min-w-0">
|
|
82
|
+
{#if title}
|
|
83
|
+
<span class="font-medium text-xs text-muted-foreground truncate">{title}</span>
|
|
84
|
+
{/if}
|
|
85
|
+
{#if tip}
|
|
86
|
+
<span
|
|
87
|
+
title={tip}
|
|
88
|
+
class="inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-muted text-[10px] text-muted-foreground/80 cursor-help"
|
|
89
|
+
>
|
|
90
|
+
?
|
|
91
|
+
</span>
|
|
92
|
+
{/if}
|
|
93
|
+
</div>
|
|
94
|
+
{#if extra}
|
|
95
|
+
<div class="shrink-0 text-xs text-muted-foreground">
|
|
96
|
+
{@render extra()}
|
|
97
|
+
</div>
|
|
98
|
+
{/if}
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
|
|
102
|
+
<!-- Main Metric Number -->
|
|
103
|
+
<div class="my-2.5">
|
|
104
|
+
<div class="flex items-baseline gap-1">
|
|
105
|
+
{#if prefix}
|
|
106
|
+
<span class="text-sm font-medium text-muted-foreground">{prefix}</span>
|
|
107
|
+
{/if}
|
|
108
|
+
<span class={cn('font-bold tracking-tight text-foreground font-mono leading-none', size === 'small' ? 'text-xl' : 'text-2xl sm:text-3xl')}>
|
|
109
|
+
{formattedValue}
|
|
110
|
+
</span>
|
|
111
|
+
{#if suffix}
|
|
112
|
+
<span class="text-xs text-muted-foreground font-normal ml-0.5">{suffix}</span>
|
|
113
|
+
{/if}
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<!-- Trend Indicators (YoY / MoM) -->
|
|
117
|
+
{#if trends.length > 0}
|
|
118
|
+
<div class="flex flex-wrap items-center gap-3 mt-2 text-xs">
|
|
119
|
+
{#each trends as trend, idx (trend.label ? trend.label + idx : idx)}
|
|
120
|
+
<div class="flex items-center gap-1">
|
|
121
|
+
{#if trend.label}
|
|
122
|
+
<span class="text-muted-foreground text-[11px]">{trend.label}</span>
|
|
123
|
+
{/if}
|
|
124
|
+
<span
|
|
125
|
+
class={cn(
|
|
126
|
+
'inline-flex items-center text-xs font-medium font-mono',
|
|
127
|
+
trend.direction === 'up' ? 'text-success' : 'text-destructive'
|
|
128
|
+
)}
|
|
129
|
+
>
|
|
130
|
+
{#if trend.direction === 'up'}
|
|
131
|
+
<svg class="w-3 h-3 shrink-0 mr-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
132
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 10l7-7m0 0l7 7m-7-7v18" />
|
|
133
|
+
</svg>
|
|
134
|
+
{:else}
|
|
135
|
+
<svg class="w-3 h-3 shrink-0 mr-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
136
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M19 14l-7 7m0 0l-7-7m7 7V3" />
|
|
137
|
+
</svg>
|
|
138
|
+
{/if}
|
|
139
|
+
{trend.value}
|
|
140
|
+
</span>
|
|
141
|
+
</div>
|
|
142
|
+
{/each}
|
|
143
|
+
</div>
|
|
144
|
+
{/if}
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Chart / Sparkline Slot -->
|
|
148
|
+
{#if chart}
|
|
149
|
+
<div class="my-1.5 w-full">
|
|
150
|
+
{@render chart()}
|
|
151
|
+
</div>
|
|
152
|
+
{/if}
|
|
153
|
+
|
|
154
|
+
<!-- Body Content -->
|
|
155
|
+
{#if children}
|
|
156
|
+
<div class="mt-1 text-xs text-muted-foreground">
|
|
157
|
+
{@render children()}
|
|
158
|
+
</div>
|
|
159
|
+
{/if}
|
|
160
|
+
|
|
161
|
+
<!-- Footer -->
|
|
162
|
+
{#if footer}
|
|
163
|
+
<div class="mt-3 pt-2.5 border-t border-border/60 text-xs text-muted-foreground">
|
|
164
|
+
{@render footer()}
|
|
165
|
+
</div>
|
|
166
|
+
{/if}
|
|
167
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
export interface StatisticTrendItem {
|
|
3
|
+
/** Label of the trend (e.g. '周同比', '日环比') */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Trend value (e.g. '12.5%', 18.2) */
|
|
6
|
+
value: string | number;
|
|
7
|
+
/** Trend direction */
|
|
8
|
+
direction: 'up' | 'down';
|
|
9
|
+
}
|
|
10
|
+
export interface StatisticCardProps {
|
|
11
|
+
/** Card title */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Tooltip explanation text */
|
|
14
|
+
tip?: string;
|
|
15
|
+
/** Main numerical value */
|
|
16
|
+
value?: string | number;
|
|
17
|
+
/** Prefix symbol (e.g. '¥', '$') */
|
|
18
|
+
prefix?: string;
|
|
19
|
+
/** Suffix symbol (e.g. '%', '人', '单') */
|
|
20
|
+
suffix?: string;
|
|
21
|
+
/** Decimal precision */
|
|
22
|
+
precision?: number;
|
|
23
|
+
/** Array of trend comparisons (e.g. YoY / MoM) */
|
|
24
|
+
trends?: StatisticTrendItem[];
|
|
25
|
+
/** Custom extra action in header */
|
|
26
|
+
extra?: Snippet;
|
|
27
|
+
/** Embedded chart or sparkline slot */
|
|
28
|
+
chart?: Snippet;
|
|
29
|
+
/** Bottom footer summary slot */
|
|
30
|
+
footer?: Snippet;
|
|
31
|
+
/** Card content slot */
|
|
32
|
+
children?: Snippet;
|
|
33
|
+
/** Card size */
|
|
34
|
+
size?: 'default' | 'small';
|
|
35
|
+
/** Additional CSS classes */
|
|
36
|
+
class?: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
declare const StatisticCard: import("svelte").Component<StatisticCardProps, {}, "">;
|
|
40
|
+
type StatisticCard = ReturnType<typeof StatisticCard>;
|
|
41
|
+
export default StatisticCard;
|
|
@@ -8,16 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
/** 折叠时保留的行数,对齐参考排版的 ellipsis.rows。 */
|
|
11
|
-
rows?: number;
|
|
11
|
+
rows?: number | undefined;
|
|
12
12
|
/** 内容超出时显示“展开 / 收起”,对齐参考排版的 ellipsis.expandable。 */
|
|
13
|
-
expandable?: boolean;
|
|
14
|
-
expanded?: boolean;
|
|
15
|
-
expandText?: string;
|
|
16
|
-
collapseText?: string;
|
|
13
|
+
expandable?: boolean | undefined;
|
|
14
|
+
expanded?: boolean | undefined;
|
|
15
|
+
expandText?: string | undefined;
|
|
16
|
+
collapseText?: string | undefined;
|
|
17
|
+
tooltip?: string | undefined;
|
|
17
18
|
/** 展开按钮的附加说明,例如“展开全部 12 条”。 */
|
|
18
|
-
expandLabel?: string;
|
|
19
|
-
class?: string;
|
|
20
|
-
onExpand?: (expanded: boolean) => void;
|
|
19
|
+
expandLabel?: string | undefined;
|
|
20
|
+
class?: string | undefined;
|
|
21
|
+
onExpand?: ((expanded: boolean) => void) | undefined;
|
|
21
22
|
children: Snippet;
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
expanded = $bindable(false),
|
|
28
29
|
expandText,
|
|
29
30
|
collapseText,
|
|
31
|
+
tooltip,
|
|
30
32
|
expandLabel,
|
|
31
33
|
class: className = '',
|
|
32
34
|
onExpand,
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
bind:this={contentEl}
|
|
74
76
|
class="svadmin-typography-ellipsis__content"
|
|
75
77
|
class:is-clamped={!expanded}
|
|
78
|
+
title={tooltip}
|
|
76
79
|
>
|
|
77
80
|
{@render children()}
|
|
78
81
|
</div>
|
|
@@ -120,4 +123,4 @@
|
|
|
120
123
|
outline-offset: var(--svadmin-focus-offset);
|
|
121
124
|
border-radius: var(--radius-sm);
|
|
122
125
|
}
|
|
123
|
-
</style>
|
|
126
|
+
</style>
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
interface Props {
|
|
3
3
|
/** 折叠时保留的行数,对齐参考排版的 ellipsis.rows。 */
|
|
4
|
-
rows?: number;
|
|
4
|
+
rows?: number | undefined;
|
|
5
5
|
/** 内容超出时显示“展开 / 收起”,对齐参考排版的 ellipsis.expandable。 */
|
|
6
|
-
expandable?: boolean;
|
|
7
|
-
expanded?: boolean;
|
|
8
|
-
expandText?: string;
|
|
9
|
-
collapseText?: string;
|
|
6
|
+
expandable?: boolean | undefined;
|
|
7
|
+
expanded?: boolean | undefined;
|
|
8
|
+
expandText?: string | undefined;
|
|
9
|
+
collapseText?: string | undefined;
|
|
10
|
+
tooltip?: string | undefined;
|
|
10
11
|
/** 展开按钮的附加说明,例如“展开全部 12 条”。 */
|
|
11
|
-
expandLabel?: string;
|
|
12
|
-
class?: string;
|
|
13
|
-
onExpand?: (expanded: boolean) => void;
|
|
12
|
+
expandLabel?: string | undefined;
|
|
13
|
+
class?: string | undefined;
|
|
14
|
+
onExpand?: ((expanded: boolean) => void) | undefined;
|
|
14
15
|
children: Snippet;
|
|
15
16
|
}
|
|
16
17
|
declare const TypographyEllipsis: import("svelte").Component<Props, {}, "expanded">;
|
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
import { tick, type Snippet } from 'svelte';
|
|
3
3
|
import { Check, Pencil, X } from '@lucide/svelte';
|
|
4
4
|
import CopyButton from './CopyButton.svelte';
|
|
5
|
+
import TypographyEllipsis from './TypographyEllipsis.svelte';
|
|
5
6
|
import { cn } from '../utils.js';
|
|
6
7
|
|
|
7
8
|
export type TypographyType = 'default' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
8
9
|
|
|
9
|
-
interface
|
|
10
|
+
export interface TypographyEllipsisConfig {
|
|
11
|
+
rows?: number;
|
|
12
|
+
expandable?: boolean;
|
|
13
|
+
expandText?: string;
|
|
14
|
+
collapseText?: string;
|
|
15
|
+
tooltip?: boolean | string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TypographyTextProps {
|
|
10
19
|
text?: string;
|
|
11
20
|
type?: TypographyType;
|
|
12
21
|
strong?: boolean;
|
|
@@ -18,6 +27,7 @@
|
|
|
18
27
|
copyable?: boolean;
|
|
19
28
|
copyLabel?: string;
|
|
20
29
|
copyDescription?: string;
|
|
30
|
+
ellipsis?: boolean | TypographyEllipsisConfig;
|
|
21
31
|
editable?: boolean;
|
|
22
32
|
editing?: boolean;
|
|
23
33
|
multiline?: boolean;
|
|
@@ -42,6 +52,7 @@
|
|
|
42
52
|
copyable = false,
|
|
43
53
|
copyLabel,
|
|
44
54
|
copyDescription,
|
|
55
|
+
ellipsis = false,
|
|
45
56
|
editable = false,
|
|
46
57
|
editing = $bindable(false),
|
|
47
58
|
multiline = false,
|
|
@@ -52,7 +63,18 @@
|
|
|
52
63
|
children,
|
|
53
64
|
onchange,
|
|
54
65
|
oncopied,
|
|
55
|
-
}:
|
|
66
|
+
}: TypographyTextProps = $props();
|
|
67
|
+
|
|
68
|
+
const isSingleEllipsis = $derived(ellipsis === true || (typeof ellipsis === 'object' && (!ellipsis.rows || ellipsis.rows === 1)));
|
|
69
|
+
const multiEllipsis = $derived(typeof ellipsis === 'object' && typeof ellipsis.rows === 'number' && ellipsis.rows > 1 ? ellipsis : null);
|
|
70
|
+
const ellipsisTooltip = $derived.by(() => {
|
|
71
|
+
if (!ellipsis) return undefined;
|
|
72
|
+
if (typeof ellipsis === 'object' && ellipsis.tooltip) {
|
|
73
|
+
return typeof ellipsis.tooltip === 'string' ? ellipsis.tooltip : text;
|
|
74
|
+
}
|
|
75
|
+
if (ellipsis === true) return text || undefined;
|
|
76
|
+
return undefined;
|
|
77
|
+
});
|
|
56
78
|
|
|
57
79
|
let draft = $state(text);
|
|
58
80
|
let input = $state<HTMLInputElement | HTMLTextAreaElement | null>(null);
|
|
@@ -117,7 +139,23 @@
|
|
|
117
139
|
</button>
|
|
118
140
|
</span>
|
|
119
141
|
{:else}
|
|
120
|
-
|
|
142
|
+
{#if multiEllipsis}
|
|
143
|
+
<TypographyEllipsis
|
|
144
|
+
rows={multiEllipsis.rows ?? 1}
|
|
145
|
+
expandable={multiEllipsis.expandable ?? false}
|
|
146
|
+
expandText={multiEllipsis.expandText}
|
|
147
|
+
collapseText={multiEllipsis.collapseText}
|
|
148
|
+
tooltip={ellipsisTooltip}
|
|
149
|
+
>
|
|
150
|
+
{#if children}{@render children()}{:else}{text}{/if}
|
|
151
|
+
</TypographyEllipsis>
|
|
152
|
+
{:else}
|
|
153
|
+
<span
|
|
154
|
+
class="svadmin-typography-text__content"
|
|
155
|
+
class:truncate={isSingleEllipsis && ellipsis !== false}
|
|
156
|
+
title={ellipsisTooltip}
|
|
157
|
+
>{#if children}{@render children()}{:else}{text}{/if}</span>
|
|
158
|
+
{/if}
|
|
121
159
|
{#if copyable}
|
|
122
160
|
<CopyButton value={text} description={copyDescription} label={copyLabel} oncopy={oncopied} class="svadmin-typography-text__action" />
|
|
123
161
|
{/if}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type Snippet } from 'svelte';
|
|
2
2
|
export type TypographyType = 'default' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
3
|
-
interface
|
|
3
|
+
export interface TypographyEllipsisConfig {
|
|
4
|
+
rows?: number;
|
|
5
|
+
expandable?: boolean;
|
|
6
|
+
expandText?: string;
|
|
7
|
+
collapseText?: string;
|
|
8
|
+
tooltip?: boolean | string;
|
|
9
|
+
}
|
|
10
|
+
export interface TypographyTextProps {
|
|
4
11
|
text?: string;
|
|
5
12
|
type?: TypographyType;
|
|
6
13
|
strong?: boolean;
|
|
@@ -12,6 +19,7 @@ interface Props {
|
|
|
12
19
|
copyable?: boolean;
|
|
13
20
|
copyLabel?: string;
|
|
14
21
|
copyDescription?: string;
|
|
22
|
+
ellipsis?: boolean | TypographyEllipsisConfig;
|
|
15
23
|
editable?: boolean;
|
|
16
24
|
editing?: boolean;
|
|
17
25
|
multiline?: boolean;
|
|
@@ -23,6 +31,6 @@ interface Props {
|
|
|
23
31
|
onchange?: (text: string) => void;
|
|
24
32
|
oncopied?: (text: string) => void;
|
|
25
33
|
}
|
|
26
|
-
declare const TypographyText: import("svelte").Component<
|
|
34
|
+
declare const TypographyText: import("svelte").Component<TypographyTextProps, {}, "text" | "editing">;
|
|
27
35
|
type TypographyText = ReturnType<typeof TypographyText>;
|
|
28
36
|
export default TypographyText;
|