@uibot/registry 0.14.0 → 0.15.1

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.
@@ -5,7 +5,7 @@
5
5
  "description": "Design-system cell editors for PagedCollectionGrid's renderCellEditor: text, number, long text, checkbox, single/multiple select, calendar dates (timestamps keep their time) and a searchable relation picker.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/renderer-react@^0.14.0",
8
+ "@uibot/renderer-react@^0.15.1",
9
9
  "cmdk@^1",
10
10
  "date-fns@^4",
11
11
  "lucide-react",
@@ -5,7 +5,7 @@
5
5
  "description": "Right-hand drawer for PagedCollectionWorkspace's renderPanel; a busy panel stays open and unsaved edits ask before closing.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/renderer-react@^0.14.0"
8
+ "@uibot/renderer-react@^0.15.1"
9
9
  ],
10
10
  "registryDependencies": [
11
11
  "button",
@@ -5,7 +5,7 @@
5
5
  "description": "Right-click record actions (expand, duplicate, copy cells, delete) for renderRecordContextMenu.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/renderer-react@^0.14.0"
8
+ "@uibot/renderer-react@^0.15.1"
9
9
  ],
10
10
  "registryDependencies": [
11
11
  "context-menu",
@@ -5,7 +5,7 @@
5
5
  "description": "Copy (zh/en), editor prop types and Tab-commit helper shared by the UIBot collection blocks.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/renderer-react@^0.14.0"
8
+ "@uibot/renderer-react@^0.15.1"
9
9
  ],
10
10
  "registryDependencies": [],
11
11
  "files": [
@@ -5,8 +5,8 @@
5
5
  "description": "Generate a new HTML artifact or rewrite the current revision, with at-most-once dispatch and reconcile from @uibot/creation-kit.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/contracts@^0.14.0",
9
- "@uibot/creation-kit@^0.14.0"
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1"
10
10
  ],
11
11
  "registryDependencies": [
12
12
  "button",
@@ -5,8 +5,8 @@
5
5
  "description": "Generate a presentation from an explicitly chosen saved HTML revision.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/contracts@^0.14.0",
9
- "@uibot/creation-kit@^0.14.0"
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1"
10
10
  ],
11
11
  "registryDependencies": [
12
12
  "button",
@@ -5,8 +5,8 @@
5
5
  "description": "Download a saved HTML revision (PPTX for presentations) once no model request is open; the host supplies the export transport.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/contracts@^0.14.0",
9
- "@uibot/creation-kit@^0.14.0"
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1"
10
10
  ],
11
11
  "registryDependencies": [
12
12
  "button",
@@ -5,15 +5,15 @@
5
5
  "description": "Copy (zh/en), domain filters and run checks shared by the UIBot creation blocks.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/contracts@^0.14.0",
9
- "@uibot/creation-kit@^0.14.0"
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1"
10
10
  ],
11
11
  "registryDependencies": [],
