"use client" /** * Maps registry slugs → live preview sections (shadcn-style stacked examples). */ import * as React from "react" import { CatalogChartCardVariantPreview, CatalogDataTablePreview, CatalogHubTablePreview, CatalogKeyMetricsPreview, CatalogPageHeaderPreview, } from "@/components/catalog-live-previews" import { CommandPreview, SelectPreview, SelectionTileGridPreview, TableBulkActionBarPreview, } from "@/components/design-system/data-display-previews" import { getComponentDocSpec } from "@/lib/design-system/component-docs" import { DesignSystemExampleCanvas } from "@/components/design-system/component-doc-shell" import { DS_DOC_SECTION_TITLE } from "@/lib/design-system/doc-typography" import { CalendarPreview, DatePickerPreview, DateRangePickerPreview, DateTextInputPreview } from "@/components/design-system/date-previews" import { FieldLayoutsPreview, FormRhfPreview, RadioGroupChoiceCardPreview, RadioGroupDefaultPreview, RadioGroupDescriptionPreview, RadioGroupFieldsetPreview, RadioGroupInvalidPreview, } from "@/components/design-system/form-previews" import { InputDefaultPreview, InputGroupPreview, LabelPreview, SliderPreview, TextareaDefaultPreview, } from "@/components/design-system/input-previews" import { WizardAllVariantsPreview, WizardErrorStatePreview, WizardHorizontalCompactPreview, WizardHorizontalIconsPreview, WizardHorizontalNumberedPreview, WizardManyStepsPreview, WizardVerticalIconsPreview, WizardVerticalNumberedPreview, } from "@/components/design-system/wizard-previews" import { AccordionPreview, CollapsiblePreview, ScrollAreaPreview, SeparatorPreview, } from "@/components/design-system/layout-previews" import { BreadcrumbPreview, TabsPrimaryVariantsPreview, TabsSecondaryVariantsPreview, } from "@/components/design-system/navigation-previews" import { AlertDialogPreview, ContextMenuPreview, DialogPreview, DropdownMenuPreview, HoverCardPreview, PopoverPreview, TipPreview, TooltipPreview, } from "@/components/design-system/overlay-previews" import { AttachmentCountCellPreview, BooleanToggleCellPreview, CurrencyCellPreview, ExternalLinkCellPreview, NumericCellPreview, PeopleAvatarRailCellPreview, PillCellPreview, ProgressCellPreview, RatingCellPreview, RelativeTimeCellPreview, RowActionsCellPreview, SignalBarsCellPreview, TagListCellPreview, } from "@/components/design-system/table-cell-previews" export interface DesignSystemPreviewSection { id: string title: string description?: string bare?: boolean children: React.ReactNode } function section( id: string, title: string, children: React.ReactNode, description?: string, bare?: boolean, ): DesignSystemPreviewSection { return { id, title, description, children, bare } } const PREVIEW_SECTIONS: Record = { // button, avatar, toggle-switch → component-docs/*.tsx // ── Forms ─────────────────────────────────────────────────────────────── field: [ section("layouts", "Top and left label layouts", , "Vertical Field vs horizontal + SettingsFormRow."), ], form: [section("rhf", "react-hook-form", )], input: [ section("default", "Input", ), section("textarea", "Textarea", ), section("input-group", "Input group", , "Leading/trailing addons."), section("label", "Label", , "Prefer FieldLabel in product forms."), section("slider", "Slider", ), ], select: [section("default", "Default", )], // checkbox → component-docs/checkbox.tsx "radio-group": [ section("default", "Default", ), section("fieldset", "Fieldset", ), section("description", "With description", ), section("choice-card", "Choice card", ), section("invalid", "Invalid", ), section("selection-tile-grid", "Selection tiles", , "Radio/checkbox tile grid."), ], "date-picker": [ section("date-picker", "Date picker", ), section("date-range", "Date range", , "DateRangePickerField popover trigger."), section("date-text", "Masked text + calendar", , "DateTextInputField for filters."), section("calendar", "Calendar", , "Low-level date grid primitive."), ], wizard: [ section("all-variants", "All variants", , "Full matrix for QA — numbered, icons, compact, vertical, error, 8-step scroll."), section("horizontal-numbered", "Horizontal numbered", , "Brand completed · tint active · muted upcoming. Min 12px type."), section("horizontal-icons", "Horizontal icons", , "Icon markers; check replaces icon when done."), section("horizontal-compact", "Horizontal compact", , "Dot rail + Step N of M for dense flows."), section("vertical-numbered", "Vertical numbered", , "Sidebar rail — PatternFly wizard."), section("vertical-icons", "Vertical icons", , "Vertical icon rail with descriptions."), section("error", "Error state", , "Current-step validation failure."), section("many-steps", "Edge case: overflow", , "8-step stress test for scroll + guidance — not a product pattern."), ], // ── Overlays ──────────────────────────────────────────────────────────── dialog: [ section("default", "Default", ), section("alert-dialog", "Alert dialog", , "Destructive / ack with actions."), ], popover: [ section("default", "Default", ), section("hover-card", "Hover card", , "Row identity preview on hover."), ], "dropdown-menu": [ section("default", "Default", ), section("context-menu", "Context menu", , "Right-click menu."), ], tip: [ section("default", "Default", , "Product tooltip wrapper; prefer in app code."), section("tooltip", "Tooltip primitive", , "Low-level primitive; Tip is the default."), ], command: [section("default", "Default", )], // ── Navigation ────────────────────────────────────────────────────────── breadcrumb: [section("default", "Default", )], tabs: [ section( "default-variant", "Default variant", , "Pill tablist (`variant` default). Label only, with icon, or with TabsCountBadge.", ), section( "line-variant", "Line variant", , "Underline tablist (`variant=\"line\"`). Same three trigger shapes.", ), ], // badge, card, coach-mark, kbd, skeleton → component-docs/*.tsx // ── Layout ────────────────────────────────────────────────────────────── accordion: [ section("default", "Default", ), section("collapsible", "Collapsible", ), ], separator: [ section("default", "Default", ), section("scroll-area", "Scroll area", ), ], // ── Data display ──────────────────────────────────────────────────────── // avatar → component-docs/avatar.tsx // table → component-docs/table.tsx "chart-card": [ section("normal", "Normal", , "Title, description, chart body, Ask Leo on card hover."), section( "tabs", "Tabs", , "Chart and Trend panels. Uses the same line tab chrome as metrics tabs.", ), section("selector", "Selector", , "Header filter select."), section( "metrics-tabs", "Metrics tabs", , "Metric cells are tab triggers.", ), section("kpi-chart", "KPI + chart", , "Hero metric above the chart."), ], // ── Patterns · Data views ─────────────────────────────────────────────── "data-table": [ section("grid", "Core grid", , "Sort, filters, resize."), section("hub-table", "HubTable", , "useTableState + toolbar + Properties."), section( "bulk-actions", "Bulk action bar", , "Floating bar when rows are selected; Esc clears.", ), ], "key-metrics": [section("variants", "Flat, card strip, and metric cards", )], "page-header": [section("default", "Hub header", )], // ── Table cells ───────────────────────────────────────────────────────── "table-cells": [ section("progress-cell", "Progress", ), section("currency-cell", "Currency", ), section("numeric-cell", "Numeric", ), section("rating-cell", "Rating", ), section("signal-bars-cell", "Signal bars", ), section("boolean-toggle-cell", "Boolean toggle", ), section("pill-cell", "Pill", ), section("tag-list-cell", "Tag list", ), section("people-avatar-rail-cell", "People rail", ), section("external-link-cell", "External link", ), section("relative-time-cell", "Relative time", ), section("attachment-count-cell", "Attachment count", ), section("row-actions-cell", "Row actions", ), ], } export function getDesignSystemPreviewSections(slug: string): DesignSystemPreviewSection[] | null { const spec = getComponentDocSpec(slug) if (spec?.sections.length) { return spec.sections.map((block) => ({ id: block.id, title: block.title, description: block.description, bare: block.bare, children: block.children, })) } const sections = PREVIEW_SECTIONS[slug] return sections && sections.length > 0 ? sections : null } export function designSystemHasLivePreview(slug: string): boolean { const spec = getComponentDocSpec(slug) if (spec?.sections.length) return true return Boolean(PREVIEW_SECTIONS[slug]?.length) } const WIDE_PREVIEW_SLUGS = new Set([ "banner", "table", "data-table", "hub-table", "table-cells", "wizard", "coach-mark", "tokens-colors", "tokens-gradients", "tokens-aliases", ]) export function DesignSystemPreviewSections({ slug }: { slug: string }) { const sections = getDesignSystemPreviewSections(slug) if (!sections) return null const wideCanvas = WIDE_PREVIEW_SLUGS.has(slug) || slug.startsWith("tokens-") return (
{sections.map((block) => (
{block.bare ? null : (

{block.title}

)} {block.children}
))}
) }