@vllnt/ui 0.2.1-canary.0aaaad2 → 0.2.1-canary.0cc4e50
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 +3 -0
- package/dist/components/activity-heatmap/activity-heatmap.js +2 -1
- package/dist/components/activity-log/activity-log.js +1 -1
- package/dist/components/ai-artifact/ai-artifact.js +8 -8
- package/dist/components/ai-chat-input/ai-chat-input.js +1 -1
- package/dist/components/ai-message-bubble/ai-message-bubble.js +1 -1
- package/dist/components/ai-sidebar/ai-sidebar.js +4 -4
- package/dist/components/ai-tool-call-display/ai-tool-call-display.js +1 -1
- package/dist/components/animated-text/animated-text.js +6 -3
- package/dist/components/annotation/annotation.js +1 -1
- package/dist/components/auto-reload/auto-reload.js +1 -1
- package/dist/components/avatar-group/avatar-group.js +1 -1
- package/dist/components/blog-card/blog-card.js +4 -2
- package/dist/components/bottom-activity-strip/bottom-activity-strip.js +2 -2
- package/dist/components/candlestick-chart/candlestick-chart.js +2 -1
- package/dist/components/canvas-shell/canvas-foundation-demo.js +1 -1
- package/dist/components/carousel/carousel.js +14 -6
- package/dist/components/category-filter/category-filter.js +1 -1
- package/dist/components/chat-dock-section/chat-dock-section.js +1 -1
- package/dist/components/checklist/checklist.js +35 -7
- package/dist/components/checklist/index.js +8 -2
- package/dist/components/chronological-timeline/chronological-timeline.js +2 -2
- package/dist/components/code-playground/code-playground.js +3 -2
- package/dist/components/combobox/combobox.js +1 -6
- package/dist/components/comment-pin/comment-pin.js +2 -2
- package/dist/components/comparison/comparison.js +2 -1
- package/dist/components/completion-dialog/completion-dialog.js +19 -11
- package/dist/components/connector-edge/connector-edge.js +1 -1
- package/dist/components/content-intro/content-intro.js +18 -15
- package/dist/components/conversation-thread/conversation-thread.js +4 -4
- package/dist/components/countdown-timer/countdown-timer.js +1 -1
- package/dist/components/data-table/data-table.js +1 -1
- package/dist/components/date-picker/date-picker.js +1 -6
- package/dist/components/exercise/exercise.js +11 -3
- package/dist/components/faq/faq.js +6 -2
- package/dist/components/file-upload/file-upload.js +1 -6
- package/dist/components/filter-bar/filter-bar.js +7 -7
- package/dist/components/flashcard/flashcard.js +1 -1
- package/dist/components/floating-toolbar/floating-toolbar.js +2 -2
- package/dist/components/form/form.js +1 -1
- package/dist/components/gantt-chart/gantt-chart.js +8 -7
- package/dist/components/globe-3d/globe-3d.js +16 -4
- package/dist/components/horizontal-scroll-row/horizontal-scroll-row.js +2 -1
- package/dist/components/inline-input/inline-input.js +1 -1
- package/dist/components/interactive-timeline/interactive-timeline.js +8 -5
- package/dist/components/jarvis-dock/jarvis-dock.js +2 -2
- package/dist/components/key-concept/key-concept.js +2 -1
- package/dist/components/keyboard-shortcuts-help/keyboard-shortcuts-help.js +2 -1
- package/dist/components/knowledge-check/knowledge-check.js +2 -2
- package/dist/components/lang-provider/lang-provider.js +3 -3
- package/dist/components/learning-objectives/learning-objectives.js +2 -1
- package/dist/components/live-feed/live-feed.js +2 -2
- package/dist/components/map-2d/map-2d.js +1 -1
- package/dist/components/map-timeline/map-timeline.js +5 -5
- package/dist/components/market-treemap/market-treemap.js +2 -2
- package/dist/components/mdx-content/mdx-content.js +17 -8
- package/dist/components/metric-gauge/metric-gauge.js +1 -1
- package/dist/components/model-selector/model-selector.js +1 -1
- package/dist/components/multi-select/multi-select.js +1 -1
- package/dist/components/navbar-saas/navbar-saas.js +5 -5
- package/dist/components/number-input/number-input.js +1 -1
- package/dist/components/number-ticker/number-ticker.js +1 -1
- package/dist/components/object-card/object-card.js +1 -1
- package/dist/components/order-book/order-book.js +2 -2
- package/dist/components/overview-board/overview-board.js +1 -1
- package/dist/components/policy-delivery-panel/policy-delivery-panel.js +2 -2
- package/dist/components/profile-section/profile-section.js +2 -1
- package/dist/components/progress-card/progress-card.js +1 -1
- package/dist/components/progress-tracker/progress-tracker.js +17 -9
- package/dist/components/prompt-templates/prompt-templates.js +2 -2
- package/dist/components/quiz/quiz.js +3 -2
- package/dist/components/relationship-inspector/relationship-inspector.js +2 -2
- package/dist/components/routing-assignment-panel/routing-assignment-panel.js +2 -2
- package/dist/components/run-timeline/run-timeline.js +2 -2
- package/dist/components/scope-selector/scope-selector.js +1 -1
- package/dist/components/search-dialog/search-dialog.js +484 -51
- package/dist/components/share-dialog/share-dialog.js +2 -2
- package/dist/components/share-section/share-section.js +2 -1
- package/dist/components/sidebar/sidebar.js +30 -25
- package/dist/components/sidebar-toggle/sidebar-toggle.js +1 -1
- package/dist/components/slideshow/slideshow.js +3 -2
- package/dist/components/social-fab/social-fab.js +10 -10
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/spinner/unicode-spinner.js +4 -2
- package/dist/components/stat-card/stat-card.js +2 -2
- package/dist/components/status-board/status-board.js +13 -6
- package/dist/components/step-by-step/step-by-step.js +2 -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 +3 -1
- package/dist/components/tabs/tabs.js +26 -8
- package/dist/components/tags-input/tags-input.js +11 -3
- package/dist/components/terminal/terminal.js +11 -3
- package/dist/components/theme-toggle/theme-toggle.js +2 -2
- package/dist/components/thinking-block/thinking-block.js +2 -2
- package/dist/components/ticker-tape/ticker-tape.js +1 -1
- package/dist/components/timeline-scrubber/timeline-scrubber.js +2 -2
- package/dist/components/tldr-section/tldr-section.js +9 -7
- package/dist/components/tour/tour.js +1 -1
- package/dist/components/transaction-list/transaction-list.js +2 -2
- package/dist/components/tutorial-card/tutorial-card.js +1 -1
- package/dist/components/tutorial-complete/tutorial-complete.js +8 -6
- 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 +1 -1
- package/dist/components/viewport-bookmarks/viewport-bookmarks.js +2 -2
- package/dist/components/watchlist/watchlist.js +2 -1
- package/dist/components/world-breadcrumbs/world-breadcrumbs.js +2 -2
- package/dist/components/world-clock-bar/world-clock-bar.js +5 -4
- package/dist/components/zoom-hud/zoom-hud.js +1 -1
- package/dist/index.d.ts +113 -29
- package/package.json +3 -3
|
@@ -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
|
};
|
|
@@ -13,7 +13,7 @@ function PlatformButton({
|
|
|
13
13
|
onClick,
|
|
14
14
|
platform
|
|
15
15
|
}) {
|
|
16
|
-
const
|
|
16
|
+
const handleSelectPlatform = () => {
|
|
17
17
|
onClick(platform.key);
|
|
18
18
|
};
|
|
19
19
|
return /* @__PURE__ */ jsx(
|
|
@@ -26,7 +26,7 @@ function PlatformButton({
|
|
|
26
26
|
"hover:bg-accent hover:text-accent-foreground",
|
|
27
27
|
"focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"
|
|
28
28
|
),
|
|
29
|
-
onClick:
|
|
29
|
+
onClick: handleSelectPlatform,
|
|
30
30
|
type: "button",
|
|
31
31
|
children: platform.label
|
|
32
32
|
}
|
|
@@ -26,6 +26,7 @@ function buildShareUrl(platform, url, title) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
function ShareSection({
|
|
29
|
+
as: Heading = "h3",
|
|
29
30
|
buildUrl: buildUrlFunction = buildShareUrl,
|
|
30
31
|
platforms = defaultPlatforms,
|
|
31
32
|
shareOn,
|
|
@@ -34,7 +35,7 @@ function ShareSection({
|
|
|
34
35
|
url
|
|
35
36
|
}) {
|
|
36
37
|
return /* @__PURE__ */ jsxs("div", { className: "border-t border-border pt-6 mt-8", children: [
|
|
37
|
-
/* @__PURE__ */ jsx(
|
|
38
|
+
/* @__PURE__ */ jsx(Heading, { className: "text-lg font-semibold mb-4", children: shareTitle }),
|
|
38
39
|
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-3", children: platforms.map((platform) => /* @__PURE__ */ jsxs(
|
|
39
40
|
"a",
|
|
40
41
|
{
|