12
12
  "files": [
13
13
  {
14
14
  "path": "components/uibot/creation/creation-shared.ts",
15
15
  "target": "components/uibot/creation/creation-shared.ts",
16
- "content": "import type { CreationDomain, CreationProject } from \"@uibot/contracts\";\nimport { type CreationLocale, unresolvedCreationRuns } from \"@uibot/creation-kit\";\n\n/** What the generation blocks need from the creation configuration endpoint. */\nexport interface CreationGenerationCapabilities {\n domains: CreationDomain[];\n generation?: { ready: boolean };\n}\n\nconst MESSAGES = {\n zh: {\n htmlTitle: \"HTML 生成\",\n generationUnavailable: \"当前模型生成不可用,仍可手工编辑 HTML。\",\n saveBeforeGenerate: \"请先保存或放弃草稿,再生成。\",\n kindLabel: \"生成类型\",\n kindPlaceholder: \"请选择可用类型\",\n intentLabel: \"生成描述\",\n generateNew: \"生成新 HTML 工件\",\n rewriteCurrent: \"重写当前 HTML 修订\",\n reconcile: \"核对生成状态\",\n referenceTitle: \"从已保存修订生成演示文稿\",\n presentationUnavailable: \"当前演示文稿生成不可用。\",\n saveBeforeReference: \"请先保存或放弃草稿,再引用已保存修订。\",\n referenceArtifactLabel: \"参考作品\",\n referenceArtifactPlaceholder: \"选择已保存 HTML 工件\",\n referenceRevisionLabel: \"参考修订\",\n referenceRevisionPlaceholder: \"明确选择已保存修订\",\n revisionOption: (number: number) => `修订 ${number}`,\n presentationIntentLabel: \"演示文稿描述\",\n generatePresentation: \"生成演示文稿\",\n exportTitle: \"导出已保存修订\",\n exporting: \"正在导出…\",\n exportHtml: (number: number) => `导出 HTML 修订 ${number}`,\n exportPptx: (number: number) => `导出 PPTX 修订 ${number}`,\n saveBeforeExport: \"请先保存或放弃草稿,再导出已保存修订。\",\n exportBlocked: \"原模型请求待核对期间不可导出。\",\n refreshingStatus: \"正在读取生成状态…\",\n refreshStatus: \"刷新生成状态\",\n exportFailed: \"导出失败,请稍后重试。\",\n refreshFailed: \"无法读取最新生成状态。\",\n workspaceLabel: \"作品工作区\",\n workspaceEyebrow: \"手工 HTML 工作区\",\n workspaceLoading: \"正在读取作品…\",\n workspaceLoadFailed: \"无法读取作品能力,请稍后重试。\",\n newProject: \"新建作品\",\n conflict: \"版本已更新。你的草稿仍保留;重新读取后再编辑。\",\n reread: \"重新读取\",\n projectTitleLabel: \"作品名称\",\n createProject: \"创建作品\",\n cancel: \"取消\",\n selectProjectLabel: \"选择作品\",\n artifactTitleLabel: \"工件标题\",\n artifactKindLabel: \"工件类型\",\n unavailableKindOption: (kind: string) => `${kind}(已不可用)`,\n refreshingCapabilities: \"正在刷新能力…\",\n refreshCapabilities: \"刷新工件能力\",\n appendArtifact: \"添加 HTML 工件\",\n kindUnavailable: (kind: string) => `所选工件类型“${kind}”已不可用,请重新选择或刷新能力。`,\n noHtmlDomains: \"当前没有启用的 HTML 工件类型\",\n htmlContentLabel: \"HTML 内容\",\n saveRevision: \"保存版本\",\n savedRevisionsLabel: \"已保存版本\",\n historyRevision: (number: number) => `历史版本 ${number}`,\n },\n en: {\n htmlTitle: \"HTML generation\",\n generationUnavailable: \"Model generation is unavailable; you can still edit HTML by hand.\",\n saveBeforeGenerate: \"Save or discard the draft before generating.\",\n kindLabel: \"Generation type\",\n kindPlaceholder: \"Choose an available type\",\n intentLabel: \"Generation brief\",\n generateNew: \"Generate new HTML artifact\",\n rewriteCurrent: \"Rewrite current HTML revision\",\n reconcile: \"Check generation status\",\n referenceTitle: \"Generate a presentation from a saved revision\",\n presentationUnavailable: \"Presentation generation is unavailable.\",\n saveBeforeReference: \"Save or discard the draft before referencing a saved revision.\",\n referenceArtifactLabel: \"Reference artifact\",\n referenceArtifactPlaceholder: \"Choose a saved HTML artifact\",\n referenceRevisionLabel: \"Reference revision\",\n referenceRevisionPlaceholder: \"Choose a saved revision\",\n revisionOption: (number: number) => `Revision ${number}`,\n presentationIntentLabel: \"Presentation brief\",\n generatePresentation: \"Generate presentation\",\n exportTitle: \"Export saved revision\",\n exporting: \"Exporting…\",\n exportHtml: (number: number) => `Export HTML revision ${number}`,\n exportPptx: (number: number) => `Export PPTX revision ${number}`,\n saveBeforeExport: \"Save or discard the draft before exporting a saved revision.\",\n exportBlocked: \"Export is unavailable while the original model request is being checked.\",\n refreshingStatus: \"Reading generation status…\",\n refreshStatus: \"Refresh generation status\",\n exportFailed: \"Export failed. Try again later.\",\n refreshFailed: \"Could not read the latest generation status.\",\n workspaceLabel: \"Creation workspace\",\n workspaceEyebrow: \"Manual HTML workspace\",\n workspaceLoading: \"Loading projects…\",\n workspaceLoadFailed: \"Could not read creation capabilities. Try again later.\",\n newProject: \"New project\",\n conflict: \"This revision changed. Your draft is kept; reread before editing again.\",\n reread: \"Reread\",\n projectTitleLabel: \"Project name\",\n createProject: \"Create project\",\n cancel: \"Cancel\",\n selectProjectLabel: \"Select project\",\n artifactTitleLabel: \"Artifact title\",\n artifactKindLabel: \"Artifact type\",\n unavailableKindOption: (kind: string) => `${kind} (unavailable)`,\n refreshingCapabilities: \"Refreshing capabilities…\",\n refreshCapabilities: \"Refresh artifact capabilities\",\n appendArtifact: \"Add HTML artifact\",\n kindUnavailable: (kind: string) =>\n `The selected artifact type \"${kind}\" is unavailable; choose another or refresh capabilities.`,\n noHtmlDomains: \"No HTML artifact types are enabled\",\n htmlContentLabel: \"HTML content\",\n saveRevision: \"Save revision\",\n savedRevisionsLabel: \"Saved revisions\",\n historyRevision: (number: number) => `Revision ${number}`,\n },\n} satisfies Record<CreationLocale, unknown>;\n\nexport type CreationBlockMessages = (typeof MESSAGES)[\"en\"];\n\nexport function creationBlockMessages(locale: CreationLocale = \"en\"): CreationBlockMessages {\n return MESSAGES[locale];\n}\n\n/** A domain that can produce HTML (directly or through HTML generation instructions). */\nexport function generatesHtml(domain: CreationDomain): boolean {\n return (\n domain.enabled &&\n domain.formats.includes(\"html\") &&\n (domain.outputFormat === \"html\" || !!domain.generationInstructions?.html)\n );\n}\n\n/** HTML-capable domains, first one per artifact kind. */\nexport function htmlGenerationDomains(domains: CreationDomain[]): CreationDomain[] {\n return domains.filter(\n (domain, index, all) =>\n generatesHtml(domain) &&\n all.findIndex((candidate) => candidate.artifactKind === domain.artifactKind) === index,\n );\n}\n\n/** True while any run may still produce a result; a malformed `runs` field fails closed. */\nexport function hasUnresolvedRun(project: CreationProject): boolean {\n const runs: unknown = project.runs;\n if (!Array.isArray(runs)) return true;\n // Checked here too: `@uibot/creation-kit` before 0.4 throws on non-object entries.\n if (runs.some((run) => !run || typeof run !== \"object\" || Array.isArray(run))) return true;\n return unresolvedCreationRuns(runs).length > 0;\n}\n\n/** Artifact kinds whose saved HTML revisions can be exported or referenced. */\nexport const HTML_DOCUMENT_KINDS = [\"web\", \"presentation\"];\n\n/** Shared field styling for the native controls the blocks use. */\nexport const FIELD_CLASS =\n \"flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n",
16
+ "content": "import type { CreationDomain, CreationProject } from \"@uibot/contracts\";\nimport { type CreationLocale, unresolvedCreationRuns } from \"@uibot/creation-kit\";\n\n/** What the generation blocks need from the creation configuration endpoint. */\nexport interface CreationGenerationCapabilities {\n domains: CreationDomain[];\n generation?: { ready: boolean };\n}\n\nconst MESSAGES = {\n zh: {\n htmlTitle: \"HTML 生成\",\n generationUnavailable: \"当前模型生成不可用,仍可手工编辑 HTML。\",\n saveBeforeGenerate: \"请先保存或放弃草稿,再生成。\",\n kindLabel: \"生成类型\",\n kindPlaceholder: \"请选择可用类型\",\n intentLabel: \"生成描述\",\n generateNew: \"生成新 HTML 工件\",\n rewriteCurrent: \"重写当前 HTML 修订\",\n reconcile: \"核对生成状态\",\n referenceTitle: \"从已保存修订生成演示文稿\",\n presentationUnavailable: \"当前演示文稿生成不可用。\",\n saveBeforeReference: \"请先保存或放弃草稿,再引用已保存修订。\",\n referenceArtifactLabel: \"参考作品\",\n referenceArtifactPlaceholder: \"选择已保存 HTML 工件\",\n referenceRevisionLabel: \"参考修订\",\n referenceRevisionPlaceholder: \"明确选择已保存修订\",\n revisionOption: (number: number) => `修订 ${number}`,\n presentationIntentLabel: \"演示文稿描述\",\n generatePresentation: \"生成演示文稿\",\n exportTitle: \"导出已保存修订\",\n exporting: \"正在导出…\",\n exportHtml: (number: number) => `导出 HTML 修订 ${number}`,\n exportPptx: (number: number) => `导出 PPTX 修订 ${number}`,\n saveBeforeExport: \"请先保存或放弃草稿,再导出已保存修订。\",\n exportBlocked: \"原模型请求待核对期间不可导出。\",\n refreshingStatus: \"正在读取生成状态…\",\n refreshStatus: \"刷新生成状态\",\n exportFailed: \"导出失败,请稍后重试。\",\n refreshFailed: \"无法读取最新生成状态。\",\n workspaceLabel: \"作品工作区\",\n workspaceEyebrow: \"手工 HTML 工作区\",\n workspaceLoading: \"正在读取作品…\",\n workspaceLoadFailed: \"无法读取作品能力,请稍后重试。\",\n newProject: \"新建作品\",\n conflict: \"版本已更新。你的草稿仍保留;重新读取后再编辑。\",\n reread: \"重新读取\",\n projectTitleLabel: \"作品名称\",\n createProject: \"创建作品\",\n cancel: \"取消\",\n selectProjectLabel: \"选择作品\",\n artifactTitleLabel: \"工件标题\",\n artifactKindLabel: \"工件类型\",\n unavailableKindOption: (kind: string) => `${kind}(已不可用)`,\n refreshingCapabilities: \"正在刷新能力…\",\n refreshCapabilities: \"刷新工件能力\",\n appendArtifact: \"添加 HTML 工件\",\n kindUnavailable: (kind: string) => `所选工件类型“${kind}”已不可用,请重新选择或刷新能力。`,\n noHtmlDomains: \"当前没有启用的 HTML 工件类型\",\n htmlContentLabel: \"HTML 内容\",\n saveRevision: \"保存版本\",\n savedRevisionsLabel: \"已保存版本\",\n historyRevision: (number: number) => `历史版本 ${number}`,\n variantsTitle: \"多方案对比\",\n variantsIntentLabel: \"多方案描述\",\n variantDirectionLabel: (index: number) => `方案 ${index} 的方向`,\n variantProjectDesign: \"按项目设计\",\n variantCustomDirection: \"自定义文字\",\n variantDirectionText: (index: number) => `方案 ${index} 的方向描述`,\n addVariant: \"增加一个方案\",\n removeVariant: (index: number) => `移除方案 ${index}`,\n generateVariants: (count: number) => `生成 ${count} 个方案`,\n variantColumn: (index: number) => `方案 ${index}`,\n variantPreview: (index: number) => `方案 ${index} 预览`,\n variantStatus: {\n sending: \"正在提交…\",\n unknown: \"提交结果未知\",\n queued: \"排队中…\",\n running: \"生成中…\",\n interrupted: \"已中断\",\n held: \"可采用\",\n completed: \"已采用\",\n failed: \"生成失败\",\n cancelled: \"已作废\",\n conflict: \"版本冲突\",\n } as Record<string, string>,\n adoptVariant: (index: number) => `采用方案 ${index}`,\n discardVariants: \"全部放弃\",\n retryVariants: \"重试提交\",\n variantsAdopted: \"已采用所选方案,作品已保存为新修订。\",\n variantsDiscarded: \"这一组方案已放弃,作品未改变。\",\n newVariantSet: \"开始新一组\",\n },\n en: {\n htmlTitle: \"HTML generation\",\n generationUnavailable: \"Model generation is unavailable; you can still edit HTML by hand.\",\n saveBeforeGenerate: \"Save or discard the draft before generating.\",\n kindLabel: \"Generation type\",\n kindPlaceholder: \"Choose an available type\",\n intentLabel: \"Generation brief\",\n generateNew: \"Generate new HTML artifact\",\n rewriteCurrent: \"Rewrite current HTML revision\",\n reconcile: \"Check generation status\",\n referenceTitle: \"Generate a presentation from a saved revision\",\n presentationUnavailable: \"Presentation generation is unavailable.\",\n saveBeforeReference: \"Save or discard the draft before referencing a saved revision.\",\n referenceArtifactLabel: \"Reference artifact\",\n referenceArtifactPlaceholder: \"Choose a saved HTML artifact\",\n referenceRevisionLabel: \"Reference revision\",\n referenceRevisionPlaceholder: \"Choose a saved revision\",\n revisionOption: (number: number) => `Revision ${number}`,\n presentationIntentLabel: \"Presentation brief\",\n generatePresentation: \"Generate presentation\",\n exportTitle: \"Export saved revision\",\n exporting: \"Exporting…\",\n exportHtml: (number: number) => `Export HTML revision ${number}`,\n exportPptx: (number: number) => `Export PPTX revision ${number}`,\n saveBeforeExport: \"Save or discard the draft before exporting a saved revision.\",\n exportBlocked: \"Export is unavailable while the original model request is being checked.\",\n refreshingStatus: \"Reading generation status…\",\n refreshStatus: \"Refresh generation status\",\n exportFailed: \"Export failed. Try again later.\",\n refreshFailed: \"Could not read the latest generation status.\",\n workspaceLabel: \"Creation workspace\",\n workspaceEyebrow: \"Manual HTML workspace\",\n workspaceLoading: \"Loading projects…\",\n workspaceLoadFailed: \"Could not read creation capabilities. Try again later.\",\n newProject: \"New project\",\n conflict: \"This revision changed. Your draft is kept; reread before editing again.\",\n reread: \"Reread\",\n projectTitleLabel: \"Project name\",\n createProject: \"Create project\",\n cancel: \"Cancel\",\n selectProjectLabel: \"Select project\",\n artifactTitleLabel: \"Artifact title\",\n artifactKindLabel: \"Artifact type\",\n unavailableKindOption: (kind: string) => `${kind} (unavailable)`,\n refreshingCapabilities: \"Refreshing capabilities…\",\n refreshCapabilities: \"Refresh artifact capabilities\",\n appendArtifact: \"Add HTML artifact\",\n kindUnavailable: (kind: string) =>\n `The selected artifact type \"${kind}\" is unavailable; choose another or refresh capabilities.`,\n noHtmlDomains: \"No HTML artifact types are enabled\",\n htmlContentLabel: \"HTML content\",\n saveRevision: \"Save revision\",\n savedRevisionsLabel: \"Saved revisions\",\n historyRevision: (number: number) => `Revision ${number}`,\n variantsTitle: \"Compare variants\",\n variantsIntentLabel: \"Variants description\",\n variantDirectionLabel: (index: number) => `Direction for variant ${index}`,\n variantProjectDesign: \"Project design\",\n variantCustomDirection: \"Custom text\",\n variantDirectionText: (index: number) => `Direction text for variant ${index}`,\n addVariant: \"Add a variant\",\n removeVariant: (index: number) => `Remove variant ${index}`,\n generateVariants: (count: number) => `Generate ${count} variants`,\n variantColumn: (index: number) => `Variant ${index}`,\n variantPreview: (index: number) => `Variant ${index} preview`,\n variantStatus: {\n sending: \"Sending…\",\n unknown: \"Send result unknown\",\n queued: \"Queued…\",\n running: \"Generating…\",\n interrupted: \"Interrupted\",\n held: \"Ready\",\n completed: \"Adopted\",\n failed: \"Failed\",\n cancelled: \"Discarded\",\n conflict: \"Revision conflict\",\n } as Record<string, string>,\n adoptVariant: (index: number) => `Adopt variant ${index}`,\n discardVariants: \"Discard all\",\n retryVariants: \"Retry sending\",\n variantsAdopted: \"The chosen variant is saved as the artifact's new revision.\",\n variantsDiscarded: \"This variant set was discarded; the artifact is unchanged.\",\n newVariantSet: \"Start a new set\",\n },\n} satisfies Record<CreationLocale, unknown>;\n\nexport type CreationBlockMessages = (typeof MESSAGES)[\"en\"];\n\nexport function creationBlockMessages(locale: CreationLocale = \"en\"): CreationBlockMessages {\n return MESSAGES[locale];\n}\n\n/** A domain that can produce HTML (directly or through HTML generation instructions). */\nexport function generatesHtml(domain: CreationDomain): boolean {\n return (\n domain.enabled &&\n domain.formats.includes(\"html\") &&\n (domain.outputFormat === \"html\" || !!domain.generationInstructions?.html)\n );\n}\n\n/** HTML-capable domains, first one per artifact kind. */\nexport function htmlGenerationDomains(domains: CreationDomain[]): CreationDomain[] {\n return domains.filter(\n (domain, index, all) =>\n generatesHtml(domain) &&\n all.findIndex((candidate) => candidate.artifactKind === domain.artifactKind) === index,\n );\n}\n\n/** True while any run may still produce a result; a malformed `runs` field fails closed. */\nexport function hasUnresolvedRun(project: CreationProject): boolean {\n const runs: unknown = project.runs;\n if (!Array.isArray(runs)) return true;\n // Checked here too: `@uibot/creation-kit` before 0.4 throws on non-object entries.\n if (runs.some((run) => !run || typeof run !== \"object\" || Array.isArray(run))) return true;\n return unresolvedCreationRuns(runs).length > 0;\n}\n\n/** Artifact kinds whose saved HTML revisions can be exported or referenced. */\nexport const HTML_DOCUMENT_KINDS = [\"web\", \"presentation\"];\n\n/** Shared field styling for the native controls the blocks use. */\nexport const FIELD_CLASS =\n \"flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-xs outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n",
17
17
  "type": "registry:lib"
18
18
  }
19
19
  ],
