Skip to content

Commit 745d449

Browse files
[autofix.ci] apply automated fixes
1 parent 8f8c4f3 commit 745d449

File tree

3 files changed

+190
-186
lines changed

3 files changed

+190
-186
lines changed

internal/ui/src/components/dialog/components/dialog-parts.tsx

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@ import * as React from "react";
55
import type { PropsWithChildren } from "react";
66
import { cn } from "../../../lib/utils";
77
import {
8-
DialogFooter as ShadcnDialogFooter,
9-
DialogHeader as ShadcnDialogHeader,
10-
DialogTitle as ShadcnDialogTitle,
8+
DialogFooter as ShadcnDialogFooter,
9+
DialogHeader as ShadcnDialogHeader,
10+
DialogTitle as ShadcnDialogTitle,
1111
} from "./dialog";
1212

1313
type DefaultDialogHeaderProps = {
14-
title: string;
15-
subTitle?: string;
16-
className?: string;
14+
title: string;
15+
subTitle?: string;
16+
className?: string;
1717
};
1818

1919
export const DefaultDialogHeader = ({ title, subTitle, className }: DefaultDialogHeaderProps) => {
20-
return (
21-
<ShadcnDialogHeader className={cn("border-b border-gray-4 bg-white dark:bg-black", className)}>
22-
<ShadcnDialogTitle className="px-6 py-4 text-gray-12 font-medium text-base flex flex-col">
23-
<span className="leading-[32px]">{title}</span>
24-
{subTitle && ( // Conditionally render subtitle span only if it exists
25-
<span className="text-gray-9 leading-[20px] text-[13px] font-normal">{subTitle}</span>
26-
)}
27-
</ShadcnDialogTitle>
28-
</ShadcnDialogHeader>
29-
);
20+
return (
21+
<ShadcnDialogHeader className={cn("border-b border-gray-4 bg-white dark:bg-black", className)}>
22+
<ShadcnDialogTitle className="px-6 py-4 text-gray-12 font-medium text-base flex flex-col">
23+
<span className="leading-[32px]">{title}</span>
24+
{subTitle && ( // Conditionally render subtitle span only if it exists
25+
<span className="text-gray-9 leading-[20px] text-[13px] font-normal">{subTitle}</span>
26+
)}
27+
</ShadcnDialogTitle>
28+
</ShadcnDialogHeader>
29+
);
3030
};
3131

3232
type DefaultDialogContentAreaProps = PropsWithChildren<{
33-
className?: string;
33+
className?: string;
3434
}>;
3535

3636
export const DefaultDialogContentArea = ({
37-
children,
38-
className,
37+
children,
38+
className,
3939
}: DefaultDialogContentAreaProps) => {
40-
return (
41-
<div className={cn("bg-grayA-2 flex flex-col gap-4 py-4 px-6 text-gray-11", className)}>
42-
{children}
43-
</div>
44-
);
40+
return (
41+
<div className={cn("bg-grayA-2 flex flex-col gap-4 py-4 px-6 text-gray-11", className)}>
42+
{children}
43+
</div>
44+
);
4545
};
4646

4747
type DefaultDialogFooterProps = PropsWithChildren<{
48-
className?: string;
48+
className?: string;
4949
}>;
5050

5151
export const DefaultDialogFooter = ({ children, className }: DefaultDialogFooterProps) => {
52-
return (
53-
<ShadcnDialogFooter
54-
className={cn("p-6 border-t border-grayA-4 bg-white dark:bg-black text-gray-9", className)}
55-
>
56-
{children}
57-
</ShadcnDialogFooter>
58-
);
59-
};
52+
return (
53+
<ShadcnDialogFooter
54+
className={cn("p-6 border-t border-grayA-4 bg-white dark:bg-black text-gray-9", className)}
55+
>
56+
{children}
57+
</ShadcnDialogFooter>
58+
);
59+
};

internal/ui/src/components/dialog/components/dialog.tsx

Lines changed: 115 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -14,149 +14,149 @@ const DialogPortal = DialogPrimitive.Portal;
1414
const DialogClose = DialogPrimitive.Close;
1515

