@vantageos/mosaic-blocks 0.5.34-alpha → 0.5.36-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.
Files changed (149) hide show
  1. package/README.md +9 -8
  2. package/dist/index.cjs +1517 -101
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +1283 -15
  5. package/dist/index.d.ts +1283 -15
  6. package/dist/index.js +1487 -102
  7. package/dist/index.js.map +1 -1
  8. package/dist/styles.css +18 -0
  9. package/package.json +38 -26
  10. package/r/mosaic-accordion.json +18 -0
  11. package/r/mosaic-activity-feed.json +16 -0
  12. package/r/mosaic-adaptive-grid.json +18 -0
  13. package/r/mosaic-adaptive-modal.json +18 -0
  14. package/r/mosaic-adaptive-navigation.json +18 -0
  15. package/r/mosaic-add-memory-form.json +25 -0
  16. package/r/mosaic-admin-only-guard.json +18 -0
  17. package/r/mosaic-agent-builder-modal.json +23 -0
  18. package/r/mosaic-agent-card.json +16 -0
  19. package/r/mosaic-agent-chat.json +26 -0
  20. package/r/mosaic-agent-composer.json +28 -0
  21. package/r/mosaic-agent-editor.json +25 -0
  22. package/r/mosaic-agent-list.json +21 -0
  23. package/r/mosaic-agent-preview.json +21 -0
  24. package/r/mosaic-alert-dialog.json +23 -0
  25. package/r/mosaic-animated-list.json +16 -0
  26. package/r/mosaic-api-key-panel.json +21 -0
  27. package/r/mosaic-app-sidebar.json +18 -0
  28. package/r/mosaic-approval-prompt.json +21 -0
  29. package/r/mosaic-artifact-canvas-adapter.json +26 -0
  30. package/r/mosaic-artifact-chart.json +18 -0
  31. package/r/mosaic-artifact-checklist.json +18 -0
  32. package/r/mosaic-artifact-data-table.json +18 -0
  33. package/r/mosaic-artifact-document.json +16 -0
  34. package/r/mosaic-artifact-library.json +18 -0
  35. package/r/mosaic-artifact-save-as-memory-form.json +24 -0
  36. package/r/mosaic-artifact-version-history.json +16 -0
  37. package/r/mosaic-avatar.json +18 -0
  38. package/r/mosaic-badge.json +23 -0
  39. package/r/mosaic-blurred-orb.json +16 -0
  40. package/r/mosaic-button.json +24 -0
  41. package/r/mosaic-callout.json +23 -0
  42. package/r/mosaic-card.json +16 -0
  43. package/r/mosaic-chat-composer.json +21 -0
  44. package/r/mosaic-chat-message.json +23 -0
  45. package/r/mosaic-chat-sidebar.json +21 -0
  46. package/r/mosaic-chat-thread.json +21 -0
  47. package/r/mosaic-checkbox.json +18 -0
  48. package/r/mosaic-clerk-org-switcher.json +18 -0
  49. package/r/mosaic-clerk-webhook-handler.json +18 -0
  50. package/r/mosaic-collapsible.json +18 -0
  51. package/r/mosaic-combobox.json +18 -0
  52. package/r/mosaic-counter.json +16 -0
  53. package/r/mosaic-dashboard-content.json +18 -0
  54. package/r/mosaic-dashboard-header.json +18 -0
  55. package/r/mosaic-dashboard-layout.json +20 -0
  56. package/r/mosaic-data-table.json +16 -0
  57. package/r/mosaic-delete-confirmation-dialog.json +18 -0
  58. package/r/mosaic-device-provider.json +16 -0
  59. package/r/mosaic-document-table.json +52 -0
  60. package/r/mosaic-document-upload.json +21 -0
  61. package/r/mosaic-drawer.json +23 -0
  62. package/r/mosaic-dropdown-menu.json +18 -0
  63. package/r/mosaic-edit-memory-dialog.json +27 -0
  64. package/r/mosaic-edit-session-dialog.json +25 -0
  65. package/r/mosaic-editable-cell.json +23 -0
  66. package/r/mosaic-empty-state.json +16 -0
  67. package/r/mosaic-falling-pattern.json +16 -0
  68. package/r/mosaic-feature-3col.json +16 -0
  69. package/r/mosaic-feature-centered-media.json +16 -0
  70. package/r/mosaic-field.json +18 -0
  71. package/r/mosaic-filter-bar.json +18 -0
  72. package/r/mosaic-filter-sidebar.json +18 -0
  73. package/r/mosaic-footer-simple.json +16 -0
  74. package/r/mosaic-hero-split.json +16 -0
  75. package/r/mosaic-input-group.json +16 -0
  76. package/r/mosaic-input.json +18 -0
  77. package/r/mosaic-integrations-badge.json +16 -0
  78. package/r/mosaic-kanban-board.json +21 -0
  79. package/r/mosaic-logos-grid.json +16 -0
  80. package/r/mosaic-main-nav.json +18 -0
  81. package/r/mosaic-markdown.json +21 -0
  82. package/r/mosaic-marketplace-card.json +24 -0
  83. package/r/mosaic-marketplace-list.json +20 -0
  84. package/r/mosaic-match-input.json +23 -0
  85. package/r/mosaic-memory-card.json +21 -0
  86. package/r/mosaic-memory-dashboard.json +23 -0
  87. package/r/mosaic-memory-grid.json +21 -0
  88. package/r/mosaic-memory-list.json +21 -0
  89. package/r/mosaic-memory-search.json +23 -0
  90. package/r/mosaic-mention-input.json +23 -0
  91. package/r/mosaic-message-card.json +16 -0
  92. package/r/mosaic-message-list.json +19 -0
  93. package/r/mosaic-message-search.json +18 -0
  94. package/r/mosaic-model-selector.json +23 -0
  95. package/r/mosaic-module-card.json +16 -0
  96. package/r/mosaic-module-library.json +18 -0
  97. package/r/mosaic-multi-tenant-provider.json +19 -0
  98. package/r/mosaic-navbar.json +16 -0
  99. package/r/mosaic-org-context-display.json +18 -0
  100. package/r/mosaic-org-panel.json +19 -0
  101. package/r/mosaic-org-profile-page.json +18 -0
  102. package/r/mosaic-org-switcher.json +16 -0
  103. package/r/mosaic-pdf-viewer.json +23 -0
  104. package/r/mosaic-popover.json +23 -0
  105. package/r/mosaic-preferences-panel.json +18 -0
  106. package/r/mosaic-pricing-card.json +16 -0
  107. package/r/mosaic-profile-panel.json +18 -0
  108. package/r/mosaic-progress.json +18 -0
  109. package/r/mosaic-quick-action-card.json +16 -0
  110. package/r/mosaic-quick-actions-menu.json +18 -0
  111. package/r/mosaic-quick-agent-selector.json +19 -0
  112. package/r/mosaic-radio-group.json +18 -0
  113. package/r/mosaic-reply-input.json +21 -0
  114. package/r/mosaic-resizable-split-pane.json +23 -0
  115. package/r/mosaic-save-chat-as-memory-form.json +25 -0
  116. package/r/mosaic-save-template-modal.json +27 -0
  117. package/r/mosaic-scroll-area.json +18 -0
  118. package/r/mosaic-select.json +18 -0
  119. package/r/mosaic-selector-modal.json +18 -0
  120. package/r/mosaic-separator.json +18 -0
  121. package/r/mosaic-session-card.json +24 -0
  122. package/r/mosaic-session-list.json +21 -0
  123. package/r/mosaic-sign-in-layout.json +18 -0
  124. package/r/mosaic-sign-up-layout.json +18 -0
  125. package/r/mosaic-skeleton.json +23 -0
  126. package/r/mosaic-slider.json +18 -0
  127. package/r/mosaic-stats-grid.json +16 -0
  128. package/r/mosaic-step-pipeline.json +21 -0
  129. package/r/mosaic-switch.json +18 -0
  130. package/r/mosaic-tabs.json +18 -0
  131. package/r/mosaic-tag-input.json +23 -0
  132. package/r/mosaic-template-agent-card.json +21 -0
  133. package/r/mosaic-template-category-chips.json +21 -0
  134. package/r/mosaic-template-gallery.json +20 -0
  135. package/r/mosaic-template-list.json +21 -0
  136. package/r/mosaic-template-management-panel.json +25 -0
  137. package/r/mosaic-testimonials-grid.json +16 -0
  138. package/r/mosaic-textarea.json +16 -0
  139. package/r/mosaic-theme-provider.json +18 -0
  140. package/r/mosaic-theme-toggle.json +16 -0
  141. package/r/mosaic-thread-indicator.json +21 -0
  142. package/r/mosaic-thread-view.json +21 -0
  143. package/r/mosaic-toast.json +28 -0
  144. package/r/mosaic-tool-toggle-list.json +23 -0
  145. package/r/mosaic-tooltip.json +18 -0
  146. package/r/mosaic-url-scraper.json +21 -0
  147. package/r/mosaic-user-button.json +18 -0
  148. package/r/use-effective-workspace-id.json +18 -0
  149. package/registry.json +179 -130
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-chat-message",
4
+ "title": "MosaicChatMessage",
5
+ "description": "MosaicChatMessage — one chat message: role + ordered parts (text / reasoning / tool call).",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-collapsible.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/chat-message/MosaicChatMessage.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicChatMessage — one chat message: role + ordered parts (text /\n * reasoning / tool call).\n *\n * Presentational only: no network call, no SDK, no markdown engine, no\n * approval UI. Three explicit extension points are exposed instead of\n * bundled dependencies:\n * - `renderText` — the host renders the text part's markdown (MVP-7\n * `MosaicMarkdown`, built in parallel). The library never picks a\n * markdown engine.\n * - `renderApproval` — required ONLY on the tool-call `\"approval-requested\"`\n * branch. The host renders its own approval UI (MVP-3\n * `MosaicApprovalPrompt`, built in parallel) — this library never depends\n * on a component that does not exist yet in its own package.\n * - `toolStatusLabels` — every user-facing tool-status word is host-owned\n * copy (SIN-01 i18n), no English fallback baked in.\n * - `renderAttachment` — required on the `\"attachment\"` part. The host\n * renders its own file/image/PDF viewer; the library bundles zero\n * attachment-rendering dependency and only exposes the attachment's\n * metadata as `data-*` attributes (never as rendered content).\n *\n * Tool-call lifecycle is a discriminated union on `state`, matching the\n * eve/react part contract exactly (input-streaming -> approval-requested ->\n * output-available | output-denied | output-error). Each state's own\n * required prop lives on that state's branch alone — `renderApproval` only\n * exists on `\"approval-requested\"`, `output` only on `\"output-available\"`,\n * `errorText` only on `\"output-error\"` (mirrors MosaicUrlScraper's\n * status-branch contract and the \"no lying prop contract\" guard).\n *\n * Pattern: MosaicUrlScraper.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module, host-controlled discriminated\n * union). Reuses MosaicCollapsible (@base-ui/react) for the reasoning\n * disclosure instead of hand-rolled state.\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --foreground, --muted, --muted-foreground, --border,\n * --destructive, --emerald (status), --ring, --card.\n * No icon library — plain text/glyphs only (matches MosaicUrlScraper's \"no\n * lucide-react runtime dependency\" convention).\n * a11y: the reasoning disclosure is a real button (MosaicCollapsibleTrigger,\n * aria-expanded managed by @base-ui/react); tool-call status is exposed as\n * visible text, not color alone.\n * Bilingual: every user-facing string (reasoningLabel/reasoningStreamingLabel\n * /toolStatusLabels.*) is a required caller-supplied prop — zero hardcoded\n * copy, zero default.\n *\n * Ported from eve/react's components/chat/message.tsx (rewritten from\n * scratch — no shared code, no license carried over): dropped the\n * streaming-text-reveal simulation, the input-request/free-text-response UI,\n * the tool-name/action heuristics (formatToolName/describeToolAction/\n * toolCategory/...), and the connection-search special-casing — all\n * app-specific business logic outside a presentational library's scope.\n * Kept the role + parts shape and the 5-state tool-call union.\n *\n * @example\n * // text + reasoning + a completed tool call\n * <MosaicChatMessage\n * messageRole=\"assistant\"\n * parts={[\n * { type: \"reasoning\", text: \"Je vérifie la doc avant de répondre.\" },\n * { type: \"text\", text: \"Voici la réponse.\" },\n * {\n * type: \"tool\",\n * toolCallId: \"call_1\",\n * toolName: \"search_docs\",\n * state: \"output-available\",\n * output: { hits: 3 },\n * },\n * ]}\n * renderText={(text) => text}\n * reasoningLabel=\"Raisonnement\"\n * reasoningStreamingLabel=\"Réflexion en cours…\"\n * toolStatusLabels={{\n * running: \"En cours\",\n * completed: \"Terminé\",\n * denied: \"Refusé\",\n * error: \"Erreur\",\n * }}\n * />\n *\n * @example\n * // a tool call awaiting host-rendered approval\n * <MosaicChatMessage\n * {...baseProps}\n * parts={[\n * {\n * type: \"tool\",\n * toolCallId: \"call_2\",\n * toolName: \"delete_file\",\n * state: \"approval-requested\",\n * renderApproval: (part) => <MosaicApprovalPrompt toolName={part.toolName} />,\n * },\n * ]}\n * />\n */\n\nimport type * as React from \"react\";\nimport {\n MosaicCollapsible,\n MosaicCollapsiblePanel,\n MosaicCollapsibleTrigger,\n} from \"@/components/ui/MosaicCollapsible\";\nimport {\n chatMessageBubbleVariants,\n chatMessageContainerVariants,\n chatMessageToolStatusVariants,\n} from \"./chat-message-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 MosaicChatMessageSenderRole = \"user\" | \"assistant\";\n\n/** Plain assistant/user text part. */\nexport interface MosaicChatMessageTextPart {\n type: \"text\";\n /** Raw text content — rendered through the host-supplied `renderText`. */\n text: string;\n}\n\n/** Repliable reasoning (\"thinking\") part. */\nexport interface MosaicChatMessageReasoningPart {\n type: \"reasoning\";\n /** Raw reasoning text — rendered through the host-supplied `renderText`. */\n text: string;\n /** Whether the reasoning is still streaming (forces the disclosure open). */\n isStreaming?: boolean;\n}\n\n/** Fields shared by every tool-call lifecycle state, read unconditionally. */\ntype MosaicChatMessageToolPartBase = {\n type: \"tool\";\n /** Stable identifier for this tool call, used as the React key. */\n toolCallId: string;\n /** Tool name, displayed as-is next to the status label. */\n toolName: string;\n /** Tool call input payload, shown (JSON-stringified) when present. */\n input?: unknown;\n};\n\n/**\n * Tool-call lifecycle, a discriminated union on `state`. Each member's\n * required field lives on that member ALONE — it is required exactly where\n * the component reads it:\n * - `\"input-streaming\"` / `\"output-denied\"`: no extra field, only the shared\n * base + status label.\n * - `\"approval-requested\"`: `renderApproval` — the ONLY branch that needs a\n * host-rendered extension point (MVP-3, not yet built).\n * - `\"output-available\"`: `output` — the tool's result payload.\n * - `\"output-error\"`: `errorText` — the host-localized error message.\n */\nexport type MosaicChatMessageToolState =\n | { state: \"input-streaming\" }\n | {\n state: \"approval-requested\";\n /**\n * Renders the host-owned approval UI (e.g. MVP-3\n * `MosaicApprovalPrompt`). Required on this branch only — the library\n * never imports a component that does not exist in its own package\n * yet, and never ships its own approval affordance.\n */\n renderApproval: (part: MosaicChatMessageToolPart) => React.ReactNode;\n }\n | {\n state: \"output-available\";\n /** The tool's result payload, JSON-stringified for display. */\n output: unknown;\n }\n | { state: \"output-denied\" }\n | {\n state: \"output-error\";\n /** Host-localized error message. Required, no default. */\n errorText: string;\n };\n\nexport type MosaicChatMessageToolPart = MosaicChatMessageToolPartBase & MosaicChatMessageToolState;\n\n/**\n * Host-rendered attachment part. Mirrors the tool-call `renderApproval`\n * pattern: the library never bundles a file viewer/renderer — the host\n * supplies `renderAttachment`. The metadata fields describe the attachment\n * (never its rendering) and are exposed as `data-*` attributes on the\n * wrapper, never as rendered text/UI.\n */\nexport interface MosaicChatMessageAttachmentPart {\n type: \"attachment\";\n /** Stable identifier for this attachment, used as the React key. */\n attachmentId: string;\n /** File name, exposed as `data-attachment-filename`. */\n fileName: string;\n /** MIME type of the attachment, exposed as `data-attachment-mimetype`. */\n mimeType: string;\n /** Size in bytes, exposed as `data-attachment-size`. */\n sizeBytes: number;\n /** URL where the attachment can be fetched/downloaded. */\n url: string;\n /**\n * Renders the host-owned attachment UI (e.g. a PDF/image viewer). Required\n * — the library never bundles a file-rendering dependency.\n */\n renderAttachment: (part: MosaicChatMessageAttachmentPart) => React.ReactNode;\n}\n\nexport type MosaicChatMessagePart =\n | MosaicChatMessageTextPart\n | MosaicChatMessageReasoningPart\n | MosaicChatMessageToolPart\n | MosaicChatMessageAttachmentPart;\n\n/** Host-owned copy for every tool-call status label. Required, no default. */\nexport interface MosaicChatMessageToolStatusLabels {\n running: string;\n completed: string;\n denied: string;\n error: string;\n}\n\nexport interface MosaicChatMessageProps {\n /**\n * Who sent the message — drives bubble alignment/styling. Named\n * `messageRole` (not `role`) so no host ever writes a `role=\"user\"` /\n * `role=\"assistant\"` JSX attribute — `\"user\"`/`\"assistant\"` are not valid\n * WAI-ARIA roles, and a linter (or a screen reader) reading a literal\n * `role` attribute cannot tell a domain enum from a DOM ARIA role.\n * Exposed on the DOM as `data-role`, never as `role`.\n */\n messageRole: MosaicChatMessageSenderRole;\n /** Ordered message parts. */\n parts: MosaicChatMessagePart[];\n /**\n * Renders a text/reasoning part's raw string. The host owns the markdown\n * engine (MVP-7 `MosaicMarkdown`) — the library never bundles one.\n * Required, no default.\n */\n renderText: (text: string) => React.ReactNode;\n /** Label on the reasoning disclosure trigger while NOT streaming. Required, no default. */\n reasoningLabel: string;\n /** Label on the reasoning disclosure trigger WHILE streaming. Required, no default. */\n reasoningStreamingLabel: string;\n /** Host-owned copy for every tool-call status. Required, no default. */\n toolStatusLabels: MosaicChatMessageToolStatusLabels;\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLElement>;\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────────────\n\nfunction partKey(part: MosaicChatMessagePart, index: number): string {\n if (part.type === \"tool\") return part.toolCallId;\n if (part.type === \"attachment\") return part.attachmentId;\n return `${part.type}:${index}`;\n}\n\nfunction toolStatusOf(\n part: MosaicChatMessageToolPart,\n): \"running\" | \"completed\" | \"denied\" | \"error\" {\n switch (part.state) {\n case \"input-streaming\":\n case \"approval-requested\":\n return \"running\";\n case \"output-available\":\n return \"completed\";\n case \"output-denied\":\n return \"denied\";\n case \"output-error\":\n return \"error\";\n }\n}\n\nfunction formatPayload(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n try {\n return JSON.stringify(value, null, 2);\n } catch {\n return String(value);\n }\n}\n\n// ── Sub-components ───────────────────────────────────────────────────────────\n\nfunction ChatMessageTextPartView({\n part,\n renderText,\n}: {\n part: MosaicChatMessageTextPart;\n renderText: (text: string) => React.ReactNode;\n}) {\n return (\n <div data-slot=\"chat-message-text\" className=\"whitespace-pre-wrap break-words\">\n {renderText(part.text)}\n </div>\n );\n}\n\nfunction ChatMessageReasoningPartView({\n part,\n reasoningLabel,\n reasoningStreamingLabel,\n renderText,\n}: {\n part: MosaicChatMessageReasoningPart;\n reasoningLabel: string;\n reasoningStreamingLabel: string;\n renderText: (text: string) => React.ReactNode;\n}) {\n const isStreaming = Boolean(part.isStreaming);\n\n return (\n <MosaicCollapsible\n data-slot=\"chat-message-reasoning\"\n defaultOpen={isStreaming}\n className=\"my-3 w-full\"\n >\n <MosaicCollapsibleTrigger className=\"justify-start gap-2 text-sm text-muted-foreground\">\n <span>{isStreaming ? reasoningStreamingLabel : reasoningLabel}</span>\n </MosaicCollapsibleTrigger>\n <MosaicCollapsiblePanel className=\"border-l border-border pl-4 text-muted-foreground\">\n {renderText(part.text)}\n </MosaicCollapsiblePanel>\n </MosaicCollapsible>\n );\n}\n\nfunction ChatMessageToolPartView({\n part,\n toolStatusLabels,\n}: {\n part: MosaicChatMessageToolPart;\n toolStatusLabels: MosaicChatMessageToolStatusLabels;\n}) {\n const status = toolStatusOf(part);\n\n return (\n <div data-slot=\"chat-message-tool\" className=\"my-2 flex flex-col gap-1 px-3\">\n <div className=\"flex items-center gap-2\">\n <span\n data-slot=\"chat-message-tool-name\"\n className=\"rounded bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground\"\n >\n {part.toolName}\n </span>\n <span\n data-slot=\"chat-message-tool-status\"\n className={chatMessageToolStatusVariants({ status })}\n >\n {toolStatusLabels[status]}\n </span>\n </div>\n\n {part.input !== undefined && (\n <pre\n data-slot=\"chat-message-tool-input\"\n className=\"max-h-56 overflow-auto rounded bg-muted/30 p-2 font-mono text-[11px] leading-5 text-muted-foreground\"\n >\n {formatPayload(part.input)}\n </pre>\n )}\n\n {part.state === \"approval-requested\" && (\n <div data-slot=\"chat-message-tool-approval\">{part.renderApproval(part)}</div>\n )}\n\n {part.state === \"output-available\" && (\n <pre\n data-slot=\"chat-message-tool-output\"\n className=\"max-h-56 overflow-auto rounded bg-muted/30 p-2 font-mono text-[11px] leading-5 text-muted-foreground\"\n >\n {formatPayload(part.output)}\n </pre>\n )}\n\n {part.state === \"output-error\" && (\n <p\n data-slot=\"chat-message-tool-error\"\n className=\"rounded bg-destructive/10 p-2 font-mono text-[11px] leading-5 text-destructive\"\n >\n {part.errorText}\n </p>\n )}\n </div>\n );\n}\n\nfunction ChatMessageAttachmentPartView({ part }: { part: MosaicChatMessageAttachmentPart }) {\n return (\n <div\n data-slot=\"chat-message-attachment\"\n data-attachment-id={part.attachmentId}\n data-attachment-filename={part.fileName}\n data-attachment-mimetype={part.mimeType}\n data-attachment-size={part.sizeBytes}\n data-attachment-url={part.url}\n className=\"my-2\"\n >\n {part.renderAttachment(part)}\n </div>\n );\n}\n\nfunction ChatMessagePartView({\n part,\n renderText,\n reasoningLabel,\n reasoningStreamingLabel,\n toolStatusLabels,\n}: {\n part: MosaicChatMessagePart;\n renderText: (text: string) => React.ReactNode;\n reasoningLabel: string;\n reasoningStreamingLabel: string;\n toolStatusLabels: MosaicChatMessageToolStatusLabels;\n}) {\n switch (part.type) {\n case \"text\":\n return <ChatMessageTextPartView part={part} renderText={renderText} />;\n case \"reasoning\":\n return (\n <ChatMessageReasoningPartView\n part={part}\n reasoningLabel={reasoningLabel}\n reasoningStreamingLabel={reasoningStreamingLabel}\n renderText={renderText}\n />\n );\n case \"tool\":\n return <ChatMessageToolPartView part={part} toolStatusLabels={toolStatusLabels} />;\n case \"attachment\":\n return <ChatMessageAttachmentPartView part={part} />;\n }\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicChatMessage — production chat-message atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders one message's role-aligned bubble and its\n * ordered parts (text/reasoning/tool call). No network call, no markdown\n * engine, no approval UI — see the module JSDoc for the three extension\n * points.\n */\nexport function MosaicChatMessage({\n messageRole,\n parts,\n renderText,\n reasoningLabel,\n reasoningStreamingLabel,\n toolStatusLabels,\n className,\n ref,\n}: MosaicChatMessageProps) {\n const isUser = messageRole === \"user\";\n\n return (\n <article\n ref={ref}\n data-slot=\"chat-message\"\n data-role={messageRole}\n className={cn(chatMessageContainerVariants({ align: isUser ? \"end\" : \"start\" }), className)}\n >\n <div className={chatMessageBubbleVariants({ role: messageRole })}>\n {parts.map((part, index) => (\n <ChatMessagePartView\n key={partKey(part, index)}\n part={part}\n renderText={renderText}\n reasoningLabel={reasoningLabel}\n reasoningStreamingLabel={reasoningStreamingLabel}\n toolStatusLabels={toolStatusLabels}\n />\n ))}\n </div>\n </article>\n );\n}\n\nMosaicChatMessage.displayName = \"MosaicChatMessage\";\n"
15
+ },
16
+ {
17
+ "path": "src/components/chat-message/chat-message-variants.ts",
18
+ "type": "registry:ui",
19
+ "content": "/**\n * chatMessageVariants — pure CVA variant functions for MosaicChatMessage.\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 row alignment — user messages align end, assistant messages align start. */\nexport const chatMessageContainerVariants = cva([\"flex w-full min-w-0\"], {\n variants: {\n align: {\n start: \"justify-start\",\n end: \"justify-end\",\n },\n },\n defaultVariants: {\n align: \"start\",\n },\n});\n\n/** Bubble surface — user gets a bounded chat bubble, assistant flows full-width. */\nexport const chatMessageBubbleVariants = cva([\"min-w-0\"], {\n variants: {\n role: {\n user: [\n \"max-w-[85%] rounded-[18px] border border-border/40 bg-muted/70 px-3 py-1.5\",\n \"text-[15px] leading-6 text-foreground shadow-sm\",\n ],\n assistant: \"w-full max-w-none text-sm leading-relaxed text-foreground\",\n },\n },\n defaultVariants: {\n role: \"assistant\",\n },\n});\n\n/** Tool-call status glyph/tone — running / completed / denied / error. */\nexport const chatMessageToolStatusVariants = cva([\"text-xs font-medium\"], {\n variants: {\n status: {\n running: \"text-muted-foreground\",\n completed: \"text-emerald-600 dark:text-emerald-500\",\n denied: \"text-destructive\",\n error: \"text-destructive\",\n },\n },\n defaultVariants: {\n status: \"running\",\n },\n});\n"
20
+ }
21
+ ],
22
+ "type": "registry:ui"
23
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-chat-sidebar",
4
+ "title": "MosaicChatSidebar",
5
+ "description": "MosaicChatSidebar — presentational, disposition-only column of conversation threads.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/chat-sidebar/MosaicChatSidebar.tsx",
11
+ "type": "registry:ui",
12
+ "content": "/**\n * MosaicChatSidebar — presentational, disposition-only column of\n * conversation threads.\n *\n * Same shape as `MosaicTemplateList`: a scrollable list over host-supplied\n * items, rendered entirely through a host-supplied `renderThread` — the\n * sidebar never invents a thread title, timestamp, preview snippet, or any\n * other domain content. It owns exactly three things: the scrollable\n * container, a roving-tabindex keyboard-navigable list, and the\n * active/inactive visual state of each row (driven by the host-controlled\n * `activeThreadId` prop, never internal state the component invents).\n *\n * Selecting a thread (`onSelectThread`) and starting a new one\n * (`onNewThread`) are callbacks up — the sidebar never mutates the thread\n * list itself.\n *\n * Empty state: the host owns the empty message (`emptyMessage`, required,\n * no default — SIN-01) — never an invented English fallback and never a\n * silent blank.\n *\n * Keyboard: roving tabindex down the list (native `<ul>` / `<li>` — semantic\n * list roles come from the elements themselves) — ArrowDown moves focus to\n * the next thread, ArrowUp to the previous, Home/End jump to the\n * first/last. Exactly one row is `tabIndex={0}` at a time.\n *\n * Deps: class-variance-authority only.\n */\n\nimport type * as React from \"react\";\nimport { useRef, useState } from \"react\";\nimport { chatSidebarThreadVariants } from \"./chat-sidebar-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 MosaicChatSidebarProps<T extends { id: string }> {\n /** The threads to lay out. The sidebar never inspects their shape beyond `id`. */\n threads: T[];\n /** Host-owned renderer for a single thread — the sidebar owns disposition only. */\n renderThread: (thread: T, index: number) => React.ReactNode;\n /**\n * The currently-active thread id, or `null` when no thread is selected.\n * Host-controlled — the sidebar never invents its own notion of \"active\".\n */\n activeThreadId: string | null;\n /** Called with the thread id when a row is selected (click or Enter/Space). */\n onSelectThread: (id: string) => void;\n /** Called when the \"new thread\" action is triggered. */\n onNewThread: () => void;\n /** Label for the \"new thread\" action. Required, no default. */\n newThreadLabel: string;\n /**\n * Message shown when `threads` is empty. Required, no default — the host\n * owns the language (e.g. `t('ChatSidebar.empty')`).\n */\n emptyMessage: string;\n /** Additional Tailwind classes on the root container. */\n className?: string;\n /** Additional Tailwind classes on each thread row wrapper. */\n itemClassName?: string;\n /** React 19 ref prop — forwarded to the root container. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Keyboard navigation ───────────────────────────────────────────────────────\n\nconst NEXT_KEYS = new Set([\"ArrowDown\"]);\nconst PREV_KEYS = new Set([\"ArrowUp\"]);\nconst SELECT_KEYS = new Set([\"Enter\", \" \"]);\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicChatSidebar — production disposition-only conversation-thread\n * column for @vantageos/mosaic-blocks.\n *\n * Purely presentational: no thread fetching, no sorting, no row content —\n * the host owns row content via `renderThread`; this component only owns\n * the scrollable disposition, keyboard roving-tabindex navigation, and the\n * active-row highlight driven by `activeThreadId`.\n *\n * @example\n * <MosaicChatSidebar\n * threads={threads}\n * activeThreadId={currentId}\n * onSelectThread={(id) => setCurrentId(id)}\n * onNewThread={() => createThread()}\n * newThreadLabel=\"New conversation\"\n * emptyMessage=\"No conversations yet.\"\n * renderThread={(thread) => <span>{thread.title}</span>}\n * />\n */\nexport function MosaicChatSidebar<T extends { id: string }>({\n threads,\n renderThread,\n activeThreadId,\n onSelectThread,\n onNewThread,\n newThreadLabel,\n emptyMessage,\n className,\n itemClassName,\n ref,\n}: MosaicChatSidebarProps<T>) {\n const itemRefs = useRef<Array<HTMLLIElement | null>>([]);\n const [focusedIndex, setFocusedIndex] = useState(0);\n\n function focusItem(index: number) {\n if (threads.length === 0) {\n return;\n }\n const clamped = Math.max(0, Math.min(threads.length - 1, index));\n setFocusedIndex(clamped);\n itemRefs.current[clamped]?.focus();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLLIElement>, index: number, id: string) {\n if (NEXT_KEYS.has(event.key)) {\n event.preventDefault();\n focusItem(index + 1);\n } else if (PREV_KEYS.has(event.key)) {\n event.preventDefault();\n focusItem(index - 1);\n } else if (event.key === \"Home\") {\n event.preventDefault();\n focusItem(0);\n } else if (event.key === \"End\") {\n event.preventDefault();\n focusItem(threads.length - 1);\n } else if (SELECT_KEYS.has(event.key)) {\n event.preventDefault();\n onSelectThread(id);\n }\n }\n\n return (\n <div\n ref={ref}\n data-slot=\"chat-sidebar\"\n className={cn(\"flex h-full flex-col gap-2 overflow-y-auto\", className)}\n >\n <button\n type=\"button\"\n data-slot=\"chat-sidebar-new-thread\"\n onClick={onNewThread}\n className=\"w-full rounded-md border border-border px-3 py-2 text-left text-foreground text-sm hover:bg-muted\"\n >\n {newThreadLabel}\n </button>\n\n {threads.length === 0 ? (\n <p\n data-slot=\"chat-sidebar-empty\"\n className=\"py-8 text-center text-muted-foreground text-sm\"\n >\n {emptyMessage}\n </p>\n ) : (\n <ul data-slot=\"chat-sidebar-list\" className=\"list-none\">\n {threads.map((thread, index) => {\n const isActive = activeThreadId === thread.id;\n return (\n <li\n key={thread.id}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n data-slot=\"chat-sidebar-thread\"\n data-active={isActive}\n tabIndex={index === focusedIndex ? 0 : -1}\n onKeyDown={(event) => handleKeyDown(event, index, thread.id)}\n onFocus={() => setFocusedIndex(index)}\n onClick={() => onSelectThread(thread.id)}\n className={cn(chatSidebarThreadVariants({ active: isActive }), itemClassName)}\n >\n {renderThread(thread, index)}\n </li>\n );\n })}\n </ul>\n )}\n </div>\n );\n}\n\nMosaicChatSidebar.displayName = \"MosaicChatSidebar\";\n"
13
+ },
14
+ {
15
+ "path": "src/components/chat-sidebar/chat-sidebar-variants.ts",
16
+ "type": "registry:ui",
17
+ "content": "/**\n * chatSidebarThreadVariants — pure CVA variant function for\n * MosaicChatSidebar's per-thread row.\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\n/**\n * Per-thread row — owns ONLY the active/inactive visual state. The row\n * never owns thread content; that is entirely host-supplied via\n * `renderThread`.\n */\nexport const chatSidebarThreadVariants = cva(\n [\"w-full cursor-pointer rounded-md px-2 py-1.5 text-left transition-colors\"],\n {\n variants: {\n active: {\n true: \"bg-accent text-accent-foreground\",\n false: \"text-foreground hover:bg-muted\",\n },\n },\n defaultVariants: {\n active: false,\n },\n },\n);\n"
18
+ }
19
+ ],
20
+ "type": "registry:ui"
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-chat-thread",
4
+ "title": "MosaicChatThread",
5
+ "description": "MosaicChatThread — presentational, auto-scrolling chat message stream",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/chat-thread/MosaicChatThread.tsx",
11
+ "type": "registry:ui",
12
+ "content": "/**\n * MosaicChatThread — presentational, auto-scrolling chat message stream\n *\n * Presentational atom. Renders a scrollable `role=\"log\"` region that keeps\n * itself pinned to the bottom as new messages arrive — the standard \"chat\n * thread\" behaviour — and surfaces a \"scroll to bottom\" button once the\n * user has scrolled up away from the latest message. It does NOT render\n * chat messages itself: the host composes the actual message list via\n * `children` (developed in parallel as `MosaicChatMessage`). This keeps the\n * thread free of any dependency on a specific message shape.\n *\n * Local behaviour (no network/data involved, pure UI mechanics):\n * - Tracks \"is the user at the bottom\" via the native `scroll` event,\n * comparing `scrollHeight - scrollTop - clientHeight` against a small\n * pixel threshold (near-bottom counts as \"at bottom\").\n * - When `children` changes (a new message was appended) AND the user was\n * at the bottom, the container is scrolled to `scrollHeight` again —\n * the \"stick to bottom\" auto-anchor.\n * - When the user has scrolled up, new children arriving do NOT force a\n * scroll — the \"scroll to bottom\" button appears instead, and clicking\n * it scrolls back down and re-arms the auto-anchor.\n *\n * Pattern: MosaicUrlScraper.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module). No icon library — uses a\n * plain \"↓\" glyph, matching the url-scraper convention (no lucide-react\n * runtime dependency).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --card, --foreground, --accent, --ring.\n * a11y: root uses `role=\"log\"` (accessible live region for a message\n * stream) and native scrolling — no focus is trapped or stolen by the\n * auto-scroll; the \"scroll to bottom\" button carries a required,\n * host-supplied `aria-label`.\n * Bilingual: the only user-facing string, the scroll button's accessible\n * name, is a required prop (`scrollToBottomLabel`) — zero hardcoded copy,\n * zero default.\n *\n * Ported from any-debate-ai components/chat/conversation.tsx (rewritten\n * from scratch — no shared code, no license carried over, and no\n * `use-stick-to-bottom` runtime dependency): dropped the third-party\n * `StickToBottom` primitive and `ChatConversationContent` split (folded\n * into a single content wrapper, this library's presentational atoms don't\n * ship a separate provider/content/button trio when a single component\n * covers the same behaviour with plain scroll math), kept the scrollable\n * `role=\"log\"` region + auto-anchor-to-bottom + \"scroll to bottom\" button\n * shape.\n *\n * @example\n * <MosaicChatThread scrollToBottomLabel=\"Revenir au dernier message\">\n * {messages.map((m) => (\n * <MosaicChatMessage key={m.id} {...m} />\n * ))}\n * </MosaicChatThread>\n */\n\nimport type * as React from \"react\";\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport {\n chatThreadContentVariants,\n chatThreadRootVariants,\n chatThreadScrollButtonVariants,\n} from \"./chat-thread-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n/** Px distance from the true bottom still counted as \"at bottom\". */\nconst BOTTOM_THRESHOLD_PX = 24;\n\nfunction isNearBottom(element: HTMLDivElement): boolean {\n return element.scrollHeight - element.scrollTop - element.clientHeight <= BOTTOM_THRESHOLD_PX;\n}\n\n/** Keyboard keys that express manual navigation intent — disengage the anchor. */\nconst NAVIGATION_KEYS = new Set([\"ArrowUp\", \"ArrowDown\", \"PageUp\", \"PageDown\", \"Home\", \"End\"]);\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\n/**\n * Snapshot of which messages are currently in the thread's viewport.\n *\n * Shape mirrors the shadcn `useMessageScrollerVisibility()` convention\n * (`currentAnchorId` / `visibleMessageIds`) so a host migrating from one to\n * the other does not need to remap fields.\n */\nexport interface MosaicChatThreadVisibleRange {\n /** Ids (DOM `id` attribute) of the direct children currently intersecting the viewport, in DOM order. */\n visibleMessageIds: string[];\n /** Id of the topmost visible child — a stable \"you are here\" anchor for a future jump-to-message affordance. `null` when nothing is visible. */\n currentAnchorId: string | null;\n}\n\nexport interface MosaicChatThreadProps {\n /** The host-rendered message list (or any other scrollable content). */\n children: React.ReactNode;\n /**\n * Accessible name for the \"scroll to bottom\" button, shown only once the\n * user has scrolled away from the latest message. Required, no default —\n * this is host copy, not an English fallback.\n */\n scrollToBottomLabel: string;\n /** Additional Tailwind classes on the root scrollable element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root scrollable element. */\n ref?: React.Ref<HTMLDivElement>;\n /**\n * OPTIONAL. Called whenever the set of visible messages changes, as\n * observed via `IntersectionObserver` on the content wrapper's direct\n * children. `children` stays fully opaque to this component — the only\n * signal read off each child is its DOM `id` attribute, never its content\n * or shape. A child without an `id` is silently excluded from the report\n * (nothing to identify it by), never introspected further.\n *\n * When this prop is omitted, NO `IntersectionObserver` is created — hosts\n * that do not need visible-range tracking pay zero cost for it.\n *\n * Opens the door to a future \"jump to message\" affordance built on top of\n * `currentAnchorId`.\n */\n onVisibleRangeChange?: (range: MosaicChatThreadVisibleRange) => void;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicChatThread — production auto-scrolling chat thread atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: no data fetching, no message rendering, no\n * conversation state — the host owns the messages and passes them as\n * `children`; this component only owns the scroll mechanics.\n */\nexport function MosaicChatThread({\n children,\n scrollToBottomLabel,\n className,\n ref,\n onVisibleRangeChange,\n}: MosaicChatThreadProps) {\n const containerRef = useRef<HTMLDivElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const isAtBottomRef = useRef(true);\n const [isAtBottom, setIsAtBottom] = useState(true);\n\n function setRefs(node: HTMLDivElement | null) {\n containerRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n (ref as React.RefObject<HTMLDivElement | null>).current = node;\n }\n }\n\n function handleScroll(event: React.UIEvent<HTMLDivElement>) {\n const atBottom = isNearBottom(event.currentTarget);\n isAtBottomRef.current = atBottom;\n setIsAtBottom(atBottom);\n }\n\n function handleScrollToBottomClick() {\n const element = containerRef.current;\n if (!element) {\n return;\n }\n element.scrollTop = element.scrollHeight;\n isAtBottomRef.current = true;\n setIsAtBottom(true);\n }\n\n /** Disengages the bottom anchor — same effect as the user scrolling up. */\n function disengageBottomAnchor() {\n isAtBottomRef.current = false;\n setIsAtBottom(false);\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (NAVIGATION_KEYS.has(event.key)) {\n disengageBottomAnchor();\n }\n }\n\n // `selectionchange` only ever fires on `document` (never on a specific\n // element), so this listener must live on `document` and be torn down on\n // unmount. A selection is only meaningful when it (a) is non-empty — a\n // plain click also fires `selectionchange` with an empty selection, and\n // disengaging there would be a false positive breaking stick-to-bottom on\n // the very first click — and (b) falls inside this thread's container.\n useEffect(() => {\n function handleSelectionChange() {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n const selection = document.getSelection();\n if (!selection || selection.isCollapsed || selection.rangeCount === 0) {\n return;\n }\n // BOTH endpoints, because the DOM's `Selection` interface defines exactly\n // two node endpoints — `anchorNode` (lib.dom.d.ts:30373) and `focusNode`\n // (:30391) — and a selection needs only ONE of them inside this thread to\n // mean \"I am reading this\".\n //\n // Checking `anchorNode` alone was a guard that knew one formulation of the\n // thing it guarded: a selection ENTERING the thread (anchored in the pane\n // next door — the split-pane's document viewer — and focused in here)\n // left `anchorNode` outside, so the handler bailed and the anchor never\n // disengaged, while thread text was visibly selected. The mirror case\n // worked, which is what made it invisible: the hole only showed one way.\n //\n // The endpoint list is DERIVED from the API, not remembered. Each endpoint\n // has its own test, and each is proven by its own mutation.\n const { anchorNode, focusNode } = selection;\n const touchesThread =\n (anchorNode !== null && container.contains(anchorNode)) ||\n (focusNode !== null && container.contains(focusNode));\n if (touchesThread) {\n isAtBottomRef.current = false;\n setIsAtBottom(false);\n }\n }\n\n document.addEventListener(\"selectionchange\", handleSelectionChange);\n return () => {\n document.removeEventListener(\"selectionchange\", handleSelectionChange);\n };\n }, []);\n\n // Reports which direct children of the content wrapper are currently\n // visible, via IntersectionObserver — keyed on each child's DOM `id`.\n // `children` stays opaque: only the `id` attribute is read, never content.\n //\n // No `onVisibleRangeChange` supplied => no observer is ever constructed —\n // hosts that don't need visible-range tracking pay zero cost for it.\n //\n // Re-runs when `children` changes (elements to observe may have changed)\n // or when `onVisibleRangeChange` itself changes. `children` is a deliberate\n // re-run trigger, not a value read inside the effect body (only the DOM\n // children of `contentRef` are read, via the ref) — same pattern as the\n // stick-to-bottom effect below.\n // biome-ignore lint/correctness/useExhaustiveDependencies: see comment above\n useEffect(() => {\n if (!onVisibleRangeChange) {\n return;\n }\n const content = contentRef.current;\n if (!content) {\n return;\n }\n\n const visibility = new Map<Element, boolean>();\n\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n visibility.set(entry.target, entry.isIntersecting);\n }\n const visibleMessageIds: string[] = [];\n for (const child of Array.from(content.children)) {\n if (child.id && visibility.get(child)) {\n visibleMessageIds.push(child.id);\n }\n }\n onVisibleRangeChange({\n visibleMessageIds,\n currentAnchorId: visibleMessageIds[0] ?? null,\n });\n });\n\n for (const child of Array.from(content.children)) {\n observer.observe(child);\n }\n\n return () => {\n observer.disconnect();\n };\n }, [children, onVisibleRangeChange]);\n\n // `children` is a deliberate re-run trigger (a new message was appended),\n // not a value read inside the effect body — the effect only touches refs.\n // biome-ignore lint/correctness/useExhaustiveDependencies: see comment above\n useLayoutEffect(() => {\n const element = containerRef.current;\n if (element && isAtBottomRef.current) {\n element.scrollTop = element.scrollHeight;\n }\n }, [children]);\n\n return (\n <div\n ref={setRefs}\n data-slot=\"chat-thread\"\n role=\"log\"\n onScroll={handleScroll}\n onKeyDown={handleKeyDown}\n className={cn(chatThreadRootVariants(), className)}\n >\n <div ref={contentRef} data-slot=\"chat-thread-content\" className={chatThreadContentVariants()}>\n {children}\n </div>\n {!isAtBottom && (\n <button\n type=\"button\"\n data-slot=\"chat-thread-scroll-button\"\n aria-label={scrollToBottomLabel}\n onClick={handleScrollToBottomClick}\n className={chatThreadScrollButtonVariants()}\n >\n <span aria-hidden=\"true\">↓</span>\n </button>\n )}\n </div>\n );\n}\n\nMosaicChatThread.displayName = \"MosaicChatThread\";\n"
13
+ },
14
+ {
15
+ "path": "src/components/chat-thread/chat-thread-variants.ts",
16
+ "type": "registry:ui",
17
+ "content": "/**\n * chatThreadVariants — pure CVA variant functions for MosaicChatThread.\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\n/** Scrollable root container. */\nexport const chatThreadRootVariants = cva([\n \"relative flex min-h-0 flex-1 flex-col overflow-y-auto\",\n]);\n\n/**\n * Inner content wrapper — centers and paces messages vertically.\n *\n * Each DIRECT CHILD gets `content-visibility: auto`, so the browser skips\n * rendering work for messages scrolled far out of view. `contain-intrinsic-size`\n * supplies a placeholder height for those skipped children — without it the\n * scrollbar would jump as they collapse to zero and re-expand on approach.\n *\n * Applied through a child selector rather than by touching the messages\n * themselves: `MosaicChatThread` takes `children` opaque and knows nothing about\n * the shape of a message. It owns the scroll mechanics, not the content — and\n * that boundary is worth more than any optimisation.\n */\nexport const chatThreadContentVariants = cva([\n \"mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6\",\n \"[&>*]:[content-visibility:auto] [&>*]:[contain-intrinsic-size:auto_4rem]\",\n]);\n\n/** \"Scroll to bottom\" floating button. */\nexport const chatThreadScrollButtonVariants = cva([\n \"absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9\",\n \"items-center justify-center rounded-full border border-border bg-card text-foreground shadow-sm\",\n \"transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n]);\n"
18
+ }
19
+ ],
20
+ "type": "registry:ui"
21
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-checkbox",
4
+ "title": "MosaicCheckbox",
5
+ "description": "MosaicCheckbox — @base-ui/react Checkbox primitive",
6
+ "dependencies": [
7
+ "@base-ui/react"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/checkbox/MosaicCheckbox.tsx",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicCheckbox — @base-ui/react Checkbox primitive\n *\n * Builds on Checkbox.Root + Checkbox.Indicator.\n * Supports controlled (checked + onCheckedChange) and uncontrolled modes.\n * Indeterminate state supported via checked=\"mixed\".\n * role=checkbox and aria-checked managed by the primitive automatically.\n *\n * data-slot=\"checkbox\" on Root, \"checkbox-indicator\" on Indicator.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Checkbox } from \"@base-ui/react/checkbox\";\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// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicCheckboxProps extends Checkbox.Root.Props {\n className?: string;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicCheckbox — production Checkbox atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/checkbox. Supports controlled + uncontrolled + indeterminate.\n * role=checkbox + aria-checked managed automatically by the primitive.\n *\n * @example\n * <MosaicCheckbox aria-label=\"Accept terms\" defaultChecked />\n * <MosaicCheckbox checked={agreed} onCheckedChange={setAgreed} />\n * <MosaicCheckbox checked=\"mixed\" aria-label=\"Select all\" />\n */\nexport function MosaicCheckbox({ className, ref, ...props }: MosaicCheckboxProps) {\n return (\n <Checkbox.Root\n ref={ref}\n data-slot=\"checkbox\"\n className={cn(\n \"peer size-4 shrink-0 cursor-pointer\",\n \"rounded-sm border border-border bg-background\",\n \"outline-none transition-colors\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n // Checked state\n \"data-[checked]:border-foreground data-[checked]:bg-foreground\",\n // Indeterminate\n \"data-[indeterminate]:border-foreground data-[indeterminate]:bg-foreground\",\n // Disabled\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n <Checkbox.Indicator\n data-slot=\"checkbox-indicator\"\n className=\"flex items-center justify-center text-background\"\n >\n {/* Checkmark icon */}\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n className=\"size-3\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n </Checkbox.Indicator>\n </Checkbox.Root>\n );\n}\n\nMosaicCheckbox.displayName = \"MosaicCheckbox\";\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-clerk-org-switcher",
4
+ "title": "MosaicClerkOrgSwitcher",
5
+ "description": "Clerk-backed org switcher (live org data). Wraps <OrganizationSwitcher> with OKLCH appearance. DISTINCT from MosaicOrgSwitcher (presentational, orgs via props).",
6
+ "dependencies": [
7
+ "@clerk/nextjs"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/auth/clerk-org-switcher/MosaicClerkOrgSwitcher.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicClerkOrgSwitcher — Clerk-backed org switcher (live org data from Clerk).\n *\n * Wraps @clerk/nextjs <OrganizationSwitcher> with OKLCH-token appearance prop.\n * Clerk is injected as a peer prop.\n *\n * DISTINCT from MosaicOrgSwitcher (presentational, orgs via props — no Clerk dep).\n * Use this component when you need live Clerk org data; use MosaicOrgSwitcher\n * for pure presentational rendering driven by your own data.\n *\n * @example\n * import { OrganizationSwitcher } from \"@clerk/nextjs\"\n * <MosaicClerkOrgSwitcher clerkOrgSwitcher={OrganizationSwitcher} />\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicClerkOrgSwitcherProps {\n /**\n * Clerk <OrganizationSwitcher> component — injected by caller.\n * Clerk-backed (live org data). Distinct from MosaicOrgSwitcher (presentational).\n */\n clerkOrgSwitcher: React.ComponentType<{\n appearance?: Record<string, unknown>;\n afterCreateOrganizationUrl?: string;\n afterSelectOrganizationUrl?: string;\n afterSelectPersonalUrl?: string;\n afterLeaveOrganizationUrl?: string;\n hidePersonal?: boolean;\n [key: string]: unknown;\n }>;\n /** URL to redirect after creating an org */\n afterCreateOrganizationUrl?: string;\n /** URL to redirect after selecting an org */\n afterSelectOrganizationUrl?: string;\n /**\n * URL to redirect after selecting the personal workspace.\n * Required for VP patterns where personal workspace has a distinct landing page.\n */\n afterSelectPersonalUrl?: string;\n /** URL to redirect after leaving an org */\n afterLeaveOrganizationUrl?: string;\n /** Hide personal workspace from the switcher */\n hidePersonal?: boolean;\n /**\n * data-testid forwarded onto the root wrapper div.\n * Allows e2e selectors (e.g. Playwright `getByTestId(\"org-switcher\")`).\n */\n \"data-testid\"?: string;\n className?: string;\n}\n\n// ── Clerk OKLCH appearance tokens ─────────────────────────────────────────────\n\nconst clerkAppearance = {\n variables: {\n colorPrimary: \"var(--primary)\",\n colorBackground: \"var(--popover)\",\n colorText: \"var(--foreground)\",\n colorTextSecondary: \"var(--muted-foreground)\",\n colorNeutral: \"var(--foreground)\",\n borderRadius: \"0.375rem\",\n },\n elements: {\n organizationSwitcherTrigger:\n \"border border-border bg-background text-foreground hover:bg-accent hover:text-accent-foreground rounded-md px-3 py-1.5 text-sm font-medium focus:ring-ring\",\n organizationPreviewAvatarBox: \"rounded bg-primary text-primary-foreground\",\n organizationSwitcherPopoverCard: \"border border-border bg-popover shadow-md\",\n organizationSwitcherPopoverActions: \"border-t border-border text-sm text-foreground\",\n organizationSwitcherPopoverActionButton:\n \"text-foreground hover:bg-accent hover:text-accent-foreground\",\n },\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicClerkOrgSwitcher({\n clerkOrgSwitcher: ClerkOrgSwitcher,\n afterCreateOrganizationUrl = \"/\",\n afterSelectOrganizationUrl = \"/\",\n afterSelectPersonalUrl,\n afterLeaveOrganizationUrl = \"/\",\n hidePersonal = false,\n \"data-testid\": dataTestId,\n className,\n}: MosaicClerkOrgSwitcherProps) {\n return (\n <div\n data-slot=\"clerk-org-switcher\"\n {...(dataTestId !== undefined && { \"data-testid\": dataTestId })}\n className={className}\n >\n <ClerkOrgSwitcher\n appearance={clerkAppearance}\n afterCreateOrganizationUrl={afterCreateOrganizationUrl}\n afterSelectOrganizationUrl={afterSelectOrganizationUrl}\n {...(afterSelectPersonalUrl !== undefined && { afterSelectPersonalUrl })}\n afterLeaveOrganizationUrl={afterLeaveOrganizationUrl}\n hidePersonal={hidePersonal}\n />\n </div>\n );\n}\n\nMosaicClerkOrgSwitcher.displayName = \"MosaicClerkOrgSwitcher\";\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-clerk-webhook-handler",
4
+ "title": "MosaicClerkWebhookHandler",
5
+ "description": "Template handler: Clerk -> Convex sync for organization.created + organizationMembership.created/deleted. svix signature verification. Returns Next.js App Router compatible Response.",
6
+ "dependencies": [
7
+ "svix"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/multi-tenant/webhook-handler/MosaicClerkWebhookHandler.ts",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicClerkWebhookHandler — template handler for Clerk → Convex sync.\n *\n * Handles: organization.created, organizationMembership.created,\n * organizationMembership.deleted events and routes them through\n * your callbacks (this handler imports nothing from cloud-identity; any sync to\n * Convex happens inside the callbacks you provide).\n *\n * Usage: import and call in your Next.js App Router API route:\n *\n * @example\n * // app/api/webhooks/clerk/route.ts\n * import { MosaicClerkWebhookHandler } from \"@vantageos/mosaic-blocks\"\n *\n * export async function POST(req: Request) {\n * return MosaicClerkWebhookHandler(req, {\n * webhookSecret: process.env.CLERK_WEBHOOK_SECRET!,\n * onOrganizationCreated: async (org) => { ... },\n * onMembershipCreated: async (data) => { ... },\n * onMembershipDeleted: async (data) => { ... },\n * })\n * }\n *\n * Note: svix is an optional peer dependency required only for webhook signature\n * verification. Install it in your app: `npm install svix`\n * If svix is absent at runtime, this handler throws an explicit Error with\n * installation instructions.\n */\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicClerkOrganization {\n id: string;\n name: string;\n slug: string | null;\n imageUrl: string;\n createdAt: number;\n updatedAt: number;\n publicMetadata: Record<string, unknown>;\n}\n\nexport interface MosaicClerkMembership {\n id: string;\n role: string;\n publicMetadata: Record<string, unknown>;\n organization: MosaicClerkOrganization;\n publicUserData: {\n userId: string;\n firstName: string | null;\n lastName: string | null;\n imageUrl: string;\n identifier: string;\n };\n}\n\nexport interface MosaicClerkWebhookHandlerOptions {\n /** Clerk webhook signing secret (CLERK_WEBHOOK_SECRET env var) */\n webhookSecret: string;\n /** Called when an organization is created in Clerk */\n onOrganizationCreated?: (org: MosaicClerkOrganization) => Promise<void> | void;\n /** Called when a member joins an organization */\n onMembershipCreated?: (data: MosaicClerkMembership) => Promise<void> | void;\n /** Called when a member leaves or is removed from an organization */\n onMembershipDeleted?: (data: MosaicClerkMembership) => Promise<void> | void;\n}\n\n// ── Svix header constants ─────────────────────────────────────────────────────\n\nconst SVIX_HEADERS = [\"svix-id\", \"svix-timestamp\", \"svix-signature\"] as const;\n\n// ── Handler ───────────────────────────────────────────────────────────────────\n\n/**\n * MosaicClerkWebhookHandler — verifies and dispatches Clerk webhook events.\n *\n * Returns a `Response` compatible with Next.js App Router route handlers.\n * svix is an optional peer dependency and must be installed in the consuming\n * app (`npm install svix`). Throws an explicit Error if svix is not installed.\n */\nexport async function MosaicClerkWebhookHandler(\n req: Request,\n options: MosaicClerkWebhookHandlerOptions,\n): Promise<Response> {\n const { webhookSecret, onOrganizationCreated, onMembershipCreated, onMembershipDeleted } =\n options;\n\n // ── Verify signature via svix ─────────────────────────────────────────────\n // svix is an optional peer dependency. A literal dynamic import lets TypeScript\n // resolve types at build time (via devDependencies) while keeping it out of the\n // main bundle at runtime. Consumers must install svix themselves.\n let Webhook: typeof import(\"svix\").Webhook;\n try {\n ({ Webhook } = await import(\"svix\"));\n } catch {\n throw new Error(\n \"MosaicClerkWebhookHandler requires the 'svix' package for webhook signature verification. Install it: npm install svix (or pnpm add svix).\",\n );\n }\n\n const svixHeaders: Record<string, string> = {};\n for (const key of SVIX_HEADERS) {\n const val = req.headers.get(key);\n if (!val) {\n return new Response(`Missing required svix header: ${key}`, { status: 400 });\n }\n svixHeaders[key] = val;\n }\n\n const body = await req.text();\n\n let evt: { type: string; data: Record<string, unknown> };\n try {\n const wh = new Webhook(webhookSecret);\n evt = wh.verify(body, svixHeaders) as typeof evt;\n } catch {\n return new Response(\"Webhook signature verification failed\", { status: 400 });\n }\n\n // ── Route events ──────────────────────────────────────────────────────────\n try {\n switch (evt.type) {\n case \"organization.created\": {\n if (onOrganizationCreated) {\n await onOrganizationCreated(evt.data as unknown as MosaicClerkOrganization);\n }\n break;\n }\n case \"organizationMembership.created\": {\n if (onMembershipCreated) {\n await onMembershipCreated(evt.data as unknown as MosaicClerkMembership);\n }\n break;\n }\n case \"organizationMembership.deleted\": {\n if (onMembershipDeleted) {\n await onMembershipDeleted(evt.data as unknown as MosaicClerkMembership);\n }\n break;\n }\n default:\n // Unknown event type — ignore gracefully\n break;\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : \"Unknown handler error\";\n return new Response(`Handler error: ${message}`, { status: 500 });\n }\n\n return new Response(\"OK\", { status: 200 });\n}\n"
15
+ }
16
+ ],
17
+ "type": "registry:lib"
18
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-collapsible",
4
+ "title": "MosaicCollapsible",
5
+ "description": "MosaicCollapsible — @base-ui/react Collapsible primitive",
6
+ "dependencies": [
7
+ "@base-ui/react"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/collapsible/MosaicCollapsible.tsx",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicCollapsible — @base-ui/react Collapsible primitive\n *\n * Builds on Collapsible.Root + Collapsible.Trigger + Collapsible.Panel.\n * Supports controlled (open + onOpenChange) and uncontrolled modes.\n * aria-expanded and aria-controls managed by the primitive automatically.\n *\n * data-slot=\"collapsible\" on Root, \"collapsible-trigger\" on Trigger,\n * \"collapsible-panel\" on Panel.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Collapsible } from \"@base-ui/react/collapsible\";\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// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicCollapsibleProps extends Collapsible.Root.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport interface MosaicCollapsibleTriggerProps extends Collapsible.Trigger.Props {\n className?: string;\n ref?: React.Ref<HTMLButtonElement>;\n}\n\nexport interface MosaicCollapsiblePanelProps extends Collapsible.Panel.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Components ────────────────────────────────────────────────────────────────\n\n/**\n * MosaicCollapsible — production Collapsible root for @vantageos/mosaic-blocks.\n *\n * Wrap with MosaicCollapsibleTrigger and MosaicCollapsiblePanel.\n *\n * @example\n * <MosaicCollapsible>\n * <MosaicCollapsibleTrigger>Toggle</MosaicCollapsibleTrigger>\n * <MosaicCollapsiblePanel>Content here</MosaicCollapsiblePanel>\n * </MosaicCollapsible>\n */\nexport function MosaicCollapsible({ className, ref, ...props }: MosaicCollapsibleProps) {\n return (\n <Collapsible.Root\n ref={ref}\n data-slot=\"collapsible\"\n className={cn(\"w-full\", className)}\n {...props}\n />\n );\n}\n\nMosaicCollapsible.displayName = \"MosaicCollapsible\";\n\n/**\n * MosaicCollapsibleTrigger — toggle button for MosaicCollapsible.\n *\n * @example\n * <MosaicCollapsibleTrigger>Show more</MosaicCollapsibleTrigger>\n */\nexport function MosaicCollapsibleTrigger({\n className,\n ref,\n ...props\n}: MosaicCollapsibleTriggerProps) {\n return (\n <Collapsible.Trigger\n ref={ref}\n data-slot=\"collapsible-trigger\"\n className={cn(\n \"inline-flex w-full items-center justify-between gap-2\",\n \"rounded-md px-0 py-2 text-sm font-medium\",\n \"text-foreground outline-none transition-colors\",\n \"hover:text-foreground/80\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n \"[&>svg]:transition-transform [&>svg]:duration-200\",\n \"data-[panel-open]:[&>svg]:rotate-180\",\n className,\n )}\n {...props}\n />\n );\n}\n\nMosaicCollapsibleTrigger.displayName = \"MosaicCollapsibleTrigger\";\n\n/**\n * MosaicCollapsiblePanel — collapsible content panel for MosaicCollapsible.\n *\n * @example\n * <MosaicCollapsiblePanel>Hidden content</MosaicCollapsiblePanel>\n */\nexport function MosaicCollapsiblePanel({ className, ref, ...props }: MosaicCollapsiblePanelProps) {\n return (\n <Collapsible.Panel\n ref={ref}\n data-slot=\"collapsible-panel\"\n className={cn(\n \"overflow-hidden text-sm transition-all\",\n \"data-[open]:animate-in data-[closed]:animate-out\",\n className,\n )}\n {...props}\n />\n );\n}\n\nMosaicCollapsiblePanel.displayName = \"MosaicCollapsiblePanel\";\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-combobox",
4
+ "title": "MosaicCombobox",
5
+ "description": "Filterable combobox built on @base-ui/react/combobox with useFilter. Props: items[], value, onValueChange, placeholder. data-slot=\"combobox\".",
6
+ "dependencies": [
7
+ "@base-ui/react"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/combobox/MosaicCombobox.tsx",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicCombobox — @base-ui/react Combobox primitive\n *\n * Path taken: @base-ui/react/combobox (NATIVE in @base-ui/react@1.5.0 — confirmed present).\n * The `combobox` subpath exports Combobox.Root / Input / Trigger / Portal /\n * Positioner / Popup / List / Item / Empty / useFilter.\n *\n * Props: items[], value, onValueChange, placeholder.\n * Filtering: built-in useFilter from @base-ui/react/combobox with \"contains\" strategy.\n *\n * data-slot=\"combobox\" on the wrapper div.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Combobox } from \"@base-ui/react/combobox\";\nimport * as React from \"react\";\n\n// Positioner placement types, derived from the public Combobox.Positioner\n// props contract (no private subpath import — `@base-ui/react` exports no\n// `./utils` entry point).\ntype PositionerSide = NonNullable<Combobox.Positioner.Props[\"side\"]>;\ntype PositionerAlign = NonNullable<Combobox.Positioner.Props[\"align\"]>;\ntype PositionerCollisionBoundary = Combobox.Positioner.Props[\"collisionBoundary\"];\ntype PositionerCollisionPadding = Combobox.Positioner.Props[\"collisionPadding\"];\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 MosaicComboboxItem {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\nexport interface MosaicComboboxProps {\n /** List of options */\n items: MosaicComboboxItem[];\n /** Controlled selected value */\n value?: string;\n /** Callback when selected value changes. Receives null when selection is cleared. */\n onValueChange?: (value: string | null) => void;\n /** Uncontrolled default value */\n defaultValue?: string;\n /** Input placeholder */\n placeholder?: string;\n disabled?: boolean;\n name?: string;\n /**\n * Message shown when no item matches the filter. Required — the host\n * owns the language (e.g. `t('Combobox.empty')`). No default, no fallback.\n */\n emptyMessage: string;\n className?: string;\n /**\n * Which side of the input the popup opens against. Base UI may still\n * auto-flip to avoid a collision unless `collisionAvoidance` disables it.\n * @default 'bottom'\n */\n side?: PositionerSide;\n /**\n * How the popup aligns relative to the requested side.\n * @default 'center'\n */\n align?: PositionerAlign;\n /**\n * Element/rect the popup is confined to.\n * @default 'clipping-ancestors'\n */\n collisionBoundary?: PositionerCollisionBoundary;\n /**\n * Space to keep between the popup and the edge of the collision boundary.\n * @default 5\n */\n collisionPadding?: PositionerCollisionPadding;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicCombobox — production Combobox atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/combobox (native in 1.5.0).\n * Filtering via built-in useFilter with \"contains\" strategy.\n * Keyboard-accessible: ArrowDown/Up navigate, Enter selects, Escape closes.\n *\n * @example\n * <MosaicCombobox\n * items={[{ value: \"ts\", label: \"TypeScript\" }]}\n * placeholder=\"Search…\"\n * onValueChange={(v) => console.log(v)}\n * emptyMessage={t('Combobox.empty')}\n * />\n */\nexport function MosaicCombobox({\n items,\n value,\n onValueChange,\n defaultValue,\n placeholder,\n disabled,\n name,\n emptyMessage,\n className,\n side,\n align,\n collisionBoundary,\n collisionPadding,\n}: MosaicComboboxProps) {\n const [inputValue, setInputValue] = React.useState(\"\");\n\n const filter = Combobox.useFilter({ sensitivity: \"base\" });\n\n const filteredItems = React.useMemo(() => {\n if (!inputValue) return items;\n return items.filter((item) => filter.contains(item.label, inputValue));\n }, [items, inputValue, filter]);\n\n return (\n <Combobox.Root\n value={value}\n onValueChange={onValueChange}\n defaultValue={defaultValue}\n disabled={disabled}\n name={name}\n onInputValueChange={setInputValue}\n autoHighlight\n >\n <div data-slot=\"combobox\" className={cn(\"relative w-full\", className)}>\n <Combobox.Input\n placeholder={placeholder}\n className={cn(\n \"h-9 w-full rounded-md border border-border bg-background px-3 py-2\",\n \"text-sm text-foreground shadow-xs outline-none\",\n \"placeholder:text-muted-foreground\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n />\n\n <Combobox.Portal>\n <Combobox.Positioner\n sideOffset={4}\n side={side}\n align={align}\n collisionBoundary={collisionBoundary}\n collisionPadding={collisionPadding}\n >\n <Combobox.Popup\n className={cn(\n \"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border\",\n \"bg-popover p-1 text-popover-foreground shadow-md\",\n \"origin-[var(--transform-origin)]\",\n \"transition-[transform,scale,opacity]\",\n \"data-[open]:scale-100 data-[open]:opacity-100\",\n \"data-[ending-style]:scale-95 data-[ending-style]:opacity-0\",\n \"data-[starting-style]:scale-95 data-[starting-style]:opacity-0\",\n )}\n >\n <Combobox.List>\n {filteredItems.length === 0 ? (\n <Combobox.Empty className=\"py-2 text-center text-sm text-muted-foreground\">\n {emptyMessage}\n </Combobox.Empty>\n ) : (\n filteredItems.map((item) => (\n <Combobox.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n className={cn(\n \"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5\",\n \"text-sm text-popover-foreground outline-none\",\n \"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[selected]:font-medium\",\n )}\n >\n {item.label}\n </Combobox.Item>\n ))\n )}\n </Combobox.List>\n </Combobox.Popup>\n </Combobox.Positioner>\n </Combobox.Portal>\n </div>\n </Combobox.Root>\n );\n}\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-counter",
4
+ "title": "MosaicCounter",
5
+ "description": "Animated metric count-up. Counts from 0 to value on mount using requestAnimationFrame (no motion dep). Props: value, duration?, format?. Respects prefers-reduced-motion.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/counter/MosaicCounter.tsx",
11
+ "type": "registry:ui",
12
+ "content": "\"use client\";\n\n/**\n * MosaicCounter — animated metric count-up\n *\n * Ported from heyfabrika/styleui components/counter (MIT).\n * Animation decision: requestAnimationFrame with easeOutExpo — no `motion` dependency.\n * styleui uses CSS + JS approach; we match with rAF for bundle budget savings (~0 kb added).\n * Bundle impact: 0 extra deps (pure rAF).\n */\n\nimport * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicCounterProps {\n /** Target numeric value to count to */\n value: number;\n /** Animation duration in ms (default 1500) */\n duration?: number;\n /** Optional format function applied to the current number */\n format?: (value: number) => string;\n className?: string;\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n// ── Easing ────────────────────────────────────────────────────────────────────\n\nfunction easeOutExpo(t: number): number {\n return t === 1 ? 1 : 1 - 2 ** (-10 * t);\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicCounter — counts up from 0 to `value` on mount using requestAnimationFrame.\n * No external animation library required. Respects prefers-reduced-motion.\n *\n * @example\n * <MosaicCounter value={10000} duration={2000} format={(v) => `${Math.round(v).toLocaleString()}+`} />\n */\nexport function MosaicCounter({\n value,\n duration = 1500,\n format,\n className,\n ref,\n}: MosaicCounterProps) {\n const [current, setCurrent] = React.useState(0);\n const rafRef = React.useRef<number>(0);\n const startTimeRef = React.useRef<number | null>(null);\n\n React.useEffect(() => {\n // Respect prefers-reduced-motion (guard: jsdom may not implement matchMedia)\n const prefersReduced =\n typeof window !== \"undefined\" &&\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n\n if (prefersReduced) {\n setCurrent(value);\n return;\n }\n\n startTimeRef.current = null;\n\n const animate = (timestamp: number) => {\n if (startTimeRef.current === null) {\n startTimeRef.current = timestamp;\n }\n const elapsed = timestamp - startTimeRef.current;\n const progress = Math.min(elapsed / duration, 1);\n const eased = easeOutExpo(progress);\n setCurrent(Math.round(eased * value));\n\n if (progress < 1) {\n rafRef.current = requestAnimationFrame(animate);\n } else {\n setCurrent(value);\n }\n };\n\n rafRef.current = requestAnimationFrame(animate);\n\n return () => {\n if (rafRef.current) cancelAnimationFrame(rafRef.current);\n };\n }, [value, duration]);\n\n const display = format ? format(current) : String(current);\n\n return (\n <span\n ref={ref}\n className={className}\n style={{ fontVariantNumeric: \"tabular-nums\" }}\n aria-label={format ? format(value) : String(value)}\n aria-live=\"polite\"\n >\n {display}\n </span>\n );\n}\n\nMosaicCounter.displayName = \"MosaicCounter\";\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-dashboard-content",
4
+ "title": "MosaicDashboardContent",
5
+ "description": "Generic dashboard content area with view switcher. Tab-based view rendering. CSS fade-in transition.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/dashboard-content/MosaicDashboardContent.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicDashboardContent — generic dashboard content area with view switcher\n *\n * Ported from components/dashboard/DashboardContent.tsx\n *\n * Features:\n * - Tab-based view switcher (currentView → renders matching content slot)\n * - Responsive padding (mobile vs desktop)\n * - Slot-based content: consumers pass views[] with id + content\n *\n * framer-motion replaced with CSS keyframe fade-in.\n * All debate-specific sub-components (SessionList, AgentLibrary) stripped.\n * Content is purely prop-driven via views[].\n */\n\nimport * as React from \"react\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst ANIM_ID = \"mosaic-dashboard-content-kf\";\n\nfunction injectStyles() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(ANIM_ID)) return;\n const s = document.createElement(\"style\");\n s.id = ANIM_ID;\n s.textContent = `\n @keyframes mosaic-content-in {\n from { opacity: 0; transform: translateY(12px); }\n to { opacity: 1; transform: translateY(0); }\n }\n .mosaic-content-view {\n animation: mosaic-content-in 220ms ease-out forwards;\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-content-view { animation: none !important; }\n }\n `;\n document.head.appendChild(s);\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicDashboardView {\n id: string;\n label?: string;\n content: React.ReactNode;\n}\n\nexport interface MosaicDashboardContentProps {\n /** Available views */\n views: MosaicDashboardView[];\n /** Currently active view id */\n currentView: string;\n /**\n * Label shown when `currentView` matches no entry in `views`. Rendered to\n * the end user — required host-owned string, no default. The component\n * appends `currentView` after it (a data value, not library-owned prose).\n */\n viewNotFoundLabel: string;\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicDashboardContent({\n views,\n currentView,\n viewNotFoundLabel,\n className,\n}: MosaicDashboardContentProps) {\n const { isMobile } = useDevice();\n\n React.useEffect(() => {\n injectStyles();\n }, []);\n\n const activeView = views.find((v) => v.id === currentView);\n\n return (\n <div\n data-slot=\"dashboard-content\"\n className={cn(\"h-full overflow-auto\", isMobile ? \"p-4\" : \"p-6\", className)}\n >\n {activeView ? (\n <div key={currentView} className=\"mosaic-content-view space-y-6\">\n {activeView.content}\n </div>\n ) : (\n <p className=\"py-12 text-center text-sm text-muted-foreground\">\n {viewNotFoundLabel}\n {currentView}\n </p>\n )}\n </div>\n );\n}\n\nMosaicDashboardContent.displayName = \"MosaicDashboardContent\";\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-dashboard-header",
4
+ "title": "MosaicDashboardHeader",
5
+ "description": "Generic sticky dashboard header. Title/subtitle, search bar (desktop), notification bell, right-side actions slot.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/dashboard-header/MosaicDashboardHeader.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicDashboardHeader — generic sticky dashboard header\n *\n * Ported from components/dashboard/DashboardHeader.tsx\n *\n * Features:\n * - Sticky backdrop-blur header\n * - Title + subtitle\n * - Desktop: inline search bar\n * - Mobile: compact search icon button\n * - Notification bell with count badge\n * - Right-side actions slot (theme toggle, avatar, etc.)\n *\n * framer-motion (header entrance + spinning sparkle) replaced with CSS.\n * next/link removed — links are callbacks.\n * All debate-specific actions stripped.\n */\n\nimport * as React from \"react\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst ANIM_ID = \"mosaic-dashboard-header2-kf\";\n\nfunction injectStyles() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(ANIM_ID)) return;\n const s = document.createElement(\"style\");\n s.id = ANIM_ID;\n s.textContent = `\n @keyframes mosaic-header2-in {\n from { opacity: 0; transform: translateY(-12px); }\n to { opacity: 1; transform: translateY(0); }\n }\n .mosaic-dashboard-header2 {\n animation: mosaic-header2-in 200ms ease-out forwards;\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-dashboard-header2 { animation: none !important; }\n }\n `;\n document.head.appendChild(s);\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicDashboardHeaderProps {\n title?: string;\n subtitle?: string;\n /** Notification count (0 = no badge) */\n notificationCount?: number;\n onNotificationsClick?: () => void;\n /**\n * Formatter for the notifications button aria-label, read only when\n * `onNotificationsClick` is set. Optional — when absent, the button\n * renders with no `aria-label` (no fallback word). The host owns the\n * language (e.g. `(count) => t('DashboardHeader.notifications', { count })`).\n */\n notificationsAriaLabel?: (count: number) => string;\n onSearchChange?: (query: string) => void;\n /** Right-side slot (theme toggle, avatar, quick actions, etc.) */\n actions?: React.ReactNode;\n /** Logo/brand slot (left of title) */\n logoSlot?: React.ReactNode;\n /**\n * Placeholder for the desktop search input. Required — the host owns\n * the language (e.g. `t('DashboardHeader.searchPlaceholder')`). No default.\n */\n searchPlaceholder: string;\n /**\n * aria-label for the mobile search icon button. Required — host-owned,\n * no default.\n */\n searchAriaLabel: string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction BellIcon() {\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 <path d=\"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9\" />\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n </svg>\n );\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\nfunction SparklesIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"18\"\n height=\"18\"\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 className=\"text-primary\"\n >\n <path d=\"M12 3l1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5z\" />\n <path d=\"M5 20l.5-1.5L7 18l-1.5-.5L5 16l-.5 1.5L3 18l1.5.5z\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicDashboardHeader({\n title,\n subtitle,\n notificationCount = 0,\n onNotificationsClick,\n notificationsAriaLabel,\n onSearchChange,\n actions,\n logoSlot,\n searchPlaceholder,\n searchAriaLabel,\n className,\n}: MosaicDashboardHeaderProps) {\n const { isMobile } = useDevice();\n const [searchQuery, setSearchQuery] = React.useState(\"\");\n\n React.useEffect(() => {\n injectStyles();\n }, []);\n\n const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {\n setSearchQuery(e.target.value);\n onSearchChange?.(e.target.value);\n };\n\n return (\n <header\n data-slot=\"dashboard-header\"\n className={cn(\n \"mosaic-dashboard-header2\",\n \"sticky top-0 z-40 border-b border-border/50 bg-background/80 backdrop-blur-sm\",\n className,\n )}\n >\n <div className={cn(isMobile ? \"px-4 py-3\" : \"container mx-auto px-4 py-4\")}>\n <div className=\"flex items-center justify-between gap-4\">\n {/* Left: logo + title */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2 md:gap-4\">\n <div className=\"flex items-center gap-2\">\n {logoSlot ?? <SparklesIcon />}\n <div className=\"min-w-0\">\n <h1 className={cn(\"font-semibold truncate\", isMobile ? \"text-lg\" : \"text-xl\")}>\n {title}\n </h1>\n {subtitle && !isMobile && (\n <p className=\"text-sm text-muted-foreground truncate\">{subtitle}</p>\n )}\n </div>\n </div>\n </div>\n\n {/* Center: search (desktop only) */}\n {!isMobile && onSearchChange && (\n <div className=\"mx-8 max-w-md flex-1\">\n <div className=\"relative\">\n <span className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\n <SearchIcon />\n </span>\n <input\n type=\"search\"\n value={searchQuery}\n onChange={handleSearch}\n placeholder={searchPlaceholder}\n className={cn(\n \"w-full rounded-md border border-input bg-background py-2 pl-9 pr-3\",\n \"text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n </div>\n )}\n\n {/* Right: actions */}\n <div className=\"flex shrink-0 items-center gap-2 md:gap-3\">\n {/* Mobile search button */}\n {isMobile && onSearchChange && (\n <button\n type=\"button\"\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n aria-label={searchAriaLabel}\n onClick={() => {\n // Consumers can intercept via onSearchChange\n }}\n >\n <SearchIcon />\n </button>\n )}\n\n {/* Notifications */}\n {onNotificationsClick && (\n <button\n type=\"button\"\n onClick={onNotificationsClick}\n className=\"relative inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n aria-label={notificationsAriaLabel?.(notificationCount)}\n >\n <BellIcon />\n {notificationCount > 0 && (\n <span className=\"absolute -right-1 -top-1 flex h-4 w-4 items-center justify-center rounded-full bg-primary text-[10px] font-bold text-primary-foreground\">\n {notificationCount > 9 ? \"9+\" : notificationCount}\n </span>\n )}\n </button>\n )}\n\n {actions}\n </div>\n </div>\n </div>\n </header>\n );\n}\n\nMosaicDashboardHeader.displayName = \"MosaicDashboardHeader\";\n"
15
+ }
16
+ ],
17
+ "type": "registry:ui"
18
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-dashboard-layout",
4
+ "title": "MosaicDashboardLayout",
5
+ "description": "Full-height app shell: sticky header (title, subtitle, breadcrumbs, actions slot), persistent sidebar on desktop, hamburger + AdaptiveModal drawer on mobile. Props: title, subtitle, breadcrumbs[], actions, sidebarProps, renderLink. Zero hardcoded branding.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-adaptive-modal.json",
9
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-app-sidebar.json",
10
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
11
+ ],
12
+ "files": [
13
+ {
14
+ "path": "src/components/dashboard-layout/MosaicDashboardLayout.tsx",
15
+ "type": "registry:ui",
16
+ "content": "\"use client\";\n\n/**\n * MosaicDashboardLayout — full app shell (PC-05)\n *\n * Ported (source: private upstream) components/dashboard/DashboardLayout.tsx\n *\n * Features:\n * - Sticky header with title, subtitle, optional breadcrumbs, actions slot\n * - Desktop: persistent sidebar (MosaicAppSidebar)\n * - Mobile: hamburger button → AdaptiveModal drawer containing sidebar\n * - headerActions slot: replaces debate-specific OrgSwitcher/TokenBalance/QuickActionsMenu\n * - Fully props-driven, zero hardcoded branding\n *\n * Framer-motion (header animation) replaced with CSS keyframe.\n * Breadcrumb: rendered with semantic <nav>/<ol> (no Radix dep).\n * next/link removed — breadcrumbs use <a> by default; renderLink prop for router consumers.\n * ScrollArea Radix removed — native overflow-auto.\n * Respects prefers-reduced-motion.\n */\n\nimport * as React from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\nimport { MosaicAppSidebar } from \"@/components/ui/MosaicAppSidebar\";\nimport type { MosaicAppSidebarProps } from \"@/components/ui/MosaicAppSidebar\";\n\n/** Omit that distributes over a discriminated union instead of collapsing it. */\ntype DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst ANIM_ID = \"mosaic-dashboard-kf\";\n\nfunction injectStyles() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(ANIM_ID)) return;\n const s = document.createElement(\"style\");\n s.id = ANIM_ID;\n s.textContent = `\n @keyframes mosaic-header-in {\n from { opacity: 0; transform: translateY(-12px); }\n to { opacity: 1; transform: translateY(0); }\n }\n .mosaic-dashboard-header {\n animation: mosaic-header-in 200ms ease-out forwards;\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-dashboard-header {\n animation: none !important;\n opacity: 1 !important;\n transform: none !important;\n }\n }\n `;\n document.head.appendChild(s);\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicBreadcrumb {\n label: string;\n href?: string;\n}\n\nexport interface MosaicDashboardLayoutProps {\n children: React.ReactNode;\n title?: string;\n subtitle?: string;\n breadcrumbs?: MosaicBreadcrumb[];\n /** Slot for header-right actions (theme toggle, avatar, etc.) */\n actions?: React.ReactNode;\n /**\n * Props forwarded to MosaicAppSidebar (navItems, quickActions, etc.).\n * Required — MosaicAppSidebar itself requires host-owned aria-label /\n * heading strings with no default.\n *\n * Uses a distributive Omit so the bottomNavItems/bottomNavAriaLabel\n * discriminated union on MosaicAppSidebarProps survives the Omit — a plain\n * `Omit<Union, K>` collapses the union and loses the discriminant.\n */\n sidebarProps: DistributiveOmit<MosaicAppSidebarProps, \"isCollapsed\" | \"onToggleCollapse\">;\n /** Whether sidebar starts collapsed (default false) */\n defaultSidebarCollapsed?: boolean;\n /** Mobile sidebar modal title. Required, no default. */\n mobileSidebarTitle: string;\n /**\n * Custom link renderer for breadcrumbs (e.g. Next.js Link).\n * Default: native <a>.\n */\n renderLink?: (href: string, children: React.ReactNode) => React.ReactNode;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n headerAriaLabel: string;\n openNavigationAriaLabel: string;\n breadcrumbAriaLabel: string;\n mobileSidebarCloseAriaLabel: string;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction MenuIcon() {\n return (\n <svg\n width=\"18\"\n height=\"18\"\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 <line x1=\"4\" y1=\"8\" x2=\"20\" y2=\"8\" />\n <line x1=\"4\" y1=\"16\" x2=\"20\" y2=\"16\" />\n </svg>\n );\n}\n\nfunction ChevronRightIcon() {\n return (\n <svg\n width=\"12\"\n height=\"12\"\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 <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicDashboardLayout — full-height app shell with persistent sidebar (desktop)\n * and drawer sidebar (mobile). All content via props/children.\n *\n * @example\n * <MosaicDeviceProvider>\n * <MosaicDashboardLayout\n * title=\"Dashboard\"\n * subtitle=\"Overview\"\n * breadcrumbs={[{ label: \"Home\", href: \"/\" }, { label: \"Dashboard\" }]}\n * actions={<ThemeToggle />}\n * sidebarProps={{\n * navItems: [...],\n * logoSlot: <img src=\"/logo.svg\" alt=\"Brand\" />,\n * }}\n * >\n * <DashboardContent />\n * </MosaicDashboardLayout>\n * </MosaicDeviceProvider>\n */\nexport function MosaicDashboardLayout({\n children,\n title,\n subtitle,\n breadcrumbs,\n actions,\n sidebarProps,\n defaultSidebarCollapsed = false,\n mobileSidebarTitle,\n renderLink,\n headerAriaLabel,\n openNavigationAriaLabel,\n breadcrumbAriaLabel,\n mobileSidebarCloseAriaLabel,\n className,\n ref,\n}: MosaicDashboardLayoutProps) {\n const { isMobile } = useDevice();\n const [isSidebarCollapsed, setIsSidebarCollapsed] = React.useState(defaultSidebarCollapsed);\n const [isMobileSidebarOpen, setIsMobileSidebarOpen] = React.useState(false);\n\n React.useEffect(() => {\n injectStyles();\n }, []);\n\n const defaultRenderLink = (href: string, children: React.ReactNode) => (\n <a href={href} className=\"transition-colors hover:text-foreground\">\n {children}\n </a>\n );\n\n const link = renderLink ?? defaultRenderLink;\n\n return (\n <div\n ref={ref}\n data-slot=\"dashboard-layout\"\n className={cn(\"flex h-screen w-full bg-background\", className)}\n >\n {/* Desktop sidebar */}\n {!isMobile && (\n <MosaicAppSidebar\n isCollapsed={isSidebarCollapsed}\n onToggleCollapse={() => setIsSidebarCollapsed((c) => !c)}\n {...sidebarProps}\n />\n )}\n\n {/* Main content */}\n <div className=\"flex min-h-0 min-w-0 flex-1 flex-col\">\n {/* Header */}\n <header\n className=\"mosaic-dashboard-header sticky top-0 z-40 shrink-0 border-b border-border/50 bg-background/80 backdrop-blur-sm\"\n aria-label={headerAriaLabel}\n >\n <div className=\"flex items-center justify-between gap-4 p-3 md:p-4\">\n {/* Left: mobile hamburger + title + breadcrumbs */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2 md:gap-4\">\n {isMobile && (\n <button\n type=\"button\"\n aria-label={openNavigationAriaLabel}\n onClick={() => setIsMobileSidebarOpen(true)}\n className={cn(\n \"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg\",\n \"text-foreground transition-colors hover:bg-muted\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <MenuIcon />\n </button>\n )}\n\n <div className=\"min-w-0 flex-1\">\n <h1 className=\"truncate text-base font-semibold md:text-lg\">{title}</h1>\n {subtitle && (\n <p className=\"hidden truncate text-xs text-muted-foreground md:block md:text-sm\">\n {subtitle}\n </p>\n )}\n\n {/* Breadcrumbs */}\n {breadcrumbs && breadcrumbs.length > 0 && (\n <nav aria-label={breadcrumbAriaLabel} className=\"mt-0.5 hidden md:block\">\n <ol className=\"flex items-center gap-1.5 text-xs text-muted-foreground\">\n {breadcrumbs.map((crumb, idx) => {\n const isLast = idx === breadcrumbs.length - 1;\n return (\n <li key={`${crumb.label}-${idx}`} className=\"flex items-center gap-1.5\">\n {isLast ? (\n <span aria-current=\"page\" className=\"font-medium text-foreground\">\n {crumb.label}\n </span>\n ) : (\n <>\n {crumb.href ? (\n link(crumb.href, crumb.label)\n ) : (\n <span>{crumb.label}</span>\n )}\n <ChevronRightIcon />\n </>\n )}\n </li>\n );\n })}\n </ol>\n </nav>\n )}\n </div>\n </div>\n\n {/* Right: actions slot */}\n {actions && <div className=\"flex shrink-0 items-center gap-2\">{actions}</div>}\n </div>\n </header>\n\n {/* Page content */}\n <div className=\"min-h-0 flex-1 overflow-auto\">\n <div className=\"container mx-auto p-4 md:p-6 lg:p-8\">{children}</div>\n </div>\n </div>\n\n {/* Mobile sidebar modal */}\n {isMobile && (\n <MosaicAdaptiveModal\n isOpen={isMobileSidebarOpen}\n onClose={() => setIsMobileSidebarOpen(false)}\n title={mobileSidebarTitle}\n closeAriaLabel={mobileSidebarCloseAriaLabel}\n >\n <MosaicAppSidebar\n isCollapsed={false}\n onToggleCollapse={() => {}}\n onNavigate={(href) => {\n setIsMobileSidebarOpen(false);\n sidebarProps?.onNavigate?.(href);\n }}\n {...sidebarProps}\n />\n </MosaicAdaptiveModal>\n )}\n </div>\n );\n}\n\nMosaicDashboardLayout.displayName = \"MosaicDashboardLayout\";\n"
17
+ }
18
+ ],
19
+ "type": "registry:ui"
20
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-data-table",
4
+ "title": "MosaicDataTable",
5
+ "description": "MosaicDataTable — generic sortable data table",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/data-table/MosaicDataTable.tsx",
11
+ "type": "registry:ui",
12
+ "content": "/**\n * MosaicDataTable — generic sortable data table\n *\n * Presentational atom. Fully generic over row type T.\n * Supports client-side sort (asc/desc) by any sortable column.\n * No icon library dependency — sort indicator via inline text chars.\n * Design tokens: border-border, bg-muted, hover:bg-muted/50, text-muted-foreground.\n * Pattern: Button.tsx (data-slot, inline cn, React 19 ref prop, displayName, JSDoc).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n *\n * Closes issue #23 — mosaic-data-table.\n *\n * @example\n * // Basic usage\n * const columns: MosaicDataTableColumn<User>[] = [\n * { key: \"name\", header: \"Name\", sortable: true },\n * { key: \"email\", header: \"Email\" },\n * ];\n * <MosaicDataTable columns={columns} rows={users} getRowKey={(r) => r.id} />\n *\n * @example\n * // With custom render + bilingual empty state\n * <MosaicDataTable\n * columns={columns}\n * rows={[]}\n * emptyState={<MosaicEmptyState title=\"Aucune donnée\" />}\n * />\n */\n\nimport { useState } from \"react\";\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// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicDataTableColumn<T> {\n /** Unique key — used to access row[key] for default rendering and sorting. */\n key: string;\n /** Column header label (ReactNode for i18n / icons). */\n header: React.ReactNode;\n /**\n * Custom cell renderer. Receives the full row object.\n * When absent, falls back to `String(row[key])`.\n * Note: sort operates on the raw `row[key]` value, not the rendered output.\n */\n render?: (row: T) => React.ReactNode;\n /** Make this column sortable (clicking header cycles asc → desc). */\n sortable?: boolean;\n /** Horizontal alignment of header + cells. */\n align?: \"left\" | \"right\" | \"center\";\n /** Additional Tailwind classes forwarded to every `<th>` and `<td>` in this column. */\n className?: string;\n}\n\nexport interface MosaicDataTableProps<T> {\n /** Column definitions. */\n columns: MosaicDataTableColumn<T>[];\n /** Array of row data objects. */\n rows: T[];\n /**\n * Stable key extractor for React reconciliation.\n * Prefer providing this — default falls back to `index` which can cause flicker.\n */\n getRowKey?: (row: T, index: number) => string | number;\n /**\n * Master sortable toggle. When `false`, overrides per-column `sortable`.\n * When `true` (default), per-column `sortable` decides per-column behaviour.\n * @default true\n */\n sortable?: boolean;\n /**\n * Content rendered when `rows` is empty.\n * Pass a `<MosaicEmptyState />` with a translated title for FR/EN support.\n * When absent, `emptyMessage` is shown as plain muted text.\n */\n emptyState?: React.ReactNode;\n /**\n * Plain-text empty-state message shown when `rows` is empty and\n * `emptyState` is not provided. Required — the host owns the language\n * (e.g. `t('DataTable.empty')`). No default, no fallback.\n */\n emptyMessage: string;\n /** Additional Tailwind classes for the root `<table>` element. */\n className?: string;\n /** React 19 ref prop — no forwardRef wrapper needed. */\n ref?: React.Ref<HTMLTableElement>;\n /**\n * Trailing content rendered inside a `<tfoot>` row, after the last data\n * row. Mount your own IntersectionObserver sentinel here to keep your\n * existing infinite-scroll pattern (e.g. Convex `usePaginatedQuery`) —\n * `MosaicDataTable` does not impose a button-driven pager.\n *\n * @example\n * <MosaicDataTable\n * columns={columns}\n * rows={results}\n * emptyMessage=\"Aucune donnée\"\n * footerSlot={<div ref={sentinelRef} />}\n * />\n */\n footerSlot?: React.ReactNode;\n /**\n * Simple load-more affordance for consumers without their own sentinel.\n * Optional as a feature — a table with no `pagination` renders exactly\n * as before. When provided, `loadMoreLabel` and `loadingLabel` are\n * REQUIRED (no default, no fallback) — the host owns the language.\n */\n pagination?: MosaicDataTablePagination;\n}\n\n/**\n * Load-more pagination config. Required as a whole (no partial shape) —\n * when a consumer opts into the simple pagination affordance, both labels\n * must be supplied. There is no English default anywhere in this type.\n */\nexport interface MosaicDataTablePagination {\n /** Whether more rows are available to fetch. */\n hasMore: boolean;\n /** Invoked when the load-more affordance is activated. */\n onLoadMore: () => void;\n /**\n * Label for the load-more button. Required — the host owns the\n * language (e.g. `t('DataTable.loadMore')`).\n */\n loadMoreLabel: string;\n /**\n * Announcement shown (and read by assistive tech via `aria-live`)\n * while more rows are being fetched. Required — the host owns the\n * language.\n */\n loadingLabel: string;\n /** True while a load-more fetch is in flight. @default false */\n isLoadingMore?: boolean;\n}\n\n// ── Sort state ────────────────────────────────────────────────────────────────\n\ntype SortDirection = \"asc\" | \"desc\";\n\ninterface SortState {\n key: string;\n direction: SortDirection;\n}\n\n// ── Default comparator ────────────────────────────────────────────────────────\n\nfunction defaultCompare(a: unknown, b: unknown): number {\n if (typeof a === \"number\" && typeof b === \"number\") return a - b;\n return String(a ?? \"\").localeCompare(String(b ?? \"\"), undefined, { numeric: true });\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicDataTable — generic sortable data table for @vantageos/mosaic-blocks.\n *\n * Renders a semantic `<table>` with typed columns and rows. Optional client-side\n * sort per column. Empty state slot. Fully accessible: `scope=\"col\"`,\n * `aria-sort` on sorted column.\n *\n * @example\n * <MosaicDataTable<Agent>\n * columns={[\n * { key: \"name\", header: \"Agent\", sortable: true },\n * { key: \"status\", header: \"Status\" },\n * ]}\n * rows={agents}\n * getRowKey={(r) => r.id}\n * emptyState={<MosaicEmptyState title=\"No agents\" />}\n * />\n */\nexport function MosaicDataTable<T>({\n columns,\n rows,\n getRowKey,\n sortable: masterSortable = true,\n emptyState,\n emptyMessage,\n className,\n ref,\n footerSlot,\n pagination,\n}: MosaicDataTableProps<T>) {\n const [sort, setSort] = useState<SortState | null>(null);\n\n // ── Sort toggle ────────────────────────────────────────────────────────────\n\n function handleHeaderClick(col: MosaicDataTableColumn<T>) {\n if (!masterSortable || !col.sortable) return;\n setSort((prev) => {\n if (prev?.key === col.key) {\n return { key: col.key, direction: prev.direction === \"asc\" ? \"desc\" : \"asc\" };\n }\n return { key: col.key, direction: \"asc\" };\n });\n }\n\n // ── Sorted rows ────────────────────────────────────────────────────────────\n\n const sortedRows = sort\n ? [...rows].sort((a, b) => {\n const aVal = (a as Record<string, unknown>)[sort.key];\n const bVal = (b as Record<string, unknown>)[sort.key];\n const cmp = defaultCompare(aVal, bVal);\n return sort.direction === \"asc\" ? cmp : -cmp;\n })\n : rows;\n\n // ── Alignment helper ───────────────────────────────────────────────────────\n\n function alignClass(align?: \"left\" | \"right\" | \"center\") {\n if (align === \"right\") return \"text-right\";\n if (align === \"center\") return \"text-center\";\n return \"text-left\";\n }\n\n // ── aria-sort helper ───────────────────────────────────────────────────────\n\n function ariaSort(col: MosaicDataTableColumn<T>): React.AriaAttributes[\"aria-sort\"] {\n if (!sort || sort.key !== col.key) return \"none\";\n return sort.direction === \"asc\" ? \"ascending\" : \"descending\";\n }\n\n // ── Sort indicator ─────────────────────────────────────────────────────────\n\n function sortIndicator(col: MosaicDataTableColumn<T>): React.ReactNode {\n if (!masterSortable || !col.sortable) return null;\n if (!sort || sort.key !== col.key) {\n return (\n <span\n aria-hidden=\"true\"\n className=\"ml-1 inline-block select-none text-xs text-muted-foreground opacity-40\"\n >\n ↕\n </span>\n );\n }\n return (\n <span aria-hidden=\"true\" className=\"ml-1 inline-block select-none text-xs\">\n {sort.direction === \"asc\" ? \"▲\" : \"▼\"}\n </span>\n );\n }\n\n // ── Render ─────────────────────────────────────────────────────────────────\n\n return (\n <table\n ref={ref}\n data-slot=\"data-table\"\n className={cn(\"w-full border-collapse text-sm\", className)}\n >\n <thead data-slot=\"data-table-header\">\n <tr data-slot=\"data-table-header-row\" className=\"border-b border-border bg-muted\">\n {columns.map((col, colIndex) => {\n const isSortable = masterSortable && col.sortable;\n return (\n <th\n key={colIndex}\n data-slot=\"data-table-th\"\n scope=\"col\"\n aria-sort={ariaSort(col)}\n tabIndex={isSortable ? 0 : undefined}\n onClick={isSortable ? () => handleHeaderClick(col) : undefined}\n onKeyDown={\n isSortable\n ? (e) => {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n handleHeaderClick(col);\n }\n }\n : undefined\n }\n className={cn(\n \"px-4 py-3 font-medium text-muted-foreground\",\n alignClass(col.align),\n col.className,\n isSortable &&\n \"cursor-pointer select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {col.header}\n {sortIndicator(col)}\n </th>\n );\n })}\n </tr>\n </thead>\n\n <tbody data-slot=\"data-table-body\">\n {sortedRows.length === 0 ? (\n <tr data-slot=\"data-table-empty-row\">\n <td\n data-slot=\"data-table-empty-cell\"\n colSpan={columns.length}\n className=\"px-4 py-12 text-center text-muted-foreground\"\n >\n {emptyState ?? emptyMessage}\n </td>\n </tr>\n ) : (\n sortedRows.map((row, index) => {\n const key = getRowKey ? getRowKey(row, index) : index;\n return (\n <tr\n key={key}\n data-slot=\"data-table-row\"\n className=\"border-b border-border hover:bg-muted/50 transition-colors\"\n >\n {columns.map((col, colIndex) => {\n const rawVal = (row as Record<string, unknown>)[col.key];\n const cell = col.render ? col.render(row) : String(rawVal ?? \"\");\n return (\n <td\n key={colIndex}\n data-slot=\"data-table-td\"\n className={cn(\n \"px-4 py-3 text-foreground\",\n alignClass(col.align),\n col.className,\n )}\n >\n {cell}\n </td>\n );\n })}\n </tr>\n );\n })\n )}\n </tbody>\n\n {(footerSlot || pagination) && (\n <tfoot data-slot=\"data-table-footer\">\n <tr data-slot=\"data-table-footer-row\">\n <td\n data-slot=\"data-table-footer-cell\"\n colSpan={columns.length}\n className=\"px-4 py-3 text-center\"\n >\n {footerSlot}\n {pagination && (\n <div\n data-slot=\"data-table-pagination\"\n aria-live=\"polite\"\n className=\"flex items-center justify-center\"\n >\n {pagination.isLoadingMore ? (\n <span className=\"text-sm text-muted-foreground\">{pagination.loadingLabel}</span>\n ) : (\n pagination.hasMore && (\n <button\n type=\"button\"\n data-slot=\"data-table-load-more\"\n onClick={pagination.onLoadMore}\n className=\"rounded-md border border-border px-4 py-2 text-sm font-medium text-foreground hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {pagination.loadMoreLabel}\n </button>\n )\n )}\n </div>\n )}\n </td>\n </tr>\n </tfoot>\n )}\n </table>\n );\n}\n\nMosaicDataTable.displayName = \"MosaicDataTable\";\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-delete-confirmation-dialog",
4
+ "title": "MosaicDeleteConfirmationDialog",
5
+ "description": "Generic destructive-action confirm dialog. Built on @base-ui/react AlertDialog. Labels and item info are props.",
6
+ "dependencies": [
7
+ "@base-ui/react"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/delete-confirmation-dialog/MosaicDeleteConfirmationDialog.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicDeleteConfirmationDialog — generic destructive-action confirm dialog\n *\n * Ported from components/shared/delete-confirmation-dialog.tsx\n *\n * Built on @base-ui/react AlertDialog primitives (namespace import).\n * Zero branding, zero debate coupling. Labels and item info are props.\n */\n\nimport { AlertDialog } from \"@base-ui/react/alert-dialog\";\nimport * 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// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicDeleteConfirmationDialogProps {\n /** Whether the dialog is open */\n open: boolean;\n /** Called when the open state should change */\n onOpenChange: (open: boolean) => void;\n /** Called when the user confirms deletion */\n onConfirm: () => void;\n // NOTE: `itemName` and `itemType` used to live here, documented as \"shown in\n // the title and button\". The i18n refactor moved that copy into the\n // host-supplied `title` / `description` / `confirmLabel` (the host bakes the\n // item's name and type into those strings itself), leaving both props read\n // NOWHERE in this component. Required-but-never-rendered = a lying prop\n // contract; they are removed rather than left forcing every host to supply a\n // value the dialog never displays. Found by the no-lying-prop-contract guard.\n /** Dialog title. Required — the host owns the language, no default. */\n title: string;\n /** Dialog description. Required — the host owns the language, no default. */\n description: string;\n /** Cancel button label. Required, no default. */\n cancelLabel: string;\n /** Confirm button label. Required, no default. */\n confirmLabel: string;\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst ANIM_ID = \"mosaic-delete-dialog-kf\";\n\nfunction injectStyles() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(ANIM_ID)) return;\n const s = document.createElement(\"style\");\n s.id = ANIM_ID;\n s.textContent = `\n @keyframes mosaic-dialog-overlay-in {\n from { opacity: 0; }\n to { opacity: 1; }\n }\n @keyframes mosaic-dialog-in {\n from { opacity: 0; transform: translate(-50%, calc(-50% - 8px)) scale(0.97); }\n to { opacity: 1; transform: translate(-50%, -50%) scale(1); }\n }\n .mosaic-delete-overlay {\n animation: mosaic-dialog-overlay-in 150ms ease-out forwards;\n }\n .mosaic-delete-content {\n animation: mosaic-dialog-in 180ms ease-out forwards;\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-delete-overlay,\n .mosaic-delete-content {\n animation: none !important;\n }\n }\n `;\n document.head.appendChild(s);\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicDeleteConfirmationDialog({\n open,\n onOpenChange,\n onConfirm,\n title,\n description,\n cancelLabel,\n confirmLabel,\n}: MosaicDeleteConfirmationDialogProps) {\n React.useEffect(() => {\n injectStyles();\n }, []);\n\n return (\n <AlertDialog.Root open={open} onOpenChange={onOpenChange}>\n <AlertDialog.Portal>\n <AlertDialog.Backdrop\n className={cn(\"mosaic-delete-overlay\", \"fixed inset-0 z-50 bg-black/50\")}\n />\n <AlertDialog.Popup\n data-slot=\"delete-confirmation-dialog\"\n className={cn(\n \"mosaic-delete-content\",\n \"fixed left-1/2 top-1/2 z-50\",\n \"w-full max-w-[92vw] sm:max-w-md\",\n \"rounded-lg border border-border bg-background p-6 shadow-xl\",\n )}\n >\n <AlertDialog.Title className=\"text-lg font-semibold text-foreground\">\n {title}\n </AlertDialog.Title>\n <AlertDialog.Description className=\"mt-2 text-sm text-muted-foreground\">\n {description}\n </AlertDialog.Description>\n <div className=\"mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n <AlertDialog.Close\n className={cn(\n \"inline-flex min-h-[44px] w-full items-center justify-center rounded-md border border-border\",\n \"bg-background px-4 py-2 text-sm font-medium text-foreground\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"sm:w-auto\",\n )}\n >\n {cancelLabel}\n </AlertDialog.Close>\n <AlertDialog.Close\n onClick={onConfirm}\n className={cn(\n \"inline-flex min-h-[44px] w-full items-center justify-center rounded-md\",\n \"bg-destructive px-4 py-2 text-sm font-medium text-destructive-foreground\",\n \"hover:bg-destructive/90\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"sm:w-auto\",\n )}\n >\n {confirmLabel}\n </AlertDialog.Close>\n </div>\n </AlertDialog.Popup>\n </AlertDialog.Portal>\n </AlertDialog.Root>\n );\n}\n\nMosaicDeleteConfirmationDialog.displayName = \"MosaicDeleteConfirmationDialog\";\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-device-provider",
4
+ "title": "MosaicDeviceProvider",
5
+ "description": "Responsive device context provider. Exposes isMobile/isTablet/isDesktop, sm/md/lg/xl breakpoint flags, orientation, viewport size. Hooks: useDevice, useBreakpoint, useIsMobile, useIsTablet, useIsDesktop, useViewport, useOrientation. SSR-safe. Required by all adaptive components.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/device-provider/MosaicDeviceProvider.tsx",
11
+ "type": "registry:ui",
12
+ "content": "\"use client\";\n\n/**\n * MosaicDeviceProvider — responsive device context (PC-01)\n *\n * Ported (source: private upstream) contexts/DeviceProvider.tsx +\n * hooks/responsive/*.ts (branch: dev).\n *\n * Provides a single context with breakpoint flags, orientation, and viewport\n * size. All adaptive components consume this via useDevice().\n *\n * Stripped: debugResponsive import (dev-only console logger, not portable).\n * Animation: none (context-only).\n * Framer-motion: N/A.\n * SSR: guarded via typeof window checks in each hook.\n */\n\nimport * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type Orientation = \"portrait\" | \"landscape\";\nexport type Breakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\nexport interface DeviceContextValue {\n isMobile: boolean;\n isTablet: boolean;\n isDesktop: boolean;\n isSmUp: boolean;\n isMdUp: boolean;\n isLgUp: boolean;\n isXlUp: boolean;\n orientation: Orientation;\n viewport: { width: number; height: number };\n isBreakpoint: (bp: Breakpoint) => boolean;\n}\n\n// Tailwind v4 default breakpoints (px)\nconst BREAKPOINTS: Record<Breakpoint, number> = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n};\n\n// ── Hooks ─────────────────────────────────────────────────────────────────────\n\n/**\n * useBreakpoint — returns true when viewport >= breakpoint (min-width media query).\n * SSR-safe: initialises to false on server. Subscribes to matchMedia change events.\n */\nexport function useBreakpoint(breakpoint: Breakpoint): boolean {\n const [matches, setMatches] = React.useState(false);\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n const mq = window.matchMedia(`(min-width: ${BREAKPOINTS[breakpoint]}px)`);\n setMatches(mq.matches);\n\n const handler = (e: MediaQueryListEvent) => setMatches(e.matches);\n\n mq.addEventListener(\"change\", handler);\n return () => mq.removeEventListener(\"change\", handler);\n }, [breakpoint]);\n\n return matches;\n}\n\n/** Returns true when viewport is mobile (< md). */\nexport function useIsMobile(): boolean {\n const isMd = useBreakpoint(\"md\");\n return !isMd;\n}\n\n/** Returns true when viewport is tablet (md ≤ width < lg). */\nexport function useIsTablet(): boolean {\n const isMd = useBreakpoint(\"md\");\n const isLg = useBreakpoint(\"lg\");\n return isMd && !isLg;\n}\n\n/** Returns true when viewport is desktop (≥ lg). */\nexport function useIsDesktop(): boolean {\n return useBreakpoint(\"lg\");\n}\n\n/**\n * useViewport — debounced resize listener returning { width, height }.\n * Initialises to { 0, 0 } on SSR.\n */\nexport function useViewport(): { width: number; height: number } {\n const [size, setSize] = React.useState({ width: 0, height: 0 });\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n const update = () => setSize({ width: window.innerWidth, height: window.innerHeight });\n update();\n\n let tid: ReturnType<typeof setTimeout>;\n const debounced = () => {\n clearTimeout(tid);\n tid = setTimeout(update, 100);\n };\n\n window.addEventListener(\"resize\", debounced);\n return () => {\n window.removeEventListener(\"resize\", debounced);\n clearTimeout(tid);\n };\n }, []);\n\n return size;\n}\n\n/**\n * useOrientation — returns \"portrait\" | \"landscape\".\n * Listens to both resize and orientationchange for full coverage.\n */\nexport function useOrientation(): Orientation {\n const [orientation, setOrientation] = React.useState<Orientation>(\"portrait\");\n\n React.useEffect(() => {\n if (typeof window === \"undefined\") return;\n\n const update = () => {\n setOrientation(window.innerHeight > window.innerWidth ? \"portrait\" : \"landscape\");\n };\n update();\n\n window.addEventListener(\"resize\", update);\n window.addEventListener(\"orientationchange\", update);\n return () => {\n window.removeEventListener(\"resize\", update);\n window.removeEventListener(\"orientationchange\", update);\n };\n }, []);\n\n return orientation;\n}\n\n// ── Context ───────────────────────────────────────────────────────────────────\n\nconst DeviceContext = React.createContext<DeviceContextValue | undefined>(undefined);\n\nexport interface MosaicDeviceProviderProps {\n children: React.ReactNode;\n}\n\n/**\n * MosaicDeviceProvider — wrap your app (or subtree) to enable useDevice().\n *\n * @example\n * <MosaicDeviceProvider>\n * <App />\n * </MosaicDeviceProvider>\n */\nexport function MosaicDeviceProvider({ children }: MosaicDeviceProviderProps) {\n const isMobile = useIsMobile();\n const isTablet = useIsTablet();\n const isDesktop = useIsDesktop();\n const isSmUp = useBreakpoint(\"sm\");\n const isMdUp = useBreakpoint(\"md\");\n const isLgUp = useBreakpoint(\"lg\");\n const isXlUp = useBreakpoint(\"xl\");\n const orientation = useOrientation();\n const viewport = useViewport();\n\n const isBreakpoint = React.useCallback(\n (bp: Breakpoint): boolean => {\n switch (bp) {\n case \"sm\":\n return isSmUp;\n case \"md\":\n return isMdUp;\n case \"lg\":\n return isLgUp;\n case \"xl\":\n return isXlUp;\n }\n },\n [isSmUp, isMdUp, isLgUp, isXlUp],\n );\n\n const value = React.useMemo<DeviceContextValue>(\n () => ({\n isMobile,\n isTablet,\n isDesktop,\n isSmUp,\n isMdUp,\n isLgUp,\n isXlUp,\n orientation,\n viewport,\n isBreakpoint,\n }),\n [\n isMobile,\n isTablet,\n isDesktop,\n isSmUp,\n isMdUp,\n isLgUp,\n isXlUp,\n orientation,\n viewport,\n isBreakpoint,\n ],\n );\n\n return <DeviceContext.Provider value={value}>{children}</DeviceContext.Provider>;\n}\n\nMosaicDeviceProvider.displayName = \"MosaicDeviceProvider\";\n\n// Developer-facing invariant errors — thrown only at hook-misuse time, never\n// rendered to an end user (same class as MosaicClerkWebhookHandler's own\n// errors). Kept as an object-literal constant, with the escape-hatch marker\n// interleaved BETWEEN its properties, because a `//` comment placed\n// immediately before a `throw new Error(...)` statement is stripped entirely\n// by esbuild's unminified output and never reaches dist/index.cjs — a marker\n// there would be silently ineffective (confirmed empirically; see\n// no-hardcoded-words-guard.mjs's own header comment on this exact esbuild\n// behaviour).\nconst DEVICE_PROVIDER_ERRORS = {\n // allow-hardcoded-word: developer-facing invariant error, never rendered to an end user\n missingProvider: \"useDevice must be used within a MosaicDeviceProvider\",\n};\n\n/**\n * useDevice — consume the device context.\n * Must be used inside <MosaicDeviceProvider>.\n */\nexport function useDevice(): DeviceContextValue {\n const ctx = React.useContext(DeviceContext);\n if (!ctx) {\n throw new Error(DEVICE_PROVIDER_ERRORS.missingProvider);\n }\n return ctx;\n}\n"
13
+ }
14
+ ],
15
+ "type": "registry:ui"
16
+ }