@@ -0,0 +1,31 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "creation-variant-compare",
4
+ "type": "registry:block",
5
+ "description": "Generate two or three HTML candidates side by side (project design, design guides or custom directions) and adopt one as the next revision, over useCreationVariants.",
6
+ "dependencies": [
7
+ "react",
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1",
10
+ "@uibot/web-preview@^0.15.1"
11
+ ],
12
+ "registryDependencies": [
13
+ "button",
14
+ "input",
15
+ "label",
16
+ "textarea",
17
+ "@uibot/creation-shared"
18
+ ],
19
+ "files": [
20
+ {
21
+ "path": "components/uibot/creation/creation-variant-compare.tsx",
22
+ "target": "components/uibot/creation/creation-variant-compare.tsx",
23
+ "content": "import { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { Textarea } from \"@/components/ui/textarea\";\nimport {\n type CreationLocale,\n type CreationRunStorage,\n type CreationVariantDirection,\n type CreationVariantsClient,\n defaultVariantDirections,\n useCreationVariants,\n} from \"@uibot/creation-kit\";\nimport {\n APP_SRCDOC_CSP,\n buildErrorBridgeScript,\n cspMetaTag,\n SANDBOX_STORAGE_SHIM_SCRIPT,\n} from \"@uibot/web-preview\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport { creationBlockMessages, FIELD_CLASS } from \"./creation-shared\";\n\nexport interface CreationVariantCompareProps {\n client: CreationVariantsClient;\n projectId: string;\n /** Artifact kind generated (an HTML domain, e.g. `web`). */\n kind: string;\n /** Update this artifact; omit to create a new one from the adopted candidate. */\n artifactId?: string;\n expectedRevisionId?: string | null;\n /** Set reservation key; scope it to the signed-in identity and project. */\n storageKey: string;\n storage?: CreationRunStorage;\n locale?: CreationLocale;\n initialIntent?: string;\n /** Called after a candidate is adopted, with the committed revision. */\n onAdopted?: (revisionId: string) => void;\n /** Poll interval while candidates generate (default 1500 ms). */\n pollMs?: number;\n /** Blocks starting and adopting (e.g. while the host has an unsaved draft). */\n disabled?: boolean;\n}\n\nconst CUSTOM = \"__custom__\";\nconst PROJECT = \"__project__\";\n\n/** Candidate HTML in a sandboxed frame, with the same shims and CSP as the preview. */\nfunction previewDocument(html: string): string {\n const shims = `${cspMetaTag(APP_SRCDOC_CSP)}${SANDBOX_STORAGE_SHIM_SCRIPT}${buildErrorBridgeScript()}`;\n const head = /<head\\b[^>]*>/i.exec(html);\n return head ? html.replace(head[0], (tag) => `${tag}${shims}`) : `${shims}${html}`;\n}\n\n/**\n * Generate two or three HTML candidates side by side and adopt one (the rest are cancelled) or\n * discard the set. Logic lives in `useCreationVariants`; the host passes transport and storage.\n * Key the component by identity, project and artifact so a switch starts fresh.\n */\nexport function CreationVariantCompare({\n client,\n projectId,\n kind,\n artifactId,\n expectedRevisionId,\n storageKey,\n storage,\n locale,\n initialIntent = \"\",\n onAdopted,\n pollMs,\n disabled = false,\n}: CreationVariantCompareProps) {\n const t = creationBlockMessages(locale);\n const id = useId();\n const variants = useCreationVariants({\n client,\n projectId,\n storageKey,\n ...(storage ? { storage } : {}),\n ...(locale ? { locale } : {}),\n ...(pollMs ? { pollMs } : {}),\n });\n const [intent, setIntent] = useState(initialIntent);\n // Rows keep a stable key so removing one does not remount the others.\n const [rows, setRows] = useState<{ key: number; direction: CreationVariantDirection }[] | null>(\n null,\n );\n const nextKey = useRef(3);\n const shownRows =\n rows ??\n defaultVariantDirections(variants.designs).map((direction, key) => ({ key, direction }));\n const shown = shownRows.map((row) => row.direction);\n const update = (index: number, direction: CreationVariantDirection) =>\n setRows(shownRows.map((row, position) => (position === index ? { ...row, direction } : row)));\n\n const adoptedRevisionId = variants.adoptedRevisionId;\n useEffect(() => {\n if (adoptedRevisionId) onAdopted?.(adoptedRevisionId);\n }, [adoptedRevisionId, onAdopted]);\n\n const selection = (direction: CreationVariantDirection) =>\n direction.designMdId ?? (direction.text !== undefined ? CUSTOM : PROJECT);\n\n return (\n <section aria-label={t.variantsTitle} className=\"flex flex-col gap-3 rounded-lg border p-4\">\n <h2 className=\"text-sm font-semibold\">{t.variantsTitle}</h2>\n {variants.message && (\n <p role=\"status\" className=\"text-sm\">\n {variants.message}\n </p>\n )}\n {variants.phase === \"idle\" && (\n <form\n className=\"flex flex-col gap-3\"\n onSubmit={(event) => {\n event.preventDefault();\n void variants.start({\n kind,\n intent,\n ...(artifactId ? { artifactId } : {}),\n ...(expectedRevisionId !== undefined ? { expectedRevisionId } : {}),\n directions: shown,\n });\n }}\n >\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-intent`}>{t.variantsIntentLabel}</Label>\n <Textarea\n id={`${id}-intent`}\n value={intent}\n onChange={(event) => setIntent(event.target.value)}\n />\n </div>\n {shownRows.map(({ key, direction }, index) => (\n <div key={key} className=\"flex flex-wrap items-end gap-2\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-direction-${index}`}>\n {t.variantDirectionLabel(index + 1)}\n </Label>\n <select\n id={`${id}-direction-${index}`}\n className={FIELD_CLASS}\n value={selection(direction)}\n onChange={(event) => {\n const value = event.target.value;\n update(\n index,\n value === PROJECT\n ? {}\n : value === CUSTOM\n ? { text: \"\" }\n : { designMdId: value },\n );\n }}\n >\n <option value={PROJECT}>{t.variantProjectDesign}</option>\n {variants.designs.map((design) => (\n <option key={design.id} value={design.id}>\n {design.title}\n </option>\n ))}\n <option value={CUSTOM}>{t.variantCustomDirection}</option>\n </select>\n </div>\n {direction.text !== undefined && (\n <Input\n aria-label={t.variantDirectionText(index + 1)}\n value={direction.text}\n onChange={(event) => update(index, { text: event.target.value })}\n />\n )}\n {shown.length > 2 && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() => setRows(shownRows.filter((_, position) => position !== index))}\n >\n {t.removeVariant(index + 1)}\n </Button>\n )}\n </div>\n ))}\n <div className=\"flex flex-wrap gap-2\">\n {shown.length < 3 && (\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => setRows([...shownRows, { key: nextKey.current++, direction: {} }])}\n >\n {t.addVariant}\n </Button>\n )}\n <Button\n type=\"submit\"\n disabled={\n disabled ||\n variants.busy ||\n !intent.trim() ||\n shown.some((direction) => direction.text !== undefined && !direction.text.trim())\n }\n >\n {t.generateVariants(shown.length)}\n </Button>\n </div>\n </form>\n )}\n {(variants.phase === \"generating\" || variants.phase === \"choosing\") && (\n <>\n <div\n className=\"grid gap-3\"\n style={{ gridTemplateColumns: `repeat(${variants.candidates.length}, minmax(0, 1fr))` }}\n >\n {variants.candidates.map((candidate) => (\n <article\n key={candidate.requestId}\n aria-label={t.variantColumn(candidate.index + 1)}\n className=\"flex min-w-0 flex-col gap-2\"\n >\n <header className=\"flex items-center justify-between gap-2 text-sm\">\n <span className=\"font-medium\">{t.variantColumn(candidate.index + 1)}</span>\n <span className=\"text-muted-foreground\">\n {t.variantStatus[candidate.status] ?? candidate.status}\n </span>\n </header>\n {candidate.html ? (\n <iframe\n title={t.variantPreview(candidate.index + 1)}\n sandbox=\"allow-scripts\"\n srcDoc={previewDocument(candidate.html)}\n className=\"h-80 w-full rounded-md border bg-background\"\n />\n ) : (\n <div className=\"flex h-80 items-center justify-center rounded-md border text-sm text-muted-foreground\">\n {candidate.error ?? \"\"}\n </div>\n )}\n {candidate.status === \"held\" && candidate.runId && (\n <Button\n type=\"button\"\n disabled={disabled || variants.busy}\n onClick={() => candidate.runId && void variants.adopt(candidate.runId)}\n >\n {t.adoptVariant(candidate.index + 1)}\n </Button>\n )}\n </article>\n ))}\n </div>\n <div className=\"flex flex-wrap gap-2\">\n {variants.candidates.some((candidate) => candidate.status === \"unknown\") && (\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={variants.busy}\n onClick={() => void variants.retrySend()}\n >\n {t.retryVariants}\n </Button>\n )}\n <Button\n type=\"button\"\n variant=\"outline\"\n disabled={variants.busy}\n onClick={() => void variants.discard()}\n >\n {t.discardVariants}\n </Button>\n </div>\n </>\n )}\n {(variants.phase === \"adopted\" || variants.phase === \"discarded\") && (\n <div className=\"flex flex-wrap items-center gap-3 text-sm\">\n <p role=\"status\">\n {variants.phase === \"adopted\" ? t.variantsAdopted : t.variantsDiscarded}\n </p>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => {\n setRows(null);\n variants.reset();\n }}\n >\n {t.newVariantSet}\n </Button>\n </div>\n )}\n </section>\n );\n}\n",
24
+ "type": "registry:component"
25
+ }
26
+ ],
27
+ "meta": {
28
+ "composite": true,
29
+ "channel": "public"
30
+ }
31
+ }
@@ -5,8 +5,9 @@
5
5
  "description": "Manual HTML creation workspace (projects, artifacts, CAS saves with a conflict step, generation, export) over useCreationWorkspace; the host renders the editor.",
