@vantageos/mosaic-blocks 0.5.35-alpha → 0.5.37-alpha
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 +11 -8
- package/dist/index.cjs +828 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +415 -11
- package/dist/index.d.ts +415 -11
- package/dist/index.js +809 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +20 -7
- package/r/mosaic-accordion.json +1 -2
- package/r/mosaic-activity-feed.json +16 -0
- package/r/mosaic-adaptive-grid.json +18 -0
- package/r/mosaic-adaptive-modal.json +18 -0
- package/r/mosaic-adaptive-navigation.json +18 -0
- package/r/mosaic-add-memory-form.json +25 -0
- package/r/mosaic-admin-only-guard.json +18 -0
- package/r/mosaic-agent-builder-modal.json +23 -0
- package/r/mosaic-agent-card.json +16 -0
- package/r/mosaic-agent-chat.json +26 -0
- package/r/mosaic-agent-composer.json +28 -0
- package/r/mosaic-agent-editor.json +25 -0
- package/r/mosaic-agent-list.json +21 -0
- package/r/mosaic-agent-preview.json +21 -0
- package/r/mosaic-alert-dialog.json +23 -0
- package/r/mosaic-animated-list.json +16 -0
- package/r/mosaic-api-key-panel.json +21 -0
- package/r/mosaic-app-sidebar.json +18 -0
- package/r/mosaic-approval-prompt.json +21 -0
- package/r/mosaic-artifact-canvas-adapter.json +26 -0
- package/r/mosaic-artifact-chart.json +18 -0
- package/r/mosaic-artifact-checklist.json +18 -0
- package/r/mosaic-artifact-data-table.json +18 -0
- package/r/mosaic-artifact-document.json +16 -0
- package/r/mosaic-artifact-library.json +18 -0
- package/r/mosaic-artifact-save-as-memory-form.json +24 -0
- package/r/mosaic-artifact-version-history.json +16 -0
- package/r/mosaic-avatar.json +18 -0
- package/r/mosaic-badge.json +23 -0
- package/r/mosaic-blurred-orb.json +16 -0
- package/r/mosaic-button.json +24 -0
- package/r/mosaic-callout.json +23 -0
- package/r/mosaic-card.json +16 -0
- package/r/mosaic-chat-composer.json +21 -0
- package/r/mosaic-chat-message.json +23 -0
- package/r/mosaic-chat-sidebar.json +21 -0
- package/r/mosaic-chat-thread.json +21 -0
- package/r/mosaic-checkbox.json +18 -0
- package/r/mosaic-clerk-org-switcher.json +18 -0
- package/r/mosaic-clerk-webhook-handler.json +18 -0
- package/r/mosaic-collapsible.json +18 -0
- package/r/mosaic-combobox.json +18 -0
- package/r/mosaic-counter.json +16 -0
- package/r/mosaic-dashboard-content.json +18 -0
- package/r/mosaic-dashboard-header.json +18 -0
- package/r/mosaic-dashboard-layout.json +20 -0
- package/r/mosaic-data-table.json +16 -0
- package/r/mosaic-delete-confirmation-dialog.json +18 -0
- package/r/mosaic-device-provider.json +16 -0
- package/r/mosaic-document-table.json +52 -0
- package/r/mosaic-document-upload.json +21 -0
- package/r/mosaic-drawer.json +23 -0
- package/r/mosaic-dropdown-menu.json +18 -0
- package/r/mosaic-edit-memory-dialog.json +27 -0
- package/r/mosaic-edit-session-dialog.json +25 -0
- package/r/mosaic-editable-cell.json +23 -0
- package/r/mosaic-empty-state.json +16 -0
- package/r/mosaic-falling-pattern.json +16 -0
- package/r/mosaic-feature-3col.json +16 -0
- package/r/mosaic-feature-centered-media.json +16 -0
- package/r/mosaic-field.json +18 -0
- package/r/mosaic-filter-bar.json +18 -0
- package/r/mosaic-filter-sidebar.json +18 -0
- package/r/mosaic-footer-simple.json +16 -0
- package/r/mosaic-grille-registre.json +53 -0
- package/r/mosaic-hero-split.json +16 -0
- package/r/mosaic-input-group.json +16 -0
- package/r/mosaic-input.json +18 -0
- package/r/mosaic-integrations-badge.json +16 -0
- package/r/mosaic-kanban-board.json +21 -0
- package/r/mosaic-logos-grid.json +16 -0
- package/r/mosaic-main-nav.json +18 -0
- package/r/mosaic-markdown.json +21 -0
- package/r/mosaic-marketplace-card.json +24 -0
- package/r/mosaic-marketplace-list.json +20 -0
- package/r/mosaic-match-input.json +23 -0
- package/r/mosaic-memory-card.json +21 -0
- package/r/mosaic-memory-dashboard.json +23 -0
- package/r/mosaic-memory-grid.json +21 -0
- package/r/mosaic-memory-list.json +21 -0
- package/r/mosaic-memory-search.json +23 -0
- package/r/mosaic-mention-input.json +23 -0
- package/r/mosaic-message-card.json +16 -0
- package/r/mosaic-message-list.json +19 -0
- package/r/mosaic-message-search.json +18 -0
- package/r/mosaic-model-selector.json +23 -0
- package/r/mosaic-module-card.json +16 -0
- package/r/mosaic-module-library.json +18 -0
- package/r/mosaic-multi-tenant-provider.json +19 -0
- package/r/mosaic-navbar.json +16 -0
- package/r/mosaic-org-context-display.json +18 -0
- package/r/mosaic-org-panel.json +19 -0
- package/r/mosaic-org-profile-page.json +18 -0
- package/r/mosaic-org-switcher.json +16 -0
- package/r/mosaic-pdf-viewer.json +23 -0
- package/r/mosaic-popover.json +23 -0
- package/r/mosaic-preferences-panel.json +18 -0
- package/r/mosaic-pricing-card.json +16 -0
- package/r/mosaic-profile-panel.json +18 -0
- package/r/mosaic-progress.json +18 -0
- package/r/mosaic-quick-action-card.json +16 -0
- package/r/mosaic-quick-actions-menu.json +18 -0
- package/r/mosaic-quick-agent-selector.json +19 -0
- package/r/mosaic-radio-group.json +18 -0
- package/r/mosaic-reply-input.json +21 -0
- package/r/mosaic-resizable-split-pane.json +23 -0
- package/r/mosaic-save-chat-as-memory-form.json +25 -0
- package/r/mosaic-save-template-modal.json +27 -0
- package/r/mosaic-scroll-area.json +18 -0
- package/r/mosaic-select.json +18 -0
- package/r/mosaic-selector-modal.json +18 -0
- package/r/mosaic-separator.json +18 -0
- package/r/mosaic-session-card.json +24 -0
- package/r/mosaic-session-list.json +21 -0
- package/r/mosaic-sign-in-layout.json +18 -0
- package/r/mosaic-sign-up-layout.json +18 -0
- package/r/mosaic-skeleton.json +23 -0
- package/r/mosaic-slider.json +18 -0
- package/r/mosaic-stats-grid.json +16 -0
- package/r/mosaic-step-pipeline.json +21 -0
- package/r/mosaic-switch.json +18 -0
- package/r/mosaic-tabs.json +18 -0
- package/r/mosaic-tag-input.json +23 -0
- package/r/mosaic-template-agent-card.json +21 -0
- package/r/mosaic-template-category-chips.json +21 -0
- package/r/mosaic-template-gallery.json +20 -0
- package/r/mosaic-template-list.json +21 -0
- package/r/mosaic-template-management-panel.json +25 -0
- package/r/mosaic-testimonials-grid.json +16 -0
- package/r/mosaic-textarea.json +16 -0
- package/r/mosaic-theme-provider.json +18 -0
- package/r/mosaic-theme-toggle.json +16 -0
- package/r/mosaic-thread-indicator.json +21 -0
- package/r/mosaic-thread-view.json +21 -0
- package/r/mosaic-toast.json +28 -0
- package/r/mosaic-tool-toggle-list.json +23 -0
- package/r/mosaic-tooltip.json +18 -0
- package/r/mosaic-url-scraper.json +21 -0
- package/r/mosaic-user-button.json +18 -0
- package/r/use-effective-workspace-id.json +18 -0
- package/registry.json +77 -130
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-canvas-adapter",
|
|
4
|
+
"title": "MosaicArtifactCanvasAdapter",
|
|
5
|
+
"description": "MosaicArtifactCanvasAdapter — dual-source artifact runtime chrome.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/artifact-canvas-adapter/MosaicArtifactCanvasAdapter.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicArtifactCanvasAdapter — dual-source artifact runtime chrome.\n *\n * Absorbs the 4 any-debate-ai runtime concerns (canvas-toggle, artifact-canvas,\n * artifact-renderer, artifact-toolbar) behind ONE presentation layer that\n * renders under either runtime source:\n *\n * (a) @ai-sdk-tools/artifacts — pass `source={{ kind: \"ai-sdk-artifacts\", ... }}`\n * (b) MCP Apps ui:// bridge — pass `source={{ kind: \"mcp-ui\", ... }}`\n *\n * Both are normalized by `normalizeArtifact` (./normalize.ts) into one\n * `NormalizedArtifact` shape before this component ever touches them — this\n * component itself never branches on `source.kind` beyond that single call.\n *\n * i18n: zero hardcoded user-facing strings (mosaic-blocks doctrine — see\n * src/__tests__/i18n-no-hardcoded-literals.test.ts). Every label is a\n * required prop; the host owns the language.\n *\n * data-slot=\"artifact-canvas-adapter\" on the root, \"artifact-canvas-toggle\"\n * on the toggle button, \"artifact-canvas-toolbar\" on the toolbar,\n * \"artifact-canvas-body\" on the rendered artifact region.\n */\n\nimport type * as React from \"react\";\nimport { normalizeArtifact } from \"./normalize.js\";\nimport type { ArtifactCanvasSource, ArtifactType } from \"./types.js\";\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicArtifactCanvasAdapterLabels {\n /** Accessible name for the collapsed-state toggle button. */\n toggleLabel: string;\n /** Accessible name for the canvas close button. */\n closeLabel: string;\n /** Region heading shown in the toolbar when the canvas is open. */\n toolbarHeading: string;\n /** Heading shown when no artifact is active. */\n emptyTitle: string;\n /** Body copy shown when no artifact is active. */\n emptyBody: string;\n /** Heading shown when the source resolves to no renderable artifact. */\n notFoundTitle: string;\n /** Body copy shown when the source resolves to no renderable artifact. */\n notFoundBody: string;\n /** Localizes the artifact type badge, e.g. (t) => ({ document: \"Document\", ... })[t]. */\n typeLabel: (type: ArtifactType) => string;\n}\n\nexport interface MosaicArtifactCanvasAdapterProps {\n /** Either runtime source; `null` renders the empty state. */\n source: ArtifactCanvasSource | null;\n isOpen: boolean;\n onToggle: () => void;\n onClose: () => void;\n labels: MosaicArtifactCanvasAdapterLabels;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport function MosaicArtifactCanvasAdapter({\n source,\n isOpen,\n onToggle,\n onClose,\n labels,\n className,\n ref,\n}: MosaicArtifactCanvasAdapterProps) {\n const artifact = source ? normalizeArtifact(source) : null;\n\n return (\n <div ref={ref} data-slot=\"artifact-canvas-adapter\" className={cn(\"relative\", className)}>\n <button\n type=\"button\"\n data-slot=\"artifact-canvas-toggle\"\n aria-label={labels.toggleLabel}\n aria-expanded={isOpen}\n onClick={onToggle}\n className={cn(\n \"inline-flex items-center justify-center rounded-md px-3 py-1.5 text-sm font-medium\",\n \"outline-none transition-colors\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"bg-muted text-muted-foreground hover:text-foreground\",\n )}\n >\n {labels.toggleLabel}\n </button>\n\n {isOpen && (\n <section\n aria-label={labels.toolbarHeading}\n data-slot=\"artifact-canvas\"\n className={cn(\n \"mt-2 flex flex-col rounded-lg border border-border bg-background\",\n \"shadow-xs\",\n )}\n >\n <div\n data-slot=\"artifact-canvas-toolbar\"\n className=\"flex items-center justify-between border-border border-b px-4 py-2\"\n >\n <span className=\"font-medium text-sm\">{labels.toolbarHeading}</span>\n <button\n type=\"button\"\n aria-label={labels.closeLabel}\n onClick={onClose}\n className={cn(\n \"rounded-md p-1 outline-none transition-colors\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"hover:bg-muted\",\n )}\n >\n {labels.closeLabel}\n </button>\n </div>\n\n <div data-slot=\"artifact-canvas-body\" className=\"flex-1 p-4\">\n {!source && (\n <div className=\"text-center\">\n <p className=\"font-medium text-muted-foreground\">{labels.emptyTitle}</p>\n <p className=\"mt-1 text-muted-foreground/70 text-sm\">{labels.emptyBody}</p>\n </div>\n )}\n\n {source && !artifact && (\n <div className=\"text-center\">\n <p className=\"font-medium text-muted-foreground\">{labels.notFoundTitle}</p>\n <p className=\"mt-1 text-muted-foreground/70 text-sm\">{labels.notFoundBody}</p>\n </div>\n )}\n\n {artifact && (\n <div data-slot=\"artifact-canvas-artifact\" data-artifact-type={artifact.type}>\n <div className=\"flex items-center gap-2\">\n <span\n data-slot=\"artifact-canvas-type-badge\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {labels.typeLabel(artifact.type)}\n </span>\n <h3 className=\"font-semibold text-base\">{artifact.title}</h3>\n </div>\n </div>\n )}\n </div>\n </section>\n )}\n </div>\n );\n}\n\nMosaicArtifactCanvasAdapter.displayName = \"MosaicArtifactCanvasAdapter\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/artifact-canvas-adapter/normalize.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "import type {\n AiSdkArtifactsSource,\n ArtifactCanvasSource,\n ArtifactType,\n McpUiSource,\n NormalizedArtifact,\n} from \"./types.js\";\n\nconst KNOWN_TYPES: readonly ArtifactType[] = [\"document\", \"data-table\", \"checklist\", \"chart\"];\n\nfunction isArtifactType(value: string): value is ArtifactType {\n return (KNOWN_TYPES as readonly string[]).includes(value);\n}\n\nfunction titleFromData(data: Record<string, unknown>): string {\n return typeof data.title === \"string\" ? data.title : \"\";\n}\n\n/** Source (a): @ai-sdk-tools/artifacts `useArtifacts()` shape. */\nexport function normalizeFromAiSdkArtifacts(\n source: AiSdkArtifactsSource,\n): NormalizedArtifact | null {\n if (!source.activeId) return null;\n const entry = source.artifacts.find((a) => a.id === source.activeId);\n if (!entry) return null;\n if (!isArtifactType(entry.type)) return null;\n return {\n id: entry.id,\n type: entry.type,\n title: titleFromData(entry.data),\n data: entry.data,\n };\n}\n\n/**\n * Source (b): MCP Apps ui:// bridge. Requires the GA-nested key\n * `_meta.ui.resourceUri` (matches mcp-doctor D6 `present`/conforming state).\n * The artifact type is the last path segment of the resourceUri\n * (`ui://artifact-canvas/document` -> \"document\"); `structuredContent` is\n * the artifact payload, same shape family as the ai-sdk-artifacts entry.\n */\nexport function normalizeFromMcpToolResult(source: McpUiSource): NormalizedArtifact | null {\n const resourceUri = source.toolResult?._meta?.ui?.resourceUri;\n if (!resourceUri) return null;\n\n const segments = resourceUri.split(\"/\").filter(Boolean);\n const typeSegment = segments[segments.length - 1];\n if (!typeSegment || !isArtifactType(typeSegment)) return null;\n\n const data = source.toolResult.structuredContent ?? {};\n const id = typeof data.id === \"string\" ? data.id : resourceUri;\n\n return {\n id,\n type: typeSegment,\n title: titleFromData(data),\n data,\n };\n}\n\n/** Single entry point: dispatches to the right normalizer by `source.kind`. */\nexport function normalizeArtifact(source: ArtifactCanvasSource): NormalizedArtifact | null {\n if (source.kind === \"ai-sdk-artifacts\") return normalizeFromAiSdkArtifacts(source);\n if (source.kind === \"mcp-ui\") return normalizeFromMcpToolResult(source);\n return null;\n}\n"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "src/components/artifact-canvas-adapter/types.ts",
|
|
21
|
+
"type": "registry:ui",
|
|
22
|
+
"content": "/**\n * artifact-canvas-adapter — dual-source contract.\n *\n * The adapter normalizes an artifact from EITHER runtime source into one\n * internal shape (`NormalizedArtifact`) so a single presentation layer\n * renders under both:\n *\n * (a) @ai-sdk-tools/artifacts — `useArtifacts()` client shape\n * (b) MCP Apps ui:// bridge — GA nested `_meta.ui.resourceUri` tool result\n *\n * Never widen this file to a third shape without adding its own\n * `normalizeFrom*` function and a dedicated integration test proving the\n * new source traverses the adapter at runtime — see D6 (mcp-doctor) for the\n * static form-check this shape must keep satisfying.\n */\n\nexport type ArtifactType = \"document\" | \"data-table\" | \"checklist\" | \"chart\";\n\nexport interface NormalizedArtifact {\n id: string;\n type: ArtifactType;\n title: string;\n /** Raw source-specific payload, kept for the type-specific renderer. */\n data: Record<string, unknown>;\n}\n\n// ── (a) @ai-sdk-tools/artifacts source shape ──────────────────────────────────\n\nexport interface AiSdkArtifactEntry {\n id: string;\n type: string;\n data: Record<string, unknown>;\n}\n\nexport interface AiSdkArtifactsSource {\n kind: \"ai-sdk-artifacts\";\n artifacts: AiSdkArtifactEntry[];\n activeId: string | null;\n}\n\n// ── (b) MCP Apps ui:// bridge source shape ────────────────────────────────────\n\n/**\n * The GA-nested MCP Apps UI key, exactly the form D6 (mcp-doctor) classifies\n * as `present`/conforming: `_meta: { ui: { resourceUri } }`. Community\n * (`io.modelcontextprotocol/ui`) and flat (`ui/resourceUri`) forms are\n * rejected by the normalizer — see `normalizeFromMcpToolResult`.\n */\nexport interface McpToolResultMeta {\n ui: { resourceUri: string };\n}\n\n// Inlined on one line (not the `McpToolResultMeta` alias) so the literal\n// GA-nested shape `_meta: { ui: ...}` is present verbatim in production\n// source — this is what mcp-doctor's D6 detector classifies as\n// `present`/conforming, distinct from the community and flat deprecated\n// forms it rejects.\nexport interface McpToolResult {\n structuredContent: Record<string, unknown>;\n _meta: { ui: { resourceUri: string } };\n}\n\nexport interface McpUiSource {\n kind: \"mcp-ui\";\n toolResult: McpToolResult;\n}\n\nexport type ArtifactCanvasSource = AiSdkArtifactsSource | McpUiSource;\n"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"type": "registry:ui"
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-chart",
|
|
4
|
+
"title": "MosaicArtifactChart",
|
|
5
|
+
"description": "MosaicArtifactChart — dumb, contract-agnostic chart artifact renderer",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"recharts"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/artifact-chart/MosaicArtifactChart.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicArtifactChart — dumb, contract-agnostic chart artifact renderer\n *\n * Renders a normalized chart artifact payload with Recharts (already the\n * charting library mosaic-blocks standardizes on). Owns no knowledge of its\n * runtime source (@ai-sdk-tools/artifacts vs the MCP Apps ui:// bridge); it\n * consumes the same `data` shape either source normalizes to.\n *\n * Read-only presentation. Ported from any-debate-ai's ChartArtifact,\n * stripped of the type-switcher/refresh/download toolbar to keep this a\n * pure render component, per the C1 adapter contract.\n *\n * `recharts` is a genuinely OPTIONAL peer dependency (see package.json\n * peerDependenciesMeta) — only hosts rendering chart artifacts need it.\n * mosaic-blocks does not bundle it: this component follows the repo's\n * canonical optional-peer pattern (dependency injection, see\n * MosaicUserButton/MosaicMultiTenantProvider) instead of a static top-level\n * `import ... from \"recharts\"`, which would make recharts a hard runtime\n * requirement and contradict the \"optional\" contract — a caller without\n * recharts installed would crash at module-resolution time. Only\n * `import type` is used below: type-only imports are erased at build time,\n * so no runtime dependency on recharts exists in the published bundle.\n * Callers that DO want charts pass the recharts primitives via the\n * `recharts` prop; callers that don't render `labels.unavailableMessage`.\n *\n * data-slot=\"artifact-chart\" on the root.\n *\n * i18n: zero hardcoded user-facing strings — every label is a required\n * prop (mosaic-blocks doctrine, see src/__tests__/i18n-no-hardcoded-literals.test.ts).\n */\n\nimport type * as React from \"react\";\nimport type {\n BarChart as BarChartType,\n Bar as BarType,\n CartesianGrid as CartesianGridType,\n Cell as CellType,\n Legend as LegendType,\n LineChart as LineChartType,\n Line as LineType,\n PieChart as PieChartType,\n Pie as PieType,\n ResponsiveContainer as ResponsiveContainerType,\n Tooltip as TooltipType,\n XAxis as XAxisType,\n YAxis as YAxisType,\n} from \"recharts\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// No hex fallbacks on purpose: --color-chart-N is declared by src/styles.css\n// from the tokens package (light + dark sets). A hardcoded fallback would win\n// silently whenever that declaration went missing and paint the same colours in\n// both themes — the defect this replaced. A host that skips styles.css sees the\n// missing series at once instead of a plausible-looking wrong palette.\nconst CHART_COLORS = [\n \"var(--color-chart-1)\",\n \"var(--color-chart-2)\",\n \"var(--color-chart-3)\",\n \"var(--color-chart-4)\",\n \"var(--color-chart-5)\",\n];\n\n// ── Data shape ────────────────────────────────────────────────────────────────\n\nexport type MosaicArtifactChartType = \"bar\" | \"line\" | \"pie\";\n\nexport interface MosaicArtifactChartConfig {\n xAxis?: string;\n colors?: string[];\n legend?: boolean;\n grid?: boolean;\n}\n\nexport interface MosaicArtifactChartData {\n title: string;\n type: MosaicArtifactChartType;\n data: Record<string, unknown>[];\n config?: MosaicArtifactChartConfig;\n metadata?: {\n dataSource?: string;\n description?: string;\n };\n}\n\nexport interface MosaicArtifactChartLabels {\n /** Formats the chart-type badge, e.g. (type) => `${type} Chart`. */\n typeBadgeLabel: (type: MosaicArtifactChartType) => string;\n /** Formats the point-count badge, e.g. (n) => `${n} points`. */\n pointsLabel: (count: number) => string;\n /** Shown when `data.type` is not one of bar/line/pie. */\n unsupportedTypeMessage: (type: string) => string;\n /** Shown when the `recharts` prop is not supplied (optional peer absent). */\n unavailableMessage: string;\n}\n\n/**\n * Recharts primitives injected by the caller. Optional peer dependency —\n * omit entirely when the host app does not render charts; the component\n * then renders `labels.unavailableMessage` instead of crashing.\n *\n * @example\n * import * as Recharts from \"recharts\"\n * <MosaicArtifactChart data={data} labels={labels} recharts={Recharts} />\n */\nexport interface MosaicArtifactChartRecharts {\n BarChart: typeof BarChartType;\n Bar: typeof BarType;\n LineChart: typeof LineChartType;\n Line: typeof LineType;\n PieChart: typeof PieChartType;\n Pie: typeof PieType;\n Cell: typeof CellType;\n XAxis: typeof XAxisType;\n YAxis: typeof YAxisType;\n CartesianGrid: typeof CartesianGridType;\n Tooltip: typeof TooltipType;\n Legend: typeof LegendType;\n ResponsiveContainer: typeof ResponsiveContainerType;\n}\n\nexport interface MosaicArtifactChartProps {\n data: MosaicArtifactChartData;\n labels: MosaicArtifactChartLabels;\n /** recharts primitives — omit when the optional recharts peer is absent. */\n recharts?: MosaicArtifactChartRecharts;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Render helpers ────────────────────────────────────────────────────────────\n\nfunction seriesKeys(rows: Record<string, unknown>[], xAxisKey: string): string[] {\n return Object.keys(rows[0] ?? {}).filter((key) => key !== xAxisKey);\n}\n\nfunction renderChart(\n data: MosaicArtifactChartData,\n labels: MosaicArtifactChartLabels,\n recharts: MosaicArtifactChartRecharts,\n): React.ReactNode {\n const {\n BarChart,\n Bar,\n LineChart,\n Line,\n PieChart,\n Pie,\n Cell,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n Legend,\n ResponsiveContainer,\n } = recharts;\n const xAxisKey = data.config?.xAxis ?? Object.keys(data.data[0] ?? {})[0] ?? \"\";\n const colors = data.config?.colors ?? CHART_COLORS;\n\n if (data.type === \"bar\") {\n return (\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChart data={data.data} margin={{ top: 20, right: 30, left: 20, bottom: 5 }}>\n {data.config?.grid && <CartesianGrid strokeDasharray=\"3 3\" />}\n <XAxis dataKey={xAxisKey} />\n <YAxis />\n <Tooltip />\n {data.config?.legend && <Legend />}\n {seriesKeys(data.data, xAxisKey).map((key, index) => (\n <Bar key={key} dataKey={key} fill={colors[index % colors.length]} />\n ))}\n </BarChart>\n </ResponsiveContainer>\n );\n }\n\n if (data.type === \"line\") {\n return (\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <LineChart data={data.data} margin={{ top: 20, right: 30, left: 20, bottom: 5 }}>\n {data.config?.grid && <CartesianGrid strokeDasharray=\"3 3\" />}\n <XAxis dataKey={xAxisKey} />\n <YAxis />\n <Tooltip />\n {data.config?.legend && <Legend />}\n {seriesKeys(data.data, xAxisKey).map((key, index) => (\n <Line\n key={key}\n type=\"monotone\"\n dataKey={key}\n stroke={colors[index % colors.length]}\n strokeWidth={2}\n />\n ))}\n </LineChart>\n </ResponsiveContainer>\n );\n }\n\n if (data.type === \"pie\") {\n const nameKey = Object.keys(data.data[0] ?? {})[0] ?? \"name\";\n const valueKey = Object.keys(data.data[0] ?? {})[1] ?? \"value\";\n return (\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <PieChart>\n <Pie data={data.data} cx=\"50%\" cy=\"50%\" outerRadius={80} dataKey={valueKey}>\n {data.data.map((entry, index) => (\n <Cell key={String(entry[nameKey] ?? index)} fill={colors[index % colors.length]} />\n ))}\n </Pie>\n <Tooltip />\n {data.config?.legend && <Legend />}\n </PieChart>\n </ResponsiveContainer>\n );\n }\n\n return (\n <div className=\"flex h-full items-center justify-center text-muted-foreground text-sm\">\n {labels.unsupportedTypeMessage(data.type)}\n </div>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicArtifactChart — read-only chart artifact renderer (bar/line/pie).\n *\n * @example\n * <MosaicArtifactChart\n * data={{ title: \"Q3 revenue\", type: \"bar\", data: [{ month: \"Jul\", value: 100 }] }}\n * labels={{\n * typeBadgeLabel: (t) => `${t} Chart`,\n * pointsLabel: (n) => `${n} points`,\n * unsupportedTypeMessage: (t) => `Unsupported chart type: ${t}`,\n * unavailableMessage: \"Charts unavailable\",\n * }}\n * recharts={Recharts}\n * />\n */\nexport function MosaicArtifactChart({\n data,\n labels,\n recharts,\n className,\n ref,\n}: MosaicArtifactChartProps) {\n return (\n <div\n ref={ref}\n data-slot=\"artifact-chart\"\n className={cn(\n \"flex h-full flex-col rounded-lg border border-border bg-background\",\n className,\n )}\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4 py-3\">\n <h3 className=\"font-medium text-base\">{data.title}</h3>\n <span\n data-slot=\"artifact-chart-type-badge\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {labels.typeBadgeLabel(data.type)}\n </span>\n <span className=\"rounded-full border border-border px-2 py-0.5 text-muted-foreground text-xs\">\n {labels.pointsLabel(data.data.length)}\n </span>\n </div>\n\n <div className=\"min-h-64 flex-1 p-6\">\n {recharts ? (\n renderChart(data, labels, recharts)\n ) : (\n <div\n data-slot=\"artifact-chart-unavailable\"\n className=\"flex h-full items-center justify-center text-muted-foreground text-sm\"\n >\n {labels.unavailableMessage}\n </div>\n )}\n </div>\n\n {(data.metadata?.dataSource || data.metadata?.description) && (\n <div className=\"border-border border-t px-4 py-3\">\n <div className=\"flex items-center gap-4 text-muted-foreground text-xs\">\n {data.metadata?.dataSource && <span>{data.metadata.dataSource}</span>}\n {data.metadata?.description && <span>{data.metadata.description}</span>}\n </div>\n </div>\n )}\n </div>\n );\n}\n\nMosaicArtifactChart.displayName = \"MosaicArtifactChart\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-checklist",
|
|
4
|
+
"title": "MosaicArtifactChecklist",
|
|
5
|
+
"description": "MosaicArtifactChecklist — dumb, contract-agnostic checklist artifact renderer",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-progress.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/artifact-checklist/MosaicArtifactChecklist.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicArtifactChecklist — dumb, contract-agnostic checklist artifact renderer\n *\n * Renders a normalized checklist artifact payload on top of the existing\n * `MosaicProgress` atom (reuse-first). Owns no knowledge of its runtime\n * source (@ai-sdk-tools/artifacts vs the MCP Apps ui:// bridge); it consumes\n * the same `data` shape either source normalizes to.\n *\n * Read-only presentation. Ported from any-debate-ai's ChecklistArtifact,\n * stripped of the toggle/add/delete/bulk-action state to keep this a pure\n * render component, per the C1 adapter contract.\n *\n * data-slot=\"artifact-checklist\" on the root, \"artifact-checklist-item\" per item.\n *\n * i18n: zero hardcoded user-facing strings — every label is a required\n * prop (mosaic-blocks doctrine, see src/__tests__/i18n-no-hardcoded-literals.test.ts).\n */\n\nimport type * as React from \"react\";\nimport { MosaicProgress } from \"@/components/ui/MosaicProgress\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Data shape ────────────────────────────────────────────────────────────────\n\nexport type MosaicArtifactChecklistPriority = \"low\" | \"medium\" | \"high\";\n\nexport interface MosaicArtifactChecklistItem {\n id: string;\n text: string;\n completed: boolean;\n priority?: MosaicArtifactChecklistPriority;\n dueDate?: number | string;\n assignee?: string;\n notes?: string;\n}\n\nexport interface MosaicArtifactChecklistData {\n title: string;\n description?: string;\n items: MosaicArtifactChecklistItem[];\n metadata?: {\n category?: string;\n };\n}\n\nexport interface MosaicArtifactChecklistLabels {\n /** Accessible text for the \"Checklist\" type badge. */\n typeBadgeLabel: string;\n /** Formats the header completed/total badge, e.g. (c, t) => `${c}/${t}`. */\n progressLabel: (completed: number, total: number) => string;\n /** Formats the progress-section summary line. */\n completedOfTotalLabel: (completed: number, total: number, percent: number) => string;\n /** Shown when there are no items. */\n emptyMessage: string;\n /** Localizes an item's priority badge. */\n priorityLabel: (priority: MosaicArtifactChecklistPriority) => string;\n}\n\nexport interface MosaicArtifactChecklistProps {\n data: MosaicArtifactChecklistData;\n labels: MosaicArtifactChecklistLabels;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicArtifactChecklist — read-only checklist artifact renderer.\n *\n * @example\n * <MosaicArtifactChecklist\n * data={{ title: \"Launch checklist\", items: [{ id: \"i1\", text: \"Ship PR\", completed: false }] }}\n * labels={{\n * typeBadgeLabel: \"Checklist\",\n * progressLabel: (c, t) => `${c}/${t}`,\n * completedOfTotalLabel: (c, t, p) => `${c} of ${t} completed (${p}%)`,\n * emptyMessage: \"No items yet.\",\n * priorityLabel: (p) => ({ low: \"Low\", medium: \"Medium\", high: \"High\" })[p],\n * }}\n * />\n */\nexport function MosaicArtifactChecklist({\n data,\n labels,\n className,\n ref,\n}: MosaicArtifactChecklistProps) {\n const completedCount = data.items.filter((item) => item.completed).length;\n const totalCount = data.items.length;\n const progress = totalCount > 0 ? (completedCount / totalCount) * 100 : 0;\n\n return (\n <div\n ref={ref}\n data-slot=\"artifact-checklist\"\n className={cn(\n \"flex h-full flex-col rounded-lg border border-border bg-background\",\n className,\n )}\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4 py-3\">\n <h3 className=\"font-medium text-base\">{data.title}</h3>\n <span\n data-slot=\"artifact-checklist-type-badge\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {labels.typeBadgeLabel}\n </span>\n <span className=\"rounded-full border border-border px-2 py-0.5 text-muted-foreground text-xs\">\n {labels.progressLabel(completedCount, totalCount)}\n </span>\n </div>\n\n <div className=\"space-y-3 border-border border-b bg-muted/20 p-4\">\n <div className=\"flex items-center justify-between text-sm\">\n <span className=\"text-muted-foreground\">\n {labels.completedOfTotalLabel(completedCount, totalCount, Math.round(progress))}\n </span>\n </div>\n <MosaicProgress value={progress} aria-label={labels.typeBadgeLabel} />\n {data.description && <p className=\"text-muted-foreground text-sm\">{data.description}</p>}\n </div>\n\n <div className=\"flex-1 overflow-auto p-4\">\n {totalCount === 0 ? (\n <p className=\"py-8 text-center text-muted-foreground text-sm\">{labels.emptyMessage}</p>\n ) : (\n <ul className=\"space-y-3\">\n {data.items.map((item) => (\n <li\n key={item.id}\n data-slot=\"artifact-checklist-item\"\n className={cn(\n \"flex items-start gap-3 rounded-lg border p-3\",\n item.completed\n ? \"border-primary/20 bg-primary/10\"\n : \"border-border bg-background\",\n )}\n >\n <span\n aria-hidden=\"true\"\n className={cn(\n \"mt-0.5 h-4 w-4 shrink-0 rounded border-2\",\n item.completed ? \"border-primary bg-primary\" : \"border-muted-foreground\",\n )}\n />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start justify-between gap-2\">\n <span\n className={cn(\n \"text-sm leading-relaxed\",\n item.completed && \"text-muted-foreground line-through\",\n )}\n >\n {item.text}\n </span>\n {item.priority && (\n <span className=\"shrink-0 rounded-full border border-border px-2 py-0.5 text-xs\">\n {labels.priorityLabel(item.priority)}\n </span>\n )}\n </div>\n {item.notes && (\n <p className=\"mt-2 rounded bg-muted/50 p-2 text-muted-foreground text-xs\">\n {item.notes}\n </p>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {data.metadata?.category && (\n <div className=\"border-border border-t bg-muted/20 px-4 py-3 text-muted-foreground text-xs\">\n {data.metadata.category}\n </div>\n )}\n </div>\n );\n}\n\nMosaicArtifactChecklist.displayName = \"MosaicArtifactChecklist\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-data-table",
|
|
4
|
+
"title": "MosaicArtifactDataTable",
|
|
5
|
+
"description": "MosaicArtifactDataTable — dumb, contract-agnostic data-table artifact renderer",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-data-table.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/artifact-data-table/MosaicArtifactDataTable.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicArtifactDataTable — dumb, contract-agnostic data-table artifact renderer\n *\n * Renders a normalized data-table artifact payload on top of the existing\n * `MosaicDataTable` atom (reuse-first — no re-implementation of sort/render\n * logic). Owns no knowledge of its runtime source (@ai-sdk-tools/artifacts vs\n * the MCP Apps ui:// bridge); it consumes the same `data` shape either source\n * normalizes to.\n *\n * Read-only presentation. Ported from any-debate-ai's DataTableArtifact,\n * stripped of inline-edit/add-row/delete-row/search state to keep this a\n * pure render component, per the C1 adapter contract.\n *\n * data-slot=\"artifact-data-table\" on the root.\n *\n * i18n: zero hardcoded user-facing strings — every label is a required\n * prop (mosaic-blocks doctrine, see src/__tests__/i18n-no-hardcoded-literals.test.ts).\n */\n\nimport type * as React from \"react\";\nimport { MosaicDataTable } from \"@/components/ui/MosaicDataTable\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Data shape ────────────────────────────────────────────────────────────────\n\nexport interface MosaicArtifactDataTableColumn {\n id: string;\n name: string;\n type: \"string\" | \"number\" | \"boolean\";\n width?: number;\n}\n\nexport interface MosaicArtifactDataTableData {\n title: string;\n columns: MosaicArtifactDataTableColumn[];\n rows: Record<string, unknown>[];\n metadata?: {\n sortBy?: string;\n sortOrder?: \"asc\" | \"desc\";\n };\n}\n\nexport interface MosaicArtifactDataTableLabels {\n /** Accessible text for the \"Data Table\" type badge. */\n typeBadgeLabel: string;\n /** Formats the row/column count badge, e.g. (rows, cols) => `${rows} rows × ${cols} cols`. */\n rowsColsLabel: (rows: number, cols: number) => string;\n /** Shown when there are no rows. */\n emptyMessage: string;\n /** Boolean-column cell label for `true`. */\n yesLabel: string;\n /** Boolean-column cell label for `false`. */\n noLabel: string;\n}\n\nexport interface MosaicArtifactDataTableProps {\n data: MosaicArtifactDataTableData;\n labels: MosaicArtifactDataTableLabels;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicArtifactDataTable — read-only data-table artifact renderer.\n *\n * @example\n * <MosaicArtifactDataTable\n * data={{ title: \"Q3 pipeline\", columns: [...], rows: [...] }}\n * labels={{\n * typeBadgeLabel: \"Data Table\",\n * rowsColsLabel: (r, c) => `${r} rows × ${c} cols`,\n * emptyMessage: \"No rows.\",\n * yesLabel: \"Yes\",\n * noLabel: \"No\",\n * }}\n * />\n */\nexport function MosaicArtifactDataTable({\n data,\n labels,\n className,\n ref,\n}: MosaicArtifactDataTableProps) {\n return (\n <div\n ref={ref}\n data-slot=\"artifact-data-table\"\n className={cn(\n \"flex h-full flex-col rounded-lg border border-border bg-background\",\n className,\n )}\n >\n <div className=\"flex items-center gap-3 border-border border-b px-4 py-3\">\n <h3 className=\"font-medium text-base\">{data.title}</h3>\n <span\n data-slot=\"artifact-data-table-type-badge\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {labels.typeBadgeLabel}\n </span>\n <span className=\"rounded-full border border-border px-2 py-0.5 text-muted-foreground text-xs\">\n {labels.rowsColsLabel(data.rows.length, data.columns.length)}\n </span>\n </div>\n\n <div className=\"flex-1 overflow-auto\">\n <MosaicDataTable\n columns={data.columns.map((column) => ({\n key: column.id,\n header: column.name,\n render: (row: Record<string, unknown>) => {\n const value = row[column.id];\n if (column.type === \"boolean\") {\n return (\n <span className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\">\n {value ? labels.yesLabel : labels.noLabel}\n </span>\n );\n }\n if (column.type === \"number\") {\n return <span className=\"font-mono\">{String(value ?? \"\")}</span>;\n }\n return String(value ?? \"\");\n },\n }))}\n rows={data.rows}\n emptyMessage={labels.emptyMessage}\n />\n </div>\n </div>\n );\n}\n\nMosaicArtifactDataTable.displayName = \"MosaicArtifactDataTable\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-document",
|
|
4
|
+
"title": "MosaicArtifactDocument",
|
|
5
|
+
"description": "MosaicArtifactDocument — dumb, contract-agnostic document artifact renderer",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/artifact-document/MosaicArtifactDocument.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicArtifactDocument — dumb, contract-agnostic document artifact renderer\n *\n * Renders a normalized document artifact payload. Owns no knowledge of its\n * runtime source (@ai-sdk-tools/artifacts vs the MCP Apps ui:// bridge) —\n * it consumes the same `data` shape either source normalizes to, one level\n * below `NormalizedArtifact[\"data\"]` in `artifact-canvas-adapter`.\n *\n * Read-only presentation. Ported from any-debate-ai's DocumentArtifact,\n * stripped of editing state (inline edit mode, autosave, markdown toolbar)\n * to keep this a pure render component, per the C1 adapter contract.\n *\n * data-slot=\"artifact-document\" on the root, \"artifact-document-section\"\n * per section, \"artifact-document-tag\" per tag.\n *\n * i18n: zero hardcoded user-facing strings — every label is a required\n * prop (mosaic-blocks doctrine, see src/__tests__/i18n-no-hardcoded-literals.test.ts).\n */\n\nimport type * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Data shape ────────────────────────────────────────────────────────────────\n\nexport interface MosaicArtifactDocumentSection {\n id: string;\n title: string;\n content: string;\n order: number;\n}\n\nexport interface MosaicArtifactDocumentData {\n title: string;\n content: string;\n sections?: MosaicArtifactDocumentSection[];\n metadata?: {\n updatedAt?: string;\n tags?: string[];\n };\n}\n\nexport interface MosaicArtifactDocumentLabels {\n /** Accessible text for the \"Document\" type badge. */\n typeBadgeLabel: string;\n /** Heading above the sections list. */\n sectionsHeading: string;\n /** Prefix label shown before the tags list. */\n tagsLabel: string;\n /** Formats the last-updated line, e.g. (date) => `Updated ${date}`. */\n updatedLabel: (formattedDate: string) => string;\n /** Shown in place of the content when it is blank. */\n emptyContentMessage: string;\n /** Formats a section's character count, e.g. (n) => `${n} chars`. */\n charsLabel: (count: number) => string;\n}\n\nexport interface MosaicArtifactDocumentProps {\n data: MosaicArtifactDocumentData;\n labels: MosaicArtifactDocumentLabels;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicArtifactDocument — read-only document artifact renderer.\n *\n * @example\n * <MosaicArtifactDocument\n * data={{ title: \"Launch plan\", content: \"...\" }}\n * labels={{\n * typeBadgeLabel: \"Document\",\n * sectionsHeading: \"Sections\",\n * tagsLabel: \"Tags:\",\n * updatedLabel: (d) => `Updated ${d}`,\n * emptyContentMessage: \"This document is empty.\",\n * charsLabel: (n) => `${n} chars`,\n * }}\n * />\n */\nexport function MosaicArtifactDocument({\n data,\n labels,\n className,\n ref,\n}: MosaicArtifactDocumentProps) {\n const sortedSections = data.sections ? [...data.sections].sort((a, b) => a.order - b.order) : [];\n\n return (\n <div\n ref={ref}\n data-slot=\"artifact-document\"\n className={cn(\n \"flex h-full flex-col rounded-lg border border-border bg-background\",\n className,\n )}\n >\n <div className=\"flex items-center justify-between gap-3 border-border border-b px-4 py-3\">\n <div className=\"flex min-w-0 flex-1 items-center gap-3\">\n <h3 className=\"truncate font-medium text-base\">{data.title}</h3>\n <span\n data-slot=\"artifact-document-type-badge\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {labels.typeBadgeLabel}\n </span>\n </div>\n {data.metadata?.updatedAt && (\n <span className=\"shrink-0 text-muted-foreground text-xs\">\n {labels.updatedLabel(new Date(data.metadata.updatedAt).toLocaleDateString())}\n </span>\n )}\n </div>\n\n <div className=\"flex-1 overflow-auto p-6\">\n <div className=\"whitespace-pre-wrap text-sm leading-relaxed\">\n {data.content || labels.emptyContentMessage}\n </div>\n </div>\n\n {sortedSections.length > 0 && (\n <div className=\"border-border border-t p-4\">\n <h4 className=\"mb-3 font-medium text-sm\">{labels.sectionsHeading}</h4>\n <ul className=\"space-y-2\">\n {sortedSections.map((section) => (\n <li\n key={section.id}\n data-slot=\"artifact-document-section\"\n className=\"flex items-center gap-2 rounded bg-muted/50 p-2\"\n >\n <span className=\"h-4 w-1 shrink-0 rounded-full bg-primary\" />\n <span className=\"font-medium text-sm\">{section.title}</span>\n <span className=\"ml-auto rounded-full border border-border px-2 py-0.5 text-muted-foreground text-xs\">\n {labels.charsLabel(section.content.length)}\n </span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {data.metadata?.tags && data.metadata.tags.length > 0 && (\n <div className=\"border-border border-t p-4\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"text-muted-foreground text-xs\">{labels.tagsLabel}</span>\n {data.metadata.tags.map((tag) => (\n <span\n key={tag}\n data-slot=\"artifact-document-tag\"\n className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {tag}\n </span>\n ))}\n </div>\n </div>\n )}\n </div>\n );\n}\n\nMosaicArtifactDocument.displayName = \"MosaicArtifactDocument\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-library",
|
|
4
|
+
"title": "MosaicArtifactLibrary",
|
|
5
|
+
"description": "MosaicArtifactLibrary — org-scoped list/search of saved artifacts, opening a selected one through the C1 adapter (MosaicArtifactCanvasAdapter) + C2 renderers.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-artifact-canvas-adapter.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/artifact-library/MosaicArtifactLibrary.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicArtifactLibrary — org-scoped list/search of saved artifacts, opening\n * a selected one through the C1 adapter (MosaicArtifactCanvasAdapter) + C2\n * renderers.\n *\n * Reuse: composed from the closest any-debate-ai pattern —\n * components/artifacts/organization/ArtifactLibrary.tsx (search + type\n * filter + grid/list of saved artifacts) — stripped of its bulk-actions,\n * folders/tags organizer (`artifactOrganizer`), framer-motion, and shadcn/ui\n * deps to keep this a pure, contract-agnostic list component per the C1\n * adapter's own doctrine. Persistence, org-scoping, and folders/tags are the\n * host's concern: this component accepts a flat `items` array plus\n * `onSelect`/`source` props — no backend, no hardcoded business data.\n *\n * data-slot=\"artifact-library\" on the root, \"artifact-library-search\" on\n * the search input, \"artifact-library-list\" on the item list,\n * \"artifact-library-item\" per item, \"artifact-library-canvas\" on the\n * forwarded MosaicArtifactCanvasAdapter.\n *\n * i18n: zero hardcoded user-facing strings (mosaic-blocks doctrine — see\n * src/__tests__/i18n-no-hardcoded-literals.test.ts). Every label is a\n * required prop; the host owns the language.\n */\n\nimport * as React from \"react\";\nimport {\n MosaicArtifactCanvasAdapter,\n type MosaicArtifactCanvasAdapterLabels,\n} from \"@/components/ui/MosaicArtifactCanvasAdapter\";\nimport type { ArtifactCanvasSource, ArtifactType } from \"@/components/ui/types\";\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicArtifactLibraryItem {\n id: string;\n type: ArtifactType;\n title: string;\n /** Host-formatted \"last updated\" string (locale/timezone owned by the host). */\n updatedAtLabel: string;\n}\n\nexport interface MosaicArtifactLibraryProps {\n /** Saved artifacts to list/search. Host-supplied — no backend, no org logic baked in. */\n items: MosaicArtifactLibraryItem[];\n selectedId: string | null;\n onSelect: (id: string) => void;\n /** Runtime source for the currently selected artifact; `null` renders the adapter's empty state. */\n source: ArtifactCanvasSource | null;\n isCanvasOpen: boolean;\n onToggleCanvas: () => void;\n onCloseCanvas: () => void;\n /** Section heading. Required, no default. */\n title: string;\n /** Search input placeholder. Required, no default. */\n searchPlaceholder: string;\n /**\n * Accessible name for the search input. Required, no default — the\n * placeholder alone is never a substitute for an accessible name (it\n * disappears once a value is typed and is not reliably exposed by every\n * assistive technology), so this prop is mandatory and applied verbatim\n * via aria-label.\n */\n searchAriaLabel: string;\n /** Message shown when the filtered item list is empty. Required, no default. */\n emptyMessage: string;\n /** Localizes an item's type badge. Required, no default. */\n typeLabel: (type: ArtifactType) => string;\n /** Formats the visible item count, e.g. (n) => `${n} artifacts`. Required, no default. */\n countLabel: (n: number) => string;\n /** Forwarded verbatim to MosaicArtifactCanvasAdapter. */\n adapterLabels: MosaicArtifactCanvasAdapterLabels;\n className?: string;\n}\n\nfunction SearchIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\" />\n </svg>\n );\n}\n\nexport function MosaicArtifactLibrary({\n items,\n selectedId,\n onSelect,\n source,\n isCanvasOpen,\n onToggleCanvas,\n onCloseCanvas,\n title,\n searchPlaceholder,\n searchAriaLabel,\n emptyMessage,\n typeLabel,\n countLabel,\n adapterLabels,\n className,\n}: MosaicArtifactLibraryProps) {\n const [query, setQuery] = React.useState(\"\");\n\n const filtered = React.useMemo(() => {\n const q = query.trim().toLowerCase();\n if (!q) return items;\n return items.filter((item) => item.title.toLowerCase().includes(q));\n }, [items, query]);\n\n return (\n <div data-slot=\"artifact-library\" className={cn(\"flex h-full flex-col\", className)}>\n <div className=\"border-border border-b px-4 py-3\">\n <div className=\"mb-3 flex items-center justify-between\">\n <h2 className=\"font-semibold text-lg\">{title}</h2>\n <span className=\"text-muted-foreground text-xs\">{countLabel(filtered.length)}</span>\n </div>\n\n <div className=\"relative\">\n <span className=\"-translate-y-1/2 absolute top-1/2 left-3 text-muted-foreground\">\n <SearchIcon />\n </span>\n <input\n type=\"search\"\n data-slot=\"artifact-library-search\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={searchPlaceholder}\n aria-label={searchAriaLabel}\n className={cn(\n \"w-full rounded-md border border-input bg-background py-2 pr-3 pl-9\",\n \"text-sm placeholder:text-muted-foreground\",\n \"outline-none focus-visible:ring-[3px] focus-visible:ring-ring\",\n )}\n />\n </div>\n </div>\n\n <div className=\"flex-1 overflow-y-auto p-4\">\n {filtered.length === 0 && (\n <p className=\"py-10 text-center text-muted-foreground text-sm\">{emptyMessage}</p>\n )}\n\n <ul data-slot=\"artifact-library-list\" className=\"space-y-2\">\n {filtered.map((item) => (\n <li key={item.id}>\n <button\n type=\"button\"\n data-slot=\"artifact-library-item\"\n aria-current={selectedId === item.id ? \"true\" : undefined}\n onClick={() => onSelect(item.id)}\n className={cn(\n \"flex w-full items-start justify-between gap-3 rounded-md border border-border px-3 py-2 text-left\",\n \"outline-none transition-colors hover:bg-muted\",\n \"focus-visible:ring-[3px] focus-visible:ring-ring\",\n selectedId === item.id && \"border-primary bg-primary/5\",\n )}\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate font-medium text-sm\">{item.title}</p>\n <p className=\"mt-1 text-muted-foreground text-xs\">{item.updatedAtLabel}</p>\n </div>\n <span\n data-slot=\"artifact-library-item-type\"\n className=\"shrink-0 rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {typeLabel(item.type)}\n </span>\n </button>\n </li>\n ))}\n </ul>\n </div>\n\n <div data-slot=\"artifact-library-canvas\" className=\"border-border border-t p-4\">\n <MosaicArtifactCanvasAdapter\n source={source}\n isOpen={isCanvasOpen}\n onToggle={onToggleCanvas}\n onClose={onCloseCanvas}\n labels={adapterLabels}\n />\n </div>\n </div>\n );\n}\n\nMosaicArtifactLibrary.displayName = \"MosaicArtifactLibrary\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-save-as-memory-form",
|
|
4
|
+
"title": "MosaicArtifactSaveAsMemoryForm",
|
|
5
|
+
"description": "MosaicArtifactSaveAsMemoryForm — presentational \"capitalise this artifact into memory\" form: the artifact → memory bridge, sibling of MosaicSaveChatAsMemoryForm (chat → memory) in the same product family.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-input.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-tag-input.json"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/artifact-save-as-memory-form/MosaicArtifactSaveAsMemoryForm.tsx",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"content": "/**\n * MosaicArtifactSaveAsMemoryForm — presentational \"capitalise this artifact\n * into memory\" form: the artifact → memory bridge, sibling of\n * MosaicSaveChatAsMemoryForm (chat → memory) in the same product family.\n *\n * Reuse: composed from the closest any-debate-ai pattern —\n * components/artifacts/save-artifact-as-memory-form.tsx — stripped of its\n * AdaptiveModal wrapper (host owns the shell/overlay), shadcn/ui deps,\n * mock-AI-extracted-learnings array, and hardcoded userRole-gated scope\n * options, to keep this a pure, contract-agnostic form component: prop-\n * driven, no backend, no hardcoded business data, same doctrine as\n * MosaicSaveChatAsMemoryForm / MosaicAddMemoryForm.\n *\n * Presentational atom composed from existing mosaic-blocks primitives:\n * MosaicInput + MosaicTagInput. This component never invents a new form\n * field or tag chip — it assembles the ones the library already ships.\n *\n * Zero extraction, zero I/O: the component does NOT read the artifact, does\n * NOT summarize it and does NOT decide what is worth remembering — it\n * renders whatever the host already extracted as fully controlled\n * `learnings`/`title`/`tags`/`scope` values, and routes save/cancel through\n * host callbacks. No network call of any kind lives in this component.\n *\n * Fully controlled: `title`/`learnings`/`scope`/`tags` are single-source-\n * of-truth values supplied by the host, every change is reported via a\n * callback. The component keeps no internal form state.\n *\n * Validation belongs to the host (SIN-01 + doctrine \"the host decides\"):\n * `canSave` is a host-computed boolean gating the save button, and\n * `titleError` is a host-computed string — this component only *displays*\n * an error, it never decides whether one exists. When an error string is\n * supplied, the title field gets `aria-invalid=\"true\"` and\n * `aria-describedby` pointing at the rendered error text; the field is\n * `aria-invalid=\"false\"` otherwise, so the absence of an error is never\n * ambiguous.\n *\n * Memory scope is a host-supplied `scopeOptions` list (e.g. gated by the\n * host's own role/permission model) — this component never hardcodes\n * \"admin\"/\"member\" or any org-scoped business rule; it renders whatever\n * options the host passes.\n *\n * isSaving sets `aria-busy=\"true\"` on the save button and disables both\n * actions — a save-in-progress is announced, never silent.\n *\n * data-slot=\"artifact-save-as-memory-form\" on the form root.\n * Bilingual: every user-facing string (labels/placeholders/errors/button\n * labels/type labels) is a required host-supplied prop — zero hardcoded\n * copy, zero default (SIN-01).\n *\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --destructive, --foreground, --muted-foreground,\n * --secondary, --secondary-foreground.\n *\n * @example\n * <MosaicArtifactSaveAsMemoryForm\n * artifact={artifact}\n * typeLabel={(type) => typeLabels[type]}\n * title={title}\n * onTitleChange={setTitle}\n * titleLabel=\"Memory Title\"\n * titleError={titleError}\n * learnings={learnings}\n * onEditLearning={(i, value) => editLearning(i, value)}\n * onRemoveLearning={(i) => removeLearning(i)}\n * learningsLabel=\"AI-Extracted Learnings\"\n * editLearningAriaLabel={(i) => `Edit learning ${i + 1}`}\n * removeLearningAriaLabel={(i) => `Remove learning ${i + 1}`}\n * scope={scope}\n * onScopeChange={setScope}\n * scopeLabel=\"Memory Scope\"\n * scopeOptions={scopeOptions}\n * tags={tags}\n * onAddTag={(t) => setTags((prev) => [...prev, t])}\n * onRemoveTag={(t) => setTags((prev) => prev.filter((x) => x !== t))}\n * tagsLabel=\"Tags\"\n * tagInputPlaceholder=\"Add a tag…\"\n * removeTagAriaLabel={(t) => `Remove ${t}`}\n * isSaving={isSaving}\n * canSave={canSave}\n * onSave={handleSave}\n * onCancel={() => setOpen(false)}\n * saveLabel=\"Save to Memory\"\n * savingLabel=\"Saving…\"\n * cancelLabel=\"Cancel\"\n * />\n */\n\nimport { useId } from \"react\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { MosaicTagInput } from \"@/components/ui/MosaicTagInput\";\nimport {\n artifactSaveAsMemoryFormButtonVariants,\n artifactSaveAsMemoryFormErrorVariants,\n artifactSaveAsMemoryFormFieldVariants,\n artifactSaveAsMemoryFormFooterVariants,\n artifactSaveAsMemoryFormLearningVariants,\n artifactSaveAsMemoryFormPreviewVariants,\n artifactSaveAsMemoryFormRootVariants,\n} from \"./artifact-save-as-memory-form-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicArtifactSaveAsMemoryArtifactType =\n | \"document\"\n | \"data-table\"\n | \"checklist\"\n | \"chart\";\n\nexport interface MosaicArtifactSaveAsMemoryArtifact {\n id: string;\n type: MosaicArtifactSaveAsMemoryArtifactType;\n title: string;\n content: string;\n preview?: string;\n}\n\nexport interface MosaicArtifactSaveAsMemoryScopeOption {\n value: string;\n label: string;\n}\n\nexport interface MosaicArtifactSaveAsMemoryFormProps {\n /** The artifact being capitalised into memory — host-supplied, read-only preview. */\n artifact: MosaicArtifactSaveAsMemoryArtifact;\n /** Localizes the artifact type badge. Required, no default. */\n typeLabel: (type: MosaicArtifactSaveAsMemoryArtifactType) => string;\n\n /** Current memory title value — controlled. */\n title: string;\n /** Called on every keystroke in the title field. */\n onTitleChange: (value: string) => void;\n /** Label for the title field. Required, no default. */\n titleLabel: string;\n /** Placeholder for the title field. */\n titlePlaceholder?: string;\n /** Host-computed validation message for the title field, or absent when valid. */\n titleError?: string;\n\n /**\n * Host-supplied, pre-extracted learnings — controlled. This component\n * never extracts or generates learnings; the host (or its own AI\n * extraction pipeline) is the sole source of this list.\n */\n learnings: string[];\n /** Called when the host user edits a learning at the given index. */\n onEditLearning: (index: number) => void;\n /** Called when the host user removes a learning at the given index. */\n onRemoveLearning: (index: number) => void;\n /** Label for the learnings section. Required, no default. */\n learningsLabel: string;\n /** Optional helper text under the learnings label. */\n learningsDescription?: string;\n /** Per-learning accessible name for the edit button. Required, no default. */\n editLearningAriaLabel: (index: number) => string;\n /** Per-learning accessible name for the remove button. Required, no default. */\n removeLearningAriaLabel: (index: number) => string;\n\n /** Current memory scope value — controlled. */\n scope: string;\n /** Called when the host user changes the memory scope. */\n onScopeChange: (value: string) => void;\n /** Label for the scope selector. Required, no default. */\n scopeLabel: string;\n /**\n * Host-supplied scope options (e.g. gated by the host's own role/\n * permission model). This component never hardcodes which scopes are\n * available — it renders exactly the options the host passes.\n */\n scopeOptions: MosaicArtifactSaveAsMemoryScopeOption[];\n\n /** Current tag list — controlled, single source of truth owned by the host. */\n tags: string[];\n /** Called when a tag should be added. */\n onAddTag: (tag: string) => void;\n /** Called when a tag should be removed. */\n onRemoveTag: (tag: string) => void;\n /** Label for the tags field. Required, no default. */\n tagsLabel: string;\n /** Placeholder for the tag input. Required, no default. */\n tagInputPlaceholder: string;\n /** Per-tag accessible name for the remove button. Required, no default. */\n removeTagAriaLabel: (tag: string) => string;\n /** Optional host-supplied suggested tags. */\n suggestedTags?: string[];\n /** Optional maximum number of tags. */\n maxTags?: number;\n\n /** True while a save request is in flight — announced via aria-busy, disables both actions. */\n isSaving: boolean;\n /**\n * Host-computed form validity gating the save button. This component\n * never decides validation itself — it only reflects the host's verdict.\n */\n canSave: boolean;\n /** Called when the host user saves the form. */\n onSave: () => void;\n /** Called when the host user clicks Cancel. */\n onCancel: () => void;\n /** Label for the save button while idle. Required, no default. */\n saveLabel: string;\n /** Label for the save button while isSaving=true. Required, no default. */\n savingLabel: string;\n /** Label for the cancel button. Required, no default. */\n cancelLabel: string;\n\n /** Additional Tailwind classes on the form root. */\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicArtifactSaveAsMemoryForm — production \"save this artifact as a\n * memory\" form for @vantageos/mosaic-blocks.\n *\n * Purely presentational and fully controlled: composes MosaicInput +\n * MosaicTagInput. No network call, no extraction logic, no built-in\n * validation, no built-in copy.\n */\nexport function MosaicArtifactSaveAsMemoryForm({\n artifact,\n typeLabel,\n title,\n onTitleChange,\n titleLabel,\n titlePlaceholder,\n titleError,\n learnings,\n onEditLearning,\n onRemoveLearning,\n learningsLabel,\n learningsDescription,\n editLearningAriaLabel,\n removeLearningAriaLabel,\n scope,\n onScopeChange,\n scopeLabel,\n scopeOptions,\n tags,\n onAddTag,\n onRemoveTag,\n tagsLabel,\n tagInputPlaceholder,\n removeTagAriaLabel,\n suggestedTags,\n maxTags,\n isSaving,\n canSave,\n onSave,\n onCancel,\n saveLabel,\n savingLabel,\n cancelLabel,\n className,\n}: MosaicArtifactSaveAsMemoryFormProps) {\n const titleErrorId = useId();\n const scopeId = useId();\n\n return (\n <div\n data-slot=\"artifact-save-as-memory-form\"\n className={cn(artifactSaveAsMemoryFormRootVariants(), className)}\n >\n <div\n data-slot=\"artifact-save-as-memory-form-preview\"\n className={artifactSaveAsMemoryFormPreviewVariants()}\n >\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate font-medium text-sm\">{artifact.title}</p>\n <p className=\"mt-1 line-clamp-2 text-muted-foreground text-xs\">\n {artifact.preview || artifact.content}\n </p>\n <span\n data-slot=\"artifact-save-as-memory-form-type\"\n className=\"mt-2 inline-block shrink-0 rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\"\n >\n {typeLabel(artifact.type)}\n </span>\n </div>\n </div>\n\n <div className={artifactSaveAsMemoryFormFieldVariants()}>\n <label\n htmlFor=\"mosaic-artifact-save-as-memory-title\"\n className=\"text-sm font-medium text-foreground\"\n >\n {titleLabel}\n </label>\n <MosaicInput\n id=\"mosaic-artifact-save-as-memory-title\"\n value={title}\n placeholder={titlePlaceholder}\n onChange={(e) => onTitleChange(e.target.value)}\n aria-invalid={titleError ? \"true\" : \"false\"}\n aria-describedby={titleError ? titleErrorId : undefined}\n />\n {titleError && (\n <p id={titleErrorId} className={artifactSaveAsMemoryFormErrorVariants()}>\n {titleError}\n </p>\n )}\n </div>\n\n <div className={artifactSaveAsMemoryFormFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{learningsLabel}</span>\n {learningsDescription && (\n <p className=\"text-muted-foreground text-xs\">{learningsDescription}</p>\n )}\n <div className=\"flex flex-col gap-2\">\n {learnings.map((learning, index) => (\n <div\n key={`${index}-${learning}`}\n data-slot=\"artifact-save-as-memory-form-learning\"\n className={artifactSaveAsMemoryFormLearningVariants()}\n >\n <p className=\"flex-1 text-sm\">{learning}</p>\n <div className=\"flex shrink-0 gap-1\">\n <button\n type=\"button\"\n data-slot=\"artifact-save-as-memory-form-learning-edit\"\n onClick={() => onEditLearning(index)}\n aria-label={editLearningAriaLabel(index)}\n className={artifactSaveAsMemoryFormButtonVariants({ intent: \"ghost\" })}\n >\n {editLearningAriaLabel(index)}\n </button>\n <button\n type=\"button\"\n data-slot=\"artifact-save-as-memory-form-learning-remove\"\n onClick={() => onRemoveLearning(index)}\n aria-label={removeLearningAriaLabel(index)}\n className={artifactSaveAsMemoryFormButtonVariants({ intent: \"ghost\" })}\n >\n {removeLearningAriaLabel(index)}\n </button>\n </div>\n </div>\n ))}\n </div>\n </div>\n\n <div className={artifactSaveAsMemoryFormFieldVariants()}>\n <label htmlFor={scopeId} className=\"text-sm font-medium text-foreground\">\n {scopeLabel}\n </label>\n <select\n id={scopeId}\n data-slot=\"artifact-save-as-memory-form-scope\"\n value={scope}\n onChange={(e) => onScopeChange(e.target.value)}\n className={cn(\n \"h-9 rounded-md border border-input bg-background px-3 text-sm\",\n \"outline-none focus-visible:ring-[3px] focus-visible:ring-ring\",\n )}\n >\n {scopeOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </div>\n\n <div className={artifactSaveAsMemoryFormFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{tagsLabel}</span>\n <MosaicTagInput\n tags={tags}\n onAddTag={onAddTag}\n onRemoveTag={onRemoveTag}\n placeholder={tagInputPlaceholder}\n removeTagAriaLabel={removeTagAriaLabel}\n suggestions={suggestedTags}\n maxTags={maxTags}\n />\n </div>\n\n <div className={artifactSaveAsMemoryFormFooterVariants()}>\n <button\n type=\"button\"\n data-slot=\"artifact-save-as-memory-form-cancel-button\"\n onClick={onCancel}\n disabled={isSaving}\n className={artifactSaveAsMemoryFormButtonVariants({ intent: \"cancel\" })}\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n data-slot=\"artifact-save-as-memory-form-save-button\"\n onClick={onSave}\n disabled={!canSave || isSaving}\n aria-busy={isSaving ? \"true\" : \"false\"}\n className={artifactSaveAsMemoryFormButtonVariants({ intent: \"save\" })}\n >\n {isSaving ? savingLabel : saveLabel}\n </button>\n </div>\n </div>\n );\n}\n\nMosaicArtifactSaveAsMemoryForm.displayName = \"MosaicArtifactSaveAsMemoryForm\";\n"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "src/components/artifact-save-as-memory-form/artifact-save-as-memory-form-variants.ts",
|
|
19
|
+
"type": "registry:ui",
|
|
20
|
+
"content": "/**\n * artifactSaveAsMemoryFormVariants — pure CVA variant functions for\n * MosaicArtifactSaveAsMemoryForm.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Form vertical layout. */\nexport const artifactSaveAsMemoryFormRootVariants = cva([\"flex flex-col gap-4\"]);\n\n/** Artifact preview card. */\nexport const artifactSaveAsMemoryFormPreviewVariants = cva([\n \"flex items-start gap-3 rounded-md border border-border p-3\",\n]);\n\n/** Field group (label + control + helper/error) vertical layout. */\nexport const artifactSaveAsMemoryFormFieldVariants = cva([\"flex flex-col gap-1.5\"]);\n\n/** Field error text. */\nexport const artifactSaveAsMemoryFormErrorVariants = cva([\"text-xs font-medium text-destructive\"]);\n\n/** Learning row (extracted insight + edit/remove actions). */\nexport const artifactSaveAsMemoryFormLearningVariants = cva([\n \"flex items-start gap-2 rounded-md border border-border p-2\",\n]);\n\n/** Footer action row. */\nexport const artifactSaveAsMemoryFormFooterVariants = cva([\n \"flex items-center justify-end gap-3 border-t border-border pt-4\",\n]);\n\n/** Save / cancel button variants by intent. */\nexport const artifactSaveAsMemoryFormButtonVariants = cva(\n [\n \"inline-flex min-h-9 items-center justify-center gap-2 rounded-md px-4 text-sm font-medium\",\n \"transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n ],\n {\n variants: {\n intent: {\n cancel: \"border border-border bg-background hover:bg-muted\",\n save: \"border border-transparent bg-primary text-primary-foreground hover:bg-primary/90\",\n ghost: \"border border-transparent bg-transparent hover:bg-muted\",\n },\n },\n defaultVariants: {\n intent: \"cancel\",\n },\n },\n);\n"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "registry:ui"
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-artifact-version-history",
|
|
4
|
+
"title": "MosaicArtifactVersionHistory",
|
|
5
|
+
"description": "MosaicArtifactVersionHistory — org-scoped version-history timeline for a deliverable, letting the user select a version to open through the C1 adapter + C2 renderers, and (optionally) restore an earlier version.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/artifact-version-history/MosaicArtifactVersionHistory.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "\"use client\";\n\n/**\n * MosaicArtifactVersionHistory — org-scoped version-history timeline for a\n * deliverable, letting the user select a version to open through the C1\n * adapter + C2 renderers, and (optionally) restore an earlier version.\n *\n * Reuse: ported from any-debate-ai —\n * components/artifacts/version-history/VersionHistoryPanel.tsx — stripped\n * of its `AdaptiveModal` chrome, `versionHistoryManager` in-memory store,\n * search/filter/diff/export UI, framer-motion, sonner, and shadcn/ui deps.\n * The panel here is a pure, prop-driven timeline: the host supplies the\n * already-fetched/filtered version list plus select/restore handlers — no\n * backend, no hardcoded org data. Diffing, comparison, search, and export\n * are host concerns kept out of this component's contract, same as the C3\n * library kept folders/tags/bulk-actions out of its own.\n *\n * data-slot=\"artifact-version-history\" on the root,\n * \"artifact-version-history-list\" on the version list,\n * \"artifact-version-history-item\" per version.\n *\n * i18n: zero hardcoded user-facing strings (mosaic-blocks doctrine — see\n * src/__tests__/i18n-no-hardcoded-literals.test.ts). Every label is a\n * required prop; the host owns the language.\n */\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicArtifactVersionHistoryVersion {\n id: string;\n /** Host-formatted version marker, e.g. \"v3\". */\n versionLabel: string;\n /** Host-formatted author name. */\n authorLabel: string;\n /** Host-formatted relative/absolute timestamp, e.g. \"2 days ago\". */\n timestampLabel: string;\n /** Host-formatted change-type badge text, e.g. \"Edited\". */\n changeTypeLabel: string;\n /** Optional host-formatted change description/commit message. */\n descriptionLabel?: string;\n /** True for the version that is currently live — hides the restore action. */\n isCurrent: boolean;\n}\n\nexport interface MosaicArtifactVersionHistoryBaseProps {\n /** Versions to render, host-ordered (newest-first is the caller's choice). */\n versions: MosaicArtifactVersionHistoryVersion[];\n selectedId: string | null;\n onSelectVersion: (id: string) => void;\n /** Section heading. Required, no default. */\n title: string;\n /** Message shown when there are no versions. Required, no default. */\n emptyMessage: string;\n /** Badge text for the current/latest version. Required, no default. */\n currentLabel: string;\n /** Accessible name for a version's select button. Required, no default. */\n selectAriaLabel: (version: MosaicArtifactVersionHistoryVersion) => string;\n className?: string;\n}\n\n/**\n * Discriminated union on `onRestoreVersion` — the restore control only ever\n * renders on the branch where a restore handler is supplied, so its label +\n * accessible-name formatter are required EXACTLY there, never on the\n * read-only branch. Requiring them unconditionally would force every\n * read-only host to supply values the component never displays (the \"lying\n * prop contract\" this retrofit closes — see the `no-lying-prop-contract`\n * guard and the `MosaicMemoryCardVariantProps` precedent in\n * `memory-card/MosaicMemoryCard.tsx`).\n */\nexport type MosaicArtifactVersionHistoryRestoreProps =\n | {\n /** Restores a version. */\n onRestoreVersion: (id: string) => void;\n /** Restore button visible text. Required — the control renders whenever `onRestoreVersion` is provided. */\n restoreLabel: string;\n /**\n * Accessible name for a version's restore button, DISTINCT per\n * version — a bare icon/shared label is never a substitute for an\n * accessible name distinguishing which version is restored (see the\n * C3 library's searchAriaLabel lesson). Required — the control\n * renders whenever `onRestoreVersion` is provided.\n */\n restoreAriaLabel: (version: MosaicArtifactVersionHistoryVersion) => string;\n }\n | {\n /** Omit to render a read-only history — no restore control at all. */\n onRestoreVersion?: undefined;\n };\n\nexport type MosaicArtifactVersionHistoryProps = MosaicArtifactVersionHistoryBaseProps &\n MosaicArtifactVersionHistoryRestoreProps;\n\nexport function MosaicArtifactVersionHistory(props: MosaicArtifactVersionHistoryProps) {\n const {\n versions,\n selectedId,\n onSelectVersion,\n title,\n emptyMessage,\n currentLabel,\n selectAriaLabel,\n className,\n } = props;\n return (\n <div data-slot=\"artifact-version-history\" className={cn(\"flex h-full flex-col\", className)}>\n <div className=\"border-border border-b px-4 py-3\">\n <h2 className=\"font-semibold text-lg\">{title}</h2>\n </div>\n\n <div className=\"flex-1 overflow-y-auto p-4\">\n {versions.length === 0 && (\n <p className=\"py-10 text-center text-muted-foreground text-sm\">{emptyMessage}</p>\n )}\n\n <ul data-slot=\"artifact-version-history-list\" className=\"space-y-2\">\n {versions.map((version) => (\n <li key={version.id} data-slot=\"artifact-version-history-item\">\n <div\n className={cn(\n \"flex items-start justify-between gap-3 rounded-md border border-border px-3 py-2\",\n selectedId === version.id && \"border-primary bg-primary/5\",\n )}\n >\n <button\n type=\"button\"\n aria-current={selectedId === version.id ? \"true\" : undefined}\n onClick={() => onSelectVersion(version.id)}\n className={cn(\n \"min-w-0 flex-1 text-left\",\n \"outline-none transition-colors\",\n \"focus-visible:ring-[3px] focus-visible:ring-ring\",\n )}\n aria-label={selectAriaLabel(version)}\n >\n <div className=\"mb-1 flex flex-wrap items-center gap-2\">\n <span className=\"rounded-full border border-border px-2 py-0.5 text-xs\">\n {version.versionLabel}\n </span>\n <span className=\"rounded-full bg-secondary px-2 py-0.5 text-secondary-foreground text-xs\">\n {version.changeTypeLabel}\n </span>\n {version.isCurrent && (\n <span className=\"rounded-full bg-primary px-2 py-0.5 text-primary-foreground text-xs\">\n {currentLabel}\n </span>\n )}\n </div>\n\n {version.descriptionLabel && (\n <p className=\"mb-1 truncate font-medium text-sm\">{version.descriptionLabel}</p>\n )}\n\n <div className=\"flex flex-wrap items-center gap-3 text-muted-foreground text-xs\">\n <span>{version.authorLabel}</span>\n <span>{version.timestampLabel}</span>\n </div>\n </button>\n\n {props.onRestoreVersion && !version.isCurrent && (\n <button\n type=\"button\"\n onClick={() => props.onRestoreVersion?.(version.id)}\n className={cn(\n \"shrink-0 rounded-md border border-input px-2 py-1 text-xs\",\n \"outline-none transition-colors hover:bg-muted\",\n \"focus-visible:ring-[3px] focus-visible:ring-ring\",\n )}\n aria-label={props.restoreAriaLabel(version)}\n >\n {props.restoreLabel}\n </button>\n )}\n </div>\n </li>\n ))}\n </ul>\n </div>\n </div>\n );\n}\n\nMosaicArtifactVersionHistory.displayName = \"MosaicArtifactVersionHistory\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-avatar",
|
|
4
|
+
"title": "MosaicAvatar",
|
|
5
|
+
"description": "Avatar with image + fallback, built on @base-ui/react/avatar. Props: src, alt, fallback. data-slot=\"avatar\".",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/avatar/MosaicAvatar.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicAvatar — built on @base-ui/react/avatar\n *\n * Uses Avatar.Root + Avatar.Image + Avatar.Fallback from @base-ui/react/avatar.\n * Props: src, alt, fallback, className.\n * data-slot attributes on root (\"avatar\"), image (\"avatar-image\"), fallback (\"avatar-fallback\").\n *\n * Design tokens: Tailwind v4 semantic classes (bg-muted, text-muted-foreground).\n */\n\nimport { Avatar } from \"@base-ui/react/avatar\";\nimport type * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport interface MosaicAvatarProps extends Avatar.Root.Props {\n /** Image source URL */\n src?: string;\n /** Alt text for the image */\n alt?: string;\n /** Text or node rendered when image is absent or fails to load */\n fallback: React.ReactNode;\n className?: string;\n}\n\n/**\n * MosaicAvatar — user avatar with automatic image fallback.\n *\n * @example\n * <MosaicAvatar src=\"/user.png\" alt=\"John\" fallback=\"JD\" />\n * <MosaicAvatar fallback=\"AB\" />\n */\nexport function MosaicAvatar({ src, alt, fallback, className, ref, ...props }: MosaicAvatarProps) {\n return (\n <Avatar.Root\n ref={ref}\n data-slot=\"avatar\"\n className={cn(\n \"relative flex size-10 shrink-0 overflow-hidden rounded-full\",\n \"bg-muted text-muted-foreground\",\n className,\n )}\n {...props}\n >\n <Avatar.Image\n src={src ?? \"\"}\n alt={alt ?? \"\"}\n data-slot=\"avatar-image\"\n className=\"aspect-square size-full object-cover\"\n />\n <Avatar.Fallback\n data-slot=\"avatar-fallback\"\n className=\"flex size-full items-center justify-center text-sm font-medium\"\n >\n {fallback}\n </Avatar.Fallback>\n </Avatar.Root>\n );\n}\n\nMosaicAvatar.displayName = \"MosaicAvatar\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-badge",
|
|
4
|
+
"title": "MosaicBadge",
|
|
5
|
+
"description": "Inline status badge. cva variants: default, secondary, destructive, outline. Style-only span, data-slot=\"badge\".",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/badge/MosaicBadge.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicBadge — style-only badge atom\n *\n * Renders a <span> with cva variants: default, secondary, destructive, outline.\n * data-slot=\"badge\" for composability.\n *\n * Design tokens: Tailwind v4 semantic classes only. No hardcoded colors.\n */\n\nimport type { VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { badgeVariants } from \"./badge-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport interface MosaicBadgeProps\n extends React.HTMLAttributes<HTMLSpanElement>,\n VariantProps<typeof badgeVariants> {\n className?: string;\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n/**\n * MosaicBadge — inline status/label badge.\n *\n * @example\n * <MosaicBadge>New</MosaicBadge>\n * <MosaicBadge variant=\"destructive\">Error</MosaicBadge>\n * <MosaicBadge variant=\"outline\">Beta</MosaicBadge>\n */\nexport function MosaicBadge({ className, variant, ref, ...props }: MosaicBadgeProps) {\n return (\n <span\n ref={ref}\n data-slot=\"badge\"\n className={cn(badgeVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nMosaicBadge.displayName = \"MosaicBadge\";\n\nexport { badgeVariants };\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/badge/badge-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * badgeVariants — pure CVA variant function for MosaicBadge.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React\n * (which is imported in MosaicBadge.tsx but not here).\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const badgeVariants = cva(\n [\n \"inline-flex items-center justify-center\",\n \"rounded-full border border-transparent\",\n \"px-2.5 py-0.5\",\n \"text-xs font-semibold\",\n \"select-none whitespace-nowrap\",\n \"transition-colors\",\n ],\n {\n variants: {\n variant: {\n default: \"bg-primary text-primary-foreground border-transparent\",\n secondary: \"bg-secondary text-secondary-foreground border-transparent\",\n destructive: \"bg-destructive text-destructive-foreground border-transparent\",\n outline: \"bg-background text-foreground border-border\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n },\n);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-blurred-orb",
|
|
4
|
+
"title": "MosaicBlurredOrb",
|
|
5
|
+
"description": "Decorative blurred gradient orb background. Pure CSS (no extra dep). Props: colors?, size?, position?, blur?, opacity?. aria-hidden. No hardcoded branding.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/blurred-orb/MosaicBlurredOrb.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicBlurredOrb — decorative blurred gradient orb background\n *\n * Ported from heyfabrika/styleui components/blurred-orb (MIT).\n * Pure CSS/SVG — zero JS animation, zero extra deps.\n * Purely decorative: aria-hidden=\"true\".\n * Colors via OKLCH props — no hardcoded branding.\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface OrbPosition {\n top?: string;\n right?: string;\n bottom?: string;\n left?: string;\n}\n\nexport interface MosaicBlurredOrbProps {\n /**\n * Array of 1–3 OKLCH color strings.\n * Default: [\"oklch(0.7 0.15 250)\", \"oklch(0.65 0.18 290)\"]\n */\n colors?: string[];\n /** Orb diameter in pixels (default 500) */\n size?: number;\n /** CSS position values — absolute positioning anchors */\n position?: OrbPosition;\n /** Blur strength in pixels (default 80) */\n blur?: number;\n /** Opacity 0–1 (default 0.6) */\n opacity?: number;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicBlurredOrb — absolutely-positioned blurred gradient blob.\n * Wrap the parent container in `position: relative; overflow: hidden`.\n *\n * @example\n * <div className=\"relative overflow-hidden\">\n * <MosaicBlurredOrb\n * colors={[\"oklch(0.7 0.2 250)\", \"oklch(0.6 0.15 300)\"]}\n * size={600}\n * position={{ top: \"-10%\", left: \"-5%\" }}\n * />\n * <YourContent />\n * </div>\n */\nexport function MosaicBlurredOrb({\n colors = [\"oklch(0.7 0.15 250)\", \"oklch(0.65 0.18 290)\"],\n size = 500,\n position = { top: \"-15%\", left: \"-10%\" },\n blur = 80,\n opacity = 0.6,\n className,\n ref,\n}: MosaicBlurredOrbProps) {\n // Build gradient stops from colors array\n const gradientStops = colors\n .map((color, i) => {\n const pct = Math.round((i / Math.max(colors.length - 1, 1)) * 100);\n return `${color} ${pct}%`;\n })\n .join(\", \");\n\n const gradient =\n colors.length === 1\n ? `radial-gradient(circle, ${colors[0]} 0%, transparent 70%)`\n : `radial-gradient(circle, ${gradientStops}, transparent 75%)`;\n\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={className}\n style={{\n position: \"absolute\",\n width: size,\n height: size,\n borderRadius: \"50%\",\n background: gradient,\n filter: `blur(${blur}px)`,\n opacity,\n pointerEvents: \"none\",\n ...position,\n }}\n />\n );\n}\n\nMosaicBlurredOrb.displayName = \"MosaicBlurredOrb\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-button",
|
|
4
|
+
"title": "MosaicButton",
|
|
5
|
+
"description": "Accessible button atom built on @base-ui/react. Variants: default, secondary, ghost, destructive, outline, link. Sizes: default, sm, lg, icon, icon-sm, icon-lg.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react",
|
|
8
|
+
"class-variance-authority"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/button/Button.tsx",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"content": "/**\n * MosaicButton — @base-ui/react Button primitive\n *\n * Ported from heyfabrika/styleui (MIT) with namespace and import adaptations.\n * Source: https://github.com/heyfabrika/styleui/blob/main/components/ui/button.tsx\n *\n * Uses @base-ui/react/button as the headless base per ADR-0001.\n * Styling: Tailwind v4 + cva variants. No tailwind-merge needed (single source).\n * API: data-slot=\"button\" attribution, ref as regular prop (React 19).\n */\n\nimport { Button as ButtonPrimitive } from \"@base-ui/react/button\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { buttonVariants } from \"./button-variants.js\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport interface MosaicButtonProps\n extends Omit<ButtonPrimitive.Props, \"ref\">,\n VariantProps<typeof buttonVariants> {\n className?: string;\n /** ref is typed as HTMLElement to preserve the original public API surface */\n ref?: React.Ref<HTMLElement>;\n}\n\n/**\n * MosaicButton — production Button atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/button (ADR-0001). Headless, accessible by default.\n * Accepts all native button props + variant/size from cva.\n *\n * @example\n * <MosaicButton variant=\"secondary\" size=\"lg\">Save</MosaicButton>\n * <MosaicButton variant=\"destructive\" disabled>Delete</MosaicButton>\n */\nexport function MosaicButton({ className, variant, size, ref, ...props }: MosaicButtonProps) {\n return (\n <ButtonPrimitive\n ref={ref as React.Ref<HTMLButtonElement>}\n data-slot=\"button\"\n className={cn(buttonVariants({ variant, size }), className)}\n {...props}\n />\n );\n}\n\nMosaicButton.displayName = \"MosaicButton\";\n\nexport { buttonVariants };\n"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "src/components/button/button-variants.ts",
|
|
19
|
+
"type": "registry:ui",
|
|
20
|
+
"content": "/**\n * buttonVariants — pure CVA variant function for MosaicButton.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in\n * React or @base-ui/react/button (which are in Button.tsx but not here).\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const buttonVariants = cva(\n // Base classes — identical to styleui base (adapted for Tailwind v4)\n [\n \"inline-flex items-center justify-center whitespace-nowrap\",\n \"rounded-md border border-transparent bg-clip-padding\",\n \"text-sm font-medium select-none\",\n \"transition-all outline-none\",\n \"focus-visible:ring-[3px]\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n \"[&_svg]:pointer-events-none [&_svg]:shrink-0\",\n \"[&_svg:not([class*='size-'])]:size-4\",\n \"group/button shrink-0\",\n ],\n {\n variants: {\n variant: {\n default: \"bg-foreground text-primary-foreground hover:bg-foreground/80\",\n secondary: \"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\n ghost: \"hover:bg-muted hover:text-foreground\",\n destructive:\n \"bg-destructive/10 hover:bg-destructive/20 text-destructive focus-visible:border-destructive/40\",\n outline: \"border-border bg-background hover:bg-muted hover:text-foreground shadow-xs\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 gap-1.5 px-4\",\n sm: \"h-8 gap-1 rounded-[10px] px-2.5\",\n lg: \"h-10 gap-1.5 px-4\",\n icon: \"size-9\",\n \"icon-sm\": \"size-8 rounded-[10px]\",\n \"icon-lg\": \"size-10\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n },\n);\n"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "registry:ui"
|
|
24
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-callout",
|
|
4
|
+
"title": "MosaicCallout",
|
|
5
|
+
"description": "MosaicCallout — inline bordered notice",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/callout/MosaicCallout.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicCallout — inline bordered notice\n *\n * Style-only component: a bordered box carrying a required title and\n * optional children/icon, supplied entirely by the host.\n *\n * variant=\"info\" -> role=\"status\" (non-urgent, ambient notice)\n * variant=\"warning\" -> role=\"alert\" (urgent, must be announced)\n *\n * data-slot=\"callout\" for composability.\n * Design tokens: Tailwind v4 semantic classes only. No hardcoded colors.\n */\n\nimport type { VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { calloutVariants } from \"./callout-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicCalloutProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\">,\n VariantProps<typeof calloutVariants> {\n /** Required — the host owns the copy, no default text is generated. */\n title: string;\n children?: React.ReactNode;\n /** Host-supplied icon, rendered as-is. */\n icon?: React.ReactNode;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicCallout — inline notice with a semantic role driven by variant.\n *\n * @example\n * <MosaicCallout variant=\"info\" title=\"Heads up\">\n * Optional supporting copy supplied by the host.\n * </MosaicCallout>\n * <MosaicCallout variant=\"warning\" title=\"Action required\" icon={<WarnIcon />} />\n */\nexport function MosaicCallout({\n variant = \"info\",\n title,\n children,\n icon,\n className,\n ref,\n ...props\n}: MosaicCalloutProps) {\n const role = variant === \"warning\" ? \"alert\" : \"status\";\n\n return (\n <div\n ref={ref}\n role={role}\n data-slot=\"callout\"\n className={cn(calloutVariants({ variant }), className)}\n {...props}\n >\n {icon ? (\n <span aria-hidden=\"true\" className=\"mt-0.5 shrink-0\">\n {icon}\n </span>\n ) : null}\n <div className=\"flex flex-col gap-0.5\">\n <p className=\"font-medium\">{title}</p>\n {children ? <div className=\"text-muted-foreground\">{children}</div> : null}\n </div>\n </div>\n );\n}\n\nMosaicCallout.displayName = \"MosaicCallout\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/callout/callout-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * calloutVariants — pure CVA variant function for MosaicCallout.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const calloutVariants = cva(\n [\"flex items-start gap-2.5\", \"rounded-md border\", \"px-3 py-2.5\", \"text-sm\"],\n {\n variants: {\n variant: {\n info: \"border-info-500/30 bg-info-50 text-foreground\",\n warning: \"border-warning-500/30 bg-warning-50 text-foreground\",\n },\n },\n defaultVariants: {\n variant: \"info\",\n },\n },\n);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-card",
|
|
4
|
+
"title": "MosaicCard",
|
|
5
|
+
"description": "Composable card surface: Card + CardHeader + CardTitle + CardDescription + CardContent + CardFooter. Style-only, data-slot per part. OKLCH theme-reactive.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/card/MosaicCard.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicCard — style-only composable Card atom\n *\n * Composable sub-parts: Card + CardHeader + CardTitle + CardDescription +\n * CardContent + CardFooter. Plain <div>s with data-slot attributes.\n * No base-ui primitive needed — purely presentational.\n *\n * Design tokens: Tailwind v4 semantic classes only (bg-card, text-card-foreground,\n * border-border). No hardcoded colors.\n */\n\nimport type * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── MosaicCard ────────────────────────────────────────────────────────────────\n\nexport interface MosaicCardProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * MosaicCard — root container with rounded border and background.\n *\n * @example\n * <MosaicCard>\n * <MosaicCardHeader>…</MosaicCardHeader>\n * <MosaicCardContent>…</MosaicCardContent>\n * <MosaicCardFooter>…</MosaicCardFooter>\n * </MosaicCard>\n */\nexport function MosaicCard({ className, ref, ...props }: MosaicCardProps) {\n return (\n <div\n ref={ref}\n data-slot=\"card\"\n className={cn(\n \"bg-card text-card-foreground rounded-xl border border-border shadow-sm\",\n className,\n )}\n {...props}\n />\n );\n}\n\nMosaicCard.displayName = \"MosaicCard\";\n\n// ── MosaicCardHeader ──────────────────────────────────────────────────────────\n\nexport interface MosaicCardHeaderProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport function MosaicCardHeader({ className, ref, ...props }: MosaicCardHeaderProps) {\n return (\n <div\n ref={ref}\n data-slot=\"card-header\"\n className={cn(\"flex flex-col gap-1.5 p-6\", className)}\n {...props}\n />\n );\n}\n\nMosaicCardHeader.displayName = \"MosaicCardHeader\";\n\n// ── MosaicCardTitle ───────────────────────────────────────────────────────────\n\nexport interface MosaicCardTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {\n className?: string;\n ref?: React.Ref<HTMLHeadingElement>;\n}\n\nexport function MosaicCardTitle({ className, ref, ...props }: MosaicCardTitleProps) {\n return (\n <h3\n ref={ref}\n data-slot=\"card-title\"\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n );\n}\n\nMosaicCardTitle.displayName = \"MosaicCardTitle\";\n\n// ── MosaicCardDescription ─────────────────────────────────────────────────────\n\nexport interface MosaicCardDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n className?: string;\n ref?: React.Ref<HTMLParagraphElement>;\n}\n\nexport function MosaicCardDescription({ className, ref, ...props }: MosaicCardDescriptionProps) {\n return (\n <p\n ref={ref}\n data-slot=\"card-description\"\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n );\n}\n\nMosaicCardDescription.displayName = \"MosaicCardDescription\";\n\n// ── MosaicCardContent ─────────────────────────────────────────────────────────\n\nexport interface MosaicCardContentProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport function MosaicCardContent({ className, ref, ...props }: MosaicCardContentProps) {\n return (\n <div ref={ref} data-slot=\"card-content\" className={cn(\"p-6 pt-0\", className)} {...props} />\n );\n}\n\nMosaicCardContent.displayName = \"MosaicCardContent\";\n\n// ── MosaicCardFooter ──────────────────────────────────────────────────────────\n\nexport interface MosaicCardFooterProps extends React.HTMLAttributes<HTMLDivElement> {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport function MosaicCardFooter({ className, ref, ...props }: MosaicCardFooterProps) {\n return (\n <div\n ref={ref}\n data-slot=\"card-footer\"\n className={cn(\"flex items-center p-6 pt-0\", className)}\n {...props}\n />\n );\n}\n\nMosaicCardFooter.displayName = \"MosaicCardFooter\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-chat-composer",
|
|
4
|
+
"title": "MosaicChatComposer",
|
|
5
|
+
"description": "MosaicChatComposer — presentational, controlled chat input + send/stop button",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/chat-composer/MosaicChatComposer.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicChatComposer — presentational, controlled chat input + send/stop button\n *\n * Presentational atom. Renders a multi-line, auto-growing textarea plus a\n * single action button whose ROLE flips between \"send\" and \"stop\" depending\n * on `status` — the STOP button (cancel the in-flight agent response) is the\n * library's differentiator versus a plain send-only composer. The component\n * performs no network call and holds no message state: the current text is\n * fully host-controlled (`value` + `onValueChange`), and both `onSubmit(text)`\n * (idle) and `onStop()` (responding) are pure prop callbacks.\n *\n * Local behaviour (no network involved): Enter (without Shift) submits the\n * trimmed value while `status === \"idle\"`; Shift+Enter inserts a newline; the\n * textarea auto-grows with the content up to a max height, then scrolls.\n *\n * Pattern: MosaicUrlScraper.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module, host-controlled status union as\n * a discriminated prop type).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --foreground, --background, --muted-foreground, --border,\n * --ring, --card.\n * No icon library — plain glyphs (\"↑\" send / \"■\" stop), matching the\n * document-upload / url-scraper convention (no lucide-react runtime\n * dependency). Glyphs are `aria-hidden`; the accessible name comes from the\n * required `sendButtonAriaLabel` / `stopButtonAriaLabel` props.\n * a11y: the textarea has a required accessible name (`textareaAriaLabel`);\n * the action button's accessible name flips with `status`; an\n * `aria-live=\"polite\"` region announces the current action-button label so\n * an assistive-technology user is told when send becomes stop (and back).\n * Bilingual: every user-facing string (`textareaAriaLabel`, `placeholder`,\n * `sendButtonAriaLabel`, `stopButtonAriaLabel`) is a required caller-supplied\n * prop — zero hardcoded copy, zero default.\n *\n * Props are pushed into the `MosaicChatComposerState` discriminated union\n * exactly where they are read: `onSubmit`/`sendButtonAriaLabel` only exist on\n * the \"idle\" variant (the send button, and the only branch Enter submits\n * from); `onStop`/`stopButtonAriaLabel` only exist on the \"responding\"\n * variant (the stop button) — declaring `stopButtonAriaLabel` on the base\n * props would force every host to supply a label that is never displayed\n * while idle, which is exactly the \"lying prop contract\" this library\n * forbids.\n *\n * Ported from any-eve-tpl components/chat/composer.tsx (rewritten from\n * scratch — no shared code, no license carried over): dropped the\n * `disabledReason`/`isPreparing`/tooltip-wrapping/character-limit business\n * logic (app-specific), kept the textarea + auto-submit-on-Enter + send/stop\n * action shape, and promoted the STOP button from \"one branch among three\"\n * to a first-class discriminated state (host-controlled, not a boolean\n * `isBusy` prop carrying unused fields).\n *\n * @example\n * // idle — can submit\n * <MosaicChatComposer\n * status=\"idle\"\n * value={value}\n * onValueChange={setValue}\n * onSubmit={(text) => send(text)}\n * textareaAriaLabel=\"Message à eve\"\n * placeholder=\"Demandez ce que vous voulez à eve...\"\n * sendButtonAriaLabel=\"Envoyer le message\"\n * />\n *\n * @example\n * // responding — can stop (the differentiator)\n * <MosaicChatComposer\n * {...baseProps}\n * status=\"responding\"\n * onStop={() => abortResponse()}\n * stopButtonAriaLabel=\"Arrêter la réponse\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport {\n chatComposerActionButtonVariants,\n chatComposerRootVariants,\n chatComposerTextareaVariants,\n} from \"./chat-composer-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\n/**\n * Base props required in EVERY status — read unconditionally by the\n * component regardless of `status` (the textarea itself, reachable from both\n * \"idle\" and \"responding\").\n */\ntype MosaicChatComposerBaseProps = {\n /** Host-controlled current textarea value. */\n value: string;\n /** Called with the raw textarea value on every keystroke. */\n onValueChange: (value: string) => void;\n /** Accessible name for the textarea (`aria-label`). Required, no default. */\n textareaAriaLabel: string;\n /** Placeholder text for the textarea. Required, no default. */\n placeholder: string;\n /** Disables the textarea (e.g. host-level connectivity loss). */\n disabled?: boolean;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLFormElement>;\n};\n\n/**\n * Host-controlled composer status. `onSubmit` + `sendButtonAriaLabel` are\n * required only while the composer CAN send (\"idle\"); `onStop` +\n * `stopButtonAriaLabel` are required only while the agent IS responding\n * (\"responding\") — each field lives exactly on the branch that renders it.\n */\nexport type MosaicChatComposerState =\n | {\n status: \"idle\";\n /** Called with the trimmed value on Enter (no Shift) or send-button click. */\n onSubmit: (text: string) => void;\n /** Accessible name for the send button. Required, no default. */\n sendButtonAriaLabel: string;\n }\n | {\n status: \"responding\";\n /** Called when the stop button is activated — the differentiator. */\n onStop: () => void;\n /** Accessible name for the stop button. Required, no default. */\n stopButtonAriaLabel: string;\n };\n\nexport type MosaicChatComposerProps = MosaicChatComposerBaseProps & MosaicChatComposerState;\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicChatComposer — production chat-input atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders a controlled, auto-growing textarea and a\n * single action button whose role (send/stop) is driven by `status`. No\n * network call, no message history, no built-in copy.\n */\nexport function MosaicChatComposer(props: MosaicChatComposerProps) {\n const {\n value,\n onValueChange,\n textareaAriaLabel,\n placeholder,\n disabled = false,\n className,\n ref,\n } = props;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const trimmedValue = value.trim();\n\n // Auto-grow: `value` drives the resize on every content change even though\n // the effect body reads `textareaRef.current`, not `value`, by design.\n // biome-ignore lint/correctness/useExhaustiveDependencies: value is the intentional resize trigger\n useEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) {\n return;\n }\n textarea.style.height = \"auto\";\n textarea.style.height = `${textarea.scrollHeight}px`;\n }, [value]);\n\n const submitValue = useCallback(() => {\n if (props.status !== \"idle\") {\n return;\n }\n const text = value.trim();\n if (!text || disabled) {\n return;\n }\n props.onSubmit(text);\n }, [disabled, props, value]);\n\n const handleSubmit = useCallback(\n (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n submitValue();\n },\n [submitValue],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submitValue();\n }\n },\n [submitValue],\n );\n\n const currentActionLabel =\n props.status === \"responding\" ? props.stopButtonAriaLabel : props.sendButtonAriaLabel;\n\n return (\n <form\n ref={ref}\n data-slot=\"chat-composer\"\n className={cn(chatComposerRootVariants(), className)}\n onSubmit={handleSubmit}\n >\n <textarea\n data-slot=\"chat-composer-input\"\n aria-label={textareaAriaLabel}\n className={chatComposerTextareaVariants()}\n disabled={disabled}\n onChange={(event) => onValueChange(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={textareaRef}\n rows={1}\n value={value}\n />\n <div className=\"flex min-h-9 items-center justify-end gap-2 px-3 pt-1 pb-2\">\n {props.status === \"responding\" ? (\n <button\n aria-label={props.stopButtonAriaLabel}\n className={chatComposerActionButtonVariants({ tone: \"stop\" })}\n data-slot=\"chat-composer-stop-button\"\n onClick={props.onStop}\n type=\"button\"\n >\n <span aria-hidden=\"true\">■</span>\n </button>\n ) : (\n <button\n aria-label={props.sendButtonAriaLabel}\n className={chatComposerActionButtonVariants({ tone: \"send\" })}\n data-slot=\"chat-composer-send-button\"\n disabled={disabled || trimmedValue.length === 0}\n type=\"submit\"\n >\n <span aria-hidden=\"true\">↑</span>\n </button>\n )}\n </div>\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"chat-composer-status-announcer\">\n {currentActionLabel}\n </span>\n </form>\n );\n}\n\nMosaicChatComposer.displayName = \"MosaicChatComposer\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/chat-composer/chat-composer-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * chatComposerVariants — pure CVA variant functions for MosaicChatComposer.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Root form container. */\nexport const chatComposerRootVariants = cva([\n \"min-w-0 rounded-[14px] border border-border bg-card shadow-sm transition-colors\",\n \"focus-within:ring-[1px] focus-within:ring-ring\",\n]);\n\n/** Textarea input. */\nexport const chatComposerTextareaVariants = cva([\n \"max-h-40 min-h-12 w-full resize-none bg-transparent px-3 pt-3 pb-1 text-sm outline-none\",\n \"placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60\",\n]);\n\n/** Send / stop action button, by tone. */\nexport const chatComposerActionButtonVariants = cva(\n [\"inline-flex size-7 shrink-0 items-center justify-center rounded-md transition-colors\"],\n {\n variants: {\n tone: {\n send: \"bg-foreground text-background hover:bg-foreground/90 disabled:cursor-not-allowed disabled:opacity-30\",\n stop: \"cursor-pointer bg-foreground/15 text-foreground hover:bg-foreground/25\",\n },\n },\n defaultVariants: {\n tone: \"send\",\n },\n },\n);\n"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"type": "registry:ui"
|
|
21
|
+
}
|