diff --git a/packages/demo/src/content/components/alert-dialog.mdx b/packages/demo/src/content/components/alert-dialog.mdx index 5d0d2603..601e229a 100644 --- a/packages/demo/src/content/components/alert-dialog.mdx +++ b/packages/demo/src/content/components/alert-dialog.mdx @@ -1,11 +1,118 @@ --- layout: "@demo/layouts/mdx-layout.astro" heading: "Alert Dialog" -description: "Alert Dialog with sizes and variants" +description: "A modal dialog for confirmations and destructive actions" --- import { AlertDialogDemo } from "@demo/components/demo/alert-dialog"; -## Default +## Overview + +A confirmation dialog that blocks interaction until the user acknowledges it. Unlike [Dialog](dialog), clicking the background overlay won't dismiss it — the user must choose an action. + +## Usage + +Import the components: + +```ts +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@eqtylab/equality"; +``` + +```jsx + + + + + + + Are you sure? + + This action cannot be undone. This will permanently delete the item. + + + + Cancel + Delete + + + +``` + +## Variants + +### Action Button Variants + +`AlertDialogAction` and `AlertDialogCancel` accept `variant` and `size` props from Button. Defaults are `primary` (action) and `tertiary` (cancel) at size `sm`. + +Use `danger` for destructive confirmations: + +```jsx + + Cancel + Delete + +``` + +### Controlled State + +Control the open state with `open` and `onOpenChange`: + +```jsx +const [open, setOpen] = useState(false); + + + + + + ... +; +``` + +## Slots + +| Name | Description | +| ------------------------ | ------------------------------------------ | +| `AlertDialog` | Root component, manages open state | +| `AlertDialogTrigger` | Opens the dialog on click | +| `AlertDialogContent` | Dialog panel with header, body, and footer | +| `AlertDialogHeader` | Contains the title and description | +| `AlertDialogTitle` | Title text (required for accessibility) | +| `AlertDialogDescription` | Describes the action being confirmed | +| `AlertDialogFooter` | Contains action and cancel buttons | +| `AlertDialogAction` | Confirms and closes the dialog | +| `AlertDialogCancel` | Dismisses without acting | + +## Props + +### AlertDialog + +| Name | Description | Type | Default | Required | +| -------------- | ------------------------------ | ------------------------- | ------- | -------- | +| `open` | Whether the dialog is open | `boolean` | - | ❌ | +| `onOpenChange` | Called when open state changes | `(open: boolean) => void` | - | ❌ | + +### AlertDialogAction + +| Name | Description | Type | Default | Required | +| --------- | -------------------- | ------------------------------------------------------------------ | --------- | -------- | +| `variant` | Button style variant | `primary`, `danger`, `secondary`, `tertiary`, `link`, `navigation` | `primary` | ❌ | +| `size` | Button size | `sm`, `md`, `lg` | `sm` | ❌ | + +### AlertDialogCancel + +| Name | Description | Type | Default | Required | +| --------- | -------------------- | ------------------------------------------------------------------ | ---------- | -------- | +| `variant` | Button style variant | `primary`, `danger`, `secondary`, `tertiary`, `link`, `navigation` | `tertiary` | ❌ | +| `size` | Button size | `sm`, `md`, `lg` | `sm` | ❌ | diff --git a/packages/ui/package.json b/packages/ui/package.json index 761730f6..89204b88 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -2,7 +2,7 @@ "name": "@eqtylab/equality", "description": "EQTYLab's component and token-based design system", "homepage": "https://equality.eqtylab.io/", - "version": "1.1.2", + "version": "1.1.3", "license": "Apache-2.0", "keywords": [ "component library", diff --git a/packages/ui/src/components/alert-dialog/alert-dialog.tsx b/packages/ui/src/components/alert-dialog/alert-dialog.tsx index 3435e910..4df1922e 100644 --- a/packages/ui/src/components/alert-dialog/alert-dialog.tsx +++ b/packages/ui/src/components/alert-dialog/alert-dialog.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'; +import { type VariantProps } from 'class-variance-authority'; import styles from '@/components/alert-dialog/alert-dialog.module.css'; import { buttonVariants } from '@/components/button/button'; @@ -78,11 +79,12 @@ AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayNam const AlertDialogAction = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( + React.ComponentPropsWithoutRef & + VariantProps +>(({ className, variant = 'primary', size = 'sm', ...props }, ref) => ( )); @@ -90,15 +92,12 @@ AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; const AlertDialogCancel = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( + React.ComponentPropsWithoutRef & + VariantProps +>(({ className, variant = 'tertiary', size = 'sm', ...props }, ref) => ( )); diff --git a/packages/ui/src/components/checkbox/checkbox.tsx b/packages/ui/src/components/checkbox/checkbox.tsx index 168630b7..ef18f7e7 100644 --- a/packages/ui/src/components/checkbox/checkbox.tsx +++ b/packages/ui/src/components/checkbox/checkbox.tsx @@ -20,7 +20,7 @@ const Checkbox = React.forwardRef - + {Icon ? : }{' '} ) diff --git a/packages/ui/src/components/control-status-badge/control-status-badge.tsx b/packages/ui/src/components/control-status-badge/control-status-badge.tsx index 5257f03a..b683f44b 100644 --- a/packages/ui/src/components/control-status-badge/control-status-badge.tsx +++ b/packages/ui/src/components/control-status-badge/control-status-badge.tsx @@ -102,6 +102,7 @@ export { ControlStatusBadge }; const MessageCircleCheckIcon = ({ className }: { className?: string }) => { return ( ; -const XIcon = X as React.ComponentType<{ className?: string }>; const ChevronLeftIcon = ChevronLeft as React.ComponentType<{ className?: string }>; const ChevronRightIcon = ChevronRight as React.ComponentType<{ className?: string }>; diff --git a/packages/ui/src/components/display-field/display-field.tsx b/packages/ui/src/components/display-field/display-field.tsx index 64b0b146..f5402d91 100644 --- a/packages/ui/src/components/display-field/display-field.tsx +++ b/packages/ui/src/components/display-field/display-field.tsx @@ -151,4 +151,4 @@ function DisplayField({ ); } -export { DisplayField, displayFieldVariants }; +export { DisplayField }; diff --git a/packages/ui/src/components/drawer/drawer.tsx b/packages/ui/src/components/drawer/drawer.tsx index daa3a3a6..5058096a 100644 --- a/packages/ui/src/components/drawer/drawer.tsx +++ b/packages/ui/src/components/drawer/drawer.tsx @@ -63,7 +63,7 @@ const DrawerHeaderActions = React.forwardRef<
); diff --git a/packages/ui/src/components/icon-button/icon-button.tsx b/packages/ui/src/components/icon-button/icon-button.tsx index 3ddcaaee..78237b80 100644 --- a/packages/ui/src/components/icon-button/icon-button.tsx +++ b/packages/ui/src/components/icon-button/icon-button.tsx @@ -91,4 +91,4 @@ function IconButton({ ); } -export { IconButton, iconButtonVariants }; +export { IconButton }; diff --git a/packages/ui/src/components/table/table-components.tsx b/packages/ui/src/components/table/table-components.tsx index 93b483ff..def0c2cb 100644 --- a/packages/ui/src/components/table/table-components.tsx +++ b/packages/ui/src/components/table/table-components.tsx @@ -11,7 +11,7 @@ const TableContainer = React.forwardRef< HTMLTableElement, React.HTMLAttributes & VariantProps >(({ className, elevation = ELEVATION.RAISED, ...props }, ref) => ( -
+
)); @@ -59,22 +59,24 @@ TableHead.displayName = 'TableHead'; const TableCell = React.forwardRef< HTMLTableCellElement, React.TdHTMLAttributes ->(({ className, ...props }, ref) =>
); +>(({ className, ...props }, ref) => ( + +)); TableCell.displayName = 'TableCell'; const TableCaption = React.forwardRef< HTMLTableCaptionElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -
+ )); TableCaption.displayName = 'TableCaption'; export { - TableContainer, TableBody, TableCaption, TableCell, + TableContainer, TableFooter, TableHead, TableHeader, diff --git a/packages/ui/src/components/toast/toast.tsx b/packages/ui/src/components/toast/toast.tsx index 5dfaf8c2..060922d1 100644 --- a/packages/ui/src/components/toast/toast.tsx +++ b/packages/ui/src/components/toast/toast.tsx @@ -15,7 +15,7 @@ interface ToastProps { } const Toast = ({ toast }: ToastProps) => { - const { id, title, description, action, icon, variant, ...props } = toast; + const { title, description, action, icon, variant, ...props } = toast; // Default icons based on variant const getDefaultIcon = () => {