6
6
  "dependencies": [
7
7
  "react",
8
- "@uibot/contracts@^0.14.0",
9
- "@uibot/creation-kit@^0.14.0"
8
+ "@uibot/contracts@^0.15.1",
9
+ "@uibot/creation-kit@^0.15.1",
10
+ "@uibot/web-preview@^0.15.1"
10
11
  ],
11
12
  "registryDependencies": [
12
13
  "button",
@@ -16,13 +17,14 @@
16
17
  "@uibot/creation-shared",
17
18
  "@uibot/creation-html-generation",
18
19
  "@uibot/creation-reference-generation",
19
- "@uibot/creation-revision-export"
20
+ "@uibot/creation-revision-export",
21
+ "@uibot/creation-variant-compare"
20
22
  ],
21
23
  "files": [
22
24
  {
23
25
  "path": "components/uibot/creation/creation-workspace.tsx",
24
26
  "target": "components/uibot/creation/creation-workspace.tsx",
25
- "content": "import { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { Textarea } from \"@/components/ui/textarea\";\nimport type { CreationContent } from \"@uibot/contracts\";\nimport {\n type CreationClient,\n type CreationLocale,\n type CreationWorkspaceClient,\n type CreationWorkspaceSaveInput,\n type CreationWorkspaceSaveResult,\n useCreationWorkspace,\n} from \"@uibot/creation-kit\";\nimport { Fragment, type ReactNode, useId, useState } from \"react\";\nimport { CreationHtmlGeneration } from \"./creation-html-generation\";\nimport { CreationReferenceGeneration } from \"./creation-reference-generation\";\nimport {\n CreationRevisionExport,\n type CreationRevisionExportProps,\n} from \"./creation-revision-export\";\nimport { creationBlockMessages, FIELD_CLASS } from \"./creation-shared\";\n\n/** What the host's editor receives; `HtmlSourceEditor` from `@uibot/renderer-react` accepts it. */\nexport interface CreationWorkspaceEditorProps {\n projectId: string;\n artifactId: string;\n title: string;\n revision: { id: string; number: number };\n source: CreationContent;\n onDirty: (dirty: boolean) => void;\n saveRevision: (input: CreationWorkspaceSaveInput) => Promise<CreationWorkspaceSaveResult>;\n renderSaveAction: (action: { disabled: boolean; onSave: () => void }) => ReactNode;\n}\n\nexport interface CreationWorkspaceProps {\n client: CreationWorkspaceClient & Pick<CreationClient, \"startRun\">;\n exportRevision: CreationRevisionExportProps[\"exportRevision\"];\n /** Run reservation key for a project; scope it to the signed-in identity. */\n runStorageKey: (projectId: string) => string;\n /** Changes when the signed-in actor or tenant changes. Hosts with sign-in must pass it. */\n authority?: () => string;\n /** Identity the export block binds a download to. */\n sessionIdentity: string;\n isSessionCurrent?: () => boolean;\n locale?: CreationLocale;\n /** The host's HTML editor (preview transport, data bridge); usually `HtmlSourceEditor`. */\n renderEditor: (editor: CreationWorkspaceEditorProps) => ReactNode;\n initialSource?: string;\n /** Host overlays rendered inside the workspace (e.g. approval dialogs). */\n children?: ReactNode;\n}\n\n/**\n * Manual HTML creation workspace: projects, artifacts, saved revisions, generation and export.\n * State lives in `useCreationWorkspace`; key the component by identity/tenant so a switch starts\n * a fresh workspace.\n */\nexport function CreationWorkspace({\n client,\n exportRevision,\n runStorageKey,\n authority,\n sessionIdentity,\n isSessionCurrent,\n locale,\n renderEditor,\n initialSource = \"<main>\\n <h1>My page</h1>\\n</main>\",\n children,\n}: CreationWorkspaceProps) {\n const t = creationBlockMessages(locale);\n const id = useId();\n const workspace = useCreationWorkspace({ client, ...(locale ? { locale } : {}) });\n const [showCreateProject, setShowCreateProject] = useState(false);\n const [projectTitle, setProjectTitle] = useState(\"\");\n const [artifactTitle, setArtifactTitle] = useState(\"\");\n const [newSource, setNewSource] = useState(initialSource);\n const {\n project,\n selectedArtifact,\n selectedRevision,\n enabledDomain,\n busy,\n refreshingDomains,\n generationPending,\n editorDirty,\n } = workspace;\n const runProps = {\n client,\n ...(authority ? { authority } : {}),\n ...(locale ? { locale } : {}),\n };\n\n if (workspace.status !== \"ready\")\n return (\n <section aria-label={t.workspaceLabel}>\n {workspace.status === \"loading\" ? (\n <p>{t.workspaceLoading}</p>\n ) : (\n <p role=\"alert\">{t.workspaceLoadFailed}</p>\n )}\n </section>\n );\n\n return (\n <section\n aria-label={t.workspaceLabel}\n data-testid=\"creation-workspace\"\n className=\"mx-auto flex max-w-6xl flex-col gap-4 p-6\"\n >\n <header className=\"flex items-center justify-between gap-4\">\n <div>\n <p className=\"text-xs text-muted-foreground\">{t.workspaceEyebrow}</p>\n <h1 className=\"text-xl font-semibold\">{t.workspaceLabel}</h1>\n </div>\n <Button type=\"button\" onClick={() => setShowCreateProject(true)} disabled={busy}>\n {t.newProject}\n </Button>\n </header>\n {workspace.message && (\n <p role=\"status\" className=\"text-sm\">\n {workspace.message}\n </p>\n )}\n {workspace.conflict && (\n <div role=\"alert\" className=\"flex items-center gap-3 text-sm\">\n <span>{t.conflict}</span>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void workspace.rereadProject()}\n disabled={busy}\n >\n {t.reread}\n </Button>\n </div>\n )}\n {showCreateProject && (\n <form\n onSubmit={(event) => {\n event.preventDefault();\n void workspace.createProject(projectTitle).then((created) => {\n if (!created) return;\n setShowCreateProject(false);\n setProjectTitle(\"\");\n });\n }}\n className=\"flex flex-wrap items-end gap-2\"\n >\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-project-title`}>{t.projectTitleLabel}</Label>\n <Input\n id={`${id}-project-title`}\n aria-label={t.projectTitleLabel}\n value={projectTitle}\n onChange={(event) => setProjectTitle(event.target.value)}\n />\n </div>\n <Button type=\"submit\" disabled={busy || !projectTitle.trim()}>\n {t.createProject}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setShowCreateProject(false)}>\n {t.cancel}\n </Button>\n </form>\n )}\n {!!workspace.projects.length && (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-project`}>{t.selectProjectLabel}</Label>\n <select\n id={`${id}-project`}\n aria-label={t.selectProjectLabel}\n className={FIELD_CLASS}\n value={project?.id ?? \"\"}\n disabled={busy}\n onChange={(event) => void workspace.selectProject(event.target.value)}\n >\n {workspace.projects.map((item) => (\n <option key={item.id} value={item.id}>\n {item.title}\n </option>\n ))}\n </select>\n </div>\n )}\n {project && (\n <>\n <CreationHtmlGeneration\n key={`html-generation:${project.id}`}\n {...runProps}\n storageKey={runStorageKey(project.id)}\n project={project}\n capabilities={workspace.capabilities}\n artifact={selectedArtifact}\n dirty={editorDirty}\n busy={busy || refreshingDomains}\n onPending={(pending) => workspace.setGenerationPending(\"html\", pending)}\n onProject={workspace.applyProject}\n />\n <CreationReferenceGeneration\n key={`reference-generation:${project.id}`}\n {...runProps}\n storageKey={runStorageKey(project.id)}\n project={project}\n capabilities={workspace.capabilities}\n dirty={editorDirty}\n busy={busy || refreshingDomains}\n onPending={(pending) => workspace.setGenerationPending(\"reference\", pending)}\n onProject={workspace.applyProject}\n />\n <div className=\"flex flex-wrap items-end gap-3 rounded-lg border p-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-artifact-title`}>{t.artifactTitleLabel}</Label>\n <Input\n id={`${id}-artifact-title`}\n aria-label={t.artifactTitleLabel}\n value={artifactTitle}\n onChange={(event) => setArtifactTitle(event.target.value)}\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-artifact-kind`}>{t.artifactKindLabel}</Label>\n <select\n id={`${id}-artifact-kind`}\n aria-label={t.artifactKindLabel}\n className={FIELD_CLASS}\n value={workspace.selectedDomainKind}\n onChange={(event) => workspace.selectDomain(event.target.value)}\n disabled={!workspace.domains.length || busy || refreshingDomains}\n >\n {workspace.selectedDomainKind && !enabledDomain && (\n <option value={workspace.selectedDomainKind} disabled>\n {t.unavailableKindOption(workspace.selectedDomainKind)}\n </option>\n )}\n {workspace.domains.map((domain) => (\n <option\n key={`${domain.artifactKind}:${domain.version}`}\n value={domain.artifactKind}\n >\n {domain.title}\n </option>\n ))}\n </select>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void workspace.refreshDomains()}\n disabled={busy || refreshingDomains || editorDirty || generationPending}\n >\n {refreshingDomains ? t.refreshingCapabilities : t.refreshCapabilities}\n </Button>\n <Button\n type=\"button\"\n onClick={() =>\n void workspace\n .appendArtifact({\n title: artifactTitle,\n source: { format: \"html\", schemaVersion: \"1\", content: newSource },\n })\n .then((appended) => {\n if (appended) setArtifactTitle(\"\");\n })\n }\n disabled={\n busy ||\n refreshingDomains ||\n generationPending ||\n !workspace.capabilitiesFresh ||\n !enabledDomain ||\n !artifactTitle.trim()\n }\n >\n {t.appendArtifact}\n </Button>\n </div>\n {workspace.selectedDomainKind && !enabledDomain && (\n <p role=\"status\" className=\"text-sm text-muted-foreground\">\n {t.kindUnavailable(workspace.selectedDomainKind)}\n </p>\n )}\n {!workspace.domains.length && (\n <p role=\"status\" className=\"text-sm text-muted-foreground\">\n {t.noHtmlDomains}\n </p>\n )}\n {!selectedArtifact && (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-source`}>{t.htmlContentLabel}</Label>\n <Textarea\n id={`${id}-source`}\n aria-label={t.htmlContentLabel}\n value={newSource}\n onChange={(event) => setNewSource(event.target.value)}\n disabled={busy}\n />\n </div>\n )}\n {selectedArtifact && selectedRevision?.source.format === \"html\" && (\n <fieldset\n disabled={refreshingDomains || generationPending}\n className=\"m-0 min-w-0 border-0 p-0\"\n >\n <Fragment\n key={`${project.id}:${selectedArtifact.id}:${workspace.editorResetGeneration}`}\n >\n {renderEditor({\n projectId: project.id,\n artifactId: selectedArtifact.id,\n title: selectedArtifact.title,\n revision: { id: selectedRevision.id, number: selectedRevision.number },\n source: selectedRevision.source,\n onDirty: workspace.setEditorDirty,\n saveRevision: workspace.saveRevision,\n renderSaveAction: ({ disabled, onSave }) => (\n <Button\n type=\"button\"\n onClick={onSave}\n disabled={disabled || busy || refreshingDomains || generationPending}\n >\n {t.saveRevision}\n </Button>\n ),\n })}\n </Fragment>\n </fieldset>\n )}\n {selectedArtifact && selectedRevision && (\n <>\n <fieldset\n aria-label={t.savedRevisionsLabel}\n className=\"m-0 flex min-w-0 flex-wrap gap-2 border-0 p-0\"\n >\n {selectedArtifact.revisions.map((revision) => (\n <Button\n key={revision.id}\n type=\"button\"\n variant=\"outline\"\n aria-pressed={\n (workspace.exportRevisionId || selectedRevision.id) === revision.id\n }\n onClick={() => workspace.selectExportRevision(revision.id)}\n disabled={busy}\n >\n {t.historyRevision(revision.number)}\n </Button>\n ))}\n </fieldset>\n <CreationRevisionExport\n client={client}\n exportRevision={exportRevision}\n {...(locale ? { locale } : {})}\n project={project}\n artifact={selectedArtifact}\n storageKey={runStorageKey(project.id)}\n sessionIdentity={sessionIdentity}\n {...(isSessionCurrent ? { isSessionCurrent } : {})}\n onProject={(updated) => workspace.applyProject(updated)}\n revision={\n selectedArtifact.revisions.find(\n (revision) => revision.id === workspace.exportRevisionId,\n ) ?? selectedRevision\n }\n dirty={editorDirty || busy || refreshingDomains || generationPending}\n />\n </>\n )}\n </>\n )}\n {children}\n </section>\n );\n}\n",
27
+ "content": "import { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { Textarea } from \"@/components/ui/textarea\";\nimport type { CreationContent } from \"@uibot/contracts\";\nimport {\n type CreationClient,\n type CreationLocale,\n type CreationWorkspaceClient,\n type CreationWorkspaceSaveInput,\n type CreationWorkspaceSaveResult,\n useCreationWorkspace,\n} from \"@uibot/creation-kit\";\nimport { Fragment, type ReactNode, useId, useState } from \"react\";\nimport { CreationHtmlGeneration } from \"./creation-html-generation\";\nimport { CreationReferenceGeneration } from \"./creation-reference-generation\";\nimport { CreationVariantCompare } from \"./creation-variant-compare\";\nimport {\n CreationRevisionExport,\n type CreationRevisionExportProps,\n} from \"./creation-revision-export\";\nimport { creationBlockMessages, FIELD_CLASS } from \"./creation-shared\";\n\n/** What the host's editor receives; `HtmlSourceEditor` from `@uibot/renderer-react` accepts it. */\nexport interface CreationWorkspaceEditorProps {\n projectId: string;\n artifactId: string;\n title: string;\n revision: { id: string; number: number };\n source: CreationContent;\n onDirty: (dirty: boolean) => void;\n saveRevision: (input: CreationWorkspaceSaveInput) => Promise<CreationWorkspaceSaveResult>;\n renderSaveAction: (action: { disabled: boolean; onSave: () => void }) => ReactNode;\n}\n\nexport interface CreationWorkspaceProps {\n client: CreationWorkspaceClient &\n Pick<\n CreationClient,\n \"startRun\" | \"adoptVariant\" | \"discardVariantGroup\" | \"listVariantDesigns\"\n >;\n exportRevision: CreationRevisionExportProps[\"exportRevision\"];\n /** Run reservation key for a project; scope it to the signed-in identity. */\n runStorageKey: (projectId: string) => string;\n /** Changes when the signed-in actor or tenant changes. Hosts with sign-in must pass it. */\n authority?: () => string;\n /** Identity the export block binds a download to. */\n sessionIdentity: string;\n isSessionCurrent?: () => boolean;\n locale?: CreationLocale;\n /** The host's HTML editor (preview transport, data bridge); usually `HtmlSourceEditor`. */\n renderEditor: (editor: CreationWorkspaceEditorProps) => ReactNode;\n initialSource?: string;\n /** Host overlays rendered inside the workspace (e.g. approval dialogs). */\n children?: ReactNode;\n}\n\n/**\n * Manual HTML creation workspace: projects, artifacts, saved revisions, generation and export.\n * State lives in `useCreationWorkspace`; key the component by identity/tenant so a switch starts\n * a fresh workspace.\n */\nexport function CreationWorkspace({\n client,\n exportRevision,\n runStorageKey,\n authority,\n sessionIdentity,\n isSessionCurrent,\n locale,\n renderEditor,\n initialSource = \"<main>\\n <h1>My page</h1>\\n</main>\",\n children,\n}: CreationWorkspaceProps) {\n const t = creationBlockMessages(locale);\n const id = useId();\n const workspace = useCreationWorkspace({ client, ...(locale ? { locale } : {}) });\n const [showCreateProject, setShowCreateProject] = useState(false);\n const [projectTitle, setProjectTitle] = useState(\"\");\n const [artifactTitle, setArtifactTitle] = useState(\"\");\n const [newSource, setNewSource] = useState(initialSource);\n const {\n project,\n selectedArtifact,\n selectedRevision,\n enabledDomain,\n busy,\n refreshingDomains,\n generationPending,\n editorDirty,\n } = workspace;\n // Variants generate HTML: for the selected artifact, or a new artifact of the chosen kind.\n const variantKind = selectedArtifact\n ? selectedRevision?.source.format === \"html\"\n ? selectedArtifact.kind\n : undefined\n : enabledDomain?.artifactKind;\n const runProps = {\n client,\n ...(authority ? { authority } : {}),\n ...(locale ? { locale } : {}),\n };\n\n if (workspace.status !== \"ready\")\n return (\n <section aria-label={t.workspaceLabel}>\n {workspace.status === \"loading\" ? (\n <p>{t.workspaceLoading}</p>\n ) : (\n <p role=\"alert\">{t.workspaceLoadFailed}</p>\n )}\n </section>\n );\n\n return (\n <section\n aria-label={t.workspaceLabel}\n data-testid=\"creation-workspace\"\n className=\"mx-auto flex max-w-6xl flex-col gap-4 p-6\"\n >\n <header className=\"flex items-center justify-between gap-4\">\n <div>\n <p className=\"text-xs text-muted-foreground\">{t.workspaceEyebrow}</p>\n <h1 className=\"text-xl font-semibold\">{t.workspaceLabel}</h1>\n </div>\n <Button type=\"button\" onClick={() => setShowCreateProject(true)} disabled={busy}>\n {t.newProject}\n </Button>\n </header>\n {workspace.message && (\n <p role=\"status\" className=\"text-sm\">\n {workspace.message}\n </p>\n )}\n {workspace.conflict && (\n <div role=\"alert\" className=\"flex items-center gap-3 text-sm\">\n <span>{t.conflict}</span>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void workspace.rereadProject()}\n disabled={busy}\n >\n {t.reread}\n </Button>\n </div>\n )}\n {showCreateProject && (\n <form\n onSubmit={(event) => {\n event.preventDefault();\n void workspace.createProject(projectTitle).then((created) => {\n if (!created) return;\n setShowCreateProject(false);\n setProjectTitle(\"\");\n });\n }}\n className=\"flex flex-wrap items-end gap-2\"\n >\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-project-title`}>{t.projectTitleLabel}</Label>\n <Input\n id={`${id}-project-title`}\n aria-label={t.projectTitleLabel}\n value={projectTitle}\n onChange={(event) => setProjectTitle(event.target.value)}\n />\n </div>\n <Button type=\"submit\" disabled={busy || !projectTitle.trim()}>\n {t.createProject}\n </Button>\n <Button type=\"button\" variant=\"outline\" onClick={() => setShowCreateProject(false)}>\n {t.cancel}\n </Button>\n </form>\n )}\n {!!workspace.projects.length && (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-project`}>{t.selectProjectLabel}</Label>\n <select\n id={`${id}-project`}\n aria-label={t.selectProjectLabel}\n className={FIELD_CLASS}\n value={project?.id ?? \"\"}\n disabled={busy}\n onChange={(event) => void workspace.selectProject(event.target.value)}\n >\n {workspace.projects.map((item) => (\n <option key={item.id} value={item.id}>\n {item.title}\n </option>\n ))}\n </select>\n </div>\n )}\n {project && (\n <>\n <CreationHtmlGeneration\n key={`html-generation:${project.id}`}\n {...runProps}\n storageKey={runStorageKey(project.id)}\n project={project}\n capabilities={workspace.capabilities}\n artifact={selectedArtifact}\n dirty={editorDirty}\n busy={busy || refreshingDomains}\n onPending={(pending) => workspace.setGenerationPending(\"html\", pending)}\n onProject={workspace.applyProject}\n />\n <CreationReferenceGeneration\n key={`reference-generation:${project.id}`}\n {...runProps}\n storageKey={runStorageKey(project.id)}\n project={project}\n capabilities={workspace.capabilities}\n dirty={editorDirty}\n busy={busy || refreshingDomains}\n onPending={(pending) => workspace.setGenerationPending(\"reference\", pending)}\n onProject={workspace.applyProject}\n />\n {variantKind && (\n <CreationVariantCompare\n key={`variants:${project.id}:${selectedArtifact?.id ?? \"new\"}:${selectedArtifact?.currentRevisionId ?? \"\"}`}\n client={client}\n projectId={project.id}\n kind={variantKind}\n {...(selectedArtifact\n ? {\n artifactId: selectedArtifact.id,\n expectedRevisionId: selectedArtifact.currentRevisionId,\n }\n : {})}\n storageKey={`${runStorageKey(project.id)}:variants`}\n {...(typeof window === \"undefined\" ? {} : { storage: window.localStorage })}\n {...(locale ? { locale } : {})}\n disabled={editorDirty || busy || refreshingDomains || generationPending}\n onAdopted={(revisionId) =>\n void client\n .getProject(project.id)\n .then((updated) =>\n workspace.applyProject(\n updated,\n updated.artifacts.find((artifact) =>\n artifact.revisions.some((revision) => revision.id === revisionId),\n )?.id,\n ),\n )\n }\n />\n )}\n <div className=\"flex flex-wrap items-end gap-3 rounded-lg border p-4\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-artifact-title`}>{t.artifactTitleLabel}</Label>\n <Input\n id={`${id}-artifact-title`}\n aria-label={t.artifactTitleLabel}\n value={artifactTitle}\n onChange={(event) => setArtifactTitle(event.target.value)}\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-artifact-kind`}>{t.artifactKindLabel}</Label>\n <select\n id={`${id}-artifact-kind`}\n aria-label={t.artifactKindLabel}\n className={FIELD_CLASS}\n value={workspace.selectedDomainKind}\n onChange={(event) => workspace.selectDomain(event.target.value)}\n disabled={!workspace.domains.length || busy || refreshingDomains}\n >\n {workspace.selectedDomainKind && !enabledDomain && (\n <option value={workspace.selectedDomainKind} disabled>\n {t.unavailableKindOption(workspace.selectedDomainKind)}\n </option>\n )}\n {workspace.domains.map((domain) => (\n <option\n key={`${domain.artifactKind}:${domain.version}`}\n value={domain.artifactKind}\n >\n {domain.title}\n </option>\n ))}\n </select>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n onClick={() => void workspace.refreshDomains()}\n disabled={busy || refreshingDomains || editorDirty || generationPending}\n >\n {refreshingDomains ? t.refreshingCapabilities : t.refreshCapabilities}\n </Button>\n <Button\n type=\"button\"\n onClick={() =>\n void workspace\n .appendArtifact({\n title: artifactTitle,\n source: { format: \"html\", schemaVersion: \"1\", content: newSource },\n })\n .then((appended) => {\n if (appended) setArtifactTitle(\"\");\n })\n }\n disabled={\n busy ||\n refreshingDomains ||\n generationPending ||\n !workspace.capabilitiesFresh ||\n !enabledDomain ||\n !artifactTitle.trim()\n }\n >\n {t.appendArtifact}\n </Button>\n </div>\n {workspace.selectedDomainKind && !enabledDomain && (\n <p role=\"status\" className=\"text-sm text-muted-foreground\">\n {t.kindUnavailable(workspace.selectedDomainKind)}\n </p>\n )}\n {!workspace.domains.length && (\n <p role=\"status\" className=\"text-sm text-muted-foreground\">\n {t.noHtmlDomains}\n </p>\n )}\n {!selectedArtifact && (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-source`}>{t.htmlContentLabel}</Label>\n <Textarea\n id={`${id}-source`}\n aria-label={t.htmlContentLabel}\n value={newSource}\n onChange={(event) => setNewSource(event.target.value)}\n disabled={busy}\n />\n </div>\n )}\n {selectedArtifact && selectedRevision?.source.format === \"html\" && (\n <fieldset\n disabled={refreshingDomains || generationPending}\n className=\"m-0 min-w-0 border-0 p-0\"\n >\n <Fragment\n key={`${project.id}:${selectedArtifact.id}:${workspace.editorResetGeneration}`}\n >\n {renderEditor({\n projectId: project.id,\n artifactId: selectedArtifact.id,\n title: selectedArtifact.title,\n revision: { id: selectedRevision.id, number: selectedRevision.number },\n source: selectedRevision.source,\n onDirty: workspace.setEditorDirty,\n saveRevision: workspace.saveRevision,\n renderSaveAction: ({ disabled, onSave }) => (\n <Button\n type=\"button\"\n onClick={onSave}\n disabled={disabled || busy || refreshingDomains || generationPending}\n >\n {t.saveRevision}\n </Button>\n ),\n })}\n </Fragment>\n </fieldset>\n )}\n {selectedArtifact && selectedRevision && (\n <>\n <fieldset\n aria-label={t.savedRevisionsLabel}\n className=\"m-0 flex min-w-0 flex-wrap gap-2 border-0 p-0\"\n >\n {selectedArtifact.revisions.map((revision) => (\n <Button\n key={revision.id}\n type=\"button\"\n variant=\"outline\"\n aria-pressed={\n (workspace.exportRevisionId || selectedRevision.id) === revision.id\n }\n onClick={() => workspace.selectExportRevision(revision.id)}\n disabled={busy}\n >\n {t.historyRevision(revision.number)}\n </Button>\n ))}\n </fieldset>\n <CreationRevisionExport\n client={client}\n exportRevision={exportRevision}\n {...(locale ? { locale } : {})}\n project={project}\n artifact={selectedArtifact}\n storageKey={runStorageKey(project.id)}\n sessionIdentity={sessionIdentity}\n {...(isSessionCurrent ? { isSessionCurrent } : {})}\n onProject={(updated) => workspace.applyProject(updated)}\n revision={\n selectedArtifact.revisions.find(\n (revision) => revision.id === workspace.exportRevisionId,\n ) ?? selectedRevision\n }\n dirty={editorDirty || busy || refreshingDomains || generationPending}\n />\n </>\n )}\n </>\n )}\n {children}\n </section>\n );\n}\n",
26
28
  "type": "registry:component"
27
29
  }
28
30
  ],
