@whity/ui 0.5.0 → 1.0.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/README.md +107 -107
- package/package.json +221 -192
- package/src/access-denied.stories.tsx +179 -179
- package/src/access-denied.tsx +305 -305
- package/src/action-proposal.tsx +338 -302
- package/src/actor-chip.tsx +71 -71
- package/src/agent-activity.tsx +163 -163
- package/src/agent-collaboration.stories.tsx +156 -156
- package/src/agent-run-status.tsx +196 -196
- package/src/alert-dialog.stories.tsx +45 -45
- package/src/alert-dialog.tsx +147 -147
- package/src/alert.stories.tsx +91 -91
- package/src/alert.tsx +89 -89
- package/src/app-sidebar.stories.tsx +195 -195
- package/src/app-sidebar.tsx +604 -500
- package/src/approval-queue.tsx +109 -108
- package/src/audience-group-picker.stories.tsx +198 -198
- package/src/audience-group-picker.tsx +362 -362
- package/src/audience-people-picker.stories.tsx +102 -102
- package/src/audience-people-picker.tsx +279 -279
- package/src/avatar-pattern.ts +138 -0
- package/src/avatar.tsx +125 -83
- package/src/badge.stories.tsx +105 -105
- package/src/badge.tsx +68 -68
- package/src/beta-warning.stories.tsx +79 -79
- package/src/beta-warning.tsx +189 -189
- package/src/bilingual-input.stories.tsx +82 -82
- package/src/bilingual-input.tsx +188 -183
- package/src/board.tsx +216 -0
- package/src/breadcrumb.stories.tsx +51 -51
- package/src/breadcrumb.tsx +90 -90
- package/src/built-on-whity.tsx +52 -0
- package/src/button.stories.tsx +87 -87
- package/src/button.tsx +123 -118
- package/src/card.stories.tsx +423 -423
- package/src/card.tsx +180 -180
- package/src/chart.stories.tsx +66 -66
- package/src/chart.tsx +228 -228
- package/src/checkbox.stories.tsx +62 -62
- package/src/checkbox.tsx +54 -54
- package/src/collapsible.stories.tsx +48 -48
- package/src/collapsible.tsx +34 -34
- package/src/color-card.stories.tsx +61 -61
- package/src/color-card.tsx +270 -270
- package/src/color-picker.stories.tsx +65 -65
- package/src/color-picker.tsx +425 -425
- package/src/column-matcher.tsx +84 -0
- package/src/command-palette.tsx +398 -306
- package/src/confirm-action.tsx +98 -0
- package/src/copy-block.stories.tsx +38 -38
- package/src/copy-block.tsx +85 -85
- package/src/data-table.stories.tsx +200 -200
- package/src/data-table.tsx +1686 -1106
- package/src/date-picker.stories.tsx +61 -61
- package/src/date-picker.tsx +456 -422
- package/src/design-cards.stories.tsx +551 -458
- package/src/dialog.stories.tsx +48 -48
- package/src/dialog.tsx +179 -166
- package/src/display-preferences.tsx +50 -0
- package/src/documents/barcode-svg.stories.tsx +72 -72
- package/src/documents/barcode-svg.tsx +79 -79
- package/src/dropdown-menu.stories.tsx +77 -77
- package/src/dropdown-menu.tsx +271 -271
- package/src/editor/agent-panel.tsx +222 -0
- package/src/editor/agents.stories.tsx +81 -0
- package/src/editor/agents.ts +55 -0
- package/src/editor/behaviour.ts +279 -279
- package/src/editor/block-ids.ts +44 -44
- package/src/editor/block-list.tsx +104 -101
- package/src/editor/block-toolbar.tsx +490 -477
- package/src/editor/bubble.tsx +119 -93
- package/src/editor/catalogue.ts +169 -103
- package/src/editor/collab-rail.tsx +746 -746
- package/src/editor/collab.stories.tsx +207 -207
- package/src/editor/collab.ts +87 -87
- package/src/editor/contract.ts +476 -408
- package/src/editor/convert.ts +414 -362
- package/src/editor/doc-editor.stories.tsx +98 -98
- package/src/editor/doc-editor.tsx +1492 -1287
- package/src/editor/editor.css +636 -536
- package/src/editor/extensions.ts +86 -86
- package/src/editor/field-bar.tsx +154 -0
- package/src/editor/field-picker.tsx +109 -107
- package/src/editor/fields.ts +100 -100
- package/src/editor/gutter.tsx +443 -367
- package/src/editor/index.ts +23 -22
- package/src/editor/label-sheet.tsx +289 -289
- package/src/editor/labels.ts +394 -310
- package/src/editor/link-tools.tsx +141 -141
- package/src/editor/node-views.tsx +461 -450
- package/src/editor/page-view.tsx +372 -353
- package/src/editor/phone.tsx +310 -0
- package/src/editor/plugin-block-view.tsx +230 -0
- package/src/editor/plugin-blocks.stories.tsx +96 -0
- package/src/editor/plugin-blocks.ts +52 -0
- package/src/editor/publish-check.tsx +201 -182
- package/src/editor/rich-blocks.stories.tsx +146 -146
- package/src/editor/sample.ts +40 -40
- package/src/editor/save-block-dialog.tsx +141 -0
- package/src/editor/saved-block-view.tsx +205 -0
- package/src/editor/saved-blocks.stories.tsx +105 -0
- package/src/editor/saved-parts.ts +192 -0
- package/src/editor/schema-rich.ts +156 -150
- package/src/editor/schema.ts +368 -315
- package/src/editor/services.tsx +205 -127
- package/src/editor/slash.ts +64 -64
- package/src/editor/suggesting.ts +372 -372
- package/src/editor/suggestions.ts +763 -763
- package/src/editor/table-keys.ts +66 -66
- package/src/editor/templates.stories.tsx +324 -324
- package/src/editor/toolbar.tsx +364 -358
- package/src/empty-state.stories.tsx +51 -51
- package/src/empty-state.tsx +126 -100
- package/src/empty-state.usage-notes.md +30 -30
- package/src/form.stories.tsx +112 -112
- package/src/form.tsx +176 -176
- package/src/globals.css +20 -20
- package/src/icon-button.tsx +85 -85
- package/src/icon-map.ts +335 -244
- package/src/icon.tsx +41 -41
- package/src/index.ts +90 -67
- package/src/input.stories.tsx +157 -157
- package/src/input.tsx +768 -759
- package/src/kpi-strip.tsx +47 -0
- package/src/localized-text.ts +76 -0
- package/src/locked-screen.stories.tsx +29 -29
- package/src/locked-screen.tsx +75 -61
- package/src/lockup.tsx +42 -0
- package/src/lottie.tsx +441 -0
- package/src/mark.tsx +62 -62
- package/src/math-text.stories.tsx +33 -33
- package/src/math-text.tsx +43 -43
- package/src/menu-bar.stories.tsx +198 -198
- package/src/menu-bar.tsx +373 -373
- package/src/message-thread.tsx +181 -0
- package/src/money/currency.ts +244 -230
- package/src/money/money-input.tsx +131 -0
- package/src/money/money.tsx +33 -0
- package/src/open-on-computer.tsx +150 -0
- package/src/otp-input.tsx +161 -0
- package/src/page-header.stories.tsx +95 -95
- package/src/page-header.tsx +122 -122
- package/src/page-shell.stories.tsx +42 -42
- package/src/page-shell.tsx +32 -32
- package/src/page-states.tsx +277 -0
- package/src/pagination.stories.tsx +45 -45
- package/src/pagination.tsx +98 -98
- package/src/paper-sheet.stories.tsx +88 -0
- package/src/paper-sheet.tsx +85 -0
- package/src/phone-tab-bar.tsx +152 -0
- package/src/plugin-card.stories.tsx +208 -180
- package/src/plugin-card.tsx +931 -848
- package/src/popover.stories.tsx +48 -48
- package/src/popover.tsx +55 -55
- package/src/radio-group.stories.tsx +26 -26
- package/src/radio-group.tsx +44 -44
- package/src/route-flow/editor.tsx +1087 -1014
- package/src/route-flow/model.ts +771 -716
- package/src/save-bar.tsx +94 -0
- package/src/scope-grant.tsx +139 -139
- package/src/screen-too-small.stories.tsx +61 -61
- package/src/screen-too-small.tsx +104 -104
- package/src/search-field.tsx +65 -0
- package/src/select.stories.tsx +44 -44
- package/src/select.tsx +197 -197
- package/src/separator.stories.tsx +34 -34
- package/src/separator.tsx +34 -34
- package/src/sheet.stories.tsx +49 -49
- package/src/sheet.tsx +168 -168
- package/src/skeleton.stories.tsx +28 -28
- package/src/skeleton.tsx +19 -19
- package/src/slider.stories.tsx +78 -78
- package/src/slider.tsx +300 -300
- package/src/spinner.stories.tsx +33 -33
- package/src/spinner.tsx +55 -55
- package/src/stepper.tsx +85 -0
- package/src/switch.stories.tsx +42 -42
- package/src/switch.tsx +41 -41
- package/src/switcher.stories.tsx +111 -111
- package/src/switcher.tsx +131 -131
- package/src/system-state.tsx +55 -0
- package/src/table.stories.tsx +48 -48
- package/src/table.tsx +121 -121
- package/src/tabs.stories.tsx +74 -74
- package/src/tabs.tsx +90 -90
- package/src/tag-input.stories.tsx +67 -67
- package/src/tag-input.tsx +117 -117
- package/src/tenant-logo.tsx +63 -63
- package/src/tenant-switcher.stories.tsx +38 -38
- package/src/tenant-switcher.tsx +164 -164
- package/src/textarea.stories.tsx +27 -27
- package/src/textarea.tsx +18 -18
- package/src/theme-mode.ts +52 -52
- package/src/time-grid.tsx +163 -0
- package/src/time-picker.stories.tsx +62 -62
- package/src/time-picker.tsx +615 -615
- package/src/toggle-group.tsx +138 -138
- package/src/tooltip.stories.tsx +43 -43
- package/src/tooltip.tsx +73 -73
- package/src/top-nav.stories.tsx +58 -58
- package/src/top-nav.tsx +324 -324
- package/src/undo-bar.tsx +107 -107
- package/src/utils.ts +45 -45
- package/src/view-toggle.stories.tsx +84 -84
- package/src/view-toggle.tsx +110 -110
package/src/plugin-card.tsx
CHANGED
|
@@ -1,848 +1,931 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import {
|
|
5
|
-
IconAlertCircle,
|
|
6
|
-
IconArrowBackUp,
|
|
7
|
-
IconCheck,
|
|
8
|
-
IconChevronLeft,
|
|
9
|
-
IconChevronRight,
|
|
10
|
-
IconDownload,
|
|
11
|
-
IconHistory,
|
|
12
|
-
IconInfoCircle,
|
|
13
|
-
IconLock,
|
|
14
|
-
IconPhoto,
|
|
15
|
-
IconPower,
|
|
16
|
-
IconPuzzle,
|
|
17
|
-
IconRefresh,
|
|
18
|
-
IconSettings,
|
|
19
|
-
IconShieldCheck,
|
|
20
|
-
IconStarFilled,
|
|
21
|
-
} from "@tabler/icons-react"
|
|
22
|
-
|
|
23
|
-
import { cn } from "./utils"
|
|
24
|
-
import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter } from "./card"
|
|
25
|
-
import { Button } from "./button"
|
|
26
|
-
import { Badge } from "./badge"
|
|
27
|
-
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./dialog"
|
|
28
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./dropdown-menu"
|
|
29
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs"
|
|
30
|
-
|
|
31
|
-
export type InstalledPluginState = "active" | "inactive" | "disabled" | "update-available"
|
|
32
|
-
|
|
33
|
-
export interface PluginVersion {
|
|
34
|
-
version: string
|
|
35
|
-
/**
|
|
36
|
-
* When this version was released, ALREADY as display text — or omitted to
|
|
37
|
-
* show nothing beside the version number.
|
|
38
|
-
*
|
|
39
|
-
* A LABEL and not a timestamp, which is what it has always actually been:
|
|
40
|
-
* the callers that exist pass "Current (Installed)" and "2 weeks ago", not
|
|
41
|
-
* an ISO string, and this component printed whatever it was given verbatim.
|
|
42
|
-
* The name said otherwise, and a name that says "timestamp" over a field that
|
|
43
|
-
* is really display text is how an unformatted `2026-08-25 14:02:11` ends up
|
|
44
|
-
* on a screen.
|
|
45
|
-
*
|
|
46
|
-
* It stays a label because this package cannot do better. `@whity/ui` is
|
|
47
|
-
* a design system: it has no access to the reader's resolved language and none
|
|
48
|
-
* to the tenant's `ui.hide_dates` preference (#1068), both of which live in
|
|
49
|
-
* `@whity/features`, which depends on THIS package and not the other way
|
|
50
|
-
* round. So the caller formats — through `useDateDisplay()`, the one
|
|
51
|
-
* sanctioned path — and omits this when that path returns null.
|
|
52
|
-
*/
|
|
53
|
-
releasedLabel?: string
|
|
54
|
-
changelog?: string
|
|
55
|
-
isCurrent?: boolean
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface PluginItem {
|
|
59
|
-
id: string
|
|
60
|
-
name: string
|
|
61
|
-
author: string
|
|
62
|
-
version: string
|
|
63
|
-
latestVersion?: string
|
|
64
|
-
description: string
|
|
65
|
-
longDescription?: string
|
|
66
|
-
category: string
|
|
67
|
-
rating: number
|
|
68
|
-
reviewCount: number
|
|
69
|
-
icon?: React.ReactNode
|
|
70
|
-
bannerUrl?: string
|
|
71
|
-
bannerGradient?: string
|
|
72
|
-
screenshots?: string[]
|
|
73
|
-
state?: InstalledPluginState
|
|
74
|
-
verified?: boolean
|
|
75
|
-
permissions?: string[]
|
|
76
|
-
versions?: PluginVersion[]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Copy for the plugin cards and their details/rollback dialogs.
|
|
81
|
-
*
|
|
82
|
-
* Every entry defaults to the English it replaced, so a caller that passes
|
|
83
|
-
* nothing renders exactly as before. `rollbackConfirmation` returns a NODE
|
|
84
|
-
* because its default is one sentence with three emphasised values inside it —
|
|
85
|
-
* the plugin name and both versions. Splitting that into fixed fragments would
|
|
86
|
-
* freeze English word order around them, so the caller supplies the finished
|
|
87
|
-
* sentence (built with useRichTranslation if it wants).
|
|
88
|
-
*/
|
|
89
|
-
export interface PluginCardLabels {
|
|
90
|
-
verified?: string
|
|
91
|
-
moreInfo?: string
|
|
92
|
-
install?: string
|
|
93
|
-
details?: string
|
|
94
|
-
activate?: string
|
|
95
|
-
deactivate?: string
|
|
96
|
-
restricted?: string
|
|
97
|
-
active?: string
|
|
98
|
-
inactive?: string
|
|
99
|
-
disabledBySystem?: string
|
|
100
|
-
updateAvailable?: (latestVersion?: string) => string
|
|
101
|
-
governanceNotice?: string
|
|
102
|
-
rollback?: string
|
|
103
|
-
versionHistory?: string
|
|
104
|
-
configure?: string
|
|
105
|
-
confirmRollbackTitle?: string
|
|
106
|
-
rollbackConfirmation?: (pluginName: string, from: string, to: string) => React.ReactNode
|
|
107
|
-
cancel?: string
|
|
108
|
-
overview?: string
|
|
109
|
-
securityVerified?: string
|
|
110
|
-
close?: string
|
|
111
|
-
installPlugin?: string
|
|
112
|
-
previousScreenshot?: string
|
|
113
|
-
nextScreenshot?: string
|
|
114
|
-
noVersionHistory?: string
|
|
115
|
-
noPermissions?: string
|
|
116
|
-
permissionsUndeclared?: string
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const DEFAULT_PLUGIN_CARD_LABELS = {
|
|
120
|
-
verified: "Verified",
|
|
121
|
-
moreInfo: "More Info",
|
|
122
|
-
install: "Install",
|
|
123
|
-
details: "Details",
|
|
124
|
-
activate: "Activate",
|
|
125
|
-
deactivate: "Deactivate",
|
|
126
|
-
restricted: "Restricted",
|
|
127
|
-
active: "Active",
|
|
128
|
-
inactive: "Inactive",
|
|
129
|
-
disabledBySystem: "Disabled by System",
|
|
130
|
-
updateAvailable: (latestVersion?: string) => `Update Available v${latestVersion}`,
|
|
131
|
-
governanceNotice:
|
|
132
|
-
"This plugin has been automatically disabled by system governance due to security or compatibility policy.",
|
|
133
|
-
rollback: "Rollback",
|
|
134
|
-
versionHistory: "Version History",
|
|
135
|
-
configure: "Configure plugin",
|
|
136
|
-
confirmRollbackTitle: "Confirm Version Rollback",
|
|
137
|
-
rollbackConfirmation: (pluginName: string, from: string, to: string): React.ReactNode => (
|
|
138
|
-
<>
|
|
139
|
-
Are you sure you want to rollback <strong>{pluginName}</strong> from version{" "}
|
|
140
|
-
<strong>v{from}</strong> back to <strong>v{to}</strong>?
|
|
141
|
-
</>
|
|
142
|
-
),
|
|
143
|
-
cancel: "Cancel",
|
|
144
|
-
overview: "Overview",
|
|
145
|
-
securityVerified: "Security Verified",
|
|
146
|
-
close: "Close",
|
|
147
|
-
installPlugin: "Install Plugin",
|
|
148
|
-
previousScreenshot: "Previous screenshot",
|
|
149
|
-
nextScreenshot: "Next screenshot",
|
|
150
|
-
noVersionHistory: "No version history available.",
|
|
151
|
-
noPermissions: "This plugin does not request any special permissions.",
|
|
152
|
-
permissionsUndeclared: "This plugin has not declared which system permissions it requests.",
|
|
153
|
-
} satisfies Required<PluginCardLabels>
|
|
154
|
-
|
|
155
|
-
export interface PluginStoreCardProps extends React.ComponentProps<"div"> {
|
|
156
|
-
plugin: PluginItem
|
|
157
|
-
onInstall?: (plugin: PluginItem) => void
|
|
158
|
-
onConfigure?: (plugin: PluginItem) => void
|
|
159
|
-
labels?: PluginCardLabels
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Real-Store Marketplace Card with Store Banner Preview image, clean borderless icon,
|
|
164
|
-
* rating stars positioned above title using neutral tones, quick install action, and "More Info" details dialog.
|
|
165
|
-
*/
|
|
166
|
-
export function PluginStoreCard({
|
|
167
|
-
className,
|
|
168
|
-
plugin,
|
|
169
|
-
onInstall,
|
|
170
|
-
onConfigure,
|
|
171
|
-
labels,
|
|
172
|
-
...props
|
|
173
|
-
}: PluginStoreCardProps) {
|
|
174
|
-
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
175
|
-
const [detailsOpen, setDetailsOpen] = React.useState(false)
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<>
|
|
179
|
-
<Card
|
|
180
|
-
interactive
|
|
181
|
-
variant="elevated"
|
|
182
|
-
className={cn("group/plugin flex flex-col justify-between w-full transition-all overflow-hidden", className)}
|
|
183
|
-
{...props}
|
|
184
|
-
>
|
|
185
|
-
{/* Real-Store Banner Preview Image Header (data-slot=card-banner removes top card padding for flush alignment) */}
|
|
186
|
-
<div data-slot="card-banner" className="relative h-32 w-full overflow-hidden border-b border-border/40 bg-muted">
|
|
187
|
-
{plugin.bannerUrl ? (
|
|
188
|
-
<img
|
|
189
|
-
src={plugin.bannerUrl}
|
|
190
|
-
alt={plugin.name}
|
|
191
|
-
className="size-full object-cover transition-transform duration-300 group-hover/plugin:scale-105"
|
|
192
|
-
/>
|
|
193
|
-
) : (
|
|
194
|
-
<div
|
|
195
|
-
className={cn(
|
|
196
|
-
"size-full flex items-center justify-center bg-linear-to-br transition-all duration-300 group-hover/plugin:scale-105 p-4 text-center",
|
|
197
|
-
plugin.bannerGradient ?? "from-primary/20 via-muted to-muted/80"
|
|
198
|
-
)}
|
|
199
|
-
>
|
|
200
|
-
<div className="flex items-center gap-2 text-foreground/40 font-heading font-semibold text-xs uppercase tracking-widest">
|
|
201
|
-
<IconPhoto className="size-4" />
|
|
202
|
-
<span>{plugin.category} Store Preview</span>
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
)}
|
|
206
|
-
|
|
207
|
-
{plugin.verified && (
|
|
208
|
-
<div className="absolute top-2.5 right-2.5">
|
|
209
|
-
<Badge variant="default" className="text-
|
|
210
|
-
{text.verified}
|
|
211
|
-
</Badge>
|
|
212
|
-
</div>
|
|
213
|
-
)}
|
|
214
|
-
</div>
|
|
215
|
-
|
|
216
|
-
<CardHeader className="pt-3 space-y-1.5">
|
|
217
|
-
{/* Rating Stars ABOVE Plugin Title in Color Neutral Styling */}
|
|
218
|
-
<div className="flex items-center gap-1.5 text-
|
|
219
|
-
<IconStarFilled className="size-3.5 text-muted-foreground/60" />
|
|
220
|
-
<span className="font-semibold text-foreground">{plugin.rating.toFixed(1)}</span>
|
|
221
|
-
<span className="text-
|
|
222
|
-
</div>
|
|
223
|
-
|
|
224
|
-
<div className="flex items-center gap-3">
|
|
225
|
-
{/* Clean Plugin Icon without bubble container */}
|
|
226
|
-
<div className="shrink-0 text-primary [&_svg]:size-6">
|
|
227
|
-
{plugin.icon ?? <IconPuzzle />}
|
|
228
|
-
</div>
|
|
229
|
-
<div className="min-w-0 flex-1">
|
|
230
|
-
<CardTitle className="text-sm font-semibold truncate">{plugin.name}</CardTitle>
|
|
231
|
-
<CardDescription className="text-xs truncate">
|
|
232
|
-
by {plugin.author} · v{plugin.version}
|
|
233
|
-
</CardDescription>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
</CardHeader>
|
|
237
|
-
|
|
238
|
-
<CardContent className="space-y-3">
|
|
239
|
-
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
|
240
|
-
{plugin.description}
|
|
241
|
-
</p>
|
|
242
|
-
|
|
243
|
-
<div className="flex items-center gap-2">
|
|
244
|
-
<Badge variant="outline" className="text-
|
|
245
|
-
</div>
|
|
246
|
-
</CardContent>
|
|
247
|
-
|
|
248
|
-
<CardFooter className="border-t border-border/40 pt-3 flex items-center justify-between gap-2">
|
|
249
|
-
<Button
|
|
250
|
-
size="sm"
|
|
251
|
-
variant="ghost"
|
|
252
|
-
onClick={() => setDetailsOpen(true)}
|
|
253
|
-
className="text-xs text-muted-foreground hover:text-foreground"
|
|
254
|
-
>
|
|
255
|
-
<IconInfoCircle data-icon="inline-start" />
|
|
256
|
-
{text.moreInfo}
|
|
257
|
-
</Button>
|
|
258
|
-
|
|
259
|
-
<Button
|
|
260
|
-
size="sm"
|
|
261
|
-
variant="default"
|
|
262
|
-
onClick={() => onInstall?.(plugin)}
|
|
263
|
-
>
|
|
264
|
-
<IconDownload data-icon="inline-start" />
|
|
265
|
-
{text.install}
|
|
266
|
-
</Button>
|
|
267
|
-
</CardFooter>
|
|
268
|
-
</Card>
|
|
269
|
-
|
|
270
|
-
{/* Plugin Details Popup Modal */}
|
|
271
|
-
<PluginDetailsModal
|
|
272
|
-
open={detailsOpen}
|
|
273
|
-
onOpenChange={setDetailsOpen}
|
|
274
|
-
plugin={plugin}
|
|
275
|
-
onInstall={onInstall}
|
|
276
|
-
labels={labels}
|
|
277
|
-
/>
|
|
278
|
-
</>
|
|
279
|
-
)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export interface InstalledPluginCardProps extends React.ComponentProps<"div"> {
|
|
283
|
-
plugin: PluginItem
|
|
284
|
-
onToggleState?: (plugin: PluginItem, newState: "active" | "inactive") => void
|
|
285
|
-
onUpdate?: (plugin: PluginItem) => void
|
|
286
|
-
onRollback?: (plugin: PluginItem, targetVersion: string) => void
|
|
287
|
-
onConfigure?: (plugin: PluginItem) => void
|
|
288
|
-
/**
|
|
289
|
-
* Copy for the card's chrome. Each entry defaults to the English below, so
|
|
290
|
-
* an untranslated caller renders exactly as it does today.
|
|
291
|
-
*
|
|
292
|
-
* `updateAvailable` is a function because the version number sits inside
|
|
293
|
-
* the phrase and languages place it differently.
|
|
294
|
-
*/
|
|
295
|
-
labels?: PluginCardLabels
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Management Card for installed plugins with toned-down background colors, clean borderless icons (no bubble container),
|
|
300
|
-
* semantic state badges using our design system's official blue (`info-solid`), and version rollback capability.
|
|
301
|
-
*/
|
|
302
|
-
export function InstalledPluginCard({
|
|
303
|
-
className,
|
|
304
|
-
plugin,
|
|
305
|
-
onToggleState,
|
|
306
|
-
onUpdate,
|
|
307
|
-
onRollback,
|
|
308
|
-
onConfigure,
|
|
309
|
-
labels,
|
|
310
|
-
...props
|
|
311
|
-
}: InstalledPluginCardProps) {
|
|
312
|
-
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
313
|
-
const [detailsOpen, setDetailsOpen] = React.useState(false)
|
|
314
|
-
const [rollbackTarget, setRollbackTarget] = React.useState<string | null>(null)
|
|
315
|
-
|
|
316
|
-
const state = plugin.state ?? "active"
|
|
317
|
-
|
|
318
|
-
const stateConfig = {
|
|
319
|
-
active: {
|
|
320
|
-
cardVariant: "success" as const,
|
|
321
|
-
borderStyle: "solid" as const,
|
|
322
|
-
badge: <Badge variant="success">{text.active}</Badge>,
|
|
323
|
-
disabled: false,
|
|
324
|
-
},
|
|
325
|
-
inactive: {
|
|
326
|
-
cardVariant: "flat" as const,
|
|
327
|
-
borderStyle: "solid" as const,
|
|
328
|
-
badge: <Badge variant="secondary">{text.inactive}</Badge>,
|
|
329
|
-
disabled: false,
|
|
330
|
-
},
|
|
331
|
-
disabled: {
|
|
332
|
-
cardVariant: "destructive" as const,
|
|
333
|
-
borderStyle: "dotted" as const,
|
|
334
|
-
badge: <Badge variant="destructive">{text.disabledBySystem}</Badge>,
|
|
335
|
-
disabled: true,
|
|
336
|
-
},
|
|
337
|
-
"update-available": {
|
|
338
|
-
cardVariant: "info" as const,
|
|
339
|
-
borderStyle: "solid" as const,
|
|
340
|
-
badge: <Badge variant="info">{text.updateAvailable(plugin.latestVersion)}</Badge>,
|
|
341
|
-
disabled: false,
|
|
342
|
-
},
|
|
343
|
-
}[state]
|
|
344
|
-
|
|
345
|
-
// No fallback (#756). Offering a rollback target the plugin never published
|
|
346
|
-
// is an action the host cannot honour, so an absent history has to REMOVE the
|
|
347
|
-
// affordance rather than populate it with plausible-looking version numbers.
|
|
348
|
-
const pastVersions = (plugin.versions ?? []).filter(
|
|
349
|
-
(v) => !v.isCurrent && v.version !== plugin.version
|
|
350
|
-
)
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<>
|
|
354
|
-
<Card
|
|
355
|
-
variant={stateConfig.cardVariant}
|
|
356
|
-
borderStyle={stateConfig.borderStyle}
|
|
357
|
-
disabled={stateConfig.disabled}
|
|
358
|
-
className={cn("group/installed flex flex-col justify-between w-full transition-all", className)}
|
|
359
|
-
{...props}
|
|
360
|
-
>
|
|
361
|
-
<CardHeader>
|
|
362
|
-
<div className="flex items-center gap-3">
|
|
363
|
-
{/* Completely Clean Plugin Icon without notification or status bubble overlay */}
|
|
364
|
-
<div className="shrink-0 text-foreground [&_svg]:size-6">
|
|
365
|
-
{plugin.icon ?? <IconPuzzle />}
|
|
366
|
-
</div>
|
|
367
|
-
<div className="min-w-0 flex-1">
|
|
368
|
-
<CardTitle className="text-sm font-semibold truncate">{plugin.name}</CardTitle>
|
|
369
|
-
<CardDescription className="text-xs truncate">
|
|
370
|
-
Installed v{plugin.version} · by {plugin.author}
|
|
371
|
-
</CardDescription>
|
|
372
|
-
</div>
|
|
373
|
-
</div>
|
|
374
|
-
<CardAction>{stateConfig.badge}</CardAction>
|
|
375
|
-
</CardHeader>
|
|
376
|
-
|
|
377
|
-
<CardContent className="space-y-3">
|
|
378
|
-
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
|
379
|
-
{state === "disabled"
|
|
380
|
-
? text.governanceNotice
|
|
381
|
-
: plugin.description}
|
|
382
|
-
</p>
|
|
383
|
-
|
|
384
|
-
<div className="flex flex-wrap items-center gap-2">
|
|
385
|
-
<Badge variant="outline" className="text-
|
|
386
|
-
|
|
387
|
-
{/* Version Rollback Dropdown */}
|
|
388
|
-
{pastVersions.length > 0 && !stateConfig.disabled && (
|
|
389
|
-
<DropdownMenu>
|
|
390
|
-
<DropdownMenuTrigger asChild>
|
|
391
|
-
<Button size="xs" variant="outline" className="ms-auto text-
|
|
392
|
-
<IconHistory className="size-3" />
|
|
393
|
-
<span>{text.rollback}</span>
|
|
394
|
-
</Button>
|
|
395
|
-
</DropdownMenuTrigger>
|
|
396
|
-
<DropdownMenuContent align="end" className="w-56">
|
|
397
|
-
<DropdownMenuLabel className="text-xs">{text.versionHistory}</DropdownMenuLabel>
|
|
398
|
-
<DropdownMenuSeparator />
|
|
399
|
-
{pastVersions.map((ver) => (
|
|
400
|
-
<DropdownMenuItem
|
|
401
|
-
key={ver.version}
|
|
402
|
-
onClick={() => setRollbackTarget(ver.version)}
|
|
403
|
-
className="flex items-center justify-between text-xs cursor-pointer"
|
|
404
|
-
>
|
|
405
|
-
<div className="flex items-center gap-2">
|
|
406
|
-
<IconArrowBackUp className="size-3.5 text-muted-foreground" />
|
|
407
|
-
<span className="font-semibold">v{ver.version}</span>
|
|
408
|
-
</div>
|
|
409
|
-
{ver.releasedLabel !== undefined && (
|
|
410
|
-
<span className="text-
|
|
411
|
-
)}
|
|
412
|
-
</DropdownMenuItem>
|
|
413
|
-
))}
|
|
414
|
-
</DropdownMenuContent>
|
|
415
|
-
</DropdownMenu>
|
|
416
|
-
)}
|
|
417
|
-
</div>
|
|
418
|
-
</CardContent>
|
|
419
|
-
|
|
420
|
-
<CardFooter className="border-t border-border/40 pt-3 flex items-center justify-between gap-2">
|
|
421
|
-
<Button
|
|
422
|
-
size="sm"
|
|
423
|
-
variant="ghost"
|
|
424
|
-
onClick={() => setDetailsOpen(true)}
|
|
425
|
-
className="text-xs text-muted-foreground hover:text-foreground"
|
|
426
|
-
>
|
|
427
|
-
<IconInfoCircle data-icon="inline-start" />
|
|
428
|
-
{text.details}
|
|
429
|
-
</Button>
|
|
430
|
-
|
|
431
|
-
<div className="flex items-center gap-2">
|
|
432
|
-
{state === "update-available" && (
|
|
433
|
-
<Button
|
|
434
|
-
size="sm"
|
|
435
|
-
variant="outline"
|
|
436
|
-
onClick={() => onUpdate?.(plugin)}
|
|
437
|
-
>
|
|
438
|
-
<IconRefresh data-icon="inline-start" />
|
|
439
|
-
Update v{plugin.latestVersion}
|
|
440
|
-
</Button>
|
|
441
|
-
)}
|
|
442
|
-
|
|
443
|
-
{state === "active" && (
|
|
444
|
-
<Button
|
|
445
|
-
size="sm"
|
|
446
|
-
variant="outline"
|
|
447
|
-
onClick={() => onToggleState?.(plugin, "inactive")}
|
|
448
|
-
>
|
|
449
|
-
<IconPower data-icon="inline-start" />
|
|
450
|
-
{text.deactivate}
|
|
451
|
-
</Button>
|
|
452
|
-
)}
|
|
453
|
-
|
|
454
|
-
{state === "inactive" && (
|
|
455
|
-
<Button
|
|
456
|
-
size="sm"
|
|
457
|
-
variant="outline"
|
|
458
|
-
onClick={() => onToggleState?.(plugin, "active")}
|
|
459
|
-
>
|
|
460
|
-
<IconCheck data-icon="inline-start" />
|
|
461
|
-
{text.activate}
|
|
462
|
-
</Button>
|
|
463
|
-
)}
|
|
464
|
-
|
|
465
|
-
{state === "disabled" && (
|
|
466
|
-
<Button size="sm" variant="outline" disabled>
|
|
467
|
-
<IconLock data-icon="inline-start" />
|
|
468
|
-
{text.restricted}
|
|
469
|
-
</Button>
|
|
470
|
-
)}
|
|
471
|
-
|
|
472
|
-
{onConfigure && !stateConfig.disabled && (
|
|
473
|
-
<Button
|
|
474
|
-
size="icon-xs"
|
|
475
|
-
variant="outline"
|
|
476
|
-
onClick={() => onConfigure(plugin)}
|
|
477
|
-
aria-label={text.configure}
|
|
478
|
-
>
|
|
479
|
-
<IconSettings />
|
|
480
|
-
</Button>
|
|
481
|
-
)}
|
|
482
|
-
</div>
|
|
483
|
-
</CardFooter>
|
|
484
|
-
</Card>
|
|
485
|
-
|
|
486
|
-
{/* Plugin Details Popup Modal */}
|
|
487
|
-
<PluginDetailsModal
|
|
488
|
-
open={detailsOpen}
|
|
489
|
-
onOpenChange={setDetailsOpen}
|
|
490
|
-
plugin={plugin}
|
|
491
|
-
installed
|
|
492
|
-
labels={labels}
|
|
493
|
-
/>
|
|
494
|
-
|
|
495
|
-
{/* Rollback Confirmation Modal */}
|
|
496
|
-
{rollbackTarget && (
|
|
497
|
-
<Dialog open={Boolean(rollbackTarget)} onOpenChange={(open) => !open && setRollbackTarget(null)}>
|
|
498
|
-
<DialogContent className="sm:max-w-md">
|
|
499
|
-
<DialogHeader>
|
|
500
|
-
<DialogTitle className="flex items-center gap-2 text-base">
|
|
501
|
-
<IconArrowBackUp className="size-5 text-
|
|
502
|
-
{text.confirmRollbackTitle}
|
|
503
|
-
</DialogTitle>
|
|
504
|
-
<DialogDescription className="text-xs">
|
|
505
|
-
{text.rollbackConfirmation(plugin.name, plugin.version, rollbackTarget)}
|
|
506
|
-
</DialogDescription>
|
|
507
|
-
</DialogHeader>
|
|
508
|
-
|
|
509
|
-
<div className="rounded-lg bg-
|
|
510
|
-
<div className="font-semibold flex items-center gap-1.5">
|
|
511
|
-
<IconAlertCircle className="size-4 shrink-0" />
|
|
512
|
-
Warning: Version Degradation
|
|
513
|
-
</div>
|
|
514
|
-
<p className="text-
|
|
515
|
-
Rolling back to v{rollbackTarget} will restore legacy schemas and configuration defaults. Ensure any data migration backups are complete.
|
|
516
|
-
</p>
|
|
517
|
-
</div>
|
|
518
|
-
|
|
519
|
-
<DialogFooter className="gap-2 sm:gap-0">
|
|
520
|
-
<Button variant="outline" onClick={() => setRollbackTarget(null)}>
|
|
521
|
-
{text.cancel}
|
|
522
|
-
</Button>
|
|
523
|
-
<Button
|
|
524
|
-
variant="default"
|
|
525
|
-
onClick={() => {
|
|
526
|
-
if (rollbackTarget) {
|
|
527
|
-
onRollback?.(plugin, rollbackTarget)
|
|
528
|
-
setRollbackTarget(null)
|
|
529
|
-
}
|
|
530
|
-
}}
|
|
531
|
-
>
|
|
532
|
-
<IconArrowBackUp data-icon="inline-start" />
|
|
533
|
-
Rollback to v{rollbackTarget}
|
|
534
|
-
</Button>
|
|
535
|
-
</DialogFooter>
|
|
536
|
-
</DialogContent>
|
|
537
|
-
</Dialog>
|
|
538
|
-
)}
|
|
539
|
-
</>
|
|
540
|
-
)
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
interface PluginDetailsModalProps {
|
|
544
|
-
open: boolean
|
|
545
|
-
onOpenChange: (open: boolean) => void
|
|
546
|
-
plugin: PluginItem
|
|
547
|
-
installed?: boolean
|
|
548
|
-
onInstall?: (plugin: PluginItem) => void
|
|
549
|
-
labels?: PluginCardLabels
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
function PluginDetailsModal({
|
|
553
|
-
open,
|
|
554
|
-
onOpenChange,
|
|
555
|
-
plugin,
|
|
556
|
-
installed = false,
|
|
557
|
-
onInstall,
|
|
558
|
-
labels,
|
|
559
|
-
}: PluginDetailsModalProps) {
|
|
560
|
-
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
561
|
-
// Both of these are OPTIONAL on PluginItem, so their old sample-array
|
|
562
|
-
// fallbacks were the DEFAULT rendering, not a defensive branch — this modal
|
|
563
|
-
// stated release numbers, dates, a changelog and a permission set that
|
|
564
|
-
// belonged to no plugin, in the screen where someone decides whether to
|
|
565
|
-
// install third-party code. Empty is the only honest answer; the tabs below
|
|
566
|
-
// say so explicitly rather than rendering an unexplained blank. (#756)
|
|
567
|
-
const versions = plugin.versions ?? []
|
|
568
|
-
// Deliberately NOT defaulted to [] alongside `versions`: for permissions the
|
|
569
|
-
// two are different statements. An empty array is the plugin saying it asks
|
|
570
|
-
// for nothing; `undefined` is nobody having told us what it asks for, and
|
|
571
|
-
// answering that with "does not request any special permissions" is a
|
|
572
|
-
// reassurance about third-party code that nobody actually made — the same
|
|
573
|
-
// class of invention as the sample array it replaced, only in the safe
|
|
574
|
-
// direction. The tab below says which of the two it has.
|
|
575
|
-
const permissions = plugin.permissions
|
|
576
|
-
|
|
577
|
-
return (
|
|
578
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
579
|
-
<DialogContent className="sm:max-w-xl">
|
|
580
|
-
<DialogHeader className="border-b border-border/40 pb-4">
|
|
581
|
-
<div className="flex items-center gap-3.5">
|
|
582
|
-
<div className="text-foreground shrink-0 [&_svg]:size-8 text-primary">
|
|
583
|
-
{plugin.icon ?? <IconPuzzle />}
|
|
584
|
-
</div>
|
|
585
|
-
<div>
|
|
586
|
-
<DialogTitle className="text-lg font-semibold flex items-center gap-2">
|
|
587
|
-
{plugin.name}
|
|
588
|
-
{plugin.verified && <Badge variant="default" className="text-
|
|
589
|
-
</DialogTitle>
|
|
590
|
-
<DialogDescription className="text-xs">
|
|
591
|
-
by {plugin.author} · Version v{plugin.version}
|
|
592
|
-
</DialogDescription>
|
|
593
|
-
</div>
|
|
594
|
-
</div>
|
|
595
|
-
</DialogHeader>
|
|
596
|
-
|
|
597
|
-
<Tabs defaultValue="overview" className="w-full text-xs">
|
|
598
|
-
<TabsList className="w-full justify-start border-b rounded-none bg-transparent p-0 h-9">
|
|
599
|
-
<TabsTrigger value="overview" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
600
|
-
{text.overview}
|
|
601
|
-
</TabsTrigger>
|
|
602
|
-
<TabsTrigger value="versions" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
603
|
-
Changelog & Versions
|
|
604
|
-
</TabsTrigger>
|
|
605
|
-
<TabsTrigger value="permissions" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
606
|
-
Permissions & Security
|
|
607
|
-
</TabsTrigger>
|
|
608
|
-
</TabsList>
|
|
609
|
-
|
|
610
|
-
<TabsContent value="overview" className="py-4 space-y-4">
|
|
611
|
-
<p className="text-xs text-muted-foreground leading-relaxed">
|
|
612
|
-
{plugin.longDescription ?? plugin.description}
|
|
613
|
-
</p>
|
|
614
|
-
|
|
615
|
-
{/* Interactive Image Gallery in More Info > Overview */}
|
|
616
|
-
<PluginImageGallery
|
|
617
|
-
screenshots={plugin.screenshots}
|
|
618
|
-
pluginName={plugin.name}
|
|
619
|
-
category={plugin.category}
|
|
620
|
-
bannerGradient={plugin.bannerGradient}
|
|
621
|
-
previousLabel={text.previousScreenshot}
|
|
622
|
-
nextLabel={text.nextScreenshot}
|
|
623
|
-
/>
|
|
624
|
-
|
|
625
|
-
<div className="flex flex-wrap items-center gap-3 pt-1">
|
|
626
|
-
<div className="flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/40 px-3 py-1.5 text-xs">
|
|
627
|
-
<IconStarFilled className="size-3.5 text-muted-foreground/70" />
|
|
628
|
-
<span className="font-semibold">{plugin.rating.toFixed(1)}</span>
|
|
629
|
-
<span className="text-muted-foreground">({plugin.reviewCount} reviews)</span>
|
|
630
|
-
</div>
|
|
631
|
-
<div className="flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/40 px-3 py-1.5 text-xs">
|
|
632
|
-
<IconShieldCheck className="size-3.5 text-
|
|
633
|
-
<span className="font-semibold">{text.securityVerified}</span>
|
|
634
|
-
</div>
|
|
635
|
-
</div>
|
|
636
|
-
</TabsContent>
|
|
637
|
-
|
|
638
|
-
<TabsContent value="versions" className="py-4 space-y-3">
|
|
639
|
-
<div className="space-y-2">
|
|
640
|
-
{versions.length === 0 && (
|
|
641
|
-
<p className="text-xs text-muted-foreground">{text.noVersionHistory}</p>
|
|
642
|
-
)}
|
|
643
|
-
{versions.map((ver) => (
|
|
644
|
-
<div key={ver.version} className="rounded-lg border border-border/60 bg-muted/20 p-3 space-y-1">
|
|
645
|
-
<div className="flex items-center justify-between">
|
|
646
|
-
<span className="font-semibold text-xs text-foreground">Version {ver.version}</span>
|
|
647
|
-
{ver.releasedLabel !== undefined && (
|
|
648
|
-
<span className="text-
|
|
649
|
-
)}
|
|
650
|
-
</div>
|
|
651
|
-
{ver.changelog && (
|
|
652
|
-
<p className="text-xs text-muted-foreground leading-relaxed">{ver.changelog}</p>
|
|
653
|
-
)}
|
|
654
|
-
</div>
|
|
655
|
-
))}
|
|
656
|
-
</div>
|
|
657
|
-
</TabsContent>
|
|
658
|
-
|
|
659
|
-
<TabsContent value="permissions" className="py-4 space-y-3">
|
|
660
|
-
<p className="text-xs text-muted-foreground">
|
|
661
|
-
{permissions === undefined
|
|
662
|
-
? text.permissionsUndeclared
|
|
663
|
-
: permissions.length === 0
|
|
664
|
-
? text.noPermissions
|
|
665
|
-
: "This plugin requests the following system permissions when activated:"}
|
|
666
|
-
</p>
|
|
667
|
-
<div className="space-y-1.5">
|
|
668
|
-
{(permissions ?? []).map((perm) => (
|
|
669
|
-
<div key={perm} className="flex items-center gap-2 rounded-md bg-muted/30 border border-border/40 px-2.5 py-1 text-xs font-mono">
|
|
670
|
-
<IconLock className="size-3.5 text-primary shrink-0" />
|
|
671
|
-
<span>{perm}</span>
|
|
672
|
-
</div>
|
|
673
|
-
))}
|
|
674
|
-
</div>
|
|
675
|
-
</TabsContent>
|
|
676
|
-
</Tabs>
|
|
677
|
-
|
|
678
|
-
<DialogFooter className="border-t border-border/40 pt-3 flex items-center justify-between">
|
|
679
|
-
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
680
|
-
{text.close}
|
|
681
|
-
</Button>
|
|
682
|
-
{!installed && (
|
|
683
|
-
<Button
|
|
684
|
-
variant="default"
|
|
685
|
-
onClick={() => {
|
|
686
|
-
onInstall?.(plugin)
|
|
687
|
-
onOpenChange(false)
|
|
688
|
-
}}
|
|
689
|
-
>
|
|
690
|
-
<IconDownload data-icon="inline-start" />
|
|
691
|
-
{text.installPlugin}
|
|
692
|
-
</Button>
|
|
693
|
-
)}
|
|
694
|
-
</DialogFooter>
|
|
695
|
-
</DialogContent>
|
|
696
|
-
</Dialog>
|
|
697
|
-
)
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
interface PluginImageGalleryProps {
|
|
701
|
-
screenshots?: string[]
|
|
702
|
-
pluginName: string
|
|
703
|
-
category: string
|
|
704
|
-
bannerGradient?: string
|
|
705
|
-
/** Accessible names for the gallery arrows. */
|
|
706
|
-
previousLabel?: string
|
|
707
|
-
nextLabel?: string
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* One gallery slide: either a real screenshot, or — when the plugin ships none —
|
|
712
|
-
* a gradient placeholder standing in for a screenshot that does not exist yet.
|
|
713
|
-
* The two shapes carry different fields, so the variant is explicit rather than
|
|
714
|
-
* inferred from a truthy `url`.
|
|
715
|
-
*/
|
|
716
|
-
type PluginGalleryItem =
|
|
717
|
-
| { kind: "screenshot"; title: string; url: string }
|
|
718
|
-
| { kind: "placeholder"; title: string; label: string; gradient: string }
|
|
719
|
-
|
|
720
|
-
function PluginImageGallery({
|
|
721
|
-
screenshots,
|
|
722
|
-
pluginName,
|
|
723
|
-
category,
|
|
724
|
-
bannerGradient = "from-primary/20 via-muted to-muted/80",
|
|
725
|
-
previousLabel,
|
|
726
|
-
nextLabel,
|
|
727
|
-
}: PluginImageGalleryProps) {
|
|
728
|
-
const [activeIndex, setActiveIndex] = React.useState(0)
|
|
729
|
-
|
|
730
|
-
const items: PluginGalleryItem[] = screenshots && screenshots.length > 0
|
|
731
|
-
? screenshots.map((url, i) => ({
|
|
732
|
-
kind: "screenshot",
|
|
733
|
-
title: `${pluginName} Screenshot ${i + 1}`,
|
|
734
|
-
url,
|
|
735
|
-
}))
|
|
736
|
-
: [
|
|
737
|
-
{
|
|
738
|
-
kind: "placeholder",
|
|
739
|
-
title: "Main Interface View",
|
|
740
|
-
label: "Dashboard View",
|
|
741
|
-
gradient: bannerGradient,
|
|
742
|
-
},
|
|
743
|
-
{
|
|
744
|
-
kind: "placeholder",
|
|
745
|
-
title: "Configuration & Settings",
|
|
746
|
-
label: "Rule Engine Settings",
|
|
747
|
-
gradient: "from-
|
|
748
|
-
},
|
|
749
|
-
{
|
|
750
|
-
kind: "placeholder",
|
|
751
|
-
title: "Telemetry & Live Logs",
|
|
752
|
-
label: "Realtime Analytics",
|
|
753
|
-
gradient: "from-
|
|
754
|
-
},
|
|
755
|
-
]
|
|
756
|
-
|
|
757
|
-
const currentItem = items[activeIndex] || items[0]
|
|
758
|
-
|
|
759
|
-
return (
|
|
760
|
-
<div className="space-y-2">
|
|
761
|
-
<div className="flex items-center justify-between">
|
|
762
|
-
<span className="text-
|
|
763
|
-
Interface Gallery & Screenshots
|
|
764
|
-
</span>
|
|
765
|
-
<span className="text-
|
|
766
|
-
{activeIndex + 1} of {items.length}
|
|
767
|
-
</span>
|
|
768
|
-
</div>
|
|
769
|
-
|
|
770
|
-
{/* Main Preview Container */}
|
|
771
|
-
<div className="group/gallery relative h-48 w-full overflow-hidden rounded-xl border border-border/60 bg-muted">
|
|
772
|
-
{currentItem.kind === "screenshot" ? (
|
|
773
|
-
<img
|
|
774
|
-
src={currentItem.url}
|
|
775
|
-
alt={currentItem.title}
|
|
776
|
-
className="size-full object-cover transition-all duration-300"
|
|
777
|
-
/>
|
|
778
|
-
) : (
|
|
779
|
-
<div
|
|
780
|
-
className={cn(
|
|
781
|
-
"size-full flex flex-col items-center justify-center bg-linear-to-br p-6 text-center transition-all duration-300",
|
|
782
|
-
currentItem.gradient
|
|
783
|
-
)}
|
|
784
|
-
>
|
|
785
|
-
<IconPhoto className="size-8 text-foreground/40 mb-2" />
|
|
786
|
-
<span className="font-heading font-semibold text-sm text-foreground/90">
|
|
787
|
-
{currentItem.title}
|
|
788
|
-
</span>
|
|
789
|
-
<span className="text-xs text-muted-foreground mt-0.5">
|
|
790
|
-
{category} Module Preview · {currentItem.label}
|
|
791
|
-
</span>
|
|
792
|
-
</div>
|
|
793
|
-
)}
|
|
794
|
-
|
|
795
|
-
{/* Carousel Prev/Next Overlay Buttons */}
|
|
796
|
-
{items.length > 1 && (
|
|
797
|
-
<>
|
|
798
|
-
<button
|
|
799
|
-
type="button"
|
|
800
|
-
onClick={() => setActiveIndex((prev) => (prev > 0 ? prev - 1 : items.length - 1))}
|
|
801
|
-
className="absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-background/80 p-1.5 text-foreground backdrop-blur-xs opacity-0 transition-opacity group-hover/gallery:opacity-100 hover:bg-background shadow-xs"
|
|
802
|
-
aria-label={previousLabel}
|
|
803
|
-
>
|
|
804
|
-
<IconChevronLeft className="size-4" />
|
|
805
|
-
</button>
|
|
806
|
-
|
|
807
|
-
<button
|
|
808
|
-
type="button"
|
|
809
|
-
onClick={() => setActiveIndex((prev) => (prev < items.length - 1 ? prev + 1 : 0))}
|
|
810
|
-
className="absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-background/80 p-1.5 text-foreground backdrop-blur-xs opacity-0 transition-opacity group-hover/gallery:opacity-100 hover:bg-background shadow-xs"
|
|
811
|
-
aria-label={nextLabel}
|
|
812
|
-
>
|
|
813
|
-
<IconChevronRight className="size-4" />
|
|
814
|
-
</button>
|
|
815
|
-
</>
|
|
816
|
-
)}
|
|
817
|
-
</div>
|
|
818
|
-
|
|
819
|
-
{/* Thumbnail Selector Strip */}
|
|
820
|
-
{items.length > 1 && (
|
|
821
|
-
<div className="grid grid-cols-3 gap-2 pt-1">
|
|
822
|
-
{items.map((item, idx) => (
|
|
823
|
-
<button
|
|
824
|
-
key={idx}
|
|
825
|
-
type="button"
|
|
826
|
-
onClick={() => setActiveIndex(idx)}
|
|
827
|
-
className={cn(
|
|
828
|
-
"relative h-14 rounded-lg overflow-hidden border transition-all text-left p-2 flex flex-col justify-end",
|
|
829
|
-
activeIndex === idx
|
|
830
|
-
? "border-primary ring-2 ring-primary/40 shadow-xs"
|
|
831
|
-
: "border-border/50 opacity-70 hover:opacity-100 hover:border-border"
|
|
832
|
-
)}
|
|
833
|
-
>
|
|
834
|
-
{item.kind === "screenshot" ? (
|
|
835
|
-
<img src={item.url} alt={item.title} className="absolute inset-0 size-full object-cover" />
|
|
836
|
-
) : (
|
|
837
|
-
<div className={cn("absolute inset-0 bg-linear-to-br", item.gradient)} />
|
|
838
|
-
)}
|
|
839
|
-
<span className="relative z-10 text-
|
|
840
|
-
{item.kind === "placeholder" ? item.label : item.title}
|
|
841
|
-
</span>
|
|
842
|
-
</button>
|
|
843
|
-
))}
|
|
844
|
-
</div>
|
|
845
|
-
)}
|
|
846
|
-
</div>
|
|
847
|
-
)
|
|
848
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import {
|
|
5
|
+
IconAlertCircle,
|
|
6
|
+
IconArrowBackUp,
|
|
7
|
+
IconCheck,
|
|
8
|
+
IconChevronLeft,
|
|
9
|
+
IconChevronRight,
|
|
10
|
+
IconDownload,
|
|
11
|
+
IconHistory,
|
|
12
|
+
IconInfoCircle,
|
|
13
|
+
IconLock,
|
|
14
|
+
IconPhoto,
|
|
15
|
+
IconPower,
|
|
16
|
+
IconPuzzle,
|
|
17
|
+
IconRefresh,
|
|
18
|
+
IconSettings,
|
|
19
|
+
IconShieldCheck,
|
|
20
|
+
IconStarFilled,
|
|
21
|
+
} from "@tabler/icons-react"
|
|
22
|
+
|
|
23
|
+
import { cn } from "./utils"
|
|
24
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardAction, CardContent, CardFooter } from "./card"
|
|
25
|
+
import { Button } from "./button"
|
|
26
|
+
import { Badge } from "./badge"
|
|
27
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./dialog"
|
|
28
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./dropdown-menu"
|
|
29
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs"
|
|
30
|
+
|
|
31
|
+
export type InstalledPluginState = "active" | "inactive" | "disabled" | "update-available"
|
|
32
|
+
|
|
33
|
+
export interface PluginVersion {
|
|
34
|
+
version: string
|
|
35
|
+
/**
|
|
36
|
+
* When this version was released, ALREADY as display text — or omitted to
|
|
37
|
+
* show nothing beside the version number.
|
|
38
|
+
*
|
|
39
|
+
* A LABEL and not a timestamp, which is what it has always actually been:
|
|
40
|
+
* the callers that exist pass "Current (Installed)" and "2 weeks ago", not
|
|
41
|
+
* an ISO string, and this component printed whatever it was given verbatim.
|
|
42
|
+
* The name said otherwise, and a name that says "timestamp" over a field that
|
|
43
|
+
* is really display text is how an unformatted `2026-08-25 14:02:11` ends up
|
|
44
|
+
* on a screen.
|
|
45
|
+
*
|
|
46
|
+
* It stays a label because this package cannot do better. `@whity/ui` is
|
|
47
|
+
* a design system: it has no access to the reader's resolved language and none
|
|
48
|
+
* to the tenant's `ui.hide_dates` preference (#1068), both of which live in
|
|
49
|
+
* `@whity/features`, which depends on THIS package and not the other way
|
|
50
|
+
* round. So the caller formats — through `useDateDisplay()`, the one
|
|
51
|
+
* sanctioned path — and omits this when that path returns null.
|
|
52
|
+
*/
|
|
53
|
+
releasedLabel?: string
|
|
54
|
+
changelog?: string
|
|
55
|
+
isCurrent?: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface PluginItem {
|
|
59
|
+
id: string
|
|
60
|
+
name: string
|
|
61
|
+
author: string
|
|
62
|
+
version: string
|
|
63
|
+
latestVersion?: string
|
|
64
|
+
description: string
|
|
65
|
+
longDescription?: string
|
|
66
|
+
category: string
|
|
67
|
+
rating: number
|
|
68
|
+
reviewCount: number
|
|
69
|
+
icon?: React.ReactNode
|
|
70
|
+
bannerUrl?: string
|
|
71
|
+
bannerGradient?: string
|
|
72
|
+
screenshots?: string[]
|
|
73
|
+
state?: InstalledPluginState
|
|
74
|
+
verified?: boolean
|
|
75
|
+
permissions?: string[]
|
|
76
|
+
versions?: PluginVersion[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Copy for the plugin cards and their details/rollback dialogs.
|
|
81
|
+
*
|
|
82
|
+
* Every entry defaults to the English it replaced, so a caller that passes
|
|
83
|
+
* nothing renders exactly as before. `rollbackConfirmation` returns a NODE
|
|
84
|
+
* because its default is one sentence with three emphasised values inside it —
|
|
85
|
+
* the plugin name and both versions. Splitting that into fixed fragments would
|
|
86
|
+
* freeze English word order around them, so the caller supplies the finished
|
|
87
|
+
* sentence (built with useRichTranslation if it wants).
|
|
88
|
+
*/
|
|
89
|
+
export interface PluginCardLabels {
|
|
90
|
+
verified?: string
|
|
91
|
+
moreInfo?: string
|
|
92
|
+
install?: string
|
|
93
|
+
details?: string
|
|
94
|
+
activate?: string
|
|
95
|
+
deactivate?: string
|
|
96
|
+
restricted?: string
|
|
97
|
+
active?: string
|
|
98
|
+
inactive?: string
|
|
99
|
+
disabledBySystem?: string
|
|
100
|
+
updateAvailable?: (latestVersion?: string) => string
|
|
101
|
+
governanceNotice?: string
|
|
102
|
+
rollback?: string
|
|
103
|
+
versionHistory?: string
|
|
104
|
+
configure?: string
|
|
105
|
+
confirmRollbackTitle?: string
|
|
106
|
+
rollbackConfirmation?: (pluginName: string, from: string, to: string) => React.ReactNode
|
|
107
|
+
cancel?: string
|
|
108
|
+
overview?: string
|
|
109
|
+
securityVerified?: string
|
|
110
|
+
close?: string
|
|
111
|
+
installPlugin?: string
|
|
112
|
+
previousScreenshot?: string
|
|
113
|
+
nextScreenshot?: string
|
|
114
|
+
noVersionHistory?: string
|
|
115
|
+
noPermissions?: string
|
|
116
|
+
permissionsUndeclared?: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const DEFAULT_PLUGIN_CARD_LABELS = {
|
|
120
|
+
verified: "Verified",
|
|
121
|
+
moreInfo: "More Info",
|
|
122
|
+
install: "Install",
|
|
123
|
+
details: "Details",
|
|
124
|
+
activate: "Activate",
|
|
125
|
+
deactivate: "Deactivate",
|
|
126
|
+
restricted: "Restricted",
|
|
127
|
+
active: "Active",
|
|
128
|
+
inactive: "Inactive",
|
|
129
|
+
disabledBySystem: "Disabled by System",
|
|
130
|
+
updateAvailable: (latestVersion?: string) => `Update Available v${latestVersion}`,
|
|
131
|
+
governanceNotice:
|
|
132
|
+
"This plugin has been automatically disabled by system governance due to security or compatibility policy.",
|
|
133
|
+
rollback: "Rollback",
|
|
134
|
+
versionHistory: "Version History",
|
|
135
|
+
configure: "Configure plugin",
|
|
136
|
+
confirmRollbackTitle: "Confirm Version Rollback",
|
|
137
|
+
rollbackConfirmation: (pluginName: string, from: string, to: string): React.ReactNode => (
|
|
138
|
+
<>
|
|
139
|
+
Are you sure you want to rollback <strong>{pluginName}</strong> from version{" "}
|
|
140
|
+
<strong>v{from}</strong> back to <strong>v{to}</strong>?
|
|
141
|
+
</>
|
|
142
|
+
),
|
|
143
|
+
cancel: "Cancel",
|
|
144
|
+
overview: "Overview",
|
|
145
|
+
securityVerified: "Security Verified",
|
|
146
|
+
close: "Close",
|
|
147
|
+
installPlugin: "Install Plugin",
|
|
148
|
+
previousScreenshot: "Previous screenshot",
|
|
149
|
+
nextScreenshot: "Next screenshot",
|
|
150
|
+
noVersionHistory: "No version history available.",
|
|
151
|
+
noPermissions: "This plugin does not request any special permissions.",
|
|
152
|
+
permissionsUndeclared: "This plugin has not declared which system permissions it requests.",
|
|
153
|
+
} satisfies Required<PluginCardLabels>
|
|
154
|
+
|
|
155
|
+
export interface PluginStoreCardProps extends React.ComponentProps<"div"> {
|
|
156
|
+
plugin: PluginItem
|
|
157
|
+
onInstall?: (plugin: PluginItem) => void
|
|
158
|
+
onConfigure?: (plugin: PluginItem) => void
|
|
159
|
+
labels?: PluginCardLabels
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Real-Store Marketplace Card with Store Banner Preview image, clean borderless icon,
|
|
164
|
+
* rating stars positioned above title using neutral tones, quick install action, and "More Info" details dialog.
|
|
165
|
+
*/
|
|
166
|
+
export function PluginStoreCard({
|
|
167
|
+
className,
|
|
168
|
+
plugin,
|
|
169
|
+
onInstall,
|
|
170
|
+
onConfigure,
|
|
171
|
+
labels,
|
|
172
|
+
...props
|
|
173
|
+
}: PluginStoreCardProps) {
|
|
174
|
+
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
175
|
+
const [detailsOpen, setDetailsOpen] = React.useState(false)
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<>
|
|
179
|
+
<Card
|
|
180
|
+
interactive
|
|
181
|
+
variant="elevated"
|
|
182
|
+
className={cn("group/plugin flex flex-col justify-between w-full transition-all overflow-hidden", className)}
|
|
183
|
+
{...props}
|
|
184
|
+
>
|
|
185
|
+
{/* Real-Store Banner Preview Image Header (data-slot=card-banner removes top card padding for flush alignment) */}
|
|
186
|
+
<div data-slot="card-banner" className="relative h-32 w-full overflow-hidden border-b border-border/40 bg-muted">
|
|
187
|
+
{plugin.bannerUrl ? (
|
|
188
|
+
<img
|
|
189
|
+
src={plugin.bannerUrl}
|
|
190
|
+
alt={plugin.name}
|
|
191
|
+
className="size-full object-cover transition-transform duration-300 group-hover/plugin:scale-105"
|
|
192
|
+
/>
|
|
193
|
+
) : (
|
|
194
|
+
<div
|
|
195
|
+
className={cn(
|
|
196
|
+
"size-full flex items-center justify-center bg-linear-to-br transition-all duration-300 group-hover/plugin:scale-105 p-4 text-center",
|
|
197
|
+
plugin.bannerGradient ?? "from-primary/20 via-muted to-muted/80"
|
|
198
|
+
)}
|
|
199
|
+
>
|
|
200
|
+
<div className="flex items-center gap-2 text-foreground/40 font-heading font-semibold text-xs uppercase tracking-widest">
|
|
201
|
+
<IconPhoto className="size-4" />
|
|
202
|
+
<span>{plugin.category} Store Preview</span>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{plugin.verified && (
|
|
208
|
+
<div className="absolute top-2.5 right-2.5">
|
|
209
|
+
<Badge variant="default" className="text-xs shadow-xs">
|
|
210
|
+
{text.verified}
|
|
211
|
+
</Badge>
|
|
212
|
+
</div>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<CardHeader className="pt-3 space-y-1.5">
|
|
217
|
+
{/* Rating Stars ABOVE Plugin Title in Color Neutral Styling */}
|
|
218
|
+
<div className="flex items-center gap-1.5 text-xs font-medium text-muted-foreground/80">
|
|
219
|
+
<IconStarFilled className="size-3.5 text-muted-foreground/60" />
|
|
220
|
+
<span className="font-semibold text-foreground">{plugin.rating.toFixed(1)}</span>
|
|
221
|
+
<span className="text-xs text-muted-foreground/70">({plugin.reviewCount} reviews)</span>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div className="flex items-center gap-3">
|
|
225
|
+
{/* Clean Plugin Icon without bubble container */}
|
|
226
|
+
<div className="shrink-0 text-primary [&_svg]:size-6">
|
|
227
|
+
{plugin.icon ?? <IconPuzzle />}
|
|
228
|
+
</div>
|
|
229
|
+
<div className="min-w-0 flex-1">
|
|
230
|
+
<CardTitle className="text-sm font-semibold truncate">{plugin.name}</CardTitle>
|
|
231
|
+
<CardDescription className="text-xs truncate">
|
|
232
|
+
by {plugin.author} · v{plugin.version}
|
|
233
|
+
</CardDescription>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</CardHeader>
|
|
237
|
+
|
|
238
|
+
<CardContent className="space-y-3">
|
|
239
|
+
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
|
240
|
+
{plugin.description}
|
|
241
|
+
</p>
|
|
242
|
+
|
|
243
|
+
<div className="flex items-center gap-2">
|
|
244
|
+
<Badge variant="outline" className="text-xs">{plugin.category}</Badge>
|
|
245
|
+
</div>
|
|
246
|
+
</CardContent>
|
|
247
|
+
|
|
248
|
+
<CardFooter className="border-t border-border/40 pt-3 flex items-center justify-between gap-2">
|
|
249
|
+
<Button
|
|
250
|
+
size="sm"
|
|
251
|
+
variant="ghost"
|
|
252
|
+
onClick={() => setDetailsOpen(true)}
|
|
253
|
+
className="text-xs text-muted-foreground hover:text-foreground"
|
|
254
|
+
>
|
|
255
|
+
<IconInfoCircle data-icon="inline-start" />
|
|
256
|
+
{text.moreInfo}
|
|
257
|
+
</Button>
|
|
258
|
+
|
|
259
|
+
<Button
|
|
260
|
+
size="sm"
|
|
261
|
+
variant="default"
|
|
262
|
+
onClick={() => onInstall?.(plugin)}
|
|
263
|
+
>
|
|
264
|
+
<IconDownload data-icon="inline-start" />
|
|
265
|
+
{text.install}
|
|
266
|
+
</Button>
|
|
267
|
+
</CardFooter>
|
|
268
|
+
</Card>
|
|
269
|
+
|
|
270
|
+
{/* Plugin Details Popup Modal */}
|
|
271
|
+
<PluginDetailsModal
|
|
272
|
+
open={detailsOpen}
|
|
273
|
+
onOpenChange={setDetailsOpen}
|
|
274
|
+
plugin={plugin}
|
|
275
|
+
onInstall={onInstall}
|
|
276
|
+
labels={labels}
|
|
277
|
+
/>
|
|
278
|
+
</>
|
|
279
|
+
)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export interface InstalledPluginCardProps extends React.ComponentProps<"div"> {
|
|
283
|
+
plugin: PluginItem
|
|
284
|
+
onToggleState?: (plugin: PluginItem, newState: "active" | "inactive") => void
|
|
285
|
+
onUpdate?: (plugin: PluginItem) => void
|
|
286
|
+
onRollback?: (plugin: PluginItem, targetVersion: string) => void
|
|
287
|
+
onConfigure?: (plugin: PluginItem) => void
|
|
288
|
+
/**
|
|
289
|
+
* Copy for the card's chrome. Each entry defaults to the English below, so
|
|
290
|
+
* an untranslated caller renders exactly as it does today.
|
|
291
|
+
*
|
|
292
|
+
* `updateAvailable` is a function because the version number sits inside
|
|
293
|
+
* the phrase and languages place it differently.
|
|
294
|
+
*/
|
|
295
|
+
labels?: PluginCardLabels
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Management Card for installed plugins with toned-down background colors, clean borderless icons (no bubble container),
|
|
300
|
+
* semantic state badges using our design system's official blue (`info-solid`), and version rollback capability.
|
|
301
|
+
*/
|
|
302
|
+
export function InstalledPluginCard({
|
|
303
|
+
className,
|
|
304
|
+
plugin,
|
|
305
|
+
onToggleState,
|
|
306
|
+
onUpdate,
|
|
307
|
+
onRollback,
|
|
308
|
+
onConfigure,
|
|
309
|
+
labels,
|
|
310
|
+
...props
|
|
311
|
+
}: InstalledPluginCardProps) {
|
|
312
|
+
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
313
|
+
const [detailsOpen, setDetailsOpen] = React.useState(false)
|
|
314
|
+
const [rollbackTarget, setRollbackTarget] = React.useState<string | null>(null)
|
|
315
|
+
|
|
316
|
+
const state = plugin.state ?? "active"
|
|
317
|
+
|
|
318
|
+
const stateConfig = {
|
|
319
|
+
active: {
|
|
320
|
+
cardVariant: "success" as const,
|
|
321
|
+
borderStyle: "solid" as const,
|
|
322
|
+
badge: <Badge variant="success">{text.active}</Badge>,
|
|
323
|
+
disabled: false,
|
|
324
|
+
},
|
|
325
|
+
inactive: {
|
|
326
|
+
cardVariant: "flat" as const,
|
|
327
|
+
borderStyle: "solid" as const,
|
|
328
|
+
badge: <Badge variant="secondary">{text.inactive}</Badge>,
|
|
329
|
+
disabled: false,
|
|
330
|
+
},
|
|
331
|
+
disabled: {
|
|
332
|
+
cardVariant: "destructive" as const,
|
|
333
|
+
borderStyle: "dotted" as const,
|
|
334
|
+
badge: <Badge variant="destructive">{text.disabledBySystem}</Badge>,
|
|
335
|
+
disabled: true,
|
|
336
|
+
},
|
|
337
|
+
"update-available": {
|
|
338
|
+
cardVariant: "info" as const,
|
|
339
|
+
borderStyle: "solid" as const,
|
|
340
|
+
badge: <Badge variant="info">{text.updateAvailable(plugin.latestVersion)}</Badge>,
|
|
341
|
+
disabled: false,
|
|
342
|
+
},
|
|
343
|
+
}[state]
|
|
344
|
+
|
|
345
|
+
// No fallback (#756). Offering a rollback target the plugin never published
|
|
346
|
+
// is an action the host cannot honour, so an absent history has to REMOVE the
|
|
347
|
+
// affordance rather than populate it with plausible-looking version numbers.
|
|
348
|
+
const pastVersions = (plugin.versions ?? []).filter(
|
|
349
|
+
(v) => !v.isCurrent && v.version !== plugin.version
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
return (
|
|
353
|
+
<>
|
|
354
|
+
<Card
|
|
355
|
+
variant={stateConfig.cardVariant}
|
|
356
|
+
borderStyle={stateConfig.borderStyle}
|
|
357
|
+
disabled={stateConfig.disabled}
|
|
358
|
+
className={cn("group/installed flex flex-col justify-between w-full transition-all", className)}
|
|
359
|
+
{...props}
|
|
360
|
+
>
|
|
361
|
+
<CardHeader>
|
|
362
|
+
<div className="flex items-center gap-3">
|
|
363
|
+
{/* Completely Clean Plugin Icon without notification or status bubble overlay */}
|
|
364
|
+
<div className="shrink-0 text-foreground [&_svg]:size-6">
|
|
365
|
+
{plugin.icon ?? <IconPuzzle />}
|
|
366
|
+
</div>
|
|
367
|
+
<div className="min-w-0 flex-1">
|
|
368
|
+
<CardTitle className="text-sm font-semibold truncate">{plugin.name}</CardTitle>
|
|
369
|
+
<CardDescription className="text-xs truncate">
|
|
370
|
+
Installed v{plugin.version} · by {plugin.author}
|
|
371
|
+
</CardDescription>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
<CardAction>{stateConfig.badge}</CardAction>
|
|
375
|
+
</CardHeader>
|
|
376
|
+
|
|
377
|
+
<CardContent className="space-y-3">
|
|
378
|
+
<p className="text-xs text-muted-foreground line-clamp-2 leading-relaxed">
|
|
379
|
+
{state === "disabled"
|
|
380
|
+
? text.governanceNotice
|
|
381
|
+
: plugin.description}
|
|
382
|
+
</p>
|
|
383
|
+
|
|
384
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
385
|
+
<Badge variant="outline" className="text-xs">{plugin.category}</Badge>
|
|
386
|
+
|
|
387
|
+
{/* Version Rollback Dropdown */}
|
|
388
|
+
{pastVersions.length > 0 && !stateConfig.disabled && (
|
|
389
|
+
<DropdownMenu>
|
|
390
|
+
<DropdownMenuTrigger asChild>
|
|
391
|
+
<Button size="xs" variant="outline" className="ms-auto text-xs gap-1.5 h-6">
|
|
392
|
+
<IconHistory className="size-3" />
|
|
393
|
+
<span>{text.rollback}</span>
|
|
394
|
+
</Button>
|
|
395
|
+
</DropdownMenuTrigger>
|
|
396
|
+
<DropdownMenuContent align="end" className="w-56">
|
|
397
|
+
<DropdownMenuLabel className="text-xs">{text.versionHistory}</DropdownMenuLabel>
|
|
398
|
+
<DropdownMenuSeparator />
|
|
399
|
+
{pastVersions.map((ver) => (
|
|
400
|
+
<DropdownMenuItem
|
|
401
|
+
key={ver.version}
|
|
402
|
+
onClick={() => setRollbackTarget(ver.version)}
|
|
403
|
+
className="flex items-center justify-between text-xs cursor-pointer"
|
|
404
|
+
>
|
|
405
|
+
<div className="flex items-center gap-2">
|
|
406
|
+
<IconArrowBackUp className="size-3.5 text-muted-foreground" />
|
|
407
|
+
<span className="font-semibold">v{ver.version}</span>
|
|
408
|
+
</div>
|
|
409
|
+
{ver.releasedLabel !== undefined && (
|
|
410
|
+
<span className="text-xs text-muted-foreground">{ver.releasedLabel}</span>
|
|
411
|
+
)}
|
|
412
|
+
</DropdownMenuItem>
|
|
413
|
+
))}
|
|
414
|
+
</DropdownMenuContent>
|
|
415
|
+
</DropdownMenu>
|
|
416
|
+
)}
|
|
417
|
+
</div>
|
|
418
|
+
</CardContent>
|
|
419
|
+
|
|
420
|
+
<CardFooter className="border-t border-border/40 pt-3 flex items-center justify-between gap-2">
|
|
421
|
+
<Button
|
|
422
|
+
size="sm"
|
|
423
|
+
variant="ghost"
|
|
424
|
+
onClick={() => setDetailsOpen(true)}
|
|
425
|
+
className="text-xs text-muted-foreground hover:text-foreground"
|
|
426
|
+
>
|
|
427
|
+
<IconInfoCircle data-icon="inline-start" />
|
|
428
|
+
{text.details}
|
|
429
|
+
</Button>
|
|
430
|
+
|
|
431
|
+
<div className="flex items-center gap-2">
|
|
432
|
+
{state === "update-available" && (
|
|
433
|
+
<Button
|
|
434
|
+
size="sm"
|
|
435
|
+
variant="outline"
|
|
436
|
+
onClick={() => onUpdate?.(plugin)}
|
|
437
|
+
>
|
|
438
|
+
<IconRefresh data-icon="inline-start" />
|
|
439
|
+
Update v{plugin.latestVersion}
|
|
440
|
+
</Button>
|
|
441
|
+
)}
|
|
442
|
+
|
|
443
|
+
{state === "active" && (
|
|
444
|
+
<Button
|
|
445
|
+
size="sm"
|
|
446
|
+
variant="outline"
|
|
447
|
+
onClick={() => onToggleState?.(plugin, "inactive")}
|
|
448
|
+
>
|
|
449
|
+
<IconPower data-icon="inline-start" />
|
|
450
|
+
{text.deactivate}
|
|
451
|
+
</Button>
|
|
452
|
+
)}
|
|
453
|
+
|
|
454
|
+
{state === "inactive" && (
|
|
455
|
+
<Button
|
|
456
|
+
size="sm"
|
|
457
|
+
variant="outline"
|
|
458
|
+
onClick={() => onToggleState?.(plugin, "active")}
|
|
459
|
+
>
|
|
460
|
+
<IconCheck data-icon="inline-start" />
|
|
461
|
+
{text.activate}
|
|
462
|
+
</Button>
|
|
463
|
+
)}
|
|
464
|
+
|
|
465
|
+
{state === "disabled" && (
|
|
466
|
+
<Button size="sm" variant="outline" disabled>
|
|
467
|
+
<IconLock data-icon="inline-start" />
|
|
468
|
+
{text.restricted}
|
|
469
|
+
</Button>
|
|
470
|
+
)}
|
|
471
|
+
|
|
472
|
+
{onConfigure && !stateConfig.disabled && (
|
|
473
|
+
<Button
|
|
474
|
+
size="icon-xs"
|
|
475
|
+
variant="outline"
|
|
476
|
+
onClick={() => onConfigure(plugin)}
|
|
477
|
+
aria-label={text.configure}
|
|
478
|
+
>
|
|
479
|
+
<IconSettings />
|
|
480
|
+
</Button>
|
|
481
|
+
)}
|
|
482
|
+
</div>
|
|
483
|
+
</CardFooter>
|
|
484
|
+
</Card>
|
|
485
|
+
|
|
486
|
+
{/* Plugin Details Popup Modal */}
|
|
487
|
+
<PluginDetailsModal
|
|
488
|
+
open={detailsOpen}
|
|
489
|
+
onOpenChange={setDetailsOpen}
|
|
490
|
+
plugin={plugin}
|
|
491
|
+
installed
|
|
492
|
+
labels={labels}
|
|
493
|
+
/>
|
|
494
|
+
|
|
495
|
+
{/* Rollback Confirmation Modal */}
|
|
496
|
+
{rollbackTarget && (
|
|
497
|
+
<Dialog open={Boolean(rollbackTarget)} onOpenChange={(open) => !open && setRollbackTarget(null)}>
|
|
498
|
+
<DialogContent className="sm:max-w-md">
|
|
499
|
+
<DialogHeader>
|
|
500
|
+
<DialogTitle className="flex items-center gap-2 text-base">
|
|
501
|
+
<IconArrowBackUp className="size-5 text-warning-text" />
|
|
502
|
+
{text.confirmRollbackTitle}
|
|
503
|
+
</DialogTitle>
|
|
504
|
+
<DialogDescription className="text-xs">
|
|
505
|
+
{text.rollbackConfirmation(plugin.name, plugin.version, rollbackTarget)}
|
|
506
|
+
</DialogDescription>
|
|
507
|
+
</DialogHeader>
|
|
508
|
+
|
|
509
|
+
<div className="rounded-lg bg-warning-tint border border-warning/30 p-3 text-xs text-warning-text space-y-1">
|
|
510
|
+
<div className="font-semibold flex items-center gap-1.5">
|
|
511
|
+
<IconAlertCircle className="size-4 shrink-0" />
|
|
512
|
+
Warning: Version Degradation
|
|
513
|
+
</div>
|
|
514
|
+
<p className="text-xs opacity-90 leading-relaxed">
|
|
515
|
+
Rolling back to v{rollbackTarget} will restore legacy schemas and configuration defaults. Ensure any data migration backups are complete.
|
|
516
|
+
</p>
|
|
517
|
+
</div>
|
|
518
|
+
|
|
519
|
+
<DialogFooter className="gap-2 sm:gap-0">
|
|
520
|
+
<Button variant="outline" onClick={() => setRollbackTarget(null)}>
|
|
521
|
+
{text.cancel}
|
|
522
|
+
</Button>
|
|
523
|
+
<Button
|
|
524
|
+
variant="default"
|
|
525
|
+
onClick={() => {
|
|
526
|
+
if (rollbackTarget) {
|
|
527
|
+
onRollback?.(plugin, rollbackTarget)
|
|
528
|
+
setRollbackTarget(null)
|
|
529
|
+
}
|
|
530
|
+
}}
|
|
531
|
+
>
|
|
532
|
+
<IconArrowBackUp data-icon="inline-start" />
|
|
533
|
+
Rollback to v{rollbackTarget}
|
|
534
|
+
</Button>
|
|
535
|
+
</DialogFooter>
|
|
536
|
+
</DialogContent>
|
|
537
|
+
</Dialog>
|
|
538
|
+
)}
|
|
539
|
+
</>
|
|
540
|
+
)
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
interface PluginDetailsModalProps {
|
|
544
|
+
open: boolean
|
|
545
|
+
onOpenChange: (open: boolean) => void
|
|
546
|
+
plugin: PluginItem
|
|
547
|
+
installed?: boolean
|
|
548
|
+
onInstall?: (plugin: PluginItem) => void
|
|
549
|
+
labels?: PluginCardLabels
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function PluginDetailsModal({
|
|
553
|
+
open,
|
|
554
|
+
onOpenChange,
|
|
555
|
+
plugin,
|
|
556
|
+
installed = false,
|
|
557
|
+
onInstall,
|
|
558
|
+
labels,
|
|
559
|
+
}: PluginDetailsModalProps) {
|
|
560
|
+
const text = { ...DEFAULT_PLUGIN_CARD_LABELS, ...labels }
|
|
561
|
+
// Both of these are OPTIONAL on PluginItem, so their old sample-array
|
|
562
|
+
// fallbacks were the DEFAULT rendering, not a defensive branch — this modal
|
|
563
|
+
// stated release numbers, dates, a changelog and a permission set that
|
|
564
|
+
// belonged to no plugin, in the screen where someone decides whether to
|
|
565
|
+
// install third-party code. Empty is the only honest answer; the tabs below
|
|
566
|
+
// say so explicitly rather than rendering an unexplained blank. (#756)
|
|
567
|
+
const versions = plugin.versions ?? []
|
|
568
|
+
// Deliberately NOT defaulted to [] alongside `versions`: for permissions the
|
|
569
|
+
// two are different statements. An empty array is the plugin saying it asks
|
|
570
|
+
// for nothing; `undefined` is nobody having told us what it asks for, and
|
|
571
|
+
// answering that with "does not request any special permissions" is a
|
|
572
|
+
// reassurance about third-party code that nobody actually made — the same
|
|
573
|
+
// class of invention as the sample array it replaced, only in the safe
|
|
574
|
+
// direction. The tab below says which of the two it has.
|
|
575
|
+
const permissions = plugin.permissions
|
|
576
|
+
|
|
577
|
+
return (
|
|
578
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
579
|
+
<DialogContent className="sm:max-w-xl">
|
|
580
|
+
<DialogHeader className="border-b border-border/40 pb-4">
|
|
581
|
+
<div className="flex items-center gap-3.5">
|
|
582
|
+
<div className="text-foreground shrink-0 [&_svg]:size-8 text-primary">
|
|
583
|
+
{plugin.icon ?? <IconPuzzle />}
|
|
584
|
+
</div>
|
|
585
|
+
<div>
|
|
586
|
+
<DialogTitle className="text-lg font-semibold flex items-center gap-2">
|
|
587
|
+
{plugin.name}
|
|
588
|
+
{plugin.verified && <Badge variant="default" className="text-xs">{text.verified}</Badge>}
|
|
589
|
+
</DialogTitle>
|
|
590
|
+
<DialogDescription className="text-xs">
|
|
591
|
+
by {plugin.author} · Version v{plugin.version}
|
|
592
|
+
</DialogDescription>
|
|
593
|
+
</div>
|
|
594
|
+
</div>
|
|
595
|
+
</DialogHeader>
|
|
596
|
+
|
|
597
|
+
<Tabs defaultValue="overview" className="w-full text-xs">
|
|
598
|
+
<TabsList className="w-full justify-start border-b rounded-none bg-transparent p-0 h-9">
|
|
599
|
+
<TabsTrigger value="overview" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
600
|
+
{text.overview}
|
|
601
|
+
</TabsTrigger>
|
|
602
|
+
<TabsTrigger value="versions" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
603
|
+
Changelog & Versions
|
|
604
|
+
</TabsTrigger>
|
|
605
|
+
<TabsTrigger value="permissions" className="rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent">
|
|
606
|
+
Permissions & Security
|
|
607
|
+
</TabsTrigger>
|
|
608
|
+
</TabsList>
|
|
609
|
+
|
|
610
|
+
<TabsContent value="overview" className="py-4 space-y-4">
|
|
611
|
+
<p className="text-xs text-muted-foreground leading-relaxed">
|
|
612
|
+
{plugin.longDescription ?? plugin.description}
|
|
613
|
+
</p>
|
|
614
|
+
|
|
615
|
+
{/* Interactive Image Gallery in More Info > Overview */}
|
|
616
|
+
<PluginImageGallery
|
|
617
|
+
screenshots={plugin.screenshots}
|
|
618
|
+
pluginName={plugin.name}
|
|
619
|
+
category={plugin.category}
|
|
620
|
+
bannerGradient={plugin.bannerGradient}
|
|
621
|
+
previousLabel={text.previousScreenshot}
|
|
622
|
+
nextLabel={text.nextScreenshot}
|
|
623
|
+
/>
|
|
624
|
+
|
|
625
|
+
<div className="flex flex-wrap items-center gap-3 pt-1">
|
|
626
|
+
<div className="flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/40 px-3 py-1.5 text-xs">
|
|
627
|
+
<IconStarFilled className="size-3.5 text-muted-foreground/70" />
|
|
628
|
+
<span className="font-semibold">{plugin.rating.toFixed(1)}</span>
|
|
629
|
+
<span className="text-muted-foreground">({plugin.reviewCount} reviews)</span>
|
|
630
|
+
</div>
|
|
631
|
+
<div className="flex items-center gap-1.5 rounded-lg border border-border/50 bg-muted/40 px-3 py-1.5 text-xs">
|
|
632
|
+
<IconShieldCheck className="size-3.5 text-success-text" />
|
|
633
|
+
<span className="font-semibold">{text.securityVerified}</span>
|
|
634
|
+
</div>
|
|
635
|
+
</div>
|
|
636
|
+
</TabsContent>
|
|
637
|
+
|
|
638
|
+
<TabsContent value="versions" className="py-4 space-y-3">
|
|
639
|
+
<div className="space-y-2">
|
|
640
|
+
{versions.length === 0 && (
|
|
641
|
+
<p className="text-xs text-muted-foreground">{text.noVersionHistory}</p>
|
|
642
|
+
)}
|
|
643
|
+
{versions.map((ver) => (
|
|
644
|
+
<div key={ver.version} className="rounded-lg border border-border/60 bg-muted/20 p-3 space-y-1">
|
|
645
|
+
<div className="flex items-center justify-between">
|
|
646
|
+
<span className="font-semibold text-xs text-foreground">Version {ver.version}</span>
|
|
647
|
+
{ver.releasedLabel !== undefined && (
|
|
648
|
+
<span className="text-xs text-muted-foreground">{ver.releasedLabel}</span>
|
|
649
|
+
)}
|
|
650
|
+
</div>
|
|
651
|
+
{ver.changelog && (
|
|
652
|
+
<p className="text-xs text-muted-foreground leading-relaxed">{ver.changelog}</p>
|
|
653
|
+
)}
|
|
654
|
+
</div>
|
|
655
|
+
))}
|
|
656
|
+
</div>
|
|
657
|
+
</TabsContent>
|
|
658
|
+
|
|
659
|
+
<TabsContent value="permissions" className="py-4 space-y-3">
|
|
660
|
+
<p className="text-xs text-muted-foreground">
|
|
661
|
+
{permissions === undefined
|
|
662
|
+
? text.permissionsUndeclared
|
|
663
|
+
: permissions.length === 0
|
|
664
|
+
? text.noPermissions
|
|
665
|
+
: "This plugin requests the following system permissions when activated:"}
|
|
666
|
+
</p>
|
|
667
|
+
<div className="space-y-1.5">
|
|
668
|
+
{(permissions ?? []).map((perm) => (
|
|
669
|
+
<div key={perm} className="flex items-center gap-2 rounded-md bg-muted/30 border border-border/40 px-2.5 py-1 text-xs font-mono">
|
|
670
|
+
<IconLock className="size-3.5 text-primary shrink-0" />
|
|
671
|
+
<span>{perm}</span>
|
|
672
|
+
</div>
|
|
673
|
+
))}
|
|
674
|
+
</div>
|
|
675
|
+
</TabsContent>
|
|
676
|
+
</Tabs>
|
|
677
|
+
|
|
678
|
+
<DialogFooter className="border-t border-border/40 pt-3 flex items-center justify-between">
|
|
679
|
+
<Button variant="outline" onClick={() => onOpenChange(false)}>
|
|
680
|
+
{text.close}
|
|
681
|
+
</Button>
|
|
682
|
+
{!installed && (
|
|
683
|
+
<Button
|
|
684
|
+
variant="default"
|
|
685
|
+
onClick={() => {
|
|
686
|
+
onInstall?.(plugin)
|
|
687
|
+
onOpenChange(false)
|
|
688
|
+
}}
|
|
689
|
+
>
|
|
690
|
+
<IconDownload data-icon="inline-start" />
|
|
691
|
+
{text.installPlugin}
|
|
692
|
+
</Button>
|
|
693
|
+
)}
|
|
694
|
+
</DialogFooter>
|
|
695
|
+
</DialogContent>
|
|
696
|
+
</Dialog>
|
|
697
|
+
)
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
interface PluginImageGalleryProps {
|
|
701
|
+
screenshots?: string[]
|
|
702
|
+
pluginName: string
|
|
703
|
+
category: string
|
|
704
|
+
bannerGradient?: string
|
|
705
|
+
/** Accessible names for the gallery arrows. */
|
|
706
|
+
previousLabel?: string
|
|
707
|
+
nextLabel?: string
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* One gallery slide: either a real screenshot, or — when the plugin ships none —
|
|
712
|
+
* a gradient placeholder standing in for a screenshot that does not exist yet.
|
|
713
|
+
* The two shapes carry different fields, so the variant is explicit rather than
|
|
714
|
+
* inferred from a truthy `url`.
|
|
715
|
+
*/
|
|
716
|
+
type PluginGalleryItem =
|
|
717
|
+
| { kind: "screenshot"; title: string; url: string }
|
|
718
|
+
| { kind: "placeholder"; title: string; label: string; gradient: string }
|
|
719
|
+
|
|
720
|
+
function PluginImageGallery({
|
|
721
|
+
screenshots,
|
|
722
|
+
pluginName,
|
|
723
|
+
category,
|
|
724
|
+
bannerGradient = "from-primary/20 via-muted to-muted/80",
|
|
725
|
+
previousLabel,
|
|
726
|
+
nextLabel,
|
|
727
|
+
}: PluginImageGalleryProps) {
|
|
728
|
+
const [activeIndex, setActiveIndex] = React.useState(0)
|
|
729
|
+
|
|
730
|
+
const items: PluginGalleryItem[] = screenshots && screenshots.length > 0
|
|
731
|
+
? screenshots.map((url, i) => ({
|
|
732
|
+
kind: "screenshot",
|
|
733
|
+
title: `${pluginName} Screenshot ${i + 1}`,
|
|
734
|
+
url,
|
|
735
|
+
}))
|
|
736
|
+
: [
|
|
737
|
+
{
|
|
738
|
+
kind: "placeholder",
|
|
739
|
+
title: "Main Interface View",
|
|
740
|
+
label: "Dashboard View",
|
|
741
|
+
gradient: bannerGradient,
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
kind: "placeholder",
|
|
745
|
+
title: "Configuration & Settings",
|
|
746
|
+
label: "Rule Engine Settings",
|
|
747
|
+
gradient: "from-info/20 via-muted to-muted/80",
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
kind: "placeholder",
|
|
751
|
+
title: "Telemetry & Live Logs",
|
|
752
|
+
label: "Realtime Analytics",
|
|
753
|
+
gradient: "from-success/20 via-muted to-muted/80",
|
|
754
|
+
},
|
|
755
|
+
]
|
|
756
|
+
|
|
757
|
+
const currentItem = items[activeIndex] || items[0]
|
|
758
|
+
|
|
759
|
+
return (
|
|
760
|
+
<div className="space-y-2">
|
|
761
|
+
<div className="flex items-center justify-between">
|
|
762
|
+
<span className="text-xs font-semibold text-foreground uppercase tracking-wider">
|
|
763
|
+
Interface Gallery & Screenshots
|
|
764
|
+
</span>
|
|
765
|
+
<span className="text-xs text-muted-foreground">
|
|
766
|
+
{activeIndex + 1} of {items.length}
|
|
767
|
+
</span>
|
|
768
|
+
</div>
|
|
769
|
+
|
|
770
|
+
{/* Main Preview Container */}
|
|
771
|
+
<div className="group/gallery relative h-48 w-full overflow-hidden rounded-xl border border-border/60 bg-muted">
|
|
772
|
+
{currentItem.kind === "screenshot" ? (
|
|
773
|
+
<img
|
|
774
|
+
src={currentItem.url}
|
|
775
|
+
alt={currentItem.title}
|
|
776
|
+
className="size-full object-cover transition-all duration-300"
|
|
777
|
+
/>
|
|
778
|
+
) : (
|
|
779
|
+
<div
|
|
780
|
+
className={cn(
|
|
781
|
+
"size-full flex flex-col items-center justify-center bg-linear-to-br p-6 text-center transition-all duration-300",
|
|
782
|
+
currentItem.gradient
|
|
783
|
+
)}
|
|
784
|
+
>
|
|
785
|
+
<IconPhoto className="size-8 text-foreground/40 mb-2" />
|
|
786
|
+
<span className="font-heading font-semibold text-sm text-foreground/90">
|
|
787
|
+
{currentItem.title}
|
|
788
|
+
</span>
|
|
789
|
+
<span className="text-xs text-muted-foreground mt-0.5">
|
|
790
|
+
{category} Module Preview · {currentItem.label}
|
|
791
|
+
</span>
|
|
792
|
+
</div>
|
|
793
|
+
)}
|
|
794
|
+
|
|
795
|
+
{/* Carousel Prev/Next Overlay Buttons */}
|
|
796
|
+
{items.length > 1 && (
|
|
797
|
+
<>
|
|
798
|
+
<button
|
|
799
|
+
type="button"
|
|
800
|
+
onClick={() => setActiveIndex((prev) => (prev > 0 ? prev - 1 : items.length - 1))}
|
|
801
|
+
className="absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-background/80 p-1.5 text-foreground backdrop-blur-xs opacity-0 transition-opacity group-hover/gallery:opacity-100 hover:bg-background shadow-xs"
|
|
802
|
+
aria-label={previousLabel}
|
|
803
|
+
>
|
|
804
|
+
<IconChevronLeft className="size-4" />
|
|
805
|
+
</button>
|
|
806
|
+
|
|
807
|
+
<button
|
|
808
|
+
type="button"
|
|
809
|
+
onClick={() => setActiveIndex((prev) => (prev < items.length - 1 ? prev + 1 : 0))}
|
|
810
|
+
className="absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-background/80 p-1.5 text-foreground backdrop-blur-xs opacity-0 transition-opacity group-hover/gallery:opacity-100 hover:bg-background shadow-xs"
|
|
811
|
+
aria-label={nextLabel}
|
|
812
|
+
>
|
|
813
|
+
<IconChevronRight className="size-4" />
|
|
814
|
+
</button>
|
|
815
|
+
</>
|
|
816
|
+
)}
|
|
817
|
+
</div>
|
|
818
|
+
|
|
819
|
+
{/* Thumbnail Selector Strip */}
|
|
820
|
+
{items.length > 1 && (
|
|
821
|
+
<div className="grid grid-cols-3 gap-2 pt-1">
|
|
822
|
+
{items.map((item, idx) => (
|
|
823
|
+
<button
|
|
824
|
+
key={idx}
|
|
825
|
+
type="button"
|
|
826
|
+
onClick={() => setActiveIndex(idx)}
|
|
827
|
+
className={cn(
|
|
828
|
+
"relative h-14 rounded-lg overflow-hidden border transition-all text-left p-2 flex flex-col justify-end",
|
|
829
|
+
activeIndex === idx
|
|
830
|
+
? "border-primary ring-2 ring-primary/40 shadow-xs"
|
|
831
|
+
: "border-border/50 opacity-70 hover:opacity-100 hover:border-border"
|
|
832
|
+
)}
|
|
833
|
+
>
|
|
834
|
+
{item.kind === "screenshot" ? (
|
|
835
|
+
<img src={item.url} alt={item.title} className="absolute inset-0 size-full object-cover" />
|
|
836
|
+
) : (
|
|
837
|
+
<div className={cn("absolute inset-0 bg-linear-to-br", item.gradient)} />
|
|
838
|
+
)}
|
|
839
|
+
<span className="relative z-10 text-xs font-semibold text-foreground/90 truncate drop-shadow-xs">
|
|
840
|
+
{item.kind === "placeholder" ? item.label : item.title}
|
|
841
|
+
</span>
|
|
842
|
+
</button>
|
|
843
|
+
))}
|
|
844
|
+
</div>
|
|
845
|
+
)}
|
|
846
|
+
</div>
|
|
847
|
+
)
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export interface PluginTileProps extends Omit<React.ComponentProps<"div">, "title"> {
|
|
851
|
+
name: string
|
|
852
|
+
publisher?: string
|
|
853
|
+
summary?: string
|
|
854
|
+
version?: string | null
|
|
855
|
+
tags?: string[]
|
|
856
|
+
/** What it adds, as chips (section 19). */
|
|
857
|
+
adds?: string[]
|
|
858
|
+
/** One line of facts: price, usage, last update. Already formatted by the caller. */
|
|
859
|
+
facts?: string[]
|
|
860
|
+
/** Draw the Verified mark. Only ever set from what the server returns. */
|
|
861
|
+
verified?: boolean
|
|
862
|
+
verifiedLabel?: string
|
|
863
|
+
/** The server's trust answer when it isn't Verified, such as "Not verified". */
|
|
864
|
+
trustLabel?: string
|
|
865
|
+
icon?: React.ReactNode
|
|
866
|
+
/** Opens the plugin's page. The name is the keyboard-reachable control; the whole tile is its target. */
|
|
867
|
+
onOpen: () => void
|
|
868
|
+
/** The tile's one action, such as Install. */
|
|
869
|
+
action?: React.ReactNode
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* A plugin in the store (docs/design/components/PluginCard): the logo, the name,
|
|
874
|
+
* the publisher, one line, and the tile's one action. No ratings or reviews
|
|
875
|
+
* (S.4). Hover lifts the tile like any clickable card.
|
|
876
|
+
*/
|
|
877
|
+
export function PluginTile({
|
|
878
|
+
className,
|
|
879
|
+
name,
|
|
880
|
+
publisher,
|
|
881
|
+
summary,
|
|
882
|
+
version,
|
|
883
|
+
tags,
|
|
884
|
+
adds,
|
|
885
|
+
facts,
|
|
886
|
+
verified,
|
|
887
|
+
verifiedLabel = "Verified",
|
|
888
|
+
trustLabel,
|
|
889
|
+
icon,
|
|
890
|
+
onOpen,
|
|
891
|
+
action,
|
|
892
|
+
...props
|
|
893
|
+
}: PluginTileProps) {
|
|
894
|
+
return (
|
|
895
|
+
<Card interactive variant="elevated" className={cn("relative flex h-full flex-col", className)} {...props}>
|
|
896
|
+
<CardHeader className="space-y-1.5">
|
|
897
|
+
<div className="flex items-center gap-3">
|
|
898
|
+
<div className="shrink-0 text-primary [&_svg]:size-8">{icon ?? <IconPuzzle />}</div>
|
|
899
|
+
<div className="min-w-0 flex-1">
|
|
900
|
+
<CardTitle className="truncate text-sm font-semibold">
|
|
901
|
+
<button
|
|
902
|
+
type="button"
|
|
903
|
+
onClick={onOpen}
|
|
904
|
+
className="text-start outline-none after:absolute after:inset-0 focus-visible:underline"
|
|
905
|
+
>
|
|
906
|
+
{name}
|
|
907
|
+
</button>
|
|
908
|
+
</CardTitle>
|
|
909
|
+
{publisher ? <CardDescription className="truncate text-xs">{publisher}</CardDescription> : null}
|
|
910
|
+
</div>
|
|
911
|
+
{verified ? <Badge variant="default" className="text-xs">{verifiedLabel}</Badge> : null}
|
|
912
|
+
{!verified && trustLabel ? <Badge variant="outline" className="text-xs">{trustLabel}</Badge> : null}
|
|
913
|
+
</div>
|
|
914
|
+
</CardHeader>
|
|
915
|
+
<CardContent className="flex-1 space-y-3">
|
|
916
|
+
{summary ? <p className="line-clamp-2 text-sm text-muted-foreground">{summary}</p> : null}
|
|
917
|
+
<div className="flex flex-wrap items-center gap-1.5">
|
|
918
|
+
{version ? <Badge variant="secondary" className="text-xs">v{version}</Badge> : null}
|
|
919
|
+
{(tags ?? []).map((tag) => (
|
|
920
|
+
<Badge key={tag} variant="outline" className="text-xs">{tag}</Badge>
|
|
921
|
+
))}
|
|
922
|
+
{(adds ?? []).map((label) => (
|
|
923
|
+
<Badge key={label} variant="secondary" className="text-xs">{label}</Badge>
|
|
924
|
+
))}
|
|
925
|
+
</div>
|
|
926
|
+
{facts && facts.length > 0 ? <p className="text-xs text-muted-foreground">{facts.join(" · ")}</p> : null}
|
|
927
|
+
</CardContent>
|
|
928
|
+
{action ? <CardFooter className="relative justify-end border-t border-border/40 pt-3">{action}</CardFooter> : null}
|
|
929
|
+
</Card>
|
|
930
|
+
)
|
|
931
|
+
}
|