// Copyright 2025 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import type { Transition } from 'framer-motion'; import { AnimatePresence, motion } from 'framer-motion'; import type { ReactNode } from 'react'; import React, { useCallback } from 'react'; import type { Key } from 'react-aria'; import { useId } from 'react-aria'; import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components'; import type { FunPickerTabKey } from '../FunConstants'; export type FunTabsProps = Readonly<{ value: FunPickerTabKey; onChange: (newTab: FunPickerTabKey) => void; children: ReactNode; }>; export function FunTabs(props: FunTabsProps): JSX.Element { const { onChange } = props; const handleTabChange = useCallback( (key: Key) => { onChange(key as FunPickerTabKey); }, [onChange] ); return ( {props.children} ); } export type FunTabListProps = Readonly<{ children: ReactNode; }>; export function FunTabList(props: FunTabListProps): JSX.Element { return {props.children}; } const FunTabTransition: Transition = { type: 'spring', stiffness: 422, damping: 37.3, mass: 1, }; export type FunTabProps = Readonly<{ id: FunPickerTabKey; children: ReactNode; }>; export function FunPickerTab(props: FunTabProps): JSX.Element { return ( {({ isSelected }) => { return (
{props.children}
{isSelected && ( )}
); }}
); } export type FunTabPanelProps = Readonly<{ id: FunPickerTabKey; children: ReactNode; }>; export function FunTabPanel(props: FunTabPanelProps): JSX.Element | null { const motionKey = useId(); return ( {({ isInert }) => { return ( {isInert ? null : ( {props.children} )} ); }} ); }