import { isBefore } from "date-fns"; import React, { forwardRef } from "react"; import { useTimelineContext } from "../hooks/useTimelineContext"; import { TimelineComponentTypes } from "../utils/types.internal"; import PinInternal, { type TimelinePinProps } from "./PinInternal"; export interface PinType extends React.ForwardRefExoticComponent< TimelinePinProps & React.RefAttributes > { componentType: TimelineComponentTypes; } export const Pin = forwardRef( ({ date, ...restProps }, forwardedRef) => { const { startDate, endDate } = useTimelineContext(); /** * Out-of-bounds pins should not be rendered */ if (isBefore(date, startDate) || isBefore(endDate, date)) { return null; } return ; }, ) as PinType; Pin.componentType = "pin"; export default Pin; export type { TimelinePinProps };