1616
const DialogOverlay = React.forwardRef<
17-
React.ElementRef<typeof DialogPrimitive.Overlay>,
18-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {
19-
showCloseWarning?: boolean;
20-
onAttemptClose?: () => void;
21-
}
17+
React.ElementRef<typeof DialogPrimitive.Overlay>,
18+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay> & {
19+
showCloseWarning?: boolean;
20+
onAttemptClose?: () => void;
21+
}
2222
>(({ className, showCloseWarning = false, onAttemptClose, ...props }, ref) => (
23-
<DialogPrimitive.Overlay
24-
ref={ref}
25-
className={cn(
26-
"fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
27-
className,
28-
)}
29-
{...props}
30-
/>
23+
<DialogPrimitive.Overlay
24+
ref={ref}
25+
className={cn(
26+
"fixed inset-0 z-50 bg-black/30 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
27+
className,
28+
)}
29+
{...props}
30+
/>
3131
));
3232
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
3333

3434
const DialogContent = React.forwardRef<
35-
React.ElementRef<typeof DialogPrimitive.Content>,
36-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
37-
showCloseWarning?: boolean;
38-
onAttemptClose?: () => void;
39-
xButtonRef?: React.RefObject<HTMLButtonElement>;
40-
}
35+
React.ElementRef<typeof DialogPrimitive.Content>,
36+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
37+
showCloseWarning?: boolean;
38+
onAttemptClose?: () => void;
39+
xButtonRef?: React.RefObject<HTMLButtonElement>;
40+
}
4141
>(
42-
(
43-
{ className, children, showCloseWarning = false, onAttemptClose, xButtonRef, ...props },
44-
ref,
45-
) => {
46-
const handleCloseAttempt = React.useCallback(() => {
47-
// This handler is now only called when showCloseWarning is true
48-
if (showCloseWarning) {
49-
onAttemptClose?.();
50-
}
51-
}, [showCloseWarning, onAttemptClose]);
42+
(
43+
{ className, children, showCloseWarning = false, onAttemptClose, xButtonRef, ...props },
44+
ref,
45+
) => {
46+
const handleCloseAttempt = React.useCallback(() => {
47+
// This handler is now only called when showCloseWarning is true
48+
if (showCloseWarning) {
49+
onAttemptClose?.();
50+
}
51+
}, [showCloseWarning, onAttemptClose]);
5252

53-
// Common class names for both button types
54-
const buttonClassNames =
55-
"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent text-muted-foreground z-[51]";
53+
// Common class names for both button types
54+
const buttonClassNames =
55+
"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent text-muted-foreground z-[51]";
5656

57-
return (
58-
<DialogPortal>
59-
<DialogOverlay showCloseWarning={showCloseWarning} onAttemptClose={handleCloseAttempt} />
60-
<DialogPrimitive.Content
61-
ref={ref}
62-
className={cn(
63-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
64-
className,
65-
)}
66-
onEscapeKeyDown={(e) => {
67-
if (showCloseWarning) {
68-
e.preventDefault();
69-
handleCloseAttempt();
70-
}
71-
}}
72-
onPointerDownOutside={(e) => {
73-
// Prevent closing only if warning is active and click is outside content
74-
if (showCloseWarning) {
75-
// Basic check: If the target is the overlay, it's handled there.
76-
// More robust checks might be needed depending on content complexity.
77-
const contentElement = (e.target as HTMLElement)?.closest('[role="dialog"]');
78-
if (!contentElement || contentElement !== e.currentTarget) {
79-
e.preventDefault();
80-
handleCloseAttempt();
81-
}
82-
}
83-
}}
84-
{...props}
85-
>
86-
{children}
57+
return (
58+
<DialogPortal>
59+
<DialogOverlay showCloseWarning={showCloseWarning} onAttemptClose={handleCloseAttempt} />
60+
<DialogPrimitive.Content
61+
ref={ref}
62+
className={cn(
63+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
64+
className,
65+
)}
66+
onEscapeKeyDown={(e) => {
67+
if (showCloseWarning) {
68+
e.preventDefault();
69+
handleCloseAttempt();
70+
}
71+
}}
72+
onPointerDownOutside={(e) => {
73+
// Prevent closing only if warning is active and click is outside content
74+
if (showCloseWarning) {
75+
// Basic check: If the target is the overlay, it's handled there.
76+
// More robust checks might be needed depending on content complexity.
77+
const contentElement = (e.target as HTMLElement)?.closest('[role="dialog"]');
78+
if (!contentElement || contentElement !== e.currentTarget) {
79+
e.preventDefault();
80+
handleCloseAttempt();
81+
}
82+
}
83+
}}
84+
{...props}
85+
>
86+
{children}
8787

88-
{/* Conditionally render the close button */}
89-
{showCloseWarning ? (
90-
<button
91-
ref={xButtonRef} // Attach ref only needed for anchoring the custom popover
92-
type="button"
93-
onClick={handleCloseAttempt} // Call attempt handler
94-
className={buttonClassNames}
95-
aria-label="Close dialog with confirmation"
96-
>
97-
<X className="w-4 h-4" />
98-
</button>
99-
) : (
100-
// Use DialogPrimitive.Close for standard behavior
101-
<DialogPrimitive.Close asChild>
102-
<button type="button" className={buttonClassNames} aria-label="Close dialog">
103-
<X className="w-4 h-4" />
104-
</button>
105-
</DialogPrimitive.Close>
106-
)}
107-
</DialogPrimitive.Content>
108-
</DialogPortal>
109-
);
110-
},
88+
{/* Conditionally render the close button */}
89+
{showCloseWarning ? (
90+
<button
91+
ref={xButtonRef} // Attach ref only needed for anchoring the custom popover
92+
type="button"
93+
onClick={handleCloseAttempt} // Call attempt handler
94+
className={buttonClassNames}
95+
aria-label="Close dialog with confirmation"
96+
>
97+
<X className="w-4 h-4" />
98+
</button>
99+
) : (
100+
// Use DialogPrimitive.Close for standard behavior
101+
<DialogPrimitive.Close asChild>
102+
<button type="button" className={buttonClassNames} aria-label="Close dialog">
103+
<X className="w-4 h-4" />
104+
</button>
105+
</DialogPrimitive.Close>
106+
)}
107+
</DialogPrimitive.Content>
108+
</DialogPortal>
109+
);
110+
},
111111
);
112112
DialogContent.displayName = DialogPrimitive.Content.displayName;
113113

