@whity/ui 0.0.0-stage → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +107 -3
  2. package/package.json +192 -6
  3. package/src/access-denied.stories.tsx +179 -0
  4. package/src/access-denied.tsx +305 -0
  5. package/src/action-proposal.tsx +302 -0
  6. package/src/actor-chip.tsx +71 -0
  7. package/src/agent-activity.tsx +163 -0
  8. package/src/agent-collaboration.stories.tsx +156 -0
  9. package/src/agent-run-status.tsx +196 -0
  10. package/src/alert-dialog.stories.tsx +45 -0
  11. package/src/alert-dialog.tsx +147 -0
  12. package/src/alert.stories.tsx +91 -0
  13. package/src/alert.tsx +89 -0
  14. package/src/app-sidebar.stories.tsx +195 -0
  15. package/src/app-sidebar.tsx +500 -0
  16. package/src/approval-queue.tsx +108 -0
  17. package/src/audience-group-picker.stories.tsx +198 -0
  18. package/src/audience-group-picker.tsx +362 -0
  19. package/src/audience-people-picker.stories.tsx +102 -0
  20. package/src/audience-people-picker.tsx +279 -0
  21. package/src/avatar.tsx +83 -0
  22. package/src/badge.stories.tsx +105 -0
  23. package/src/badge.tsx +68 -0
  24. package/src/beta-warning.stories.tsx +79 -0
  25. package/src/beta-warning.tsx +189 -0
  26. package/src/bilingual-input.stories.tsx +82 -0
  27. package/src/bilingual-input.tsx +183 -0
  28. package/src/breadcrumb.stories.tsx +51 -0
  29. package/src/breadcrumb.tsx +90 -0
  30. package/src/button.stories.tsx +87 -0
  31. package/src/button.tsx +118 -0
  32. package/src/card.stories.tsx +423 -0
  33. package/src/card.tsx +180 -0
  34. package/src/chart.stories.tsx +66 -0
  35. package/src/chart.tsx +228 -0
  36. package/src/checkbox.stories.tsx +62 -0
  37. package/src/checkbox.tsx +54 -0
  38. package/src/collapsible.stories.tsx +48 -0
  39. package/src/collapsible.tsx +34 -0
  40. package/src/color-card.stories.tsx +61 -0
  41. package/src/color-card.tsx +270 -0
  42. package/src/color-picker.stories.tsx +65 -0
  43. package/src/color-picker.tsx +425 -0
  44. package/src/command-palette.tsx +306 -0
  45. package/src/copy-block.stories.tsx +38 -0
  46. package/src/copy-block.tsx +85 -0
  47. package/src/data-table.stories.tsx +200 -0
  48. package/src/data-table.tsx +1106 -0
  49. package/src/date-picker.stories.tsx +61 -0
  50. package/src/date-picker.tsx +422 -0
  51. package/src/design-cards.stories.tsx +458 -0
  52. package/src/dialog.stories.tsx +48 -0
  53. package/src/dialog.tsx +166 -0
  54. package/src/documents/barcode-svg.stories.tsx +72 -0
  55. package/src/documents/barcode-svg.tsx +79 -0
  56. package/src/dropdown-menu.stories.tsx +77 -0
  57. package/src/dropdown-menu.tsx +271 -0
  58. package/src/editor/behaviour.ts +279 -0
  59. package/src/editor/block-ids.ts +44 -0
  60. package/src/editor/block-list.tsx +101 -0
  61. package/src/editor/block-toolbar.tsx +477 -0
  62. package/src/editor/bubble.tsx +93 -0
  63. package/src/editor/catalogue.ts +103 -0
  64. package/src/editor/collab-rail.tsx +746 -0
  65. package/src/editor/collab.stories.tsx +207 -0
  66. package/src/editor/collab.ts +87 -0
  67. package/src/editor/contract.ts +408 -0
  68. package/src/editor/convert.ts +362 -0
  69. package/src/editor/doc-editor.stories.tsx +98 -0
  70. package/src/editor/doc-editor.tsx +1287 -0
  71. package/src/editor/editor.css +536 -0
  72. package/src/editor/extensions.ts +86 -0
  73. package/src/editor/field-picker.tsx +107 -0
  74. package/src/editor/fields.ts +100 -0
  75. package/src/editor/gutter.tsx +367 -0
  76. package/src/editor/index.ts +22 -0
  77. package/src/editor/label-sheet.tsx +289 -0
  78. package/src/editor/labels.ts +310 -0
  79. package/src/editor/link-tools.tsx +141 -0
  80. package/src/editor/node-views.tsx +450 -0
  81. package/src/editor/page-view.tsx +353 -0
  82. package/src/editor/publish-check.tsx +182 -0
  83. package/src/editor/rich-blocks.stories.tsx +146 -0
  84. package/src/editor/sample.ts +40 -0
  85. package/src/editor/schema-rich.ts +150 -0
  86. package/src/editor/schema.ts +315 -0
  87. package/src/editor/services.tsx +127 -0
  88. package/src/editor/slash.ts +64 -0
  89. package/src/editor/suggesting.ts +372 -0
  90. package/src/editor/suggestions.ts +763 -0
  91. package/src/editor/table-keys.ts +66 -0
  92. package/src/editor/templates.stories.tsx +324 -0
  93. package/src/editor/toolbar.tsx +358 -0
  94. package/src/empty-state.stories.tsx +51 -0
  95. package/src/empty-state.tsx +100 -0
  96. package/src/empty-state.usage-notes.md +30 -0
  97. package/src/form.stories.tsx +112 -0
  98. package/src/form.tsx +176 -0
  99. package/src/globals.css +20 -0
  100. package/src/icon-button.tsx +85 -0
  101. package/src/icon-map.ts +244 -0
  102. package/src/icon.tsx +41 -0
  103. package/src/index.ts +67 -0
  104. package/src/input.stories.tsx +157 -0
  105. package/src/input.tsx +759 -0
  106. package/src/locked-screen.stories.tsx +29 -0
  107. package/src/locked-screen.tsx +61 -0
  108. package/src/mark.tsx +62 -0
  109. package/src/math-text.stories.tsx +33 -0
  110. package/src/math-text.tsx +43 -0
  111. package/src/menu-bar.stories.tsx +198 -0
  112. package/src/menu-bar.tsx +373 -0
  113. package/src/money/currency.ts +230 -0
  114. package/src/page-header.stories.tsx +95 -0
  115. package/src/page-header.tsx +122 -0
  116. package/src/page-shell.stories.tsx +42 -0
  117. package/src/page-shell.tsx +32 -0
  118. package/src/pagination.stories.tsx +45 -0
  119. package/src/pagination.tsx +98 -0
  120. package/src/plugin-card.stories.tsx +180 -0
  121. package/src/plugin-card.tsx +848 -0
  122. package/src/popover.stories.tsx +48 -0
  123. package/src/popover.tsx +55 -0
  124. package/src/radio-group.stories.tsx +26 -0
  125. package/src/radio-group.tsx +44 -0
  126. package/src/route-flow/editor.tsx +1014 -0
  127. package/src/route-flow/model.ts +716 -0
  128. package/src/scope-grant.tsx +139 -0
  129. package/src/screen-too-small.stories.tsx +61 -0
  130. package/src/screen-too-small.tsx +104 -0
  131. package/src/select.stories.tsx +44 -0
  132. package/src/select.tsx +197 -0
  133. package/src/separator.stories.tsx +34 -0
  134. package/src/separator.tsx +34 -0
  135. package/src/sheet.stories.tsx +49 -0
  136. package/src/sheet.tsx +168 -0
  137. package/src/skeleton.stories.tsx +28 -0
  138. package/src/skeleton.tsx +19 -0
  139. package/src/slider.stories.tsx +78 -0
  140. package/src/slider.tsx +300 -0
  141. package/src/spinner.stories.tsx +33 -0
  142. package/src/spinner.tsx +55 -0
  143. package/src/switch.stories.tsx +42 -0
  144. package/src/switch.tsx +41 -0
  145. package/src/switcher.stories.tsx +111 -0
  146. package/src/switcher.tsx +131 -0
  147. package/src/table.stories.tsx +48 -0
  148. package/src/table.tsx +121 -0
  149. package/src/tabs.stories.tsx +74 -0
  150. package/src/tabs.tsx +90 -0
  151. package/src/tag-input.stories.tsx +67 -0
  152. package/src/tag-input.tsx +117 -0
  153. package/src/tenant-logo.tsx +63 -0
  154. package/src/tenant-switcher.stories.tsx +38 -0
  155. package/src/tenant-switcher.tsx +164 -0
  156. package/src/textarea.stories.tsx +27 -0
  157. package/src/textarea.tsx +18 -0
  158. package/src/theme-mode.ts +52 -0
  159. package/src/time-picker.stories.tsx +62 -0
  160. package/src/time-picker.tsx +615 -0
  161. package/src/toggle-group.tsx +138 -0
  162. package/src/tooltip.stories.tsx +43 -0
  163. package/src/tooltip.tsx +73 -0
  164. package/src/top-nav.stories.tsx +58 -0
  165. package/src/top-nav.tsx +324 -0
  166. package/src/undo-bar.tsx +107 -0
  167. package/src/utils.ts +45 -0
  168. package/src/view-toggle.stories.tsx +84 -0
  169. package/src/view-toggle.tsx +110 -0
