@atlaskit/popup
Version:
A popup displays brief content in an overlay.
73 lines (72 loc) • 3.15 kB
TypeScript
import React from 'react';
import { type ContentProps, type DialogContentProps, type PopupProps as LegacyPopupProps, type TInitialFocusRole } from '../types';
type CommonContentPopupProps = Pick<LegacyPopupProps, 'xcss' | 'appearance' | 'boundary' | 'offset' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldRenderToParent' | 'shouldUseCaptureOnOutsideClick' | 'shouldIgnoreCloseEvent' | 'shouldDisableFocusLock' | 'strategy' | 'zIndex' | 'shouldFitViewport' | 'label' | 'titleId'> & {
/**
* ___Use with caution___
*
* Disables popper.js GPU acceleration for this popup.
* This means only positioning will be used, without any transforms.
*
* Performance will be degraded if the popup is expected to move.
*
* This should almost never be used, but is sometimes needed
* to resolve layering issues.
*/
shouldDisableGpuAcceleration?: boolean;
};
type ShouldFitContainerContentPopupProps = CommonContentPopupProps & {
shouldFitContainer: true;
shouldRenderToParent?: true;
strategy?: 'absolute';
};
type StandardPopupContentProps = CommonContentPopupProps & {
shouldFitContainer?: false;
};
type TPopupContentBase = ShouldFitContainerContentPopupProps | StandardPopupContentProps;
/**
* Props for popup content with any role, or no role. `children` does not get `setInitialFocusRef`.
*/
export type PopupContentProps = TPopupContentBase & {
/**
* Use this to set the accessibility role for the popup.
* We strongly recommend using only `menu` or `dialog`.
* Must be used along with `label` or `titleId`.
*
* Only `role="dialog"` and `role="alertdialog"` (as literal types) give `children`
* the `setInitialFocusRef` setter.
*/
role?: string;
children: (props: ContentProps) => React.ReactNode;
};
/**
* Props for popup content with `role="dialog"` or `role="alertdialog"`.
* `children` gets `setInitialFocusRef`.
*/
export type DialogPopupContentProps = TPopupContentBase & {
/**
* Use this to set the accessibility role for the popup.
* Must be used along with `label` or `titleId`.
* Required. `undefined` lets a role gated on `platform-dst-top-layer` keep the setter.
*/
role: TInitialFocusRole | undefined;
children: (props: DialogContentProps) => React.ReactNode;
};
/**
* The `PopupContent` component type. The dialog signature comes first, so only a role
* that is always `'dialog'` or `'alertdialog'` gets `setInitialFocusRef`.
*/
export interface TPopupContent {
(props: DialogPopupContentProps): React.ReactNode;
(props: PopupContentProps): React.ReactNode;
}
/**
* __Popup content__
*
* Popup content is the component that renders the content of the popup.
*
* It must be a child of the Popup component. Only `role="dialog"` and
* `role="alertdialog"` give `children` the `setInitialFocusRef` setter.
*/
declare function PopupContent(props: DialogPopupContentProps): React.ReactNode;
declare function PopupContent(props: PopupContentProps): React.ReactNode;
export { PopupContent };