@@ -541,8 +541,8 @@
541
541
  "registryDependencies": [],
542
542
  "dependencies": [
543
543
  "react",
544
- "@uibot/contracts@^0.14.0",
545
- "@uibot/creation-kit@^0.14.0"
544
+ "@uibot/contracts@^0.15.1",
545
+ "@uibot/creation-kit@^0.15.1"
546
546
  ]
547
547
  },
548
548
  {
@@ -557,8 +557,8 @@
557
557
  ],
558
558
  "dependencies": [
559
559
  "react",
560
- "@uibot/contracts@^0.14.0",
561
- "@uibot/creation-kit@^0.14.0"
560
+ "@uibot/contracts@^0.15.1",
561
+ "@uibot/creation-kit@^0.15.1"
562
562
  ]
563
563
  },
564
564
  {
@@ -573,8 +573,8 @@
573
573
  ],
574
574
  "dependencies": [
575
575
  "react",
576
- "@uibot/contracts@^0.14.0",
577
- "@uibot/creation-kit@^0.14.0"
576
+ "@uibot/contracts@^0.15.1",
577
+ "@uibot/creation-kit@^0.15.1"
578
578
  ]
579
579
  },
580
580
  {
@@ -587,8 +587,26 @@
587
587
  ],
588
588
  "dependencies": [
589
589
  "react",
590
- "@uibot/contracts@^0.14.0",
591
- "@uibot/creation-kit@^0.14.0"
590
+ "@uibot/contracts@^0.15.1",
591
+ "@uibot/creation-kit@^0.15.1"
592
+ ]
593
+ },
594
+ {
595
+ "name": "creation-variant-compare",
596
+ "type": "registry:block",
597
+ "description": "Generate two or three HTML candidates side by side (project design, design guides or custom directions) and adopt one as the next revision, over useCreationVariants.",
598
+ "registryDependencies": [
599
+ "button",
600
+ "input",
601
+ "label",
602
+ "textarea",
603
+ "@uibot/creation-shared"
604
+ ],
605
+ "dependencies": [
606
+ "react",
607
+ "@uibot/contracts@^0.15.1",
608
+ "@uibot/creation-kit@^0.15.1",
609
+ "@uibot/web-preview@^0.15.1"
592
610
  ]
593
611
  },
