import { type ElementProps, type FloatingContext, type OpenChangeReason as FloatingUIOpenChangeReason, useInteractions } from "@floating-ui/react"; import { useFloatingUI } from "@salt-ds/core"; import { type ReactNode } from "react"; /** Reason for overlay state change, can be a custom reason */ export type DatePickerOpenChangeReason = FloatingUIOpenChangeReason | "apply" | "cancel" | string; /** * Interface representing the state for a DatePicker overlay. */ interface DatePickerOverlayState { /** * If `true`, the overlay is open. */ open: boolean; /** * If `true`, the overlay contains the active element */ focused: boolean; /** * The result of the floating UI calculations. */ floatingUIResult: ReturnType; /** * Ref to attach to the initially focused element, when the overlay is opened. */ initialFocusRef?: React.MutableRefObject; } /** * Interface representing the helper functions for a DatePicker overlay. */ interface DatePickerOverlayHelpers { /** * Function to get the props for the floating element. */ getFloatingProps: ReturnType["getFloatingProps"]; /** * Function to get the props for the reference element. */ getReferenceProps: ReturnType["getReferenceProps"]; /** * Sets the open state of the overlay. * @param newOpen - The new value for the open state. * @param event - event that triggered the state change * @param reason - reason for the the state change */ setOpen: (newOpen: boolean, event?: Event, reason?: DatePickerOpenChangeReason) => void; /**~ * Register a callback for when onDismiss is called * @param onDismissCallback */ setOnDismiss: (onDismissCallback: (event?: Event) => void) => void; } /** * Interface representing the context type for a DatePicker overlay. */ interface DatePickerOverlayContextType { /** * The state of the DatePicker overlay. */ state: DatePickerOverlayState; /** * The helper functions for the DatePicker overlay. */ helpers: DatePickerOverlayHelpers; } /** * Props for the DatePickerOverlayProvider component. */ interface DatePickerOverlayProviderProps { /** * If `true`, the overlay is open. */ open?: boolean; /** * When `open` is uncontrolled, set this to `true` to open on click */ openOnClick?: boolean; /** * Handler for when open state changes * @param newOpen - true when opened * @param reason - reason for the the state change */ onOpenChange?: (newOpen: boolean, reason?: DatePickerOpenChangeReason) => void; /** * The default open state of the overlay. */ defaultOpen?: boolean; /** * The content to be rendered inside the overlay provider. */ children: ReactNode; /** * A factory method to create a set of interaction, if provided overrides the default interactions */ interactions?: (context: FloatingContext) => Array; /** * When true, shouldn't open the overlay. */ readOnly?: boolean; } export declare const DatePickerOverlayProvider: React.FC; export declare const useDatePickerOverlay: () => DatePickerOverlayContextType; export {};