@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-org-context-display",
|
|
4
|
+
"title": "MosaicOrgContextDisplay",
|
|
5
|
+
"description": "MosaicOrgContextDisplay — active organization (cloisonnement) indicator + switcher, EveVantage M3 C6.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-org-panel.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/org-context-display/MosaicOrgContextDisplay.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicOrgContextDisplay — active organization (cloisonnement) indicator +\n * switcher, EveVantage M3 C6.\n *\n * Reuse: ported from any-debate-ai —\n * components/organization/org-context-display.tsx — stripped of its\n * `mockOrgContext` fixture, `useDevice` project-local import path, and\n * shadcn/ui `Button`. The role badge is reused from this repo's own\n * `MosaicOrgRoleBadge` (`org-panel/MosaicOrgPanel.tsx`) rather than a second\n * port of `role-badge.tsx` — the component already ships here.\n *\n * The panel is a pure, prop-driven display: the host supplies the active\n * organization state (`org`) plus, when the host allows switching, an\n * `onSwitchOrg` handler. There is no backend, no fetch, no hardcoded org\n * data — the host owns fetching the org, computing membership, and driving\n * the switch flow (dialog, route change, etc.) from `onSwitchOrg`.\n *\n * The role badge and member-count caption are hidden below the `md`\n * breakpoint via Tailwind (`hidden md:...`), never via a `useDevice()`\n * JS branch — this repo's device hooks resolve via `matchMedia`, which the\n * jsdom test environment always reports as non-matching, so a JS-branched\n * \"desktop-only\" element would be permanently hidden under test.\n *\n * data-slot=\"org-context-display\" on the root.\n *\n * i18n: zero hardcoded user-facing strings (mosaic-blocks doctrine — see\n * src/__tests__/i18n-no-hardcoded-literals.test.ts). Every label is a\n * required prop; the host owns the language.\n */\n\nimport type * as React from \"react\";\nimport type { MosaicOrgRole } from \"@/components/ui/MosaicOrgPanel\";\nimport { MosaicOrgRoleBadge } from \"@/components/ui/MosaicOrgPanel\";\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicOrgContextInfo {\n id: string;\n name: string;\n avatarUrl?: string;\n memberCount: number;\n role: MosaicOrgRole;\n}\n\nexport interface MosaicOrgContextDisplayBaseProps {\n /** The currently active organization (the cloisonnement/partitioning state this display reflects). */\n org: MosaicOrgContextInfo;\n /** Host-owned display label for `org.role` (e.g. \"Admin\" / \"Administrateur\"). Required, no default. */\n roleLabel: string;\n /** Host-owned description rendered as the role badge's `title` tooltip. Required, no default. */\n roleDescription: string;\n /** Host-formatted member-count caption, e.g. `(count) => `${count} members`` or a pluralized `t()` call. Required, no default. */\n memberCountLabel: (count: number) => React.ReactNode;\n className?: string;\n}\n\n/**\n * Discriminated union on `onSwitchOrg` — the switch control only ever\n * renders on the branch where a switch handler is supplied, so its\n * accessible-name prop is required EXACTLY there, never on the read-only\n * branch. See `MosaicArtifactVersionHistoryRestoreProps` (C6 retrofit) and\n * `MosaicMemoryCardVariantProps` for the same repo-wide pattern.\n */\nexport type MosaicOrgContextDisplaySwitchProps =\n | {\n /** Invoked when the host should present the org-switch UI. */\n onSwitchOrg: () => void;\n /**\n * Accessible name for the switch control, reflecting the currently\n * active org (e.g. `Switch organization, current: ${org.name}`).\n * Required — the control renders whenever `onSwitchOrg` is provided.\n */\n switchAriaLabel: string;\n }\n | {\n /** Omit to render a read-only display — no switch control at all. */\n onSwitchOrg?: undefined;\n };\n\nexport type MosaicOrgContextDisplayProps = MosaicOrgContextDisplayBaseProps &\n MosaicOrgContextDisplaySwitchProps;\n\nfunction ChevronDownIcon() {\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 className=\"h-4 w-4 shrink-0 text-muted-foreground\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n );\n}\n\nfunction OrgAvatar({ org }: { org: MosaicOrgContextInfo }) {\n if (org.avatarUrl) {\n return (\n <img\n src={org.avatarUrl}\n alt=\"\"\n className=\"h-8 w-8 shrink-0 rounded-full object-cover md:h-10 md:w-10\"\n />\n );\n }\n return (\n <div className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 md:h-10 md:w-10\">\n <span aria-hidden=\"true\" className=\"text-primary text-sm font-medium\">\n {org.name.charAt(0).toUpperCase()}\n </span>\n </div>\n );\n}\n\nexport function MosaicOrgContextDisplay(props: MosaicOrgContextDisplayProps) {\n const { org, roleLabel, roleDescription, memberCountLabel, className } = props;\n\n const content = (\n <>\n <OrgAvatar org={org} />\n <div className=\"min-w-0 flex-1 text-left\">\n <div className=\"flex items-center gap-2\">\n <span className=\"truncate font-medium text-sm md:text-base\">{org.name}</span>\n <span className=\"hidden md:inline-flex\">\n <MosaicOrgRoleBadge role={org.role} label={roleLabel} description={roleDescription} />\n </span>\n </div>\n <div className=\"hidden text-muted-foreground text-xs md:block\">\n {memberCountLabel(org.memberCount)}\n </div>\n </div>\n </>\n );\n\n if (!props.onSwitchOrg) {\n return (\n <div\n data-slot=\"org-context-display\"\n className={cn(\"flex w-full items-center gap-3 min-h-[44px] p-2 md:p-3\", className)}\n >\n {content}\n </div>\n );\n }\n\n return (\n <button\n type=\"button\"\n data-slot=\"org-context-display\"\n onClick={props.onSwitchOrg}\n aria-label={props.switchAriaLabel}\n className={cn(\n \"flex w-full items-center gap-3 justify-start rounded-md border border-border\",\n \"outline-none transition-colors hover:bg-accent min-h-[44px] p-2 md:p-3\",\n \"focus-visible:ring-[3px] focus-visible:ring-ring\",\n className,\n )}\n >\n {content}\n <ChevronDownIcon />\n </button>\n );\n}\n\nMosaicOrgContextDisplay.displayName = \"MosaicOrgContextDisplay\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-org-panel",
|
|
4
|
+
"title": "MosaicOrgPanel",
|
|
5
|
+
"description": "Generic org management shell. Includes MosaicOrgRoleBadge, MosaicMultiOrgIndicator, MosaicCreateOrgDialog, MosaicInviteMemberDialog, MosaicMemberList. Pure presentational — no Clerk/Convex.",
|
|
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-device-provider.json"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/org-panel/MosaicOrgPanel.tsx",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"content": "\"use client\";\n\n/**\n * MosaicOrgPanel — generic multi-tenant organization management shell\n *\n * Ported from components/organization/ (OrgOverview desktop/mobile,\n * OrgSettings desktop/mobile, MemberList desktop/mobile, role-badge,\n * multi-org-indicator, create/invite dialogs)\n *\n * IMPORTANT: All Clerk/Convex calls STRIPPED. This is a PURE PRESENTATIONAL\n * shell. Data + handlers come entirely via props. Auth wiring is T1.5.\n *\n * Exports:\n * MosaicOrgPanel — responsive org management (tabs: overview/members/settings)\n * MosaicOrgRoleBadge — member role badge\n * MosaicMultiOrgIndicator — multi-org count badge\n * MosaicCreateOrgDialog — create org form modal\n * MosaicInviteMemberDialog — invite member form modal\n * MosaicMemberList — responsive member list (responsive-pair)\n */\n\nimport * as React from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicOrgRole = \"admin\" | \"member\" | \"owner\";\n\nexport interface MosaicOrgMember {\n id: string;\n name: string;\n email: string;\n avatarUrl?: string;\n role: MosaicOrgRole;\n joinedAt?: string | number | Date;\n}\n\nexport interface MosaicOrgStats {\n totalMembers?: number;\n totalItems?: number;\n storageUsed?: number;\n storageTotal?: number;\n [key: string]: number | undefined;\n}\n\nexport interface MosaicOrgInfo {\n id: string;\n name: string;\n slug?: string;\n description?: string;\n avatarUrl?: string;\n stats?: MosaicOrgStats;\n}\n\nexport interface MosaicStatItem {\n id: string;\n label: string;\n value: string | number;\n icon?: React.ReactNode;\n description?: string;\n}\n\n// ── MosaicOrgRoleBadge ────────────────────────────────────────────────────────\n\n// Styling only — no user-facing words. The display LABEL for each role is a\n// required host-owned prop (see MosaicOrgRoleBadgeProps.label below); this\n// map only supplies the Tailwind className, which is never rendered as text.\nconst roleClassName: Record<MosaicOrgRole, string> = {\n owner: \"bg-primary text-primary-foreground\",\n admin: \"bg-secondary text-secondary-foreground\",\n member: \"bg-muted text-muted-foreground\",\n};\n\nexport interface MosaicOrgRoleBadgeProps {\n role: MosaicOrgRole;\n /**\n * Host-owned display label for this role (e.g. \"Owner\" / \"Propriétaire\").\n * Required, no default — the label is rendered unconditionally whenever\n * the badge renders, so there is no branch where this value is absent.\n */\n label: string;\n /**\n * Host-owned description rendered as the badge's `title` tooltip.\n * Required, no default — the `title` attribute is set unconditionally\n * whenever the badge renders, so there is no branch where this value is\n * absent.\n */\n description: string;\n className?: string;\n}\n\nexport function MosaicOrgRoleBadge({\n role,\n label,\n description,\n className,\n}: MosaicOrgRoleBadgeProps) {\n const config = roleClassName[role] ?? roleClassName.member;\n return (\n <span\n data-slot=\"org-role-badge\"\n title={description}\n className={cn(\n \"inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium\",\n config,\n className,\n )}\n >\n {label}\n </span>\n );\n}\n\nMosaicOrgRoleBadge.displayName = \"MosaicOrgRoleBadge\";\n\n// ── MosaicMultiOrgIndicator ───────────────────────────────────────────────────\n\nexport interface MosaicMultiOrgIndicatorProps {\n orgCount: number;\n /** Visible org-count text. Receives the count; host owns the unit word. Required, no default. */\n formatOrgCount: (count: number) => string;\n currentOrgName?: string;\n onSwitchOrg?: () => void;\n className?: string;\n}\n\nexport function MosaicMultiOrgIndicator({\n orgCount,\n formatOrgCount,\n currentOrgName,\n onSwitchOrg,\n className,\n}: MosaicMultiOrgIndicatorProps) {\n if (orgCount <= 1) return null;\n\n return (\n <div data-slot=\"multi-org-indicator\" className={cn(\"flex items-center gap-2\", className)}>\n {onSwitchOrg ? (\n <button\n type=\"button\"\n onClick={onSwitchOrg}\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full bg-secondary px-2.5 py-1 text-xs font-medium text-secondary-foreground\",\n \"hover:bg-secondary/80\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\" />\n <polyline points=\"9 22 9 12 15 12 15 22\" />\n </svg>\n {formatOrgCount(orgCount)}\n </button>\n ) : (\n <span className=\"inline-flex items-center gap-1.5 rounded-full bg-secondary px-2.5 py-1 text-xs font-medium text-secondary-foreground\">\n {formatOrgCount(orgCount)}\n </span>\n )}\n {currentOrgName && <span className=\"text-xs text-muted-foreground\">{currentOrgName}</span>}\n </div>\n );\n}\n\nMosaicMultiOrgIndicator.displayName = \"MosaicMultiOrgIndicator\";\n\n// ── MosaicCreateOrgDialog ─────────────────────────────────────────────────────\n\nexport interface MosaicCreateOrgDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onCreateOrg: (data: { name: string; slug: string; description?: string }) => void | Promise<void>;\n isLoading?: boolean;\n /** Dialog title. Required, no default. */\n title: string;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n closeAriaLabel: string;\n orgNameFieldLabel: string;\n orgNamePlaceholder: string;\n slugFieldLabel: string;\n slugPlaceholder: string;\n descriptionFieldLabel: string;\n descriptionPlaceholder: string;\n cancelLabel: string;\n creatingLabel: string;\n createLabel: string;\n /**\n * Optional host-owned validation messages. Each is rendered ONLY when the\n * corresponding field is invalid — omitting one means the field is still\n * validated (submission is still blocked) but no message text renders.\n * No fallback word: an absent prop is silence, never a manufactured\n * English string.\n */\n nameRequiredMessage?: string;\n slugRequiredMessage?: string;\n slugFormatMessage?: string;\n}\n\nexport function MosaicCreateOrgDialog({\n open,\n onOpenChange,\n onCreateOrg,\n isLoading = false,\n title,\n closeAriaLabel,\n orgNameFieldLabel,\n orgNamePlaceholder,\n slugFieldLabel,\n slugPlaceholder,\n descriptionFieldLabel,\n descriptionPlaceholder,\n cancelLabel,\n creatingLabel,\n createLabel,\n nameRequiredMessage,\n slugRequiredMessage,\n slugFormatMessage,\n}: MosaicCreateOrgDialogProps) {\n const [name, setName] = React.useState(\"\");\n const [slug, setSlug] = React.useState(\"\");\n const [description, setDescription] = React.useState(\"\");\n // Validity is tracked as a discriminant, never as a hardcoded message —\n // the field is invalid whether or not the host supplies display text.\n const [errors, setErrors] = React.useState<{ name?: boolean; slug?: \"required\" | \"format\" }>({});\n\n const validate = () => {\n const errs: { name?: boolean; slug?: \"required\" | \"format\" } = {};\n if (!name.trim()) errs.name = true;\n if (!slug.trim()) errs.slug = \"required\";\n else if (!/^[a-z0-9-]+$/.test(slug)) errs.slug = \"format\";\n setErrors(errs);\n return Object.keys(errs).length === 0;\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!validate()) return;\n await onCreateOrg({\n name: name.trim(),\n slug: slug.trim(),\n description: description.trim() || undefined,\n });\n setName(\"\");\n setSlug(\"\");\n setDescription(\"\");\n setErrors({});\n onOpenChange(false);\n };\n\n // Auto-generate slug from name\n React.useEffect(() => {\n if (!name) {\n setSlug(\"\");\n return;\n }\n setSlug(\n name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-|-$/g, \"\"),\n );\n }, [name]);\n\n return (\n <MosaicAdaptiveModal\n isOpen={open}\n onClose={() => onOpenChange(false)}\n title={title}\n closeAriaLabel={closeAriaLabel}\n >\n <form\n data-slot=\"create-org-dialog\"\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4 p-4\"\n >\n {/* Name */}\n <div className=\"space-y-1.5\">\n <label htmlFor=\"org-name\" className=\"text-sm font-medium\">\n {orgNameFieldLabel}\n </label>\n <input\n id=\"org-name\"\n type=\"text\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n placeholder={orgNamePlaceholder}\n required\n className={cn(\n \"w-full rounded-md border bg-background px-3 py-2 min-h-[40px] text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n errors.name ? \"border-destructive\" : \"border-input\",\n )}\n />\n {errors.name && nameRequiredMessage && (\n <p className=\"text-xs text-destructive\">{nameRequiredMessage}</p>\n )}\n </div>\n {/* Slug */}\n <div className=\"space-y-1.5\">\n <label htmlFor=\"org-slug\" className=\"text-sm font-medium\">\n {slugFieldLabel}\n </label>\n <input\n id=\"org-slug\"\n type=\"text\"\n value={slug}\n onChange={(e) => setSlug(e.target.value)}\n placeholder={slugPlaceholder}\n required\n className={cn(\n \"w-full rounded-md border bg-background px-3 py-2 min-h-[40px] text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n errors.slug ? \"border-destructive\" : \"border-input\",\n )}\n />\n {errors.slug === \"required\" && slugRequiredMessage && (\n <p className=\"text-xs text-destructive\">{slugRequiredMessage}</p>\n )}\n {errors.slug === \"format\" && slugFormatMessage && (\n <p className=\"text-xs text-destructive\">{slugFormatMessage}</p>\n )}\n </div>\n {/* Description */}\n <div className=\"space-y-1.5\">\n <label htmlFor=\"org-desc\" className=\"text-sm font-medium\">\n {descriptionFieldLabel}\n </label>\n <textarea\n id=\"org-desc\"\n value={description}\n onChange={(e) => setDescription(e.target.value)}\n placeholder={descriptionPlaceholder}\n rows={3}\n className=\"w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground resize-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n />\n </div>\n <div className=\"flex justify-end gap-2 pt-2\">\n <button\n type=\"button\"\n onClick={() => onOpenChange(false)}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md border border-border bg-background px-4 text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {cancelLabel}\n </button>\n <button\n type=\"submit\"\n disabled={isLoading}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:pointer-events-none\"\n >\n {isLoading ? creatingLabel : createLabel}\n </button>\n </div>\n </form>\n </MosaicAdaptiveModal>\n );\n}\n\nMosaicCreateOrgDialog.displayName = \"MosaicCreateOrgDialog\";\n\n// ── MosaicInviteMemberDialog ──────────────────────────────────────────────────\n\nexport interface MosaicInviteMemberDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n onInvite: (data: { email: string; role: MosaicOrgRole }) => void | Promise<void>;\n isLoading?: boolean;\n /**\n * Host-owned role options (value + display label). Required, no default —\n * a default role list would reintroduce hardcoded English labels\n * (\"Admin\"/\"Member\") the library must never ship on its own.\n */\n roles: Array<{ value: MosaicOrgRole; label: string }>;\n /** Dialog title. Required, no default. */\n title: string;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n closeAriaLabel: string;\n emailFieldLabel: string;\n emailPlaceholder: string;\n roleFieldLabel: string;\n cancelLabel: string;\n sendingLabel: string;\n sendInvitationLabel: string;\n /**\n * Optional host-owned validation messages. Each is rendered ONLY when the\n * email field is invalid for that specific reason — an absent prop means\n * the field is still validated (submission still blocked) but renders no\n * message text. No fallback word.\n */\n emailRequiredMessage?: string;\n emailInvalidMessage?: string;\n}\n\nexport function MosaicInviteMemberDialog({\n open,\n onOpenChange,\n onInvite,\n isLoading = false,\n roles,\n title,\n closeAriaLabel,\n emailFieldLabel,\n emailPlaceholder,\n roleFieldLabel,\n cancelLabel,\n sendingLabel,\n sendInvitationLabel,\n emailRequiredMessage,\n emailInvalidMessage,\n}: MosaicInviteMemberDialogProps) {\n const [email, setEmail] = React.useState(\"\");\n const [role, setRole] = React.useState<MosaicOrgRole>(\"member\");\n // Validity is tracked as a discriminant, never as a hardcoded message —\n // the field is invalid whether or not the host supplies display text.\n const [errors, setErrors] = React.useState<{ email?: \"required\" | \"invalid\" }>({});\n\n const validate = () => {\n const errs: { email?: \"required\" | \"invalid\" } = {};\n if (!email.trim()) errs.email = \"required\";\n else if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email)) errs.email = \"invalid\";\n setErrors(errs);\n return Object.keys(errs).length === 0;\n };\n\n const handleSubmit = async (e: React.FormEvent) => {\n e.preventDefault();\n if (!validate()) return;\n await onInvite({ email: email.trim(), role });\n setEmail(\"\");\n setRole(\"member\");\n setErrors({});\n onOpenChange(false);\n };\n\n return (\n <MosaicAdaptiveModal\n isOpen={open}\n onClose={() => onOpenChange(false)}\n title={title}\n closeAriaLabel={closeAriaLabel}\n >\n <form\n data-slot=\"invite-member-dialog\"\n onSubmit={handleSubmit}\n className=\"flex flex-col gap-4 p-4\"\n >\n <div className=\"space-y-1.5\">\n <label htmlFor=\"invite-email\" className=\"text-sm font-medium\">\n {emailFieldLabel}\n </label>\n <input\n id=\"invite-email\"\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder={emailPlaceholder}\n required\n className={cn(\n \"w-full rounded-md border bg-background px-3 py-2 min-h-[40px] text-sm placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n errors.email ? \"border-destructive\" : \"border-input\",\n )}\n />\n {errors.email === \"required\" && emailRequiredMessage && (\n <p className=\"text-xs text-destructive\">{emailRequiredMessage}</p>\n )}\n {errors.email === \"invalid\" && emailInvalidMessage && (\n <p className=\"text-xs text-destructive\">{emailInvalidMessage}</p>\n )}\n </div>\n <div className=\"space-y-1.5\">\n <label htmlFor=\"invite-role\" className=\"text-sm font-medium\">\n {roleFieldLabel}\n </label>\n <select\n id=\"invite-role\"\n value={role}\n onChange={(e) => setRole(e.target.value as MosaicOrgRole)}\n className=\"w-full rounded-md border border-input bg-background px-3 py-2 min-h-[44px] text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {roles.map((r) => (\n <option key={r.value} value={r.value}>\n {r.label}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex justify-end gap-2 pt-2\">\n <button\n type=\"button\"\n onClick={() => onOpenChange(false)}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md border border-border bg-background px-4 text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {cancelLabel}\n </button>\n <button\n type=\"submit\"\n disabled={isLoading}\n className=\"inline-flex min-h-[44px] items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 disabled:pointer-events-none\"\n >\n {isLoading ? sendingLabel : sendInvitationLabel}\n </button>\n </div>\n </form>\n </MosaicAdaptiveModal>\n );\n}\n\nMosaicInviteMemberDialog.displayName = \"MosaicInviteMemberDialog\";\n\n// ── MosaicMemberList ──────────────────────────────────────────────────────────\n\nexport interface MosaicMemberListProps {\n members: MosaicOrgMember[];\n currentUserId?: string;\n onChangeRole?: (memberId: string, role: MosaicOrgRole) => void;\n onRemoveMember?: (memberId: string) => void;\n onInvite?: () => void;\n /**\n * Host-owned role options (value + display label), used to populate the\n * \"change role\" menu. Required, no default — a default role list would\n * reintroduce hardcoded English labels the library must never ship.\n */\n roles: Array<{ value: MosaicOrgRole; label: string }>;\n isLoading?: boolean;\n searchPlaceholder: string;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n youLabel: string;\n memberActionsAriaLabel: string;\n removeMemberLabel: string;\n emptyMessage: string;\n inviteLabel: string;\n /**\n * Host-owned description per role, rendered as each member's role badge\n * tooltip. Required, no default — every rendered row shows a role badge\n * unconditionally.\n */\n roleDescriptions: Record<MosaicOrgRole, string>;\n /**\n * Host-owned display label per role, rendered inside each member's role\n * badge. Required, no default — every rendered row shows a role badge\n * unconditionally.\n */\n roleLabels: Record<MosaicOrgRole, string>;\n /**\n * Host-composed \"joined on <date>\" caption. Required, no default; called\n * ONLY for members that have a `joinedAt` — a member without one renders\n * no caption at all, so the function is never invoked for that row. The\n * host owns the whole sentence (word order varies by language), never a\n * library-side \"Joined \" + date concatenation.\n */\n joinedLabel: (date: string) => string;\n /**\n * Host-composed \"make <role>\" menu-item caption (e.g. \"Make admin\" /\n * \"Nommer admin\"). Required, no default; the host owns the whole sentence,\n * never a library-side \"Make \" + label concatenation.\n */\n makeRoleLabel: (roleLabel: string) => string;\n className?: string;\n}\n\nfunction MemberRow({\n member,\n currentUserId,\n onChangeRole,\n onRemoveMember,\n roles,\n youLabel,\n memberActionsAriaLabel,\n removeMemberLabel,\n roleDescriptions,\n roleLabels,\n joinedLabel,\n makeRoleLabel,\n}: {\n member: MosaicOrgMember;\n currentUserId?: string;\n onChangeRole?: (id: string, role: MosaicOrgRole) => void;\n onRemoveMember?: (id: string) => void;\n roles: Array<{ value: MosaicOrgRole; label: string }>;\n youLabel: string;\n memberActionsAriaLabel: string;\n removeMemberLabel: string;\n roleDescriptions: Record<MosaicOrgRole, string>;\n roleLabels: Record<MosaicOrgRole, string>;\n joinedLabel: (date: string) => string;\n makeRoleLabel: (roleLabel: string) => string;\n}) {\n const [menuOpen, setMenuOpen] = React.useState(false);\n const menuRef = React.useRef<HTMLDivElement>(null);\n const isSelf = member.id === currentUserId;\n\n React.useEffect(() => {\n if (!menuOpen) return;\n const h = (e: MouseEvent) => {\n if (menuRef.current && !menuRef.current.contains(e.target as Node)) setMenuOpen(false);\n };\n document.addEventListener(\"mousedown\", h);\n return () => document.removeEventListener(\"mousedown\", h);\n }, [menuOpen]);\n\n const initials = member.name\n .split(\" \")\n .map((n) => n[0])\n .filter(Boolean)\n .slice(0, 2)\n .join(\"\")\n .toUpperCase();\n const joinedDate = member.joinedAt ? new Date(member.joinedAt).toLocaleDateString() : undefined;\n\n return (\n <div className=\"flex items-center gap-3 py-3\">\n <span className=\"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground\">\n {member.avatarUrl ? (\n <img\n src={member.avatarUrl}\n alt={member.name}\n className=\"h-full w-full rounded-full object-cover\"\n />\n ) : (\n initials\n )}\n </span>\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2\">\n <p className=\"text-sm font-medium truncate\">{member.name}</p>\n {isSelf && (\n <span className=\"shrink-0 rounded-full bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground\">\n {youLabel}\n </span>\n )}\n </div>\n <p className=\"text-xs text-muted-foreground truncate\">{member.email}</p>\n {joinedDate && <p className=\"text-xs text-muted-foreground\">{joinedLabel(joinedDate)}</p>}\n </div>\n <MosaicOrgRoleBadge\n role={member.role}\n label={roleLabels[member.role]}\n description={roleDescriptions[member.role]}\n />\n {!isSelf && (onChangeRole || onRemoveMember) && (\n <div ref={menuRef} className=\"relative shrink-0\">\n <button\n type=\"button\"\n onClick={() => setMenuOpen((v) => !v)}\n className=\"inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n aria-label={memberActionsAriaLabel}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"5\" r=\"1\" />\n <circle cx=\"12\" cy=\"12\" r=\"1\" />\n <circle cx=\"12\" cy=\"19\" r=\"1\" />\n </svg>\n </button>\n {menuOpen && (\n <div\n role=\"menu\"\n className=\"absolute right-0 top-full z-50 mt-1 min-w-[160px] rounded-md border border-border bg-popover py-1 shadow-md\"\n >\n {onChangeRole &&\n roles?.map(\n (r) =>\n r.value !== member.role && (\n <button\n key={r.value}\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n onChangeRole(member.id, r.value);\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n {makeRoleLabel(r.label)}\n </button>\n ),\n )}\n {onRemoveMember && (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n onRemoveMember(member.id);\n setMenuOpen(false);\n }}\n className=\"flex w-full items-center px-3 py-2 text-sm text-destructive hover:bg-destructive/10\"\n >\n {removeMemberLabel}\n </button>\n )}\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nexport function MosaicMemberList({\n members,\n currentUserId,\n onChangeRole,\n onRemoveMember,\n onInvite,\n roles,\n isLoading,\n searchPlaceholder,\n youLabel,\n memberActionsAriaLabel,\n removeMemberLabel,\n emptyMessage,\n inviteLabel,\n roleDescriptions,\n roleLabels,\n joinedLabel,\n makeRoleLabel,\n className,\n}: MosaicMemberListProps) {\n const [query, setQuery] = React.useState(\"\");\n\n const filtered = members.filter(\n (m) =>\n !query ||\n m.name.toLowerCase().includes(query.toLowerCase()) ||\n m.email.toLowerCase().includes(query.toLowerCase()),\n );\n\n return (\n <div data-slot=\"member-list\" className={cn(\"flex flex-col gap-4\", className)}>\n <div className=\"flex items-center gap-3\">\n <div className=\"relative flex-1\">\n <span className=\"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground\">\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"11\" cy=\"11\" r=\"8\" />\n <line x1=\"21\" y1=\"21\" x2=\"16.65\" y2=\"16.65\" />\n </svg>\n </span>\n <input\n type=\"search\"\n value={query}\n onChange={(e) => setQuery(e.target.value)}\n placeholder={searchPlaceholder}\n className=\"w-full rounded-md border border-input bg-background py-2 pl-8 pr-3 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n />\n </div>\n {onInvite && (\n <button\n type=\"button\"\n onClick={onInvite}\n className=\"inline-flex min-h-[40px] items-center gap-1.5 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring shrink-0\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\" />\n <circle cx=\"9\" cy=\"7\" r=\"4\" />\n <line x1=\"19\" y1=\"8\" x2=\"19\" y2=\"14\" />\n <line x1=\"22\" y1=\"11\" x2=\"16\" y2=\"11\" />\n </svg>\n {inviteLabel}\n </button>\n )}\n </div>\n\n {isLoading ? (\n <div className=\"space-y-3\">\n {[\"skeleton-1\", \"skeleton-2\", \"skeleton-3\"].map((skeletonId) => (\n <div key={skeletonId} className=\"h-14 animate-pulse rounded-lg bg-muted\" />\n ))}\n </div>\n ) : (\n <div className=\"divide-y divide-border\">\n {filtered.map((member) => (\n <MemberRow\n key={member.id}\n member={member}\n currentUserId={currentUserId}\n onChangeRole={onChangeRole}\n onRemoveMember={onRemoveMember}\n roles={roles}\n youLabel={youLabel}\n memberActionsAriaLabel={memberActionsAriaLabel}\n removeMemberLabel={removeMemberLabel}\n roleDescriptions={roleDescriptions}\n roleLabels={roleLabels}\n joinedLabel={joinedLabel}\n makeRoleLabel={makeRoleLabel}\n />\n ))}\n {filtered.length === 0 && (\n <p className=\"py-8 text-center text-sm text-muted-foreground\">{emptyMessage}</p>\n )}\n </div>\n )}\n </div>\n );\n}\n\nMosaicMemberList.displayName = \"MosaicMemberList\";\n\n// ── MosaicOrgPanel (main orchestrator with tabs) ──────────────────────────────\n\nexport interface MosaicOrgPanelTab {\n id: string;\n label: string;\n content: React.ReactNode;\n}\n\nexport interface MosaicOrgPanelProps {\n org: MosaicOrgInfo;\n tabs?: MosaicOrgPanelTab[];\n defaultTab?: string;\n /** Header-right slot (actions, invite button, etc.) */\n headerActions?: React.ReactNode;\n className?: string;\n}\n\nexport function MosaicOrgPanel({\n org,\n tabs = [],\n defaultTab,\n headerActions,\n className,\n}: MosaicOrgPanelProps) {\n const { isMobile } = useDevice();\n const [activeTab, setActiveTab] = React.useState(defaultTab ?? tabs[0]?.id ?? \"\");\n\n const activeContent = tabs.find((t) => t.id === activeTab)?.content;\n\n return (\n <div data-slot=\"org-panel\" className={cn(\"flex h-full flex-col\", className)}>\n {/* Header */}\n <div className=\"border-b border-border px-4 py-4 md:px-6\">\n <div className=\"flex items-start justify-between gap-4\">\n <div className=\"flex items-center gap-3\">\n <span className=\"inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted text-lg font-bold text-muted-foreground\">\n {org.avatarUrl ? (\n <img\n src={org.avatarUrl}\n alt={org.name}\n className=\"h-full w-full rounded-lg object-cover\"\n />\n ) : (\n org.name[0]?.toUpperCase()\n )}\n </span>\n <div>\n <h1 className=\"text-base font-semibold md:text-lg\">{org.name}</h1>\n {org.slug && <p className=\"text-xs text-muted-foreground\">@{org.slug}</p>}\n </div>\n </div>\n {headerActions}\n </div>\n\n {/* Tabs */}\n {tabs.length > 0 && (\n <div className={cn(\"mt-4 flex gap-1\", isMobile && \"overflow-x-auto\")}>\n {tabs.map((tab) => (\n <button\n key={tab.id}\n type=\"button\"\n onClick={() => setActiveTab(tab.id)}\n className={cn(\n \"shrink-0 rounded-md px-3 py-1.5 text-sm font-medium transition-colors\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n activeTab === tab.id\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground\",\n )}\n >\n {tab.label}\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Tab content */}\n <div className=\"flex-1 overflow-y-auto p-4 md:p-6\">{activeContent}</div>\n </div>\n );\n}\n\nMosaicOrgPanel.displayName = \"MosaicOrgPanel\";\n"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"type": "registry:ui"
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-org-profile-page",
|
|
4
|
+
"title": "MosaicOrgProfilePage",
|
|
5
|
+
"description": "Clerk <OrganizationProfile> for team management with OKLCH appearance. hash/path/virtual routing modes. Clerk injected as peer prop.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@clerk/nextjs"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/auth/org-profile-page/MosaicOrgProfilePage.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicOrgProfilePage — Clerk <OrganizationProfile> with OKLCH appearance.\n *\n * Wraps @clerk/nextjs <OrganizationProfile> for team management. Clerk is\n * injected as a peer prop so mosaic-blocks does not bundle @clerk/nextjs.\n *\n * @example\n * import { OrganizationProfile } from \"@clerk/nextjs\"\n * <MosaicOrgProfilePage clerkOrgProfile={OrganizationProfile} />\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicOrgProfilePageProps {\n /** Clerk <OrganizationProfile> component — injected by caller */\n clerkOrgProfile: React.ComponentType<{\n appearance?: Record<string, unknown>;\n routing?: \"hash\" | \"path\" | \"virtual\";\n path?: string;\n [key: string]: unknown;\n }>;\n /** Routing mode for Clerk's internal navigation */\n routing?: \"hash\" | \"path\" | \"virtual\";\n /** Base path when routing=\"path\" */\n path?: 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 navbar: \"border-r border-border bg-background\",\n navbarButton: \"text-foreground hover:bg-accent hover:text-accent-foreground\",\n navbarButtonIcon: \"text-muted-foreground\",\n formButtonPrimary: \"bg-primary text-primary-foreground hover:bg-primary/90 shadow-none\",\n formButtonReset:\n \"border border-border text-foreground hover:bg-accent hover:text-accent-foreground\",\n formFieldInput: \"border-input bg-background text-foreground focus:ring-ring\",\n badge: \"bg-secondary text-secondary-foreground\",\n table: \"text-foreground\",\n tableHead: \"text-muted-foreground text-xs font-medium\",\n memberListTableRow: \"border-b border-border\",\n },\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicOrgProfilePage({\n clerkOrgProfile: ClerkOrgProfile,\n routing = \"hash\",\n path,\n className,\n}: MosaicOrgProfilePageProps) {\n return (\n <div\n data-slot=\"org-profile-page\"\n className={[\"flex min-h-0 flex-1 flex-col bg-background\", className]\n .filter(Boolean)\n .join(\" \")}\n >\n <ClerkOrgProfile\n appearance={clerkAppearance}\n routing={routing}\n {...(path !== undefined ? { path } : {})}\n />\n </div>\n );\n}\n\nMosaicOrgProfilePage.displayName = \"MosaicOrgProfilePage\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-org-switcher",
|
|
4
|
+
"title": "MosaicOrgSwitcher",
|
|
5
|
+
"description": "Presentational org picker dropdown. Current org + avatar in trigger. Pure props — no Clerk. Auth wiring is T1.5.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/org-switcher/MosaicOrgSwitcher.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "\"use client\";\n\n/**\n * MosaicOrgSwitcher — presentational org picker dropdown\n *\n * Ported from components/dashboard/OrgSwitcher.tsx (which used Clerk's\n * OrganizationSwitcher). Clerk STRIPPED. Pure presentational shell.\n *\n * Features:\n * - Dropdown with list of organizations\n * - Current org name + avatar/initials displayed in trigger\n * - Optional \"Create organization\" action at bottom\n *\n * Data comes entirely via props. Auth wiring is T1.5.\n */\n\nimport * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicOrg {\n id: string;\n name: string;\n avatarUrl?: string;\n slug?: string;\n}\n\nexport interface MosaicOrgSwitcherProps {\n organizations?: MosaicOrg[];\n currentOrgId?: string;\n onSelectOrg?: (orgId: string) => void;\n onCreateOrg?: () => void;\n /** Label for the \"create organization\" action (shown when `onCreateOrg` is set). Required, no default. */\n createOrgLabel: string;\n /** aria-label for the trigger button. Required, no default. */\n triggerAriaLabel: string;\n /**\n * Trigger label shown when no organization is selected/available.\n * Required — the host owns the language (e.g. `t('OrgSwitcher.none')`).\n * No default, no fallback.\n */\n noOrgSelectedLabel: string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction ChevronDownIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <polyline points=\"6 9 12 15 18 9\" />\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\nfunction PlusIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicOrgSwitcher({\n organizations = [],\n currentOrgId,\n onSelectOrg,\n onCreateOrg,\n createOrgLabel,\n triggerAriaLabel,\n noOrgSelectedLabel,\n className,\n}: MosaicOrgSwitcherProps) {\n const [open, setOpen] = React.useState(false);\n const ref = React.useRef<HTMLDivElement>(null);\n\n const currentOrg = organizations.find((o) => o.id === currentOrgId) ?? organizations[0];\n\n React.useEffect(() => {\n if (!open) return;\n const h = (e: MouseEvent) => {\n if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);\n };\n document.addEventListener(\"mousedown\", h);\n return () => document.removeEventListener(\"mousedown\", h);\n }, [open]);\n\n if (!currentOrg && organizations.length === 0 && !onCreateOrg) return null;\n\n const initials =\n currentOrg?.name\n .split(\" \")\n .map((n) => n[0])\n .filter(Boolean)\n .slice(0, 2)\n .join(\"\")\n .toUpperCase() ?? \"?\";\n\n return (\n <div ref={ref} data-slot=\"org-switcher\" className={cn(\"relative\", className)}>\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n className={cn(\n \"inline-flex items-center gap-2 rounded-md border border-border bg-background px-3 py-1.5\",\n \"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 aria-haspopup=\"menu\"\n aria-expanded={open}\n >\n <span className=\"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded bg-primary text-[10px] font-bold text-primary-foreground overflow-hidden\">\n {currentOrg?.avatarUrl ? (\n <img\n src={currentOrg.avatarUrl}\n alt={currentOrg.name}\n className=\"h-full w-full object-cover\"\n />\n ) : (\n initials\n )}\n </span>\n <span className=\"max-w-[120px] truncate\">{currentOrg?.name ?? noOrgSelectedLabel}</span>\n <ChevronDownIcon />\n </button>\n\n {open && (\n <div\n role=\"menu\"\n aria-label={triggerAriaLabel}\n className={cn(\n \"absolute left-0 top-full z-50 mt-1 min-w-[200px] rounded-md border border-border\",\n \"bg-popover py-1 shadow-md\",\n )}\n >\n {organizations.map((org) => (\n <button\n key={org.id}\n type=\"button\"\n role=\"menuitem\"\n aria-current={org.id === currentOrgId ? \"true\" : undefined}\n onClick={() => {\n onSelectOrg?.(org.id);\n setOpen(false);\n }}\n className={cn(\n \"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-foreground\",\n \"hover:bg-accent hover:text-accent-foreground\",\n org.id === currentOrgId && \"bg-primary/10 text-primary\",\n )}\n >\n <span className=\"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded bg-muted text-[10px] font-bold text-muted-foreground overflow-hidden\">\n {org.avatarUrl ? (\n <img src={org.avatarUrl} alt={org.name} className=\"h-full w-full object-cover\" />\n ) : (\n org.name[0]?.toUpperCase()\n )}\n </span>\n <span className=\"flex-1 truncate\">{org.name}</span>\n {org.id === currentOrgId && <CheckIcon />}\n </button>\n ))}\n\n {onCreateOrg && (\n <>\n {organizations.length > 0 && <div className=\"my-1 border-t border-border\" />}\n <button\n type=\"button\"\n onClick={() => {\n onCreateOrg();\n setOpen(false);\n }}\n className=\"flex w-full items-center gap-2.5 px-3 py-2 text-sm text-foreground hover:bg-accent hover:text-accent-foreground\"\n >\n <PlusIcon />\n {createOrgLabel}\n </button>\n </>\n )}\n </div>\n )}\n </div>\n );\n}\n\nMosaicOrgSwitcher.displayName = \"MosaicOrgSwitcher\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-pdf-viewer",
|
|
4
|
+
"title": "MosaicPdfViewer",
|
|
5
|
+
"description": "Presentational inline PDF preview via the browser's native PDF renderer (iframe). Host-controlled page navigation and zoom, local loading/error status (no PDF library, no network call by the component itself).",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"class-variance-authority"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/pdf-viewer/MosaicPdfViewer.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicPdfViewer — presentational inline PDF preview\n *\n * Presentational atom. Renders a PDF document, given a `fileUrl`, inline via\n * the browser's native PDF renderer (an `<iframe>` pointed at `fileUrl`,\n * optionally suffixed with the standard `#page=`/`#zoom=` viewer fragment).\n * The component performs no network call of its own: it never calls `fetch`\n * or any SDK — the browser's own iframe navigation is what loads `fileUrl`,\n * exactly as it would for any other iframe `src`. The host owns `fileUrl`\n * (including any signing/auth query string) and owns page/zoom state.\n *\n * Page navigation and zoom are both fully host-controlled, exactly like\n * `MosaicUrlScraper`'s `url`/`onUrlChange`: `currentPage`/`onPageChange` and\n * `zoom`/`onZoomChange` are independent optional pairs — the toolbar for a\n * given control only renders when that pair's value prop is supplied, and\n * activating a toolbar button only calls back out; it never mutates local\n * page/zoom state itself.\n *\n * Loading/error status IS local state (not host-controlled): it reflects\n * whether the browser has finished loading `fileUrl` into the iframe.\n * `loadingLabel` is shown until the iframe's native `load` event fires;\n * `errorLabel` replaces the frame if the iframe instead fires a native\n * `error` event (e.g. `fileUrl` unreachable). Changing `fileUrl` resets this\n * local status back to loading — pattern lifted from `MosaicDocumentUpload`'s\n * per-file host-controlled status conventions, applied here to a single\n * host-supplied `fileUrl`.\n *\n * Both listeners are attached with a plain `addEventListener` on the iframe\n * DOM node (via a local `useRef`+`useEffect`), NOT via React's `onLoad`/\n * `onError` JSX props: React only special-cases the `iframe`/`object` tags\n * for its non-delegated-event optimization on `load`, never on `error` (the\n * `error` special-case list only covers `img`/`image`/`source`/`embed`/\n * `link`) — so a React `onError` prop on an `<iframe>` is silently never\n * invoked, in every browser, not just under jsdom. Attaching the listener\n * directly on the node sidesteps React's synthetic-event dispatch entirely\n * and reacts to the DOM event regardless of delegation/bubbling support.\n *\n * Pattern: MosaicUrlScraper.tsx / MosaicDocumentUpload.tsx (data-slot, inline\n * cn, React 19 ref prop, displayName, JSDoc, pure variants module, presentational\n * — host owns fetch, no PDF library dependency: the browser's built-in PDF\n * plugin renders the iframe, exactly like MosaicUrlScraper leans on the\n * browser's own `new URL()` for local syntax validation instead of a parsing\n * library).\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist; the\n * `useState` below requires the client runtime at use-time.\n * Design tokens: --foreground, --muted-foreground, --border, --destructive,\n * --card, --accent, --background.\n * No icon library — plain glyphs (\"‹\"/\"›\"/\"−\"/\"+\"), matching the\n * document-upload/url-scraper convention (no lucide-react runtime dependency).\n * a11y: the loading region uses `role=\"status\"`; the error region uses\n * `role=\"alert\"`. The iframe's `title` is `fileUrl` itself — the only\n * caller-independent, non-hardcoded string available to describe \"the\n * document this frame is showing\" (no new required prop was introduced for\n * this — the JSDoc on the field explains the choice).\n * Bilingual: every user-facing string (`loadingLabel`/`errorLabel`) is a\n * required caller-supplied prop — zero hardcoded copy, zero default.\n *\n * @example\n * <MosaicPdfViewer\n * fileUrl={documentUrl}\n * currentPage={page}\n * onPageChange={setPage}\n * totalPages={totalPages}\n * zoom={zoom}\n * onZoomChange={setZoom}\n * loadingLabel=\"Chargement du document…\"\n * errorLabel=\"Impossible d'afficher ce document.\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n pdfViewerFrameVariants,\n pdfViewerStatusVariants,\n pdfViewerToolbarButtonVariants,\n} from \"./pdf-viewer-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n/**\n * Appends the standard browser-native PDF-viewer fragment (`#page=`/`#zoom=`)\n * to `fileUrl`. Pure string composition — no network call, no PDF parsing.\n */\nfunction buildFrameSrc(fileUrl: string, currentPage: number | undefined, zoom: number | undefined) {\n const fragmentParts: string[] = [];\n if (currentPage !== undefined) fragmentParts.push(`page=${currentPage}`);\n if (zoom !== undefined) fragmentParts.push(`zoom=${Math.round(zoom * 100)}`);\n if (fragmentParts.length === 0) return fileUrl;\n const separator = fileUrl.includes(\"#\") ? \"&\" : \"#\";\n return `${fileUrl}${separator}${fragmentParts.join(\"&\")}`;\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicPdfViewerProps {\n /** URL of the PDF document to render. The host owns fetching/signing it. */\n fileUrl: string;\n /** Current page, controlled by the host (1-indexed). Omit to hide page controls. */\n currentPage?: number;\n /** Called with the requested page when a page-navigation button is activated. */\n onPageChange?: (page: number) => void;\n /** Total page count, shown next to `currentPage` and used to disable \"next\" at the end. */\n totalPages?: number;\n /** Current zoom factor (e.g. `1` = 100%), controlled by the host. Omit to hide zoom controls. */\n zoom?: number;\n /** Called with the requested zoom factor when a zoom button is activated. */\n onZoomChange?: (zoom: number) => void;\n /** Message shown while the document is loading. Required, no default. */\n loadingLabel: string;\n /** Message shown if the document fails to load. Required, no default. */\n errorLabel: 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 * MosaicPdfViewer — production inline-PDF-preview atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders `fileUrl` inline via the browser's native\n * PDF renderer, reports host-controlled page/zoom navigation via callbacks,\n * and surfaces load/error state via `loadingLabel`/`errorLabel`. No network\n * call of its own, no PDF library dependency, no built-in copy.\n */\nexport function MosaicPdfViewer({\n fileUrl,\n currentPage,\n onPageChange,\n totalPages,\n zoom,\n onZoomChange,\n loadingLabel,\n errorLabel,\n className,\n ref,\n}: MosaicPdfViewerProps) {\n const [status, setStatus] = useState<\"loading\" | \"loaded\" | \"error\">(\"loading\");\n const [trackedFileUrl, setTrackedFileUrl] = useState(fileUrl);\n const frameRef = useRef<HTMLIFrameElement>(null);\n\n // `fileUrl` changed since the last render — reset local load status.\n // (Render-phase state update, the documented React pattern for\n // \"derive state from a changed prop\" — no effect needed.)\n if (fileUrl !== trackedFileUrl) {\n setTrackedFileUrl(fileUrl);\n setStatus(\"loading\");\n }\n\n // Native listeners (see file JSDoc: React's onError never fires on an\n // <iframe>, in any browser). Attached once — the iframe DOM node persists\n // across re-renders; only its `src` attribute changes.\n useEffect(() => {\n const node = frameRef.current;\n if (!node) return;\n function handleLoad() {\n setStatus(\"loaded\");\n }\n function handleError() {\n setStatus(\"error\");\n }\n node.addEventListener(\"load\", handleLoad);\n node.addEventListener(\"error\", handleError);\n return () => {\n node.removeEventListener(\"load\", handleLoad);\n node.removeEventListener(\"error\", handleError);\n };\n }, []);\n\n const showPageControls = currentPage !== undefined;\n const showZoomControls = zoom !== undefined;\n\n function handlePrevPage() {\n if (currentPage === undefined || onPageChange === undefined || currentPage <= 1) return;\n onPageChange(currentPage - 1);\n }\n\n function handleNextPage() {\n if (currentPage === undefined || onPageChange === undefined) return;\n if (totalPages !== undefined && currentPage >= totalPages) return;\n onPageChange(currentPage + 1);\n }\n\n function handleZoomOut() {\n if (zoom === undefined || onZoomChange === undefined) return;\n onZoomChange(Math.round((zoom - 0.1) * 100) / 100);\n }\n\n function handleZoomIn() {\n if (zoom === undefined || onZoomChange === undefined) return;\n onZoomChange(Math.round((zoom + 0.1) * 100) / 100);\n }\n\n return (\n <div ref={ref} data-slot=\"pdf-viewer\" className={cn(\"flex flex-col gap-2\", className)}>\n {(showPageControls || showZoomControls) && (\n <div\n data-slot=\"pdf-viewer-toolbar\"\n className=\"flex items-center justify-between gap-2 text-sm\"\n >\n {showPageControls && (\n <div data-slot=\"pdf-viewer-page-controls\" className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n data-slot=\"pdf-viewer-prev-page-button\"\n onClick={handlePrevPage}\n disabled={(currentPage ?? 1) <= 1}\n className={pdfViewerToolbarButtonVariants()}\n >\n ‹\n </button>\n <span data-slot=\"pdf-viewer-page-indicator\">\n {currentPage}\n {totalPages !== undefined ? ` / ${totalPages}` : \"\"}\n </span>\n <button\n type=\"button\"\n data-slot=\"pdf-viewer-next-page-button\"\n onClick={handleNextPage}\n disabled={totalPages !== undefined && (currentPage ?? 0) >= totalPages}\n className={pdfViewerToolbarButtonVariants()}\n >\n ›\n </button>\n </div>\n )}\n {showZoomControls && (\n <div data-slot=\"pdf-viewer-zoom-controls\" className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n data-slot=\"pdf-viewer-zoom-out-button\"\n onClick={handleZoomOut}\n className={pdfViewerToolbarButtonVariants()}\n >\n −\n </button>\n <span data-slot=\"pdf-viewer-zoom-indicator\">{Math.round((zoom ?? 1) * 100)}%</span>\n <button\n type=\"button\"\n data-slot=\"pdf-viewer-zoom-in-button\"\n onClick={handleZoomIn}\n className={pdfViewerToolbarButtonVariants()}\n >\n +\n </button>\n </div>\n )}\n </div>\n )}\n\n <div data-slot=\"pdf-viewer-frame-container\" className={pdfViewerFrameVariants()}>\n {status === \"loading\" && (\n <output\n data-slot=\"pdf-viewer-loading\"\n className={pdfViewerStatusVariants({ tone: \"loading\" })}\n >\n {loadingLabel}\n </output>\n )}\n {status === \"error\" && (\n <div\n data-slot=\"pdf-viewer-error\"\n role=\"alert\"\n className={pdfViewerStatusVariants({ tone: \"error\" })}\n >\n {errorLabel}\n </div>\n )}\n <iframe\n ref={frameRef}\n data-slot=\"pdf-viewer-frame\"\n src={buildFrameSrc(fileUrl, currentPage, zoom)}\n title={fileUrl}\n className={cn(\n \"h-full min-h-64 w-full border-0\",\n status !== \"loaded\" && \"pointer-events-none absolute inset-0 opacity-0\",\n )}\n />\n </div>\n </div>\n );\n}\n\nMosaicPdfViewer.displayName = \"MosaicPdfViewer\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/pdf-viewer/pdf-viewer-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * pdfViewerVariants — pure CVA variant functions for MosaicPdfViewer.\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/** Frame container — hosts the iframe + the loading/error overlay. */\nexport const pdfViewerFrameVariants = cva([\n \"relative min-h-64 w-full flex-1 overflow-hidden rounded-lg border border-border bg-card\",\n]);\n\n/** Loading / error status region rendered over the frame. */\nexport const pdfViewerStatusVariants = cva(\n [\"flex h-full w-full flex-col items-center justify-center gap-2 p-4 text-center text-sm\"],\n {\n variants: {\n tone: {\n loading: \"text-muted-foreground\",\n error: \"text-destructive\",\n },\n },\n defaultVariants: {\n tone: \"loading\",\n },\n },\n);\n\n/** Toolbar icon buttons — page navigation + zoom controls. */\nexport const pdfViewerToolbarButtonVariants = cva([\n \"inline-flex min-h-8 min-w-8 items-center justify-center rounded-md border border-border text-sm\",\n \"transition-colors hover:bg-accent/50 disabled:opacity-50 disabled:hover:bg-transparent\",\n]);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-popover",
|
|
4
|
+
"title": "MosaicPopover",
|
|
5
|
+
"description": "MosaicPopover — @base-ui/react Popover primitive, anchored to any host element",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/popover/MosaicPopover.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicPopover — @base-ui/react Popover primitive, anchored to any host element\n *\n * Built on @base-ui/react/popover. Fully host-controlled (`open` +\n * `onOpenChange`) and anchored via an explicit `anchor` ref rather than a\n * built-in `Popover.Trigger` button — the trigger does not have to be a\n * `<button>`. This makes the component equally at home wrapping a menu\n * button and anchoring to a text input mid-typing (e.g. a mention-input\n * that opens a list of selectable entries while the caret stays inside the\n * input).\n *\n * The popover owns exactly three things: anchoring, dismissal (Escape,\n * outside click), and focus management. It owns none of the content: the\n * list, its items, filtering, selection — all of that is supplied by the\n * host as `children` and surfaced back through the host's own callbacks.\n * Non-modal by default (`modal={false}`) so a host anchoring to a live text\n * input is not forced into a focus trap; pass `modal` to opt into stronger\n * guarantees for other use cases (e.g. a standalone popover menu).\n *\n * data-slot=\"popover\" on the popup root, \"popover-positioner\" on the\n * positioning wrapper.\n *\n * SIN-01: the component carries zero visible strings. Every prop is either\n * structural (open/anchor/children) or an optional pass-through\n * (`aria-label`) with no default value — the host decides whether and what\n * to set.\n */\n\nimport { Popover } from \"@base-ui/react/popover\";\nimport type * as React from \"react\";\nimport { popoverPopupVariants } from \"./popover-variants.js\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicPopoverProps {\n /** Controlled open state — the host owns the truth. */\n open: boolean;\n /** Controlled state setter, called on every open/close intent. */\n onOpenChange: (open: boolean) => void;\n /**\n * The element the popup is positioned against. Any host element — a\n * button, a text input, a table cell — not limited to a\n * `Popover.Trigger`-rendered button.\n */\n anchor: React.RefObject<Element | null>;\n /** Host-owned content: list, form, or any other panel body. */\n children: React.ReactNode;\n /** Side of the anchor the popup opens toward. @default \"bottom\" */\n side?: \"top\" | \"bottom\" | \"left\" | \"right\";\n /** Alignment relative to the anchor. @default \"start\" */\n align?: \"start\" | \"center\" | \"end\";\n /**\n * Interaction scope while open.\n * - `false` (default): the rest of the page stays interactive — the\n * right choice when anchoring to a live input the host wants to keep\n * receiving keystrokes.\n * - `true` / `\"trap-focus\"`: stronger isolation for standalone popover\n * menus.\n * @default false\n */\n modal?: boolean | \"trap-focus\";\n /**\n * Element to move focus to when the popup opens. `false` leaves focus on\n * the host's own anchor (e.g. a text input mid-typing); `true` moves\n * focus to the first tabbable element inside the popup.\n * @default false\n */\n initialFocus?: boolean | React.RefObject<HTMLElement | null>;\n /**\n * Optional accessible name for the popup surface. No default — omit it\n * when the host's content already carries its own accessible structure\n * (e.g. a labelled list).\n */\n \"aria-label\"?: string;\n className?: string;\n}\n\n/**\n * MosaicPopover — anchored floating panel for @vantageos/mosaic-blocks.\n *\n * @example\n * // Anchored to a live text input; focus stays on the input while the\n * // host renders its own selectable list of entries.\n * const anchorRef = useRef<HTMLInputElement>(null);\n * <input ref={anchorRef} onChange={handleTyping} />\n * <MosaicPopover open={open} onOpenChange={setOpen} anchor={anchorRef}>\n * <ul role=\"listbox\">\n * {entries.map((entry) => (\n * <li key={entry.id}>\n * <button type=\"button\" onClick={() => selectEntry(entry)}>\n * {entry.label}\n * </button>\n * </li>\n * ))}\n * </ul>\n * </MosaicPopover>\n */\nexport function MosaicPopover({\n open,\n onOpenChange,\n anchor,\n children,\n side = \"bottom\",\n align = \"start\",\n modal = false,\n initialFocus = false,\n \"aria-label\": ariaLabel,\n className,\n}: MosaicPopoverProps) {\n return (\n <Popover.Root open={open} onOpenChange={(nextOpen) => onOpenChange(nextOpen)} modal={modal}>\n <Popover.Portal>\n <Popover.Positioner\n data-slot=\"popover-positioner\"\n anchor={anchor}\n side={side}\n align={align}\n sideOffset={4}\n >\n <Popover.Popup\n data-slot=\"popover\"\n aria-label={ariaLabel}\n initialFocus={initialFocus}\n className={cn(popoverPopupVariants(), className)}\n >\n {children}\n </Popover.Popup>\n </Popover.Positioner>\n </Popover.Portal>\n </Popover.Root>\n );\n}\n\nMosaicPopover.displayName = \"MosaicPopover\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/popover/popover-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * popoverPopupVariants — pure CVA variant function for MosaicPopover.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React or\n * @base-ui/react.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Floating popup panel — anchored, transitions in/out with the positioner. */\nexport const popoverPopupVariants = cva([\n \"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border\",\n \"bg-popover text-popover-foreground shadow-md outline-none\",\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"
|
|
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-preferences-panel",
|
|
4
|
+
"title": "MosaicPreferencesPanel",
|
|
5
|
+
"description": "Generic user preferences form. Grouped sections with select and toggle fields. Fully controlled via props.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/preferences-panel/MosaicPreferencesPanel.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicPreferencesPanel — generic user preferences form\n *\n * Ported from components/settings/preferences-panel.tsx\n *\n * Fully controlled via props. No internal toast calls, no API calls.\n * Consumers wire onSave + manage state externally if needed.\n * Strip: useToast, debate-specific model names (passed as items[]).\n */\n\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicSelectItem {\n value: string;\n label: string;\n}\n\nexport interface MosaicPreference {\n id: string;\n label: string;\n description?: string;\n type: \"select\" | \"toggle\";\n value: string | boolean;\n /** For type=\"select\" — list of options */\n options?: MosaicSelectItem[];\n}\n\nexport interface MosaicPreferenceGroup {\n id: string;\n title: string;\n description?: string;\n preferences: MosaicPreference[];\n}\n\nexport interface MosaicPreferencesPanelProps {\n /** Grouped preference sections */\n groups: MosaicPreferenceGroup[];\n /** Called with updated key/value when a preference changes */\n onChange: (id: string, value: string | boolean) => void;\n /** Called when user clicks Save */\n onSave: () => void;\n /** Whether the save action is pending */\n isSaving?: boolean;\n /** Label for the save button. Required, no default. */\n saveLabel: string;\n /** Label shown on the save button while `isSaving` is true. Required, no default. */\n savingLabel: string;\n className?: string;\n}\n\n// ── Sub-components ────────────────────────────────────────────────────────────\n\nfunction Toggle({\n id,\n checked,\n onChange,\n}: {\n id: string;\n checked: boolean;\n onChange: (v: boolean) => void;\n}) {\n return (\n <button\n type=\"button\"\n role=\"switch\"\n id={id}\n aria-checked={checked}\n onClick={() => onChange(!checked)}\n className={cn(\n \"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent\",\n \"transition-colors duration-200 ease-in-out\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n checked ? \"bg-primary\" : \"bg-muted\",\n )}\n >\n <span\n className={cn(\n \"pointer-events-none inline-block h-5 w-5 rounded-full bg-background shadow-lg\",\n \"transform transition duration-200 ease-in-out\",\n checked ? \"translate-x-5\" : \"translate-x-0\",\n )}\n />\n </button>\n );\n}\n\nfunction NativeSelect({\n id,\n value,\n options,\n onChange,\n}: {\n id: string;\n value: string;\n options: MosaicSelectItem[];\n onChange: (v: string) => void;\n}) {\n return (\n <select\n id={id}\n value={value}\n onChange={(e) => onChange(e.target.value)}\n className={cn(\n \"flex min-h-[48px] w-full rounded-md border border-input bg-background px-3 py-2\",\n \"text-sm text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n >\n {options.map((opt) => (\n <option key={opt.value} value={opt.value}>\n {opt.label}\n </option>\n ))}\n </select>\n );\n}\n\n// ── Main component ────────────────────────────────────────────────────────────\n\nexport function MosaicPreferencesPanel({\n groups,\n onChange,\n onSave,\n isSaving = false,\n saveLabel,\n savingLabel,\n className,\n}: MosaicPreferencesPanelProps) {\n const { isMobile } = useDevice();\n\n return (\n <div data-slot=\"preferences-panel\" className={cn(\"space-y-4 md:space-y-6\", className)}>\n {groups.map((group) => (\n <div\n key={group.id}\n className=\"rounded-lg border border-border bg-card text-card-foreground shadow-sm\"\n >\n <div className=\"flex flex-col space-y-1.5 p-6\">\n <h3 className=\"text-lg font-semibold leading-none tracking-tight md:text-xl\">\n {group.title}\n </h3>\n {group.description && (\n <p className=\"text-sm text-muted-foreground\">{group.description}</p>\n )}\n </div>\n <div className=\"p-6 pt-0 space-y-4 md:space-y-6\">\n {group.preferences.map((pref) => (\n <div key={pref.id}>\n {pref.type === \"select\" && (\n <div className=\"space-y-2\">\n <label htmlFor={pref.id} className=\"text-base font-medium leading-none\">\n {pref.label}\n </label>\n {pref.description && (\n <p className=\"text-sm text-muted-foreground\">{pref.description}</p>\n )}\n <NativeSelect\n id={pref.id}\n value={pref.value as string}\n options={pref.options ?? []}\n onChange={(v) => onChange(pref.id, v)}\n />\n </div>\n )}\n {pref.type === \"toggle\" && (\n <div className=\"flex min-h-[44px] items-center justify-between\">\n <div className=\"space-y-0.5\">\n <label htmlFor={pref.id} className=\"cursor-pointer text-base font-medium\">\n {pref.label}\n </label>\n {pref.description && (\n <p className=\"text-sm text-muted-foreground\">{pref.description}</p>\n )}\n </div>\n <Toggle\n id={pref.id}\n checked={pref.value as boolean}\n onChange={(v) => onChange(pref.id, v)}\n />\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n ))}\n\n <div className={cn(\"flex\", isMobile ? \"flex-col\" : \"justify-end\")}>\n <button\n type=\"button\"\n onClick={onSave}\n disabled={isSaving}\n className={cn(\n \"inline-flex min-h-[44px] items-center justify-center gap-2 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 isMobile ? \"w-full\" : \"w-auto\",\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z\" />\n <polyline points=\"17 21 17 13 7 13 7 21\" />\n <polyline points=\"7 3 7 8 15 8\" />\n </svg>\n {isSaving ? savingLabel : saveLabel}\n </button>\n </div>\n </div>\n );\n}\n\nMosaicPreferencesPanel.displayName = \"MosaicPreferencesPanel\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-pricing-card",
|
|
4
|
+
"title": "MosaicPricingCard",
|
|
5
|
+
"description": "Single pricing tier card. Props: tier, price, features[], cta, highlighted. Compose multiple in a grid for a full pricing section.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/pricing-card/MosaicPricingCard.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicPricingCard — single pricing tier card\n *\n * Ported from heyfabrika/styleui blocks/pricing/pricing-card.tsx (MIT).\n * Adapted: props-driven (tier, price, features, cta, highlighted).\n * No shadcn Card/Badge imports — self-contained for lib portability.\n * Styling: Tailwind v4 + OKLCH tokens.\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface PricingCta {\n label: string;\n href: string;\n}\n\nexport interface MosaicPricingCardProps {\n /** Tier name, e.g. \"Free\", \"Pro\", \"Enterprise\" */\n tier: string;\n /** Price string, e.g. \"$19/mo\" or \"Free\" */\n price: string;\n /** Feature list items */\n features: string[];\n /** CTA button config */\n cta: PricingCta;\n /** Highlighted tier — renders with accent border + tinted background */\n highlighted?: boolean;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicPricingCard — a single pricing tier. Compose multiple inside a flex/grid\n * wrapper to build a full pricing section.\n *\n * @example\n * <MosaicPricingCard\n * tier=\"Pro\"\n * price=\"$19/mo\"\n * features={[\"Unlimited projects\", \"Priority support\", \"Custom domain\"]}\n * cta={{ label: \"Get started\", href: \"/signup/pro\" }}\n * highlighted\n * />\n */\nexport function MosaicPricingCard({\n tier,\n price,\n features,\n cta,\n highlighted = false,\n className,\n ref,\n}: MosaicPricingCardProps) {\n return (\n <div\n ref={ref}\n className={cn(\n \"flex min-w-72 flex-col gap-6 rounded-2xl border p-8\",\n highlighted\n ? \"border-[oklch(0.6_0.15_250_/_0.5)] bg-[oklch(0.97_0.02_250)]\"\n : \"border-[oklch(0.9_0.005_250)] bg-[oklch(1_0_0)]\",\n className,\n )}\n >\n {/* Tier badge */}\n <span\n className={cn(\n \"inline-flex w-fit items-center rounded-sm border px-2.5 py-0.5 text-xs font-semibold\",\n highlighted\n ? \"border-transparent bg-[oklch(0.15_0.01_250)] text-[oklch(0.98_0_0)]\"\n : \"border-[oklch(0.85_0.01_250)] bg-[oklch(1_0_0)] text-[oklch(0.2_0.01_250)]\",\n )}\n >\n {tier}\n </span>\n\n {/* Price */}\n <p className=\"text-xl font-semibold text-[oklch(0.12_0.01_250)]\">{price}</p>\n\n {/* CTA */}\n <a\n href={cta.href}\n className={cn(\n \"inline-flex w-full items-center justify-center rounded-lg px-4 py-2.5 text-sm font-medium transition-colors\",\n highlighted\n ? \"bg-[oklch(0.15_0.01_250)] text-[oklch(0.98_0_0)] hover:bg-[oklch(0.25_0.01_250)]\"\n : \"border border-[oklch(0.75_0.01_250)] bg-transparent text-[oklch(0.15_0.01_250)] hover:bg-[oklch(0.96_0.005_250)]\",\n )}\n >\n {cta.label}\n </a>\n\n {/* Features */}\n <ul className=\"flex flex-col gap-2\">\n {features.map((feature) => (\n <li key={feature} className=\"flex items-center gap-2 text-sm text-[oklch(0.35_0.01_250)]\">\n {/* Check icon (inline SVG — no lucide-react dep) */}\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.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"shrink-0 text-[oklch(0.5_0.12_145)]\"\n aria-hidden=\"true\"\n >\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n {feature}\n </li>\n ))}\n </ul>\n </div>\n );\n}\n\nMosaicPricingCard.displayName = \"MosaicPricingCard\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-profile-panel",
|
|
4
|
+
"title": "MosaicProfilePanel",
|
|
5
|
+
"description": "Generic user profile form. Avatar upload slot, field list, security section. Fully controlled via props.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/profile-panel/MosaicProfilePanel.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicProfilePanel — generic user profile form\n *\n * Ported from components/settings/profile-panel.tsx\n *\n * Fully controlled via props. No internal toast calls, no API calls.\n * Consumers wire onSave, onAvatarUpload, onChange externally.\n * Avatar upload trigger is a slot (optional). No Radix Avatar dep — CSS initials fallback.\n */\n\nimport type * as React from \"react\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicProfileField {\n id: string;\n label: string;\n type?: \"text\" | \"email\" | \"textarea\" | \"password\";\n value: string;\n placeholder?: string;\n readOnly?: boolean;\n}\n\nexport interface MosaicProfilePanelProps {\n /** Display name — used for avatar initials fallback */\n displayName?: string;\n /** Avatar image URL */\n avatarSrc?: string;\n /** Profile fields to render */\n fields?: MosaicProfileField[];\n /** Called when a field value changes */\n onFieldChange?: (id: string, value: string) => void;\n /** Called when user clicks Save */\n onSave: () => void;\n /** Whether save is pending */\n isSaving?: boolean;\n /** Called when user clicks the avatar upload button */\n onAvatarUpload?: () => void;\n /** Custom sections to render below the form */\n extraSections?: React.ReactNode;\n /** Label for the save button. Required, no default. */\n saveLabel: string;\n /** Security section: called when user clicks \"Change Password\" */\n onChangePassword?: () => void;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n avatarHeading: string;\n avatarSubheading: string;\n uploadPhotoLabel: string;\n personalInfoHeading: string;\n personalInfoSubheading: string;\n securityHeading: string;\n securitySubheading: string;\n changePasswordLabel: string;\n savingLabel: string;\n /**\n * Fallback name used for avatar initials when `displayName` is empty.\n * Required, no default.\n */\n unnamedUserLabel: string;\n className?: string;\n}\n\n// ── Avatar ────────────────────────────────────────────────────────────────────\n\nfunction AvatarDisplay({\n src,\n name,\n size,\n}: {\n src?: string;\n name: string;\n size: \"md\" | \"lg\";\n}) {\n const initials = name\n .split(\" \")\n .map((n) => n[0])\n .filter(Boolean)\n .slice(0, 2)\n .join(\"\")\n .toUpperCase();\n\n const sizeClass = size === \"lg\" ? \"h-24 w-24 text-2xl\" : \"h-20 w-20 text-xl\";\n\n return (\n <span\n className={cn(\n \"inline-flex shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground font-semibold overflow-hidden\",\n sizeClass,\n )}\n >\n {src ? <img src={src} alt={name} className=\"h-full w-full object-cover\" /> : initials}\n </span>\n );\n}\n\n// ── Main component ────────────────────────────────────────────────────────────\n\nexport function MosaicProfilePanel({\n displayName = \"\",\n avatarSrc,\n fields = [],\n onFieldChange,\n onSave,\n isSaving = false,\n onAvatarUpload,\n extraSections,\n saveLabel,\n onChangePassword,\n avatarHeading,\n avatarSubheading,\n uploadPhotoLabel,\n personalInfoHeading,\n personalInfoSubheading,\n securityHeading,\n securitySubheading,\n changePasswordLabel,\n savingLabel,\n unnamedUserLabel,\n className,\n}: MosaicProfilePanelProps) {\n const { isMobile } = useDevice();\n\n return (\n <div data-slot=\"profile-panel\" className={cn(\"space-y-4 md:space-y-6\", className)}>\n {/* Avatar section */}\n <div className=\"rounded-lg border border-border bg-card text-card-foreground shadow-sm\">\n <div className=\"flex flex-col space-y-1.5 p-6\">\n <h3 className=\"text-lg font-semibold leading-none tracking-tight md:text-xl\">\n {avatarHeading}\n </h3>\n <p className=\"text-sm text-muted-foreground\">{avatarSubheading}</p>\n </div>\n <div className=\"p-6 pt-0\">\n <div className=\"flex items-center gap-4\">\n <AvatarDisplay\n src={avatarSrc}\n name={displayName || unnamedUserLabel}\n size={isMobile ? \"md\" : \"lg\"}\n />\n {onAvatarUpload && (\n <button\n type=\"button\"\n onClick={onAvatarUpload}\n className={cn(\n \"inline-flex min-h-[44px] items-center justify-center gap-2 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 isMobile ? \"w-full\" : \"w-auto\",\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\" />\n <polyline points=\"17 8 12 3 7 8\" />\n <line x1=\"12\" y1=\"3\" x2=\"12\" y2=\"15\" />\n </svg>\n {uploadPhotoLabel}\n </button>\n )}\n </div>\n </div>\n </div>\n\n {/* Profile fields */}\n {fields.length > 0 && (\n <div className=\"rounded-lg border border-border bg-card text-card-foreground shadow-sm\">\n <div className=\"flex flex-col space-y-1.5 p-6\">\n <h3 className=\"text-lg font-semibold leading-none tracking-tight md:text-xl\">\n {personalInfoHeading}\n </h3>\n <p className=\"text-sm text-muted-foreground\">{personalInfoSubheading}</p>\n </div>\n <div className=\"p-6 pt-0 space-y-4 md:space-y-6\">\n {fields.map((field) => (\n <div key={field.id} className=\"space-y-2\">\n <label htmlFor={field.id} className=\"text-base font-medium leading-none\">\n {field.label}\n </label>\n {field.type === \"textarea\" ? (\n <textarea\n id={field.id}\n value={field.value}\n readOnly={field.readOnly}\n placeholder={field.placeholder}\n onChange={(e) => onFieldChange?.(field.id, e.target.value)}\n rows={4}\n className={cn(\n \"flex min-h-[120px] w-full rounded-md border border-input bg-background px-3 py-2\",\n \"text-sm text-foreground placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"disabled:cursor-not-allowed disabled:opacity-50 resize-none\",\n )}\n />\n ) : (\n <input\n id={field.id}\n type={field.type ?? \"text\"}\n value={field.value}\n readOnly={field.readOnly}\n placeholder={field.placeholder}\n onChange={(e) => onFieldChange?.(field.id, e.target.value)}\n className={cn(\n \"flex min-h-[48px] w-full rounded-md border border-input bg-background px-3 py-2\",\n \"text-sm text-foreground placeholder:text-muted-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n \"disabled:cursor-not-allowed disabled:opacity-50\",\n )}\n />\n )}\n </div>\n ))}\n </div>\n </div>\n )}\n\n {/* Security section */}\n {onChangePassword && (\n <div className=\"rounded-lg border border-border bg-card text-card-foreground shadow-sm\">\n <div className=\"flex flex-col space-y-1.5 p-6\">\n <h3 className=\"text-lg font-semibold leading-none tracking-tight md:text-xl\">\n {securityHeading}\n </h3>\n <p className=\"text-sm text-muted-foreground\">{securitySubheading}</p>\n </div>\n <div className=\"p-6 pt-0\">\n <button\n type=\"button\"\n onClick={onChangePassword}\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 isMobile ? \"w-full\" : \"w-auto\",\n )}\n >\n {changePasswordLabel}\n </button>\n </div>\n </div>\n )}\n\n {extraSections}\n\n {/* Save button */}\n <div className={cn(\"flex\", isMobile ? \"flex-col\" : \"justify-end\")}>\n <button\n type=\"button\"\n onClick={onSave}\n disabled={isSaving}\n className={cn(\n \"inline-flex min-h-[44px] items-center justify-center gap-2 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 isMobile ? \"w-full\" : \"w-auto\",\n )}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z\" />\n <polyline points=\"17 21 17 13 7 13 7 21\" />\n <polyline points=\"7 3 7 8 15 8\" />\n </svg>\n {isSaving ? savingLabel : saveLabel}\n </button>\n </div>\n </div>\n );\n}\n\nMosaicProfilePanel.displayName = \"MosaicProfilePanel\";\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-progress",
|
|
4
|
+
"title": "MosaicProgress",
|
|
5
|
+
"description": "MosaicProgress — @base-ui/react Progress primitive",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/progress/MosaicProgress.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicProgress — @base-ui/react Progress primitive\n *\n * Builds on Progress.Root + Progress.Track + Progress.Indicator.\n * Supports determinate (value prop) and indeterminate states.\n * aria-valuenow, aria-valuemin, aria-valuemax managed by the primitive.\n *\n * data-slot=\"progress\" on Root, \"progress-track\" on Track, \"progress-indicator\" on Indicator.\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Progress } from \"@base-ui/react/progress\";\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 MosaicProgressProps extends Progress.Root.Props {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicProgress — production Progress atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/progress. Determinate and indeterminate modes.\n * Pass `value={null}` for indeterminate; pass `value={0–100}` for determinate.\n *\n * @example\n * <MosaicProgress value={60} />\n * <MosaicProgress value={null} aria-label=\"Loading…\" />\n */\nexport function MosaicProgress({\n className,\n value,\n max = 100,\n ref,\n ...props\n}: MosaicProgressProps) {\n return (\n <Progress.Root\n ref={ref}\n data-slot=\"progress\"\n value={value}\n max={max}\n className={cn(\"w-full\", className)}\n {...props}\n >\n <Progress.Track\n data-slot=\"progress-track\"\n className=\"relative h-2 w-full overflow-hidden rounded-full bg-secondary\"\n >\n <Progress.Indicator\n data-slot=\"progress-indicator\"\n className=\"h-full w-full flex-1 rounded-full bg-foreground transition-transform duration-300 ease-in-out\"\n style={{ transform: `translateX(-${100 - (value ?? 0)}%)` }}\n />\n </Progress.Track>\n </Progress.Root>\n );\n}\n\nMosaicProgress.displayName = \"MosaicProgress\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-quick-action-card",
|
|
4
|
+
"title": "MosaicQuickActionCard",
|
|
5
|
+
"description": "Grid of action cards with 6 accent color presets (yellow, blue, green, purple, orange, cyan). CSS stagger reveal on mount. Props: actions[] {id, title, description, icon, href, accent?}, heading, columns, renderLink. No hardcoded routes.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/quick-action-card/MosaicQuickActionCard.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "\"use client\";\n\n/**\n * MosaicQuickActionCard — 6-accent action card grid (PC-07)\n *\n * Ported (source: private upstream) components/dashboard/QuickActions.tsx\n *\n * Renders a grid of action cards. Each card: icon slot, title, description,\n * accent color variant (6 presets: yellow, blue, green, purple, orange, cyan).\n * Cards have hover scale (CSS) + stagger reveal (CSS keyframes).\n *\n * Generalized: hardcoded debate hrefs stripped; externalized as actions[] prop.\n * Icon: caller-provided ReactNode (any SVG/component).\n * Link: uses <a> by default; provide renderLink prop for router-aware links.\n *\n * Framer-motion replaced with CSS keyframe stagger (precedent: MosaicAnimatedList).\n * Respects prefers-reduced-motion.\n * Icons: caller-provided (no lucide dep).\n */\n\nimport * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst ANIM_ID = \"mosaic-quick-action-kf\";\n\nfunction injectStyles() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(ANIM_ID)) return;\n const s = document.createElement(\"style\");\n s.id = ANIM_ID;\n s.textContent = `\n @keyframes mosaic-action-in {\n from { opacity: 0; transform: scale(0.92); }\n to { opacity: 1; transform: scale(1); }\n }\n .mosaic-action-item {\n opacity: 0;\n animation: mosaic-action-in 250ms ease-out forwards;\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-action-item {\n animation: none !important;\n opacity: 1 !important;\n }\n }\n `;\n document.head.appendChild(s);\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicActionAccent =\n | \"yellow\"\n | \"blue\"\n | \"green\"\n | \"purple\"\n | \"orange\"\n | \"cyan\"\n | \"gray\";\n\nexport interface MosaicQuickAction {\n /** Stable unique identifier for this action */\n id: string;\n title: string;\n description: string;\n /** Icon node — caller provides any SVG or component (no lucide dep) */\n icon: React.ReactNode;\n href: string;\n /** Accent color preset (default \"blue\") */\n accent?: MosaicActionAccent;\n}\n\nexport interface MosaicQuickActionCardProps {\n actions: MosaicQuickAction[];\n /** Section heading (optional) */\n heading?: string;\n /** Custom columns (default: 2 mobile, 3 desktop) */\n columns?: { mobile?: number; desktop?: number };\n /**\n * Custom link renderer — use for Next.js Link or router-aware navigation.\n * Receives href + children, must return a valid anchor-like element.\n * Default: native <a>.\n */\n renderLink?: (href: string, children: React.ReactNode) => React.ReactNode;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Accent map ────────────────────────────────────────────────────────────────\n\nconst ACCENT_CLASSES: Record<MosaicActionAccent, string> = {\n yellow: \"bg-yellow-500/10 text-yellow-600 border-yellow-500/20 dark:text-yellow-400\",\n blue: \"bg-blue-500/10 text-blue-600 border-blue-500/20 dark:text-blue-400\",\n green: \"bg-green-500/10 text-green-600 border-green-500/20 dark:text-green-400\",\n purple: \"bg-purple-500/10 text-purple-600 border-purple-500/20 dark:text-purple-400\",\n orange: \"bg-orange-500/10 text-orange-600 border-orange-500/20 dark:text-orange-400\",\n cyan: \"bg-cyan-500/10 text-cyan-600 border-cyan-500/20 dark:text-cyan-400\",\n gray: \"bg-gray-500/10 text-gray-600 border-gray-500/20 dark:text-gray-400\",\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicQuickActionCard — grid of action cards with 6 accent variants.\n * Each card links to an href. Fully props-driven; no hardcoded routes.\n *\n * @example\n * <MosaicQuickActionCard\n * heading=\"Quick Actions\"\n * actions={[\n * { id: \"create\", title: \"Create\", description: \"Start new item\", icon: <PlusIcon />, href: \"/create\", accent: \"green\" },\n * ]}\n * />\n */\nexport function MosaicQuickActionCard({\n actions,\n heading,\n columns = {},\n renderLink,\n className,\n ref,\n}: MosaicQuickActionCardProps) {\n const { mobile = 2, desktop = 3 } = columns;\n\n React.useEffect(() => {\n injectStyles();\n }, []);\n\n const defaultRenderLink = (href: string, children: React.ReactNode) => (\n <a href={href} className=\"block h-full\">\n {children}\n </a>\n );\n\n const link = renderLink ?? defaultRenderLink;\n\n return (\n <div\n ref={ref}\n data-slot=\"quick-action-card\"\n className={cn(\"rounded-xl border border-border bg-card\", className)}\n >\n {heading && (\n <div className=\"border-b border-border px-6 py-4\">\n <h3 className=\"text-lg font-semibold text-foreground\">{heading}</h3>\n </div>\n )}\n <div\n className=\"p-6\"\n style={{\n display: \"grid\",\n gap: \"0.75rem\",\n gridTemplateColumns: `repeat(${mobile}, minmax(0, 1fr))`,\n }}\n >\n {actions.map((action, idx) => {\n const accent = action.accent ?? \"blue\";\n const accentClass = ACCENT_CLASSES[accent];\n\n return (\n <div\n key={action.id}\n className=\"mosaic-action-item h-full\"\n style={{ animationDelay: `${idx * 50}ms` }}\n >\n {link(\n action.href,\n <div\n className={cn(\n \"flex min-h-[100px] cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border p-4\",\n \"transition-transform duration-150 hover:scale-105 active:scale-[0.98]\",\n accentClass,\n )}\n >\n <div className=\"shrink-0 text-[1.4rem] leading-none\" aria-hidden=\"true\">\n {action.icon}\n </div>\n <div className=\"w-full space-y-0.5 text-center\">\n <p className=\"text-sm font-medium leading-tight\">{action.title}</p>\n <p className=\"text-xs leading-tight text-current/70\">{action.description}</p>\n </div>\n </div>,\n )}\n </div>\n );\n })}\n </div>\n\n {/* Responsive desktop columns via style injection avoids JIT dynamic class issue */}\n <style>{`\n @media (min-width: 768px) {\n [data-slot=\"quick-action-card\"] > div:last-child {\n grid-template-columns: repeat(${desktop}, minmax(0, 1fr));\n }\n }\n `}</style>\n </div>\n );\n}\n\nMosaicQuickActionCard.displayName = \"MosaicQuickActionCard\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-quick-actions-menu",
|
|
4
|
+
"title": "MosaicQuickActionsMenu",
|
|
5
|
+
"description": "Generic + button dropdown for quick actions. Items with icon + label + separator. Custom link renderer prop.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.36-alpha/r/mosaic-device-provider.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/quick-actions-menu/MosaicQuickActionsMenu.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicQuickActionsMenu — generic dropdown quick-actions button\n *\n * Ported from components/dashboard/QuickActionsMenu.tsx\n *\n * Features:\n * - Dropdown menu triggered by a \"+\" button\n * - Action items with icon + label\n * - Separator support\n * - Mobile-aware width\n * - All hrefs/routes are props (no next/link hardcoded)\n *\n * next/Link removed → renderItem prop or href + onClick.\n * All debate-specific actions stripped — items are generic props.\n */\n\nimport * as React from \"react\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicQuickAction {\n id: string;\n label: string;\n icon?: React.ReactNode;\n onClick?: () => void;\n href?: string;\n /** If true, renders a separator BEFORE this item */\n separator?: boolean;\n}\n\nexport interface MosaicQuickActionsMenuProps {\n actions?: MosaicQuickAction[];\n /** Trigger button label (hidden on mobile when icon-only). Required, no default. */\n label: string;\n /** Custom trigger icon */\n triggerIcon?: React.ReactNode;\n /** Menu header label. Required, no default. */\n menuTitle: string;\n /** Custom link renderer for href items */\n renderLink?: (\n action: MosaicQuickAction,\n children: React.ReactNode,\n className: string,\n ) => React.ReactNode;\n /** Message shown when `actions` is empty. Required, no default. */\n emptyMessage: string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction PlusIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n );\n}\n\n// ── Default actions (generic) ─────────────────────────────────────────────────\n\nconst DEFAULT_ACTIONS: MosaicQuickAction[] = [];\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicQuickActionsMenu({\n actions = DEFAULT_ACTIONS,\n label,\n triggerIcon,\n menuTitle,\n renderLink,\n emptyMessage,\n className,\n}: MosaicQuickActionsMenuProps) {\n const { isMobile } = useDevice();\n const [open, setOpen] = React.useState(false);\n const ref = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!open) return;\n const h = (e: MouseEvent) => {\n if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);\n };\n document.addEventListener(\"mousedown\", h);\n return () => document.removeEventListener(\"mousedown\", h);\n }, [open]);\n\n const itemClass = cn(\n \"flex w-full items-center gap-2 px-3 py-2 text-sm text-foreground\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n \"min-h-[44px]\",\n );\n\n return (\n <div ref={ref} data-slot=\"quick-actions-menu\" className={cn(\"relative\", className)}>\n <button\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n className={cn(\n \"inline-flex items-center justify-center gap-2 rounded-md border border-border bg-background\",\n \"min-h-[44px] min-w-[44px] px-3 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 aria-haspopup=\"menu\"\n aria-expanded={open}\n aria-label={label}\n >\n {triggerIcon ?? <PlusIcon />}\n <span className={cn(\"hidden md:inline\")}>{label}</span>\n </button>\n\n {open && (\n <div\n role=\"menu\"\n aria-label={menuTitle}\n className={cn(\n \"absolute right-0 top-full z-50 mt-1 rounded-md border border-border bg-popover py-1 shadow-md\",\n isMobile ? \"w-[min(90vw,280px)]\" : \"w-56\",\n )}\n >\n {menuTitle && (\n <div className=\"px-3 py-1.5\">\n <p className=\"text-xs font-semibold text-muted-foreground uppercase tracking-wide\">\n {menuTitle}\n </p>\n </div>\n )}\n <div className={cn(menuTitle && \"border-t border-border\")} />\n\n {actions.map((action) => (\n <React.Fragment key={action.id}>\n {action.separator && <div className=\"my-1 border-t border-border\" />}\n {action.href && renderLink ? (\n renderLink(\n action,\n <>\n {action.icon}\n {action.label}\n </>,\n itemClass,\n )\n ) : action.href ? (\n <a href={action.href} className={itemClass} onClick={() => setOpen(false)}>\n {action.icon}\n {action.label}\n </a>\n ) : (\n <button\n type=\"button\"\n role=\"menuitem\"\n onClick={() => {\n action.onClick?.();\n setOpen(false);\n }}\n className={itemClass}\n >\n {action.icon}\n {action.label}\n </button>\n )}\n </React.Fragment>\n ))}\n\n {actions.length === 0 && (\n <p className=\"px-3 py-4 text-center text-sm text-muted-foreground\">{emptyMessage}</p>\n )}\n </div>\n )}\n </div>\n );\n}\n\nMosaicQuickActionsMenu.displayName = \"MosaicQuickActionsMenu\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-quick-agent-selector",
|
|
4
|
+
"title": "MosaicQuickAgentSelector",
|
|
5
|
+
"description": "Compact agent pill picker with desktop dropdown / mobile drawer. Selected agents shown as removable pills.",
|
|
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-device-provider.json"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/quick-agent-selector/MosaicQuickAgentSelector.tsx",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"content": "\"use client\";\n\n/**\n * MosaicQuickAgentSelector — compact agent picker with pill tags + add dropdown/drawer\n *\n * Ported from components/agent-management/QuickAgentSelector.tsx\n *\n * Features:\n * - Scrollable list of selected agent pills with remove button\n * - Desktop: dropdown panel\n * - Mobile: bottom drawer via MosaicAdaptiveModal\n * - \"Create custom\" action slot\n *\n * framer-motion replaced with CSS transitions.\n * sonner toast removed — actions are callbacks.\n * Drawer replaced with MosaicAdaptiveModal (wave-1 component).\n */\n\nimport * as React from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\nimport { useDevice } from \"@/components/ui/MosaicDeviceProvider\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicQuickAgent {\n id: string;\n /** Display name */\n name: string;\n /** Short type key (e.g. \"GPT-4\") */\n type: string;\n /** Description shown in the picker list */\n description?: string;\n /** Tailwind bg class for the accent dot */\n accentColor?: string;\n isActive?: boolean;\n}\n\nexport interface MosaicQuickAgentSelectorProps {\n /** Currently selected agents */\n selectedAgents: MosaicQuickAgent[];\n /** Available agents to pick from (already-selected ones hidden) */\n availableAgents?: MosaicQuickAgent[];\n onAddAgent: (agentId: string) => void;\n onRemoveAgent: (agentId: string) => void;\n /**\n * Formatter for the remove-pill aria-label. Required, no default — the\n * host owns the language (e.g. `(name) => t('QuickAgentSelector.remove', { name })`).\n */\n removeAgentAriaLabel: (agentName: string) => string;\n /** Called when user clicks \"Create custom\" / \"Configure\" CTA */\n onOpenBuilder?: () => void;\n /** Max number of agents allowed */\n maxAgents?: number;\n /** Label for the add button. Required, no default. */\n addLabel: string;\n /** Label for the create-custom CTA (shown when `onOpenBuilder` is set). Required, no default. */\n createLabel: string;\n /**\n * Required host-owned strings — no default, no fallback. The host owns\n * the language (e.g. next-intl `t()`).\n */\n quickAddHeading: string;\n configureBehaviorCaption: string;\n noAgentsAvailableMessage: string;\n addAgentModalTitle: string;\n closeAriaLabel: string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction PlusIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n );\n}\n\nfunction XIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"10\"\n height=\"10\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n );\n}\n\nfunction SparklesIcon() {\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 3l1.5 4.5L18 9l-4.5 1.5L12 15l-1.5-4.5L6 9l4.5-1.5z\" />\n <path d=\"M5 20l.5-1.5L7 18l-1.5-.5L5 16l-.5 1.5L3 18l1.5.5z\" />\n </svg>\n );\n}\n\n// ── Picker content ────────────────────────────────────────────────────────────\n\nfunction PickerContent({\n available,\n onAdd,\n onOpenBuilder,\n createLabel,\n quickAddHeading,\n configureBehaviorCaption,\n noAgentsAvailableMessage,\n}: {\n available: MosaicQuickAgent[];\n onAdd: (id: string) => void;\n onOpenBuilder?: () => void;\n createLabel: string;\n quickAddHeading: string;\n configureBehaviorCaption: string;\n noAgentsAvailableMessage: string;\n}) {\n return (\n <div className=\"p-4\">\n <h4 className=\"mb-3 font-medium text-foreground\">{quickAddHeading}</h4>\n <div className=\"space-y-1\">\n {available.map((agent) => (\n <button\n key={agent.id}\n type=\"button\"\n onClick={() => onAdd(agent.id)}\n className={cn(\n \"flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-sm\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n {agent.accentColor && (\n <span\n className={cn(\"h-3 w-3 shrink-0 rounded-full\", agent.accentColor)}\n aria-hidden=\"true\"\n />\n )}\n <div className=\"text-left\">\n <p className=\"font-medium\">{agent.name}</p>\n {agent.description && (\n <p className=\"text-xs text-muted-foreground\">{agent.description}</p>\n )}\n </div>\n </button>\n ))}\n\n {onOpenBuilder && (\n <div className=\"mt-2 border-t border-border pt-2\">\n <button\n type=\"button\"\n onClick={onOpenBuilder}\n className={cn(\n \"flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-sm\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <SparklesIcon />\n <div className=\"text-left\">\n <p className=\"font-medium text-primary\">{createLabel}</p>\n <p className=\"text-xs text-muted-foreground\">{configureBehaviorCaption}</p>\n </div>\n </button>\n </div>\n )}\n\n {available.length === 0 && !onOpenBuilder && (\n <p className=\"px-3 py-2 text-sm text-muted-foreground\">{noAgentsAvailableMessage}</p>\n )}\n </div>\n </div>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicQuickAgentSelector({\n selectedAgents,\n availableAgents = [],\n onAddAgent,\n onRemoveAgent,\n removeAgentAriaLabel,\n onOpenBuilder,\n maxAgents = 4,\n addLabel,\n createLabel,\n quickAddHeading,\n configureBehaviorCaption,\n noAgentsAvailableMessage,\n addAgentModalTitle,\n closeAriaLabel,\n className,\n}: MosaicQuickAgentSelectorProps) {\n const { isMobile } = useDevice();\n const [pickerOpen, setPickerOpen] = React.useState(false);\n const dropdownRef = React.useRef<HTMLDivElement>(null);\n\n // Close desktop dropdown on outside click\n React.useEffect(() => {\n if (!pickerOpen || isMobile) return;\n const handler = (e: MouseEvent) => {\n if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) {\n setPickerOpen(false);\n }\n };\n const t = setTimeout(() => document.addEventListener(\"mousedown\", handler), 100);\n return () => {\n clearTimeout(t);\n document.removeEventListener(\"mousedown\", handler);\n };\n }, [pickerOpen, isMobile]);\n\n const handleAdd = (id: string) => {\n onAddAgent(id);\n setPickerOpen(false);\n };\n\n const canAdd = selectedAgents.length < maxAgents;\n\n return (\n <div data-slot=\"quick-agent-selector\" className={cn(\"flex items-center gap-2\", className)}>\n {/* Selected agent pills */}\n <div className=\"flex items-center gap-2 overflow-x-auto\">\n {selectedAgents.map((agent) => (\n <div\n key={agent.id}\n className={cn(\n \"group flex shrink-0 items-center gap-2 rounded-md border border-border bg-card\",\n isMobile ? \"px-2 py-1\" : \"px-3 py-1.5\",\n )}\n >\n {agent.accentColor && (\n <span\n className={cn(\"h-2 w-2 shrink-0 rounded-full\", agent.accentColor)}\n aria-hidden=\"true\"\n />\n )}\n <span className={cn(\"whitespace-nowrap font-medium\", isMobile ? \"text-xs\" : \"text-sm\")}>\n {isMobile ? agent.type.split(\"-\")[0] : agent.name}\n </span>\n <button\n type=\"button\"\n onClick={() => onRemoveAgent(agent.id)}\n className={cn(\n \"inline-flex h-4 w-4 items-center justify-center rounded\",\n \"text-muted-foreground hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n isMobile ? \"opacity-100\" : \"opacity-0 transition-opacity group-hover:opacity-100\",\n )}\n aria-label={removeAgentAriaLabel(agent.name)}\n >\n <XIcon />\n </button>\n </div>\n ))}\n </div>\n\n {/* Add button + picker */}\n {canAdd && (\n <div ref={dropdownRef} className=\"relative shrink-0\">\n <button\n type=\"button\"\n onClick={() => setPickerOpen((v) => !v)}\n className={cn(\n \"inline-flex items-center justify-center gap-2 rounded-md border border-border bg-background\",\n \"px-3 py-1.5 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 <PlusIcon />\n {!isMobile && addLabel}\n </button>\n\n {/* Desktop dropdown */}\n {!isMobile && pickerOpen && (\n <div\n className={cn(\n \"absolute left-0 top-full z-50 mt-2 w-72 rounded-lg border border-border\",\n \"bg-popover shadow-lg\",\n )}\n >\n <PickerContent\n available={availableAgents}\n onAdd={handleAdd}\n onOpenBuilder={\n onOpenBuilder\n ? () => {\n onOpenBuilder();\n setPickerOpen(false);\n }\n : undefined\n }\n createLabel={createLabel}\n quickAddHeading={quickAddHeading}\n configureBehaviorCaption={configureBehaviorCaption}\n noAgentsAvailableMessage={noAgentsAvailableMessage}\n />\n </div>\n )}\n\n {/* Mobile drawer */}\n {isMobile && (\n <MosaicAdaptiveModal\n isOpen={pickerOpen}\n onClose={() => setPickerOpen(false)}\n title={addAgentModalTitle}\n closeAriaLabel={closeAriaLabel}\n >\n <PickerContent\n available={availableAgents}\n onAdd={handleAdd}\n onOpenBuilder={\n onOpenBuilder\n ? () => {\n onOpenBuilder();\n setPickerOpen(false);\n }\n : undefined\n }\n createLabel={createLabel}\n quickAddHeading={quickAddHeading}\n configureBehaviorCaption={configureBehaviorCaption}\n noAgentsAvailableMessage={noAgentsAvailableMessage}\n />\n </MosaicAdaptiveModal>\n )}\n </div>\n )}\n\n {/* Count badge */}\n <span\n className={cn(\n \"shrink-0 rounded-md bg-secondary px-2 py-0.5 text-xs font-medium text-secondary-foreground\",\n )}\n >\n {selectedAgents.length}/{maxAgents}\n </span>\n </div>\n );\n}\n\nMosaicQuickAgentSelector.displayName = \"MosaicQuickAgentSelector\";\n"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"type": "registry:ui"
|
|
19
|
+
}
|