create-sidekick-app 0.0.0-stage → 2.0.0
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/LICENSE.md +202 -0
- package/NOTICE +27 -0
- package/README.md +30 -2
- package/dist/index.js +59 -0
- package/package.json +69 -3
- package/template/base/ai-chat/.env.example +6 -0
- package/template/base/ai-chat/.prettierignore +2 -0
- package/template/base/ai-chat/.prettierrc.json +5 -0
- package/template/base/ai-chat/README.md +38 -0
- package/template/base/ai-chat/_gitignore +41 -0
- package/template/base/ai-chat/components.json +23 -0
- package/template/base/ai-chat/next.config.ts +5 -0
- package/template/base/ai-chat/package.json +61 -0
- package/template/base/ai-chat/postcss.config.mjs +5 -0
- package/template/base/ai-chat/src/app/api/chat/route.ts +141 -0
- package/template/base/ai-chat/src/app/api/instant/route.ts +5 -0
- package/template/base/ai-chat/src/app/chat/[id]/page.tsx +20 -0
- package/template/base/ai-chat/src/app/globals.css +124 -0
- package/template/base/ai-chat/src/app/layout.tsx +34 -0
- package/template/base/ai-chat/src/app/page.tsx +6 -0
- package/template/base/ai-chat/src/components/AuthGate.tsx +15 -0
- package/template/base/ai-chat/src/components/Chat.tsx +228 -0
- package/template/base/ai-chat/src/components/InstantProvider.tsx +18 -0
- package/template/base/ai-chat/src/components/Login.tsx +163 -0
- package/template/base/ai-chat/src/components/Sidebar.tsx +100 -0
- package/template/base/ai-chat/src/components/ai-elements/agent.tsx +142 -0
- package/template/base/ai-chat/src/components/ai-elements/artifact.tsx +149 -0
- package/template/base/ai-chat/src/components/ai-elements/attachments.tsx +427 -0
- package/template/base/ai-chat/src/components/ai-elements/audio-player.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/canvas.tsx +26 -0
- package/template/base/ai-chat/src/components/ai-elements/chain-of-thought.tsx +223 -0
- package/template/base/ai-chat/src/components/ai-elements/checkpoint.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/code-block.tsx +556 -0
- package/template/base/ai-chat/src/components/ai-elements/commit.tsx +449 -0
- package/template/base/ai-chat/src/components/ai-elements/confirmation.tsx +173 -0
- package/template/base/ai-chat/src/components/ai-elements/connection.tsx +28 -0
- package/template/base/ai-chat/src/components/ai-elements/context.tsx +410 -0
- package/template/base/ai-chat/src/components/ai-elements/controls.tsx +19 -0
- package/template/base/ai-chat/src/components/ai-elements/conversation.tsx +167 -0
- package/template/base/ai-chat/src/components/ai-elements/edge.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/environment-variables.tsx +325 -0
- package/template/base/ai-chat/src/components/ai-elements/file-tree.tsx +298 -0
- package/template/base/ai-chat/src/components/ai-elements/image.tsx +25 -0
- package/template/base/ai-chat/src/components/ai-elements/inline-citation.tsx +294 -0
- package/template/base/ai-chat/src/components/ai-elements/jsx-preview.tsx +250 -0
- package/template/base/ai-chat/src/components/ai-elements/message.tsx +356 -0
- package/template/base/ai-chat/src/components/ai-elements/mic-selector.tsx +372 -0
- package/template/base/ai-chat/src/components/ai-elements/model-selector.tsx +214 -0
- package/template/base/ai-chat/src/components/ai-elements/node.tsx +72 -0
- package/template/base/ai-chat/src/components/ai-elements/open-in-chat.tsx +367 -0
- package/template/base/ai-chat/src/components/ai-elements/package-info.tsx +235 -0
- package/template/base/ai-chat/src/components/ai-elements/panel.tsx +16 -0
- package/template/base/ai-chat/src/components/ai-elements/persona.tsx +280 -0
- package/template/base/ai-chat/src/components/ai-elements/plan.tsx +144 -0
- package/template/base/ai-chat/src/components/ai-elements/prompt-input.tsx +1341 -0
- package/template/base/ai-chat/src/components/ai-elements/queue.tsx +275 -0
- package/template/base/ai-chat/src/components/ai-elements/reasoning.tsx +229 -0
- package/template/base/ai-chat/src/components/ai-elements/sandbox.tsx +128 -0
- package/template/base/ai-chat/src/components/ai-elements/schema-display.tsx +473 -0
- package/template/base/ai-chat/src/components/ai-elements/shimmer.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/snippet.tsx +141 -0
- package/template/base/ai-chat/src/components/ai-elements/sources.tsx +78 -0
- package/template/base/ai-chat/src/components/ai-elements/speech-input.tsx +324 -0
- package/template/base/ai-chat/src/components/ai-elements/stack-trace.tsx +531 -0
- package/template/base/ai-chat/src/components/ai-elements/suggestion.tsx +55 -0
- package/template/base/ai-chat/src/components/ai-elements/task.tsx +88 -0
- package/template/base/ai-chat/src/components/ai-elements/terminal.tsx +277 -0
- package/template/base/ai-chat/src/components/ai-elements/test-results.tsx +497 -0
- package/template/base/ai-chat/src/components/ai-elements/tool.tsx +174 -0
- package/template/base/ai-chat/src/components/ai-elements/toolbar.tsx +17 -0
- package/template/base/ai-chat/src/components/ai-elements/transcription.tsx +126 -0
- package/template/base/ai-chat/src/components/ai-elements/voice-selector.tsx +525 -0
- package/template/base/ai-chat/src/components/ai-elements/web-preview.tsx +282 -0
- package/template/base/ai-chat/src/components/ui/accordion.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/alert.tsx +66 -0
- package/template/base/ai-chat/src/components/ui/avatar.tsx +109 -0
- package/template/base/ai-chat/src/components/ui/badge.tsx +48 -0
- package/template/base/ai-chat/src/components/ui/button-group.tsx +83 -0
- package/template/base/ai-chat/src/components/ui/button.tsx +64 -0
- package/template/base/ai-chat/src/components/ui/card.tsx +92 -0
- package/template/base/ai-chat/src/components/ui/carousel.tsx +241 -0
- package/template/base/ai-chat/src/components/ui/collapsible.tsx +33 -0
- package/template/base/ai-chat/src/components/ui/command.tsx +184 -0
- package/template/base/ai-chat/src/components/ui/dialog.tsx +158 -0
- package/template/base/ai-chat/src/components/ui/dropdown-menu.tsx +257 -0
- package/template/base/ai-chat/src/components/ui/hover-card.tsx +44 -0
- package/template/base/ai-chat/src/components/ui/input-group.tsx +170 -0
- package/template/base/ai-chat/src/components/ui/input.tsx +21 -0
- package/template/base/ai-chat/src/components/ui/popover.tsx +89 -0
- package/template/base/ai-chat/src/components/ui/progress.tsx +31 -0
- package/template/base/ai-chat/src/components/ui/scroll-area.tsx +58 -0
- package/template/base/ai-chat/src/components/ui/select.tsx +190 -0
- package/template/base/ai-chat/src/components/ui/separator.tsx +28 -0
- package/template/base/ai-chat/src/components/ui/spinner.tsx +16 -0
- package/template/base/ai-chat/src/components/ui/switch.tsx +35 -0
- package/template/base/ai-chat/src/components/ui/tabs.tsx +91 -0
- package/template/base/ai-chat/src/components/ui/textarea.tsx +18 -0
- package/template/base/ai-chat/src/components/ui/tooltip.tsx +57 -0
- package/template/base/ai-chat/src/instant.perms.ts +34 -0
- package/template/base/ai-chat/src/instant.schema.ts +107 -0
- package/template/base/ai-chat/src/lib/adminDb.ts +8 -0
- package/template/base/ai-chat/src/lib/db.ts +8 -0
- package/template/base/ai-chat/src/lib/mockModel.ts +119 -0
- package/template/base/ai-chat/src/lib/utils.ts +6 -0
- package/template/base/ai-chat/tsconfig.json +33 -0
- package/template/base/bun-react/.env.example +2 -0
- package/template/base/bun-react/README.md +12 -0
- package/template/base/bun-react/_gitignore +34 -0
- package/template/base/bun-react/bun-env.d.ts +17 -0
- package/template/base/bun-react/bunfig.toml +4 -0
- package/template/base/bun-react/package.json +22 -0
- package/template/base/bun-react/src/App.tsx +168 -0
- package/template/base/bun-react/src/frontend.tsx +20 -0
- package/template/base/bun-react/src/getUnusedPort.ts +32 -0
- package/template/base/bun-react/src/index.css +25 -0
- package/template/base/bun-react/src/index.html +13 -0
- package/template/base/bun-react/src/index.ts +21 -0
- package/template/base/bun-react/src/instant.perms.ts +24 -0
- package/template/base/bun-react/src/instant.schema.ts +46 -0
- package/template/base/bun-react/src/lib/db.ts +8 -0
- package/template/base/bun-react/src/logo.svg +1 -0
- package/template/base/bun-react/tsconfig.json +36 -0
- package/template/base/expo/.env.example +2 -0
- package/template/base/expo/README.md +18 -0
- package/template/base/expo/_gitignore +41 -0
- package/template/base/expo/app/+not-found.tsx +16 -0
- package/template/base/expo/app/_layout.tsx +37 -0
- package/template/base/expo/app/index.tsx +64 -0
- package/template/base/expo/app.json +42 -0
- package/template/base/expo/assets/fonts/SpaceMono-Regular.ttf +0 -0
- package/template/base/expo/assets/images/adaptive-icon.png +0 -0
- package/template/base/expo/assets/images/favicon.png +0 -0
- package/template/base/expo/assets/images/icon.png +0 -0
- package/template/base/expo/assets/images/partial-react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo.png +0 -0
- package/template/base/expo/assets/images/react-logo@2x.png +0 -0
- package/template/base/expo/assets/images/react-logo@3x.png +0 -0
- package/template/base/expo/assets/images/splash-icon.png +0 -0
- package/template/base/expo/babel.config.js +12 -0
- package/template/base/expo/constants/Colors.ts +26 -0
- package/template/base/expo/eslint.config.js +10 -0
- package/template/base/expo/global.css +3 -0
- package/template/base/expo/hooks/useColorScheme.ts +1 -0
- package/template/base/expo/hooks/useColorScheme.web.ts +21 -0
- package/template/base/expo/hooks/useThemeColor.ts +21 -0
- package/template/base/expo/instant.perms.ts +24 -0
- package/template/base/expo/instant.schema.ts +44 -0
- package/template/base/expo/lib/db.ts +7 -0
- package/template/base/expo/metro.config.js +6 -0
- package/template/base/expo/nativewind-env.d.ts +1 -0
- package/template/base/expo/package.json +57 -0
- package/template/base/expo/scripts/reset-project.js +112 -0
- package/template/base/expo/tailwind.config.js +9 -0
- package/template/base/expo/tsconfig.json +18 -0
- package/template/base/next-js-app-dir/.env.example +2 -0
- package/template/base/next-js-app-dir/README.md +18 -0
- package/template/base/next-js-app-dir/_gitignore +41 -0
- package/template/base/next-js-app-dir/next.config.ts +7 -0
- package/template/base/next-js-app-dir/package.json +27 -0
- package/template/base/next-js-app-dir/postcss.config.mjs +5 -0
- package/template/base/next-js-app-dir/public/file.svg +1 -0
- package/template/base/next-js-app-dir/public/globe.svg +1 -0
- package/template/base/next-js-app-dir/public/next.svg +1 -0
- package/template/base/next-js-app-dir/public/vercel.svg +1 -0
- package/template/base/next-js-app-dir/public/window.svg +1 -0
- package/template/base/next-js-app-dir/src/app/favicon.ico +0 -0
- package/template/base/next-js-app-dir/src/app/globals.css +26 -0
- package/template/base/next-js-app-dir/src/app/layout.tsx +34 -0
- package/template/base/next-js-app-dir/src/app/page.tsx +169 -0
- package/template/base/next-js-app-dir/src/instant.perms.ts +24 -0
- package/template/base/next-js-app-dir/src/instant.schema.ts +50 -0
- package/template/base/next-js-app-dir/src/lib/db.ts +8 -0
- package/template/base/next-js-app-dir/tsconfig.json +41 -0
- package/template/base/solidjs-vite/README.md +15 -0
- package/template/base/solidjs-vite/_gitignore +25 -0
- package/template/base/solidjs-vite/index.html +15 -0
- package/template/base/solidjs-vite/package.json +25 -0
- package/template/base/solidjs-vite/src/App.tsx +171 -0
- package/template/base/solidjs-vite/src/index.css +25 -0
- package/template/base/solidjs-vite/src/index.tsx +16 -0
- package/template/base/solidjs-vite/src/instant.perms.ts +24 -0
- package/template/base/solidjs-vite/src/instant.schema.ts +46 -0
- package/template/base/solidjs-vite/src/lib/db.ts +8 -0
- package/template/base/solidjs-vite/tsconfig.json +20 -0
- package/template/base/solidjs-vite/vite.config.ts +11 -0
- package/template/base/sveltekit/README.md +15 -0
- package/template/base/sveltekit/_gitignore +26 -0
- package/template/base/sveltekit/package.json +25 -0
- package/template/base/sveltekit/src/app.css +25 -0
- package/template/base/sveltekit/src/app.html +11 -0
- package/template/base/sveltekit/src/instant.perms.ts +24 -0
- package/template/base/sveltekit/src/instant.schema.ts +46 -0
- package/template/base/sveltekit/src/lib/db.ts +8 -0
- package/template/base/sveltekit/src/routes/+layout.svelte +6 -0
- package/template/base/sveltekit/src/routes/+page.svelte +236 -0
- package/template/base/sveltekit/src/routes/+page.ts +1 -0
- package/template/base/sveltekit/svelte.config.js +10 -0
- package/template/base/sveltekit/tsconfig.json +14 -0
- package/template/base/sveltekit/vite.config.ts +7 -0
- package/template/base/tanstack-start/.cta.json +12 -0
- package/template/base/tanstack-start/README.md +17 -0
- package/template/base/tanstack-start/_gitignore +13 -0
- package/template/base/tanstack-start/package.json +43 -0
- package/template/base/tanstack-start/public/favicon.ico +0 -0
- package/template/base/tanstack-start/public/logo192.png +0 -0
- package/template/base/tanstack-start/public/logo512.png +0 -0
- package/template/base/tanstack-start/public/manifest.json +25 -0
- package/template/base/tanstack-start/public/robots.txt +3 -0
- package/template/base/tanstack-start/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start/src/lib/adminDb.ts +12 -0
- package/template/base/tanstack-start/src/lib/db.ts +9 -0
- package/template/base/tanstack-start/src/logo.svg +12 -0
- package/template/base/tanstack-start/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start/src/router.tsx +22 -0
- package/template/base/tanstack-start/src/routes/__root.tsx +70 -0
- package/template/base/tanstack-start/src/routes/api/instant.ts +18 -0
- package/template/base/tanstack-start/src/routes/index.tsx +238 -0
- package/template/base/tanstack-start/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start/src/styles.css +18 -0
- package/template/base/tanstack-start/tsconfig.json +28 -0
- package/template/base/tanstack-start/vite.config.ts +33 -0
- package/template/base/tanstack-start-with-tanstack-query/.cta.json +12 -0
- package/template/base/tanstack-start-with-tanstack-query/README.md +18 -0
- package/template/base/tanstack-start-with-tanstack-query/_gitignore +13 -0
- package/template/base/tanstack-start-with-tanstack-query/package.json +46 -0
- package/template/base/tanstack-start-with-tanstack-query/public/favicon.ico +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo192.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/logo512.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/manifest.json +25 -0
- package/template/base/tanstack-start-with-tanstack-query/public/robots.txt +3 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-circle-logo.png +0 -0
- package/template/base/tanstack-start-with-tanstack-query/public/tanstack-word-logo-white.svg +1 -0
- package/template/base/tanstack-start-with-tanstack-query/src/components/Header.tsx +21 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.perms.ts +24 -0
- package/template/base/tanstack-start-with-tanstack-query/src/instant.schema.ts +50 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/adminDb.ts +9 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/db.ts +11 -0
- package/template/base/tanstack-start-with-tanstack-query/src/lib/instantQuery.ts +93 -0
- package/template/base/tanstack-start-with-tanstack-query/src/logo.svg +12 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routeTree.gen.ts +104 -0
- package/template/base/tanstack-start-with-tanstack-query/src/router.tsx +108 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/__root.tsx +76 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/api/instant.ts +16 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/index.tsx +231 -0
- package/template/base/tanstack-start-with-tanstack-query/src/routes/login.tsx +140 -0
- package/template/base/tanstack-start-with-tanstack-query/src/styles.css +17 -0
- package/template/base/tanstack-start-with-tanstack-query/tsconfig.json +28 -0
- package/template/base/tanstack-start-with-tanstack-query/vite.config.ts +33 -0
- package/template/base/vite-react/README.md +16 -0
- package/template/base/vite-react/_gitignore +26 -0
- package/template/base/vite-react/eslint.config.js +23 -0
- package/template/base/vite-react/index.html +13 -0
- package/template/base/vite-react/package.json +35 -0
- package/template/base/vite-react/public/favicon.svg +1 -0
- package/template/base/vite-react/src/App.tsx +167 -0
- package/template/base/vite-react/src/index.css +1 -0
- package/template/base/vite-react/src/instant.perms.ts +24 -0
- package/template/base/vite-react/src/instant.schema.ts +51 -0
- package/template/base/vite-react/src/lib/db.ts +8 -0
- package/template/base/vite-react/src/main.tsx +10 -0
- package/template/base/vite-react/tsconfig.app.json +25 -0
- package/template/base/vite-react/tsconfig.json +7 -0
- package/template/base/vite-react/tsconfig.node.json +24 -0
- package/template/base/vite-react/vite.config.ts +8 -0
- package/template/base/vite-vanilla/.env.example +2 -0
- package/template/base/vite-vanilla/README.md +17 -0
- package/template/base/vite-vanilla/_gitignore +25 -0
- package/template/base/vite-vanilla/index.html +13 -0
- package/template/base/vite-vanilla/package.json +20 -0
- package/template/base/vite-vanilla/pnpm-lock.yaml +707 -0
- package/template/base/vite-vanilla/public/vite.svg +1 -0
- package/template/base/vite-vanilla/src/instant.perms.ts +24 -0
- package/template/base/vite-vanilla/src/instant.schema.ts +50 -0
- package/template/base/vite-vanilla/src/lib/db.ts +11 -0
- package/template/base/vite-vanilla/src/main.ts +242 -0
- package/template/base/vite-vanilla/src/style.css +96 -0
- package/template/base/vite-vanilla/src/typescript.svg +1 -0
- package/template/base/vite-vanilla/src/vite-env.d.ts +1 -0
- package/template/base/vite-vanilla/tsconfig.json +24 -0
- package/template/base/vue-vite/README.md +15 -0
- package/template/base/vue-vite/_gitignore +43 -0
- package/template/base/vue-vite/env.d.ts +1 -0
- package/template/base/vue-vite/index.html +12 -0
- package/template/base/vue-vite/package.json +34 -0
- package/template/base/vue-vite/src/App.vue +238 -0
- package/template/base/vue-vite/src/assets/main.css +25 -0
- package/template/base/vue-vite/src/instant.perms.ts +24 -0
- package/template/base/vue-vite/src/instant.schema.ts +46 -0
- package/template/base/vue-vite/src/lib/db.ts +8 -0
- package/template/base/vue-vite/src/main.ts +6 -0
- package/template/base/vue-vite/tsconfig.app.json +15 -0
- package/template/base/vue-vite/tsconfig.json +11 -0
- package/template/base/vue-vite/tsconfig.node.json +27 -0
- package/template/base/vue-vite/vite.config.ts +16 -0
- package/template/rules/AGENTS.md +436 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import {
|
|
8
|
+
Command,
|
|
9
|
+
CommandEmpty,
|
|
10
|
+
CommandInput,
|
|
11
|
+
CommandItem,
|
|
12
|
+
CommandList,
|
|
13
|
+
} from '@/components/ui/command';
|
|
14
|
+
import {
|
|
15
|
+
Popover,
|
|
16
|
+
PopoverContent,
|
|
17
|
+
PopoverTrigger,
|
|
18
|
+
} from '@/components/ui/popover';
|
|
19
|
+
import { cn } from '@/lib/utils';
|
|
20
|
+
import { ChevronsUpDownIcon } from 'lucide-react';
|
|
21
|
+
import {
|
|
22
|
+
createContext,
|
|
23
|
+
useCallback,
|
|
24
|
+
useContext,
|
|
25
|
+
useEffect,
|
|
26
|
+
useMemo,
|
|
27
|
+
useRef,
|
|
28
|
+
useState,
|
|
29
|
+
} from 'react';
|
|
30
|
+
|
|
31
|
+
const deviceIdRegex = /\(([\da-fA-F]{4}:[\da-fA-F]{4})\)$/;
|
|
32
|
+
|
|
33
|
+
interface MicSelectorContextType {
|
|
34
|
+
data: MediaDeviceInfo[];
|
|
35
|
+
value: string | undefined;
|
|
36
|
+
onValueChange?: (value: string) => void;
|
|
37
|
+
open: boolean;
|
|
38
|
+
onOpenChange?: (open: boolean) => void;
|
|
39
|
+
width: number;
|
|
40
|
+
setWidth?: (width: number) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const MicSelectorContext = createContext<MicSelectorContextType>({
|
|
44
|
+
data: [],
|
|
45
|
+
onOpenChange: undefined,
|
|
46
|
+
onValueChange: undefined,
|
|
47
|
+
open: false,
|
|
48
|
+
setWidth: undefined,
|
|
49
|
+
value: undefined,
|
|
50
|
+
width: 200,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export type MicSelectorProps = ComponentProps<typeof Popover> & {
|
|
54
|
+
defaultValue?: string;
|
|
55
|
+
value?: string | undefined;
|
|
56
|
+
onValueChange?: (value: string | undefined) => void;
|
|
57
|
+
open?: boolean;
|
|
58
|
+
onOpenChange?: (open: boolean) => void;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const MicSelector = ({
|
|
62
|
+
defaultValue,
|
|
63
|
+
value: controlledValue,
|
|
64
|
+
onValueChange: controlledOnValueChange,
|
|
65
|
+
defaultOpen = false,
|
|
66
|
+
open: controlledOpen,
|
|
67
|
+
onOpenChange: controlledOnOpenChange,
|
|
68
|
+
...props
|
|
69
|
+
}: MicSelectorProps) => {
|
|
70
|
+
const [value, onValueChange] = useControllableState<string | undefined>({
|
|
71
|
+
defaultProp: defaultValue,
|
|
72
|
+
onChange: controlledOnValueChange,
|
|
73
|
+
prop: controlledValue,
|
|
74
|
+
});
|
|
75
|
+
const [open, onOpenChange] = useControllableState({
|
|
76
|
+
defaultProp: defaultOpen,
|
|
77
|
+
onChange: controlledOnOpenChange,
|
|
78
|
+
prop: controlledOpen,
|
|
79
|
+
});
|
|
80
|
+
const [width, setWidth] = useState(200);
|
|
81
|
+
const { devices, loading, hasPermission, loadDevices } = useAudioDevices();
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (open && !hasPermission && !loading) {
|
|
85
|
+
loadDevices();
|
|
86
|
+
}
|
|
87
|
+
}, [open, hasPermission, loading, loadDevices]);
|
|
88
|
+
|
|
89
|
+
const contextValue = useMemo(
|
|
90
|
+
() => ({
|
|
91
|
+
data: devices,
|
|
92
|
+
onOpenChange,
|
|
93
|
+
onValueChange,
|
|
94
|
+
open,
|
|
95
|
+
setWidth,
|
|
96
|
+
value,
|
|
97
|
+
width,
|
|
98
|
+
}),
|
|
99
|
+
[devices, onOpenChange, onValueChange, open, setWidth, value, width],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<MicSelectorContext.Provider value={contextValue}>
|
|
104
|
+
<Popover {...props} onOpenChange={onOpenChange} open={open} />
|
|
105
|
+
</MicSelectorContext.Provider>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type MicSelectorTriggerProps = ComponentProps<typeof Button>;
|
|
110
|
+
|
|
111
|
+
export const MicSelectorTrigger = ({
|
|
112
|
+
children,
|
|
113
|
+
...props
|
|
114
|
+
}: MicSelectorTriggerProps) => {
|
|
115
|
+
const { setWidth } = useContext(MicSelectorContext);
|
|
116
|
+
const ref = useRef<HTMLButtonElement>(null);
|
|
117
|
+
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
// Create a ResizeObserver to detect width changes
|
|
120
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
const newWidth = (entry.target as HTMLElement).offsetWidth;
|
|
123
|
+
if (newWidth) {
|
|
124
|
+
setWidth?.(newWidth);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
if (ref.current) {
|
|
130
|
+
resizeObserver.observe(ref.current);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Clean up the observer when component unmounts
|
|
134
|
+
return () => {
|
|
135
|
+
resizeObserver.disconnect();
|
|
136
|
+
};
|
|
137
|
+
}, [setWidth]);
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<PopoverTrigger asChild>
|
|
141
|
+
<Button variant="outline" {...props} ref={ref}>
|
|
142
|
+
{children}
|
|
143
|
+
<ChevronsUpDownIcon
|
|
144
|
+
className="text-muted-foreground shrink-0"
|
|
145
|
+
size={16}
|
|
146
|
+
/>
|
|
147
|
+
</Button>
|
|
148
|
+
</PopoverTrigger>
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export type MicSelectorContentProps = ComponentProps<typeof Command> & {
|
|
153
|
+
popoverOptions?: ComponentProps<typeof PopoverContent>;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const MicSelectorContent = ({
|
|
157
|
+
className,
|
|
158
|
+
popoverOptions,
|
|
159
|
+
...props
|
|
160
|
+
}: MicSelectorContentProps) => {
|
|
161
|
+
const { width, onValueChange, value } = useContext(MicSelectorContext);
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<PopoverContent
|
|
165
|
+
className={cn('p-0', className)}
|
|
166
|
+
style={{ width }}
|
|
167
|
+
{...popoverOptions}
|
|
168
|
+
>
|
|
169
|
+
<Command onValueChange={onValueChange} value={value} {...props} />
|
|
170
|
+
</PopoverContent>
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export type MicSelectorInputProps = ComponentProps<typeof CommandInput> & {
|
|
175
|
+
value?: string;
|
|
176
|
+
defaultValue?: string;
|
|
177
|
+
onValueChange?: (value: string) => void;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const MicSelectorInput = ({ ...props }: MicSelectorInputProps) => (
|
|
181
|
+
<CommandInput placeholder="Search microphones..." {...props} />
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
export type MicSelectorListProps = Omit<
|
|
185
|
+
ComponentProps<typeof CommandList>,
|
|
186
|
+
'children'
|
|
187
|
+
> & {
|
|
188
|
+
children: (devices: MediaDeviceInfo[]) => ReactNode;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
export const MicSelectorList = ({
|
|
192
|
+
children,
|
|
193
|
+
...props
|
|
194
|
+
}: MicSelectorListProps) => {
|
|
195
|
+
const { data } = useContext(MicSelectorContext);
|
|
196
|
+
|
|
197
|
+
return <CommandList {...props}>{children(data)}</CommandList>;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export type MicSelectorEmptyProps = ComponentProps<typeof CommandEmpty>;
|
|
201
|
+
|
|
202
|
+
export const MicSelectorEmpty = ({
|
|
203
|
+
children = 'No microphone found.',
|
|
204
|
+
...props
|
|
205
|
+
}: MicSelectorEmptyProps) => <CommandEmpty {...props}>{children}</CommandEmpty>;
|
|
206
|
+
|
|
207
|
+
export type MicSelectorItemProps = ComponentProps<typeof CommandItem>;
|
|
208
|
+
|
|
209
|
+
export const MicSelectorItem = (props: MicSelectorItemProps) => {
|
|
210
|
+
const { onValueChange, onOpenChange } = useContext(MicSelectorContext);
|
|
211
|
+
|
|
212
|
+
const handleSelect = useCallback(
|
|
213
|
+
(currentValue: string) => {
|
|
214
|
+
onValueChange?.(currentValue);
|
|
215
|
+
onOpenChange?.(false);
|
|
216
|
+
},
|
|
217
|
+
[onValueChange, onOpenChange],
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
return <CommandItem onSelect={handleSelect} {...props} />;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type MicSelectorLabelProps = ComponentProps<'span'> & {
|
|
224
|
+
device: MediaDeviceInfo;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export const MicSelectorLabel = ({
|
|
228
|
+
device,
|
|
229
|
+
className,
|
|
230
|
+
...props
|
|
231
|
+
}: MicSelectorLabelProps) => {
|
|
232
|
+
const matches = device.label.match(deviceIdRegex);
|
|
233
|
+
|
|
234
|
+
if (!matches) {
|
|
235
|
+
return (
|
|
236
|
+
<span className={className} {...props}>
|
|
237
|
+
{device.label}
|
|
238
|
+
</span>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const [, deviceId] = matches;
|
|
243
|
+
const name = device.label.replace(deviceIdRegex, '');
|
|
244
|
+
|
|
245
|
+
return (
|
|
246
|
+
<span className={className} {...props}>
|
|
247
|
+
<span>{name}</span>
|
|
248
|
+
<span className="text-muted-foreground"> ({deviceId})</span>
|
|
249
|
+
</span>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export type MicSelectorValueProps = ComponentProps<'span'>;
|
|
254
|
+
|
|
255
|
+
export const MicSelectorValue = ({
|
|
256
|
+
className,
|
|
257
|
+
...props
|
|
258
|
+
}: MicSelectorValueProps) => {
|
|
259
|
+
const { data, value } = useContext(MicSelectorContext);
|
|
260
|
+
const currentDevice = data.find((d) => d.deviceId === value);
|
|
261
|
+
|
|
262
|
+
if (!currentDevice) {
|
|
263
|
+
return (
|
|
264
|
+
<span className={cn('flex-1 text-left', className)} {...props}>
|
|
265
|
+
Select microphone...
|
|
266
|
+
</span>
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<MicSelectorLabel
|
|
272
|
+
className={cn('flex-1 text-left', className)}
|
|
273
|
+
device={currentDevice}
|
|
274
|
+
{...props}
|
|
275
|
+
/>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export const useAudioDevices = () => {
|
|
280
|
+
const [devices, setDevices] = useState<MediaDeviceInfo[]>([]);
|
|
281
|
+
const [loading, setLoading] = useState(true);
|
|
282
|
+
const [error, setError] = useState<string | null>(null);
|
|
283
|
+
const [hasPermission, setHasPermission] = useState(false);
|
|
284
|
+
|
|
285
|
+
const loadDevicesWithoutPermission = useCallback(async () => {
|
|
286
|
+
try {
|
|
287
|
+
setLoading(true);
|
|
288
|
+
setError(null);
|
|
289
|
+
|
|
290
|
+
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
|
291
|
+
const audioInputs = deviceList.filter(
|
|
292
|
+
(device) => device.kind === 'audioinput',
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
setDevices(audioInputs);
|
|
296
|
+
} catch (error) {
|
|
297
|
+
const message =
|
|
298
|
+
error instanceof Error ? error.message : 'Failed to get audio devices';
|
|
299
|
+
|
|
300
|
+
setError(message);
|
|
301
|
+
console.error('Error getting audio devices:', message);
|
|
302
|
+
} finally {
|
|
303
|
+
setLoading(false);
|
|
304
|
+
}
|
|
305
|
+
}, []);
|
|
306
|
+
|
|
307
|
+
const loadDevicesWithPermission = useCallback(async () => {
|
|
308
|
+
if (loading) {
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
setLoading(true);
|
|
314
|
+
setError(null);
|
|
315
|
+
|
|
316
|
+
const tempStream = await navigator.mediaDevices.getUserMedia({
|
|
317
|
+
audio: true,
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
for (const track of tempStream.getTracks()) {
|
|
321
|
+
track.stop();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const deviceList = await navigator.mediaDevices.enumerateDevices();
|
|
325
|
+
const audioInputs = deviceList.filter(
|
|
326
|
+
(device) => device.kind === 'audioinput',
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
setDevices(audioInputs);
|
|
330
|
+
setHasPermission(true);
|
|
331
|
+
} catch (error) {
|
|
332
|
+
const message =
|
|
333
|
+
error instanceof Error ? error.message : 'Failed to get audio devices';
|
|
334
|
+
|
|
335
|
+
setError(message);
|
|
336
|
+
console.error('Error getting audio devices:', message);
|
|
337
|
+
} finally {
|
|
338
|
+
setLoading(false);
|
|
339
|
+
}
|
|
340
|
+
}, [loading]);
|
|
341
|
+
|
|
342
|
+
useEffect(() => {
|
|
343
|
+
loadDevicesWithoutPermission();
|
|
344
|
+
}, [loadDevicesWithoutPermission]);
|
|
345
|
+
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
const handleDeviceChange = () => {
|
|
348
|
+
if (hasPermission) {
|
|
349
|
+
loadDevicesWithPermission();
|
|
350
|
+
} else {
|
|
351
|
+
loadDevicesWithoutPermission();
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
navigator.mediaDevices.addEventListener('devicechange', handleDeviceChange);
|
|
356
|
+
|
|
357
|
+
return () => {
|
|
358
|
+
navigator.mediaDevices.removeEventListener(
|
|
359
|
+
'devicechange',
|
|
360
|
+
handleDeviceChange,
|
|
361
|
+
);
|
|
362
|
+
};
|
|
363
|
+
}, [hasPermission, loadDevicesWithPermission, loadDevicesWithoutPermission]);
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
devices,
|
|
367
|
+
error,
|
|
368
|
+
hasPermission,
|
|
369
|
+
loadDevices: loadDevicesWithPermission,
|
|
370
|
+
loading,
|
|
371
|
+
};
|
|
372
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Command,
|
|
5
|
+
CommandDialog,
|
|
6
|
+
CommandEmpty,
|
|
7
|
+
CommandGroup,
|
|
8
|
+
CommandInput,
|
|
9
|
+
CommandItem,
|
|
10
|
+
CommandList,
|
|
11
|
+
CommandSeparator,
|
|
12
|
+
CommandShortcut,
|
|
13
|
+
} from '@/components/ui/command';
|
|
14
|
+
import {
|
|
15
|
+
Dialog,
|
|
16
|
+
DialogContent,
|
|
17
|
+
DialogTitle,
|
|
18
|
+
DialogTrigger,
|
|
19
|
+
} from '@/components/ui/dialog';
|
|
20
|
+
import { cn } from '@/lib/utils';
|
|
21
|
+
|
|
22
|
+
export type ModelSelectorProps = ComponentProps<typeof Dialog>;
|
|
23
|
+
|
|
24
|
+
export const ModelSelector = (props: ModelSelectorProps) => (
|
|
25
|
+
<Dialog {...props} />
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export type ModelSelectorTriggerProps = ComponentProps<typeof DialogTrigger>;
|
|
29
|
+
|
|
30
|
+
export const ModelSelectorTrigger = (props: ModelSelectorTriggerProps) => (
|
|
31
|
+
<DialogTrigger {...props} />
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export type ModelSelectorContentProps = ComponentProps<typeof DialogContent> & {
|
|
35
|
+
title?: ReactNode;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const ModelSelectorContent = ({
|
|
39
|
+
className,
|
|
40
|
+
children,
|
|
41
|
+
title = 'Model Selector',
|
|
42
|
+
...props
|
|
43
|
+
}: ModelSelectorContentProps) => (
|
|
44
|
+
<DialogContent
|
|
45
|
+
aria-describedby={undefined}
|
|
46
|
+
className={cn(
|
|
47
|
+
'outline-border! border-none! p-0 outline! outline-solid!',
|
|
48
|
+
className,
|
|
49
|
+
)}
|
|
50
|
+
{...props}
|
|
51
|
+
>
|
|
52
|
+
<DialogTitle className="sr-only">{title}</DialogTitle>
|
|
53
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-auto">
|
|
54
|
+
{children}
|
|
55
|
+
</Command>
|
|
56
|
+
</DialogContent>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export type ModelSelectorDialogProps = ComponentProps<typeof CommandDialog>;
|
|
60
|
+
|
|
61
|
+
export const ModelSelectorDialog = (props: ModelSelectorDialogProps) => (
|
|
62
|
+
<CommandDialog {...props} />
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export type ModelSelectorInputProps = ComponentProps<typeof CommandInput>;
|
|
66
|
+
|
|
67
|
+
export const ModelSelectorInput = ({
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
}: ModelSelectorInputProps) => (
|
|
71
|
+
<CommandInput className={cn('h-auto py-3.5', className)} {...props} />
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
export type ModelSelectorListProps = ComponentProps<typeof CommandList>;
|
|
75
|
+
|
|
76
|
+
export const ModelSelectorList = (props: ModelSelectorListProps) => (
|
|
77
|
+
<CommandList {...props} />
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
export type ModelSelectorEmptyProps = ComponentProps<typeof CommandEmpty>;
|
|
81
|
+
|
|
82
|
+
export const ModelSelectorEmpty = (props: ModelSelectorEmptyProps) => (
|
|
83
|
+
<CommandEmpty {...props} />
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export type ModelSelectorGroupProps = ComponentProps<typeof CommandGroup>;
|
|
87
|
+
|
|
88
|
+
export const ModelSelectorGroup = (props: ModelSelectorGroupProps) => (
|
|
89
|
+
<CommandGroup {...props} />
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
export type ModelSelectorItemProps = ComponentProps<typeof CommandItem>;
|
|
93
|
+
|
|
94
|
+
export const ModelSelectorItem = (props: ModelSelectorItemProps) => (
|
|
95
|
+
<CommandItem {...props} />
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
export type ModelSelectorShortcutProps = ComponentProps<typeof CommandShortcut>;
|
|
99
|
+
|
|
100
|
+
export const ModelSelectorShortcut = (props: ModelSelectorShortcutProps) => (
|
|
101
|
+
<CommandShortcut {...props} />
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export type ModelSelectorSeparatorProps = ComponentProps<
|
|
105
|
+
typeof CommandSeparator
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
export const ModelSelectorSeparator = (props: ModelSelectorSeparatorProps) => (
|
|
109
|
+
<CommandSeparator {...props} />
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
export type ModelSelectorLogoProps = Omit<
|
|
113
|
+
ComponentProps<'img'>,
|
|
114
|
+
'src' | 'alt'
|
|
115
|
+
> & {
|
|
116
|
+
provider:
|
|
117
|
+
| 'moonshotai-cn'
|
|
118
|
+
| 'lucidquery'
|
|
119
|
+
| 'moonshotai'
|
|
120
|
+
| 'zai-coding-plan'
|
|
121
|
+
| 'alibaba'
|
|
122
|
+
| 'xai'
|
|
123
|
+
| 'vultr'
|
|
124
|
+
| 'nvidia'
|
|
125
|
+
| 'upstage'
|
|
126
|
+
| 'groq'
|
|
127
|
+
| 'github-copilot'
|
|
128
|
+
| 'mistral'
|
|
129
|
+
| 'vercel'
|
|
130
|
+
| 'nebius'
|
|
131
|
+
| 'deepseek'
|
|
132
|
+
| 'alibaba-cn'
|
|
133
|
+
| 'google-vertex-anthropic'
|
|
134
|
+
| 'venice'
|
|
135
|
+
| 'chutes'
|
|
136
|
+
| 'cortecs'
|
|
137
|
+
| 'github-models'
|
|
138
|
+
| 'togetherai'
|
|
139
|
+
| 'azure'
|
|
140
|
+
| 'baseten'
|
|
141
|
+
| 'huggingface'
|
|
142
|
+
| 'opencode'
|
|
143
|
+
| 'fastrouter'
|
|
144
|
+
| 'google'
|
|
145
|
+
| 'google-vertex'
|
|
146
|
+
| 'cloudflare-workers-ai'
|
|
147
|
+
| 'inception'
|
|
148
|
+
| 'wandb'
|
|
149
|
+
| 'openai'
|
|
150
|
+
| 'zhipuai-coding-plan'
|
|
151
|
+
| 'perplexity'
|
|
152
|
+
| 'openrouter'
|
|
153
|
+
| 'zenmux'
|
|
154
|
+
| 'v0'
|
|
155
|
+
| 'iflowcn'
|
|
156
|
+
| 'synthetic'
|
|
157
|
+
| 'deepinfra'
|
|
158
|
+
| 'zhipuai'
|
|
159
|
+
| 'submodel'
|
|
160
|
+
| 'zai'
|
|
161
|
+
| 'inference'
|
|
162
|
+
| 'requesty'
|
|
163
|
+
| 'morph'
|
|
164
|
+
| 'lmstudio'
|
|
165
|
+
| 'anthropic'
|
|
166
|
+
| 'aihubmix'
|
|
167
|
+
| 'fireworks-ai'
|
|
168
|
+
| 'modelscope'
|
|
169
|
+
| 'llama'
|
|
170
|
+
| 'scaleway'
|
|
171
|
+
| 'amazon-bedrock'
|
|
172
|
+
| 'cerebras'
|
|
173
|
+
// oxlint-disable-next-line typescript-eslint(ban-types) -- intentional pattern for autocomplete-friendly string union
|
|
174
|
+
| (string & {});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const ModelSelectorLogo = ({
|
|
178
|
+
provider,
|
|
179
|
+
className,
|
|
180
|
+
...props
|
|
181
|
+
}: ModelSelectorLogoProps) => (
|
|
182
|
+
<img
|
|
183
|
+
{...props}
|
|
184
|
+
alt={`${provider} logo`}
|
|
185
|
+
className={cn('size-3 dark:invert', className)}
|
|
186
|
+
height={12}
|
|
187
|
+
src={`https://models.dev/logos/${provider}.svg`}
|
|
188
|
+
width={12}
|
|
189
|
+
/>
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
export type ModelSelectorLogoGroupProps = ComponentProps<'div'>;
|
|
193
|
+
|
|
194
|
+
export const ModelSelectorLogoGroup = ({
|
|
195
|
+
className,
|
|
196
|
+
...props
|
|
197
|
+
}: ModelSelectorLogoGroupProps) => (
|
|
198
|
+
<div
|
|
199
|
+
className={cn(
|
|
200
|
+
'[&>img]:bg-background dark:[&>img]:bg-foreground flex shrink-0 items-center -space-x-1 [&>img]:rounded-full [&>img]:p-px [&>img]:ring-1',
|
|
201
|
+
className,
|
|
202
|
+
)}
|
|
203
|
+
{...props}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
export type ModelSelectorNameProps = ComponentProps<'span'>;
|
|
208
|
+
|
|
209
|
+
export const ModelSelectorName = ({
|
|
210
|
+
className,
|
|
211
|
+
...props
|
|
212
|
+
}: ModelSelectorNameProps) => (
|
|
213
|
+
<span className={cn('flex-1 truncate text-left', className)} {...props} />
|
|
214
|
+
);
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Card,
|
|
5
|
+
CardAction,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardDescription,
|
|
8
|
+
CardFooter,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from '@/components/ui/card';
|
|
12
|
+
import { cn } from '@/lib/utils';
|
|
13
|
+
import { Handle, Position } from '@xyflow/react';
|
|
14
|
+
|
|
15
|
+
export type NodeProps = ComponentProps<typeof Card> & {
|
|
16
|
+
handles: {
|
|
17
|
+
target: boolean;
|
|
18
|
+
source: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Node = ({ handles, className, ...props }: NodeProps) => (
|
|
23
|
+
<Card
|
|
24
|
+
className={cn(
|
|
25
|
+
'node-container relative size-full h-auto w-sm gap-0 rounded-md p-0',
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
28
|
+
{...props}
|
|
29
|
+
>
|
|
30
|
+
{handles.target && <Handle position={Position.Left} type="target" />}
|
|
31
|
+
{handles.source && <Handle position={Position.Right} type="source" />}
|
|
32
|
+
{props.children}
|
|
33
|
+
</Card>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
export type NodeHeaderProps = ComponentProps<typeof CardHeader>;
|
|
37
|
+
|
|
38
|
+
export const NodeHeader = ({ className, ...props }: NodeHeaderProps) => (
|
|
39
|
+
<CardHeader
|
|
40
|
+
className={cn('bg-secondary gap-0.5 rounded-t-md border-b p-3!', className)}
|
|
41
|
+
{...props}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export type NodeTitleProps = ComponentProps<typeof CardTitle>;
|
|
46
|
+
|
|
47
|
+
export const NodeTitle = (props: NodeTitleProps) => <CardTitle {...props} />;
|
|
48
|
+
|
|
49
|
+
export type NodeDescriptionProps = ComponentProps<typeof CardDescription>;
|
|
50
|
+
|
|
51
|
+
export const NodeDescription = (props: NodeDescriptionProps) => (
|
|
52
|
+
<CardDescription {...props} />
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export type NodeActionProps = ComponentProps<typeof CardAction>;
|
|
56
|
+
|
|
57
|
+
export const NodeAction = (props: NodeActionProps) => <CardAction {...props} />;
|
|
58
|
+
|
|
59
|
+
export type NodeContentProps = ComponentProps<typeof CardContent>;
|
|
60
|
+
|
|
61
|
+
export const NodeContent = ({ className, ...props }: NodeContentProps) => (
|
|
62
|
+
<CardContent className={cn('p-3', className)} {...props} />
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export type NodeFooterProps = ComponentProps<typeof CardFooter>;
|
|
66
|
+
|
|
67
|
+
export const NodeFooter = ({ className, ...props }: NodeFooterProps) => (
|
|
68
|
+
<CardFooter
|
|
69
|
+
className={cn('bg-secondary rounded-b-md border-t p-3!', className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|