diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsx index e17eb4f9c02..7e6779fef1b 100644 --- a/apps/design-system/__registry__/index.tsx +++ b/apps/design-system/__registry__/index.tsx @@ -1864,5 +1864,16 @@ export const Index: Record = { subcategory: "undefined", chunks: [] }, + "expanding-textarea-demo": { + name: "expanding-textarea-demo", + type: "docs:example", + registryDependencies: undefined, + component: React.lazy(() => import("@/registry/default/example/expanding-textarea-demo")), + source: "", + files: ["registry/default/example/expanding-textarea-demo.tsx"], + category: "undefined", + subcategory: "undefined", + chunks: [] + }, }, } diff --git a/apps/design-system/app/layout.tsx b/apps/design-system/app/layout.tsx index 7e8ff99a5a9..b0e13e68153 100644 --- a/apps/design-system/app/layout.tsx +++ b/apps/design-system/app/layout.tsx @@ -6,7 +6,7 @@ import { ThemeProvider } from './Providers' const inter = Inter({ subsets: ['latin'] }) export const metadata: Metadata = { - title: 'Create Next App', + title: 'Supabase Design System', description: 'Generated by create next app', } diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.ts index 4e1a7be559d..caaf8c695f5 100644 --- a/apps/design-system/config/docs.ts +++ b/apps/design-system/config/docs.ts @@ -374,6 +374,11 @@ export const docsConfig: DocsConfig = { href: '/docs/components/tree-view', items: [], }, + { + title: 'Expanding Textarea', + href: '/docs/components/expanding-textarea', + items: [], + }, ], }, ], diff --git a/apps/design-system/content/docs/components/expanding-textarea.mdx b/apps/design-system/content/docs/components/expanding-textarea.mdx new file mode 100644 index 00000000000..dded1c63207 --- /dev/null +++ b/apps/design-system/content/docs/components/expanding-textarea.mdx @@ -0,0 +1,25 @@ +--- +title: Expanding Textarea +description: Displays a textarea which autoexpands (or shrinks) based on its content. +component: true +source: + shadcn: true +--- + + + +## Usage + +```tsx +import { ExpandingTextArea } from 'ui' +``` + +```tsx + +``` + +## Examples + +### Default + + diff --git a/apps/design-system/next.config.mjs b/apps/design-system/next.config.mjs index 3c67b4ac18e..2280b564d29 100644 --- a/apps/design-system/next.config.mjs +++ b/apps/design-system/next.config.mjs @@ -1,5 +1,7 @@ import { withContentlayer } from 'next-contentlayer2' +const BASE_PATH = process.env.NEXT_PUBLIC_BASE_PATH || '/design-system' + /** @type {import('next').NextConfig} */ const nextConfig = { transpilePackages: ['ui', 'common', 'shared-data', 'icons', 'tsconfig'], @@ -22,11 +24,11 @@ const nextConfig = { }, async redirects() { return [ - ...(process.env.NEXT_PUBLIC_BASE_PATH?.length + ...(BASE_PATH.length ? [ { source: '/', - destination: process.env.NEXT_PUBLIC_BASE_PATH, + destination: BASE_PATH, basePath: false, permanent: false, }, diff --git a/apps/design-system/registry/default/example/expanding-textarea-demo.tsx b/apps/design-system/registry/default/example/expanding-textarea-demo.tsx new file mode 100644 index 00000000000..464d1db42ab --- /dev/null +++ b/apps/design-system/registry/default/example/expanding-textarea-demo.tsx @@ -0,0 +1,16 @@ +import { useState } from 'react' +import { ExpandingTextArea } from 'ui' + +export default function ExpandingTextareaDemo() { + const [value, setValue] = useState('') + + return ( + { + setValue(event.target.value) + }} + /> + ) +} diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.ts index 26a7386efbe..f8e00260d70 100644 --- a/apps/design-system/registry/examples.ts +++ b/apps/design-system/registry/examples.ts @@ -1065,4 +1065,9 @@ export const examples: Registry = [ type: 'docs:example', files: ['example/color-usage-surface-studio-frame.tsx'], }, + { + name: 'expanding-textarea-demo', + type: 'docs:example', + files: ['example/expanding-textarea-demo.tsx'], + }, ] diff --git a/apps/studio/components/interfaces/SQLEditor/AiAssistantPanel/index.tsx b/apps/studio/components/interfaces/SQLEditor/AiAssistantPanel/index.tsx index 8f9c72a5bf8..e6e19e3fa80 100644 --- a/apps/studio/components/interfaces/SQLEditor/AiAssistantPanel/index.tsx +++ b/apps/studio/components/interfaces/SQLEditor/AiAssistantPanel/index.tsx @@ -15,12 +15,12 @@ import { IS_PLATFORM, LOCAL_STORAGE_KEYS, OPT_IN_TAGS } from 'lib/constants' import { useProfile } from 'lib/profile' import { useAppStateSnapshot } from 'state/app-state' import { + ExpandingTextArea, Button, FormControl_Shadcn_, FormField_Shadcn_, FormItem_Shadcn_, Form_Shadcn_, - Input_Shadcn_, cn, } from 'ui' import { AiIcon } from 'ui-patterns/Cmdk' @@ -86,6 +86,8 @@ export const AiAssistantPanel = ({ } }, [loading]) + const formRef = useRef(null) + return (
) => { onSubmit(data.chat) @@ -168,18 +171,23 @@ export const AiAssistantPanel = ({ control={form.control} name="chat" render={({ field }) => ( - +
- { + if (event.key === 'Enter' && !event.shiftKey) { + event.preventDefault() + formRef?.current?.requestSubmit() + } + }} placeholder="Ask a question about your SQL query" /> {loading && } diff --git a/packages/ui-patterns/AssistantChat/AssistantChatForm.tsx b/packages/ui-patterns/AssistantChat/AssistantChatForm.tsx index dedae876eb7..4f836f6c702 100644 --- a/packages/ui-patterns/AssistantChat/AssistantChatForm.tsx +++ b/packages/ui-patterns/AssistantChat/AssistantChatForm.tsx @@ -95,6 +95,7 @@ const AssistantChatForm = React.forwardRef( {icon}
)} + {/* TODO: Replace this with ExpandingTextArea */}