@vantageos/mosaic-blocks 0.5.35-alpha → 0.5.37-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 +11 -8
- package/dist/index.cjs +828 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +415 -11
- package/dist/index.d.ts +415 -11
- package/dist/index.js +809 -41
- package/dist/index.js.map +1 -1
- package/dist/styles.css +18 -0
- package/package.json +20 -7
- package/r/mosaic-accordion.json +1 -2
- package/r/mosaic-activity-feed.json +16 -0
- package/r/mosaic-adaptive-grid.json +18 -0
- package/r/mosaic-adaptive-modal.json +18 -0
- package/r/mosaic-adaptive-navigation.json +18 -0
- package/r/mosaic-add-memory-form.json +25 -0
- package/r/mosaic-admin-only-guard.json +18 -0
- package/r/mosaic-agent-builder-modal.json +23 -0
- package/r/mosaic-agent-card.json +16 -0
- package/r/mosaic-agent-chat.json +26 -0
- package/r/mosaic-agent-composer.json +28 -0
- package/r/mosaic-agent-editor.json +25 -0
- package/r/mosaic-agent-list.json +21 -0
- package/r/mosaic-agent-preview.json +21 -0
- package/r/mosaic-alert-dialog.json +23 -0
- package/r/mosaic-animated-list.json +16 -0
- package/r/mosaic-api-key-panel.json +21 -0
- package/r/mosaic-app-sidebar.json +18 -0
- package/r/mosaic-approval-prompt.json +21 -0
- package/r/mosaic-artifact-canvas-adapter.json +26 -0
- package/r/mosaic-artifact-chart.json +18 -0
- package/r/mosaic-artifact-checklist.json +18 -0
- package/r/mosaic-artifact-data-table.json +18 -0
- package/r/mosaic-artifact-document.json +16 -0
- package/r/mosaic-artifact-library.json +18 -0
- package/r/mosaic-artifact-save-as-memory-form.json +24 -0
- package/r/mosaic-artifact-version-history.json +16 -0
- package/r/mosaic-avatar.json +18 -0
- package/r/mosaic-badge.json +23 -0
- package/r/mosaic-blurred-orb.json +16 -0
- package/r/mosaic-button.json +24 -0
- package/r/mosaic-callout.json +23 -0
- package/r/mosaic-card.json +16 -0
- package/r/mosaic-chat-composer.json +21 -0
- package/r/mosaic-chat-message.json +23 -0
- package/r/mosaic-chat-sidebar.json +21 -0
- package/r/mosaic-chat-thread.json +21 -0
- package/r/mosaic-checkbox.json +18 -0
- package/r/mosaic-clerk-org-switcher.json +18 -0
- package/r/mosaic-clerk-webhook-handler.json +18 -0
- package/r/mosaic-collapsible.json +18 -0
- package/r/mosaic-combobox.json +18 -0
- package/r/mosaic-counter.json +16 -0
- package/r/mosaic-dashboard-content.json +18 -0
- package/r/mosaic-dashboard-header.json +18 -0
- package/r/mosaic-dashboard-layout.json +20 -0
- package/r/mosaic-data-table.json +16 -0
- package/r/mosaic-delete-confirmation-dialog.json +18 -0
- package/r/mosaic-device-provider.json +16 -0
- package/r/mosaic-document-table.json +52 -0
- package/r/mosaic-document-upload.json +21 -0
- package/r/mosaic-drawer.json +23 -0
- package/r/mosaic-dropdown-menu.json +18 -0
- package/r/mosaic-edit-memory-dialog.json +27 -0
- package/r/mosaic-edit-session-dialog.json +25 -0
- package/r/mosaic-editable-cell.json +23 -0
- package/r/mosaic-empty-state.json +16 -0
- package/r/mosaic-falling-pattern.json +16 -0
- package/r/mosaic-feature-3col.json +16 -0
- package/r/mosaic-feature-centered-media.json +16 -0
- package/r/mosaic-field.json +18 -0
- package/r/mosaic-filter-bar.json +18 -0
- package/r/mosaic-filter-sidebar.json +18 -0
- package/r/mosaic-footer-simple.json +16 -0
- package/r/mosaic-grille-registre.json +53 -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 +77 -130
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-document-table",
|
|
4
|
+
"title": "MosaicDocumentTable",
|
|
5
|
+
"description": "MosaicDocumentTable — generic document table, built on MosaicDataTable.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-data-table.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-editable-cell.json",
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-pdf-viewer.json",
|
|
11
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-resizable-split-pane.json",
|
|
12
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-tabs.json"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "src/components/document-review/MosaicDocumentCriteriaPanel.tsx",
|
|
17
|
+
"type": "registry:ui",
|
|
18
|
+
"content": "/**\n * MosaicDocumentCriteriaPanel — the review panel for one row.\n *\n * Built on MosaicTabs + MosaicResizableSplitPane + MosaicPdfViewer +\n * MosaicEditableCell. It OPENS ON COMPARE (document left, fields right) with no\n * interaction; the other tabs show the document alone or the fields alone. Every\n * field is editable (unless its column says otherwise) and shows a provenance\n * label supplied by the host. Editing reports a correction request carrying the\n * actor and the correction provenance. Prev/next walk the host's row order.\n *\n * No business vocabulary and no default copy: every word is in `labels` or in\n * the column model.\n */\nimport { useState } from \"react\";\nimport { MosaicEditableCell } from \"@/components/ui/MosaicEditableCell\";\nimport { MosaicPdfViewer } from \"@/components/ui/MosaicPdfViewer\";\nimport { MosaicResizableSplitPane } from \"@/components/ui/MosaicResizableSplitPane\";\nimport {\n MosaicTabs,\n MosaicTabsList,\n MosaicTabsPanel,\n MosaicTabsTrigger,\n} from \"@/components/ui/MosaicTabs\";\nimport {\n type ColumnVisibility,\n type FieldCorrectionRequest,\n INITIAL_REVIEW_PANEL_TAB,\n REVIEW_PANEL_TABS,\n type ReviewColumn,\n type ReviewPanelTab,\n initialColumnVisibility,\n neighbourRowId,\n visibleColumns,\n} from \"./document-review-logic.js\";\n\nexport interface MosaicDocumentCriteriaPanelLabels {\n tabCompare: string;\n tabDocument: string;\n tabRow: string;\n previous: string;\n next: string;\n documentLoading: string;\n documentError: string;\n collapse: string;\n resize: string;\n /** Accessible name of a field's editor, from its column label. */\n editField: (columnLabel: string) => string;\n}\n\nexport interface MosaicDocumentCriteriaPanelProps<T> {\n row: T;\n rowId: string;\n /** The column model; the fields shown are its visible columns. */\n columns: ReviewColumn<T>[];\n /** Overrides the model's `defaultVisible` per column id. */\n columnVisibility?: ColumnVisibility;\n documentUrl: string;\n /** Row ids in display order. */\n orderedRowIds: readonly string[];\n onNavigate: (rowId: string) => void;\n /** Receives the correction request, with actor and provenance. */\n onCorrect: (request: FieldCorrectionRequest) => unknown;\n /** Who is correcting. */\n actor: string;\n /** Provenance tag recorded with every correction made from this panel. */\n correctionProvenance: string;\n /** Provenance label shown next to a field (source name, corrected by…), or null for none. */\n provenanceLabel: (row: T, column: ReviewColumn<T>) => string | null;\n labels: MosaicDocumentCriteriaPanelLabels;\n /** Defaults to Compare. */\n defaultTab?: ReviewPanelTab;\n className?: string;\n}\n\nexport function MosaicDocumentCriteriaPanel<T>({\n row,\n rowId,\n columns,\n columnVisibility,\n documentUrl,\n orderedRowIds,\n onNavigate,\n onCorrect,\n actor,\n correctionProvenance,\n provenanceLabel,\n labels,\n defaultTab = INITIAL_REVIEW_PANEL_TAB,\n className,\n}: MosaicDocumentCriteriaPanelProps<T>) {\n const [tab, setTab] = useState<ReviewPanelTab>(defaultTab);\n const [sideWidth, setSideWidth] = useState(45);\n const [isSideCollapsed, setIsSideCollapsed] = useState(false);\n\n const previousId = neighbourRowId(orderedRowIds, rowId, \"prev\");\n const nextId = neighbourRowId(orderedRowIds, rowId, \"next\");\n\n const tabLabel: Record<ReviewPanelTab, string> = {\n compare: labels.tabCompare,\n document: labels.tabDocument,\n row: labels.tabRow,\n };\n\n const document_ = (\n <MosaicPdfViewer\n fileUrl={documentUrl}\n loadingLabel={labels.documentLoading}\n errorLabel={labels.documentError}\n />\n );\n\n const fields = (\n <dl data-slot=\"document-criteria-fields\" className=\"flex flex-col gap-3 p-3\">\n {visibleColumns(columns, columnVisibility ?? initialColumnVisibility(columns)).map(\n (column) => {\n const value = column.accessor(row);\n const provenance = provenanceLabel(row, column);\n return (\n <div\n key={column.id}\n data-slot=\"document-criteria-field\"\n className=\"flex flex-col gap-1\"\n >\n <dt className=\"text-xs font-medium text-muted-foreground\">{column.label}</dt>\n <dd className=\"m-0 flex flex-col gap-1\">\n <MosaicEditableCell\n value={value === null ? \"\" : String(value)}\n disabled={column.editable === false}\n editAriaLabel={labels.editField(column.label)}\n onCommit={(input) => {\n onCorrect({\n rowId,\n field: column.id,\n input,\n by: actor,\n provenance: correctionProvenance,\n });\n }}\n />\n {provenance ? (\n <span\n data-slot=\"document-criteria-provenance\"\n className=\"text-xs text-muted-foreground\"\n >\n {provenance}\n </span>\n ) : null}\n </dd>\n </div>\n );\n },\n )}\n </dl>\n );\n\n return (\n <section\n data-slot=\"document-criteria-panel\"\n data-row-id={rowId}\n className={[\"flex flex-col gap-2 rounded-md border border-border p-2\", className]\n .filter(Boolean)\n .join(\" \")}\n >\n <MosaicTabs value={tab} onValueChange={(next) => setTab(next as ReviewPanelTab)}>\n <div className=\"flex items-center justify-between gap-2\">\n <MosaicTabsList>\n {REVIEW_PANEL_TABS.map((value) => (\n <MosaicTabsTrigger key={value} value={value}>\n {tabLabel[value]}\n </MosaicTabsTrigger>\n ))}\n </MosaicTabsList>\n <div className=\"flex gap-2\">\n <button\n type=\"button\"\n disabled={previousId === null}\n onClick={() => previousId !== null && onNavigate(previousId)}\n className=\"rounded-md border border-border px-3 py-1 text-sm disabled:opacity-50\"\n >\n {labels.previous}\n </button>\n <button\n type=\"button\"\n disabled={nextId === null}\n onClick={() => nextId !== null && onNavigate(nextId)}\n className=\"rounded-md border border-border px-3 py-1 text-sm disabled:opacity-50\"\n >\n {labels.next}\n </button>\n </div>\n </div>\n <MosaicTabsPanel value=\"compare\">\n <MosaicResizableSplitPane\n main={document_}\n side={fields}\n sideWidth={sideWidth}\n onSideWidthChange={setSideWidth}\n isSideCollapsed={isSideCollapsed}\n onToggleSideCollapsed={() => setIsSideCollapsed((c) => !c)}\n collapseButtonAriaLabel={labels.collapse}\n resizeHandleAriaLabel={labels.resize}\n />\n </MosaicTabsPanel>\n <MosaicTabsPanel value=\"document\">{document_}</MosaicTabsPanel>\n <MosaicTabsPanel value=\"row\">{fields}</MosaicTabsPanel>\n </MosaicTabs>\n </section>\n );\n}\n\nMosaicDocumentCriteriaPanel.displayName = \"MosaicDocumentCriteriaPanel\";\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "src/components/document-review/MosaicDocumentTable.tsx",
|
|
22
|
+
"type": "registry:ui",
|
|
23
|
+
"content": "/**\n * MosaicDocumentTable — generic document table, built on MosaicDataTable.\n *\n * Rows and the column model come from props; column visibility comes from the\n * model (`defaultVisible`) unless the host passes a `columnVisibility` override.\n * Selecting a row (click, Enter, Space) opens `renderPanel` for that row. The\n * module ships no business vocabulary: every label is a prop.\n *\n * Row activation is delivered WITHOUT touching MosaicDataTable: the first visible\n * column renders its value inside a real `<button>` (keyboard + assistive tech),\n * and a click anywhere on a body row is resolved to its row through the table's own\n * `sectionRowIndex` (delegated on the wrapper).\n *\n * Sorting is off: MosaicDataTable sorts on `row[key]`, and a column model reads\n * values through accessors, so the table keeps the host's row order — which is\n * also the order prev/next navigation walks.\n */\nimport { useState } from \"react\";\nimport type * as React from \"react\";\nimport { MosaicDataTable, type MosaicDataTableColumn } from \"@/components/ui/MosaicDataTable\";\nimport {\n type ColumnVisibility,\n type ReviewColumn,\n initialColumnVisibility,\n visibleColumns,\n} from \"./document-review-logic.js\";\n\nexport interface MosaicDocumentTableRowContext {\n rowId: string;\n /** Row ids in display order — what prev/next navigation walks. */\n orderedRowIds: string[];\n /** Select another row (the panel stays open on it). */\n selectRow: (rowId: string) => void;\n /** Close the panel. */\n closeRow: () => void;\n}\n\nexport interface MosaicDocumentTableProps<T> {\n columns: ReviewColumn<T>[];\n rows: T[];\n getRowId: (row: T) => string;\n /** Overrides the model's `defaultVisible` per column id. */\n columnVisibility?: ColumnVisibility;\n /** Controlled selection. Omit for internal state. */\n selectedRowId?: string | null;\n onSelectedRowChange?: (rowId: string | null) => void;\n /** Rendered for the selected row. */\n renderPanel?: (row: T, context: MosaicDocumentTableRowContext) => React.ReactNode;\n /** Required — the host owns the language. */\n emptyMessage: string;\n className?: string;\n}\n\nexport function MosaicDocumentTable<T>({\n columns,\n rows,\n getRowId,\n columnVisibility,\n selectedRowId: controlledSelectedRowId,\n onSelectedRowChange,\n renderPanel,\n emptyMessage,\n className,\n}: MosaicDocumentTableProps<T>) {\n const [internalSelectedRowId, setInternalSelectedRowId] = useState<string | null>(null);\n const isControlled = controlledSelectedRowId !== undefined;\n const selectedRowId = isControlled ? controlledSelectedRowId : internalSelectedRowId;\n\n function select(rowId: string | null) {\n if (!isControlled) setInternalSelectedRowId(rowId);\n onSelectedRowChange?.(rowId);\n }\n\n const shown = visibleColumns(columns, columnVisibility ?? initialColumnVisibility(columns));\n const tableColumns: MosaicDataTableColumn<T>[] = shown.map((column, columnIndex) => ({\n key: column.id,\n header: column.label,\n render: (row) => {\n const value = column.accessor(row);\n const text = value === null ? \"\" : String(value);\n if (columnIndex !== 0) return text;\n const isSelected = getRowId(row) === selectedRowId;\n return (\n <button\n type=\"button\"\n data-slot=\"document-table-open\"\n aria-current={isSelected ? \"true\" : undefined}\n data-selected={isSelected ? \"true\" : undefined}\n className=\"text-left underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {text}\n </button>\n );\n },\n }));\n\n // One delegated handler: a click on any cell of a body row selects that row. A\n // button's keyboard activation arrives here as a click, so one path serves both.\n function handleClick(event: React.MouseEvent<HTMLDivElement>) {\n const tr = (event.target as HTMLElement).closest(\"tr[data-slot='data-table-row']\");\n if (!(tr instanceof HTMLTableRowElement)) return;\n const row = rows[tr.sectionRowIndex];\n if (row !== undefined) select(getRowId(row));\n }\n\n const orderedRowIds = rows.map(getRowId);\n const selectedRow =\n selectedRowId === null ? undefined : rows.find((row) => getRowId(row) === selectedRowId);\n\n return (\n // biome-ignore lint/a11y/useKeyWithClickEvents: keyboard path is the first column's real <button>; this only resolves mouse clicks on other cells to their row\n <div data-slot=\"document-table\" className={className} onClick={handleClick}>\n <MosaicDataTable<T>\n columns={tableColumns}\n rows={rows}\n getRowKey={(row) => getRowId(row)}\n sortable={false}\n emptyMessage={emptyMessage}\n />\n {selectedRow !== undefined && renderPanel\n ? renderPanel(selectedRow, {\n rowId: getRowId(selectedRow),\n orderedRowIds,\n selectRow: (rowId) => select(rowId),\n closeRow: () => select(null),\n })\n : null}\n </div>\n );\n}\n\nMosaicDocumentTable.displayName = \"MosaicDocumentTable\";\n"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"path": "src/components/document-review/column-model.ts",
|
|
27
|
+
"type": "registry:ui",
|
|
28
|
+
"content": "/**\n * Generic column model. Ships no field name and no label of its own: ids, labels\n * and accessors all come from the host.\n */\n\nexport type FieldValue = string | number | boolean | null;\n\nexport interface ReviewColumn<T> {\n /** Stable column id. */\n id: string;\n /** Host-supplied label (the host owns the language). */\n label: string;\n /** Whether the column is shown before the user changes anything. */\n defaultVisible: boolean;\n /** Reads this column's value from a row. */\n accessor: (row: T) => FieldValue;\n /** False for derived columns that must never be typed by hand. Defaults to true. */\n editable?: boolean;\n}\n\n/** Explicit visibility per column id; an absent id falls back to `defaultVisible`. */\nexport type ColumnVisibility = Readonly<Record<string, boolean>>;\n\n// Developer-facing invariant error, thrown at misuse time, never rendered to an end\n// user. Kept as an object-literal constant with the marker BETWEEN properties: a `//`\n// comment right before a `throw new Error(...)` is stripped by esbuild and would never\n// reach dist (same pattern as MosaicDeviceProvider).\nconst COLUMN_MODEL_ERRORS = {\n // allow-hardcoded-word: developer-facing invariant error, never rendered to an end user\n unknownColumn: (id: string) => `document-review: visibility names unknown column \"${id}\"`,\n};\n\nfunction assertKnown<T>(columns: readonly ReviewColumn<T>[], ids: Iterable<string>): void {\n const known = new Set(columns.map((c) => c.id));\n for (const id of ids) {\n if (!known.has(id)) {\n throw new Error(COLUMN_MODEL_ERRORS.unknownColumn(id));\n }\n }\n}\n\nexport function initialColumnVisibility<T>(columns: readonly ReviewColumn<T>[]): ColumnVisibility {\n return Object.fromEntries(columns.map((c) => [c.id, c.defaultVisible]));\n}\n\nexport function toggleColumnVisibility<T>(\n columns: readonly ReviewColumn<T>[],\n visibility: ColumnVisibility,\n id: string,\n): ColumnVisibility {\n assertKnown(columns, [id]);\n const column = columns.find((c) => c.id === id) as ReviewColumn<T>;\n const current = visibility[id] ?? column.defaultVisible;\n return { ...visibility, [id]: !current };\n}\n\n/** Columns to show, in column order. An unknown id in `visibility` throws, naming it. */\nexport function visibleColumns<T>(\n columns: readonly ReviewColumn<T>[],\n visibility: ColumnVisibility,\n): ReviewColumn<T>[] {\n assertKnown(columns, Object.keys(visibility));\n return columns.filter((c) => visibility[c.id] ?? c.defaultVisible);\n}\n"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "src/components/document-review/document-review-logic.ts",
|
|
32
|
+
"type": "registry:ui",
|
|
33
|
+
"content": "export { INITIAL_REVIEW_PANEL_TAB, REVIEW_PANEL_TABS } from \"./panel-tab.js\";\nexport type { ReviewPanelTab } from \"./panel-tab.js\";\nexport { isEditableTarget, neighbourRowId } from \"./row-navigation.js\";\nexport type { NavDirection } from \"./row-navigation.js\";\nexport {\n initialColumnVisibility,\n toggleColumnVisibility,\n visibleColumns,\n} from \"./column-model.js\";\nexport type { ColumnVisibility, FieldValue, ReviewColumn } from \"./column-model.js\";\nexport { applyFieldCorrection, correctionOutcome } from \"./field-correction.js\";\nexport type {\n ApplyFieldCorrectionArgs,\n CorrectionRecord,\n FieldCorrectionRequest,\n FieldCorrectionResult,\n FieldValidation,\n FieldValidator,\n FieldWriteResponse,\n ReviewRow,\n} from \"./field-correction.js\";\n"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "src/components/document-review/field-correction.ts",
|
|
37
|
+
"type": "registry:ui",
|
|
38
|
+
"content": "/**\n * The write path of a field correction: validate, write, and on failure hand back\n * the row from BEFORE.\n *\n * A failed write must never leave the screen showing a value the store does not\n * hold. The function is pure with respect to its input: it never mutates the row,\n * it returns a new one, so the caller replaces what it displays with what comes\n * back and has no decision to take.\n *\n * Provenance: the ORIGINAL value is kept (the first one, across successive\n * corrections), next to the corrected value, who made it, when, and the host's\n * provenance tag.\n */\nimport type { FieldValue } from \"./column-model.js\";\n\nexport interface CorrectionRecord {\n original: FieldValue;\n corrected: FieldValue;\n by: string;\n /** ISO-8601 instant. */\n at: string;\n provenance: string;\n}\n\nexport interface ReviewRow {\n id: string;\n values: Readonly<Record<string, FieldValue>>;\n corrections?: Readonly<Record<string, CorrectionRecord>>;\n}\n\n/** What the correction UI hands to the host, and what the host passes on to the writer. */\nexport interface FieldCorrectionRequest {\n rowId: string;\n field: string;\n /** The user's raw input. */\n input: string;\n by: string;\n provenance: string;\n}\n\n/**\n * `value` is the value as the store re-read it. It is OPTIONAL on purpose: a store\n * that does not echo it yields an unconfirmed result, never a silent success.\n * Presence is what counts (`\"value\" in response`): `null` confirms an erasure.\n */\nexport type FieldWriteResponse = { ok: true; value?: FieldValue } | { ok: false; message: string };\n\nexport type FieldValidation = { ok: true; value: FieldValue } | { ok: false; message: string };\n\nexport type FieldValidator = (field: string, input: string, row: ReviewRow) => FieldValidation;\n\nexport interface ApplyFieldCorrectionArgs extends Omit<FieldCorrectionRequest, \"rowId\"> {\n row: ReviewRow;\n write: (request: FieldCorrectionRequest) => Promise<FieldWriteResponse>;\n /** Defaults to accepting the raw input as the value. */\n validate?: FieldValidator;\n /** Injectable clock, ISO-8601. Defaults to the current instant. */\n now?: () => string;\n}\n\nexport type FieldCorrectionResult =\n | { ok: true; row: ReviewRow; confirmed: boolean }\n | { ok: false; row: ReviewRow; message: string };\n\nexport async function applyFieldCorrection(\n args: ApplyFieldCorrectionArgs,\n): Promise<FieldCorrectionResult> {\n const { row, field, input, by, provenance, write, validate, now } = args;\n\n const checked: FieldValidation = validate\n ? validate(field, input, row)\n : { ok: true, value: input };\n if (!checked.ok) return { ok: false, row, message: checked.message };\n\n let response: FieldWriteResponse;\n try {\n response = await write({ rowId: row.id, field, input, by, provenance });\n } catch (e) {\n // The thrown message is kept verbatim: rewording it would remove what lets the user fix it.\n return { ok: false, row, message: e instanceof Error ? e.message : String(e) };\n }\n if (!response.ok) return { ok: false, row, message: response.message };\n\n const confirmed = \"value\" in response;\n // Unconfirmed: show what was sent, and say so through `confirmed: false`.\n const corrected: FieldValue = confirmed ? (response.value ?? null) : checked.value;\n const original = row.corrections?.[field]?.original ?? row.values[field] ?? null;\n const record: CorrectionRecord = {\n original,\n corrected,\n by,\n at: now ? now() : new Date().toISOString(),\n provenance,\n };\n return {\n ok: true,\n confirmed,\n row: {\n ...row,\n values: { ...row.values, [field]: corrected },\n corrections: { ...row.corrections, [field]: record },\n },\n };\n}\n\n/** Three outcomes, never two: \"uncertain\" is a write that succeeded but was not read back. */\nexport function correctionOutcome(result: FieldCorrectionResult): \"ok\" | \"uncertain\" | \"failed\" {\n if (!result.ok) return \"failed\";\n return result.confirmed ? \"ok\" : \"uncertain\";\n}\n"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"path": "src/components/document-review/panel-tab.ts",
|
|
42
|
+
"type": "registry:ui",
|
|
43
|
+
"content": "/**\n * The tabs of a document-review panel, named by ROLE (never by a business noun).\n *\n * - \"compare\" document and fields side by side — the INITIAL tab.\n * - \"document\" the document alone.\n * - \"row\" the row's fields alone.\n */\nexport type ReviewPanelTab = \"compare\" | \"document\" | \"row\";\n\nexport const REVIEW_PANEL_TABS: readonly ReviewPanelTab[] = [\"compare\", \"document\", \"row\"];\n\n/** A panel opens on Compare: reading the document and editing the fields at once is the point. */\nexport const INITIAL_REVIEW_PANEL_TAB: ReviewPanelTab = \"compare\";\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "src/components/document-review/row-navigation.ts",
|
|
47
|
+
"type": "registry:ui",
|
|
48
|
+
"content": "// The caller passes the table's current display order; this module never derives its own.\n\nexport type NavDirection = \"prev\" | \"next\";\n\n// Arrow keys inside a field move the caret or the option, never the row.\nexport function isEditableTarget(target: EventTarget | null): boolean {\n return (\n target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target instanceof HTMLSelectElement ||\n (target instanceof HTMLElement && target.isContentEditable === true)\n );\n}\n\n/** Neighbour row id, or null at either end or when the current id is not listed. */\nexport function neighbourRowId(\n orderedRowIds: readonly string[],\n currentRowId: string,\n direction: NavDirection,\n): string | null {\n const index = orderedRowIds.indexOf(currentRowId);\n if (index === -1) return null;\n const neighbourIndex = index + (direction === \"next\" ? 1 : -1);\n if (neighbourIndex < 0 || neighbourIndex >= orderedRowIds.length) return null;\n return orderedRowIds[neighbourIndex] ?? null;\n}\n"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"type": "registry:ui"
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-document-upload",
|
|
4
|
+
"title": "MosaicDocumentUpload",
|
|
5
|
+
"description": "MosaicDocumentUpload — presentational document drop-zone + file status list",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/document-upload/MosaicDocumentUpload.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicDocumentUpload — presentational document drop-zone + file status list\n *\n * Presentational atom. Renders a drag&drop / click-to-browse zone and, below\n * it, one status row per file (uploading / success / error). The component\n * never performs a network call: file selection (drop or file-input change)\n * is surfaced via `onFilesSelected(files: File[])` — the host owns where the\n * upload goes, how progress is tracked, and how errors are produced. `files`\n * is fully host-controlled state (id, name, sizeBytes, status, optional\n * progress / errorMessage).\n *\n * Pattern: MosaicStepPipeline.tsx (data-slot, inline cn, React 19 ref prop,\n * displayName, JSDoc, pure variants module).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n * Design tokens: --foreground, --muted, --muted-foreground, --border,\n * --destructive, --ring, --accent, --card, --background.\n * No icon library — uses ✓ / ✕ chars for success/error, matching the\n * step-pipeline convention (no lucide-react runtime dependency).\n * a11y: drop-zone is a labelled, keyboard-reachable button; file rows use\n * role=\"status\" region semantics; remove buttons have a required per-file\n * accessible name.\n * Bilingual: every user-facing string (idle/drag/browse/accept-hint/status\n * labels/remove label/error message) is a required caller-supplied prop —\n * zero hardcoded copy, zero default.\n *\n * Ported from any-debate-ai components/memory/document-upload.tsx (rewritten\n * from scratch — no shared code, no license carried over): dropped the\n * embedded mock \"extracted memories\" review UI (app-specific business logic)\n * and the network/simulation logic (violates presentational-component rule),\n * kept the upload zone + per-file status list shape.\n *\n * @example\n * <MosaicDocumentUpload\n * files={files}\n * onFilesSelected={(selected) => uploadFiles(selected)}\n * onRemoveFile={(id) => removeFile(id)}\n * idleLabel=\"Glissez-déposez un fichier ici, ou cliquez pour parcourir\"\n * dragActiveLabel=\"Déposez le fichier ici\"\n * browseButtonLabel=\"Choisir un fichier\"\n * acceptHint=\"PDF, DOC, DOCX, TXT, MD (10 Mo max)\"\n * accept=\".pdf,.doc,.docx,.txt,.md\"\n * removeFileAriaLabel={(name) => `Supprimer ${name}`}\n * statusLabels={{ uploading: \"Envoi en cours\", success: \"Envoyé\", error: \"Échec\" }}\n * sizeLabel={(bytes) => `${(bytes / 1024).toFixed(1)} Ko`}\n * dropZoneAriaLabel=\"Zone de dépôt de document\"\n * />\n */\n\nimport type * as React from \"react\";\nimport { useId, useRef, useState } from \"react\";\nimport {\n documentUploadDropZoneVariants,\n documentUploadFileRowVariants,\n documentUploadProgressFillVariants,\n documentUploadProgressTrackVariants,\n documentUploadStatusLabelVariants,\n} from \"./document-upload-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport type MosaicDocumentUploadFileStatus = \"uploading\" | \"success\" | \"error\";\n\nexport interface MosaicDocumentUploadFile {\n /** Stable id — used as React key and passed back to onRemoveFile. */\n id: string;\n /** File name, displayed as-is. */\n name: string;\n /** File size in bytes — formatted for display via the required sizeLabel prop. */\n sizeBytes: number;\n /** Current upload status, fully host-controlled. */\n status: MosaicDocumentUploadFileStatus;\n /** Upload progress 0-100, rendered only while status === \"uploading\". */\n progress?: number;\n /**\n * Host-provided, host-localized error message (e.g. \"File too large\",\n * \"Unsupported format\"). Required content when status === \"error\" — the\n * library never generates its own error strings.\n */\n errorMessage?: string;\n}\n\nexport interface MosaicDocumentUploadProps {\n /** Host-controlled list of files with their upload status. */\n files: MosaicDocumentUploadFile[];\n /**\n * Called with the raw browser `File[]` chosen via drag&drop or the file\n * picker. The component performs no upload itself — the host decides\n * where the files go and how `files` state is updated afterward.\n */\n onFilesSelected: (files: File[]) => void;\n /** Called with a file's id when its remove button is activated. */\n onRemoveFile: (id: string) => void;\n /** Drop-zone label shown when idle (not dragging). Required, no default. */\n idleLabel: string;\n /** Drop-zone label shown while a drag is over the zone. Required, no default. */\n dragActiveLabel: string;\n /** Label for the click-to-browse button. Required, no default. */\n browseButtonLabel: string;\n /** Supporting hint text (accepted formats / size limit). Required, no default. */\n acceptHint: string;\n /** Accessible name for the drop-zone region (`aria-label`). Required, no default. */\n dropZoneAriaLabel: string;\n /**\n * Per-file accessible name for the remove button, e.g.\n * `(name) => \\`Remove ${name}\\``. Required — no hardcoded \"Remove\" string\n * in the library.\n */\n removeFileAriaLabel: (fileName: string) => string;\n /** Status labels rendered next to each file row. All three required, no default. */\n statusLabels: {\n uploading: string;\n success: string;\n error: string;\n };\n /**\n * Formats a file's size for display, e.g. `(bytes) => \\`${(bytes/1024).toFixed(1)} KB\\``.\n * Required — the library never hardcodes a unit string (\"KB\", \"Ko\", ...).\n */\n sizeLabel: (sizeBytes: number) => string;\n /** Native `accept` attribute forwarded to the hidden file input. */\n accept?: string;\n /** Allow selecting/dropping more than one file at a time. @default false */\n multiple?: boolean;\n /** Additional Tailwind classes on the root element. */\n className?: string;\n /** React 19 ref prop — forwarded to the root element. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicDocumentUpload — production document-upload atom for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational: renders the drop-zone and the file status list from\n * props, and reports file selection / removal via callbacks. No network\n * call, no upload simulation, no built-in copy.\n */\nexport function MosaicDocumentUpload({\n files,\n onFilesSelected,\n onRemoveFile,\n idleLabel,\n dragActiveLabel,\n browseButtonLabel,\n acceptHint,\n dropZoneAriaLabel,\n removeFileAriaLabel,\n statusLabels,\n sizeLabel,\n accept,\n multiple = false,\n className,\n ref,\n}: MosaicDocumentUploadProps) {\n const [isDragActive, setIsDragActive] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const inputId = useId();\n\n function handleDragOver(event: React.DragEvent<HTMLDivElement>) {\n event.preventDefault();\n setIsDragActive(true);\n }\n\n function handleDragLeave() {\n setIsDragActive(false);\n }\n\n function handleDrop(event: React.DragEvent<HTMLDivElement>) {\n event.preventDefault();\n setIsDragActive(false);\n const dropped = Array.from(event.dataTransfer.files);\n if (dropped.length > 0) onFilesSelected(dropped);\n }\n\n function handleInputChange(event: React.ChangeEvent<HTMLInputElement>) {\n const selected = event.target.files ? Array.from(event.target.files) : [];\n if (selected.length > 0) onFilesSelected(selected);\n // Reset so selecting the same file again still fires a change event.\n event.target.value = \"\";\n }\n\n return (\n <div ref={ref} data-slot=\"document-upload\" className={cn(\"flex flex-col gap-4\", className)}>\n <div\n data-slot=\"document-upload-drop-zone\"\n aria-label={dropZoneAriaLabel}\n onDragOver={handleDragOver}\n onDragLeave={handleDragLeave}\n onDrop={handleDrop}\n className={documentUploadDropZoneVariants({ dragActive: isDragActive })}\n >\n <p data-slot=\"document-upload-idle-label\" className=\"text-sm font-medium\">\n {isDragActive ? dragActiveLabel : idleLabel}\n </p>\n <input\n ref={inputRef}\n id={inputId}\n type=\"file\"\n className=\"hidden\"\n accept={accept}\n multiple={multiple}\n onChange={handleInputChange}\n />\n <label htmlFor={inputId}>\n <span\n data-slot=\"document-upload-browse-button\"\n className=\"inline-flex min-h-9 items-center justify-center rounded-md border border-border px-3 text-sm font-medium hover:bg-accent/50 transition-colors\"\n >\n {browseButtonLabel}\n </span>\n </label>\n <p data-slot=\"document-upload-accept-hint\" className=\"text-xs text-muted-foreground\">\n {acceptHint}\n </p>\n </div>\n\n {files.length > 0 && (\n <ul data-slot=\"document-upload-file-list\" className=\"flex flex-col gap-2\">\n {files.map((file) => (\n <li\n key={file.id}\n data-slot=\"document-upload-file-row\"\n data-status={file.status}\n className={documentUploadFileRowVariants({ status: file.status })}\n >\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-start justify-between gap-2\">\n <p data-slot=\"document-upload-file-name\" className=\"text-sm font-medium truncate\">\n {file.name}\n </p>\n <span\n data-slot=\"document-upload-status-label\"\n className={documentUploadStatusLabelVariants({ status: file.status })}\n >\n {statusLabels[file.status]}\n </span>\n </div>\n <p data-slot=\"document-upload-file-size\" className=\"text-xs text-muted-foreground\">\n {sizeLabel(file.sizeBytes)}\n </p>\n\n {file.status === \"uploading\" && (\n <div\n data-slot=\"document-upload-progress-track\"\n role=\"progressbar\"\n // Non-interactive status indicator: not a tab stop, but still\n // programmatically focusable to satisfy a11y/useFocusableInteractive.\n tabIndex={-1}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={file.progress ?? 0}\n className={cn(documentUploadProgressTrackVariants(), \"mt-2\")}\n >\n <div\n data-slot=\"document-upload-progress-fill\"\n className={documentUploadProgressFillVariants()}\n style={{ width: `${file.progress ?? 0}%` }}\n />\n </div>\n )}\n\n {file.status === \"error\" && file.errorMessage !== undefined && (\n <p\n data-slot=\"document-upload-error-message\"\n className=\"mt-1 text-xs text-destructive\"\n >\n {file.errorMessage}\n </p>\n )}\n </div>\n\n <button\n type=\"button\"\n data-slot=\"document-upload-remove-button\"\n aria-label={removeFileAriaLabel(file.name)}\n onClick={() => onRemoveFile(file.id)}\n className=\"shrink-0 inline-flex min-h-9 min-w-9 items-center justify-center rounded-md hover:bg-accent/50 transition-colors\"\n >\n {file.status === \"success\" ? \"✓\" : \"✕\"}\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n}\n\nMosaicDocumentUpload.displayName = \"MosaicDocumentUpload\";\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/document-upload/document-upload-variants.ts",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"content": "/**\n * documentUploadVariants — pure CVA variant functions for MosaicDocumentUpload.\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/** Drop-zone container variants — idle vs. drag-over. */\nexport const documentUploadDropZoneVariants = cva(\n [\n \"flex flex-col items-center justify-center text-center\",\n \"rounded-lg border-2 border-dashed p-8 gap-2\",\n \"transition-colors cursor-pointer\",\n ],\n {\n variants: {\n dragActive: {\n true: \"border-ring bg-accent/40\",\n false: \"border-border hover:border-ring/50\",\n },\n },\n defaultVariants: {\n dragActive: false,\n },\n },\n);\n\n/** Per-file row container variants by upload status. */\nexport const documentUploadFileRowVariants = cva(\n [\"flex items-start gap-3 rounded-lg border p-4 transition-colors\"],\n {\n variants: {\n status: {\n uploading: \"border-border bg-card\",\n success: \"border-border bg-card\",\n error: \"border-destructive/40 bg-destructive/5\",\n },\n },\n defaultVariants: {\n status: \"uploading\",\n },\n },\n);\n\n/** Status badge text variants by upload status. */\nexport const documentUploadStatusLabelVariants = cva([\"text-xs font-medium\"], {\n variants: {\n status: {\n uploading: \"text-muted-foreground\",\n success: \"text-foreground\",\n error: \"text-destructive\",\n },\n },\n defaultVariants: {\n status: \"uploading\",\n },\n});\n\n/** Progress bar track variants (uploading state only). */\nexport const documentUploadProgressTrackVariants = cva(\n [\"h-1.5 w-full overflow-hidden rounded-full bg-muted\"],\n {\n variants: {},\n defaultVariants: {},\n },\n);\n\n/** Progress bar fill variants. */\nexport const documentUploadProgressFillVariants = cva(\n [\"h-full rounded-full bg-foreground transition-[width]\"],\n {\n variants: {},\n defaultVariants: {},\n },\n);\n"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"type": "registry:ui"
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-drawer",
|
|
4
|
+
"title": "MosaicDrawer",
|
|
5
|
+
"description": "MosaicDrawer — agent detail viewed as a side panel (SW-xx)",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/drawer/MosaicDrawer.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicDrawer — agent detail viewed as a side panel (SW-xx)\n *\n * Ported (source: any-debate-ai components/ui/drawer.tsx) — the upstream\n * component wraps `vaul`. This port re-implements the same side-panel\n * pattern on `@base-ui/react/dialog` instead: `vaul` is not a locked\n * production dependency for @vantageos/mosaic-blocks, and Base UI's Dialog\n * primitive already ships everything a drawer needs — focus trap, Escape,\n * focus return to the trigger, and an inert (non-focusable) background —\n * for free, out of the box, with `modal` (the default).\n *\n * Fully host-controlled: `open` + `onOpenChange` come from the caller, the\n * component keeps no state of its own (cf. MosaicResizableSplitPane /\n * MosaicAdaptiveModal convention in this package).\n *\n * Why a drawer and not a modal: this is the agent detail sheet — the caller\n * consults the record *without losing the list* behind it. A centered modal\n * hides that list; a side drawer keeps it in view. `side` (left/right/top/\n * bottom) is a cva variant, so the same component serves a right-hand\n * detail panel, a left nav drawer, or a bottom sheet on mobile.\n *\n * data-slot=\"drawer\" on the popup root (matches upstream slot naming),\n * \"drawer-backdrop\" on the backdrop, \"drawer-header\"/\"drawer-footer\" for\n * layout regions supplied by the host as children.\n *\n * SIN-01: every visible string (`title`, `closeAriaLabel`) is a REQUIRED\n * prop with no default — the library carries no copy, the host owns i18n.\n */\n\nimport { Dialog } from \"@base-ui/react/dialog\";\nimport * as React from \"react\";\nimport { drawerBackdropVariants, drawerPopupVariants } from \"./drawer-variants.js\";\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\nexport interface MosaicDrawerProps {\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 * Visible drawer title, wired to `aria-labelledby`. Required — no\n * default, no fallback. The host supplies the localized string.\n */\n title: string;\n /**\n * aria-label for the close button. Required — the host owns the\n * language (e.g. `t('Drawer.aria.close')`). No default, no fallback.\n */\n closeAriaLabel: string;\n children: React.ReactNode;\n /** Panel edge + slide direction. @default \"right\" */\n side?: \"left\" | \"right\" | \"top\" | \"bottom\";\n className?: string;\n}\n\n/**\n * MosaicDrawer — side panel showing agent (or any record) detail without\n * covering the list behind it.\n *\n * @example\n * // Host owns i18n (e.g. next-intl) — title/closeAriaLabel always required.\n * <MosaicDrawer\n * open={open}\n * onOpenChange={setOpen}\n * title={agent.name}\n * closeAriaLabel={t('Drawer.aria.close')}\n * side=\"right\"\n * >\n * <p>Agent detail body</p> // allow-hardcode-i18n: JSDoc @example doc comment, not shipped code\n * </MosaicDrawer>\n */\nexport function MosaicDrawer({\n open,\n onOpenChange,\n title,\n closeAriaLabel,\n children,\n side = \"right\",\n className,\n}: MosaicDrawerProps) {\n const titleId = React.useId();\n\n return (\n <Dialog.Root open={open} onOpenChange={(nextOpen) => onOpenChange(nextOpen)} modal>\n <Dialog.Portal>\n <Dialog.Backdrop data-slot=\"drawer-backdrop\" className={drawerBackdropVariants()} />\n <Dialog.Popup\n data-slot=\"drawer\"\n aria-labelledby={titleId}\n aria-modal=\"true\"\n className={cn(drawerPopupVariants({ side }), className)}\n >\n <div\n data-slot=\"drawer-header\"\n className=\"flex items-center justify-between gap-4 border-b border-border p-4\"\n >\n <Dialog.Title id={titleId} className=\"text-base font-semibold text-foreground\">\n {title}\n </Dialog.Title>\n <Dialog.Close\n aria-label={closeAriaLabel}\n className={cn(\n \"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors\",\n \"hover:bg-muted hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <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=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </Dialog.Close>\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto p-4\">{children}</div>\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\nMosaicDrawer.displayName = \"MosaicDrawer\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/drawer/drawer-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * drawerVariants — pure CVA variant functions for MosaicDrawer.\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/** Popup panel — position + slide direction depend on `side`. */\nexport const drawerPopupVariants = cva(\n [\n \"fixed z-50 flex flex-col bg-background shadow-xl outline-none\",\n \"transition-transform duration-200 ease-out\",\n \"data-[ending-style]:transition-none\",\n ],\n {\n variants: {\n side: {\n right: \"inset-y-0 right-0 h-full w-3/4 border-l border-border sm:max-w-sm\",\n left: \"inset-y-0 left-0 h-full w-3/4 border-r border-border sm:max-w-sm\",\n top: \"inset-x-0 top-0 max-h-[80vh] w-full border-b border-border\",\n bottom: \"inset-x-0 bottom-0 max-h-[80vh] w-full border-t border-border\",\n },\n },\n defaultVariants: {\n side: \"right\",\n },\n },\n);\n\n/** Backdrop overlay behind the popup. */\nexport const drawerBackdropVariants = cva([\"fixed inset-0 z-50 bg-black/50\"]);\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-dropdown-menu",
|
|
4
|
+
"title": "MosaicDropdownMenu",
|
|
5
|
+
"description": "Dropdown menu built on @base-ui/react/menu: Trigger + items + separators. Keyboard nav, focus-visible. data-slot=\"dropdown-menu\".",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/dropdown-menu/MosaicDropdownMenu.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicDropdownMenu — @base-ui/react Menu primitive\n *\n * Builds on Menu.Root / Trigger / Portal / Positioner / Popup / Item / Separator.\n * Exported as MosaicDropdownMenu per spec (named separately from Menu to avoid clash).\n *\n * data-slot=\"dropdown-menu\" on Popup.\n * Items render with role=menuitem (managed by base-ui).\n * Styling: Tailwind v4 semantic tokens only.\n */\n\nimport { Menu } from \"@base-ui/react/menu\";\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 MosaicDropdownMenuItem {\n id: string;\n label: string;\n disabled?: boolean;\n /** Render a separator BEFORE this item */\n separator?: boolean;\n}\n\nexport interface MosaicDropdownMenuProps {\n /** The trigger element — wrapped in Menu.Trigger automatically */\n trigger: React.ReactNode;\n /** List of menu items */\n items: MosaicDropdownMenuItem[];\n /** Callback when an item is selected, receives item.id */\n onItemSelect?: (id: string) => void;\n /** Whether the menu is open (controlled) */\n open?: boolean;\n /** Callback when open state changes (controlled) */\n onOpenChange?: (open: boolean) => void;\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicDropdownMenu — production DropdownMenu atom for @vantageos/mosaic-blocks.\n *\n * Built on @base-ui/react/menu. Portal-rendered popup, keyboard-accessible.\n * Keyboard: Enter/Space opens, ArrowDown/Up navigate, Escape closes, Enter selects.\n *\n * @example\n * <MosaicDropdownMenu\n * trigger={<button type=\"button\">Open menu</button>}\n * items={[{ id: \"edit\", label: \"Edit\" }, { id: \"delete\", label: \"Delete\" }]}\n * onItemSelect={(id) => console.log(id)}\n * />\n */\nexport function MosaicDropdownMenu({\n trigger,\n items,\n onItemSelect,\n open,\n onOpenChange,\n className,\n}: MosaicDropdownMenuProps) {\n return (\n <Menu.Root open={open} onOpenChange={onOpenChange}>\n <Menu.Trigger render={trigger as React.ReactElement} />\n\n <Menu.Portal>\n <Menu.Positioner sideOffset={4}>\n <Menu.Popup\n data-slot=\"dropdown-menu\"\n className={cn(\n \"z-50 min-w-[8rem] overflow-hidden rounded-md border border-border\",\n \"bg-popover p-1 text-popover-foreground shadow-md\",\n \"origin-[var(--transform-origin)]\",\n \"transition-[transform,scale,opacity]\",\n \"data-[open]:scale-100 data-[open]:opacity-100\",\n \"data-[ending-style]:scale-95 data-[ending-style]:opacity-0\",\n \"data-[starting-style]:scale-95 data-[starting-style]:opacity-0\",\n className,\n )}\n >\n {items.map((item) => (\n <React.Fragment key={item.id}>\n {item.separator && <Menu.Separator className=\"my-1 h-px bg-border\" />}\n <Menu.Item\n disabled={item.disabled}\n onClick={() => onItemSelect?.(item.id)}\n className={cn(\n \"relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5\",\n \"text-sm text-popover-foreground outline-none\",\n \"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground\",\n \"data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50\",\n )}\n >\n {item.label}\n </Menu.Item>\n </React.Fragment>\n ))}\n </Menu.Popup>\n </Menu.Positioner>\n </Menu.Portal>\n </Menu.Root>\n );\n}\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-edit-memory-dialog",
|
|
4
|
+
"title": "MosaicEditMemoryDialog",
|
|
5
|
+
"description": "MosaicEditMemoryDialog — dialog to correct a stale knowledge entry (a \"memory\"): edit its content, type and tags, then save or cancel.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-select.json",
|
|
11
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-tag-input.json",
|
|
12
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-textarea.json"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "src/components/edit-memory-dialog/MosaicEditMemoryDialog.tsx",
|
|
17
|
+
"type": "registry:ui",
|
|
18
|
+
"content": "\"use client\";\n\n/**\n * MosaicEditMemoryDialog — dialog to correct a stale knowledge entry (a\n * \"memory\"): edit its content, type and tags, then save or cancel.\n *\n * Built on `@base-ui/react/dialog` (not `alert-dialog`): correcting a memory\n * is not a destructive action needing an `alertdialog` role, so the plain\n * Dialog primitive is the correct fit — same focus trap, Escape-to-cancel\n * and background-inert behavior as `alert-dialog`. Shell idiom matches\n * MosaicAgentBuilderModal (header with title/description/close button, a\n * scrollable body, a footer with cancel/save actions).\n *\n * Presentational atom composed from existing mosaic-blocks primitives:\n * MosaicTextarea (content), MosaicSelect (type) and MosaicTagInput (tags).\n * This component never invents a new form field — it assembles the ones the\n * library already ships (same doctrine as MosaicSaveTemplateModal).\n *\n * Fully controlled: `open`/`onOpenChange` own visibility, `content`/`type`/\n * `tags` are single-source-of-truth values supplied by the host, every\n * change is reported via a callback. The component keeps no internal form\n * state of its own — it never persists, never fetches, never diffs against\n * a stored memory. Save goes up as a plain callback (`onSave`); the host\n * decides what \"correcting a memory\" means for its own data model.\n *\n * No hardcoded taxonomy: `types` is a required host-supplied list of\n * `MosaicSelectItem` — the set of memory types is business/domain knowledge,\n * never baked into the library.\n *\n * Validation belongs to the host: `canSave` is a host-computed boolean\n * gating the save button, and `contentError` is a host-computed string —\n * this component only *displays* an error, it never decides whether one\n * exists. When `contentError` is supplied, the content field gets\n * `aria-invalid=\"true\"` and `aria-describedby` pointing at the rendered\n * error text; it is `aria-invalid=\"false\"` otherwise, so the absence of an\n * error is never ambiguous.\n *\n * The save button does NOT auto-close the dialog on click: correcting a\n * memory is commonly asynchronous (a network call), so the host decides\n * when to flip `open` to `false` — typically only after the save succeeds.\n * The cancel button, however, always closes immediately (`Dialog.Close`) in\n * addition to notifying the host via `onCancel`. Escape maps to the native\n * Dialog \"cancel\" intent and calls `onOpenChange(false)` only — `onSave` is\n * never called as a side effect of closing.\n *\n * SIN-01: every visible string (`title`, `description`, `closeAriaLabel`,\n * `contentLabel`, `typeLabel`, `tagsLabel`, `tagInputPlaceholder`,\n * `removeTagAriaLabel`, `saveLabel`, `savingLabel`, `cancelLabel`) is a\n * REQUIRED prop with no default — the library carries no copy, the host\n * owns i18n. `contentError`/`contentPlaceholder`/`suggestedTags`/`maxTags`\n * are optional because they are conditionally rendered, host-computed\n * values, never a hardcoded fallback string.\n *\n * data-slot=\"edit-memory-dialog\" on the popup root.\n * No \"use client\" side effects beyond the dialog's own open state — it has\n * none; prepend-use-client.mjs adds the directive to dist regardless.\n * Design tokens: --background, --border, --foreground, --muted-foreground,\n * --destructive, --primary, --ring.\n *\n * @example\n * <MosaicEditMemoryDialog\n * open={open}\n * onOpenChange={setOpen}\n * title={t('EditMemory.title')}\n * description={t('EditMemory.description')}\n * closeAriaLabel={t('EditMemory.aria.close')}\n * content={content}\n * onContentChange={setContent}\n * contentLabel={t('EditMemory.content')}\n * contentError={contentError}\n * types={memoryTypes}\n * type={type}\n * onTypeChange={setType}\n * typeLabel={t('EditMemory.type')}\n * tags={tags}\n * onAddTag={(tag) => setTags((prev) => [...prev, tag])}\n * onRemoveTag={(tag) => setTags((prev) => prev.filter((t) => t !== tag))}\n * tagsLabel={t('EditMemory.tags')}\n * tagInputPlaceholder={t('EditMemory.tagsPlaceholder')}\n * removeTagAriaLabel={(tag) => t('EditMemory.aria.removeTag', { tag })}\n * canSave={isValid}\n * isSaving={isSaving}\n * onSave={handleSave}\n * onCancel={() => setOpen(false)}\n * saveLabel={t('EditMemory.save')}\n * savingLabel={t('EditMemory.saving')}\n * cancelLabel={t('EditMemory.cancel')}\n * />\n */\n\nimport { Dialog } from \"@base-ui/react/dialog\";\nimport * as React from \"react\";\nimport { MosaicSelect, type MosaicSelectItem } from \"@/components/ui/MosaicSelect\";\nimport { MosaicTagInput } from \"@/components/ui/MosaicTagInput\";\nimport { MosaicTextarea } from \"@/components/ui/MosaicTextarea\";\nimport {\n editMemoryDialogBackdropVariants,\n editMemoryDialogErrorVariants,\n editMemoryDialogFieldVariants,\n editMemoryDialogPopupVariants,\n} from \"./edit-memory-dialog-variants.js\";\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 MosaicEditMemoryDialogProps {\n /** Controlled open state — the host owns the truth. */\n open: boolean;\n /** Controlled state setter, called on every open/close intent (including Escape and Cancel). */\n onOpenChange: (open: boolean) => void;\n\n /** Dialog title, wired to `aria-labelledby`. Required — no default. */\n title: string;\n /** Dialog description, wired to `aria-describedby`. Required — no default. */\n description: string;\n /** aria-label for the close (X) button. Required — the host owns the language. */\n closeAriaLabel: string;\n\n /** Current memory content value — controlled. */\n content: string;\n /** Called on every keystroke in the content field. */\n onContentChange: (value: string) => void;\n /** Label for the content field. Required — no default. */\n contentLabel: string;\n /** Placeholder for the content field. */\n contentPlaceholder?: string;\n /** Host-computed validation message for the content field, or absent when valid. */\n contentError?: string;\n\n /** Host-supplied memory-type taxonomy — never hardcoded in the library. */\n types: MosaicSelectItem[];\n /** Currently selected type value — controlled. */\n type: string;\n /** Called when the host user picks a different type. */\n onTypeChange: (value: string) => void;\n /** Label for the type field. Required — no default. */\n typeLabel: string;\n\n /** Current tag list — controlled, single source of truth owned by the host. */\n tags: string[];\n /** Called when a tag should be added. */\n onAddTag: (tag: string) => void;\n /** Called when a tag should be removed. */\n onRemoveTag: (tag: string) => void;\n /** Label for the tags field. Required — no default. */\n tagsLabel: string;\n /** Placeholder for the tag input. Required — no default. */\n tagInputPlaceholder: string;\n /** Per-tag accessible name for the remove button. Required, no default. */\n removeTagAriaLabel: (tag: string) => string;\n /** Optional host-supplied suggested tags. */\n suggestedTags?: string[];\n /** Optional maximum number of tags. */\n maxTags?: number;\n\n /** True while a save request is in flight — disables both actions, swaps the save label. */\n isSaving: boolean;\n /**\n * Host-computed form validity gating the save button. This component\n * never decides validation itself — it only reflects the host's verdict.\n */\n canSave: boolean;\n /** Called when the save button is clicked and `canSave` is true. Does not close the dialog. */\n onSave: () => void;\n /** Called when the cancel button is clicked, before the dialog closes. */\n onCancel: () => void;\n /** Label for the save button while idle. Required — no default. */\n saveLabel: string;\n /** Label for the save button while `isSaving` is true. Required — no default. */\n savingLabel: string;\n /** Label for the cancel button. Required — no default. */\n cancelLabel: string;\n\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicEditMemoryDialog — production \"edit a stale memory\" dialog for\n * @vantageos/mosaic-blocks.\n *\n * Purely presentational and fully controlled: composes @base-ui/react/dialog\n * with MosaicTextarea + MosaicSelect + MosaicTagInput. No network call, no\n * built-in taxonomy, no built-in validation, no built-in copy.\n */\nexport function MosaicEditMemoryDialog({\n open,\n onOpenChange,\n title,\n description,\n closeAriaLabel,\n content,\n onContentChange,\n contentLabel,\n contentPlaceholder,\n contentError,\n types,\n type,\n onTypeChange,\n typeLabel,\n tags,\n onAddTag,\n onRemoveTag,\n tagsLabel,\n tagInputPlaceholder,\n removeTagAriaLabel,\n suggestedTags,\n maxTags,\n isSaving,\n canSave,\n onSave,\n onCancel,\n saveLabel,\n savingLabel,\n cancelLabel,\n className,\n}: MosaicEditMemoryDialogProps) {\n const titleId = React.useId();\n const descriptionId = React.useId();\n const contentErrorId = React.useId();\n\n const saveDisabled = !canSave || isSaving;\n\n const handleSave = () => {\n if (saveDisabled) return;\n onSave();\n };\n\n return (\n <Dialog.Root open={open} onOpenChange={(nextOpen) => onOpenChange(nextOpen)} modal>\n <Dialog.Portal>\n <Dialog.Backdrop\n data-slot=\"edit-memory-dialog-backdrop\"\n className={editMemoryDialogBackdropVariants()}\n />\n <Dialog.Popup\n data-slot=\"edit-memory-dialog\"\n aria-labelledby={titleId}\n aria-describedby={descriptionId}\n aria-modal=\"true\"\n className={cn(editMemoryDialogPopupVariants(), className)}\n >\n <div\n data-slot=\"edit-memory-dialog-header\"\n className=\"flex items-start justify-between gap-4 border-b border-border p-4\"\n >\n <div className=\"flex flex-col gap-1\">\n <Dialog.Title id={titleId} className=\"text-base font-semibold text-foreground\">\n {title}\n </Dialog.Title>\n <Dialog.Description id={descriptionId} className=\"text-sm text-muted-foreground\">\n {description}\n </Dialog.Description>\n </div>\n <Dialog.Close\n aria-label={closeAriaLabel}\n className={cn(\n \"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors\",\n \"hover:bg-muted hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n >\n <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=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n </Dialog.Close>\n </div>\n\n <div\n data-slot=\"edit-memory-dialog-body\"\n className=\"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4\"\n >\n <div className={editMemoryDialogFieldVariants()}>\n <label\n htmlFor=\"mosaic-edit-memory-content\"\n className=\"text-sm font-medium text-foreground\"\n >\n {contentLabel}\n </label>\n <MosaicTextarea\n id=\"mosaic-edit-memory-content\"\n value={content}\n placeholder={contentPlaceholder}\n onChange={(event) => onContentChange(event.target.value)}\n rows={4}\n aria-invalid={contentError ? \"true\" : \"false\"}\n aria-describedby={contentError ? contentErrorId : undefined}\n />\n {contentError && (\n <p id={contentErrorId} className={editMemoryDialogErrorVariants()}>\n {contentError}\n </p>\n )}\n </div>\n\n <div className={editMemoryDialogFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{typeLabel}</span>\n <MosaicSelect\n items={types}\n value={type}\n onValueChange={(value) => {\n if (value) onTypeChange(value);\n }}\n />\n </div>\n\n <div className={editMemoryDialogFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{tagsLabel}</span>\n <MosaicTagInput\n tags={tags}\n onAddTag={onAddTag}\n onRemoveTag={onRemoveTag}\n placeholder={tagInputPlaceholder}\n removeTagAriaLabel={removeTagAriaLabel}\n suggestions={suggestedTags}\n maxTags={maxTags}\n />\n </div>\n </div>\n\n <div\n data-slot=\"edit-memory-dialog-footer\"\n className=\"flex flex-col-reverse gap-2 border-t border-border p-4 sm:flex-row sm:justify-end\"\n >\n <Dialog.Close\n onClick={onCancel}\n className={cn(\n \"inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-border px-4\",\n \"bg-background text-sm font-medium text-foreground shadow-xs\",\n \"hover:bg-muted hover:text-foreground\",\n \"focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n )}\n >\n {cancelLabel}\n </Dialog.Close>\n <button\n type=\"button\"\n onClick={handleSave}\n disabled={saveDisabled}\n className={cn(\n \"inline-flex h-9 items-center justify-center gap-1.5 rounded-md px-4\",\n \"bg-primary text-sm font-medium text-primary-foreground\",\n \"hover:bg-primary/90\",\n \"focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-ring\",\n \"disabled:pointer-events-none disabled:opacity-50\",\n )}\n >\n {isSaving ? savingLabel : saveLabel}\n </button>\n </div>\n </Dialog.Popup>\n </Dialog.Portal>\n </Dialog.Root>\n );\n}\n\nMosaicEditMemoryDialog.displayName = \"MosaicEditMemoryDialog\";\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "src/components/edit-memory-dialog/edit-memory-dialog-variants.ts",
|
|
22
|
+
"type": "registry:ui",
|
|
23
|
+
"content": "/**\n * editMemoryDialogVariants — pure CVA variant functions for\n * MosaicEditMemoryDialog.\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 (which live in MosaicEditMemoryDialog.tsx but not here).\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const editMemoryDialogPopupVariants = cva([\n \"fixed top-1/2 left-1/2 z-50 flex max-h-[85vh] w-full max-w-[calc(100%-2rem)] flex-col\",\n \"-translate-x-1/2 -translate-y-1/2\",\n \"rounded-lg border border-border bg-background shadow-lg outline-none\",\n \"sm:max-w-lg\",\n]);\n\nexport const editMemoryDialogBackdropVariants = cva([\"fixed inset-0 z-50 bg-black/50\"]);\n\nexport const editMemoryDialogFieldVariants = cva([\"flex flex-col gap-1.5\"]);\n\nexport const editMemoryDialogErrorVariants = cva([\"text-sm text-destructive\"]);\n"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"type": "registry:ui"
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-edit-session-dialog",
|
|
4
|
+
"title": "MosaicEditSessionDialog",
|
|
5
|
+
"description": "MosaicEditSessionDialog — presentational \"rename / reclassify a work-in-progress session\" form modal",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-adaptive-modal.json",
|
|
9
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-input.json",
|
|
10
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-select.json"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "src/components/edit-session-dialog/MosaicEditSessionDialog.tsx",
|
|
15
|
+
"type": "registry:ui",
|
|
16
|
+
"content": "/**\n * MosaicEditSessionDialog — presentational \"rename / reclassify a\n * work-in-progress session\" form modal\n *\n * Built so the owner of a session can find it again weeks later: edit its\n * name and classification, then save or cancel.\n *\n * Presentational atom composed from existing mosaic-blocks primitives:\n * MosaicAdaptiveModal (dialog/sheet shell), MosaicInput (name) and\n * MosaicSelect (classification). This component never invents a new modal\n * or form field — it assembles the ones the library already ships (same\n * doctrine as MosaicSaveTemplateModal).\n *\n * Fully controlled: `open`/`onOpenChange` own visibility, `name`/\n * `classification` are single-source-of-truth values supplied by the host,\n * every change is reported via a callback. The component keeps no internal\n * form state of its own — it never persists, never fetches, never diffs\n * against a stored session.\n *\n * Validation belongs to the host (SIN-01 + doctrine \"the host decides\"):\n * `canSave` is a host-computed boolean gating the save button, and\n * `nameError` is a host-computed string — this component only *displays*\n * an error, it never decides whether one exists. When `nameError` is\n * supplied, the name field gets `aria-invalid=\"true\"` and\n * `aria-describedby` pointing at the rendered error text; it is\n * `aria-invalid=\"false\"` otherwise, so the absence of an error is never\n * ambiguous.\n *\n * No hardcoded taxonomy: `classifications` is a required host-supplied\n * list of `MosaicSelectItem` — the set of classifications a session can\n * take is business/domain knowledge, never baked into the library.\n *\n * Escape closes the modal WITHOUT saving — MosaicAdaptiveModal maps the\n * native `<dialog>` \"cancel\" event (fired on Escape) straight to\n * `onOpenChange(false)`; `onSave` is never called as a side effect of\n * closing. isSaving sets `aria-busy=\"true\"` on the save button and\n * disables both actions — a save-in-progress is announced, never silent.\n *\n * data-slot=\"edit-session-dialog\" on the form body.\n * Every user-facing string (title/description/labels/placeholders/\n * error/button labels/aria-labels) is a required host-supplied prop —\n * zero hardcoded copy, zero default (SIN-01).\n *\n * No \"use client\" in source — prepend-use-client.mjs adds it to dist.\n * Design tokens: --border, --destructive, --foreground, --muted-foreground.\n *\n * @example\n * <MosaicEditSessionDialog\n * open={open}\n * onOpenChange={setOpen}\n * title={t('EditSession.title')}\n * closeAriaLabel={t('EditSession.aria.close')}\n * name={name}\n * onNameChange={setName}\n * nameLabel={t('EditSession.name')}\n * nameError={nameError}\n * classifications={classifications}\n * classification={classification}\n * onClassificationChange={setClassification}\n * classificationLabel={t('EditSession.classification')}\n * isSaving={isSaving}\n * canSave={isValid}\n * onSave={handleSave}\n * onCancel={() => setOpen(false)}\n * saveButtonLabel={t('EditSession.save')}\n * savingLabel={t('EditSession.saving')}\n * cancelButtonLabel={t('EditSession.cancel')}\n * />\n */\n\nimport { useId } from \"react\";\nimport { MosaicAdaptiveModal } from \"@/components/ui/MosaicAdaptiveModal\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { MosaicSelect, type MosaicSelectItem } from \"@/components/ui/MosaicSelect\";\nimport {\n editSessionDialogBodyVariants,\n editSessionDialogButtonVariants,\n editSessionDialogErrorVariants,\n editSessionDialogFieldVariants,\n editSessionDialogFooterVariants,\n} from \"./edit-session-dialog-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicEditSessionDialogProps {\n /** Controlled open state — the host owns the source of truth. */\n open: boolean;\n /** Called whenever the modal wants to change its open state (save, cancel, Escape, backdrop click). */\n onOpenChange: (open: boolean) => void;\n /** Modal heading. Required, no default. */\n title: string;\n /** Optional modal subheading. */\n description?: string;\n /** Accessible name for the desktop close button, forwarded to MosaicAdaptiveModal. */\n closeAriaLabel: string;\n\n /** Current session name value — controlled, pre-filled from the host's current session. */\n name: string;\n /** Called on every keystroke in the name field. */\n onNameChange: (value: string) => void;\n /** Label for the name field. Required, no default. */\n nameLabel: string;\n /** Placeholder for the name field. */\n namePlaceholder?: string;\n /** Host-computed validation message for the name field, or absent when valid. */\n nameError?: string;\n\n /** Host-supplied classification taxonomy — never hardcoded in the library. */\n classifications: MosaicSelectItem[];\n /** Currently selected classification value — controlled, pre-filled from the host's current session. */\n classification: string;\n /** Called when the host user picks a different classification. */\n onClassificationChange: (value: string) => void;\n /** Label for the classification field. Required, no default. */\n classificationLabel: string;\n\n /** True while a save request is in flight — announced via aria-busy, disables both actions. */\n isSaving: boolean;\n /**\n * Host-computed form validity gating the save button. This component\n * never decides validation itself — it only reflects the host's verdict.\n */\n canSave: boolean;\n /** Called when the host user submits the form. Never called on Escape/backdrop close. */\n onSave: () => void;\n /** Called when the host user clicks Cancel. Does not mutate anything by itself. */\n onCancel: () => void;\n /** Label for the save button while idle. Required, no default. */\n saveButtonLabel: string;\n /** Label for the save button while isSaving=true. Required, no default. */\n savingLabel: string;\n /** Label for the cancel button. Required, no default. */\n cancelButtonLabel: string;\n\n /** Additional Tailwind classes on the modal body. */\n className?: string;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicEditSessionDialog — production \"rename / reclassify a session\"\n * form modal for @vantageos/mosaic-blocks.\n *\n * Purely presentational and fully controlled: composes MosaicAdaptiveModal +\n * MosaicInput + MosaicSelect. No network call, no built-in taxonomy, no\n * built-in validation, no built-in copy.\n */\nexport function MosaicEditSessionDialog({\n open,\n onOpenChange,\n title,\n description,\n closeAriaLabel,\n name,\n onNameChange,\n nameLabel,\n namePlaceholder,\n nameError,\n classifications,\n classification,\n onClassificationChange,\n classificationLabel,\n isSaving,\n canSave,\n onSave,\n onCancel,\n saveButtonLabel,\n savingLabel,\n cancelButtonLabel,\n className,\n}: MosaicEditSessionDialogProps) {\n const nameErrorId = useId();\n\n if (!open) return null;\n\n return (\n <MosaicAdaptiveModal\n isOpen={open}\n onClose={() => onOpenChange(false)}\n title={title}\n description={description}\n closeAriaLabel={closeAriaLabel}\n >\n <div\n data-slot=\"edit-session-dialog\"\n className={cn(editSessionDialogBodyVariants(), className)}\n >\n <div className={editSessionDialogFieldVariants()}>\n <label htmlFor=\"mosaic-edit-session-name\" className=\"text-sm font-medium text-foreground\">\n {nameLabel}\n </label>\n <MosaicInput\n id=\"mosaic-edit-session-name\"\n value={name}\n placeholder={namePlaceholder}\n onChange={(e) => onNameChange(e.target.value)}\n aria-invalid={nameError ? \"true\" : \"false\"}\n aria-describedby={nameError ? nameErrorId : undefined}\n />\n {nameError && (\n <p id={nameErrorId} className={editSessionDialogErrorVariants()}>\n {nameError}\n </p>\n )}\n </div>\n\n <div className={editSessionDialogFieldVariants()}>\n <span className=\"text-sm font-medium text-foreground\">{classificationLabel}</span>\n <MosaicSelect\n items={classifications}\n value={classification}\n onValueChange={(value) => {\n if (value) onClassificationChange(value);\n }}\n />\n </div>\n\n <div className={editSessionDialogFooterVariants()}>\n <button\n type=\"button\"\n data-slot=\"edit-session-dialog-cancel-button\"\n onClick={onCancel}\n disabled={isSaving}\n className={editSessionDialogButtonVariants({ intent: \"cancel\" })}\n >\n {cancelButtonLabel}\n </button>\n <button\n type=\"button\"\n data-slot=\"edit-session-dialog-save-button\"\n onClick={onSave}\n disabled={!canSave || isSaving}\n aria-busy={isSaving ? \"true\" : \"false\"}\n className={editSessionDialogButtonVariants({ intent: \"save\" })}\n >\n {isSaving ? savingLabel : saveButtonLabel}\n </button>\n </div>\n </div>\n </MosaicAdaptiveModal>\n );\n}\n\nMosaicEditSessionDialog.displayName = \"MosaicEditSessionDialog\";\n"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "src/components/edit-session-dialog/edit-session-dialog-variants.ts",
|
|
20
|
+
"type": "registry:ui",
|
|
21
|
+
"content": "/**\n * editSessionDialogVariants — pure CVA variant functions for\n * MosaicEditSessionDialog.\n *\n * Isolated in their own module so they can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\n/** Form body vertical layout. */\nexport const editSessionDialogBodyVariants = cva([\"flex flex-col gap-4\"]);\n\n/** Field group (label + control + helper/error) vertical layout. */\nexport const editSessionDialogFieldVariants = cva([\"flex flex-col gap-1.5\"]);\n\n/** Field error text. */\nexport const editSessionDialogErrorVariants = cva([\"text-xs font-medium text-destructive\"]);\n\n/** Footer action row. */\nexport const editSessionDialogFooterVariants = cva([\n \"flex items-center justify-end gap-3 border-t border-border pt-4\",\n]);\n\n/** Submit / cancel button variants by intent. */\nexport const editSessionDialogButtonVariants = cva(\n [\n \"inline-flex min-h-9 items-center justify-center gap-2 rounded-md px-4 text-sm font-medium\",\n \"transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n ],\n {\n variants: {\n intent: {\n cancel: \"border border-border bg-background hover:bg-muted\",\n save: \"border border-transparent bg-primary text-primary-foreground hover:bg-primary/90\",\n },\n },\n defaultVariants: {\n intent: \"cancel\",\n },\n },\n);\n"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"type": "registry:ui"
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-editable-cell",
|
|
4
|
+
"title": "MosaicEditableCell",
|
|
5
|
+
"description": "MosaicEditableCell — table cell with double-click-to-edit",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-input.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/editable-cell/MosaicEditableCell.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicEditableCell — table cell with double-click-to-edit\n *\n * Composes MosaicInput. Double-click enters edit mode; Enter validates\n * and commits; Escape cancels and restores the original value. A failed\n * `validate` blocks the commit and surfaces its error message inline.\n *\n * data-slot=\"editable-cell\" on the wrapper.\n */\n\nimport * as React from \"react\";\nimport { MosaicInput } from \"@/components/ui/MosaicInput\";\nimport { editableCellVariants } from \"./editable-cell-variants.js\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicEditableCellProps {\n value: string;\n onCommit: (next: string) => void;\n onCancel?: () => void;\n /** Returns an error message to block the commit, or null to allow it. */\n validate?: (next: string) => string | null;\n /** Required — the host owns the language, no default fallback. */\n editAriaLabel: string;\n disabled?: boolean;\n className?: string;\n ref?: React.Ref<HTMLButtonElement | HTMLDivElement>;\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicEditableCell — double-click to edit a table cell.\n *\n * @example\n * <MosaicEditableCell\n * value={row.name}\n * onCommit={(next) => save(row.id, next)}\n * validate={(next) => (next.trim() ? null : t('EditableCell.required'))}\n * editAriaLabel={t('EditableCell.editLabel')}\n * />\n */\nexport function MosaicEditableCell({\n value,\n onCommit,\n onCancel,\n validate,\n editAriaLabel,\n disabled,\n className,\n ref,\n}: MosaicEditableCellProps) {\n const [isEditing, setIsEditing] = React.useState(false);\n // Not seeded from `value`: the read-mode view below always renders the\n // live `value` prop directly, never `draft`. `draft` only exists for the\n // duration of an edit session and is (re)seeded from the CURRENT prop by\n // `startEdit`, never from a snapshot taken at mount.\n const [draft, setDraft] = React.useState(\"\");\n const [error, setError] = React.useState<string | null>(null);\n\n function startEdit() {\n if (disabled) return;\n setDraft(value);\n setError(null);\n setIsEditing(true);\n }\n\n function commit() {\n const message = validate ? validate(draft) : null;\n if (message) {\n setError(message);\n return;\n }\n setError(null);\n setIsEditing(false);\n onCommit(draft);\n }\n\n function cancel() {\n setDraft(value);\n setError(null);\n setIsEditing(false);\n onCancel?.();\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {\n if (event.key === \"Enter\") {\n commit();\n } else if (event.key === \"Escape\") {\n cancel();\n }\n }\n\n if (!isEditing) {\n return (\n <button\n ref={ref as React.Ref<HTMLButtonElement>}\n type=\"button\"\n data-slot=\"editable-cell\"\n disabled={disabled}\n aria-label={editAriaLabel}\n className={cn(editableCellVariants({ disabled }), \"text-left\", className)}\n onDoubleClick={startEdit}\n onKeyDown={(event) => {\n if (!disabled && event.key === \"Enter\") {\n startEdit();\n }\n }}\n >\n {value}\n </button>\n );\n }\n\n return (\n <div\n ref={ref as React.Ref<HTMLDivElement>}\n data-slot=\"editable-cell\"\n className={cn(\"flex flex-col gap-1\", className)}\n >\n <MosaicInput\n aria-label={editAriaLabel}\n value={draft}\n autoFocus\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={handleKeyDown}\n onBlur={commit}\n />\n {error ? <span className=\"text-xs text-destructive\">{error}</span> : null}\n </div>\n );\n}\n\nMosaicEditableCell.displayName = \"MosaicEditableCell\";\n"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/editable-cell/editable-cell-variants.ts",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"content": "/**\n * editableCellVariants — pure CVA variant function for MosaicEditableCell.\n *\n * Isolated in its own module so it can be re-exported from the\n * `@vantageos/mosaic-blocks/server` subpath without pulling in React.\n *\n * Zero browser / React runtime dependencies — safe in RSC / Node.js.\n */\n\nimport { cva } from \"class-variance-authority\";\n\nexport const editableCellVariants = cva(\n [\"inline-flex w-full items-center rounded-sm px-1.5 py-1 text-sm\"],\n {\n variants: {\n disabled: {\n true: \"cursor-not-allowed text-muted-foreground\",\n false: \"cursor-text hover:bg-accent/50\",\n },\n },\n defaultVariants: {\n disabled: false,\n },\n },\n);\n"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"type": "registry:ui"
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-empty-state",
|
|
4
|
+
"title": "MosaicEmptyState",
|
|
5
|
+
"description": "MosaicEmptyState — centered vertical stack for empty/zero-data states",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/empty-state/MosaicEmptyState.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicEmptyState — centered vertical stack for empty/zero-data states\n *\n * Presentational atom. No icon library dependency — caller passes any ReactNode.\n * Design tokens: text-foreground, text-muted-foreground, gap-4.\n * Pattern: Button.tsx (data-slot, inline cn, React 19 ref prop, displayName, JSDoc).\n *\n * @example\n * <MosaicEmptyState\n * icon={<InboxIcon className=\"size-10 text-muted-foreground\" />}\n * title=\"No messages yet\"\n * description=\"Send your first message to get started.\"\n * action={<MosaicButton>New message</MosaicButton>}\n * />\n */\n\nimport type * as React from \"react\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport interface MosaicEmptyStateProps {\n /** Optional icon node rendered at the top, above the title. */\n icon?: React.ReactNode;\n /** Primary heading — required. */\n title: React.ReactNode;\n /** Supporting description text rendered below the title. */\n description?: React.ReactNode;\n /** Optional CTA rendered at the bottom (a button, link, or any node). */\n action?: React.ReactNode;\n /** Additional Tailwind classes for the root container. */\n className?: string;\n /** React 19 ref prop — no forwardRef wrapper needed. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * MosaicEmptyState — empty / zero-data state atom for @vantageos/mosaic-blocks.\n *\n * Renders a centered vertical stack: icon → title → description → action.\n * All slots except `title` are optional. Caller owns the icon node (no icon\n * library bundled). Accessible: uses semantic heading inside.\n *\n * @example\n * <MosaicEmptyState\n * icon={<FolderOpenIcon className=\"size-10 text-muted-foreground\" />}\n * title=\"No projects\"\n * description=\"Create your first project to get started.\"\n * action={<button type=\"button\">New project</button>}\n * />\n */\nexport function MosaicEmptyState({\n icon,\n title,\n description,\n action,\n className,\n ref,\n}: MosaicEmptyStateProps) {\n return (\n <div\n ref={ref}\n data-slot=\"empty-state\"\n className={cn(\n \"flex flex-col items-center justify-center gap-4 px-4 py-12 text-center\",\n className,\n )}\n >\n {icon != null && (\n <div\n data-slot=\"empty-state-icon\"\n className=\"flex items-center justify-center text-muted-foreground\"\n >\n {icon}\n </div>\n )}\n\n <div data-slot=\"empty-state-text\" className=\"flex flex-col gap-1.5\">\n <h3 data-slot=\"empty-state-title\" className=\"text-base font-medium text-foreground\">\n {title}\n </h3>\n\n {description != null && (\n <p data-slot=\"empty-state-description\" className=\"text-sm text-muted-foreground\">\n {description}\n </p>\n )}\n </div>\n\n {action != null && (\n <div data-slot=\"empty-state-action\" className=\"mt-2\">\n {action}\n </div>\n )}\n </div>\n );\n}\n\nMosaicEmptyState.displayName = \"MosaicEmptyState\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-falling-pattern",
|
|
4
|
+
"title": "MosaicFallingPattern",
|
|
5
|
+
"description": "Animated dot-grid background pattern (SVG + CSS falling dot animation). Props: density?, color?, animationDuration?. aria-hidden. No extra deps. Respects prefers-reduced-motion.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/falling-pattern/MosaicFallingPattern.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicFallingPattern — animated grid/dot background pattern\n *\n * Ported from heyfabrika/styleui components/grid-pattern / falling-pattern (MIT).\n * Implementation: SVG pattern + CSS animation for \"falling\" dot effect.\n * Zero extra deps — pure SVG/CSS.\n * Purely decorative: aria-hidden=\"true\".\n * Color via prop (OKLCH string) — no hardcoded branding.\n */\n\nimport * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicFallingPatternProps {\n /**\n * Number of columns in the grid (default 12).\n * Higher = denser pattern.\n */\n density?: number;\n /**\n * Dot/grid line color (default \"oklch(0.85 0.005 250)\").\n * Accepts any CSS color string — use OKLCH for theme-reactive behavior.\n */\n color?: string;\n /** Animation duration for one full cycle in ms (default 4000) */\n animationDuration?: number;\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\n// ── Keyframe injection ────────────────────────────────────────────────────────\n\nconst PATTERN_ANIM_ID = \"mosaic-falling-pattern-kf\";\n\nfunction injectPatternKeyframes() {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(PATTERN_ANIM_ID)) return;\n const style = document.createElement(\"style\");\n style.id = PATTERN_ANIM_ID;\n style.textContent = `\n @keyframes mosaic-falling-dots {\n 0% { transform: translateY(0); opacity: 1; }\n 100% { transform: translateY(48px); opacity: 0; }\n }\n @media (prefers-reduced-motion: reduce) {\n .mosaic-falling-dot { animation: none !important; opacity: 0.5 !important; }\n }\n `;\n document.head.appendChild(style);\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicFallingPattern — decorative animated dot-grid background.\n * Position absolutely within a `relative overflow-hidden` container.\n *\n * @example\n * <div className=\"relative overflow-hidden min-h-96\">\n * <MosaicFallingPattern density={14} color=\"oklch(0.8 0.05 250)\" />\n * <YourContent className=\"relative z-10\" />\n * </div>\n */\nexport function MosaicFallingPattern({\n density = 12,\n color = \"oklch(0.85 0.005 250)\",\n animationDuration = 4000,\n className,\n ref,\n}: MosaicFallingPatternProps) {\n const uniqueId = React.useId();\n\n React.useEffect(() => {\n injectPatternKeyframes();\n }, []);\n\n // Build grid dots: density × (density / 2) dots for aspect ratio\n const cols = density;\n const rows = Math.ceil(density / 2);\n const cellW = 100 / cols;\n const cellH = 100 / rows;\n\n return (\n <div\n ref={ref}\n aria-hidden=\"true\"\n className={className}\n style={{\n position: \"absolute\",\n inset: 0,\n overflow: \"hidden\",\n pointerEvents: \"none\",\n }}\n >\n <svg\n width=\"100%\"\n height=\"100%\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-hidden=\"true\"\n style={{ position: \"absolute\", inset: 0 }}\n >\n <defs>\n <pattern\n id={`mosaic-grid-${uniqueId}`}\n x=\"0\"\n y=\"0\"\n width={`${cellW}%`}\n height={`${cellH}%`}\n patternUnits=\"userSpaceOnUse\"\n >\n <circle cx=\"50%\" cy=\"50%\" r=\"1.5\" fill={color} />\n </pattern>\n </defs>\n <rect width=\"100%\" height=\"100%\" fill={`url(#mosaic-grid-${uniqueId})`} />\n </svg>\n\n {/* Falling animated dots — staggered across columns */}\n {Array.from({ length: cols }, (_, i) => {\n const leftPct = (i + 0.5) * cellW;\n const delay = (i / cols) * animationDuration;\n // col-N is stable: dots are positional columns, never reordered\n const colKey = `col-${i}`;\n return (\n <span\n key={colKey}\n className=\"mosaic-falling-dot\"\n style={{\n position: \"absolute\",\n top: \"-12px\",\n left: `${leftPct}%`,\n width: 3,\n height: 3,\n borderRadius: \"50%\",\n background: color,\n animation: `mosaic-falling-dots ${animationDuration}ms ease-in ${delay}ms infinite`,\n opacity: 0,\n }}\n />\n );\n })}\n </div>\n );\n}\n\nMosaicFallingPattern.displayName = \"MosaicFallingPattern\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-feature-3col",
|
|
4
|
+
"title": "MosaicFeature3Col",
|
|
5
|
+
"description": "3-column feature grid section. Props: heading?, subtext?, features[] {id, title, body, icon?}. Responsive: 1-col mobile, 3-col md+. Icon slot per cell. data-slot API. Distinct from MosaicFeatureCenteredMedia (single centered layout).",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/feature-3col/MosaicFeature3Col.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicFeature3Col — 3-column feature grid section\n *\n * Distinct from MosaicFeatureCenteredMedia (single centered layout).\n * Layout: optional header, then a 3-col responsive grid of feature cells.\n * Each cell has an optional icon slot, title, and body.\n * No hardcoded branding. OKLCH semantic classes only.\n * React-19 ref-as-prop (no forwardRef).\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface Feature3ColItem {\n /** Stable unique identifier for this feature */\n id: string;\n /** Feature title */\n title: string;\n /** Feature body / description */\n body: string;\n /** Optional icon node rendered above the title */\n icon?: React.ReactNode;\n}\n\nexport interface MosaicFeature3ColProps {\n /** Optional section heading */\n heading?: string;\n /** Optional section subtext */\n subtext?: string;\n /** Array of feature cells */\n features: Feature3ColItem[];\n className?: string;\n /** Forwarded to the root <section> element (React-19 ref-as-prop) */\n ref?: React.Ref<HTMLElement>;\n}\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicFeature3Col — 3-column feature grid with optional heading + subtext.\n * Responsive: 1 column on mobile, 3 at md+.\n *\n * @example\n * <MosaicFeature3Col\n * heading=\"Why teams choose us\"\n * subtext=\"Built for speed and scale.\"\n * features={[\n * { id: \"f1\", title: \"Fast\", body: \"Deploy in seconds.\", icon: <SpeedIcon /> },\n * { id: \"f2\", title: \"Reliable\", body: \"99.9% uptime SLA.\" },\n * { id: \"f3\", title: \"Secure\", body: \"Enterprise-grade by default.\" },\n * ]}\n * />\n */\nexport function MosaicFeature3Col({\n heading,\n subtext,\n features,\n className,\n ref,\n}: MosaicFeature3ColProps) {\n return (\n <section\n ref={ref}\n data-slot=\"feature-3col\"\n className={cn(\"mx-auto w-full max-w-6xl px-4 py-16\", className)}\n >\n {/* Header */}\n {(heading || subtext) && (\n <div className=\"mb-12 text-center\">\n {heading && (\n <h2 className=\"text-3xl font-medium tracking-tight text-foreground sm:text-4xl\">\n {heading}\n </h2>\n )}\n {subtext && (\n <p className=\"mt-4 text-sm text-muted-foreground sm:text-base max-w-xl mx-auto\">\n {subtext}\n </p>\n )}\n </div>\n )}\n\n {/* Feature grid */}\n <div className=\"grid grid-cols-1 gap-8 md:grid-cols-3\">\n {features.map((feature) => (\n <div key={feature.id} data-slot=\"feature-3col-item\" className=\"flex flex-col gap-3\">\n {feature.icon !== undefined && (\n <div\n data-slot=\"feature-3col-icon\"\n className=\"flex size-10 items-center justify-center text-foreground\"\n >\n {feature.icon}\n </div>\n )}\n <h3 className=\"text-base font-medium text-foreground\">{feature.title}</h3>\n <p className=\"text-sm leading-relaxed text-muted-foreground\">{feature.body}</p>\n </div>\n ))}\n </div>\n </section>\n );\n}\n\nMosaicFeature3Col.displayName = \"MosaicFeature3Col\";\n"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"type": "registry:ui"
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "mosaic-feature-centered-media",
|
|
4
|
+
"title": "MosaicFeatureCenteredMedia",
|
|
5
|
+
"description": "Centered feature section: heading + body + optional feature grid + centered media slot. Props: title, body, features[], media.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "src/components/feature-centered-media/MosaicFeatureCenteredMedia.tsx",
|
|
11
|
+
"type": "registry:ui",
|
|
12
|
+
"content": "/**\n * MosaicFeatureCenteredMedia — centered feature section with media\n *\n * Ported from heyfabrika/styleui components/templates/axis/feature.tsx (MIT).\n * Adapted: props-driven features list + media slot. No hardcoded copy.\n * Layout: text header centered, media centered below.\n */\n\nimport type * as React from \"react\";\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface FeatureItem {\n id: string;\n title: string;\n description: string;\n}\n\nexport interface MosaicFeatureCenteredMediaProps {\n /** Section heading */\n title: React.ReactNode;\n /** Section subtext / body */\n body: React.ReactNode;\n /** Optional feature list — rendered in a grid below the heading */\n features?: FeatureItem[];\n /** Media slot — centered below or beside the text */\n media?: React.ReactNode;\n className?: string;\n ref?: React.Ref<HTMLElement>;\n}\n\n// ── Utility ──────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * MosaicFeatureCenteredMedia — centered heading + body, optional feature grid,\n * centered media below. Media slot accepts any React node.\n *\n * @example\n * <MosaicFeatureCenteredMedia\n * title=\"Everything you need\"\n * body=\"Built for teams that move fast.\"\n * features={[{ id: \"f1\", title: \"Fast\", description: \"Deploy in seconds.\" }]}\n * media={<img src=\"/feature.png\" alt=\"Feature screenshot\" className=\"w-full rounded-2xl\" />}\n * />\n */\nexport function MosaicFeatureCenteredMedia({\n title,\n body,\n features,\n media,\n className,\n ref,\n}: MosaicFeatureCenteredMediaProps) {\n return (\n <section ref={ref} className={cn(\"relative mx-auto w-full max-w-6xl px-4 py-16\", className)}>\n {/* Header */}\n <div className=\"mb-12 text-center lg:mb-16\">\n <h2 className=\"text-3xl font-medium tracking-tight text-[oklch(0.12_0.01_250)] sm:text-4xl\">\n {title}\n </h2>\n <p className=\"mt-4 text-sm text-[oklch(0.5_0.01_250)] sm:text-base max-w-xl mx-auto\">\n {body}\n </p>\n </div>\n\n {/* Feature grid (optional) */}\n {features && features.length > 0 && (\n <div className=\"mb-12 grid grid-cols-1 gap-8 sm:grid-cols-2 lg:grid-cols-4\">\n {features.map((feature) => (\n <div key={feature.id} className=\"flex flex-col gap-2\">\n <h3 className=\"text-base font-medium text-[oklch(0.12_0.01_250)]\">{feature.title}</h3>\n <p className=\"text-sm leading-relaxed text-[oklch(0.5_0.01_250)]\">\n {feature.description}\n </p>\n </div>\n ))}\n </div>\n )}\n\n {/* Media slot */}\n {media && (\n <div className=\"flex justify-center\">\n <div className=\"w-full max-w-4xl\">{media}</div>\n </div>\n )}\n </section>\n );\n}\n\nMosaicFeatureCenteredMedia.displayName = \"MosaicFeatureCenteredMedia\";\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-field",
|
|
4
|
+
"title": "MosaicField",
|
|
5
|
+
"description": "Accessible form field built on @base-ui/react/field: Field + Label + Control + Description + Error with wired a11y associations. data-slot=\"field\".",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"@base-ui/react"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/field/MosaicField.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicField — @base-ui/react Field primitive\n *\n * Wires Field.Root + Field.Label + Field.Control + Field.Description + Field.Error\n * with full a11y associations (htmlFor, aria-describedby, aria-errormessage).\n *\n * API: data-slot=\"field\" on root. Compound component pattern via static props.\n * Styling: Tailwind v4 semantic tokens only, no hardcoded colors.\n */\n\nimport { Field } from \"@base-ui/react/field\";\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// ── Root ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicFieldProps extends React.ComponentPropsWithoutRef<typeof Field.Root> {\n className?: string;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction MosaicFieldRoot({ className, children, ref, ...props }: MosaicFieldProps) {\n return (\n <Field.Root\n ref={ref}\n data-slot=\"field\"\n className={cn(\"flex flex-col gap-1.5\", className)}\n {...props}\n >\n {children}\n </Field.Root>\n );\n}\nMosaicFieldRoot.displayName = \"MosaicField\";\n\n// ── Label ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicFieldLabelProps extends React.ComponentPropsWithoutRef<typeof Field.Label> {\n className?: string;\n ref?: React.Ref<HTMLLabelElement>;\n}\n\nfunction MosaicFieldLabel({ className, children, ref, ...props }: MosaicFieldLabelProps) {\n return (\n <Field.Label\n ref={ref}\n className={cn(\n \"text-sm font-medium leading-none text-foreground\",\n \"data-[disabled]:opacity-50\",\n className,\n )}\n {...props}\n >\n {children}\n </Field.Label>\n );\n}\nMosaicFieldLabel.displayName = \"MosaicField.Label\";\n\n// ── Control ───────────────────────────────────────────────────────────────────\n\nexport interface MosaicFieldControlProps\n extends React.ComponentPropsWithoutRef<typeof Field.Control> {\n className?: string;\n ref?: React.Ref<HTMLElement>;\n}\n\nfunction MosaicFieldControl({ className, ref, ...props }: MosaicFieldControlProps) {\n return <Field.Control ref={ref} className={cn(className)} {...props} />;\n}\nMosaicFieldControl.displayName = \"MosaicField.Control\";\n\n// ── Description ───────────────────────────────────────────────────────────────\n\nexport interface MosaicFieldDescriptionProps\n extends React.ComponentPropsWithoutRef<typeof Field.Description> {\n className?: string;\n ref?: React.Ref<HTMLParagraphElement>;\n}\n\nfunction MosaicFieldDescription({\n className,\n children,\n ref,\n ...props\n}: MosaicFieldDescriptionProps) {\n return (\n <Field.Description\n ref={ref}\n className={cn(\"text-xs text-muted-foreground\", className)}\n {...props}\n >\n {children}\n </Field.Description>\n );\n}\nMosaicFieldDescription.displayName = \"MosaicField.Description\";\n\n// ── Error ─────────────────────────────────────────────────────────────────────\n\nexport interface MosaicFieldErrorProps extends React.ComponentPropsWithoutRef<typeof Field.Error> {\n className?: string;\n /** Force-show the error even without native validity state */\n show?: boolean;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nfunction MosaicFieldError({\n className,\n children,\n show: _show,\n ref,\n ...props\n}: MosaicFieldErrorProps) {\n const show = _show;\n return (\n <Field.Error\n ref={ref}\n match={show === true ? true : undefined}\n className={cn(\"text-xs font-medium text-destructive\", className)}\n {...props}\n >\n {children}\n </Field.Error>\n );\n}\nMosaicFieldError.displayName = \"MosaicField.Error\";\n\n// ── Compound export ────────────────────────────────────────────────────────────\n\nexport const MosaicField = Object.assign(MosaicFieldRoot, {\n Label: MosaicFieldLabel,\n Control: MosaicFieldControl,\n Description: MosaicFieldDescription,\n Error: MosaicFieldError,\n});\n\nexport { MosaicFieldLabel, MosaicFieldControl, MosaicFieldDescription, MosaicFieldError };\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-filter-bar",
|
|
4
|
+
"title": "MosaicFilterBar",
|
|
5
|
+
"description": "MosaicFilterBar — responsive horizontal control bar for filter rows",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-button.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/filter-bar/MosaicFilterBar.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "/**\n * MosaicFilterBar — responsive horizontal control bar for filter rows\n *\n * Presentational layout atom. Unifies VP dashboard filter rows\n * (ActivityTypeFilter, ChannelFilter, HistoryFiltersBar, OrchestratorFilter,\n * StatsTimeWindow) into a single consistent, bilingual-safe container.\n *\n * Pattern: Button.tsx (data-slot, inline cn, React 19 ref prop, displayName, JSDoc).\n * No \"use client\" — prepend-use-client.mjs adds it to dist.\n *\n * Closes issue #21 — mosaic-filter-bar.\n *\n * @example\n * // Basic usage — controls only\n * <MosaicFilterBar>\n * <Select ... />\n * <Select ... />\n * </MosaicFilterBar>\n *\n * @example\n * // With label and clear affordance (bilingual)\n * <MosaicFilterBar\n * label=\"Filtres\"\n * onClearAll={() => resetFilters()}\n * clearLabel=\"Réinitialiser\"\n * >\n * <ActivityTypeFilter />\n * <ChannelFilter />\n * </MosaicFilterBar>\n *\n * @example\n * // Space-between layout (label pinned left, clear pinned right)\n * <MosaicFilterBar label=\"Historique\" onClearAll={clear} align=\"between\">\n * <DateRangePicker />\n * </MosaicFilterBar>\n */\n\nimport type * as React from \"react\";\nimport { MosaicButton } from \"@/components/ui/Button\";\n\n// ── Utility ───────────────────────────────────────────────────────────────────\n\nfunction cn(...classes: (string | undefined | null | false)[]): string {\n return classes.filter(Boolean).join(\" \");\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport interface MosaicFilterBarProps {\n /**\n * Optional leading label / title rendered before the filter controls.\n * Caller owns the node — pass translated strings for FR/EN support.\n */\n label?: React.ReactNode;\n /**\n * The filter controls (Select, DatePicker, Toggle, etc.).\n * Caller-owned — this component is a presentational layout wrapper only.\n */\n children: React.ReactNode;\n /**\n * When provided, renders a trailing \"Clear\" ghost button that calls this\n * handler when clicked. When absent, no Clear button is rendered.\n */\n onClearAll?: () => void;\n /**\n * Label for the Clear button (shown only when `onClearAll` is set).\n * Required — the host owns the language (e.g. FR: \"Réinitialiser\"). No\n * default, no fallback.\n */\n clearLabel: React.ReactNode;\n /**\n * Layout alignment of the bar contents.\n * - `\"start\"` (default) — all controls grouped at the leading edge\n * - `\"between\"` — label at leading edge, clear button at trailing edge,\n * controls fill the middle\n */\n align?: \"start\" | \"between\";\n /** Additional Tailwind classes forwarded to the root element. */\n className?: string;\n /** React 19 ref prop — no forwardRef wrapper needed. */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * MosaicFilterBar — responsive filter/control bar for @vantageos/mosaic-blocks.\n *\n * Wraps a row of filter controls (passed as children) with optional leading\n * label and trailing clear affordance. Mobile-first: wraps to multiple lines\n * on narrow viewports. Bilingual-safe: all user-facing strings are props.\n *\n * @example\n * <MosaicFilterBar label=\"Filters\" onClearAll={reset} clearLabel=\"Clear all\">\n * <MosaicSelect ... />\n * <MosaicSelect ... />\n * </MosaicFilterBar>\n */\nexport function MosaicFilterBar({\n label,\n children,\n onClearAll,\n clearLabel,\n align = \"start\",\n className,\n ref,\n}: MosaicFilterBarProps) {\n const isBetween = align === \"between\";\n\n return (\n <div\n ref={ref}\n data-slot=\"filter-bar\"\n className={cn(\n \"flex flex-wrap items-center gap-2\",\n isBetween ? \"justify-between\" : \"justify-start\",\n className,\n )}\n >\n {label != null && (\n <span\n data-slot=\"filter-bar-label\"\n className=\"shrink-0 text-sm font-medium text-muted-foreground\"\n >\n {label}\n </span>\n )}\n\n <div\n data-slot=\"filter-bar-controls\"\n className={cn(\"flex flex-wrap items-center gap-2\", isBetween && \"flex-1\")}\n >\n {children}\n </div>\n\n {onClearAll != null && (\n <MosaicButton\n data-slot=\"filter-bar-clear\"\n variant=\"ghost\"\n size=\"sm\"\n onClick={onClearAll}\n className=\"shrink-0\"\n >\n {clearLabel}\n </MosaicButton>\n )}\n </div>\n );\n}\n\nMosaicFilterBar.displayName = \"MosaicFilterBar\";\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-filter-sidebar",
|
|
4
|
+
"title": "MosaicFilterSidebar",
|
|
5
|
+
"description": "Generic collapsible filter sidebar. Filter tabs + category list with counts. Reusable across agents/marketplace/templates.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"https://cdn.jsdelivr.net/npm/@vantageos/mosaic-blocks@0.5.37-alpha/r/mosaic-device-provider.json"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/filter-sidebar/MosaicFilterSidebar.tsx",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"content": "\"use client\";\n\n/**\n * MosaicFilterSidebar — generic collapsible filter sidebar\n *\n * Ported from components/agents/AgentFilterSidebar.tsx\n *\n * Features:\n * - Collapsible (64px icon-only / expanded)\n * - Filter tabs (e.g. \"All\", \"Favorites\", \"Templates\")\n * - Category list with counts\n * - Fully generic — labels, filters, categories are props\n *\n * framer-motion replaced with CSS transitions.\n * useDevice used for mobile/tablet width adjustment.\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 MosaicFilterOption {\n id: string;\n label: string;\n count?: number | null;\n}\n\nexport interface MosaicFilterSidebarProps {\n isCollapsed: boolean;\n onToggleCollapse: () => void;\n /** Top-level filter tabs (e.g. All / Favorites / Templates) */\n filters?: MosaicFilterOption[];\n selectedFilter: string;\n onFilterChange: (filterId: string) => void;\n /** Category list */\n categories?: MosaicFilterOption[];\n selectedCategory: string;\n onCategoryChange: (categoryId: string) => void;\n /** Optional title for the sidebar */\n title?: string;\n /**\n * aria-label for the collapsed \"expand filters\" icon button. Required —\n * host-owned, no default.\n */\n expandFiltersAriaLabel: string;\n /** Heading above the categories list. Required — host-owned, no default. */\n categoriesHeading: string;\n /** aria-label for the toggle button when expanded. Required, no default. */\n collapseSidebarAriaLabel: string;\n /** aria-label for the toggle button when collapsed. Required, no default. */\n expandSidebarAriaLabel: string;\n className?: string;\n}\n\n// ── Inline icons ──────────────────────────────────────────────────────────────\n\nfunction ChevronLeftIcon() {\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 <polyline points=\"15 18 9 12 15 6\" />\n </svg>\n );\n}\n\nfunction ChevronRightIcon() {\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 <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\nfunction FilterIcon() {\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 <polygon points=\"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3\" />\n </svg>\n );\n}\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\nexport function MosaicFilterSidebar({\n isCollapsed,\n onToggleCollapse,\n filters = [],\n selectedFilter,\n onFilterChange,\n categories = [],\n selectedCategory,\n onCategoryChange,\n title,\n expandFiltersAriaLabel,\n categoriesHeading,\n collapseSidebarAriaLabel,\n expandSidebarAriaLabel,\n className,\n}: MosaicFilterSidebarProps) {\n const { isMobile, isTablet } = useDevice();\n\n const width = isMobile\n ? \"100%\"\n : isTablet\n ? isCollapsed\n ? \"64px\"\n : \"280px\"\n : isCollapsed\n ? \"64px\"\n : \"320px\";\n\n return (\n <div\n data-slot=\"filter-sidebar\"\n style={{ width, minWidth: isCollapsed && !isMobile ? \"64px\" : undefined }}\n className={cn(\n \"relative flex flex-col border-r border-border bg-card\",\n \"transition-[width] duration-200 ease-in-out\",\n \"overflow-hidden\",\n className,\n )}\n >\n {/* Toggle button */}\n {!isMobile && (\n <button\n type=\"button\"\n onClick={onToggleCollapse}\n className={cn(\n \"absolute -right-3 top-6 z-10 flex h-6 w-6 items-center justify-center rounded-full\",\n \"border border-border bg-background shadow-sm\",\n \"hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n )}\n aria-label={isCollapsed ? expandSidebarAriaLabel : collapseSidebarAriaLabel}\n >\n {isCollapsed ? <ChevronRightIcon /> : <ChevronLeftIcon />}\n </button>\n )}\n\n {/* Collapsed icon-only view */}\n {isCollapsed && !isMobile && (\n <div className=\"flex flex-col items-center gap-4 p-3 pt-6\">\n <button\n type=\"button\"\n onClick={onToggleCollapse}\n className=\"flex h-10 w-10 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground\"\n aria-label={expandFiltersAriaLabel}\n >\n <FilterIcon />\n </button>\n </div>\n )}\n\n {/* Expanded content */}\n {(!isCollapsed || isMobile) && (\n <div className=\"flex flex-col gap-4 overflow-y-auto p-4 h-full\">\n {/* Title */}\n <div className=\"flex items-center gap-2\">\n <FilterIcon />\n <span className=\"font-semibold text-sm\">{title}</span>\n </div>\n\n {/* Filter tabs */}\n {filters.length > 0 && (\n <div className=\"flex flex-col gap-1\">\n {filters.map((f) => (\n <button\n key={f.id}\n type=\"button\"\n onClick={() => onFilterChange(f.id)}\n className={cn(\n \"flex min-h-[40px] items-center justify-between rounded-md px-3 py-2 text-sm font-medium\",\n \"transition-colors hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n selectedFilter === f.id ? \"bg-primary/10 text-primary\" : \"text-foreground\",\n )}\n >\n <span>{f.label}</span>\n {f.count != null && (\n <span className=\"rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground\">\n {f.count}\n </span>\n )}\n </button>\n ))}\n </div>\n )}\n\n {/* Categories */}\n {categories.length > 0 && (\n <div>\n <p className=\"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground\">\n {categoriesHeading}\n </p>\n <div className=\"flex flex-col gap-1\">\n {categories.map((cat) => (\n <button\n key={cat.id}\n type=\"button\"\n onClick={() => onCategoryChange(cat.id)}\n className={cn(\n \"flex min-h-[36px] items-center justify-between rounded-md px-3 py-1.5 text-sm\",\n \"transition-colors hover:bg-accent hover:text-accent-foreground\",\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n selectedCategory === cat.id\n ? \"bg-primary/10 text-primary font-medium\"\n : \"text-foreground\",\n )}\n >\n <span className=\"text-left leading-snug\">{cat.label}</span>\n {cat.count != null && (\n <span className=\"shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs text-muted-foreground\">\n {cat.count}\n </span>\n )}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n\nMosaicFilterSidebar.displayName = \"MosaicFilterSidebar\";\n"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
}
|