@@ -0,0 +1,122 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "./utils"
4
+
5
+ export interface PageHeaderProps {
6
+ /**
7
+ * Main page title text or node.
8
+ */
9
+ title: React.ReactNode
10
+ /**
11
+ * Subtitle or description explaining the page context.
12
+ */
13
+ description?: React.ReactNode
14
+ /**
15
+ * Optional icon displayed in a rounded container next to the title.
16
+ */
17
+ icon?: React.ReactNode
18
+ /**
19
+ * Optional status or version badge node displayed next to the title.
20
+ */
21
+ badge?: React.ReactNode
22
+ /**
23
+ * Action buttons or controls rendered on the right side of the header.
24
+ */
25
+ action?: React.ReactNode
26
+ /**
27
+ * Breadcrumb navigation trail rendered above the title.
28
+ */
29
+ breadcrumb?: React.ReactNode
30
+ /**
31
+ * Secondary controls rendered below the header (e.g. tabs, search bar, filters).
32
+ */
33
+ children?: React.ReactNode
34
+ /**
35
+ * Visual layout style: "default" (clean section with border) or "card" (elevated card container).
36
+ */
37
+ variant?: "default" | "card"
38
+ className?: string
39
+ }
40
+
41
+ export function PageHeader({
42
+ title,
43
+ description,
44
+ icon,
45
+ badge,
46
+ action,
47
+ breadcrumb,
48
+ children,
49
+ variant = "default",
50
+ className,
51
+ }: PageHeaderProps) {
52
+ if (variant === "card") {
53
+ return (
54
+ <div
55
+ data-slot="page-header"
56
+ className={cn(
57
+ "mb-6 flex flex-col gap-4 rounded-xl border border-border bg-card p-5 md:p-6 shadow-2xs transition-colors",
58
+ className
59
+ )}
60
+ >
61
+ {breadcrumb && <div className="text-xs text-muted-foreground">{breadcrumb}</div>}
62
+ <div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
63
+ <div className="flex items-start gap-3.5 min-w-0">
64
+ {icon && (
65
+ <div className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary shadow-2xs">
66
+ <span className="[&_svg]:size-5">{icon}</span>
67
+ </div>
68
+ )}
69
+ <div className="flex flex-col gap-1 min-w-0">
70
+ <div className="flex flex-wrap items-center gap-2">
71
+ <h1 className="text-xl md:text-2xl font-semibold tracking-tight text-foreground truncate">
72
+ {title}
73
+ </h1>
74
+ {badge && <div className="shrink-0">{badge}</div>}
75
+ </div>
76
+ {description && (
77
+ <p className="text-xs md:text-sm text-muted-foreground leading-relaxed max-w-3xl">
78
+ {description}
79
+ </p>
80
+ )}
81
+ </div>
82
+ </div>
83
+ {action && <div className="flex items-center gap-2 shrink-0 self-start md:self-center">{action}</div>}
84
+ </div>
85
+ {children && <div className="pt-2 border-t border-border/50">{children}</div>}
86
+ </div>
87
+ )
88
+ }
89
+
90
+ return (
91
+ <div
92
+ data-slot="page-header"
93
+ className={cn("mb-6 flex flex-col gap-3.5 border-b border-border pb-5", className)}
94
+ >
95
+ {breadcrumb && <div className="text-xs text-muted-foreground">{breadcrumb}</div>}
96
+ <div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
97
+ <div className="flex items-start gap-3.5 min-w-0">
98
+ {icon && (
99
+ <div className="flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary shadow-2xs mt-0.5">
100
+ <span className="[&_svg]:size-4.5">{icon}</span>
101
+ </div>
102
+ )}
103
+ <div className="flex flex-col gap-1 min-w-0">
104
+ <div className="flex flex-wrap items-center gap-2">
105
+ <h1 className="text-xl md:text-2xl font-semibold tracking-tight text-foreground truncate">
106
+ {title}
107
+ </h1>
108
+ {badge && <div className="shrink-0">{badge}</div>}
109
+ </div>
110
+ {description && (
111
+ <p className="text-xs md:text-sm text-muted-foreground leading-relaxed max-w-3xl">
112
+ {description}
113
+ </p>
114
+ )}
115
+ </div>
116
+ </div>
117
+ {action && <div className="flex items-center gap-2 shrink-0 self-start md:self-center">{action}</div>}
118
+ </div>
119
+ {children && <div className="pt-2">{children}</div>}
120
+ </div>
121
+ )
122
+ }
@@ -0,0 +1,42 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+
3
+ import { PageShell } from "./page-shell"
4
+
5
+ const DemoSidebar = () => (
6
+ <div className="w-56 shrink-0 border-e border-sidebar-border bg-sidebar p-4 text-sm text-sidebar-foreground">
7
+ Sidebar
8
+ </div>
9
+ )
10
+
11
+ const DemoTopBar = () => (
12
+ <div className="flex h-12 items-center border-b border-border px-4 text-sm text-foreground">Top bar</div>
13
+ )
14
+
15
+ const meta = {
16
+ title: "Layout/PageShell",
17
+ component: PageShell,
18
+ tags: ["autodocs"],
19
+ args: {
20
+ sidebar: <DemoSidebar />,
21
+ className: "h-full min-h-0",
22
+ children: <p className="text-sm text-foreground">Page content goes here.</p>,
23
+ },
24
+ // The shell fills its parent, so every story is framed by a fixed-height box
25
+ // the way a real app viewport frames it.
26
+ decorators: [
27
+ (Story) => (
28
+ <div className="h-80 overflow-hidden rounded-lg border border-border">
29
+ <Story />
30
+ </div>
31
+ ),
32
+ ],
33
+ } satisfies Meta<typeof PageShell>
34
+
35
+ export default meta
36
+ type Story = StoryObj<typeof meta>
37
+
38
+ export const Default: Story = {}
39
+
40
+ export const WithTopBar: Story = {
41
+ args: { topBar: <DemoTopBar /> },
42
+ }
@@ -0,0 +1,32 @@
1
+ import * as React from "react"
2
+
3
+ import { cn } from "./utils"
4
+
5
+ /**
6
+ * PRESENTATIONAL application-frame layout only — slots for a sidebar, an
7
+ * optional top bar, and a content region. No auth/redirect/onboarding logic
8
+ * (that's the app-specific route layout wrapping this, e.g.
9
+ * web/app/(protected)/layout.tsx) — this component only owns the chrome
10
+ * arrangement so every client's "logged-in app frame" matches without
11
+ * re-implementing the flex/scroll layout by hand.
12
+ */
13
+ export interface PageShellProps {
14
+ sidebar: React.ReactNode
15
+ topBar?: React.ReactNode
16
+ children: React.ReactNode
17
+ className?: string
18
+ /** Class applied to the scrollable content region (defaults to standard page padding). */
19
+ contentClassName?: string
20
+ }
21
+
22
+ export function PageShell({ sidebar, topBar, children, className, contentClassName }: PageShellProps) {
23
+ return (
24
+ <div data-slot="page-shell" className={cn("flex min-h-screen bg-background", className)}>
25
+ {sidebar}
26
+ <div className="flex min-w-0 flex-1 flex-col">
27
+ {topBar}
28
+ <main className={cn("flex-1 overflow-y-auto p-6", contentClassName)}>{children}</main>
29
+ </div>
30
+ </div>
31
+ )
32
+ }
@@ -0,0 +1,45 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+ import * as React from "react"
3
+
4
+ import { Pagination } from "./pagination"
5
+
6
+ const meta = {
7
+ title: "Primitives/Pagination",
8
+ component: Pagination,
9
+ tags: ["autodocs"],
10
+ } satisfies Meta<typeof Pagination>
11
+
12
+ export default meta
13
+ type Story = StoryObj<typeof meta>
14
+
15
+ export const Default: Story = {
16
+ args: { page: 2, perPage: 25, total: 214, onPageChange: () => {} },
17
+ render: (args) => {
18
+ const [page, setPage] = React.useState(args.page)
19
+ return <Pagination {...args} page={page} onPageChange={setPage} />
20
+ },
21
+ }
22
+
23
+ export const FirstPage: Story = {
24
+ args: { page: 1, perPage: 25, total: 214, onPageChange: () => {} },
25
+ render: (args) => {
26
+ const [page, setPage] = React.useState(args.page)
27
+ return <Pagination {...args} page={page} onPageChange={setPage} />
28
+ },
29
+ }
30
+
31
+ export const LastPage: Story = {
32
+ args: { page: 9, perPage: 25, total: 214, onPageChange: () => {} },
33
+ render: (args) => {
34
+ const [page, setPage] = React.useState(args.page)
35
+ return <Pagination {...args} page={page} onPageChange={setPage} />
36
+ },
37
+ }
38
+
39
+ export const SinglePage: Story = {
40
+ args: { page: 1, perPage: 25, total: 12, onPageChange: () => {} },
41
+ render: (args) => {
42
+ const [page, setPage] = React.useState(args.page)
43
+ return <Pagination {...args} page={page} onPageChange={setPage} />
44
+ },
45
+ }
@@ -0,0 +1,98 @@
1
+ import * as React from "react"
2
+ import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react"
3
+
4
+ import { cn } from "./utils"
5
+ import { Button } from "./button"
6
+
7
+ /**
8
+ * Routing-agnostic prev/next pagination — modeled on the ad-hoc pattern
9
+ * already used on the audit-logs page (total/page/totalPages + prev/next
10
+ * buttons disabled at the boundaries), promoted to a shared, token-styled
11
+ * primitive. Migrating that page's inline markup onto this component is a
12
+ * follow-up, not in scope here.
13
+ *
14
+ * PLATFORM NOTE: `page`/`perPage`/`total`/`onPageChange` are plain
15
+ * numbers/callbacks — no coupling to Next.js routing (no useRouter/
16
+ * useSearchParams anywhere here) — directly mirrorable by a future Flutter
17
+ * pagination widget.
18
+ */
19
+ export interface PaginationProps extends Omit<React.ComponentProps<"nav">, "onChange"> {
20
+ /** 1-indexed current page. */
21
+ page: number
22
+ perPage: number
23
+ /** Total row count across all pages (not just the current page). */
24
+ total: number
25
+ onPageChange: (page: number) => void
26
+ /** Optional override for the "N entries" label (e.g. singular/plural, i18n). */
27
+ entriesLabel?: (total: number) => string
28
+ /**
29
+ * Optional override for "page 2 of 7".
30
+ *
31
+ * A function, not a string, for the same reason `entriesLabel` is one: the
32
+ * numbers sit INSIDE the sentence, and word order around them differs
33
+ * between languages. A caller that could only supply "page" and "of"
34
+ * separately would be pinned to English order.
35
+ */
36
+ pageLabel?: (page: number, totalPages: number) => string
37
+ /** Accessible name for the surrounding <nav>. */
38
+ navLabel?: string
39
+ /** Accessible name for the previous-page button. */
40
+ previousLabel?: string
41
+ /** Accessible name for the next-page button. */
42
+ nextLabel?: string
43
+ }
44
+
45
+ function Pagination({
46
+ className,
47
+ page,
48
+ perPage,
49
+ total,
50
+ onPageChange,
51
+ entriesLabel,
52
+ pageLabel,
53
+ navLabel = "Pagination",
54
+ previousLabel = "Previous page",
55
+ nextLabel = "Next page",
56
+ ...props
57
+ }: PaginationProps) {
58
+ const totalPages = Math.max(1, Math.ceil(total / perPage))
59
+ const label = entriesLabel ?? ((n: number) => (n === 1 ? "1 entry" : `${n} entries`))
60
+ const pages = pageLabel ?? ((current: number, last: number) => `page ${current} of ${last}`)
61
+
62
+ return (
63
+ <nav
64
+ data-slot="pagination"
65
+ aria-label={navLabel}
66
+ className={cn("flex items-center justify-between", className)}
67
+ {...props}
68
+ >
69
+ <p className="text-sm text-muted-foreground">
70
+ {label(total)} &middot; {pages(page, totalPages)}
71
+ </p>
72
+ <div className="flex gap-2">
73
+ <Button
74
+ type="button"
75
+ variant="outline"
76
+ size="icon-sm"
77
+ disabled={page <= 1}
78
+ onClick={() => onPageChange(Math.max(1, page - 1))}
79
+ aria-label={previousLabel}
80
+ >
81
+ <IconChevronLeft className="rtl:rotate-180" />
82
+ </Button>
83
+ <Button
84
+ type="button"
85
+ variant="outline"
86
+ size="icon-sm"
87
+ disabled={page >= totalPages}
88
+ onClick={() => onPageChange(Math.min(totalPages, page + 1))}
89
+ aria-label={nextLabel}
90
+ >
91
+ <IconChevronRight className="rtl:rotate-180" />
92
+ </Button>
93
+ </div>
94
+ </nav>
95
+ )
96
+ }
97
+
98
+ export { Pagination }
@@ -0,0 +1,180 @@
1
+ import type { Meta, StoryObj } from "@storybook/react-vite"
2
+ import { fn } from "storybook/test"
3
+ import * as React from "react"
4
+ import { IconCloudUpload, IconDatabase, IconPuzzle, IconShieldCheck } from "@tabler/icons-react"
5
+
6
+ import { PluginStoreCard, InstalledPluginCard, type PluginItem } from "./plugin-card"
7
+
8
+ const SAMPLE_PLUGINS: PluginItem[] = [
9
+ {
10
+ id: "p1",
11
+ name: "AI Document Summarizer",
12
+ author: "Whity AI Labs",
13
+ version: "2.4.0",
14
+ latestVersion: "2.5.0",
15
+ description: "Extract key takeaways, executive summaries, and action items from uploaded PDF documents using local or cloud LLM models.",
16
+ longDescription: "AI Document Summarizer provides native document parsing for PDF, DOCX, and TXT files. It integrates directly into Whity storage backends to offer one-click executive summaries, entity extraction, and automated metadata tagging with full multi-tenant isolation.",
17
+ category: "Productivity",
18
+ rating: 4.9,
19
+ reviewCount: 128,
20
+ icon: <IconPuzzle className="size-6 text-primary" />,
21
+ bannerGradient: "from-primary/30 via-slate-800/20 to-muted/80",
22
+ screenshots: [
23
+ "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&auto=format&fit=crop&q=60",
24
+ "https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&auto=format&fit=crop&q=60",
25
+ "https://images.unsplash.com/photo-1460925895917-afdab827c52f?w=800&auto=format&fit=crop&q=60",
26
+ ],
27
+ verified: true,
28
+ state: "update-available",
29
+ permissions: ["storage:read-write", "ai-engine:invoke", "documents:parse"],
30
+ versions: [
31
+ { version: "2.4.0", releasedLabel: "Current (Installed)", isCurrent: true },
32
+ { version: "2.3.1", releasedLabel: "2 weeks ago", changelog: "Added batch PDF processing worker support." },
33
+ { version: "2.2.0", releasedLabel: "1 month ago", changelog: "Initial multi-lingual summary support." },
34
+ ],
35
+ },
36
+ {
37
+ id: "p2",
38
+ name: "S3 Cloud Storage Connector",
39
+ author: "CloudSync Inc",
40
+ version: "1.8.2",
41
+ description: "Stream seamless backups, media assets, and export archives directly to Amazon S3, Cloudflare R2, or MinIO storage buckets.",
42
+ category: "Storage",
43
+ rating: 4.8,
44
+ reviewCount: 84,
45
+ icon: <IconCloudUpload className="size-6 text-blue-600 dark:text-blue-400" />,
46
+ bannerGradient: "from-blue-600/30 via-cyan-600/20 to-muted/80",
47
+ verified: true,
48
+ state: "active",
49
+ permissions: ["storage:read-write", "network:outbound-https"],
50
+ versions: [
51
+ { version: "1.8.2", releasedLabel: "Current", isCurrent: true },
52
+ { version: "1.7.5", releasedLabel: "3 weeks ago", changelog: "Added MinIO multipart upload chunking." },
53
+ { version: "1.6.0", releasedLabel: "2 months ago", changelog: "S3 server-side encryption support." },
54
+ ],
55
+ },
56
+ {
57
+ id: "p3",
58
+ name: "Advanced Audit Telemetry",
59
+ author: "Security Suite",
60
+ version: "3.1.0",
61
+ description: "Immutable audit event logging, SIEM webhook forwarding, and automated ISO 27001 compliance reporting.",
62
+ category: "Security",
63
+ rating: 4.95,
64
+ reviewCount: 210,
65
+ icon: <IconShieldCheck className="size-6 text-emerald-600 dark:text-emerald-400" />,
66
+ bannerGradient: "from-emerald-600/30 via-teal-600/20 to-muted/80",
67
+ verified: true,
68
+ state: "inactive",
69
+ permissions: ["audit-log:read-write", "webhooks:dispatch"],
70
+ versions: [
71
+ { version: "3.1.0", releasedLabel: "Current", isCurrent: true },
72
+ { version: "3.0.2", releasedLabel: "1 month ago" },
73
+ { version: "2.9.0", releasedLabel: "3 months ago" },
74
+ ],
75
+ },
76
+ {
77
+ id: "p4",
78
+ name: "Legacy Database Connector v1",
79
+ author: "Core Engine",
80
+ version: "1.0.4",
81
+ description: "Deprecated legacy MySQL 5.7 driver bridge. Restrictive policy enforced.",
82
+ category: "Database",
83
+ rating: 3.5,
84
+ reviewCount: 12,
85
+ icon: <IconDatabase className="size-6 text-red-600 dark:text-red-400" />,
86
+ bannerGradient: "from-red-600/30 via-amber-600/20 to-muted/80",
87
+ verified: false,
88
+ state: "disabled",
89
+ permissions: ["database:raw-connect"],
90
+ },
91
+ ]
92
+
93
+ const meta = {
94
+ title: "Primitives/PluginCard",
95
+ component: PluginStoreCard,
96
+ subcomponents: { InstalledPluginCard },
97
+ tags: ["autodocs"],
98
+ parameters: { layout: "padded" },
99
+ args: {
100
+ plugin: SAMPLE_PLUGINS[0],
101
+ onInstall: fn(),
102
+ onConfigure: fn(),
103
+ },
104
+ } satisfies Meta<typeof PluginStoreCard>
105
+
106
+ export default meta
107
+ type Story = StoryObj<typeof meta>
108
+
109
+ /** A single store card, driven entirely by the Controls panel. */
110
+ export const StoreCard: Story = {}
111
+
112
+ export const PluginStoreMarketplace: Story = {
113
+ render: (args) => (
114
+ <div className="space-y-4 max-w-4xl">
115
+ <div className="space-y-1">
116
+ <h3 className="text-base font-semibold text-foreground">Real-Store Plugin Marketplace</h3>
117
+ <p className="text-xs text-muted-foreground">
118
+ Features store preview banners, neutral rating stars positioned above title, clean borderless icons, and interactive image gallery inside More Info &gt; Overview modal.
119
+ </p>
120
+ </div>
121
+
122
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
123
+ {/* The first card is the `plugin` arg; the second shows a second
124
+ catalogue entry beside it, as the marketplace grid renders them. */}
125
+ {[args.plugin, SAMPLE_PLUGINS[1]].map((plugin) => (
126
+ <PluginStoreCard {...args} key={plugin.id} plugin={plugin} />
127
+ ))}
128
+ </div>
129
+ </div>
130
+ ),
131
+ }
132
+
133
+ /** `onUpdate` is not one of the store card's args, so it gets its own spy. */
134
+ const logUpdate = fn()
135
+
136
+ export const InstalledPluginsAllStates: Story = {
137
+ args: { plugin: SAMPLE_PLUGINS[0] },
138
+ render: ({ plugin, onConfigure }) => {
139
+ const [plugins, setPlugins] = React.useState<PluginItem[]>(() => [
140
+ plugin,
141
+ ...SAMPLE_PLUGINS.slice(1),
142
+ ])
143
+
144
+ const handleToggle = (target: PluginItem, newState: "active" | "inactive") => {
145
+ setPlugins((prev) =>
146
+ prev.map((p) => (p.id === target.id ? { ...p, state: newState } : p))
147
+ )
148
+ }
149
+
150
+ const handleRollback = (target: PluginItem, version: string) => {
151
+ setPlugins((prev) =>
152
+ prev.map((p) => (p.id === target.id ? { ...p, version, state: "active" } : p))
153
+ )
154
+ }
155
+
156
+ return (
157
+ <div className="space-y-4 max-w-4xl">
158
+ <div className="space-y-1">
159
+ <h3 className="text-base font-semibold text-foreground">Installed Plugins Management</h3>
160
+ <p className="text-xs text-muted-foreground">
161
+ Demonstrates Active, Inactive, Disabled by System, and Update Available (Blue info theme) states with version rollback and details modal gallery.
162
+ </p>
163
+ </div>
164
+
165
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
166
+ {plugins.map((p) => (
167
+ <InstalledPluginCard
168
+ key={p.id}
169
+ plugin={p}
170
+ onToggleState={handleToggle}
171
+ onUpdate={logUpdate}
172
+ onRollback={handleRollback}
173
+ onConfigure={onConfigure}
174
+ />
175
+ ))}
176
+ </div>
177
+ </div>
178
+ )
179
+ },
180
+ }