@conscience-technology/ovenn 0.6.7 → 0.7.2
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/assets/components/AIMessage/AIMessage.module.css +23 -1
- package/assets/components/AIMessage/AIMessage.tsx +27 -7
- package/assets/components/Accordion/Accordion.module.css +3 -0
- package/assets/components/AppFrame/AppFrame.module.css +2 -0
- package/assets/components/AttachmentItem/AttachmentItem.module.css +50 -13
- package/assets/components/AttachmentItem/AttachmentItem.tsx +25 -8
- package/assets/components/AttachmentThumb/AttachmentThumb.module.css +12 -9
- package/assets/components/Avatar/Avatar.module.css +26 -11
- package/assets/components/Avatar/Avatar.tsx +1 -1
- package/assets/components/AvatarUpload/AvatarUpload.module.css +4 -3
- package/assets/components/Badge/Badge.module.css +96 -70
- package/assets/components/Badge/Badge.tsx +33 -25
- package/assets/components/Breadcrumb/Breadcrumb.module.css +8 -4
- package/assets/components/Breadcrumb/Breadcrumb.tsx +1 -1
- package/assets/components/Bubble/Bubble.module.css +6 -0
- package/assets/components/Button/Button.module.css +6 -0
- package/assets/components/Calendar/Calendar.module.css +244 -0
- package/assets/components/Calendar/Calendar.tsx +419 -0
- package/assets/components/Calendar/index.ts +2 -0
- package/assets/components/Callout/Callout.module.css +54 -7
- package/assets/components/Callout/Callout.tsx +26 -2
- package/assets/components/Callout/index.ts +1 -1
- package/assets/components/Canvas/Canvas.module.css +75 -0
- package/assets/components/Canvas/Canvas.tsx +699 -0
- package/assets/components/Canvas/alignment.ts +34 -0
- package/assets/components/Canvas/clipboard.ts +30 -0
- package/assets/components/Canvas/collision.ts +67 -0
- package/assets/components/Canvas/edgeOptions.ts +11 -0
- package/assets/components/Canvas/graph.ts +11 -0
- package/assets/components/Canvas/history.ts +41 -0
- package/assets/components/Canvas/index.ts +4 -0
- package/assets/components/Canvas/selection.ts +56 -0
- package/assets/components/Canvas/tokens.css +61 -0
- package/assets/components/Canvas/types.ts +27 -0
- package/assets/components/Canvas/useCanvasSettlement.ts +79 -0
- package/assets/components/CanvasEdge/CanvasEdge.module.css +62 -0
- package/assets/components/CanvasEdge/CanvasEdge.tsx +121 -0
- package/assets/components/CanvasEdge/geometry.ts +350 -0
- package/assets/components/CanvasEdge/index.ts +4 -0
- package/assets/components/CanvasEdge/interactions.ts +14 -0
- package/assets/components/CanvasEdge/tokens.css +29 -0
- package/assets/components/CanvasNode/CanvasNode.module.css +234 -30
- package/assets/components/CanvasNode/CanvasNode.tsx +95 -28
- package/assets/components/CanvasNode/index.ts +1 -1
- package/assets/components/CanvasNode/runningOutline.ts +59 -0
- package/assets/components/CanvasNode/tokens.css +76 -13
- package/assets/components/Card/Card.module.css +5 -0
- package/assets/components/Chart/Chart.module.css +278 -0
- package/assets/components/Chart/Chart.tsx +385 -0
- package/assets/components/Chart/entrance.tsx +57 -0
- package/assets/components/Chart/index.ts +14 -0
- package/assets/components/ChatComposer/ChatComposer.module.css +17 -0
- package/assets/components/ChatComposer/ChatComposer.tsx +131 -0
- package/assets/components/ChatComposer/index.ts +2 -0
- package/assets/components/ChatInput/ChatInput.module.css +197 -30
- package/assets/components/ChatInput/ChatInput.tsx +137 -45
- package/assets/components/ChatInput/SendButton.tsx +4 -1
- package/assets/components/ChatInput/index.ts +5 -0
- package/assets/components/ChatMessage/ChatMessage.module.css +19 -0
- package/assets/components/ChatMessage/ChatMessage.tsx +63 -0
- package/assets/components/ChatMessage/index.ts +2 -0
- package/assets/components/ChatReactions/ChatReactions.module.css +15 -0
- package/assets/components/ChatReactions/ChatReactions.tsx +58 -0
- package/assets/components/ChatReactions/index.ts +2 -0
- package/assets/components/Checkbox/Checkbox.module.css +39 -0
- package/assets/components/Checkbox/Checkbox.tsx +99 -14
- package/assets/components/Checkbox/index.ts +1 -1
- package/assets/components/CheckboxCard/CheckboxCard.module.css +1 -177
- package/assets/components/CheckboxCard/CheckboxCard.tsx +6 -72
- package/assets/components/Chip/Chip.module.css +20 -30
- package/assets/components/Code/Code.module.css +1 -0
- package/assets/components/CodeBlock/CodeBlock.module.css +113 -13
- package/assets/components/CodeBlock/CodeBlock.tsx +114 -29
- package/assets/components/CodeBlock/SyntaxHighlight.tsx +20 -0
- package/assets/components/CodeBlock/diff-lines.ts +21 -0
- package/assets/components/CodeBlock/index.ts +2 -1
- package/assets/components/CodeBlock/line-preview.ts +7 -0
- package/assets/components/CodeBlock/syntax-highlighter.ts +96 -0
- package/assets/components/CodeBlock/use-syntax-tokens.ts +17 -0
- package/assets/components/ColorArea/ColorArea.module.css +3 -0
- package/assets/components/ColorField/ColorField.module.css +19 -190
- package/assets/components/ColorField/ColorField.tsx +116 -107
- package/assets/components/ColorPicker/ColorPicker.module.css +310 -0
- package/assets/components/ColorPicker/ColorPicker.tsx +387 -0
- package/assets/components/ColorPicker/index.ts +16 -0
- package/assets/components/ColorSlider/ColorSlider.module.css +15 -12
- package/assets/components/ColorSlider/ColorSlider.tsx +3 -3
- package/assets/components/ColorSwatch/ColorSwatch.module.css +2 -2
- package/assets/components/ColorSwatchPicker/ColorSwatchPicker.module.css +4 -3
- package/assets/components/Combobox/Combobox.module.css +21 -4
- package/assets/components/Combobox/Combobox.tsx +38 -22
- package/assets/components/CommandPalette/CommandPalette.module.css +19 -24
- package/assets/components/CommandPalette/CommandPalette.tsx +7 -5
- package/assets/components/Comment/Comment.module.css +25 -0
- package/assets/components/Comment/Comment.tsx +44 -0
- package/assets/components/Comment/CommentComposer.module.css +26 -0
- package/assets/components/Comment/CommentComposer.tsx +56 -0
- package/assets/components/Comment/CommentEditor.module.css +8 -0
- package/assets/components/Comment/CommentEditor.tsx +43 -0
- package/assets/components/Comment/CommentMentionInput.module.css +9 -0
- package/assets/components/Comment/CommentMentionInput.tsx +150 -0
- package/assets/components/Comment/index.ts +9 -0
- package/assets/components/Comment/types.ts +1 -0
- package/assets/components/ContextMenu/ContextMenu.module.css +5 -2
- package/assets/components/ContextMenu/ContextMenu.tsx +5 -0
- package/assets/components/ControlGroup/ControlGroup.module.css +20 -7
- package/assets/components/DataTable/DataTable.module.css +2 -0
- package/assets/components/DatePicker/DateField.tsx +72 -25
- package/assets/components/DatePicker/DatePicker.module.css +56 -54
- package/assets/components/DatePicker/DatePicker.tsx +86 -40
- package/assets/components/DatePicker/TimeSelector.tsx +1 -1
- package/assets/components/Disclosure/Disclosure.module.css +1 -0
- package/assets/components/Drawer/Drawer.module.css +23 -19
- package/assets/components/Drawer/Drawer.tsx +20 -24
- package/assets/components/DropdownMenu/DropdownMenu.tsx +5 -0
- package/assets/components/EmojiPicker/EmojiGlyph.module.css +2 -0
- package/assets/components/EmojiPicker/EmojiGlyph.tsx +12 -0
- package/assets/components/EmojiPicker/EmojiPicker.module.css +43 -0
- package/assets/components/EmojiPicker/EmojiPicker.tsx +143 -0
- package/assets/components/EmojiPicker/UNICODE-LICENSE.txt +39 -0
- package/assets/components/EmojiPicker/data.ts +41 -0
- package/assets/components/EmojiPicker/emojiData-0.json +1 -0
- package/assets/components/EmojiPicker/emojiData-1.json +1 -0
- package/assets/components/EmojiPicker/emojiData-2.json +1 -0
- package/assets/components/EmojiPicker/emojiData-3.json +1 -0
- package/assets/components/EmojiPicker/emojiData.sources.json +35 -0
- package/assets/components/EmojiPicker/emojiData.ts +8 -0
- package/assets/components/EmojiPicker/emojiFallbacks.json +1 -0
- package/assets/components/EmojiPicker/index.ts +4 -0
- package/assets/components/EmptyState/EmptyState.module.css +2 -2
- package/assets/components/EventChip/EventChip.module.css +120 -53
- package/assets/components/EventChip/EventChip.tsx +54 -6
- package/assets/components/EventChip/index.ts +1 -1
- package/assets/components/EventListItem/EventListItem.module.css +3 -0
- package/assets/components/EventListItem/EventListItem.tsx +15 -8
- package/assets/components/FileIcon/FileIcon.module.css +6 -6
- package/assets/components/FileUpload/FileUpload.module.css +10 -3
- package/assets/components/FileUpload/FileUpload.tsx +5 -9
- package/assets/components/FileUpload/FileUploadItem.tsx +34 -0
- package/assets/components/GalleryItem/GalleryItem.module.css +16 -19
- package/assets/components/GeneratedImage/GeneratedImage.module.css +2 -0
- package/assets/components/Icon/Icon.tsx +264 -1088
- package/assets/components/Icon/LucideFamilyIcon.tsx +436 -0
- package/assets/components/Icon/MissingIcon.tsx +25 -0
- package/assets/components/Icon/SolarFamilyIcon.tsx +443 -0
- package/assets/components/Icon/catalogNames.ts +8 -0
- package/assets/components/Icon/context.tsx +1 -1
- package/assets/components/Icon/index.ts +2 -0
- package/assets/components/Icon/lucideCatalog.ts +11358 -0
- package/assets/components/Icon/phosphorCatalog.ts +3052 -0
- package/assets/components/Icon/solarCatalog.ts +16064 -0
- package/assets/components/IconButton/IconButton.module.css +3 -2
- package/assets/components/Input/Input.module.css +63 -22
- package/assets/components/Input/Input.tsx +21 -10
- package/assets/components/Kanban/Kanban.module.css +6 -0
- package/assets/components/ListItem/ListItem.module.css +9 -6
- package/assets/components/MenuItem/MenuItem.module.css +24 -22
- package/assets/components/MenuItem/MenuItem.tsx +12 -12
- package/assets/components/MessageActions/MessageActions.module.css +38 -2
- package/assets/components/MessageActions/MessageActions.tsx +53 -28
- package/assets/components/MessageQuote/MessageQuote.module.css +1 -0
- package/assets/components/MessageSources/MessageSources.module.css +2 -0
- package/assets/components/MessageState/MessageState.module.css +1 -1
- package/assets/components/MetricCard/MetricCard.module.css +96 -108
- package/assets/components/MetricCard/MetricCard.tsx +45 -23
- package/assets/components/MetricCard/tokens.css +10 -0
- package/assets/components/MiniCalendar/MiniCalendar.module.css +130 -0
- package/assets/components/MiniCalendar/MiniCalendar.tsx +161 -0
- package/assets/components/MiniCalendar/index.ts +2 -0
- package/assets/components/Modal/Modal.module.css +13 -4
- package/assets/components/Modal/Modal.tsx +4 -0
- package/assets/components/Onboarding/LayoutBuilder.tsx +12 -50
- package/assets/components/Onboarding/Onboarding.module.css +211 -278
- package/assets/components/Onboarding/OnboardingAxisPanel.tsx +81 -125
- package/assets/components/Onboarding/OnboardingPage.tsx +244 -467
- package/assets/components/Onboarding/actions.ts +5 -0
- package/assets/components/Onboarding/palette.css +8 -0
- package/assets/components/Onboarding/wizardData.ts +8 -8
- package/assets/components/ProgressBar/ProgressBar.module.css +42 -8
- package/assets/components/ProgressBar/ProgressBar.tsx +5 -6
- package/assets/components/ProgressBar/index.ts +0 -1
- package/assets/components/QuotationBar/QuotationBar.module.css +2 -0
- package/assets/components/Radio/Radio.module.css +2 -0
- package/assets/components/RadioCard/RadioCard.module.css +96 -3
- package/assets/components/RadioCard/RadioCard.tsx +76 -13
- package/assets/components/RadioCard/index.ts +1 -1
- package/assets/components/SegmentedChart/SegmentedChart.module.css +16 -0
- package/assets/components/SegmentedChart/SegmentedChart.tsx +25 -8
- package/assets/components/Select/Select.module.css +9 -7
- package/assets/components/Select/Select.tsx +22 -6
- package/assets/components/Shortcut/Shortcut.module.css +2 -0
- package/assets/components/Sidebar/Sidebar.module.css +1 -0
- package/assets/components/Sidebar/Sidebar.tsx +2 -2
- package/assets/components/Skeleton/Skeleton.module.css +33 -0
- package/assets/components/Skeleton/Skeleton.tsx +20 -0
- package/assets/components/Skeleton/index.ts +2 -0
- package/assets/components/Skeleton/tokens.css +11 -0
- package/assets/components/Slider/Slider.module.css +3 -0
- package/assets/components/Slider/Slider.tsx +7 -2
- package/assets/components/Spinner/LottiePlayer.tsx +4 -4
- package/assets/components/Spinner/Spinner.module.css +3 -0
- package/assets/components/Spinner/lottieManifest.ts +3 -0
- package/assets/components/Stepper/Stepper.module.css +56 -8
- package/assets/components/Stepper/Stepper.tsx +13 -4
- package/assets/components/Switch/Switch.module.css +55 -42
- package/assets/components/Switch/Switch.tsx +6 -2
- package/assets/components/Switch/index.ts +1 -1
- package/assets/components/TabStrip/TabStrip.module.css +5 -1
- package/assets/components/TableCell/TableCell.module.css +8 -1
- package/assets/components/TableCell/TableCellBadge.tsx +7 -3
- package/assets/components/TableCell/TableCellImage.tsx +1 -1
- package/assets/components/TableCell/TableCellTag.tsx +23 -0
- package/assets/components/TableCell/index.ts +3 -0
- package/assets/components/TableHeader/TableHeader.module.css +4 -0
- package/assets/components/TableRow/TableRow.module.css +3 -0
- package/assets/components/TableRowEdit/TableRowEdit.module.css +2 -0
- package/assets/components/TableToolbar/TableToolbar.module.css +1 -0
- package/assets/components/Tabs/Tabs.module.css +23 -8
- package/assets/components/Tabs/Tabs.tsx +4 -3
- package/assets/components/Tag/Tag.module.css +101 -0
- package/assets/components/Tag/Tag.tsx +55 -0
- package/assets/components/Tag/index.ts +2 -0
- package/assets/components/TemplateBoundary/TemplateBoundary.tsx +22 -18
- package/assets/components/TemplateBoundary/types.ts +2 -0
- package/assets/components/Textarea/Textarea.module.css +30 -226
- package/assets/components/Textarea/Textarea.tsx +2 -2
- package/assets/components/ThemeController.tsx +30 -3
- package/assets/components/TimePicker/TimePicker.module.css +17 -4
- package/assets/components/TimePicker/TimePicker.tsx +102 -23
- package/assets/components/TimelineView/TimelineEventBar.tsx +109 -0
- package/assets/components/TimelineView/TimelineView.module.css +203 -0
- package/assets/components/TimelineView/TimelineView.tsx +137 -0
- package/assets/components/TimelineView/axis.ts +62 -0
- package/assets/components/TimelineView/index.ts +3 -0
- package/assets/components/TimelineView/layout.ts +56 -0
- package/assets/components/TimelineView/move.ts +51 -0
- package/assets/components/TimelineView/useTimelineDrag.ts +215 -0
- package/assets/components/TimelineView/useTimelineZoom.ts +92 -0
- package/assets/components/Toast/Toast.module.css +20 -0
- package/assets/components/Toast/Toast.tsx +1 -1
- package/assets/components/Toolbar/Toolbar.module.css +31 -24
- package/assets/components/Toolbar/Toolbar.tsx +4 -3
- package/assets/components/Tooltip/Tooltip.module.css +10 -0
- package/assets/components/Tooltip/Tooltip.tsx +50 -15
- package/assets/components/TopLoader/TopLoader.module.css +1 -0
- package/assets/components/TreeNav/TreeNav.module.css +1 -0
- package/assets/components/UserMessage/UserMessage.module.css +110 -1
- package/assets/components/UserMessage/UserMessage.tsx +138 -16
- package/assets/components/UserMessage/index.ts +4 -0
- package/assets/components/_color.ts +2 -2
- package/assets/components/_data.ts +37 -31
- package/assets/components/_utils.css +36 -5
- package/assets/components/axisOptions.ts +2 -0
- package/assets/components/component-registry.json +1731 -94
- package/assets/components/index.ts +23 -0
- package/assets/components/materialScope.tsx +11 -0
- package/assets/components/reset.css +1 -0
- package/assets/components/themeBootScript.ts +3 -2
- package/assets/components/tokens.css +308 -71
- package/assets/components/useChartEntrance.ts +119 -0
- package/assets/prompts/ASSEMBLY.md +20 -7
- package/assets/prompts/CATALOG.md +110 -92
- package/assets/prompts/FEEDBACK_PROCESS.md +19 -0
- package/assets/prompts/PRINCIPLES.md +25 -1
- package/assets/prompts/TEMPLATE_PREVIEWS.md +21 -0
- package/assets/prompts/WORKFLOW_DESIGN.md +48 -70
- package/assets/prompts/axes/font.md +12 -1
- package/assets/prompts/axes/icon.md +6 -4
- package/assets/prompts/axes/material.md +40 -0
- package/assets/prompts/axes/motion.md +2 -0
- package/assets/prompts/axes/palette.md +10 -2
- package/assets/prompts/axes/shape.md +8 -0
- package/assets/prompts/axes/voice.md +4 -0
- package/assets/prompts/components/README.md +3 -3
- package/assets/prompts/components/_variants.md +35 -35
- package/assets/prompts/components/accordion.md +15 -15
- package/assets/prompts/components/ai-message.md +14 -12
- package/assets/prompts/components/app-frame.md +16 -16
- package/assets/prompts/components/attachment-item.md +38 -31
- package/assets/prompts/components/attachment-thumb.md +14 -12
- package/assets/prompts/components/avatar-upload.md +10 -10
- package/assets/prompts/components/avatar.md +16 -16
- package/assets/prompts/components/badge.md +32 -97
- package/assets/prompts/components/breadcrumb.md +25 -24
- package/assets/prompts/components/bubble.md +13 -13
- package/assets/prompts/components/button-group.md +1 -1
- package/assets/prompts/components/button.md +36 -36
- package/assets/prompts/components/calendar.md +151 -0
- package/assets/prompts/components/callout.md +39 -23
- package/assets/prompts/components/canvas-edge.md +70 -0
- package/assets/prompts/components/canvas-node.md +27 -10
- package/assets/prompts/components/canvas.md +85 -0
- package/assets/prompts/components/card.md +31 -31
- package/assets/prompts/components/chart-bar.md +77 -0
- package/assets/prompts/components/chart-pie.md +63 -0
- package/assets/prompts/components/chart-radar.md +56 -0
- package/assets/prompts/components/chart-radial.md +56 -0
- package/assets/prompts/components/chart.md +129 -0
- package/assets/prompts/components/chat-composer.md +71 -0
- package/assets/prompts/components/chat-input.md +82 -27
- package/assets/prompts/components/chat-message.md +48 -0
- package/assets/prompts/components/chat-reactions.md +38 -0
- package/assets/prompts/components/checkbox-card.md +26 -45
- package/assets/prompts/components/checkbox.md +40 -17
- package/assets/prompts/components/chip.md +34 -34
- package/assets/prompts/components/code-block.md +109 -65
- package/assets/prompts/components/code.md +4 -4
- package/assets/prompts/components/color-area.md +9 -9
- package/assets/prompts/components/color-field.md +17 -13
- package/assets/prompts/components/color-picker.md +173 -0
- package/assets/prompts/components/color-slider.md +14 -14
- package/assets/prompts/components/color-swatch-picker.md +8 -8
- package/assets/prompts/components/color-swatch.md +9 -9
- package/assets/prompts/components/combobox.md +5 -2
- package/assets/prompts/components/command-palette.md +31 -30
- package/assets/prompts/components/comment.md +75 -0
- package/assets/prompts/components/context-menu.md +28 -25
- package/assets/prompts/components/control-group.md +4 -4
- package/assets/prompts/components/data-table.md +9 -0
- package/assets/prompts/components/date-picker.md +41 -23
- package/assets/prompts/components/disclosure.md +10 -10
- package/assets/prompts/components/drawer.md +29 -18
- package/assets/prompts/components/dropdown-menu.md +23 -21
- package/assets/prompts/components/emoji-picker.md +45 -0
- package/assets/prompts/components/empty-state.md +20 -18
- package/assets/prompts/components/event-chip.md +70 -28
- package/assets/prompts/components/event-list-item.md +32 -28
- package/assets/prompts/components/file-icon.md +18 -19
- package/assets/prompts/components/file-upload.md +1 -1
- package/assets/prompts/components/gallery-item.md +24 -23
- package/assets/prompts/components/generated-image.md +10 -10
- package/assets/prompts/components/hint.md +19 -19
- package/assets/prompts/components/icon-button.md +16 -16
- package/assets/prompts/components/icon.md +42 -17
- package/assets/prompts/components/input.md +49 -46
- package/assets/prompts/components/kanban.md +35 -35
- package/assets/prompts/components/list-item.md +50 -41
- package/assets/prompts/components/menu-item.md +49 -44
- package/assets/prompts/components/message-actions.md +15 -6
- package/assets/prompts/components/message-quote.md +7 -7
- package/assets/prompts/components/message-sources.md +10 -10
- package/assets/prompts/components/message-state.md +17 -17
- package/assets/prompts/components/message-table.md +5 -5
- package/assets/prompts/components/metric-card.md +57 -109
- package/assets/prompts/components/mini-calendar.md +77 -0
- package/assets/prompts/components/modal.md +40 -39
- package/assets/prompts/components/multi-select.md +4 -1
- package/assets/prompts/components/onboarding.md +23 -19
- package/assets/prompts/components/page-header.md +42 -33
- package/assets/prompts/components/pagination.md +17 -17
- package/assets/prompts/components/progress-bar.md +26 -13
- package/assets/prompts/components/quotation-bar.md +10 -10
- package/assets/prompts/components/radio-card.md +34 -117
- package/assets/prompts/components/radio.md +9 -9
- package/assets/prompts/components/segmented-chart.md +19 -5
- package/assets/prompts/components/select.md +29 -25
- package/assets/prompts/components/shortcut.md +11 -11
- package/assets/prompts/components/sidebar.md +67 -58
- package/assets/prompts/components/skeleton.md +47 -0
- package/assets/prompts/components/slider.md +18 -18
- package/assets/prompts/components/spinner.md +16 -16
- package/assets/prompts/components/stepper.md +29 -15
- package/assets/prompts/components/switch.md +30 -26
- package/assets/prompts/components/tab-strip.md +32 -31
- package/assets/prompts/components/table-cell.md +9 -7
- package/assets/prompts/components/table-header.md +16 -16
- package/assets/prompts/components/table-row-edit.md +19 -19
- package/assets/prompts/components/table-row-select.md +9 -9
- package/assets/prompts/components/table-row.md +29 -20
- package/assets/prompts/components/table-toolbar.md +9 -0
- package/assets/prompts/components/tabs.md +30 -27
- package/assets/prompts/components/tag.md +54 -0
- package/assets/prompts/components/textarea.md +16 -15
- package/assets/prompts/components/time-picker.md +22 -14
- package/assets/prompts/components/timeline-view.md +129 -0
- package/assets/prompts/components/toast.md +43 -42
- package/assets/prompts/components/toolbar.md +36 -23
- package/assets/prompts/components/tooltip.md +36 -17
- package/assets/prompts/components/top-loader.md +12 -12
- package/assets/prompts/components/topbar.md +43 -34
- package/assets/prompts/components/tree-nav.md +10 -10
- package/assets/prompts/components/user-message.md +23 -12
- package/assets/prompts/design-examples/README.md +1 -1
- package/assets/prompts/design-examples/ai-chat-full-page.png +0 -0
- package/assets/prompts/design-examples/catalog.json +124 -1
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.module.css +346 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/ChatExperience.tsx +375 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/FullPageChat.tsx +8 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/REFERENCE.md +19 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useChatDemo.ts +139 -0
- package/assets/prompts/design-examples/sources/ai-chat-full-page/useDemoTextStream.ts +30 -0
- package/assets/prompts/primitives/emerge.md +2 -0
- package/assets/prompts/templates/README.md +1 -1
- package/assets/prompts/templates/ains.md +9 -1
- package/assets/prompts/templates/aurora.md +5 -4
- package/assets/prompts/templates/minimal.md +14 -6
- package/assets/prompts/templates/onboarding.md +156 -0
- package/assets/prompts/templates/workspace.md +16 -11
- package/assets/prompts/tokens/color.md +11 -4
- package/assets/prompts/tokens/material.md +51 -0
- package/assets/prompts/tokens/radius.md +34 -0
- package/assets/prompts/tokens/typography.md +24 -2
- package/assets/prompts/use-cases/chart-chart-area.md +1334 -0
- package/assets/prompts/use-cases/chart-chart-bar.md +1886 -0
- package/assets/prompts/use-cases/chart-chart-pie.md +1031 -0
- package/assets/prompts/use-cases/chart-chart-radar.md +785 -0
- package/assets/prompts/use-cases/chart-chart-radial.md +988 -0
- package/assets/prompts/use-cases/chart-segmented-chart.md +262 -0
- package/assets/prompts/use-cases/chat-chat-composer.md +529 -0
- package/assets/prompts/use-cases/chat-chat-input.md +1766 -0
- package/assets/prompts/use-cases/data-comment.md +360 -0
- package/assets/prompts/use-cases/data-data-table.md +249 -0
- package/assets/prompts/use-cases/data-list-item.md +1056 -0
- package/assets/prompts/use-cases/data-metric-card.md +673 -0
- package/assets/prompts/use-cases/data-table-row.md +966 -0
- package/assets/prompts/use-cases/data-table-toolbar.md +481 -0
- package/assets/prompts/use-cases/feedback-drawer.md +1168 -0
- package/assets/prompts/use-cases/feedback-progress-bar.md +432 -0
- package/assets/prompts/use-cases/general-toolbar.md +854 -0
- package/assets/prompts/use-cases/general-tooltip.md +652 -0
- package/assets/prompts/use-cases/input-checkbox.md +443 -0
- package/assets/prompts/use-cases/structure-card.md +603 -0
- package/assets/prompts/use-cases/structure-page-header.md +755 -0
- package/assets/prompts/use-cases/structure-sidebar.md +1132 -0
- package/assets/prompts/use-cases/structure-topbar.md +1196 -0
- package/assets/public/ovenn-wordmark.svg +19 -0
- package/assets/skills/ovenn-wireframe/SKILL.md +17 -4
- package/package.json +10 -2
- package/src/commands/info.js +1 -1
- package/src/utils/design-examples.js +3 -4
- package/assets/prompts/templates/glass-button.md +0 -336
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
접힘 애니메이션은 측정된 max-height 전환 — body는 항상 렌더. */
|
|
4
4
|
|
|
5
5
|
.root {
|
|
6
|
+
--syntax-foreground: var(--fg-strong);
|
|
7
|
+
--syntax-background: var(--bg);
|
|
6
8
|
position: relative;
|
|
9
|
+
corner-shape: var(--corner-shape);
|
|
7
10
|
border-radius: var(--radius-md);
|
|
8
11
|
overflow: hidden;
|
|
9
12
|
width: 100%;
|
|
@@ -21,12 +24,15 @@
|
|
|
21
24
|
display: flex;
|
|
22
25
|
align-items: center;
|
|
23
26
|
justify-content: space-between;
|
|
24
|
-
padding: var(--space-2);
|
|
27
|
+
padding: var(--space-2) var(--space-4);
|
|
25
28
|
gap: var(--space-2);
|
|
26
29
|
color: var(--fg-muted);
|
|
27
30
|
min-height: calc(var(--size-6) + var(--size-2) * 2);
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/* Header controls share the existing copy action without changing peek mode. */
|
|
34
|
+
.headerActions { display: flex; align-items: center; flex-shrink: 0; gap: var(--space-1); }
|
|
35
|
+
|
|
30
36
|
/* 비접힘 상태의 좌측 — 아이콘 + 언어 라벨. toggle이 있을 땐 안 보임. */
|
|
31
37
|
.lang {
|
|
32
38
|
min-width: 0;
|
|
@@ -46,7 +52,7 @@
|
|
|
46
52
|
overflow: hidden;
|
|
47
53
|
text-overflow: ellipsis;
|
|
48
54
|
white-space: nowrap;
|
|
49
|
-
line-height:
|
|
55
|
+
line-height: var(--lh-xs);
|
|
50
56
|
}
|
|
51
57
|
|
|
52
58
|
/* 접기 토글 — 좌측 lang 자리를 대체. 모양·크기는 lang과 일관되게 유지해
|
|
@@ -65,6 +71,7 @@
|
|
|
65
71
|
font-size: var(--text-xs);
|
|
66
72
|
line-height: 1;
|
|
67
73
|
cursor: pointer;
|
|
74
|
+
corner-shape: var(--corner-shape);
|
|
68
75
|
border-radius: var(--radius-sm);
|
|
69
76
|
transition: var(--transition-colors);
|
|
70
77
|
}
|
|
@@ -73,7 +80,7 @@
|
|
|
73
80
|
}
|
|
74
81
|
.toggle:focus-visible {
|
|
75
82
|
outline: none;
|
|
76
|
-
|
|
83
|
+
background: var(--hover);
|
|
77
84
|
}
|
|
78
85
|
.toggleChevron {
|
|
79
86
|
flex-shrink: 0;
|
|
@@ -90,7 +97,7 @@
|
|
|
90
97
|
overflow: hidden;
|
|
91
98
|
text-overflow: ellipsis;
|
|
92
99
|
white-space: nowrap;
|
|
93
|
-
line-height:
|
|
100
|
+
line-height: var(--lh-xs);
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
/* Copy 버튼 — 접힘 상태에선 opacity·pointer-events로만 숨기고 공간은 유지
|
|
@@ -105,6 +112,7 @@
|
|
|
105
112
|
border: 0;
|
|
106
113
|
background: transparent;
|
|
107
114
|
color: var(--fg-muted);
|
|
115
|
+
corner-shape: var(--corner-shape);
|
|
108
116
|
border-radius: var(--radius-sm);
|
|
109
117
|
cursor: pointer;
|
|
110
118
|
width: var(--size-6);
|
|
@@ -119,6 +127,7 @@
|
|
|
119
127
|
content: "";
|
|
120
128
|
position: absolute;
|
|
121
129
|
inset: 0;
|
|
130
|
+
corner-shape: inherit;
|
|
122
131
|
border-radius: inherit;
|
|
123
132
|
background: var(--hover);
|
|
124
133
|
opacity: 0;
|
|
@@ -135,7 +144,7 @@
|
|
|
135
144
|
}
|
|
136
145
|
.copyBtn:focus-visible {
|
|
137
146
|
outline: none;
|
|
138
|
-
|
|
147
|
+
background: var(--hover);
|
|
139
148
|
}
|
|
140
149
|
.root[data-collapsible]:not([data-open]) .copyBtn {
|
|
141
150
|
opacity: 0;
|
|
@@ -170,7 +179,7 @@
|
|
|
170
179
|
padding: var(--space-2) var(--space-4) var(--space-4);
|
|
171
180
|
font-family: var(--font-code);
|
|
172
181
|
font-size: var(--text-sm);
|
|
173
|
-
line-height:
|
|
182
|
+
line-height: var(--lh-code);
|
|
174
183
|
color: var(--fg-strong);
|
|
175
184
|
white-space: pre;
|
|
176
185
|
word-wrap: normal;
|
|
@@ -238,18 +247,109 @@
|
|
|
238
247
|
z-index: var(--z-raised);
|
|
239
248
|
}
|
|
240
249
|
|
|
241
|
-
/* 하이라이터 토큰 — ReactNode로 넘어온 span의 data-tok 속성에 색 공급. */
|
|
250
|
+
/* Legacy external ReactNode 하이라이터 토큰 — ReactNode로 넘어온 span의 data-tok 속성에 색 공급. */
|
|
242
251
|
.code [data-tok] {
|
|
243
252
|
font-family: inherit;
|
|
244
253
|
/* syntax 로컬 토큰: keyword·builtin 전용. primary 와 구분 톤. */
|
|
245
|
-
--tok-accent:
|
|
254
|
+
--tok-accent: var(--syntax-token-keyword);
|
|
246
255
|
}
|
|
247
256
|
/* 역할 있는 토큰만 명시 색. 나머지(attr/punct/plain)는 .code color 상속(접힘=subtle, 펼침=muted). */
|
|
248
257
|
.code [data-tok="comment"] { color: var(--fg-subtle); font-style: italic; }
|
|
249
|
-
.code [data-tok="string"] { color: var(--
|
|
250
|
-
.code [data-tok="keyword"] { color: var(--tok-accent); font-weight: var(--font-weight-
|
|
251
|
-
.code [data-tok="builtin"] { color: var(--
|
|
252
|
-
.code [data-tok="tag"] { color: var(--
|
|
253
|
-
.code [data-tok="number"] { color: var(--
|
|
258
|
+
.code [data-tok="string"] { color: var(--syntax-token-string); }
|
|
259
|
+
.code [data-tok="keyword"] { color: var(--tok-accent); font-weight: var(--font-weight-book); }
|
|
260
|
+
.code [data-tok="builtin"] { color: var(--syntax-token-function); }
|
|
261
|
+
.code [data-tok="tag"] { color: var(--syntax-token-function); }
|
|
262
|
+
.code [data-tok="number"] { color: var(--syntax-token-constant); }
|
|
254
263
|
.code [data-tok="attr"] { color: inherit; }
|
|
255
264
|
.code [data-tok="punct"] { color: inherit; }
|
|
265
|
+
|
|
266
|
+
/* Fixed dark palette: independent of the surrounding page mode. */
|
|
267
|
+
.root[data-variant="dark"] {
|
|
268
|
+
--code-dark-accent: var(--syntax-dark-keyword);
|
|
269
|
+
--code-dark-string: var(--syntax-dark-string);
|
|
270
|
+
--bg: var(--code-dark-bg);
|
|
271
|
+
--fg: var(--code-dark-fg);
|
|
272
|
+
--fg-strong: var(--code-dark-fg);
|
|
273
|
+
--fg-muted: var(--code-dark-muted);
|
|
274
|
+
--fg-subtle: var(--code-dark-muted);
|
|
275
|
+
--fg-disabled: var(--code-dark-muted);
|
|
276
|
+
--hover: var(--code-dark-hover);
|
|
277
|
+
--primary: var(--code-dark-accent);
|
|
278
|
+
background: var(--code-dark-bg);
|
|
279
|
+
color-scheme: dark;
|
|
280
|
+
}
|
|
281
|
+
.root[data-variant="dark"] .code [data-tok="string"] { color: var(--code-dark-string); }
|
|
282
|
+
.root[data-variant="dark"] .code [data-tok="keyword"],
|
|
283
|
+
.root[data-variant="dark"] .code [data-tok="builtin"] { color: var(--code-dark-accent); }
|
|
284
|
+
.code:focus-visible { outline: none; background: var(--hover); }
|
|
285
|
+
.code[data-lines] { padding-inline: 0; }
|
|
286
|
+
.code[data-lines] > code { display: block; min-width: max-content; }
|
|
287
|
+
.line {
|
|
288
|
+
display: flex;
|
|
289
|
+
min-height: calc(var(--text-sm) * var(--lh-code));
|
|
290
|
+
padding-inline: var(--space-4);
|
|
291
|
+
}
|
|
292
|
+
.line[data-highlighted] { background: var(--hover); }
|
|
293
|
+
.lineNumber {
|
|
294
|
+
flex-shrink: 0;
|
|
295
|
+
min-width: var(--size-8);
|
|
296
|
+
padding-right: var(--space-4);
|
|
297
|
+
text-align: right;
|
|
298
|
+
color: var(--fg-muted);
|
|
299
|
+
user-select: none;
|
|
300
|
+
}
|
|
301
|
+
.lineContent { flex: 1; }
|
|
302
|
+
|
|
303
|
+
.root[data-diff] {
|
|
304
|
+
--diff-addition-bg: var(--success-subtle);
|
|
305
|
+
--diff-deletion-bg: var(--destructive-subtle);
|
|
306
|
+
--diff-addition: var(--success);
|
|
307
|
+
--diff-deletion: var(--destructive);
|
|
308
|
+
}
|
|
309
|
+
.root[data-variant="dark"] {
|
|
310
|
+
--diff-addition-bg: var(--code-dark-addition-bg);
|
|
311
|
+
--diff-deletion-bg: var(--code-dark-deletion-bg);
|
|
312
|
+
--diff-addition: var(--code-dark-addition);
|
|
313
|
+
--diff-deletion: var(--code-dark-deletion);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
.diffLine {
|
|
318
|
+
display: flex;
|
|
319
|
+
padding-inline: var(--space-4);
|
|
320
|
+
min-height: calc(var(--text-sm) * var(--lh-code));
|
|
321
|
+
}
|
|
322
|
+
.diffLine[data-change="addition"] { background: var(--diff-addition-bg); }
|
|
323
|
+
.diffLine[data-change="deletion"] { background: var(--diff-deletion-bg); }
|
|
324
|
+
.diffNumber {
|
|
325
|
+
flex-shrink: 0;
|
|
326
|
+
width: var(--size-8);
|
|
327
|
+
padding-right: var(--space-3);
|
|
328
|
+
text-align: right;
|
|
329
|
+
color: var(--fg-muted);
|
|
330
|
+
user-select: none;
|
|
331
|
+
}
|
|
332
|
+
.diffMarker {
|
|
333
|
+
flex-shrink: 0;
|
|
334
|
+
width: var(--size-5);
|
|
335
|
+
user-select: none;
|
|
336
|
+
}
|
|
337
|
+
.diffLine[data-change="addition"] .diffMarker { color: var(--diff-addition); }
|
|
338
|
+
.diffLine[data-change="deletion"] .diffMarker { color: var(--diff-deletion); }
|
|
339
|
+
|
|
340
|
+
.diffEmpty { display: block; padding-inline: var(--space-4); color: var(--fg-muted); }
|
|
341
|
+
|
|
342
|
+
.root[data-variant="dark"] {
|
|
343
|
+
--syntax-token-constant: var(--syntax-dark-constant);
|
|
344
|
+
--syntax-token-string: var(--syntax-dark-string);
|
|
345
|
+
--syntax-token-comment: var(--syntax-dark-comment);
|
|
346
|
+
--syntax-token-keyword: var(--syntax-dark-keyword);
|
|
347
|
+
--syntax-token-parameter: var(--syntax-dark-parameter);
|
|
348
|
+
--syntax-token-function: var(--syntax-dark-function);
|
|
349
|
+
--syntax-token-string-expression: var(--syntax-dark-string-expression);
|
|
350
|
+
--syntax-token-punctuation: var(--syntax-dark-punctuation);
|
|
351
|
+
--syntax-token-link: var(--syntax-dark-link);
|
|
352
|
+
}
|
|
353
|
+
.code [data-syntax-italic] { font-style: italic; }
|
|
354
|
+
.code [data-syntax-bold] { font-weight: var(--font-weight-medium); }
|
|
355
|
+
.code [data-syntax-underline] { text-decoration: underline; }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
Fragment,
|
|
4
5
|
useCallback,
|
|
5
6
|
useEffect,
|
|
6
7
|
useId,
|
|
@@ -20,7 +21,12 @@ import {
|
|
|
20
21
|
import { Tooltip, TooltipProvider } from "@/components/ovenn/Tooltip";
|
|
21
22
|
import { Button } from "@/components/ovenn/Button";
|
|
22
23
|
import { useTheme } from "../ThemeController";
|
|
24
|
+
import { diffToText, getDiffRows, type CodeBlockDiffLine } from "./diff-lines";
|
|
25
|
+
import { resolveCodeLanguage } from "./syntax-highlighter";
|
|
26
|
+
import { useSyntaxTokens } from "./use-syntax-tokens";
|
|
27
|
+
import { SyntaxTokens } from "./SyntaxHighlight";
|
|
23
28
|
import { copyCode } from "./copy-code";
|
|
29
|
+
import { getLinePreview } from "./line-preview";
|
|
24
30
|
import styles from "./CodeBlock.module.css";
|
|
25
31
|
|
|
26
32
|
const CODE_BLOCK_LABELS = {
|
|
@@ -29,6 +35,8 @@ const CODE_BLOCK_LABELS = {
|
|
|
29
35
|
copying: "복사 중",
|
|
30
36
|
copyFailed: "복사하지 못했습니다. 다시 시도하세요.",
|
|
31
37
|
code: "코드",
|
|
38
|
+
copyDiff: "변경 내역 복사",
|
|
39
|
+
addition: "추가", deletion: "삭제", context: "유지", empty: "변경 사항 없음", old: "이전 줄", next: "이후 줄",
|
|
32
40
|
copy: "복사",
|
|
33
41
|
copyCode: "코드 복사",
|
|
34
42
|
expandBtn: "코드 펼치기",
|
|
@@ -39,6 +47,8 @@ const CODE_BLOCK_LABELS = {
|
|
|
39
47
|
copying: "Copying",
|
|
40
48
|
copyFailed: "Could not copy code. Try again.",
|
|
41
49
|
code: "Code",
|
|
50
|
+
copyDiff: "Copy diff",
|
|
51
|
+
addition: "Added", deletion: "Deleted", context: "Unchanged", empty: "No changes", old: "Old line", next: "New line",
|
|
42
52
|
copy: "Copy",
|
|
43
53
|
copyCode: "Copy code",
|
|
44
54
|
expandBtn: "Expand code",
|
|
@@ -46,22 +56,35 @@ const CODE_BLOCK_LABELS = {
|
|
|
46
56
|
},
|
|
47
57
|
} as const;
|
|
48
58
|
|
|
49
|
-
export type CodeBlockVariant = "neutral" | "primary";
|
|
59
|
+
export type CodeBlockVariant = "neutral" | "primary" | "dark";
|
|
50
60
|
|
|
51
61
|
export interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
52
|
-
/**
|
|
53
|
-
code
|
|
62
|
+
/** 문자열은 language/filename에 따라 자동 구문 강조. ReactNode는 그대로 렌더. */
|
|
63
|
+
code?: string | ReactNode;
|
|
64
|
+
/** 변경 행. 빈 배열도 diff 모드이며 code/rawCode보다 우선한다. */
|
|
65
|
+
diff?: readonly CodeBlockDiffLine[];
|
|
66
|
+
oldStartLineNumber?: number;
|
|
67
|
+
newStartLineNumber?: number;
|
|
54
68
|
/** 하이라이트된 코드의 복사용 원문. 문자열 code보다 우선함. */
|
|
55
69
|
rawCode?: string;
|
|
56
70
|
/** 헤더 파일명. language보다 우선 표시하며 peek에서는 헤더와 함께 숨김. */
|
|
57
71
|
filename?: string;
|
|
58
|
-
/**
|
|
72
|
+
/** 구문 강조 언어 및 헤더 라벨. 미지정 시 filename 확장자로 추론. */
|
|
59
73
|
language?: string;
|
|
60
74
|
/**
|
|
61
75
|
* 톤. 기본은 중성 회색(neutral) — docs·AI message 모두 안전.
|
|
62
76
|
* primary는 Palette 축의 brand가 들어간 primary-subtle 배경 — 강조·단독 블록에.
|
|
63
77
|
*/
|
|
64
78
|
variant?: CodeBlockVariant;
|
|
79
|
+
/** 문자열 코드를 줄 단위로 표시. ReactNode는 임의 분할하지 않는다. */
|
|
80
|
+
lineNumbers?: boolean;
|
|
81
|
+
startLineNumber?: number;
|
|
82
|
+
/** 실제 표시 번호 기준. 문자열 code에만 적용. */
|
|
83
|
+
highlightLines?: readonly number[];
|
|
84
|
+
/** 문자열 코드의 줄별 구문 강조. 복사는 원문을 사용한다. */
|
|
85
|
+
renderLine?: (line: string, lineNumber: number) => ReactNode;
|
|
86
|
+
/** 복사 대상에 맞는 접근 가능한 이름. */
|
|
87
|
+
copyLabel?: string;
|
|
65
88
|
/** 접을 수 있게. 지정하면 상단 toggle이 Code 라벨 자리에 들어가고, 처음엔 접혀있음. */
|
|
66
89
|
collapsible?: boolean;
|
|
67
90
|
/** collapsible=true일 때 처음부터 펼침. 기본 false. */
|
|
@@ -73,6 +96,8 @@ export interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "ch
|
|
|
73
96
|
peek?: boolean;
|
|
74
97
|
/** peek 모드일 때 노출 높이 (px). 기본 120. */
|
|
75
98
|
peekHeight?: number;
|
|
99
|
+
/** Show up to this many source lines, with header expand/collapse and full-source copying. */
|
|
100
|
+
maxLines?: number;
|
|
76
101
|
/** copy 버튼 클릭 시 호출. 미지정이면 clipboard API로 자동 복사. */
|
|
77
102
|
onCopyCode?: (code: string) => void | Promise<void>;
|
|
78
103
|
/** clipboard 또는 사용자 복사 핸들러의 실패 알림. */
|
|
@@ -81,14 +106,23 @@ export interface CodeBlockProps extends Omit<HTMLAttributes<HTMLDivElement>, "ch
|
|
|
81
106
|
|
|
82
107
|
export function CodeBlock({
|
|
83
108
|
code,
|
|
109
|
+
diff,
|
|
110
|
+
oldStartLineNumber = 1,
|
|
111
|
+
newStartLineNumber = 1,
|
|
84
112
|
rawCode,
|
|
85
113
|
filename,
|
|
86
114
|
language,
|
|
87
115
|
variant = "neutral",
|
|
116
|
+
lineNumbers = false,
|
|
117
|
+
startLineNumber = 1,
|
|
118
|
+
highlightLines = [],
|
|
119
|
+
renderLine,
|
|
120
|
+
copyLabel: customCopyLabel,
|
|
88
121
|
collapsible = false,
|
|
89
122
|
defaultOpen = false,
|
|
90
123
|
peek = false,
|
|
91
124
|
peekHeight = 120,
|
|
125
|
+
maxLines,
|
|
92
126
|
onCopyCode,
|
|
93
127
|
onCopyError,
|
|
94
128
|
className,
|
|
@@ -102,10 +136,14 @@ export function CodeBlock({
|
|
|
102
136
|
const [open, setOpen] = useState(defaultOpen);
|
|
103
137
|
const [expanded, setExpanded] = useState(false);
|
|
104
138
|
const bodyId = useId();
|
|
105
|
-
const
|
|
139
|
+
const isDiff = diff !== undefined;
|
|
140
|
+
const linePreview = typeof code === "string" && !isDiff && !peek ? getLinePreview(code, maxLines, expanded) : undefined;
|
|
141
|
+
const lineLimited = linePreview?.limit !== undefined;
|
|
142
|
+
const displayCode = linePreview?.code ?? code;
|
|
143
|
+
const codeText = isDiff ? diffToText(diff) : rawCode ?? (typeof code === "string" ? code : undefined);
|
|
106
144
|
const canCopy = codeText !== undefined || !!onCopyCode;
|
|
107
145
|
const copied = copyState === "success";
|
|
108
|
-
const copyLabel = copied ? L.copied : copyState === "pending" ? L.copying : copyState === "error" ? L.copyFailed : L.copyCode;
|
|
146
|
+
const copyLabel = copied ? L.copied : copyState === "pending" ? L.copying : copyState === "error" ? L.copyFailed : (customCopyLabel ?? (isDiff ? L.copyDiff : L.copyCode));
|
|
109
147
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
110
148
|
const preRef = useRef<HTMLPreElement | null>(null);
|
|
111
149
|
const [contentHeight, setContentHeight] = useState<number | null>(null);
|
|
@@ -114,7 +152,7 @@ export function CodeBlock({
|
|
|
114
152
|
natural layout 높이를 유지하므로 접힘·펼침 상태 상관없이 안정적으로 측정됨.
|
|
115
153
|
ResizeObserver로 창 크기·내용 변경에 반응. */
|
|
116
154
|
useLayoutEffect(() => {
|
|
117
|
-
if (!collapsible && !peek) return;
|
|
155
|
+
if ((!collapsible && !peek) || lineLimited) return;
|
|
118
156
|
const el = preRef.current;
|
|
119
157
|
if (!el) return;
|
|
120
158
|
const measure = () => setContentHeight(el.scrollHeight);
|
|
@@ -124,7 +162,7 @@ export function CodeBlock({
|
|
|
124
162
|
return () => ro.disconnect();
|
|
125
163
|
/* expanded도 deps — padding-bottom이 바뀌면 즉시 재측정해서 maxHeight도 함께 늘어남.
|
|
126
164
|
ResizeObserver만 믿으면 Chromium batch 때문에 뒤늦게 발화해 간격이 안 늘어나 보임. */
|
|
127
|
-
}, [collapsible, peek, code, expanded]);
|
|
165
|
+
}, [collapsible, peek, code, diff, expanded, lineLimited]);
|
|
128
166
|
|
|
129
167
|
useEffect(() => {
|
|
130
168
|
mountedRef.current = true;
|
|
@@ -156,8 +194,44 @@ export function CodeBlock({
|
|
|
156
194
|
}
|
|
157
195
|
}, [codeText, onCopyCode, onCopyError]);
|
|
158
196
|
|
|
197
|
+
const syntaxLanguage = resolveCodeLanguage(language, filename);
|
|
198
|
+
const oldSource = diff?.filter((line) => line.type !== "addition").map((line) => line.content).join("\n");
|
|
199
|
+
const newSource = isDiff ? diff.filter((line) => line.type !== "deletion").map((line) => line.content).join("\n") : typeof displayCode === "string" ? displayCode : undefined;
|
|
200
|
+
const oldTokens = useSyntaxTokens(renderLine ? undefined : oldSource, syntaxLanguage);
|
|
201
|
+
const newTokens = useSyntaxTokens(renderLine ? undefined : newSource, syntaxLanguage);
|
|
202
|
+
|
|
203
|
+
const firstLine = Number.isSafeInteger(startLineNumber) && startLineNumber > 0 ? startLineNumber : 1;
|
|
204
|
+
const numbered = !isDiff && typeof displayCode === "string" && (lineNumbers || highlightLines.length > 0 || !!renderLine);
|
|
205
|
+
const highlighted = new Set(highlightLines);
|
|
206
|
+
const sourceLines = typeof displayCode === "string" ? displayCode.split("\n") : [];
|
|
207
|
+
const plainContent = numbered ? sourceLines.map((line, index) => {
|
|
208
|
+
const number = firstLine + index;
|
|
209
|
+
return <span key={index} className={styles.line} data-highlighted={highlighted.has(number) || undefined}>
|
|
210
|
+
{lineNumbers && <span className={styles.lineNumber} aria-hidden="true">{number}</span>}
|
|
211
|
+
<span className={styles.lineContent}>{renderLine ? renderLine(line, number) : <SyntaxTokens tokens={newTokens?.[index]} fallback={line} />}{index < sourceLines.length - 1 ? "\n" : ""}</span>
|
|
212
|
+
</span>;
|
|
213
|
+
}) : typeof displayCode === "string" && syntaxLanguage ? sourceLines.map((line, index) =>
|
|
214
|
+
<Fragment key={index}><SyntaxTokens tokens={newTokens?.[index]} fallback={line} />{index < sourceLines.length - 1 ? "\n" : ""}</Fragment>
|
|
215
|
+
) : displayCode;
|
|
216
|
+
|
|
217
|
+
const rows = diff === undefined ? [] : getDiffRows(diff, oldStartLineNumber, newStartLineNumber);
|
|
218
|
+
let oldIndex = 0;
|
|
219
|
+
let newIndex = 0;
|
|
220
|
+
const content = !isDiff ? plainContent : rows.length === 0 ? <span className={styles.diffEmpty}>{L.empty}</span> : rows.map((row, index) => {
|
|
221
|
+
const tokens = row.type === "deletion" ? oldTokens?.[oldIndex] : newTokens?.[newIndex];
|
|
222
|
+
if (row.type !== "addition") oldIndex++;
|
|
223
|
+
if (row.type !== "deletion") newIndex++;
|
|
224
|
+
return <span key={index} className={styles.diffLine} data-change={row.type}>
|
|
225
|
+
<span className="visually-hidden">{L[row.type]}{row.oldNumber !== undefined ? `, ${L.old} ${row.oldNumber}` : ""}{row.newNumber !== undefined ? `, ${L.next} ${row.newNumber}` : ""}: </span>
|
|
226
|
+
<span className={styles.diffNumber} aria-hidden="true">{row.oldNumber}</span>
|
|
227
|
+
<span className={styles.diffNumber} aria-hidden="true">{row.newNumber}</span>
|
|
228
|
+
<span className={styles.diffMarker} aria-hidden="true">{row.marker}</span>
|
|
229
|
+
<span className={styles.lineContent}>{renderLine ? renderLine(row.content, row.newNumber ?? row.oldNumber ?? 1) : <SyntaxTokens tokens={tokens} fallback={row.content} />}{index < rows.length - 1 ? "\n" : ""}</span>
|
|
230
|
+
</span>;
|
|
231
|
+
});
|
|
232
|
+
|
|
159
233
|
const cls = [styles.root, className].filter(Boolean).join(" ");
|
|
160
|
-
const isCollapsible = collapsible && !peek;
|
|
234
|
+
const isCollapsible = collapsible && !peek && !lineLimited;
|
|
161
235
|
const effectivelyOpen = !isCollapsible || open;
|
|
162
236
|
/* 첫 측정 전엔 transition 끔 — 초기 "9999 → 실제값" 깜빡임 방지. */
|
|
163
237
|
const measured = contentHeight !== null;
|
|
@@ -173,7 +247,7 @@ export function CodeBlock({
|
|
|
173
247
|
maxHeight: inPeek ? peekHeight : (contentHeight ?? 9999),
|
|
174
248
|
transition: measured ? "" : "none",
|
|
175
249
|
}
|
|
176
|
-
:
|
|
250
|
+
: isCollapsible
|
|
177
251
|
? {
|
|
178
252
|
maxHeight: effectivelyOpen ? (contentHeight ?? 9999) : 0,
|
|
179
253
|
transition: measured ? "" : "none",
|
|
@@ -184,9 +258,12 @@ export function CodeBlock({
|
|
|
184
258
|
<TooltipProvider>
|
|
185
259
|
<div
|
|
186
260
|
className={cls}
|
|
261
|
+
data-code-syntax=""
|
|
187
262
|
data-variant={variant}
|
|
263
|
+
data-diff={isDiff || undefined}
|
|
188
264
|
data-collapsible={isCollapsible || undefined}
|
|
189
265
|
data-peek={peek || undefined}
|
|
266
|
+
data-max-lines={linePreview?.limit}
|
|
190
267
|
data-overflowed={overflowed || undefined}
|
|
191
268
|
data-open={effectivelyOpen || undefined}
|
|
192
269
|
data-expanded={expanded || undefined}
|
|
@@ -195,7 +272,7 @@ export function CodeBlock({
|
|
|
195
272
|
{/* peek 모드엔 상단 header 숨김 (HeroUI 톤). copy 버튼은 body 우상단 absolute. */}
|
|
196
273
|
{!peek && (
|
|
197
274
|
<div className={styles.header}>
|
|
198
|
-
{
|
|
275
|
+
{isCollapsible ? (
|
|
199
276
|
<button
|
|
200
277
|
type="button"
|
|
201
278
|
className={styles.toggle}
|
|
@@ -212,22 +289,27 @@ export function CodeBlock({
|
|
|
212
289
|
{filename || language ? <span className={styles.langLabel} title={filename}>{filename ?? language}</span> : null}
|
|
213
290
|
</div>
|
|
214
291
|
)}
|
|
215
|
-
<
|
|
216
|
-
<
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
292
|
+
<div className={styles.headerActions}>
|
|
293
|
+
{linePreview?.hasMore && <Button size="sm" variant="ghost" onClick={() => setExpanded(value => !value)} aria-expanded={expanded} aria-controls={bodyId}>
|
|
294
|
+
{expanded ? L.collapseBtn : L.expandBtn}
|
|
295
|
+
</Button>}
|
|
296
|
+
<Tooltip content={copyState === "idle" ? L.copy : copyLabel}>
|
|
297
|
+
<button
|
|
298
|
+
type="button"
|
|
299
|
+
className={styles.copyBtn}
|
|
300
|
+
onClick={handleCopy}
|
|
301
|
+
aria-label={copyLabel}
|
|
302
|
+
disabled={!canCopy || copyState === "pending"}
|
|
303
|
+
tabIndex={effectivelyOpen ? 0 : -1}
|
|
304
|
+
>
|
|
305
|
+
{copied ? (
|
|
306
|
+
<PhCheck className={styles.copyIcon} weight="bold" />
|
|
307
|
+
) : (
|
|
308
|
+
<PhCopy className={styles.copyIcon} weight="regular" />
|
|
309
|
+
)}
|
|
310
|
+
</button>
|
|
311
|
+
</Tooltip>
|
|
312
|
+
</div>
|
|
231
313
|
</div>
|
|
232
314
|
)}
|
|
233
315
|
<div
|
|
@@ -235,8 +317,11 @@ export function CodeBlock({
|
|
|
235
317
|
style={bodyStyle}
|
|
236
318
|
aria-hidden={!effectivelyOpen}
|
|
237
319
|
>
|
|
238
|
-
<pre id={bodyId} className={styles.code} ref={preRef}
|
|
239
|
-
|
|
320
|
+
<pre id={bodyId} className={styles.code} ref={preRef}
|
|
321
|
+
tabIndex={effectivelyOpen ? 0 : -1}
|
|
322
|
+
aria-label={filename ?? language ?? L.code}
|
|
323
|
+
data-lines={numbered || isDiff || undefined}>
|
|
324
|
+
<code>{content}</code>
|
|
240
325
|
</pre>
|
|
241
326
|
{/* peek 모드: 우상단 copy 버튼은 항상. Expand 버튼은 overflow될 때만. */}
|
|
242
327
|
{peek && (
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
import { resolveCodeLanguage, type ThemedToken } from "./syntax-highlighter";
|
|
5
|
+
import { useSyntaxTokens } from "./use-syntax-tokens";
|
|
6
|
+
|
|
7
|
+
export function SyntaxTokens({ tokens, fallback }: { tokens?: ThemedToken[]; fallback: string }) {
|
|
8
|
+
return tokens ? tokens.map((token, index) => <span key={index} data-syntax="token"
|
|
9
|
+
data-syntax-italic={!!((token.fontStyle ?? 0) & 1) || undefined}
|
|
10
|
+
data-syntax-bold={!!((token.fontStyle ?? 0) & 2) || undefined}
|
|
11
|
+
data-syntax-underline={!!((token.fontStyle ?? 0) & 4) || undefined}
|
|
12
|
+
style={{ color: token.color }}>{token.content}</span>) : fallback;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Internal adapter for legacy highlighted ReactNode consumers. */
|
|
16
|
+
export function SyntaxHighlight({ code, language = "tsx" }: { code: string; language?: string }) {
|
|
17
|
+
const tokens = useSyntaxTokens(code, resolveCodeLanguage(language));
|
|
18
|
+
const lines = code.split("\n");
|
|
19
|
+
return lines.map((line, index) => <Fragment key={index}><SyntaxTokens tokens={tokens?.[index]} fallback={line} />{index < lines.length - 1 ? "\n" : ""}</Fragment>);
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CodeBlockDiffLine {
|
|
2
|
+
type: "context" | "addition" | "deletion";
|
|
3
|
+
/** One source line, without its newline terminator. Empty lines use "". */
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getDiffRows(lines: readonly CodeBlockDiffLine[], oldStart = 1, newStart = 1) {
|
|
8
|
+
let oldNumber = Number.isSafeInteger(oldStart) && oldStart > 0 ? oldStart : 1;
|
|
9
|
+
let newNumber = Number.isSafeInteger(newStart) && newStart > 0 ? newStart : 1;
|
|
10
|
+
return lines.map((line) => ({
|
|
11
|
+
...line,
|
|
12
|
+
oldNumber: line.type === "addition" ? undefined : oldNumber++,
|
|
13
|
+
newNumber: line.type === "deletion" ? undefined : newNumber++,
|
|
14
|
+
marker: line.type === "addition" ? "+" : line.type === "deletion" ? "-" : " ",
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Displayed patch fragment; source whitespace and empty lines are preserved. */
|
|
19
|
+
export function diffToText(lines: readonly CodeBlockDiffLine[]) {
|
|
20
|
+
return lines.map((line) => `${line.type === "addition" ? "+" : line.type === "deletion" ? "-" : " "}${line.content}`).join("\n");
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Keep the source intact for copying; limit only the rendered preview. */
|
|
2
|
+
export function getLinePreview(source: string, maxLines: number | undefined, expanded = false) {
|
|
3
|
+
const limit = Number.isSafeInteger(maxLines) && (maxLines ?? 0) > 0 ? maxLines : undefined;
|
|
4
|
+
const lines = source.split(/\r?\n/);
|
|
5
|
+
const hasMore = limit !== undefined && lines.length > limit;
|
|
6
|
+
return { limit, hasMore, code: hasMore && !expanded ? lines.slice(0, limit).join("\n") : source };
|
|
7
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { HighlighterCore, ThemedToken, ThemeRegistration } from "shiki/core";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/** TextMate scope-to-token mapping only; grammar parsing stays entirely in Shiki. */
|
|
5
|
+
const syntaxTheme: ThemeRegistration = {
|
|
6
|
+
name: "ovenn",
|
|
7
|
+
fg: "var(--syntax-foreground)",
|
|
8
|
+
bg: "var(--syntax-background)",
|
|
9
|
+
tokenColors: [
|
|
10
|
+
{ scope: ["string", "markup.fenced_code", "markup.inline"], settings: { foreground: "var(--syntax-token-string)" } },
|
|
11
|
+
{ scope: ["comment", "string.quoted.docstring.multi"], settings: { foreground: "var(--syntax-token-comment)" } },
|
|
12
|
+
{ scope: ["constant.numeric", "constant.language", "constant.other.placeholder", "constant.character.format.placeholder", "variable.language.this", "variable.other.object", "variable.other.class", "variable.other.constant", "meta.property-name", "meta.property-value", "support"], settings: { foreground: "var(--syntax-token-constant)" } },
|
|
13
|
+
{ scope: ["keyword", "storage.modifier", "storage.type", "storage.control.clojure", "entity.name.function.clojure", "entity.name.tag.yaml", "support.function.node", "support.type.property-name.json", "punctuation.separator.key-value", "punctuation.definition.template-expression"], settings: { foreground: "var(--syntax-token-keyword)" } },
|
|
14
|
+
{ scope: "variable.parameter.function", settings: { foreground: "var(--syntax-token-parameter)" } },
|
|
15
|
+
{ scope: ["support.function", "entity.name.type", "entity.other.inherited-class", "meta.function-call", "meta.instance.constructor", "entity.other.attribute-name", "entity.name.function", "entity.name.tag", "support.class.component", "meta.tag.custom"], settings: { foreground: "var(--syntax-token-function)" } },
|
|
16
|
+
{ scope: ["punctuation.definition.string", "punctuation.definition.template-expression", "punctuation.definition.tag"], settings: { foreground: "var(--syntax-token-punctuation)" } },
|
|
17
|
+
{ scope: ["string.quoted", "string.template", "string.unquoted", "string.regexp", "string.interpolated", "string.other"], settings: { foreground: "var(--syntax-token-string-expression)" } },
|
|
18
|
+
{ scope: ["keyword.operator.accessor", "meta.group.braces.round.function.arguments", "meta.template.expression", "markup.fenced_code meta.embedded.block"], settings: { foreground: "var(--syntax-foreground)" } },
|
|
19
|
+
{ scope: ["emphasis", "markup.italic.markdown"], settings: { fontStyle: "italic" } },
|
|
20
|
+
{ scope: ["strong", "markup.heading.markdown", "markup.bold.markdown"], settings: { fontStyle: "bold" } },
|
|
21
|
+
{ scope: "meta.link.inline.markdown", settings: { foreground: "var(--syntax-token-link)", fontStyle: "underline" } },
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const languages = {
|
|
26
|
+
javascript: () => import("shiki/langs/javascript.mjs"),
|
|
27
|
+
typescript: () => import("shiki/langs/typescript.mjs"),
|
|
28
|
+
jsx: () => import("shiki/langs/jsx.mjs"),
|
|
29
|
+
tsx: () => import("shiki/langs/tsx.mjs"),
|
|
30
|
+
json: () => import("shiki/langs/json.mjs"),
|
|
31
|
+
html: () => import("shiki/langs/html.mjs"),
|
|
32
|
+
css: () => import("shiki/langs/css.mjs"),
|
|
33
|
+
scss: () => import("shiki/langs/scss.mjs"),
|
|
34
|
+
bash: () => import("shiki/langs/bash.mjs"),
|
|
35
|
+
python: () => import("shiki/langs/python.mjs"),
|
|
36
|
+
sql: () => import("shiki/langs/sql.mjs"),
|
|
37
|
+
yaml: () => import("shiki/langs/yaml.mjs"),
|
|
38
|
+
markdown: () => import("shiki/langs/markdown.mjs"),
|
|
39
|
+
go: () => import("shiki/langs/go.mjs"),
|
|
40
|
+
rust: () => import("shiki/langs/rust.mjs"),
|
|
41
|
+
java: () => import("shiki/langs/java.mjs"),
|
|
42
|
+
c: () => import("shiki/langs/c.mjs"),
|
|
43
|
+
cpp: () => import("shiki/langs/cpp.mjs"),
|
|
44
|
+
csharp: () => import("shiki/langs/csharp.mjs"),
|
|
45
|
+
php: () => import("shiki/langs/php.mjs"),
|
|
46
|
+
ruby: () => import("shiki/langs/ruby.mjs"),
|
|
47
|
+
swift: () => import("shiki/langs/swift.mjs"),
|
|
48
|
+
kotlin: () => import("shiki/langs/kotlin.mjs"),
|
|
49
|
+
dockerfile: () => import("shiki/langs/dockerfile.mjs"),
|
|
50
|
+
};
|
|
51
|
+
type Language = keyof typeof languages;
|
|
52
|
+
const aliases: Record<string, string> = {
|
|
53
|
+
js: "javascript", mjs: "javascript", cjs: "javascript", ts: "typescript", mts: "typescript", cts: "typescript",
|
|
54
|
+
htm: "html", svg: "html", xml: "html", sh: "bash", shell: "bash", zsh: "bash", py: "python", yml: "yaml", md: "markdown",
|
|
55
|
+
rs: "rust", h: "c", cc: "cpp", hpp: "cpp", cs: "csharp", rb: "ruby", kt: "kotlin", kts: "kotlin",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Explicit language (including plaintext/unknown) always takes precedence over filename. */
|
|
59
|
+
export function resolveCodeLanguage(language?: string, filename?: string): Language | undefined {
|
|
60
|
+
const file = filename?.split(/[\\/]/).at(-1)?.toLowerCase();
|
|
61
|
+
const name = language !== undefined ? language.trim().toLowerCase() : file === "dockerfile" ? "dockerfile" : file?.split(".").at(-1);
|
|
62
|
+
if (!name) return undefined;
|
|
63
|
+
const canonical = aliases[name] ?? name;
|
|
64
|
+
return Object.hasOwn(languages, canonical) ? canonical as Language : undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let instance: Promise<HighlighterCore> | undefined;
|
|
68
|
+
const loading = new Map<Language, Promise<void>>();
|
|
69
|
+
async function getHighlighter() {
|
|
70
|
+
if (!instance) {
|
|
71
|
+
instance = Promise.all([import("shiki/core"), import("shiki/engine/javascript")]).then(([core, engine]) =>
|
|
72
|
+
core.createHighlighterCore({
|
|
73
|
+
engine: engine.createJavaScriptRegexEngine(),
|
|
74
|
+
langs: [],
|
|
75
|
+
themes: [syntaxTheme],
|
|
76
|
+
}),
|
|
77
|
+
).catch((error) => { instance = undefined; throw error; });
|
|
78
|
+
}
|
|
79
|
+
return instance;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export async function highlightSource(source: string, language?: string): Promise<ThemedToken[][] | undefined> {
|
|
83
|
+
const lang = resolveCodeLanguage(language);
|
|
84
|
+
if (!lang) return undefined;
|
|
85
|
+
const highlighter = await getHighlighter();
|
|
86
|
+
if (!loading.has(lang)) {
|
|
87
|
+
loading.set(lang, languages[lang]().then((grammar) => highlighter.loadLanguage(grammar.default)).catch((error) => {
|
|
88
|
+
loading.delete(lang);
|
|
89
|
+
throw error;
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
await loading.get(lang);
|
|
93
|
+
return highlighter.codeToTokensBase(source, { lang, theme: "ovenn" });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type { ThemedToken };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { highlightSource, type ThemedToken } from "./syntax-highlighter";
|
|
5
|
+
|
|
6
|
+
export function useSyntaxTokens(source: string | undefined, language: string | undefined) {
|
|
7
|
+
const [result, setResult] = useState<{ source: string; language: string; tokens: ThemedToken[][] }>();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (source === undefined || !language) return;
|
|
10
|
+
let active = true;
|
|
11
|
+
highlightSource(source, language).then((tokens) => {
|
|
12
|
+
if (active && tokens) setResult({ source, language, tokens });
|
|
13
|
+
}).catch(() => { /* Keep the original source readable if loading/tokenization fails. */ });
|
|
14
|
+
return () => { active = false; };
|
|
15
|
+
}, [source, language]);
|
|
16
|
+
return result && result.source === source && result.language === language ? result.tokens : undefined;
|
|
17
|
+
}
|