594
612
  {
@@ -603,12 +621,14 @@
603
621
  "@uibot/creation-shared",
604
622
  "@uibot/creation-html-generation",
605
623
  "@uibot/creation-reference-generation",
606
- "@uibot/creation-revision-export"
624
+ "@uibot/creation-revision-export",
625
+ "@uibot/creation-variant-compare"
607
626
  ],
608
627
  "dependencies": [
609
628
  "react",
610
- "@uibot/contracts@^0.14.0",
611
- "@uibot/creation-kit@^0.14.0"
629
+ "@uibot/contracts@^0.15.1",
630
+ "@uibot/creation-kit@^0.15.1",
631
+ "@uibot/web-preview@^0.15.1"
612
632
  ]
613
633
  },
614
634
  {
@@ -618,7 +638,7 @@
618
638
  "registryDependencies": [],
619
639
  "dependencies": [
620
640
  "react",
621
- "@uibot/renderer-react@^0.14.0"
641
+ "@uibot/renderer-react@^0.15.1"
622
642
  ]
623
643
  },
624
644
  {
@@ -636,7 +656,7 @@
636
656
  ],
637
657
  "dependencies": [
638
658
  "react",
639
- "@uibot/renderer-react@^0.14.0",
659
+ "@uibot/renderer-react@^0.15.1",
640
660
  "cmdk@^1",
641
661
  "date-fns@^4",
642
662
  "lucide-react",
@@ -653,7 +673,7 @@
653
673
  ],
654
674
  "dependencies": [
655
675
  "react",
656
- "@uibot/renderer-react@^0.14.0"
676
+ "@uibot/renderer-react@^0.15.1"
657
677
  ]
658
678
  },
659
679
  {
@@ -667,7 +687,7 @@
667
687
  ],
668
688
  "dependencies": [
669
689
  "react",
670
- "@uibot/renderer-react@^0.14.0"
690
+ "@uibot/renderer-react@^0.15.1"
671
691
  ]
672
692
  },
673
693
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uibot/registry",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@uibot/contracts": "^0.14.0"
30
+ "@uibot/contracts": "^0.15.1"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "rm -rf dist tsconfig.tsbuildinfo && bun build --minify ./src/index.ts --outdir ./dist --format esm --target bun && bun x tsc -b",