@vercel/geistdocs 1.2.2 → 1.2.3-canary.48fea3c

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.
Files changed (339) hide show
  1. package/dist/cli/index.js +3 -0
  2. package/dist/components/callout.d.ts +12 -0
  3. package/dist/components/callout.d.ts.map +1 -0
  4. package/dist/components/callout.js +7 -0
  5. package/dist/components/code-block-tabs.d.ts +7 -0
  6. package/dist/components/code-block-tabs.d.ts.map +1 -0
  7. package/dist/components/code-block-tabs.js +7 -0
  8. package/dist/components/code-block.d.ts +14 -0
  9. package/dist/components/code-block.d.ts.map +1 -0
  10. package/dist/components/code-block.js +45 -0
  11. package/dist/components/copy-prompt.d.ts +11 -0
  12. package/dist/components/copy-prompt.d.ts.map +1 -0
  13. package/dist/components/copy-prompt.js +58 -0
  14. package/dist/components/mermaid.d.ts +4 -0
  15. package/dist/components/mermaid.d.ts.map +1 -0
  16. package/dist/components/mermaid.js +44 -0
  17. package/dist/components/theme-aware-image.d.ts +12 -0
  18. package/dist/components/theme-aware-image.d.ts.map +1 -0
  19. package/dist/components/theme-aware-image.js +8 -0
  20. package/dist/components/video.d.ts +6 -0
  21. package/dist/components/video.d.ts.map +1 -0
  22. package/dist/components/video.js +3 -0
  23. package/dist/config.d.ts +71 -0
  24. package/dist/config.d.ts.map +1 -0
  25. package/dist/config.js +1 -0
  26. package/dist/controls.d.ts +15 -0
  27. package/dist/controls.d.ts.map +1 -0
  28. package/dist/controls.js +52 -0
  29. package/dist/internal/chat/context.d.ts +19 -0
  30. package/dist/internal/chat/context.d.ts.map +1 -0
  31. package/dist/internal/chat/context.js +36 -0
  32. package/dist/internal/chat/conversation.d.ts +10 -0
  33. package/dist/internal/chat/conversation.d.ts.map +1 -0
  34. package/dist/internal/chat/conversation.js +16 -0
  35. package/dist/internal/chat/copy-chat.d.ts +5 -0
  36. package/dist/internal/chat/copy-chat.d.ts.map +1 -0
  37. package/dist/internal/chat/copy-chat.js +35 -0
  38. package/dist/internal/chat/db.d.ts +13 -0
  39. package/dist/internal/chat/db.d.ts.map +1 -0
  40. package/dist/internal/chat/db.js +19 -0
  41. package/dist/internal/chat/message-metadata.d.ts +8 -0
  42. package/dist/internal/chat/message-metadata.d.ts.map +1 -0
  43. package/dist/internal/chat/message-metadata.js +29 -0
  44. package/dist/internal/chat/message.d.ts +11 -0
  45. package/dist/internal/chat/message.d.ts.map +1 -0
  46. package/dist/internal/chat/message.js +11 -0
  47. package/dist/internal/chat/prompt-input.d.ts +13 -0
  48. package/dist/internal/chat/prompt-input.d.ts.map +1 -0
  49. package/dist/internal/chat/prompt-input.js +39 -0
  50. package/dist/internal/chat/shell.d.ts +2 -0
  51. package/dist/internal/chat/shell.d.ts.map +1 -0
  52. package/dist/internal/chat/shell.js +194 -0
  53. package/dist/internal/chat/shimmer.d.ts +11 -0
  54. package/dist/internal/chat/shimmer.d.ts.map +1 -0
  55. package/dist/internal/chat/shimmer.js +18 -0
  56. package/dist/internal/chat/sources.d.ts +13 -0
  57. package/dist/internal/chat/sources.d.ts.map +1 -0
  58. package/dist/internal/chat/sources.js +9 -0
  59. package/dist/internal/chat/suggestion.d.ts +11 -0
  60. package/dist/internal/chat/suggestion.d.ts.map +1 -0
  61. package/dist/internal/chat/suggestion.js +12 -0
  62. package/dist/internal/cn.d.ts +3 -0
  63. package/dist/internal/cn.d.ts.map +1 -0
  64. package/dist/internal/cn.js +3 -0
  65. package/dist/internal/feedback-action.d.ts +14 -0
  66. package/dist/internal/feedback-action.d.ts.map +1 -0
  67. package/dist/internal/feedback-action.js +34 -0
  68. package/dist/internal/i18n.d.ts +6 -0
  69. package/dist/internal/i18n.d.ts.map +1 -0
  70. package/dist/internal/i18n.js +18 -0
  71. package/dist/internal/languages.d.ts +7 -0
  72. package/dist/internal/languages.d.ts.map +1 -0
  73. package/dist/internal/languages.js +18 -0
  74. package/dist/internal/not-implemented.d.ts +2 -0
  75. package/dist/internal/not-implemented.d.ts.map +1 -0
  76. package/dist/internal/not-implemented.js +4 -0
  77. package/dist/internal/page-actions-client.d.ts +13 -0
  78. package/dist/internal/page-actions-client.d.ts.map +1 -0
  79. package/dist/internal/page-actions-client.js +160 -0
  80. package/dist/internal/page-actions.d.ts +18 -0
  81. package/dist/internal/page-actions.d.ts.map +1 -0
  82. package/dist/internal/page-actions.js +4 -0
  83. package/dist/internal/provider-client.d.ts +9 -0
  84. package/dist/internal/provider-client.d.ts.map +1 -0
  85. package/dist/internal/provider-client.js +23 -0
  86. package/dist/internal/search.d.ts +5 -0
  87. package/dist/internal/search.d.ts.map +1 -0
  88. package/dist/internal/search.js +14 -0
  89. package/dist/internal/sidebar.d.ts +9 -0
  90. package/dist/internal/sidebar.d.ts.map +1 -0
  91. package/dist/internal/sidebar.js +38 -0
  92. package/dist/internal/table-of-contents.d.ts +9 -0
  93. package/dist/internal/table-of-contents.d.ts.map +1 -0
  94. package/dist/internal/table-of-contents.js +5 -0
  95. package/dist/internal/ui/button-group.d.ts +13 -0
  96. package/dist/internal/ui/button-group.d.ts.map +1 -0
  97. package/dist/internal/ui/button-group.js +26 -0
  98. package/dist/internal/ui/button.d.ts +12 -0
  99. package/dist/internal/ui/button.d.ts.map +1 -0
  100. package/dist/internal/ui/button.js +33 -0
  101. package/dist/internal/ui/card.d.ts +6 -0
  102. package/dist/internal/ui/card.d.ts.map +1 -0
  103. package/dist/internal/ui/card.js +14 -0
  104. package/dist/internal/ui/collapsible.d.ts +6 -0
  105. package/dist/internal/ui/collapsible.d.ts.map +1 -0
  106. package/dist/internal/ui/collapsible.js +12 -0
  107. package/dist/internal/ui/drawer.d.ts +6 -0
  108. package/dist/internal/ui/drawer.d.ts.map +1 -0
  109. package/dist/internal/ui/drawer.js +13 -0
  110. package/dist/internal/ui/dropdown-menu.d.ts +22 -0
  111. package/dist/internal/ui/dropdown-menu.d.ts.map +1 -0
  112. package/dist/internal/ui/dropdown-menu.js +41 -0
  113. package/dist/internal/ui/input-group.d.ts +15 -0
  114. package/dist/internal/ui/input-group.d.ts.map +1 -0
  115. package/dist/internal/ui/input-group.js +44 -0
  116. package/dist/internal/ui/input.d.ts +3 -0
  117. package/dist/internal/ui/input.d.ts.map +1 -0
  118. package/dist/internal/ui/input.js +5 -0
  119. package/dist/internal/ui/kbd.d.ts +4 -0
  120. package/dist/internal/ui/kbd.d.ts.map +1 -0
  121. package/dist/internal/ui/kbd.js +8 -0
  122. package/dist/internal/ui/popover.d.ts +6 -0
  123. package/dist/internal/ui/popover.d.ts.map +1 -0
  124. package/dist/internal/ui/popover.js +13 -0
  125. package/dist/internal/ui/scroll-area.d.ts +5 -0
  126. package/dist/internal/ui/scroll-area.d.ts.map +1 -0
  127. package/dist/internal/ui/scroll-area.js +12 -0
  128. package/dist/internal/ui/separator.d.ts +4 -0
  129. package/dist/internal/ui/separator.d.ts.map +1 -0
  130. package/dist/internal/ui/separator.js +7 -0
  131. package/dist/internal/ui/sheet.d.ts +10 -0
  132. package/dist/internal/ui/sheet.d.ts.map +1 -0
  133. package/dist/internal/ui/sheet.js +24 -0
  134. package/dist/internal/ui/sonner.d.ts +3 -0
  135. package/dist/internal/ui/sonner.d.ts.map +1 -0
  136. package/dist/internal/ui/sonner.js +20 -0
  137. package/dist/internal/ui/spinner.d.ts +3 -0
  138. package/dist/internal/ui/spinner.d.ts.map +1 -0
  139. package/dist/internal/ui/spinner.js +6 -0
  140. package/dist/internal/ui/textarea.d.ts +3 -0
  141. package/dist/internal/ui/textarea.d.ts.map +1 -0
  142. package/dist/internal/ui/textarea.js +5 -0
  143. package/dist/internal/ui/tooltip.d.ts +7 -0
  144. package/dist/internal/ui/tooltip.d.ts.map +1 -0
  145. package/dist/internal/ui/tooltip.js +16 -0
  146. package/dist/internal/use-mobile.d.ts +2 -0
  147. package/dist/internal/use-mobile.d.ts.map +1 -0
  148. package/dist/internal/use-mobile.js +16 -0
  149. package/dist/layout.d.ts +14 -0
  150. package/dist/layout.d.ts.map +1 -0
  151. package/dist/layout.js +31 -0
  152. package/dist/mdx.d.ts +36 -0
  153. package/dist/mdx.d.ts.map +1 -0
  154. package/dist/mdx.js +74 -0
  155. package/dist/pages/docs.d.ts +77 -0
  156. package/dist/pages/docs.d.ts.map +1 -0
  157. package/dist/pages/docs.js +92 -0
  158. package/dist/proxy.d.ts +37 -0
  159. package/dist/proxy.d.ts.map +1 -0
  160. package/dist/proxy.js +162 -0
  161. package/dist/routes/chat.d.ts +14 -0
  162. package/dist/routes/chat.d.ts.map +1 -0
  163. package/dist/routes/chat.js +242 -0
  164. package/dist/routes/llms.d.ts +51 -0
  165. package/dist/routes/llms.d.ts.map +1 -0
  166. package/dist/routes/llms.js +59 -0
  167. package/dist/routes/search.d.ts +11 -0
  168. package/dist/routes/search.d.ts.map +1 -0
  169. package/dist/routes/search.js +74 -0
  170. package/dist/routes/sitemap.d.ts +44 -0
  171. package/dist/routes/sitemap.d.ts.map +1 -0
  172. package/dist/routes/sitemap.js +168 -0
  173. package/dist/sidebar.d.ts +11 -0
  174. package/dist/sidebar.d.ts.map +1 -0
  175. package/dist/sidebar.js +16 -0
  176. package/dist/source.d.ts +174 -0
  177. package/dist/source.d.ts.map +1 -0
  178. package/dist/source.js +129 -0
  179. package/dist/versions.d.ts +15 -0
  180. package/dist/versions.d.ts.map +1 -0
  181. package/dist/versions.js +52 -0
  182. package/package.json +141 -9
  183. package/styles.css +193 -0
  184. package/template/_gitignore +29 -0
  185. package/template/app/[lang]/(home)/components/centered-section.tsx +26 -0
  186. package/template/app/[lang]/(home)/components/cta.tsx +19 -0
  187. package/template/app/[lang]/(home)/components/hero.tsx +27 -0
  188. package/template/app/[lang]/(home)/components/one-two-section.tsx +25 -0
  189. package/template/app/[lang]/(home)/components/templates.tsx +50 -0
  190. package/template/app/[lang]/(home)/components/text-grid-section.tsx +20 -0
  191. package/template/app/[lang]/(home)/layout.tsx +14 -0
  192. package/template/app/[lang]/(home)/page.tsx +126 -0
  193. package/template/app/[lang]/docs/[[...slug]]/page.tsx +19 -0
  194. package/template/app/[lang]/docs/layout.tsx +14 -0
  195. package/template/app/[lang]/layout.tsx +29 -0
  196. package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +7 -0
  197. package/template/app/[lang]/llms.txt/route.ts +6 -0
  198. package/template/app/[lang]/og/[...slug]/background.png +0 -0
  199. package/template/app/[lang]/og/[...slug]/geist-sans-regular.ttf +0 -0
  200. package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
  201. package/template/app/[lang]/og/[...slug]/route.tsx +95 -0
  202. package/template/app/[lang]/rss.xml/route.ts +52 -0
  203. package/template/app/[lang]/sitemap.md/route.ts +9 -0
  204. package/template/app/actions/feedback/emotions.ts +18 -0
  205. package/template/app/actions/feedback/index.ts +45 -0
  206. package/template/app/api/chat/route.ts +8 -0
  207. package/template/app/api/search/route.ts +5 -0
  208. package/template/app/favicon.ico +0 -0
  209. package/template/app/global.css +2 -0
  210. package/template/app/robots.ts +14 -0
  211. package/template/app/sitemap.ts +36 -0
  212. package/template/app/styles/geistdocs.css +554 -0
  213. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right-small.tsx +35 -0
  214. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-arrow-up-right.tsx +27 -0
  215. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-check.tsx +27 -0
  216. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-down-small.tsx +30 -0
  217. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-chevron-right.tsx +27 -0
  218. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy.tsx +27 -0
  219. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-file-text.tsx +25 -0
  220. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-menu-alt.tsx +27 -0
  221. package/template/components/geistcn-fallbacks/geistcn-assets/icons/icon-slash-forward.tsx +36 -0
  222. package/template/components/geistcn-fallbacks/geistcn-assets/icons/index.tsx +11 -0
  223. package/template/components/geistcn-fallbacks/geistcn-assets/logos/index.tsx +14 -0
  224. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-elements.tsx +29 -0
  225. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-ai-sdk.tsx +38 -0
  226. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-chat-sdk.tsx +42 -0
  227. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-flags-sdk.tsx +42 -0
  228. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-icon-vercel.tsx +31 -0
  229. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-streamdown.tsx +29 -0
  230. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-vercel-oss.tsx +24 -0
  231. package/template/components/geistcn-fallbacks/geistcn-assets/logos/logo-workflow-sdk.tsx +73 -0
  232. package/template/components/geistdocs/callout.tsx +40 -0
  233. package/template/components/geistdocs/chat.tsx +24 -0
  234. package/template/components/geistdocs/code-block-tabs.tsx +61 -0
  235. package/template/components/geistdocs/code-block.tsx +134 -0
  236. package/template/components/geistdocs/copy-page.tsx +27 -0
  237. package/template/components/geistdocs/desktop-menu.tsx +52 -0
  238. package/template/components/geistdocs/docs-layout.tsx +20 -0
  239. package/template/components/geistdocs/docs-page.tsx +35 -0
  240. package/template/components/geistdocs/edit-source.tsx +30 -0
  241. package/template/components/geistdocs/feedback.tsx +139 -0
  242. package/template/components/geistdocs/footer.tsx +30 -0
  243. package/template/components/geistdocs/github-button.tsx +19 -0
  244. package/template/components/geistdocs/home-layout.tsx +46 -0
  245. package/template/components/geistdocs/icons.tsx +13 -0
  246. package/template/components/geistdocs/installer.tsx +58 -0
  247. package/template/components/geistdocs/language-selector.tsx +3 -0
  248. package/template/components/geistdocs/mdx-components.tsx +5 -0
  249. package/template/components/geistdocs/mermaid.tsx +68 -0
  250. package/template/components/geistdocs/mobile-docs-bar.tsx +77 -0
  251. package/template/components/geistdocs/mobile-menu.tsx +150 -0
  252. package/template/components/geistdocs/navbar-logo.tsx +124 -0
  253. package/template/components/geistdocs/navbar.tsx +22 -0
  254. package/template/components/geistdocs/provider.tsx +31 -0
  255. package/template/components/geistdocs/rss-button.tsx +10 -0
  256. package/template/components/geistdocs/scroll-top.tsx +21 -0
  257. package/template/components/geistdocs/search.tsx +17 -0
  258. package/template/components/geistdocs/sidebar.tsx +128 -0
  259. package/template/components/geistdocs/theme-aware-image.tsx +22 -0
  260. package/template/components/geistdocs/theme-toggle.tsx +3 -0
  261. package/template/components/geistdocs/video.tsx +16 -0
  262. package/template/components/ui/badge.tsx +46 -0
  263. package/template/components/ui/button-group.tsx +83 -0
  264. package/template/components/ui/button.tsx +60 -0
  265. package/template/components/ui/card.tsx +92 -0
  266. package/template/components/ui/collapsible.tsx +33 -0
  267. package/template/components/ui/command-prompt.tsx +488 -0
  268. package/template/components/ui/command.tsx +184 -0
  269. package/template/components/ui/dialog.tsx +143 -0
  270. package/template/components/ui/drawer.tsx +135 -0
  271. package/template/components/ui/dropdown-menu.tsx +257 -0
  272. package/template/components/ui/hover-card.tsx +44 -0
  273. package/template/components/ui/input-group.tsx +170 -0
  274. package/template/components/ui/input.tsx +21 -0
  275. package/template/components/ui/kbd.tsx +28 -0
  276. package/template/components/ui/navigation-menu.tsx +192 -0
  277. package/template/components/ui/popover.tsx +48 -0
  278. package/template/components/ui/scroll-area.tsx +58 -0
  279. package/template/components/ui/select.tsx +187 -0
  280. package/template/components/ui/separator.tsx +28 -0
  281. package/template/components/ui/sheet.tsx +139 -0
  282. package/template/components/ui/sonner.tsx +40 -0
  283. package/template/components/ui/spinner.tsx +16 -0
  284. package/template/components/ui/textarea.tsx +18 -0
  285. package/template/components/ui/tooltip.tsx +61 -0
  286. package/template/components.json +22 -0
  287. package/template/content/docs/ask-ai.cn.mdx +85 -0
  288. package/template/content/docs/ask-ai.mdx +89 -0
  289. package/template/content/docs/configuration.cn.mdx +155 -0
  290. package/template/content/docs/configuration.mdx +200 -0
  291. package/template/content/docs/deployment.cn.mdx +34 -0
  292. package/template/content/docs/deployment.mdx +40 -0
  293. package/template/content/docs/edit-on-github.cn.mdx +47 -0
  294. package/template/content/docs/edit-on-github.mdx +51 -0
  295. package/template/content/docs/env.cn.mdx +25 -0
  296. package/template/content/docs/env.mdx +29 -0
  297. package/template/content/docs/feedback.cn.mdx +85 -0
  298. package/template/content/docs/feedback.mdx +89 -0
  299. package/template/content/docs/getting-started.cn.mdx +86 -0
  300. package/template/content/docs/getting-started.mdx +107 -0
  301. package/template/content/docs/index.cn.mdx +57 -0
  302. package/template/content/docs/index.mdx +92 -0
  303. package/template/content/docs/internationalization.cn.mdx +111 -0
  304. package/template/content/docs/internationalization.mdx +122 -0
  305. package/template/content/docs/llms-txt.cn.mdx +72 -0
  306. package/template/content/docs/llms-txt.mdx +85 -0
  307. package/template/content/docs/md.cn.mdx +65 -0
  308. package/template/content/docs/md.mdx +81 -0
  309. package/template/content/docs/meta.json +23 -0
  310. package/template/content/docs/open-in-chat.cn.mdx +78 -0
  311. package/template/content/docs/open-in-chat.mdx +80 -0
  312. package/template/content/docs/provider.cn.mdx +70 -0
  313. package/template/content/docs/provider.mdx +74 -0
  314. package/template/content/docs/proxy.cn.mdx +96 -0
  315. package/template/content/docs/proxy.mdx +124 -0
  316. package/template/content/docs/rss.cn.mdx +104 -0
  317. package/template/content/docs/rss.mdx +108 -0
  318. package/template/content/docs/syntax.cn.mdx +416 -0
  319. package/template/content/docs/syntax.mdx +411 -0
  320. package/template/content/docs/theme-aware-image.mdx +57 -0
  321. package/template/content/docs/versioned-docs.cn.mdx +117 -0
  322. package/template/content/docs/versioned-docs.mdx +181 -0
  323. package/template/geistdocs.tsx +51 -0
  324. package/template/hooks/geistdocs/use-sidebar.ts +13 -0
  325. package/template/hooks/use-mobile.ts +19 -0
  326. package/template/lib/geistdocs/config.tsx +27 -0
  327. package/template/lib/geistdocs/fonts.ts +18 -0
  328. package/template/lib/geistdocs/i18n.ts +13 -0
  329. package/template/lib/geistdocs/md-tracking.ts +56 -0
  330. package/template/lib/geistdocs/source.ts +12 -0
  331. package/template/lib/utils.ts +6 -0
  332. package/template/next.config.ts +22 -0
  333. package/template/package.json +63 -0
  334. package/template/postcss.config.mjs +5 -0
  335. package/template/proxy.ts +18 -0
  336. package/template/source.config.ts +62 -0
  337. package/template/tsconfig.json +37 -0
  338. package/dist/index.js +0 -2
  339. /package/dist/{index.d.ts → cli/index.d.ts} +0 -0
