@progress/kendo-react-popup
Version:
React Popup positions a piece of content next to a specific anchor component. KendoReact Popup package
362 lines (343 loc) • 11.1 kB
TypeScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import { AlignStrategy } from '@progress/kendo-popup-common';
import { CollisionType as CollisionType_2 } from '@progress/kendo-popup-common';
import { MarginSettings } from '@progress/kendo-popup-common';
import { OffsetPosition } from '@progress/kendo-popup-common';
import { PopupClassStructure } from '@progress/kendo-react-common';
import { PopupSettings } from '@progress/kendo-popup-common';
import { PositionMode as PositionMode_2 } from '@progress/kendo-popup-common';
import * as React_2 from 'react';
/**
* Defines the horizontal and vertical aligning point of the Popup.
*/
export declare interface Align extends AlignStrategy {
/**
* Defines the possible horizontal point values that are relative to the anchor or the Popup.
*
* The available options are:
* - `left`—Uses the leftmost point of the anchor element.
* - `center`—Uses the center point of the anchor element.
* - `right`—Uses the rightmost point of the anchor element.
*/
horizontal: 'left' | 'center' | 'right';
/**
* Defines the possible vertical point values that are relative to the anchor or the Popup.
*
* The available options are:
* - `top`—Uses the top point of the anchor element.
* - `center`—Uses the center point of the anchor element.
* - `bottom`—Uses the bottom point of the anchor element.
*/
vertical: 'top' | 'center' | 'bottom';
}
/**
* Defines the horizontal and vertical collision behavior of the Popup.
*/
export declare interface Collision {
/**
* Defines the horizontal collision behavior of the Popup.
*/
horizontal: CollisionType;
/**
* Defines the vertical collision behavior of the Popup.
*/
vertical: CollisionType;
}
/**
* Defines the possible collision behavior when the Popup is not fully visible.
*
* The available options are:
* - `fit`—Moves the Popup horizontally until it is fully displayed in the viewport.
* - `flip`—Flips the Popup position based on the origin and the position properties.
* - `none`—The Popup is rendered at its original position.
*/
export declare type CollisionType = CollisionType_2;
/**
* Defines the horizontal and the vertical margin offset of the component.
*/
export declare interface Margin extends MarginSettings {
/**
* Defines the possible horizontal margin value.
*/
horizontal: number;
/**
* Defines the possible vertical margin value.
*/
vertical: number;
}
/**
* Represents the object of the `MouseDownOutside` Popup event.
*/
export declare interface MouseDownOutsideEvent {
/**
* An event target.
*/
target: PopupHandle;
/**
* The event object.
*/
event: MouseEvent;
/**
* The state of the Popup.
*/
state: PopupState;
/**
* Indicates if the MouseDown event is triggered over the anchor of the Popup.
*/
isAnchorClicked: boolean;
}
/**
* The offset position of the Popup.
*/
export declare interface Offset extends OffsetPosition {
/**
* Defines the top position of the Popup.
*/
top: number;
/**
* Defines the left position of the Popup.
*/
left: number;
}
/**
* The KendoReact Popup component.
*/
export declare const Popup: React_2.ForwardRefExoticComponent<PopupProps & React_2.RefAttributes<PopupHandle | null>>;
/**
* The animation settings for the Popup component.
*/
export declare interface PopupAnimation {
/**
* The duration of the opening animation in milliseconds. Defaults to `300ms`.
*/
openDuration?: number;
/**
* The duration of the closing animation in milliseconds. Defaults to `300ms`.
*/
closeDuration?: number;
/**
* The direction of the animation.
*/
direction?: 'left' | 'right' | 'up' | 'down';
}
/**
* Represents the object of the `Close` Popup event.
*/
export declare interface PopupCloseEvent {
/**
* An event target.
*/
target: PopupHandle;
}
/**
* The KendoReact PopupHandle component.
*/
export declare interface PopupHandle {
/**
* Represents the Popup DOM element.
*/
element: any;
/**
* The props of the PopupHandle component.
*/
props: PopupProps;
}
/**
* Represents the object of the `Open` Popup event.
*/
export declare interface PopupOpenEvent {
/**
* An event target.
*/
target: PopupHandle;
}
/**
* Represents the props of the [KendoReact Popup component]({% slug overview_popup %}).
*/
export declare interface PopupProps extends PopupSettings {
/**
* Controls the Popup animation ([see example]({% slug animations_popup %})). By default, the opening and closing animations are enabled.
*/
animate?: boolean | PopupAnimation;
/**
* Specifies the element which will be used as an anchor ([see example]({% slug alignmentpositioning_popup %})). The Popup opens next to that element.
*/
anchor?: HTMLElement | null;
/**
* Defines the container to which the Popup will be appended. Defaults to [`body`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body).
* * If set to `null` the Popup will be rendered without React Portal.
*/
appendTo?: HTMLElement | null;
/**
* Specifies the pivot point of the anchor ([see example]({% slug alignmentpositioning_popup %})).
*/
anchorAlign?: Align;
/**
* Configures the collision behavior of the Popup ([see example]({% slug viewportboundarydetection_popup %})).
*/
collision?: Collision;
/**
* Configures the margin value that will be added to the popup dimensions
* in pixels and leaves a blank space between the popup and the anchor.
*/
margin?: Margin;
/**
* Specifies the position mode of the component. By default, the Popup uses fixed positioning.
* To make the Popup acquire absolute positioning, set this option to `absolute`.
*
* > If you need to support mobile browsers with the zoom option, use the `absolute` positioning of the Popup.
*/
positionMode?: PositionMode;
/**
* Used to set the document scale when using a [scale transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/scale).
*
* The document or container scale is required to compute the popup position correctly. Detecting the scale is not reliable and must be set by providing a value for SCALE.
*
* > Using this token is not necessary for user-applied browser zoom.
*
*/
scale?: number;
/**
* Specifies the pivot point of the Popup ([see example]({% slug alignmentpositioning_popup %})).
*/
popupAlign?: Align;
/**
* Specifies the absolute position of the element ([see example]({% slug alignmentpositioning_popup %})). The Popup opens next to that point. The pivot point of the Popup is defined by the `popupAlign` configuration option. The boundary detection is applied by using the window viewport.
*/
offset?: Offset;
/**
* Specifies a list of CSS classes that will be added to the internal animated element ([see example]({% slug appearance_popup %})).
*/
popupClass?: string | Array<string> | {
[key: string]: boolean;
};
/**
* Specifies a list of CSS classes that will be added to the Popup element.
*/
className?: string | Array<string>;
/**
* Specifies the id that will be added to the Popup element.
*/
id?: string;
/**
* Represents the styles that are applied to the Popup.
*/
style?: React.CSSProperties;
/**
* Fires after the Popup is opened and the opening animation ends.
*/
onOpen?: (event: PopupOpenEvent) => void;
/**
* Fires after the Popup is closed.
*/
onClose?: (event: PopupCloseEvent) => void;
/**
* Fires after the Popup position is set.
*/
onPosition?: (event: PositionEvent) => void;
/**
* Fires when the mousedown event is triggered outside the Popup.
*/
onMouseDownOutside?: (event: MouseDownOutsideEvent) => void;
/**
* Controls the Popup visibility ([see example]({% slug hidden_popup %})). Defaults to `false`.
*/
show?: boolean;
/**
* @hidden
*
* If contentKey has changed, the popup will recalculate its position.
*/
contentKey?: any;
/**
* @hidden
*/
children?: React.ReactNode;
/**
* @hidden
*/
useBaseStyles?: boolean;
/**
* @hidden
*/
role?: string;
/**
* @hidden
*/
onKeyDown?: (event: React.KeyboardEvent) => void;
/**
* @hidden
*/
unstyled?: PopupClassStructure;
}
/**
* The PopupPropsContext. It allows to configure the Popup props from a wrapper component.
*
* @example
* ```jsx-no-run
* <PopupPropsContext.Provider value={props => ({ ...props, appendTo: document.querySelector('myPopupsContainer') })}>
* <DropDownList />
* <Editor />
* </PopupPropsContext.Provider>
* ```
*/
export declare const PopupPropsContext: React_2.Context<(props: PopupProps) => PopupProps>;
/**
* @hidden
*/
declare interface PopupState {
current: Status;
previous: Status;
props: {
show?: boolean;
anchor?: HTMLElement | null;
anchorAlign?: Align;
appendTo?: HTMLElement | null;
collision?: Collision;
popupAlign?: Align;
className?: string | string[] | {
[key: string]: boolean;
};
popupClass?: string | string[] | {
[key: string]: boolean;
};
style?: React_2.CSSProperties;
offset?: Offset;
contentKey?: any;
};
}
/**
* Represents the object of the `Position` Popup event.
*/
export declare interface PositionEvent {
/**
* An event target.
*/
target: PopupHandle;
/**
* Indicates if the position is fitted.
*/
fitted: boolean;
/**
* Indicates if the position is flipped.
*/
flipped: boolean;
}
/**
* The type which defines all possible position modes of the Popup.
*/
export declare type PositionMode = PositionMode_2;
declare enum Status {
hiding = "hiding",
hidden = "hidden",
showing = "showing",
shown = "shown",
reposition = "reposition"
}
export { }