mirror of
https://github.com/ente-io/ente.git
synced 2025-06-03 07:49:45 +00:00
This reverts commit 5b17711b55e9e8995454121e3a209ee5e8c9b3c1, reversing changes made to 85bf3eebcb5ac197ce6a5901cbc8db1d03be0113.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import type { ModalVisibilityProps } from "@/base/components/utils/modal";
|
|
import { Dialog, DialogContent, DialogTitle } from "@mui/material";
|
|
import React from "react";
|
|
import { SingleInputForm, type SingleInputFormProps } from "./SingleInputForm";
|
|
|
|
type SingleInputDialogProps = ModalVisibilityProps &
|
|
Omit<SingleInputFormProps, "onCancel"> & {
|
|
/** Title of the dialog. */
|
|
title: string;
|
|
};
|
|
|
|
/**
|
|
* A dialog that can be used to ask for a single text input using a
|
|
* {@link SingleInputForm}.
|
|
*
|
|
* If the submission handler provided to this component resolves successfully,
|
|
* then the dialog is closed.
|
|
*
|
|
* See also: {@link CollectionNamer}, its older sibling.
|
|
*/
|
|
export const SingleInputDialog: React.FC<SingleInputDialogProps> = ({
|
|
open,
|
|
onClose,
|
|
onSubmit,
|
|
title,
|
|
...rest
|
|
}) => {
|
|
const handleSubmit = async (value: string) => {
|
|
await onSubmit(value);
|
|
onClose();
|
|
};
|
|
|
|
return (
|
|
<Dialog
|
|
open={open}
|
|
onClose={onClose}
|
|
maxWidth="xs"
|
|
fullWidth
|
|
slotProps={{ paper: { sx: { p: "8px 4px 4px 4px" } } }}
|
|
>
|
|
<DialogTitle>{title}</DialogTitle>
|
|
<DialogContent sx={{ "&&&": { pt: 0 } }}>
|
|
<SingleInputForm
|
|
onCancel={onClose}
|
|
onSubmit={handleSubmit}
|
|
{...rest}
|
|
/>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|