@umituz/web-design-system 4.7.1 → 4.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-design-system",
3
- "version": "4.7.1",
3
+ "version": "4.7.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Web Design System - Tailwind v4 authored, precompiled CSS shipped. Atomic Design components (Atoms, Molecules, Organisms, Templates) for React applications.",
@@ -32,6 +32,7 @@ import { Drawer } from '../presentation/organisms/Drawer';
32
32
  import { Timeline } from '../presentation/organisms/Timeline';
33
33
  import { Checklist } from '../presentation/organisms/Checklist';
34
34
  import { FormModal } from '../presentation/organisms/FormModal';
35
+ import { ConfirmDialog } from '../presentation/organisms/ConfirmDialog';
35
36
  import { BatteryPill } from '../presentation/atoms/BatteryPill';
36
37
  import { Kbd } from '../presentation/atoms/Kbd';
37
38
 
@@ -880,4 +881,20 @@ describe('accessia supersets', () => {
880
881
  fireEvent.click(screen.getByRole('button', { name: 'Create' }));
881
882
  expect(onSubmit).toHaveBeenCalledWith({ welcome: true });
882
883
  });
884
+
885
+ it('ConfirmDialog confirms and closes, cancel only closes', () => {
886
+ const onConfirm = vi.fn();
887
+ const onClose = vi.fn();
888
+ render(
889
+ <ConfirmDialog title="Delete row?" body="This cannot be undone." confirmLabel="Delete" onConfirm={onConfirm} onClose={onClose} />,
890
+ );
891
+ expect(screen.getByRole('dialog')).toBeTruthy();
892
+ expect(screen.getByText('This cannot be undone.')).toBeTruthy();
893
+ fireEvent.click(screen.getByRole('button', { name: 'Cancel' }));
894
+ expect(onClose).toHaveBeenCalledTimes(1);
895
+ expect(onConfirm).not.toHaveBeenCalled();
896
+ fireEvent.click(screen.getByRole('button', { name: 'Delete' }));
897
+ expect(onConfirm).toHaveBeenCalledTimes(1);
898
+ expect(onClose).toHaveBeenCalledTimes(2);
899
+ });
883
900
  });
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ConfirmDialog Component (Organism)
3
+ * @description Destructive/primary confirmation built on Modal: title, body and
4
+ * Cancel + confirm actions; unmounts itself after confirming
5
+ */
6
+
7
+ import type { ReactNode } from 'react';
8
+ import { Button } from '../atoms/Button';
9
+ import { Modal } from './Modal';
10
+
11
+ export interface ConfirmDialogProps {
12
+ title: ReactNode;
13
+ body?: ReactNode;
14
+ confirmLabel?: string;
15
+ cancelLabel?: string;
16
+ /** Visual weight of the confirm action; defaults to danger. */
17
+ tone?: 'danger' | 'primary';
18
+ onConfirm: () => void;
19
+ onClose: () => void;
20
+ }
21
+
22
+ export function ConfirmDialog({ title, body, confirmLabel = 'Confirm', cancelLabel = 'Cancel', tone = 'danger', onConfirm, onClose }: ConfirmDialogProps) {
23
+ return (
24
+ <Modal
25
+ open
26
+ danger={tone === 'danger'}
27
+ title={title}
28
+ description={body}
29
+ onClose={onClose}
30
+ footer={
31
+ <>
32
+ <Button variant="secondary" size="sm" onClick={onClose}>
33
+ {cancelLabel}
34
+ </Button>
35
+ <Button variant={tone === 'danger' ? 'danger' : 'default'} size="sm" onClick={() => { onConfirm(); onClose(); }}>
36
+ {confirmLabel}
37
+ </Button>
38
+ </>
39
+ }
40
+ />
41
+ );
42
+ }
@@ -137,3 +137,6 @@ export type {
137
137
  FormModalValues,
138
138
  FormStep,
139
139
  } from './FormModal';
140
+
141
+ export { ConfirmDialog } from './ConfirmDialog';
142
+ export type { ConfirmDialogProps } from './ConfirmDialog';