@@ -0,0 +1,488 @@
1
+ "use client";
2
+
3
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
4
+ import {
5
+ Children,
6
+ type ComponentPropsWithoutRef,
7
+ createContext,
8
+ isValidElement,
9
+ type JSX,
10
+ type ReactNode,
11
+ useContext,
12
+ useEffect,
13
+ useLayoutEffect,
14
+ useRef,
15
+ useState,
16
+ } from "react";
17
+ import { IconCheck } from "@/components/geistcn-fallbacks/geistcn-assets/icons/icon-check";
18
+ import { IconCopy } from "@/components/geistcn-fallbacks/geistcn-assets/icons/icon-copy";
19
+ import { cn } from "@/lib/utils";
20
+
21
+ type CommandPromptContextValue = {
22
+ value: string;
23
+ setValue: (value: string) => void;
24
+ copied: boolean;
25
+ copyActiveValue: () => void;
26
+ activeCopyValue: string;
27
+ setActiveCopyValue: (value: string) => void;
28
+ commandWidth?: number;
29
+ setCommandWidth: (value: number | undefined) => void;
30
+ isOverflowing: boolean;
31
+ setIsOverflowing: (value: boolean) => void;
32
+ canShowGradient: boolean;
33
+ setCanShowGradient: (value: boolean) => void;
34
+ };
35
+
36
+ const CommandPromptContext = createContext<CommandPromptContextValue | null>(
37
+ null
38
+ );
39
+
40
+ function useCommandPromptContext(component: string) {
41
+ const context = useContext(CommandPromptContext);
42
+
43
+ if (!context) {
44
+ throw new Error(`${component} must be used within CommandPrompt.Root`);
45
+ }
46
+
47
+ return context;
48
+ }
49
+
50
+ type CommandPromptRootProps = Omit<
51
+ ComponentPropsWithoutRef<"div">,
52
+ "onChange"
53
+ > & {
54
+ value?: string;
55
+ defaultValue?: string;
56
+ onValueChange?: (value: string) => void;
57
+ };
58
+
59
+ export function CommandPromptRoot({
60
+ value: valueProp,
61
+ defaultValue,
62
+ onValueChange,
63
+ className,
64
+ children,
65
+ ...props
66
+ }: CommandPromptRootProps): JSX.Element {
67
+ const [uncontrolledValue, setUncontrolledValue] = useState(
68
+ defaultValue ?? ""
69
+ );
70
+ const [copied, setCopied] = useState(false);
71
+ const [activeCopyValue, setActiveCopyValue] = useState("");
72
+ const [commandWidth, setCommandWidth] = useState<number>();
73
+ const [isOverflowing, setIsOverflowing] = useState(false);
74
+ const [canShowGradient, setCanShowGradient] = useState(true);
75
+ const timeoutRef = useRef<ReturnType<typeof setTimeout>>(null);
76
+ const value = valueProp ?? uncontrolledValue;
77
+
78
+ useEffect(() => {
79
+ return () => {
80
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
81
+ };
82
+ }, []);
83
+
84
+ function resetCopiedState() {
85
+ setCopied(false);
86
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
87
+ }
88
+
89
+ function setValue(nextValue: string) {
90
+ if (valueProp === undefined) {
91
+ setUncontrolledValue(nextValue);
92
+ }
93
+
94
+ resetCopiedState();
95
+ onValueChange?.(nextValue);
96
+ }
97
+
98
+ function copyActiveValue() {
99
+ if (!activeCopyValue) return;
100
+
101
+ void navigator.clipboard.writeText(activeCopyValue);
102
+ setCopied(true);
103
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
104
+ timeoutRef.current = setTimeout(() => setCopied(false), 1000);
105
+ }
106
+
107
+ return (
108
+ <CommandPromptContext.Provider
109
+ value={{
110
+ value,
111
+ setValue,
112
+ copied,
113
+ copyActiveValue,
114
+ activeCopyValue,
115
+ setActiveCopyValue,
116
+ commandWidth,
117
+ setCommandWidth,
118
+ isOverflowing,
119
+ setIsOverflowing,
120
+ canShowGradient,
121
+ setCanShowGradient,
122
+ }}
123
+ >
124
+ <div
125
+ className={cn("w-full flex items-center flex-col gap-2", className)}
126
+ {...props}
127
+ >
128
+ {children}
129
+ </div>
130
+ </CommandPromptContext.Provider>
131
+ );
132
+ }
133
+
134
+ export function CommandPromptList({
135
+ className,
136
+ ...props
137
+ }: ComponentPropsWithoutRef<"div">): JSX.Element {
138
+ return <div className={cn("flex items-center", className)} {...props} />;
139
+ }
140
+
141
+ type CommandPromptTriggerProps = ComponentPropsWithoutRef<"button"> & {
142
+ value: string;
143
+ };
144
+
145
+ export function CommandPromptTrigger({
146
+ value,
147
+ className,
148
+ onClick,
149
+ children,
150
+ ...props
151
+ }: CommandPromptTriggerProps): JSX.Element {
152
+ const context = useCommandPromptContext("CommandPrompt.Trigger");
153
+ const active = context.value === value;
154
+
155
+ return (
156
+ <button
157
+ aria-pressed={active}
158
+ className={cn(
159
+ "cursor-pointer text-gray-900 hover:text-gray-1000 px-3 py-2",
160
+ "text-label-13! font-medium! touch-manipulation border-none bg-transparent rounded-sm",
161
+ "outline outline-2 outline-offset-2 outline-transparent focus-visible:outline-[var(--ds-focus-color)]",
162
+ "text-gray-900 data-[active]:text-gray-1000 data-[active]:font-medium",
163
+ "flex gap-1.5 items-center whitespace-nowrap",
164
+ className
165
+ )}
166
+ data-active={active ? "" : undefined}
167
+ onClick={(event) => {
168
+ onClick?.(event);
169
+ if (event.defaultPrevented) return;
170
+ context.setValue(value);
171
+ }}
172
+ type="button"
173
+ {...props}
174
+ >
175
+ {children}
176
+ </button>
177
+ );
178
+ }
179
+
180
+ export function CommandPromptTriggerDivider({
181
+ className,
182
+ ...props
183
+ }: ComponentPropsWithoutRef<"div">): JSX.Element {
184
+ return (
185
+ <div
186
+ aria-hidden
187
+ className={cn("w-px h-3 bg-gray-400", className)}
188
+ {...props}
189
+ />
190
+ );
191
+ }
192
+
193
+ export function CommandPromptSurface({
194
+ className,
195
+ onClick,
196
+ children,
197
+ }: {
198
+ className?: string;
199
+ children: ReactNode;
200
+ onClick?: ComponentPropsWithoutRef<"div">["onClick"];
201
+ }): JSX.Element {
202
+ const context = useCommandPromptContext("CommandPrompt.Surface");
203
+ const shouldReduceMotion = useReducedMotion();
204
+
205
+ return (
206
+ <motion.div
207
+ className={cn(
208
+ "relative flex items-center group gap-1 material-small transition-colors pl-5 py-2 pr-3 max-w-[calc(100vw-48px)] rounded-full",
209
+ className
210
+ )}
211
+ layout
212
+ onClick={(event) => {
213
+ onClick?.(event);
214
+ if (event.defaultPrevented) return;
215
+ if (window.getSelection()?.toString()) return;
216
+ context.copyActiveValue();
217
+ }}
218
+ transition={
219
+ shouldReduceMotion
220
+ ? { duration: 0 }
221
+ : { type: "spring", bounce: 0, duration: 0.4 }
222
+ }
223
+ >
224
+ {children}
225
+ </motion.div>
226
+ );
227
+ }
228
+
229
+ export function CommandPromptPrefix({
230
+ className,
231
+ ...props
232
+ }: ComponentPropsWithoutRef<"span">): JSX.Element {
233
+ return (
234
+ <span
235
+ className={cn("block text-label-16-mono! text-gray-500 pr-1", className)}
236
+ {...props}
237
+ />
238
+ );
239
+ }
240
+
241
+ type CommandPromptContentProps = {
242
+ value: string;
243
+ copyValue?: string;
244
+ className?: string;
245
+ children: ReactNode;
246
+ };
247
+
248
+ export function CommandPromptViewport({
249
+ className,
250
+ children,
251
+ }: {
252
+ className?: string;
253
+ children: ReactNode;
254
+ }): JSX.Element {
255
+ const context = useCommandPromptContext("CommandPrompt.Viewport");
256
+ const shouldReduceMotion = useReducedMotion();
257
+ const {
258
+ commandWidth,
259
+ canShowGradient,
260
+ isOverflowing,
261
+ setActiveCopyValue,
262
+ setCanShowGradient,
263
+ setCommandWidth,
264
+ setIsOverflowing,
265
+ } = context;
266
+ const measureRef = useRef<HTMLSpanElement>(null);
267
+ const scrollObserverCleanup = useRef<(() => void) | null>(null);
268
+ const items = Children.toArray(children)
269
+ .filter((child): child is React.ReactElement<CommandPromptContentProps> =>
270
+ isValidElement<CommandPromptContentProps>(child)
271
+ )
272
+ .map((child) => child.props);
273
+ const activeItem = items.find((item) => item.value === context.value);
274
+ const command = activeItem?.children ?? null;
275
+ const fallbackCopyValue =
276
+ typeof command === "string" || typeof command === "number"
277
+ ? String(command)
278
+ : Children.toArray(command)
279
+ .filter(
280
+ (child): child is string | number =>
281
+ typeof child === "string" || typeof child === "number"
282
+ )
283
+ .join("");
284
+ const copyValue = activeItem?.copyValue ?? fallbackCopyValue;
285
+
286
+ useLayoutEffect(() => {
287
+ setIsOverflowing(false);
288
+ setCanShowGradient(Boolean(shouldReduceMotion));
289
+ }, [copyValue, setCanShowGradient, setIsOverflowing, shouldReduceMotion]);
290
+
291
+ useEffect(() => {
292
+ setActiveCopyValue(copyValue);
293
+
294
+ return () => {
295
+ setIsOverflowing(false);
296
+ scrollObserverCleanup.current?.();
297
+ scrollObserverCleanup.current = null;
298
+ };
299
+ }, [copyValue, setActiveCopyValue, setIsOverflowing]);
300
+
301
+ useLayoutEffect(() => {
302
+ if (!measureRef.current) return;
303
+
304
+ setCommandWidth(measureRef.current.getBoundingClientRect().width);
305
+ }, [command, copyValue, setCommandWidth]);
306
+
307
+ return (
308
+ <motion.span
309
+ animate={
310
+ commandWidth === undefined
311
+ ? undefined
312
+ : { width: shouldReduceMotion ? "auto" : commandWidth }
313
+ }
314
+ className={cn(
315
+ "relative block min-w-0 overflow-hidden text-label-14-mono! text-gray-1000",
316
+ className
317
+ )}
318
+ initial={false}
319
+ onAnimationComplete={() => {
320
+ setCanShowGradient(true);
321
+ }}
322
+ transition={
323
+ shouldReduceMotion
324
+ ? { duration: 0 }
325
+ : { type: "spring", bounce: 0, duration: 0.4 }
326
+ }
327
+ >
328
+ <span
329
+ aria-hidden
330
+ className="pointer-events-none invisible absolute whitespace-nowrap"
331
+ ref={measureRef}
332
+ >
333
+ {command}
334
+ </span>
335
+ <AnimatePresence initial={false} mode="wait">
336
+ {Children.toArray(children).map((child) => {
337
+ if (!isValidElement<CommandPromptContentProps>(child)) return null;
338
+ if (child.props.value !== context.value) return null;
339
+
340
+ return (
341
+ <motion.span
342
+ animate={{ opacity: 1, filter: "blur(0px)" }}
343
+ className={cn(
344
+ "block whitespace-nowrap min-w-0 py-2",
345
+ canShowGradient && isOverflowing
346
+ ? "overflow-x-auto"
347
+ : "overflow-x-hidden",
348
+ child.props.className
349
+ )}
350
+ exit={{ opacity: 0, filter: "blur(1px)" }}
351
+ initial={{ opacity: 0, filter: "blur(1px)" }}
352
+ key={copyValue}
353
+ ref={(element) => {
354
+ scrollObserverCleanup.current?.();
355
+ scrollObserverCleanup.current = null;
356
+ if (!element) return;
357
+
358
+ const checkOverflow = () => {
359
+ setIsOverflowing(element.scrollWidth > element.clientWidth);
360
+ };
361
+
362
+ checkOverflow();
363
+ const observer = new ResizeObserver(checkOverflow);
364
+ observer.observe(element);
365
+ scrollObserverCleanup.current = () => observer.disconnect();
366
+ }}
367
+ transition={
368
+ shouldReduceMotion ? { duration: 0 } : { duration: 0.15 }
369
+ }
370
+ >
371
+ {child.props.children}
372
+ </motion.span>
373
+ );
374
+ })}
375
+ </AnimatePresence>
376
+ <AnimatePresence>
377
+ {canShowGradient && isOverflowing && (
378
+ <motion.span
379
+ animate={{ opacity: 1 }}
380
+ aria-hidden
381
+ className="pointer-events-none block z-10 absolute right-0 bg-gradient-to-r from-transparent to-background-100 top-0 bottom-0 w-4"
382
+ exit={{ opacity: 0 }}
383
+ initial={{ opacity: 0 }}
384
+ transition={
385
+ shouldReduceMotion ? { duration: 0 } : { duration: 0.2 }
386
+ }
387
+ />
388
+ )}
389
+ </AnimatePresence>
390
+ </motion.span>
391
+ );
392
+ }
393
+
394
+ export function CommandPromptContent(
395
+ _props: CommandPromptContentProps
396
+ ): JSX.Element | null {
397
+ return null;
398
+ }
399
+
400
+ export function CommandPromptCopy({
401
+ className,
402
+ onClick,
403
+ ...props
404
+ }: ComponentPropsWithoutRef<"button">): JSX.Element {
405
+ const context = useCommandPromptContext("CommandPrompt.Copy");
406
+ const shouldReduceMotion = useReducedMotion();
407
+
408
+ return (
409
+ <button
410
+ aria-label={context.copied ? "Copied" : "Copy command"}
411
+ className={cn(
412
+ "text-gray-1000 rounded-full border-none bg-transparent shrink-0 cursor-pointer relative size-8 flex items-center justify-center translate-x-0.5",
413
+ "group-hover:bg-gray-alpha-100 hover:!bg-gray-alpha-200 transition-colors touch-manipulation",
414
+ "outline-2 outline-offset-2 outline-transparent focus-visible:outline-[var(--ds-focus-color)]",
415
+ className
416
+ )}
417
+ onClick={(event) => {
418
+ onClick?.(event);
419
+ if (event.defaultPrevented) return;
420
+ event.stopPropagation();
421
+ context.copyActiveValue();
422
+ }}
423
+ type="button"
424
+ {...props}
425
+ >
426
+ <AnimatePresence initial={false}>
427
+ {!context.copied && (
428
+ <motion.span
429
+ animate={{
430
+ opacity: 1,
431
+ transform: "scale(1)",
432
+ filter: "blur(0px)",
433
+ }}
434
+ className="absolute inset-0 flex items-center justify-center"
435
+ exit={{
436
+ opacity: 0,
437
+ transform: "scale(0.5)",
438
+ filter: "blur(1px)",
439
+ }}
440
+ initial={{
441
+ opacity: 0,
442
+ transform: "scale(0.5)",
443
+ filter: "blur(1px)",
444
+ }}
445
+ key="copy"
446
+ transition={
447
+ shouldReduceMotion
448
+ ? { duration: 0 }
449
+ : { duration: 0.2, ease: [0.23, 1, 0.32, 1] }
450
+ }
451
+ >
452
+ <IconCopy className="block" size={16} />
453
+ </motion.span>
454
+ )}
455
+ </AnimatePresence>
456
+ <AnimatePresence initial={false}>
457
+ {context.copied && (
458
+ <motion.span
459
+ animate={{
460
+ opacity: 1,
461
+ transform: "scale(1)",
462
+ filter: "blur(0px)",
463
+ }}
464
+ className="absolute inset-0 flex items-center justify-center"
465
+ exit={{
466
+ opacity: 0,
467
+ transform: "scale(0.5)",
468
+ filter: "blur(1px)",
469
+ }}
470
+ initial={{
471
+ opacity: 0,
472
+ transform: "scale(0.5)",
473
+ filter: "blur(1px)",
474
+ }}
475
+ key="check"
476
+ transition={
477
+ shouldReduceMotion
478
+ ? { duration: 0 }
479
+ : { duration: 0.2, ease: [0.23, 1, 0.32, 1] }
480
+ }
481
+ >
482
+ <IconCheck className="block" size={16} />
483
+ </motion.span>
484
+ )}
485
+ </AnimatePresence>
486
+ </button>
487
+ );
488
+ }
@@ -0,0 +1,184 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Command as CommandPrimitive } from "cmdk"
5
+ import { SearchIcon } from "lucide-react"
6
+
7
+ import { cn } from "@/lib/utils"
8
+ import {
9
+ Dialog,
10
+ DialogContent,
11
+ DialogDescription,
12
+ DialogHeader,
13
+ DialogTitle,
14
+ } from "@/components/ui/dialog"
15
+
16
+ function Command({
17
+ className,
18
+ ...props
19
+ }: React.ComponentProps<typeof CommandPrimitive>) {
20
+ return (
21
+ <CommandPrimitive
22
+ data-slot="command"
23
+ className={cn(
24
+ "bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
25
+ className
26
+ )}
27
+ {...props}
28
+ />
29
+ )
30
+ }
31
+
32
+ function CommandDialog({
33
+ title = "Command Palette",
34
+ description = "Search for a command to run...",
35
+ children,
36
+ className,
37
+ showCloseButton = true,
38
+ ...props
39
+ }: React.ComponentProps<typeof Dialog> & {
40
+ title?: string
41
+ description?: string
42
+ className?: string
43
+ showCloseButton?: boolean
44
+ }) {
45
+ return (
46
+ <Dialog {...props}>
47
+ <DialogHeader className="sr-only">
48
+ <DialogTitle>{title}</DialogTitle>
49
+ <DialogDescription>{description}</DialogDescription>
50
+ </DialogHeader>
51
+ <DialogContent
52
+ className={cn("overflow-hidden p-0", className)}
53
+ showCloseButton={showCloseButton}
54
+ >
55
+ <Command className="[&_[cmdk-group-heading]]:text-muted-foreground **:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
56
+ {children}
57
+ </Command>
58
+ </DialogContent>
59
+ </Dialog>
60
+ )
61
+ }
62
+
63
+ function CommandInput({
64
+ className,
65
+ ...props
66
+ }: React.ComponentProps<typeof CommandPrimitive.Input>) {
67
+ return (
68
+ <div
69
+ data-slot="command-input-wrapper"
70
+ className="flex h-9 items-center gap-2 border-b px-3"
71
+ >
72
+ <SearchIcon className="size-4 shrink-0 opacity-50" />
73
+ <CommandPrimitive.Input
74
+ data-slot="command-input"
75
+ className={cn(
76
+ "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
77
+ className
78
+ )}
79
+ {...props}
80
+ />
81
+ </div>
82
+ )
83
+ }
84
+
85
+ function CommandList({
86
+ className,
87
+ ...props
88
+ }: React.ComponentProps<typeof CommandPrimitive.List>) {
89
+ return (
90
+ <CommandPrimitive.List
91
+ data-slot="command-list"
92
+ className={cn(
93
+ "max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
94
+ className
95
+ )}
96
+ {...props}
97
+ />
98
+ )
99
+ }
100
+
101
+ function CommandEmpty({
102
+ ...props
103
+ }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
104
+ return (
105
+ <CommandPrimitive.Empty
106
+ data-slot="command-empty"
107
+ className="py-6 text-center text-sm"
108
+ {...props}
109
+ />
110
+ )
111
+ }
112
+
113
+ function CommandGroup({
114
+ className,
115
+ ...props
116
+ }: React.ComponentProps<typeof CommandPrimitive.Group>) {
117
+ return (
118
+ <CommandPrimitive.Group
119
+ data-slot="command-group"
120
+ className={cn(
121
+ "text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
122
+ className
123
+ )}
124
+ {...props}
125
+ />
126
+ )
127
+ }
128
+
129
+ function CommandSeparator({
130
+ className,
131
+ ...props
132
+ }: React.ComponentProps<typeof CommandPrimitive.Separator>) {
133
+ return (
134
+ <CommandPrimitive.Separator
135
+ data-slot="command-separator"
136
+ className={cn("bg-border -mx-1 h-px", className)}
137
+ {...props}
138
+ />
139
+ )
140
+ }
141
+
142
+ function CommandItem({
143
+ className,
144
+ ...props
145
+ }: React.ComponentProps<typeof CommandPrimitive.Item>) {
146
+ return (
147
+ <CommandPrimitive.Item
148
+ data-slot="command-item"
149
+ className={cn(
150
+ "data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
151
+ className
152
+ )}
153
+ {...props}
154
+ />
155
+ )
156
+ }
157
+
158
+ function CommandShortcut({
159
+ className,
160
+ ...props
161
+ }: React.ComponentProps<"span">) {
162
+ return (
163
+ <span
164
+ data-slot="command-shortcut"
165
+ className={cn(
166
+ "text-muted-foreground ml-auto text-xs tracking-widest",
167
+ className
168
+ )}
169
+ {...props}
170
+ />
171
+ )
172
+ }
173
+
174
+ export {
175
+ Command,
176
+ CommandDialog,
177
+ CommandInput,
178
+ CommandList,
179
+ CommandEmpty,
180
+ CommandGroup,
181
+ CommandItem,
182
+ CommandShortcut,
183
+ CommandSeparator,
184
+ }