@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.
- package/README.md +9 -8
- package/dist/index.cjs +338 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +231 -11
- package/dist/index.d.ts +231 -11
- package/dist/index.js +328 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +12 -7
- package/r/mosaic-accordion.json +1 -2
- package/r/mosaic-activity-feed.json +16 -0
- package/r/mosaic-adaptive-grid.json +18 -0
- package/r/mosaic-adaptive-modal.json +18 -0
- package/r/mosaic-adaptive-navigation.json +18 -0
- package/r/mosaic-add-memory-form.json +25 -0
- package/r/mosaic-admin-only-guard.json +18 -0
- package/r/mosaic-agent-builder-modal.json +23 -0
- package/r/mosaic-agent-card.json +16 -0
- package/r/mosaic-agent-chat.json +26 -0
- package/r/mosaic-agent-composer.json +28 -0
- package/r/mosaic-agent-editor.json +25 -0
- package/r/mosaic-agent-list.json +21 -0
- package/r/mosaic-agent-preview.json +21 -0
- package/r/mosaic-alert-dialog.json +23 -0
- package/r/mosaic-animated-list.json +16 -0
- package/r/mosaic-api-key-panel.json +21 -0
- package/r/mosaic-app-sidebar.json +18 -0
- package/r/mosaic-approval-prompt.json +21 -0
- package/r/mosaic-artifact-canvas-adapter.json +26 -0
- package/r/mosaic-artifact-chart.json +18 -0
- package/r/mosaic-artifact-checklist.json +18 -0
- package/r/mosaic-artifact-data-table.json +18 -0
- package/r/mosaic-artifact-document.json +16 -0
- package/r/mosaic-artifact-library.json +18 -0
- package/r/mosaic-artifact-save-as-memory-form.json +24 -0
- package/r/mosaic-artifact-version-history.json +16 -0
- package/r/mosaic-avatar.json +18 -0
- package/r/mosaic-badge.json +23 -0
- package/r/mosaic-blurred-orb.json +16 -0
- package/r/mosaic-button.json +24 -0
- package/r/mosaic-callout.json +23 -0
- package/r/mosaic-card.json +16 -0
- package/r/mosaic-chat-composer.json +21 -0
- package/r/mosaic-chat-message.json +23 -0
- package/r/mosaic-chat-sidebar.json +21 -0
- package/r/mosaic-chat-thread.json +21 -0
- package/r/mosaic-checkbox.json +18 -0
- package/r/mosaic-clerk-org-switcher.json +18 -0
- package/r/mosaic-clerk-webhook-handler.json +18 -0
- package/r/mosaic-collapsible.json +18 -0
- package/r/mosaic-combobox.json +18 -0
- package/r/mosaic-counter.json +16 -0
- package/r/mosaic-dashboard-content.json +18 -0
- package/r/mosaic-dashboard-header.json +18 -0
- package/r/mosaic-dashboard-layout.json +20 -0
- package/r/mosaic-data-table.json +16 -0
- package/r/mosaic-delete-confirmation-dialog.json +18 -0
- package/r/mosaic-device-provider.json +16 -0
- package/r/mosaic-document-table.json +52 -0
- package/r/mosaic-document-upload.json +21 -0
- package/r/mosaic-drawer.json +23 -0
- package/r/mosaic-dropdown-menu.json +18 -0
- package/r/mosaic-edit-memory-dialog.json +27 -0
- package/r/mosaic-edit-session-dialog.json +25 -0
- package/r/mosaic-editable-cell.json +23 -0
- package/r/mosaic-empty-state.json +16 -0
- package/r/mosaic-falling-pattern.json +16 -0
- package/r/mosaic-feature-3col.json +16 -0
- package/r/mosaic-feature-centered-media.json +16 -0
- package/r/mosaic-field.json +18 -0
- package/r/mosaic-filter-bar.json +18 -0
- package/r/mosaic-filter-sidebar.json +18 -0
- package/r/mosaic-footer-simple.json +16 -0
- package/r/mosaic-hero-split.json +16 -0
- package/r/mosaic-input-group.json +16 -0
- package/r/mosaic-input.json +18 -0
- package/r/mosaic-integrations-badge.json +16 -0
- package/r/mosaic-kanban-board.json +21 -0
- package/r/mosaic-logos-grid.json +16 -0
- package/r/mosaic-main-nav.json +18 -0
- package/r/mosaic-markdown.json +21 -0
- package/r/mosaic-marketplace-card.json +24 -0
- package/r/mosaic-marketplace-list.json +20 -0
- package/r/mosaic-match-input.json +23 -0
- package/r/mosaic-memory-card.json +21 -0
- package/r/mosaic-memory-dashboard.json +23 -0
- package/r/mosaic-memory-grid.json +21 -0
- package/r/mosaic-memory-list.json +21 -0
- package/r/mosaic-memory-search.json +23 -0
- package/r/mosaic-mention-input.json +23 -0
- package/r/mosaic-message-card.json +16 -0
- package/r/mosaic-message-list.json +19 -0
- package/r/mosaic-message-search.json +18 -0
- package/r/mosaic-model-selector.json +23 -0
- package/r/mosaic-module-card.json +16 -0
- package/r/mosaic-module-library.json +18 -0
- package/r/mosaic-multi-tenant-provider.json +19 -0
- package/r/mosaic-navbar.json +16 -0
- package/r/mosaic-org-context-display.json +18 -0
- package/r/mosaic-org-panel.json +19 -0
- package/r/mosaic-org-profile-page.json +18 -0
- package/r/mosaic-org-switcher.json +16 -0
- package/r/mosaic-pdf-viewer.json +23 -0
- package/r/mosaic-popover.json +23 -0
- package/r/mosaic-preferences-panel.json +18 -0
- package/r/mosaic-pricing-card.json +16 -0
- package/r/mosaic-profile-panel.json +18 -0
- package/r/mosaic-progress.json +18 -0
- package/r/mosaic-quick-action-card.json +16 -0
- package/r/mosaic-quick-actions-menu.json +18 -0
- package/r/mosaic-quick-agent-selector.json +19 -0
- package/r/mosaic-radio-group.json +18 -0
- package/r/mosaic-reply-input.json +21 -0
- package/r/mosaic-resizable-split-pane.json +23 -0
- package/r/mosaic-save-chat-as-memory-form.json +25 -0
- package/r/mosaic-save-template-modal.json +27 -0
- package/r/mosaic-scroll-area.json +18 -0
- package/r/mosaic-select.json +18 -0
- package/r/mosaic-selector-modal.json +18 -0
- package/r/mosaic-separator.json +18 -0
- package/r/mosaic-session-card.json +24 -0
- package/r/mosaic-session-list.json +21 -0
- package/r/mosaic-sign-in-layout.json +18 -0
- package/r/mosaic-sign-up-layout.json +18 -0
- package/r/mosaic-skeleton.json +23 -0
- package/r/mosaic-slider.json +18 -0
- package/r/mosaic-stats-grid.json +16 -0
- package/r/mosaic-step-pipeline.json +21 -0
- package/r/mosaic-switch.json +18 -0
- package/r/mosaic-tabs.json +18 -0
- package/r/mosaic-tag-input.json +23 -0
- package/r/mosaic-template-agent-card.json +21 -0
- package/r/mosaic-template-category-chips.json +21 -0
- package/r/mosaic-template-gallery.json +20 -0
- package/r/mosaic-template-list.json +21 -0
- package/r/mosaic-template-management-panel.json +25 -0
- package/r/mosaic-testimonials-grid.json +16 -0
- package/r/mosaic-textarea.json +16 -0
- package/r/mosaic-theme-provider.json +18 -0
- package/r/mosaic-theme-toggle.json +16 -0
- package/r/mosaic-thread-indicator.json +21 -0
- package/r/mosaic-thread-view.json +21 -0
- package/r/mosaic-toast.json +28 -0
- package/r/mosaic-tool-toggle-list.json +23 -0
- package/r/mosaic-tooltip.json +18 -0
- package/r/mosaic-url-scraper.json +21 -0
- package/r/mosaic-user-button.json +18 -0
- package/r/use-effective-workspace-id.json +18 -0
- package/registry.json +35 -130
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-thread-indicator",
|
|
4
|
+
"title": "MosaicThreadIndicator",
|
|
5
|
+
"description": "MosaicThreadIndicator — signals a thread has UNREAD replies",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/thread-indicator/MosaicThreadIndicator.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicThreadIndicator — signals a thread has UNREAD replies\n *\n * Presentational atom. Without it a thread with new agent replies is\n * invisible from the surrounding flow — this renders the trigger that makes\n * that state legible and clickable.\n *\n * The unread count is NEVER typed by the library: it is DERIVED, on every\n * render, from the host-supplied `replies` array (`replies.filter((r) =>\n * r.unread).length`). Mutating the array mutates what is shown — the\n * component holds no count state of its own. When the derived count is zero\n * (including an empty `replies` array), the count pill does not render at\n * all: that is a named absence-of-state, not a library-authored \"0\" or word.\n *\n * Pattern: MosaicReplyInput.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --accent, --accent-foreground, --ring, --primary,\n * --primary-foreground.\n * a11y: the trigger is a native `<button>`; its accessible name is computed\n * by the host-supplied `ariaLabel(count)` from the same derived count shown\n * visually — assistive technology and sighted users read the same number.\n * Bilingual: `label` and `ariaLabel` are required caller-supplied props —\n * zero hardcoded copy, zero default. The library owns no word for \"unread\",\n * \"replies\", or the zero-state; the host's `ariaLabel` formatter carries all\n * of that wording.\n *\n * @example\n * <MosaicThreadIndicator\n * replies={thread.replies}\n * label=\"Thread\"\n * ariaLabel={(count) => `Thread, ${count} unread replies`}\n * onActivate={() => openThread(thread.id)}\n * />\n */\n\nimport type * as React from \"react\";\nimport {\n threadIndicatorCountVariants,\n threadIndicatorRootVariants,\n} from \"./thread-indicator-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/** Minimal host-supplied reply-status shape the unread count is derived from. */\nexport type MosaicThreadIndicatorReplyStatus = {\n /** Stable identity for the reply. */\n id: string;\n /** Whether this specific reply is unread, per the host's own state. */\n unread: boolean;\n};\n\nexport type MosaicThreadIndicatorProps = {\n /**\n * Host-supplied replies for this thread. The rendered unread count is\n * DERIVED from this array (`replies.filter((r) => r.unread).length`) —\n * the library never receives or stores a pre-computed count.\n */\n replies: MosaicThreadIndicatorReplyStatus[];\n /** Visible label for the trigger (e.g. \"Thread\"). Required, no default. */\n label: string;\n /**\n * Accessible-name formatter, called with the derived unread count.\n * Required — the host owns pluralization/wording, the library owns none.\n */\n ariaLabel: (unreadCount: number) => string;\n /** Called when the trigger is activated (click). */\n onActivate: () => void;\n /** Disables the trigger (e.g. host-level connectivity loss). */\n disabled?: boolean;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLButtonElement>;\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicThreadIndicator — production unread-thread-indicator atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: derives an unread count from host-supplied data and\n * renders a labelled, clickable trigger. No network call, no stored count.\n */\nexport function MosaicThreadIndicator(props: MosaicThreadIndicatorProps) {\n const { replies, label, ariaLabel, onActivate, disabled = false, className, ref } = props;\n\n const unreadCount = replies.filter((reply) => reply.unread).length;\n\n return (\n <button\n ref={ref}\n data-slot=\"thread-indicator\"\n type=\"button\"\n aria-label={ariaLabel(unreadCount)}\n className={cn(threadIndicatorRootVariants(), className)}\n disabled={disabled}\n onClick={onActivate}\n >\n <span data-slot=\"thread-indicator-label\">{label}</span>\n {unreadCount > 0 && (\n <span\n data-slot=\"thread-indicator-count\"\n data-testid=\"thread-indicator-count\"\n className={threadIndicatorCountVariants()}\n >\n {unreadCount}\n </span>\n )}\n </button>\n );\n}\n\nMosaicThreadIndicator.displayName = \"MosaicThreadIndicator\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/thread-indicator/thread-indicator-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * threadIndicatorVariants — pure CVA variant functions for MosaicThreadIndicator.\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 button/trigger for the thread indicator. */\nexport const threadIndicatorRootVariants = cva([\n \"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n \"disabled:cursor-not-allowed disabled:opacity-60\",\n]);\n\n/** Unread-count pill, shown only when the derived unread count is greater than zero. */\nexport const threadIndicatorCountVariants = cva([\n \"inline-flex min-w-4 items-center justify-center rounded-full px-1.5 py-0.5\",\n \"bg-primary text-primary-foreground text-[10px] font-semibold leading-none\",\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-thread-view",
|
|
4
|
+
"title": "MosaicThreadView",
|
|
5
|
+
"description": "MosaicThreadView — one client request, several agents replying beneath it",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/thread-view/MosaicThreadView.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicThreadView — one client request, several agents replying beneath it\n *\n * Presentational atom. Makes agent collaboration readable: renders a single\n * root message, then every host-supplied reply nested beneath it, in\n * document order, inside its own labelled region — distinguishing \"the\n * question\" from \"the agents answering it\" for assistive technology and\n * sighted users alike.\n *\n * The root message and every reply's author/content are host-supplied\n * `React.ReactNode`s (`root.author`, `root.content`, `replies[].author`,\n * `replies[].content`): the library never invents sender names, avatars, or\n * message copy. Zero I/O, zero fetch, zero server-side filtering — the\n * thread data is fully host-supplied and host-controlled.\n *\n * Pattern: MosaicReplyInput.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --card, --muted, --muted-foreground.\n * a11y: the root message and the replies list are each their own labelled\n * region (`rootAriaLabel`, `repliesAriaLabel`), required props with no\n * default, so assistive technology can navigate directly to either.\n * Bilingual: `rootAriaLabel`, `repliesAriaLabel` and `emptyRepliesLabel` are\n * required caller-supplied strings — zero hardcoded copy, zero default. An\n * empty `replies` array is a named, host-worded state (`emptyRepliesLabel`);\n * the library invents no \"No replies yet\" text of its own.\n *\n * @example\n * <MosaicThreadView\n * root={{ id: root.id, author: <SenderName sender={root.sender} />, content: <p>{root.text}</p> }}\n * replies={replies.map((r) => ({\n * id: r.id,\n * author: <SenderName sender={r.sender} />,\n * content: <p>{r.text}</p>,\n * }))}\n * rootAriaLabel=\"Original request\"\n * repliesAriaLabel=\"Agent replies\"\n * emptyRepliesLabel=\"No replies yet\"\n * />\n */\n\nimport type * as React from \"react\";\nimport {\n threadViewEmptyVariants,\n threadViewRepliesVariants,\n threadViewReplyVariants,\n threadViewRootMessageVariants,\n threadViewRootVariants,\n} from \"./thread-view-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/** Host-supplied message entry — author and content are fully host-owned nodes. */\nexport type MosaicThreadViewMessage = {\n /** Stable identity for the message (used as list key for replies). */\n id: string;\n /** Host-supplied node rendering the sender (name, avatar, badge, ...). */\n author: React.ReactNode;\n /** Host-supplied node rendering the message body. */\n content: React.ReactNode;\n};\n\nexport type MosaicThreadViewProps = {\n /** The single client request every reply is nested beneath. */\n root: MosaicThreadViewMessage;\n /** Every agent reply, nested beneath the root, rendered in array order. */\n replies: MosaicThreadViewMessage[];\n /** Accessible name for the root-message region. Required, no default. */\n rootAriaLabel: string;\n /** Accessible name for the nested-replies region. Required, no default. */\n repliesAriaLabel: string;\n /**\n * Host-worded text shown when `replies` is empty. Required — this is a\n * named absence-of-state, and the library carries no fallback word of its\n * own for \"no replies yet\".\n */\n emptyRepliesLabel: 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// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicThreadView — production thread-view atom for @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders one root message and every host-supplied\n * reply nested beneath it inside a distinct labelled region. No network\n * call, no message state, no invented copy.\n */\nexport function MosaicThreadView(props: MosaicThreadViewProps) {\n const { root, replies, rootAriaLabel, repliesAriaLabel, emptyRepliesLabel, className, ref } =\n props;\n\n return (\n <div ref={ref} data-slot=\"thread-view\" className={cn(threadViewRootVariants(), className)}>\n <div\n aria-label={rootAriaLabel}\n className={threadViewRootMessageVariants()}\n data-slot=\"thread-view-root\"\n >\n {root.author}\n {root.content}\n </div>\n <div\n aria-label={repliesAriaLabel}\n className={threadViewRepliesVariants()}\n data-slot=\"thread-view-replies\"\n >\n {replies.length === 0 ? (\n <p className={threadViewEmptyVariants()} data-slot=\"thread-view-empty\">\n {emptyRepliesLabel}\n </p>\n ) : (\n replies.map((reply) => (\n <div className={threadViewReplyVariants()} data-slot=\"thread-view-reply\" key={reply.id}>\n {reply.author}\n {reply.content}\n </div>\n ))\n )}\n </div>\n </div>\n );\n}\n\nMosaicThreadView.displayName = \"MosaicThreadView\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/thread-view/thread-view-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * threadViewVariants — pure CVA variant functions for MosaicThreadView.\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 container for the whole thread (root message + nested replies). */\nexport const threadViewRootVariants = cva([\"flex min-w-0 flex-col gap-3\"]);\n\n/** Root-message region. */\nexport const threadViewRootMessageVariants = cva([\n \"rounded-lg border border-border bg-card p-4 shadow-sm\",\n]);\n\n/** Nested-replies list region. */\nexport const threadViewRepliesVariants = cva([\"flex flex-col gap-2 border-border border-l-2 pl-4\"]);\n\n/** A single nested reply entry. */\nexport const threadViewReplyVariants = cva([\n \"rounded-lg border border-border bg-muted/40 p-3 text-sm\",\n]);\n\n/** Named empty-state paragraph, shown only when the host has zero replies to show. */\nexport const threadViewEmptyVariants = cva([\"px-1 py-2 text-muted-foreground text-sm\"]);\n"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"type": "registry:ui"
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-toast",
|
|
4
|
+
"title": "MosaicToast",
|
|
5
|
+
"description": "Presentational ephemeral notification (success/error/info/warning), optional auto-dismiss via durationMs, host-controlled action node. Paired with MosaicToastProvider for stack positioning (top-right/top-center/bottom-right/bottom-center). No toast queue/runtime — the host owns the visible stack.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/toast/MosaicToast.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicToast — presentational ephemeral notification\n *\n * Presentational atom. Displays a short-lived status message (success /\n * error / info / warning) with an optional description, an optional\n * host-rendered action, and a required dismiss control. The component\n * performs no network call and owns no SDK / toast-stacking runtime:\n * dismissal is surfaced purely via the `onDismiss()` callback — the host\n * (typically paired with `MosaicToastProvider`) owns the actual queue of\n * visible toasts, their insertion order, and any exit animation.\n *\n * Auto-dismiss is opt-in via `durationMs`: when provided, the component\n * starts a single `setTimeout` on mount and calls `onDismiss()` once it\n * elapses (cleared on unmount / prop change). When `durationMs` is\n * omitted, the toast never dismisses itself — the host's dismiss button\n * (or its own external logic) is the only path to `onDismiss()`.\n *\n * Pattern: MosaicApprovalPrompt.tsx (data-slot, inline cn, React 19 ref\n * prop, displayName, JSDoc, pure variants module).\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist; the\n * `useEffect` timer below requires the client runtime at use-time.\n * Design tokens: --foreground, --muted-foreground, --border,\n * --destructive, --card, --accent, --background (amber-* utility classes\n * for the \"warning\" variant, consistent with Tailwind's built-in palette).\n * a11y: the root carries `role=\"alert\"` for the \"error\" variant (the only\n * variant that represents an unrecoverable failure worth interrupting the\n * screen-reader user for) and `role=\"status\"` for every other variant —\n * both roles are implicitly live regions, so no extra `aria-live` is\n * needed. The dismiss button's accessible name IS the required\n * `dismissAriaLabel` prop — zero hardcoded copy, zero default.\n * Bilingual: every user-facing string (`title`/`description`/\n * `dismissAriaLabel`) is a required-or-explicit caller-supplied prop —\n * the library never generates its own copy.\n *\n * @example\n * <MosaicToast\n * variant=\"success\"\n * title=\"Modifications enregistrées\"\n * description=\"Vos changements ont été appliqués.\"\n * onDismiss={() => removeToast(id)}\n * dismissAriaLabel=\"Fermer la notification\"\n * durationMs={5000}\n * />\n */\n\nimport type * as React from \"react\";\nimport { useEffect } from \"react\";\nimport {\n toastCardVariants,\n toastDismissButtonVariants,\n toastTitleVariants,\n} from \"./toast-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/** Visual + semantic tone of the toast. Drives styling AND the a11y role. */\nexport type MosaicToastVariant = \"success\" | \"error\" | \"info\" | \"warning\";\n\nexport interface MosaicToastProps {\n /** Visual + semantic tone. Drives the a11y role (\"alert\" for \"error\", \"status\" otherwise). */\n variant: MosaicToastVariant;\n /** Toast headline. Required, no default — the library never generates its own copy. */\n title: string;\n /** Optional supporting detail rendered below the title. */\n description?: string;\n /** Host-rendered action region (e.g. an \"Undo\" button). The library never decides its shape. */\n action?: React.ReactNode;\n /** Called when the toast is dismissed — by the dismiss button OR the `durationMs` timer. */\n onDismiss: () => void;\n /** Accessible name of the dismiss button. Required, no default. */\n dismissAriaLabel: string;\n /** When set, the toast auto-dismisses (`onDismiss()`) after this many milliseconds. */\n durationMs?: number;\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// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicToast — production ephemeral-notification atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders variant + title + optional description +\n * optional host-rendered action + a required dismiss control, and reports\n * dismissal via `onDismiss()`. No network call, no SDK, no built-in copy,\n * no toast queue / stacking logic (that is `MosaicToastProvider`'s job, or\n * the host's).\n */\nexport function MosaicToast({\n variant,\n title,\n description,\n action,\n onDismiss,\n dismissAriaLabel,\n durationMs,\n className,\n ref,\n}: MosaicToastProps) {\n useEffect(() => {\n if (durationMs === undefined) return;\n const timer = setTimeout(onDismiss, durationMs);\n return () => clearTimeout(timer);\n }, [durationMs, onDismiss]);\n\n const role = variant === \"error\" ? \"alert\" : \"status\";\n\n return (\n <div\n ref={ref}\n data-slot=\"toast\"\n role={role}\n className={cn(toastCardVariants({ variant }), className)}\n >\n <div data-slot=\"toast-body\" className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <p data-slot=\"toast-title\" className={toastTitleVariants({ variant })}>\n {title}\n </p>\n {description !== undefined && (\n <p data-slot=\"toast-description\" className=\"text-sm text-muted-foreground\">\n {description}\n </p>\n )}\n {action !== undefined && <div data-slot=\"toast-action\">{action}</div>}\n </div>\n <button\n type=\"button\"\n data-slot=\"toast-dismiss-button\"\n onClick={onDismiss}\n aria-label={dismissAriaLabel}\n className={toastDismissButtonVariants()}\n >\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n width=\"16\"\n height=\"16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n </div>\n );\n}\n\nMosaicToast.displayName = \"MosaicToast\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/toast/MosaicToastProvider.tsx",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * MosaicToastProvider — presentational fixed-position toast stack container\n *\n * Presentational atom. Anchors a vertical stack of `MosaicToast` elements to\n * one screen corner/edge and stacks them with a fixed gap. It owns no state\n * and no queue: the host renders whichever `MosaicToast` elements are\n * currently visible as `children`, in the order it wants them stacked — this\n * component only positions the resulting stack on screen.\n *\n * Autonomous: does NOT depend on `MosaicToast` itself — any content can be\n * passed as `children`, mirroring the rest of the library's host-controlled\n * composition pattern.\n *\n * Pattern: MosaicApprovalPrompt.tsx (data-slot, inline cn, React 19 ref\n * prop, displayName, JSDoc, pure variants module).\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist.\n * Design tokens: none directly (the stack itself is unstyled beyond\n * position/spacing) — visual tokens live on the `MosaicToast` children.\n * a11y: the container is `pointer-events-none` so it never intercepts\n * clicks meant for content underneath; each toast re-enables pointer events\n * on itself (native `<button>`/interactive elements are always clickable\n * regardless of an ancestor's `pointer-events: none`... in practice hosts\n * commonly leave toasts non-interactive except for the dismiss button,\n * which still receives events because `pointer-events` do not cascade to\n * elements given their own explicit `pointer-events: auto`; MosaicToast\n * does not set that here, so a host embedding interactive `action` nodes\n * should override `className` on `MosaicToastProvider` if needed).\n * Bilingual: no user-facing copy — the container renders no text of its own.\n */\n\nimport type * as React from \"react\";\nimport { toastProviderPositionVariants } from \"./toast-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/** Screen anchor for the toast stack. */\nexport type MosaicToastProviderPosition =\n | \"top-right\"\n | \"top-center\"\n | \"bottom-right\"\n | \"bottom-center\";\n\nexport interface MosaicToastProviderProps {\n /** The currently visible toasts, host-ordered. */\n children: React.ReactNode;\n /** Screen anchor for the stack. Defaults to \"top-right\" (a layout default, not visible copy). */\n position?: MosaicToastProviderPosition;\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// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicToastProvider — production toast-stack positioning atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: fixes `children` to one screen corner/edge and\n * stacks them with a gap. No state, no queue, no timers — those live on\n * each `MosaicToast` child (`durationMs`) or on the host.\n */\nexport function MosaicToastProvider({\n children,\n position = \"top-right\",\n className,\n ref,\n}: MosaicToastProviderProps) {\n return (\n <div\n ref={ref}\n data-slot=\"toast-provider\"\n className={cn(toastProviderPositionVariants({ position }), className)}\n >\n {children}\n </div>\n );\n}\n\nMosaicToastProvider.displayName = \"MosaicToastProvider\";\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "src/components/toast/toast-variants.ts",
|
|
23
|
+
"type": "registry:ui",
|
|
24
|
+
"content": "/**\n * toastVariants — pure CVA variant functions for MosaicToast / MosaicToastProvider.\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 toast card container variants by variant. */\nexport const toastCardVariants = cva(\n [\"flex w-full items-start gap-3 rounded-lg border p-4 shadow-lg sm:max-w-sm\"],\n {\n variants: {\n variant: {\n success: \"border-border bg-card\",\n error: \"border-destructive/40 bg-destructive/5\",\n info: \"border-border bg-card\",\n warning: \"border-amber-500/40 bg-amber-500/5\",\n },\n },\n defaultVariants: {\n variant: \"info\",\n },\n },\n);\n\n/** Title text variants by variant. */\nexport const toastTitleVariants = cva([\"text-sm font-medium\"], {\n variants: {\n variant: {\n success: \"text-foreground\",\n error: \"text-destructive\",\n info: \"text-foreground\",\n warning: \"text-amber-600 dark:text-amber-400\",\n },\n },\n defaultVariants: {\n variant: \"info\",\n },\n});\n\n/** Dismiss button variants — a single visual treatment across every variant. */\nexport const toastDismissButtonVariants = cva([\n \"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground\",\n]);\n\n/** Provider stack positioning — anchors the toast stack in a screen corner/edge. */\nexport const toastProviderPositionVariants = cva(\n [\"pointer-events-none fixed z-50 flex flex-col gap-2 p-4\"],\n {\n variants: {\n position: {\n \"top-right\": \"top-0 right-0 items-end\",\n \"top-center\": \"top-0 left-1/2 -translate-x-1/2 items-center\",\n \"bottom-right\": \"bottom-0 right-0 items-end\",\n \"bottom-center\": \"bottom-0 left-1/2 -translate-x-1/2 items-center\",\n },\n },\n defaultVariants: {\n position: \"top-right\",\n },\n },\n);\n"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
"type": "registry:ui"
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-tool-toggle-list",
|
|
4
|
+
"title": "MosaicToolToggleList",
|
|
5
|
+
"description": "MosaicToolToggleList — presentational per-tool enable switch + approval level selector, grouped into host-supplied sections.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/tool-toggle-list/MosaicToolToggleList.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicToolToggleList — presentational per-tool enable switch + approval\n * level selector, grouped into host-supplied sections.\n *\n * Differentiator (this is the whole point of the component): the tool\n * catalogue is DATA, not code. adam's `AgentForm.svelte` (builder-web)\n * hardcodes six tool checkboxes with zero approval concept\n * (`~/AgentForm.svelte:49-56,177-190`); this library has never heard of a\n * single tool name. `tools`, `approvalLevels` and `sections` are all\n * required props supplied by the host — a new tool, a renamed approval\n * level, or a reshuffled \"Teamwork\" section ships without touching this\n * package.\n *\n * One row per tool: name + description + enable/disable MosaicSwitch +\n * approval-level MosaicSelect-style combobox (built directly on\n * @base-ui/react/select here, same primitive as MosaicSelect, to keep the\n * per-row aria-label wiring local). Rows are grouped under host-supplied\n * section headings (`sections[].title`), each section listing the\n * `toolIds` it owns — the grouping shape itself (e.g. a \"Teamwork\" section\n * bundling the four VantagePeers tools) is a hosting decision, not a\n * library concept.\n *\n * Controlled component: no internal persisted state beyond the CHANGE\n * event flowing straight to `onToggleTool` / `onChangeApproval`. The host\n * owns `tools` and re-renders with the updated `enabled` /\n * `approvalLevelId` after handling the callback.\n *\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --foreground, --muted, --muted-foreground, --border,\n * --card, --background, --popover, --popover-foreground, --accent,\n * --accent-foreground, --ring.\n * a11y: each switch's accessible name is a required per-tool callback\n * prop (`toggleAriaLabel`); each approval selector's accessible name is\n * likewise a required per-tool callback prop (`approvalSelectAriaLabel`).\n * Approval options render with role=\"option\" (base-ui Select.Item), the\n * trigger with role=\"combobox\" — both managed by @base-ui/react/select.\n * Bilingual: every user-facing string (section titles, tool names/\n * descriptions, approval-level labels, aria-labels) is host-supplied data\n * or a required prop — zero hardcoded copy, zero default.\n *\n * @example\n * <MosaicToolToggleList\n * sections={[\n * { id: \"teamwork\", title: \"Travail d'équipe\", toolIds: [\"send_message\", \"check_messages\"] },\n * ]}\n * tools={[\n * { id: \"send_message\", name: \"send_message\", description: \"Envoyer un message\", enabled: true, approvalLevelId: \"never\" },\n * { id: \"check_messages\", name: \"check_messages\", description: \"Vérifier les messages\", enabled: false, approvalLevelId: \"always\" },\n * ]}\n * approvalLevels={[\n * { id: \"never\", label: \"Ne jamais demander\" },\n * { id: \"always\", label: \"Demander à chaque appel\" },\n * { id: \"first\", label: \"Demander la première fois\" },\n * ]}\n * onToggleTool={(toolId, enabled) => updateTool(toolId, { enabled })}\n * onChangeApproval={(toolId, levelId) => updateTool(toolId, { approvalLevelId: levelId })}\n * toggleAriaLabel={(toolName) => `Activer/désactiver ${toolName}`}\n * approvalSelectAriaLabel={(toolName) => `Niveau d'approbation pour ${toolName}`}\n * />\n */\n\nimport { Select } from \"@base-ui/react/select\";\nimport { Switch } from \"@base-ui/react/switch\";\nimport type * as React from \"react\";\nimport {\n toolToggleListRowVariants,\n toolToggleListSectionVariants,\n} from \"./tool-toggle-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\n/** One selectable approval level. Labels are host copy — no built-in set. */\nexport interface MosaicToolToggleListApprovalLevel {\n /** Stable identifier, matched against `tool.approvalLevelId`. */\n id: string;\n /** Host-supplied, host-localized display label. */\n label: string;\n}\n\n/** One tool row's data. The library knows nothing about any tool by name. */\nexport interface MosaicToolToggleListTool {\n /** Stable identifier, also referenced by `sections[].toolIds`. */\n id: string;\n /** Host-supplied display name (e.g. an MCP tool name). */\n name: string;\n /** Host-supplied short description of what the tool does. */\n description: string;\n /** Whether the tool is currently enabled. */\n enabled: boolean;\n /** Current approval level, matched against `approvalLevels[].id`. */\n approvalLevelId: string;\n}\n\n/**\n * A host-defined grouping of tools (e.g. \"Teamwork\" bundling the\n * VantagePeers tools). The section title and the grouping itself are\n * data — the library renders whatever grouping it is given.\n */\nexport interface MosaicToolToggleListSection {\n /** Stable identifier for the section. */\n id: string;\n /** Host-supplied, host-localized section heading. */\n title: string;\n /** Ordered ids of the tools that belong to this section. */\n toolIds: string[];\n}\n\nexport interface MosaicToolToggleListProps {\n /** Host-defined groupings of tools, rendered in order. */\n sections: MosaicToolToggleListSection[];\n /** Full open catalogue of tools — a PROP, never a library constant. */\n tools: MosaicToolToggleListTool[];\n /** Open catalogue of approval levels — a PROP, never a library constant. */\n approvalLevels: MosaicToolToggleListApprovalLevel[];\n /** Called when a tool's enable switch is toggled. */\n onToggleTool: (toolId: string, enabled: boolean) => void;\n /** Called when a tool's approval level is changed. */\n onChangeApproval: (toolId: string, approvalLevelId: string) => void;\n /** Per-tool accessible name for the enable/disable switch. Required, no default. */\n toggleAriaLabel: (toolName: string) => string;\n /** Per-tool accessible name for the approval-level selector. Required, no default. */\n approvalSelectAriaLabel: (toolName: string) => 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// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicToolToggleList — production tool-permissions atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders one row per tool (switch + approval\n * selector), grouped under host-supplied section headings, and reports\n * every change via callbacks. No network call, no internal persisted\n * state, no hardcoded tool catalogue.\n */\nexport function MosaicToolToggleList({\n sections,\n tools,\n approvalLevels,\n onToggleTool,\n onChangeApproval,\n toggleAriaLabel,\n approvalSelectAriaLabel,\n className,\n ref,\n}: MosaicToolToggleListProps) {\n const toolsById = new Map(tools.map((tool) => [tool.id, tool]));\n const approvalLabelById = new Map(approvalLevels.map((level) => [level.id, level.label]));\n\n return (\n <div ref={ref} data-slot=\"tool-toggle-list\" className={cn(\"flex flex-col gap-6\", className)}>\n {sections.map((section) => (\n <div\n key={section.id}\n data-slot=\"tool-toggle-list-section\"\n className={toolToggleListSectionVariants()}\n >\n <h3\n data-slot=\"tool-toggle-list-section-title\"\n className=\"text-sm font-semibold text-foreground\"\n >\n {section.title}\n </h3>\n {section.toolIds.map((toolId) => {\n const tool = toolsById.get(toolId);\n if (!tool) return null;\n return (\n <div\n key={tool.id}\n data-slot=\"tool-toggle-list-row\"\n className={toolToggleListRowVariants({ enabled: tool.enabled })}\n >\n <div className=\"flex items-center gap-3\">\n <Switch.Root\n checked={tool.enabled}\n onCheckedChange={(checked) => onToggleTool(tool.id, checked)}\n aria-label={toggleAriaLabel(tool.name)}\n data-slot=\"tool-toggle-list-switch\"\n className={cn(\n \"relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center\",\n \"rounded-full border-2 border-transparent outline-none\",\n \"bg-muted transition-colors\",\n \"data-[checked]:bg-foreground\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n )}\n >\n <Switch.Thumb\n data-slot=\"tool-toggle-list-switch-thumb\"\n className={cn(\n \"pointer-events-none block h-4 w-4 rounded-full\",\n \"bg-background shadow-sm\",\n \"translate-x-0 transition-transform\",\n \"data-[checked]:translate-x-5\",\n )}\n />\n </Switch.Root>\n <div className=\"flex flex-col gap-0.5\">\n <span\n data-slot=\"tool-toggle-list-name\"\n className=\"text-sm font-medium text-foreground\"\n >\n {tool.name}\n </span>\n <span\n data-slot=\"tool-toggle-list-description\"\n className=\"text-sm text-muted-foreground\"\n >\n {tool.description}\n </span>\n </div>\n </div>\n\n <Select.Root\n value={tool.approvalLevelId}\n onValueChange={(value) => {\n if (value !== null) onChangeApproval(tool.id, value);\n }}\n >\n <Select.Trigger\n aria-label={approvalSelectAriaLabel(tool.name)}\n data-slot=\"tool-toggle-list-approval-trigger\"\n className={cn(\n \"inline-flex h-9 min-w-[10rem] items-center justify-between gap-2\",\n \"rounded-md border border-border bg-background px-3 py-2\",\n \"text-sm text-foreground shadow-xs outline-none\",\n \"hover:bg-muted\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"data-[popup-open]:ring-ring data-[popup-open]:ring-[3px]\",\n )}\n >\n <Select.Value>\n {(val: string | null) => (val != null ? approvalLabelById.get(val) : \"\")}\n </Select.Value>\n <Select.Icon className=\"size-4 shrink-0 text-muted-foreground\">\n <ChevronDownIcon />\n </Select.Icon>\n </Select.Trigger>\n\n <Select.Portal>\n <Select.Positioner sideOffset={4}>\n <Select.Popup\n data-slot=\"tool-toggle-list-approval-popup\"\n className={cn(\n \"z-50 min-w-[10rem] 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 <Select.List>\n {approvalLevels.map((level) => (\n <Select.Item\n key={level.id}\n value={level.id}\n className={cn(\n \"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5\",\n \"text-sm text-popover-foreground outline-none\",\n \"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground\",\n \"data-[selected]:font-medium\",\n )}\n >\n <Select.ItemText>{level.label}</Select.ItemText>\n <Select.ItemIndicator className=\"ml-auto size-4\">\n <CheckIcon />\n </Select.ItemIndicator>\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n );\n}\n\nMosaicToolToggleList.displayName = \"MosaicToolToggleList\";\n\n// ── Icons (inline SVG — zero dependency) ──────────────────────────────────────\n\nfunction ChevronDownIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n className=\"size-4\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\n\nfunction CheckIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n className=\"size-4\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n );\n}\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/tool-toggle-list/tool-toggle-list-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * toolToggleListVariants — pure CVA variant functions for MosaicToolToggleList.\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/** Section header container. */\nexport const toolToggleListSectionVariants = cva([\"flex flex-col gap-2\"], {\n variants: {},\n});\n\n/** One tool row — enabled vs. disabled tone. */\nexport const toolToggleListRowVariants = cva(\n [\n \"flex flex-col gap-3 rounded-lg border p-3 transition-colors sm:flex-row sm:items-center sm:justify-between\",\n ],\n {\n variants: {\n enabled: {\n true: \"border-border bg-card\",\n false: \"border-border bg-card/50 opacity-70\",\n },\n },\n defaultVariants: {\n enabled: true,\n },\n },\n);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-tooltip",
|
|
4
|
+
"title": "MosaicTooltip",
|
|
5
|
+
"description": "MosaicTooltip — @base-ui/react Tooltip primitive",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/tooltip/MosaicTooltip.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicTooltip — @base-ui/react Tooltip primitive\n *\n * Builds on Tooltip.Provider + Tooltip.Root + Tooltip.Trigger +\n * Tooltip.Portal + Tooltip.Positioner + Tooltip.Popup.\n * role=tooltip managed by the primitive automatically.\n *\n * data-slot=\"tooltip-trigger\" on Trigger, \"tooltip-content\" on Popup.\n * Styling: Tailwind v4 semantic tokens only.\n *\n * Sub-components (MosaicTooltipProvider / MosaicTooltipRoot /\n * MosaicTooltipTrigger / MosaicTooltipContent) are exported individually\n * so hosts can compose custom tooltip trees (issue #35), in addition to\n * the compound `MosaicTooltip` convenience component below.\n */\n\nimport { Tooltip } from \"@base-ui/react/tooltip\";\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\nconst CONTENT_CLASS_NAME = cn(\n \"z-50 max-w-xs overflow-hidden rounded-md\",\n \"border border-border bg-foreground px-3 py-1.5\",\n \"text-xs text-background 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// ── Sub-components ───────────────────────────────────────────────────────────\n\nexport interface MosaicTooltipProviderProps {\n children: React.ReactNode;\n /** Delay before opening any tooltip in this group (ms). @default 600 */\n delay?: number;\n /** Delay before closing any tooltip in this group (ms). */\n closeDelay?: number;\n}\n\n/**\n * MosaicTooltipProvider — groups tooltips so adjacent triggers open\n * instantly once one tooltip in the group is already visible.\n *\n * @example\n * <MosaicTooltipProvider delay={600}>\n * <MosaicTooltipRoot>\n * <MosaicTooltipTrigger asChild>\n * <button>Hover me</button>\n * </MosaicTooltipTrigger>\n * <MosaicTooltipContent>Helpful tip</MosaicTooltipContent>\n * </MosaicTooltipRoot>\n * </MosaicTooltipProvider>\n */\nexport function MosaicTooltipProvider({\n children,\n delay = 600,\n closeDelay,\n}: MosaicTooltipProviderProps) {\n return (\n <Tooltip.Provider delay={delay} closeDelay={closeDelay}>\n {children}\n </Tooltip.Provider>\n );\n}\n\nMosaicTooltipProvider.displayName = \"MosaicTooltipProvider\";\n\nexport interface MosaicTooltipRootProps {\n children: React.ReactNode;\n /** Whether the tooltip is initially open (uncontrolled). @default false */\n defaultOpen?: boolean;\n /** Controlled open state. */\n open?: boolean;\n /** Called when the open state changes. */\n onOpenChange?: (open: boolean) => void;\n}\n\n/**\n * MosaicTooltipRoot — groups a single Trigger + Content pair. Required by\n * @base-ui/react/tooltip's architecture: the Trigger and the Content must\n * share a Root to coordinate open state and positioning anchor.\n */\nexport function MosaicTooltipRoot({\n children,\n defaultOpen,\n open,\n onOpenChange,\n}: MosaicTooltipRootProps) {\n return (\n <Tooltip.Root defaultOpen={defaultOpen} open={open} onOpenChange={onOpenChange}>\n {children}\n </Tooltip.Root>\n );\n}\n\nMosaicTooltipRoot.displayName = \"MosaicTooltipRoot\";\n\nexport interface MosaicTooltipTriggerProps {\n children: React.ReactElement;\n /** Merge props onto `children` instead of rendering a wrapping `<button>`. @default false */\n asChild?: boolean;\n className?: string;\n}\n\n/**\n * MosaicTooltipTrigger — the element that opens the tooltip on hover/focus.\n * Pass `asChild` to attach the trigger behavior directly to a single child\n * element instead of wrapping it in a `<button>`.\n */\nexport function MosaicTooltipTrigger({\n children,\n asChild = false,\n className,\n}: MosaicTooltipTriggerProps) {\n if (asChild) {\n return <Tooltip.Trigger data-slot=\"tooltip-trigger\" className={className} render={children} />;\n }\n return (\n <Tooltip.Trigger data-slot=\"tooltip-trigger\" className={className}>\n {children}\n </Tooltip.Trigger>\n );\n}\n\nMosaicTooltipTrigger.displayName = \"MosaicTooltipTrigger\";\n\nexport interface MosaicTooltipContentProps {\n children: React.ReactNode;\n /** Side to render the tooltip. @default \"top\" */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n /** Alignment on the cross axis. @default \"center\" */\n align?: \"start\" | \"center\" | \"end\";\n /** Offset (px) between the trigger and the tooltip. @default 6 */\n sideOffset?: number;\n /** Native `hidden` attribute, forwarded to the popup element. */\n hidden?: boolean;\n className?: string;\n}\n\n/**\n * MosaicTooltipContent — portalled, positioned tooltip popup. Must be\n * rendered inside a `MosaicTooltipRoot`.\n */\nexport function MosaicTooltipContent({\n children,\n side = \"top\",\n align = \"center\",\n sideOffset = 6,\n hidden,\n className,\n}: MosaicTooltipContentProps) {\n return (\n <Tooltip.Portal>\n <Tooltip.Positioner side={side} align={align} sideOffset={sideOffset}>\n <Tooltip.Popup\n data-slot=\"tooltip-content\"\n hidden={hidden}\n className={cn(CONTENT_CLASS_NAME, className)}\n >\n {children}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n );\n}\n\nMosaicTooltipContent.displayName = \"MosaicTooltipContent\";\n\n// ── Compound props ───────────────────────────────────────────────────────────\n\nexport interface MosaicTooltipProps {\n /** The element that triggers the tooltip */\n children: React.ReactNode;\n /** Tooltip content */\n content: React.ReactNode;\n /** Delay before opening (ms). @default 600 */\n delay?: number;\n /** Side to render the tooltip. @default \"top\" */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n /** Alignment on the cross axis. @default \"center\" */\n align?: \"start\" | \"center\" | \"end\";\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicTooltip — production Tooltip atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/tooltip. Wraps trigger + content in a single component.\n * role=tooltip managed automatically. Keyboard (focus) + pointer accessible.\n *\n * @example\n * <MosaicTooltip content=\"Delete this item\">\n * <button>Delete</button>\n * </MosaicTooltip>\n *\n * <MosaicTooltip content=\"Saved!\" side=\"bottom\">\n * <MosaicButton>Save</MosaicButton>\n * </MosaicTooltip>\n */\nexport function MosaicTooltip({\n children,\n content,\n delay = 600,\n side = \"top\",\n align = \"center\",\n className,\n}: MosaicTooltipProps) {\n return (\n <Tooltip.Provider delay={delay}>\n <Tooltip.Root>\n <Tooltip.Trigger data-slot=\"tooltip-trigger\" render={children as React.ReactElement} />\n <Tooltip.Portal>\n <Tooltip.Positioner side={side} align={align} sideOffset={6}>\n <Tooltip.Popup\n data-slot=\"tooltip-content\"\n className={cn(CONTENT_CLASS_NAME, className)}\n >\n {content}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n </Tooltip.Provider>\n );\n}\n\nMosaicTooltip.displayName = \"MosaicTooltip\";\n\n// Named exports for compound usage\nexport { Tooltip };\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-url-scraper",
|
|
4
|
+
"title": "MosaicUrlScraper",
|
|
5
|
+
"description": "MosaicUrlScraper — presentational URL-input + scraped-content preview",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/url-scraper/MosaicUrlScraper.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicUrlScraper — presentational URL-input + scraped-content preview\n *\n * Presentational atom. Renders a URL input + submit button and, below it,\n * one of three host-controlled states: a loading indicator, a scraped\n * content preview (title/description/optional image/link), or an error\n * message. The component never performs a network call: submitting a\n * syntactically-valid URL is surfaced via `onScrape(url: string)` — the\n * host owns how the page is actually fetched/scraped, how long it takes,\n * and what counts as an error (invalid URL, unreachable page, empty\n * content are all just different host-supplied `errorMessage` values).\n *\n * Local behaviour (no network involved): a client-side URL-syntax check via\n * `new URL()` runs on submit so a malformed URL is caught immediately\n * without a host round-trip. This mirrors the source app's own\n * `isValidUrl` check — it is UI validation, not a scrape.\n *\n * Pattern: MosaicDocumentUpload.tsx (data-slot, inline cn, React 19 ref\n * prop, displayName, JSDoc, pure variants module, host-controlled status\n * union as a discriminated prop type).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --foreground, --muted, --muted-foreground, --border,\n * --destructive, --ring, --accent, --card, --background.\n * No icon library — uses a plain \"↗\" glyph for the external link, matching\n * the document-upload convention (no lucide-react runtime dependency).\n * a11y: input has a required accessible name; the external link has a\n * required per-content accessible name; the loading region uses\n * role=\"status\".\n * Bilingual: every user-facing string (placeholder/button labels/loading\n * message/invalid-URL message/error message/reset label/link+image\n * accessible names) is a required caller-supplied prop — zero hardcoded\n * copy, zero default.\n *\n * Ported from any-debate-ai components/memory/url-scraper.tsx (rewritten\n * from scratch — no shared code, no license carried over): dropped the\n * embedded mock \"AI-extracted memories\" review UI (app-specific business\n * logic, same call as document-upload's dropped mock-extraction review)\n * and the network/simulation logic (violates presentational-component\n * rule), kept the URL input + scrape action + scraped-content preview +\n * error-state shape.\n *\n * Props are pushed into the `MosaicUrlScraperState` discriminated union\n * exactly where they are read — no prop is required in a status branch\n * that never renders it (e.g. `loadingMessage` only exists on the\n * \"loading\" variant, `content`/`resetButtonLabel`/`onReset` only on\n * \"success\", etc.). Known, documented exception: `imageAlt` is required\n * on the whole \"success\" branch, not narrowed further by\n * `content.image` presence — see the prop's own JSDoc.\n *\n * @example\n * // idle\n * <MosaicUrlScraper\n * status=\"idle\"\n * url={url}\n * onUrlChange={setUrl}\n * onScrape={(scrapedUrl) => scrapePage(scrapedUrl)}\n * inputAriaLabel=\"URL de la page à aspirer\"\n * inputPlaceholder=\"https://exemple.com/article\"\n * scrapeButtonLabel=\"Aspirer\"\n * invalidUrlMessage=\"Veuillez saisir une URL valide\"\n * />\n *\n * @example\n * // success\n * <MosaicUrlScraper\n * {...baseProps}\n * status=\"success\"\n * content={content}\n * openLinkAriaLabel={(pageUrl) => `Ouvrir ${pageUrl} dans un nouvel onglet`}\n * imageAlt={(title) => `Aperçu de ${title}`}\n * resetButtonLabel=\"Aspirer une autre page\"\n * onReset={() => reset()}\n * />\n */\n\nimport type * as React from \"react\";\nimport { useState } from \"react\";\nimport {\n urlScraperCardVariants,\n urlScraperInputVariants,\n urlScraperMessageVariants,\n} from \"./url-scraper-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nfunction isSyntacticallyValidUrl(candidate: string): boolean {\n try {\n // eslint-disable-next-line no-new\n new URL(candidate);\n return true;\n } catch {\n return false;\n }\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\n/** Host-supplied scraped page content, shown once status === \"success\". */\nexport interface MosaicUrlScraperContent {\n /** Scraped page title, displayed as-is. */\n title: string;\n /** Scraped page description/summary, displayed as-is. */\n description: string;\n /** Optional preview image URL — the image is rendered only when present. */\n image?: string;\n /** The scraped page's canonical URL, used as the external-link href. */\n url: string;\n}\n\n/**\n * Base props required in EVERY status — read unconditionally by the\n * component regardless of `status` (input row + local URL-syntax\n * validation, both reachable from \"idle\").\n */\ntype MosaicUrlScraperBaseProps = {\n /** Host-controlled current input value. */\n url: string;\n /** Called with the raw input value on every keystroke. */\n onUrlChange: (url: string) => void;\n /**\n * Called with the trimmed URL once it passes local syntax validation.\n * The component performs no scrape itself — the host decides how the\n * page is fetched and how `status`/`content`/`errorMessage` are updated\n * afterward.\n */\n onScrape: (url: string) => void;\n /** Accessible name for the URL input (`aria-label`). Required, no default. */\n inputAriaLabel: string;\n /** Placeholder text for the URL input. Required, no default. */\n inputPlaceholder: string;\n /** Label for the submit button when idle/ready. Required, no default. */\n scrapeButtonLabel: string;\n /**\n * Message shown when the local `new URL()` syntax check fails on submit.\n * Required, no default — this is host copy, not an English fallback.\n * Reachable from \"idle\": the local check runs on the first submit,\n * before the host ever sets `status` to \"loading\".\n */\n invalidUrlMessage: 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/**\n * Host-controlled scrape status. Every prop that is only ever rendered in\n * ONE status branch lives on that branch's variant — not on the base\n * props — so the type contract matches exactly what the component reads\n * (mirrors MosaicDocumentUploadFile's status-driven shape, and the\n * memory-card \"a required prop must be used exactly where it's declared\"\n * rule).\n */\nexport type MosaicUrlScraperState =\n | { status: \"idle\" }\n | {\n status: \"loading\";\n /** Label for the submit button while status === \"loading\". Required, no default. */\n scrapingLabel: string;\n /** Message shown inside the loading region while status === \"loading\". Required, no default. */\n loadingMessage: string;\n }\n | {\n status: \"success\";\n content: MosaicUrlScraperContent;\n /**\n * Per-content accessible name for the external \"open\" link, e.g.\n * `(pageUrl) => \\`Open ${pageUrl}\\``. Required — no hardcoded string.\n */\n openLinkAriaLabel: (pageUrl: string) => string;\n /**\n * Per-content alt text for the preview image. Required on this\n * branch (not narrowed further by `content.image` presence — see\n * MosaicUrlScraper.tsx JSDoc for why); invoked only when\n * `content.image` is actually present.\n */\n imageAlt: (title: string) => string;\n /** Label for the reset/\"scrape another\" button. Required, no default. */\n resetButtonLabel: string;\n /** Called when the reset/\"scrape another\" button is activated. */\n onReset: () => void;\n }\n | {\n status: \"error\";\n /**\n * Host-provided, host-localized error message (e.g. \"Invalid URL\",\n * \"Page unreachable\", \"Empty content\"). The library never generates\n * its own error strings — every occurrence is a distinct required\n * value supplied by the caller.\n */\n errorMessage: string;\n /** Label for the reset/\"scrape another\" button. Required, no default. */\n resetButtonLabel: string;\n /** Called when the reset/\"scrape another\" button is activated. */\n onReset: () => void;\n };\n\nexport type MosaicUrlScraperProps = MosaicUrlScraperBaseProps & MosaicUrlScraperState;\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicUrlScraper — production URL-scraper atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders the URL input, the current status\n * (loading/success/error), and reports a validated scrape request / reset\n * via callbacks. No network call, no scraping simulation, no built-in copy.\n */\nexport function MosaicUrlScraper(props: MosaicUrlScraperProps) {\n const {\n url,\n onUrlChange,\n onScrape,\n inputAriaLabel,\n inputPlaceholder,\n scrapeButtonLabel,\n invalidUrlMessage,\n className,\n ref,\n } = props;\n\n const [isLocallyInvalid, setIsLocallyInvalid] = useState(false);\n const isBusy = props.status === \"loading\" || props.status === \"success\";\n\n function handleSubmit(event: React.FormEvent<HTMLFormElement>) {\n event.preventDefault();\n const trimmed = url.trim();\n if (!isSyntacticallyValidUrl(trimmed)) {\n setIsLocallyInvalid(true);\n return;\n }\n setIsLocallyInvalid(false);\n onScrape(trimmed);\n }\n\n function handleUrlChange(event: React.ChangeEvent<HTMLInputElement>) {\n setIsLocallyInvalid(false);\n onUrlChange(event.target.value);\n }\n\n return (\n <div ref={ref} data-slot=\"url-scraper\" className={cn(\"flex flex-col gap-4\", className)}>\n <form\n data-slot=\"url-scraper-form\"\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-2 md:flex-row\"\n >\n <input\n type=\"url\"\n data-slot=\"url-scraper-input\"\n aria-label={inputAriaLabel}\n placeholder={inputPlaceholder}\n value={url}\n onChange={handleUrlChange}\n disabled={isBusy}\n className={urlScraperInputVariants({ invalid: isLocallyInvalid })}\n />\n <button\n type=\"submit\"\n data-slot=\"url-scraper-submit-button\"\n disabled={isBusy}\n className=\"min-h-9 inline-flex items-center justify-center rounded-md border border-border px-4 text-sm font-medium transition-colors hover:bg-accent/50 disabled:opacity-50\"\n >\n {props.status === \"loading\" ? props.scrapingLabel : scrapeButtonLabel}\n </button>\n </form>\n\n {isLocallyInvalid && (\n <p\n data-slot=\"url-scraper-invalid-message\"\n className={urlScraperMessageVariants({ tone: \"error\" })}\n >\n {invalidUrlMessage}\n </p>\n )}\n\n {props.status === \"loading\" && (\n <output\n data-slot=\"url-scraper-loading\"\n className={urlScraperCardVariants({ tone: \"neutral\" })}\n >\n <p className={urlScraperMessageVariants({ tone: \"muted\" })}>{props.loadingMessage}</p>\n </output>\n )}\n\n {props.status === \"error\" && (\n <div data-slot=\"url-scraper-error\" className={urlScraperCardVariants({ tone: \"error\" })}>\n <p\n data-slot=\"url-scraper-error-message\"\n className={urlScraperMessageVariants({ tone: \"error\" })}\n >\n {props.errorMessage}\n </p>\n <button\n type=\"button\"\n data-slot=\"url-scraper-reset-button\"\n onClick={props.onReset}\n className=\"min-h-9 inline-flex w-fit items-center justify-center rounded-md border border-border px-3 text-sm font-medium transition-colors hover:bg-accent/50\"\n >\n {props.resetButtonLabel}\n </button>\n </div>\n )}\n\n {props.status === \"success\" && (\n <div\n data-slot=\"url-scraper-content\"\n className={urlScraperCardVariants({ tone: \"neutral\" })}\n >\n {props.content.image !== undefined && (\n <img\n data-slot=\"url-scraper-image\"\n src={props.content.image}\n alt={props.imageAlt(props.content.title)}\n className=\"h-32 w-full rounded-md object-cover md:h-48\"\n />\n )}\n <div className=\"flex items-start justify-between gap-2\">\n <h3 data-slot=\"url-scraper-title\" className=\"text-base font-semibold md:text-lg\">\n {props.content.title}\n </h3>\n <a\n data-slot=\"url-scraper-link\"\n href={props.content.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n aria-label={props.openLinkAriaLabel(props.content.url)}\n className=\"shrink-0 text-sm text-muted-foreground transition-colors hover:text-foreground\"\n >\n ↗\n </a>\n </div>\n <p\n data-slot=\"url-scraper-description\"\n className={urlScraperMessageVariants({ tone: \"muted\" })}\n >\n {props.content.description}\n </p>\n <button\n type=\"button\"\n data-slot=\"url-scraper-reset-button\"\n onClick={props.onReset}\n className=\"min-h-9 inline-flex w-fit items-center justify-center rounded-md border border-border px-3 text-sm font-medium transition-colors hover:bg-accent/50\"\n >\n {props.resetButtonLabel}\n </button>\n </div>\n )}\n </div>\n );\n}\n\nMosaicUrlScraper.displayName = \"MosaicUrlScraper\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/url-scraper/url-scraper-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * urlScraperVariants — pure CVA variant functions for MosaicUrlScraper.\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/** URL input variants — normal vs. locally-invalid. */\nexport const urlScraperInputVariants = cva(\n [\n \"min-h-9 flex-1 rounded-md border bg-transparent px-3 text-sm outline-none\",\n \"transition-colors focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50\",\n ],\n {\n variants: {\n invalid: {\n true: \"border-destructive\",\n false: \"border-border\",\n },\n },\n defaultVariants: {\n invalid: false,\n },\n },\n);\n\n/** Inline message text variants by tone. */\nexport const urlScraperMessageVariants = cva([\"text-sm\"], {\n variants: {\n tone: {\n error: \"text-destructive\",\n muted: \"text-muted-foreground\",\n },\n },\n defaultVariants: {\n tone: \"muted\",\n },\n});\n\n/** Loading / success / error card container variants. */\nexport const urlScraperCardVariants = cva([\"flex flex-col gap-2 rounded-lg border p-4\"], {\n variants: {\n tone: {\n neutral: \"border-border bg-card\",\n error: \"border-destructive/40 bg-destructive/5\",\n },\n },\n defaultVariants: {\n tone: \"neutral\",\n },\n});\n"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"type": "registry:ui"
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-user-button",
|
|
4
|
+
"title": "MosaicUserButton",
|
|
5
|
+
"description": "Clerk <UserButton> with OKLCH-token appearance. Avatar + popover themed to mosaic tokens. Clerk injected as peer prop.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@clerk/nextjs"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/auth/user-button/MosaicUserButton.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicUserButton — Clerk <UserButton> with OKLCH-token appearance.\n *\n * Wraps @clerk/nextjs <UserButton>. Clerk is injected as a peer prop so\n * mosaic-blocks does not bundle @clerk/nextjs directly.\n *\n * @example\n * import { UserButton } from \"@clerk/nextjs\"\n * <MosaicUserButton clerkUserButton={UserButton} />\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicUserButtonProps {\n /** Clerk <UserButton> component — injected by caller to avoid bundling Clerk */\n clerkUserButton: React.ComponentType<{\n appearance?: Record<string, unknown>;\n afterSignOutUrl?: string;\n showName?: boolean;\n [key: string]: unknown;\n }>;\n /** URL to redirect after sign-out */\n afterSignOutUrl?: string;\n /** Show the user's name next to avatar */\n showName?: boolean;\n className?: string;\n}\n\n// ── Clerk OKLCH appearance tokens ─────────────────────────────────────────────\n\nconst clerkAppearance = {\n variables: {\n colorPrimary: \"var(--primary)\",\n colorBackground: \"var(--popover)\",\n colorText: \"var(--foreground)\",\n colorTextSecondary: \"var(--muted-foreground)\",\n colorNeutral: \"var(--foreground)\",\n borderRadius: \"0.375rem\",\n },\n elements: {\n avatarBox: \"ring-2 ring-border\",\n userButtonPopoverCard: \"border border-border bg-popover shadow-md\",\n userButtonPopoverActions: \"border-t border-border\",\n userButtonPopoverActionButton:\n \"text-foreground hover:bg-accent hover:text-accent-foreground text-sm\",\n userButtonPopoverActionButtonText: \"text-foreground\",\n userButtonPopoverFooter: \"border-t border-border\",\n userPreviewMainIdentifier: \"text-foreground font-medium\",\n userPreviewSecondaryIdentifier: \"text-muted-foreground text-xs\",\n },\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicUserButton({\n clerkUserButton: ClerkUserButton,\n afterSignOutUrl = \"/\",\n showName = false,\n className,\n}: MosaicUserButtonProps) {\n return (\n <div data-slot=\"user-button\" className={className}>\n <ClerkUserButton\n appearance={clerkAppearance}\n afterSignOutUrl={afterSignOutUrl}\n showName={showName}\n />\n </div>\n );\n}\n\nMosaicUserButton.displayName = \"MosaicUserButton\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "use-effective-workspace-id",
|
|
4
|
+
"title": "useEffectiveWorkspaceId",
|
|
5
|
+
"description": "Re-exposes cloud-identity workspace resolver as a typed React hook. Reads from MosaicMultiTenantProvider context.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-multi-tenant-provider.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/multi-tenant/multi-tenant-provider/useEffectiveWorkspaceId.ts",
|
|
13
|
+
"type": "registry:hook",
|
|
14
|
+
"content": "/**\n * useEffectiveWorkspaceId — alias of `useMosaicWorkspace`: reads the workspace\n * id the provider resolved.\n *\n * The hook reads from MosaicMultiTenantProvider's context. If used outside that\n * provider it returns `{ workspaceId: null, isLoading: false }`.\n *\n * It does NOT import from @vantageos/cloud-identity, and cloud-identity exports\n * no symbol of this name (its equivalent is called `getEffectiveTenantId`). The\n * provider's `resolveWorkspaceId` prop is the integration point.\n *\n * @example\n * const { workspaceId } = useEffectiveWorkspaceId();\n * // workspaceId: string | null\n */\n\nexport { useMosaicWorkspace as useEffectiveWorkspaceId } from \"./MosaicMultiTenantProvider.js\";\nexport type { MosaicWorkspaceContext } from \"./MosaicMultiTenantProvider.js\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:hook"
|
|
18
|
+
}
|