[FIX] Frontend: Ajouter composants Dialog manquants pour WebhooksPage
- Ajout DialogContent, DialogDescription, DialogTitle, DialogTrigger - Support onOpenChange pour compatibilité Radix UI - Import React ajouté - Corrige erreurs de compilation dans WebhooksPage
This commit is contained in:
parent
a486536bed
commit
9d0bd8a343
1 changed files with 83 additions and 4 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import React from 'react';
|
||||||
import { Modal } from './modal';
|
import { Modal } from './modal';
|
||||||
import { Button } from './button';
|
import { Button } from './button';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
|
@ -5,7 +6,8 @@ import { AlertCircle, Info } from 'lucide-react';
|
||||||
|
|
||||||
export interface DialogProps {
|
export interface DialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose?: () => void;
|
||||||
|
onOpenChange?: (open: boolean) => void;
|
||||||
title?: string;
|
title?: string;
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
footer?: React.ReactNode;
|
footer?: React.ReactNode;
|
||||||
|
|
@ -38,6 +40,7 @@ const variantStyles = {
|
||||||
export function Dialog({
|
export function Dialog({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
|
onOpenChange,
|
||||||
title,
|
title,
|
||||||
children,
|
children,
|
||||||
footer,
|
footer,
|
||||||
|
|
@ -49,18 +52,26 @@ export function Dialog({
|
||||||
showCancel = true,
|
showCancel = true,
|
||||||
size = 'md',
|
size = 'md',
|
||||||
}: DialogProps) {
|
}: DialogProps) {
|
||||||
|
const handleClose = () => {
|
||||||
|
if (onOpenChange) {
|
||||||
|
onOpenChange(false);
|
||||||
|
} else if (onClose) {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
if (onConfirm) {
|
if (onConfirm) {
|
||||||
await onConfirm();
|
await onConfirm();
|
||||||
}
|
}
|
||||||
onClose();
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
if (onCancel) {
|
if (onCancel) {
|
||||||
onCancel();
|
onCancel();
|
||||||
}
|
}
|
||||||
onClose();
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const IconComponent = variantIcons[variant];
|
const IconComponent = variantIcons[variant];
|
||||||
|
|
@ -69,7 +80,7 @@ export function Dialog({
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={open}
|
open={open}
|
||||||
onClose={onClose}
|
onClose={handleClose}
|
||||||
size={size}
|
size={size}
|
||||||
closeOnOverlayClick={variant === 'default'}
|
closeOnOverlayClick={variant === 'default'}
|
||||||
>
|
>
|
||||||
|
|
@ -184,3 +195,71 @@ export function DialogFooter({ children, className }: DialogFooterProps) {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Radix UI-style components for compatibility
|
||||||
|
export interface DialogContentProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DialogContent({ children, className }: DialogContentProps) {
|
||||||
|
return <div className={cn('p-6', className)}>{children}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DialogDescriptionProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DialogDescription({
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
}: DialogDescriptionProps) {
|
||||||
|
return (
|
||||||
|
<p className={cn('text-sm text-muted-foreground', className)}>
|
||||||
|
{children}
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DialogTitleProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DialogTitle({ children, className }: DialogTitleProps) {
|
||||||
|
return (
|
||||||
|
<h2
|
||||||
|
className={cn(
|
||||||
|
'text-2xl font-semibold leading-none tracking-tight',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</h2>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DialogTriggerProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
asChild?: boolean;
|
||||||
|
onClick?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DialogTrigger({
|
||||||
|
children,
|
||||||
|
asChild,
|
||||||
|
onClick,
|
||||||
|
}: DialogTriggerProps) {
|
||||||
|
// If asChild, we expect the child to handle the click
|
||||||
|
if (asChild && React.isValidElement(children)) {
|
||||||
|
return React.cloneElement(children, {
|
||||||
|
onClick: onClick || children.props.onClick,
|
||||||
|
} as any);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div onClick={onClick} style={{ display: 'inline-block' }}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue