import { useOnce, useMutable } from '../../react' import { wheelEvent } from './index' import { isF } from '../utils' import type { ReactNode } from 'react' import type { WheelConfig, WheelState } from './types' export const useWheel = (config: WheelConfig) => { if (isF(config)) config = { wheel: config } const memo = useMutable(config) return useOnce(() => wheelEvent(memo as any)) } export default useWheel export interface WheelProps extends Partial> { children: (state: WheelState) => ReactNode } export const Wheel = (props: WheelProps) => { const { children, ...other } = props return children(useWheel(other)) }