@vantageos/mosaic-blocks 0.5.35-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 +338 -40
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +231 -11
  5. package/dist/index.d.ts +231 -11
  6. package/dist/index.js +328 -41
  7. package/dist/index.js.map +1 -1
  8. package/dist/styles.css +18 -0
  9. package/package.json +12 -7
  10. package/r/mosaic-accordion.json +1 -2
  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 +35 -130
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-memory-grid",
4
+ "title": "MosaicMemoryGrid",
5
+ "description": "MosaicMemoryGrid — presentational, tile-disposition-only grid of host items",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/memory-grid/MosaicMemoryGrid.tsx",
11
+ "type": "registry:ui",
12
+ "content": "/**\n * MosaicMemoryGrid — presentational, tile-disposition-only grid of host items\n *\n * The tile presentation of a knowledge base: a responsive grid of tiles, one\n * per entry. `MosaicMemoryList` is its row-disposition sibling — both take\n * the SAME `items` + `renderItem` + `emptyMessage` contract and differ ONLY\n * in the container's Tailwind layout classes (`memory-grid-variants.ts` vs.\n * `memory-list-variants.ts`).\n *\n * The grid owns disposition ONLY:\n * - `items`: the host's array of entries, each requiring only an `id`.\n * - `renderItem`: the host-supplied per-entry renderer — the grid never\n * renders a tile of its own and never hardcodes a field, a category, a\n * sort order, or any domain content (no-hardcoded-business-knowledge).\n * - `emptyMessage`: required, no default (SIN-01) — the host owns the\n * language, e.g. `t('MemoryGrid.empty')`.\n *\n * Keyboard: roving tabindex across items (native `<ul>` / `<li>` — semantic\n * list roles come from the elements themselves, no explicit `role` needed)\n * — ArrowRight/ArrowDown moves focus to the next item, ArrowLeft/ArrowUp to\n * the previous, Home/End jump to the first/last. Exactly one item is\n * `tabIndex={0}` at a time; the rest are `tabIndex={-1}`.\n */\n\nimport type * as React from \"react\";\nimport { useRef, useState } from \"react\";\nimport { memoryGridVariants } from \"./memory-grid-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 MosaicMemoryGridProps<T extends { id: string }> {\n /** The entries to lay out as tiles. The grid never inspects their shape beyond `id`. */\n items: T[];\n /** Host-owned renderer for a single entry — the grid owns disposition only. */\n renderItem: (item: T, index: number) => React.ReactNode;\n /** Tile density: \"comfortable\" (default) or \"compact\". Changes gap only. */\n density?: \"comfortable\" | \"compact\";\n /**\n * Message shown when `items` is empty. Required, no default — the host\n * owns the language (e.g. `t('MemoryGrid.empty')`).\n */\n emptyMessage: string;\n /** Additional Tailwind classes on the root container. */\n className?: string;\n /** Additional Tailwind classes on each tile wrapper. */\n itemClassName?: string;\n /** React 19 ref prop — forwarded to the root container. */\n ref?: React.Ref<HTMLDivElement | HTMLUListElement>;\n}\n\n// ── Keyboard navigation ───────────────────────────────────────────────────────\n\nconst NEXT_KEYS = new Set([\"ArrowRight\", \"ArrowDown\"]);\nconst PREV_KEYS = new Set([\"ArrowLeft\", \"ArrowUp\"]);\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicMemoryGrid — production tile-disposition atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: no filtering, no sorting, no item rendering — the\n * host owns the entry content via `renderItem`; this component only owns\n * the tile grid layout and keyboard roving-tabindex navigation.\n */\nexport function MosaicMemoryGrid<T extends { id: string }>({\n items,\n renderItem,\n density = \"comfortable\",\n emptyMessage,\n className,\n itemClassName,\n ref,\n}: MosaicMemoryGridProps<T>) {\n const itemRefs = useRef<Array<HTMLLIElement | null>>([]);\n const [focusedIndex, setFocusedIndex] = useState(0);\n\n function focusItem(index: number) {\n if (items.length === 0) {\n return;\n }\n const clamped = Math.max(0, Math.min(items.length - 1, index));\n setFocusedIndex(clamped);\n itemRefs.current[clamped]?.focus();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLLIElement>, index: number) {\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(items.length - 1);\n }\n }\n\n if (items.length === 0) {\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement> | undefined}\n data-slot=\"memory-grid\"\n className={cn(memoryGridVariants({ density }), className)}\n >\n <p\n data-slot=\"memory-grid-empty\"\n className=\"col-span-full py-12 text-center text-sm text-muted-foreground\"\n >\n {emptyMessage}\n </p>\n </div>\n );\n }\n\n return (\n <ul\n ref={ref as React.Ref<HTMLUListElement> | undefined}\n data-slot=\"memory-grid\"\n className={cn(\"list-none\", memoryGridVariants({ density }), className)}\n >\n {items.map((item, index) => (\n <li\n key={item.id}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n data-slot=\"memory-grid-item\"\n tabIndex={index === focusedIndex ? 0 : -1}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={() => setFocusedIndex(index)}\n className={itemClassName}\n >\n {renderItem(item, index)}\n </li>\n ))}\n </ul>\n );\n}\n\nMosaicMemoryGrid.displayName = \"MosaicMemoryGrid\";\n"
13
+ },
14
+ {
15
+ "path": "src/components/memory-grid/memory-grid-variants.ts",
16
+ "type": "registry:ui",
17
+ "content": "/**\n * memoryGridVariants — pure CVA variant function for MosaicMemoryGrid.\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 * Root container layout — a responsive tile grid. Owns disposition ONLY;\n * item content is entirely host-supplied via `renderItem`.\n */\nexport const memoryGridVariants = cva([\"grid\", \"grid-cols-1 sm:grid-cols-2 lg:grid-cols-3\"], {\n variants: {\n density: {\n comfortable: \"gap-4\",\n compact: \"gap-2\",\n },\n },\n defaultVariants: {\n density: \"comfortable\",\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-memory-list",
4
+ "title": "MosaicMemoryList",
5
+ "description": "MosaicMemoryList — presentational, row-disposition-only list of host items",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/memory-list/MosaicMemoryList.tsx",
11
+ "type": "registry:ui",
12
+ "content": "/**\n * MosaicMemoryList — presentational, row-disposition-only list of host items\n *\n * The row presentation of a knowledge base: a single-column stack of\n * divided rows, one per entry. `MosaicMemoryGrid` is its tile-disposition\n * sibling — both take the SAME `items` + `renderItem` + `emptyMessage`\n * contract and differ ONLY in the container's Tailwind layout classes\n * (`memory-list-variants.ts` vs. `memory-grid-variants.ts`).\n *\n * The list owns disposition ONLY:\n * - `items`: the host's array of entries, each requiring only an `id`.\n * - `renderItem`: the host-supplied per-entry renderer — the list never\n * renders a row of its own and never hardcodes a field, a category, a\n * sort order, or any domain content (no-hardcoded-business-knowledge).\n * - `emptyMessage`: required, no default (SIN-01) — the host owns the\n * language, e.g. `t('MemoryList.empty')`.\n *\n * Keyboard: roving tabindex across items (native `<ul>` / `<li>` — semantic\n * list roles come from the elements themselves, no explicit `role` needed)\n * — ArrowDown/ArrowRight moves focus to the next row, ArrowUp/ArrowLeft to\n * the previous, Home/End jump to the first/last. Exactly one item is\n * `tabIndex={0}` at a time; the rest are `tabIndex={-1}`.\n */\n\nimport type * as React from \"react\";\nimport { useRef, useState } from \"react\";\nimport { memoryListItemVariants, memoryListVariants } from \"./memory-list-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 MosaicMemoryListProps<T extends { id: string }> {\n /** The entries to lay out as rows. The list never inspects their shape beyond `id`. */\n items: T[];\n /** Host-owned renderer for a single entry — the list owns disposition only. */\n renderItem: (item: T, index: number) => React.ReactNode;\n /** Row density: \"comfortable\" (default) or \"compact\". Changes row padding only. */\n density?: \"comfortable\" | \"compact\";\n /**\n * Message shown when `items` is empty. Required, no default — the host\n * owns the language (e.g. `t('MemoryList.empty')`).\n */\n emptyMessage: string;\n /** Additional Tailwind classes on the root container. */\n className?: string;\n /** Additional Tailwind classes on each row wrapper. */\n itemClassName?: string;\n /** React 19 ref prop — forwarded to the root container. */\n ref?: React.Ref<HTMLDivElement | HTMLUListElement>;\n}\n\n// ── Keyboard navigation ───────────────────────────────────────────────────────\n\nconst NEXT_KEYS = new Set([\"ArrowRight\", \"ArrowDown\"]);\nconst PREV_KEYS = new Set([\"ArrowLeft\", \"ArrowUp\"]);\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicMemoryList — production row-disposition atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: no filtering, no sorting, no item rendering — the\n * host owns the entry content via `renderItem`; this component only owns\n * the row list layout and keyboard roving-tabindex navigation.\n */\nexport function MosaicMemoryList<T extends { id: string }>({\n items,\n renderItem,\n density = \"comfortable\",\n emptyMessage,\n className,\n itemClassName,\n ref,\n}: MosaicMemoryListProps<T>) {\n const itemRefs = useRef<Array<HTMLLIElement | null>>([]);\n const [focusedIndex, setFocusedIndex] = useState(0);\n\n function focusItem(index: number) {\n if (items.length === 0) {\n return;\n }\n const clamped = Math.max(0, Math.min(items.length - 1, index));\n setFocusedIndex(clamped);\n itemRefs.current[clamped]?.focus();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLLIElement>, index: number) {\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(items.length - 1);\n }\n }\n\n if (items.length === 0) {\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement> | undefined}\n data-slot=\"memory-list\"\n className={cn(memoryListVariants({ density }), className)}\n >\n <p\n data-slot=\"memory-list-empty\"\n className=\"py-12 text-center text-sm text-muted-foreground\"\n >\n {emptyMessage}\n </p>\n </div>\n );\n }\n\n return (\n <ul\n ref={ref as React.Ref<HTMLUListElement> | undefined}\n data-slot=\"memory-list\"\n className={cn(\"list-none\", memoryListVariants({ density }), className)}\n >\n {items.map((item, index) => (\n <li\n key={item.id}\n ref={(node) => {\n itemRefs.current[index] = node;\n }}\n data-slot=\"memory-list-item\"\n tabIndex={index === focusedIndex ? 0 : -1}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={() => setFocusedIndex(index)}\n className={cn(memoryListItemVariants({ density }), itemClassName)}\n >\n {renderItem(item, index)}\n </li>\n ))}\n </ul>\n );\n}\n\nMosaicMemoryList.displayName = \"MosaicMemoryList\";\n"
13
+ },
14
+ {
15
+ "path": "src/components/memory-list/memory-list-variants.ts",
16
+ "type": "registry:ui",
17
+ "content": "/**\n * memoryListVariants — pure CVA variant function for MosaicMemoryList.\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 * Root container layout — a single-column, divided row stack. Owns\n * disposition ONLY; item content is entirely host-supplied via `renderItem`.\n */\nexport const memoryListVariants = cva([\"flex flex-col\", \"divide-y divide-border\"], {\n variants: {\n density: {\n comfortable: \"\",\n compact: \"\",\n },\n },\n defaultVariants: {\n density: \"comfortable\",\n },\n});\n\n/**\n * Per-row wrapper — owns the row's vertical rhythm (density-dependent\n * padding). Isolated from `memoryListVariants` because it targets the\n * `<li>` wrapper, not the `<ul>` root.\n */\nexport const memoryListItemVariants = cva([], {\n variants: {\n density: {\n comfortable: \"py-3\",\n compact: \"py-1\",\n },\n },\n defaultVariants: {\n density: \"comfortable\",\n },\n});\n"
18
+ }
19
+ ],
20
+ "type": "registry:ui"
21
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-memory-search",
4
+ "title": "MosaicMemorySearch",
5
+ "description": "MosaicMemorySearch — search bar over a host-supplied knowledge base: a query input, optional filter chips (by type/tag), a clear action, and a result-count indication.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-input.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/memory-search/MosaicMemorySearch.tsx",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicMemorySearch — search bar over a host-supplied knowledge base: a\n * query input, optional filter chips (by type/tag), a clear action, and a\n * result-count indication.\n *\n * Fully controlled, presentational atom: `query` + `onQueryChange` own the\n * text; the component never searches anything itself. It has no idea what\n * \"type\" or \"tag\" means — the entire filter catalogue (`filters`) is\n * host-supplied DATA, exactly like `MosaicTemplateCategoryChips`. A client\n * with a different taxonomy (legal, healthcare, e-commerce) supplies its own\n * filter list without touching this package.\n *\n * The result count is never assembled by this component: `resultCount` is a\n * number, and `formatResultCount` is a host-supplied function that turns it\n * into a localized, pluralized string (e.g. `(n) => n === 1 ? \"1 result\" :\n * \\`${n} results\\`` or the FR equivalent). Pluralisation is a language; this\n * library speaks none (SIN-01).\n *\n * The clear action only appears once `query` is non-empty — that switch is\n * genuinely presentation state, not a missing word, so `clearButtonLabel`\n * remains a required prop with no default (the host always supplies it, the\n * button simply isn't rendered until there is something to clear).\n *\n * `filters` / `selectedFilterIds` / `onFilterToggle` are optional as a GROUP:\n * a host that has no filter feature at all renders the search bar with none\n * of the three, and no filter chip row is rendered. That optionality encodes\n * the absence of the whole filter FEATURE, not a missing word — every label\n * that IS rendered (each `filter.label`) is still host-owned data, required\n * on the filter object itself.\n *\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --primary, --primary-foreground, --background, --foreground,\n * --border, --muted, --muted-foreground, --input, --ring.\n * a11y: the query input is `type=\"search\"` with an explicit `aria-label`\n * (`searchLabel`, host-owned — no host is forced to also render a visible\n * `<label>`). Each filter chip is a real `<button>` with `aria-pressed` so\n * the selection state reaches screen-reader users without relying on color.\n * The clear button carries its own required `aria-label` for the same\n * reason.\n *\n * Deps: @base-ui/react (via MosaicInput) + class-variance-authority only.\n *\n * @example\n * <MosaicMemorySearch\n * query={query}\n * onQueryChange={setQuery}\n * searchLabel=\"Search knowledge base\"\n * searchPlaceholder=\"Search…\"\n * clearButtonLabel=\"Clear search\"\n * resultCount={results.length}\n * formatResultCount={(n) => (n === 1 ? \"1 result\" : `${n} results`)}\n * filters={[\n * { id: \"type-note\", label: \"Note\" },\n * { id: \"type-decision\", label: \"Decision\" },\n * ]}\n * selectedFilterIds={selectedFilterIds}\n * onFilterToggle={toggleFilter}\n * />\n */\n\nimport type * as React from \"react\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { memorySearchFilterChipVariants } from \"./memory-search-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\n/**\n * One selectable filter (type, tag, or any other host-defined facet). The\n * library knows nothing about any filter by name — the whole catalogue is\n * host-supplied DATA.\n */\nexport interface MosaicMemorySearchFilter {\n /** Stable identifier, matched against `selectedFilterIds` and passed to `onFilterToggle`. */\n id: string;\n /** Host-supplied, host-localized display label. No built-in taxonomy. */\n label: string;\n}\n\nexport interface MosaicMemorySearchProps {\n /** Current query text. Controlled by the host. */\n query: string;\n /** Called with the new query text on every keystroke. */\n onQueryChange: (query: string) => void;\n /** aria-label for the query input. Required, no default. */\n searchLabel: string;\n /** Placeholder for the query input. Required, no default. */\n searchPlaceholder: string;\n /** aria-label for the clear button. Required, no default — rendered only once `query` is non-empty. */\n clearButtonLabel: string;\n /** Total number of results for the current query/filters. Pure data — never computed here. */\n resultCount: number;\n /**\n * Derives the displayed result-count string from `resultCount`. Required —\n * the host owns pluralisation and language, this component never\n * assembles a count string itself.\n */\n formatResultCount: (count: number) => string;\n /**\n * Full open catalogue of filters — a PROP, never a library constant. Omit\n * entirely (with `selectedFilterIds` and `onFilterToggle`) when the host\n * has no filter feature; no filter chip row is then rendered.\n */\n filters?: MosaicMemorySearchFilter[];\n /** Ids of the currently selected filters. Controlled by the host. */\n selectedFilterIds?: string[];\n /** Called with the filter id when a chip is activated. */\n onFilterToggle?: (id: string) => void;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\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 ClearIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicMemorySearch — production search bar for @vantageos/mosaic-blocks.\n *\n * Purely presentational + controlled: renders the query input, an optional\n * host-supplied filter-chip row, a clear action, and a host-formatted\n * result-count string. No network call, no internal query state, no\n * hardcoded filter catalogue.\n */\nexport function MosaicMemorySearch({\n query,\n onQueryChange,\n searchLabel,\n searchPlaceholder,\n clearButtonLabel,\n resultCount,\n formatResultCount,\n filters,\n selectedFilterIds,\n onFilterToggle,\n className,\n ref,\n}: MosaicMemorySearchProps) {\n return (\n <div ref={ref} data-slot=\"memory-search\" className={cn(\"flex flex-col gap-2\", className)}>\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 <MosaicInput\n type=\"search\"\n aria-label={searchLabel}\n placeholder={searchPlaceholder}\n value={query}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) =>\n onQueryChange(event.target.value)\n }\n className=\"pl-9 pr-9\"\n />\n {query.length > 0 && (\n <button\n type=\"button\"\n aria-label={clearButtonLabel}\n onClick={() => onQueryChange(\"\")}\n className={cn(\n \"absolute right-2 top-1/2 -translate-y-1/2\",\n \"flex size-5 items-center justify-center rounded-full\",\n \"text-muted-foreground hover:bg-muted hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-[3px]\",\n )}\n >\n <ClearIcon />\n </button>\n )}\n </div>\n\n {filters && filters.length > 0 && (\n <div data-slot=\"memory-search-filters\" className=\"flex flex-wrap items-center gap-2\">\n {filters.map((filter) => {\n const isSelected = (selectedFilterIds ?? []).includes(filter.id);\n return (\n <button\n key={filter.id}\n type=\"button\"\n data-slot=\"memory-search-filter-chip\"\n aria-pressed={isSelected}\n onClick={() => onFilterToggle?.(filter.id)}\n className={memorySearchFilterChipVariants({ selected: isSelected })}\n >\n {filter.label}\n </button>\n );\n })}\n </div>\n )}\n\n <p data-slot=\"memory-search-result-count\" className=\"text-sm text-muted-foreground\">\n {formatResultCount(resultCount)}\n </p>\n </div>\n );\n}\n\nMosaicMemorySearch.displayName = \"MosaicMemorySearch\";\n"
15
+ },
16
+ {
17
+ "path": "src/components/memory-search/memory-search-variants.ts",
18
+ "type": "registry:ui",
19
+ "content": "/**\n * memorySearchFilterChipVariants — pure CVA variant function for the\n * optional filter chips rendered by MosaicMemorySearch.\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/** One filter chip button — selected vs. unselected tone. */\nexport const memorySearchFilterChipVariants = cva(\n [\n \"inline-flex items-center justify-center whitespace-nowrap\",\n \"rounded-full border px-3 py-1 gap-1\",\n \"text-xs font-medium transition-colors\",\n \"focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-[3px]\",\n ],\n {\n variants: {\n selected: {\n true: \"border-transparent bg-primary text-primary-foreground\",\n false: \"border-border bg-background text-foreground hover:bg-muted\",\n },\n },\n defaultVariants: {\n selected: false,\n },\n },\n);\n"
20
+ }
21
+ ],
22
+ "type": "registry:ui"
23
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-mention-input",
4
+ "title": "MosaicMentionInput",
5
+ "description": "MosaicMentionInput — text input that opens an anchored, host-owned list of mentionable entries when the host-chosen trigger character is typed.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-popover.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/mention-input/MosaicMentionInput.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicMentionInput — text input that opens an anchored, host-owned list of\n * mentionable entries when the host-chosen trigger character is typed.\n *\n * Built on `MosaicPopover` for anchoring and dismissal (Escape, outside\n * click) — this component does not re-implement either. It owns exactly\n * three things:\n * 1. Detecting the trigger character and the query fragment typed after it,\n * reported to the host via `onQueryChange` — the host decides what\n * \"matches\" means, this component never filters.\n * 2. Roving keyboard navigation (ArrowUp/ArrowDown, wrap-free, clamped) over\n * whichever entries the host currently supplies via `entries`.\n * 3. Inserting the host-chosen text for the selected entry back into the\n * input value and reporting the selection via `onSelectEntry`.\n *\n * The mentionable entries themselves — their data, their rendering, and the\n * decision of which ones currently match the typed query — belong entirely\n * to the host, exactly like `MosaicTemplateList`'s `renderItem` idiom: this\n * component never hardcodes, invents, fetches, or filters an entry.\n *\n * SIN-01: the component carries zero visible strings. `inputAriaLabel`,\n * `listAriaLabel`, and `emptyMessage` are all required props with no\n * default — the host supplies every word.\n *\n * Trigger-detection note: scans backward from the caret for the trigger\n * character, stopping at the first whitespace. This models a single-glyph\n * trigger (e.g. \"@\") — the common case; a multi-character trigger is not a\n * supported shape here.\n */\n\nimport type * as React from \"react\";\nimport { useRef, useState } from \"react\";\nimport { MosaicPopover } from \"@/components/ui/MosaicPopover\";\nimport {\n mentionInputFieldVariants,\n mentionListItemVariants,\n mentionListVariants,\n} from \"./mention-input-variants.js\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n/**\n * Scans backward from `cursor` for `trigger`, stopping at the first\n * whitespace character. Returns the index of the trigger character, or\n * `null` when the caret is not currently inside a mention context.\n */\nfunction findMentionStart(text: string, cursor: number, trigger: string): number | null {\n for (let i = cursor - 1; i >= 0; i--) {\n const char = text[i];\n if (char === trigger) {\n return i;\n }\n if (/\\s/.test(char)) {\n return null;\n }\n }\n return null;\n}\n\n// ── Types ────────────────────────────────────────────────────────────────────\n\nexport interface MosaicMentionInputProps<T extends { id: string }> {\n /** Controlled input value — the host owns the truth. */\n value: string;\n /** Called with the next value on every keystroke and on mention insertion. */\n onValueChange: (value: string) => void;\n /** The character that opens the mention list (e.g. \"@\"). Single glyph. */\n triggerCharacter: string;\n /**\n * The entries to show in the list. Host-owned and, when the host is\n * filtering as the user types, already filtered — this component never\n * inspects or narrows this array itself.\n */\n entries: T[];\n /** Host-owned renderer for a single entry; `active` marks the roving selection. */\n renderEntry: (entry: T, index: number, active: boolean) => React.ReactNode;\n /** Host-owned mapping from an entry to the plain text inserted on selection. */\n getEntryText: (entry: T) => string;\n /**\n * Called with the fragment typed after the trigger character (may be an\n * empty string right after the trigger), or `null` when the caret is not\n * inside a mention context (list closed).\n */\n onQueryChange: (query: string | null) => void;\n /** Called with the chosen entry when the host or user picks one. */\n onSelectEntry?: (entry: T) => void;\n /** Required accessible name for the text input — no default (SIN-01). */\n inputAriaLabel: string;\n /** Required accessible name for the entries list — no default (SIN-01). */\n listAriaLabel: string;\n /** Required message shown when `entries` is empty while the list is open. */\n emptyMessage: string;\n className?: string;\n inputClassName?: string;\n}\n\n/**\n * MosaicMentionInput — production mention-input atom for\n * @vantageos/mosaic-blocks.\n *\n * @example\n * <MosaicMentionInput\n * value={draft}\n * onValueChange={setDraft}\n * triggerCharacter=\"@\"\n * entries={filteredPeople}\n * getEntryText={(person) => person.name}\n * renderEntry={(person, _i, active) => (\n * <PersonRow person={person} active={active} />\n * )}\n * onQueryChange={(query) => setFragment(query)}\n * onSelectEntry={(person) => trackMention(person)}\n * inputAriaLabel={t('Composer.inputLabel')}\n * listAriaLabel={t('Composer.mentionListLabel')}\n * emptyMessage={t('Composer.noMatches')}\n * />\n */\nexport function MosaicMentionInput<T extends { id: string }>({\n value,\n onValueChange,\n triggerCharacter,\n entries,\n renderEntry,\n getEntryText,\n onQueryChange,\n onSelectEntry,\n inputAriaLabel,\n listAriaLabel,\n emptyMessage,\n className,\n inputClassName,\n}: MosaicMentionInputProps<T>) {\n const inputRef = useRef<HTMLInputElement>(null);\n const [mentionStart, setMentionStart] = useState<number | null>(null);\n const [activeIndex, setActiveIndex] = useState(0);\n\n const open = mentionStart !== null;\n\n function closeMention() {\n setMentionStart(null);\n setActiveIndex(0);\n onQueryChange(null);\n }\n\n function handleChange(event: React.ChangeEvent<HTMLInputElement>) {\n const nextValue = event.target.value;\n const cursor = event.target.selectionStart ?? nextValue.length;\n onValueChange(nextValue);\n\n const start = findMentionStart(nextValue, cursor, triggerCharacter);\n if (start === null) {\n if (open) {\n closeMention();\n }\n return;\n }\n setMentionStart(start);\n setActiveIndex(0);\n onQueryChange(nextValue.slice(start + triggerCharacter.length, cursor));\n }\n\n function selectEntry(entry: T) {\n if (mentionStart === null || !inputRef.current) {\n return;\n }\n const cursor = inputRef.current.selectionStart ?? value.length;\n const insertText = getEntryText(entry);\n const nextValue = `${value.slice(0, mentionStart)}${insertText} ${value.slice(cursor)}`;\n onValueChange(nextValue);\n onSelectEntry?.(entry);\n closeMention();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n if (!open) {\n return;\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeMention();\n return;\n }\n if (event.key === \"ArrowDown\") {\n event.preventDefault();\n setActiveIndex((index) => Math.min(entries.length - 1, index + 1));\n return;\n }\n if (event.key === \"ArrowUp\") {\n event.preventDefault();\n setActiveIndex((index) => Math.max(0, index - 1));\n return;\n }\n if (event.key === \"Enter\") {\n const entry = entries[activeIndex];\n if (entry) {\n event.preventDefault();\n selectEntry(entry);\n }\n }\n }\n\n return (\n <div data-slot=\"mention-input\" className={className}>\n <input\n ref={inputRef}\n type=\"text\"\n aria-label={inputAriaLabel}\n value={value}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n className={cn(mentionInputFieldVariants(), inputClassName)}\n />\n <MosaicPopover\n open={open}\n onOpenChange={(nextOpen) => {\n if (!nextOpen) {\n closeMention();\n }\n }}\n anchor={inputRef}\n initialFocus={false}\n aria-label={listAriaLabel}\n >\n {entries.length === 0 ? (\n <p data-slot=\"mention-input-empty\" className=\"px-2 py-1.5 text-sm text-muted-foreground\">\n {emptyMessage}\n </p>\n ) : (\n <ul data-slot=\"mention-input-list\" className={mentionListVariants()}>\n {entries.map((entry, index) => (\n <li\n key={entry.id}\n data-slot=\"mention-input-item\"\n aria-selected={index === activeIndex}\n className={mentionListItemVariants({ active: index === activeIndex })}\n onMouseEnter={() => setActiveIndex(index)}\n onClick={() => selectEntry(entry)}\n onKeyDown={(event) => {\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n selectEntry(entry);\n }\n }}\n >\n {renderEntry(entry, index, index === activeIndex)}\n </li>\n ))}\n </ul>\n )}\n </MosaicPopover>\n </div>\n );\n}\n\nMosaicMentionInput.displayName = \"MosaicMentionInput\";\n"
15
+ },
16
+ {
17
+ "path": "src/components/mention-input/mention-input-variants.ts",
18
+ "type": "registry:ui",
19
+ "content": "/**\n * mentionInputVariants — pure CVA variant functions for MosaicMentionInput.\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 or\n * @base-ui/react.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** The text input itself. */\nexport const mentionInputFieldVariants = cva([\n \"flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm\",\n \"outline-none transition-colors placeholder:text-muted-foreground\",\n \"focus-visible:ring-1 focus-visible:ring-ring\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n]);\n\n/** The mentionable-entries list surface. */\nexport const mentionListVariants = cva([\"m-0 max-h-64 list-none overflow-y-auto p-1\"]);\n\n/** A single entry row inside the list — active variant highlights the roving selection. */\nexport const mentionListItemVariants = cva(\n [\"cursor-pointer rounded-sm px-2 py-1.5 text-sm outline-none\"],\n {\n variants: {\n active: {\n true: \"bg-accent text-accent-foreground\",\n false: \"\",\n },\n },\n defaultVariants: {\n active: false,\n },\n },\n);\n"
20
+ }
21
+ ],
22
+ "type": "registry:ui"
23
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-message-card",
4
+ "title": "MosaicMessageCard",
5
+ "description": "Generic message/chat card. Sender avatar, like/dislike, bookmark, copy, reply. Compact mode.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/message-card/MosaicMessageCard.tsx",
11
+ "type": "registry:ui",
12
+ "content": "\"use client\";\n\n/**\n * MosaicMessageCard — generic message/chat card\n *\n * Ported from components/messages/message-card.tsx\n *\n * Features:\n * - Sender avatar (initials fallback) + name + type badge\n * - Message content + relative timestamp\n * - Like/dislike reactions, reply count, bookmark, copy, reply actions\n * - Compact mode\n *\n * Stripped: ChatMessage type from lib/chat/types, sonner toast, formatRelativeTime util.\n * Reactions managed as uncontrolled local state (callbacks still fire).\n */\n\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\nfunction relativeTime(ts: string | number | Date): string {\n const now = Date.now();\n const then = new Date(ts).getTime();\n const diff = Math.floor((now - then) / 1000);\n if (diff < 60) return \"just now\";\n if (diff < 3600) return `${Math.floor(diff / 60)}m ago`;\n if (diff < 86400) return `${Math.floor(diff / 3600)}h ago`;\n return `${Math.floor(diff / 86400)}d ago`;\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicMessageSenderType = \"user\" | \"ai\" | \"system\";\n\nexport interface MosaicMessageSender {\n id: string;\n name: string;\n type: MosaicMessageSenderType;\n avatarUrl?: string;\n /** Tailwind bg class for the avatar (e.g. \"bg-green-500\") */\n accentColor?: string;\n}\n\nexport interface MosaicMessageReactions {\n likes?: number;\n dislikes?: number;\n}\n\nexport interface MosaicMessage {\n id: string;\n content: string;\n sender: MosaicMessageSender;\n timestamp: string | number | Date;\n reactions?: MosaicMessageReactions;\n replyCount?: number;\n parentMessageId?: string;\n bookmarked?: boolean;\n}\n\nexport interface MosaicMessageCardProps {\n message: MosaicMessage;\n onReply?: (messageId: string) => void;\n onReaction?: (messageId: string, type: \"like\" | \"dislike\") => void;\n onBookmark?: (messageId: string) => void;\n onCopy?: (messageId: string, content: string) => void;\n showThread?: boolean;\n compact?: boolean;\n /** Label for the reply button. Required — host-owned, no default. */\n replyLabel: string;\n /** aria-label for the more-options menu trigger. Required — host-owned, no default. */\n moreOptionsAriaLabel: string;\n /** aria-label for the bookmark button when currently bookmarked. Required, no default. */\n removeBookmarkAriaLabel: string;\n /** aria-label for the bookmark button when not bookmarked. Required, no default. */\n bookmarkAriaLabel: string;\n /** Label for the bookmark toggle menu item when currently bookmarked. Required, no default. */\n removeBookmarkLabel: string;\n /** Label for the bookmark toggle menu item when not bookmarked. Required, no default. */\n bookmarkLabel: string;\n /** Label for the \"copy message\" menu item. Required, no default. */\n copyMessageLabel: string;\n /**\n * Label for the sender-type badge shown next to an AI sender's name.\n * Optional and host-owned — no default, no fallback word. When the sender\n * is an AI (`message.sender.type === \"ai\"`) and this label is provided,\n * the badge renders with it; when omitted, no badge renders at all. The\n * library carries no English/French word of its own for this UI state.\n */\n aiSenderLabel?: string;\n /** Label for the \"view thread\" button, shown when the message has a parent. Required, no default. */\n viewThreadLabel: string;\n /**\n * aria-label for the like button, shown for AI-sender messages. Required —\n * the host formats/pluralizes the count, the library owns no word.\n */\n likeAriaLabel: (count: number) => string;\n /**\n * aria-label for the dislike button, shown for AI-sender messages. Required —\n * the host formats/pluralizes the count, the library owns no word.\n */\n dislikeAriaLabel: (count: number) => string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nconst icons = {\n user: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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=\"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2\" />\n <circle cx=\"12\" cy=\"7\" r=\"4\" />\n </svg>\n ),\n bot: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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 <rect x=\"3\" y=\"11\" width=\"18\" height=\"10\" rx=\"2\" />\n <circle cx=\"12\" cy=\"5\" r=\"2\" />\n <path d=\"M12 7v4\" />\n <line x1=\"8\" y1=\"16\" x2=\"8\" y2=\"16\" />\n <line x1=\"16\" y1=\"16\" x2=\"16\" y2=\"16\" />\n </svg>\n ),\n thumbUp: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"13\"\n height=\"13\"\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=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3z\" />\n <path d=\"M7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\" />\n </svg>\n ),\n thumbDown: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"13\"\n height=\"13\"\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=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3z\" />\n <path d=\"M17 2h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\" />\n </svg>\n ),\n reply: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"13\"\n height=\"13\"\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 17 4 12 9 7\" />\n <path d=\"M20 18v-2a4 4 0 0 0-4-4H4\" />\n </svg>\n ),\n bookmark: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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=\"M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z\" />\n </svg>\n ),\n copy: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"13\"\n height=\"13\"\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 <rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\" ry=\"2\" />\n <path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\" />\n </svg>\n ),\n msgSquare: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"13\"\n height=\"13\"\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=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\" />\n </svg>\n ),\n more: (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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=\"12\" cy=\"12\" r=\"1\" />\n <circle cx=\"19\" cy=\"12\" r=\"1\" />\n <circle cx=\"5\" cy=\"12\" r=\"1\" />\n </svg>\n ),\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicMessageCard({\n message,\n onReply,\n onReaction,\n onBookmark,\n onCopy,\n showThread = true,\n compact = false,\n replyLabel,\n moreOptionsAriaLabel,\n removeBookmarkAriaLabel,\n bookmarkAriaLabel,\n removeBookmarkLabel,\n bookmarkLabel,\n copyMessageLabel,\n aiSenderLabel,\n viewThreadLabel,\n likeAriaLabel,\n dislikeAriaLabel,\n className,\n}: MosaicMessageCardProps) {\n const [bookmarked, setBookmarked] = React.useState(message.bookmarked ?? false);\n const [likes, setLikes] = React.useState(message.reactions?.likes ?? 0);\n const [dislikes, setDislikes] = React.useState(message.reactions?.dislikes ?? 0);\n const [hasLiked, setHasLiked] = React.useState(false);\n const [hasDisliked, setHasDisliked] = React.useState(false);\n const [menuOpen, setMenuOpen] = React.useState(false);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n const initials = message.sender.name\n .split(\" \")\n .map((n) => n[0])\n .filter(Boolean)\n .slice(0, 2)\n .join(\"\")\n .toUpperCase();\n\n const handleLike = () => {\n if (hasLiked) {\n setLikes(likes - 1);\n setHasLiked(false);\n } else {\n setLikes(likes + 1);\n setHasLiked(true);\n if (hasDisliked) {\n setDislikes(dislikes - 1);\n setHasDisliked(false);\n }\n }\n onReaction?.(message.id, \"like\");\n };\n\n const handleDislike = () => {\n if (hasDisliked) {\n setDislikes(dislikes - 1);\n setHasDisliked(false);\n } else {\n setDislikes(dislikes + 1);\n setHasDisliked(true);\n if (hasLiked) {\n setLikes(likes - 1);\n setHasLiked(false);\n }\n }\n onReaction?.(message.id, \"dislike\");\n };\n\n const handleBookmark = () => {\n setBookmarked((b) => !b);\n onBookmark?.(message.id);\n };\n\n const handleCopy = () => {\n navigator.clipboard.writeText(message.content).catch(() => null);\n onCopy?.(message.id, message.content);\n };\n\n React.useEffect(() => {\n if (!menuOpen) return;\n const h = (e: MouseEvent) => {\n if (menuRef.current && !menuRef.current.contains(e.target as Node)) setMenuOpen(false);\n };\n document.addEventListener(\"mousedown\", h);\n return () => document.removeEventListener(\"mousedown\", h);\n }, [menuOpen]);\n\n return (\n <div\n data-slot=\"message-card\"\n className={cn(\n \"rounded-lg border border-border bg-card p-4 shadow-sm transition-shadow hover:shadow-md\",\n compact && \"p-3\",\n message.sender.type === \"user\" && \"bg-primary/5\",\n className,\n )}\n >\n <div className=\"flex gap-3\">\n {/* Avatar */}\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center rounded-full text-white font-semibold\",\n compact ? \"h-8 w-8 text-xs\" : \"h-10 w-10 text-sm\",\n message.sender.accentColor ?? \"bg-muted text-muted-foreground\",\n )}\n >\n {message.sender.avatarUrl ? (\n <img\n src={message.sender.avatarUrl}\n alt={message.sender.name}\n className=\"h-full w-full rounded-full object-cover\"\n />\n ) : message.sender.type === \"user\" ? (\n initials || icons.user\n ) : (\n icons.bot\n )}\n </span>\n\n <div className=\"min-w-0 flex-1\">\n {/* Header */}\n <div className=\"mb-2 flex items-center justify-between gap-2\">\n <div className=\"flex items-center gap-2\">\n <span className={cn(\"font-medium\", compact ? \"text-sm\" : \"text-base\")}>\n {message.sender.name}\n </span>\n {message.sender.type === \"ai\" && aiSenderLabel && (\n <span className=\"rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground\">\n {aiSenderLabel}\n </span>\n )}\n </div>\n <span className=\"shrink-0 text-xs text-muted-foreground\">\n {relativeTime(message.timestamp)}\n </span>\n </div>\n\n {/* Content */}\n <p\n className={cn(\n \"leading-relaxed text-foreground mb-3\",\n compact ? \"text-sm\" : \"text-base\",\n )}\n >\n {message.content}\n </p>\n\n {/* Actions bar */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex items-center gap-1\">\n {message.sender.type === \"ai\" && (\n <>\n <button\n type=\"button\"\n onClick={handleLike}\n className={cn(\n \"inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n hasLiked && \"text-primary\",\n )}\n aria-label={likeAriaLabel(likes)}\n >\n {icons.thumbUp}\n <span>{likes}</span>\n </button>\n <button\n type=\"button\"\n onClick={handleDislike}\n className={cn(\n \"inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n hasDisliked && \"text-destructive\",\n )}\n aria-label={dislikeAriaLabel(dislikes)}\n >\n {icons.thumbDown}\n <span>{dislikes}</span>\n </button>\n </>\n )}\n {showThread && (message.replyCount ?? 0) > 0 && (\n <button\n type=\"button\"\n onClick={() => onReply?.(message.id)}\n className=\"inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n >\n {icons.msgSquare}\n <span>{message.replyCount}</span>\n </button>\n )}\n <button\n type=\"button\"\n onClick={() => onReply?.(message.id)}\n className=\"inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n >\n {icons.reply}\n <span>{replyLabel}</span>\n </button>\n </div>\n\n <div className=\"flex items-center gap-1\">\n <button\n type=\"button\"\n onClick={handleBookmark}\n className={cn(\n \"inline-flex h-8 w-8 items-center justify-center rounded-md\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n bookmarked && \"text-primary\",\n )}\n aria-label={bookmarked ? removeBookmarkAriaLabel : bookmarkAriaLabel}\n aria-pressed={bookmarked}\n >\n {icons.bookmark}\n </button>\n\n {/* More menu */}\n <div ref={menuRef} className=\"relative\">\n <button\n type=\"button\"\n onClick={() => setMenuOpen((v) => !v)}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\"\n aria-label={moreOptionsAriaLabel}\n aria-haspopup=\"menu\"\n >\n {icons.more}\n </button>\n {menuOpen && (\n <div\n role=\"menu\"\n className=\"absolute right-0 top-full z-50 mt-1 min-w-[140px] rounded-md border border-border bg-popover py-1 shadow-md\"\n >\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n handleCopy();\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n {icons.copy}\n {copyMessageLabel}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n onReply?.(message.id);\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n {icons.reply}\n {replyLabel}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n handleBookmark();\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n {icons.bookmark}\n {bookmarked ? removeBookmarkLabel : bookmarkLabel}\n </button>\n </div>\n )}\n </div>\n </div>\n </div>\n\n {message.parentMessageId && showThread && (\n <div className=\"mt-2 border-t border-border pt-2\">\n <button\n type=\"button\"\n onClick={() => onReply?.(message.id)}\n className=\"inline-flex h-7 items-center gap-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-accent-foreground px-2\"\n >\n {icons.msgSquare}\n {viewThreadLabel}\n </button>\n </div>\n )}\n </div>\n </div>\n </div>\n );\n}\n\nMosaicMessageCard.displayName = \"MosaicMessageCard\";\n"
13
+ }
14
+ ],
15
+ "type": "registry:ui"
16
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-message-list",
4
+ "title": "MosaicMessageList",
5
+ "description": "Responsive message list (responsive-pair). Desktop: sticky header + search. Mobile: compact list.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json",
9
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-message-card.json"
10
+ ],
11
+ "files": [
12
+ {
13
+ "path": "src/components/message-list/MosaicMessageList.tsx",
14
+ "type": "registry:ui",
15
+ "content": "\"use client\";\n\n/**\n * MosaicMessageList — responsive message list (desktop + mobile responsive-pair)\n *\n * Ported from components/messages/message-list.tsx +\n * messages/desktop/message-list-desktop.tsx +\n * messages/mobile/message-list-mobile.tsx\n *\n * Orchestrator reads useDevice → Desktop/Mobile variant.\n * Desktop: scrollable card list with sticky header + search.\n * Mobile: compact card list with sticky \"Load more\" button.\n *\n * Props-driven — no internal state for messages (fully controlled).\n * sonner toast removed.\n */\n\nimport * as React from \"react\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\nimport { type MosaicMessage, MosaicMessageCard } from \"@/components/ui/MosaicMessageCard\";\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 MosaicMessageListProps {\n messages: MosaicMessage[];\n onReply?: (messageId: string) => void;\n onReaction?: (messageId: string, type: \"like\" | \"dislike\") => void;\n onBookmark?: (messageId: string) => void;\n onCopy?: (messageId: string, content: string) => void;\n onLoadMore?: () => void;\n hasMore?: boolean;\n /** Optional title for the list header */\n title?: string;\n /** Whether messages are loading */\n isLoading?: boolean;\n /** Placeholder for the desktop search input. Required, no default. */\n searchPlaceholder: string;\n /** Message shown when the filtered list is empty. Required, no default. */\n emptyMessage: string;\n /** Label for the \"load more\" button. Required, no default. */\n loadMoreLabel: string;\n /** Required host-owned strings forwarded to every MosaicMessageCard. */\n replyLabel: string;\n moreOptionsAriaLabel: string;\n removeBookmarkAriaLabel: string;\n bookmarkAriaLabel: string;\n removeBookmarkLabel: string;\n bookmarkLabel: string;\n copyMessageLabel: string;\n viewThreadLabel: string;\n likeAriaLabel: (count: number) => string;\n dislikeAriaLabel: (count: number) => string;\n className?: string;\n}\n\n// ── Search icon ───────────────────────────────────────────────────────────────\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\n// ── Desktop variant ───────────────────────────────────────────────────────────\n\nfunction MessageListDesktop({\n messages,\n onReply,\n onReaction,\n onBookmark,\n onCopy,\n onLoadMore,\n hasMore,\n title,\n isLoading,\n searchPlaceholder,\n emptyMessage,\n loadMoreLabel,\n replyLabel,\n moreOptionsAriaLabel,\n removeBookmarkAriaLabel,\n bookmarkAriaLabel,\n removeBookmarkLabel,\n bookmarkLabel,\n copyMessageLabel,\n viewThreadLabel,\n likeAriaLabel,\n dislikeAriaLabel,\n className,\n}: MosaicMessageListProps) {\n const [query, setQuery] = React.useState(\"\");\n\n const filtered = query\n ? messages.filter(\n (m) =>\n m.content.toLowerCase().includes(query.toLowerCase()) ||\n m.sender.name.toLowerCase().includes(query.toLowerCase()),\n )\n : messages;\n\n return (\n <div data-slot=\"message-list-desktop\" className={cn(\"flex h-full flex-col\", className)}>\n {/* Header */}\n <div className=\"flex items-center justify-between border-b border-border px-6 py-4\">\n {title && <h2 className=\"text-lg font-semibold\">{title}</h2>}\n <div className=\"relative ml-auto max-w-xs flex-1\">\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={query}\n onChange={(e) => setQuery(e.target.value)}\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 {/* List */}\n <div className=\"flex-1 space-y-3 overflow-y-auto p-6\">\n {isLoading && (\n <div className=\"space-y-3\">\n {[0, 1, 2].map((i) => (\n <div key={i} className=\"h-24 animate-pulse rounded-lg bg-muted\" />\n ))}\n </div>\n )}\n {!isLoading &&\n filtered.map((message) => (\n <MosaicMessageCard\n key={message.id}\n message={message}\n onReply={onReply}\n onReaction={onReaction}\n onBookmark={onBookmark}\n onCopy={onCopy}\n replyLabel={replyLabel}\n moreOptionsAriaLabel={moreOptionsAriaLabel}\n removeBookmarkAriaLabel={removeBookmarkAriaLabel}\n bookmarkAriaLabel={bookmarkAriaLabel}\n removeBookmarkLabel={removeBookmarkLabel}\n bookmarkLabel={bookmarkLabel}\n copyMessageLabel={copyMessageLabel}\n viewThreadLabel={viewThreadLabel}\n likeAriaLabel={likeAriaLabel}\n dislikeAriaLabel={dislikeAriaLabel}\n />\n ))}\n {!isLoading && filtered.length === 0 && (\n <p className=\"py-12 text-center text-sm text-muted-foreground\">{emptyMessage}</p>\n )}\n </div>\n\n {hasMore && (\n <div className=\"border-t border-border p-4\">\n <button\n type=\"button\"\n onClick={onLoadMore}\n className={cn(\n \"w-full rounded-md border border-border bg-background px-4 py-2 text-sm font-medium\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {loadMoreLabel}\n </button>\n </div>\n )}\n </div>\n );\n}\n\n// ── Mobile variant ────────────────────────────────────────────────────────────\n\nfunction MessageListMobile({\n messages,\n onReply,\n onReaction,\n onBookmark,\n onCopy,\n onLoadMore,\n hasMore,\n title,\n isLoading,\n emptyMessage,\n loadMoreLabel,\n replyLabel,\n moreOptionsAriaLabel,\n removeBookmarkAriaLabel,\n bookmarkAriaLabel,\n removeBookmarkLabel,\n bookmarkLabel,\n copyMessageLabel,\n viewThreadLabel,\n likeAriaLabel,\n dislikeAriaLabel,\n className,\n}: MosaicMessageListProps) {\n return (\n <div data-slot=\"message-list-mobile\" className={cn(\"flex flex-col\", className)}>\n {title && (\n <div className=\"sticky top-0 z-10 border-b border-border bg-background px-4 py-3\">\n <h2 className=\"text-base font-semibold\">{title}</h2>\n </div>\n )}\n\n <div className=\"space-y-3 p-4\">\n {isLoading && (\n <div className=\"space-y-3\">\n {[0, 1, 2].map((i) => (\n <div key={i} className=\"h-20 animate-pulse rounded-lg bg-muted\" />\n ))}\n </div>\n )}\n {!isLoading &&\n messages.map((message) => (\n <MosaicMessageCard\n key={message.id}\n message={message}\n onReply={onReply}\n onReaction={onReaction}\n onBookmark={onBookmark}\n onCopy={onCopy}\n replyLabel={replyLabel}\n moreOptionsAriaLabel={moreOptionsAriaLabel}\n removeBookmarkAriaLabel={removeBookmarkAriaLabel}\n bookmarkAriaLabel={bookmarkAriaLabel}\n removeBookmarkLabel={removeBookmarkLabel}\n bookmarkLabel={bookmarkLabel}\n copyMessageLabel={copyMessageLabel}\n viewThreadLabel={viewThreadLabel}\n likeAriaLabel={likeAriaLabel}\n dislikeAriaLabel={dislikeAriaLabel}\n compact\n />\n ))}\n {!isLoading && messages.length === 0 && (\n <p className=\"py-10 text-center text-sm text-muted-foreground\">{emptyMessage}</p>\n )}\n </div>\n\n {hasMore && (\n <div className=\"px-4 pb-4\">\n <button\n type=\"button\"\n onClick={onLoadMore}\n className={cn(\n \"w-full min-h-[44px] rounded-md border border-border bg-background px-4 py-2 text-sm font-medium\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {loadMoreLabel}\n </button>\n </div>\n )}\n </div>\n );\n}\n\n// ── Orchestrator ──────────────────────────────────────────────────────────────\n\nexport function MosaicMessageList(props: MosaicMessageListProps) {\n const { isMobile } = useDevice();\n return isMobile ? <MessageListMobile {...props} /> : <MessageListDesktop {...props} />;\n}\n\nMosaicMessageList.displayName = \"MosaicMessageList\";\n\nexport { MessageListDesktop as MosaicMessageListDesktop };\nexport { MessageListMobile as MosaicMessageListMobile };\n"
16
+ }
17
+ ],
18
+ "type": "registry:ui"
19
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-message-search",
4
+ "title": "MosaicMessageSearch",
5
+ "description": "MosaicMessageSearch — search bar over the messages of a single, already-open conversation: a query input and a clear action, with the matching results rendered entirely by the host.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-input.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/message-search/MosaicMessageSearch.tsx",
13
+ "type": "registry:ui",
14
+ "content": "/**\n * MosaicMessageSearch — search bar over the messages of a single, already-open\n * conversation: a query input and a clear action, with the matching results\n * rendered entirely by the host.\n *\n * Distinct from `MosaicMemorySearch` (which searches a host-supplied\n * knowledge base): this component searches WITHIN a conversation's message\n * history so an agent (or a human) can recall a past instruction without\n * re-reading the whole thread.\n *\n * Fully controlled, presentational atom: `query` + `onQueryChange` own the\n * text; the component never searches anything, filters anything, counts\n * anything, or performs any network I/O. It has no idea what a \"message\" or a\n * \"match\" looks like — the entire results area is a host-owned slot\n * (`resultsSlot`), exactly like `MosaicMemorySearch`'s `filters` catalogue.\n *\n * The clear action only appears once `query` is non-empty — that switch is\n * genuinely presentation state, not a missing word, so `clearButtonLabel`\n * remains a required prop with no default (the host always supplies it, the\n * button simply isn't rendered until there is something to clear).\n *\n * `resultsSlot` and `emptyResultsLabel` are optional as a GROUP, but for two\n * different reasons:\n * - `resultsSlot` omitted encodes \"the host has not rendered a results view\n * yet\" (e.g. the query is empty, or results are still being gathered) —\n * absence of a whole feature, not a missing word.\n * - `emptyResultsLabel` is the one SIN-01 exception: a NAMED, host-worded\n * zero-results state. It is rendered only when `resultsSlot` is absent, so\n * the host signals \"I searched and found nothing\" by supplying this label\n * without a results node. When both are supplied, `resultsSlot` wins — the\n * host is trusted to omit `emptyResultsLabel` once it has real results.\n *\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --primary, --primary-foreground, --background, --foreground,\n * --border, --muted, --muted-foreground, --input, --ring.\n * a11y: the query input is `type=\"search\"` with an explicit `aria-label`\n * (`searchLabel`, host-owned — no host is forced to also render a visible\n * `<label>`). The clear button carries its own required `aria-label` for the\n * same reason.\n *\n * Deps: @base-ui/react (via MosaicInput) + class-variance-authority only.\n *\n * @example\n * <MosaicMessageSearch\n * query={query}\n * onQueryChange={setQuery}\n * searchLabel=\"Search this conversation\"\n * searchPlaceholder=\"Search messages…\"\n * clearButtonLabel=\"Clear search\"\n * resultsSlot={matches.length > 0 ? <MatchList matches={matches} /> : undefined}\n * emptyResultsLabel=\"No messages match your search\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\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 MosaicMessageSearchProps {\n /** Current query text. Controlled by the host. */\n query: string;\n /** Called with the new query text on every keystroke. */\n onQueryChange: (query: string) => void;\n /** aria-label for the query input. Required, no default. */\n searchLabel: string;\n /** Placeholder for the query input. Required, no default. */\n searchPlaceholder: string;\n /** aria-label for the clear button. Required, no default — rendered only once `query` is non-empty. */\n clearButtonLabel: string;\n /**\n * Host-owned results view for the current query — a node, never data the\n * component would render itself. The host performs the search; this\n * component never sees a single message.\n */\n resultsSlot?: React.ReactNode;\n /**\n * Host-worded zero-results state. Rendered only when `resultsSlot` is\n * absent — the host signals \"I searched and found nothing\" by supplying\n * this label without a results node. Absence (with `resultsSlot` also\n * absent) encodes a neutral state (e.g. no search performed yet).\n */\n emptyResultsLabel?: string;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\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 ClearIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\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=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicMessageSearch — production in-thread message search bar for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational + controlled: renders the query input, a clear\n * action, and whatever host-owned results view is passed in. No network\n * call, no internal query state, no message model of any kind.\n */\nexport function MosaicMessageSearch({\n query,\n onQueryChange,\n searchLabel,\n searchPlaceholder,\n clearButtonLabel,\n resultsSlot,\n emptyResultsLabel,\n className,\n ref,\n}: MosaicMessageSearchProps) {\n return (\n <div ref={ref} data-slot=\"message-search\" className={cn(\"flex flex-col gap-2\", className)}>\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 <MosaicInput\n type=\"search\"\n aria-label={searchLabel}\n placeholder={searchPlaceholder}\n value={query}\n onChange={(event: React.ChangeEvent<HTMLInputElement>) =>\n onQueryChange(event.target.value)\n }\n className=\"pl-9 pr-9\"\n />\n {query.length > 0 && (\n <button\n type=\"button\"\n aria-label={clearButtonLabel}\n onClick={() => onQueryChange(\"\")}\n className={cn(\n \"absolute right-2 top-1/2 -translate-y-1/2\",\n \"flex size-5 items-center justify-center rounded-full\",\n \"text-muted-foreground hover:bg-muted hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-ring focus-visible:ring-[3px]\",\n )}\n >\n <ClearIcon />\n </button>\n )}\n </div>\n\n {resultsSlot ? (\n <div data-slot=\"message-search-results\">{resultsSlot}</div>\n ) : (\n emptyResultsLabel && (\n <p data-slot=\"message-search-results\" className=\"text-sm text-muted-foreground\">\n {emptyResultsLabel}\n </p>\n )\n )}\n </div>\n );\n}\n\nMosaicMessageSearch.displayName = \"MosaicMessageSearch\";\n"
15
+ }
16
+ ],
17
+ "type": "registry:ui"
18
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-model-selector",
4
+ "title": "MosaicModelSelector",
5
+ "description": "MosaicModelSelector — @base-ui/react Combobox primitive",
6
+ "dependencies": [
7
+ "@base-ui/react"
8
+ ],
9
+ "registryDependencies": [],
10
+ "files": [
11
+ {
12
+ "path": "src/components/model-selector/MosaicModelSelector.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicModelSelector — @base-ui/react Combobox primitive\n *\n * Ported from any-debate-ai components/agent-composer/ModelSelector.tsx.\n * (gh api repos/elpiarthera/any-debate-ai/contents/components/agent-composer/ModelSelector.tsx)\n *\n * The source component hard-coded AVAILABLE_MODELS + getRecommendedModels\n * from a local catalogue module. That catalogue is business knowledge that\n * changes independently of the library — it does NOT belong in\n * @vantageos/mosaic-blocks. This port strips it entirely: the host supplies\n * `models: MosaicModelOption[]`, the library only knows how to render and\n * navigate a list of options it is handed.\n *\n * Built on @base-ui/react/combobox (native in @base-ui/react@1.5.0).\n * Filtering via built-in useFilter with \"contains\" strategy (same recipe as\n * MosaicCombobox). Keyboard-accessible: ArrowDown/Up navigate, Enter selects,\n * Escape closes. Disabled options are visibly non-interactive\n * (aria-disabled) and never fire onValueChange.\n *\n * Controlled: `value` + `onValueChange` are owned by the host.\n * data-slot=\"model-selector\" on the root wrapper.\n */\n\nimport { Combobox } from \"@base-ui/react/combobox\";\nimport * as React from \"react\";\nimport {\n modelSelectorItemVariants,\n modelSelectorTriggerVariants,\n} from \"./model-selector-variants.js\";\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 MosaicModelOption {\n /** Unique identifier the host resolves back to its own model catalogue. */\n value: string;\n /** Display name (e.g. \"GPT-5\", \"Claude Opus\"). */\n label: string;\n /** Optional one-line description, supplied by the host. */\n description?: string;\n /** Optional meta line (e.g. context window / pricing), supplied by the host. */\n meta?: string;\n /** Optional badge text (e.g. \"Recommended\"), supplied by the host. */\n badge?: string;\n /** When true, the option is shown but cannot be selected. */\n disabled?: boolean;\n}\n\nexport interface MosaicModelSelectorProps {\n /** The full list of selectable models. The library knows no model names — host-owned. */\n models: MosaicModelOption[];\n /** Controlled selected value. */\n value?: string;\n /** Callback fired when the host's selection should change. Never fires for disabled options. */\n onValueChange?: (value: string) => void;\n /**\n * Text shown in the trigger when no model is selected. Required — the\n * host owns the language (e.g. `t('ModelSelector.placeholder')`).\n */\n placeholder: string;\n /**\n * Message shown when no model matches the filter. Required — the host\n * owns the language. No default, no fallback.\n */\n emptyMessage: string;\n disabled?: boolean;\n name?: string;\n className?: string;\n /**\n * Which side of the trigger 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 * MosaicModelSelector — production model-picker atom for @vantageos/mosaic-blocks.\n *\n * The component owns zero model knowledge: `models` is supplied by the host,\n * filtered as the user types, and the selected id is surfaced through\n * `onValueChange`. All visible strings that are not per-model host data\n * (placeholder, emptyMessage) are required props with no default.\n *\n * @example\n * <MosaicModelSelector\n * models={[{ value: \"gpt-5\", label: \"GPT-5\", description: \"Flagship model\" }]}\n * value={selectedModel}\n * onValueChange={setSelectedModel}\n * placeholder={t('ModelSelector.placeholder')}\n * emptyMessage={t('ModelSelector.empty')}\n * />\n */\nexport function MosaicModelSelector({\n models,\n value,\n onValueChange,\n placeholder,\n emptyMessage,\n disabled,\n name,\n className,\n side,\n align,\n collisionBoundary,\n collisionPadding,\n}: MosaicModelSelectorProps) {\n const [inputValue, setInputValue] = React.useState(\"\");\n\n const filter = Combobox.useFilter({ sensitivity: \"base\" });\n\n const filteredModels = React.useMemo(() => {\n if (!inputValue) return models;\n return models.filter((model) => filter.contains(model.label, inputValue));\n }, [models, inputValue, filter]);\n\n const labelMap = React.useMemo(\n () => Object.fromEntries(models.map((model) => [model.value, model.label])),\n [models],\n );\n\n const handleValueChange = React.useCallback(\n (nextValue: unknown, eventDetails: unknown) => {\n if (typeof nextValue !== \"string\") return;\n const selected = models.find((model) => model.value === nextValue);\n if (!selected || selected.disabled) return;\n onValueChange?.(nextValue);\n void eventDetails;\n },\n [models, onValueChange],\n );\n\n return (\n <Combobox.Root\n value={value}\n onValueChange={handleValueChange}\n disabled={disabled}\n name={name}\n onInputValueChange={setInputValue}\n autoHighlight\n >\n <div data-slot=\"model-selector\" className={cn(\"relative w-full\", className)}>\n <Combobox.Input\n placeholder={placeholder}\n className={modelSelectorTriggerVariants({ className })}\n />\n {value != null && value in labelMap && inputValue === \"\" && (\n <span className=\"pointer-events-none absolute inset-y-0 left-3 flex items-center text-sm text-foreground\">\n {labelMap[value]}\n </span>\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-[16rem] 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 {filteredModels.length === 0 ? (\n <Combobox.Empty className=\"py-2 text-center text-sm text-muted-foreground\">\n {emptyMessage}\n </Combobox.Empty>\n ) : (\n filteredModels.map((model) => (\n <Combobox.Item\n key={model.value}\n value={model.value}\n disabled={model.disabled}\n className={modelSelectorItemVariants({ className: undefined })}\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"font-medium\">{model.label}</span>\n {model.badge && (\n <span className=\"rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground\">\n {model.badge}\n </span>\n )}\n </div>\n {model.description && (\n <span className=\"text-xs text-muted-foreground\">{model.description}</span>\n )}\n {model.meta && (\n <span className=\"text-xs text-muted-foreground\">{model.meta}</span>\n )}\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\nMosaicModelSelector.displayName = \"MosaicModelSelector\";\n"
15
+ },
16
+ {
17
+ "path": "src/components/model-selector/model-selector-variants.ts",
18
+ "type": "registry:ui",
19
+ "content": "/**\n * modelSelectorVariants — pure CVA variant functions for MosaicModelSelector.\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 trigger button — shows either the selected model summary or the placeholder. */\nexport const modelSelectorTriggerVariants = cva(\n [\n \"flex w-full min-h-[44px] items-center justify-between gap-2 rounded-md border\",\n \"border-border bg-background px-3 py-2 text-left text-sm text-foreground shadow-xs\",\n \"outline-none transition-colors hover:bg-muted\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[popup-open]:ring-ring data-[popup-open]:ring-[3px]\",\n ],\n {\n variants: {},\n },\n);\n\n/** One model row in the popup list — selected vs. disabled tone. */\nexport const modelSelectorItemVariants = cva(\n [\n \"relative flex cursor-pointer select-none flex-col gap-0.5 rounded-sm px-2 py-1.5\",\n \"text-sm text-popover-foreground outline-none transition-colors\",\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 variants: {},\n },\n);\n"
20
+ }
21
+ ],
22
+ "type": "registry:ui"
23
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-module-card",
4
+ "title": "MosaicModuleCard",
5
+ "description": "Selected-module display card for composer slot. Shows name, description, optional details, emoji icon, tags, edit/remove actions. Props: type, module {name, description, details?, icon?, tags?}, onEdit, onRemove, isSelected, isCustom. Generic — no debate domain types.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/module-card/MosaicModuleCard.tsx",
11
+ "type": "registry:ui",
12
+ "content": "\"use client\";\n\n/**\n * MosaicModuleCard — selected-module display card (PC-11)\n *\n * Ported (source: private upstream) components/agent-composer/ModuleCard.tsx\n *\n * Displays a selected module (role / persona / framework / any custom type)\n * with name, description, optional tags/details string, and edit/remove actions.\n * Used inside AgentComposer Desktop + Mobile variants.\n *\n * Generalized: removed debate-specific types (Role, Persona, ThinkingFramework)\n * in favour of a generic MosaicModuleData interface.\n * Removed useDevice dependency (parent controls layout context).\n *\n * Framer-motion: N/A.\n * Icons: inline SVG (no lucide dep).\n */\n\nimport type * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicModuleData {\n name: string;\n description?: string;\n /** Short detail string shown below description (e.g. \"3 steps\", \"Expertise: UX, Research\") */\n details?: string;\n /** Optional emoji or short string icon displayed in the card */\n icon?: string;\n /** Optional array of tag strings shown as badges */\n tags?: string[];\n}\n\nexport type MosaicModuleType = \"role\" | \"persona\" | \"framework\" | string;\n\nexport interface MosaicModuleCardProps {\n type: MosaicModuleType;\n module: MosaicModuleData;\n onRemove?: () => void;\n onEdit?: () => void;\n isSelected?: boolean;\n isCustom?: boolean;\n /** Badge label shown when `isCustom` is true. Required, no default. */\n customBadgeLabel: string;\n /** aria-label for the edit button. Required, no default. */\n editAriaLabel: string;\n /** aria-label for the remove button. Required, no default. */\n removeAriaLabel: string;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction EditIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7\" />\n <path d=\"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z\" />\n </svg>\n );\n}\n\nfunction RemoveIcon() {\n return (\n <svg\n width=\"14\"\n height=\"14\"\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=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicModuleCard — filled-state card for a selected module slot.\n * Shows name, description, optional details, icon, tags, and edit/remove actions.\n *\n * @example\n * <MosaicModuleCard\n * type=\"role\"\n * module={{ name: \"Product Manager\", description: \"Drives product strategy\", tags: [\"strategy\", \"roadmap\"] }}\n * onEdit={() => openRolePicker()}\n * onRemove={() => clearRole()}\n * />\n */\nexport function MosaicModuleCard({\n type: _type,\n module,\n onRemove,\n onEdit,\n isSelected = false,\n isCustom = false,\n customBadgeLabel,\n editAriaLabel,\n removeAriaLabel,\n className,\n ref,\n}: MosaicModuleCardProps) {\n return (\n <div\n ref={ref}\n data-slot=\"module-card\"\n className={cn(\n \"min-h-[80px] rounded-xl border border-border bg-card p-4 transition-all\",\n \"flex items-start gap-3\",\n isSelected && \"ring-2 ring-primary bg-primary/5\",\n className,\n )}\n >\n {/* Icon */}\n {module.icon && (\n <span className=\"mt-0.5 shrink-0 text-2xl\" aria-hidden=\"true\">\n {module.icon}\n </span>\n )}\n\n {/* Content */}\n <div className=\"min-w-0 flex-1\">\n <div className=\"mb-1 flex items-center gap-2\">\n <h4 className=\"truncate text-sm font-medium text-foreground\">{module.name}</h4>\n {isCustom && (\n <span className=\"shrink-0 rounded-full bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground\">\n {customBadgeLabel}\n </span>\n )}\n </div>\n\n {module.description && (\n <p className=\"mb-2 line-clamp-2 text-xs text-muted-foreground\">{module.description}</p>\n )}\n\n {module.details && (\n <p className=\"truncate text-xs font-medium text-muted-foreground/80\">{module.details}</p>\n )}\n\n {module.tags && module.tags.length > 0 && (\n <div className=\"mt-2 flex flex-wrap gap-1\">\n {module.tags.slice(0, 4).map((tag) => (\n <span\n key={tag}\n className=\"rounded-full border border-border bg-muted px-2 py-0.5 text-xs text-muted-foreground\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n\n {/* Actions */}\n {(onEdit || onRemove) && (\n <div className=\"flex shrink-0 items-center gap-1\">\n {onEdit && (\n <button\n type=\"button\"\n onClick={onEdit}\n aria-label={editAriaLabel}\n className=\"flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <EditIcon />\n </button>\n )}\n {onRemove && (\n <button\n type=\"button\"\n onClick={onRemove}\n aria-label={removeAriaLabel}\n className=\"flex h-8 w-8 items-center justify-center rounded-md text-destructive transition-colors hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <RemoveIcon />\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nMosaicModuleCard.displayName = \"MosaicModuleCard\";\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-module-library",
4
+ "title": "MosaicModuleLibrary",
5
+ "description": "Generic module/library manager (responsive-pair). Includes MosaicModuleForm. Tabs, search, CRUD callbacks.",
6
+ "dependencies": [],
7
+ "registryDependencies": [
8
+ "https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-adaptive-modal.json"
9
+ ],
10
+ "files": [
11
+ {
12
+ "path": "src/components/module-library/MosaicModuleLibrary.tsx",
13
+ "type": "registry:ui",
14
+ "content": "\"use client\";\n\n/**\n * MosaicModuleLibrary — generic module/framework/persona/role library (responsive-pair)\n *\n * Ported from components/module-libraries/ (FrameworkLibrary, PersonaLibrary,\n * RoleLibrary + desktop/mobile variants + forms + editor modals)\n * Combined into a single generic pattern.\n *\n * \"Module\" = any reusable item in a library (framework, persona, role, skill, etc.)\n * Labels and field configs are fully prop-driven.\n *\n * Exports:\n * MosaicModuleLibrary — responsive orchestrator\n * MosaicModuleForm — create/edit form for a module\n *\n * All domain-specific hooks (useFrameworkManager) stripped.\n * Data + CRUD callbacks are props.\n */\n\nimport * as React from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\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 MosaicModuleItem {\n id: string;\n name: string;\n description?: string;\n icon?: string;\n tags?: string[];\n /** Steps or methodology items */\n steps?: string[];\n /** Best-for use cases */\n bestFor?: string[];\n /** Whether this item was created by the user (editable/deletable) */\n isCustom?: boolean;\n [key: string]: unknown;\n}\n\nexport interface MosaicModuleFormField {\n id: string;\n label: string;\n type: \"text\" | \"textarea\" | \"emoji\" | \"tag-list\";\n placeholder?: string;\n description?: string;\n required?: boolean;\n}\n\nexport interface MosaicModuleLibraryProps {\n /** All items in the library (system + custom) */\n items: MosaicModuleItem[];\n /** Whether items are loading */\n isLoading?: boolean;\n onCreateItem: (data: Omit<MosaicModuleItem, \"id\">) => void;\n onUpdateItem: (id: string, data: Partial<MosaicModuleItem>) => void;\n onDeleteItem: (id: string) => void;\n /** Tabs to switch between (e.g. \"My Modules\" vs \"System\") */\n tabs?: Array<{ id: string; label: string }>;\n /** Filter function for each tab */\n tabFilter?: (item: MosaicModuleItem, tabId: string) => boolean;\n /** Additional form fields beyond name/description */\n formFields?: MosaicModuleFormField[];\n /** Library heading. Required, no default. */\n title: string;\n /** Label for the \"create item\" button. Required, no default. */\n createLabel: string;\n /** Search input placeholder. Required, no default. */\n searchPlaceholder: string;\n /** Message shown when the filtered list is empty. Required, no default. */\n emptyMessage: string;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n nameFieldLabel: string;\n descriptionFieldLabel: string;\n namePlaceholder: string;\n descriptionPlaceholder: string;\n cancelLabel: string;\n saveChangesLabel: string;\n createItemLabel: string;\n itemActionsAriaLabel: string;\n editItemLabel: string;\n deleteItemLabel: string;\n closeEditorAriaLabel: string;\n /** Modal title for the editor. Required — `(itemName) => string`. */\n editModalTitle: (itemName: string) => string;\n /**\n * Placeholder for the \"add a tag\" input in `tag-list` fields (used only\n * when the field itself doesn't set its own `placeholder`). Required,\n * no default.\n */\n tagListAddPlaceholder: string;\n /**\n * Formatter for a tag-chip's remove-button aria-label, read only when a\n * `tag-list` field renders an existing tag. Optional — when absent, the\n * remove button renders with no `aria-label` (no fallback word). The host\n * owns the language (e.g. `(tag) => t('ModuleForm.removeTag', { tag })`).\n */\n removeTagAriaLabel?: (tag: string) => string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction PlusIcon() {\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 <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\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 MoreVertIcon() {\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=\"12\" cy=\"5\" r=\"1\" />\n <circle cx=\"12\" cy=\"12\" r=\"1\" />\n <circle cx=\"12\" cy=\"19\" r=\"1\" />\n </svg>\n );\n}\n\nfunction XIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\n// ── MosaicModuleForm ──────────────────────────────────────────────────────────\n\n/** Props shared by both form modes — read unconditionally. */\nexport interface MosaicModuleFormBaseProps {\n item?: MosaicModuleItem;\n formFields?: MosaicModuleFormField[];\n onSave: (data: Omit<MosaicModuleItem, \"id\"> | MosaicModuleItem) => void;\n onCancel: () => void;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n nameFieldLabel: string;\n descriptionFieldLabel: string;\n namePlaceholder: string;\n descriptionPlaceholder: string;\n cancelLabel: string;\n /**\n * Placeholder for the \"add a tag\" input in `tag-list` fields (used only\n * when the field itself doesn't set its own `placeholder`). Required,\n * no default.\n */\n tagListAddPlaceholder: string;\n /**\n * Formatter for a tag-chip's remove-button aria-label, read only when a\n * `tag-list` field renders an existing tag. Optional — when absent, the\n * remove button renders with no `aria-label` (no fallback word). The host\n * owns the language (e.g. `(tag) => t('ModuleForm.removeTag', { tag })`).\n */\n removeTagAriaLabel?: (tag: string) => string;\n}\n\n/**\n * Discriminated union on `mode`. The submit button renders EXACTLY ONE label:\n * `createItemLabel` in \"create\", `saveChangesLabel` in \"edit\". Requiring both\n * in both modes forced every host to supply a string the form never displays —\n * a \"lying prop contract\", found by the `no-lying-prop-contract` guard (the\n * same defect class as MosaicMemoryCard's `formatMoreTags`). Each label now\n * lives on the branch that actually renders it.\n */\nexport type MosaicModuleFormModeProps =\n | {\n mode: \"create\";\n /** Submit-button label in create mode. Required here — not in \"edit\". */\n createItemLabel: string;\n }\n | {\n mode: \"edit\";\n /** Submit-button label in edit mode. Required here — not in \"create\". */\n saveChangesLabel: string;\n };\n\nexport type MosaicModuleFormProps = MosaicModuleFormBaseProps & MosaicModuleFormModeProps;\n\nexport function MosaicModuleForm(props: MosaicModuleFormProps) {\n const {\n item,\n mode,\n formFields = [],\n onSave,\n onCancel,\n nameFieldLabel,\n descriptionFieldLabel,\n namePlaceholder,\n descriptionPlaceholder,\n cancelLabel,\n tagListAddPlaceholder,\n removeTagAriaLabel,\n } = props;\n const [formData, setFormData] = React.useState<Partial<MosaicModuleItem>>({\n name: item?.name ?? \"\",\n description: item?.description ?? \"\",\n icon: item?.icon ?? \"\",\n tags: item?.tags ?? [],\n steps: item?.steps ?? [],\n bestFor: item?.bestFor ?? [],\n ...Object.fromEntries(\n formFields.map((f) => [f.id, item?.[f.id] ?? (f.type === \"tag-list\" ? [] : \"\")]),\n ),\n });\n\n const [tagInputs, setTagInputs] = React.useState<Record<string, string>>({});\n\n const update = (key: string, value: unknown) => {\n setFormData((prev) => ({ ...prev, [key]: value }));\n };\n\n const addTag = (fieldId: string) => {\n const val = tagInputs[fieldId]?.trim();\n if (!val) return;\n const existing = (formData[fieldId] as string[]) ?? [];\n if (!existing.includes(val)) {\n update(fieldId, [...existing, val]);\n }\n setTagInputs((prev) => ({ ...prev, [fieldId]: \"\" }));\n };\n\n const removeTag = (fieldId: string, tag: string) => {\n update(\n fieldId,\n ((formData[fieldId] as string[]) ?? []).filter((t) => t !== tag),\n );\n };\n\n const handleSave = () => {\n if (mode === \"edit\" && item) {\n onSave({ ...formData, id: item.id } as MosaicModuleItem);\n } else {\n onSave(formData as Omit<MosaicModuleItem, \"id\">);\n }\n };\n\n return (\n <div data-slot=\"module-form\" className=\"flex flex-col gap-4 p-4\">\n {/* Name */}\n <div className=\"space-y-1.5\">\n <label htmlFor=\"module-name\" className=\"text-sm font-medium\">\n {nameFieldLabel}\n </label>\n <input\n id=\"module-name\"\n type=\"text\"\n value={formData.name as string}\n onChange={(e) => update(\"name\", e.target.value)}\n placeholder={namePlaceholder}\n required\n className={cn(\n \"w-full rounded-md border border-input bg-background px-3 py-2 min-h-[40px]\",\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\n {/* Description */}\n <div className=\"space-y-1.5\">\n <label htmlFor=\"module-desc\" className=\"text-sm font-medium\">\n {descriptionFieldLabel}\n </label>\n <textarea\n id=\"module-desc\"\n value={formData.description as string}\n onChange={(e) => update(\"description\", e.target.value)}\n placeholder={descriptionPlaceholder}\n rows={3}\n className={cn(\n \"w-full rounded-md border border-input bg-background px-3 py-2\",\n \"text-sm placeholder:text-muted-foreground resize-none\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n\n {/* Extra fields */}\n {formFields.map((field) => (\n <div key={field.id} className=\"space-y-1.5\">\n <label htmlFor={`field-${field.id}`} className=\"text-sm font-medium\">\n {field.label}\n {field.required && \" *\"}\n </label>\n {field.description && (\n <p className=\"text-xs text-muted-foreground\">{field.description}</p>\n )}\n {field.type === \"text\" && (\n <input\n id={`field-${field.id}`}\n type=\"text\"\n value={(formData[field.id] as string) ?? \"\"}\n onChange={(e) => update(field.id, e.target.value)}\n placeholder={field.placeholder}\n className={cn(\n \"w-full rounded-md border border-input bg-background px-3 py-2 min-h-[40px]\",\n \"text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n )}\n {field.type === \"textarea\" && (\n <textarea\n id={`field-${field.id}`}\n value={(formData[field.id] as string) ?? \"\"}\n onChange={(e) => update(field.id, e.target.value)}\n placeholder={field.placeholder}\n rows={3}\n className={cn(\n \"w-full rounded-md border border-input bg-background px-3 py-2\",\n \"text-sm placeholder:text-muted-foreground resize-none\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n )}\n {field.type === \"emoji\" && (\n <input\n id={`field-${field.id}`}\n type=\"text\"\n value={(formData[field.id] as string) ?? \"\"}\n onChange={(e) => update(field.id, e.target.value)}\n placeholder={field.placeholder ?? \"🧠\"}\n maxLength={4}\n className={cn(\n \"w-20 rounded-md border border-input bg-background px-3 py-2 text-2xl\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n )}\n {field.type === \"tag-list\" && (\n <div className=\"space-y-2\">\n <div className=\"flex gap-2\">\n <input\n type=\"text\"\n value={tagInputs[field.id] ?? \"\"}\n onChange={(e) =>\n setTagInputs((prev) => ({ ...prev, [field.id]: e.target.value }))\n }\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n addTag(field.id);\n }\n }}\n placeholder={field.placeholder ?? tagListAddPlaceholder}\n className={cn(\n \"flex-1 rounded-md border border-input bg-background px-3 py-2 min-h-[36px]\",\n \"text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n <button\n type=\"button\"\n onClick={() => addTag(field.id)}\n className=\"inline-flex h-9 w-9 items-center justify-center rounded-md border border-border bg-background hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <PlusIcon />\n </button>\n </div>\n <div className=\"flex flex-wrap gap-1.5\">\n {((formData[field.id] as string[]) ?? []).map((tag) => (\n <span\n key={tag}\n className=\"inline-flex items-center gap-1 rounded-full bg-secondary px-2.5 py-0.5 text-xs font-medium text-secondary-foreground\"\n >\n {tag}\n <button\n type=\"button\"\n onClick={() => removeTag(field.id, tag)}\n className=\"hover:text-destructive\"\n aria-label={removeTagAriaLabel?.(tag)}\n >\n <XIcon />\n </button>\n </span>\n ))}\n </div>\n </div>\n )}\n </div>\n ))}\n\n {/* Actions */}\n <div className=\"flex justify-end gap-2 pt-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md border border-border bg-background px-4 text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={!formData.name}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:pointer-events-none\"\n >\n {props.mode === \"edit\" ? props.saveChangesLabel : props.createItemLabel}\n </button>\n </div>\n </div>\n );\n}\n\nMosaicModuleForm.displayName = \"MosaicModuleForm\";\n\n// ── Module card ───────────────────────────────────────────────────────────────\n\nfunction ModuleItemCard({\n item,\n onEdit,\n onDelete,\n itemActionsAriaLabel,\n editItemLabel,\n deleteItemLabel,\n}: {\n item: MosaicModuleItem;\n onEdit: (item: MosaicModuleItem) => void;\n onDelete: (id: string) => void;\n itemActionsAriaLabel: string;\n editItemLabel: string;\n deleteItemLabel: string;\n}) {\n const [menuOpen, setMenuOpen] = React.useState(false);\n const menuRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!menuOpen) return;\n const h = (e: MouseEvent) => {\n if (menuRef.current && !menuRef.current.contains(e.target as Node)) setMenuOpen(false);\n };\n document.addEventListener(\"mousedown\", h);\n return () => document.removeEventListener(\"mousedown\", h);\n }, [menuOpen]);\n\n return (\n <div className=\"group relative rounded-lg border border-border bg-card p-4 hover:shadow-sm transition-shadow\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-start gap-3 min-w-0 flex-1\">\n {item.icon && (\n <span className=\"shrink-0 text-xl\" aria-hidden=\"true\">\n {item.icon}\n </span>\n )}\n <div className=\"min-w-0\">\n <p className=\"font-semibold text-sm\">{item.name}</p>\n {item.description && (\n <p className=\"mt-0.5 text-xs text-muted-foreground line-clamp-2\">\n {item.description}\n </p>\n )}\n {item.tags && item.tags.length > 0 && (\n <div className=\"mt-2 flex flex-wrap gap-1\">\n {item.tags.slice(0, 3).map((tag) => (\n <span\n key={tag}\n className=\"rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n </div>\n\n {item.isCustom && (\n <div ref={menuRef} className=\"relative shrink-0\">\n <button\n type=\"button\"\n onClick={() => setMenuOpen((v) => !v)}\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 opacity-0 group-hover:opacity-100 transition-opacity\"\n aria-label={itemActionsAriaLabel}\n aria-haspopup=\"menu\"\n >\n <MoreVertIcon />\n </button>\n {menuOpen && (\n <div\n role=\"menu\"\n className=\"absolute right-0 top-full z-50 mt-1 min-w-[120px] rounded-md border border-border bg-popover py-1 shadow-md\"\n >\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n onEdit(item);\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n {editItemLabel}\n </button>\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n onDelete(item.id);\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center px-3 py-2 text-sm text-destructive hover:bg-destructive/10\"\n >\n {deleteItemLabel}\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n </div>\n );\n}\n\n// ── Main library component (shared between desktop/mobile) ───────────────────\n\nfunction LibraryContent({\n items,\n isLoading,\n onCreateItem,\n onUpdateItem,\n onDeleteItem,\n tabs,\n tabFilter,\n formFields,\n title,\n createLabel,\n searchPlaceholder,\n emptyMessage,\n nameFieldLabel,\n descriptionFieldLabel,\n namePlaceholder,\n descriptionPlaceholder,\n cancelLabel,\n saveChangesLabel,\n createItemLabel,\n itemActionsAriaLabel,\n editItemLabel,\n deleteItemLabel,\n closeEditorAriaLabel,\n editModalTitle,\n tagListAddPlaceholder,\n removeTagAriaLabel,\n}: MosaicModuleLibraryProps) {\n const [query, setQuery] = React.useState(\"\");\n const [activeTab, setActiveTab] = React.useState(tabs?.[0]?.id ?? \"all\");\n const [editorOpen, setEditorOpen] = React.useState(false);\n const [editingItem, setEditingItem] = React.useState<MosaicModuleItem | undefined>();\n const [editorMode, setEditorMode] = React.useState<\"create\" | \"edit\">(\"create\");\n\n const openCreate = () => {\n setEditingItem(undefined);\n setEditorMode(\"create\");\n setEditorOpen(true);\n };\n\n const openEdit = (item: MosaicModuleItem) => {\n setEditingItem(item);\n setEditorMode(\"edit\");\n setEditorOpen(true);\n };\n\n const handleSave = (data: Omit<MosaicModuleItem, \"id\"> | MosaicModuleItem) => {\n if (editorMode === \"edit\" && \"id\" in data) {\n const { id, ...rest } = data;\n onUpdateItem(id as string, rest);\n } else {\n onCreateItem(data as Omit<MosaicModuleItem, \"id\">);\n }\n setEditorOpen(false);\n };\n\n const filtered = items.filter((item) => {\n const matchesQuery =\n !query ||\n item.name.toLowerCase().includes(query.toLowerCase()) ||\n (item.description ?? \"\").toLowerCase().includes(query.toLowerCase());\n const matchesTab = !tabFilter || tabFilter(item, activeTab);\n return matchesQuery && matchesTab;\n });\n\n return (\n <div data-slot=\"module-library\" className=\"flex h-full flex-col\">\n {/* Header */}\n <div className=\"border-b border-border px-4 py-4 md:px-6\">\n <div className=\"flex items-center justify-between\">\n <h1 className=\"text-lg font-semibold md:text-xl\">{title}</h1>\n <button\n type=\"button\"\n onClick={openCreate}\n className={cn(\n \"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground\",\n \"hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <PlusIcon />\n <span className=\"hidden sm:inline\">{createLabel}</span>\n </button>\n </div>\n\n {/* Search */}\n <div className=\"relative mt-3\">\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={query}\n onChange={(e) => setQuery(e.target.value)}\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\n {/* Tabs */}\n {tabs && tabs.length > 0 && (\n <div className=\"mt-3 flex gap-1\">\n {tabs.map((tab) => (\n <button\n key={tab.id}\n type=\"button\"\n onClick={() => setActiveTab(tab.id)}\n className={cn(\n \"rounded-md px-3 py-1.5 text-sm font-medium transition-colors\",\n activeTab === tab.id\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground\",\n )}\n >\n {tab.label}\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Content */}\n <div className=\"flex-1 overflow-y-auto p-4 md:p-6\">\n {isLoading ? (\n <div className=\"space-y-4\">\n {[0, 1, 2].map((i) => (\n <div key={i} className=\"h-24 animate-pulse rounded-lg bg-muted\" />\n ))}\n </div>\n ) : filtered.length === 0 ? (\n <p className=\"py-12 text-center text-sm text-muted-foreground\">{emptyMessage}</p>\n ) : (\n <div className=\"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3\">\n {filtered.map((item) => (\n <ModuleItemCard\n key={item.id}\n item={item}\n onEdit={openEdit}\n onDelete={onDeleteItem}\n itemActionsAriaLabel={itemActionsAriaLabel}\n editItemLabel={editItemLabel}\n deleteItemLabel={deleteItemLabel}\n />\n ))}\n </div>\n )}\n </div>\n\n {/* Editor modal */}\n <MosaicAdaptiveModal\n isOpen={editorOpen}\n onClose={() => setEditorOpen(false)}\n title={editorMode === \"edit\" ? editModalTitle(editingItem?.name ?? \"\") : createLabel}\n closeAriaLabel={closeEditorAriaLabel}\n >\n <MosaicModuleForm\n item={editingItem}\n formFields={formFields}\n onSave={handleSave}\n onCancel={() => setEditorOpen(false)}\n nameFieldLabel={nameFieldLabel}\n descriptionFieldLabel={descriptionFieldLabel}\n namePlaceholder={namePlaceholder}\n descriptionPlaceholder={descriptionPlaceholder}\n cancelLabel={cancelLabel}\n tagListAddPlaceholder={tagListAddPlaceholder}\n removeTagAriaLabel={removeTagAriaLabel}\n // The library renders the form in BOTH modes, so it legitimately\n // keeps both labels required on its OWN props — and hands the form\n // exactly the one that its mode actually renders.\n {...(editorMode === \"edit\"\n ? ({ mode: \"edit\", saveChangesLabel } as const)\n : ({ mode: \"create\", createItemLabel } as const))}\n />\n </MosaicAdaptiveModal>\n </div>\n );\n}\n\n// ── Orchestrator ──────────────────────────────────────────────────────────────\n\nexport function MosaicModuleLibrary(props: MosaicModuleLibraryProps) {\n return <LibraryContent {...props} />;\n}\n\nMosaicModuleLibrary.displayName = \"MosaicModuleLibrary\";\n"
15
+ }
16
+ ],
17
+ "type": "registry:ui"
18
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-multi-tenant-provider",
4
+ "title": "MosaicMultiTenantProvider",
5
+ "description": "Wraps <ClerkProvider> + cloud-identity workspace-scope context. resolveWorkspaceId prop integrates @vantageos/cloud-identity. Exposes useMosaicWorkspace hook.",
6
+ "dependencies": [
7
+ "@clerk/nextjs",
8
+ "@vantageos/cloud-identity"
9
+ ],
10
+ "registryDependencies": [],
11
+ "files": [
12
+ {
13
+ "path": "src/components/multi-tenant/multi-tenant-provider/MosaicMultiTenantProvider.tsx",
14
+ "type": "registry:ui",
15
+ "content": "\"use client\";\n\n/**\n * MosaicMultiTenantProvider — wraps <ClerkProvider> with cloud-identity\n * workspace-scope context.\n *\n * Clerk and the workspace-id resolver are injected as peer props so\n * mosaic-blocks does not bundle @clerk/nextjs or @vantageos/cloud-identity.\n *\n * @example\n * import { ClerkProvider } from \"@clerk/nextjs\"\n * import { resolveTenantIdOrAbsent } from \"@vantageos/cloud-identity\" // >= 0.6.0\n *\n * // Adapts cloud-identity's typed result to the (orgId) => string | null shape\n * // of the `resolveWorkspaceId` prop. cloud-identity names this \"tenant\".\n * const resolveWorkspaceId = (orgId: string | null) => {\n * const r = resolveTenantIdOrAbsent({ kind: \"session\", identity: { orgId } })\n * return r.present ? r.tenantId : null\n * }\n *\n * <MosaicMultiTenantProvider\n * clerkProvider={ClerkProvider}\n * publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}\n * resolveWorkspaceId={resolveWorkspaceId}\n * >\n * {children}\n * </MosaicMultiTenantProvider>\n */\n\nimport * as React from \"react\";\n\n// ── Context ───────────────────────────────────────────────────────────────────\n\nexport interface MosaicWorkspaceContext {\n workspaceId: string | null;\n isLoading: boolean;\n}\n\nconst WorkspaceCtx = React.createContext<MosaicWorkspaceContext>({\n workspaceId: null,\n isLoading: false,\n});\n\n/** Access the resolved workspace ID from any child component. */\nexport function useMosaicWorkspace(): MosaicWorkspaceContext {\n return React.useContext(WorkspaceCtx);\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicMultiTenantProviderProps {\n children: React.ReactNode;\n /** Clerk <ClerkProvider> component — injected by caller */\n clerkProvider: React.ComponentType<{\n publishableKey?: string;\n appearance?: Record<string, unknown>;\n children?: React.ReactNode;\n [key: string]: unknown;\n }>;\n /** Clerk publishable key */\n publishableKey?: string;\n /**\n * Optional workspace-ID resolver, typically built on\n * `resolveTenantIdOrAbsent` from @vantageos/cloud-identity (see the example\n * above). cloud-identity exports no function of this exact shape.\n * Called with the current Clerk org ID (or null for personal workspace).\n * Defaults to identity pass-through when not provided.\n */\n resolveWorkspaceId?: (orgId: string | null) => Promise<string | null> | string | null;\n /** Initial org ID hint (e.g. from URL slug) */\n initialOrgId?: string | null;\n /** Clerk appearance override */\n appearance?: Record<string, unknown>;\n}\n\n// ── Default OKLCH Clerk appearance ────────────────────────────────────────────\n\nconst defaultClerkAppearance = {\n variables: {\n colorPrimary: \"var(--primary)\",\n colorBackground: \"var(--background)\",\n colorText: \"var(--foreground)\",\n colorTextSecondary: \"var(--muted-foreground)\",\n colorNeutral: \"var(--foreground)\",\n borderRadius: \"0.5rem\",\n },\n};\n\n// ── Inner workspace resolver ──────────────────────────────────────────────────\n\ninterface WorkspaceResolverProps {\n resolveWorkspaceId: MosaicMultiTenantProviderProps[\"resolveWorkspaceId\"];\n initialOrgId: string | null | undefined;\n children: React.ReactNode;\n}\n\nfunction WorkspaceResolver({ resolveWorkspaceId, initialOrgId, children }: WorkspaceResolverProps) {\n const [workspaceId, setWorkspaceId] = React.useState<string | null>(null);\n const [isLoading, setIsLoading] = React.useState<boolean>(false);\n\n React.useEffect(() => {\n if (!resolveWorkspaceId) {\n setWorkspaceId(initialOrgId ?? null);\n return;\n }\n let cancelled = false;\n setIsLoading(true);\n const result = resolveWorkspaceId(initialOrgId ?? null);\n if (result instanceof Promise) {\n result\n .then((id) => {\n if (!cancelled) {\n setWorkspaceId(id);\n setIsLoading(false);\n }\n })\n .catch(() => {\n if (!cancelled) {\n setWorkspaceId(null);\n setIsLoading(false);\n }\n });\n } else {\n setWorkspaceId(result);\n setIsLoading(false);\n }\n return () => {\n cancelled = true;\n };\n }, [resolveWorkspaceId, initialOrgId]);\n\n return (\n <WorkspaceCtx.Provider value={{ workspaceId, isLoading }}>{children}</WorkspaceCtx.Provider>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicMultiTenantProvider({\n children,\n clerkProvider: ClerkProvider,\n publishableKey,\n resolveWorkspaceId,\n initialOrgId,\n appearance,\n}: MosaicMultiTenantProviderProps) {\n const mergedAppearance = appearance ?? defaultClerkAppearance;\n\n return (\n <ClerkProvider publishableKey={publishableKey} appearance={mergedAppearance}>\n <WorkspaceResolver resolveWorkspaceId={resolveWorkspaceId} initialOrgId={initialOrgId}>\n <div data-slot=\"multi-tenant-provider\">{children}</div>\n </WorkspaceResolver>\n </ClerkProvider>\n );\n}\n\nMosaicMultiTenantProvider.displayName = \"MosaicMultiTenantProvider\";\n"
16
+ }
17
+ ],
18
+ "type": "registry:ui"
19
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "mosaic-navbar",
4
+ "title": "MosaicNavbar",
5
+ "description": "Scroll-aware fixed navbar: hide-on-scroll-down, blur backdrop, mobile hamburger menu. Props: logo, links[], cta. No hardcoded branding.",
6
+ "dependencies": [],
7
+ "registryDependencies": [],
8
+ "files": [
9
+ {
10
+ "path": "src/components/navbar/MosaicNavbar.tsx",
11
+ "type": "registry:ui",
12
+ "content": "\"use client\";\n\n/**\n * MosaicNavbar — scroll-aware fixed navbar\n *\n * Ported from heyfabrika/styleui components/templates/axis/navbar.tsx (MIT).\n * Adapted: props-driven (no hardcoded links/logo/cta), no next/router dependency,\n * motion/react replaced with CSS transitions for bundle budget.\n * Scroll hide-on-scroll-down via native scroll listener.\n */\n\nimport * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface NavLink {\n label: string;\n href: string;\n}\n\nexport interface NavCta {\n label: string;\n href: string;\n}\n\nexport interface MosaicNavbarProps {\n /** Logo node (image, svg, or text). All branding via this prop. */\n logo: React.ReactNode;\n /** Navigation links */\n links: NavLink[];\n /** Optional CTA button */\n cta?: NavCta;\n /**\n * aria-label for the root `<nav>` element. Required — the host owns the\n * language (e.g. `t('Navbar.aria.main')`). No default, no fallback.\n */\n navAriaLabel: string;\n /**\n * aria-label for the hamburger button when the mobile menu is closed.\n * Required — host-provided, no default.\n */\n openMenuAriaLabel: string;\n /**\n * aria-label for the hamburger button when the mobile menu is open.\n * Required — host-provided, no default.\n */\n closeMenuAriaLabel: string;\n className?: string;\n ref?: React.Ref<HTMLElement>;\n}\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicNavbar — fixed top navbar with scroll-aware hide-on-scroll-down and\n * blur backdrop on scroll. Mobile menu included. All content via props.\n *\n * @example\n * // Host owns i18n (e.g. next-intl) — labels are always required props.\n * <MosaicNavbar\n * logo={<img src=\"/logo.svg\" alt=\"Brand\" className=\"h-8 w-auto\" />}\n * links={[{ label: \"Features\", href: \"#features\" }, { label: \"Pricing\", href: \"#pricing\" }]}\n * cta={{ label: \"Get started\", href: \"#start\" }}\n * navAriaLabel={t('Navbar.aria.main')}\n * openMenuAriaLabel={t('Navbar.aria.openMenu')}\n * closeMenuAriaLabel={t('Navbar.aria.closeMenu')}\n * />\n */\nexport function MosaicNavbar({\n logo,\n links,\n cta,\n navAriaLabel,\n openMenuAriaLabel,\n closeMenuAriaLabel,\n className,\n ref,\n}: MosaicNavbarProps) {\n const [isScrolled, setIsScrolled] = React.useState(false);\n const [isHidden, setIsHidden] = React.useState(false);\n const [isOpen, setIsOpen] = React.useState(false);\n const lastScrollY = React.useRef(0);\n\n React.useEffect(() => {\n const handleScroll = () => {\n const current = window.scrollY;\n setIsScrolled(current > 50);\n if (current > lastScrollY.current && current > 150) {\n setIsHidden(true);\n setIsOpen(false);\n } else {\n setIsHidden(false);\n }\n lastScrollY.current = current;\n };\n\n window.addEventListener(\"scroll\", handleScroll, { passive: true });\n return () => window.removeEventListener(\"scroll\", handleScroll);\n }, []);\n\n React.useEffect(() => {\n document.body.style.overflow = isOpen ? \"hidden\" : \"\";\n return () => {\n document.body.style.overflow = \"\";\n };\n }, [isOpen]);\n\n return (\n <nav\n ref={ref}\n aria-label={navAriaLabel}\n className={cn(\n \"fixed left-0 right-0 top-0 z-50 px-4 pt-4 mx-auto w-full max-w-6xl transition-all duration-300 ease-out\",\n isHidden ? \"opacity-0 -translate-y-5 pointer-events-none\" : \"opacity-100 translate-y-0\",\n className,\n )}\n >\n <div\n className={cn(\n \"relative mx-auto transition-transform duration-200\",\n isScrolled ? \"scale-[0.98]\" : \"scale-100\",\n )}\n >\n <div\n className={cn(\n \"flex flex-row items-center justify-between gap-4 rounded-full border border-[oklch(0.9_0.005_250)] p-2 transition-all duration-300\",\n isScrolled\n ? \"bg-[oklch(1_0_0_/_0.8)] backdrop-blur-[12px] shadow-[0_4px_20px_-5px_oklch(0_0_0_/_0.1)]\"\n : \"bg-[oklch(1_0_0)]\",\n )}\n >\n {/* Logo */}\n <div className=\"ml-2 flex items-center\">{logo}</div>\n\n {/* Desktop links */}\n <div className=\"hidden flex-row items-center gap-4 lg:flex\">\n <div className=\"flex flex-row gap-8\">\n {links.map((link) => (\n <a\n key={link.href}\n href={link.href}\n className=\"flex flex-row items-center gap-1 font-medium transition-colors hover:text-[oklch(0.6_0.01_250)]\"\n >\n {link.label}\n </a>\n ))}\n </div>\n {cta && (\n <a\n href={cta.href}\n className=\"inline-flex items-center justify-center rounded-full bg-[oklch(0.15_0.01_250)] px-5 py-2 text-sm font-medium text-[oklch(0.98_0_0)] transition-colors hover:bg-[oklch(0.25_0.01_250)]\"\n >\n {cta.label}\n </a>\n )}\n </div>\n\n {/* Mobile: cta + hamburger */}\n <div className=\"flex flex-row items-center gap-2 lg:hidden\">\n {cta && (\n <a\n href={cta.href}\n className=\"inline-flex items-center justify-center rounded-full bg-[oklch(0.15_0.01_250)] px-4 py-1.5 text-sm font-medium text-[oklch(0.98_0_0)] transition-colors\"\n >\n {cta.label}\n </a>\n )}\n <button\n type=\"button\"\n aria-label={isOpen ? closeMenuAriaLabel : openMenuAriaLabel}\n aria-expanded={isOpen}\n aria-controls=\"mosaic-mobile-menu\"\n onClick={() => setIsOpen((v) => !v)}\n className=\"inline-flex size-9 items-center justify-center rounded-full transition-colors hover:bg-[oklch(0.95_0.005_250)]\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"20\"\n height=\"20\"\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 {isOpen ? (\n <>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </>\n ) : (\n <>\n <line x1=\"4\" y1=\"8\" x2=\"20\" y2=\"8\" />\n <line x1=\"4\" y1=\"16\" x2=\"20\" y2=\"16\" />\n </>\n )}\n </svg>\n </button>\n </div>\n </div>\n\n {/* Mobile dropdown */}\n {isOpen && (\n <div\n id=\"mosaic-mobile-menu\"\n className=\"absolute left-0 right-0 top-full z-50 mt-2 overflow-hidden lg:hidden\"\n >\n <div className=\"flex flex-col gap-2 rounded-2xl border border-[oklch(0.9_0.005_250)] bg-[oklch(1_0_0_/_0.95)] p-4 backdrop-blur-xl\">\n {links.map((link) => (\n <a\n key={link.href}\n href={link.href}\n onClick={() => setIsOpen(false)}\n className=\"flex flex-row items-center justify-between rounded-lg px-4 py-3 font-medium transition-colors hover:bg-[oklch(0.96_0.005_250)]\"\n >\n {link.label}\n </a>\n ))}\n </div>\n </div>\n )}\n </div>\n </nav>\n );\n}\n\nMosaicNavbar.displayName = \"MosaicNavbar\";\n"
13
+ }
14
+ ],
15
+ "type": "registry:ui"
16
+ }