@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
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useId,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState
|
|
10
|
+
} from "react";
|
|
4
11
|
import { Search } from "lucide-react";
|
|
5
12
|
import { cn } from "../../lib/utils";
|
|
6
|
-
import { Button } from "../button";
|
|
13
|
+
import { Button } from "../button/button";
|
|
7
14
|
import {
|
|
8
15
|
CommandDialog,
|
|
9
16
|
CommandEmpty,
|
|
@@ -32,71 +39,497 @@ function useKeyboardShortcut(callback) {
|
|
|
32
39
|
};
|
|
33
40
|
}, [callback]);
|
|
34
41
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
42
|
+
const DEFAULT_SCOPE_LABELS = {
|
|
43
|
+
components: "Components",
|
|
44
|
+
docs: "Docs",
|
|
45
|
+
everything: "Everything"
|
|
46
|
+
};
|
|
47
|
+
function getItemValue(item) {
|
|
48
|
+
return [
|
|
49
|
+
item.title,
|
|
50
|
+
item.description,
|
|
51
|
+
item.snippet,
|
|
52
|
+
item.keywords,
|
|
53
|
+
item.href,
|
|
54
|
+
item.id
|
|
55
|
+
].filter(Boolean).join(" ");
|
|
56
|
+
}
|
|
57
|
+
function HighlightedText({ query, text }) {
|
|
58
|
+
const trimmedQuery = query.trim();
|
|
59
|
+
if (!trimmedQuery) {
|
|
60
|
+
return text;
|
|
61
|
+
}
|
|
62
|
+
const index = text.toLowerCase().indexOf(trimmedQuery.toLowerCase());
|
|
63
|
+
if (index === -1) {
|
|
64
|
+
return text;
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
+
text.slice(0, index),
|
|
68
|
+
/* @__PURE__ */ jsx("mark", { className: "rounded bg-primary/15 px-0.5 text-foreground", children: text.slice(index, index + trimmedQuery.length) }),
|
|
69
|
+
text.slice(index + trimmedQuery.length)
|
|
70
|
+
] });
|
|
71
|
+
}
|
|
72
|
+
function ScopeTabs({
|
|
73
|
+
getTabId,
|
|
74
|
+
labels,
|
|
75
|
+
onScopeChange,
|
|
76
|
+
panelId,
|
|
77
|
+
scope
|
|
78
|
+
}) {
|
|
79
|
+
const scopes = ["components", "docs", "everything"];
|
|
80
|
+
return /* @__PURE__ */ jsx(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
"aria-label": "Search scope",
|
|
84
|
+
className: "grid grid-cols-3 gap-1 border-b p-1",
|
|
85
|
+
role: "tablist",
|
|
86
|
+
children: scopes.map((nextScope) => /* @__PURE__ */ jsx(
|
|
87
|
+
"button",
|
|
88
|
+
{
|
|
89
|
+
"aria-controls": panelId,
|
|
90
|
+
"aria-selected": scope === nextScope,
|
|
91
|
+
className: cn(
|
|
92
|
+
"h-8 rounded-sm px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",
|
|
93
|
+
scope === nextScope && "bg-accent text-accent-foreground"
|
|
94
|
+
),
|
|
95
|
+
id: getTabId(nextScope),
|
|
96
|
+
onClick: () => {
|
|
97
|
+
onScopeChange(nextScope);
|
|
98
|
+
},
|
|
99
|
+
role: "tab",
|
|
100
|
+
type: "button",
|
|
101
|
+
children: labels[nextScope]
|
|
102
|
+
},
|
|
103
|
+
nextScope
|
|
104
|
+
))
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function SearchResultContent({
|
|
109
|
+
item,
|
|
110
|
+
query
|
|
111
|
+
}) {
|
|
112
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col", children: [
|
|
113
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: item.title }),
|
|
114
|
+
item.snippet ? /* @__PURE__ */ jsx("span", { className: "line-clamp-2 text-xs text-muted-foreground", children: /* @__PURE__ */ jsx(HighlightedText, { query, text: item.snippet }) }) : item.description ? /* @__PURE__ */ jsx("span", { className: "line-clamp-2 text-xs text-muted-foreground", children: item.description }) : null
|
|
115
|
+
] });
|
|
116
|
+
}
|
|
117
|
+
function SearchTriggerButton({
|
|
118
|
+
buttonText,
|
|
119
|
+
buttonTextMobile,
|
|
120
|
+
onOpen
|
|
121
|
+
}) {
|
|
122
|
+
return /* @__PURE__ */ jsxs(
|
|
123
|
+
Button,
|
|
124
|
+
{
|
|
125
|
+
className: cn(
|
|
126
|
+
"relative h-9 w-full justify-start text-sm text-muted-foreground sm:pr-12 md:w-40 lg:w-64"
|
|
127
|
+
),
|
|
128
|
+
onClick: onOpen,
|
|
129
|
+
variant: "outline",
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ jsx(Search, { className: "mr-2 size-4" }),
|
|
132
|
+
/* @__PURE__ */ jsx("span", { className: "hidden lg:inline-flex", children: buttonText ?? "Search..." }),
|
|
133
|
+
/* @__PURE__ */ jsx("span", { className: "inline-flex lg:hidden", children: buttonTextMobile ?? "Search..." }),
|
|
134
|
+
/* @__PURE__ */ jsxs("kbd", { className: "pointer-events-none absolute right-1.5 top-1.5 hidden h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex", children: [
|
|
135
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs", children: "\u2318" }),
|
|
136
|
+
"K"
|
|
137
|
+
] })
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function ComponentResultsGroup({
|
|
40
143
|
groupHeading,
|
|
144
|
+
hasDocumentationSearch,
|
|
41
145
|
items,
|
|
146
|
+
labels,
|
|
42
147
|
onSelect,
|
|
43
|
-
|
|
148
|
+
query
|
|
149
|
+
}) {
|
|
150
|
+
return /* @__PURE__ */ jsx(
|
|
151
|
+
CommandGroup,
|
|
152
|
+
{
|
|
153
|
+
heading: groupHeading ?? (hasDocumentationSearch ? labels.components : void 0),
|
|
154
|
+
children: items.map((item) => /* @__PURE__ */ jsx(
|
|
155
|
+
CommandItem,
|
|
156
|
+
{
|
|
157
|
+
onSelect: () => {
|
|
158
|
+
onSelect(item);
|
|
159
|
+
},
|
|
160
|
+
value: getItemValue(item),
|
|
161
|
+
children: /* @__PURE__ */ jsx(SearchResultContent, { item, query })
|
|
162
|
+
},
|
|
163
|
+
item.id
|
|
164
|
+
))
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
function DocumentationStatusItem({
|
|
169
|
+
documentationSearchLength,
|
|
170
|
+
trimmedQuery
|
|
171
|
+
}) {
|
|
172
|
+
return /* @__PURE__ */ jsx(CommandItem, { disabled: true, value: `${trimmedQuery} search-docs-min-length`, children: /* @__PURE__ */ jsxs("span", { className: "text-sm text-muted-foreground", children: [
|
|
173
|
+
"Type at least ",
|
|
174
|
+
documentationSearchLength,
|
|
175
|
+
" characters to search docs."
|
|
176
|
+
] }) });
|
|
177
|
+
}
|
|
178
|
+
function DocumentationLoadingItem({ trimmedQuery }) {
|
|
179
|
+
return /* @__PURE__ */ jsx(CommandItem, { disabled: true, value: `${trimmedQuery} searching-docs`, children: /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "Searching docs..." }) });
|
|
180
|
+
}
|
|
181
|
+
function DocumentationResultsGroup({
|
|
182
|
+
docsGroupHeading,
|
|
183
|
+
documentationItems,
|
|
184
|
+
documentationLoading,
|
|
185
|
+
documentationSearchLength,
|
|
186
|
+
onSelect,
|
|
187
|
+
query,
|
|
188
|
+
scope,
|
|
189
|
+
trimmedQuery
|
|
190
|
+
}) {
|
|
191
|
+
const showMinimumLengthPrompt = scope === "docs" && trimmedQuery.length < documentationSearchLength;
|
|
192
|
+
const showDocumentationItems = !documentationLoading && trimmedQuery.length >= documentationSearchLength;
|
|
193
|
+
return /* @__PURE__ */ jsxs(CommandGroup, { heading: docsGroupHeading ?? "Docs", children: [
|
|
194
|
+
showMinimumLengthPrompt ? /* @__PURE__ */ jsx(
|
|
195
|
+
DocumentationStatusItem,
|
|
196
|
+
{
|
|
197
|
+
documentationSearchLength,
|
|
198
|
+
trimmedQuery
|
|
199
|
+
}
|
|
200
|
+
) : null,
|
|
201
|
+
documentationLoading ? /* @__PURE__ */ jsx(DocumentationLoadingItem, { trimmedQuery }) : null,
|
|
202
|
+
showDocumentationItems ? documentationItems.map((item) => /* @__PURE__ */ jsx(
|
|
203
|
+
CommandItem,
|
|
204
|
+
{
|
|
205
|
+
onSelect: () => {
|
|
206
|
+
onSelect(item);
|
|
207
|
+
},
|
|
208
|
+
value: getItemValue(item),
|
|
209
|
+
children: /* @__PURE__ */ jsx(SearchResultContent, { item, query })
|
|
210
|
+
},
|
|
211
|
+
item.id
|
|
212
|
+
)) : null
|
|
213
|
+
] });
|
|
214
|
+
}
|
|
215
|
+
function SearchDialogList({
|
|
216
|
+
activeTabId,
|
|
217
|
+
currentEmptyText,
|
|
218
|
+
docsGroupHeading,
|
|
219
|
+
documentationItems,
|
|
220
|
+
documentationLoading,
|
|
221
|
+
documentationSearchLength,
|
|
222
|
+
groupHeading,
|
|
223
|
+
hasDocumentationSearch,
|
|
224
|
+
labels,
|
|
225
|
+
onComponentSelect,
|
|
226
|
+
onDocumentationSelect,
|
|
227
|
+
panelId,
|
|
228
|
+
query,
|
|
229
|
+
scope,
|
|
230
|
+
showComponents,
|
|
231
|
+
showDocumentation,
|
|
232
|
+
sortedItems,
|
|
233
|
+
trimmedQuery
|
|
234
|
+
}) {
|
|
235
|
+
return /* @__PURE__ */ jsxs(
|
|
236
|
+
CommandList,
|
|
237
|
+
{
|
|
238
|
+
"aria-labelledby": activeTabId,
|
|
239
|
+
className: "max-h-[420px]",
|
|
240
|
+
id: panelId,
|
|
241
|
+
role: activeTabId === void 0 ? void 0 : "tabpanel",
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: currentEmptyText }),
|
|
244
|
+
showComponents ? /* @__PURE__ */ jsx(
|
|
245
|
+
ComponentResultsGroup,
|
|
246
|
+
{
|
|
247
|
+
groupHeading,
|
|
248
|
+
hasDocumentationSearch,
|
|
249
|
+
items: sortedItems,
|
|
250
|
+
labels,
|
|
251
|
+
onSelect: onComponentSelect,
|
|
252
|
+
query
|
|
253
|
+
}
|
|
254
|
+
) : null,
|
|
255
|
+
showDocumentation ? /* @__PURE__ */ jsx(
|
|
256
|
+
DocumentationResultsGroup,
|
|
257
|
+
{
|
|
258
|
+
docsGroupHeading,
|
|
259
|
+
documentationItems,
|
|
260
|
+
documentationLoading,
|
|
261
|
+
documentationSearchLength,
|
|
262
|
+
onSelect: onDocumentationSelect,
|
|
263
|
+
query,
|
|
264
|
+
scope,
|
|
265
|
+
trimmedQuery
|
|
266
|
+
}
|
|
267
|
+
) : null
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
function useDocumentationSearch({
|
|
273
|
+
docsSearch,
|
|
274
|
+
minDocsSearchLength
|
|
275
|
+
}) {
|
|
276
|
+
const [documentationItems, setDocumentationItems] = useState(
|
|
277
|
+
[]
|
|
278
|
+
);
|
|
279
|
+
const [documentationLoading, setDocumentationLoading] = useState(false);
|
|
280
|
+
const activeDocumentationRequest = useRef(0);
|
|
281
|
+
const documentationSearchLength = minDocsSearchLength ?? 2;
|
|
282
|
+
const runDocumentationSearch = useCallback(
|
|
283
|
+
(nextQuery, nextScope) => {
|
|
284
|
+
const nextTrimmedQuery = nextQuery.trim();
|
|
285
|
+
const nextRequest = activeDocumentationRequest.current + 1;
|
|
286
|
+
activeDocumentationRequest.current = nextRequest;
|
|
287
|
+
if (!docsSearch || nextScope === "components" || nextTrimmedQuery.length < documentationSearchLength) {
|
|
288
|
+
setDocumentationItems([]);
|
|
289
|
+
setDocumentationLoading(false);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
setDocumentationLoading(true);
|
|
293
|
+
docsSearch(nextTrimmedQuery).then((results) => {
|
|
294
|
+
if (activeDocumentationRequest.current === nextRequest) {
|
|
295
|
+
setDocumentationItems(results);
|
|
296
|
+
}
|
|
297
|
+
}).catch(() => {
|
|
298
|
+
if (activeDocumentationRequest.current === nextRequest) {
|
|
299
|
+
setDocumentationItems([]);
|
|
300
|
+
}
|
|
301
|
+
}).finally(() => {
|
|
302
|
+
if (activeDocumentationRequest.current === nextRequest) {
|
|
303
|
+
setDocumentationLoading(false);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
[docsSearch, documentationSearchLength]
|
|
308
|
+
);
|
|
309
|
+
return {
|
|
310
|
+
documentationItems,
|
|
311
|
+
documentationLoading,
|
|
312
|
+
documentationSearchLength,
|
|
313
|
+
hasDocumentationSearch: docsSearch !== void 0,
|
|
314
|
+
runDocumentationSearch
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function useSearchDialogHandlers({
|
|
318
|
+
enableKeyboardShortcut,
|
|
319
|
+
onDocsSelect,
|
|
320
|
+
onSelect,
|
|
321
|
+
runDocumentationSearch
|
|
44
322
|
}) {
|
|
45
323
|
const [open, setOpen] = useState(false);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
324
|
+
const [query, setQuery] = useState("");
|
|
325
|
+
const [scope, setScope] = useState("components");
|
|
326
|
+
const toggleOpen = useCallback(() => {
|
|
327
|
+
if (enableKeyboardShortcut ?? true) {
|
|
49
328
|
setOpen((previous) => !previous);
|
|
50
329
|
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
330
|
+
}, [enableKeyboardShortcut]);
|
|
331
|
+
useKeyboardShortcut(toggleOpen);
|
|
332
|
+
const handleQueryChange = useCallback(
|
|
333
|
+
(nextQuery) => {
|
|
334
|
+
setQuery(nextQuery);
|
|
335
|
+
runDocumentationSearch(nextQuery, scope);
|
|
336
|
+
},
|
|
337
|
+
[runDocumentationSearch, scope]
|
|
338
|
+
);
|
|
339
|
+
const handleScopeChange = useCallback(
|
|
340
|
+
(nextScope) => {
|
|
341
|
+
setScope(nextScope);
|
|
342
|
+
runDocumentationSearch(query, nextScope);
|
|
343
|
+
},
|
|
344
|
+
[query, runDocumentationSearch]
|
|
345
|
+
);
|
|
346
|
+
const handleOpenChange = useCallback(
|
|
347
|
+
(nextOpen) => {
|
|
348
|
+
setOpen(nextOpen);
|
|
349
|
+
if (nextOpen) {
|
|
350
|
+
runDocumentationSearch(query, scope);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
[query, runDocumentationSearch, scope]
|
|
354
|
+
);
|
|
355
|
+
const handleComponentSelect = useCallback(
|
|
356
|
+
(item) => {
|
|
357
|
+
setOpen(false);
|
|
358
|
+
onSelect(item);
|
|
359
|
+
},
|
|
360
|
+
[onSelect]
|
|
361
|
+
);
|
|
362
|
+
const handleDocumentationSelect = useCallback(
|
|
363
|
+
(item) => {
|
|
364
|
+
setOpen(false);
|
|
365
|
+
(onDocsSelect ?? onSelect)(item);
|
|
366
|
+
},
|
|
367
|
+
[onDocsSelect, onSelect]
|
|
368
|
+
);
|
|
369
|
+
return {
|
|
370
|
+
handleComponentSelect,
|
|
371
|
+
handleDocumentationSelect,
|
|
372
|
+
handleOpenChange,
|
|
373
|
+
handleQueryChange,
|
|
374
|
+
handleScopeChange,
|
|
375
|
+
open,
|
|
376
|
+
query,
|
|
377
|
+
scope
|
|
55
378
|
};
|
|
379
|
+
}
|
|
380
|
+
function getCurrentEmptyText({
|
|
381
|
+
docsEmptyText,
|
|
382
|
+
documentationSearchLength,
|
|
383
|
+
emptyText,
|
|
384
|
+
scope,
|
|
385
|
+
trimmedQuery
|
|
386
|
+
}) {
|
|
387
|
+
if (scope === "docs" && trimmedQuery.length < documentationSearchLength) {
|
|
388
|
+
return `Type at least ${documentationSearchLength} characters to search docs.`;
|
|
389
|
+
}
|
|
390
|
+
if (scope === "docs") {
|
|
391
|
+
return docsEmptyText ?? "No docs found.";
|
|
392
|
+
}
|
|
393
|
+
return emptyText ?? "No results found.";
|
|
394
|
+
}
|
|
395
|
+
function SearchDialogView({
|
|
396
|
+
buttonText,
|
|
397
|
+
buttonTextMobile,
|
|
398
|
+
currentEmptyText,
|
|
399
|
+
docsGroupHeading,
|
|
400
|
+
documentationSearch,
|
|
401
|
+
groupHeading,
|
|
402
|
+
handlers,
|
|
403
|
+
labels,
|
|
404
|
+
searchPlaceholder,
|
|
405
|
+
showDocumentation,
|
|
406
|
+
sortedItems,
|
|
407
|
+
trimmedQuery
|
|
408
|
+
}) {
|
|
409
|
+
const baseId = useId();
|
|
410
|
+
const getTabId = (s) => `${baseId}-tab-${s}`;
|
|
411
|
+
const panelId = `${baseId}-panel`;
|
|
56
412
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
413
|
+
/* @__PURE__ */ jsx(
|
|
414
|
+
SearchTriggerButton,
|
|
415
|
+
{
|
|
416
|
+
buttonText,
|
|
417
|
+
buttonTextMobile,
|
|
418
|
+
onOpen: () => {
|
|
419
|
+
handlers.handleOpenChange(true);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
),
|
|
57
423
|
/* @__PURE__ */ jsxs(
|
|
58
|
-
|
|
424
|
+
CommandDialog,
|
|
59
425
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
),
|
|
63
|
-
onClick: () => {
|
|
64
|
-
setOpen(true);
|
|
65
|
-
},
|
|
66
|
-
variant: "outline",
|
|
426
|
+
onOpenChange: handlers.handleOpenChange,
|
|
427
|
+
open: handlers.open,
|
|
67
428
|
children: [
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
429
|
+
/* @__PURE__ */ jsx(
|
|
430
|
+
CommandInput,
|
|
431
|
+
{
|
|
432
|
+
onValueChange: handlers.handleQueryChange,
|
|
433
|
+
placeholder: searchPlaceholder ?? "Search...",
|
|
434
|
+
value: handlers.query
|
|
435
|
+
}
|
|
436
|
+
),
|
|
437
|
+
documentationSearch.hasDocumentationSearch ? /* @__PURE__ */ jsx(
|
|
438
|
+
ScopeTabs,
|
|
439
|
+
{
|
|
440
|
+
getTabId,
|
|
441
|
+
labels,
|
|
442
|
+
onScopeChange: handlers.handleScopeChange,
|
|
443
|
+
panelId,
|
|
444
|
+
scope: handlers.scope
|
|
445
|
+
}
|
|
446
|
+
) : null,
|
|
447
|
+
/* @__PURE__ */ jsx(
|
|
448
|
+
SearchDialogList,
|
|
449
|
+
{
|
|
450
|
+
activeTabId: documentationSearch.hasDocumentationSearch ? getTabId(handlers.scope) : void 0,
|
|
451
|
+
currentEmptyText,
|
|
452
|
+
docsGroupHeading,
|
|
453
|
+
documentationItems: documentationSearch.documentationItems,
|
|
454
|
+
documentationLoading: documentationSearch.documentationLoading,
|
|
455
|
+
documentationSearchLength: documentationSearch.documentationSearchLength,
|
|
456
|
+
groupHeading,
|
|
457
|
+
hasDocumentationSearch: documentationSearch.hasDocumentationSearch,
|
|
458
|
+
labels,
|
|
459
|
+
onComponentSelect: handlers.handleComponentSelect,
|
|
460
|
+
onDocumentationSelect: handlers.handleDocumentationSelect,
|
|
461
|
+
panelId: documentationSearch.hasDocumentationSearch ? panelId : void 0,
|
|
462
|
+
query: handlers.query,
|
|
463
|
+
scope: handlers.scope,
|
|
464
|
+
showComponents: handlers.scope !== "docs",
|
|
465
|
+
showDocumentation,
|
|
466
|
+
sortedItems,
|
|
467
|
+
trimmedQuery
|
|
468
|
+
}
|
|
469
|
+
)
|
|
75
470
|
]
|
|
76
471
|
}
|
|
77
|
-
)
|
|
78
|
-
/* @__PURE__ */ jsxs(CommandDialog, { onOpenChange: setOpen, open, children: [
|
|
79
|
-
/* @__PURE__ */ jsx(CommandInput, { placeholder: searchPlaceholder }),
|
|
80
|
-
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
81
|
-
/* @__PURE__ */ jsx(CommandEmpty, { children: emptyText }),
|
|
82
|
-
/* @__PURE__ */ jsx(CommandGroup, { heading: groupHeading, children: sortedItems.map((item) => /* @__PURE__ */ jsx(
|
|
83
|
-
CommandItem,
|
|
84
|
-
{
|
|
85
|
-
onSelect: () => {
|
|
86
|
-
handleSelect(item);
|
|
87
|
-
},
|
|
88
|
-
value: `${item.title} ${item.description || ""} ${item.keywords || ""} ${item.id}`,
|
|
89
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
90
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium", children: item.title }),
|
|
91
|
-
item.description ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: item.description }) : null
|
|
92
|
-
] })
|
|
93
|
-
},
|
|
94
|
-
item.id
|
|
95
|
-
)) })
|
|
96
|
-
] })
|
|
97
|
-
] })
|
|
472
|
+
)
|
|
98
473
|
] });
|
|
99
474
|
}
|
|
475
|
+
function SearchDialog({
|
|
476
|
+
buttonText,
|
|
477
|
+
buttonTextMobile,
|
|
478
|
+
docsEmptyText,
|
|
479
|
+
docsGroupHeading,
|
|
480
|
+
docsSearch,
|
|
481
|
+
emptyText,
|
|
482
|
+
enableKeyboardShortcut,
|
|
483
|
+
groupHeading,
|
|
484
|
+
items,
|
|
485
|
+
minDocsSearchLength,
|
|
486
|
+
onDocsSelect,
|
|
487
|
+
onSelect,
|
|
488
|
+
scopeLabels,
|
|
489
|
+
searchPlaceholder
|
|
490
|
+
}) {
|
|
491
|
+
const documentationSearch = useDocumentationSearch({
|
|
492
|
+
docsSearch,
|
|
493
|
+
minDocsSearchLength
|
|
494
|
+
});
|
|
495
|
+
const handlers = useSearchDialogHandlers({
|
|
496
|
+
enableKeyboardShortcut,
|
|
497
|
+
onDocsSelect,
|
|
498
|
+
onSelect,
|
|
499
|
+
runDocumentationSearch: documentationSearch.runDocumentationSearch
|
|
500
|
+
});
|
|
501
|
+
const labels = { ...DEFAULT_SCOPE_LABELS, ...scopeLabels };
|
|
502
|
+
const trimmedQuery = handlers.query.trim();
|
|
503
|
+
const sortedItems = useMemo(
|
|
504
|
+
() => [...items].sort((a, b) => a.title.localeCompare(b.title)),
|
|
505
|
+
[items]
|
|
506
|
+
);
|
|
507
|
+
const currentEmptyText = getCurrentEmptyText({
|
|
508
|
+
docsEmptyText,
|
|
509
|
+
documentationSearchLength: documentationSearch.documentationSearchLength,
|
|
510
|
+
emptyText,
|
|
511
|
+
scope: handlers.scope,
|
|
512
|
+
trimmedQuery
|
|
513
|
+
});
|
|
514
|
+
const showDocumentation = documentationSearch.hasDocumentationSearch && handlers.scope !== "components";
|
|
515
|
+
return /* @__PURE__ */ jsx(
|
|
516
|
+
SearchDialogView,
|
|
517
|
+
{
|
|
518
|
+
buttonText,
|
|
519
|
+
buttonTextMobile,
|
|
520
|
+
currentEmptyText,
|
|
521
|
+
docsGroupHeading,
|
|
522
|
+
documentationSearch,
|
|
523
|
+
groupHeading,
|
|
524
|
+
handlers,
|
|
525
|
+
labels,
|
|
526
|
+
searchPlaceholder,
|
|
527
|
+
showDocumentation,
|
|
528
|
+
sortedItems,
|
|
529
|
+
trimmedQuery
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
}
|
|
100
533
|
export {
|
|
101
534
|
SearchDialog
|
|
102
535
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SegmentedControl,
|
|
3
|
+
SegmentedControlItem,
|
|
4
|
+
segmentedControlItemVariants,
|
|
5
|
+
segmentedControlVariants
|
|
6
|
+
} from "./segmented-control";
|
|
7
|
+
export {
|
|
8
|
+
SegmentedControl,
|
|
9
|
+
SegmentedControlItem,
|
|
10
|
+
segmentedControlItemVariants,
|
|
11
|
+
segmentedControlVariants
|
|
12
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../../lib/utils";
|
|
7
|
+
const segmentedControlVariants = cva(
|
|
8
|
+
"inline-flex w-full items-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
9
|
+
{
|
|
10
|
+
defaultVariants: {
|
|
11
|
+
size: "default"
|
|
12
|
+
},
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
default: "min-h-10",
|
|
16
|
+
lg: "min-h-11",
|
|
17
|
+
sm: "min-h-9"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
const segmentedControlItemVariants = cva(
|
|
23
|
+
"inline-flex flex-1 items-center justify-center rounded-md px-3 text-sm font-medium whitespace-nowrap transition-all outline-none ring-offset-background focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm",
|
|
24
|
+
{
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
size: "default"
|
|
27
|
+
},
|
|
28
|
+
variants: {
|
|
29
|
+
size: {
|
|
30
|
+
default: "min-h-8",
|
|
31
|
+
lg: "min-h-9 px-4",
|
|
32
|
+
sm: "min-h-7 px-2.5 text-xs"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
const SegmentedControl = React.forwardRef(({ className, size, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
38
|
+
ToggleGroupPrimitive.Root,
|
|
39
|
+
{
|
|
40
|
+
className: cn(segmentedControlVariants({ size }), className),
|
|
41
|
+
ref,
|
|
42
|
+
type: "single",
|
|
43
|
+
...props
|
|
44
|
+
}
|
|
45
|
+
));
|
|
46
|
+
SegmentedControl.displayName = "SegmentedControl";
|
|
47
|
+
const SegmentedControlItem = React.forwardRef(({ className, size, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
48
|
+
ToggleGroupPrimitive.Item,
|
|
49
|
+
{
|
|
50
|
+
className: cn(segmentedControlItemVariants({ size }), className),
|
|
51
|
+
ref,
|
|
52
|
+
...props
|
|
53
|
+
}
|
|
54
|
+
));
|
|
55
|
+
SegmentedControlItem.displayName = "SegmentedControlItem";
|
|
56
|
+
export {
|
|
57
|
+
SegmentedControl,
|
|
58
|
+
SegmentedControlItem,
|
|
59
|
+
segmentedControlItemVariants,
|
|
60
|
+
segmentedControlVariants
|
|
61
|
+
};
|
|
@@ -18,7 +18,7 @@ const SelectTrigger = forwardRef(({ children, className, ...props }, ref) => /*
|
|
|
18
18
|
...props,
|
|
19
19
|
children: [
|
|
20
20
|
children,
|
|
21
|
-
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "
|
|
21
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4 opacity-50" }) })
|
|
22
22
|
]
|
|
23
23
|
}
|
|
24
24
|
));
|
|
@@ -32,7 +32,7 @@ const SelectScrollUpButton = forwardRef(({ className, ...props }, ref) => /* @__
|
|
|
32
32
|
),
|
|
33
33
|
ref,
|
|
34
34
|
...props,
|
|
35
|
-
children: /* @__PURE__ */ jsx(ChevronUp, { className: "
|
|
35
|
+
children: /* @__PURE__ */ jsx(ChevronUp, { className: "size-4" })
|
|
36
36
|
}
|
|
37
37
|
));
|
|
38
38
|
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
@@ -45,7 +45,7 @@ const SelectScrollDownButton = forwardRef(({ className, ...props }, ref) => /* @
|
|
|
45
45
|
),
|
|
46
46
|
ref,
|
|
47
47
|
...props,
|
|
48
|
-
children: /* @__PURE__ */ jsx(ChevronDown, { className: "
|
|
48
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { className: "size-4" })
|
|
49
49
|
}
|
|
50
50
|
));
|
|
51
51
|
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
@@ -96,7 +96,7 @@ const SelectItem = forwardRef(({ children, className, ...props }, ref) => /* @__
|
|
|
96
96
|
ref,
|
|
97
97
|
...props,
|
|
98
98
|
children: [
|
|
99
|
-
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex
|
|
99
|
+
/* @__PURE__ */ jsx("span", { className: "absolute left-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "size-4" }) }) }),
|
|
100
100
|
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
101
101
|
]
|
|
102
102
|
}
|
|
@@ -105,7 +105,7 @@ SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
|
105
105
|
const SelectSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
106
106
|
SelectPrimitive.Separator,
|
|
107
107
|
{
|
|
108
|
-
className: cn("-
|
|
108
|
+
className: cn("-m-1 h-px bg-muted", className),
|
|
109
109
|
ref,
|
|
110
110
|
...props
|
|
111
111
|
}
|