flipper-plugin
Version:
Flipper Desktop plugin SDK and components
70 lines • 2.61 kB
TypeScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import { ButtonProps } from 'antd';
import React from 'react';
export type DialogResult<T> = Promise<false | T> & {
close: () => void;
};
type BaseDialogOptions = {
title: string;
okText?: string;
cancelText?: string;
width?: number;
okButtonProps?: ButtonProps;
cancelButtonProps?: ButtonProps;
};
export declare const Dialog: {
show<T>(opts: BaseDialogOptions & {
defaultValue: T;
children: (currentValue: T, setValue: (v: T) => void) => React.ReactNode;
onConfirm?: ((currentValue: T) => Promise<T>) | undefined;
onValidate?: ((value: T) => string) | undefined;
}): DialogResult<T>;
/**
* Shows an item in the modal stack, but without providing any further UI, like .show does.
*/
showModal<T_1 = void>(fn: (hide: (result?: T_1 | undefined) => void) => React.ReactElement): DialogResult<T_1>;
confirm({ message, onConfirm, ...rest }: {
message: React.ReactNode;
onConfirm?: (() => Promise<true>) | undefined;
} & BaseDialogOptions): DialogResult<true>;
alert({ message, type, ...rest }: {
message: React.ReactNode;
type: 'info' | 'error' | 'warning' | 'success';
} & BaseDialogOptions): Promise<void> & {
close(): void;
};
prompt({ message, defaultValue, onConfirm, ...rest }: BaseDialogOptions & {
message: React.ReactNode;
defaultValue?: string | undefined;
onConfirm?: ((value: string) => Promise<string>) | undefined;
}): DialogResult<string>;
options({ message, onConfirm, options, ...rest }: BaseDialogOptions & {
message: React.ReactNode;
options: {
label: string;
value: string;
}[];
onConfirm?: ((value: string) => Promise<string>) | undefined;
}): DialogResult<string | false>;
select<T_2>({ defaultValue, renderer, onValidate, ...rest }: {
defaultValue: T_2;
renderer: (value: T_2, onChange: (newValue: T_2) => void, onCancel: () => void) => React.ReactElement;
onValidate?: ((value: T_2) => string) | undefined;
} & BaseDialogOptions): DialogResult<false | T_2>;
loading({ title, message, width, }: {
title?: string | undefined;
message: React.ReactNode;
width?: number | undefined;
}): Promise<void> & {
close(): void;
};
};
export {};
//# sourceMappingURL=Dialog.d.ts.map