@humain/ui 2.2.6 → 2.2.9
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/dist/index101.js +2 -2
- package/dist/index101.js.map +1 -1
- package/dist/index103.js +3 -3
- package/dist/index103.js.map +1 -1
- package/dist/index108.js +1 -1
- package/dist/index108.js.map +1 -1
- package/dist/index117.js +1 -1
- package/dist/index117.js.map +1 -1
- package/dist/index122.js +6 -6
- package/dist/index122.js.map +1 -1
- package/dist/index126.js +1 -1
- package/dist/index126.js.map +1 -1
- package/dist/index130.js +2 -2
- package/dist/index130.js.map +1 -1
- package/dist/index146.js +4 -4
- package/dist/index146.js.map +1 -1
- package/dist/index152.js +1 -1
- package/dist/index152.js.map +1 -1
- package/dist/index154.js +2 -2
- package/dist/index154.js.map +1 -1
- package/dist/index166.js +1 -1
- package/dist/index166.js.map +1 -1
- package/dist/index168.js +1 -1
- package/dist/index168.js.map +1 -1
- package/dist/index169.js +1 -1
- package/dist/index169.js.map +1 -1
- package/dist/index173.js +2 -2
- package/dist/index173.js.map +1 -1
- package/dist/index175.js +4 -4
- package/dist/index175.js.map +1 -1
- package/dist/index176.js +2 -2
- package/dist/index176.js.map +1 -1
- package/dist/index177.js +2 -2
- package/dist/index177.js.map +1 -1
- package/dist/index184.js +1 -1
- package/dist/index184.js.map +1 -1
- package/dist/index191.js +3 -3
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +2 -2
- package/dist/index192.js.map +1 -1
- package/dist/index201.js +2 -2
- package/dist/index201.js.map +1 -1
- package/dist/index204.js +4 -4
- package/dist/index204.js.map +1 -1
- package/dist/index228.js +1 -1
- package/dist/index228.js.map +1 -1
- package/dist/index229.js +1 -1
- package/dist/index229.js.map +1 -1
- package/dist/index24.js +2 -2
- package/dist/index24.js.map +1 -1
- package/dist/index5.js +1 -1
- package/dist/index5.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/wc/AICodeBlock.js +41 -41
- package/dist/wc/AICodeBlock.js.map +1 -1
- package/dist/wc/AIMermaidDiagram.js +7 -7
- package/dist/wc/AIMermaidDiagram.js.map +1 -1
- package/dist/wc/AIMessage.js +6 -6
- package/dist/wc/AIMessage.js.map +1 -1
- package/dist/wc/AISource.js +2 -2
- package/dist/wc/AISource.js.map +1 -1
- package/dist/wc/AIToolCall.js +1 -1
- package/dist/wc/AIToolCall.js.map +1 -1
- package/dist/wc/Breadcrumb.js +43 -43
- package/dist/wc/Breadcrumb.js.map +1 -1
- package/dist/wc/DropdownMenu.js +9 -9
- package/dist/wc/DropdownMenu.js.map +1 -1
- package/dist/wc/Kbd.js +22 -22
- package/dist/wc/Kbd.js.map +1 -1
- package/dist/wc/button.js +7 -7
- package/dist/wc/button.js.map +1 -1
- package/dist/wc/close-button.js +19 -19
- package/dist/wc/close-button.js.map +1 -1
- package/dist/wc/hf-ai-prompt-suggestion.js +14 -14
- package/dist/wc/hf-ai-prompt-suggestion.js.map +1 -1
- package/dist/wc/hf-ai-reasoning-block.js +13 -13
- package/dist/wc/hf-ai-reasoning-block.js.map +1 -1
- package/dist/wc/hf-ai-steps.js +53 -53
- package/dist/wc/hf-ai-steps.js.map +1 -1
- package/dist/wc/hf-ai-system-message.js +26 -26
- package/dist/wc/hf-ai-system-message.js.map +1 -1
- package/dist/wc/hf-code-snippet.js +35 -35
- package/dist/wc/hf-code-snippet.js.map +1 -1
- package/dist/wc/hf-command-menu.js +39 -39
- package/dist/wc/hf-command-menu.js.map +1 -1
- package/dist/wc/hf-data-table.js +3 -3
- package/dist/wc/hf-data-table.js.map +1 -1
- package/dist/wc/hf-display-value.js +50 -50
- package/dist/wc/hf-display-value.js.map +1 -1
- package/dist/wc/hf-nav-account-menu.js +5 -5
- package/dist/wc/hf-nav-account-menu.js.map +1 -1
- package/dist/wc/hf-rich-textarea.js +1 -1
- package/dist/wc/hf-rich-textarea.js.map +1 -1
- package/dist/wc/hf-steps.js +8 -8
- package/dist/wc/hf-steps.js.map +1 -1
- package/dist/wc/markdown-renderer.js +1 -1
- package/dist/wc/markdown-renderer.js.map +1 -1
- package/dist/wc/selection-group.js +26 -26
- package/dist/wc/selection-group.js.map +1 -1
- package/dist/wc/syntax-highlight.js +4 -4
- package/dist/wc/syntax-highlight.js.map +1 -1
- package/dist/wc/workflow-step-renderer.js +51 -51
- package/dist/wc/workflow-step-renderer.js.map +1 -1
- package/dist/wc-react/AICodeBlock.js +17 -17
- package/dist/wc-react/AICodeBlock.js.map +1 -1
- package/dist/wc-react/AIMermaidDiagram.js +16 -16
- package/dist/wc-react/AIMermaidDiagram.js.map +1 -1
- package/dist/wc-react/AIMessage.js +7 -7
- package/dist/wc-react/AIMessage.js.map +1 -1
- package/dist/wc-react/AISource.js +41 -41
- package/dist/wc-react/AISource.js.map +1 -1
- package/dist/wc-react/AIToolCall.js +6 -6
- package/dist/wc-react/AIToolCall.js.map +1 -1
- package/dist/wc-react/Breadcrumb.js +18 -18
- package/dist/wc-react/Breadcrumb.js.map +1 -1
- package/dist/wc-react/DropdownMenu.js +27 -27
- package/dist/wc-react/DropdownMenu.js.map +1 -1
- package/dist/wc-react/Kbd.js +17 -17
- package/dist/wc-react/Kbd.js.map +1 -1
- package/dist/wc-react/button.js +12 -12
- package/dist/wc-react/button.js.map +1 -1
- package/dist/wc-react/close-button.js +19 -19
- package/dist/wc-react/close-button.js.map +1 -1
- package/dist/wc-react/hf-ai-prompt-suggestion.js +1 -1
- package/dist/wc-react/hf-ai-prompt-suggestion.js.map +1 -1
- package/dist/wc-react/hf-ai-reasoning-block.js +1 -1
- package/dist/wc-react/hf-ai-reasoning-block.js.map +1 -1
- package/dist/wc-react/hf-ai-steps.js +33 -33
- package/dist/wc-react/hf-ai-steps.js.map +1 -1
- package/dist/wc-react/hf-ai-system-message.js +9 -9
- package/dist/wc-react/hf-ai-system-message.js.map +1 -1
- package/dist/wc-react/hf-code-snippet.js +3 -3
- package/dist/wc-react/hf-code-snippet.js.map +1 -1
- package/dist/wc-react/hf-command-menu.js +56 -56
- package/dist/wc-react/hf-command-menu.js.map +1 -1
- package/dist/wc-react/hf-data-table.js +3 -3
- package/dist/wc-react/hf-data-table.js.map +1 -1
- package/dist/wc-react/hf-display-value.js +58 -58
- package/dist/wc-react/hf-display-value.js.map +1 -1
- package/dist/wc-react/hf-nav-account-menu.js +7 -7
- package/dist/wc-react/hf-nav-account-menu.js.map +1 -1
- package/dist/wc-react/hf-rich-textarea.js +5 -5
- package/dist/wc-react/hf-rich-textarea.js.map +1 -1
- package/dist/wc-react/hf-steps.js +2 -2
- package/dist/wc-react/hf-steps.js.map +1 -1
- package/dist/wc-react/markdown-renderer.js +1 -1
- package/dist/wc-react/markdown-renderer.js.map +1 -1
- package/dist/wc-react/selection-group.js +7 -7
- package/dist/wc-react/selection-group.js.map +1 -1
- package/dist/wc-react/syntax-highlight.js +4 -4
- package/dist/wc-react/syntax-highlight.js.map +1 -1
- package/dist/wc-react/workflow-step-renderer.js +44 -44
- package/dist/wc-react/workflow-step-renderer.js.map +1 -1
- package/package.json +1 -1
- package/skills/humain-ui/SKILL.md +1 -1
- package/skills/humain-ui-wc/SKILL.md +1 -1
- package/skills/humain-ui-wc.skill +0 -0
- package/skills/humain-ui.skill +0 -0
- package/src/tokens.css +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-step-renderer.js","names":["__iconNode"],"sources":["../../../../../../../../../../../Users/akarim/Documents/test/humain_foundation_ui/node_modules/.bun/lucide-react@1.27.0+0f58469d5b3bd39f/node_modules/lucide-react/dist/esm/icons/loader.mjs","../../../../../../../../../../../Users/akarim/Documents/test/humain_foundation_ui/node_modules/.bun/lucide-react@1.27.0+0f58469d5b3bd39f/node_modules/lucide-react/dist/esm/icons/pause.mjs","../../src/components/organisms/ai/_shared/format-ai-duration.ts","../../src/components/organisms/ai/_shared/workflow-step-renderer.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.27.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m16.2 7.8 2.9-2.9\", key: \"r700ao\" }],\n [\"path\", { d: \"M18 12h4\", key: \"wj9ykh\" }],\n [\"path\", { d: \"m16.2 16.2 2.9 2.9\", key: \"1bxg5t\" }],\n [\"path\", { d: \"M12 18v4\", key: \"jadmvz\" }],\n [\"path\", { d: \"m4.9 19.1 2.9-2.9\", key: \"bwix9q\" }],\n [\"path\", { d: \"M2 12h4\", key: \"j09sii\" }],\n [\"path\", { d: \"m4.9 4.9 2.9 2.9\", key: \"giyufr\" }]\n];\nconst Loader = createLucideIcon(\"loader\", __iconNode);\n\nexport { __iconNode, Loader as default };\n//# sourceMappingURL=loader.mjs.map\n","/**\n * @license lucide-react v1.27.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { x: \"14\", y: \"3\", width: \"5\", height: \"18\", rx: \"1\", key: \"kaeet6\" }],\n [\"rect\", { x: \"5\", y: \"3\", width: \"5\", height: \"18\", rx: \"1\", key: \"1wsw3u\" }]\n];\nconst Pause = createLucideIcon(\"pause\", __iconNode);\n\nexport { __iconNode, Pause as default };\n//# sourceMappingURL=pause.mjs.map\n","export function formatAIDuration(durationMs: number): string {\n const normalizedMs = Math.max(0, Math.round(durationMs));\n if (normalizedMs < 1000) return `${normalizedMs}ms`;\n\n const totalSeconds = Math.round(normalizedMs / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n\n if (hours > 0) {\n return [hours ? `${hours}h` : '', minutes ? `${minutes}m` : '']\n .filter(Boolean)\n .join(' ');\n }\n if (minutes > 0) {\n return `${minutes}m${seconds ? ` ${seconds}s` : ''}`;\n }\n return `${totalSeconds}s`;\n}\n","import { cva } from 'class-variance-authority';\nimport {\n AlertCircle,\n Check,\n ChevronDown,\n ChevronRight,\n Loader,\n Pause,\n} from 'lucide-react';\nimport { AnimatePresence, motion, useReducedMotion } from 'motion/react';\nimport * as React from 'react';\nimport { assertNever, cn } from '@/lib/utils';\nimport { formatAIDuration } from './format-ai-duration';\n\nexport type WorkflowStepStatus =\n | 'pending'\n | 'running'\n | 'suspended'\n | 'completed'\n | 'error';\n\nexport type WorkflowStepAppearance = 'contained' | 'embedded' | 'timeline';\n\nexport interface WorkflowStepViewModel {\n id: string;\n title: string;\n description?: string;\n contextLabel?: string;\n status: WorkflowStepStatus;\n content?: React.ReactNode;\n durationMs?: number;\n error?: string;\n}\n\nexport interface WorkflowStepRendererProps {\n steps: readonly WorkflowStepViewModel[];\n appearance?: WorkflowStepAppearance;\n itemSlot?: string;\n expandable?: boolean;\n activeStepId?: string;\n expandedStepIds?: readonly string[];\n defaultExpandedStepIds?: readonly string[];\n onExpandedStepIdsChange?: (ids: readonly string[]) => void;\n className?: string;\n}\n\ninterface PrivateWorkflowStepRendererProps extends WorkflowStepRendererProps {\n renderItems?: boolean;\n}\n\nconst workflowStepItemStatusClasses = {\n pending: 'text-muted-foreground',\n running: 'text-primary',\n suspended: 'text-warning',\n completed: 'text-success',\n error: 'text-destructive',\n} as const satisfies Record<WorkflowStepStatus, string>;\n\nconst workflowStepIconStatusClasses = {\n pending: 'bg-accent text-muted-foreground',\n running: 'bg-primary/20 text-primary',\n suspended: 'bg-warning/20 text-warning',\n completed: 'bg-success/20 text-success',\n error: 'bg-destructive/20 text-destructive',\n} as const satisfies Record<WorkflowStepStatus, string>;\n\nexport const workflowStepItemVariants = cva(\n 'flex items-start gap-3 px-4 py-3 transition-colors motion-reduce:transition-none',\n {\n variants: {\n status: workflowStepItemStatusClasses,\n },\n defaultVariants: {\n status: 'pending',\n },\n },\n);\n\nexport const workflowStepIconVariants = cva(\n 'size-5 shrink-0 flex items-center justify-center rounded-full',\n {\n variants: {\n status: workflowStepIconStatusClasses,\n },\n defaultVariants: {\n status: 'pending',\n },\n },\n);\n\nconst workflowStepAppearanceConfig = {\n contained: {\n rootClassName: 'relative',\n hasDivider: true,\n hasConnector: false,\n },\n embedded: {\n rootClassName: 'relative',\n hasDivider: true,\n hasConnector: false,\n },\n timeline: {\n rootClassName: 'relative',\n hasDivider: false,\n hasConnector: true,\n },\n} as const satisfies Record<\n WorkflowStepAppearance,\n { rootClassName: string; hasDivider: boolean; hasConnector: boolean }\n>;\n\nexport function normalizeExpandedWorkflowStepIds(\n ids: readonly string[],\n steps: readonly WorkflowStepViewModel[],\n): string[] {\n const requested = new Set(ids);\n return steps.flatMap((step) => (requested.has(step.id) ? [step.id] : []));\n}\n\nfunction areWorkflowStepIdsEqual(\n left: readonly string[],\n right: readonly string[],\n): boolean {\n return (\n left.length === right.length &&\n left.every((id, index) => id === right[index])\n );\n}\n\nfunction isIterableWorkflowStepContent(\n content: React.ReactNode,\n): content is Iterable<React.ReactNode> {\n return (\n typeof content === 'object' &&\n content !== null &&\n Symbol.iterator in content &&\n typeof (content as Iterable<React.ReactNode>)[Symbol.iterator] ===\n 'function'\n );\n}\n\nfunction isIteratorWorkflowStepContent(\n content: unknown,\n): content is Iterator<React.ReactNode> {\n return (\n typeof (content as Partial<Iterator<React.ReactNode>>).next === 'function'\n );\n}\n\ninterface NormalizedWorkflowStepContent {\n content: React.ReactNode;\n hasRenderableContent: boolean;\n changed: boolean;\n}\n\nconst normalizedOneShotWorkflowStepContent = new WeakMap<\n object,\n NormalizedWorkflowStepContent\n>();\n\nfunction normalizeIterableWorkflowStepContent(\n content: Iterable<React.ReactNode>,\n iterator: Iterator<React.ReactNode>,\n): NormalizedWorkflowStepContent {\n const normalizedChildren: React.ReactNode[] = [];\n let hasRenderableContent = false;\n let changed = !Array.isArray(content);\n\n for (let result = iterator.next(); !result.done; result = iterator.next()) {\n const normalizedChild = normalizeWorkflowStepContent(result.value);\n normalizedChildren.push(normalizedChild.content);\n hasRenderableContent ||= normalizedChild.hasRenderableContent;\n changed ||= normalizedChild.changed;\n }\n\n return {\n content: changed ? normalizedChildren : content,\n hasRenderableContent,\n changed,\n };\n}\n\nfunction normalizeWorkflowStepContent(\n content: React.ReactNode,\n): NormalizedWorkflowStepContent {\n if (\n content === null ||\n content === undefined ||\n typeof content === 'boolean' ||\n content === ''\n ) {\n return { content, hasRenderableContent: false, changed: false };\n }\n\n if (\n typeof content === 'string' ||\n typeof content === 'number' ||\n typeof content === 'bigint'\n ) {\n return { content, hasRenderableContent: true, changed: false };\n }\n\n if (React.isValidElement<{ children?: React.ReactNode }>(content)) {\n if (content.type !== React.Fragment) {\n return { content, hasRenderableContent: true, changed: false };\n }\n\n const normalizedChildren = normalizeWorkflowStepContent(\n content.props.children,\n );\n return {\n content: normalizedChildren.changed\n ? React.cloneElement(content, undefined, normalizedChildren.content)\n : content,\n hasRenderableContent: normalizedChildren.hasRenderableContent,\n changed: normalizedChildren.changed,\n };\n }\n\n if (isIterableWorkflowStepContent(content)) {\n const iterator = content[Symbol.iterator]();\n const oneShotCacheKey = isIteratorWorkflowStepContent(iterator)\n ? (iterator as object)\n : null;\n\n if (oneShotCacheKey !== null) {\n const cached = normalizedOneShotWorkflowStepContent.get(oneShotCacheKey);\n if (cached !== undefined) return cached;\n }\n\n const normalized = normalizeIterableWorkflowStepContent(content, iterator);\n if (oneShotCacheKey !== null) {\n normalizedOneShotWorkflowStepContent.set(oneShotCacheKey, normalized);\n }\n return normalized;\n }\n\n return { content, hasRenderableContent: true, changed: false };\n}\n\nfunction getNonBlankWorkflowStepError(\n error: string | undefined,\n): string | undefined {\n return error?.trim() ? error : undefined;\n}\n\nfunction getWorkflowStepStatusLabel(status: WorkflowStepStatus): string {\n switch (status) {\n case 'pending':\n return 'Pending';\n case 'running':\n return 'Running';\n case 'suspended':\n return 'Paused';\n case 'completed':\n return 'Completed';\n case 'error':\n return 'Error';\n default:\n return assertNever(status);\n }\n}\n\nexport interface WorkflowStepStatusIconProps {\n status: WorkflowStepStatus;\n index: number;\n className?: string;\n}\n\nexport function WorkflowStepStatusIcon({\n status,\n index,\n className,\n}: WorkflowStepStatusIconProps) {\n const iconClass = cn(workflowStepIconVariants({ status }), className);\n\n switch (status) {\n case 'pending':\n return (\n <div data-slot=\"workflow-step-icon\" className={iconClass}>\n <span className=\"text-xs font-medium\">{index + 1}</span>\n </div>\n );\n case 'running':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(\n iconClass,\n 'delight-status-pulse motion-reduce:!animate-none',\n )}\n >\n <Loader className=\"size-3 animate-spin motion-reduce:animate-none\" />\n </div>\n );\n case 'suspended':\n return (\n <div data-slot=\"workflow-step-icon\" className={iconClass}>\n <Pause className=\"size-3\" />\n </div>\n );\n case 'completed':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(\n iconClass,\n 'delight-check-bounce motion-reduce:!animate-none',\n )}\n >\n <Check className=\"size-3\" />\n </div>\n );\n case 'error':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(iconClass, 'delight-shake motion-reduce:!animate-none')}\n >\n <AlertCircle className=\"size-3\" />\n </div>\n );\n default:\n return assertNever(status);\n }\n}\n\nWorkflowStepStatusIcon.displayName = 'WorkflowStepStatusIcon';\n\nexport interface WorkflowStepItemProps {\n step: WorkflowStepViewModel;\n index: number;\n isLast: boolean;\n appearance?: WorkflowStepAppearance;\n itemSlot?: string;\n expandable?: boolean;\n expanded: boolean;\n active?: boolean;\n onExpandedChange: () => void;\n}\n\nexport function WorkflowStepItem({\n step,\n index,\n isLast,\n appearance = 'contained',\n itemSlot = 'workflow-step-item',\n expandable = true,\n expanded,\n active = false,\n onExpandedChange,\n}: WorkflowStepItemProps) {\n const contentId = React.useId();\n const errorDescriptionId = React.useId();\n const normalizedContent = normalizeWorkflowStepContent(step.content);\n const hasContent = normalizedContent.hasRenderableContent;\n const error = getNonBlankWorkflowStepError(step.error);\n const hasError = error !== undefined;\n const hasExpandableDetails = hasContent || hasError;\n const isDisclosureControl = hasExpandableDetails && expandable;\n const prefersReducedMotion = useReducedMotion();\n const appearanceConfig = workflowStepAppearanceConfig[appearance];\n const disclosureTransition = {\n duration: prefersReducedMotion ? 0 : 0.2,\n };\n const stepContent = (\n <>\n <WorkflowStepStatusIcon status={step.status} index={index} />\n\n <div className=\"min-w-0 flex-1 text-start\">\n <div className=\"flex flex-wrap items-center gap-2\">\n {step.contextLabel && (\n <span\n data-slot=\"workflow-step-context\"\n className=\"rounded-full border border-border px-2 py-0.5 text-[0.6875rem] font-medium leading-none text-secondary-foreground\"\n >\n {step.contextLabel}\n </span>\n )}\n <span\n className={cn(\n 'text-sm font-medium',\n step.status === 'pending'\n ? 'text-text-quaternary'\n : 'text-foreground',\n )}\n >\n {step.title}\n </span>\n <span className=\"text-xs text-secondary-foreground\">\n {getWorkflowStepStatusLabel(step.status)}\n </span>\n {step.durationMs !== undefined && (\n <span className=\"text-xs text-muted-foreground\">\n {formatAIDuration(step.durationMs)}\n </span>\n )}\n </div>\n {step.description && (\n <p className=\"mt-0.5 text-xs text-text-quaternary\">\n {step.description}\n </p>\n )}\n </div>\n\n {isDisclosureControl && (\n <div className=\"shrink-0\">\n {expanded ? (\n <ChevronDown className=\"size-4 text-muted-foreground\" />\n ) : (\n <ChevronRight className=\"size-4 text-muted-foreground rtl:rotate-180\" />\n )}\n </div>\n )}\n </>\n );\n\n return (\n <div\n data-slot={itemSlot}\n data-step-status={step.status}\n data-appearance={appearance}\n className={cn(\n appearanceConfig.rootClassName,\n appearanceConfig.hasDivider && !isLast && 'border-b border-border',\n )}\n >\n {isDisclosureControl ? (\n <button\n type=\"button\"\n onClick={onExpandedChange}\n aria-current={active ? 'step' : undefined}\n aria-expanded={expanded}\n aria-controls={contentId}\n aria-describedby={hasError ? errorDescriptionId : undefined}\n className={cn(\n workflowStepItemVariants({ status: step.status }),\n 'w-full cursor-pointer hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring',\n )}\n >\n {stepContent}\n </button>\n ) : (\n <div\n aria-current={active ? 'step' : undefined}\n aria-describedby={hasError ? errorDescriptionId : undefined}\n className={cn(\n workflowStepItemVariants({ status: step.status }),\n 'w-full',\n )}\n >\n {stepContent}\n </div>\n )}\n\n <AnimatePresence initial={false}>\n {expanded && hasExpandableDetails && (\n <motion.div\n id={contentId}\n data-slot=\"workflow-step-panel\"\n initial={{ height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={{ height: 0, opacity: 0 }}\n transition={disclosureTransition}\n className=\"overflow-hidden motion-reduce:transition-none\"\n >\n <div className=\"px-4 pb-3 ps-12\">\n {hasError && (\n <div className=\"rounded-lg border border-destructive/50 bg-destructive/10 p-3\">\n <div className=\"flex items-start gap-2\">\n <AlertCircle className=\"mt-0.5 size-4 shrink-0 text-destructive\" />\n <p className=\"text-sm text-destructive\">{error}</p>\n </div>\n </div>\n )}\n {hasContent && (\n <div className={hasError ? 'mt-3' : undefined}>\n {normalizedContent.content}\n </div>\n )}\n </div>\n </motion.div>\n )}\n </AnimatePresence>\n\n {hasError && (\n <span id={errorDescriptionId} className=\"sr-only\">\n {error}\n </span>\n )}\n\n {appearanceConfig.hasConnector && !isLast && (\n <div\n data-slot=\"workflow-step-connector\"\n aria-hidden=\"true\"\n className=\"absolute top-8 -bottom-3 start-6 w-px bg-border\"\n />\n )}\n </div>\n );\n}\n\nWorkflowStepItem.displayName = 'WorkflowStepItem';\n\nexport function WorkflowStepRenderer({\n steps,\n appearance = 'contained',\n itemSlot = 'workflow-step-item',\n expandable = true,\n activeStepId,\n expandedStepIds: controlledExpandedStepIds,\n defaultExpandedStepIds = [],\n onExpandedStepIdsChange,\n className,\n renderItems = true,\n}: PrivateWorkflowStepRendererProps) {\n const isControlled = controlledExpandedStepIds !== undefined;\n const controlledSnapshot = isControlled\n ? [...controlledExpandedStepIds]\n : undefined;\n const [uncontrolledExpandedStepIds, setUncontrolledExpandedStepIds] =\n React.useState<readonly string[]>(() =>\n normalizeExpandedWorkflowStepIds(defaultExpandedStepIds, steps),\n );\n const lastControlledExpandedStepIdsRef = React.useRef<readonly string[]>(\n controlledSnapshot ?? [],\n );\n const wasControlledRef = React.useRef(isControlled);\n const rawExpandedStepIds = isControlled\n ? controlledExpandedStepIds\n : uncontrolledExpandedStepIds;\n const visibleExpandedStepIds = normalizeExpandedWorkflowStepIds(\n rawExpandedStepIds,\n steps,\n );\n const expandedSet = new Set(visibleExpandedStepIds);\n\n React.useLayoutEffect(() => {\n if (controlledSnapshot !== undefined) {\n lastControlledExpandedStepIdsRef.current = controlledSnapshot;\n }\n }, [controlledSnapshot]);\n\n React.useLayoutEffect(() => {\n const wasControlled = wasControlledRef.current;\n wasControlledRef.current = isControlled;\n if (isControlled) return;\n\n setUncontrolledExpandedStepIds((current) => {\n const source = wasControlled\n ? lastControlledExpandedStepIdsRef.current\n : current;\n const reconciled = normalizeExpandedWorkflowStepIds(source, steps);\n return areWorkflowStepIdsEqual(reconciled, current)\n ? current\n : reconciled;\n });\n }, [isControlled, steps]);\n\n const toggleStep = (id: string) => {\n const next = new Set(visibleExpandedStepIds);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n const normalizedNext = normalizeExpandedWorkflowStepIds([...next], steps);\n if (!isControlled) {\n setUncontrolledExpandedStepIds([...normalizedNext]);\n }\n onExpandedStepIdsChange?.([...normalizedNext]);\n };\n\n if (!renderItems) return null;\n\n return (\n <ol\n data-slot=\"workflow-step-list\"\n data-appearance={appearance}\n className={cn('m-0 list-none p-0', className)}\n >\n {steps.map((step, index) => (\n <li key={step.id}>\n <WorkflowStepItem\n step={step}\n index={index}\n isLast={index === steps.length - 1}\n appearance={appearance}\n itemSlot={itemSlot}\n expandable={expandable}\n expanded={expandedSet.has(step.id)}\n active={activeStepId === step.id}\n onExpandedChange={() => toggleStep(step.id)}\n />\n </li>\n ))}\n </ol>\n );\n}\n\nWorkflowStepRenderer.displayName = 'WorkflowStepRenderer';\n"],"x_google_ignoreList":[0,1],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AK;AACjE,aAAO,EAAwB,GAAY,CAAO,IAC9C,IACA;AAAA,IACN,CAAC;AAAA,EACH,GAAG,CAAC,GAAc,CAAK,CAAC;AAExB,QAAM,IAAA,CAAc,MAAe;AACjC,UAAM,IAAO,IAAI,IAAI,CAAsB;AAC3C,IAAI,EAAK,IAAI,CAAE,IAAG,EAAK,OAAO,CAAE,IAC3B,EAAK,IAAI,CAAE;AAChB,UAAM,IAAiB,EAAiC,CAAC,GAAG,CAAI,GAAG,CAAK;AACxE,IAAK,KACH,EAA+B,CAAC,GAAG,CAAc,CAAC,GAEpD,IAA0B,CAAC,GAAG,CAAc,CAAC;AAAA,EAC/C;AAEA,SAAK,IAGH,oBAAA,EAAA,KAAC,MAAD;AAAA,IACE,aAAU;AAAA,IACV,mBAAiB;AAAA,IACjB,WAAW,EAAG,qBAAqB,CAAS;AAAA,cAE3C,EAAM,IAAA,CAAK,GAAM,MAChB,oBAAA,EAAA,KAAC,MAAD,EAAA,UACE,oBAAA,EAAA,KAAC,GAAD;AAAA,MACQ,MAAA;AAAA,MACC,OAAA;AAAA,MACP,QAAQ,MAAU,EAAM,SAAS;AAAA,MACrB,YAAA;AAAA,MACF,UAAA;AAAA,MACE,YAAA;AAAA,MACZ,UAAU,EAAY,IAAI,EAAK,EAAE;AAAA,MACjC,QAAQ,MAAiB,EAAK;AAAA,MAC9B,kBAAA,MAAwB,EAAW,EAAK,EAAE;AAAA,IAC3C,CAAA,EACC,GAZK,EAAK,EAYV,CACL;AAAA,EACC,CAAA,IAvBmB;AAyB3B;AAEA,GAAqB,cAAc"}
|
|
1
|
+
{"version":3,"file":"workflow-step-renderer.js","names":["__iconNode"],"sources":["../../../../../../../../../../../Users/akarim/Documents/test/humain_foundation_ui/node_modules/.bun/lucide-react@1.27.0+0f58469d5b3bd39f/node_modules/lucide-react/dist/esm/icons/loader.mjs","../../../../../../../../../../../Users/akarim/Documents/test/humain_foundation_ui/node_modules/.bun/lucide-react@1.27.0+0f58469d5b3bd39f/node_modules/lucide-react/dist/esm/icons/pause.mjs","../../src/components/organisms/ai/_shared/format-ai-duration.ts","../../src/components/organisms/ai/_shared/workflow-step-renderer.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.27.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m16.2 7.8 2.9-2.9\", key: \"r700ao\" }],\n [\"path\", { d: \"M18 12h4\", key: \"wj9ykh\" }],\n [\"path\", { d: \"m16.2 16.2 2.9 2.9\", key: \"1bxg5t\" }],\n [\"path\", { d: \"M12 18v4\", key: \"jadmvz\" }],\n [\"path\", { d: \"m4.9 19.1 2.9-2.9\", key: \"bwix9q\" }],\n [\"path\", { d: \"M2 12h4\", key: \"j09sii\" }],\n [\"path\", { d: \"m4.9 4.9 2.9 2.9\", key: \"giyufr\" }]\n];\nconst Loader = createLucideIcon(\"loader\", __iconNode);\n\nexport { __iconNode, Loader as default };\n//# sourceMappingURL=loader.mjs.map\n","/**\n * @license lucide-react v1.27.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconNode = [\n [\"rect\", { x: \"14\", y: \"3\", width: \"5\", height: \"18\", rx: \"1\", key: \"kaeet6\" }],\n [\"rect\", { x: \"5\", y: \"3\", width: \"5\", height: \"18\", rx: \"1\", key: \"1wsw3u\" }]\n];\nconst Pause = createLucideIcon(\"pause\", __iconNode);\n\nexport { __iconNode, Pause as default };\n//# sourceMappingURL=pause.mjs.map\n","export function formatAIDuration(durationMs: number): string {\n const normalizedMs = Math.max(0, Math.round(durationMs));\n if (normalizedMs < 1000) return `${normalizedMs}ms`;\n\n const totalSeconds = Math.round(normalizedMs / 1000);\n const hours = Math.floor(totalSeconds / 3600);\n const minutes = Math.floor((totalSeconds % 3600) / 60);\n const seconds = totalSeconds % 60;\n\n if (hours > 0) {\n return [hours ? `${hours}h` : '', minutes ? `${minutes}m` : '']\n .filter(Boolean)\n .join(' ');\n }\n if (minutes > 0) {\n return `${minutes}m${seconds ? ` ${seconds}s` : ''}`;\n }\n return `${totalSeconds}s`;\n}\n","import { cva } from 'class-variance-authority';\nimport {\n AlertCircle,\n Check,\n ChevronDown,\n ChevronRight,\n Loader,\n Pause,\n} from 'lucide-react';\nimport { AnimatePresence, motion, useReducedMotion } from 'motion/react';\nimport * as React from 'react';\nimport { assertNever, cn } from '@/lib/utils';\nimport { formatAIDuration } from './format-ai-duration';\n\nexport type WorkflowStepStatus =\n | 'pending'\n | 'running'\n | 'suspended'\n | 'completed'\n | 'error';\n\nexport type WorkflowStepAppearance = 'contained' | 'embedded' | 'timeline';\n\nexport interface WorkflowStepViewModel {\n id: string;\n title: string;\n description?: string;\n contextLabel?: string;\n status: WorkflowStepStatus;\n content?: React.ReactNode;\n durationMs?: number;\n error?: string;\n}\n\nexport interface WorkflowStepRendererProps {\n steps: readonly WorkflowStepViewModel[];\n appearance?: WorkflowStepAppearance;\n itemSlot?: string;\n expandable?: boolean;\n activeStepId?: string;\n expandedStepIds?: readonly string[];\n defaultExpandedStepIds?: readonly string[];\n onExpandedStepIdsChange?: (ids: readonly string[]) => void;\n className?: string;\n}\n\ninterface PrivateWorkflowStepRendererProps extends WorkflowStepRendererProps {\n renderItems?: boolean;\n}\n\nconst workflowStepItemStatusClasses = {\n pending: 'text-secondary-foreground',\n running: 'text-primary',\n suspended: 'text-warning',\n completed: 'text-success',\n error: 'text-destructive',\n} as const satisfies Record<WorkflowStepStatus, string>;\n\nconst workflowStepIconStatusClasses = {\n pending: 'bg-accent text-muted-foreground',\n running: 'bg-primary/20 text-primary',\n suspended: 'bg-warning/20 text-warning',\n completed: 'bg-success/20 text-success',\n error: 'bg-destructive/20 text-destructive',\n} as const satisfies Record<WorkflowStepStatus, string>;\n\nexport const workflowStepItemVariants = cva(\n 'flex items-start gap-3 px-4 py-3 transition-colors motion-reduce:transition-none',\n {\n variants: {\n status: workflowStepItemStatusClasses,\n },\n defaultVariants: {\n status: 'pending',\n },\n },\n);\n\nexport const workflowStepIconVariants = cva(\n 'size-5 shrink-0 flex items-center justify-center rounded-full',\n {\n variants: {\n status: workflowStepIconStatusClasses,\n },\n defaultVariants: {\n status: 'pending',\n },\n },\n);\n\nconst workflowStepAppearanceConfig = {\n contained: {\n rootClassName: 'relative',\n hasDivider: true,\n hasConnector: false,\n },\n embedded: {\n rootClassName: 'relative',\n hasDivider: true,\n hasConnector: false,\n },\n timeline: {\n rootClassName: 'relative',\n hasDivider: false,\n hasConnector: true,\n },\n} as const satisfies Record<\n WorkflowStepAppearance,\n { rootClassName: string; hasDivider: boolean; hasConnector: boolean }\n>;\n\nexport function normalizeExpandedWorkflowStepIds(\n ids: readonly string[],\n steps: readonly WorkflowStepViewModel[],\n): string[] {\n const requested = new Set(ids);\n return steps.flatMap((step) => (requested.has(step.id) ? [step.id] : []));\n}\n\nfunction areWorkflowStepIdsEqual(\n left: readonly string[],\n right: readonly string[],\n): boolean {\n return (\n left.length === right.length &&\n left.every((id, index) => id === right[index])\n );\n}\n\nfunction isIterableWorkflowStepContent(\n content: React.ReactNode,\n): content is Iterable<React.ReactNode> {\n return (\n typeof content === 'object' &&\n content !== null &&\n Symbol.iterator in content &&\n typeof (content as Iterable<React.ReactNode>)[Symbol.iterator] ===\n 'function'\n );\n}\n\nfunction isIteratorWorkflowStepContent(\n content: unknown,\n): content is Iterator<React.ReactNode> {\n return (\n typeof (content as Partial<Iterator<React.ReactNode>>).next === 'function'\n );\n}\n\ninterface NormalizedWorkflowStepContent {\n content: React.ReactNode;\n hasRenderableContent: boolean;\n changed: boolean;\n}\n\nconst normalizedOneShotWorkflowStepContent = new WeakMap<\n object,\n NormalizedWorkflowStepContent\n>();\n\nfunction normalizeIterableWorkflowStepContent(\n content: Iterable<React.ReactNode>,\n iterator: Iterator<React.ReactNode>,\n): NormalizedWorkflowStepContent {\n const normalizedChildren: React.ReactNode[] = [];\n let hasRenderableContent = false;\n let changed = !Array.isArray(content);\n\n for (let result = iterator.next(); !result.done; result = iterator.next()) {\n const normalizedChild = normalizeWorkflowStepContent(result.value);\n normalizedChildren.push(normalizedChild.content);\n hasRenderableContent ||= normalizedChild.hasRenderableContent;\n changed ||= normalizedChild.changed;\n }\n\n return {\n content: changed ? normalizedChildren : content,\n hasRenderableContent,\n changed,\n };\n}\n\nfunction normalizeWorkflowStepContent(\n content: React.ReactNode,\n): NormalizedWorkflowStepContent {\n if (\n content === null ||\n content === undefined ||\n typeof content === 'boolean' ||\n content === ''\n ) {\n return { content, hasRenderableContent: false, changed: false };\n }\n\n if (\n typeof content === 'string' ||\n typeof content === 'number' ||\n typeof content === 'bigint'\n ) {\n return { content, hasRenderableContent: true, changed: false };\n }\n\n if (React.isValidElement<{ children?: React.ReactNode }>(content)) {\n if (content.type !== React.Fragment) {\n return { content, hasRenderableContent: true, changed: false };\n }\n\n const normalizedChildren = normalizeWorkflowStepContent(\n content.props.children,\n );\n return {\n content: normalizedChildren.changed\n ? React.cloneElement(content, undefined, normalizedChildren.content)\n : content,\n hasRenderableContent: normalizedChildren.hasRenderableContent,\n changed: normalizedChildren.changed,\n };\n }\n\n if (isIterableWorkflowStepContent(content)) {\n const iterator = content[Symbol.iterator]();\n const oneShotCacheKey = isIteratorWorkflowStepContent(iterator)\n ? (iterator as object)\n : null;\n\n if (oneShotCacheKey !== null) {\n const cached = normalizedOneShotWorkflowStepContent.get(oneShotCacheKey);\n if (cached !== undefined) return cached;\n }\n\n const normalized = normalizeIterableWorkflowStepContent(content, iterator);\n if (oneShotCacheKey !== null) {\n normalizedOneShotWorkflowStepContent.set(oneShotCacheKey, normalized);\n }\n return normalized;\n }\n\n return { content, hasRenderableContent: true, changed: false };\n}\n\nfunction getNonBlankWorkflowStepError(\n error: string | undefined,\n): string | undefined {\n return error?.trim() ? error : undefined;\n}\n\nfunction getWorkflowStepStatusLabel(status: WorkflowStepStatus): string {\n switch (status) {\n case 'pending':\n return 'Pending';\n case 'running':\n return 'Running';\n case 'suspended':\n return 'Paused';\n case 'completed':\n return 'Completed';\n case 'error':\n return 'Error';\n default:\n return assertNever(status);\n }\n}\n\nexport interface WorkflowStepStatusIconProps {\n status: WorkflowStepStatus;\n index: number;\n className?: string;\n}\n\nexport function WorkflowStepStatusIcon({\n status,\n index,\n className,\n}: WorkflowStepStatusIconProps) {\n const iconClass = cn(workflowStepIconVariants({ status }), className);\n\n switch (status) {\n case 'pending':\n return (\n <div data-slot=\"workflow-step-icon\" className={iconClass}>\n <span className=\"text-xs font-medium\">{index + 1}</span>\n </div>\n );\n case 'running':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(\n iconClass,\n 'delight-status-pulse motion-reduce:!animate-none',\n )}\n >\n <Loader className=\"size-3 animate-spin motion-reduce:animate-none\" />\n </div>\n );\n case 'suspended':\n return (\n <div data-slot=\"workflow-step-icon\" className={iconClass}>\n <Pause className=\"size-3\" />\n </div>\n );\n case 'completed':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(\n iconClass,\n 'delight-check-bounce motion-reduce:!animate-none',\n )}\n >\n <Check className=\"size-3\" />\n </div>\n );\n case 'error':\n return (\n <div\n data-slot=\"workflow-step-icon\"\n className={cn(iconClass, 'delight-shake motion-reduce:!animate-none')}\n >\n <AlertCircle className=\"size-3\" />\n </div>\n );\n default:\n return assertNever(status);\n }\n}\n\nWorkflowStepStatusIcon.displayName = 'WorkflowStepStatusIcon';\n\nexport interface WorkflowStepItemProps {\n step: WorkflowStepViewModel;\n index: number;\n isLast: boolean;\n appearance?: WorkflowStepAppearance;\n itemSlot?: string;\n expandable?: boolean;\n expanded: boolean;\n active?: boolean;\n onExpandedChange: () => void;\n}\n\nexport function WorkflowStepItem({\n step,\n index,\n isLast,\n appearance = 'contained',\n itemSlot = 'workflow-step-item',\n expandable = true,\n expanded,\n active = false,\n onExpandedChange,\n}: WorkflowStepItemProps) {\n const contentId = React.useId();\n const errorDescriptionId = React.useId();\n const normalizedContent = normalizeWorkflowStepContent(step.content);\n const hasContent = normalizedContent.hasRenderableContent;\n const error = getNonBlankWorkflowStepError(step.error);\n const hasError = error !== undefined;\n const hasExpandableDetails = hasContent || hasError;\n const isDisclosureControl = hasExpandableDetails && expandable;\n const prefersReducedMotion = useReducedMotion();\n const appearanceConfig = workflowStepAppearanceConfig[appearance];\n const disclosureTransition = {\n duration: prefersReducedMotion ? 0 : 0.2,\n };\n const stepContent = (\n <>\n <WorkflowStepStatusIcon status={step.status} index={index} />\n\n <div className=\"min-w-0 flex-1 text-start\">\n <div className=\"flex flex-wrap items-center gap-2\">\n {step.contextLabel && (\n <span\n data-slot=\"workflow-step-context\"\n className=\"rounded-full border border-border px-2 py-0.5 text-[0.6875rem] font-medium leading-none text-secondary-foreground\"\n >\n {step.contextLabel}\n </span>\n )}\n <span\n className={cn(\n 'text-sm font-medium',\n step.status === 'pending'\n ? 'text-secondary-foreground'\n : 'text-foreground',\n )}\n >\n {step.title}\n </span>\n <span className=\"text-xs text-secondary-foreground\">\n {getWorkflowStepStatusLabel(step.status)}\n </span>\n {step.durationMs !== undefined && (\n <span className=\"text-xs text-secondary-foreground\">\n {formatAIDuration(step.durationMs)}\n </span>\n )}\n </div>\n {step.description && (\n <p className=\"mt-0.5 text-xs text-secondary-foreground\">\n {step.description}\n </p>\n )}\n </div>\n\n {isDisclosureControl && (\n <div className=\"shrink-0\">\n {expanded ? (\n <ChevronDown className=\"size-4 text-muted-foreground\" />\n ) : (\n <ChevronRight className=\"size-4 text-muted-foreground rtl:rotate-180\" />\n )}\n </div>\n )}\n </>\n );\n\n return (\n <div\n data-slot={itemSlot}\n data-step-status={step.status}\n data-appearance={appearance}\n className={cn(\n appearanceConfig.rootClassName,\n appearanceConfig.hasDivider && !isLast && 'border-b border-border',\n )}\n >\n {isDisclosureControl ? (\n <button\n type=\"button\"\n onClick={onExpandedChange}\n aria-current={active ? 'step' : undefined}\n aria-expanded={expanded}\n aria-controls={contentId}\n aria-describedby={hasError ? errorDescriptionId : undefined}\n className={cn(\n workflowStepItemVariants({ status: step.status }),\n 'w-full cursor-pointer hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring',\n )}\n >\n {stepContent}\n </button>\n ) : (\n <div\n aria-current={active ? 'step' : undefined}\n aria-describedby={hasError ? errorDescriptionId : undefined}\n className={cn(\n workflowStepItemVariants({ status: step.status }),\n 'w-full',\n )}\n >\n {stepContent}\n </div>\n )}\n\n <AnimatePresence initial={false}>\n {expanded && hasExpandableDetails && (\n <motion.div\n id={contentId}\n data-slot=\"workflow-step-panel\"\n initial={{ height: 0, opacity: 0 }}\n animate={{ height: 'auto', opacity: 1 }}\n exit={{ height: 0, opacity: 0 }}\n transition={disclosureTransition}\n className=\"overflow-hidden motion-reduce:transition-none\"\n >\n <div className=\"px-4 pb-3 ps-12\">\n {hasError && (\n <div className=\"rounded-lg border border-destructive/50 bg-destructive/10 p-3\">\n <div className=\"flex items-start gap-2\">\n <AlertCircle className=\"mt-0.5 size-4 shrink-0 text-destructive\" />\n <p className=\"text-sm text-destructive\">{error}</p>\n </div>\n </div>\n )}\n {hasContent && (\n <div className={hasError ? 'mt-3' : undefined}>\n {normalizedContent.content}\n </div>\n )}\n </div>\n </motion.div>\n )}\n </AnimatePresence>\n\n {hasError && (\n <span id={errorDescriptionId} className=\"sr-only\">\n {error}\n </span>\n )}\n\n {appearanceConfig.hasConnector && !isLast && (\n <div\n data-slot=\"workflow-step-connector\"\n aria-hidden=\"true\"\n className=\"absolute top-8 -bottom-3 start-6 w-px bg-border\"\n />\n )}\n </div>\n );\n}\n\nWorkflowStepItem.displayName = 'WorkflowStepItem';\n\nexport function WorkflowStepRenderer({\n steps,\n appearance = 'contained',\n itemSlot = 'workflow-step-item',\n expandable = true,\n activeStepId,\n expandedStepIds: controlledExpandedStepIds,\n defaultExpandedStepIds = [],\n onExpandedStepIdsChange,\n className,\n renderItems = true,\n}: PrivateWorkflowStepRendererProps) {\n const isControlled = controlledExpandedStepIds !== undefined;\n const controlledSnapshot = isControlled\n ? [...controlledExpandedStepIds]\n : undefined;\n const [uncontrolledExpandedStepIds, setUncontrolledExpandedStepIds] =\n React.useState<readonly string[]>(() =>\n normalizeExpandedWorkflowStepIds(defaultExpandedStepIds, steps),\n );\n const lastControlledExpandedStepIdsRef = React.useRef<readonly string[]>(\n controlledSnapshot ?? [],\n );\n const wasControlledRef = React.useRef(isControlled);\n const rawExpandedStepIds = isControlled\n ? controlledExpandedStepIds\n : uncontrolledExpandedStepIds;\n const visibleExpandedStepIds = normalizeExpandedWorkflowStepIds(\n rawExpandedStepIds,\n steps,\n );\n const expandedSet = new Set(visibleExpandedStepIds);\n\n React.useLayoutEffect(() => {\n if (controlledSnapshot !== undefined) {\n lastControlledExpandedStepIdsRef.current = controlledSnapshot;\n }\n }, [controlledSnapshot]);\n\n React.useLayoutEffect(() => {\n const wasControlled = wasControlledRef.current;\n wasControlledRef.current = isControlled;\n if (isControlled) return;\n\n setUncontrolledExpandedStepIds((current) => {\n const source = wasControlled\n ? lastControlledExpandedStepIdsRef.current\n : current;\n const reconciled = normalizeExpandedWorkflowStepIds(source, steps);\n return areWorkflowStepIdsEqual(reconciled, current)\n ? current\n : reconciled;\n });\n }, [isControlled, steps]);\n\n const toggleStep = (id: string) => {\n const next = new Set(visibleExpandedStepIds);\n if (next.has(id)) next.delete(id);\n else next.add(id);\n const normalizedNext = normalizeExpandedWorkflowStepIds([...next], steps);\n if (!isControlled) {\n setUncontrolledExpandedStepIds([...normalizedNext]);\n }\n onExpandedStepIdsChange?.([...normalizedNext]);\n };\n\n if (!renderItems) return null;\n\n return (\n <ol\n data-slot=\"workflow-step-list\"\n data-appearance={appearance}\n className={cn('m-0 list-none p-0', className)}\n >\n {steps.map((step, index) => (\n <li key={step.id}>\n <WorkflowStepItem\n step={step}\n index={index}\n isLast={index === steps.length - 1}\n appearance={appearance}\n itemSlot={itemSlot}\n expandable={expandable}\n expanded={expandedSet.has(step.id)}\n active={activeStepId === step.id}\n onExpandedChange={() => toggleStep(step.id)}\n />\n </li>\n ))}\n </ol>\n );\n}\n\nWorkflowStepRenderer.displayName = 'WorkflowStepRenderer';\n"],"x_google_ignoreList":[0,1],"mappings":";;;;;;;;;;;;AASA,IAAMA,IAAa;AAAA,EACjB,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAW,KAAK;AAAA,EAAS,CAAC;AAAA,EACxC,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAqB,KAAK;AAAA,EAAS,CAAC;AAAA,EAClD,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAY,KAAK;AAAA,EAAS,CAAC;AAAA,EACzC,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAsB,KAAK;AAAA,EAAS,CAAC;AAAA,EACnD,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAY,KAAK;AAAA,EAAS,CAAC;AAAA,EACzC,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAqB,KAAK;AAAA,EAAS,CAAC;AAAA,EAClD,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAW,KAAK;AAAA,EAAS,CAAC;AAAA,EACxC,CAAC,QAAQ;AAAA,IAAE,GAAG;AAAA,IAAoB,KAAK;AAAA,EAAS,CAAC;AACnD,GACM,IAAS,EAAiB,UAAUA,CAAU,GCV9C,IAAa,CACjB,CAAC,QAAQ;AAAA,EAAE,GAAG;AAAA,EAAM,GAAG;AAAA,EAAK,OAAO;AAAA,EAAK,QAAQ;AAAA,EAAM,IAAI;AAAA,EAAK,KAAK;AAAS,CAAC,GAC9E,CAAC,QAAQ;AAAA,EAAE,GAAG;AAAA,EAAK,GAAG;AAAA,EAAK,OAAO;AAAA,EAAK,QAAQ;AAAA,EAAM,IAAI;AAAA,EAAK,KAAK;AAAS,CAAC,CAC/E,GACM,IAAQ,EAA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{ t as H } from "./button.js";
|
|
7
7
|
import { n as z } from "./syntax-highlight.js";
|
|
8
8
|
import { n as T, t as F } from "./syntax-highlight-react.js";
|
|
9
|
-
import * as
|
|
9
|
+
import * as c from "react";
|
|
10
10
|
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
11
11
|
var h = R("relative overflow-hidden rounded-xl border border-border bg-muted", {
|
|
12
12
|
variants: { size: {
|
|
@@ -25,17 +25,17 @@ function V(o, r) {
|
|
|
25
25
|
copied: !1
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
function p({ language: o, fileName: r, showCopyButton: n = !0, onCopy: a, copied: t = !1, className:
|
|
28
|
+
function p({ language: o, fileName: r, showCopyButton: n = !0, onCopy: a, copied: t = !1, className: i, actions: m }) {
|
|
29
29
|
return /* @__PURE__ */ l("div", {
|
|
30
30
|
"data-slot": "ai-code-block-header",
|
|
31
|
-
className: d("flex items-center justify-between px-4 py-2 border-b border-border bg-accent",
|
|
31
|
+
className: d("flex items-center justify-between px-4 py-2 border-b border-border bg-accent", i),
|
|
32
32
|
children: [/* @__PURE__ */ l("div", {
|
|
33
33
|
className: "flex items-center gap-2",
|
|
34
34
|
children: [r && /* @__PURE__ */ e("span", {
|
|
35
35
|
className: "text-sm font-medium text-secondary-foreground",
|
|
36
36
|
children: r
|
|
37
37
|
}), o && !r && /* @__PURE__ */ e("span", {
|
|
38
|
-
className: "text-xs font-medium text-
|
|
38
|
+
className: "text-xs font-medium text-secondary-foreground uppercase",
|
|
39
39
|
children: o
|
|
40
40
|
})]
|
|
41
41
|
}), /* @__PURE__ */ l("div", {
|
|
@@ -46,7 +46,7 @@ function p({ language: o, fileName: r, showCopyButton: n = !0, onCopy: a, copied
|
|
|
46
46
|
size: "sm",
|
|
47
47
|
onClick: a,
|
|
48
48
|
"aria-label": t ? "Copied to clipboard" : "Copy code to clipboard",
|
|
49
|
-
className: "h-7 px-2 text-
|
|
49
|
+
className: "h-7 px-2 text-secondary-foreground hover:text-foreground transition-colors duration-150 ease-out",
|
|
50
50
|
children: [t ? /* @__PURE__ */ e(I, { className: "size-4 text-success delight-bounce-in motion-reduce:animate-none" }) : /* @__PURE__ */ e(A, { className: "size-4" }), /* @__PURE__ */ e("span", {
|
|
51
51
|
className: "ms-1.5 text-xs",
|
|
52
52
|
children: t ? "Copied!" : "Copy"
|
|
@@ -63,7 +63,7 @@ function j({ children: o, showLineNumbers: r, startLineNumber: n }) {
|
|
|
63
63
|
className: "flex flex-col items-end pe-4 select-none border-e border-border me-4",
|
|
64
64
|
children: o.split(`
|
|
65
65
|
`).map((a, t) => /* @__PURE__ */ e("span", {
|
|
66
|
-
className: "text-
|
|
66
|
+
className: "text-secondary-foreground leading-relaxed",
|
|
67
67
|
children: n + t
|
|
68
68
|
}, t))
|
|
69
69
|
}), /* @__PURE__ */ e("section", {
|
|
@@ -97,12 +97,12 @@ function _({ children: o, showLineNumbers: r = !1, startLineNumber: n = 1, class
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
_.displayName = "AICodeBlockContent";
|
|
100
|
-
function v({ code: o, language: r = "plaintext", fileName: n, showHeader: a = !0, showCopyButton: t = !0, showLineNumbers:
|
|
101
|
-
const
|
|
100
|
+
function v({ code: o, language: r = "plaintext", fileName: n, showHeader: a = !0, showCopyButton: t = !0, showLineNumbers: i = !1, startLineNumber: m = 1, highlightedCode: f, size: y, className: C, headerActions: k }) {
|
|
101
|
+
const g = c.useMemo(() => f ? T(f) : F(o), [o, f]), [u, b] = c.useReducer(V, {
|
|
102
102
|
copied: !1,
|
|
103
103
|
resetKey: 0
|
|
104
|
-
}), { copied:
|
|
105
|
-
|
|
104
|
+
}), { copied: w } = u, x = c.useRef(null);
|
|
105
|
+
c.useEffect(() => {
|
|
106
106
|
if (!u.copied) return;
|
|
107
107
|
const s = setTimeout(() => {
|
|
108
108
|
b(!1);
|
|
@@ -111,7 +111,7 @@ function v({ code: o, language: r = "plaintext", fileName: n, showHeader: a = !0
|
|
|
111
111
|
clearTimeout(s);
|
|
112
112
|
};
|
|
113
113
|
}, [u]);
|
|
114
|
-
const N =
|
|
114
|
+
const N = c.useCallback(async () => {
|
|
115
115
|
try {
|
|
116
116
|
const s = x.current?.ownerDocument.defaultView;
|
|
117
117
|
if (!s) return;
|
|
@@ -130,22 +130,22 @@ function v({ code: o, language: r = "plaintext", fileName: n, showHeader: a = !0
|
|
|
130
130
|
fileName: n,
|
|
131
131
|
showCopyButton: t,
|
|
132
132
|
onCopy: N,
|
|
133
|
-
copied:
|
|
133
|
+
copied: w,
|
|
134
134
|
actions: k
|
|
135
135
|
}), /* @__PURE__ */ e("section", {
|
|
136
|
-
className: d("p-4 overflow-x-auto font-mono leading-relaxed [overflow-wrap:normal] !bg-transparent !m-0 !border-0 !rounded-none", "[&_.sh__line]:block [&_.sh__line]:leading-relaxed",
|
|
137
|
-
style:
|
|
136
|
+
className: d("p-4 overflow-x-auto font-mono leading-relaxed [overflow-wrap:normal] !bg-transparent !m-0 !border-0 !rounded-none", "[&_.sh__line]:block [&_.sh__line]:leading-relaxed", i && ["[&_.sh__line]:[counter-increment:sh-line]", "[&_.sh__line]:before:[content:counter(sh-line)] [&_.sh__line]:before:inline-block [&_.sh__line]:before:w-8 [&_.sh__line]:before:me-4 [&_.sh__line]:before:text-end [&_.sh__line]:before:text-secondary-foreground [&_.sh__line]:before:select-none"]),
|
|
137
|
+
style: i ? { counterReset: `sh-line ${m - 1}` } : void 0,
|
|
138
138
|
"aria-label": "Code content",
|
|
139
139
|
tabIndex: 0,
|
|
140
140
|
children: /* @__PURE__ */ e("pre", {
|
|
141
141
|
className: "!m-0 !bg-transparent [overflow-wrap:normal]",
|
|
142
|
-
children:
|
|
142
|
+
children: g
|
|
143
143
|
})
|
|
144
144
|
})]
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
v.displayName = "AICodeBlock";
|
|
148
|
-
var
|
|
148
|
+
var q = /* @__PURE__ */ B({
|
|
149
149
|
AICodeBlock: () => v,
|
|
150
150
|
AICodeBlockContent: () => _,
|
|
151
151
|
AICodeBlockHeader: () => p,
|
|
@@ -153,7 +153,7 @@ var Y = /* @__PURE__ */ B({
|
|
|
153
153
|
});
|
|
154
154
|
export {
|
|
155
155
|
v as n,
|
|
156
|
-
|
|
156
|
+
q as t
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
//# sourceMappingURL=AICodeBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AICodeBlock.js","names":[],"sources":["../../src/components/organisms/ai/AICodeBlock/AICodeBlock.tsx","../../src/components/organisms/ai/AICodeBlock/index.ts"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport { Check, Copy } from 'lucide-react';\nimport * as React from 'react';\nimport { Button } from '@/components/atoms/buttons/Button';\nimport { SUGAR_HIGH_STYLE } from '@/lib/syntax-highlight';\nimport {\n renderHighlightedCode,\n renderHighlightedMarkup,\n} from '@/lib/syntax-highlight-react';\nimport { cn } from '@/lib/utils';\n\n// =============================================================================\n// Variants\n// =============================================================================\n\nconst codeBlockVariants = cva(\n 'relative overflow-hidden rounded-xl border border-border bg-muted',\n {\n variants: {\n size: {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n },\n);\n\ninterface CopyFeedbackState {\n copied: boolean;\n resetKey: number;\n}\n\nfunction copyFeedbackReducer(\n state: CopyFeedbackState,\n copied: boolean,\n): CopyFeedbackState {\n return copied\n ? { copied: true, resetKey: state.resetKey + 1 }\n : { ...state, copied: false };\n}\n\n// =============================================================================\n// Code Block Header\n// =============================================================================\n\nexport interface AICodeBlockHeaderProps {\n /** Programming language */\n language?: string;\n /** File name to display */\n fileName?: string;\n /** Whether to show copy button */\n showCopyButton?: boolean;\n /** Callback when copy is clicked */\n onCopy?: () => void;\n /** Whether content was copied */\n copied?: boolean;\n /** Additional class name */\n className?: string;\n /** Extra actions to render */\n actions?: React.ReactNode;\n}\n\nfunction AICodeBlockHeader({\n language,\n fileName,\n showCopyButton = true,\n onCopy,\n copied = false,\n className,\n actions,\n}: AICodeBlockHeaderProps) {\n return (\n <div\n data-slot=\"ai-code-block-header\"\n className={cn(\n 'flex items-center justify-between px-4 py-2 border-b border-border bg-accent',\n className,\n )}\n >\n <div className=\"flex items-center gap-2\">\n {fileName && (\n <span className=\"text-sm font-medium text-secondary-foreground\">\n {fileName}\n </span>\n )}\n {language && !fileName && (\n <span className=\"text-xs font-medium text-text-quaternary uppercase\">\n {language}\n </span>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {actions}\n {showCopyButton && (\n <Button\n appearance=\"ghost\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onCopy}\n aria-label={\n copied ? 'Copied to clipboard' : 'Copy code to clipboard'\n }\n className=\"h-7 px-2 text-text-quaternary hover:text-secondary-foreground transition-colors duration-150 ease-out\"\n >\n {copied ? (\n <Check className=\"size-4 text-success delight-bounce-in motion-reduce:animate-none\" />\n ) : (\n <Copy className=\"size-4\" />\n )}\n <span className=\"ms-1.5 text-xs\">\n {copied ? 'Copied!' : 'Copy'}\n </span>\n </Button>\n )}\n </div>\n </div>\n );\n}\n\nAICodeBlockHeader.displayName = 'AICodeBlockHeader';\n\n// =============================================================================\n// Code Block Content\n// =============================================================================\n\nexport interface AICodeBlockContentProps {\n /** Code content */\n children: React.ReactNode;\n /** Whether to show line numbers */\n showLineNumbers?: boolean;\n /** Starting line number */\n startLineNumber?: number;\n /** Additional class name */\n className?: string;\n}\n\ninterface AICodeBlockContentBodyProps {\n children: React.ReactNode;\n showLineNumbers: boolean;\n startLineNumber: number;\n}\n\nfunction AICodeBlockContentBody({\n children,\n showLineNumbers,\n startLineNumber,\n}: AICodeBlockContentBodyProps): React.ReactNode {\n if (showLineNumbers && typeof children === 'string') {\n const lines = children.split('\\n');\n return (\n <div className=\"flex\">\n <div className=\"flex flex-col items-end pe-4 select-none border-e border-border me-4\">\n {lines.map((_, index) => (\n <span key={index} className=\"text-muted-foreground leading-relaxed\">\n {startLineNumber + index}\n </span>\n ))}\n </div>\n <section\n className=\"flex-1 overflow-x-auto [overflow-wrap:normal] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"m-0 [overflow-wrap:normal]\">\n <code>{children}</code>\n </pre>\n </section>\n </div>\n );\n }\n\n return (\n <section\n className=\"overflow-x-auto [overflow-wrap:normal] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"m-0 [overflow-wrap:normal]\">\n <code>{children}</code>\n </pre>\n </section>\n );\n}\n\nfunction AICodeBlockContent({\n children,\n showLineNumbers = false,\n startLineNumber = 1,\n className,\n}: AICodeBlockContentProps) {\n return (\n <div\n data-slot=\"ai-code-block-content\"\n className={cn('p-4 text-sm font-mono leading-relaxed', className)}\n >\n <AICodeBlockContentBody\n showLineNumbers={showLineNumbers}\n startLineNumber={startLineNumber}\n >\n {children}\n </AICodeBlockContentBody>\n </div>\n );\n}\n\nAICodeBlockContent.displayName = 'AICodeBlockContent';\n\n// =============================================================================\n// Main AICodeBlock Component\n// =============================================================================\n\nexport interface AICodeBlockProps\n extends VariantProps<typeof codeBlockVariants> {\n /** Code content to display */\n code: string;\n /** Programming language for syntax highlighting */\n language?: string;\n /** File name to display in header */\n fileName?: string;\n /** Whether to show the header */\n showHeader?: boolean;\n /** Whether to show copy button */\n showCopyButton?: boolean;\n /** Whether to show line numbers */\n showLineNumbers?: boolean;\n /** Starting line number */\n startLineNumber?: number;\n /** Pre-highlighted HTML content */\n highlightedCode?: string;\n /** Additional class name */\n className?: string;\n /** Extra actions for the header */\n headerActions?: React.ReactNode;\n}\n\nfunction AICodeBlock({\n code,\n language = 'plaintext',\n fileName,\n showHeader = true,\n showCopyButton = true,\n showLineNumbers = false,\n startLineNumber = 1,\n highlightedCode,\n size,\n className,\n headerActions,\n}: AICodeBlockProps) {\n const highlightedContent = React.useMemo(\n () =>\n highlightedCode\n ? renderHighlightedMarkup(highlightedCode)\n : renderHighlightedCode(code),\n [code, highlightedCode],\n );\n const [copyFeedback, setCopyFeedback] = React.useReducer(\n copyFeedbackReducer,\n { copied: false, resetKey: 0 },\n );\n const { copied } = copyFeedback;\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!copyFeedback.copied) return;\n\n const copyResetTimer = setTimeout(() => {\n setCopyFeedback(false);\n }, 2000);\n\n return () => {\n clearTimeout(copyResetTimer);\n };\n }, [copyFeedback]);\n\n const handleCopy = React.useCallback(async () => {\n try {\n // SSR guard: access clipboard via ref's ownerDocument\n const win = rootRef.current?.ownerDocument.defaultView;\n if (!win) return;\n await win.navigator.clipboard.writeText(code);\n setCopyFeedback(true);\n } catch (err) {\n console.error('Failed to copy code:', err);\n }\n }, [code]);\n\n return (\n <div\n ref={rootRef}\n data-slot=\"ai-code-block\"\n className={cn(codeBlockVariants({ size }), className)}\n style={SUGAR_HIGH_STYLE}\n >\n {showHeader && (\n <AICodeBlockHeader\n language={language}\n fileName={fileName}\n showCopyButton={showCopyButton}\n onCopy={handleCopy}\n copied={copied}\n actions={headerActions}\n />\n )}\n <section\n className={cn(\n 'p-4 overflow-x-auto font-mono leading-relaxed [overflow-wrap:normal] !bg-transparent !m-0 !border-0 !rounded-none',\n '[&_.sh__line]:block [&_.sh__line]:leading-relaxed',\n showLineNumbers && [\n '[&_.sh__line]:[counter-increment:sh-line]',\n '[&_.sh__line]:before:[content:counter(sh-line)] [&_.sh__line]:before:inline-block [&_.sh__line]:before:w-8 [&_.sh__line]:before:me-4 [&_.sh__line]:before:text-end [&_.sh__line]:before:text-muted-foreground [&_.sh__line]:before:select-none',\n ],\n )}\n style={\n showLineNumbers\n ? ({\n counterReset: `sh-line ${startLineNumber - 1}`,\n } as React.CSSProperties)\n : undefined\n }\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"!m-0 !bg-transparent [overflow-wrap:normal]\">\n {highlightedContent}\n </pre>\n </section>\n </div>\n );\n}\n\nAICodeBlock.displayName = 'AICodeBlock';\n\nexport {\n AICodeBlock,\n AICodeBlockContent,\n AICodeBlockHeader,\n codeBlockVariants,\n};\n","export * from './AICodeBlock';\n"],"mappings":";;;;;;;;;;AAeA,IAAM,IAAoB,EACxB,qEACA;AAAA,EACE,UAAU,EACR,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EACN,EACF;AAAA,EACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;AAOA,SAAS,EACP,GACA,GACmB;AACnB,SAAO,IACH;AAAA,IAAE,QAAQ;AAAA,IAAM,UAAU,EAAM,WAAW;AAAA,EAAE,IAC7C;AAAA,IAAE,GAAG;AAAA,IAAO,QAAQ;AAAA,EAAM;AAChC;AAuBA,SAAS,EAAkB,EACzB,UAAA,GACA,UAAA,GACA,gBAAA,IAAiB,IACjB,QAAA,GACA,QAAA,IAAS,IACT,WAAA,GACA,SAAA,EAAA,GACyB;AACzB,SACE,gBAAA,EAAC,OAAD;AAAA,IACE,aAAU;AAAA,IACV,WAAW,EACT,gFACA,CACF;AAAA,cALF,CAOE,gBAAA,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,gBAAf,CACG,KACC,gBAAA,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,kBACb;AAAA,MACG,CAAA,GAEP,KAAY,CAAC,KACZ,gBAAA,EAAC,QAAD;AAAA,QAAM,WAAU;AAAA,kBACb;AAAA,MACG,CAAA,CAEL;AAAA,QACL,gBAAA,EAAC,OAAD;AAAA,MAAK,WAAU;AAAA,gBAA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K;AACZ,cAAQ,MAAM,wBAAwB,CAAG;AAAA,IAC3C;AAAA,EACF,GAAG,CAAC,CAAI,CAAC;AAET,SACE,gBAAA,EAAC,OAAD;AAAA,IACE,KAAK;AAAA,IACL,aAAU;AAAA,IACV,WAAW,EAAG,EAAkB,EAAE,MAAA,EAAK,CAAC,GAAG,CAAS;AAAA,IACpD,OAAO;AAAA,cAJT,CAMG,KACC,gBAAA,EAAC,GAAD;AAAA,MACY,UAAA;AAAA,MACA,UAAA;AAAA,MACM,gBAAA;AAAA,MAChB,QAAQ;AAAA,MACA,QAAA;AAAA,MACR,SAAS;AAAA,IACV,CAAA,GAEH,gBAAA,EAAC,WAAD;AAAA,MACE,WAAW,EACT,qHACA,qDACA,KAAmB,CACjB,6CACA,gPACF,CACF;AAAA,MACA,OACE,IACK,EACC,cAAc,WAAW,IAAkB,CAAA,GAC7C,IACA;AAAA,MAEN,cAAW;AAAA,MAEX,UAAU;AAAA,gBAEV,gBAAA,EAAC,OAAD;AAAA,QAAK,WAAU;AAAA,kBACZ;AAAA,MACE,CAAA;AAAA,IACE,CAAA,CACN;AAAA;AAET;AAEA,EAAY,cAAc"}
|
|
1
|
+
{"version":3,"file":"AICodeBlock.js","names":[],"sources":["../../src/components/organisms/ai/AICodeBlock/AICodeBlock.tsx","../../src/components/organisms/ai/AICodeBlock/index.ts"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport { Check, Copy } from 'lucide-react';\nimport * as React from 'react';\nimport { Button } from '@/components/atoms/buttons/Button';\nimport { SUGAR_HIGH_STYLE } from '@/lib/syntax-highlight';\nimport {\n renderHighlightedCode,\n renderHighlightedMarkup,\n} from '@/lib/syntax-highlight-react';\nimport { cn } from '@/lib/utils';\n\n// =============================================================================\n// Variants\n// =============================================================================\n\nconst codeBlockVariants = cva(\n 'relative overflow-hidden rounded-xl border border-border bg-muted',\n {\n variants: {\n size: {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n },\n },\n defaultVariants: {\n size: 'md',\n },\n },\n);\n\ninterface CopyFeedbackState {\n copied: boolean;\n resetKey: number;\n}\n\nfunction copyFeedbackReducer(\n state: CopyFeedbackState,\n copied: boolean,\n): CopyFeedbackState {\n return copied\n ? { copied: true, resetKey: state.resetKey + 1 }\n : { ...state, copied: false };\n}\n\n// =============================================================================\n// Code Block Header\n// =============================================================================\n\nexport interface AICodeBlockHeaderProps {\n /** Programming language */\n language?: string;\n /** File name to display */\n fileName?: string;\n /** Whether to show copy button */\n showCopyButton?: boolean;\n /** Callback when copy is clicked */\n onCopy?: () => void;\n /** Whether content was copied */\n copied?: boolean;\n /** Additional class name */\n className?: string;\n /** Extra actions to render */\n actions?: React.ReactNode;\n}\n\nfunction AICodeBlockHeader({\n language,\n fileName,\n showCopyButton = true,\n onCopy,\n copied = false,\n className,\n actions,\n}: AICodeBlockHeaderProps) {\n return (\n <div\n data-slot=\"ai-code-block-header\"\n className={cn(\n 'flex items-center justify-between px-4 py-2 border-b border-border bg-accent',\n className,\n )}\n >\n <div className=\"flex items-center gap-2\">\n {fileName && (\n <span className=\"text-sm font-medium text-secondary-foreground\">\n {fileName}\n </span>\n )}\n {language && !fileName && (\n <span className=\"text-xs font-medium text-secondary-foreground uppercase\">\n {language}\n </span>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {actions}\n {showCopyButton && (\n <Button\n appearance=\"ghost\"\n variant=\"secondary\"\n size=\"sm\"\n onClick={onCopy}\n aria-label={\n copied ? 'Copied to clipboard' : 'Copy code to clipboard'\n }\n className=\"h-7 px-2 text-secondary-foreground hover:text-foreground transition-colors duration-150 ease-out\"\n >\n {copied ? (\n <Check className=\"size-4 text-success delight-bounce-in motion-reduce:animate-none\" />\n ) : (\n <Copy className=\"size-4\" />\n )}\n <span className=\"ms-1.5 text-xs\">\n {copied ? 'Copied!' : 'Copy'}\n </span>\n </Button>\n )}\n </div>\n </div>\n );\n}\n\nAICodeBlockHeader.displayName = 'AICodeBlockHeader';\n\n// =============================================================================\n// Code Block Content\n// =============================================================================\n\nexport interface AICodeBlockContentProps {\n /** Code content */\n children: React.ReactNode;\n /** Whether to show line numbers */\n showLineNumbers?: boolean;\n /** Starting line number */\n startLineNumber?: number;\n /** Additional class name */\n className?: string;\n}\n\ninterface AICodeBlockContentBodyProps {\n children: React.ReactNode;\n showLineNumbers: boolean;\n startLineNumber: number;\n}\n\nfunction AICodeBlockContentBody({\n children,\n showLineNumbers,\n startLineNumber,\n}: AICodeBlockContentBodyProps): React.ReactNode {\n if (showLineNumbers && typeof children === 'string') {\n const lines = children.split('\\n');\n return (\n <div className=\"flex\">\n <div className=\"flex flex-col items-end pe-4 select-none border-e border-border me-4\">\n {lines.map((_, index) => (\n <span\n key={index}\n className=\"text-secondary-foreground leading-relaxed\"\n >\n {startLineNumber + index}\n </span>\n ))}\n </div>\n <section\n className=\"flex-1 overflow-x-auto [overflow-wrap:normal] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"m-0 [overflow-wrap:normal]\">\n <code>{children}</code>\n </pre>\n </section>\n </div>\n );\n }\n\n return (\n <section\n className=\"overflow-x-auto [overflow-wrap:normal] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\"\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"m-0 [overflow-wrap:normal]\">\n <code>{children}</code>\n </pre>\n </section>\n );\n}\n\nfunction AICodeBlockContent({\n children,\n showLineNumbers = false,\n startLineNumber = 1,\n className,\n}: AICodeBlockContentProps) {\n return (\n <div\n data-slot=\"ai-code-block-content\"\n className={cn('p-4 text-sm font-mono leading-relaxed', className)}\n >\n <AICodeBlockContentBody\n showLineNumbers={showLineNumbers}\n startLineNumber={startLineNumber}\n >\n {children}\n </AICodeBlockContentBody>\n </div>\n );\n}\n\nAICodeBlockContent.displayName = 'AICodeBlockContent';\n\n// =============================================================================\n// Main AICodeBlock Component\n// =============================================================================\n\nexport interface AICodeBlockProps\n extends VariantProps<typeof codeBlockVariants> {\n /** Code content to display */\n code: string;\n /** Programming language for syntax highlighting */\n language?: string;\n /** File name to display in header */\n fileName?: string;\n /** Whether to show the header */\n showHeader?: boolean;\n /** Whether to show copy button */\n showCopyButton?: boolean;\n /** Whether to show line numbers */\n showLineNumbers?: boolean;\n /** Starting line number */\n startLineNumber?: number;\n /** Pre-highlighted HTML content */\n highlightedCode?: string;\n /** Additional class name */\n className?: string;\n /** Extra actions for the header */\n headerActions?: React.ReactNode;\n}\n\nfunction AICodeBlock({\n code,\n language = 'plaintext',\n fileName,\n showHeader = true,\n showCopyButton = true,\n showLineNumbers = false,\n startLineNumber = 1,\n highlightedCode,\n size,\n className,\n headerActions,\n}: AICodeBlockProps) {\n const highlightedContent = React.useMemo(\n () =>\n highlightedCode\n ? renderHighlightedMarkup(highlightedCode)\n : renderHighlightedCode(code),\n [code, highlightedCode],\n );\n const [copyFeedback, setCopyFeedback] = React.useReducer(\n copyFeedbackReducer,\n { copied: false, resetKey: 0 },\n );\n const { copied } = copyFeedback;\n const rootRef = React.useRef<HTMLDivElement>(null);\n\n React.useEffect(() => {\n if (!copyFeedback.copied) return;\n\n const copyResetTimer = setTimeout(() => {\n setCopyFeedback(false);\n }, 2000);\n\n return () => {\n clearTimeout(copyResetTimer);\n };\n }, [copyFeedback]);\n\n const handleCopy = React.useCallback(async () => {\n try {\n // SSR guard: access clipboard via ref's ownerDocument\n const win = rootRef.current?.ownerDocument.defaultView;\n if (!win) return;\n await win.navigator.clipboard.writeText(code);\n setCopyFeedback(true);\n } catch (err) {\n console.error('Failed to copy code:', err);\n }\n }, [code]);\n\n return (\n <div\n ref={rootRef}\n data-slot=\"ai-code-block\"\n className={cn(codeBlockVariants({ size }), className)}\n style={SUGAR_HIGH_STYLE}\n >\n {showHeader && (\n <AICodeBlockHeader\n language={language}\n fileName={fileName}\n showCopyButton={showCopyButton}\n onCopy={handleCopy}\n copied={copied}\n actions={headerActions}\n />\n )}\n <section\n className={cn(\n 'p-4 overflow-x-auto font-mono leading-relaxed [overflow-wrap:normal] !bg-transparent !m-0 !border-0 !rounded-none',\n '[&_.sh__line]:block [&_.sh__line]:leading-relaxed',\n showLineNumbers && [\n '[&_.sh__line]:[counter-increment:sh-line]',\n '[&_.sh__line]:before:[content:counter(sh-line)] [&_.sh__line]:before:inline-block [&_.sh__line]:before:w-8 [&_.sh__line]:before:me-4 [&_.sh__line]:before:text-end [&_.sh__line]:before:text-secondary-foreground [&_.sh__line]:before:select-none',\n ],\n )}\n style={\n showLineNumbers\n ? ({\n counterReset: `sh-line ${startLineNumber - 1}`,\n } as React.CSSProperties)\n : undefined\n }\n aria-label=\"Code content\"\n // biome-ignore lint/a11y/noNoninteractiveTabindex: Focusable scroll region satisfies axe scrollable-region-focusable.\n tabIndex={0}\n >\n <pre className=\"!m-0 !bg-transparent [overflow-wrap:normal]\">\n {highlightedContent}\n </pre>\n </section>\n </div>\n );\n}\n\nAICodeBlock.displayName = 'AICodeBlock';\n\nexport {\n AICodeBlock,\n AICodeBlockContent,\n AICodeBlockHeader,\n codeBlockVariants,\n};\n","export * from './AICodeBlock';\n"],"mappings":";;;;;;;;;;AAeA,IAAM,IAAoB,EACxB,qEACA;AAAA,EACE,UAAU,EACR,MAAM;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ,IAAI;AAAA,EACN,EACF;AAAA,EACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;AAOA,SAAS,EACP,GACA,GACmB;AACnB,SAAO,IACH;AAAA,IAAE,QAAQ;AAAA,IAAM,UAAU,EAAM,WAAW;AAAA,EAAE,IAC7C;AAAA,IAAE,GAAG;AAAA,IAAO,QAAQ;AAAA,EAAM;AAChC;AAuBA,SAAS,EAAkB,EACzB,UAAA,GACA,U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runtime.js";
|
|
2
2
|
import { f as M } from "./_shared.js";
|
|
3
|
-
import { t as
|
|
3
|
+
import { t as y } from "./Skeleton2.js";
|
|
4
4
|
import { n as _ } from "./AICodeBlock.js";
|
|
5
5
|
import * as l from "react";
|
|
6
6
|
import { jsx as t, jsxs as u } from "react/jsx-runtime";
|
|
@@ -275,18 +275,18 @@ function A({ maxHeight: a }) {
|
|
|
275
275
|
children: /* @__PURE__ */ u("div", {
|
|
276
276
|
className: "flex flex-col items-center gap-4 w-full max-w-md",
|
|
277
277
|
children: [
|
|
278
|
-
/* @__PURE__ */ t(
|
|
278
|
+
/* @__PURE__ */ t(y, { className: "h-4 w-3/4" }),
|
|
279
279
|
/* @__PURE__ */ u("div", {
|
|
280
280
|
className: "flex items-center justify-center gap-4 w-full",
|
|
281
281
|
children: [
|
|
282
|
-
/* @__PURE__ */ t(
|
|
283
|
-
/* @__PURE__ */ t(
|
|
284
|
-
/* @__PURE__ */ t(
|
|
285
|
-
/* @__PURE__ */ t(
|
|
286
|
-
/* @__PURE__ */ t(
|
|
282
|
+
/* @__PURE__ */ t(y, { className: "h-16 w-24 rounded-lg" }),
|
|
283
|
+
/* @__PURE__ */ t(y, { className: "h-1 w-8" }),
|
|
284
|
+
/* @__PURE__ */ t(y, { className: "h-16 w-24 rounded-lg" }),
|
|
285
|
+
/* @__PURE__ */ t(y, { className: "h-1 w-8" }),
|
|
286
|
+
/* @__PURE__ */ t(y, { className: "h-16 w-24 rounded-lg" })
|
|
287
287
|
]
|
|
288
288
|
}),
|
|
289
|
-
/* @__PURE__ */ t(
|
|
289
|
+
/* @__PURE__ */ t(y, { className: "h-4 w-1/2" })
|
|
290
290
|
]
|
|
291
291
|
})
|
|
292
292
|
});
|
|
@@ -368,13 +368,13 @@ function T({ code: a, theme: i = "auto", caption: r, interactive: e = !1, maxHei
|
|
|
368
368
|
async function b() {
|
|
369
369
|
F(!0), C(null), v(null);
|
|
370
370
|
try {
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
const V = `${O.current}-${Date.now()}`, { svg: Y } = await
|
|
371
|
+
const f = (await import("./mermaid.core.js")).default, S = G(o, w.current ?? D.current);
|
|
372
|
+
f.initialize(S);
|
|
373
|
+
const V = `${O.current}-${Date.now()}`, { svg: Y } = await f.render(V, a.trim());
|
|
374
374
|
s || (v(Y), C(null));
|
|
375
|
-
} catch (
|
|
375
|
+
} catch (f) {
|
|
376
376
|
if (!s) {
|
|
377
|
-
const S =
|
|
377
|
+
const S = f instanceof Error ? f.message : "Failed to parse diagram";
|
|
378
378
|
C(S), v(null);
|
|
379
379
|
}
|
|
380
380
|
} finally {
|
|
@@ -397,8 +397,8 @@ function T({ code: a, theme: i = "auto", caption: r, interactive: e = !1, maxHei
|
|
|
397
397
|
if (!e) return;
|
|
398
398
|
o.preventDefault();
|
|
399
399
|
const s = o.deltaY > 0 ? 0.9 : 1.1, b = Math.min(Math.max(c.scale * s, 0.5), 3);
|
|
400
|
-
d((
|
|
401
|
-
...
|
|
400
|
+
d((f) => ({
|
|
401
|
+
...f,
|
|
402
402
|
scale: b
|
|
403
403
|
}));
|
|
404
404
|
}, [
|
|
@@ -537,7 +537,7 @@ function T({ code: a, theme: i = "auto", caption: r, interactive: e = !1, maxHei
|
|
|
537
537
|
})
|
|
538
538
|
}),
|
|
539
539
|
/* @__PURE__ */ u("span", {
|
|
540
|
-
className: "text-xs text-
|
|
540
|
+
className: "text-xs text-secondary-foreground px-1 tabular-nums",
|
|
541
541
|
children: [Math.round(c.scale * 100), "%"]
|
|
542
542
|
})
|
|
543
543
|
]
|