@vllnt/ui 0.2.1-canary.e1bc2b3 → 0.2.1-canary.e62eaf0
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 +36 -0
- 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 +5 -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/animated-text/animated-text.js +1 -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/blog-card/blog-card.js +3 -1
- 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/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 +3 -2
- package/dist/components/canvas-shell/canvas-foundation-demo.js +4 -4
- package/dist/components/carousel/carousel.js +18 -10
- package/dist/components/chat-dock-section/chat-dock-section.js +1 -1
- package/dist/components/checkbox/checkbox.js +2 -2
- package/dist/components/checklist/checklist.js +38 -10
- package/dist/components/checklist/index.js +8 -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 +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 +10 -8
- 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 +11 -10
- package/dist/components/completion-dialog/completion-dialog.js +19 -11
- package/dist/components/content-intro/content-intro.js +24 -20
- 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 +8 -8
- 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 +10 -10
- package/dist/components/data-list/data-list.js +1 -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/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 +14 -6
- package/dist/components/faq/faq.js +8 -4
- package/dist/components/file-upload/file-upload.js +3 -3
- package/dist/components/filter-bar/filter-bar.js +8 -7
- 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/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/globe-3d/globe-3d.js +429 -0
- package/dist/components/globe-3d/index.js +10 -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 +432 -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 +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/learning-objectives/learning-objectives.js +14 -13
- 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 +16 -14
- 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 +8 -7
- 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/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/multi-select.js +3 -3
- 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 +4 -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-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/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 +4 -3
- package/dist/components/progress-tracker/progress-tracker.js +19 -11
- 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/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 +483 -50
- 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 +20 -19
- package/dist/components/sidebar-toggle/sidebar-toggle.js +2 -2
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/slideshow/slideshow.js +14 -12
- 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/stat-card/stat-card.js +4 -4
- 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 +13 -6
- 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/tags-input/tags-input.js +12 -4
- package/dist/components/terminal/terminal.js +58 -36
- 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 +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 +11 -9
- 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 +15 -13
- package/dist/components/tutorial-filters/tutorial-filters.js +1 -1
- package/dist/components/tutorial-intro-content/tutorial-intro-content.js +5 -5
- package/dist/components/tutorial-mdx/tutorial-mdx.js +5 -5
- package/dist/components/usage-breakdown/usage-breakdown.js +9 -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 +7 -6
- 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 +34 -13
- package/dist/index.d.ts +7336 -256
- package/dist/index.js +3 -1
- package/package.json +4 -4
|
@@ -0,0 +1,89 @@
|
|
|
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 PALETTE = {
|
|
8
|
+
amber: { chip: "bg-amber-500 text-white", ring: "ring-amber-500" },
|
|
9
|
+
blue: { chip: "bg-blue-500 text-white", ring: "ring-blue-500" },
|
|
10
|
+
emerald: { chip: "bg-emerald-500 text-white", ring: "ring-emerald-500" },
|
|
11
|
+
purple: { chip: "bg-purple-500 text-white", ring: "ring-purple-500" },
|
|
12
|
+
red: { chip: "bg-red-500 text-white", ring: "ring-red-500" },
|
|
13
|
+
rose: { chip: "bg-rose-500 text-white", ring: "ring-rose-500" }
|
|
14
|
+
};
|
|
15
|
+
const DEFAULT_LABELS = {
|
|
16
|
+
region: "Follow mode",
|
|
17
|
+
stop: "Stop"
|
|
18
|
+
};
|
|
19
|
+
const FollowMode = forwardRef(
|
|
20
|
+
(props, ref) => {
|
|
21
|
+
const {
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
color = "blue",
|
|
25
|
+
labels,
|
|
26
|
+
name,
|
|
27
|
+
onStop,
|
|
28
|
+
...rest
|
|
29
|
+
} = props;
|
|
30
|
+
const palette = PALETTE[color];
|
|
31
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
32
|
+
return /* @__PURE__ */ jsxs(
|
|
33
|
+
"div",
|
|
34
|
+
{
|
|
35
|
+
"aria-label": resolvedLabels.region,
|
|
36
|
+
className: cn(
|
|
37
|
+
"relative h-full w-full rounded-2xl ring-2 ring-inset",
|
|
38
|
+
palette.ring,
|
|
39
|
+
className
|
|
40
|
+
),
|
|
41
|
+
"data-follow-color": color,
|
|
42
|
+
ref,
|
|
43
|
+
...rest,
|
|
44
|
+
children: [
|
|
45
|
+
/* @__PURE__ */ jsxs(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
className: "pointer-events-auto absolute left-1/2 top-2 z-30 flex -translate-x-1/2 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-semibold shadow-sm",
|
|
49
|
+
"data-follow-chip": true,
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsxs(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: cn(
|
|
55
|
+
"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5",
|
|
56
|
+
palette.chip
|
|
57
|
+
),
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u25B8" }),
|
|
60
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
61
|
+
"Following ",
|
|
62
|
+
name
|
|
63
|
+
] })
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
onStop ? /* @__PURE__ */ jsx(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
"aria-label": resolvedLabels.stop,
|
|
71
|
+
className: "inline-flex h-5 items-center rounded-full border border-border bg-background px-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
72
|
+
onClick: onStop,
|
|
73
|
+
type: "button",
|
|
74
|
+
children: resolvedLabels.stop
|
|
75
|
+
}
|
|
76
|
+
) : null
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
children
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
FollowMode.displayName = "FollowMode";
|
|
87
|
+
export {
|
|
88
|
+
FollowMode
|
|
89
|
+
};
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef,
|
|
5
|
+
useMemo
|
|
6
|
+
} from "react";
|
|
7
|
+
import { cn } from "../../lib/utils";
|
|
8
|
+
const MS_PER_DAY = 24 * 60 * 60 * 1e3;
|
|
9
|
+
const DEFAULT_LOCALE = "en-US";
|
|
10
|
+
const COLOR_CLASSES = {
|
|
11
|
+
amber: {
|
|
12
|
+
bar: "bg-amber-500/30",
|
|
13
|
+
progress: "bg-amber-600 dark:bg-amber-500"
|
|
14
|
+
},
|
|
15
|
+
blue: {
|
|
16
|
+
bar: "bg-blue-500/30",
|
|
17
|
+
progress: "bg-blue-600 dark:bg-blue-500"
|
|
18
|
+
},
|
|
19
|
+
emerald: {
|
|
20
|
+
bar: "bg-emerald-500/30",
|
|
21
|
+
progress: "bg-emerald-600 dark:bg-emerald-500"
|
|
22
|
+
},
|
|
23
|
+
neutral: {
|
|
24
|
+
bar: "bg-muted",
|
|
25
|
+
progress: "bg-muted-foreground"
|
|
26
|
+
},
|
|
27
|
+
purple: {
|
|
28
|
+
bar: "bg-purple-500/30",
|
|
29
|
+
progress: "bg-purple-600 dark:bg-purple-500"
|
|
30
|
+
},
|
|
31
|
+
red: {
|
|
32
|
+
bar: "bg-red-500/30",
|
|
33
|
+
progress: "bg-red-600 dark:bg-red-500"
|
|
34
|
+
},
|
|
35
|
+
rose: {
|
|
36
|
+
bar: "bg-rose-500/30",
|
|
37
|
+
progress: "bg-rose-600 dark:bg-rose-500"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const DEFAULT_LABELS = {
|
|
41
|
+
milestone: "Milestone",
|
|
42
|
+
today: "Today"
|
|
43
|
+
};
|
|
44
|
+
function toDate(value) {
|
|
45
|
+
return value instanceof Date ? new Date(value.getTime()) : new Date(value);
|
|
46
|
+
}
|
|
47
|
+
function clamp(value, min, max) {
|
|
48
|
+
return Math.min(Math.max(value, min), max);
|
|
49
|
+
}
|
|
50
|
+
function diffInDays(later, earlier) {
|
|
51
|
+
return (later.getTime() - earlier.getTime()) / MS_PER_DAY;
|
|
52
|
+
}
|
|
53
|
+
const TICK_FORMATTER_CACHE = /* @__PURE__ */ new Map();
|
|
54
|
+
function getTickDateTimeFormatter(locale, scale) {
|
|
55
|
+
const key = `${locale}|${scale}`;
|
|
56
|
+
let formatter = TICK_FORMATTER_CACHE.get(key);
|
|
57
|
+
if (!formatter) {
|
|
58
|
+
const options = scale === "month" ? { month: "short", year: "numeric" } : { day: "2-digit", month: "short" };
|
|
59
|
+
formatter = Intl.DateTimeFormat(locale, options);
|
|
60
|
+
TICK_FORMATTER_CACHE.set(key, formatter);
|
|
61
|
+
}
|
|
62
|
+
return formatter;
|
|
63
|
+
}
|
|
64
|
+
function buildTickFormatter(scale, locale) {
|
|
65
|
+
switch (scale) {
|
|
66
|
+
case "day":
|
|
67
|
+
return getTickDateTimeFormatter(locale, "day").format;
|
|
68
|
+
case "week":
|
|
69
|
+
return getTickDateTimeFormatter(locale, "week").format;
|
|
70
|
+
case "month":
|
|
71
|
+
return getTickDateTimeFormatter(locale, "month").format;
|
|
72
|
+
case "quarter":
|
|
73
|
+
return (date) => {
|
|
74
|
+
const quarter = Math.floor(date.getMonth() / 3) + 1;
|
|
75
|
+
return `Q${quarter.toString()} ${date.getFullYear().toString()}`;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function getTickStep(scale) {
|
|
80
|
+
switch (scale) {
|
|
81
|
+
case "day":
|
|
82
|
+
return 1;
|
|
83
|
+
case "week":
|
|
84
|
+
return 7;
|
|
85
|
+
case "month":
|
|
86
|
+
return 30;
|
|
87
|
+
case "quarter":
|
|
88
|
+
return 91;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function buildTicks(input) {
|
|
92
|
+
const { end, locale, scale, start, totalDays } = input;
|
|
93
|
+
const formatter = buildTickFormatter(scale, locale);
|
|
94
|
+
const stepDays = getTickStep(scale);
|
|
95
|
+
const tickCount = Math.floor(totalDays / stepDays);
|
|
96
|
+
return Array.from({ length: tickCount + 1 }).reduce((ticks, _, index) => {
|
|
97
|
+
const day = index * stepDays;
|
|
98
|
+
const date = new Date(start.getTime() + day * MS_PER_DAY);
|
|
99
|
+
if (date.getTime() <= end.getTime()) {
|
|
100
|
+
ticks.push({ label: formatter(date), offset: day });
|
|
101
|
+
}
|
|
102
|
+
return ticks;
|
|
103
|
+
}, []);
|
|
104
|
+
}
|
|
105
|
+
function useChartGeometry(options) {
|
|
106
|
+
const { endDate, locale, scale, startDate } = options;
|
|
107
|
+
return useMemo(() => {
|
|
108
|
+
const start = toDate(startDate);
|
|
109
|
+
const end = toDate(endDate);
|
|
110
|
+
const totalDays = Math.max(1, diffInDays(end, start));
|
|
111
|
+
const ticks = buildTicks({ end, locale, scale, start, totalDays });
|
|
112
|
+
return {
|
|
113
|
+
end,
|
|
114
|
+
pxPerDay: 1 / totalDays,
|
|
115
|
+
start,
|
|
116
|
+
ticks,
|
|
117
|
+
totalDays
|
|
118
|
+
};
|
|
119
|
+
}, [endDate, locale, scale, startDate]);
|
|
120
|
+
}
|
|
121
|
+
function TaskBar({ geometry, task }) {
|
|
122
|
+
const start = toDate(task.start);
|
|
123
|
+
const end = toDate(task.end);
|
|
124
|
+
const offsetDays = diffInDays(start, geometry.start);
|
|
125
|
+
const durationDays = Math.max(0.5, diffInDays(end, start));
|
|
126
|
+
const leftRatio = clamp(offsetDays / geometry.totalDays, 0, 1);
|
|
127
|
+
const widthRatio = clamp(durationDays / geometry.totalDays, 0, 1 - leftRatio);
|
|
128
|
+
const palette = COLOR_CLASSES[task.color ?? "blue"];
|
|
129
|
+
const progress = clamp(task.progress ?? 0, 0, 100);
|
|
130
|
+
const ariaLabel = typeof task.title === "string" ? `${task.title} from ${start.toISOString().slice(0, 10)} to ${end.toISOString().slice(0, 10)}, ${progress.toString()} percent complete` : void 0;
|
|
131
|
+
return /* @__PURE__ */ jsx(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
"aria-label": ariaLabel,
|
|
135
|
+
"aria-valuemax": 100,
|
|
136
|
+
"aria-valuemin": 0,
|
|
137
|
+
"aria-valuenow": progress,
|
|
138
|
+
className: cn(
|
|
139
|
+
"absolute top-1.5 flex h-5 items-center overflow-hidden rounded-md ring-1 ring-border",
|
|
140
|
+
palette.bar
|
|
141
|
+
),
|
|
142
|
+
"data-task-id": task.id,
|
|
143
|
+
role: "progressbar",
|
|
144
|
+
style: {
|
|
145
|
+
left: `${(leftRatio * 100).toString()}%`,
|
|
146
|
+
width: `${(widthRatio * 100).toString()}%`
|
|
147
|
+
},
|
|
148
|
+
children: /* @__PURE__ */ jsx(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
"aria-hidden": "true",
|
|
152
|
+
className: cn("h-full rounded-md", palette.progress),
|
|
153
|
+
style: { width: `${progress.toString()}%` }
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function MilestoneMarker({
|
|
160
|
+
geometry,
|
|
161
|
+
label,
|
|
162
|
+
milestone
|
|
163
|
+
}) {
|
|
164
|
+
const date = toDate(milestone.date);
|
|
165
|
+
const offsetDays = diffInDays(date, geometry.start);
|
|
166
|
+
if (offsetDays < 0 || offsetDays > geometry.totalDays) return null;
|
|
167
|
+
const leftRatio = offsetDays / geometry.totalDays;
|
|
168
|
+
const titleText = typeof milestone.title === "string" ? milestone.title : "";
|
|
169
|
+
return /* @__PURE__ */ jsxs(
|
|
170
|
+
"div",
|
|
171
|
+
{
|
|
172
|
+
"aria-label": `${label}: ${titleText}`,
|
|
173
|
+
className: "absolute top-0 z-10 -ml-1.5 flex flex-col items-center",
|
|
174
|
+
"data-milestone-id": milestone.id,
|
|
175
|
+
style: { left: `${(leftRatio * 100).toString()}%` },
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
"aria-hidden": "true",
|
|
181
|
+
className: "size-3 rotate-45 bg-amber-500 ring-2 ring-background"
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
titleText ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 whitespace-nowrap rounded bg-amber-500/20 px-1 text-[10px] font-medium text-amber-900 dark:text-amber-200", children: titleText }) : null
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
function TodayLine({ geometry, label, now }) {
|
|
190
|
+
const offsetDays = diffInDays(now, geometry.start);
|
|
191
|
+
if (offsetDays < 0 || offsetDays > geometry.totalDays) return null;
|
|
192
|
+
const leftRatio = offsetDays / geometry.totalDays;
|
|
193
|
+
return /* @__PURE__ */ jsxs(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
"aria-label": label,
|
|
197
|
+
className: "pointer-events-none absolute inset-y-0 z-10",
|
|
198
|
+
style: { left: `${(leftRatio * 100).toString()}%` },
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
"div",
|
|
202
|
+
{
|
|
203
|
+
"aria-hidden": "true",
|
|
204
|
+
className: "absolute inset-y-0 w-0.5 -translate-x-1/2 bg-destructive"
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
/* @__PURE__ */ jsx("span", { className: "absolute -top-5 -translate-x-1/2 whitespace-nowrap rounded bg-destructive/15 px-1 text-[10px] font-semibold uppercase tracking-wide text-destructive", children: label })
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
function Axis({ geometry }) {
|
|
213
|
+
return /* @__PURE__ */ jsx("div", { className: "relative flex h-7 items-end border-b border-border text-[10px] font-medium uppercase tracking-wide text-muted-foreground", children: geometry.ticks.map((tick) => /* @__PURE__ */ jsx(
|
|
214
|
+
"span",
|
|
215
|
+
{
|
|
216
|
+
className: "absolute -translate-x-1/2 px-1",
|
|
217
|
+
style: {
|
|
218
|
+
left: `${(tick.offset / geometry.totalDays * 100).toString()}%`
|
|
219
|
+
},
|
|
220
|
+
children: tick.label
|
|
221
|
+
},
|
|
222
|
+
tick.offset
|
|
223
|
+
)) });
|
|
224
|
+
}
|
|
225
|
+
function TaskRow({ geometry, task }) {
|
|
226
|
+
return /* @__PURE__ */ jsx("div", { className: "relative flex h-8 items-center border-b border-border/40", children: /* @__PURE__ */ jsx(TaskBar, { geometry, task }) });
|
|
227
|
+
}
|
|
228
|
+
function LeftColumn({ groups, taskColumnWidth }) {
|
|
229
|
+
return /* @__PURE__ */ jsxs(
|
|
230
|
+
"div",
|
|
231
|
+
{
|
|
232
|
+
className: "flex flex-col border-r border-border bg-background",
|
|
233
|
+
style: {
|
|
234
|
+
minWidth: `${taskColumnWidth.toString()}px`,
|
|
235
|
+
width: `${taskColumnWidth.toString()}px`
|
|
236
|
+
},
|
|
237
|
+
children: [
|
|
238
|
+
/* @__PURE__ */ jsx("div", { className: "h-7 border-b border-border" }),
|
|
239
|
+
groups.map((group) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
240
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-7 items-center border-b border-border/60 px-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: group.name }),
|
|
241
|
+
group.tasks.map((task) => /* @__PURE__ */ jsxs(
|
|
242
|
+
"div",
|
|
243
|
+
{
|
|
244
|
+
className: "flex h-8 items-center justify-between gap-2 border-b border-border/40 px-3 text-sm text-foreground",
|
|
245
|
+
children: [
|
|
246
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: task.title }),
|
|
247
|
+
task.assignee ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: task.assignee }) : null
|
|
248
|
+
]
|
|
249
|
+
},
|
|
250
|
+
task.id
|
|
251
|
+
))
|
|
252
|
+
] }, group.id))
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
function TimelineColumn({
|
|
258
|
+
geometry,
|
|
259
|
+
groups,
|
|
260
|
+
labels,
|
|
261
|
+
milestones,
|
|
262
|
+
now
|
|
263
|
+
}) {
|
|
264
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative min-w-0 flex-1", children: [
|
|
265
|
+
/* @__PURE__ */ jsx(Axis, { geometry }),
|
|
266
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
267
|
+
groups.map((group) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
268
|
+
/* @__PURE__ */ jsx("div", { className: "h-7 border-b border-border/60 bg-muted/20" }),
|
|
269
|
+
group.tasks.map((task) => /* @__PURE__ */ jsx(TaskRow, { geometry, task }, task.id))
|
|
270
|
+
] }, group.id)),
|
|
271
|
+
milestones.map((milestone) => /* @__PURE__ */ jsx(
|
|
272
|
+
MilestoneMarker,
|
|
273
|
+
{
|
|
274
|
+
geometry,
|
|
275
|
+
label: labels.milestone,
|
|
276
|
+
milestone
|
|
277
|
+
},
|
|
278
|
+
milestone.id
|
|
279
|
+
)),
|
|
280
|
+
/* @__PURE__ */ jsx(TodayLine, { geometry, label: labels.today, now })
|
|
281
|
+
] })
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
284
|
+
const GanttChart = forwardRef(
|
|
285
|
+
(props, ref) => {
|
|
286
|
+
const {
|
|
287
|
+
className,
|
|
288
|
+
endDate,
|
|
289
|
+
groups,
|
|
290
|
+
labels,
|
|
291
|
+
locale = DEFAULT_LOCALE,
|
|
292
|
+
milestones = [],
|
|
293
|
+
now,
|
|
294
|
+
scale = "month",
|
|
295
|
+
startDate,
|
|
296
|
+
taskColumnWidth = 200,
|
|
297
|
+
...rest
|
|
298
|
+
} = props;
|
|
299
|
+
const resolvedLabels = useMemo(
|
|
300
|
+
() => ({ ...DEFAULT_LABELS, ...labels }),
|
|
301
|
+
[labels]
|
|
302
|
+
);
|
|
303
|
+
const geometry = useChartGeometry({ endDate, locale, scale, startDate });
|
|
304
|
+
const nowDate = useMemo(() => now ? toDate(now) : /* @__PURE__ */ new Date(), [now]);
|
|
305
|
+
return /* @__PURE__ */ jsxs(
|
|
306
|
+
"div",
|
|
307
|
+
{
|
|
308
|
+
className: cn(
|
|
309
|
+
"flex w-full overflow-x-auto rounded-2xl border bg-background text-foreground",
|
|
310
|
+
className
|
|
311
|
+
),
|
|
312
|
+
ref,
|
|
313
|
+
...rest,
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ jsx(LeftColumn, { groups, taskColumnWidth }),
|
|
316
|
+
/* @__PURE__ */ jsx(
|
|
317
|
+
TimelineColumn,
|
|
318
|
+
{
|
|
319
|
+
geometry,
|
|
320
|
+
groups,
|
|
321
|
+
labels: resolvedLabels,
|
|
322
|
+
milestones,
|
|
323
|
+
now: nowDate
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
);
|
|
331
|
+
GanttChart.displayName = "GanttChart";
|
|
332
|
+
export {
|
|
333
|
+
GanttChart
|
|
334
|
+
};
|