create-sidekick-app 0.0.1 → 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 +29 -2
- package/dist/index.js +59 -0
- package/package.json +65 -4
- 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,427 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { FileUIPart, SourceDocumentUIPart } from 'ai';
|
|
4
|
+
import type { ComponentProps, HTMLAttributes, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import {
|
|
8
|
+
HoverCard,
|
|
9
|
+
HoverCardContent,
|
|
10
|
+
HoverCardTrigger,
|
|
11
|
+
} from '@/components/ui/hover-card';
|
|
12
|
+
import { cn } from '@/lib/utils';
|
|
13
|
+
import {
|
|
14
|
+
FileTextIcon,
|
|
15
|
+
GlobeIcon,
|
|
16
|
+
ImageIcon,
|
|
17
|
+
Music2Icon,
|
|
18
|
+
PaperclipIcon,
|
|
19
|
+
VideoIcon,
|
|
20
|
+
XIcon,
|
|
21
|
+
} from 'lucide-react';
|
|
22
|
+
import { createContext, useCallback, useContext, useMemo } from 'react';
|
|
23
|
+
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Types
|
|
26
|
+
// ============================================================================
|
|
27
|
+
|
|
28
|
+
export type AttachmentData =
|
|
29
|
+
| (FileUIPart & { id: string })
|
|
30
|
+
| (SourceDocumentUIPart & { id: string });
|
|
31
|
+
|
|
32
|
+
export type AttachmentMediaCategory =
|
|
33
|
+
| 'image'
|
|
34
|
+
| 'video'
|
|
35
|
+
| 'audio'
|
|
36
|
+
| 'document'
|
|
37
|
+
| 'source'
|
|
38
|
+
| 'unknown';
|
|
39
|
+
|
|
40
|
+
export type AttachmentVariant = 'grid' | 'inline' | 'list';
|
|
41
|
+
|
|
42
|
+
const mediaCategoryIcons: Record<AttachmentMediaCategory, typeof ImageIcon> = {
|
|
43
|
+
audio: Music2Icon,
|
|
44
|
+
document: FileTextIcon,
|
|
45
|
+
image: ImageIcon,
|
|
46
|
+
source: GlobeIcon,
|
|
47
|
+
unknown: PaperclipIcon,
|
|
48
|
+
video: VideoIcon,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
// Utility Functions
|
|
53
|
+
// ============================================================================
|
|
54
|
+
|
|
55
|
+
export const getMediaCategory = (
|
|
56
|
+
data: AttachmentData,
|
|
57
|
+
): AttachmentMediaCategory => {
|
|
58
|
+
if (data.type === 'source-document') {
|
|
59
|
+
return 'source';
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const mediaType = data.mediaType ?? '';
|
|
63
|
+
|
|
64
|
+
if (mediaType.startsWith('image/')) {
|
|
65
|
+
return 'image';
|
|
66
|
+
}
|
|
67
|
+
if (mediaType.startsWith('video/')) {
|
|
68
|
+
return 'video';
|
|
69
|
+
}
|
|
70
|
+
if (mediaType.startsWith('audio/')) {
|
|
71
|
+
return 'audio';
|
|
72
|
+
}
|
|
73
|
+
if (mediaType.startsWith('application/') || mediaType.startsWith('text/')) {
|
|
74
|
+
return 'document';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return 'unknown';
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const getAttachmentLabel = (data: AttachmentData): string => {
|
|
81
|
+
if (data.type === 'source-document') {
|
|
82
|
+
return data.title || data.filename || 'Source';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const category = getMediaCategory(data);
|
|
86
|
+
return data.filename || (category === 'image' ? 'Image' : 'Attachment');
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const renderAttachmentImage = (
|
|
90
|
+
url: string,
|
|
91
|
+
filename: string | undefined,
|
|
92
|
+
isGrid: boolean,
|
|
93
|
+
) =>
|
|
94
|
+
isGrid ? (
|
|
95
|
+
<img
|
|
96
|
+
alt={filename || 'Image'}
|
|
97
|
+
className="size-full object-cover"
|
|
98
|
+
height={96}
|
|
99
|
+
src={url}
|
|
100
|
+
width={96}
|
|
101
|
+
/>
|
|
102
|
+
) : (
|
|
103
|
+
<img
|
|
104
|
+
alt={filename || 'Image'}
|
|
105
|
+
className="size-full rounded object-cover"
|
|
106
|
+
height={20}
|
|
107
|
+
src={url}
|
|
108
|
+
width={20}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// ============================================================================
|
|
113
|
+
// Contexts
|
|
114
|
+
// ============================================================================
|
|
115
|
+
|
|
116
|
+
interface AttachmentsContextValue {
|
|
117
|
+
variant: AttachmentVariant;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const AttachmentsContext = createContext<AttachmentsContextValue | null>(null);
|
|
121
|
+
|
|
122
|
+
interface AttachmentContextValue {
|
|
123
|
+
data: AttachmentData;
|
|
124
|
+
mediaCategory: AttachmentMediaCategory;
|
|
125
|
+
onRemove?: () => void;
|
|
126
|
+
variant: AttachmentVariant;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const AttachmentContext = createContext<AttachmentContextValue | null>(null);
|
|
130
|
+
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Hooks
|
|
133
|
+
// ============================================================================
|
|
134
|
+
|
|
135
|
+
export const useAttachmentsContext = () =>
|
|
136
|
+
useContext(AttachmentsContext) ?? { variant: 'grid' as const };
|
|
137
|
+
|
|
138
|
+
export const useAttachmentContext = () => {
|
|
139
|
+
const ctx = useContext(AttachmentContext);
|
|
140
|
+
if (!ctx) {
|
|
141
|
+
throw new Error('Attachment components must be used within <Attachment>');
|
|
142
|
+
}
|
|
143
|
+
return ctx;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// ============================================================================
|
|
147
|
+
// Attachments - Container
|
|
148
|
+
// ============================================================================
|
|
149
|
+
|
|
150
|
+
export type AttachmentsProps = HTMLAttributes<HTMLDivElement> & {
|
|
151
|
+
variant?: AttachmentVariant;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const Attachments = ({
|
|
155
|
+
variant = 'grid',
|
|
156
|
+
className,
|
|
157
|
+
children,
|
|
158
|
+
...props
|
|
159
|
+
}: AttachmentsProps) => {
|
|
160
|
+
const contextValue = useMemo(() => ({ variant }), [variant]);
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<AttachmentsContext.Provider value={contextValue}>
|
|
164
|
+
<div
|
|
165
|
+
className={cn(
|
|
166
|
+
'flex items-start',
|
|
167
|
+
variant === 'list' ? 'flex-col gap-2' : 'flex-wrap gap-2',
|
|
168
|
+
variant === 'grid' && 'ml-auto w-fit',
|
|
169
|
+
className,
|
|
170
|
+
)}
|
|
171
|
+
{...props}
|
|
172
|
+
>
|
|
173
|
+
{children}
|
|
174
|
+
</div>
|
|
175
|
+
</AttachmentsContext.Provider>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// ============================================================================
|
|
180
|
+
// Attachment - Item
|
|
181
|
+
// ============================================================================
|
|
182
|
+
|
|
183
|
+
export type AttachmentProps = HTMLAttributes<HTMLDivElement> & {
|
|
184
|
+
data: AttachmentData;
|
|
185
|
+
onRemove?: () => void;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const Attachment = ({
|
|
189
|
+
data,
|
|
190
|
+
onRemove,
|
|
191
|
+
className,
|
|
192
|
+
children,
|
|
193
|
+
...props
|
|
194
|
+
}: AttachmentProps) => {
|
|
195
|
+
const { variant } = useAttachmentsContext();
|
|
196
|
+
const mediaCategory = getMediaCategory(data);
|
|
197
|
+
|
|
198
|
+
const contextValue = useMemo<AttachmentContextValue>(
|
|
199
|
+
() => ({ data, mediaCategory, onRemove, variant }),
|
|
200
|
+
[data, mediaCategory, onRemove, variant],
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<AttachmentContext.Provider value={contextValue}>
|
|
205
|
+
<div
|
|
206
|
+
className={cn(
|
|
207
|
+
'group relative',
|
|
208
|
+
variant === 'grid' && 'size-24 overflow-hidden rounded-lg',
|
|
209
|
+
variant === 'inline' && [
|
|
210
|
+
'flex h-8 cursor-pointer items-center gap-1.5 select-none',
|
|
211
|
+
'border-border rounded-md border px-1.5',
|
|
212
|
+
'text-sm font-medium transition-all',
|
|
213
|
+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
|
|
214
|
+
],
|
|
215
|
+
variant === 'list' && [
|
|
216
|
+
'flex w-full items-center gap-3 rounded-lg border p-3',
|
|
217
|
+
'hover:bg-accent/50',
|
|
218
|
+
],
|
|
219
|
+
className,
|
|
220
|
+
)}
|
|
221
|
+
{...props}
|
|
222
|
+
>
|
|
223
|
+
{children}
|
|
224
|
+
</div>
|
|
225
|
+
</AttachmentContext.Provider>
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// ============================================================================
|
|
230
|
+
// AttachmentPreview - Media preview
|
|
231
|
+
// ============================================================================
|
|
232
|
+
|
|
233
|
+
export type AttachmentPreviewProps = HTMLAttributes<HTMLDivElement> & {
|
|
234
|
+
fallbackIcon?: ReactNode;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const AttachmentPreview = ({
|
|
238
|
+
fallbackIcon,
|
|
239
|
+
className,
|
|
240
|
+
...props
|
|
241
|
+
}: AttachmentPreviewProps) => {
|
|
242
|
+
const { data, mediaCategory, variant } = useAttachmentContext();
|
|
243
|
+
|
|
244
|
+
const iconSize = variant === 'inline' ? 'size-3' : 'size-4';
|
|
245
|
+
|
|
246
|
+
const renderIcon = (Icon: typeof ImageIcon) => (
|
|
247
|
+
<Icon className={cn(iconSize, 'text-muted-foreground')} />
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const renderContent = () => {
|
|
251
|
+
if (mediaCategory === 'image' && data.type === 'file' && data.url) {
|
|
252
|
+
return renderAttachmentImage(data.url, data.filename, variant === 'grid');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (mediaCategory === 'video' && data.type === 'file' && data.url) {
|
|
256
|
+
return <video className="size-full object-cover" muted src={data.url} />;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const Icon = mediaCategoryIcons[mediaCategory];
|
|
260
|
+
return fallbackIcon ?? renderIcon(Icon);
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<div
|
|
265
|
+
className={cn(
|
|
266
|
+
'flex shrink-0 items-center justify-center overflow-hidden',
|
|
267
|
+
variant === 'grid' && 'bg-muted size-full',
|
|
268
|
+
variant === 'inline' && 'bg-background size-5 rounded',
|
|
269
|
+
variant === 'list' && 'bg-muted size-12 rounded',
|
|
270
|
+
className,
|
|
271
|
+
)}
|
|
272
|
+
{...props}
|
|
273
|
+
>
|
|
274
|
+
{renderContent()}
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
// ============================================================================
|
|
280
|
+
// AttachmentInfo - Name and type display
|
|
281
|
+
// ============================================================================
|
|
282
|
+
|
|
283
|
+
export type AttachmentInfoProps = HTMLAttributes<HTMLDivElement> & {
|
|
284
|
+
showMediaType?: boolean;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export const AttachmentInfo = ({
|
|
288
|
+
showMediaType = false,
|
|
289
|
+
className,
|
|
290
|
+
...props
|
|
291
|
+
}: AttachmentInfoProps) => {
|
|
292
|
+
const { data, variant } = useAttachmentContext();
|
|
293
|
+
const label = getAttachmentLabel(data);
|
|
294
|
+
|
|
295
|
+
if (variant === 'grid') {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<div className={cn('min-w-0 flex-1', className)} {...props}>
|
|
301
|
+
<span className="block truncate">{label}</span>
|
|
302
|
+
{showMediaType && data.mediaType && (
|
|
303
|
+
<span className="text-muted-foreground block truncate text-xs">
|
|
304
|
+
{data.mediaType}
|
|
305
|
+
</span>
|
|
306
|
+
)}
|
|
307
|
+
</div>
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// ============================================================================
|
|
312
|
+
// AttachmentRemove - Remove button
|
|
313
|
+
// ============================================================================
|
|
314
|
+
|
|
315
|
+
export type AttachmentRemoveProps = ComponentProps<typeof Button> & {
|
|
316
|
+
label?: string;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export const AttachmentRemove = ({
|
|
320
|
+
label = 'Remove',
|
|
321
|
+
className,
|
|
322
|
+
children,
|
|
323
|
+
...props
|
|
324
|
+
}: AttachmentRemoveProps) => {
|
|
325
|
+
const { onRemove, variant } = useAttachmentContext();
|
|
326
|
+
|
|
327
|
+
const handleClick = useCallback(
|
|
328
|
+
(e: React.MouseEvent) => {
|
|
329
|
+
e.stopPropagation();
|
|
330
|
+
onRemove?.();
|
|
331
|
+
},
|
|
332
|
+
[onRemove],
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
if (!onRemove) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return (
|
|
340
|
+
<Button
|
|
341
|
+
aria-label={label}
|
|
342
|
+
className={cn(
|
|
343
|
+
variant === 'grid' && [
|
|
344
|
+
'absolute top-2 right-2 size-6 rounded-full p-0',
|
|
345
|
+
'bg-background/80 backdrop-blur-sm',
|
|
346
|
+
'opacity-0 transition-opacity group-hover:opacity-100',
|
|
347
|
+
'hover:bg-background',
|
|
348
|
+
'[&>svg]:size-3',
|
|
349
|
+
],
|
|
350
|
+
variant === 'inline' && [
|
|
351
|
+
'size-5 rounded p-0',
|
|
352
|
+
'opacity-0 transition-opacity group-hover:opacity-100',
|
|
353
|
+
'[&>svg]:size-2.5',
|
|
354
|
+
],
|
|
355
|
+
variant === 'list' && ['size-8 shrink-0 rounded p-0', '[&>svg]:size-4'],
|
|
356
|
+
className,
|
|
357
|
+
)}
|
|
358
|
+
onClick={handleClick}
|
|
359
|
+
type="button"
|
|
360
|
+
variant="ghost"
|
|
361
|
+
{...props}
|
|
362
|
+
>
|
|
363
|
+
{children ?? <XIcon />}
|
|
364
|
+
<span className="sr-only">{label}</span>
|
|
365
|
+
</Button>
|
|
366
|
+
);
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// ============================================================================
|
|
370
|
+
// AttachmentHoverCard - Hover preview
|
|
371
|
+
// ============================================================================
|
|
372
|
+
|
|
373
|
+
export type AttachmentHoverCardProps = ComponentProps<typeof HoverCard>;
|
|
374
|
+
|
|
375
|
+
export const AttachmentHoverCard = ({
|
|
376
|
+
openDelay = 0,
|
|
377
|
+
closeDelay = 0,
|
|
378
|
+
...props
|
|
379
|
+
}: AttachmentHoverCardProps) => (
|
|
380
|
+
<HoverCard closeDelay={closeDelay} openDelay={openDelay} {...props} />
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
export type AttachmentHoverCardTriggerProps = ComponentProps<
|
|
384
|
+
typeof HoverCardTrigger
|
|
385
|
+
>;
|
|
386
|
+
|
|
387
|
+
export const AttachmentHoverCardTrigger = (
|
|
388
|
+
props: AttachmentHoverCardTriggerProps,
|
|
389
|
+
) => <HoverCardTrigger {...props} />;
|
|
390
|
+
|
|
391
|
+
export type AttachmentHoverCardContentProps = ComponentProps<
|
|
392
|
+
typeof HoverCardContent
|
|
393
|
+
>;
|
|
394
|
+
|
|
395
|
+
export const AttachmentHoverCardContent = ({
|
|
396
|
+
align = 'start',
|
|
397
|
+
className,
|
|
398
|
+
...props
|
|
399
|
+
}: AttachmentHoverCardContentProps) => (
|
|
400
|
+
<HoverCardContent
|
|
401
|
+
align={align}
|
|
402
|
+
className={cn('w-auto p-2', className)}
|
|
403
|
+
{...props}
|
|
404
|
+
/>
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
// ============================================================================
|
|
408
|
+
// AttachmentEmpty - Empty state
|
|
409
|
+
// ============================================================================
|
|
410
|
+
|
|
411
|
+
export type AttachmentEmptyProps = HTMLAttributes<HTMLDivElement>;
|
|
412
|
+
|
|
413
|
+
export const AttachmentEmpty = ({
|
|
414
|
+
className,
|
|
415
|
+
children,
|
|
416
|
+
...props
|
|
417
|
+
}: AttachmentEmptyProps) => (
|
|
418
|
+
<div
|
|
419
|
+
className={cn(
|
|
420
|
+
'text-muted-foreground flex items-center justify-center p-4 text-sm',
|
|
421
|
+
className,
|
|
422
|
+
)}
|
|
423
|
+
{...props}
|
|
424
|
+
>
|
|
425
|
+
{children ?? 'No attachments'}
|
|
426
|
+
</div>
|
|
427
|
+
);
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { Experimental_SpeechResult as SpeechResult } from 'ai';
|
|
4
|
+
import type { ComponentProps, CSSProperties } from 'react';
|
|
5
|
+
|
|
6
|
+
import { Button } from '@/components/ui/button';
|
|
7
|
+
import { ButtonGroup, ButtonGroupText } from '@/components/ui/button-group';
|
|
8
|
+
import { cn } from '@/lib/utils';
|
|
9
|
+
import {
|
|
10
|
+
MediaControlBar,
|
|
11
|
+
MediaController,
|
|
12
|
+
MediaDurationDisplay,
|
|
13
|
+
MediaMuteButton,
|
|
14
|
+
MediaPlayButton,
|
|
15
|
+
MediaSeekBackwardButton,
|
|
16
|
+
MediaSeekForwardButton,
|
|
17
|
+
MediaTimeDisplay,
|
|
18
|
+
MediaTimeRange,
|
|
19
|
+
MediaVolumeRange,
|
|
20
|
+
} from 'media-chrome/react';
|
|
21
|
+
|
|
22
|
+
export type AudioPlayerProps = Omit<
|
|
23
|
+
ComponentProps<typeof MediaController>,
|
|
24
|
+
'audio'
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const AudioPlayer = ({
|
|
28
|
+
children,
|
|
29
|
+
style,
|
|
30
|
+
...props
|
|
31
|
+
}: AudioPlayerProps) => (
|
|
32
|
+
<MediaController
|
|
33
|
+
audio
|
|
34
|
+
data-slot="audio-player"
|
|
35
|
+
style={
|
|
36
|
+
{
|
|
37
|
+
'--media-background-color': 'transparent',
|
|
38
|
+
'--media-button-icon-height': '1rem',
|
|
39
|
+
'--media-button-icon-width': '1rem',
|
|
40
|
+
'--media-control-background': 'transparent',
|
|
41
|
+
'--media-control-hover-background': 'var(--color-accent)',
|
|
42
|
+
'--media-control-padding': '0',
|
|
43
|
+
'--media-font': 'var(--font-sans)',
|
|
44
|
+
'--media-font-size': '10px',
|
|
45
|
+
'--media-icon-color': 'currentColor',
|
|
46
|
+
'--media-preview-time-background': 'var(--color-background)',
|
|
47
|
+
'--media-preview-time-border-radius': 'var(--radius-md)',
|
|
48
|
+
'--media-preview-time-text-shadow': 'none',
|
|
49
|
+
'--media-primary-color': 'var(--color-primary)',
|
|
50
|
+
'--media-range-bar-color': 'var(--color-primary)',
|
|
51
|
+
'--media-range-track-background': 'var(--color-secondary)',
|
|
52
|
+
'--media-secondary-color': 'var(--color-secondary)',
|
|
53
|
+
'--media-text-color': 'var(--color-foreground)',
|
|
54
|
+
'--media-tooltip-arrow-display': 'none',
|
|
55
|
+
'--media-tooltip-background': 'var(--color-background)',
|
|
56
|
+
'--media-tooltip-border-radius': 'var(--radius-md)',
|
|
57
|
+
...style,
|
|
58
|
+
} as CSSProperties
|
|
59
|
+
}
|
|
60
|
+
{...props}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</MediaController>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
export type AudioPlayerElementProps = Omit<ComponentProps<'audio'>, 'src'> &
|
|
67
|
+
(
|
|
68
|
+
| {
|
|
69
|
+
data: SpeechResult['audio'];
|
|
70
|
+
}
|
|
71
|
+
| {
|
|
72
|
+
src: string;
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
export const AudioPlayerElement = ({ ...props }: AudioPlayerElementProps) => (
|
|
77
|
+
// oxlint-disable-next-line eslint-plugin-jsx-a11y(media-has-caption) -- audio player captions are provided by consumer
|
|
78
|
+
<audio
|
|
79
|
+
data-slot="audio-player-element"
|
|
80
|
+
slot="media"
|
|
81
|
+
src={
|
|
82
|
+
'src' in props
|
|
83
|
+
? props.src
|
|
84
|
+
: `data:${props.data.mediaType};base64,${props.data.base64}`
|
|
85
|
+
}
|
|
86
|
+
{...props}
|
|
87
|
+
/>
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
export type AudioPlayerControlBarProps = ComponentProps<typeof MediaControlBar>;
|
|
91
|
+
|
|
92
|
+
export const AudioPlayerControlBar = ({
|
|
93
|
+
children,
|
|
94
|
+
...props
|
|
95
|
+
}: AudioPlayerControlBarProps) => (
|
|
96
|
+
<MediaControlBar data-slot="audio-player-control-bar" {...props}>
|
|
97
|
+
<ButtonGroup orientation="horizontal">{children}</ButtonGroup>
|
|
98
|
+
</MediaControlBar>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
export type AudioPlayerPlayButtonProps = ComponentProps<typeof MediaPlayButton>;
|
|
102
|
+
|
|
103
|
+
export const AudioPlayerPlayButton = ({
|
|
104
|
+
className,
|
|
105
|
+
...props
|
|
106
|
+
}: AudioPlayerPlayButtonProps) => (
|
|
107
|
+
<Button asChild size="icon-sm" variant="outline">
|
|
108
|
+
<MediaPlayButton
|
|
109
|
+
className={cn('bg-transparent', className)}
|
|
110
|
+
data-slot="audio-player-play-button"
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
</Button>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
export type AudioPlayerSeekBackwardButtonProps = ComponentProps<
|
|
117
|
+
typeof MediaSeekBackwardButton
|
|
118
|
+
>;
|
|
119
|
+
|
|
120
|
+
export const AudioPlayerSeekBackwardButton = ({
|
|
121
|
+
seekOffset = 10,
|
|
122
|
+
...props
|
|
123
|
+
}: AudioPlayerSeekBackwardButtonProps) => (
|
|
124
|
+
<Button asChild size="icon-sm" variant="outline">
|
|
125
|
+
<MediaSeekBackwardButton
|
|
126
|
+
data-slot="audio-player-seek-backward-button"
|
|
127
|
+
seekOffset={seekOffset}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
</Button>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
export type AudioPlayerSeekForwardButtonProps = ComponentProps<
|
|
134
|
+
typeof MediaSeekForwardButton
|
|
135
|
+
>;
|
|
136
|
+
|
|
137
|
+
export const AudioPlayerSeekForwardButton = ({
|
|
138
|
+
seekOffset = 10,
|
|
139
|
+
...props
|
|
140
|
+
}: AudioPlayerSeekForwardButtonProps) => (
|
|
141
|
+
<Button asChild size="icon-sm" variant="outline">
|
|
142
|
+
<MediaSeekForwardButton
|
|
143
|
+
data-slot="audio-player-seek-forward-button"
|
|
144
|
+
seekOffset={seekOffset}
|
|
145
|
+
{...props}
|
|
146
|
+
/>
|
|
147
|
+
</Button>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
export type AudioPlayerTimeDisplayProps = ComponentProps<
|
|
151
|
+
typeof MediaTimeDisplay
|
|
152
|
+
>;
|
|
153
|
+
|
|
154
|
+
export const AudioPlayerTimeDisplay = ({
|
|
155
|
+
className,
|
|
156
|
+
...props
|
|
157
|
+
}: AudioPlayerTimeDisplayProps) => (
|
|
158
|
+
<ButtonGroupText asChild className="bg-transparent">
|
|
159
|
+
<MediaTimeDisplay
|
|
160
|
+
className={cn('tabular-nums', className)}
|
|
161
|
+
data-slot="audio-player-time-display"
|
|
162
|
+
{...props}
|
|
163
|
+
/>
|
|
164
|
+
</ButtonGroupText>
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
export type AudioPlayerTimeRangeProps = ComponentProps<typeof MediaTimeRange>;
|
|
168
|
+
|
|
169
|
+
export const AudioPlayerTimeRange = ({
|
|
170
|
+
className,
|
|
171
|
+
...props
|
|
172
|
+
}: AudioPlayerTimeRangeProps) => (
|
|
173
|
+
<ButtonGroupText asChild className="bg-transparent">
|
|
174
|
+
<MediaTimeRange
|
|
175
|
+
className={cn('', className)}
|
|
176
|
+
data-slot="audio-player-time-range"
|
|
177
|
+
{...props}
|
|
178
|
+
/>
|
|
179
|
+
</ButtonGroupText>
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
export type AudioPlayerDurationDisplayProps = ComponentProps<
|
|
183
|
+
typeof MediaDurationDisplay
|
|
184
|
+
>;
|
|
185
|
+
|
|
186
|
+
export const AudioPlayerDurationDisplay = ({
|
|
187
|
+
className,
|
|
188
|
+
...props
|
|
189
|
+
}: AudioPlayerDurationDisplayProps) => (
|
|
190
|
+
<ButtonGroupText asChild className="bg-transparent">
|
|
191
|
+
<MediaDurationDisplay
|
|
192
|
+
className={cn('tabular-nums', className)}
|
|
193
|
+
data-slot="audio-player-duration-display"
|
|
194
|
+
{...props}
|
|
195
|
+
/>
|
|
196
|
+
</ButtonGroupText>
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
export type AudioPlayerMuteButtonProps = ComponentProps<typeof MediaMuteButton>;
|
|
200
|
+
|
|
201
|
+
export const AudioPlayerMuteButton = ({
|
|
202
|
+
className,
|
|
203
|
+
...props
|
|
204
|
+
}: AudioPlayerMuteButtonProps) => (
|
|
205
|
+
<ButtonGroupText asChild className="bg-transparent">
|
|
206
|
+
<MediaMuteButton
|
|
207
|
+
className={cn('', className)}
|
|
208
|
+
data-slot="audio-player-mute-button"
|
|
209
|
+
{...props}
|
|
210
|
+
/>
|
|
211
|
+
</ButtonGroupText>
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
export type AudioPlayerVolumeRangeProps = ComponentProps<
|
|
215
|
+
typeof MediaVolumeRange
|
|
216
|
+
>;
|
|
217
|
+
|
|
218
|
+
export const AudioPlayerVolumeRange = ({
|
|
219
|
+
className,
|
|
220
|
+
...props
|
|
221
|
+
}: AudioPlayerVolumeRangeProps) => (
|
|
222
|
+
<ButtonGroupText asChild className="bg-transparent">
|
|
223
|
+
<MediaVolumeRange
|
|
224
|
+
className={cn('', className)}
|
|
225
|
+
data-slot="audio-player-volume-range"
|
|
226
|
+
{...props}
|
|
227
|
+
/>
|
|
228
|
+
</ButtonGroupText>
|
|
229
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactFlowProps } from '@xyflow/react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Background, ReactFlow } from '@xyflow/react';
|
|
5
|
+
import '@xyflow/react/dist/style.css';
|
|
6
|
+
|
|
7
|
+
type CanvasProps = ReactFlowProps & {
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const deleteKeyCode = ['Backspace', 'Delete'];
|
|
12
|
+
|
|
13
|
+
export const Canvas = ({ children, ...props }: CanvasProps) => (
|
|
14
|
+
<ReactFlow
|
|
15
|
+
deleteKeyCode={deleteKeyCode}
|
|
16
|
+
fitView
|
|
17
|
+
panOnDrag={false}
|
|
18
|
+
panOnScroll
|
|
19
|
+
selectionOnDrag={true}
|
|
20
|
+
zoomOnDoubleClick={false}
|
|
21
|
+
{...props}
|
|
22
|
+
>
|
|
23
|
+
<Background bgColor="var(--sidebar)" />
|
|
24
|
+
{children}
|
|
25
|
+
</ReactFlow>
|
|
26
|
+
);
|