diff --git a/packages/admin-ui/package.json b/packages/admin-ui/package.json index e5de5587f53..29d61684983 100644 --- a/packages/admin-ui/package.json +++ b/packages/admin-ui/package.json @@ -26,7 +26,6 @@ "@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-toast": "^1.2.1", "@radix-ui/react-tooltip": "^1.1.2", - "@radix-ui/react-visually-hidden": "^1.1.1", "@webiny/react-composition": "0.0.0", "@webiny/react-router": "0.0.0", "@webiny/utils": "0.0.0", diff --git a/packages/admin-ui/src/Card/Card.tsx b/packages/admin-ui/src/Card/Card.tsx index 6d97fc86e92..06e15a8894b 100644 --- a/packages/admin-ui/src/Card/Card.tsx +++ b/packages/admin-ui/src/Card/Card.tsx @@ -52,8 +52,8 @@ CardRootBase.displayName = "CardRoot"; const CardRoot = makeDecoratable("CardRoot", CardRootBase); interface CardProps extends CardRootProps, VariantProps { - title?: React.ReactNode | string; - description?: React.ReactNode | string; + title?: React.ReactNode; + description?: React.ReactNode; actions?: React.ReactNode; options?: React.ReactNode; } diff --git a/packages/admin-ui/src/Dialog/Dialog.stories.tsx b/packages/admin-ui/src/Dialog/Dialog.stories.tsx index f54f83fb1f4..59787be8c06 100644 --- a/packages/admin-ui/src/Dialog/Dialog.stories.tsx +++ b/packages/admin-ui/src/Dialog/Dialog.stories.tsx @@ -123,17 +123,17 @@ export const DropdownMenuInDialog: Story = { } }; -export const WithTitleIcon: Story = { +export const WithIcon: Story = { args: { ...Default.args, - titleIcon: } label={"Title icon"} /> + icon: } label={"Title icon"} /> } }; export const PreventOutsideDismiss: Story = { args: { ...Default.args, - preventOutsideDismiss: true + dismissible: false } }; diff --git a/packages/admin-ui/src/Dialog/Dialog.tsx b/packages/admin-ui/src/Dialog/Dialog.tsx index 729494c4d68..932a24b04f3 100644 --- a/packages/admin-ui/src/Dialog/Dialog.tsx +++ b/packages/admin-ui/src/Dialog/Dialog.tsx @@ -8,7 +8,7 @@ import { DialogOverlay } from "~/Dialog/components/DialogOverlay"; import { DialogPortal } from "./components/DialogPortal"; import { DialogRoot } from "./components/DialogRoot"; import { DialogTrigger } from "./components/DialogTrigger"; -import { TitleIcon } from "./components/TitleIcon"; +import { Icon } from "./components/Icon"; import { ConfirmButton } from "./components/ConfirmButton"; import { CancelButton } from "./components/CancelButton"; @@ -16,12 +16,12 @@ export interface DialogProps extends React.ComponentPropsWithoutRef, Omit, "title"> { trigger?: React.ReactNode; - title?: React.ReactNode | string; - titleIcon?: React.ReactElement; + title?: React.ReactNode; + icon?: React.ReactElement; showCloseButton?: boolean; - preventOutsideDismiss?: boolean; + dismissible?: boolean; bodyPadding?: boolean; - description?: React.ReactNode | string; + description?: React.ReactNode; children: React.ReactNode; actions?: React.ReactNode; info?: React.ReactNode; @@ -43,7 +43,7 @@ const DialogBase = (props: DialogProps) => { // Header props. title, - titleIcon, + icon, description, showCloseButton, @@ -72,7 +72,7 @@ const DialogBase = (props: DialogProps) => { // that are decorated with `makeDecoratable`. This will be fixed in the future. children:
{trigger}
}, - headerProps: { title, titleIcon, description, showCloseButton }, + headerProps: { title, icon, description, showCloseButton }, bodyProps: { children, bodyPadding }, footerProps: { info, actions }, contentProps @@ -101,7 +101,7 @@ const DecoratableDialog = makeDecoratable("Dialog", DialogBase); const Dialog = withStaticProps(DecoratableDialog, { ConfirmButton, CancelButton, - TitleIcon + Icon }); export { Dialog }; diff --git a/packages/admin-ui/src/Dialog/components/DialogContent.tsx b/packages/admin-ui/src/Dialog/components/DialogContent.tsx index c9866e929ff..dd3d91779b2 100644 --- a/packages/admin-ui/src/Dialog/components/DialogContent.tsx +++ b/packages/admin-ui/src/Dialog/components/DialogContent.tsx @@ -4,27 +4,29 @@ import { cn } from "~/utils"; export interface DialogContentProps extends React.ComponentPropsWithoutRef { - preventOutsideDismiss?: boolean; + dismissible?: boolean; } const DialogContent = React.forwardRef< React.ElementRef, DialogContentProps ->(({ className, preventOutsideDismiss, children, ...props }, ref) => { - let preventOutsideDismissProps: Pick< - DialogPrimitive.DialogContentProps, - "onInteractOutside" | "onEscapeKeyDown" - > = {}; - if (preventOutsideDismiss) { - preventOutsideDismissProps = { - onInteractOutside: event => event.preventDefault(), - onEscapeKeyDown: event => event.preventDefault() - }; - } +>(({ className, dismissible, children, ...props }, ref) => { + const dismissibleProps = React.useMemo< + Pick + >(() => { + if (dismissible === false) { + return { + onInteractOutside: event => event.preventDefault(), + onEscapeKeyDown: event => event.preventDefault() + }; + } + + return {}; + }, [dismissible]); return ( ); - -DialogDescription.displayName = DialogPrimitive.Description.displayName; diff --git a/packages/admin-ui/src/Dialog/components/DialogFooter.tsx b/packages/admin-ui/src/Dialog/components/DialogFooter.tsx index 7f2d65ee50b..4b110b8e97c 100644 --- a/packages/admin-ui/src/Dialog/components/DialogFooter.tsx +++ b/packages/admin-ui/src/Dialog/components/DialogFooter.tsx @@ -13,10 +13,12 @@ export const DialogFooter = ({ actions, info, className, ...props }: DialogFoote return (
-
-
{info}
-
-
{actions}
+ {info && ( +
+
{info}
+
+ )} + {actions &&
{actions}
}
); }; diff --git a/packages/admin-ui/src/Dialog/components/DialogHeader.tsx b/packages/admin-ui/src/Dialog/components/DialogHeader.tsx index 8e119379a2a..4aa4bd245bf 100644 --- a/packages/admin-ui/src/Dialog/components/DialogHeader.tsx +++ b/packages/admin-ui/src/Dialog/components/DialogHeader.tsx @@ -3,44 +3,23 @@ import { cn } from "~/utils"; import { type DialogProps } from "../Dialog"; import { DialogTitle } from "./DialogTitle"; import { DialogDescription } from "./DialogDescription"; -import * as VisuallyHidden from "@radix-ui/react-visually-hidden"; import { ReactComponent as XIcon } from "@material-design-icons/svg/filled/close.svg"; import { IconButton } from "~/Button"; import * as DialogPrimitive from "@radix-ui/react-dialog"; export type DialogHeaderProps = Omit, "title"> & - Pick; + Pick; export const DialogHeader = ({ title, - titleIcon, + icon, description, showCloseButton, className, ...props }: DialogHeaderProps) => { - let renderedTitle = ( - - {titleIcon} - {title} - - ); - if (!title) { - renderedTitle = {renderedTitle}; - } - - let renderedDescription = {description}; - if (!description) { - renderedDescription = {renderedDescription}; - } - if (!title && !description) { - return ( - <> - {renderedTitle} - {renderedDescription} - - ); + return null; } return ( @@ -57,9 +36,12 @@ export const DialogHeader = ({ } /> )} - {renderedTitle} + + {icon} + {title} + - {renderedDescription} + {description} ); }; diff --git a/packages/admin-ui/src/Dialog/components/DialogTitle.tsx b/packages/admin-ui/src/Dialog/components/DialogTitle.tsx index 64026145296..730770f1fe4 100644 --- a/packages/admin-ui/src/Dialog/components/DialogTitle.tsx +++ b/packages/admin-ui/src/Dialog/components/DialogTitle.tsx @@ -7,5 +7,3 @@ export type DialogTitleProps = React.ComponentPropsWithoutRef ( ); - -DialogTitle.displayName = DialogPrimitive.Title.displayName; diff --git a/packages/admin-ui/src/Dialog/components/Icon.tsx b/packages/admin-ui/src/Dialog/components/Icon.tsx new file mode 100644 index 00000000000..a327de866e4 --- /dev/null +++ b/packages/admin-ui/src/Dialog/components/Icon.tsx @@ -0,0 +1,18 @@ +import * as React from "react"; +import { cn, makeDecoratable } from "~/utils"; +import { Icon as IconComponent, IconProps as IconComponentProps } from "~/Icon"; + +type IconProps = IconComponentProps; + +const IconBase = ({ className, ...props }: IconProps) => { + return ( + + ); +}; + +export const Icon = makeDecoratable("Icon", IconBase); diff --git a/packages/admin-ui/src/Dialog/components/TitleIcon.tsx b/packages/admin-ui/src/Dialog/components/TitleIcon.tsx deleted file mode 100644 index 2ed35fbb2dc..00000000000 --- a/packages/admin-ui/src/Dialog/components/TitleIcon.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as React from "react"; -import { cn, makeDecoratable } from "~/utils"; -import { Icon, IconProps } from "~/Icon"; - -type TitleIconProps = IconProps; - -const TitleIconBase = ({ className, ...props }: TitleIconProps) => { - return ( - - ); -}; - -export const TitleIcon = makeDecoratable("TitleIcon", TitleIconBase); diff --git a/packages/admin-ui/src/Heading/Heading.tsx b/packages/admin-ui/src/Heading/Heading.tsx index 4e76c3da942..44196de36f8 100644 --- a/packages/admin-ui/src/Heading/Heading.tsx +++ b/packages/admin-ui/src/Heading/Heading.tsx @@ -3,7 +3,7 @@ import { makeDecoratable } from "@webiny/react-composition"; import { cva, type VariantProps } from "class-variance-authority"; import { cn } from "~/utils"; -export type HeadingTags = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "div"; +export type HeadingTags = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; export type HeadingLevels = 1 | 2 | 3 | 4 | 5 | 6; // Create a mapping of variant to tag diff --git a/packages/app-admin-rmwc/src/modules/Overlays/Dialog.tsx b/packages/app-admin-rmwc/src/modules/Overlays/Dialog.tsx index c3e5d8314a9..25b3abb6feb 100644 --- a/packages/app-admin-rmwc/src/modules/Overlays/Dialog.tsx +++ b/packages/app-admin-rmwc/src/modules/Overlays/Dialog.tsx @@ -73,7 +73,6 @@ export const DialogContainer = () => { {actions.accept.label} diff --git a/packages/ui/package.json b/packages/ui/package.json index 871075e463c..8505567e88a 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -37,7 +37,6 @@ "load-script": "^1.0.0", "lodash": "^4.17.21", "material-components-web": "^14.0.0", - "nprogress": "^0.2.0", "nuka-carousel": "4.7.1", "react-butterfiles": "^1.3.3", "react-color": "^2.19.3", @@ -50,7 +49,6 @@ "devDependencies": { "@emotion/babel-plugin": "^11.11.0", "@testing-library/react": "^15.0.7", - "@types/nprogress": "^0.2.0", "@types/react-color": "^2.17.11", "@types/react-custom-scrollbars": "^4.0.10", "@types/react-transition-group": "^4.4.4", diff --git a/packages/ui/src/Dialog/Dialog.tsx b/packages/ui/src/Dialog/Dialog.tsx index 73477035164..49aa7525633 100644 --- a/packages/ui/src/Dialog/Dialog.tsx +++ b/packages/ui/src/Dialog/Dialog.tsx @@ -113,7 +113,7 @@ export const Dialog = ({ { if (!opened && onClose) { diff --git a/packages/ui/src/TopProgressBar/README.md b/packages/ui/src/TopProgressBar/README.md deleted file mode 100644 index b602420074e..00000000000 --- a/packages/ui/src/TopProgressBar/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# TopProgressBar - -### Description - -Use `TopProgressBar` to let users know their actions are being processed. - -### Import - -```js -import { TopProgressBar } from "@webiny/ui/TopProgressBar"; -``` diff --git a/packages/ui/src/TopProgressBar/TopProgressBar.tsx b/packages/ui/src/TopProgressBar/TopProgressBar.tsx deleted file mode 100644 index d02ea78ea4c..00000000000 --- a/packages/ui/src/TopProgressBar/TopProgressBar.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from "react"; -import nprogress from "nprogress"; -import "./style.scss"; - -export interface TopProgressBarRender { - start: () => void; - finish: () => void; - nprogress: typeof nprogress; -} - -export interface TopProgressBarProps { - /** - * Elements that require top loading bar to be shown. - */ - children: (params: TopProgressBarRender) => React.ReactElement; -} - -export const TopProgressBar = (props: TopProgressBarProps) => { - return props.children({ - start: nprogress.start, - finish: nprogress.done, - nprogress - }); -}; diff --git a/packages/ui/src/TopProgressBar/hoc/index.ts b/packages/ui/src/TopProgressBar/hoc/index.ts deleted file mode 100644 index 9ca0173b8ff..00000000000 --- a/packages/ui/src/TopProgressBar/hoc/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as withTopProgressBar } from "./withTopProgressBar"; diff --git a/packages/ui/src/TopProgressBar/hoc/withTopProgressBar.tsx b/packages/ui/src/TopProgressBar/hoc/withTopProgressBar.tsx deleted file mode 100644 index ff299f46949..00000000000 --- a/packages/ui/src/TopProgressBar/hoc/withTopProgressBar.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from "react"; -import { TopProgressBar } from ".."; - -const withTopProgressBar = () => { - return (BaseComponent: React.ComponentType) => { - const WithTopProgressBar = (props: any) => { - return ( - - {({ start, finish, nprogress }) => ( - - )} - - ); - }; - - return WithTopProgressBar; - }; -}; - -export default withTopProgressBar; diff --git a/packages/ui/src/TopProgressBar/index.ts b/packages/ui/src/TopProgressBar/index.ts deleted file mode 100644 index f885bc298ce..00000000000 --- a/packages/ui/src/TopProgressBar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./TopProgressBar"; diff --git a/packages/ui/src/TopProgressBar/style.scss b/packages/ui/src/TopProgressBar/style.scss deleted file mode 100644 index d2ae4d4c0b0..00000000000 --- a/packages/ui/src/TopProgressBar/style.scss +++ /dev/null @@ -1,21 +0,0 @@ -/* Make clicks pass-through */ -#nprogress { - pointer-events: none; -} - -#nprogress .bar { - background: var(--mdc-theme-secondary); - - position: fixed; - z-index: 1031; - top: 64px; - left: 0; - - width: 100%; - height: 2px; -} - -/* Fancy blur effect */ -#nprogress .peg { - display: none; -} diff --git a/yarn.lock b/yarn.lock index 1e8af89458e..bd6d57941ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10508,25 +10508,6 @@ __metadata: languageName: node linkType: hard -"@radix-ui/react-visually-hidden@npm:^1.1.1": - version: 1.1.1 - resolution: "@radix-ui/react-visually-hidden@npm:1.1.1" - dependencies: - "@radix-ui/react-primitive": "npm:2.0.1" - peerDependencies: - "@types/react": "*" - "@types/react-dom": "*" - react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc - react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc - peerDependenciesMeta: - "@types/react": - optional: true - "@types/react-dom": - optional: true - checksum: 10/ccbdf29811283fb257f0b0f8604923e6fe349a264986463f6d6a20946fc51e243527985e69f0af27659f78fd7a4199dacbba5bfc7af3667aa409cd23a0ae3283 - languageName: node - linkType: hard - "@radix-ui/rect@npm:1.0.1": version: 1.0.1 resolution: "@radix-ui/rect@npm:1.0.1" @@ -15306,7 +15287,6 @@ __metadata: "@radix-ui/react-tabs": "npm:^1.1.0" "@radix-ui/react-toast": "npm:^1.2.1" "@radix-ui/react-tooltip": "npm:^1.1.2" - "@radix-ui/react-visually-hidden": "npm:^1.1.1" "@storybook/addon-a11y": "npm:7.6.20" "@storybook/addon-essentials": "npm:7.6.20" "@storybook/react": "npm:7.6.20" @@ -19648,7 +19628,6 @@ __metadata: "@svgr/webpack": "npm:^6.1.1" "@tanstack/react-table": "npm:^8.5.22" "@testing-library/react": "npm:^15.0.7" - "@types/nprogress": "npm:^0.2.0" "@types/react-color": "npm:^2.17.11" "@types/react-custom-scrollbars": "npm:^4.0.10" "@types/react-transition-group": "npm:^4.4.4" @@ -19669,7 +19648,6 @@ __metadata: lodash: "npm:^4.17.21" material-components-web: "npm:^14.0.0" ncp: "npm:^2.0.0" - nprogress: "npm:^0.2.0" nuka-carousel: "npm:4.7.1" raw-loader: "npm:^4.0.2" react-butterfiles: "npm:^1.3.3"