114114
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
115-
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
115+
<div className={cn("flex flex-col space-y-1.5 text-center sm:text-left", className)} {...props} />
116116
);
117117
DialogHeader.displayName = "DialogHeader";
118118

119119
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
120-
<div
121-
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
122-
{...props}
123-
/>
120+
<div
121+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
122+
{...props}
123+
/>
124124
);
125125
DialogFooter.displayName = "DialogFooter";
126126

127127
const DialogTitle = React.forwardRef<
128-
React.ElementRef<typeof DialogPrimitive.Title>,
129-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
128+
React.ElementRef<typeof DialogPrimitive.Title>,
129+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
130130
>(({ className, ...props }, ref) => (
131-
<DialogPrimitive.Title
132-
ref={ref}
133-
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
134-
{...props}
135-
/>
131+
<DialogPrimitive.Title
132+
ref={ref}
133+
className={cn("text-lg font-semibold leading-none tracking-tight", className)}
134+
{...props}
135+
/>
136136
));
137137
DialogTitle.displayName = DialogPrimitive.Title.displayName;
138138

139139
const DialogDescription = React.forwardRef<
140-
React.ElementRef<typeof DialogPrimitive.Description>,
141-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
140+
React.ElementRef<typeof DialogPrimitive.Description>,
141+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
142142
>(({ className, ...props }, ref) => (
143-
<DialogPrimitive.Description
144-
ref={ref}
145-
className={cn("text-sm text-content-subtle", className)}
146-
{...props}
147-
/>
143+
<DialogPrimitive.Description
144+
ref={ref}
145+
className={cn("text-sm text-content-subtle", className)}
146+
{...props}
147+
/>
148148
));
149149
DialogDescription.displayName = DialogPrimitive.Description.displayName;
150150

151151
export {
152-
Dialog,
153-
DialogPortal,
154-
DialogOverlay,
155-
DialogClose,
156-
DialogTrigger,
157-
DialogContent,
158-
DialogHeader,
159-
DialogFooter,
160-
DialogTitle,
161-
DialogDescription,
162-
};
152+
Dialog,
153+
DialogPortal,
154+
DialogOverlay,
155+
DialogClose,
156+
DialogTrigger,
157+
DialogContent,
158+
DialogHeader,
159+
DialogFooter,
160+
DialogTitle,
161+
DialogDescription,
162+
};

0 commit comments

Comments
 (0)