@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
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
# Chat Composer 사용 사례 소스
|
|
2
|
+
|
|
3
|
+
<!-- Generated by scripts/build-use-cases.mjs. Edit original TSX/CSS, then regenerate. -->
|
|
4
|
+
|
|
5
|
+
### 사례 목록
|
|
6
|
+
|
|
7
|
+
- Sending and file uploads
|
|
8
|
+
- Footer tools
|
|
9
|
+
- Selection mini toolbar
|
|
10
|
+
- Mentions and commands
|
|
11
|
+
|
|
12
|
+
문서: /en/components/chat/chat-composer#use-cases
|
|
13
|
+
|
|
14
|
+
문서 페이지에서 렌더하는 사례입니다.
|
|
15
|
+
|
|
16
|
+
### 조회 방법
|
|
17
|
+
|
|
18
|
+
get_guide(topic="use-cases/chat-chat-composer", sections=["사례 목록", "파일 목록"])로 먼저 확인하고, 필요한 Section 또는 Source 파일 헤딩만 sections로 조회하세요. 전체 문서는 문서 페이지의 다른 예제도 포함합니다. 공용 컴포넌트 계약은 get_component로 읽고, 예제의 docs 전용 셸·locale·import 경로는 대상 프로젝트에 맞게 조합하세요. 이 연결은 디자인 승인이나 기능 검증을 뜻하지 않습니다.
|
|
19
|
+
|
|
20
|
+
### 파일 목록
|
|
21
|
+
|
|
22
|
+
- `web/app/[lang]/components/chat/chat-composer/page.tsx`
|
|
23
|
+
- `web/examples/chatAttachmentDownload.ts`
|
|
24
|
+
- `web/examples/ChatComposerExamples.tsx`
|
|
25
|
+
- `web/examples/RichChatComposerExample.module.css`
|
|
26
|
+
- `web/examples/RichChatComposerExample.tsx`
|
|
27
|
+
- `web/examples/TeamChatDemo.module.css`
|
|
28
|
+
- `web/examples/useChatDelivery.ts`
|
|
29
|
+
|
|
30
|
+
### Section: web/app/[lang]/components/chat/chat-composer/page.tsx#use-cases
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
<section id="use-cases">
|
|
34
|
+
<h2>{ko ? "사용 사례" : "Use cases"}</h2>
|
|
35
|
+
<div id="delivery-states">
|
|
36
|
+
<h3>{ko ? "전송 대기와 파일 업로드" : "Sending and file uploads"}</h3>
|
|
37
|
+
<p className="desc">{ko ? "메시지를 보내면 전송 중에는 회색으로 표시되고, 전송이 끝나면 원래 색으로 바뀌어요. 파일 업로드 체험으로 첨부 하단의 로딩 표시도 확인해 보세요. 실제 서버 전송 없이 대기 시간을 재현해요." : "Send a message or try a file upload to see the pending states. This example simulates upload and delivery latency."}</p>
|
|
38
|
+
<ExampleBlock align="column" previewWidth="full" code={`<ChatMessage author="Taylor Kim" deliveryStatus={isSending ? "sending" : "sent"}>
|
|
39
|
+
{message.body}
|
|
40
|
+
</ChatMessage>
|
|
41
|
+
|
|
42
|
+
<ChatComposer attachments={files} value={value} onValueChange={setValue} onSend={send} />
|
|
43
|
+
${ko ? "// 업로드 진행률을 uploadProgress에 넣고, 완료되면 해당 속성을 제거하세요." : "// Set uploadProgress from upload events and remove it after confirmation."}`}><ComposerExample uploadDemo initialValue={ko ? "검토 의견을 정리했어요." : "The review notes are ready."} /></ExampleBlock>
|
|
44
|
+
</div>
|
|
45
|
+
<div id="footer-tools">
|
|
46
|
+
<h3>{ko ? "하단 도구 모음" : "Footer tools"}</h3>
|
|
47
|
+
<p className="desc">{ko ? "텍스트를 선택한 뒤 하단 도구로 굵게, 기울임, 밑줄을 적용해 보세요. 이모지를 넣을 수 있고, GIF 버튼은 배치 예시로만 제공해요." : "Format selected text and insert emoji. The GIF button is a placement example and has no action."}</p>
|
|
48
|
+
<ExampleBlock align="column" previewWidth="full" code={`import { RichChatComposerExample } from "@/examples/RichChatComposerExample";
|
|
49
|
+
|
|
50
|
+
<RichChatComposerExample mode="footer" />`}><RichChatComposerExample mode="footer" /></ExampleBlock>
|
|
51
|
+
</div>
|
|
52
|
+
<div id="selection-tools">
|
|
53
|
+
<h3>{ko ? "선택 영역 미니 툴바" : "Selection mini toolbar"}</h3>
|
|
54
|
+
<p className="desc">{ko ? "텍스트를 선택하면 서식 도구가 나타나요. Alt+F10으로 도구에 포커스를 옮길 수 있어요. 이모지는 하단 버튼에서 선택해요." : "Select text to reveal formatting tools. Press Alt+F10 to focus the tools. Choose emoji from the footer."}</p>
|
|
55
|
+
<ExampleBlock align="column" previewWidth="full" code={`import { RichChatComposerExample } from "@/examples/RichChatComposerExample";
|
|
56
|
+
|
|
57
|
+
<RichChatComposerExample mode="selection" />`}><RichChatComposerExample mode="selection" /></ExampleBlock>
|
|
58
|
+
</div>
|
|
59
|
+
<h3>{ko ? "멘션과 명령" : "Mentions and commands"}</h3>
|
|
60
|
+
<p className="desc">{ko ? "@를 입력하면 사용자를, /를 입력하면 명령을 찾을 수 있어요. 위아래 방향키로 이동한 뒤 Enter를 누르거나 항목을 클릭해 선택하세요." : "Type @ to find people or / to find commands. Select with arrow keys and Enter, or click an item."}</p>
|
|
61
|
+
<ExampleBlock align="column" previewWidth="full" code={`const [value, setValue] = useState("");
|
|
62
|
+
const [mentions, setMentions] = useState<ChatMention[]>([]);
|
|
63
|
+
|
|
64
|
+
<ChatComposer value={value} mentions={mentions}
|
|
65
|
+
onValueChange={(text, nextMentions) => {
|
|
66
|
+
setValue(text); setMentions(nextMentions);
|
|
67
|
+
}}
|
|
68
|
+
mentionOptions={[{ id: "alex", label: "Alex Morgan" }]}
|
|
69
|
+
commands={[{ id: "task", label: "task", insertText: "TODO: " }]}
|
|
70
|
+
onSend={() => save({ value, mentions })}
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
<ChatMessageText value={message.value} mentions={message.mentions} />`}><ComposerExample contextual /></ExampleBlock>
|
|
74
|
+
</section>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Source: web/app/[lang]/components/chat/chat-composer/page.tsx
|
|
78
|
+
|
|
79
|
+
````tsx
|
|
80
|
+
"use client";
|
|
81
|
+
|
|
82
|
+
import { useState } from "react";
|
|
83
|
+
import { usePathname } from "next/navigation";
|
|
84
|
+
import { RichChatComposerExample } from "@/examples/RichChatComposerExample";
|
|
85
|
+
import { ComposerExample, composerAttachments } from "@/examples/ChatComposerExamples";
|
|
86
|
+
import type { ChatInputShape, ChatInputVariant, ChatInputAppearance, ChatInputSendVariant, ChatInputSendIcon } from "@/components/ChatInput";
|
|
87
|
+
import { ExampleBlock } from "../../../../_components/ExampleBlock";
|
|
88
|
+
import { DocsTable } from "../../../../_components/DocsTable";
|
|
89
|
+
import { Playground } from "../../../../_components/Playground";
|
|
90
|
+
import { localeFromPathname } from "../../../../_dict";
|
|
91
|
+
|
|
92
|
+
export default function Page() {
|
|
93
|
+
const ko = localeFromPathname(usePathname() ?? "/") === "ko";
|
|
94
|
+
const [shape, setShape] = useState<ChatInputShape>("multi");
|
|
95
|
+
const [variant, setVariant] = useState<ChatInputVariant>("framed");
|
|
96
|
+
const [appearance, setAppearance] = useState<ChatInputAppearance>("outline");
|
|
97
|
+
const [sendVariant, setSendVariant] = useState<ChatInputSendVariant>("solid");
|
|
98
|
+
const [sendIcon, setSendIcon] = useState<ChatInputSendIcon>("arrow-up");
|
|
99
|
+
const [separateSend, setSeparateSend] = useState(false);
|
|
100
|
+
const [withAttachments, setWithAttachments] = useState(false);
|
|
101
|
+
const [withQuote, setWithQuote] = useState(false);
|
|
102
|
+
const [disabled, setDisabled] = useState(false);
|
|
103
|
+
const [sending, setSending] = useState(false);
|
|
104
|
+
const [sendDisabled, setSendDisabled] = useState(false);
|
|
105
|
+
const [maxRows, setMaxRows] = useState(8);
|
|
106
|
+
const rows = [
|
|
107
|
+
["shape", "'multi' | 'single'", "multi", ko ? "여러 줄 또는 한 줄 입력" : "Multiline / inline layout"],
|
|
108
|
+
["variant", "'framed' | 'flush'", "framed", ko ? "테두리가 있는 입력 또는 주변 영역에 이어지는 입력" : "Framed / edge-to-edge shell input"],
|
|
109
|
+
["appearance", "'outline' | 'filled'", "outline", ko ? "테두리 또는 배경으로 입력 영역 구분" : "Input surface"],
|
|
110
|
+
["separateSend", "boolean", "false", ko ? "한 줄 입력에서 전송 버튼을 입력 영역 밖에 배치" : "Separate send button in single layout"],
|
|
111
|
+
["sendVariant", "'solid' | 'ghost' | 'soft'", "solid", ko ? "전송 버튼 스타일" : "Send button tone"],
|
|
112
|
+
["sendIcon", "'arrow-up' | 'return' | 'paper-plane'", "arrow-up", ko ? "전송 아이콘" : "Send icon"],
|
|
113
|
+
["value / onValueChange", "string / (value, mentions) => void", "", ko ? "입력 내용과 멘션 정보를 함께 관리" : "Control text and mention metadata together"],
|
|
114
|
+
["onSend", "() => void", "", ko ? "입력 내용이나 첨부가 있을 때 실행되는 전송 함수" : "Send text or attachments"],
|
|
115
|
+
["attachments / onAttach / onRemoveAttachment", "ChatAttachment[] / callbacks", "[]", ko ? "첨부 목록, 파일 선택, 첨부 삭제" : "Images, files, upload progress and removal"],
|
|
116
|
+
["quotation", "{ text, onRemove? }", "", ko ? "인용할 내용과 인용 취소 함수" : "Quotation bar"],
|
|
117
|
+
["replyTo", "{ author, text, onCancel? }", "", ko ? "답글을 받을 대상. quotation과 함께 설정하면 답글 대상을 표시" : "Reply context; takes precedence over quotation"],
|
|
118
|
+
["disabled / sending", "boolean", "false", ko ? "입력, 첨부, 전송 비활성화" : "Block editing, attachments and sending"],
|
|
119
|
+
["sendDisabled", "boolean", "false", ko ? "입력은 허용하고 전송만 비활성화" : "Disable sending while keeping editing enabled"],
|
|
120
|
+
["maxRows", "number", "8", ko ? "최대 입력 행 수" : "Maximum input rows"],
|
|
121
|
+
["mentions / mentionOptions", "ChatMention[] / ChatMentionOption[]", "[]", ko ? "본문의 멘션 정보와 @로 찾을 사용자 목록" : "Saved mention ranges and @ suggestions"],
|
|
122
|
+
["commands / onCommandSelect", "ChatCommand[] / (command) => void", "[]", ko ? "/로 찾을 명령 목록과 명령을 선택했을 때 실행할 함수" : "/ command insertion and selection callback"],
|
|
123
|
+
["editor", "ReactNode", "", ko ? "기본 입력 대신 사용할 편집기. 텍스트 선택, 서식, 키보드 동작을 직접 구현" : "Host-owned rich editor, selection and keyboard behavior"],
|
|
124
|
+
["tools", "ReactNode", "", ko ? "추가 입력 도구" : "Additional input controls"],
|
|
125
|
+
["label / placeholder / autoFocus", "string / string / boolean", "", ko ? "스크린리더용 이름, 입력 안내, 자동 포커스" : "Accessible name, placeholder and autofocus"],
|
|
126
|
+
];
|
|
127
|
+
return <>
|
|
128
|
+
<h1 className="page-title">Chat Composer</h1>
|
|
129
|
+
<section id="usage" className="section-first">
|
|
130
|
+
<h2>{ko ? "사용법" : "Usage"}</h2>
|
|
131
|
+
<ExampleBlock align="column" previewWidth="full" code={`<ChatComposer value={value} onValueChange={setValue} onSend={send}
|
|
132
|
+
attachments={files} onAttach={attach} onRemoveAttachment={remove}
|
|
133
|
+
/>`}><ComposerExample /></ExampleBlock>
|
|
134
|
+
</section>
|
|
135
|
+
<Playground axes={[
|
|
136
|
+
{ label: "shape", value: shape, onChange: v => setShape(v as ChatInputShape), options: ["multi", "single"] },
|
|
137
|
+
{ label: "variant", value: variant, onChange: v => setVariant(v as ChatInputVariant), options: ["framed", "flush"] },
|
|
138
|
+
{ label: "appearance", value: appearance, onChange: v => setAppearance(v as ChatInputAppearance), options: ["outline", "filled"] },
|
|
139
|
+
{ label: "sendVariant", value: sendVariant, onChange: v => setSendVariant(v as ChatInputSendVariant), options: ["solid", "ghost", "soft"] },
|
|
140
|
+
{ label: "sendIcon", value: sendIcon, onChange: v => setSendIcon(v as ChatInputSendIcon), options: ["arrow-up", "return", "paper-plane"] },
|
|
141
|
+
]} toggles={[
|
|
142
|
+
{ group: "layout", label: "separateSend (single only)", value: separateSend, onChange: setSeparateSend },
|
|
143
|
+
{ group: "content", label: "attachments", value: withAttachments, onChange: setWithAttachments },
|
|
144
|
+
{ group: "content", label: "quotation", value: withQuote, onChange: setWithQuote },
|
|
145
|
+
{ group: "state", label: "disabled", value: disabled, onChange: setDisabled },
|
|
146
|
+
{ group: "state", label: "sending", value: sending, onChange: setSending },
|
|
147
|
+
{ group: "state", label: "sendDisabled", value: sendDisabled, onChange: setSendDisabled },
|
|
148
|
+
]} sliders={[{ label: "maxRows", value: maxRows, onChange: setMaxRows, min: 1, max: 12, step: 1 }]}>
|
|
149
|
+
<ComposerExample key={`${withAttachments}-${withQuote}`} options={{ shape, variant, appearance, sendVariant, sendIcon, separateSend, disabled, sending, sendDisabled, maxRows }} initialAttachments={withAttachments ? composerAttachments : []} withQuote={withQuote} />
|
|
150
|
+
</Playground>
|
|
151
|
+
<section id="with-attachments">
|
|
152
|
+
<h2>{ko ? "이미지 · 파일 · 인용" : "Images, files and quotation"}</h2>
|
|
153
|
+
<ExampleBlock align="column" previewWidth="full" code={`<ChatComposer attachments={[
|
|
154
|
+
{ id: "image", kind: "image", alt: "Layout preview" },
|
|
155
|
+
{ id: "upload", kind: "image", loading: true },
|
|
156
|
+
{ id: "pdf", kind: "file", filename: "review-notes.pdf" },
|
|
157
|
+
]} quotation={{ text: "Please review the layout.", onRemove: clearQuote }}
|
|
158
|
+
value={value} onValueChange={setValue} onSend={send}
|
|
159
|
+
onAttach={attach} onRemoveAttachment={remove}
|
|
160
|
+
/>`}><ComposerExample initialAttachments={composerAttachments} withQuote /></ExampleBlock>
|
|
161
|
+
</section>
|
|
162
|
+
<section id="use-cases">
|
|
163
|
+
<h2>{ko ? "사용 사례" : "Use cases"}</h2>
|
|
164
|
+
<div id="delivery-states">
|
|
165
|
+
<h3>{ko ? "전송 대기와 파일 업로드" : "Sending and file uploads"}</h3>
|
|
166
|
+
<p className="desc">{ko ? "메시지를 보내면 전송 중에는 회색으로 표시되고, 전송이 끝나면 원래 색으로 바뀌어요. 파일 업로드 체험으로 첨부 하단의 로딩 표시도 확인해 보세요. 실제 서버 전송 없이 대기 시간을 재현해요." : "Send a message or try a file upload to see the pending states. This example simulates upload and delivery latency."}</p>
|
|
167
|
+
<ExampleBlock align="column" previewWidth="full" code={`<ChatMessage author="Taylor Kim" deliveryStatus={isSending ? "sending" : "sent"}>
|
|
168
|
+
{message.body}
|
|
169
|
+
</ChatMessage>
|
|
170
|
+
|
|
171
|
+
<ChatComposer attachments={files} value={value} onValueChange={setValue} onSend={send} />
|
|
172
|
+
${ko ? "// 업로드 진행률을 uploadProgress에 넣고, 완료되면 해당 속성을 제거하세요." : "// Set uploadProgress from upload events and remove it after confirmation."}`}><ComposerExample uploadDemo initialValue={ko ? "검토 의견을 정리했어요." : "The review notes are ready."} /></ExampleBlock>
|
|
173
|
+
</div>
|
|
174
|
+
<div id="footer-tools">
|
|
175
|
+
<h3>{ko ? "하단 도구 모음" : "Footer tools"}</h3>
|
|
176
|
+
<p className="desc">{ko ? "텍스트를 선택한 뒤 하단 도구로 굵게, 기울임, 밑줄을 적용해 보세요. 이모지를 넣을 수 있고, GIF 버튼은 배치 예시로만 제공해요." : "Format selected text and insert emoji. The GIF button is a placement example and has no action."}</p>
|
|
177
|
+
<ExampleBlock align="column" previewWidth="full" code={`import { RichChatComposerExample } from "@/examples/RichChatComposerExample";
|
|
178
|
+
|
|
179
|
+
<RichChatComposerExample mode="footer" />`}><RichChatComposerExample mode="footer" /></ExampleBlock>
|
|
180
|
+
</div>
|
|
181
|
+
<div id="selection-tools">
|
|
182
|
+
<h3>{ko ? "선택 영역 미니 툴바" : "Selection mini toolbar"}</h3>
|
|
183
|
+
<p className="desc">{ko ? "텍스트를 선택하면 서식 도구가 나타나요. Alt+F10으로 도구에 포커스를 옮길 수 있어요. 이모지는 하단 버튼에서 선택해요." : "Select text to reveal formatting tools. Press Alt+F10 to focus the tools. Choose emoji from the footer."}</p>
|
|
184
|
+
<ExampleBlock align="column" previewWidth="full" code={`import { RichChatComposerExample } from "@/examples/RichChatComposerExample";
|
|
185
|
+
|
|
186
|
+
<RichChatComposerExample mode="selection" />`}><RichChatComposerExample mode="selection" /></ExampleBlock>
|
|
187
|
+
</div>
|
|
188
|
+
<h3>{ko ? "멘션과 명령" : "Mentions and commands"}</h3>
|
|
189
|
+
<p className="desc">{ko ? "@를 입력하면 사용자를, /를 입력하면 명령을 찾을 수 있어요. 위아래 방향키로 이동한 뒤 Enter를 누르거나 항목을 클릭해 선택하세요." : "Type @ to find people or / to find commands. Select with arrow keys and Enter, or click an item."}</p>
|
|
190
|
+
<ExampleBlock align="column" previewWidth="full" code={`const [value, setValue] = useState("");
|
|
191
|
+
const [mentions, setMentions] = useState<ChatMention[]>([]);
|
|
192
|
+
|
|
193
|
+
<ChatComposer value={value} mentions={mentions}
|
|
194
|
+
onValueChange={(text, nextMentions) => {
|
|
195
|
+
setValue(text); setMentions(nextMentions);
|
|
196
|
+
}}
|
|
197
|
+
mentionOptions={[{ id: "alex", label: "Alex Morgan" }]}
|
|
198
|
+
commands={[{ id: "task", label: "task", insertText: "TODO: " }]}
|
|
199
|
+
onSend={() => save({ value, mentions })}
|
|
200
|
+
/>
|
|
201
|
+
|
|
202
|
+
<ChatMessageText value={message.value} mentions={message.mentions} />`}><ComposerExample contextual /></ExampleBlock>
|
|
203
|
+
</section>
|
|
204
|
+
<section id="api"><h2>{ko ? "속성" : "API"}</h2><DocsTable columns={[{ key: "prop", label: ko ? "속성" : "Prop", width: 200 }, { key: "type", label: ko ? "타입" : "Type", flex: true, minWidth: 220 }, { key: "default", label: ko ? "기본값" : "Default", width: 100 }, { key: "description", label: ko ? "설명" : "Description", flex: true, minWidth: 220 }]} rows={rows.map(([prop, type, defaultValue, description]) => ({ prop, type, default: defaultValue, description }))} /></section>
|
|
205
|
+
</>;
|
|
206
|
+
}
|
|
207
|
+
````
|
|
208
|
+
|
|
209
|
+
### Source: web/examples/chatAttachmentDownload.ts
|
|
210
|
+
|
|
211
|
+
````tsx
|
|
212
|
+
import type { ChatAttachmentFile } from "@/components/ChatInput";
|
|
213
|
+
|
|
214
|
+
export function downloadChatFile(file: ChatAttachmentFile) {
|
|
215
|
+
if (!file.downloadUrl) return;
|
|
216
|
+
const link = document.createElement("a");
|
|
217
|
+
link.href = file.downloadUrl;
|
|
218
|
+
link.download = file.filename;
|
|
219
|
+
document.body.append(link);
|
|
220
|
+
link.click();
|
|
221
|
+
link.remove();
|
|
222
|
+
}
|
|
223
|
+
````
|
|
224
|
+
|
|
225
|
+
### Source: web/examples/ChatComposerExamples.tsx
|
|
226
|
+
|
|
227
|
+
````tsx
|
|
228
|
+
"use client";
|
|
229
|
+
|
|
230
|
+
import { PreviewButton } from "@/app/_components/PreviewButton";
|
|
231
|
+
|
|
232
|
+
import { useState } from "react";
|
|
233
|
+
import { ChatComposer, ChatMessageText, type ChatComposerProps, type ChatMention } from "@/components/ChatComposer";
|
|
234
|
+
import { ChatMessage } from "@/components/ChatMessage";
|
|
235
|
+
import { AttachmentItem } from "@/components/AttachmentItem";
|
|
236
|
+
import { AttachmentThumb } from "@/components/AttachmentThumb";
|
|
237
|
+
import { useTheme } from "@/components/ThemeController";
|
|
238
|
+
import type { ChatAttachment } from "@/components/ChatInput";
|
|
239
|
+
import { useChatUploads, useChatDelivery } from "./useChatDelivery";
|
|
240
|
+
import { downloadChatFile } from "./chatAttachmentDownload";
|
|
241
|
+
import styles from "./TeamChatDemo.module.css";
|
|
242
|
+
|
|
243
|
+
export const composerAttachments: ChatAttachment[] = [
|
|
244
|
+
{ id: "image", kind: "image", alt: "Layout preview" },
|
|
245
|
+
{ id: "loading-image", kind: "image", loading: true, alt: "Uploading image" },
|
|
246
|
+
{ id: "pdf", kind: "file", filename: "review-notes.pdf", downloadUrl: "/examples/review-notes.pdf" },
|
|
247
|
+
{ id: "fig", kind: "file", filename: "components.fig" },
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
type Options = Pick<ChatComposerProps, "shape" | "variant" | "appearance" | "separateSend" | "sendIcon" | "sendVariant" | "disabled" | "sending" | "sendDisabled" | "maxRows">;
|
|
251
|
+
export function ComposerExample({ options, initialAttachments = [], withQuote = false, contextual = false, uploadDemo = false, initialValue = "" }: { uploadDemo?: boolean; initialValue?: string; options?: Options; initialAttachments?: ChatAttachment[]; withQuote?: boolean; contextual?: boolean }) {
|
|
252
|
+
const { lang } = useTheme();
|
|
253
|
+
const ko = lang === "ko";
|
|
254
|
+
const [value, setValue] = useState(initialValue);
|
|
255
|
+
const [mentions, setMentions] = useState<ChatMention[]>([]);
|
|
256
|
+
const { attachments, attach, queue, remove, clear } = useChatUploads(initialAttachments);
|
|
257
|
+
const { sending, deliver } = useChatDelivery();
|
|
258
|
+
const [quote, setQuote] = useState(withQuote);
|
|
259
|
+
const [sent, setSent] = useState<{ id: number; value: string; mentions: ChatMention[]; attachments: ChatAttachment[] } | null>(null);
|
|
260
|
+
return <div className={styles.root}>
|
|
261
|
+
{sent && <ChatMessage key={sent.id} deliveryStatus={sending ? "sending" : "sent"} author="Taylor Kim" timestamp={ko ? "방금" : "Just now"} attachments={sent.attachments.map(item => item.kind === "file" ? <AttachmentItem key={item.id} filename={item.filename} onDownload={item.downloadUrl ? () => downloadChatFile(item) : undefined} /> : <AttachmentThumb key={item.id} src={item.src} alt={item.alt} />)}><ChatMessageText value={sent.value} mentions={sent.mentions} /></ChatMessage>}
|
|
262
|
+
{uploadDemo && <PreviewButton className={styles.uploadExample} size="sm" onClick={() => queue([{ id: `demo-${Date.now()}`, kind: "file", filename: "review-notes.pdf", downloadUrl: "/examples/review-notes.pdf" }])}>{ko ? "파일 업로드 체험" : "Try file upload"}</PreviewButton>}
|
|
263
|
+
<ChatComposer {...options} sendDisabled={options?.sendDisabled || sending} value={value} onValueChange={(next, nextMentions) => { setValue(next); setMentions(nextMentions); }} mentions={mentions} placeholder={contextual ? (ko ? "@ 사용자 멘션, / 명령" : "@ mention someone, / choose a command") : undefined} mentionOptions={contextual ? [{ id: "alex", label: "Alex Morgan" }, { id: "jamie", label: "Jamie Chen" }, { id: "taylor", label: "Taylor Kim" }] : undefined} commands={contextual ? [{ id: "task", label: "task", description: ko ? "할 일 작성" : "Write a task", insertText: "TODO: " }, { id: "decision", label: "decision", description: ko ? "결정 사항 기록" : "Record a decision", insertText: "Decision: " }, { id: "note", label: "note", description: ko ? "팀 노트 작성" : "Write a team note", insertText: "Note: " }] : undefined} attachments={attachments} onAttach={attach} onRemoveAttachment={remove} quotation={quote ? { text: ko ? "Alex Morgan: 모바일 레이아웃을 검토해 주세요." : "Alex Morgan: Please review the mobile layout.", onRemove: () => setQuote(false) } : undefined} onSend={() => deliver(() => { setSent({ id: Date.now(), value, mentions, attachments }); setValue(""); setMentions([]); clear(); setQuote(false); }, () => {})} />
|
|
264
|
+
</div>;
|
|
265
|
+
}
|
|
266
|
+
````
|
|
267
|
+
|
|
268
|
+
### Source: web/examples/RichChatComposerExample.module.css
|
|
269
|
+
|
|
270
|
+
````css
|
|
271
|
+
.root { display: grid; gap: var(--space-4); width: 100%; min-width: 0; }
|
|
272
|
+
.editor { min-height: calc(var(--lh-base) + var(--space-3) * 2); padding: var(--space-3) var(--space-4); color: var(--fg-strong); font-family: var(--font-normal); font-size: var(--text-base); line-height: var(--lh-base); white-space: pre-wrap; overflow-wrap: anywhere; outline: none; }
|
|
273
|
+
.editor:empty::before { content: attr(data-placeholder); color: var(--fg-subtle); pointer-events: none; }
|
|
274
|
+
.editor strong, .root :global([data-slot="chat-message-body"] strong) { font-weight: var(--font-weight-bold); }
|
|
275
|
+
.footerTools.footerTools[data-size] { --iconbtn-h-md: var(--size-8); --toolbar-icon-size: var(--size-4); padding: 0; border: 0; }
|
|
276
|
+
.root :global([data-kind="image"] > span) { background: var(--bg-muted); color: var(--fg-muted); }
|
|
277
|
+
.mediaThumb { background: var(--bg-muted); color: var(--fg-muted); }
|
|
278
|
+
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: 0; overflow: hidden; clip-path: inset(100%); white-space: nowrap; border: 0; }
|
|
279
|
+
|
|
280
|
+
.selectionPopover { z-index: var(--z-popover); outline: none; }
|
|
281
|
+
|
|
282
|
+
.emojiPopover { --float-open-duration: var(--duration-fast); z-index: var(--z-popover); max-width: calc(100vw - var(--space-4)); outline: none; }
|
|
283
|
+
````
|
|
284
|
+
|
|
285
|
+
### Source: web/examples/RichChatComposerExample.tsx
|
|
286
|
+
|
|
287
|
+
````tsx
|
|
288
|
+
"use client";
|
|
289
|
+
|
|
290
|
+
import { useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from "react";
|
|
291
|
+
import * as Popover from "@radix-ui/react-popover";
|
|
292
|
+
import { ChatComposer } from "@/components/ChatComposer";
|
|
293
|
+
import { ChatMessage } from "@/components/ChatMessage";
|
|
294
|
+
import { AttachmentItem } from "@/components/AttachmentItem";
|
|
295
|
+
import { AttachmentThumb } from "@/components/AttachmentThumb";
|
|
296
|
+
import { Toolbar } from "@/components/Toolbar";
|
|
297
|
+
import { IconButton } from "@/components/IconButton";
|
|
298
|
+
import { Icon } from "@/components/Icon";
|
|
299
|
+
import { EmojiPicker } from "@/components/EmojiPicker";
|
|
300
|
+
import { Gif } from "@phosphor-icons/react";
|
|
301
|
+
import { useTheme } from "@/components/ThemeController";
|
|
302
|
+
import type { ChatAttachment } from "@/components/ChatInput";
|
|
303
|
+
import { useChatUploads, useChatDelivery } from "./useChatDelivery";
|
|
304
|
+
import { downloadChatFile } from "./chatAttachmentDownload";
|
|
305
|
+
import styles from "./RichChatComposerExample.module.css";
|
|
306
|
+
|
|
307
|
+
type Mark = "bold" | "italic" | "underline";
|
|
308
|
+
type Character = { text: string; bold: boolean; italic: boolean; underline: boolean };
|
|
309
|
+
type TextSelection = { start: number; end: number };
|
|
310
|
+
const plain = (text: string): Character[] => text.split("").map(text => ({ text, bold: false, italic: false, underline: false }));
|
|
311
|
+
const runs = (doc: Character[]) => doc.reduce<Character[]>((result, char) => {
|
|
312
|
+
const last = result.at(-1);
|
|
313
|
+
if (last && last.bold === char.bold && last.italic === char.italic && last.underline === char.underline) last.text += char.text;
|
|
314
|
+
else result.push({ ...char });
|
|
315
|
+
return result;
|
|
316
|
+
}, []);
|
|
317
|
+
function RichText({ doc }: { doc: Character[] }) {
|
|
318
|
+
return <>{runs(doc).map((run, i) => {
|
|
319
|
+
let node: ReactNode = run.text;
|
|
320
|
+
if (run.underline) node = <u>{node}</u>;
|
|
321
|
+
if (run.italic) node = <em>{node}</em>;
|
|
322
|
+
if (run.bold) node = <strong>{node}</strong>;
|
|
323
|
+
return <span key={i}>{node}</span>;
|
|
324
|
+
})}</>;
|
|
325
|
+
}
|
|
326
|
+
/** Read only text and the three supported semantic marks. No editable HTML is persisted. */
|
|
327
|
+
function read(root: Node): Character[] {
|
|
328
|
+
const result: Character[] = [];
|
|
329
|
+
const visit = (node: Node, marks = { bold: false, italic: false, underline: false }) => {
|
|
330
|
+
if (node.nodeType === Node.TEXT_NODE) { result.push(...plain((node.textContent ?? "").replaceAll("\u00a0", " ")).map(char => ({ ...char, ...marks }))); return; }
|
|
331
|
+
if (!(node instanceof Element) && node !== root) return;
|
|
332
|
+
const tag = node instanceof Element ? node.tagName : "";
|
|
333
|
+
if (tag === "BR") { if (node.parentNode?.childNodes.length !== 1) result.push(...plain("\n")); return; }
|
|
334
|
+
if (/^(DIV|P)$/.test(tag) && node.previousSibling) result.push(...plain("\n"));
|
|
335
|
+
const next = { bold: marks.bold || tag === "STRONG" || tag === "B", italic: marks.italic || tag === "EM" || tag === "I", underline: marks.underline || tag === "U" };
|
|
336
|
+
node.childNodes.forEach(child => visit(child, next));
|
|
337
|
+
};
|
|
338
|
+
root.childNodes.forEach(node => visit(node));
|
|
339
|
+
return result;
|
|
340
|
+
}
|
|
341
|
+
function write(root: HTMLElement, doc: Character[], selection: TextSelection) {
|
|
342
|
+
const fragment = document.createDocumentFragment();
|
|
343
|
+
for (const run of runs(doc)) {
|
|
344
|
+
let node: Node = document.createTextNode(run.text);
|
|
345
|
+
for (const [mark, tag] of [[run.underline, "u"], [run.italic, "em"], [run.bold, "strong"]] as const) {
|
|
346
|
+
if (mark) { const wrapper = document.createElement(tag); wrapper.append(node); node = wrapper; }
|
|
347
|
+
}
|
|
348
|
+
fragment.append(node);
|
|
349
|
+
}
|
|
350
|
+
if (!fragment.childNodes.length) fragment.append(document.createTextNode(""));
|
|
351
|
+
root.replaceChildren(fragment);
|
|
352
|
+
const point = (offset: number): [Node, number] => {
|
|
353
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
354
|
+
let remaining = Math.max(0, Math.min(doc.length, offset));
|
|
355
|
+
let node = walker.nextNode();
|
|
356
|
+
while (node) { const length = node.textContent?.length ?? 0; if (remaining <= length) return [node, remaining]; remaining -= length; node = walker.nextNode(); }
|
|
357
|
+
return [root, root.childNodes.length];
|
|
358
|
+
};
|
|
359
|
+
const range = document.createRange();
|
|
360
|
+
range.setStart(...point(selection.start)); range.setEnd(...point(selection.end));
|
|
361
|
+
root.focus({ preventScroll: true });
|
|
362
|
+
const current = window.getSelection(); current?.removeAllRanges(); current?.addRange(range);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const initialText = "The updated chat input is ready for review.";
|
|
366
|
+
|
|
367
|
+
/** Consumer-owned editor demonstrating two tool arrangements over the same ChatComposer. */
|
|
368
|
+
export function RichChatComposerExample({ mode }: { mode: "footer" | "selection" }) {
|
|
369
|
+
const { lang } = useTheme();
|
|
370
|
+
const ko = lang === "ko";
|
|
371
|
+
const label = ko ? "서식 있는 메시지 작성" : "Write a formatted message";
|
|
372
|
+
const editor = useRef<HTMLDivElement>(null);
|
|
373
|
+
const initial = useRef(<RichText doc={plain(initialText)} />);
|
|
374
|
+
const [doc, setDoc] = useState(() => plain(initialText));
|
|
375
|
+
const current = useRef(doc);
|
|
376
|
+
const selection = useRef<TextSelection>({ start: initialText.length, end: initialText.length });
|
|
377
|
+
const [selected, setSelected] = useState<TextSelection>(selection.current);
|
|
378
|
+
const [bubble, setBubble] = useState(false);
|
|
379
|
+
const [emojiOpen, setEmojiOpen] = useState(false);
|
|
380
|
+
const composing = useRef(false);
|
|
381
|
+
const virtual = useRef<{ getBoundingClientRect: () => DOMRect } | null>(null);
|
|
382
|
+
const toolbar = useRef<HTMLDivElement>(null);
|
|
383
|
+
const history = useRef([{ doc, selection: selection.current }]);
|
|
384
|
+
const historyIndex = useRef(0);
|
|
385
|
+
const { attachments, attach, remove, clear } = useChatUploads();
|
|
386
|
+
const { sending, deliver } = useChatDelivery();
|
|
387
|
+
const [sent, setSent] = useState<{ id: number; doc: Character[]; attachments: ChatAttachment[] } | null>(null);
|
|
388
|
+
const helpId = useId();
|
|
389
|
+
const capture = () => {
|
|
390
|
+
const root = editor.current;
|
|
391
|
+
const sel = window.getSelection();
|
|
392
|
+
if (!root || !sel?.rangeCount || !root.contains(sel.anchorNode) || !root.contains(sel.focusNode)) { setBubble(false); return; }
|
|
393
|
+
const range = sel.getRangeAt(0);
|
|
394
|
+
const offset = (node: Node, position: number) => { const prefix = document.createRange(); prefix.selectNodeContents(root); prefix.setEnd(node, position); return read(prefix.cloneContents()).length; };
|
|
395
|
+
const next = { start: offset(range.startContainer, range.startOffset), end: offset(range.endContainer, range.endOffset) };
|
|
396
|
+
selection.current = next; setSelected(next);
|
|
397
|
+
const rect = range.getBoundingClientRect();
|
|
398
|
+
virtual.current = { getBoundingClientRect: () => rect };
|
|
399
|
+
setBubble(!composing.current && next.end > next.start);
|
|
400
|
+
};
|
|
401
|
+
useEffect(() => { document.addEventListener("selectionchange", capture); return () => document.removeEventListener("selectionchange", capture); }, []);
|
|
402
|
+
const commit = (next: Character[], position: TextSelection, updateDOM = true, remember = true) => {
|
|
403
|
+
if (remember) { history.current = history.current.slice(0, historyIndex.current + 1); history.current.push({ doc: next, selection: position }); historyIndex.current++; }
|
|
404
|
+
current.current = next; setDoc(next); selection.current = position; setSelected(position);
|
|
405
|
+
if (updateDOM && editor.current) { write(editor.current, next, position); capture(); }
|
|
406
|
+
};
|
|
407
|
+
const insert = (text: string) => {
|
|
408
|
+
const { start, end } = selection.current;
|
|
409
|
+
const next = [...current.current.slice(0, start), ...plain(text), ...current.current.slice(end)];
|
|
410
|
+
commit(next, { start: start + text.length, end: start + text.length });
|
|
411
|
+
};
|
|
412
|
+
const format = (mark: Mark) => {
|
|
413
|
+
const { start, end } = selection.current;
|
|
414
|
+
if (end <= start) return;
|
|
415
|
+
const enabled = !current.current.slice(start, end).every(char => char[mark]);
|
|
416
|
+
commit(current.current.map((char, index) => index >= start && index < end ? { ...char, [mark]: enabled } : char), { start, end });
|
|
417
|
+
};
|
|
418
|
+
const send = () => {
|
|
419
|
+
if (sending || attachments.some(item => item.uploadProgress != null)) return;
|
|
420
|
+
if (!current.current.map(char => char.text).join("").trim() && !attachments.length) return;
|
|
421
|
+
deliver(() => { setSent({ id: Date.now(), doc: current.current, attachments }); clear(); commit([], { start: 0, end: 0 }); setBubble(false); }, () => {});
|
|
422
|
+
};
|
|
423
|
+
const buttons = () => <Toolbar.Group>{([
|
|
424
|
+
["bold", "text-b", ko ? "굵게" : "Bold"], ["italic", "text-italic", ko ? "기울임" : "Italic"], ["underline", "text-underline", ko ? "밑줄" : "Underline"],
|
|
425
|
+
] as const).map(([mark, icon, name]) => <IconButton key={mark} icon={<Icon name={icon} />} aria-label={name} title={name} aria-pressed={selected.end > selected.start && doc.slice(selected.start, selected.end).every(char => char[mark])} disabled={selected.end <= selected.start} onPointerDown={event => event.preventDefault()} onClick={() => format(mark)} />)}</Toolbar.Group>;
|
|
426
|
+
const tools = <Toolbar variant="attached" stretch={false} size="xs" className={styles.footerTools} aria-label={ko ? "메시지 도구" : "Message tools"}>
|
|
427
|
+
{mode === "footer" && <>{buttons()}<Toolbar.Divider /></>}
|
|
428
|
+
<Toolbar.Group>
|
|
429
|
+
<Popover.Root open={emojiOpen} onOpenChange={setEmojiOpen}><Popover.Trigger asChild><IconButton icon={<Icon name="smiley" />} aria-label={ko ? "이모지" : "Emoji"} title={ko ? "이모지" : "Emoji"} /></Popover.Trigger>
|
|
430
|
+
<Popover.Portal><Popover.Content className={`${styles.emojiPopover} m-float`} aria-label={ko ? "이모지 선택" : "Choose emoji"} side="top" align="start" sideOffset={8} collisionPadding={8} onOpenAutoFocus={event => event.preventDefault()} onCloseAutoFocus={event => { event.preventDefault(); if (editor.current) write(editor.current, current.current, selection.current); }}>
|
|
431
|
+
<EmojiPicker autoFocus onSelect={item => { insert(item.emoji); setEmojiOpen(false); }} />
|
|
432
|
+
</Popover.Content></Popover.Portal>
|
|
433
|
+
</Popover.Root>
|
|
434
|
+
<IconButton icon={<Gif weight="regular" />} aria-label="GIF" title="GIF" />
|
|
435
|
+
</Toolbar.Group>
|
|
436
|
+
</Toolbar>;
|
|
437
|
+
return <div className={styles.root} data-rich-composer={mode}>
|
|
438
|
+
{sent && <ChatMessage key={sent.id} deliveryStatus={sending ? "sending" : "sent"} author="Taylor Kim" timestamp={ko ? "방금" : "Just now"} attachments={sent.attachments.map(item => item.kind === "image" ? <AttachmentThumb key={item.id} src={item.src} alt={item.alt} className={styles.mediaThumb} style={{ "--at-ph-bg-light": "var(--bg-muted)", "--at-ph-fg-light": "var(--fg-muted)", "--at-ph-bg-dark": "var(--bg-muted)", "--at-ph-fg-dark": "var(--fg-muted)" } as CSSProperties} /> : <AttachmentItem key={item.id} filename={item.filename} onDownload={item.downloadUrl ? () => downloadChatFile(item) : undefined} />)}><RichText doc={sent.doc} /></ChatMessage>}
|
|
439
|
+
<ChatComposer sendDisabled={sending} value={doc.map(char => char.text).join("")} onValueChange={() => {}} onSend={send} tools={tools} attachments={attachments} onAttach={attach} onRemoveAttachment={remove} editor={<div ref={editor} className={styles.editor} role="textbox" aria-multiline="true" aria-label={label} aria-describedby={mode === "selection" ? helpId : undefined} contentEditable suppressContentEditableWarning data-placeholder={ko ? "메시지 입력" : "Write a message"} onInput={() => { if (!composing.current && editor.current) { capture(); commit(read(editor.current), selection.current, false); } }} onCompositionStart={() => { composing.current = true; setBubble(false); }} onCompositionEnd={() => { composing.current = false; if (editor.current) { capture(); commit(read(editor.current), selection.current, false); } }} onPaste={event => { event.preventDefault(); insert(event.clipboardData.getData("text/plain")); }} onKeyDown={event => {
|
|
440
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
|
441
|
+
const modifier = event.metaKey || event.ctrlKey;
|
|
442
|
+
if (modifier && ["b", "i", "u"].includes(event.key.toLowerCase())) { event.preventDefault(); capture(); format(event.key.toLowerCase() === "b" ? "bold" : event.key.toLowerCase() === "i" ? "italic" : "underline"); }
|
|
443
|
+
else if (modifier && ["z", "y"].includes(event.key.toLowerCase())) { event.preventDefault(); const direction = event.key.toLowerCase() === "y" || event.shiftKey ? 1 : -1; const index = Math.max(0, Math.min(history.current.length - 1, historyIndex.current + direction)); historyIndex.current = index; const snapshot = history.current[index]; commit(snapshot.doc, snapshot.selection, true, false); }
|
|
444
|
+
else if (event.altKey && event.key === "F10" && mode === "selection" && selection.current.end > selection.current.start) { event.preventDefault(); setBubble(true); requestAnimationFrame(() => toolbar.current?.querySelector<HTMLButtonElement>("button")?.focus()); }
|
|
445
|
+
else if (event.key === "Escape") { setBubble(false); }
|
|
446
|
+
else if (event.key === "Enter" && !event.shiftKey) { event.preventDefault(); send(); }
|
|
447
|
+
}}>{initial.current}</div>} />
|
|
448
|
+
{mode === "selection" && <>
|
|
449
|
+
<span id={helpId} className={styles.srOnly}>{ko ? "텍스트를 선택해 서식을 적용합니다. Alt+F10으로 서식 도구에 이동합니다." : "Select text to format it. Press Alt+F10 to focus formatting tools."}</span>
|
|
450
|
+
<Popover.Root open={bubble} onOpenChange={setBubble} modal={false}><Popover.Anchor virtualRef={virtual} /><Popover.Portal><Popover.Content className={`${styles.selectionPopover} m-float`} aria-label={ko ? "서식 도구" : "Formatting tools"} side="top" sideOffset={8} collisionPadding={8} onOpenAutoFocus={event => event.preventDefault()} onCloseAutoFocus={event => event.preventDefault()} onInteractOutside={event => { if (editor.current?.contains(event.target as Node)) event.preventDefault(); }}>
|
|
451
|
+
<Toolbar ref={toolbar} variant="floating" size="xs" aria-label={ko ? "선택 텍스트 서식" : "Selection formatting"} onKeyDownCapture={event => { if (event.key === "Escape") { setBubble(false); if (editor.current) write(editor.current, current.current, selection.current); } }}>{buttons()}</Toolbar>
|
|
452
|
+
</Popover.Content></Popover.Portal></Popover.Root>
|
|
453
|
+
</>}
|
|
454
|
+
</div>;
|
|
455
|
+
}
|
|
456
|
+
````
|
|
457
|
+
|
|
458
|
+
### Source: web/examples/TeamChatDemo.module.css
|
|
459
|
+
|
|
460
|
+
````css
|
|
461
|
+
.root { width: 100%; min-width: 0; display: grid; gap: var(--space-2); }
|
|
462
|
+
.threadContent { display: grid; gap: var(--space-2); padding-bottom: var(--space-4); }
|
|
463
|
+
.threadComposer { width: 100%; min-width: 0; }
|
|
464
|
+
|
|
465
|
+
.uploadExample { justify-self: center; }
|
|
466
|
+
|
|
467
|
+
.threadDivider { width: 100%; margin: 0; border: 0; border-top: var(--hairline) solid var(--border); }
|
|
468
|
+
````
|
|
469
|
+
|
|
470
|
+
### Source: web/examples/useChatDelivery.ts
|
|
471
|
+
|
|
472
|
+
````tsx
|
|
473
|
+
"use client";
|
|
474
|
+
|
|
475
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
476
|
+
import type { ChatAttachment } from "@/components/ChatInput";
|
|
477
|
+
|
|
478
|
+
/** Local documentation simulation. Production hosts replace these timers with upload/ack events. */
|
|
479
|
+
export function useChatUploads(initial: ChatAttachment[] = []) {
|
|
480
|
+
const [attachments, setAttachments] = useState(initial);
|
|
481
|
+
const timers = useRef(new Map<string, ReturnType<typeof setTimeout>>());
|
|
482
|
+
const urls = useRef<string[]>([]);
|
|
483
|
+
useEffect(() => () => { timers.current.forEach(clearTimeout); urls.current.forEach(url => URL.revokeObjectURL(url)); }, []);
|
|
484
|
+
const remove = useCallback((id: string) => {
|
|
485
|
+
const timer = timers.current.get(id); if (timer) clearTimeout(timer);
|
|
486
|
+
timers.current.delete(id); setAttachments(previous => previous.filter(item => item.id !== id));
|
|
487
|
+
}, []);
|
|
488
|
+
const queue = useCallback((items: ChatAttachment[]) => {
|
|
489
|
+
setAttachments(previous => [...previous, ...items.map(item => ({ ...item, uploadProgress: 0 }))]);
|
|
490
|
+
items.forEach(item => {
|
|
491
|
+
const tick = (value: number) => {
|
|
492
|
+
setAttachments(previous => previous.map(attachment => attachment.id === item.id ? { ...attachment, uploadProgress: value } : attachment));
|
|
493
|
+
if (value < 100) timers.current.set(item.id, setTimeout(() => tick(Math.min(100, value + 10)), 120));
|
|
494
|
+
else timers.current.set(item.id, setTimeout(() => {
|
|
495
|
+
timers.current.delete(item.id);
|
|
496
|
+
setAttachments(previous => previous.map(attachment => {
|
|
497
|
+
if (attachment.id !== item.id) return attachment;
|
|
498
|
+
const ready = { ...attachment }; delete ready.uploadProgress; return ready;
|
|
499
|
+
}));
|
|
500
|
+
}, 240));
|
|
501
|
+
};
|
|
502
|
+
timers.current.set(item.id, setTimeout(() => tick(10), 120));
|
|
503
|
+
});
|
|
504
|
+
}, []);
|
|
505
|
+
const attach = useCallback((files: File[]) => {
|
|
506
|
+
queue(files.map((file, index): ChatAttachment => {
|
|
507
|
+
const id = `${Date.now()}-${index}-${file.name}`;
|
|
508
|
+
const src = URL.createObjectURL(file); urls.current.push(src);
|
|
509
|
+
if (!file.type.startsWith("image/")) return { id, kind: "file", filename: file.name, downloadUrl: src };
|
|
510
|
+
return { id, kind: "image", src, alt: file.name };
|
|
511
|
+
}));
|
|
512
|
+
}, [queue]);
|
|
513
|
+
const clear = useCallback(() => { timers.current.forEach(clearTimeout); timers.current.clear(); setAttachments([]); }, []);
|
|
514
|
+
return { attachments, attach, queue, remove, clear };
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export function useChatDelivery() {
|
|
518
|
+
const [sending, setSending] = useState(false);
|
|
519
|
+
const busy = useRef(false);
|
|
520
|
+
const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
521
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
522
|
+
const deliver = useCallback((optimistic: () => void, confirmed: () => void) => {
|
|
523
|
+
if (busy.current) return;
|
|
524
|
+
busy.current = true; setSending(true); optimistic();
|
|
525
|
+
timer.current = setTimeout(() => { busy.current = false; confirmed(); setSending(false); }, 1100);
|
|
526
|
+
}, []);
|
|
527
|
+
return { sending, deliver };
|
|
528
|
+
}
|
|
529
|
+
````
|