@svadmin/ui 0.114.0 → 0.116.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.
@@ -1,7 +1,11 @@
1
+ import type { AuditEntry, AuditQueryParams } from '@svadmin/core';
2
+ export type AuditLogDrawerLoader = (params: AuditQueryParams) => Promise<AuditEntry[]>;
1
3
  type $$ComponentProps = {
2
4
  open: boolean;
3
5
  resource: string;
4
6
  recordId?: string | number;
7
+ /** Optional loader; defaults to the AdminContext auditLogProvider. */
8
+ loadEntries?: AuditLogDrawerLoader;
5
9
  };
6
10
  declare const AuditLogDrawer: import("svelte").Component<$$ComponentProps, {}, "open">;
7
11
  type AuditLogDrawer = ReturnType<typeof AuditLogDrawer>;
@@ -0,0 +1,149 @@
1
+ <script lang="ts">
2
+ import { untrack, type Snippet } from 'svelte';
3
+ import { Loader2 } from '@lucide/svelte';
4
+ import { cn } from '../utils.js';
5
+
6
+ export interface CheckCardProps {
7
+ /** Whether the card is selected */
8
+ checked?: boolean;
9
+ /** Default checked state for uncontrolled usage */
10
+ defaultChecked?: boolean;
11
+ /** Title of the card */
12
+ title?: string;
13
+ /** Description or secondary text */
14
+ description?: string;
15
+ /** Disabled state */
16
+ disabled?: boolean;
17
+ /** Loading state */
18
+ loading?: boolean;
19
+ /** Card size */
20
+ size?: 'default' | 'small';
21
+ /** Custom icon or avatar snippet */
22
+ avatar?: Snippet;
23
+ /** Extra content in the header */
24
+ extra?: Snippet;
25
+ /** Card body content */
26
+ children?: Snippet;
27
+ /** Callback when checked state changes */
28
+ onchange?: (checked: boolean) => void;
29
+ /** Additional CSS classes */
30
+ class?: string;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ let {
35
+ checked,
36
+ defaultChecked = false,
37
+ title,
38
+ description,
39
+ disabled = false,
40
+ loading = false,
41
+ size = 'default',
42
+ avatar,
43
+ extra,
44
+ children,
45
+ onchange,
46
+ class: className = '',
47
+ ...restProps
48
+ }: CheckCardProps = $props();
49
+
50
+ let internalChecked = $state(untrack(() => defaultChecked));
51
+ const isChecked = $derived(checked !== undefined ? checked : internalChecked);
52
+
53
+ function handleClick() {
54
+ if (disabled || loading) return;
55
+ const next = !isChecked;
56
+ if (checked === undefined) {
57
+ internalChecked = next;
58
+ }
59
+ onchange?.(next);
60
+ }
61
+
62
+ function handleKeyDown(event: KeyboardEvent) {
63
+ if (disabled || loading) return;
64
+ if (event.key === ' ' || event.key === 'Enter') {
65
+ event.preventDefault();
66
+ handleClick();
67
+ }
68
+ }
69
+ </script>
70
+
71
+ <div
72
+ role="checkbox"
73
+ aria-checked={isChecked}
74
+ aria-disabled={disabled || loading}
75
+ aria-busy={loading}
76
+ tabindex={disabled || loading ? -1 : 0}
77
+ onclick={handleClick}
78
+ onkeydown={handleKeyDown}
79
+ data-svadmin-component="CheckCard"
80
+ class={cn(
81
+ 'svadmin-check-card relative flex flex-col justify-between border transition-all select-none cursor-pointer rounded-[4px] bg-card text-card-foreground',
82
+ size === 'small' ? 'p-3 text-xs min-w-[140px]' : 'p-4 text-sm min-w-[180px]',
83
+ isChecked
84
+ ? 'border-primary bg-primary/5 shadow-sm'
85
+ : 'border-border hover:border-primary/50 hover:bg-muted/30',
86
+ (disabled || loading) && 'opacity-50 cursor-not-allowed hover:border-border hover:bg-card',
87
+ loading && 'cursor-wait',
88
+ className
89
+ )}
90
+ {...restProps}
91
+ >
92
+ {#if loading}
93
+ <Loader2 class="absolute right-3 top-3 h-4 w-4 animate-spin text-muted-foreground" aria-hidden="true" />
94
+ {/if}
95
+ <!-- Active Checkmark Ribbon in Top-Right Corner (Arco style) -->
96
+ {#if isChecked}
97
+ <div
98
+ class="absolute top-0 right-0 w-0 h-0 border-t-[22px] border-l-[22px] border-t-primary border-l-transparent rounded-tr-[3px]"
99
+ aria-hidden="true"
100
+ >
101
+ <svg
102
+ class="absolute -top-[21px] -left-[11px] w-2.5 h-2.5 text-primary-foreground"
103
+ fill="none"
104
+ viewBox="0 0 24 24"
105
+ stroke="currentColor"
106
+ stroke-width="3.5"
107
+ >
108
+ <path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
109
+ </svg>
110
+ </div>
111
+ {/if}
112
+
113
+ <!-- Header: Avatar + Title + Extra -->
114
+ {#if title || avatar || extra}
115
+ <div class="flex items-start justify-between gap-2.5 mb-1.5">
116
+ <div class="flex items-center gap-2.5 min-w-0">
117
+ {#if avatar}
118
+ <div class="shrink-0 flex items-center justify-center">
119
+ {@render avatar()}
120
+ </div>
121
+ {/if}
122
+ {#if title}
123
+ <span class="font-semibold text-foreground truncate leading-snug">
124
+ {title}
125
+ </span>
126
+ {/if}
127
+ </div>
128
+ {#if extra}
129
+ <div class="shrink-0 text-muted-foreground text-xs">
130
+ {@render extra()}
131
+ </div>
132
+ {/if}
133
+ </div>
134
+ {/if}
135
+
136
+ <!-- Description -->
137
+ {#if description}
138
+ <p class="text-xs text-muted-foreground leading-relaxed line-clamp-2 mt-0.5">
139
+ {description}
140
+ </p>
141
+ {/if}
142
+
143
+ <!-- Body Content -->
144
+ {#if children}
145
+ <div class="mt-2 text-xs text-foreground/90">
146
+ {@render children()}
147
+ </div>
148
+ {/if}
149
+ </div>
@@ -0,0 +1,31 @@
1
+ import { type Snippet } from 'svelte';
2
+ export interface CheckCardProps {
3
+ /** Whether the card is selected */
4
+ checked?: boolean;
5
+ /** Default checked state for uncontrolled usage */
6
+ defaultChecked?: boolean;
7
+ /** Title of the card */
8
+ title?: string;
9
+ /** Description or secondary text */
10
+ description?: string;
11
+ /** Disabled state */
12
+ disabled?: boolean;
13
+ /** Loading state */
14
+ loading?: boolean;
15
+ /** Card size */
16
+ size?: 'default' | 'small';
17
+ /** Custom icon or avatar snippet */
18
+ avatar?: Snippet;
19
+ /** Extra content in the header */
20
+ extra?: Snippet;
21
+ /** Card body content */
22
+ children?: Snippet;
23
+ /** Callback when checked state changes */
24
+ onchange?: (checked: boolean) => void;
25
+ /** Additional CSS classes */
26
+ class?: string;
27
+ [key: string]: unknown;
28
+ }
29
+ declare const CheckCard: import("svelte").Component<CheckCardProps, {}, "">;
30
+ type CheckCard = ReturnType<typeof CheckCard>;
31
+ export default CheckCard;
@@ -76,6 +76,39 @@
76
76
  const showTopNavigation = $derived(navigation === 'top' || navigation === 'mix');
77
77
  const topLevelMenu = $derived((menu ?? []).filter((item) => !item.meta?.hidden));
78
78
 
79
+ let selectedMixRootKey = $state<string | null>(null);
80
+
81
+ // 混合导航模式下,当前激活的一级根菜单项
82
+ const activeMixRoot = $derived.by(() => {
83
+ if (navigation !== 'mix') return null;
84
+ const currentPath = getPath();
85
+ // URL 是深链接、后退和外部导航的事实来源。
86
+ for (const item of topLevelMenu) {
87
+ if (item.children && item.children.some((c) => c.href && (currentPath === c.href || currentPath.startsWith(`${c.href}/`)))) {
88
+ return item;
89
+ }
90
+ if (item.href && (currentPath === item.href || currentPath.startsWith(`${item.href}/`))) {
91
+ return item;
92
+ }
93
+ }
94
+ if (selectedMixRootKey) {
95
+ const match = topLevelMenu.find((m) => m.name === selectedMixRootKey);
96
+ if (match) return match;
97
+ }
98
+ return topLevelMenu[0] ?? null;
99
+ });
100
+
101
+ // 在 mix 模式下,左侧侧边栏联动展示当前激活根菜单的子菜单
102
+ const effectiveSidebarMenu = $derived.by(() => {
103
+ if (navigation === 'mix' && activeMixRoot) {
104
+ if (activeMixRoot.children && activeMixRoot.children.length > 0) {
105
+ return activeMixRoot.children;
106
+ }
107
+ return [activeMixRoot];
108
+ }
109
+ return menu;
110
+ });
111
+
79
112
  const auth = $derived(adminContext.authProvider);
80
113
  let loading = $state(true);
81
114
  let identity = $state<Identity | null>(null);
@@ -236,7 +269,7 @@
236
269
  <!-- Desktop sidebar -->
237
270
  {#if showSidebar}
238
271
  <div class="svadmin-layout__desktop-sidebar">
239
- <Sidebar {collapsed} {identity} {title} {...definedOptions({ "menu": menu })} {routeMode} onToggle={() => collapsed = !collapsed} onLogout={handleLogout} />
272
+ <Sidebar {collapsed} {identity} {title} {...definedOptions({ "menu": effectiveSidebarMenu })} {routeMode} onToggle={() => collapsed = !collapsed} onLogout={handleLogout} />
240
273
  </div>
241
274
  {/if}
242
275
 
@@ -250,7 +283,7 @@
250
283
  >
251
284
  <Sheet.Title id={`${layoutScope}-mobile-navigation-title`} class="sr-only">{title}</Sheet.Title>
252
285
  <div class="md:hidden">
253
- <Sidebar collapsed={false} {identity} {title} {...definedOptions({ "menu": menu })} {routeMode} onToggle={() => { mobileMenuOpen = false; }} onLogout={handleLogout} />
286
+ <Sidebar collapsed={false} {identity} {title} {...definedOptions({ "menu": effectiveSidebarMenu })} {routeMode} onToggle={() => { mobileMenuOpen = false; }} onLogout={handleLogout} />
254
287
  </div>
255
288
  </Sheet.Root>
256
289
 
@@ -300,8 +333,19 @@
300
333
  {#if showTopNavigation}
301
334
  <nav class="svadmin-top-navigation" aria-label={title}>
302
335
  {#each topLevelMenu as item (item.name)}
303
- {@const active = item.href ? getPath().startsWith(item.href) : false}
304
- <a class="svadmin-top-navigation__item" class:is-active={active} href={item.href ?? '#'}>
336
+ {@const isMixActive = navigation === 'mix' && activeMixRoot?.name === item.name}
337
+ {@const isPathActive = item.href ? getPath().startsWith(item.href) : false}
338
+ {@const active = navigation === 'mix' ? isMixActive : isPathActive}
339
+ <a
340
+ class="svadmin-top-navigation__item"
341
+ class:is-active={active}
342
+ href={item.href ?? (item.children?.[0]?.href ?? '#')}
343
+ onclick={() => {
344
+ if (navigation === 'mix') {
345
+ selectedMixRootKey = item.name;
346
+ }
347
+ }}
348
+ >
305
349
  {item.label ?? i18n.t(`menu.${item.name}`)}
306
350
  </a>
307
351
  {/each}
@@ -0,0 +1,158 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { cn } from '../utils.js';
4
+ import { Check, X } from '@lucide/svelte';
5
+
6
+ export interface PricingFeature {
7
+ /** Feature title or description */
8
+ label: string;
9
+ /** Whether this feature is included in the tier. Defaults to true */
10
+ included?: boolean;
11
+ /** Optional secondary hint */
12
+ hint?: string;
13
+ }
14
+
15
+ export interface PricingCardProps {
16
+ /** Tier name, e.g., 'Starter', 'Professional', 'Enterprise' */
17
+ title: string;
18
+ /** Short summary or audience description */
19
+ description?: string;
20
+ /** Display price, e.g. '$29' or 29 */
21
+ price: string | number;
22
+ /** Billing interval suffix, e.g. '/month', '/yr' or 'per seat' */
23
+ interval?: string;
24
+ /** Optional tag/badge text, e.g. 'Recommended', 'Most Popular' */
25
+ badge?: string;
26
+ /** Whether this card is highlighted as the primary tier */
27
+ highlighted?: boolean;
28
+ /** List of features for this tier */
29
+ features?: (PricingFeature | string)[];
30
+ /** Primary CTA button label */
31
+ buttonText?: string;
32
+ /** Primary CTA button disabled state */
33
+ disabled?: boolean;
34
+ /** CTA variant style */
35
+ buttonVariant?: 'default' | 'outline' | 'secondary';
36
+ /** Custom CTA snippet slot */
37
+ action?: Snippet;
38
+ /** Custom header or badge slot */
39
+ headerExtra?: Snippet;
40
+ /** Click callback when CTA is activated */
41
+ onselect?: () => void;
42
+ /** Additional CSS classes */
43
+ class?: string;
44
+ }
45
+
46
+ let {
47
+ title,
48
+ description,
49
+ price,
50
+ interval = '/mo',
51
+ badge,
52
+ highlighted = false,
53
+ features = [],
54
+ buttonText = 'Get Started',
55
+ disabled = false,
56
+ buttonVariant = 'default',
57
+ action,
58
+ headerExtra,
59
+ onselect,
60
+ class: className = '',
61
+ }: PricingCardProps = $props();
62
+
63
+ const normalizedFeatures = $derived(
64
+ features.map((f) => (typeof f === 'string' ? { label: f, included: true } : f)),
65
+ );
66
+ </script>
67
+
68
+ <div
69
+ class={cn(
70
+ 'relative flex flex-col rounded-xl border p-6 transition-all duration-200',
71
+ 'bg-card text-card-foreground',
72
+ highlighted
73
+ ? 'border-primary shadow-lg ring-1 ring-primary'
74
+ : 'border-border shadow-sm hover:border-primary/50',
75
+ className,
76
+ )}
77
+ data-svadmin-component="PricingCard"
78
+ data-highlighted={highlighted ? 'true' : 'false'}
79
+ >
80
+ {#if badge}
81
+ <div class="absolute -top-3 right-6">
82
+ <span
83
+ class="inline-flex items-center rounded-full bg-primary px-3 py-1 text-xs font-semibold text-primary-foreground shadow-sm"
84
+ >
85
+ {badge}
86
+ </span>
87
+ </div>
88
+ {/if}
89
+
90
+ <div class="flex items-start justify-between gap-2">
91
+ <div>
92
+ <h3 class="text-xl font-bold tracking-tight">{title}</h3>
93
+ {#if description}
94
+ <p class="mt-1 text-sm text-muted-foreground">{description}</p>
95
+ {/if}
96
+ </div>
97
+ {#if headerExtra}
98
+ {@render headerExtra()}
99
+ {/if}
100
+ </div>
101
+
102
+ <div class="mt-6 flex items-baseline gap-1">
103
+ <span class="text-4xl font-extrabold tracking-tight">{price}</span>
104
+ {#if interval}
105
+ <span class="text-sm font-medium text-muted-foreground">{interval}</span>
106
+ {/if}
107
+ </div>
108
+
109
+ {#if normalizedFeatures.length > 0}
110
+ <ul class="my-6 flex-1 space-y-3 border-t border-border/60 pt-6 text-sm">
111
+ {#each normalizedFeatures as feature, idx (feature.label + idx)}
112
+ <li class="flex items-center gap-2">
113
+ {#if feature.included ?? true}
114
+ <span class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">
115
+ <Check class="h-3 w-3 stroke-[2.5]" />
116
+ </span>
117
+ <span class="text-foreground">{feature.label}</span>
118
+ {:else}
119
+ <span class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground">
120
+ <X class="h-3 w-3 stroke-[2.5]" />
121
+ </span>
122
+ <span class="text-muted-foreground line-through">{feature.label}</span>
123
+ {/if}
124
+ {#if feature.hint}
125
+ <span class="text-xs text-muted-foreground">({feature.hint})</span>
126
+ {/if}
127
+ </li>
128
+ {/each}
129
+ </ul>
130
+ {/if}
131
+
132
+ <div class="mt-auto pt-4">
133
+ {#if action}
134
+ {@render action()}
135
+ {:else}
136
+ <button
137
+ type="button"
138
+ {disabled}
139
+ onclick={() => onselect?.()}
140
+ class={cn(
141
+ 'w-full rounded-md px-4 py-2.5 text-sm font-medium transition-colors',
142
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
143
+ disabled && 'cursor-not-allowed opacity-50',
144
+ buttonVariant === 'default' &&
145
+ (highlighted
146
+ ? 'bg-primary text-primary-foreground hover:bg-primary/90'
147
+ : 'bg-primary/90 text-primary-foreground hover:bg-primary'),
148
+ buttonVariant === 'outline' &&
149
+ 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
150
+ buttonVariant === 'secondary' &&
151
+ 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
152
+ )}
153
+ >
154
+ {buttonText}
155
+ </button>
156
+ {/if}
157
+ </div>
158
+ </div>
@@ -0,0 +1,42 @@
1
+ import type { Snippet } from 'svelte';
2
+ export interface PricingFeature {
3
+ /** Feature title or description */
4
+ label: string;
5
+ /** Whether this feature is included in the tier. Defaults to true */
6
+ included?: boolean;
7
+ /** Optional secondary hint */
8
+ hint?: string;
9
+ }
10
+ export interface PricingCardProps {
11
+ /** Tier name, e.g., 'Starter', 'Professional', 'Enterprise' */
12
+ title: string;
13
+ /** Short summary or audience description */
14
+ description?: string;
15
+ /** Display price, e.g. '$29' or 29 */
16
+ price: string | number;
17
+ /** Billing interval suffix, e.g. '/month', '/yr' or 'per seat' */
18
+ interval?: string;
19
+ /** Optional tag/badge text, e.g. 'Recommended', 'Most Popular' */
20
+ badge?: string;
21
+ /** Whether this card is highlighted as the primary tier */
22
+ highlighted?: boolean;
23
+ /** List of features for this tier */
24
+ features?: (PricingFeature | string)[];
25
+ /** Primary CTA button label */
26
+ buttonText?: string;
27
+ /** Primary CTA button disabled state */
28
+ disabled?: boolean;
29
+ /** CTA variant style */
30
+ buttonVariant?: 'default' | 'outline' | 'secondary';
31
+ /** Custom CTA snippet slot */
32
+ action?: Snippet;
33
+ /** Custom header or badge slot */
34
+ headerExtra?: Snippet;
35
+ /** Click callback when CTA is activated */
36
+ onselect?: () => void;
37
+ /** Additional CSS classes */
38
+ class?: string;
39
+ }
40
+ declare const PricingCard: import("svelte").Component<PricingCardProps, {}, "">;
41
+ type PricingCard = ReturnType<typeof PricingCard>;
42
+ export default PricingCard;
@@ -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;
13
+ /** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
14
+ warningThreshold?: number;
15
+ /** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
16
+ criticalThreshold?: number;
17
+ /** Whether to display the percentage badge. Defaults to true */
18
+ showPercent?: boolean;
19
+ /** Optional custom number formatter */
20
+ formatter?: (val: number) => string;
21
+ /** Optional extra description or action */
22
+ description?: string;
23
+ /** Compact inline single-line display */
24
+ compact?: boolean;
25
+ /** Additional CSS classes */
26
+ class?: string;
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;
10
+ /** Ratio for warning state (0-1). Defaults to 0.8 (80%) */
11
+ warningThreshold?: number;
12
+ /** Ratio for critical state (0-1). Defaults to 0.95 (95%) */
13
+ criticalThreshold?: number;
14
+ /** Whether to display the percentage badge. Defaults to true */
15
+ showPercent?: boolean;
16
+ /** Optional custom number formatter */
17
+ formatter?: (val: number) => string;
18
+ /** Optional extra description or action */
19
+ description?: string;
20
+ /** Compact inline single-line display */
21
+ compact?: boolean;
22
+ /** Additional CSS classes */
23
+ class?: string;
24
+ }
25
+ declare const QuotaProgressBar: import("svelte").Component<QuotaProgressBarProps, {}, "">;
26
+ type QuotaProgressBar = ReturnType<typeof QuotaProgressBar>;
27
+ export default QuotaProgressBar;