import type React from 'react'; import { useTriggerGestures } from '../../../os/hooks/useTriggerGestures'; import type { TransitionId } from '../navigation.declaration'; import { useAppNavigate } from '../navigation'; type SystemTriggerId = 'system.back'; type GestureId = TransitionId | SystemTriggerId; export function useNotesGestures() { const { go, back, navigateTo } = useAppNavigate(); const { bindTap, bindLongPress, bindDoubleTap } = useTriggerGestures({ execute: (id, params) => { if (id === 'system.back') return; go(id, params); }, }); type TriggerTapOptions = { params?: Record; preventDefault?: boolean; stopPropagation?: boolean; beforeTrigger?: (event: React.SyntheticEvent) => void; onTrigger?: () => void; }; const bindBack = ( options?: (TriggerTapOptions & { steps?: number }) | undefined, ) => { if (!options) { const binding = bindTap('system.back', { params: { steps: 1 } }); return { ...binding, 'data-trigger-type': 'back' as const }; } const { steps, params, ...rest } = options; const binding = bindTap('system.back', { ...rest, params: { ...(params ?? {}), steps: steps ?? 1 }, }); return { ...binding, 'data-trigger-type': 'back' as const }; }; return { bindTap, bindLongPress, bindDoubleTap, bindBack, go, back, navigateTo, }; }