@vllnt/ui 0.2.1 → 0.3.0-canary.a42d8f4
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 +37 -0
- package/README.md +59 -30
- package/dist/components/accordion/accordion.js +2 -2
- package/dist/components/activity-heatmap/activity-heatmap.js +17 -14
- package/dist/components/activity-log/activity-log.js +7 -6
- 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 +3 -3
- package/dist/components/ai-message-bubble/ai-message-bubble.js +2 -2
- 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 +5 -5
- 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 +8 -7
- package/dist/components/annotation/annotation.js +1 -1
- 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 +5 -5
- package/dist/components/banner/banner.js +155 -0
- package/dist/components/banner/index.js +10 -0
- package/dist/components/blog-card/blog-card.js +4 -2
- package/dist/components/border-beam/border-beam.js +2 -2
- 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 +6 -5
- 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 +18 -10
- package/dist/components/category-filter/category-filter.js +1 -1
- 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 +45 -10
- package/dist/components/checklist/index.js +10 -2
- 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 +343 -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 +33 -12
- package/dist/components/code-playground/code-playground.js +12 -9
- package/dist/components/combobox/combobox.js +47 -28
- 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 +11 -10
- package/dist/components/completion-dialog/completion-dialog.js +20 -12
- 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 +25 -21
- 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 +9 -8
- 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 +6 -5
- package/dist/components/date-picker/date-picker.js +2 -7
- 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 +15 -7
- package/dist/components/faq/faq.js +8 -4
- package/dist/components/file-upload/file-upload.js +4 -9
- package/dist/components/filter-bar/filter-bar.js +9 -8
- package/dist/components/flashcard/flashcard.js +2 -2
- 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 +334 -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 +429 -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 +6 -5
- package/dist/components/index.js +570 -1
- package/dist/components/infinite-plane/index.js +6 -0
- package/dist/components/infinite-plane/infinite-plane.js +75 -0
- package/dist/components/inline-input/inline-input.js +1 -1
- 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 +711 -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 +6 -5
- package/dist/components/keyboard-shortcuts-help/keyboard-shortcuts-help.js +4 -3
- package/dist/components/knowledge-check/index.js +6 -0
- package/dist/components/knowledge-check/knowledge-check.js +448 -0
- package/dist/components/lang-provider/lang-provider.js +3 -3
- package/dist/components/learning-objectives/learning-objectives.js +14 -13
- 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 +17 -15
- 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 +3 -3
- package/dist/components/mdx-content/mdx-content.js +21 -10
- 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 +2 -2
- 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 +3 -3
- 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 +9 -8
- 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 +2 -2
- 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/order-book/order-book.js +2 -2
- 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 +3 -2
- package/dist/components/progress-card/progress-card.js +5 -4
- package/dist/components/progress-tracker/index.js +20 -0
- package/dist/components/progress-tracker/progress-tracker.js +537 -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 +7 -6
- 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 +8 -8
- package/dist/components/search-bar/search-bar.js +24 -2
- package/dist/components/search-dialog/search-dialog.js +484 -51
- 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/share-dialog/share-dialog.js +2 -2
- package/dist/components/share-section/share-section.js +2 -1
- package/dist/components/sheet/sheet.js +1 -1
- package/dist/components/sidebar/sidebar.js +31 -26
- package/dist/components/sidebar-toggle/sidebar-toggle.js +5 -3
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/slideshow/slideshow.js +15 -13
- 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 +12 -11
- package/dist/components/sparkline-grid/sparkline-grid.js +1 -1
- package/dist/components/spinner/spinner.js +4 -4
- package/dist/components/spinner/unicode-spinner.js +5 -2
- package/dist/components/stat-card/stat-card.js +5 -5
- 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/static-code/index.js +4 -0
- package/dist/components/static-code/static-code-copy.js +29 -0
- package/dist/components/static-code/static-code.js +41 -0
- package/dist/components/status-board/status-board.js +14 -7
- package/dist/components/status-indicator/status-indicator.js +3 -3
- package/dist/components/step-by-step/step-by-step.js +10 -8
- 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/table-of-contents.js +5 -2
- package/dist/components/table-of-contents-panel/table-of-contents-panel.js +8 -6
- package/dist/components/tabs/tabs.js +26 -8
- package/dist/components/tags-input/index.js +4 -0
- package/dist/components/tags-input/tags-input.js +186 -0
- package/dist/components/terminal/terminal.js +61 -37
- package/dist/components/theme-preset-provider/index.js +4 -0
- package/dist/components/theme-preset-provider/theme-preset-provider.js +55 -0
- package/dist/components/theme-switcher/index.js +4 -0
- package/dist/components/theme-switcher/theme-switcher.js +43 -0
- package/dist/components/theme-toggle/theme-toggle.js +2 -2
- package/dist/components/thinking-block/thinking-block.js +3 -3
- 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 +4 -4
- 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 +11 -9
- 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 +2 -2
- 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-card/tutorial-card.js +1 -1
- package/dist/components/tutorial-complete/tutorial-complete.js +16 -14
- package/dist/components/tutorial-filters/tutorial-filters.js +2 -2
- package/dist/components/tutorial-intro-content/tutorial-intro-content.js +5 -5
- package/dist/components/tutorial-mdx/tutorial-mdx.js +6 -6
- package/dist/components/usage-breakdown/usage-breakdown.js +11 -6
- 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 +118 -0
- package/dist/components/wallet-card/wallet-card.js +1 -1
- package/dist/components/watchlist/watchlist.js +7 -6
- 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 +35 -14
- package/dist/components/zoom-hud/index.js +4 -0
- package/dist/components/zoom-hud/zoom-hud.js +61 -0
- package/dist/index.d.ts +8066 -246
- package/dist/index.js +21 -1
- package/dist/lib/theme-presets.js +32 -0
- package/dist/lib/use-theme-preset.js +94 -0
- package/dist/tailwind-preset.js +19 -19
- package/package.json +13 -8
- package/styles.css +38 -38
- package/themes/default.css +39 -39
- package/themes/presets.css +547 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
function normalizeTag(tag) {
|
|
7
|
+
return tag.trim();
|
|
8
|
+
}
|
|
9
|
+
function getNormalizedTags(tags) {
|
|
10
|
+
return tags.reduce(
|
|
11
|
+
(state, tag) => {
|
|
12
|
+
const normalizedTag = normalizeTag(tag);
|
|
13
|
+
if (normalizedTag.length > 0 && !state.seen.has(normalizedTag)) {
|
|
14
|
+
state.seen.add(normalizedTag);
|
|
15
|
+
state.tags.push(normalizedTag);
|
|
16
|
+
}
|
|
17
|
+
return state;
|
|
18
|
+
},
|
|
19
|
+
{ seen: /* @__PURE__ */ new Set(), tags: [] }
|
|
20
|
+
).tags;
|
|
21
|
+
}
|
|
22
|
+
function shouldAddTagFromKey(key) {
|
|
23
|
+
return key === "Enter" || key === ",";
|
|
24
|
+
}
|
|
25
|
+
function useTagsInputState({
|
|
26
|
+
defaultValue,
|
|
27
|
+
onValueChange,
|
|
28
|
+
value
|
|
29
|
+
}) {
|
|
30
|
+
const [uncontrolledValue, setUncontrolledValue] = React.useState(
|
|
31
|
+
() => getNormalizedTags(defaultValue)
|
|
32
|
+
);
|
|
33
|
+
const isControlled = value !== void 0;
|
|
34
|
+
const tags = React.useMemo(
|
|
35
|
+
() => getNormalizedTags(value ?? uncontrolledValue),
|
|
36
|
+
[uncontrolledValue, value]
|
|
37
|
+
);
|
|
38
|
+
const updateTags = React.useCallback(
|
|
39
|
+
(nextTags) => {
|
|
40
|
+
const normalizedTags = getNormalizedTags(nextTags);
|
|
41
|
+
if (!isControlled) {
|
|
42
|
+
setUncontrolledValue(normalizedTags);
|
|
43
|
+
}
|
|
44
|
+
onValueChange?.(normalizedTags);
|
|
45
|
+
},
|
|
46
|
+
[isControlled, onValueChange]
|
|
47
|
+
);
|
|
48
|
+
return { tags, updateTags };
|
|
49
|
+
}
|
|
50
|
+
function useTagsInputHandlers({
|
|
51
|
+
disabled,
|
|
52
|
+
inputValue,
|
|
53
|
+
onKeyDown,
|
|
54
|
+
setInputValue,
|
|
55
|
+
tags,
|
|
56
|
+
updateTags
|
|
57
|
+
}) {
|
|
58
|
+
const removeTag = React.useCallback(
|
|
59
|
+
(tagToRemove) => {
|
|
60
|
+
updateTags(tags.filter((tag) => tag !== tagToRemove));
|
|
61
|
+
},
|
|
62
|
+
[tags, updateTags]
|
|
63
|
+
);
|
|
64
|
+
const commitTag = React.useCallback(() => {
|
|
65
|
+
const nextTag = normalizeTag(inputValue);
|
|
66
|
+
if (nextTag.length === 0 || tags.includes(nextTag)) {
|
|
67
|
+
setInputValue("");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
updateTags([...tags, nextTag]);
|
|
71
|
+
setInputValue("");
|
|
72
|
+
}, [inputValue, setInputValue, tags, updateTags]);
|
|
73
|
+
const handleKeyDown = React.useCallback(
|
|
74
|
+
(event) => {
|
|
75
|
+
onKeyDown?.(event);
|
|
76
|
+
if (event.defaultPrevented || disabled) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (shouldAddTagFromKey(event.key)) {
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
commitTag();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if ((event.key === "Backspace" || event.key === "Delete") && inputValue.length === 0) {
|
|
85
|
+
const lastTag = tags.at(-1);
|
|
86
|
+
if (lastTag) {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
removeTag(lastTag);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
[commitTag, disabled, inputValue.length, onKeyDown, removeTag, tags]
|
|
93
|
+
);
|
|
94
|
+
return { handleKeyDown, removeTag };
|
|
95
|
+
}
|
|
96
|
+
function TagList({ disabled, onRemove, tags }) {
|
|
97
|
+
return /* @__PURE__ */ jsx("ul", { className: "flex flex-wrap items-center gap-2", children: tags.map((tag) => /* @__PURE__ */ jsxs(
|
|
98
|
+
"li",
|
|
99
|
+
{
|
|
100
|
+
className: "flex items-center gap-1 rounded-md border bg-muted px-2 py-1 text-sm text-foreground",
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ jsx("span", { children: tag }),
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
"button",
|
|
105
|
+
{
|
|
106
|
+
"aria-label": `Remove ${tag}`,
|
|
107
|
+
className: "rounded-sm text-muted-foreground outline-none ring-offset-background transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
108
|
+
disabled,
|
|
109
|
+
onClick: (event) => {
|
|
110
|
+
event.stopPropagation();
|
|
111
|
+
onRemove(tag);
|
|
112
|
+
},
|
|
113
|
+
type: "button",
|
|
114
|
+
children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
tag
|
|
120
|
+
)) });
|
|
121
|
+
}
|
|
122
|
+
const TagsInput = React.forwardRef(
|
|
123
|
+
({
|
|
124
|
+
className,
|
|
125
|
+
defaultValue = [],
|
|
126
|
+
disabled = false,
|
|
127
|
+
onBlur,
|
|
128
|
+
onKeyDown,
|
|
129
|
+
onValueChange,
|
|
130
|
+
placeholder = "Add a tag",
|
|
131
|
+
value,
|
|
132
|
+
...props
|
|
133
|
+
}, ref) => {
|
|
134
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
135
|
+
const { tags, updateTags } = useTagsInputState({
|
|
136
|
+
defaultValue,
|
|
137
|
+
onValueChange,
|
|
138
|
+
value
|
|
139
|
+
});
|
|
140
|
+
const { handleKeyDown, removeTag } = useTagsInputHandlers({
|
|
141
|
+
disabled,
|
|
142
|
+
inputValue,
|
|
143
|
+
onKeyDown,
|
|
144
|
+
setInputValue,
|
|
145
|
+
tags,
|
|
146
|
+
updateTags
|
|
147
|
+
});
|
|
148
|
+
return /* @__PURE__ */ jsxs(
|
|
149
|
+
"div",
|
|
150
|
+
{
|
|
151
|
+
"aria-disabled": disabled || void 0,
|
|
152
|
+
className: cn(
|
|
153
|
+
"flex min-h-10 w-full flex-wrap items-center gap-2 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background transition-colors focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
|
|
154
|
+
disabled && "cursor-not-allowed opacity-50",
|
|
155
|
+
className
|
|
156
|
+
),
|
|
157
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
158
|
+
role: "group",
|
|
159
|
+
children: [
|
|
160
|
+
/* @__PURE__ */ jsx(TagList, { disabled, onRemove: removeTag, tags }),
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
"input",
|
|
163
|
+
{
|
|
164
|
+
...props,
|
|
165
|
+
className: "min-w-[8rem] flex-1 border-0 bg-transparent p-0 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed",
|
|
166
|
+
disabled,
|
|
167
|
+
onBlur,
|
|
168
|
+
onChange: (event) => {
|
|
169
|
+
setInputValue(event.target.value);
|
|
170
|
+
},
|
|
171
|
+
onKeyDown: handleKeyDown,
|
|
172
|
+
placeholder,
|
|
173
|
+
ref,
|
|
174
|
+
type: "text",
|
|
175
|
+
value: inputValue
|
|
176
|
+
}
|
|
177
|
+
)
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
TagsInput.displayName = "TagsInput";
|
|
184
|
+
export {
|
|
185
|
+
TagsInput
|
|
186
|
+
};
|
|
@@ -2,14 +2,22 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { Check, Copy, Terminal as TerminalIcon } from "lucide-react";
|
|
5
|
-
import { Button } from "../button";
|
|
5
|
+
import { Button } from "../button/button";
|
|
6
|
+
function getCommandContents(lines) {
|
|
7
|
+
return lines.reduce((commands, line) => {
|
|
8
|
+
if (line.type === "command") {
|
|
9
|
+
commands.push(line.content);
|
|
10
|
+
}
|
|
11
|
+
return commands;
|
|
12
|
+
}, []);
|
|
13
|
+
}
|
|
6
14
|
function Terminal({
|
|
7
15
|
copyable = true,
|
|
8
16
|
lines,
|
|
9
17
|
title = "Terminal"
|
|
10
18
|
}) {
|
|
11
19
|
const [copied, setCopied] = useState(false);
|
|
12
|
-
const commands = lines
|
|
20
|
+
const commands = getCommandContents(lines);
|
|
13
21
|
const handleCopy = async () => {
|
|
14
22
|
await navigator.clipboard.writeText(commands.join("\n"));
|
|
15
23
|
setCopied(true);
|
|
@@ -20,35 +28,43 @@ function Terminal({
|
|
|
20
28
|
return /* @__PURE__ */ jsxs("div", { className: "my-6 rounded-lg border bg-zinc-950 dark:bg-zinc-900 overflow-hidden", children: [
|
|
21
29
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2 bg-zinc-900 dark:bg-zinc-800 border-b border-zinc-800", children: [
|
|
22
30
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(TerminalIcon, { className: "
|
|
31
|
+
/* @__PURE__ */ jsx(TerminalIcon, { className: "size-4 text-zinc-400" }),
|
|
24
32
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-zinc-300", children: title })
|
|
25
33
|
] }),
|
|
26
34
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
27
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
28
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
29
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
35
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-red-500" }),
|
|
36
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-yellow-500" }),
|
|
37
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-green-500" })
|
|
30
38
|
] })
|
|
31
39
|
] }),
|
|
32
40
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
33
|
-
/* @__PURE__ */ jsx("div", { className: "p-4 font-mono text-sm space-y-1 overflow-x-auto", children: lines.map((line
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 font-mono text-sm space-y-1 overflow-x-auto", children: lines.map((line) => /* @__PURE__ */ jsxs(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: "flex items-start",
|
|
45
|
+
children: [
|
|
46
|
+
line.type === "command" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx("span", { className: "text-green-400 mr-2 select-none", children: "$" }),
|
|
48
|
+
/* @__PURE__ */ jsx("span", { className: "text-zinc-100", children: line.content })
|
|
49
|
+
] }),
|
|
50
|
+
line.type === "output" && /* @__PURE__ */ jsx("span", { className: "text-zinc-400", children: line.content }),
|
|
51
|
+
line.type === "comment" && /* @__PURE__ */ jsxs("span", { className: "text-zinc-600 italic", children: [
|
|
52
|
+
"# ",
|
|
53
|
+
line.content
|
|
54
|
+
] })
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
`${line.type}-${line.content}`
|
|
58
|
+
)) }),
|
|
44
59
|
copyable && commands.length > 0 ? /* @__PURE__ */ jsx(
|
|
45
60
|
Button,
|
|
46
61
|
{
|
|
47
|
-
|
|
62
|
+
"aria-label": copied ? "Copied" : "Copy commands",
|
|
63
|
+
className: "absolute top-2 right-2 size-8 bg-zinc-800 hover:bg-zinc-700 text-zinc-300",
|
|
48
64
|
onClick: handleCopy,
|
|
49
65
|
size: "icon",
|
|
50
66
|
variant: "ghost",
|
|
51
|
-
children: copied ? /* @__PURE__ */ jsx(Check, { className: "
|
|
67
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-3" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3" })
|
|
52
68
|
}
|
|
53
69
|
) : null
|
|
54
70
|
] })
|
|
@@ -68,7 +84,7 @@ function SimpleTerminal({
|
|
|
68
84
|
}
|
|
69
85
|
return { content: line, type: "output" };
|
|
70
86
|
});
|
|
71
|
-
const commands = lines
|
|
87
|
+
const commands = getCommandContents(lines);
|
|
72
88
|
const handleCopy = async () => {
|
|
73
89
|
await navigator.clipboard.writeText(commands.join("\n"));
|
|
74
90
|
setCopied(true);
|
|
@@ -79,35 +95,43 @@ function SimpleTerminal({
|
|
|
79
95
|
return /* @__PURE__ */ jsxs("div", { className: "my-6 rounded-lg border bg-zinc-950 dark:bg-zinc-900 overflow-hidden", children: [
|
|
80
96
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-2 bg-zinc-900 dark:bg-zinc-800 border-b border-zinc-800", children: [
|
|
81
97
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
82
|
-
/* @__PURE__ */ jsx(TerminalIcon, { className: "
|
|
98
|
+
/* @__PURE__ */ jsx(TerminalIcon, { className: "size-4 text-zinc-400" }),
|
|
83
99
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-zinc-300", children: title })
|
|
84
100
|
] }),
|
|
85
101
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
|
|
86
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
87
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
88
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
102
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-red-500" }),
|
|
103
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-yellow-500" }),
|
|
104
|
+
/* @__PURE__ */ jsx("div", { className: "size-3 rounded-full bg-green-500" })
|
|
89
105
|
] })
|
|
90
106
|
] }),
|
|
91
107
|
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
92
|
-
/* @__PURE__ */ jsx("div", { className: "p-4 font-mono text-sm space-y-1 overflow-x-auto", children: lines.map((line
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
108
|
+
/* @__PURE__ */ jsx("div", { className: "p-4 font-mono text-sm space-y-1 overflow-x-auto", children: lines.map((line) => /* @__PURE__ */ jsxs(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: "flex items-start",
|
|
112
|
+
children: [
|
|
113
|
+
line.type === "command" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: "text-green-400 mr-2 select-none", children: "$" }),
|
|
115
|
+
/* @__PURE__ */ jsx("span", { className: "text-zinc-100", children: line.content })
|
|
116
|
+
] }),
|
|
117
|
+
line.type === "output" && /* @__PURE__ */ jsx("span", { className: "text-zinc-400", children: line.content }),
|
|
118
|
+
line.type === "comment" && /* @__PURE__ */ jsxs("span", { className: "text-zinc-600 italic", children: [
|
|
119
|
+
"# ",
|
|
120
|
+
line.content
|
|
121
|
+
] })
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
`${line.type}-${line.content}`
|
|
125
|
+
)) }),
|
|
103
126
|
commands.length > 0 && /* @__PURE__ */ jsx(
|
|
104
127
|
Button,
|
|
105
128
|
{
|
|
106
|
-
|
|
129
|
+
"aria-label": copied ? "Copied" : "Copy commands",
|
|
130
|
+
className: "absolute top-2 right-2 size-8 bg-zinc-800 hover:bg-zinc-700 text-zinc-300",
|
|
107
131
|
onClick: handleCopy,
|
|
108
132
|
size: "icon",
|
|
109
133
|
variant: "ghost",
|
|
110
|
-
children: copied ? /* @__PURE__ */ jsx(Check, { className: "
|
|
134
|
+
children: copied ? /* @__PURE__ */ jsx(Check, { className: "size-3" }) : /* @__PURE__ */ jsx(Copy, { className: "size-3" })
|
|
111
135
|
}
|
|
112
136
|
)
|
|
113
137
|
] })
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import {
|
|
5
|
+
CUSTOM_THEME_NAME,
|
|
6
|
+
DEFAULT_THEME_PRESET,
|
|
7
|
+
isThemePresetName,
|
|
8
|
+
THEME_CUSTOM_CSS_STORAGE_KEY,
|
|
9
|
+
THEME_CUSTOM_STYLE_ID,
|
|
10
|
+
THEME_PRESET_STORAGE_KEY
|
|
11
|
+
} from "../../lib/theme-presets";
|
|
12
|
+
import { setThemePreset } from "../../lib/use-theme-preset";
|
|
13
|
+
const FOUC_SCRIPT = `(function(){try{var v=localStorage.getItem(${JSON.stringify(
|
|
14
|
+
THEME_PRESET_STORAGE_KEY
|
|
15
|
+
)});if(!v||v===${JSON.stringify(
|
|
16
|
+
DEFAULT_THEME_PRESET
|
|
17
|
+
)})return;document.documentElement.setAttribute("data-theme",v);if(v===${JSON.stringify(
|
|
18
|
+
CUSTOM_THEME_NAME
|
|
19
|
+
)}){var c=localStorage.getItem(${JSON.stringify(
|
|
20
|
+
THEME_CUSTOM_CSS_STORAGE_KEY
|
|
21
|
+
)});if(c){var s=document.createElement("style");s.id=${JSON.stringify(
|
|
22
|
+
THEME_CUSTOM_STYLE_ID
|
|
23
|
+
)};s.textContent=c;document.head.appendChild(s);}}}catch(e){}})();`;
|
|
24
|
+
function ThemePresetProvider({
|
|
25
|
+
children,
|
|
26
|
+
defaultPreset
|
|
27
|
+
}) {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!defaultPreset || defaultPreset === DEFAULT_THEME_PRESET) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
let stored = null;
|
|
33
|
+
try {
|
|
34
|
+
stored = window.localStorage.getItem(THEME_PRESET_STORAGE_KEY);
|
|
35
|
+
} catch {
|
|
36
|
+
stored = null;
|
|
37
|
+
}
|
|
38
|
+
if (!stored && isThemePresetName(defaultPreset)) {
|
|
39
|
+
setThemePreset(defaultPreset);
|
|
40
|
+
}
|
|
41
|
+
}, [defaultPreset]);
|
|
42
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
"script",
|
|
45
|
+
{
|
|
46
|
+
dangerouslySetInnerHTML: { __html: FOUC_SCRIPT },
|
|
47
|
+
suppressHydrationWarning: true
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
children
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
ThemePresetProvider
|
|
55
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMounted } from "../../lib/use-mounted";
|
|
4
|
+
import { useThemePreset } from "../../lib/use-theme-preset";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
function ThemeSwitcher({ className }) {
|
|
7
|
+
const mounted = useMounted();
|
|
8
|
+
const { preset, presets, setPreset } = useThemePreset();
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
"aria-label": "Theme preset",
|
|
13
|
+
className: cn("flex items-center gap-1.5", className),
|
|
14
|
+
role: "radiogroup",
|
|
15
|
+
children: presets.map((item) => {
|
|
16
|
+
const active = mounted && preset === item.name;
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"button",
|
|
19
|
+
{
|
|
20
|
+
"aria-checked": active,
|
|
21
|
+
"aria-label": item.label,
|
|
22
|
+
className: cn(
|
|
23
|
+
"size-6 rounded-full border transition-transform hover:scale-110",
|
|
24
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
25
|
+
active ? "border-foreground ring-2 ring-ring ring-offset-2 ring-offset-background" : "border-border"
|
|
26
|
+
),
|
|
27
|
+
onClick: () => {
|
|
28
|
+
setPreset(item.name);
|
|
29
|
+
},
|
|
30
|
+
role: "radio",
|
|
31
|
+
style: { backgroundColor: item.swatch },
|
|
32
|
+
title: item.label,
|
|
33
|
+
type: "button"
|
|
34
|
+
},
|
|
35
|
+
item.name
|
|
36
|
+
);
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
ThemeSwitcher
|
|
43
|
+
};
|
|
@@ -20,7 +20,7 @@ function ThemeButton({
|
|
|
20
20
|
Button,
|
|
21
21
|
{
|
|
22
22
|
"aria-label": ariaLabel,
|
|
23
|
-
className: "bg-background text-foreground border border-
|
|
23
|
+
className: "bg-background text-foreground border border-zinc-300 dark:border-zinc-600 hover:border-zinc-400 dark:hover:border-zinc-500 transition-colors",
|
|
24
24
|
size: "icon",
|
|
25
25
|
variant: "outline",
|
|
26
26
|
...props,
|
|
@@ -120,7 +120,7 @@ function ThemeToggle({ dict }) {
|
|
|
120
120
|
DropdownMenuContent,
|
|
121
121
|
{
|
|
122
122
|
align: "end",
|
|
123
|
-
className: "bg-background border border-
|
|
123
|
+
className: "bg-background border border-zinc-300 dark:border-zinc-600",
|
|
124
124
|
onMouseEnter: () => {
|
|
125
125
|
isHoveringOverMenuAreaReference.current = true;
|
|
126
126
|
clearCloseTimer();
|
|
@@ -30,10 +30,10 @@ function ThinkingBlock({
|
|
|
30
30
|
onClick: toggleExpanded,
|
|
31
31
|
type: "button",
|
|
32
32
|
children: [
|
|
33
|
-
isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "
|
|
33
|
+
isExpanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "size-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "size-3" }),
|
|
34
34
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
35
35
|
"Thinking",
|
|
36
|
-
isStreaming ? /* @__PURE__ */ jsx("span", { className: "ml-1 animate-pulse", children: "
|
|
36
|
+
isStreaming ? /* @__PURE__ */ jsx("span", { className: "ml-1 animate-pulse", children: "\u2026" }) : null
|
|
37
37
|
] })
|
|
38
38
|
]
|
|
39
39
|
}
|
|
@@ -41,7 +41,7 @@ function ThinkingBlock({
|
|
|
41
41
|
isExpanded ? /* @__PURE__ */ jsxs(
|
|
42
42
|
"div",
|
|
43
43
|
{
|
|
44
|
-
className: "mt-2 p-3 bg-muted/50 rounded text-xs text-muted-foreground whitespace-pre-wrap border-l
|
|
44
|
+
className: "mt-2 p-3 bg-muted/50 rounded text-xs text-muted-foreground whitespace-pre-wrap border-l border-muted-foreground/30 max-h-48 overflow-y-auto",
|
|
45
45
|
id: contentId,
|
|
46
46
|
children: [
|
|
47
47
|
thinking,
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const DEFAULT_LABELS = {
|
|
8
|
+
empty: "No replies yet",
|
|
9
|
+
region: "Comment thread"
|
|
10
|
+
};
|
|
11
|
+
const Message = (props) => {
|
|
12
|
+
const { message } = props;
|
|
13
|
+
return /* @__PURE__ */ jsxs("li", { className: "space-y-0.5", "data-thread-bubble-message": message.id, children: [
|
|
14
|
+
/* @__PURE__ */ jsxs("header", { className: "flex items-baseline justify-between gap-2 text-[10px]", children: [
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
"span",
|
|
17
|
+
{
|
|
18
|
+
className: "font-semibold",
|
|
19
|
+
"data-thread-bubble-author": true,
|
|
20
|
+
style: message.authorColor ? { color: message.authorColor } : void 0,
|
|
21
|
+
children: message.author
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
message.ts ? /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", "data-thread-bubble-ts": true, children: message.ts }) : null
|
|
25
|
+
] }),
|
|
26
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-foreground", "data-thread-bubble-body": true, children: message.body })
|
|
27
|
+
] });
|
|
28
|
+
};
|
|
29
|
+
const ThreadBubble = forwardRef(
|
|
30
|
+
(props, ref) => {
|
|
31
|
+
const { className, footer, labels, messages, onResolve, title, ...rest } = props;
|
|
32
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
33
|
+
const handleResolve = () => {
|
|
34
|
+
onResolve?.();
|
|
35
|
+
};
|
|
36
|
+
return /* @__PURE__ */ jsxs(
|
|
37
|
+
"section",
|
|
38
|
+
{
|
|
39
|
+
"aria-label": resolvedLabels.region,
|
|
40
|
+
className: cn(
|
|
41
|
+
"flex w-72 flex-col gap-2 rounded-lg border border-border bg-background p-3 text-foreground shadow-md",
|
|
42
|
+
className
|
|
43
|
+
),
|
|
44
|
+
"data-thread-bubble": true,
|
|
45
|
+
ref,
|
|
46
|
+
...rest,
|
|
47
|
+
children: [
|
|
48
|
+
title || onResolve ? /* @__PURE__ */ jsxs("header", { className: "flex items-center justify-between gap-2 text-[11px] uppercase tracking-wide text-muted-foreground", children: [
|
|
49
|
+
title ? /* @__PURE__ */ jsx("span", { className: "truncate font-semibold", "data-thread-bubble-title": true, children: title }) : /* @__PURE__ */ jsx("span", { "aria-hidden": "true" }),
|
|
50
|
+
onResolve ? /* @__PURE__ */ jsx(
|
|
51
|
+
"button",
|
|
52
|
+
{
|
|
53
|
+
className: "rounded-full border border-border px-2 py-0.5 text-[10px] font-medium text-muted-foreground transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
54
|
+
"data-thread-bubble-resolve": true,
|
|
55
|
+
onClick: handleResolve,
|
|
56
|
+
type: "button",
|
|
57
|
+
children: "Resolve"
|
|
58
|
+
}
|
|
59
|
+
) : null
|
|
60
|
+
] }) : null,
|
|
61
|
+
messages.length === 0 ? /* @__PURE__ */ jsx(
|
|
62
|
+
"p",
|
|
63
|
+
{
|
|
64
|
+
className: "px-1 py-2 text-center text-[11px] text-muted-foreground",
|
|
65
|
+
"data-thread-bubble-state": "empty",
|
|
66
|
+
children: resolvedLabels.empty
|
|
67
|
+
}
|
|
68
|
+
) : /* @__PURE__ */ jsx("ul", { className: "space-y-2 overflow-y-auto", "data-thread-bubble-list": true, children: messages.map((message) => /* @__PURE__ */ jsx(Message, { message }, message.id)) }),
|
|
69
|
+
footer ? /* @__PURE__ */ jsx(
|
|
70
|
+
"footer",
|
|
71
|
+
{
|
|
72
|
+
className: "border-t border-border pt-2",
|
|
73
|
+
"data-thread-bubble-footer": true,
|
|
74
|
+
children: footer
|
|
75
|
+
}
|
|
76
|
+
) : null
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
ThreadBubble.displayName = "ThreadBubble";
|
|
83
|
+
export {
|
|
84
|
+
ThreadBubble
|
|
85
|
+
};
|