cleanplate 0.1.10 → 0.2.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/accordion/Accordion.d.ts +23 -12
- package/dist/components/accordion/Accordion.d.ts.map +1 -1
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.d.ts.map +1 -1
- package/dist/components/animated/Animated.d.ts +18 -16
- package/dist/components/animated/Animated.d.ts.map +1 -1
- package/dist/components/animated/index.d.ts +2 -2
- package/dist/components/animated/index.d.ts.map +1 -1
- package/dist/components/app-shell/AppShell.d.ts +35 -3
- package/dist/components/app-shell/AppShell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +2 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/bottom-sheet/BottomSheet.d.ts +17 -16
- package/dist/components/bottom-sheet/BottomSheet.d.ts.map +1 -1
- package/dist/components/bottom-sheet/index.d.ts +2 -1
- package/dist/components/bottom-sheet/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/BreadCrumb.d.ts +26 -0
- package/dist/components/breadcrumb/BreadCrumb.d.ts.map +1 -0
- package/dist/components/breadcrumb/index.d.ts +3 -2
- package/dist/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/footer/Footer.d.ts +21 -16
- package/dist/components/footer/Footer.d.ts.map +1 -1
- package/dist/components/footer/index.d.ts +2 -1
- package/dist/components/footer/index.d.ts.map +1 -1
- package/dist/components/form-controls/Checkbox.d.ts +10 -8
- package/dist/components/form-controls/Checkbox.d.ts.map +1 -1
- package/dist/components/form-controls/Date.d.ts +6 -4
- package/dist/components/form-controls/Date.d.ts.map +1 -1
- package/dist/components/form-controls/File.d.ts +10 -9
- package/dist/components/form-controls/File.d.ts.map +1 -1
- package/dist/components/form-controls/Input.d.ts +11 -9
- package/dist/components/form-controls/Input.d.ts.map +1 -1
- package/dist/components/form-controls/Radio.d.ts +10 -9
- package/dist/components/form-controls/Radio.d.ts.map +1 -1
- package/dist/components/form-controls/Select.d.ts +12 -6
- package/dist/components/form-controls/Select.d.ts.map +1 -1
- package/dist/components/form-controls/Stepper.d.ts +10 -8
- package/dist/components/form-controls/Stepper.d.ts.map +1 -1
- package/dist/components/form-controls/TextArea.d.ts +10 -8
- package/dist/components/form-controls/TextArea.d.ts.map +1 -1
- package/dist/components/form-controls/Toggle.d.ts +10 -9
- package/dist/components/form-controls/Toggle.d.ts.map +1 -1
- package/dist/components/form-controls/index.d.ts +30 -20
- package/dist/components/form-controls/index.d.ts.map +1 -1
- package/dist/components/header/Header.d.ts +32 -28
- package/dist/components/header/Header.d.ts.map +1 -1
- package/dist/components/header/index.d.ts +2 -1
- package/dist/components/header/index.d.ts.map +1 -1
- package/dist/components/menu-list/MenuList.d.ts +32 -22
- package/dist/components/menu-list/MenuList.d.ts.map +1 -1
- package/dist/components/menu-list/index.d.ts +2 -1
- package/dist/components/menu-list/index.d.ts.map +1 -1
- package/dist/components/page-header/PageHeader.d.ts +22 -3
- package/dist/components/page-header/PageHeader.d.ts.map +1 -1
- package/dist/components/page-header/index.d.ts +2 -1
- package/dist/components/page-header/index.d.ts.map +1 -1
- package/dist/components/toast/Toast.d.ts +20 -12
- package/dist/components/toast/Toast.d.ts.map +1 -1
- package/dist/components/toast/index.d.ts +2 -1
- package/dist/components/toast/index.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +3 -3
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/docs/Alert.md +0 -131
- package/docs/Avatar.md +0 -130
- package/docs/Badge.md +0 -83
- package/docs/Button.md +0 -175
- package/docs/ConfirmDialog.md +0 -139
- package/docs/Container.md +0 -230
- package/docs/Dropdown.md +0 -175
- package/docs/Icon.md +0 -225
- package/docs/MediaObject.md +0 -303
- package/docs/Modal.md +0 -152
- package/docs/Pagination.md +0 -142
- package/docs/Pills.md +0 -104
- package/docs/Spinner.md +0 -115
- package/docs/Stepper.md +0 -131
- package/docs/Table.md +0 -194
- package/docs/Typography.md +0 -226
- package/llms.txt +0 -171
- package/scripts/generate-icons.js +0 -175
- package/templates/README.md +0 -10
- package/templates/docs-template-sample.md +0 -67
- package/templates/storybook-docs-template.md +0 -236
- package/tsconfig.json +0 -26
package/docs/Avatar.md
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
# Avatar Component
|
|
2
|
-
|
|
3
|
-
Purpose: Displays user initials, an image, or a Material icon in a consistent circle. Use it for user identity in headers, lists, MediaObject, or anywhere you need a compact avatar. Supports sizes, spacing (margin), and optional click handling.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| name | string | no | "" | Display name; used for initials and `title` when no image/icon. Also used for image `alt` and for generating background color when showing initials. |
|
|
10
|
-
| image | string | no | "" | Image URL; when set, shows image instead of initials or icon. |
|
|
11
|
-
| icon | MaterialIconName | no | — | Material icon name; when set (and no image), shows icon instead of initials. |
|
|
12
|
-
| size | "small" \| "medium" | no | "medium" | Size of the avatar. |
|
|
13
|
-
| margin | string \| string[] | no | "m-0" | Spacing **suffix** for outer margin. The component adds the `m-` prefix (e.g. `"0"` → m-0, `"b-2"` → m-b-2). Use a single string or array: `"0"`, `["2", "b-3"]`. |
|
|
14
|
-
| onClick | function | no | — | Click handler for the root div. |
|
|
15
|
-
| className | string | no | "" | Additional class names for the root element. |
|
|
16
|
-
| ...rest | React.HTMLAttributes<HTMLDivElement> | no | — | Any other div attributes (e.g. `id`, `data-*`, `aria-*`, `style`) are forwarded. |
|
|
17
|
-
|
|
18
|
-
## Types
|
|
19
|
-
|
|
20
|
-
### SpacingOption
|
|
21
|
-
```typescript
|
|
22
|
-
type SpacingOption = (typeof SPACING_OPTIONS)[number];
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### AvatarSize
|
|
26
|
-
```typescript
|
|
27
|
-
type AvatarSize = "small" | "medium";
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### AvatarMargin
|
|
31
|
-
```typescript
|
|
32
|
-
type AvatarMargin = string | SpacingOption[];
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### AvatarProps
|
|
36
|
-
```typescript
|
|
37
|
-
interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
38
|
-
name?: string;
|
|
39
|
-
image?: string;
|
|
40
|
-
icon?: MaterialIconName; // from "../icon/material-icon-names"
|
|
41
|
-
size?: AvatarSize;
|
|
42
|
-
margin?: AvatarMargin;
|
|
43
|
-
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
44
|
-
className?: string;
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## Usage Examples
|
|
49
|
-
|
|
50
|
-
### Name (initials)
|
|
51
|
-
|
|
52
|
-
```jsx
|
|
53
|
-
import { Avatar } from "cleanplate";
|
|
54
|
-
|
|
55
|
-
export const Example = () => (
|
|
56
|
-
<>
|
|
57
|
-
<Avatar name="John Doe" size="medium" />
|
|
58
|
-
<Avatar name="Jane Smith" size="small" margin="2" />
|
|
59
|
-
</>
|
|
60
|
-
);
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Icon
|
|
64
|
-
|
|
65
|
-
```jsx
|
|
66
|
-
import { Avatar } from "cleanplate";
|
|
67
|
-
|
|
68
|
-
export const Example = () => (
|
|
69
|
-
<>
|
|
70
|
-
<Avatar icon="person" size="medium" />
|
|
71
|
-
<Avatar icon="account_circle" size="small" />
|
|
72
|
-
</>
|
|
73
|
-
);
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Image
|
|
77
|
-
|
|
78
|
-
```jsx
|
|
79
|
-
import { Avatar } from "cleanplate";
|
|
80
|
-
|
|
81
|
-
export const Example = () => (
|
|
82
|
-
<Avatar
|
|
83
|
-
name="John Doe"
|
|
84
|
-
image="https://example.com/photo.jpg"
|
|
85
|
-
size="medium"
|
|
86
|
-
/>
|
|
87
|
-
);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Clickable avatar
|
|
91
|
-
|
|
92
|
-
```jsx
|
|
93
|
-
import { Avatar } from "cleanplate";
|
|
94
|
-
|
|
95
|
-
export const Example = () => (
|
|
96
|
-
<Avatar
|
|
97
|
-
name="John Doe"
|
|
98
|
-
size="medium"
|
|
99
|
-
onClick={() => console.log("Avatar clicked")}
|
|
100
|
-
/>
|
|
101
|
-
);
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### With Container
|
|
105
|
-
|
|
106
|
-
```jsx
|
|
107
|
-
import { Avatar, Container } from "cleanplate";
|
|
108
|
-
|
|
109
|
-
export const Example = () => (
|
|
110
|
-
<Container display="flex" gap="2" align="center">
|
|
111
|
-
<Avatar name="Alice" size="small" margin="0" />
|
|
112
|
-
<Avatar icon="person" size="medium" margin="0" />
|
|
113
|
-
<Avatar image="https://example.com/bob.jpg" name="Bob" size="medium" margin="0" />
|
|
114
|
-
</Container>
|
|
115
|
-
);
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
## Behavior Notes
|
|
119
|
-
|
|
120
|
-
- **Display priority:** If `image` is set, the image is shown. Else if `icon` is set, the Material icon is shown. Otherwise initials from `name` are shown.
|
|
121
|
-
- **Initials:** Derived from the first letter of each word in `name` (up to 2 characters), e.g. "John Doe" → "JD".
|
|
122
|
-
- **Background color:** When showing initials, background color is generated deterministically from `name` (hash-based).
|
|
123
|
-
- **Spacing:** `margin` accepts the **spacing suffix**; the component adds the `m-` prefix via `getSpacingClass`. Use suffix form (e.g. `"0"`, `"2"`, `"b-3"`) when passing values explicitly.
|
|
124
|
-
- **Root element:** A `div`; all standard HTML div attributes and ref are supported via `...rest`.
|
|
125
|
-
|
|
126
|
-
## Related Components / Links
|
|
127
|
-
|
|
128
|
-
- MediaObject (often uses Avatar via `mediaAvatar` for the media slot)
|
|
129
|
-
- Container (layout and spacing around avatars)
|
|
130
|
-
- Icon (Avatar can show an icon via the `icon` prop; uses Material icon names)
|
package/docs/Badge.md
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
# Badge Component
|
|
2
|
-
|
|
3
|
-
Purpose: Displays a short label with a colored background. Use it for status (e.g. success, error, warning), tags, or counts. Renders as an inline-block element with five variants (default, info, success, warning, error). Optional `className` for custom styling.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| label | string | no | — | Text shown inside the badge. |
|
|
10
|
-
| variant | "default" \| "info" \| "warning" \| "error" \| "success" | no | "default" | Visual variant (gray, blue, orange, red, green). |
|
|
11
|
-
| className | string | no | "" | Additional class names for the root element. |
|
|
12
|
-
|
|
13
|
-
## Types
|
|
14
|
-
|
|
15
|
-
### BadgeVariant
|
|
16
|
-
```typescript
|
|
17
|
-
type BadgeVariant = "default" | "info" | "warning" | "error" | "success";
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### BadgeProps
|
|
21
|
-
```typescript
|
|
22
|
-
interface BadgeProps {
|
|
23
|
-
label?: string;
|
|
24
|
-
variant?: BadgeVariant;
|
|
25
|
-
className?: string;
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Usage Examples
|
|
30
|
-
|
|
31
|
-
### Basic
|
|
32
|
-
|
|
33
|
-
```jsx
|
|
34
|
-
import { Badge } from "cleanplate";
|
|
35
|
-
|
|
36
|
-
<Badge label="New" />
|
|
37
|
-
<Badge label="Active" variant="success" />
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Variants
|
|
41
|
-
|
|
42
|
-
```jsx
|
|
43
|
-
<Badge label="Default" variant="default" />
|
|
44
|
-
<Badge label="Info" variant="info" />
|
|
45
|
-
<Badge label="Success" variant="success" />
|
|
46
|
-
<Badge label="Warning" variant="warning" />
|
|
47
|
-
<Badge label="Error" variant="error" />
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### With Table (customRender)
|
|
51
|
-
|
|
52
|
-
```jsx
|
|
53
|
-
import { Table, Badge } from "cleanplate";
|
|
54
|
-
|
|
55
|
-
const columns = [
|
|
56
|
-
{ id: "name", title: "Name" },
|
|
57
|
-
{
|
|
58
|
-
id: "status",
|
|
59
|
-
title: "Status",
|
|
60
|
-
customRender: (rowData, column) => (
|
|
61
|
-
<Badge label={String(rowData.status)} variant="success" />
|
|
62
|
-
),
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
<Table columns={columns} data={data} />;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Custom className
|
|
69
|
-
|
|
70
|
-
```jsx
|
|
71
|
-
<Badge label="Custom" variant="info" className="my-badge" />
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Behavior Notes
|
|
75
|
-
|
|
76
|
-
- **Element:** Renders as a `<p>` with `display: inline-block` in styles.
|
|
77
|
-
- **Label:** Optional; can be omitted or empty.
|
|
78
|
-
- **Variants:** Each variant maps to a CSS class that sets background color via design tokens (e.g. `var(--blue)` for info, `var(--green)` for success).
|
|
79
|
-
|
|
80
|
-
## Related Components / Links
|
|
81
|
-
|
|
82
|
-
- Table (often use Badge in column `customRender` for status or tag columns)
|
|
83
|
-
- Container (for layout when showing multiple badges)
|
package/docs/Button.md
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Button Component
|
|
2
|
-
|
|
3
|
-
Purpose: A highly customizable and interactive UI element designed to handle user actions with various styles, sizes, and variants. Supports loading states, disabled states, and click events.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| children | React.ReactNode | no | — | Content to display inside the button. |
|
|
10
|
-
| isLoading | boolean | no | false | Shows a loading spinner and disables the button. |
|
|
11
|
-
| isDisabled | boolean | no | false | Disables the button and prevents click events. |
|
|
12
|
-
| isFluid | boolean | no | false | Makes the button take full width of its container. |
|
|
13
|
-
| size | "small" \| "medium" | no | "medium" | Size variant of the button. |
|
|
14
|
-
| variant | "solid" \| "outline" \| "ghost" \| "icon" | no | "solid" | Visual style variant of the button. |
|
|
15
|
-
| margin | string \| string[] | no | "m-0" | Spacing utility token(s), such as `m-0` or `["m-1", "m-b-2"]`. |
|
|
16
|
-
| onClick | function | no | — | Called with the click event when button is clicked. Prevents execution if `isDisabled` or `isLoading` is true. |
|
|
17
|
-
| className | string | no | "" | Additional class names for the root element. |
|
|
18
|
-
| type | "button" \| "submit" \| "reset" | no | "button" | HTML button type attribute. |
|
|
19
|
-
| ...rest | React.ButtonHTMLAttributes | no | — | All other standard HTML button attributes are supported. |
|
|
20
|
-
|
|
21
|
-
## Types
|
|
22
|
-
|
|
23
|
-
### ButtonSize
|
|
24
|
-
```typescript
|
|
25
|
-
type ButtonSize = "small" | "medium";
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### ButtonVariant
|
|
29
|
-
```typescript
|
|
30
|
-
type ButtonVariant = "solid" | "outline" | "ghost" | "icon";
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### ButtonMargin
|
|
34
|
-
```typescript
|
|
35
|
-
type ButtonMargin = string | SpacingOption[];
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### SpacingOption
|
|
39
|
-
```typescript
|
|
40
|
-
type SpacingOption = typeof SPACING_OPTIONS[number];
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### ButtonProps
|
|
44
|
-
```typescript
|
|
45
|
-
interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "type" | "onClick"> {
|
|
46
|
-
children?: React.ReactNode;
|
|
47
|
-
isLoading?: boolean;
|
|
48
|
-
isDisabled?: boolean;
|
|
49
|
-
isFluid?: boolean;
|
|
50
|
-
size?: ButtonSize;
|
|
51
|
-
variant?: ButtonVariant;
|
|
52
|
-
margin?: ButtonMargin;
|
|
53
|
-
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
54
|
-
className?: string;
|
|
55
|
-
type?: "button" | "submit" | "reset";
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Usage Examples
|
|
60
|
-
|
|
61
|
-
### Basic button
|
|
62
|
-
|
|
63
|
-
```jsx
|
|
64
|
-
import { Button } from "cleanplate";
|
|
65
|
-
|
|
66
|
-
export const Example = () => (
|
|
67
|
-
<Button onClick={() => console.log("Clicked")}>
|
|
68
|
-
Click me
|
|
69
|
-
</Button>
|
|
70
|
-
);
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Variants
|
|
74
|
-
|
|
75
|
-
```jsx
|
|
76
|
-
import { Button } from "cleanplate";
|
|
77
|
-
|
|
78
|
-
export const Example = () => (
|
|
79
|
-
<>
|
|
80
|
-
<Button variant="solid">Solid</Button>
|
|
81
|
-
<Button variant="outline">Outline</Button>
|
|
82
|
-
<Button variant="ghost">Ghost</Button>
|
|
83
|
-
<Button variant="icon">Icon</Button>
|
|
84
|
-
</>
|
|
85
|
-
);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Sizes
|
|
89
|
-
|
|
90
|
-
```jsx
|
|
91
|
-
import { Button } from "cleanplate";
|
|
92
|
-
|
|
93
|
-
export const Example = () => (
|
|
94
|
-
<>
|
|
95
|
-
<Button size="small">Small</Button>
|
|
96
|
-
<Button size="medium">Medium</Button>
|
|
97
|
-
</>
|
|
98
|
-
);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### Loading state
|
|
102
|
-
|
|
103
|
-
```jsx
|
|
104
|
-
import { Button } from "cleanplate";
|
|
105
|
-
|
|
106
|
-
export const Example = () => (
|
|
107
|
-
<Button isLoading>
|
|
108
|
-
Loading...
|
|
109
|
-
</Button>
|
|
110
|
-
);
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
### Disabled state
|
|
114
|
-
|
|
115
|
-
```jsx
|
|
116
|
-
import { Button } from "cleanplate";
|
|
117
|
-
|
|
118
|
-
export const Example = () => (
|
|
119
|
-
<Button isDisabled>
|
|
120
|
-
Disabled
|
|
121
|
-
</Button>
|
|
122
|
-
);
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Fluid button
|
|
126
|
-
|
|
127
|
-
```jsx
|
|
128
|
-
import { Button } from "cleanplate";
|
|
129
|
-
|
|
130
|
-
export const Example = () => (
|
|
131
|
-
<Button isFluid>
|
|
132
|
-
Full Width Button
|
|
133
|
-
</Button>
|
|
134
|
-
);
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### With margin spacing
|
|
138
|
-
|
|
139
|
-
```jsx
|
|
140
|
-
import { Button } from "cleanplate";
|
|
141
|
-
|
|
142
|
-
export const Example = () => (
|
|
143
|
-
<>
|
|
144
|
-
<Button margin="m-2">With margin</Button>
|
|
145
|
-
<Button margin={["m-1", "m-b-3"]}>With multiple margins</Button>
|
|
146
|
-
</>
|
|
147
|
-
);
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Submit button
|
|
151
|
-
|
|
152
|
-
```jsx
|
|
153
|
-
import { Button } from "cleanplate";
|
|
154
|
-
|
|
155
|
-
export const Example = () => (
|
|
156
|
-
<form onSubmit={(e) => { e.preventDefault(); console.log("Submitted"); }}>
|
|
157
|
-
<Button type="submit">Submit</Button>
|
|
158
|
-
</form>
|
|
159
|
-
);
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Behavior Notes
|
|
163
|
-
|
|
164
|
-
- When `isLoading` is true, a progress spinner icon is displayed and the button is automatically disabled.
|
|
165
|
-
- When `isDisabled` is true, click events are prevented and the button appears visually disabled.
|
|
166
|
-
- If both `isDisabled` and `isLoading` are true, the button is disabled and the loading spinner is shown.
|
|
167
|
-
- The `onClick` handler is not called if the button is disabled or loading, even if the event is triggered.
|
|
168
|
-
- The button extends standard HTML button attributes, so you can use props like `aria-label`, `data-*`, etc.
|
|
169
|
-
- The `type` prop defaults to `"button"` to prevent accidental form submissions. Use `type="submit"` for form submission buttons.
|
|
170
|
-
- Margin spacing accepts either a single string token (e.g., `"m-2"`) or an array of tokens (e.g., `["m-1", "m-b-3"]`).
|
|
171
|
-
|
|
172
|
-
## Related Components / Links
|
|
173
|
-
|
|
174
|
-
- Icon (used internally for loading spinner)
|
|
175
|
-
- FormControls (often used alongside buttons in forms)
|
package/docs/ConfirmDialog.md
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
# ConfirmDialog Component
|
|
2
|
-
|
|
3
|
-
Purpose: A modal dialog for confirmation actions (e.g. delete, discard, proceed). Shows a title, optional description, primary and secondary buttons, and optional close button. Use it for user confirmations, destructive actions, and warnings. Supports overlay click and Escape to close, body scroll lock when open, and focus management.
|
|
4
|
-
|
|
5
|
-
## Props / Inputs
|
|
6
|
-
|
|
7
|
-
| Prop | Type | Required | Default | Description |
|
|
8
|
-
| --- | --- | --- | --- | --- |
|
|
9
|
-
| isOpen | boolean | no | false | Whether the dialog is visible. |
|
|
10
|
-
| onClose | () => void | no | — | Called when the dialog should close (close button, overlay, Escape, or after primary/secondary click). |
|
|
11
|
-
| title | string | no | "Confirm Action" | Dialog title. |
|
|
12
|
-
| description | string | no | "" | Optional description below the title. |
|
|
13
|
-
| primaryButtonLabel | string | no | "Confirm" | Label for the primary (confirm) button. |
|
|
14
|
-
| onPrimaryButtonClick | () => void | no | — | Called when the primary button is clicked; onClose is also called. |
|
|
15
|
-
| secondaryButtonLabel | string | no | "Cancel" | Label for the secondary (cancel) button; empty string hides it. |
|
|
16
|
-
| onSecondaryButtonClick | () => void | no | — | Called when the secondary button is clicked; onClose is also called. |
|
|
17
|
-
| size | "small" \| "medium" \| "large" | no | "small" | Size of the dialog. |
|
|
18
|
-
| variant | "default" \| "destructive" \| "warning" | no | "default" | Visual variant. |
|
|
19
|
-
| showCloseButton | boolean | no | true | Whether to show the X close button. |
|
|
20
|
-
| closeOnOverlayClick | boolean | no | true | Whether clicking the overlay closes the dialog. |
|
|
21
|
-
| closeOnEscape | boolean | no | true | Whether pressing Escape closes the dialog. |
|
|
22
|
-
| className | string | no | "" | Additional class names for the dialog panel. |
|
|
23
|
-
| overlayClassName | string | no | "" | Additional class names for the overlay. |
|
|
24
|
-
|
|
25
|
-
## Types
|
|
26
|
-
|
|
27
|
-
### ConfirmDialogSize
|
|
28
|
-
```typescript
|
|
29
|
-
type ConfirmDialogSize = "small" | "medium" | "large";
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### ConfirmDialogVariant
|
|
33
|
-
```typescript
|
|
34
|
-
type ConfirmDialogVariant = "default" | "destructive" | "warning";
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### ConfirmDialogProps
|
|
38
|
-
```typescript
|
|
39
|
-
interface ConfirmDialogProps {
|
|
40
|
-
isOpen?: boolean;
|
|
41
|
-
onClose?: () => void;
|
|
42
|
-
title?: string;
|
|
43
|
-
description?: string;
|
|
44
|
-
primaryButtonLabel?: string;
|
|
45
|
-
onPrimaryButtonClick?: () => void;
|
|
46
|
-
secondaryButtonLabel?: string;
|
|
47
|
-
onSecondaryButtonClick?: () => void;
|
|
48
|
-
size?: ConfirmDialogSize;
|
|
49
|
-
variant?: ConfirmDialogVariant;
|
|
50
|
-
showCloseButton?: boolean;
|
|
51
|
-
closeOnOverlayClick?: boolean;
|
|
52
|
-
closeOnEscape?: boolean;
|
|
53
|
-
className?: string;
|
|
54
|
-
overlayClassName?: string;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Usage Examples
|
|
59
|
-
|
|
60
|
-
### Basic
|
|
61
|
-
|
|
62
|
-
```jsx
|
|
63
|
-
import { ConfirmDialog, Button } from "cleanplate";
|
|
64
|
-
import { useState } from "react";
|
|
65
|
-
|
|
66
|
-
const App = () => {
|
|
67
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
68
|
-
const handleConfirm = () => { /* ... */ setIsOpen(false); };
|
|
69
|
-
return (
|
|
70
|
-
<>
|
|
71
|
-
<Button onClick={() => setIsOpen(true)}>Delete</Button>
|
|
72
|
-
<ConfirmDialog
|
|
73
|
-
isOpen={isOpen}
|
|
74
|
-
onClose={() => setIsOpen(false)}
|
|
75
|
-
title="Delete Item"
|
|
76
|
-
description="Are you sure? This cannot be undone."
|
|
77
|
-
primaryButtonLabel="Delete"
|
|
78
|
-
onPrimaryButtonClick={handleConfirm}
|
|
79
|
-
secondaryButtonLabel="Cancel"
|
|
80
|
-
/>
|
|
81
|
-
</>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Variants
|
|
87
|
-
|
|
88
|
-
```jsx
|
|
89
|
-
<ConfirmDialog variant="default" title="Save?" ... />
|
|
90
|
-
<ConfirmDialog variant="destructive" title="Delete Account?" ... />
|
|
91
|
-
<ConfirmDialog variant="warning" title="Proceed Anyway?" ... />
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Sizes
|
|
95
|
-
|
|
96
|
-
```jsx
|
|
97
|
-
<ConfirmDialog size="small" title="Quick confirm" ... />
|
|
98
|
-
<ConfirmDialog size="medium" title="Standard confirm" ... />
|
|
99
|
-
<ConfirmDialog size="large" title="Important decision" ... />
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### No description, custom buttons
|
|
103
|
-
|
|
104
|
-
```jsx
|
|
105
|
-
<ConfirmDialog
|
|
106
|
-
isOpen={isOpen}
|
|
107
|
-
onClose={() => setIsOpen(false)}
|
|
108
|
-
title="Are you sure?"
|
|
109
|
-
primaryButtonLabel="Yes"
|
|
110
|
-
onPrimaryButtonClick={handleConfirm}
|
|
111
|
-
secondaryButtonLabel="No"
|
|
112
|
-
/>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Close behavior
|
|
116
|
-
|
|
117
|
-
```jsx
|
|
118
|
-
<ConfirmDialog
|
|
119
|
-
showCloseButton={true}
|
|
120
|
-
closeOnOverlayClick={true}
|
|
121
|
-
closeOnEscape={true}
|
|
122
|
-
onClose={handleClose}
|
|
123
|
-
...
|
|
124
|
-
/>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## Behavior Notes
|
|
128
|
-
|
|
129
|
-
- **Rendering:** When `isOpen` is false, the component returns `null` (nothing in the DOM).
|
|
130
|
-
- **Close:** onClose is called when the user clicks the X button, the overlay (if closeOnOverlayClick), Escape (if closeOnEscape), or either action button (after their handler runs).
|
|
131
|
-
- **Body scroll:** When open, `document.body.style.overflow` is set to `"hidden"`; restored on close.
|
|
132
|
-
- **Focus:** On open, focus moves to the dialog panel (ref + tabIndex={-1}); on close, focus returns to the previously focused element.
|
|
133
|
-
- **ARIA:** The overlay has `role="dialog"`, `aria-modal="true"`, and `aria-labelledby` pointing to the title.
|
|
134
|
-
|
|
135
|
-
## Related Components / Links
|
|
136
|
-
|
|
137
|
-
- Button (used to open the dialog and for primary/secondary actions inside)
|
|
138
|
-
- Typography (used for title and description)
|
|
139
|
-
- Icon (used for the close button)
|