@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,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 | undefined;
|
|
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 | undefined;
|
|
24
|
+
/** Optional tag/badge text, e.g. 'Recommended', 'Most Popular' */
|
|
25
|
+
badge?: string | undefined;
|
|
26
|
+
/** Whether this card is highlighted as the primary tier */
|
|
27
|
+
highlighted?: boolean | undefined;
|
|
28
|
+
/** List of features for this tier */
|
|
29
|
+
features?: (PricingFeature | string)[] | undefined;
|
|
30
|
+
/** Primary CTA button label */
|
|
31
|
+
buttonText?: string | undefined;
|
|
32
|
+
/** Primary CTA button disabled state */
|
|
33
|
+
disabled?: boolean | undefined;
|
|
34
|
+
/** CTA variant style */
|
|
35
|
+
buttonVariant?: 'default' | 'outline' | 'secondary' | undefined;
|
|
36
|
+
/** Custom CTA snippet slot */
|
|
37
|
+
action?: Snippet | undefined;
|
|
38
|
+
/** Custom header or badge slot */
|
|
39
|
+
headerExtra?: Snippet | undefined;
|
|
40
|
+
/** Click callback when CTA is activated */
|
|
41
|
+
onselect?: (() => void) | undefined;
|
|
42
|
+
/** Additional CSS classes */
|
|
43
|
+
class?: string | undefined;
|
|
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 | undefined;
|
|
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 | undefined;
|
|
19
|
+
/** Optional tag/badge text, e.g. 'Recommended', 'Most Popular' */
|
|
20
|
+
badge?: string | undefined;
|
|
21
|
+
/** Whether this card is highlighted as the primary tier */
|
|
22
|
+
highlighted?: boolean | undefined;
|
|
23
|
+
/** List of features for this tier */
|
|
24
|
+
features?: (PricingFeature | string)[] | undefined;
|
|
25
|
+
/** Primary CTA button label */
|
|
26
|
+
buttonText?: string | undefined;
|
|
27
|
+
/** Primary CTA button disabled state */
|
|
28
|
+
disabled?: boolean | undefined;
|
|
29
|
+
/** CTA variant style */
|
|
30
|
+
buttonVariant?: 'default' | 'outline' | 'secondary' | undefined;
|
|
31
|
+
/** Custom CTA snippet slot */
|
|
32
|
+
action?: Snippet | undefined;
|
|
33
|
+
/** Custom header or badge slot */
|
|
34
|
+
headerExtra?: Snippet | undefined;
|
|
35
|
+
/** Click callback when CTA is activated */
|
|
36
|
+
onselect?: (() => void) | undefined;
|
|
37
|
+
/** Additional CSS classes */
|
|
38
|
+
class?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
declare const PricingCard: import("svelte").Component<PricingCardProps, {}, "">;
|
|
41
|
+
type PricingCard = ReturnType<typeof PricingCard>;
|
|
42
|
+
export default PricingCard;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../utils.js';
|
|
3
|
+
import PricingCard, { type PricingFeature } from './PricingCard.svelte';
|
|
4
|
+
import { Check, X } from '@lucide/svelte';
|
|
5
|
+
|
|
6
|
+
export interface PricingPlan {
|
|
7
|
+
key: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
monthlyPrice: string | number;
|
|
11
|
+
yearlyPrice?: string | number;
|
|
12
|
+
badge?: string;
|
|
13
|
+
highlighted?: boolean;
|
|
14
|
+
buttonText?: string;
|
|
15
|
+
buttonVariant?: 'default' | 'outline' | 'secondary';
|
|
16
|
+
features?: (PricingFeature | string)[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FeatureComparisonRow {
|
|
20
|
+
name: string;
|
|
21
|
+
hint?: string;
|
|
22
|
+
/** Map plan key to value (boolean or string) */
|
|
23
|
+
values: Record<string, boolean | string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FeatureComparisonGroup {
|
|
27
|
+
category: string;
|
|
28
|
+
rows: FeatureComparisonRow[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface PricingTableProps {
|
|
32
|
+
/** Available subscription plans */
|
|
33
|
+
plans: PricingPlan[];
|
|
34
|
+
/** Current billing cycle (can be bound with bind:cycle) */
|
|
35
|
+
cycle?: 'monthly' | 'yearly';
|
|
36
|
+
/** Badge or highlight on the yearly toggle */
|
|
37
|
+
yearlyDiscountBadge?: string;
|
|
38
|
+
/** Optional detailed feature comparison matrix */
|
|
39
|
+
comparisonGroups?: FeatureComparisonGroup[];
|
|
40
|
+
/** Callback when a plan CTA is clicked */
|
|
41
|
+
onselectplan?: (plan: PricingPlan, cycle: 'monthly' | 'yearly') => void;
|
|
42
|
+
/** Additional CSS classes */
|
|
43
|
+
class?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let {
|
|
47
|
+
plans = [],
|
|
48
|
+
cycle = $bindable<'monthly' | 'yearly'>('monthly'),
|
|
49
|
+
yearlyDiscountBadge = 'Save 20%',
|
|
50
|
+
comparisonGroups = [],
|
|
51
|
+
onselectplan,
|
|
52
|
+
class: className = '',
|
|
53
|
+
}: PricingTableProps = $props();
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<div
|
|
57
|
+
class={cn('w-full space-y-10', className)}
|
|
58
|
+
data-svadmin-component="PricingTable"
|
|
59
|
+
data-cycle={cycle}
|
|
60
|
+
>
|
|
61
|
+
<!-- Cycle toggle -->
|
|
62
|
+
<div class="flex items-center justify-center gap-3">
|
|
63
|
+
<div class="inline-flex items-center rounded-lg border border-border bg-muted/60 p-1 text-sm font-medium">
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
onclick={() => (cycle = 'monthly')}
|
|
67
|
+
class={cn(
|
|
68
|
+
'rounded-md px-4 py-1.5 transition-all',
|
|
69
|
+
cycle === 'monthly'
|
|
70
|
+
? 'bg-background text-foreground shadow-sm'
|
|
71
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
72
|
+
)}
|
|
73
|
+
>
|
|
74
|
+
Monthly
|
|
75
|
+
</button>
|
|
76
|
+
<button
|
|
77
|
+
type="button"
|
|
78
|
+
onclick={() => (cycle = 'yearly')}
|
|
79
|
+
class={cn(
|
|
80
|
+
'relative inline-flex items-center gap-1.5 rounded-md px-4 py-1.5 transition-all',
|
|
81
|
+
cycle === 'yearly'
|
|
82
|
+
? 'bg-background text-foreground shadow-sm'
|
|
83
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
84
|
+
)}
|
|
85
|
+
>
|
|
86
|
+
<span>Yearly</span>
|
|
87
|
+
{#if yearlyDiscountBadge}
|
|
88
|
+
<span class="rounded-full bg-primary/10 px-2 py-0.5 text-[11px] font-semibold text-primary">
|
|
89
|
+
{yearlyDiscountBadge}
|
|
90
|
+
</span>
|
|
91
|
+
{/if}
|
|
92
|
+
</button>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<!-- Pricing Cards Grid -->
|
|
97
|
+
<div
|
|
98
|
+
class={cn(
|
|
99
|
+
'grid gap-6',
|
|
100
|
+
plans.length === 1 && 'max-w-md mx-auto',
|
|
101
|
+
plans.length === 2 && 'grid-cols-1 md:grid-cols-2 max-w-4xl mx-auto',
|
|
102
|
+
plans.length >= 3 && 'grid-cols-1 md:grid-cols-3',
|
|
103
|
+
plans.length >= 4 && 'lg:grid-cols-4',
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
{#each plans as plan (plan.key)}
|
|
107
|
+
<PricingCard
|
|
108
|
+
title={plan.title}
|
|
109
|
+
description={plan.description}
|
|
110
|
+
price={cycle === 'yearly' ? (plan.yearlyPrice ?? plan.monthlyPrice) : plan.monthlyPrice}
|
|
111
|
+
interval={cycle === 'yearly' ? '/yr' : '/mo'}
|
|
112
|
+
badge={plan.badge}
|
|
113
|
+
highlighted={plan.highlighted}
|
|
114
|
+
buttonText={plan.buttonText ?? 'Choose Plan'}
|
|
115
|
+
buttonVariant={plan.buttonVariant}
|
|
116
|
+
features={plan.features}
|
|
117
|
+
onselect={() => onselectplan?.(plan, cycle)}
|
|
118
|
+
/>
|
|
119
|
+
{/each}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<!-- Detailed Feature Comparison Table (Optional) -->
|
|
123
|
+
{#if comparisonGroups.length > 0}
|
|
124
|
+
<div class="overflow-x-auto rounded-xl border border-border bg-card p-6 shadow-sm">
|
|
125
|
+
<div class="mb-6">
|
|
126
|
+
<h3 class="text-lg font-bold tracking-tight text-foreground">Feature Comparison</h3>
|
|
127
|
+
<p class="text-sm text-muted-foreground">Compare features across all subscription plans</p>
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<table class="w-full text-left text-sm">
|
|
131
|
+
<thead>
|
|
132
|
+
<tr class="border-b border-border text-muted-foreground">
|
|
133
|
+
<th class="py-3 pr-4 font-medium">Features</th>
|
|
134
|
+
{#each plans as plan (plan.key)}
|
|
135
|
+
<th class="px-4 py-3 text-center font-medium">
|
|
136
|
+
<span class={plan.highlighted ? 'font-bold text-primary' : 'text-foreground'}>
|
|
137
|
+
{plan.title}
|
|
138
|
+
</span>
|
|
139
|
+
</th>
|
|
140
|
+
{/each}
|
|
141
|
+
</tr>
|
|
142
|
+
</thead>
|
|
143
|
+
<tbody class="divide-y divide-border/60">
|
|
144
|
+
{#each comparisonGroups as group, gIdx (group.category || gIdx)}
|
|
145
|
+
<tr class="bg-muted/40 font-semibold text-foreground">
|
|
146
|
+
<td colspan={plans.length + 1} class="py-2.5 pl-2 text-xs tracking-wide uppercase">
|
|
147
|
+
{group.category}
|
|
148
|
+
</td>
|
|
149
|
+
</tr>
|
|
150
|
+
{#each group.rows as row (row.name)}
|
|
151
|
+
<tr class="hover:bg-muted/20">
|
|
152
|
+
<td class="py-3 pr-4">
|
|
153
|
+
<div class="font-medium text-foreground">{row.name}</div>
|
|
154
|
+
{#if row.hint}
|
|
155
|
+
<div class="text-xs text-muted-foreground">{row.hint}</div>
|
|
156
|
+
{/if}
|
|
157
|
+
</td>
|
|
158
|
+
{#each plans as plan (plan.key)}
|
|
159
|
+
{@const val = row.values[plan.key]}
|
|
160
|
+
<td class="px-4 py-3 text-center">
|
|
161
|
+
{#if typeof val === 'boolean'}
|
|
162
|
+
{#if val}
|
|
163
|
+
<span class="inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary/10 text-primary">
|
|
164
|
+
<Check class="h-3.5 w-3.5 stroke-[2.5]" />
|
|
165
|
+
</span>
|
|
166
|
+
{:else}
|
|
167
|
+
<span class="inline-flex h-5 w-5 items-center justify-center rounded-full bg-muted text-muted-foreground">
|
|
168
|
+
<X class="h-3.5 w-3.5 stroke-[2.5]" />
|
|
169
|
+
</span>
|
|
170
|
+
{/if}
|
|
171
|
+
{:else if val}
|
|
172
|
+
<span class="font-medium text-foreground">{val}</span>
|
|
173
|
+
{:else}
|
|
174
|
+
<span class="text-muted-foreground">—</span>
|
|
175
|
+
{/if}
|
|
176
|
+
</td>
|
|
177
|
+
{/each}
|
|
178
|
+
</tr>
|
|
179
|
+
{/each}
|
|
180
|
+
{/each}
|
|
181
|
+
</tbody>
|
|
182
|
+
</table>
|
|
183
|
+
</div>
|
|
184
|
+
{/if}
|
|
185
|
+
</div>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type PricingFeature } from './PricingCard.svelte';
|
|
2
|
+
export interface PricingPlan {
|
|
3
|
+
key: string;
|
|
4
|
+
title: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
monthlyPrice: string | number;
|
|
7
|
+
yearlyPrice?: string | number;
|
|
8
|
+
badge?: string;
|
|
9
|
+
highlighted?: boolean;
|
|
10
|
+
buttonText?: string;
|
|
11
|
+
buttonVariant?: 'default' | 'outline' | 'secondary';
|
|
12
|
+
features?: (PricingFeature | string)[];
|
|
13
|
+
}
|
|
14
|
+
export interface FeatureComparisonRow {
|
|
15
|
+
name: string;
|
|
16
|
+
hint?: string;
|
|
17
|
+
/** Map plan key to value (boolean or string) */
|
|
18
|
+
values: Record<string, boolean | string>;
|
|
19
|
+
}
|
|
20
|
+
export interface FeatureComparisonGroup {
|
|
21
|
+
category: string;
|
|
22
|
+
rows: FeatureComparisonRow[];
|
|
23
|
+
}
|
|
24
|
+
export interface PricingTableProps {
|
|
25
|
+
/** Available subscription plans */
|
|
26
|
+
plans: PricingPlan[];
|
|
27
|
+
/** Current billing cycle (can be bound with bind:cycle) */
|
|
28
|
+
cycle?: 'monthly' | 'yearly';
|
|
29
|
+
/** Badge or highlight on the yearly toggle */
|
|
30
|
+
yearlyDiscountBadge?: string;
|
|
31
|
+
/** Optional detailed feature comparison matrix */
|
|
32
|
+
comparisonGroups?: FeatureComparisonGroup[];
|
|
33
|
+
/** Callback when a plan CTA is clicked */
|
|
34
|
+
onselectplan?: (plan: PricingPlan, cycle: 'monthly' | 'yearly') => void;
|
|
35
|
+
/** Additional CSS classes */
|
|
36
|
+
class?: string;
|
|
37
|
+
}
|
|
38
|
+
declare const PricingTable: import("svelte").Component<PricingTableProps, {}, "cycle">;
|
|
39
|
+
type PricingTable = ReturnType<typeof PricingTable>;
|
|
40
|
+
export default PricingTable;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack, type Snippet } from 'svelte';
|
|
3
|
+
import { ChevronRight, HelpCircle, Loader2 } from '@lucide/svelte';
|
|
4
|
+
import { cn } from '../utils.js';
|
|
5
|
+
|
|
6
|
+
export interface ProCardTab {
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ProCardProps {
|
|
13
|
+
/** Title of the card header */
|
|
14
|
+
title?: string | Snippet;
|
|
15
|
+
/** Subtitle or secondary description */
|
|
16
|
+
subTitle?: string | Snippet;
|
|
17
|
+
/** Information tooltip description displayed next to the title */
|
|
18
|
+
tooltip?: string;
|
|
19
|
+
/** Extra actions or elements in the top right of the header */
|
|
20
|
+
extra?: Snippet;
|
|
21
|
+
/** Bottom actions slot */
|
|
22
|
+
actions?: Snippet;
|
|
23
|
+
/** Whether the card has an outer border */
|
|
24
|
+
bordered?: boolean;
|
|
25
|
+
/** Whether the card elevates on hover */
|
|
26
|
+
hoverable?: boolean;
|
|
27
|
+
/** Ghost mode: removes background, border, and padding for seamless grid nesting */
|
|
28
|
+
ghost?: boolean;
|
|
29
|
+
/** Whether the card can be collapsed */
|
|
30
|
+
collapsible?: boolean;
|
|
31
|
+
/** Controlled collapsed state */
|
|
32
|
+
collapsed?: boolean;
|
|
33
|
+
/** Initial default collapsed state */
|
|
34
|
+
defaultCollapsed?: boolean;
|
|
35
|
+
/** Callback when collapsed state toggles */
|
|
36
|
+
oncollapse?: (collapsed: boolean) => void;
|
|
37
|
+
/** Split layout for child elements */
|
|
38
|
+
split?: 'vertical' | 'horizontal';
|
|
39
|
+
/** Tab items displayed in the card header */
|
|
40
|
+
tabs?: ProCardTab[];
|
|
41
|
+
/** Controlled active tab key */
|
|
42
|
+
activeTabKey?: string;
|
|
43
|
+
/** Callback when active tab changes */
|
|
44
|
+
ontabchange?: (key: string) => void;
|
|
45
|
+
/** Size tier of the card */
|
|
46
|
+
size?: 'default' | 'small';
|
|
47
|
+
/** Loading indicator */
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
/** Additional class names for header */
|
|
50
|
+
headerClass?: string;
|
|
51
|
+
/** Additional class names for card body */
|
|
52
|
+
bodyClass?: string;
|
|
53
|
+
/** Additional root class names */
|
|
54
|
+
class?: string;
|
|
55
|
+
/** Body content slot */
|
|
56
|
+
children?: Snippet;
|
|
57
|
+
[key: string]: unknown;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let {
|
|
61
|
+
title,
|
|
62
|
+
subTitle,
|
|
63
|
+
tooltip,
|
|
64
|
+
extra,
|
|
65
|
+
actions,
|
|
66
|
+
bordered = true,
|
|
67
|
+
hoverable = false,
|
|
68
|
+
ghost = false,
|
|
69
|
+
collapsible = false,
|
|
70
|
+
collapsed,
|
|
71
|
+
defaultCollapsed = false,
|
|
72
|
+
oncollapse,
|
|
73
|
+
split,
|
|
74
|
+
tabs,
|
|
75
|
+
activeTabKey = $bindable(),
|
|
76
|
+
ontabchange,
|
|
77
|
+
size = 'default',
|
|
78
|
+
loading = false,
|
|
79
|
+
headerClass = '',
|
|
80
|
+
bodyClass = '',
|
|
81
|
+
class: className = '',
|
|
82
|
+
children,
|
|
83
|
+
...restProps
|
|
84
|
+
}: ProCardProps = $props();
|
|
85
|
+
|
|
86
|
+
let internalCollapsed = $state(untrack(() => defaultCollapsed));
|
|
87
|
+
const isCollapsed = $derived(collapsed !== undefined ? collapsed : internalCollapsed);
|
|
88
|
+
|
|
89
|
+
let internalActiveTab = $state(untrack(() => activeTabKey ?? tabs?.[0]?.key));
|
|
90
|
+
const currentTab = $derived(activeTabKey !== undefined ? activeTabKey : internalActiveTab);
|
|
91
|
+
|
|
92
|
+
function toggleCollapse() {
|
|
93
|
+
if (!collapsible) return;
|
|
94
|
+
const next = !isCollapsed;
|
|
95
|
+
if (collapsed === undefined) {
|
|
96
|
+
internalCollapsed = next;
|
|
97
|
+
}
|
|
98
|
+
oncollapse?.(next);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function handleTabSelect(key: string, disabled?: boolean) {
|
|
102
|
+
if (disabled) return;
|
|
103
|
+
if (activeTabKey === undefined) {
|
|
104
|
+
internalActiveTab = key;
|
|
105
|
+
}
|
|
106
|
+
activeTabKey = key;
|
|
107
|
+
ontabchange?.(key);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const hasHeader = $derived(
|
|
111
|
+
Boolean(title || subTitle || tooltip || extra || collapsible || (tabs && tabs.length > 0))
|
|
112
|
+
);
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<div
|
|
116
|
+
data-svadmin-component="ProCard"
|
|
117
|
+
data-ghost={ghost}
|
|
118
|
+
data-collapsed={isCollapsed}
|
|
119
|
+
data-size={size}
|
|
120
|
+
class={cn(
|
|
121
|
+
'relative flex flex-col transition-all duration-200',
|
|
122
|
+
ghost
|
|
123
|
+
? 'bg-transparent border-0 shadow-none'
|
|
124
|
+
: cn(
|
|
125
|
+
'bg-card text-card-foreground rounded-[4px]',
|
|
126
|
+
bordered && 'border border-border',
|
|
127
|
+
hoverable && 'hover:shadow-md hover:border-primary/40 cursor-pointer'
|
|
128
|
+
),
|
|
129
|
+
className
|
|
130
|
+
)}
|
|
131
|
+
{...restProps}
|
|
132
|
+
>
|
|
133
|
+
{#if loading}
|
|
134
|
+
<div
|
|
135
|
+
role="status"
|
|
136
|
+
aria-label="Loading"
|
|
137
|
+
class="absolute inset-0 z-20 flex items-center justify-center bg-card/60 backdrop-blur-[1px] rounded-[4px]"
|
|
138
|
+
>
|
|
139
|
+
<Loader2 class="h-6 w-6 animate-spin text-primary" />
|
|
140
|
+
</div>
|
|
141
|
+
{/if}
|
|
142
|
+
|
|
143
|
+
{#if hasHeader}
|
|
144
|
+
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
145
|
+
<div
|
|
146
|
+
class={cn(
|
|
147
|
+
'flex items-center justify-between border-b border-border/60 transition-colors',
|
|
148
|
+
size === 'small' ? 'px-3 py-2' : 'px-4 py-3',
|
|
149
|
+
collapsible && 'cursor-pointer select-none hover:bg-muted/40',
|
|
150
|
+
isCollapsed && 'border-b-0',
|
|
151
|
+
headerClass
|
|
152
|
+
)}
|
|
153
|
+
onclick={collapsible ? toggleCollapse : undefined}
|
|
154
|
+
onkeydown={(e) => {
|
|
155
|
+
if (collapsible && (e.key === 'Enter' || e.key === ' ')) {
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
toggleCollapse();
|
|
158
|
+
}
|
|
159
|
+
}}
|
|
160
|
+
role={collapsible ? 'button' : undefined}
|
|
161
|
+
tabindex={collapsible ? 0 : undefined}
|
|
162
|
+
aria-expanded={collapsible ? !isCollapsed : undefined}
|
|
163
|
+
>
|
|
164
|
+
<!-- Title & Subtitle Section -->
|
|
165
|
+
<div class="flex items-center gap-2 min-w-0">
|
|
166
|
+
{#if collapsible}
|
|
167
|
+
<ChevronRight
|
|
168
|
+
class={cn(
|
|
169
|
+
'h-4 w-4 text-muted-foreground transition-transform duration-200 shrink-0',
|
|
170
|
+
!isCollapsed && 'rotate-90'
|
|
171
|
+
)}
|
|
172
|
+
/>
|
|
173
|
+
{/if}
|
|
174
|
+
|
|
175
|
+
<div class="flex items-center gap-1.5 flex-wrap">
|
|
176
|
+
{#if title}
|
|
177
|
+
<span class={cn('font-semibold text-foreground truncate', size === 'small' ? 'text-xs' : 'text-sm')}>
|
|
178
|
+
{#if typeof title === 'string'}
|
|
179
|
+
{title}
|
|
180
|
+
{:else}
|
|
181
|
+
{@render title()}
|
|
182
|
+
{/if}
|
|
183
|
+
</span>
|
|
184
|
+
{/if}
|
|
185
|
+
|
|
186
|
+
{#if subTitle}
|
|
187
|
+
<span class="text-xs text-muted-foreground font-normal truncate">
|
|
188
|
+
{#if typeof subTitle === 'string'}
|
|
189
|
+
{subTitle}
|
|
190
|
+
{:else}
|
|
191
|
+
{@render subTitle()}
|
|
192
|
+
{/if}
|
|
193
|
+
</span>
|
|
194
|
+
{/if}
|
|
195
|
+
|
|
196
|
+
{#if tooltip}
|
|
197
|
+
<span title={tooltip} class="inline-flex text-muted-foreground hover:text-foreground cursor-help">
|
|
198
|
+
<HelpCircle class="h-3.5 w-3.5" />
|
|
199
|
+
</span>
|
|
200
|
+
{/if}
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<!-- Tabs or Extra Section -->
|
|
205
|
+
<div class="flex items-center gap-2 shrink-0">
|
|
206
|
+
{#if tabs && tabs.length > 0}
|
|
207
|
+
<div class="flex items-center gap-1 bg-muted/60 p-0.5 rounded-[4px] border border-border/40">
|
|
208
|
+
{#each tabs as tab (tab.key)}
|
|
209
|
+
{@const active = currentTab === tab.key}
|
|
210
|
+
<button
|
|
211
|
+
type="button"
|
|
212
|
+
disabled={tab.disabled}
|
|
213
|
+
class={cn(
|
|
214
|
+
'px-2.5 py-1 text-xs font-medium rounded-[2px] transition-colors',
|
|
215
|
+
active
|
|
216
|
+
? 'bg-background text-foreground shadow-xs'
|
|
217
|
+
: 'text-muted-foreground hover:text-foreground',
|
|
218
|
+
tab.disabled && 'opacity-50 cursor-not-allowed'
|
|
219
|
+
)}
|
|
220
|
+
onclick={(e) => {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
handleTabSelect(tab.key, tab.disabled);
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
{tab.label}
|
|
226
|
+
</button>
|
|
227
|
+
{/each}
|
|
228
|
+
</div>
|
|
229
|
+
{/if}
|
|
230
|
+
|
|
231
|
+
{#if extra}
|
|
232
|
+
<div class="flex items-center gap-1.5 text-xs text-muted-foreground" onclick={(e) => e.stopPropagation()} role="none">
|
|
233
|
+
{@render extra()}
|
|
234
|
+
</div>
|
|
235
|
+
{/if}
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
{/if}
|
|
239
|
+
|
|
240
|
+
<!-- Body Content -->
|
|
241
|
+
{#if !isCollapsed}
|
|
242
|
+
<div
|
|
243
|
+
class={cn(
|
|
244
|
+
'flex-1',
|
|
245
|
+
ghost ? '' : (size === 'small' ? 'p-3' : 'p-4'),
|
|
246
|
+
split === 'vertical' && 'flex flex-row divide-x divide-border',
|
|
247
|
+
split === 'horizontal' && 'flex flex-col divide-y divide-border',
|
|
248
|
+
bodyClass
|
|
249
|
+
)}
|
|
250
|
+
>
|
|
251
|
+
{#if children}
|
|
252
|
+
{@render children()}
|
|
253
|
+
{/if}
|
|
254
|
+
</div>
|
|
255
|
+
|
|
256
|
+
{#if actions}
|
|
257
|
+
<div
|
|
258
|
+
class={cn(
|
|
259
|
+
'border-t border-border/60 bg-muted/20 flex items-center justify-end gap-2',
|
|
260
|
+
size === 'small' ? 'px-3 py-2' : 'px-4 py-2.5'
|
|
261
|
+
)}
|
|
262
|
+
>
|
|
263
|
+
{@render actions()}
|
|
264
|
+
</div>
|
|
265
|
+
{/if}
|
|
266
|
+
{/if}
|
|
267
|
+
</div>
|