@vllnt/ui 0.2.0 → 0.2.1-canary.0aaaad2
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/CHANGELOG.md +46 -1
- package/README.md +27 -12
- package/dist/components/accordion/accordion.js +2 -2
- package/dist/components/activity-heatmap/activity-heatmap.js +15 -13
- package/dist/components/activity-log/activity-log.js +6 -5
- package/dist/components/agent-activity/agent-activity.js +311 -0
- package/dist/components/agent-activity/index.js +18 -0
- package/dist/components/ai-artifact/ai-artifact.js +422 -0
- package/dist/components/ai-artifact/index.js +24 -0
- package/dist/components/ai-chat-input/ai-chat-input.js +2 -2
- package/dist/components/ai-message-bubble/ai-message-bubble.js +1 -1
- package/dist/components/ai-sidebar/ai-sidebar.js +254 -0
- package/dist/components/ai-sidebar/index.js +22 -0
- package/dist/components/ai-source-citation/ai-source-citation.js +2 -2
- package/dist/components/ai-tool-call-display/ai-tool-call-display.js +4 -4
- package/dist/components/alert-pulse/alert-pulse.js +93 -0
- package/dist/components/alert-pulse/index.js +6 -0
- package/dist/components/anchor-port/anchor-port.js +51 -0
- package/dist/components/anchor-port/index.js +4 -0
- package/dist/components/animated-text/animated-text.js +2 -4
- package/dist/components/auto-reload/auto-reload.js +377 -0
- package/dist/components/auto-reload/index.js +6 -0
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/avatar-group/avatar-group.js +4 -4
- package/dist/components/banner/banner.js +155 -0
- package/dist/components/banner/index.js +10 -0
- package/dist/components/bottom-activity-strip/bottom-activity-strip.js +91 -0
- package/dist/components/bottom-activity-strip/index.js +6 -0
- package/dist/components/bottom-bar/bottom-bar.js +25 -0
- package/dist/components/bottom-bar/index.js +4 -0
- package/dist/components/breadcrumb/breadcrumb.js +33 -26
- package/dist/components/button/button.js +1 -1
- package/dist/components/calendar/calendar.js +6 -6
- package/dist/components/callout/callout.js +1 -1
- package/dist/components/candlestick-chart/candlestick-chart.js +1 -1
- package/dist/components/canvas-shell/canvas-foundation-demo.js +183 -0
- package/dist/components/canvas-shell/canvas-shell-route-config.js +0 -0
- package/dist/components/canvas-shell/canvas-shell.js +261 -0
- package/dist/components/canvas-shell/index.js +4 -0
- package/dist/components/canvas-view/canvas-view.js +461 -0
- package/dist/components/canvas-view/index.js +6 -0
- package/dist/components/carousel/carousel.js +4 -4
- package/dist/components/chart/area-chart.js +1 -0
- package/dist/components/chart/line-chart.js +1 -0
- package/dist/components/chat-dock-section/chat-dock-section.js +56 -0
- package/dist/components/chat-dock-section/index.js +6 -0
- package/dist/components/checkbox/checkbox.js +2 -2
- package/dist/components/checklist/checklist.js +10 -3
- package/dist/components/checklist/index.js +3 -1
- package/dist/components/choropleth-map/choropleth-map.js +373 -0
- package/dist/components/choropleth-map/index.js +10 -0
- package/dist/components/chronological-timeline/chronological-timeline.js +338 -0
- package/dist/components/chronological-timeline/index.js +8 -0
- package/dist/components/civilization-card/civilization-card.js +258 -0
- package/dist/components/civilization-card/index.js +8 -0
- package/dist/components/code-block/code-block.js +2 -2
- package/dist/components/code-playground/code-playground.js +8 -7
- package/dist/components/combobox/combobox.js +46 -22
- package/dist/components/command/command.js +1 -1
- package/dist/components/comment-pin/comment-pin.js +104 -0
- package/dist/components/comment-pin/index.js +6 -0
- package/dist/components/comparison/comparison.js +9 -9
- package/dist/components/completion-dialog/completion-dialog.js +1 -1
- package/dist/components/connector-edge/connector-edge.js +66 -0
- package/dist/components/connector-edge/index.js +6 -0
- package/dist/components/content-intro/content-intro.js +7 -6
- package/dist/components/context-lens/context-lens.js +98 -0
- package/dist/components/context-lens/index.js +6 -0
- package/dist/components/context-menu/context-menu.js +4 -4
- package/dist/components/conversation-thread/conversation-thread.js +348 -0
- package/dist/components/conversation-thread/index.js +20 -0
- package/dist/components/cookie-consent/cookie-consent.js +1 -1
- package/dist/components/copy-button/copy-button.js +189 -0
- package/dist/components/copy-button/index.js +8 -0
- package/dist/components/countdown-timer/countdown-timer.js +8 -7
- package/dist/components/credit-badge/credit-badge.js +1 -7
- package/dist/components/curriculum/curriculum.js +349 -0
- package/dist/components/curriculum/index.js +10 -0
- package/dist/components/data-list/data-list.js +2 -1
- package/dist/components/data-table/data-table.js +5 -4
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/dialog.js +1 -1
- package/dist/components/document-sibling-nav/document-sibling-nav.js +111 -0
- package/dist/components/document-sibling-nav/index.js +8 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +3 -3
- package/dist/components/edge-label/edge-label.js +26 -0
- package/dist/components/edge-label/index.js +4 -0
- package/dist/components/empty-state/empty-state.js +93 -0
- package/dist/components/empty-state/index.js +8 -0
- package/dist/components/era-comparison/era-comparison.js +198 -0
- package/dist/components/era-comparison/index.js +16 -0
- package/dist/components/exercise/exercise.js +4 -4
- package/dist/components/faq/faq.js +2 -2
- package/dist/components/file-upload/file-upload.js +3 -3
- package/dist/components/filter-bar/filter-bar.js +2 -1
- package/dist/components/flashcard/flashcard.js +1 -1
- package/dist/components/floating-action-button/floating-action-button.js +1 -1
- package/dist/components/floating-toolbar/floating-toolbar.js +66 -0
- package/dist/components/floating-toolbar/index.js +6 -0
- package/dist/components/flow-diagram/flow-controls.js +9 -9
- package/dist/components/flow-diagram/flow-error-boundary.js +2 -2
- package/dist/components/flow-diagram/flow-fullscreen.js +2 -2
- package/dist/components/follow-mode/follow-mode.js +89 -0
- package/dist/components/follow-mode/index.js +6 -0
- package/dist/components/form/form.js +432 -0
- package/dist/components/form/index.js +20 -0
- package/dist/components/gantt-chart/gantt-chart.js +333 -0
- package/dist/components/gantt-chart/index.js +6 -0
- package/dist/components/geography-quiz-map/geography-quiz-map.js +343 -0
- package/dist/components/geography-quiz-map/index.js +12 -0
- package/dist/components/glass-panel/glass-panel.js +21 -0
- package/dist/components/glass-panel/index.js +4 -0
- package/dist/components/globe-3d/globe-3d.js +417 -0
- package/dist/components/globe-3d/index.js +10 -0
- package/dist/components/group-hull/group-hull.js +29 -0
- package/dist/components/group-hull/index.js +4 -0
- package/dist/components/handoff-beacon/handoff-beacon.js +78 -0
- package/dist/components/handoff-beacon/index.js +6 -0
- package/dist/components/heat-map-overlay/heat-map-overlay.js +215 -0
- package/dist/components/heat-map-overlay/index.js +6 -0
- package/dist/components/heat-overlay/heat-overlay.js +92 -0
- package/dist/components/heat-overlay/index.js +6 -0
- package/dist/components/historic-timeline/historic-timeline.js +342 -0
- package/dist/components/historic-timeline/index.js +6 -0
- package/dist/components/historical-figure-card/historical-figure-card.js +270 -0
- package/dist/components/historical-figure-card/index.js +6 -0
- package/dist/components/horizontal-scroll-row/horizontal-scroll-row.js +4 -4
- package/dist/components/index.js +568 -1
- package/dist/components/infinite-plane/index.js +6 -0
- package/dist/components/infinite-plane/infinite-plane.js +75 -0
- package/dist/components/input-otp/input-otp.js +1 -1
- package/dist/components/interactive-timeline/index.js +16 -0
- package/dist/components/interactive-timeline/interactive-timeline.js +708 -0
- package/dist/components/jarvis-dock/index.js +6 -0
- package/dist/components/jarvis-dock/jarvis-dock.js +98 -0
- package/dist/components/kbd/index.js +5 -0
- package/dist/components/kbd/kbd.js +117 -0
- package/dist/components/key-concept/key-concept.js +4 -4
- package/dist/components/keyboard-shortcuts-help/keyboard-shortcuts-help.js +2 -2
- package/dist/components/knowledge-check/index.js +6 -0
- package/dist/components/knowledge-check/knowledge-check.js +448 -0
- package/dist/components/learning-objectives/learning-objectives.js +12 -12
- package/dist/components/left-rail/index.js +4 -0
- package/dist/components/left-rail/left-rail.js +25 -0
- package/dist/components/live-cursor/index.js +6 -0
- package/dist/components/live-cursor/live-cursor.js +62 -0
- package/dist/components/live-feed/live-feed.js +15 -13
- package/dist/components/map-2d/index.js +20 -0
- package/dist/components/map-2d/map-2d.js +455 -0
- package/dist/components/map-timeline/index.js +16 -0
- package/dist/components/map-timeline/map-timeline.js +506 -0
- package/dist/components/market-treemap/market-treemap.js +1 -1
- package/dist/components/mdx-content/mdx-content.js +2 -1
- package/dist/components/menubar/menubar.js +4 -4
- package/dist/components/metric-cluster/index.js +6 -0
- package/dist/components/metric-cluster/metric-cluster.js +96 -0
- package/dist/components/metric-gauge/metric-gauge.js +1 -1
- package/dist/components/mini-map-panel/index.js +6 -0
- package/dist/components/mini-map-panel/mini-map-panel.js +74 -0
- package/dist/components/model-comparison/index.js +12 -0
- package/dist/components/model-comparison/model-comparison.js +211 -0
- package/dist/components/model-selector/model-selector.js +2 -2
- package/dist/components/multi-select/index.js +6 -0
- package/dist/components/multi-select/multi-select.js +258 -0
- package/dist/components/multi-select-lasso/index.js +6 -0
- package/dist/components/multi-select-lasso/multi-select-lasso.js +76 -0
- package/dist/components/navbar-saas/navbar-saas.js +3 -2
- package/dist/components/navigation-menu/navigation-menu.js +2 -2
- package/dist/components/newsletter-signup/index.js +8 -0
- package/dist/components/newsletter-signup/newsletter-signup.js +269 -0
- package/dist/components/number-input/number-input.js +1 -1
- package/dist/components/number-ticker/number-ticker.js +11 -4
- package/dist/components/object-card/index.js +6 -0
- package/dist/components/object-card/object-card.js +126 -0
- package/dist/components/object-handle/index.js +4 -0
- package/dist/components/object-handle/object-handle.js +38 -0
- package/dist/components/object-inspector/index.js +6 -0
- package/dist/components/object-inspector/object-inspector.js +136 -0
- package/dist/components/overview-board/index.js +8 -0
- package/dist/components/overview-board/overview-board.js +127 -0
- package/dist/components/parallel-timeline/index.js +6 -0
- package/dist/components/parallel-timeline/parallel-timeline.js +251 -0
- package/dist/components/password-input/password-input.js +1 -1
- package/dist/components/plan-badge/plan-badge.js +1 -7
- package/dist/components/playback-ghost/index.js +6 -0
- package/dist/components/playback-ghost/playback-ghost.js +83 -0
- package/dist/components/policy-delivery-panel/index.js +6 -0
- package/dist/components/policy-delivery-panel/policy-delivery-panel.js +99 -0
- package/dist/components/presence-stack/index.js +6 -0
- package/dist/components/presence-stack/presence-stack.js +108 -0
- package/dist/components/presence-sync-indicator/index.js +6 -0
- package/dist/components/presence-sync-indicator/presence-sync-indicator.js +73 -0
- package/dist/components/pricing-table/index.js +8 -0
- package/dist/components/pricing-table/pricing-table.js +247 -0
- package/dist/components/primary-source-viewer/index.js +26 -0
- package/dist/components/primary-source-viewer/primary-source-viewer.js +439 -0
- package/dist/components/pro-tip/pro-tip.js +6 -6
- package/dist/components/profile-section/profile-section.js +1 -1
- package/dist/components/progress-card/progress-card.js +4 -3
- package/dist/components/progress-tracker/index.js +20 -0
- package/dist/components/progress-tracker/progress-tracker.js +529 -0
- package/dist/components/prompt-templates/index.js +6 -0
- package/dist/components/prompt-templates/prompt-templates.js +403 -0
- package/dist/components/property-section/index.js +6 -0
- package/dist/components/property-section/property-section.js +101 -0
- package/dist/components/quiz/quiz.js +5 -5
- package/dist/components/radio-group/radio-group.js +2 -2
- package/dist/components/rating/rating.js +3 -3
- package/dist/components/relationship-inspector/index.js +6 -0
- package/dist/components/relationship-inspector/relationship-inspector.js +102 -0
- package/dist/components/resizable/resizable.js +1 -1
- package/dist/components/right-dock/index.js +4 -0
- package/dist/components/right-dock/right-dock.js +28 -0
- package/dist/components/route-map/index.js +6 -0
- package/dist/components/route-map/route-map.js +339 -0
- package/dist/components/routing-assignment-panel/index.js +6 -0
- package/dist/components/routing-assignment-panel/routing-assignment-panel.js +122 -0
- package/dist/components/run-timeline/index.js +6 -0
- package/dist/components/run-timeline/run-timeline.js +221 -0
- package/dist/components/runtime-overview-panel/index.js +6 -0
- package/dist/components/runtime-overview-panel/runtime-overview-panel.js +89 -0
- package/dist/components/scope-selector/scope-selector.js +7 -7
- package/dist/components/search-bar/search-bar.js +24 -2
- package/dist/components/search-dialog/search-dialog.js +1 -1
- package/dist/components/segmented-control/index.js +12 -0
- package/dist/components/segmented-control/segmented-control.js +61 -0
- package/dist/components/select/select.js +5 -5
- package/dist/components/selection-halo/index.js +6 -0
- package/dist/components/selection-halo/selection-halo.js +72 -0
- package/dist/components/selection-presence/index.js +6 -0
- package/dist/components/selection-presence/selection-presence.js +50 -0
- package/dist/components/severity-badge/severity-badge.js +2 -2
- package/dist/components/sheet/sheet.js +1 -1
- package/dist/components/sidebar/sidebar.js +1 -1
- package/dist/components/sidebar-toggle/sidebar-toggle.js +2 -2
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/slideshow/slideshow.js +12 -11
- package/dist/components/snap-guides/index.js +6 -0
- package/dist/components/snap-guides/snap-guides.js +45 -0
- package/dist/components/social-fab/social-fab.js +2 -1
- package/dist/components/sparkline-grid/sparkline-grid.js +1 -1
- package/dist/components/spinner/spinner.js +3 -3
- package/dist/components/spinner/unicode-spinner.js +1 -0
- package/dist/components/stat-card/stat-card.js +3 -3
- package/dist/components/state-badge-overlay/index.js +6 -0
- package/dist/components/state-badge-overlay/state-badge-overlay.js +90 -0
- package/dist/components/status-board/status-board.js +1 -1
- package/dist/components/status-indicator/status-indicator.js +3 -3
- package/dist/components/step-by-step/step-by-step.js +8 -7
- package/dist/components/step-navigation/step-navigation.js +2 -2
- package/dist/components/stepper/stepper.js +3 -3
- package/dist/components/sticky-metric/index.js +6 -0
- package/dist/components/sticky-metric/sticky-metric.js +83 -0
- package/dist/components/story-map/index.js +8 -0
- package/dist/components/story-map/story-map.js +414 -0
- package/dist/components/subscription-card/subscription-card.js +1 -1
- package/dist/components/switch/switch.js +1 -1
- package/dist/components/table-of-contents-panel/table-of-contents-panel.js +5 -5
- package/dist/components/tags-input/index.js +4 -0
- package/dist/components/tags-input/tags-input.js +178 -0
- package/dist/components/terminal/terminal.js +48 -34
- package/dist/components/thinking-block/thinking-block.js +1 -1
- package/dist/components/thread-bubble/index.js +6 -0
- package/dist/components/thread-bubble/thread-bubble.js +85 -0
- package/dist/components/threshold-ring/index.js +6 -0
- package/dist/components/threshold-ring/threshold-ring.js +160 -0
- package/dist/components/ticker-tape/ticker-tape.js +3 -3
- package/dist/components/timeline/index.js +12 -0
- package/dist/components/timeline/timeline.js +239 -0
- package/dist/components/timeline-scrubber/index.js +6 -0
- package/dist/components/timeline-scrubber/timeline-scrubber.js +179 -0
- package/dist/components/tldr-section/tldr-section.js +2 -2
- package/dist/components/top-bar/index.js +4 -0
- package/dist/components/top-bar/top-bar.js +31 -0
- package/dist/components/tour/tour.js +1 -1
- package/dist/components/transaction-list/index.js +14 -0
- package/dist/components/transaction-list/transaction-list.js +247 -0
- package/dist/components/tree-view/index.js +6 -0
- package/dist/components/tree-view/tree-view.js +298 -0
- package/dist/components/tutorial-complete/tutorial-complete.js +8 -8
- package/dist/components/usage-breakdown/usage-breakdown.js +10 -5
- package/dist/components/video-embed/video-embed.js +2 -2
- package/dist/components/viewport-bookmarks/index.js +6 -0
- package/dist/components/viewport-bookmarks/viewport-bookmarks.js +116 -0
- package/dist/components/wallet-card/wallet-card.js +1 -1
- package/dist/components/watchlist/watchlist.js +5 -5
- package/dist/components/workspace-switcher/index.js +6 -0
- package/dist/components/workspace-switcher/workspace-switcher.js +61 -0
- package/dist/components/world-breadcrumbs/index.js +6 -0
- package/dist/components/world-breadcrumbs/world-breadcrumbs.js +114 -0
- package/dist/components/world-clock-bar/world-clock-bar.js +32 -12
- package/dist/components/zoom-hud/index.js +4 -0
- package/dist/components/zoom-hud/zoom-hud.js +61 -0
- package/dist/index.d.ts +7907 -226
- package/dist/index.js +3 -1
- package/package.json +9 -5
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
forwardRef,
|
|
6
|
+
useCallback,
|
|
7
|
+
useContext,
|
|
8
|
+
useMemo,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
11
|
+
import {
|
|
12
|
+
Check,
|
|
13
|
+
Copy,
|
|
14
|
+
Download,
|
|
15
|
+
Maximize2,
|
|
16
|
+
Minimize2,
|
|
17
|
+
Pencil
|
|
18
|
+
} from "lucide-react";
|
|
19
|
+
import { cn } from "../../lib/utils";
|
|
20
|
+
import { Badge } from "../badge/badge";
|
|
21
|
+
import { Button } from "../button/button";
|
|
22
|
+
const COPIED_TIMEOUT_MS = 2e3;
|
|
23
|
+
const DEFAULT_LABELS = {
|
|
24
|
+
copied: "Copied",
|
|
25
|
+
copy: "Copy",
|
|
26
|
+
download: "Download",
|
|
27
|
+
edit: "Edit",
|
|
28
|
+
enterFullscreen: "Enter fullscreen",
|
|
29
|
+
exitFullscreen: "Exit fullscreen",
|
|
30
|
+
versions: "Versions"
|
|
31
|
+
};
|
|
32
|
+
const NO_OP = () => {
|
|
33
|
+
return;
|
|
34
|
+
};
|
|
35
|
+
const DEFAULT_CONTEXT = {
|
|
36
|
+
copied: false,
|
|
37
|
+
copy: async () => false,
|
|
38
|
+
download: NO_OP,
|
|
39
|
+
filename: "artifact.txt",
|
|
40
|
+
fullscreen: false,
|
|
41
|
+
hasOnEdit: false,
|
|
42
|
+
labels: DEFAULT_LABELS,
|
|
43
|
+
onEdit: NO_OP,
|
|
44
|
+
toggleFullscreen: NO_OP,
|
|
45
|
+
type: "code",
|
|
46
|
+
value: ""
|
|
47
|
+
};
|
|
48
|
+
const AIArtifactContext = createContext(DEFAULT_CONTEXT);
|
|
49
|
+
function useAIArtifact() {
|
|
50
|
+
return useContext(AIArtifactContext);
|
|
51
|
+
}
|
|
52
|
+
function pickExtension(type, language) {
|
|
53
|
+
if (language) return language;
|
|
54
|
+
switch (type) {
|
|
55
|
+
case "code":
|
|
56
|
+
return "txt";
|
|
57
|
+
case "custom":
|
|
58
|
+
return "txt";
|
|
59
|
+
case "diagram":
|
|
60
|
+
return "mmd";
|
|
61
|
+
case "document":
|
|
62
|
+
return "md";
|
|
63
|
+
case "html":
|
|
64
|
+
return "html";
|
|
65
|
+
case "image":
|
|
66
|
+
return "png";
|
|
67
|
+
case "table":
|
|
68
|
+
return "csv";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const SLUG_INVALID_CHARS = /[^\da-z]+/g;
|
|
72
|
+
const SLUG_TRIM = /^-+|-+$/g;
|
|
73
|
+
function buildFilename({
|
|
74
|
+
filename,
|
|
75
|
+
language,
|
|
76
|
+
title,
|
|
77
|
+
type
|
|
78
|
+
}) {
|
|
79
|
+
if (filename) return filename;
|
|
80
|
+
const base = typeof title === "string" && title.length > 0 ? title : "artifact";
|
|
81
|
+
const slug = base.toLowerCase().replaceAll(SLUG_INVALID_CHARS, "-").replaceAll(SLUG_TRIM, "");
|
|
82
|
+
const safeBase = slug.length > 0 ? slug : "artifact";
|
|
83
|
+
return `${safeBase}.${pickExtension(type, language)}`;
|
|
84
|
+
}
|
|
85
|
+
async function writeToClipboard(value) {
|
|
86
|
+
if (typeof navigator === "undefined" || typeof navigator.clipboard?.writeText !== "function") {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
await navigator.clipboard.writeText(value);
|
|
91
|
+
return true;
|
|
92
|
+
} catch {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function downloadValueAsFile(value, filename) {
|
|
97
|
+
if (typeof document === "undefined") return;
|
|
98
|
+
const blob = new Blob([value], { type: "text/plain;charset=utf-8" });
|
|
99
|
+
const url = URL.createObjectURL(blob);
|
|
100
|
+
const anchor = document.createElement("a");
|
|
101
|
+
anchor.href = url;
|
|
102
|
+
anchor.download = filename;
|
|
103
|
+
anchor.style.display = "none";
|
|
104
|
+
document.body.append(anchor);
|
|
105
|
+
anchor.click();
|
|
106
|
+
anchor.remove();
|
|
107
|
+
URL.revokeObjectURL(url);
|
|
108
|
+
}
|
|
109
|
+
function ArtifactHeader({
|
|
110
|
+
language,
|
|
111
|
+
subtitle,
|
|
112
|
+
title,
|
|
113
|
+
type
|
|
114
|
+
}) {
|
|
115
|
+
if (!title && !subtitle && !language) return null;
|
|
116
|
+
return /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-1", children: [
|
|
117
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
118
|
+
title ? /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold tracking-tight text-foreground", children: title }) : null,
|
|
119
|
+
/* @__PURE__ */ jsx(Badge, { variant: "secondary", children: language || type })
|
|
120
|
+
] }),
|
|
121
|
+
subtitle ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: subtitle }) : null
|
|
122
|
+
] });
|
|
123
|
+
}
|
|
124
|
+
function useArtifactController(options) {
|
|
125
|
+
const {
|
|
126
|
+
defaultFullscreen,
|
|
127
|
+
filename,
|
|
128
|
+
labels,
|
|
129
|
+
language,
|
|
130
|
+
onEdit,
|
|
131
|
+
title,
|
|
132
|
+
type,
|
|
133
|
+
value
|
|
134
|
+
} = options;
|
|
135
|
+
const [fullscreen, setFullscreen] = useState(defaultFullscreen);
|
|
136
|
+
const [copied, setCopied] = useState(false);
|
|
137
|
+
const resolvedFilename = useMemo(
|
|
138
|
+
() => buildFilename({ filename, language, title, type }),
|
|
139
|
+
[filename, language, title, type]
|
|
140
|
+
);
|
|
141
|
+
const copy = useCallback(async () => {
|
|
142
|
+
const ok = await writeToClipboard(value);
|
|
143
|
+
if (!ok) return false;
|
|
144
|
+
setCopied(true);
|
|
145
|
+
setTimeout(() => {
|
|
146
|
+
setCopied(false);
|
|
147
|
+
}, COPIED_TIMEOUT_MS);
|
|
148
|
+
return true;
|
|
149
|
+
}, [value]);
|
|
150
|
+
const download = useCallback(() => {
|
|
151
|
+
downloadValueAsFile(value, resolvedFilename);
|
|
152
|
+
}, [resolvedFilename, value]);
|
|
153
|
+
const toggleFullscreen = useCallback(() => {
|
|
154
|
+
setFullscreen((current) => !current);
|
|
155
|
+
}, []);
|
|
156
|
+
const triggerEdit = useCallback(() => {
|
|
157
|
+
onEdit?.();
|
|
158
|
+
}, [onEdit]);
|
|
159
|
+
return useMemo(
|
|
160
|
+
() => ({
|
|
161
|
+
copied,
|
|
162
|
+
copy,
|
|
163
|
+
download,
|
|
164
|
+
filename: resolvedFilename,
|
|
165
|
+
fullscreen,
|
|
166
|
+
hasOnEdit: onEdit !== void 0,
|
|
167
|
+
labels,
|
|
168
|
+
onEdit: triggerEdit,
|
|
169
|
+
toggleFullscreen,
|
|
170
|
+
type,
|
|
171
|
+
value
|
|
172
|
+
}),
|
|
173
|
+
[
|
|
174
|
+
copied,
|
|
175
|
+
copy,
|
|
176
|
+
download,
|
|
177
|
+
fullscreen,
|
|
178
|
+
labels,
|
|
179
|
+
onEdit,
|
|
180
|
+
resolvedFilename,
|
|
181
|
+
toggleFullscreen,
|
|
182
|
+
triggerEdit,
|
|
183
|
+
type,
|
|
184
|
+
value
|
|
185
|
+
]
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const AIArtifact = forwardRef(
|
|
189
|
+
(props, ref) => {
|
|
190
|
+
const {
|
|
191
|
+
children,
|
|
192
|
+
className,
|
|
193
|
+
defaultFullscreen = false,
|
|
194
|
+
filename,
|
|
195
|
+
labels,
|
|
196
|
+
language = "",
|
|
197
|
+
onEdit,
|
|
198
|
+
subtitle,
|
|
199
|
+
title,
|
|
200
|
+
type = "code",
|
|
201
|
+
value = "",
|
|
202
|
+
...rest
|
|
203
|
+
} = props;
|
|
204
|
+
const resolvedLabels = useMemo(
|
|
205
|
+
() => ({ ...DEFAULT_LABELS, ...labels }),
|
|
206
|
+
[labels]
|
|
207
|
+
);
|
|
208
|
+
const contextValue = useArtifactController({
|
|
209
|
+
defaultFullscreen,
|
|
210
|
+
filename,
|
|
211
|
+
labels: resolvedLabels,
|
|
212
|
+
language,
|
|
213
|
+
onEdit,
|
|
214
|
+
title,
|
|
215
|
+
type,
|
|
216
|
+
value
|
|
217
|
+
});
|
|
218
|
+
return /* @__PURE__ */ jsx(AIArtifactContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
219
|
+
"section",
|
|
220
|
+
{
|
|
221
|
+
"aria-label": typeof title === "string" ? title : void 0,
|
|
222
|
+
className: cn(
|
|
223
|
+
"flex flex-col gap-3 rounded-2xl border bg-background p-4",
|
|
224
|
+
className
|
|
225
|
+
),
|
|
226
|
+
"data-fullscreen": contextValue.fullscreen ? "true" : "false",
|
|
227
|
+
"data-type": type,
|
|
228
|
+
ref,
|
|
229
|
+
...rest,
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsx(
|
|
232
|
+
ArtifactHeader,
|
|
233
|
+
{
|
|
234
|
+
language,
|
|
235
|
+
subtitle,
|
|
236
|
+
title,
|
|
237
|
+
type
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
children
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
) });
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
AIArtifact.displayName = "AIArtifact";
|
|
247
|
+
const AIArtifactToolbar = forwardRef(({ className, ...rest }, ref) => /* @__PURE__ */ jsx(
|
|
248
|
+
"div",
|
|
249
|
+
{
|
|
250
|
+
className: cn(
|
|
251
|
+
"flex flex-wrap items-center gap-1.5 border-b border-border pb-2",
|
|
252
|
+
className
|
|
253
|
+
),
|
|
254
|
+
ref,
|
|
255
|
+
role: "toolbar",
|
|
256
|
+
...rest
|
|
257
|
+
}
|
|
258
|
+
));
|
|
259
|
+
AIArtifactToolbar.displayName = "AIArtifactToolbar";
|
|
260
|
+
const AIArtifactCopyButton = forwardRef(({ className, onClick, ...rest }, ref) => {
|
|
261
|
+
const { copied, copy, labels } = useAIArtifact();
|
|
262
|
+
const handleClick = useCallback(
|
|
263
|
+
(event) => {
|
|
264
|
+
onClick?.(event);
|
|
265
|
+
if (event.defaultPrevented) return;
|
|
266
|
+
void copy();
|
|
267
|
+
},
|
|
268
|
+
[copy, onClick]
|
|
269
|
+
);
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
Button,
|
|
272
|
+
{
|
|
273
|
+
"aria-label": copied ? labels.copied : labels.copy,
|
|
274
|
+
className: cn("size-8", className),
|
|
275
|
+
onClick: handleClick,
|
|
276
|
+
ref,
|
|
277
|
+
size: "icon",
|
|
278
|
+
type: "button",
|
|
279
|
+
variant: "ghost",
|
|
280
|
+
...rest,
|
|
281
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { "aria-hidden": "true", className: "size-4" }) : /* @__PURE__ */ jsx(Copy, { "aria-hidden": "true", className: "size-4" })
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
});
|
|
285
|
+
AIArtifactCopyButton.displayName = "AIArtifactCopyButton";
|
|
286
|
+
const AIArtifactEditButton = forwardRef(({ className, onClick, ...rest }, ref) => {
|
|
287
|
+
const { hasOnEdit, labels, onEdit } = useAIArtifact();
|
|
288
|
+
const handleClick = useCallback(
|
|
289
|
+
(event) => {
|
|
290
|
+
onClick?.(event);
|
|
291
|
+
if (event.defaultPrevented) return;
|
|
292
|
+
onEdit();
|
|
293
|
+
},
|
|
294
|
+
[onClick, onEdit]
|
|
295
|
+
);
|
|
296
|
+
if (!hasOnEdit) return null;
|
|
297
|
+
return /* @__PURE__ */ jsx(
|
|
298
|
+
Button,
|
|
299
|
+
{
|
|
300
|
+
"aria-label": labels.edit,
|
|
301
|
+
className: cn("size-8", className),
|
|
302
|
+
onClick: handleClick,
|
|
303
|
+
ref,
|
|
304
|
+
size: "icon",
|
|
305
|
+
type: "button",
|
|
306
|
+
variant: "ghost",
|
|
307
|
+
...rest,
|
|
308
|
+
children: /* @__PURE__ */ jsx(Pencil, { "aria-hidden": "true", className: "size-4" })
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
});
|
|
312
|
+
AIArtifactEditButton.displayName = "AIArtifactEditButton";
|
|
313
|
+
const AIArtifactDownloadButton = forwardRef(({ className, onClick, ...rest }, ref) => {
|
|
314
|
+
const { download, labels } = useAIArtifact();
|
|
315
|
+
const handleClick = useCallback(
|
|
316
|
+
(event) => {
|
|
317
|
+
onClick?.(event);
|
|
318
|
+
if (event.defaultPrevented) return;
|
|
319
|
+
download();
|
|
320
|
+
},
|
|
321
|
+
[download, onClick]
|
|
322
|
+
);
|
|
323
|
+
return /* @__PURE__ */ jsx(
|
|
324
|
+
Button,
|
|
325
|
+
{
|
|
326
|
+
"aria-label": labels.download,
|
|
327
|
+
className: cn("size-8", className),
|
|
328
|
+
onClick: handleClick,
|
|
329
|
+
ref,
|
|
330
|
+
size: "icon",
|
|
331
|
+
type: "button",
|
|
332
|
+
variant: "ghost",
|
|
333
|
+
...rest,
|
|
334
|
+
children: /* @__PURE__ */ jsx(Download, { "aria-hidden": "true", className: "size-4" })
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
});
|
|
338
|
+
AIArtifactDownloadButton.displayName = "AIArtifactDownloadButton";
|
|
339
|
+
const AIArtifactFullscreenButton = forwardRef(({ className, onClick, ...rest }, ref) => {
|
|
340
|
+
const { fullscreen, labels, toggleFullscreen } = useAIArtifact();
|
|
341
|
+
const handleClick = useCallback(
|
|
342
|
+
(event) => {
|
|
343
|
+
onClick?.(event);
|
|
344
|
+
if (event.defaultPrevented) return;
|
|
345
|
+
toggleFullscreen();
|
|
346
|
+
},
|
|
347
|
+
[onClick, toggleFullscreen]
|
|
348
|
+
);
|
|
349
|
+
return /* @__PURE__ */ jsx(
|
|
350
|
+
Button,
|
|
351
|
+
{
|
|
352
|
+
"aria-label": fullscreen ? labels.exitFullscreen : labels.enterFullscreen,
|
|
353
|
+
"aria-pressed": fullscreen,
|
|
354
|
+
className: cn("size-8", className),
|
|
355
|
+
onClick: handleClick,
|
|
356
|
+
ref,
|
|
357
|
+
size: "icon",
|
|
358
|
+
type: "button",
|
|
359
|
+
variant: "ghost",
|
|
360
|
+
...rest,
|
|
361
|
+
children: fullscreen ? /* @__PURE__ */ jsx(Minimize2, { "aria-hidden": "true", className: "size-4" }) : /* @__PURE__ */ jsx(Maximize2, { "aria-hidden": "true", className: "size-4" })
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
});
|
|
365
|
+
AIArtifactFullscreenButton.displayName = "AIArtifactFullscreenButton";
|
|
366
|
+
const AIArtifactContent = forwardRef(({ className, ...rest }, ref) => /* @__PURE__ */ jsx(
|
|
367
|
+
"div",
|
|
368
|
+
{
|
|
369
|
+
className: cn(
|
|
370
|
+
"min-h-[6rem] overflow-auto rounded-lg border border-border bg-muted/20 p-3 text-sm text-foreground",
|
|
371
|
+
className
|
|
372
|
+
),
|
|
373
|
+
ref,
|
|
374
|
+
...rest
|
|
375
|
+
}
|
|
376
|
+
));
|
|
377
|
+
AIArtifactContent.displayName = "AIArtifactContent";
|
|
378
|
+
const AIArtifactVersions = forwardRef(({ children, className, ...rest }, ref) => {
|
|
379
|
+
const { labels } = useAIArtifact();
|
|
380
|
+
return /* @__PURE__ */ jsx(
|
|
381
|
+
"nav",
|
|
382
|
+
{
|
|
383
|
+
"aria-label": labels.versions,
|
|
384
|
+
className: cn(
|
|
385
|
+
"flex flex-wrap items-center gap-1.5 border-t border-border pt-2",
|
|
386
|
+
className
|
|
387
|
+
),
|
|
388
|
+
ref,
|
|
389
|
+
...rest,
|
|
390
|
+
children
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
});
|
|
394
|
+
AIArtifactVersions.displayName = "AIArtifactVersions";
|
|
395
|
+
const AIArtifactVersion = forwardRef(({ active = false, className, label, ...rest }, ref) => /* @__PURE__ */ jsx(
|
|
396
|
+
"button",
|
|
397
|
+
{
|
|
398
|
+
"aria-current": active ? "true" : void 0,
|
|
399
|
+
className: cn(
|
|
400
|
+
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
401
|
+
active ? "border-primary bg-primary text-primary-foreground" : "border-border bg-background text-muted-foreground hover:bg-accent",
|
|
402
|
+
className
|
|
403
|
+
),
|
|
404
|
+
ref,
|
|
405
|
+
type: "button",
|
|
406
|
+
...rest,
|
|
407
|
+
children: label
|
|
408
|
+
}
|
|
409
|
+
));
|
|
410
|
+
AIArtifactVersion.displayName = "AIArtifactVersion";
|
|
411
|
+
export {
|
|
412
|
+
AIArtifact,
|
|
413
|
+
AIArtifactContent,
|
|
414
|
+
AIArtifactCopyButton,
|
|
415
|
+
AIArtifactDownloadButton,
|
|
416
|
+
AIArtifactEditButton,
|
|
417
|
+
AIArtifactFullscreenButton,
|
|
418
|
+
AIArtifactToolbar,
|
|
419
|
+
AIArtifactVersion,
|
|
420
|
+
AIArtifactVersions,
|
|
421
|
+
useAIArtifact
|
|
422
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AIArtifact,
|
|
3
|
+
AIArtifactContent,
|
|
4
|
+
AIArtifactCopyButton,
|
|
5
|
+
AIArtifactDownloadButton,
|
|
6
|
+
AIArtifactEditButton,
|
|
7
|
+
AIArtifactFullscreenButton,
|
|
8
|
+
AIArtifactToolbar,
|
|
9
|
+
AIArtifactVersion,
|
|
10
|
+
AIArtifactVersions,
|
|
11
|
+
useAIArtifact
|
|
12
|
+
} from "./ai-artifact";
|
|
13
|
+
export {
|
|
14
|
+
AIArtifact,
|
|
15
|
+
AIArtifactContent,
|
|
16
|
+
AIArtifactCopyButton,
|
|
17
|
+
AIArtifactDownloadButton,
|
|
18
|
+
AIArtifactEditButton,
|
|
19
|
+
AIArtifactFullscreenButton,
|
|
20
|
+
AIArtifactToolbar,
|
|
21
|
+
AIArtifactVersion,
|
|
22
|
+
AIArtifactVersions,
|
|
23
|
+
useAIArtifact
|
|
24
|
+
};
|
|
@@ -36,7 +36,7 @@ function AIChatInputFooter({
|
|
|
36
36
|
disabled: isSubmitDisabled,
|
|
37
37
|
type: "submit",
|
|
38
38
|
children: [
|
|
39
|
-
isSubmitting ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2
|
|
39
|
+
isSubmitting ? /* @__PURE__ */ jsx(LoaderCircle, { className: "mr-2 size-4 animate-spin" }) : /* @__PURE__ */ jsx(SendHorizontal, { className: "mr-2 size-4" }),
|
|
40
40
|
submitLabel
|
|
41
41
|
]
|
|
42
42
|
}
|
|
@@ -72,7 +72,7 @@ const AIChatInput = forwardRef(
|
|
|
72
72
|
/* @__PURE__ */ jsx(
|
|
73
73
|
Textarea,
|
|
74
74
|
{
|
|
75
|
-
className: "min-h-[120px] resize-none rounded-xl border-0 bg-transparent
|
|
75
|
+
className: "min-h-[120px] resize-none rounded-xl border-0 bg-transparent p-1 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
76
76
|
disabled,
|
|
77
77
|
onChange: (event) => {
|
|
78
78
|
textareaProps?.onChange?.(event);
|
|
@@ -73,7 +73,7 @@ const AIMessageBubble = forwardRef(
|
|
|
73
73
|
isUser ? "flex-row-reverse text-right" : "flex-row"
|
|
74
74
|
),
|
|
75
75
|
children: [
|
|
76
|
-
/* @__PURE__ */ jsx(Avatar, { className: "mt-0.5
|
|
76
|
+
/* @__PURE__ */ jsx(Avatar, { className: "mt-0.5 size-8 border border-border/70", children: /* @__PURE__ */ jsx(AvatarFallback, { className: "bg-muted text-[11px] font-medium uppercase text-muted-foreground", children: fallbackLabel }) }),
|
|
77
77
|
/* @__PURE__ */ jsxs(
|
|
78
78
|
"div",
|
|
79
79
|
{
|