@common-origin/design-system 2.9.0 → 2.10.0
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/dist/components/molecules/Modal/Modal.d.ts +65 -0
- package/dist/components/molecules/Modal/index.d.ts +2 -0
- package/dist/components/molecules/index.d.ts +1 -0
- package/dist/index.esm.js +520 -297
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +520 -296
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type IconName } from '../../../types/icons';
|
|
3
|
+
export type ModalSize = 'small' | 'medium' | 'large';
|
|
4
|
+
export interface ModalAction {
|
|
5
|
+
/** Button label text */
|
|
6
|
+
label: string;
|
|
7
|
+
/** Callback when the action is clicked */
|
|
8
|
+
onClick: () => void;
|
|
9
|
+
/** Button variant */
|
|
10
|
+
variant?: 'primary' | 'secondary' | 'naked' | 'emphasis' | 'danger';
|
|
11
|
+
/** Optional leading icon */
|
|
12
|
+
icon?: IconName;
|
|
13
|
+
/** Whether the button is disabled */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ModalProps {
|
|
17
|
+
/** Whether the modal is visible */
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
/** Callback fired when the modal should close (close button, overlay, Escape) */
|
|
20
|
+
onClose: () => void;
|
|
21
|
+
/** Title displayed in the modal header */
|
|
22
|
+
title: string;
|
|
23
|
+
/** Body content of the modal */
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Width preset. All sizes auto-switch to fullscreen below the `md` breakpoint (768 px).
|
|
27
|
+
* - small → 400 px
|
|
28
|
+
* - medium → 560 px
|
|
29
|
+
* - large → 720 px
|
|
30
|
+
* @default 'medium'
|
|
31
|
+
*/
|
|
32
|
+
size?: ModalSize;
|
|
33
|
+
/** Structured action buttons rendered in the footer */
|
|
34
|
+
actions?: ModalAction[];
|
|
35
|
+
/**
|
|
36
|
+
* Close when the backdrop overlay is clicked
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
39
|
+
closeOnOverlayClick?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Close when the Escape key is pressed
|
|
42
|
+
* @default true
|
|
43
|
+
*/
|
|
44
|
+
closeOnEscape?: boolean;
|
|
45
|
+
/** Test identifier for automated testing */
|
|
46
|
+
'data-testid'?: string;
|
|
47
|
+
/** Accessible label – falls back to `title` */
|
|
48
|
+
'aria-label'?: string;
|
|
49
|
+
/** ID of an element that describes the modal */
|
|
50
|
+
'aria-describedby'?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Modal component
|
|
54
|
+
*
|
|
55
|
+
* A centred dialog overlay with a title, close button (IconButton), scrollable
|
|
56
|
+
* body content, and an optional footer with structured action buttons.
|
|
57
|
+
*
|
|
58
|
+
* - Renders via `createPortal` to avoid z-index / overflow issues.
|
|
59
|
+
* - Auto-fullscreen on viewports narrower than 768 px.
|
|
60
|
+
* - Focus trap, Escape-to-close, overlay-click-to-close.
|
|
61
|
+
* - Locks body scroll while open.
|
|
62
|
+
*
|
|
63
|
+
* Composes: IconButton, Button, Typography, Stack, Divider
|
|
64
|
+
*/
|
|
65
|
+
export declare const Modal: React.FC<ModalProps>;
|