@vercel/geistdocs 1.2.2 → 1.2.3-canary.a12a9c6
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/dist/assets/icons/icon-arrow-up-right-small.d.ts +8 -0
- package/dist/assets/icons/icon-arrow-up-right-small.d.ts.map +1 -0
- package/dist/assets/icons/icon-arrow-up-right-small.js +4 -0
- package/dist/assets/icons/icon-arrow-up-right.d.ts +5 -0
- package/dist/assets/icons/icon-arrow-up-right.d.ts.map +1 -0
- package/dist/assets/icons/icon-arrow-up-right.js +4 -0
- package/dist/assets/icons/icon-check.d.ts +5 -0
- package/dist/assets/icons/icon-check.d.ts.map +1 -0
- package/dist/assets/icons/icon-check.js +4 -0
- package/dist/assets/icons/icon-chevron-down-small.d.ts +8 -0
- package/dist/assets/icons/icon-chevron-down-small.d.ts.map +1 -0
- package/dist/assets/icons/icon-chevron-down-small.js +7 -0
- package/dist/assets/icons/icon-chevron-right.d.ts +5 -0
- package/dist/assets/icons/icon-chevron-right.d.ts.map +1 -0
- package/dist/assets/icons/icon-chevron-right.js +4 -0
- package/dist/assets/icons/icon-copy.d.ts +5 -0
- package/dist/assets/icons/icon-copy.d.ts.map +1 -0
- package/dist/assets/icons/icon-copy.js +4 -0
- package/dist/assets/icons/icon-file-text.d.ts +5 -0
- package/dist/assets/icons/icon-file-text.d.ts.map +1 -0
- package/dist/assets/icons/icon-file-text.js +4 -0
- package/dist/assets/icons/icon-menu-alt.d.ts +5 -0
- package/dist/assets/icons/icon-menu-alt.d.ts.map +1 -0
- package/dist/assets/icons/icon-menu-alt.js +4 -0
- package/dist/assets/icons/icon-slash-forward.d.ts +8 -0
- package/dist/assets/icons/icon-slash-forward.d.ts.map +1 -0
- package/dist/assets/icons/icon-slash-forward.js +4 -0
- package/dist/assets/icons/index.d.ts +10 -0
- package/dist/assets/icons/index.d.ts.map +1 -0
- package/dist/assets/icons/index.js +10 -0
- package/dist/assets/logos/index.d.ts +13 -0
- package/dist/assets/logos/index.d.ts.map +1 -0
- package/dist/assets/logos/index.js +13 -0
- package/dist/assets/logos/logo-ai-elements.d.ts +8 -0
- package/dist/assets/logos/logo-ai-elements.d.ts.map +1 -0
- package/dist/assets/logos/logo-ai-elements.js +8 -0
- package/dist/assets/logos/logo-ai-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-ai-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-ai-sdk.js +8 -0
- package/dist/assets/logos/logo-chat-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-chat-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-chat-sdk.js +8 -0
- package/dist/assets/logos/logo-flags-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-flags-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-flags-sdk.js +8 -0
- package/dist/assets/logos/logo-icon-vercel.d.ts +9 -0
- package/dist/assets/logos/logo-icon-vercel.d.ts.map +1 -0
- package/dist/assets/logos/logo-icon-vercel.js +8 -0
- package/dist/assets/logos/logo-streamdown.d.ts +8 -0
- package/dist/assets/logos/logo-streamdown.d.ts.map +1 -0
- package/dist/assets/logos/logo-streamdown.js +8 -0
- package/dist/assets/logos/logo-vercel-oss.d.ts +8 -0
- package/dist/assets/logos/logo-vercel-oss.d.ts.map +1 -0
- package/dist/assets/logos/logo-vercel-oss.js +7 -0
- package/dist/assets/logos/logo-workflow-sdk.d.ts +8 -0
- package/dist/assets/logos/logo-workflow-sdk.d.ts.map +1 -0
- package/dist/assets/logos/logo-workflow-sdk.js +8 -0
- package/dist/cli/index.js +3 -0
- package/dist/components/callout.d.ts +12 -0
- package/dist/components/callout.d.ts.map +1 -0
- package/dist/components/callout.js +7 -0
- package/dist/components/code-block-tabs.d.ts +7 -0
- package/dist/components/code-block-tabs.d.ts.map +1 -0
- package/dist/components/code-block-tabs.js +7 -0
- package/dist/components/code-block.d.ts +14 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +45 -0
- package/dist/components/copy-prompt.d.ts +11 -0
- package/dist/components/copy-prompt.d.ts.map +1 -0
- package/dist/components/copy-prompt.js +58 -0
- package/dist/components/mermaid.d.ts +4 -0
- package/dist/components/mermaid.d.ts.map +1 -0
- package/dist/components/mermaid.js +44 -0
- package/dist/components/theme-aware-image.d.ts +12 -0
- package/dist/components/theme-aware-image.d.ts.map +1 -0
- package/dist/components/theme-aware-image.js +8 -0
- package/dist/components/video.d.ts +6 -0
- package/dist/components/video.d.ts.map +1 -0
- package/dist/components/video.js +3 -0
- package/dist/config.d.ts +71 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1 -0
- package/dist/controls.d.ts +15 -0
- package/dist/controls.d.ts.map +1 -0
- package/dist/controls.js +52 -0
- package/dist/internal/chat/context.d.ts +19 -0
- package/dist/internal/chat/context.d.ts.map +1 -0
- package/dist/internal/chat/context.js +36 -0
- package/dist/internal/chat/conversation.d.ts +10 -0
- package/dist/internal/chat/conversation.d.ts.map +1 -0
- package/dist/internal/chat/conversation.js +16 -0
- package/dist/internal/chat/copy-chat.d.ts +5 -0
- package/dist/internal/chat/copy-chat.d.ts.map +1 -0
- package/dist/internal/chat/copy-chat.js +35 -0
- package/dist/internal/chat/db.d.ts +13 -0
- package/dist/internal/chat/db.d.ts.map +1 -0
- package/dist/internal/chat/db.js +19 -0
- package/dist/internal/chat/message-metadata.d.ts +8 -0
- package/dist/internal/chat/message-metadata.d.ts.map +1 -0
- package/dist/internal/chat/message-metadata.js +29 -0
- package/dist/internal/chat/message.d.ts +11 -0
- package/dist/internal/chat/message.d.ts.map +1 -0
- package/dist/internal/chat/message.js +11 -0
- package/dist/internal/chat/prompt-input.d.ts +13 -0
- package/dist/internal/chat/prompt-input.d.ts.map +1 -0
- package/dist/internal/chat/prompt-input.js +39 -0
- package/dist/internal/chat/shell.d.ts +2 -0
- package/dist/internal/chat/shell.d.ts.map +1 -0
- package/dist/internal/chat/shell.js +194 -0
- package/dist/internal/chat/shimmer.d.ts +11 -0
- package/dist/internal/chat/shimmer.d.ts.map +1 -0
- package/dist/internal/chat/shimmer.js +18 -0
- package/dist/internal/chat/sources.d.ts +13 -0
- package/dist/internal/chat/sources.d.ts.map +1 -0
- package/dist/internal/chat/sources.js +9 -0
- package/dist/internal/chat/suggestion.d.ts +11 -0
- package/dist/internal/chat/suggestion.d.ts.map +1 -0
- package/dist/internal/chat/suggestion.js +12 -0
- package/dist/internal/cn.d.ts +3 -0
- package/dist/internal/cn.d.ts.map +1 -0
- package/dist/internal/cn.js +3 -0
- package/dist/internal/feedback-action.d.ts +14 -0
- package/dist/internal/feedback-action.d.ts.map +1 -0
- package/dist/internal/feedback-action.js +34 -0
- package/dist/internal/i18n.d.ts +6 -0
- package/dist/internal/i18n.d.ts.map +1 -0
- package/dist/internal/i18n.js +18 -0
- package/dist/internal/languages.d.ts +7 -0
- package/dist/internal/languages.d.ts.map +1 -0
- package/dist/internal/languages.js +18 -0
- package/dist/internal/not-implemented.d.ts +2 -0
- package/dist/internal/not-implemented.d.ts.map +1 -0
- package/dist/internal/not-implemented.js +4 -0
- package/dist/internal/page-actions-client.d.ts +13 -0
- package/dist/internal/page-actions-client.d.ts.map +1 -0
- package/dist/internal/page-actions-client.js +160 -0
- package/dist/internal/page-actions.d.ts +18 -0
- package/dist/internal/page-actions.d.ts.map +1 -0
- package/dist/internal/page-actions.js +4 -0
- package/dist/internal/provider-client.d.ts +9 -0
- package/dist/internal/provider-client.d.ts.map +1 -0
- package/dist/internal/provider-client.js +23 -0
- package/dist/internal/search.d.ts +5 -0
- package/dist/internal/search.d.ts.map +1 -0
- package/dist/internal/search.js +14 -0
- package/dist/internal/sidebar.d.ts +9 -0
- package/dist/internal/sidebar.d.ts.map +1 -0
- package/dist/internal/sidebar.js +38 -0
- package/dist/internal/table-of-contents.d.ts +9 -0
- package/dist/internal/table-of-contents.d.ts.map +1 -0
- package/dist/internal/table-of-contents.js +5 -0
- package/dist/internal/ui/button-group.d.ts +13 -0
- package/dist/internal/ui/button-group.d.ts.map +1 -0
- package/dist/internal/ui/button-group.js +26 -0
- package/dist/internal/ui/button.d.ts +12 -0
- package/dist/internal/ui/button.d.ts.map +1 -0
- package/dist/internal/ui/button.js +33 -0
- package/dist/internal/ui/card.d.ts +6 -0
- package/dist/internal/ui/card.d.ts.map +1 -0
- package/dist/internal/ui/card.js +14 -0
- package/dist/internal/ui/collapsible.d.ts +6 -0
- package/dist/internal/ui/collapsible.d.ts.map +1 -0
- package/dist/internal/ui/collapsible.js +12 -0
- package/dist/internal/ui/drawer.d.ts +6 -0
- package/dist/internal/ui/drawer.d.ts.map +1 -0
- package/dist/internal/ui/drawer.js +13 -0
- package/dist/internal/ui/dropdown-menu.d.ts +22 -0
- package/dist/internal/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/internal/ui/dropdown-menu.js +41 -0
- package/dist/internal/ui/input-group.d.ts +15 -0
- package/dist/internal/ui/input-group.d.ts.map +1 -0
- package/dist/internal/ui/input-group.js +44 -0
- package/dist/internal/ui/input.d.ts +3 -0
- package/dist/internal/ui/input.d.ts.map +1 -0
- package/dist/internal/ui/input.js +5 -0
- package/dist/internal/ui/kbd.d.ts +4 -0
- package/dist/internal/ui/kbd.d.ts.map +1 -0
- package/dist/internal/ui/kbd.js +8 -0
- package/dist/internal/ui/popover.d.ts +6 -0
- package/dist/internal/ui/popover.d.ts.map +1 -0
- package/dist/internal/ui/popover.js +13 -0
- package/dist/internal/ui/scroll-area.d.ts +5 -0
- package/dist/internal/ui/scroll-area.d.ts.map +1 -0
- package/dist/internal/ui/scroll-area.js +12 -0
- package/dist/internal/ui/separator.d.ts +4 -0
- package/dist/internal/ui/separator.d.ts.map +1 -0
- package/dist/internal/ui/separator.js +7 -0
- package/dist/internal/ui/sheet.d.ts +10 -0
- package/dist/internal/ui/sheet.d.ts.map +1 -0
- package/dist/internal/ui/sheet.js +24 -0
- package/dist/internal/ui/sonner.d.ts +3 -0
- package/dist/internal/ui/sonner.d.ts.map +1 -0
- package/dist/internal/ui/sonner.js +20 -0
- package/dist/internal/ui/spinner.d.ts +3 -0
- package/dist/internal/ui/spinner.d.ts.map +1 -0
- package/dist/internal/ui/spinner.js +6 -0
- package/dist/internal/ui/textarea.d.ts +3 -0
- package/dist/internal/ui/textarea.d.ts.map +1 -0
- package/dist/internal/ui/textarea.js +5 -0
- package/dist/internal/ui/tooltip.d.ts +7 -0
- package/dist/internal/ui/tooltip.d.ts.map +1 -0
- package/dist/internal/ui/tooltip.js +16 -0
- package/dist/internal/use-mobile.d.ts +2 -0
- package/dist/internal/use-mobile.d.ts.map +1 -0
- package/dist/internal/use-mobile.js +16 -0
- package/dist/layout.d.ts +14 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +31 -0
- package/dist/mdx.d.ts +36 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +80 -0
- package/dist/pages/docs.d.ts +77 -0
- package/dist/pages/docs.d.ts.map +1 -0
- package/dist/pages/docs.js +92 -0
- package/dist/proxy.d.ts +37 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/proxy.js +162 -0
- package/dist/routes/chat.d.ts +14 -0
- package/dist/routes/chat.d.ts.map +1 -0
- package/dist/routes/chat.js +242 -0
- package/dist/routes/llms.d.ts +51 -0
- package/dist/routes/llms.d.ts.map +1 -0
- package/dist/routes/llms.js +59 -0
- package/dist/routes/search.d.ts +11 -0
- package/dist/routes/search.d.ts.map +1 -0
- package/dist/routes/search.js +74 -0
- package/dist/routes/sitemap.d.ts +44 -0
- package/dist/routes/sitemap.d.ts.map +1 -0
- package/dist/routes/sitemap.js +168 -0
- package/dist/shiki-theme.d.ts +20 -0
- package/dist/shiki-theme.d.ts.map +1 -0
- package/dist/shiki-theme.js +110 -0
- package/dist/sidebar.d.ts +11 -0
- package/dist/sidebar.d.ts.map +1 -0
- package/dist/sidebar.js +16 -0
- package/dist/source.d.ts +174 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +129 -0
- package/dist/versions.d.ts +15 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +52 -0
- package/package.json +161 -9
- package/styles.css +556 -0
- package/template/_gitignore +29 -0
- package/template/app/[lang]/(home)/components/centered-section.tsx +24 -0
- package/template/app/[lang]/(home)/components/cta.tsx +19 -0
- package/template/app/[lang]/(home)/components/hero.tsx +27 -0
- package/template/app/[lang]/(home)/components/one-two-section.tsx +23 -0
- package/template/app/[lang]/(home)/components/templates.tsx +48 -0
- package/template/app/[lang]/(home)/components/text-grid-section.tsx +20 -0
- package/template/app/[lang]/(home)/layout.tsx +14 -0
- package/template/app/[lang]/(home)/page.tsx +126 -0
- package/template/app/[lang]/docs/[[...slug]]/page.tsx +19 -0
- package/template/app/[lang]/docs/layout.tsx +14 -0
- package/template/app/[lang]/layout.tsx +29 -0
- package/template/app/[lang]/llms.mdx/[[...slug]]/route.ts +7 -0
- package/template/app/[lang]/llms.txt/route.ts +6 -0
- package/template/app/[lang]/og/[...slug]/background.png +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-regular.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/geist-sans-semibold.ttf +0 -0
- package/template/app/[lang]/og/[...slug]/route.tsx +95 -0
- package/template/app/[lang]/rss.xml/route.ts +52 -0
- package/template/app/[lang]/sitemap.md/route.ts +9 -0
- package/template/app/actions/feedback/emotions.ts +18 -0
- package/template/app/actions/feedback/index.ts +45 -0
- package/template/app/api/chat/route.ts +8 -0
- package/template/app/api/search/route.ts +5 -0
- package/template/app/favicon.ico +0 -0
- package/template/app/global.css +2 -0
- package/template/app/robots.ts +14 -0
- package/template/app/sitemap.ts +36 -0
- package/template/app/styles/geistdocs.css +595 -0
- package/template/components/geistdocs/chat.tsx +24 -0
- package/template/components/geistdocs/desktop-menu.tsx +52 -0
- package/template/components/geistdocs/docs-layout.tsx +20 -0
- package/template/components/geistdocs/feedback.tsx +139 -0
- package/template/components/geistdocs/footer.tsx +30 -0
- package/template/components/geistdocs/github-button.tsx +19 -0
- package/template/components/geistdocs/home-layout.tsx +46 -0
- package/template/components/geistdocs/language-selector.tsx +3 -0
- package/template/components/geistdocs/mdx-components.tsx +5 -0
- package/template/components/geistdocs/mobile-docs-bar.tsx +77 -0
- package/template/components/geistdocs/mobile-menu.tsx +150 -0
- package/template/components/geistdocs/navbar-logo.tsx +124 -0
- package/template/components/geistdocs/navbar.tsx +22 -0
- package/template/components/geistdocs/provider.tsx +31 -0
- package/template/components/geistdocs/rss-button.tsx +10 -0
- package/template/components/geistdocs/search.tsx +17 -0
- package/template/components/geistdocs/sidebar.tsx +128 -0
- package/template/components/geistdocs/theme-aware-image.tsx +22 -0
- package/template/components/geistdocs/theme-toggle.tsx +3 -0
- package/template/components/ui/badge.tsx +46 -0
- package/template/components/ui/button.tsx +60 -0
- package/template/components/ui/card.tsx +92 -0
- package/template/components/ui/command-prompt.tsx +488 -0
- package/template/components/ui/dialog.tsx +143 -0
- package/template/components/ui/input-group.tsx +170 -0
- package/template/components/ui/input.tsx +21 -0
- package/template/components/ui/navigation-menu.tsx +192 -0
- package/template/components/ui/popover.tsx +48 -0
- package/template/components/ui/separator.tsx +28 -0
- package/template/components/ui/sheet.tsx +139 -0
- package/template/components/ui/textarea.tsx +18 -0
- package/template/components.json +22 -0
- package/template/content/docs/ask-ai.cn.mdx +85 -0
- package/template/content/docs/ask-ai.mdx +89 -0
- package/template/content/docs/configuration.cn.mdx +155 -0
- package/template/content/docs/configuration.mdx +200 -0
- package/template/content/docs/deployment.cn.mdx +34 -0
- package/template/content/docs/deployment.mdx +40 -0
- package/template/content/docs/edit-on-github.cn.mdx +47 -0
- package/template/content/docs/edit-on-github.mdx +51 -0
- package/template/content/docs/env.cn.mdx +25 -0
- package/template/content/docs/env.mdx +29 -0
- package/template/content/docs/feedback.cn.mdx +85 -0
- package/template/content/docs/feedback.mdx +89 -0
- package/template/content/docs/getting-started.cn.mdx +86 -0
- package/template/content/docs/getting-started.mdx +107 -0
- package/template/content/docs/index.cn.mdx +57 -0
- package/template/content/docs/index.mdx +92 -0
- package/template/content/docs/internationalization.cn.mdx +111 -0
- package/template/content/docs/internationalization.mdx +122 -0
- package/template/content/docs/llms-txt.cn.mdx +72 -0
- package/template/content/docs/llms-txt.mdx +85 -0
- package/template/content/docs/md.cn.mdx +65 -0
- package/template/content/docs/md.mdx +81 -0
- package/template/content/docs/meta.json +23 -0
- package/template/content/docs/open-in-chat.cn.mdx +78 -0
- package/template/content/docs/open-in-chat.mdx +80 -0
- package/template/content/docs/provider.cn.mdx +70 -0
- package/template/content/docs/provider.mdx +74 -0
- package/template/content/docs/proxy.cn.mdx +96 -0
- package/template/content/docs/proxy.mdx +124 -0
- package/template/content/docs/rss.cn.mdx +104 -0
- package/template/content/docs/rss.mdx +108 -0
- package/template/content/docs/syntax.cn.mdx +416 -0
- package/template/content/docs/syntax.mdx +411 -0
- package/template/content/docs/theme-aware-image.mdx +57 -0
- package/template/content/docs/versioned-docs.cn.mdx +117 -0
- package/template/content/docs/versioned-docs.mdx +181 -0
- package/template/geistdocs.tsx +51 -0
- package/template/hooks/geistdocs/use-sidebar.ts +13 -0
- package/template/hooks/use-mobile.ts +19 -0
- package/template/lib/geistdocs/config.tsx +27 -0
- package/template/lib/geistdocs/fonts.ts +18 -0
- package/template/lib/geistdocs/i18n.ts +13 -0
- package/template/lib/geistdocs/md-tracking.ts +56 -0
- package/template/lib/geistdocs/source.ts +12 -0
- package/template/lib/utils.ts +6 -0
- package/template/next.config.ts +22 -0
- package/template/package.json +63 -0
- package/template/postcss.config.mjs +5 -0
- package/template/proxy.ts +18 -0
- package/template/source.config.ts +179 -0
- package/template/tsconfig.json +37 -0
- package/dist/index.js +0 -2
- /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 "@vercel/geistdocs/assets/icons/icon-check";
|
|
18
|
+
import { IconCopy } from "@vercel/geistdocs/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,143 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Dialog as DialogPrimitive } from "radix-ui"
|
|
5
|
+
import { XIcon } from "lucide-react"
|
|
6
|
+
|
|
7
|
+
import { cn } from "@/lib/utils"
|
|
8
|
+
|
|
9
|
+
function Dialog({
|
|
10
|
+
...props
|
|
11
|
+
}: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
12
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function DialogTrigger({
|
|
16
|
+
...props
|
|
17
|
+
}: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
18
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function DialogPortal({
|
|
22
|
+
...props
|
|
23
|
+
}: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
24
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function DialogClose({
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
30
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function DialogOverlay({
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
37
|
+
return (
|
|
38
|
+
<DialogPrimitive.Overlay
|
|
39
|
+
data-slot="dialog-overlay"
|
|
40
|
+
className={cn(
|
|
41
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
{...props}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function DialogContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
showCloseButton = true,
|
|
53
|
+
...props
|
|
54
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
55
|
+
showCloseButton?: boolean
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<DialogPortal data-slot="dialog-portal">
|
|
59
|
+
<DialogOverlay />
|
|
60
|
+
<DialogPrimitive.Content
|
|
61
|
+
data-slot="dialog-content"
|
|
62
|
+
className={cn(
|
|
63
|
+
"bg-background-100 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
64
|
+
className
|
|
65
|
+
)}
|
|
66
|
+
{...props}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
{showCloseButton && (
|
|
70
|
+
<DialogPrimitive.Close
|
|
71
|
+
data-slot="dialog-close"
|
|
72
|
+
className="ring-offset-background-100 focus:ring-gray-600 data-[state=open]:bg-gray-100 data-[state=open]:text-gray-800 absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
73
|
+
>
|
|
74
|
+
<XIcon />
|
|
75
|
+
<span className="sr-only">Close</span>
|
|
76
|
+
</DialogPrimitive.Close>
|
|
77
|
+
)}
|
|
78
|
+
</DialogPrimitive.Content>
|
|
79
|
+
</DialogPortal>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
data-slot="dialog-header"
|
|
87
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
88
|
+
{...props}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-footer"
|
|
97
|
+
className={cn(
|
|
98
|
+
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function DialogTitle({
|
|
107
|
+
className,
|
|
108
|
+
...props
|
|
109
|
+
}: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
110
|
+
return (
|
|
111
|
+
<DialogPrimitive.Title
|
|
112
|
+
data-slot="dialog-title"
|
|
113
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
114
|
+
{...props}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function DialogDescription({
|
|
120
|
+
className,
|
|
121
|
+
...props
|
|
122
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
123
|
+
return (
|
|
124
|
+
<DialogPrimitive.Description
|
|
125
|
+
data-slot="dialog-description"
|
|
126
|
+
className={cn("text-gray-800 text-sm", className)}
|
|
127
|
+
{...props}
|
|
128
|
+
/>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {
|
|
133
|
+
Dialog,
|
|
134
|
+
DialogClose,
|
|
135
|
+
DialogContent,
|
|
136
|
+
DialogDescription,
|
|
137
|
+
DialogFooter,
|
|
138
|
+
DialogHeader,
|
|
139
|
+
DialogOverlay,
|
|
140
|
+
DialogPortal,
|
|
141
|
+
DialogTitle,
|
|
142
|
+
DialogTrigger,
|
|
143
|
+
}
|