import type { FunctionComponent, PropsWithChildren } from "react"; import type { PressHookProps } from "@react-aria/interactions"; import { usePress } from "@react-aria/interactions"; type Props = { onDigitPressProps: (digit: string) => PressHookProps; onZeroPressProps: PressHookProps; }; const Keypad: FunctionComponent> = ({ children, onDigitPressProps, onZeroPressProps }) => { return (
ABC DEF GHI JKL MNO PQRS TUV WXYZ {typeof children !== "undefined" ? {children} : null}
); }; export default Keypad; const Row: FunctionComponent> = ({ children }) => (
{children}
); const DigitLetters: FunctionComponent> = ({ children }) =>
{children}
; type DigitProps = { digit: string; onPressProps: Props["onDigitPressProps"]; }; const Digit: FunctionComponent> = ({ children, digit, onPressProps }) => { const { pressProps } = usePress(onPressProps(digit)); return (
{digit} {children}
); }; type ZeroDigitProps = { onPressProps: Props["onZeroPressProps"]; }; const ZeroDigit: FunctionComponent> = ({ onPressProps }) => { const { pressProps } = usePress(onPressProps); return (
0 +
); };