/** * Copyright 2025, SumUp Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type HTMLAttributes, type ReactNode, type RefObject } from 'react'; import type { Locale } from '../../util/i18n.js'; type DataAttribute = `data-${string}`; export interface PublicDialogProps extends Omit, 'children'> { /** * Whether the modal dialog is open or not. Learn more about the `dialog` api https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/open. */ open: boolean; /** * Whether the dialog is modal or not. */ isModal?: boolean; /** * The duration of the dialog animation in milliseconds. * If you wish to animate the dialog, provide a value of the animation duration to enable the animation to complete before the dialog closes. * @default 0 */ animationDuration?: number; /** * Text label for the close button for screen readers. * Important for accessibility. */ closeButtonLabel?: string; /** * One or more [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) * locale identifiers such as `'de-DE'` or `['GB', 'en-US']`. * When passing an array, the first supported locale is used. * Defaults to `navigator.language` in supported environments. */ locale?: Locale; /** * A `ReactNode` or a function that returns the content of the modal dialog. */ children?: ReactNode | (({ onClose }: { onClose?: DialogProps['onCloseEnd']; }) => ReactNode); [key: DataAttribute]: string | undefined; } export interface DialogProps extends PublicDialogProps { /** * Fired when the dialog starts to close. * Use this to trigger animations before the dialog closes. */ onCloseStart?: () => void; /** * Callback function invoked when the dialog closes. */ onCloseEnd?: () => void; /** * Prevent users from closing the modal by clicking/tapping outside the dialog element. * @default false */ preventOutsideClickClose?: boolean; /** * Prevent users from closing the dialog by pressing the escape key. * On Chromium-based modal dialogs, this would prevent closing on the first press of the escape key * but would close the modal on the second press, as intended by Chromium. * To learn more about this particular behaviour, see https://issues.chromium.org/issues/41491338 * @default false */ preventEscapeKeyClose?: boolean; /** * Hides the close button when the dialog is modal. @default false */ hideCloseButton?: boolean; /** * By passing a `preventOutsideClickRefs` ref or array of refs, * you can prevent the dialog from closing when clicking on elements referenced by these refs. */ preventOutsideClickRefs?: RefObject | RefObject[]; } export declare const Dialog: import("react").ForwardRefExoticComponent>; export {};