mic-selector.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Derived from vercel/ai-elements (skills/ai-elements/scripts/mic-selector.tsx).
  3. * Copyright 2023 Vercel, Inc. Licensed under Apache-2.0.
  4. * Modified by ZCode: local integration, formatting and adaptations.
  5. * See THIRD-PARTY-NOTICES.md in the repository root for license and provenance.
  6. */
  7. "use client";
  8. import {
  9. MicSelector,
  10. MicSelectorContent,
  11. MicSelectorEmpty,
  12. MicSelectorInput,
  13. MicSelectorItem,
  14. MicSelectorLabel,
  15. MicSelectorList,
  16. MicSelectorTrigger,
  17. MicSelectorValue,
  18. } from "@/components/ai-elements/mic-selector";
  19. const handleOpenChange = (open: boolean) => {
  20. console.log("MicSelector is open?", open);
  21. };
  22. const handleValueChange = (newValue: string) => {
  23. console.log("MicSelector value:", newValue);
  24. };
  25. const Example = () => (
  26. <div className="flex size-full flex-col items-center justify-center gap-4">
  27. <MicSelector onOpenChange={handleOpenChange} onValueChange={handleValueChange}>
  28. <MicSelectorTrigger className="w-full max-w-sm">
  29. <MicSelectorValue />
  30. </MicSelectorTrigger>
  31. <MicSelectorContent>
  32. <MicSelectorInput />
  33. <MicSelectorEmpty />
  34. <MicSelectorList>
  35. {(devices) =>
  36. devices.map((device) => (
  37. <MicSelectorItem key={device.deviceId} value={device.deviceId}>
  38. <MicSelectorLabel device={device} />
  39. </MicSelectorItem>
  40. ))
  41. }
  42. </MicSelectorList>
  43. </MicSelectorContent>
  44. </MicSelector>
  45. </div>
  46. );
  47. export default Example;