@loke/ui
Version:
To install dependencies:
68 lines (67 loc) • 3.18 kB
text/typescript
import { Primitive } from "@loke/ui/primitive";
import { type ComponentPropsWithoutRef, type ComponentRef, type RefCallback } from "react";
type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
interface DismissableLayerProps extends PrimitiveDivProps {
/**
* When `true`, a pointer interaction outside waits for its click event before
* dispatching so third-party code can cancel dismissal by stopping propagation.
*/
deferPointerDownOutside?: boolean;
/**
* When `true`, hover/focus/click interactions will be disabled on elements outside
* the `DismissableLayer`. Users will need to click twice on outside elements to
* interact with them: once to close the `DismissableLayer`, and again to trigger the element.
*/
disableOutsidePointerEvents?: boolean;
/**
* Handler called when the `DismissableLayer` should be dismissed
*/
onDismiss?: () => void;
/**
* Event handler called when the escape key is down.
* Can be prevented.
*/
onEscapeKeyDown?: (event: KeyboardEvent) => void;
/**
* Event handler called when the focus moves outside of the `DismissableLayer`.
* Can be prevented.
*/
onFocusOutside?: (event: FocusOutsideEvent) => void;
/**
* Event handler called when an interaction happens outside the `DismissableLayer`.
* Specifically, when a `pointerdown` event happens outside or focus moves outside of it.
* Can be prevented.
*/
onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;
/**
* Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.
* Can be prevented.
*/
onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;
}
declare const DismissableLayer: import("react").ForwardRefExoticComponent<DismissableLayerProps & import("react").RefAttributes<HTMLDivElement>> & {
displayName: string;
};
type DismissableLayerBranchElement = ComponentRef<typeof Primitive.div>;
declare const DismissableLayerBranch: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
asChild?: boolean;
}, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
displayName: string;
};
declare function useDismissableLayerSurface(): RefCallback<DismissableLayerBranchElement>;
type PointerDownOutsideEvent = CustomEvent<{
originalEvent: PointerEvent;
}>;
type FocusOutsideEvent = CustomEvent<{
originalEvent: FocusEvent;
}>;
declare const Root: import("react").ForwardRefExoticComponent<DismissableLayerProps & import("react").RefAttributes<HTMLDivElement>> & {
displayName: string;
};
declare const Branch: import("react").ForwardRefExoticComponent<Omit<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
asChild?: boolean;
}, "ref"> & import("react").RefAttributes<HTMLDivElement>> & {
displayName: string;
};
export type { DismissableLayerProps };
export { Branch, DismissableLayer, DismissableLayerBranch, Root, useDismissableLayerSurface, };