@vantageos/mosaic-blocks 0.5.34-alpha → 0.5.36-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/index.cjs +1517 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1283 -15
- package/dist/index.d.ts +1283 -15
- package/dist/index.js +1487 -102
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +38 -26
- package/r/mosaic-accordion.json +18 -0
- 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 +179 -130
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-radio-group",
|
|
4
|
+
"title": "MosaicRadioGroup",
|
|
5
|
+
"description": "MosaicRadioGroup — @base-ui/react RadioGroup + Radio primitives",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/radio-group/MosaicRadioGroup.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicRadioGroup — @base-ui/react RadioGroup + Radio primitives\n *\n * Builds on RadioGroup (from @base-ui/react/radio-group) +\n * Radio.Root + Radio.Indicator (from @base-ui/react/radio).\n * Supports controlled (value + onValueChange) and uncontrolled modes.\n * role=radiogroup + role=radio + aria-checked managed by primitives automatically.\n *\n * data-slot=\"radio-group\" on RadioGroup, \"radio\" on Radio.Root,\n * \"radio-indicator\" on Radio.Indicator.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Radio } from \"@base-ui/react/radio\";\nimport { RadioGroup } from \"@base-ui/react/radio-group\";\nimport type * as React from \"react\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicRadioGroupProps extends RadioGroup.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport interface MosaicRadioGroupItemProps extends Radio.Root.Props {\n className?: string;\n ref?: React.Ref<HTMLSpanElement>;\n}\n\n// ── Components ────────────────────────────────────────────────────────────────\n\n/**\n * MosaicRadioGroup — production RadioGroup for @vantageos/mosaic-blocks.\n *\n * Wrap with MosaicRadioGroupItem for each option.\n * role=radiogroup is set automatically by the primitive.\n *\n * @example\n * <MosaicRadioGroup value={plan} onValueChange={setPlan} aria-label=\"Plan\">\n * <MosaicRadioGroupItem value=\"free\">Free</MosaicRadioGroupItem>\n * <MosaicRadioGroupItem value=\"pro\">Pro</MosaicRadioGroupItem>\n * </MosaicRadioGroup>\n */\nexport function MosaicRadioGroup({ className, ref, ...props }: MosaicRadioGroupProps) {\n return (\n <RadioGroup\n ref={ref}\n data-slot=\"radio-group\"\n className={cn(\"flex flex-col gap-2\", className)}\n {...props}\n />\n );\n}\n\nMosaicRadioGroup.displayName = \"MosaicRadioGroup\";\n\n/**\n * MosaicRadioGroupItem — individual radio button for MosaicRadioGroup.\n *\n * @example\n * <MosaicRadioGroupItem value=\"option-a\">Option A</MosaicRadioGroupItem>\n */\nexport function MosaicRadioGroupItem({\n className,\n children,\n ref,\n ...props\n}: MosaicRadioGroupItemProps) {\n return (\n <Radio.Root\n ref={ref}\n data-slot=\"radio\"\n className={cn(\n \"flex items-center gap-2 text-sm font-medium\",\n \"cursor-pointer select-none\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n {/* Radio button circle */}\n <span\n className={cn(\n \"flex size-4 shrink-0 items-center justify-center\",\n \"rounded-full border border-border bg-background\",\n \"outline-none transition-colors\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"peer-data-[checked]:border-foreground\",\n )}\n >\n <Radio.Indicator data-slot=\"radio-indicator\" className=\"flex items-center justify-center\">\n <span className=\"size-2 rounded-full bg-foreground\" />\n </Radio.Indicator>\n </span>\n {children}\n </Radio.Root>\n );\n}\n\nMosaicRadioGroupItem.displayName = \"MosaicRadioGroupItem\";\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-reply-input",
|
|
4
|
+
"title": "MosaicReplyInput",
|
|
5
|
+
"description": "MosaicReplyInput — presentational, controlled reply input scoped to one thread",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/reply-input/MosaicReplyInput.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicReplyInput — presentational, controlled reply input scoped to one thread\n *\n * Presentational atom. Gives follow-up to a single agent/thread without\n * mixing it into the general flow: it renders a host-supplied thread-context\n * node above a multi-line, auto-growing textarea, plus Send and Cancel\n * buttons. The component performs no network call and holds no message\n * state: the current text is fully host-controlled (`value` +\n * `onValueChange`), the thread it replies into is a host-supplied node\n * (`context`), and `onSubmit(text)` / `onCancel()` are pure prop callbacks.\n *\n * Local behaviour (no network involved): Enter (without Shift) submits the\n * trimmed value; Shift+Enter inserts a newline; the textarea auto-grows with\n * the content up to a max height, then scrolls.\n *\n * Pattern: MosaicChatComposer.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: --foreground, --background, --muted-foreground, --border,\n * --ring, --card.\n * No icon library dependency — plain glyphs (\"↑\" send / \"×\" cancel), matching\n * the chat-composer / url-scraper convention. Glyphs are `aria-hidden`; the\n * accessible name comes from the required `sendButtonAriaLabel` /\n * `cancelButtonAriaLabel` props.\n * a11y: the textarea has a required accessible name (`textareaAriaLabel`);\n * the thread-context region has a required accessible name\n * (`contextAriaLabel`) distinguishing it, for assistive technology, from the\n * general conversation flow.\n * Bilingual: every user-facing string (`textareaAriaLabel`, `placeholder`,\n * `contextAriaLabel`, `sendButtonAriaLabel`, `cancelButtonAriaLabel`) is a\n * required caller-supplied prop — zero hardcoded copy, zero default. The\n * thread context itself is a host-supplied `React.ReactNode` (`context`):\n * the library never invents the wording that identifies which thread a\n * reply targets.\n *\n * @example\n * <MosaicReplyInput\n * value={value}\n * onValueChange={setValue}\n * onSubmit={(text) => postReply(threadId, text)}\n * onCancel={() => closeReplyBox()}\n * context={<span>Replying to {agentName}</span>}\n * contextAriaLabel=\"Thread this reply targets\"\n * textareaAriaLabel=\"Reply in this thread\"\n * placeholder=\"Write your reply...\"\n * sendButtonAriaLabel=\"Send reply\"\n * cancelButtonAriaLabel=\"Cancel reply\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useCallback, useEffect, useRef } from \"react\";\nimport {\n replyInputActionButtonVariants,\n replyInputContextVariants,\n replyInputRootVariants,\n replyInputTextareaVariants,\n} from \"./reply-input-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicReplyInputProps = {\n /** Host-controlled current textarea value. */\n value: string;\n /** Called with the raw textarea value on every keystroke. */\n onValueChange: (value: string) => void;\n /** Called with the trimmed value on Enter (no Shift) or send-button click. */\n onSubmit: (text: string) => void;\n /** Called when the cancel button is activated. */\n onCancel: () => void;\n /**\n * Host-supplied node identifying the thread this reply targets (e.g. the\n * agent/message it replies to). The library never invents this wording.\n */\n context: React.ReactNode;\n /** Accessible name for the thread-context region. Required, no default. */\n contextAriaLabel: string;\n /** Accessible name for the textarea (`aria-label`). Required, no default. */\n textareaAriaLabel: string;\n /** Placeholder text for the textarea. Required, no default. */\n placeholder: string;\n /** Accessible name for the send button. Required, no default. */\n sendButtonAriaLabel: string;\n /** Accessible name for the cancel button. Required, no default. */\n cancelButtonAriaLabel: string;\n /** Disables every control (e.g. host-level connectivity loss). */\n disabled?: boolean;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLFormElement>;\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicReplyInput — production reply-input atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders a host-supplied thread-context node, a\n * controlled auto-growing textarea, and Send/Cancel buttons. No network\n * call, no message history, no built-in copy.\n */\nexport function MosaicReplyInput(props: MosaicReplyInputProps) {\n const {\n value,\n onValueChange,\n onSubmit,\n onCancel,\n context,\n contextAriaLabel,\n textareaAriaLabel,\n placeholder,\n sendButtonAriaLabel,\n cancelButtonAriaLabel,\n disabled = false,\n className,\n ref,\n } = props;\n\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const trimmedValue = value.trim();\n\n // Auto-grow: `value` drives the resize on every content change even though\n // the effect body reads `textareaRef.current`, not `value`, by design.\n // biome-ignore lint/correctness/useExhaustiveDependencies: value is the intentional resize trigger\n useEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) {\n return;\n }\n textarea.style.height = \"auto\";\n textarea.style.height = `${textarea.scrollHeight}px`;\n }, [value]);\n\n const submitValue = useCallback(() => {\n const text = value.trim();\n if (!text || disabled) {\n return;\n }\n onSubmit(text);\n }, [disabled, onSubmit, value]);\n\n const handleSubmit = useCallback(\n (event: React.FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n submitValue();\n },\n [submitValue],\n );\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submitValue();\n }\n },\n [submitValue],\n );\n\n return (\n <form\n ref={ref}\n data-slot=\"reply-input\"\n className={cn(replyInputRootVariants(), className)}\n onSubmit={handleSubmit}\n >\n <div\n aria-label={contextAriaLabel}\n className={replyInputContextVariants()}\n data-slot=\"reply-input-context\"\n >\n {context}\n </div>\n <textarea\n data-slot=\"reply-input-textarea\"\n aria-label={textareaAriaLabel}\n className={replyInputTextareaVariants()}\n disabled={disabled}\n onChange={(event) => onValueChange(event.target.value)}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={textareaRef}\n rows={1}\n value={value}\n />\n <div className=\"flex min-h-9 items-center justify-end gap-2 px-3 pt-1 pb-2\">\n <button\n aria-label={cancelButtonAriaLabel}\n className={replyInputActionButtonVariants({ tone: \"cancel\" })}\n data-slot=\"reply-input-cancel-button\"\n disabled={disabled}\n onClick={onCancel}\n type=\"button\"\n >\n <span aria-hidden=\"true\">×</span>\n </button>\n <button\n aria-label={sendButtonAriaLabel}\n className={replyInputActionButtonVariants({ tone: \"send\" })}\n data-slot=\"reply-input-send-button\"\n disabled={disabled || trimmedValue.length === 0}\n type=\"submit\"\n >\n <span aria-hidden=\"true\">↑</span>\n </button>\n </div>\n </form>\n );\n}\n\nMosaicReplyInput.displayName = \"MosaicReplyInput\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/reply-input/reply-input-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * replyInputVariants — pure CVA variant functions for MosaicReplyInput.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Root form container. */\nexport const replyInputRootVariants = cva([\n \"min-w-0 rounded-[14px] border border-border bg-card shadow-sm transition-colors\",\n \"focus-within:ring-[1px] focus-within:ring-ring\",\n]);\n\n/** Host-supplied thread-context region, shown above the textarea. */\nexport const replyInputContextVariants = cva([\n \"truncate border-border border-b px-3 py-2 text-muted-foreground text-xs\",\n]);\n\n/** Textarea input. */\nexport const replyInputTextareaVariants = cva([\n \"max-h-40 min-h-12 w-full resize-none bg-transparent px-3 pt-3 pb-1 text-sm outline-none\",\n \"placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-60\",\n]);\n\n/** Send / cancel action button, by tone. */\nexport const replyInputActionButtonVariants = cva(\n [\n \"inline-flex h-7 shrink-0 items-center justify-center rounded-md px-2.5 text-xs transition-colors\",\n \"disabled:cursor-not-allowed disabled:opacity-30\",\n ],\n {\n variants: {\n tone: {\n send: \"bg-foreground text-background hover:bg-foreground/90\",\n cancel: \"bg-foreground/10 text-foreground hover:bg-foreground/20\",\n },\n },\n defaultVariants: {\n tone: \"send\",\n },\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-resizable-split-pane",
|
|
4
|
+
"title": "MosaicResizableSplitPane",
|
|
5
|
+
"description": "Presentational resizable two-pane content layout (drag or arrow-key resize, host-controlled width and collapsed state). Forms a pair with MosaicPdfViewer for side-by-side document preview + edit panel.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/resizable-split-pane/MosaicResizableSplitPane.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicResizableSplitPane — presentational resizable two-pane layout\n *\n * Presentational content-level split, forming a pair with `MosaicPdfViewer`\n * (`main` = document preview, `side` = the edit panel next to it). The pattern\n * it replaces shows the document in a modal — so the reviewer sees the\n * document OR edits fields, never both at once. This component removes that\n * modal round-trip: `main` and `side` render side by side, and the boundary\n * between them is draggable.\n *\n * Fully host-controlled, exactly like `MosaicPdfViewer`'s page/zoom pair:\n * `sideWidth`/`onSideWidthChange` and `isSideCollapsed`/`onToggleSideCollapsed`\n * are independent controlled pairs — the component never keeps its own copy\n * of width or collapsed state, it only reports drag/keyboard/click intents\n * via callbacks. No business data lives in this contract: it only knows\n * `main` / `side` / dimensions — same pattern noted in the property contract\n * (\"generalisable car aucune donnée métier dans le contrat de props\").\n *\n * Distinct from `MosaicDashboardLayout`: that component owns the app SHELL\n * (header, sidebar, mobile drawer). This one owns CONTENT layout only — it\n * has no header, no navigation, no app-level concept, and composes *inside*\n * a page (or inside `MosaicDashboardLayout`'s children slot).\n *\n * Drag is implemented with plain `pointerdown`/`pointermove`/`pointerup`\n * listeners (no split-pane library dependency — matches the\n * `MosaicPdfViewer`/`MosaicUrlScraper` convention of leaning on browser\n * primitives instead of adding a runtime dependency). `pointerdown` is\n * attached via the JSX `onPointerDown` prop on the handle (React does\n * delegate pointer events); `pointermove`/`pointerup` are attached with a\n * plain `addEventListener` on `window` inside a `useEffect`, because the drag\n * must keep tracking the pointer even once it leaves the handle's bounds —\n * mirrors `MosaicPdfViewer`'s native-listener rationale (JSDoc there), here\n * applied because the *drag gesture* — not a single element's native event —\n * needs to outlive the handle's own DOM bounds.\n *\n * The resize handle is `role=\"separator\"` with `aria-orientation=\"vertical\"`,\n * `aria-valuenow`/`aria-valuemin`/`aria-valuemax`, and `tabIndex={0}` — it is\n * reachable and operable by keyboard alone (ArrowLeft/ArrowRight adjust\n * `sideWidth` by a fixed step), never mouse-only. This is a daily working\n * screen — a mouse-only resize handle would be a real accessibility defect,\n * not a nicety.\n *\n * Pattern: MosaicPdfViewer.tsx / MosaicSlider.tsx (data-slot, inline cn,\n * React 19 ref prop, displayName, JSDoc, pure variants module, presentational\n * — host owns width/collapsed state, no split-pane library dependency).\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist; the\n * `useRef`/`useEffect` below require the client runtime at use-time.\n * Design tokens: --border, --accent, --ring.\n * No icon library — plain glyphs (\"‹\"/\"›\"), matching the\n * pdf-viewer/dashboard-layout convention (no lucide-react runtime dependency).\n * Bilingual: every user-facing string (`collapseButtonAriaLabel` /\n * `resizeHandleAriaLabel`) is a required caller-supplied prop — zero\n * hardcoded copy, zero default.\n *\n * @example\n * <MosaicResizableSplitPane\n * main={<MosaicPdfViewer fileUrl={documentUrl} loadingLabel=\"…\" errorLabel=\"…\" />}\n * side={<DocumentEditPanel />}\n * sideWidth={sideWidth}\n * onSideWidthChange={setSideWidth}\n * isSideCollapsed={isSideCollapsed}\n * onToggleSideCollapsed={() => setIsSideCollapsed((c) => !c)}\n * collapseButtonAriaLabel=\"Replier le panneau latéral\"\n * resizeHandleAriaLabel=\"Redimensionner le panneau latéral\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useEffect, useRef } from \"react\";\nimport {\n splitPaneCollapseButtonVariants,\n splitPaneHandleVariants,\n splitPaneRootVariants,\n} from \"./split-pane-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n/** Merges an external React-19 ref prop with an internally-held ref. */\nfunction mergeRefs<T>(externalRef: React.Ref<T> | undefined, node: T | null) {\n if (typeof externalRef === \"function\") {\n externalRef(node);\n } else if (externalRef && typeof externalRef === \"object\") {\n (externalRef as React.MutableRefObject<T | null>).current = node;\n }\n}\n\n// ── Constants ─────────────────────────────────────────────────────────────────\n\nconst DEFAULT_SIDE_WIDTH = 30;\nconst MIN_SIDE_WIDTH = 15;\nconst MAX_SIDE_WIDTH = 70;\nconst KEYBOARD_STEP = 5;\n\nfunction clampSideWidth(width: number): number {\n return Math.min(MAX_SIDE_WIDTH, Math.max(MIN_SIDE_WIDTH, width));\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicResizableSplitPaneProps {\n /** Main pane content (e.g. a document preview). */\n main: React.ReactNode;\n /** Side pane content (e.g. an edit panel). Hidden when `isSideCollapsed`. */\n side: React.ReactNode;\n /** Side pane width as a percentage of the container, controlled by the host. */\n sideWidth?: number;\n /** Called with the requested width (percentage) while dragging the handle or using arrow keys. */\n onSideWidthChange?: (width: number) => void;\n /** Whether the side pane is collapsed, controlled by the host. */\n isSideCollapsed?: boolean;\n /** Called when the collapse/expand button is activated. */\n onToggleSideCollapsed?: () => void;\n /** Accessible label for the collapse/expand button. Required, no default. */\n collapseButtonAriaLabel: string;\n /** Accessible label for the resize handle. Required, no default. */\n resizeHandleAriaLabel: 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 * MosaicResizableSplitPane — production resizable content-split layout for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders `main`/`side` side by side, reports drag and\n * keyboard resize intents via `onSideWidthChange`, and reports collapse\n * intent via `onToggleSideCollapsed`. No split-pane library dependency, no\n * local width/collapsed state, no built-in copy.\n */\nexport function MosaicResizableSplitPane({\n main,\n side,\n sideWidth = DEFAULT_SIDE_WIDTH,\n onSideWidthChange,\n isSideCollapsed = false,\n onToggleSideCollapsed,\n collapseButtonAriaLabel,\n resizeHandleAriaLabel,\n className,\n ref,\n}: MosaicResizableSplitPaneProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const isDraggingRef = useRef(false);\n\n // Drag tracking must outlive the handle's own bounds (the pointer can move\n // past the handle mid-drag) — attached on `window`, cleaned up on unmount.\n useEffect(() => {\n function handlePointerMove(event: PointerEvent) {\n if (!isDraggingRef.current) return;\n const rootNode = rootRef.current;\n if (!rootNode || onSideWidthChange === undefined) return;\n const rect = rootNode.getBoundingClientRect();\n if (rect.width === 0) return;\n const distanceFromRight = rect.right - event.clientX;\n const rawWidth = (distanceFromRight / rect.width) * 100;\n onSideWidthChange(clampSideWidth(rawWidth));\n }\n function handlePointerUp() {\n isDraggingRef.current = false;\n }\n window.addEventListener(\"pointermove\", handlePointerMove);\n window.addEventListener(\"pointerup\", handlePointerUp);\n return () => {\n window.removeEventListener(\"pointermove\", handlePointerMove);\n window.removeEventListener(\"pointerup\", handlePointerUp);\n };\n }, [onSideWidthChange]);\n\n function handleHandlePointerDown() {\n isDraggingRef.current = true;\n }\n\n function handleHandleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (onSideWidthChange === undefined) return;\n if (event.key === \"ArrowLeft\") {\n event.preventDefault();\n onSideWidthChange(clampSideWidth(sideWidth - KEYBOARD_STEP));\n } else if (event.key === \"ArrowRight\") {\n event.preventDefault();\n onSideWidthChange(clampSideWidth(sideWidth + KEYBOARD_STEP));\n }\n }\n\n return (\n <div\n ref={(node) => {\n rootRef.current = node;\n mergeRefs(ref, node);\n }}\n data-slot=\"resizable-split-pane\"\n className={cn(splitPaneRootVariants(), className)}\n >\n <div data-slot=\"resizable-split-pane-main\" className=\"min-h-0 min-w-0 flex-1 overflow-auto\">\n {main}\n </div>\n\n {!isSideCollapsed && (\n <>\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-valuenow={Math.round(sideWidth)}\n aria-valuemin={MIN_SIDE_WIDTH}\n aria-valuemax={MAX_SIDE_WIDTH}\n aria-label={resizeHandleAriaLabel}\n tabIndex={0}\n data-slot=\"resizable-split-pane-handle\"\n onPointerDown={handleHandlePointerDown}\n onKeyDown={handleHandleKeyDown}\n className={splitPaneHandleVariants()}\n />\n <div\n data-slot=\"resizable-split-pane-side\"\n style={{ width: `${sideWidth}%` }}\n className=\"min-h-0 shrink-0 overflow-auto\"\n >\n {side}\n </div>\n </>\n )}\n\n <button\n type=\"button\"\n data-slot=\"resizable-split-pane-collapse-button\"\n aria-label={collapseButtonAriaLabel}\n aria-expanded={!isSideCollapsed}\n onClick={onToggleSideCollapsed}\n className={splitPaneCollapseButtonVariants()}\n >\n {isSideCollapsed ? \"‹\" : \"›\"}\n </button>\n </div>\n );\n}\n\nMosaicResizableSplitPane.displayName = \"MosaicResizableSplitPane\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/resizable-split-pane/split-pane-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * splitPaneVariants — pure CVA variant functions for MosaicResizableSplitPane.\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 — flex row hosting main pane, handle, side pane. */\nexport const splitPaneRootVariants = cva([\"flex h-full w-full min-h-0\"]);\n\n/** Draggable resize handle between the two panes. */\nexport const splitPaneHandleVariants = cva([\n \"relative w-1 shrink-0 cursor-col-resize touch-none select-none bg-border\",\n \"transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n]);\n\n/** Collapse/expand toggle button, anchored next to the handle. */\nexport const splitPaneCollapseButtonVariants = cva([\n \"inline-flex h-11 w-6 shrink-0 items-center justify-center self-center rounded-md border border-border text-sm\",\n \"transition-colors hover:bg-accent/50\",\n]);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-save-chat-as-memory-form",
|
|
4
|
+
"title": "MosaicSaveChatAsMemoryForm",
|
|
5
|
+
"description": "MosaicSaveChatAsMemoryForm — presentational \"turn this thread into agency knowledge\" form: the chat → memory bridge.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-input.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-tag-input.json",
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-textarea.json"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/components/save-chat-as-memory-form/MosaicSaveChatAsMemoryForm.tsx",
|
|
15
|
+
"type": "registry:ui",
|
|
16
|
+
"content": "/**\n * MosaicSaveChatAsMemoryForm — presentational \"turn this thread into agency\n * knowledge\" form: the chat → memory bridge.\n *\n * Presentational atom composed from existing mosaic-blocks primitives:\n * MosaicInput, MosaicTextarea and MosaicTagInput. This component never\n * invents a new form field or tag chip — it assembles the ones the library\n * already ships (same doctrine as MosaicAddMemoryForm / MosaicEditMemoryDialog).\n *\n * Zero extraction, zero I/O: the component does NOT read the chat, does NOT\n * summarize it and does NOT decide what is worth remembering — it renders\n * whatever the host already extracted as a fully controlled `content` value,\n * lets the host user title/tag it, and routes save/cancel through host\n * callbacks. No network call of any kind lives in this component.\n *\n * Fully controlled: `title`/`content`/`tags` are single-source-of-truth\n * values supplied by the host, every change is reported via a callback. The\n * component keeps no internal form state.\n *\n * Validation belongs to the host (SIN-01 + doctrine \"the host decides\"):\n * `canSave` is a host-computed boolean gating the save button, and\n * `titleError`/`contentError` are host-computed strings — this component\n * only *displays* an error, it never decides whether one exists. When an\n * error string is supplied, the matching field gets `aria-invalid=\"true\"`\n * and `aria-describedby` pointing at the rendered error text; the field is\n * `aria-invalid=\"false\"` otherwise, so the absence of an error is never\n * ambiguous.\n *\n * isSaving sets `aria-busy=\"true\"` on the save button and disables both\n * actions — a save-in-progress is announced, never silent.\n *\n * data-slot=\"save-chat-as-memory-form\" on the form root.\n * Bilingual: every user-facing string (labels/placeholders/errors/button\n * labels) is a required host-supplied prop — zero hardcoded copy, zero\n * default (SIN-01).\n *\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --destructive, --foreground.\n *\n * @example\n * <MosaicSaveChatAsMemoryForm\n * title={title}\n * onTitleChange={setTitle}\n * titleLabel=\"Title\"\n * titleError={titleError}\n * content={extractedContent}\n * onContentChange={setContent}\n * contentLabel=\"Content\"\n * contentError={contentError}\n * tags={tags}\n * onAddTag={(t) => setTags((prev) => [...prev, t])}\n * onRemoveTag={(t) => setTags((prev) => prev.filter((x) => x !== t))}\n * tagsLabel=\"Tags\"\n * tagInputPlaceholder=\"Add a tag…\"\n * removeTagAriaLabel={(t) => `Remove ${t}`}\n * isSaving={isSaving}\n * canSave={canSave}\n * onSave={handleSave}\n * onCancel={() => setOpen(false)}\n * saveLabel=\"Save Memory\"\n * savingLabel=\"Saving…\"\n * cancelLabel=\"Cancel\"\n * />\n */\n\nimport { useId } from \"react\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { MosaicTagInput } from \"@/components/ui/MosaicTagInput\";\nimport { MosaicTextarea } from \"@/components/ui/MosaicTextarea\";\nimport {\n saveChatAsMemoryFormButtonVariants,\n saveChatAsMemoryFormErrorVariants,\n saveChatAsMemoryFormFieldVariants,\n saveChatAsMemoryFormFooterVariants,\n saveChatAsMemoryFormRootVariants,\n} from \"./save-chat-as-memory-form-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSaveChatAsMemoryFormProps {\n /** Current memory title value — controlled. */\n title: string;\n /** Called on every keystroke in the title field. */\n onTitleChange: (value: string) => void;\n /** Label for the title field. Required, no default. */\n titleLabel: string;\n /** Placeholder for the title field. */\n titlePlaceholder?: string;\n /** Host-computed validation message for the title field, or absent when valid. */\n titleError?: string;\n\n /**\n * Host-supplied, pre-extracted content value — controlled. This component\n * never reads or summarizes the source thread; the host is the sole\n * source of the extracted text.\n */\n content: string;\n /** Called on every keystroke in the content field. */\n onContentChange: (value: string) => void;\n /** Label for the content field. Required, no default. */\n contentLabel: string;\n /** Placeholder for the content field. */\n contentPlaceholder?: string;\n /** Host-computed validation message for the content field, or absent when valid. */\n contentError?: string;\n\n /** Current tag list — controlled, single source of truth owned by the host. */\n tags: string[];\n /** Called when a tag should be added. */\n onAddTag: (tag: string) => void;\n /** Called when a tag should be removed. */\n onRemoveTag: (tag: string) => void;\n /** Label for the tags field. Required, no default. */\n tagsLabel: string;\n /** Placeholder for the tag input. Required, no default. */\n tagInputPlaceholder: string;\n /** Per-tag accessible name for the remove button. Required, no default. */\n removeTagAriaLabel: (tag: string) => string;\n /** Optional host-supplied suggested tags. */\n suggestedTags?: string[];\n /** Optional maximum number of tags. */\n maxTags?: number;\n\n /** True while a save request is in flight — announced via aria-busy, disables both actions. */\n isSaving: boolean;\n /**\n * Host-computed form validity gating the save button. This component\n * never decides validation itself — it only reflects the host's verdict.\n */\n canSave: boolean;\n /** Called when the host user saves the form. */\n onSave: () => void;\n /** Called when the host user clicks Cancel. */\n onCancel: () => void;\n /** Label for the save button while idle. Required, no default. */\n saveLabel: string;\n /** Label for the save button while isSaving=true. Required, no default. */\n savingLabel: string;\n /** Label for the cancel button. Required, no default. */\n cancelLabel: string;\n\n /** Additional Tailwind classes on the form root. */\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSaveChatAsMemoryForm — production \"save this thread as a memory\"\n * form for @vantageos/mosaic-blocks.\n *\n * Purely presentational and fully controlled: composes MosaicInput +\n * MosaicTextarea + MosaicTagInput. No network call, no extraction logic, no\n * built-in validation, no built-in copy.\n */\nexport function MosaicSaveChatAsMemoryForm({\n title,\n onTitleChange,\n titleLabel,\n titlePlaceholder,\n titleError,\n content,\n onContentChange,\n contentLabel,\n contentPlaceholder,\n contentError,\n tags,\n onAddTag,\n onRemoveTag,\n tagsLabel,\n tagInputPlaceholder,\n removeTagAriaLabel,\n suggestedTags,\n maxTags,\n isSaving,\n canSave,\n onSave,\n onCancel,\n saveLabel,\n savingLabel,\n cancelLabel,\n className,\n}: MosaicSaveChatAsMemoryFormProps) {\n const titleErrorId = useId();\n const contentErrorId = useId();\n\n return (\n <div\n data-slot=\"save-chat-as-memory-form\"\n className={cn(saveChatAsMemoryFormRootVariants(), className)}\n >\n <div className={saveChatAsMemoryFormFieldVariants()}>\n <label\n htmlFor=\"mosaic-save-chat-as-memory-title\"\n className=\"text-sm font-medium text-foreground\"\n >\n {titleLabel}\n </label>\n <MosaicInput\n id=\"mosaic-save-chat-as-memory-title\"\n value={title}\n placeholder={titlePlaceholder}\n onChange={(e) => onTitleChange(e.target.value)}\n aria-invalid={titleError ? \"true\" : \"false\"}\n aria-describedby={titleError ? titleErrorId : undefined}\n />\n {titleError && (\n <p id={titleErrorId} className={saveChatAsMemoryFormErrorVariants()}>\n {titleError}\n </p>\n )}\n </div>\n\n <div className={saveChatAsMemoryFormFieldVariants()}>\n <label\n htmlFor=\"mosaic-save-chat-as-memory-content\"\n className=\"text-sm font-medium text-foreground\"\n >\n {contentLabel}\n </label>\n <MosaicTextarea\n id=\"mosaic-save-chat-as-memory-content\"\n value={content}\n placeholder={contentPlaceholder}\n onChange={(e) => onContentChange(e.target.value)}\n rows={4}\n aria-invalid={contentError ? \"true\" : \"false\"}\n aria-describedby={contentError ? contentErrorId : undefined}\n />\n {contentError && (\n <p id={contentErrorId} className={saveChatAsMemoryFormErrorVariants()}>\n {contentError}\n </p>\n )}\n </div>\n\n <div className={saveChatAsMemoryFormFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{tagsLabel}</span>\n <MosaicTagInput\n tags={tags}\n onAddTag={onAddTag}\n onRemoveTag={onRemoveTag}\n placeholder={tagInputPlaceholder}\n removeTagAriaLabel={removeTagAriaLabel}\n suggestions={suggestedTags}\n maxTags={maxTags}\n />\n </div>\n\n <div className={saveChatAsMemoryFormFooterVariants()}>\n <button\n type=\"button\"\n data-slot=\"save-chat-as-memory-form-cancel-button\"\n onClick={onCancel}\n disabled={isSaving}\n className={saveChatAsMemoryFormButtonVariants({ intent: \"cancel\" })}\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n data-slot=\"save-chat-as-memory-form-save-button\"\n onClick={onSave}\n disabled={!canSave || isSaving}\n aria-busy={isSaving ? \"true\" : \"false\"}\n className={saveChatAsMemoryFormButtonVariants({ intent: \"save\" })}\n >\n {isSaving ? savingLabel : saveLabel}\n </button>\n </div>\n </div>\n );\n}\n\nMosaicSaveChatAsMemoryForm.displayName = \"MosaicSaveChatAsMemoryForm\";\n"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "src/components/save-chat-as-memory-form/save-chat-as-memory-form-variants.ts",
|
|
20
|
+
"type": "registry:ui",
|
|
21
|
+
"content": "/**\n * saveChatAsMemoryFormVariants — pure CVA variant functions for\n * MosaicSaveChatAsMemoryForm.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Form vertical layout. */\nexport const saveChatAsMemoryFormRootVariants = cva([\"flex flex-col gap-4\"]);\n\n/** Field group (label + control + helper/error) vertical layout. */\nexport const saveChatAsMemoryFormFieldVariants = cva([\"flex flex-col gap-1.5\"]);\n\n/** Field error text. */\nexport const saveChatAsMemoryFormErrorVariants = cva([\"text-xs font-medium text-destructive\"]);\n\n/** Footer action row. */\nexport const saveChatAsMemoryFormFooterVariants = cva([\n \"flex items-center justify-end gap-3 border-t border-border pt-4\",\n]);\n\n/** Save / cancel button variants by intent. */\nexport const saveChatAsMemoryFormButtonVariants = cva(\n [\n \"inline-flex min-h-9 items-center justify-center gap-2 rounded-md px-4 text-sm font-medium\",\n \"transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n ],\n {\n variants: {\n intent: {\n cancel: \"border border-border bg-background hover:bg-muted\",\n save: \"border border-transparent bg-primary text-primary-foreground hover:bg-primary/90\",\n },\n },\n defaultVariants: {\n intent: \"cancel\",\n },\n },\n);\n"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"type": "registry:ui"
|
|
25
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-save-template-modal",
|
|
4
|
+
"title": "MosaicSaveTemplateModal",
|
|
5
|
+
"description": "MosaicSaveTemplateModal — presentational \"save as template\" form modal",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-adaptive-modal.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-input.json",
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-select.json",
|
|
11
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-tag-input.json",
|
|
12
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-textarea.json"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "src/components/save-template-modal/MosaicSaveTemplateModal.tsx",
|
|
17
|
+
"type": "registry:ui",
|
|
18
|
+
"content": "/**\n * MosaicSaveTemplateModal — presentational \"save as template\" form modal\n *\n * Ported (source: private upstream) components/templates/SaveTemplateModal.tsx\n *\n * Presentational atom composed from existing mosaic-blocks primitives:\n * MosaicAdaptiveModal (dialog/sheet shell), MosaicInput, MosaicTextarea,\n * MosaicSelect and MosaicTagInput (tags). This component never invents a\n * new modal, form field, or tag chip — it assembles the ones the library\n * already ships.\n *\n * Fully controlled: `open`/`onOpenChange` own visibility, `name`/\n * `templateDescription`/`category`/`tags` are single-source-of-truth values\n * supplied by the host, every change is reported via a callback. The\n * component keeps no internal form state.\n *\n * Validation belongs to the host (SIN-01 + doctrine \"the host decides\"):\n * `canSave` is a host-computed boolean gating the save button, and\n * `nameError`/`descriptionError` are host-computed strings — this\n * component only *displays* an error, it never decides whether one exists.\n * When an error string is supplied, the matching field gets\n * `aria-invalid=\"true\"` and `aria-describedby` pointing at the rendered\n * error text; the field is `aria-invalid=\"false\"` otherwise, so the\n * absence of an error is never ambiguous.\n *\n * No hardcoded taxonomy: `categories` is a required host-supplied list\n * (business taxonomy is client knowledge, never baked into the library).\n * Suggested tags (`suggestedTags`) are likewise entirely host-supplied.\n *\n * Escape closes the modal WITHOUT saving — MosaicAdaptiveModal maps the\n * native `<dialog>` \"cancel\" event (fired on Escape) straight to\n * `onOpenChange(false)`; `onSave` is never called as a side effect of\n * closing. isSaving sets `aria-busy=\"true\"` on the save button and\n * disables both actions — a save-in-progress is announced, never silent.\n *\n * `children` is an optional host-rendered slot rendered above the footer\n * actions (e.g. an app-specific \"agents in this template\" summary) — the\n * library never bakes in a preview of anything domain-specific.\n *\n * data-slot=\"save-template-modal\" on the form body.\n * Bilingual: every user-facing string (title/description/labels/\n * placeholders/errors/button labels) is a required host-supplied prop —\n * zero hardcoded copy, zero default (SIN-01).\n *\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --destructive, --foreground, --muted-foreground.\n *\n * @example\n * <MosaicSaveTemplateModal\n * open={open}\n * onOpenChange={setOpen}\n * title=\"Enregistrer comme modèle\"\n * closeAriaLabel=\"Fermer\"\n * name={name}\n * onNameChange={setName}\n * nameLabel=\"Nom du modèle\"\n * nameError={nameError}\n * templateDescription={description}\n * onTemplateDescriptionChange={setDescription}\n * descriptionLabel=\"Description\"\n * categories={categories}\n * category={category}\n * onCategoryChange={setCategory}\n * categoryLabel=\"Catégorie\"\n * tags={tags}\n * onAddTag={(t) => setTags((prev) => [...prev, t])}\n * onRemoveTag={(t) => setTags((prev) => prev.filter((x) => x !== t))}\n * tagsLabel=\"Étiquettes\"\n * tagInputPlaceholder=\"Ajouter une étiquette…\"\n * removeTagAriaLabel={(t) => `Retirer ${t}`}\n * isSaving={isSaving}\n * canSave={canSave}\n * onSave={handleSave}\n * onCancel={() => setOpen(false)}\n * saveButtonLabel=\"Enregistrer\"\n * savingLabel=\"Enregistrement…\"\n * cancelButtonLabel=\"Annuler\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useId } from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { MosaicSelect, type MosaicSelectItem } from \"@/components/ui/MosaicSelect\";\nimport { MosaicTagInput } from \"@/components/ui/MosaicTagInput\";\nimport { MosaicTextarea } from \"@/components/ui/MosaicTextarea\";\nimport {\n saveTemplateModalBodyVariants,\n saveTemplateModalButtonVariants,\n saveTemplateModalErrorVariants,\n saveTemplateModalFieldVariants,\n saveTemplateModalFooterVariants,\n} from \"./save-template-modal-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 MosaicSaveTemplateModalProps {\n /** Controlled open state — the host owns the source of truth. */\n open: boolean;\n /** Called whenever the modal wants to change its open state (save, cancel, Escape, backdrop click). */\n onOpenChange: (open: boolean) => void;\n /** Modal heading. Required, no default. */\n title: string;\n /** Optional modal subheading. */\n description?: string;\n /** Accessible name for the desktop close button, forwarded to MosaicAdaptiveModal. */\n closeAriaLabel: string;\n\n /** Current template name value — controlled. */\n name: string;\n /** Called on every keystroke in the name field. */\n onNameChange: (value: string) => void;\n /** Label for the name field. Required, no default. */\n nameLabel: string;\n /** Placeholder for the name field. */\n namePlaceholder?: string;\n /** Host-computed validation message for the name field, or absent when valid. */\n nameError?: string;\n\n /** Current template description value — controlled. */\n templateDescription: string;\n /** Called on every keystroke in the description field. */\n onTemplateDescriptionChange: (value: string) => void;\n /** Label for the description field. Required, no default. */\n descriptionLabel: string;\n /** Placeholder for the description field. */\n descriptionPlaceholder?: string;\n /** Host-computed validation message for the description field, or absent when valid. */\n descriptionError?: string;\n\n /** Host-supplied category taxonomy — never hardcoded in the library. */\n categories: MosaicSelectItem[];\n /** Currently selected category value — controlled. */\n category: string;\n /** Called when the host user picks a different category. */\n onCategoryChange: (value: string) => void;\n /** Label for the category field. Required, no default. */\n categoryLabel: string;\n\n /** Current tag list — controlled, single source of truth owned by the host. */\n tags: string[];\n /** Called when a tag should be added. */\n onAddTag: (tag: string) => void;\n /** Called when a tag should be removed. */\n onRemoveTag: (tag: string) => void;\n /** Label for the tags field. Required, no default. */\n tagsLabel: string;\n /** Placeholder for the tag input. Required, no default. */\n tagInputPlaceholder: string;\n /** Per-tag accessible name for the remove button. Required, no default. */\n removeTagAriaLabel: (tag: string) => string;\n /** Optional host-supplied suggested tags (e.g. derived from the chosen category). */\n suggestedTags?: string[];\n /** Optional maximum number of tags. */\n maxTags?: number;\n\n /** True while a save request is in flight — announced via aria-busy, disables both actions. */\n isSaving: boolean;\n /**\n * Host-computed form validity gating the save button. This component\n * never decides validation itself — it only reflects the host's verdict.\n */\n canSave: boolean;\n /** Called when the host user submits the form. Never called on Escape/backdrop close. */\n onSave: () => void;\n /** Called when the host user clicks Cancel. */\n onCancel: () => void;\n /** Label for the save button while idle. Required, no default. */\n saveButtonLabel: string;\n /** Label for the save button while isSaving=true. Required, no default. */\n savingLabel: string;\n /** Label for the cancel button. Required, no default. */\n cancelButtonLabel: string;\n\n /** Optional host-rendered extra content, shown above the footer actions. */\n children?: React.ReactNode;\n /** Additional Tailwind classes on the modal body. */\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSaveTemplateModal — production \"save as template\" form modal for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational and fully controlled: composes MosaicAdaptiveModal +\n * MosaicInput + MosaicTextarea + MosaicSelect + MosaicTagInput. No network\n * call, no built-in taxonomy, no built-in validation, no built-in copy.\n */\nexport function MosaicSaveTemplateModal({\n open,\n onOpenChange,\n title,\n description,\n closeAriaLabel,\n name,\n onNameChange,\n nameLabel,\n namePlaceholder,\n nameError,\n templateDescription,\n onTemplateDescriptionChange,\n descriptionLabel,\n descriptionPlaceholder,\n descriptionError,\n categories,\n category,\n onCategoryChange,\n categoryLabel,\n tags,\n onAddTag,\n onRemoveTag,\n tagsLabel,\n tagInputPlaceholder,\n removeTagAriaLabel,\n suggestedTags,\n maxTags,\n isSaving,\n canSave,\n onSave,\n onCancel,\n saveButtonLabel,\n savingLabel,\n cancelButtonLabel,\n children,\n className,\n}: MosaicSaveTemplateModalProps) {\n const nameErrorId = useId();\n const descriptionErrorId = useId();\n\n if (!open) return null;\n\n return (\n <MosaicAdaptiveModal\n isOpen={open}\n onClose={() => onOpenChange(false)}\n title={title}\n description={description}\n closeAriaLabel={closeAriaLabel}\n >\n <div\n data-slot=\"save-template-modal\"\n className={cn(saveTemplateModalBodyVariants(), className)}\n >\n <div className={saveTemplateModalFieldVariants()}>\n <label\n htmlFor=\"mosaic-save-template-name\"\n className=\"text-sm font-medium text-foreground\"\n >\n {nameLabel}\n </label>\n <MosaicInput\n id=\"mosaic-save-template-name\"\n value={name}\n placeholder={namePlaceholder}\n onChange={(e) => onNameChange(e.target.value)}\n aria-invalid={nameError ? \"true\" : \"false\"}\n aria-describedby={nameError ? nameErrorId : undefined}\n />\n {nameError && (\n <p id={nameErrorId} className={saveTemplateModalErrorVariants()}>\n {nameError}\n </p>\n )}\n </div>\n\n <div className={saveTemplateModalFieldVariants()}>\n <label\n htmlFor=\"mosaic-save-template-description\"\n className=\"text-sm font-medium text-foreground\"\n >\n {descriptionLabel}\n </label>\n <MosaicTextarea\n id=\"mosaic-save-template-description\"\n value={templateDescription}\n placeholder={descriptionPlaceholder}\n onChange={(e) => onTemplateDescriptionChange(e.target.value)}\n rows={3}\n aria-invalid={descriptionError ? \"true\" : \"false\"}\n aria-describedby={descriptionError ? descriptionErrorId : undefined}\n />\n {descriptionError && (\n <p id={descriptionErrorId} className={saveTemplateModalErrorVariants()}>\n {descriptionError}\n </p>\n )}\n </div>\n\n <div className={saveTemplateModalFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{categoryLabel}</span>\n <MosaicSelect\n items={categories}\n value={category}\n onValueChange={(value) => {\n if (value) onCategoryChange(value);\n }}\n />\n </div>\n\n <div className={saveTemplateModalFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{tagsLabel}</span>\n <MosaicTagInput\n tags={tags}\n onAddTag={onAddTag}\n onRemoveTag={onRemoveTag}\n placeholder={tagInputPlaceholder}\n removeTagAriaLabel={removeTagAriaLabel}\n suggestions={suggestedTags}\n maxTags={maxTags}\n />\n </div>\n\n {children}\n\n <div className={saveTemplateModalFooterVariants()}>\n <button\n type=\"button\"\n data-slot=\"save-template-modal-cancel-button\"\n onClick={onCancel}\n disabled={isSaving}\n className={saveTemplateModalButtonVariants({ intent: \"cancel\" })}\n >\n {cancelButtonLabel}\n </button>\n <button\n type=\"button\"\n data-slot=\"save-template-modal-save-button\"\n onClick={onSave}\n disabled={!canSave || isSaving}\n aria-busy={isSaving ? \"true\" : \"false\"}\n className={saveTemplateModalButtonVariants({ intent: \"save\" })}\n >\n {isSaving ? savingLabel : saveButtonLabel}\n </button>\n </div>\n </div>\n </MosaicAdaptiveModal>\n );\n}\n\nMosaicSaveTemplateModal.displayName = \"MosaicSaveTemplateModal\";\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "src/components/save-template-modal/save-template-modal-variants.ts",
|
|
22
|
+
"type": "registry:ui",
|
|
23
|
+
"content": "/**\n * saveTemplateModalVariants — pure CVA variant functions for\n * MosaicSaveTemplateModal.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Form body vertical layout. */\nexport const saveTemplateModalBodyVariants = cva([\"flex flex-col gap-4\"]);\n\n/** Field group (label + control + helper/error) vertical layout. */\nexport const saveTemplateModalFieldVariants = cva([\"flex flex-col gap-1.5\"]);\n\n/** Field error text. */\nexport const saveTemplateModalErrorVariants = cva([\"text-xs font-medium text-destructive\"]);\n\n/** Footer action row. */\nexport const saveTemplateModalFooterVariants = cva([\n \"flex items-center justify-end gap-3 border-t border-border pt-4\",\n]);\n\n/** Submit / cancel button variants by intent. */\nexport const saveTemplateModalButtonVariants = cva(\n [\n \"inline-flex min-h-9 items-center justify-center gap-2 rounded-md px-4 text-sm font-medium\",\n \"transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n ],\n {\n variants: {\n intent: {\n cancel: \"border border-border bg-background hover:bg-muted\",\n save: \"border border-transparent bg-primary text-primary-foreground hover:bg-primary/90\",\n },\n },\n defaultVariants: {\n intent: \"cancel\",\n },\n },\n);\n"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"type": "registry:ui"
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-scroll-area",
|
|
4
|
+
"title": "MosaicScrollArea",
|
|
5
|
+
"description": "MosaicScrollArea — @base-ui/react ScrollArea primitive",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/scroll-area/MosaicScrollArea.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicScrollArea — @base-ui/react ScrollArea primitive\n *\n * Builds on ScrollArea.Root + ScrollArea.Viewport + ScrollArea.Content +\n * ScrollArea.Scrollbar + ScrollArea.Thumb + ScrollArea.Corner.\n * Custom scrollbar styling that matches design tokens.\n * Native scroll behavior with custom scrollbar overlay.\n *\n * data-slot=\"scroll-area\" on Root, \"scroll-area-viewport\" on Viewport,\n * \"scroll-area-scrollbar\" on Scrollbar, \"scroll-area-thumb\" on Thumb.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { ScrollArea } from \"@base-ui/react/scroll-area\";\nimport type * as React from \"react\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicScrollAreaProps extends ScrollArea.Root.Props {\n className?: string;\n /** Whether to show horizontal scrollbar. @default false */\n horizontal?: boolean;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicScrollArea — production ScrollArea atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/scroll-area. Custom scrollbar with semantic tokens.\n * Shows vertical scrollbar by default; set horizontal to show horizontal bar too.\n *\n * @example\n * <MosaicScrollArea className=\"h-48\">\n * <div>Long content here…</div>\n * </MosaicScrollArea>\n */\nexport function MosaicScrollArea({\n className,\n horizontal = false,\n children,\n ref,\n ...props\n}: MosaicScrollAreaProps) {\n return (\n <ScrollArea.Root\n ref={ref}\n data-slot=\"scroll-area\"\n className={cn(\"relative overflow-hidden\", className)}\n {...props}\n >\n <ScrollArea.Viewport data-slot=\"scroll-area-viewport\" className=\"size-full rounded-[inherit]\">\n <ScrollArea.Content>{children}</ScrollArea.Content>\n </ScrollArea.Viewport>\n\n {/* Vertical scrollbar */}\n <ScrollArea.Scrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation=\"vertical\"\n className=\"flex w-2.5 touch-none select-none border-l border-l-transparent p-px transition-colors\"\n >\n <ScrollArea.Thumb className=\"relative flex-1 rounded-full bg-border\" />\n </ScrollArea.Scrollbar>\n\n {/* Horizontal scrollbar (opt-in) */}\n {horizontal && (\n <ScrollArea.Scrollbar\n data-slot=\"scroll-area-scrollbar-h\"\n orientation=\"horizontal\"\n className=\"flex h-2.5 touch-none select-none flex-col border-t border-t-transparent p-px transition-colors\"\n >\n <ScrollArea.Thumb className=\"relative flex-1 rounded-full bg-border\" />\n </ScrollArea.Scrollbar>\n )}\n\n <ScrollArea.Corner />\n </ScrollArea.Root>\n );\n}\n\nMosaicScrollArea.displayName = \"MosaicScrollArea\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-select",
|
|
4
|
+
"title": "MosaicSelect",
|
|
5
|
+
"description": "Listbox select built on @base-ui/react/select. Props: items[], value, onValueChange, placeholder. Keyboard + focus management. data-slot=\"select\".",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/select/MosaicSelect.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicSelect — @base-ui/react Select primitive\n *\n * Builds on Select.Root / Trigger / Value / Portal / Positioner / Popup / Item.\n * Props: items[], value, onValueChange, placeholder.\n *\n * data-slot=\"select\" on Trigger, \"select-popup\" on Popup.\n * Items render with role=option (managed by base-ui).\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Select } from \"@base-ui/react/select\";\nimport * as React from \"react\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSelectItem {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\nexport interface MosaicSelectProps {\n /** List of options to display */\n items: MosaicSelectItem[];\n /** Controlled value */\n value?: string;\n /** Callback when value changes. Receives null when selection is cleared. */\n onValueChange?: (value: string | null) => void;\n /** Placeholder text shown when no item is selected */\n placeholder?: string;\n /** Uncontrolled default value */\n defaultValue?: string;\n disabled?: boolean;\n required?: boolean;\n name?: string;\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSelect — production Select atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/select. Keyboard-accessible, portal-rendered popup.\n * Accepts a flat items[] array for simplicity over the compound pattern.\n *\n * @example\n * <MosaicSelect\n * items={[{ value: \"a\", label: \"Option A\" }]}\n * placeholder=\"Pick one\"\n * onValueChange={(v) => console.log(v)}\n * />\n */\nexport function MosaicSelect({\n items,\n value,\n onValueChange,\n placeholder,\n defaultValue,\n disabled,\n required,\n name,\n className,\n}: MosaicSelectProps) {\n // Build value→label lookup so Select.Value renders the label, not the raw value\n const labelMap = React.useMemo(\n () => Object.fromEntries(items.map((item) => [item.value, item.label])),\n [items],\n );\n\n return (\n <Select.Root\n value={value}\n onValueChange={onValueChange}\n defaultValue={defaultValue}\n disabled={disabled}\n required={required}\n name={name}\n >\n <Select.Trigger\n data-slot=\"select\"\n className={cn(\n \"inline-flex h-9 w-full min-w-[8rem] 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-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[popup-open]:ring-ring data-[popup-open]:ring-[3px]\",\n className,\n )}\n >\n <Select.Value placeholder={placeholder}>\n {(val: string | null) => (val != null && val in labelMap ? labelMap[val] : placeholder)}\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=\"select-popup\"\n className={cn(\n \"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border\",\n \"bg-popover p-1 text-popover-foreground shadow-md\",\n \"origin-[var(--transform-origin)]\",\n \"transition-[transform,scale,opacity]\",\n \"data-[open]:scale-100 data-[open]:opacity-100\",\n \"data-[ending-style]:scale-95 data-[ending-style]:opacity-0\",\n \"data-[starting-style]:scale-95 data-[starting-style]:opacity-0\",\n )}\n >\n <Select.List>\n {items.map((item) => (\n <Select.Item\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n className={cn(\n \"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5\",\n \"text-sm text-popover-foreground outline-none\",\n \"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n \"data-[selected]:font-medium\",\n )}\n >\n <Select.ItemText>{item.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 );\n}\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
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-selector-modal",
|
|
4
|
+
"title": "MosaicSelectorModal",
|
|
5
|
+
"description": "Generic searchable item picker modal. Search bar + category tabs + card grid. Confirm/cancel actions.",
|
|
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/selector-modal/MosaicSelectorModal.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicSelectorModal — generic searchable item picker modal\n *\n * Ported from components/agent-config/FrameworkSelector / PersonaSelector / RoleSelector\n * combined into a single generic pattern.\n *\n * Features:\n * - Search bar\n * - Optional tab/category filter\n * - Card grid (1 or 2 columns) with selection state\n * - Multi-step stepper support (prev/next) when used inside AgentBuilderModal\n * - \"Preview\" slot for selected item detail\n *\n * Domain data (items, categories) are fully externalized via props.\n * framer-motion replaced with CSS transitions.\n * Rendered inside MosaicAdaptiveModal (wave-1).\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 MosaicSelectorItem {\n id: string;\n name: string;\n description?: string;\n tags?: string[];\n /** Optional icon or emoji */\n icon?: React.ReactNode;\n /** Category key for tab filtering */\n category?: string;\n /** Additional metadata to surface in cards */\n meta?: Record<string, string | number | boolean>;\n}\n\nexport interface MosaicSelectorCategory {\n id: string;\n label: string;\n}\n\nexport interface MosaicSelectorModalProps {\n isOpen: boolean;\n onClose: () => void;\n /** Dialog title */\n title: string;\n /** Optional description under title */\n description?: string;\n items: MosaicSelectorItem[];\n /** Currently selected item id */\n selectedId?: string;\n onSelect: (item: MosaicSelectorItem) => void;\n /** If provided, renders category tabs */\n categories?: MosaicSelectorCategory[];\n /** Search placeholder text. Required, no default. */\n searchPlaceholder: string;\n /** Number of columns in the grid (1 or 2, default 2) */\n columns?: 1 | 2;\n /** Slot rendered alongside selected item for preview */\n renderPreview?: (item: MosaicSelectorItem) => React.ReactNode;\n /** Confirm button label. Required, no default. */\n confirmLabel: string;\n /** Cancel button label. Required, no default. */\n cancelLabel: string;\n /** Label for the \"All\" category tab. Required, no default. */\n allCategoryLabel: string;\n /** Message shown when the filtered item grid is empty. Required, no default. */\n emptyMessage: string;\n /** aria-label for the modal close button. Required, no default. */\n closeAriaLabel: string;\n className?: string;\n}\n\n// ── Search icon (inline SVG) ──────────────────────────────────────────────────\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 CheckIcon() {\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.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicSelectorModal({\n isOpen,\n onClose,\n title,\n description,\n items,\n selectedId,\n onSelect,\n categories,\n searchPlaceholder,\n columns = 2,\n renderPreview,\n confirmLabel,\n cancelLabel,\n allCategoryLabel,\n emptyMessage,\n closeAriaLabel,\n}: MosaicSelectorModalProps) {\n const [query, setQuery] = React.useState(\"\");\n const [activeCategory, setActiveCategory] = React.useState(\"all\");\n const [pendingId, setPendingId] = React.useState<string | undefined>(selectedId);\n\n // Reset pending when dialog opens\n React.useEffect(() => {\n if (isOpen) {\n setPendingId(selectedId);\n setQuery(\"\");\n setActiveCategory(\"all\");\n }\n }, [isOpen, selectedId]);\n\n const filtered = items.filter((item) => {\n const q = query.toLowerCase();\n const matchesQuery =\n !q ||\n item.name.toLowerCase().includes(q) ||\n (item.description ?? \"\").toLowerCase().includes(q) ||\n (item.tags ?? []).some((t) => t.toLowerCase().includes(q));\n const matchesCategory = activeCategory === \"all\" || item.category === activeCategory;\n return matchesQuery && matchesCategory;\n });\n\n const pendingItem = pendingId ? items.find((i) => i.id === pendingId) : undefined;\n\n const handleConfirm = () => {\n if (pendingItem) {\n onSelect(pendingItem);\n }\n onClose();\n };\n\n return (\n <MosaicAdaptiveModal\n isOpen={isOpen}\n onClose={onClose}\n title={title}\n description={description}\n closeAriaLabel={closeAriaLabel}\n >\n <div data-slot=\"selector-modal\" className=\"flex flex-col gap-4 p-4\">\n {/* Search */}\n <div className=\"relative\">\n <span className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\n <SearchIcon />\n </span>\n <input\n type=\"search\"\n value={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 text-foreground placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n />\n </div>\n\n {/* Category tabs */}\n {categories && categories.length > 0 && (\n <div className=\"flex gap-1 overflow-x-auto pb-1\">\n <button\n type=\"button\"\n onClick={() => setActiveCategory(\"all\")}\n className={cn(\n \"shrink-0 rounded-md px-3 py-1.5 text-sm font-medium transition-colors\",\n activeCategory === \"all\"\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground\",\n )}\n >\n {allCategoryLabel}\n </button>\n {categories.map((cat) => (\n <button\n key={cat.id}\n type=\"button\"\n onClick={() => setActiveCategory(cat.id)}\n className={cn(\n \"shrink-0 rounded-md px-3 py-1.5 text-sm font-medium transition-colors\",\n activeCategory === cat.id\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground\",\n )}\n >\n {cat.label}\n </button>\n ))}\n </div>\n )}\n\n {/* Item grid */}\n <div\n className={cn(\n \"max-h-[50vh] overflow-y-auto\",\n columns === 2 ? \"grid grid-cols-1 gap-3 sm:grid-cols-2\" : \"flex flex-col gap-3\",\n )}\n >\n {filtered.map((item) => {\n const isSelected = pendingId === item.id;\n return (\n <button\n key={item.id}\n type=\"button\"\n onClick={() => setPendingId(item.id)}\n className={cn(\n \"group relative rounded-lg border p-4 text-left transition-all duration-150\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n isSelected\n ? \"border-primary bg-primary/5 ring-2 ring-primary\"\n : \"border-border bg-card hover:border-primary/50\",\n )}\n >\n {isSelected && (\n <span className=\"absolute right-2 top-2 inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-primary-foreground\">\n <CheckIcon />\n </span>\n )}\n <div className=\"flex items-start gap-2\">\n {item.icon && <span className=\"mt-0.5 shrink-0\">{item.icon}</span>}\n <div className=\"min-w-0\">\n <p className=\"font-semibold text-sm text-foreground\">{item.name}</p>\n {item.description && (\n <p className=\"mt-1 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 bg-muted px-1.5 py-0.5 text-xs text-muted-foreground\"\n >\n {tag}\n </span>\n ))}\n </div>\n )}\n </div>\n </div>\n </button>\n );\n })}\n\n {filtered.length === 0 && (\n <p className=\"col-span-2 py-8 text-center text-sm text-muted-foreground\">\n {emptyMessage}\n </p>\n )}\n </div>\n\n {/* Preview slot */}\n {renderPreview && pendingItem && (\n <div className=\"rounded-lg border border-border bg-card p-4\">\n {renderPreview(pendingItem)}\n </div>\n )}\n\n {/* Actions */}\n <div className=\"flex justify-end gap-2 pt-2\">\n <button\n type=\"button\"\n onClick={onClose}\n className={cn(\n \"inline-flex min-h-[44px] items-center justify-center rounded-md border border-border\",\n \"bg-background px-4 py-2 text-sm font-medium text-foreground\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {cancelLabel}\n </button>\n <button\n type=\"button\"\n onClick={handleConfirm}\n disabled={!pendingItem}\n className={cn(\n \"inline-flex min-h-[44px] items-center justify-center rounded-md\",\n \"bg-primary px-4 py-2 text-sm font-medium text-primary-foreground\",\n \"hover:bg-primary/90\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n )}\n >\n {confirmLabel}\n </button>\n </div>\n </div>\n </MosaicAdaptiveModal>\n );\n}\n\nMosaicSelectorModal.displayName = \"MosaicSelectorModal\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-separator",
|
|
4
|
+
"title": "MosaicSeparator",
|
|
5
|
+
"description": "MosaicSeparator — @base-ui/react Separator primitive",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/separator/MosaicSeparator.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicSeparator — @base-ui/react Separator primitive\n *\n * A visual and semantic divider. Supports horizontal (default) and vertical orientations.\n * role=separator and aria attributes managed by the primitive automatically.\n *\n * data-slot=\"separator\" on the rendered element.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Separator } from \"@base-ui/react/separator\";\nimport type * as React from \"react\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSeparatorProps extends Separator.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSeparator — production Separator atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/separator. Accessible separator with role=\"separator\".\n * Supports horizontal and vertical orientations.\n *\n * @example\n * <MosaicSeparator />\n * <MosaicSeparator orientation=\"vertical\" className=\"h-8\" />\n */\nexport function MosaicSeparator({\n className,\n orientation = \"horizontal\",\n ref,\n ...props\n}: MosaicSeparatorProps) {\n return (\n <Separator\n ref={ref}\n data-slot=\"separator\"\n orientation={orientation}\n className={cn(\n \"shrink-0 bg-border\",\n orientation === \"vertical\" ? \"h-full w-px\" : \"h-px w-full\",\n className,\n )}\n {...props}\n />\n );\n}\n\nMosaicSeparator.displayName = \"MosaicSeparator\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-session-card",
|
|
4
|
+
"title": "MosaicSessionCard",
|
|
5
|
+
"description": "MosaicSessionCard — a single work-in-progress session at a glance (default / compact variants)",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-badge.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-card.json"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/session-card/MosaicSessionCard.tsx",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"content": "\"use client\";\n\n/**\n * MosaicSessionCard — a single work-in-progress session at a glance\n * (default / compact variants)\n *\n * A \"session\" is host data: a piece of work in progress (e.g. a mandate),\n * carrying an id, a title, a host-defined status, and a last-updated\n * timestamp. The card renders exactly that state — it never fetches,\n * derives, or infers anything of its own.\n *\n * Two density variants, modeled as ONE component with a `variant` prop\n * (not two components) — same doctrine as MosaicMemoryCard:\n * - `\"default\"` (default): full card, includes a labelled \"last updated\"\n * footer caption, produced by `formatUpdatedAt`.\n * - `\"compact\"`: single dense row, drops the \"last updated\" footer\n * entirely and never calls `formatUpdatedAt` — so it is NOT required on\n * this variant (no-lying-prop-contract: a prop is required exactly on\n * the branch that reads it).\n *\n * Selection is opt-in and travels as a pair: `onSelect` and `selectLabel`\n * are either both present or both absent. Absent (default) — the root is\n * a plain, non-interactive container: no `role=\"button\"`, no\n * `aria-label`. Present — the root becomes a keyboard-operable\n * button-role element (Enter/Space activate it, same as a native\n * `<button>`), with `aria-label={selectLabel}` required and host-owned\n * (SIN-01 — no fallback word).\n *\n * Composed from this repo's own primitives: `MosaicCard` (root/header/\n * content/footer) + `MosaicBadge` (status chip) — not re-implemented.\n *\n * Pattern: MosaicMemoryCard.tsx (data-slot, inline utility `cn`, React 19\n * ref prop, displayName, JSDoc, discriminated-union variant props).\n * Design tokens: --card, --card-foreground, --border, --muted-foreground,\n * --ring (via MosaicCard / MosaicBadge — no ad-hoc colors here).\n * Bilingual (SIN-01): zero user-facing strings hardcoded. `formatStatus` /\n * `formatUpdatedAt` / `selectLabel` are all host-owned, no default.\n * Zero I/O — the card never fetches; all state is host-supplied.\n *\n * @example\n * // Default variant — full card, \"last updated\" footer\n * <MosaicSessionCard\n * session={session}\n * formatStatus={(status) => t(`session.status.${status}`)}\n * formatUpdatedAt={(updatedAt) => t(\"session.updatedAt\", { value: formatRelative(updatedAt) })}\n * />\n *\n * @example\n * // Compact variant — no footer, no formatUpdatedAt call at all\n * <MosaicSessionCard\n * session={session}\n * variant=\"compact\"\n * formatStatus={(status) => t(`session.status.${status}`)}\n * />\n *\n * @example\n * // Selectable — onSelect + selectLabel travel together\n * <MosaicSessionCard\n * session={session}\n * formatStatus={(status) => t(`session.status.${status}`)}\n * formatUpdatedAt={(updatedAt) => formatRelative(updatedAt)}\n * onSelect={(id) => openSession(id)}\n * selectLabel={t(\"session.open\", { title: session.title })}\n * />\n */\n\nimport type * as React from \"react\";\nimport { MosaicBadge } from \"@/components/ui/MosaicBadge\";\nimport {\n MosaicCard,\n MosaicCardContent,\n MosaicCardFooter,\n MosaicCardHeader,\n} from \"@/components/ui/MosaicCard\";\nimport { sessionCardVariants } from \"./session-card-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicSessionStatus = \"active\" | \"waiting\" | \"blocked\" | \"done\";\n\nexport interface MosaicSessionData {\n id: string;\n title: string;\n status: MosaicSessionStatus;\n /** Epoch milliseconds. */\n updatedAt: number;\n}\n\n/** Props read unconditionally regardless of `variant` or selectability. */\nexport interface MosaicSessionCardBaseProps {\n session: MosaicSessionData;\n /**\n * Formatter mapping `session.status` to its displayed label. Required —\n * the host owns the language (e.g. `(status) => t(\\`session.status.\\${status}\\`)`).\n */\n formatStatus: (status: MosaicSessionStatus) => React.ReactNode;\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Discriminated union on `variant` — `formatUpdatedAt` is required EXACTLY\n * on the `\"default\"` member (the only one that renders a \"last updated\"\n * footer). The `\"compact\"` member never renders that footer and never\n * calls `formatUpdatedAt` — requiring it there would force every host to\n * supply a value the library never displays (a \"lying prop contract\").\n */\nexport type MosaicSessionCardVariantProps =\n | {\n /**\n * Full card layout with a labelled \"last updated\" footer.\n * Default when omitted.\n * @default \"default\"\n */\n variant?: \"default\";\n /**\n * Formatter producing the \"last updated\" caption from\n * `session.updatedAt`. Only ever rendered in the `\"default\"`\n * variant — required here, not on `\"compact\"`. Host-owned.\n */\n formatUpdatedAt: (updatedAt: number) => React.ReactNode;\n }\n | {\n /** Dense single-row layout — no \"last updated\" footer, no call. */\n variant: \"compact\";\n };\n\n/**\n * Discriminated union on selectability — `onSelect` and `selectLabel`\n * travel together. Absent by default: the root stays a plain,\n * non-interactive container. Present: the root becomes a keyboard-operable\n * `role=\"button\"` element and `selectLabel` (required, host-owned, no\n * default) becomes its `aria-label`.\n */\nexport type MosaicSessionCardInteractionProps =\n | { onSelect?: undefined; selectLabel?: undefined }\n | {\n /** Called with `session.id` on click / Enter / Space. */\n onSelect: (sessionId: string) => void;\n /** aria-label for the selectable root. Required — host-owned, no default. */\n selectLabel: string;\n };\n\nexport type MosaicSessionCardProps = MosaicSessionCardBaseProps &\n MosaicSessionCardVariantProps &\n MosaicSessionCardInteractionProps;\n\nconst ACTIVATION_KEYS = new Set([\"Enter\", \" \"]);\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSessionCard — production single-session card for\n * @vantageos/mosaic-blocks.\n *\n * One component, two density variants (`default` default / `compact`),\n * opt-in selectability — see file JSDoc for the exact prop contract.\n */\nexport function MosaicSessionCard(props: MosaicSessionCardProps) {\n const { session, formatStatus, className, ref, onSelect, selectLabel } = props;\n const selectable = Boolean(onSelect);\n\n function activate() {\n onSelect?.(session.id);\n }\n\n const interactionProps = selectable\n ? {\n role: \"button\" as const,\n tabIndex: 0,\n \"aria-label\": selectLabel,\n onClick: activate,\n onKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (ACTIVATION_KEYS.has(event.key)) {\n event.preventDefault();\n activate();\n }\n },\n }\n : {};\n\n const statusBadge = (\n <MosaicBadge data-slot=\"session-card-status\">{formatStatus(session.status)}</MosaicBadge>\n );\n\n if (props.variant === \"compact\") {\n return (\n <MosaicCard\n ref={ref}\n data-slot=\"session-card\"\n data-variant=\"compact\"\n className={cn(sessionCardVariants({ variant: \"compact\", selectable }), className)}\n {...interactionProps}\n >\n <span className=\"min-w-0 flex-1 truncate text-sm font-medium\">{session.title}</span>\n {statusBadge}\n </MosaicCard>\n );\n }\n\n return (\n <MosaicCard\n ref={ref}\n data-slot=\"session-card\"\n data-variant=\"default\"\n className={cn(sessionCardVariants({ variant: \"default\", selectable }), className)}\n {...interactionProps}\n >\n <MosaicCardHeader className=\"flex-row items-center justify-between gap-3 p-0\">\n <h3 className=\"line-clamp-1 text-base font-semibold\">{session.title}</h3>\n {statusBadge}\n </MosaicCardHeader>\n <MosaicCardContent className=\"p-0 pt-3\">\n <MosaicCardFooter\n data-slot=\"session-card-updated-at\"\n className=\"p-0 pt-2 text-xs text-muted-foreground\"\n >\n {props.formatUpdatedAt(session.updatedAt)}\n </MosaicCardFooter>\n </MosaicCardContent>\n </MosaicCard>\n );\n}\n\nMosaicSessionCard.displayName = \"MosaicSessionCard\";\n"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "src/components/session-card/session-card-variants.ts",
|
|
19
|
+
"type": "registry:ui",
|
|
20
|
+
"content": "/**\n * sessionCardVariants — pure CVA variant functions for MosaicSessionCard.\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/** Root card container variants */\nexport const sessionCardVariants = cva(\n [\n \"rounded-lg border border-border bg-card text-card-foreground shadow-sm transition-all\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n ],\n {\n variants: {\n variant: {\n default: \"p-5\",\n compact: \"flex items-center justify-between gap-3 p-3\",\n },\n selectable: {\n true: \"cursor-pointer hover:shadow-md\",\n false: \"\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n selectable: false,\n },\n },\n);\n"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"type": "registry:ui"
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-session-list",
|
|
4
|
+
"title": "MosaicSessionList",
|
|
5
|
+
"description": "MosaicSessionList — presentational, layout-disposition-only list of the workstation's in-progress sessions",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/session-list/MosaicSessionList.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicSessionList — presentational, layout-disposition-only list of the\n * workstation's in-progress sessions\n *\n * The source implementation shipped as FOUR separate list components\n * (\"stack\", \"grid\", \"compact\", \"inline\" dispositions). Merged here into\n * ONE variant-driven component — the list does not exist without the\n * card, and it does not exist four times over either: same doctrine as\n * MosaicMemoryList, applied to the `layout` axis instead of `density`.\n *\n * The list owns disposition ONLY:\n * - `items`: the host's array of sessions, each requiring only an `id`.\n * - `renderItem`: the host-supplied per-session renderer (typically a\n * `MosaicSessionCard`) — the list never renders a row of its own and\n * never hardcodes a status, a sort order, or any domain content\n * (no-hardcoded-business-knowledge). It never fetches its own data.\n * - `emptyMessage`: required, no default (SIN-01) — the host owns the\n * language, e.g. `t('SessionList.empty')`.\n *\n * Keyboard: roving tabindex across items (native `<ul>` / `<li>` —\n * semantic list roles come from the elements themselves) — ArrowDown/\n * ArrowRight moves focus to the next row, ArrowUp/ArrowLeft to the\n * previous, Home/End jump to the first/last. Exactly one item is\n * `tabIndex={0}` at a time; the rest are `tabIndex={-1}`. Behavior is the\n * same across all four `layout` values — only the container/item Tailwind\n * classes differ.\n *\n * Pattern: MosaicMemoryList.tsx (data-slot, inline utility `cn`, roving\n * tabindex, React 19 ref prop, displayName, JSDoc).\n */\n\nimport type * as React from \"react\";\nimport { useRef, useState } from \"react\";\nimport { sessionListItemVariants, sessionListVariants } from \"./session-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/** The four merged source dispositions, as ONE variant prop. */\nexport type MosaicSessionListLayout = \"stack\" | \"grid\" | \"compact\" | \"inline\";\n\nexport interface MosaicSessionListProps<T extends { id: string }> {\n /** The sessions to lay out. The list never inspects their shape beyond `id`. */\n items: T[];\n /** Host-owned renderer for a single session — the list owns disposition only. */\n renderItem: (item: T, index: number) => React.ReactNode;\n /**\n * Container disposition — the four merged source variants.\n * @default \"stack\"\n */\n layout?: MosaicSessionListLayout;\n /**\n * Message shown when `items` is empty. Required, no default — the host\n * owns the language (e.g. `t('SessionList.empty')`).\n */\n emptyMessage: string;\n /** Additional Tailwind classes on the root container. */\n className?: string;\n /** Additional Tailwind classes on each item 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 * MosaicSessionList — production layout-disposition atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: no filtering, no sorting, no item rendering, no\n * I/O — the host owns the session content via `renderItem`; this\n * component only owns the four merged layout dispositions and keyboard\n * roving-tabindex navigation.\n */\nexport function MosaicSessionList<T extends { id: string }>({\n items,\n renderItem,\n layout = \"stack\",\n emptyMessage,\n className,\n itemClassName,\n ref,\n}: MosaicSessionListProps<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=\"session-list\"\n data-layout={layout}\n className={cn(sessionListVariants({ layout }), className)}\n >\n <p\n data-slot=\"session-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=\"session-list\"\n data-layout={layout}\n className={cn(\"list-none\", sessionListVariants({ layout }), 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=\"session-list-item\"\n tabIndex={index === focusedIndex ? 0 : -1}\n onKeyDown={(event) => handleKeyDown(event, index)}\n onFocus={() => setFocusedIndex(index)}\n className={cn(sessionListItemVariants({ layout }), itemClassName)}\n >\n {renderItem(item, index)}\n </li>\n ))}\n </ul>\n );\n}\n\nMosaicSessionList.displayName = \"MosaicSessionList\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/session-list/session-list-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * sessionListVariants — pure CVA variant function for MosaicSessionList.\n *\n * The source implementation shipped as FOUR separate list components, one\n * per disposition. Merged here into ONE component with a `layout` variant\n * prop — the doctrine used throughout this repo (see MosaicMemoryCard,\n * MosaicMemoryList): one component, variants, never N components for what\n * is really the same `items` + `renderItem` + `emptyMessage` contract with\n * a different container layout.\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 — owns disposition ONLY; item content is entirely\n * host-supplied via `renderItem`.\n */\nexport const sessionListVariants = cva([], {\n variants: {\n layout: {\n /** Single-column vertical stack, divided rows. */\n stack: \"flex flex-col divide-y divide-border\",\n /** Responsive tile grid. */\n grid: \"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3\",\n /** Dense single-column stack — tighter row padding, no divider. */\n compact: \"flex flex-col gap-1\",\n /** Horizontal-scroll row of tiles. */\n inline: \"flex flex-row gap-3 overflow-x-auto\",\n },\n },\n defaultVariants: {\n layout: \"stack\",\n },\n});\n\n/** Per-item wrapper — spacing depends on the container layout. */\nexport const sessionListItemVariants = cva([], {\n variants: {\n layout: {\n stack: \"py-3\",\n grid: \"\",\n compact: \"py-1\",\n inline: \"shrink-0\",\n },\n },\n defaultVariants: {\n layout: \"stack\",\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-sign-in-layout",
|
|
4
|
+
"title": "MosaicSignInLayout",
|
|
5
|
+
"description": "Sign-in page layout, themed, mobile-first. Wraps Clerk <SignIn> with OKLCH-token appearance. Clerk injected as peer prop.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@clerk/nextjs"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/auth/sign-in-layout/MosaicSignInLayout.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicSignInLayout — sign-in page layout, themed, mobile-first.\n *\n * Wraps Clerk <SignIn> with OKLCH-token appearance prop. Clerk is injected as a\n * peer prop so mosaic-blocks does not bundle @clerk/nextjs directly.\n *\n * @example\n * import { SignIn } from \"@clerk/nextjs\"\n * <MosaicSignInLayout clerkSignIn={SignIn} />\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSignInLayoutProps {\n /** Clerk <SignIn> component — injected by caller to avoid bundling Clerk */\n clerkSignIn: React.ComponentType<{\n appearance?: Record<string, unknown>;\n signUpUrl?: string;\n signInUrl?: string;\n fallbackRedirectUrl?: string;\n forceRedirectUrl?: string;\n routing?: \"hash\" | \"path\" | \"virtual\";\n path?: string;\n [key: string]: unknown;\n }>;\n /** URL for sign-up page */\n signUpUrl?: string;\n /** URL for sign-in page (passed to the Clerk widget as signInUrl) */\n signInUrl?: string;\n /** URL to redirect after successful sign-in (Clerk v7 fallbackRedirectUrl) */\n afterSignInUrl?: string;\n /** Force redirect URL — overrides query-param-based redirects (Clerk v7) */\n forceRedirectUrl?: string;\n /**\n * Clerk routing mode for catch-all routes.\n * Required for [[...sign-in]] App Router pages. Defaults to \"path\" when path is set.\n */\n routing?: \"hash\" | \"path\" | \"virtual\";\n /**\n * Base path for \"path\" routing (e.g. \"/sign-in\").\n * Required when routing=\"path\".\n */\n path?: string;\n /** Optional headline above the Clerk widget */\n headline?: string;\n /** Optional sub-headline */\n subheadline?: string;\n className?: string;\n}\n\n// ── Clerk OKLCH appearance tokens ─────────────────────────────────────────────\n\nconst clerkAppearance = {\n variables: {\n colorPrimary: \"var(--primary)\",\n colorBackground: \"var(--background)\",\n colorText: \"var(--foreground)\",\n colorTextSecondary: \"var(--muted-foreground)\",\n colorInputBackground: \"var(--background)\",\n colorInputText: \"var(--foreground)\",\n colorNeutral: \"var(--foreground)\",\n borderRadius: \"0.5rem\",\n },\n elements: {\n card: \"shadow-none border border-border bg-card\",\n headerTitle: \"text-foreground font-semibold\",\n headerSubtitle: \"text-muted-foreground\",\n formButtonPrimary: \"bg-primary text-primary-foreground hover:bg-primary/90 shadow-none\",\n formFieldInput: \"border-input bg-background text-foreground focus:ring-ring\",\n footerActionLink: \"text-primary hover:text-primary/80\",\n identityPreviewEditButton: \"text-primary hover:text-primary/80\",\n dividerLine: \"bg-border\",\n dividerText: \"text-muted-foreground text-xs\",\n socialButtonsBlockButton:\n \"border-border text-foreground hover:bg-accent hover:text-accent-foreground\",\n },\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicSignInLayout({\n clerkSignIn: ClerkSignIn,\n signUpUrl = \"/sign-up\",\n signInUrl,\n afterSignInUrl = \"/\",\n forceRedirectUrl,\n routing,\n path,\n headline,\n subheadline,\n className,\n}: MosaicSignInLayoutProps) {\n return (\n <div\n data-slot=\"sign-in-layout\"\n className={[\n \"flex min-h-svh flex-col items-center justify-center\",\n \"bg-background px-4 py-12 sm:px-6 lg:px-8\",\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n >\n {(headline ?? subheadline) && (\n <div className=\"mb-8 text-center\">\n {headline && (\n <h1 className=\"text-2xl font-bold tracking-tight text-foreground sm:text-3xl\">\n {headline}\n </h1>\n )}\n {subheadline && <p className=\"mt-2 text-sm text-muted-foreground\">{subheadline}</p>}\n </div>\n )}\n <div className=\"w-full max-w-sm\">\n <ClerkSignIn\n appearance={clerkAppearance}\n signUpUrl={signUpUrl}\n {...(signInUrl !== undefined && { signInUrl })}\n fallbackRedirectUrl={afterSignInUrl}\n {...(forceRedirectUrl !== undefined && { forceRedirectUrl })}\n {...(routing !== undefined && { routing })}\n {...(path !== undefined && { path })}\n />\n </div>\n </div>\n );\n}\n\nMosaicSignInLayout.displayName = \"MosaicSignInLayout\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-sign-up-layout",
|
|
4
|
+
"title": "MosaicSignUpLayout",
|
|
5
|
+
"description": "Sign-up page layout, themed, mobile-first. Wraps Clerk <SignUp> with OKLCH-token appearance. Clerk injected as peer prop.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@clerk/nextjs"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/auth/sign-up-layout/MosaicSignUpLayout.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicSignUpLayout — sign-up page layout, themed, mobile-first.\n *\n * Wraps Clerk <SignUp> with OKLCH-token appearance prop. Clerk is injected as a\n * peer prop so mosaic-blocks does not bundle @clerk/nextjs directly.\n *\n * @example\n * import { SignUp } from \"@clerk/nextjs\"\n * <MosaicSignUpLayout clerkSignUp={SignUp} />\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSignUpLayoutProps {\n /** Clerk <SignUp> component — injected by caller to avoid bundling Clerk */\n clerkSignUp: React.ComponentType<{\n appearance?: Record<string, unknown>;\n signInUrl?: string;\n signUpUrl?: string;\n fallbackRedirectUrl?: string;\n forceRedirectUrl?: string;\n routing?: \"hash\" | \"path\" | \"virtual\";\n path?: string;\n [key: string]: unknown;\n }>;\n /** URL for sign-in page */\n signInUrl?: string;\n /** URL for sign-up page (passed to the Clerk widget as signUpUrl) */\n signUpUrl?: string;\n /** URL to redirect after successful sign-up (Clerk v7 fallbackRedirectUrl) */\n afterSignUpUrl?: string;\n /** Force redirect URL — overrides query-param-based redirects (Clerk v7) */\n forceRedirectUrl?: string;\n /**\n * Clerk routing mode for catch-all routes.\n * Required for [[...sign-up]] App Router pages. Defaults to \"path\" when path is set.\n */\n routing?: \"hash\" | \"path\" | \"virtual\";\n /**\n * Base path for \"path\" routing (e.g. \"/sign-up\").\n * Required when routing=\"path\".\n */\n path?: string;\n /** Optional headline above the Clerk widget */\n headline?: string;\n /** Optional sub-headline */\n subheadline?: string;\n className?: string;\n}\n\n// ── Clerk OKLCH appearance tokens ─────────────────────────────────────────────\n\nconst clerkAppearance = {\n variables: {\n colorPrimary: \"var(--primary)\",\n colorBackground: \"var(--background)\",\n colorText: \"var(--foreground)\",\n colorTextSecondary: \"var(--muted-foreground)\",\n colorInputBackground: \"var(--background)\",\n colorInputText: \"var(--foreground)\",\n colorNeutral: \"var(--foreground)\",\n borderRadius: \"0.5rem\",\n },\n elements: {\n card: \"shadow-none border border-border bg-card\",\n headerTitle: \"text-foreground font-semibold\",\n headerSubtitle: \"text-muted-foreground\",\n formButtonPrimary: \"bg-primary text-primary-foreground hover:bg-primary/90 shadow-none\",\n formFieldInput: \"border-input bg-background text-foreground focus:ring-ring\",\n footerActionLink: \"text-primary hover:text-primary/80\",\n identityPreviewEditButton: \"text-primary hover:text-primary/80\",\n dividerLine: \"bg-border\",\n dividerText: \"text-muted-foreground text-xs\",\n socialButtonsBlockButton:\n \"border-border text-foreground hover:bg-accent hover:text-accent-foreground\",\n },\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicSignUpLayout({\n clerkSignUp: ClerkSignUp,\n signInUrl = \"/sign-in\",\n signUpUrl,\n afterSignUpUrl = \"/\",\n forceRedirectUrl,\n routing,\n path,\n headline,\n subheadline,\n className,\n}: MosaicSignUpLayoutProps) {\n return (\n <div\n data-slot=\"sign-up-layout\"\n className={[\n \"flex min-h-svh flex-col items-center justify-center\",\n \"bg-background px-4 py-12 sm:px-6 lg:px-8\",\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n >\n {(headline ?? subheadline) && (\n <div className=\"mb-8 text-center\">\n {headline && (\n <h1 className=\"text-2xl font-bold tracking-tight text-foreground sm:text-3xl\">\n {headline}\n </h1>\n )}\n {subheadline && <p className=\"mt-2 text-sm text-muted-foreground\">{subheadline}</p>}\n </div>\n )}\n <div className=\"w-full max-w-sm\">\n <ClerkSignUp\n appearance={clerkAppearance}\n signInUrl={signInUrl}\n {...(signUpUrl !== undefined && { signUpUrl })}\n fallbackRedirectUrl={afterSignUpUrl}\n {...(forceRedirectUrl !== undefined && { forceRedirectUrl })}\n {...(routing !== undefined && { routing })}\n {...(path !== undefined && { path })}\n />\n </div>\n </div>\n );\n}\n\nMosaicSignUpLayout.displayName = \"MosaicSignUpLayout\";\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-skeleton",
|
|
4
|
+
"title": "MosaicSkeleton",
|
|
5
|
+
"description": "MosaicSkeleton — loading skeleton primitive for @vantageos/mosaic-blocks.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/skeleton/MosaicSkeleton.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicSkeleton — loading skeleton primitive for @vantageos/mosaic-blocks.\n *\n * Pulsing placeholder block using the muted token background (animate-pulse bg-muted).\n * Supports shape variants and multi-line text skeletons.\n *\n * Pattern: follows Button.tsx conventions (data-slot, React 19 ref prop,\n * inline cn helper, no \"use client\" — prepend-use-client.mjs handles dist).\n *\n * Closes issue #20 — replaces DashboardSkeleton + 11+ inline loading sites\n * in vantage-peers-dashboard.\n *\n * @example\n * // Single block\n * <MosaicSkeleton className=\"h-24 w-full\" />\n *\n * @example\n * // Multi-line text placeholder (3 lines, last ~60% width)\n * <MosaicSkeleton variant=\"text\" lines={3} />\n *\n * @example\n * // Avatar circle\n * <MosaicSkeleton variant=\"circle\" className=\"w-10\" />\n *\n * @example\n * // Button-shaped placeholder\n * <MosaicSkeleton variant=\"button\" className=\"w-24\" />\n */\n\nimport type { VariantProps } from \"class-variance-authority\";\nimport type * as React from \"react\";\nimport { skeletonVariants } from \"./skeleton-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 MosaicSkeletonProps\n extends React.HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof skeletonVariants> {\n /**\n * Number of stacked text lines to render.\n * Only effective when `variant=\"text\"`. When > 1, renders N lines\n * where the last line is ~60% width to mimic natural text flow.\n * @default 1\n */\n lines?: number;\n /** ref is typed as HTMLDivElement (React 19 prop, no forwardRef needed) */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSkeleton — production loading skeleton atom for @vantageos/mosaic-blocks.\n *\n * Renders an animated placeholder block. Use `variant` to control shape,\n * and `lines` (with `variant=\"text\"`) to render multi-line text skeletons.\n *\n * @example\n * <MosaicSkeleton className=\"h-24 w-full\" />\n * <MosaicSkeleton variant=\"text\" lines={3} />\n * <MosaicSkeleton variant=\"circle\" className=\"w-10\" />\n */\nexport function MosaicSkeleton({\n className,\n variant,\n lines = 1,\n ref,\n ...props\n}: MosaicSkeletonProps) {\n // Multi-line text skeleton: render N stacked lines, last one ~60% width\n if (variant === \"text\" && lines > 1) {\n // Build a stable key array from the line count — purely positional/static,\n // these placeholder divs never reorder, carry no state, and have no identity.\n const lineKeys = Array.from({ length: lines }, (_, i) => `line-${lines}-${i}`);\n return (\n <div\n ref={ref}\n data-slot=\"skeleton\"\n className={cn(\"flex flex-col gap-2\", className)}\n {...props}\n >\n {lineKeys.map((key, i) => (\n <div\n key={key}\n className={cn(skeletonVariants({ variant }), i === lines - 1 && \"w-[60%]\")}\n />\n ))}\n </div>\n );\n }\n\n return (\n <div\n ref={ref}\n data-slot=\"skeleton\"\n className={cn(skeletonVariants({ variant }), className)}\n {...props}\n />\n );\n}\n\nMosaicSkeleton.displayName = \"MosaicSkeleton\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/skeleton/skeleton-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * skeletonVariants — pure CVA variant function for MosaicSkeleton.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React\n * (which is imported in MosaicSkeleton.tsx but not here).\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const skeletonVariants = cva(\n // Base: animate-pulse + muted background token\n [\"animate-pulse\", \"bg-muted\"],\n {\n variants: {\n variant: {\n /** Rounded block — generic rectangular placeholder (cards, images, sections) */\n default: \"rounded-md\",\n /** Text line — h-4 rounded, for single/multi-line text placeholders */\n text: \"h-4 rounded\",\n /** Circle — rounded-full aspect-square, for avatars and icons */\n circle: \"rounded-full aspect-square\",\n /** Button-shaped — h-9 rounded-md, mirrors MosaicButton default size */\n button: \"h-9 rounded-md\",\n },\n },\n defaultVariants: {\n variant: \"default\",\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-slider",
|
|
4
|
+
"title": "MosaicSlider",
|
|
5
|
+
"description": "MosaicSlider — @base-ui/react Slider primitive",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/slider/MosaicSlider.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicSlider — @base-ui/react Slider primitive\n *\n * Builds on Slider.Root + Slider.Control + Slider.Track +\n * Slider.Indicator + Slider.Thumb.\n * Supports single value and range (array) values.\n * role=slider and aria-valuenow managed by the primitive automatically.\n *\n * data-slot=\"slider\" on Root, \"slider-track\" on Track,\n * \"slider-indicator\" on Indicator, \"slider-thumb\" on Thumb.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Slider } from \"@base-ui/react/slider\";\nimport type * as React from \"react\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Props ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSliderProps extends Slider.Root.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicSlider — production Slider atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/slider. Supports single value + range (array).\n * Keyboard accessible: arrow keys, Home, End.\n *\n * @example\n * <MosaicSlider defaultValue={50} aria-label=\"Volume\" />\n * <MosaicSlider defaultValue={[20, 80]} aria-label=\"Price range\" />\n */\nexport function MosaicSlider({ className, ref, ...props }: MosaicSliderProps) {\n const isRange = Array.isArray(props.defaultValue ?? props.value);\n const thumbCount = isRange ? ((props.defaultValue ?? props.value) as number[]).length : 1;\n\n return (\n <Slider.Root\n ref={ref}\n data-slot=\"slider\"\n className={cn(\"w-full touch-none select-none\", className)}\n {...props}\n >\n <Slider.Control className=\"flex items-center\">\n <Slider.Track\n data-slot=\"slider-track\"\n className=\"relative h-2 w-full grow rounded-full bg-secondary\"\n >\n <Slider.Indicator\n data-slot=\"slider-indicator\"\n className=\"absolute h-full rounded-full bg-foreground\"\n />\n {Array.from({ length: thumbCount }).map((_, i) => (\n <Slider.Thumb\n // biome-ignore lint/suspicious/noArrayIndexKey: slider thumbs have stable positional identity\n key={i}\n data-slot=\"slider-thumb\"\n className={cn(\n \"block size-5 rounded-full\",\n \"border-2 border-foreground bg-background\",\n \"shadow-sm outline-none transition-colors\",\n \"focus-visible:ring-ring focus-visible:ring-[3px]\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n )}\n />\n ))}\n </Slider.Track>\n </Slider.Control>\n </Slider.Root>\n );\n}\n\nMosaicSlider.displayName = \"MosaicSlider\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|