diff --git a/packages/admin-ui/src/Dialog/components/DialogFooter.tsx b/packages/admin-ui/src/Dialog/components/DialogFooter.tsx index 5d2afcdfc5e..743ec1c95cd 100644 --- a/packages/admin-ui/src/Dialog/components/DialogFooter.tsx +++ b/packages/admin-ui/src/Dialog/components/DialogFooter.tsx @@ -1,5 +1,4 @@ import * as React from "react"; -import { cn } from "~/utils"; export interface DialogFooterProps extends React.HTMLAttributes { actions?: React.ReactNode; diff --git a/packages/app-form-builder/src/admin/components/FormEditor/Tabs/EditTab/EditFieldDialog.tsx b/packages/app-form-builder/src/admin/components/FormEditor/Tabs/EditTab/EditFieldDialog.tsx index cdd2f962fe8..61c8a9ba58b 100644 --- a/packages/app-form-builder/src/admin/components/FormEditor/Tabs/EditTab/EditFieldDialog.tsx +++ b/packages/app-form-builder/src/admin/components/FormEditor/Tabs/EditTab/EditFieldDialog.tsx @@ -1,6 +1,5 @@ import React, { useState, useEffect, useCallback } from "react"; import cloneDeep from "lodash/cloneDeep"; -import { css } from "emotion"; import styled from "@emotion/styled"; import { Dialog, @@ -8,7 +7,8 @@ import { DialogTitle, DialogCancel, DialogActions, - DialogButton + DialogButton, + DialogAccept } from "@webiny/ui/Dialog"; import { Form, FormOnSubmit } from "@webiny/form"; import { plugins } from "@webiny/plugins"; @@ -17,17 +17,11 @@ import GeneralTab from "./EditFieldDialog/GeneralTab"; import ValidatorsTab from "./EditFieldDialog/ValidatorsTab"; import FieldTypeSelector from "./EditFieldDialog/FieldTypeSelector"; import { i18n } from "@webiny/app/i18n"; + const t = i18n.namespace("FormEditor.EditFieldDialog"); import { useFormEditor } from "../../Context"; import { FbBuilderFieldPlugin, FbFormModelField } from "~/types"; -const dialogBody = css({ - "&.webiny-ui-dialog__content": { - width: 875, - height: 450 - } -}); - const FbFormModelFieldList = styled("div")({ display: "flex", justifyContent: "center", @@ -86,7 +80,7 @@ const EditFieldDialog = ({ field, onSubmit, ...props }: EditFieldDialogProps) =>
{form => ( <> - + @@ -98,20 +92,14 @@ const EditFieldDialog = ({ field, onSubmit, ...props }: EditFieldDialogProps) => )} - + {isNewField && ( setScreen("fieldType")} >{t`Go back`} )} -
- {t`Cancel`} - {t`Save`} -
+ {t`Cancel`} + {t`Save`}
)} @@ -122,7 +110,7 @@ const EditFieldDialog = ({ field, onSubmit, ...props }: EditFieldDialogProps) => default: render = ( <> - + {plugins .byType("form-editor-field-type") diff --git a/packages/ui/src/Dialog/Dialog.tsx b/packages/ui/src/Dialog/Dialog.tsx index dce8dc30554..e46167d59d8 100644 --- a/packages/ui/src/Dialog/Dialog.tsx +++ b/packages/ui/src/Dialog/Dialog.tsx @@ -8,26 +8,16 @@ import { DialogHeader as AdminUiDialogHeader } from "@webiny/admin-ui/Dialog/com import { DialogFooter as AdminUiDialogFooter } from "@webiny/admin-ui/Dialog/components/DialogFooter"; import { DialogClose as AdminUiDialogClose } from "@webiny/admin-ui/Dialog/components/DialogClose"; -//export type DialogOnClose = (event: DialogOnCloseEventT) => void; export type DialogOnClose = any; -// export interface DialogProps extends RmwcDialogProps { -// className?: string; -// -// // Component's custom in-line styles. -// style?: React.CSSProperties; -// -// onClose?: (evt: DialogOnCloseEventT) => void; -// -// preventOutsideDismiss?: boolean; -// -// children?: React.ReactNode; -// } - export interface DialogActionsProps { children: React.ReactNode[] | React.ReactNode; } +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ export const DialogActions = (props: DialogActionsProps) => { return ; }; @@ -36,15 +26,31 @@ export interface DialogAcceptProps extends AdminUiButtonProps { children?: React.ReactNode[] | React.ReactNode; } +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ export const DialogAccept = (props: DialogAcceptProps) => { - return ; + return ; }; -export interface DialogCancelProps extends AdminUiButtonProps { +export interface DialogButtonProps extends AdminUiButtonProps { children?: React.ReactNode[] | React.ReactNode; } -export const DialogCancel = (props: DialogCancelProps) => { +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ +export const DialogButton = (props: DialogButtonProps) => { + return ; +}; + +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ +export const DialogCancel = (props: DialogButtonProps) => { return ( @@ -58,6 +64,10 @@ export interface DialogContentProps { children: React.ReactNode[] | React.ReactNode; } +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ export const DialogContent = (props: DialogContentProps) => { return <>{props.children}; }; @@ -68,12 +78,20 @@ export interface DialogTitleProps { children: React.ReactNode[] | React.ReactNode; } +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ export const DialogTitle = (props: DialogTitleProps) => { return ; }; DialogTitle.displayName = "DialogTitle"; +/** + * @deprecated This component is deprecated and will be removed in future releases. + * Please use the `Dialog` component from the `@webiny/admin-ui` package instead. + */ export const Dialog = ({ onClose, open, children, showCloseButton }: any) => { return ( { {children} ); - - // container: HTMLElement; - // - // constructor(props: DialogProps) { - // super(props); - // /** - // * We can safely cast - // */ - // this.container = document.getElementById("dialog-container") as HTMLElement; - // - // if (!this.container) { - // this.container = document.createElement("div"); - // this.container.setAttribute("id", "dialog-container"); - // const container = this.container; - // document.body && document.body.appendChild(container); - // } - // } - // - // public override render() { - // const { children, ...props } = this.props; - // const container = this.container; - // - // // Let's pass "permanent" / "persistent" / "temporary" flags as "mode" prop instead. - // return ReactDOM.createPortal( - // {children}, - // container - // ); - // } }; - -// export interface DialogTitleProps extends RmwcDialogTitleProps { -// /** -// * Title text. -// */ -// children: React.ReactNode[] | React.ReactNode; -// } -// -// /** -// * Dialog's header, which can accept DialogHeaderTitle component or any other set of components. -// */ -// export const DialogTitle = (props: DialogTitleProps) => ( -// -// ); -// -// export type DialogContentProps = RmwcDialogContentProps & { -// /** -// * Dialog content. -// */ -// children: React.ReactNode[] | React.ReactNode; -// -// className?: string; -// }; -// -// /** -// * A simple component for showing dialog's body. -// */ -// export const DialogContent = (props: DialogContentProps) => ( -// -// ); -// -// export interface DialogActionsProps extends RmwcDialogActionsProps { -// /** -// * Action buttons. -// */ -// children: React.ReactNode[] | React.ReactNode; -// -// // Dialog component's custom in-line styles. -// style?: React.CSSProperties; -// } -// -// /** -// * Can be used to show accept and cancel buttons. -// */ -// export const DialogActions = (props: DialogActionsProps) => ( -// -// ); -// -// interface DialogButtonProps extends RmwcDialogButtonProps { -// /** -// * Callback to execute then button is clicked. -// */ -// onClick?: (e: React.MouseEvent) => void; -// -// className?: string; -// } -// -// /** -// * Use this to show a simple button. -// */ -// export const DialogButton = (props: DialogButtonProps) => ( -// -// ); -// -// interface DialogCancelProps extends RmwcDialogButtonProps { -// /** -// * Callback to execute then button is clicked. -// */ -// onClick?: (e: React.MouseEvent) => void; -// } -// -// /** -// * Use this to close the dialog without taking any additional action. -// */ -// export const DialogCancel = (props: DialogCancelProps) => { -// return ( -// -// {props.children} -// -// ); -// }; -// -// interface DialogAcceptProps extends RmwcDialogButtonProps { -// /** -// * Callback to execute then button is clicked. -// */ -// onClick?: (e: React.MouseEvent) => void; -// } -// -// /** -// * Use this to close the dialog without taking any additional action. -// */ -// export const DialogAccept = (props: DialogAcceptProps) => { -// return ( -// -// {props.children} -// -// ); -// };