npm doesn't support the "@" character in package names (it's used for scopes). We eventually want to move from yarn to npm, so in preparation, rename our internal packages accordingly so that they also work with npm workspaces. Methodology: No manual code changes, just automatic search replace of ``` "@/accounts => "ente-accounts "@/utils => "ente-utils ... "@ente/shared => "ente-shared ``` Then reran prettier.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { Dialog, DialogContent, DialogTitle } from "@mui/material";
|
|
import type { ModalVisibilityProps } from "ente-base/components/utils/modal";
|
|
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}.
|
|
*
|
|
* The dialog closes when the promise returned by the {@link onSubmit} callback
|
|
* fulfills.
|
|
*
|
|
* 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>
|
|
);
|
|
};
|