create-sidekick-app 0.0.1 → 2.0.1
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 +450 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { Experimental_TranscriptionResult as TranscriptionResult } from 'ai';
|
|
4
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useControllableState } from '@radix-ui/react-use-controllable-state';
|
|
7
|
+
import { cn } from '@/lib/utils';
|
|
8
|
+
import { createContext, useCallback, useContext, useMemo } from 'react';
|
|
9
|
+
|
|
10
|
+
type TranscriptionSegment = TranscriptionResult['segments'][number];
|
|
11
|
+
|
|
12
|
+
interface TranscriptionContextValue {
|
|
13
|
+
segments: TranscriptionSegment[];
|
|
14
|
+
currentTime: number;
|
|
15
|
+
onTimeUpdate: (time: number) => void;
|
|
16
|
+
onSeek?: (time: number) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const TranscriptionContext = createContext<TranscriptionContextValue | null>(
|
|
20
|
+
null,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const useTranscription = () => {
|
|
24
|
+
const context = useContext(TranscriptionContext);
|
|
25
|
+
if (!context) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
'Transcription components must be used within Transcription',
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type TranscriptionProps = Omit<ComponentProps<'div'>, 'children'> & {
|
|
34
|
+
segments: TranscriptionSegment[];
|
|
35
|
+
currentTime?: number;
|
|
36
|
+
onSeek?: (time: number) => void;
|
|
37
|
+
children: (segment: TranscriptionSegment, index: number) => ReactNode;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Transcription = ({
|
|
41
|
+
segments,
|
|
42
|
+
currentTime: externalCurrentTime,
|
|
43
|
+
onSeek,
|
|
44
|
+
className,
|
|
45
|
+
children,
|
|
46
|
+
...props
|
|
47
|
+
}: TranscriptionProps) => {
|
|
48
|
+
const [currentTime, setCurrentTime] = useControllableState({
|
|
49
|
+
defaultProp: 0,
|
|
50
|
+
onChange: onSeek,
|
|
51
|
+
prop: externalCurrentTime,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const contextValue = useMemo(
|
|
55
|
+
() => ({ currentTime, onSeek, onTimeUpdate: setCurrentTime, segments }),
|
|
56
|
+
[currentTime, onSeek, setCurrentTime, segments],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<TranscriptionContext.Provider value={contextValue}>
|
|
61
|
+
<div
|
|
62
|
+
className={cn(
|
|
63
|
+
'flex flex-wrap gap-1 text-sm leading-relaxed',
|
|
64
|
+
className,
|
|
65
|
+
)}
|
|
66
|
+
data-slot="transcription"
|
|
67
|
+
{...props}
|
|
68
|
+
>
|
|
69
|
+
{segments
|
|
70
|
+
.filter((segment) => segment.text.trim())
|
|
71
|
+
.map((segment, index) => children(segment, index))}
|
|
72
|
+
</div>
|
|
73
|
+
</TranscriptionContext.Provider>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type TranscriptionSegmentProps = ComponentProps<'button'> & {
|
|
78
|
+
segment: TranscriptionSegment;
|
|
79
|
+
index: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const TranscriptionSegment = ({
|
|
83
|
+
segment,
|
|
84
|
+
index,
|
|
85
|
+
className,
|
|
86
|
+
onClick,
|
|
87
|
+
...props
|
|
88
|
+
}: TranscriptionSegmentProps) => {
|
|
89
|
+
const { currentTime, onSeek } = useTranscription();
|
|
90
|
+
|
|
91
|
+
const isActive =
|
|
92
|
+
currentTime >= segment.startSecond && currentTime < segment.endSecond;
|
|
93
|
+
const isPast = currentTime >= segment.endSecond;
|
|
94
|
+
|
|
95
|
+
const handleClick = useCallback(
|
|
96
|
+
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
97
|
+
if (onSeek) {
|
|
98
|
+
onSeek(segment.startSecond);
|
|
99
|
+
}
|
|
100
|
+
onClick?.(event);
|
|
101
|
+
},
|
|
102
|
+
[onSeek, segment.startSecond, onClick],
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<button
|
|
107
|
+
className={cn(
|
|
108
|
+
'inline text-left',
|
|
109
|
+
isActive && 'text-primary',
|
|
110
|
+
isPast && 'text-muted-foreground',
|
|
111
|
+
!(isActive || isPast) && 'text-muted-foreground/60',
|
|
112
|
+
onSeek && 'hover:text-foreground cursor-pointer',
|
|
113
|
+
!onSeek && 'cursor-default',
|
|
114
|
+
className,
|
|
115
|
+
)}
|
|
116
|
+
data-active={isActive}
|
|
117
|
+
data-index={index}
|
|
118
|
+
data-slot="transcription-segment"
|
|
119
|
+
onClick={handleClick}
|
|
120
|
+
type="button"
|
|
121
|
+
{...props}
|
|
122
|
+
>
|
|
123
|
+
{segment.text}
|
|
124
|
+
</button>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
@@ -0,0 +1,525 @@
|
|
|
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
|
+
CommandDialog,
|
|
10
|
+
CommandEmpty,
|
|
11
|
+
CommandGroup,
|
|
12
|
+
CommandInput,
|
|
13
|
+
CommandItem,
|
|
14
|
+
CommandList,
|
|
15
|
+
CommandSeparator,
|
|
16
|
+
CommandShortcut,
|
|
17
|
+
} from '@/components/ui/command';
|
|
18
|
+
import {
|
|
19
|
+
Dialog,
|
|
20
|
+
DialogContent,
|
|
21
|
+
DialogTitle,
|
|
22
|
+
DialogTrigger,
|
|
23
|
+
} from '@/components/ui/dialog';
|
|
24
|
+
import { Spinner } from '@/components/ui/spinner';
|
|
25
|
+
import { cn } from '@/lib/utils';
|
|
26
|
+
import {
|
|
27
|
+
CircleSmallIcon,
|
|
28
|
+
MarsIcon,
|
|
29
|
+
MarsStrokeIcon,
|
|
30
|
+
NonBinaryIcon,
|
|
31
|
+
PauseIcon,
|
|
32
|
+
PlayIcon,
|
|
33
|
+
TransgenderIcon,
|
|
34
|
+
VenusAndMarsIcon,
|
|
35
|
+
VenusIcon,
|
|
36
|
+
} from 'lucide-react';
|
|
37
|
+
import { createContext, useCallback, useContext, useMemo } from 'react';
|
|
38
|
+
|
|
39
|
+
interface VoiceSelectorContextValue {
|
|
40
|
+
value: string | undefined;
|
|
41
|
+
setValue: (value: string | undefined) => void;
|
|
42
|
+
open: boolean;
|
|
43
|
+
setOpen: (open: boolean) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const VoiceSelectorContext = createContext<VoiceSelectorContextValue | null>(
|
|
47
|
+
null,
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export const useVoiceSelector = () => {
|
|
51
|
+
const context = useContext(VoiceSelectorContext);
|
|
52
|
+
if (!context) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
'VoiceSelector components must be used within VoiceSelector',
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return context;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type VoiceSelectorProps = ComponentProps<typeof Dialog> & {
|
|
61
|
+
value?: string;
|
|
62
|
+
defaultValue?: string;
|
|
63
|
+
onValueChange?: (value: string | undefined) => void;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const VoiceSelector = ({
|
|
67
|
+
value: valueProp,
|
|
68
|
+
defaultValue,
|
|
69
|
+
onValueChange,
|
|
70
|
+
open: openProp,
|
|
71
|
+
defaultOpen = false,
|
|
72
|
+
onOpenChange,
|
|
73
|
+
children,
|
|
74
|
+
...props
|
|
75
|
+
}: VoiceSelectorProps) => {
|
|
76
|
+
const [value, setValue] = useControllableState({
|
|
77
|
+
defaultProp: defaultValue,
|
|
78
|
+
onChange: onValueChange,
|
|
79
|
+
prop: valueProp,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const [open, setOpen] = useControllableState({
|
|
83
|
+
defaultProp: defaultOpen,
|
|
84
|
+
onChange: onOpenChange,
|
|
85
|
+
prop: openProp,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const voiceSelectorContext = useMemo(
|
|
89
|
+
() => ({ open, setOpen, setValue, value }),
|
|
90
|
+
[value, setValue, open, setOpen],
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<VoiceSelectorContext.Provider value={voiceSelectorContext}>
|
|
95
|
+
<Dialog onOpenChange={setOpen} open={open} {...props}>
|
|
96
|
+
{children}
|
|
97
|
+
</Dialog>
|
|
98
|
+
</VoiceSelectorContext.Provider>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type VoiceSelectorTriggerProps = ComponentProps<typeof DialogTrigger>;
|
|
103
|
+
|
|
104
|
+
export const VoiceSelectorTrigger = (props: VoiceSelectorTriggerProps) => (
|
|
105
|
+
<DialogTrigger {...props} />
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
export type VoiceSelectorContentProps = ComponentProps<typeof DialogContent> & {
|
|
109
|
+
title?: ReactNode;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const VoiceSelectorContent = ({
|
|
113
|
+
className,
|
|
114
|
+
children,
|
|
115
|
+
title = 'Voice Selector',
|
|
116
|
+
...props
|
|
117
|
+
}: VoiceSelectorContentProps) => (
|
|
118
|
+
<DialogContent
|
|
119
|
+
aria-describedby={undefined}
|
|
120
|
+
className={cn('p-0', className)}
|
|
121
|
+
{...props}
|
|
122
|
+
>
|
|
123
|
+
<DialogTitle className="sr-only">{title}</DialogTitle>
|
|
124
|
+
<Command className="**:data-[slot=command-input-wrapper]:h-auto">
|
|
125
|
+
{children}
|
|
126
|
+
</Command>
|
|
127
|
+
</DialogContent>
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
export type VoiceSelectorDialogProps = ComponentProps<typeof CommandDialog>;
|
|
131
|
+
|
|
132
|
+
export const VoiceSelectorDialog = (props: VoiceSelectorDialogProps) => (
|
|
133
|
+
<CommandDialog {...props} />
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
export type VoiceSelectorInputProps = ComponentProps<typeof CommandInput>;
|
|
137
|
+
|
|
138
|
+
export const VoiceSelectorInput = ({
|
|
139
|
+
className,
|
|
140
|
+
...props
|
|
141
|
+
}: VoiceSelectorInputProps) => (
|
|
142
|
+
<CommandInput className={cn('h-auto py-3.5', className)} {...props} />
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
export type VoiceSelectorListProps = ComponentProps<typeof CommandList>;
|
|
146
|
+
|
|
147
|
+
export const VoiceSelectorList = (props: VoiceSelectorListProps) => (
|
|
148
|
+
<CommandList {...props} />
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
export type VoiceSelectorEmptyProps = ComponentProps<typeof CommandEmpty>;
|
|
152
|
+
|
|
153
|
+
export const VoiceSelectorEmpty = (props: VoiceSelectorEmptyProps) => (
|
|
154
|
+
<CommandEmpty {...props} />
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
export type VoiceSelectorGroupProps = ComponentProps<typeof CommandGroup>;
|
|
158
|
+
|
|
159
|
+
export const VoiceSelectorGroup = (props: VoiceSelectorGroupProps) => (
|
|
160
|
+
<CommandGroup {...props} />
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export type VoiceSelectorItemProps = ComponentProps<typeof CommandItem>;
|
|
164
|
+
|
|
165
|
+
export const VoiceSelectorItem = ({
|
|
166
|
+
className,
|
|
167
|
+
...props
|
|
168
|
+
}: VoiceSelectorItemProps) => (
|
|
169
|
+
<CommandItem className={cn('px-4 py-2', className)} {...props} />
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
export type VoiceSelectorShortcutProps = ComponentProps<typeof CommandShortcut>;
|
|
173
|
+
|
|
174
|
+
export const VoiceSelectorShortcut = (props: VoiceSelectorShortcutProps) => (
|
|
175
|
+
<CommandShortcut {...props} />
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
export type VoiceSelectorSeparatorProps = ComponentProps<
|
|
179
|
+
typeof CommandSeparator
|
|
180
|
+
>;
|
|
181
|
+
|
|
182
|
+
export const VoiceSelectorSeparator = (props: VoiceSelectorSeparatorProps) => (
|
|
183
|
+
<CommandSeparator {...props} />
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
export type VoiceSelectorGenderProps = ComponentProps<'span'> & {
|
|
187
|
+
value?:
|
|
188
|
+
| 'male'
|
|
189
|
+
| 'female'
|
|
190
|
+
| 'transgender'
|
|
191
|
+
| 'androgyne'
|
|
192
|
+
| 'non-binary'
|
|
193
|
+
| 'intersex';
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
export const VoiceSelectorGender = ({
|
|
197
|
+
className,
|
|
198
|
+
value,
|
|
199
|
+
children,
|
|
200
|
+
...props
|
|
201
|
+
}: VoiceSelectorGenderProps) => {
|
|
202
|
+
let icon: ReactNode | null = null;
|
|
203
|
+
|
|
204
|
+
switch (value) {
|
|
205
|
+
case 'male': {
|
|
206
|
+
icon = <MarsIcon className="size-4" />;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
case 'female': {
|
|
210
|
+
icon = <VenusIcon className="size-4" />;
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case 'transgender': {
|
|
214
|
+
icon = <TransgenderIcon className="size-4" />;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case 'androgyne': {
|
|
218
|
+
icon = <MarsStrokeIcon className="size-4" />;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
case 'non-binary': {
|
|
222
|
+
icon = <NonBinaryIcon className="size-4" />;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
case 'intersex': {
|
|
226
|
+
icon = <VenusAndMarsIcon className="size-4" />;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
default: {
|
|
230
|
+
icon = <CircleSmallIcon className="size-4" />;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<span className={cn('text-muted-foreground text-xs', className)} {...props}>
|
|
236
|
+
{children ?? icon}
|
|
237
|
+
</span>
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export type VoiceSelectorAccentProps = ComponentProps<'span'> & {
|
|
242
|
+
value?:
|
|
243
|
+
| 'american'
|
|
244
|
+
| 'british'
|
|
245
|
+
| 'australian'
|
|
246
|
+
| 'canadian'
|
|
247
|
+
| 'irish'
|
|
248
|
+
| 'scottish'
|
|
249
|
+
| 'indian'
|
|
250
|
+
| 'south-african'
|
|
251
|
+
| 'new-zealand'
|
|
252
|
+
| 'spanish'
|
|
253
|
+
| 'french'
|
|
254
|
+
| 'german'
|
|
255
|
+
| 'italian'
|
|
256
|
+
| 'portuguese'
|
|
257
|
+
| 'brazilian'
|
|
258
|
+
| 'mexican'
|
|
259
|
+
| 'argentinian'
|
|
260
|
+
| 'japanese'
|
|
261
|
+
| 'chinese'
|
|
262
|
+
| 'korean'
|
|
263
|
+
| 'russian'
|
|
264
|
+
| 'arabic'
|
|
265
|
+
| 'dutch'
|
|
266
|
+
| 'swedish'
|
|
267
|
+
| 'norwegian'
|
|
268
|
+
| 'danish'
|
|
269
|
+
| 'finnish'
|
|
270
|
+
| 'polish'
|
|
271
|
+
| 'turkish'
|
|
272
|
+
| 'greek'
|
|
273
|
+
| string;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const VoiceSelectorAccent = ({
|
|
277
|
+
className,
|
|
278
|
+
value,
|
|
279
|
+
children,
|
|
280
|
+
...props
|
|
281
|
+
}: VoiceSelectorAccentProps) => {
|
|
282
|
+
let emoji: string | null = null;
|
|
283
|
+
|
|
284
|
+
switch (value) {
|
|
285
|
+
case 'american': {
|
|
286
|
+
emoji = '🇺🇸';
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
case 'british': {
|
|
290
|
+
emoji = '🇬🇧';
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case 'australian': {
|
|
294
|
+
emoji = '🇦🇺';
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
case 'canadian': {
|
|
298
|
+
emoji = '🇨🇦';
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
case 'irish': {
|
|
302
|
+
emoji = '🇮🇪';
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case 'scottish': {
|
|
306
|
+
emoji = '🏴';
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
case 'indian': {
|
|
310
|
+
emoji = '🇮🇳';
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
case 'south-african': {
|
|
314
|
+
emoji = '🇿🇦';
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
case 'new-zealand': {
|
|
318
|
+
emoji = '🇳🇿';
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case 'spanish': {
|
|
322
|
+
emoji = '🇪🇸';
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
case 'french': {
|
|
326
|
+
emoji = '🇫🇷';
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
case 'german': {
|
|
330
|
+
emoji = '🇩🇪';
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
case 'italian': {
|
|
334
|
+
emoji = '🇮🇹';
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case 'portuguese': {
|
|
338
|
+
emoji = '🇵🇹';
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
case 'brazilian': {
|
|
342
|
+
emoji = '🇧🇷';
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
case 'mexican': {
|
|
346
|
+
emoji = '🇲🇽';
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
case 'argentinian': {
|
|
350
|
+
emoji = '🇦🇷';
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case 'japanese': {
|
|
354
|
+
emoji = '🇯🇵';
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
case 'chinese': {
|
|
358
|
+
emoji = '🇨🇳';
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
case 'korean': {
|
|
362
|
+
emoji = '🇰🇷';
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
case 'russian': {
|
|
366
|
+
emoji = '🇷🇺';
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
case 'arabic': {
|
|
370
|
+
emoji = '🇸🇦';
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
case 'dutch': {
|
|
374
|
+
emoji = '🇳🇱';
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
case 'swedish': {
|
|
378
|
+
emoji = '🇸🇪';
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
case 'norwegian': {
|
|
382
|
+
emoji = '🇳🇴';
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
case 'danish': {
|
|
386
|
+
emoji = '🇩🇰';
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
case 'finnish': {
|
|
390
|
+
emoji = '🇫🇮';
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
case 'polish': {
|
|
394
|
+
emoji = '🇵🇱';
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
case 'turkish': {
|
|
398
|
+
emoji = '🇹🇷';
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
case 'greek': {
|
|
402
|
+
emoji = '🇬🇷';
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
default: {
|
|
406
|
+
emoji = null;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return (
|
|
411
|
+
<span className={cn('text-muted-foreground text-xs', className)} {...props}>
|
|
412
|
+
{children ?? emoji}
|
|
413
|
+
</span>
|
|
414
|
+
);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export type VoiceSelectorAgeProps = ComponentProps<'span'>;
|
|
418
|
+
|
|
419
|
+
export const VoiceSelectorAge = ({
|
|
420
|
+
className,
|
|
421
|
+
...props
|
|
422
|
+
}: VoiceSelectorAgeProps) => (
|
|
423
|
+
<span
|
|
424
|
+
className={cn('text-muted-foreground text-xs tabular-nums', className)}
|
|
425
|
+
{...props}
|
|
426
|
+
/>
|
|
427
|
+
);
|
|
428
|
+
|
|
429
|
+
export type VoiceSelectorNameProps = ComponentProps<'span'>;
|
|
430
|
+
|
|
431
|
+
export const VoiceSelectorName = ({
|
|
432
|
+
className,
|
|
433
|
+
...props
|
|
434
|
+
}: VoiceSelectorNameProps) => (
|
|
435
|
+
<span
|
|
436
|
+
className={cn('flex-1 truncate text-left font-medium', className)}
|
|
437
|
+
{...props}
|
|
438
|
+
/>
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
export type VoiceSelectorDescriptionProps = ComponentProps<'span'>;
|
|
442
|
+
|
|
443
|
+
export const VoiceSelectorDescription = ({
|
|
444
|
+
className,
|
|
445
|
+
...props
|
|
446
|
+
}: VoiceSelectorDescriptionProps) => (
|
|
447
|
+
<span className={cn('text-muted-foreground text-xs', className)} {...props} />
|
|
448
|
+
);
|
|
449
|
+
|
|
450
|
+
export type VoiceSelectorAttributesProps = ComponentProps<'div'>;
|
|
451
|
+
|
|
452
|
+
export const VoiceSelectorAttributes = ({
|
|
453
|
+
className,
|
|
454
|
+
children,
|
|
455
|
+
...props
|
|
456
|
+
}: VoiceSelectorAttributesProps) => (
|
|
457
|
+
<div className={cn('flex items-center text-xs', className)} {...props}>
|
|
458
|
+
{children}
|
|
459
|
+
</div>
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
export type VoiceSelectorBulletProps = ComponentProps<'span'>;
|
|
463
|
+
|
|
464
|
+
export const VoiceSelectorBullet = ({
|
|
465
|
+
className,
|
|
466
|
+
...props
|
|
467
|
+
}: VoiceSelectorBulletProps) => (
|
|
468
|
+
<span
|
|
469
|
+
aria-hidden="true"
|
|
470
|
+
className={cn('text-border select-none', className)}
|
|
471
|
+
{...props}
|
|
472
|
+
>
|
|
473
|
+
•
|
|
474
|
+
</span>
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
export type VoiceSelectorPreviewProps = Omit<
|
|
478
|
+
ComponentProps<'button'>,
|
|
479
|
+
'children'
|
|
480
|
+
> & {
|
|
481
|
+
playing?: boolean;
|
|
482
|
+
loading?: boolean;
|
|
483
|
+
onPlay?: () => void;
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
export const VoiceSelectorPreview = ({
|
|
487
|
+
className,
|
|
488
|
+
playing,
|
|
489
|
+
loading,
|
|
490
|
+
onPlay,
|
|
491
|
+
onClick,
|
|
492
|
+
...props
|
|
493
|
+
}: VoiceSelectorPreviewProps) => {
|
|
494
|
+
const handleClick = useCallback(
|
|
495
|
+
(event: React.MouseEvent<HTMLButtonElement>) => {
|
|
496
|
+
event.stopPropagation();
|
|
497
|
+
onClick?.(event);
|
|
498
|
+
onPlay?.();
|
|
499
|
+
},
|
|
500
|
+
[onClick, onPlay],
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
let icon = <PlayIcon className="size-3" />;
|
|
504
|
+
|
|
505
|
+
if (loading) {
|
|
506
|
+
icon = <Spinner className="size-3" />;
|
|
507
|
+
} else if (playing) {
|
|
508
|
+
icon = <PauseIcon className="size-3" />;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return (
|
|
512
|
+
<Button
|
|
513
|
+
aria-label={playing ? 'Pause preview' : 'Play preview'}
|
|
514
|
+
className={cn('size-6', className)}
|
|
515
|
+
disabled={loading}
|
|
516
|
+
onClick={handleClick}
|
|
517
|
+
size="icon-sm"
|
|
518
|
+
type="button"
|
|
519
|
+
variant="outline"
|
|
520
|
+
{...props}
|
|
521
|
+
>
|
|
522
|
+
{icon}
|
|
523
|
+
</Button>
|
|
524
|
+
);
|
|
525
|
+
};
|