cleanplate 0.1.11 → 0.2.1
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/README.md +193 -60
- 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/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/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/icon/material-icon-names.d.ts +5 -5
- package/dist/components/icon/material-icon-names.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/docs/Accordion.md +125 -0
- package/docs/Alert.md +131 -0
- package/docs/Animated.md +101 -0
- package/docs/AppShell.md +145 -0
- package/docs/Avatar.md +130 -0
- package/docs/Badge.md +83 -0
- package/docs/BottomSheet.md +78 -0
- package/docs/BreadCrumb.md +133 -0
- package/docs/Button.md +189 -0
- package/docs/ConfirmDialog.md +139 -0
- package/docs/Container.md +230 -0
- package/docs/Dropdown.md +175 -0
- package/docs/Footer.md +93 -0
- package/docs/FormControls.md +115 -0
- package/docs/Header.md +115 -0
- package/docs/Icon.md +225 -0
- package/docs/MediaObject.md +303 -0
- package/docs/MenuList.md +113 -0
- package/docs/Modal.md +152 -0
- package/docs/PageHeader.md +134 -0
- package/docs/Pagination.md +142 -0
- package/docs/Pills.md +104 -0
- package/docs/Spinner.md +115 -0
- package/docs/Stepper.md +131 -0
- package/docs/Table.md +194 -0
- package/docs/Toast.md +96 -0
- package/docs/Typography.md +231 -0
- package/llms.txt +293 -0
- package/package.json +6 -1
package/docs/Dropdown.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Dropdown Component
|
|
2
|
+
|
|
3
|
+
Purpose: A floating panel that shows content relative to a trigger. Use it for menus, option lists, or any content that opens on click. Supports 12 placements, optional flip/shift to stay in viewport, and three trigger modes: a `trigger` element, a `renderTrigger` function, or a `triggerLabel` for a default button.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| trigger | React.ReactElement | no | — | Trigger element to clone; ref and onClick are attached. Omit when using `renderTrigger` or `triggerLabel`. |
|
|
10
|
+
| content | React.ReactElement | yes | — | Content shown in the floating panel. Receives `onClose` and `className` when cloned. |
|
|
11
|
+
| placement | DropdownPlacement | no | "bottom-end" | Preferred position relative to trigger (e.g. "bottom-end", "top-start"). |
|
|
12
|
+
| offset | number | no | 4 | Gap in pixels between trigger and panel. |
|
|
13
|
+
| shift | boolean | no | true | When true, shift panel to stay inside viewport. |
|
|
14
|
+
| flip | boolean | no | true | When true, flip to opposite side when there is no space. |
|
|
15
|
+
| closeOnClickOutside | boolean | no | true | Close when user clicks outside trigger and panel. |
|
|
16
|
+
| closeOnEscape | boolean | no | true | Close when user presses Escape. |
|
|
17
|
+
| className | string | no | "" | Class name for the wrapper div. |
|
|
18
|
+
| contentClassName | string | no | "" | Class name applied to the cloned content element. |
|
|
19
|
+
| renderTrigger | (params: DropdownRenderTriggerParams) => React.ReactNode | no | — | Render prop for a custom trigger; receives `isOpen`, `isAnimating`, `placement`, `toggle`, `close`, `triggerProps`. |
|
|
20
|
+
| triggerLabel | string | no | — | Label for the default button trigger. Use when neither `trigger` nor `renderTrigger` is provided. |
|
|
21
|
+
|
|
22
|
+
## Types
|
|
23
|
+
|
|
24
|
+
### DropdownPlacement
|
|
25
|
+
```typescript
|
|
26
|
+
type DropdownPlacement =
|
|
27
|
+
| "top" | "top-start" | "top-end"
|
|
28
|
+
| "bottom" | "bottom-start" | "bottom-end"
|
|
29
|
+
| "left" | "left-start" | "left-end"
|
|
30
|
+
| "right" | "right-start" | "right-end";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### DropdownTriggerProps
|
|
34
|
+
```typescript
|
|
35
|
+
interface DropdownTriggerProps {
|
|
36
|
+
ref: RefObject<HTMLElement | null>;
|
|
37
|
+
onClick: (e: React.MouseEvent<HTMLElement>) => void;
|
|
38
|
+
className: string;
|
|
39
|
+
role: string;
|
|
40
|
+
"aria-expanded": boolean;
|
|
41
|
+
"aria-haspopup": string;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### DropdownRenderTriggerParams
|
|
46
|
+
```typescript
|
|
47
|
+
interface DropdownRenderTriggerParams {
|
|
48
|
+
isOpen: boolean;
|
|
49
|
+
isAnimating: boolean;
|
|
50
|
+
placement: DropdownPlacement;
|
|
51
|
+
toggle: () => void;
|
|
52
|
+
close: () => void;
|
|
53
|
+
triggerProps: DropdownTriggerProps;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### DropdownProps
|
|
58
|
+
```typescript
|
|
59
|
+
interface DropdownProps {
|
|
60
|
+
trigger?: React.ReactElement;
|
|
61
|
+
content: React.ReactElement;
|
|
62
|
+
placement?: DropdownPlacement;
|
|
63
|
+
offset?: number;
|
|
64
|
+
shift?: boolean;
|
|
65
|
+
flip?: boolean;
|
|
66
|
+
closeOnClickOutside?: boolean;
|
|
67
|
+
closeOnEscape?: boolean;
|
|
68
|
+
className?: string;
|
|
69
|
+
contentClassName?: string;
|
|
70
|
+
renderTrigger?: (params: DropdownRenderTriggerParams) => React.ReactNode;
|
|
71
|
+
triggerLabel?: string;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage Examples
|
|
76
|
+
|
|
77
|
+
### With trigger element
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
import { Dropdown, Button } from "cleanplate";
|
|
81
|
+
|
|
82
|
+
const MenuContent = ({ onClose }) => (
|
|
83
|
+
<div style={{ padding: "var(--space-2)" }}>
|
|
84
|
+
<button onClick={onClose}>Close</button>
|
|
85
|
+
<p>Menu items here</p>
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
export const Example = () => (
|
|
90
|
+
<Dropdown
|
|
91
|
+
trigger={<Button>Open Menu</Button>}
|
|
92
|
+
content={<MenuContent />}
|
|
93
|
+
placement="bottom-end"
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### With triggerLabel
|
|
99
|
+
|
|
100
|
+
```jsx
|
|
101
|
+
import { Dropdown } from "cleanplate";
|
|
102
|
+
|
|
103
|
+
export const Example = () => (
|
|
104
|
+
<Dropdown
|
|
105
|
+
triggerLabel="Select Option"
|
|
106
|
+
content={<MenuContent />}
|
|
107
|
+
placement="bottom-end"
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### With renderTrigger
|
|
113
|
+
|
|
114
|
+
```jsx
|
|
115
|
+
import { Dropdown, Button } from "cleanplate";
|
|
116
|
+
|
|
117
|
+
export const Example = () => (
|
|
118
|
+
<Dropdown
|
|
119
|
+
renderTrigger={({ isOpen, triggerProps }) => (
|
|
120
|
+
<Button {...triggerProps}>
|
|
121
|
+
{isOpen ? "Close" : "Open"}
|
|
122
|
+
</Button>
|
|
123
|
+
)}
|
|
124
|
+
content={<MenuContent />}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Placement and offset
|
|
130
|
+
|
|
131
|
+
```jsx
|
|
132
|
+
<Dropdown
|
|
133
|
+
trigger={<Button>Menu</Button>}
|
|
134
|
+
content={<MenuContent />}
|
|
135
|
+
placement="top-start"
|
|
136
|
+
offset={8}
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Disable flip / shift
|
|
141
|
+
|
|
142
|
+
```jsx
|
|
143
|
+
<Dropdown
|
|
144
|
+
trigger={<Button>Menu</Button>}
|
|
145
|
+
content={<MenuContent />}
|
|
146
|
+
placement="top"
|
|
147
|
+
flip={false}
|
|
148
|
+
shift={false}
|
|
149
|
+
/>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Close behavior
|
|
153
|
+
|
|
154
|
+
```jsx
|
|
155
|
+
<Dropdown
|
|
156
|
+
trigger={<Button>Menu</Button>}
|
|
157
|
+
content={<MenuContent />}
|
|
158
|
+
closeOnClickOutside={false}
|
|
159
|
+
closeOnEscape={true}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Behavior Notes
|
|
164
|
+
|
|
165
|
+
- **Trigger modes:** Exactly one of `trigger`, `renderTrigger`, or `triggerLabel` must be used; the component throws if none are provided.
|
|
166
|
+
- **Content:** The `content` element is cloned; the component injects `onClose` and merges `className` so the panel can close and be styled.
|
|
167
|
+
- **Positioning:** Placement is applied via CSS classes; when `flip` or `shift` are true, the component adjusts placement/position so the panel stays in view.
|
|
168
|
+
- **Accessibility:** The trigger receives `aria-expanded` and `aria-haspopup`; the panel has `role="menu"`. Escape and (optionally) click-outside close the dropdown.
|
|
169
|
+
- **Animation:** Opening/closing uses CSS classes (`dropdown-opening` / `dropdown-closing`); a short delay (e.g. 150ms) is used before unmounting so the close animation can run.
|
|
170
|
+
|
|
171
|
+
## Related Components / Links
|
|
172
|
+
|
|
173
|
+
- Button (commonly used as trigger or inside renderTrigger)
|
|
174
|
+
- MenuList (often used inside dropdown content for menu items)
|
|
175
|
+
- Icon (used in the default trigger when `triggerLabel` is set for arrow icons)
|
package/docs/Footer.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Footer Component
|
|
2
|
+
|
|
3
|
+
Purpose: Customizable footer with copyright text, optional powered-by link, and custom content via children. Use for app footers with branding, legal links, or column layouts. Supports sizes (small, medium, large), variants (light, dark), and margin spacing.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| margin | string \| SpacingOption[] | no | "0" | Spacing suffix(s) for outer margin; component adds m- prefix. |
|
|
10
|
+
| size | "small" \| "medium" \| "large" | no | "large" | Size of the footer. |
|
|
11
|
+
| variant | "light" \| "dark" | no | "light" | Visual variant. |
|
|
12
|
+
| brandName | string | no | "" | Brand name shown in copyright (e.g. "Acme Inc"). |
|
|
13
|
+
| poweredByLabel | string | no | "" | Label for the powered-by link (e.g. "Powered by X"). |
|
|
14
|
+
| poweredByLink | string | no | "" | URL for the powered-by link; shown when poweredByLabel is also set. |
|
|
15
|
+
| children | ReactNode | no | — | Custom content rendered above the copyright line. |
|
|
16
|
+
| className | string | no | "" | Additional class names for the root element. |
|
|
17
|
+
|
|
18
|
+
## Types
|
|
19
|
+
|
|
20
|
+
### FooterSize
|
|
21
|
+
```typescript
|
|
22
|
+
type FooterSize = "small" | "medium" | "large";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### FooterVariant
|
|
26
|
+
```typescript
|
|
27
|
+
type FooterVariant = "light" | "dark";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### FooterMargin
|
|
31
|
+
```typescript
|
|
32
|
+
type FooterMargin = string | SpacingOption[];
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### FooterProps
|
|
36
|
+
```typescript
|
|
37
|
+
interface FooterProps {
|
|
38
|
+
margin?: FooterMargin;
|
|
39
|
+
size?: FooterSize;
|
|
40
|
+
variant?: FooterVariant;
|
|
41
|
+
brandName?: string;
|
|
42
|
+
poweredByLabel?: string;
|
|
43
|
+
poweredByLink?: string;
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
className?: string;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage Examples
|
|
50
|
+
|
|
51
|
+
### Basic
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
import { Footer } from "cleanplate";
|
|
55
|
+
|
|
56
|
+
<Footer brandName="Acme Inc" />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### With powered-by link
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
<Footer
|
|
63
|
+
brandName="Acme Inc"
|
|
64
|
+
poweredByLabel="Powered by Sivadass"
|
|
65
|
+
poweredByLink="https://sivadass.in"
|
|
66
|
+
/>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With custom content
|
|
70
|
+
|
|
71
|
+
```jsx
|
|
72
|
+
<Footer brandName="Acme Inc">
|
|
73
|
+
<Container display="flex" gap="4">
|
|
74
|
+
<Container width="quarter">
|
|
75
|
+
<Typography variant="h6" margin={["0", "b-2"]}>Links</Typography>
|
|
76
|
+
<ul><li><a href="/contact">Contact</a></li></ul>
|
|
77
|
+
</Container>
|
|
78
|
+
</Container>
|
|
79
|
+
</Footer>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Behavior Notes
|
|
83
|
+
|
|
84
|
+
- **Copyright:** Uses current year and `brandName` in "© {year} {brandName}. All rights reserved."
|
|
85
|
+
- **Powered-by:** Link shows only when both `poweredByLabel` and `poweredByLink` are set; link has `rel="noopener noreferrer"`.
|
|
86
|
+
- **children:** Rendered in a wrapper div above the copyright line.
|
|
87
|
+
- **Margin:** Uses the suffix API (e.g. `"0"` → m-0).
|
|
88
|
+
|
|
89
|
+
## Related Components / Links
|
|
90
|
+
|
|
91
|
+
- Container (layout for footer columns or custom content)
|
|
92
|
+
- Typography (used internally for copyright)
|
|
93
|
+
- Header (often paired with Footer for app layout)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# FormControls
|
|
2
|
+
|
|
3
|
+
FormControls is a set of form primitives exported as a namespace: `FormControls.Input`, `FormControls.Select`, `FormControls.TextArea`, `FormControls.Date`, `FormControls.Checkbox`, `FormControls.Radio`, `FormControls.File`, `FormControls.Toggle`, `FormControls.Stepper`. Use them to build forms with consistent styling, labels, validation messages, and optional fluid layout. Common props across controls: label, isDisabled, isRequired, isFluid, className, error.
|
|
4
|
+
|
|
5
|
+
## Controls overview
|
|
6
|
+
|
|
7
|
+
| Control | Purpose | Key props |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Input | Single-line text | placeholder, value, onChange(e), type |
|
|
10
|
+
| TextArea | Multi-line text | placeholder, value, onChange(e) |
|
|
11
|
+
| Select | Single or multi select dropdown | options ({ label, value }[]), value, onChange(option \| option[]), isMulti, placeholder |
|
|
12
|
+
| Date | Day/month/year picker (DD-MMM-YYYY) | defaultValue, onChange(dateValue: string) |
|
|
13
|
+
| Checkbox | Single checkbox | value (boolean), onChange(checked: boolean) |
|
|
14
|
+
| Radio | Radio input | name, value, onChange(e) |
|
|
15
|
+
| File | File input | onChange(e) |
|
|
16
|
+
| Toggle | Toggle input | name, value, onChange(e) |
|
|
17
|
+
| Stepper | Text input for step flows | placeholder, value, onChange(e) |
|
|
18
|
+
|
|
19
|
+
## Types
|
|
20
|
+
|
|
21
|
+
### SelectOption
|
|
22
|
+
```typescript
|
|
23
|
+
interface SelectOption {
|
|
24
|
+
label: string;
|
|
25
|
+
value: string | number;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### SelectProps
|
|
30
|
+
```typescript
|
|
31
|
+
interface SelectProps {
|
|
32
|
+
onChange?: (option: SelectOption | SelectOption[]) => void;
|
|
33
|
+
value?: SelectOption | SelectOption[] | null;
|
|
34
|
+
label?: string;
|
|
35
|
+
options?: SelectOption[];
|
|
36
|
+
placeholder?: string;
|
|
37
|
+
isMulti?: boolean;
|
|
38
|
+
isRequired?: boolean;
|
|
39
|
+
isDisabled?: boolean;
|
|
40
|
+
isFluid?: boolean;
|
|
41
|
+
error?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
triggerClassName?: string;
|
|
44
|
+
triggerActiveClassName?: string;
|
|
45
|
+
contentsClassName?: string;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### InputProps
|
|
50
|
+
```typescript
|
|
51
|
+
interface InputProps {
|
|
52
|
+
name?: string;
|
|
53
|
+
id?: string;
|
|
54
|
+
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
55
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
56
|
+
value?: string;
|
|
57
|
+
defaultValue?: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
placeholder?: string;
|
|
60
|
+
type?: string;
|
|
61
|
+
isRequired?: boolean;
|
|
62
|
+
isDisabled?: boolean;
|
|
63
|
+
isFluid?: boolean;
|
|
64
|
+
className?: string;
|
|
65
|
+
error?: string;
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Other control types
|
|
70
|
+
- **TextAreaProps**, **FileProps**, **RadioProps**, **ToggleProps**: label, value/defaultValue, onChange, isDisabled, isRequired, isFluid, className, error (where applicable).
|
|
71
|
+
- **CheckboxProps**: value (boolean), onChange(checked: boolean).
|
|
72
|
+
- **DateProps**: defaultValue (string "dd-mm-yyyy"), onChange(dateValue: string).
|
|
73
|
+
- **FormControlsStepperProps**: label, placeholder, value, onChange(e).
|
|
74
|
+
|
|
75
|
+
## Usage Examples
|
|
76
|
+
|
|
77
|
+
### Input and Select
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
import { FormControls } from "cleanplate";
|
|
81
|
+
|
|
82
|
+
<FormControls.Input label="Email" placeholder="user@example.com" isRequired />
|
|
83
|
+
<FormControls.Select
|
|
84
|
+
label="Fruit"
|
|
85
|
+
placeholder="Select"
|
|
86
|
+
options={[{ label: "Apple", value: "apple" }, { label: "Mango", value: "mango" }]}
|
|
87
|
+
onChange={(option) => console.log(option)}
|
|
88
|
+
/>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### TextArea, Checkbox, Date
|
|
92
|
+
|
|
93
|
+
```jsx
|
|
94
|
+
<FormControls.TextArea label="Message" placeholder="Hello" />
|
|
95
|
+
<FormControls.Checkbox label="Accept terms?" value={checked} onChange={setChecked} />
|
|
96
|
+
<FormControls.Date label="DOB" defaultValue="31-05-1992" onChange={(v) => {}} />
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Used by other components
|
|
100
|
+
|
|
101
|
+
Pagination uses `FormControls.Select` for rows-per-page. Pills uses `FormControls.Input` in edit mode.
|
|
102
|
+
|
|
103
|
+
## Behavior Notes
|
|
104
|
+
|
|
105
|
+
- **Select:** options are `{ label, value }`; single select passes one option to onChange, multi passes an array. value can be option or array for multi.
|
|
106
|
+
- **Date:** Returns string "dd-mm-yyyy" to onChange; uses internal day/month/year Selects.
|
|
107
|
+
- **Error:** When `error` is set, the field shows error styling and message below.
|
|
108
|
+
- **isFluid:** Full-width field wrapper.
|
|
109
|
+
|
|
110
|
+
## Related Components / Links
|
|
111
|
+
|
|
112
|
+
- Pills (uses FormControls.Input in edit mode)
|
|
113
|
+
- Pagination (uses FormControls.Select for rows-per-page)
|
|
114
|
+
- Container (layout around form fields)
|
|
115
|
+
- Button (submit/cancel in forms)
|
package/docs/Header.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Header Component
|
|
2
|
+
|
|
3
|
+
Purpose: Responsive navigation header with logo, menu items, and customizable left, center, and right slots. Use for app navigation. Supports sizes, variants, margin spacing, and a responsive mobile menu that slides in from the left. Uses MenuList for nav items; headerLeft, headerCenter, headerRight for custom content.
|
|
4
|
+
|
|
5
|
+
## Props / Inputs
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
9
|
+
| logoUrl | string | no | — | URL for the logo image (shown when headerLeft is not provided). |
|
|
10
|
+
| activeMenuItem | string | no | — | Value of the currently active menu item (matches item.value). |
|
|
11
|
+
| onMenuItemClick | (item: MenuListItem) => void | no | — | Called when a menu item is clicked; receives the clicked item. |
|
|
12
|
+
| className | string | no | "" | Additional class names for the root element. |
|
|
13
|
+
| headerLeft | ReactNode | no | — | Custom content for the left area (replaces logo when provided). |
|
|
14
|
+
| headerRight | ReactNode | no | — | Custom content for the right area. |
|
|
15
|
+
| headerCenter | ReactNode | no | — | Custom content for the center area (replaces MenuList when provided). |
|
|
16
|
+
| menuItems | MenuListItem[] | yes | — | Menu items for center nav and mobile menu; each has label, value, optional icon. |
|
|
17
|
+
| size | "small" \| "medium" \| "large" | no | — | Size of the header. |
|
|
18
|
+
| variant | "light" \| "dark" | no | — | Visual variant. |
|
|
19
|
+
| margin | string \| SpacingOption[] | no | — | Spacing suffix(s) for outer margin; component adds m- prefix. |
|
|
20
|
+
|
|
21
|
+
## Types
|
|
22
|
+
|
|
23
|
+
### HeaderSize
|
|
24
|
+
```typescript
|
|
25
|
+
type HeaderSize = "small" | "medium" | "large";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### HeaderVariant
|
|
29
|
+
```typescript
|
|
30
|
+
type HeaderVariant = "light" | "dark";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### HeaderMargin
|
|
34
|
+
```typescript
|
|
35
|
+
type HeaderMargin = string | SpacingOption[];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### HeaderProps
|
|
39
|
+
```typescript
|
|
40
|
+
interface HeaderProps {
|
|
41
|
+
logoUrl?: string;
|
|
42
|
+
activeMenuItem?: string;
|
|
43
|
+
onMenuItemClick?: (item: MenuListItem) => void;
|
|
44
|
+
className?: string;
|
|
45
|
+
headerLeft?: React.ReactNode;
|
|
46
|
+
headerRight?: React.ReactNode;
|
|
47
|
+
headerCenter?: React.ReactNode;
|
|
48
|
+
menuItems: MenuListItem[];
|
|
49
|
+
size?: HeaderSize;
|
|
50
|
+
variant?: HeaderVariant;
|
|
51
|
+
margin?: HeaderMargin;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Usage Examples
|
|
56
|
+
|
|
57
|
+
### Basic
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
import { useState } from "react";
|
|
61
|
+
import { Header, Avatar } from "cleanplate";
|
|
62
|
+
|
|
63
|
+
const MENU_ITEMS = [
|
|
64
|
+
{ label: "Dashboard", value: "/", icon: "speed" },
|
|
65
|
+
{ label: "Projects", value: "/projects", icon: "receipt_long" },
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
const AppHeader = () => {
|
|
69
|
+
const [activeMenuItem, setActiveMenuItem] = useState("/");
|
|
70
|
+
return (
|
|
71
|
+
<Header
|
|
72
|
+
logoUrl="/logo.svg"
|
|
73
|
+
menuItems={MENU_ITEMS}
|
|
74
|
+
activeMenuItem={activeMenuItem}
|
|
75
|
+
onMenuItemClick={(item) => setActiveMenuItem(item.value)}
|
|
76
|
+
headerRight={<Avatar name="John" />}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With custom slots
|
|
83
|
+
|
|
84
|
+
```jsx
|
|
85
|
+
<Header
|
|
86
|
+
menuItems={menuItems}
|
|
87
|
+
activeMenuItem={activeItem}
|
|
88
|
+
onMenuItemClick={handleClick}
|
|
89
|
+
headerLeft={<img src="/logo.svg" alt="Logo" />}
|
|
90
|
+
headerRight={<Avatar name="User" />}
|
|
91
|
+
/>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Variants and sizes
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
<Header menuItems={items} variant="light" activeMenuItem={active} onMenuItemClick={handle} />
|
|
98
|
+
<Header menuItems={items} variant="dark" activeMenuItem={active} onMenuItemClick={handle} />
|
|
99
|
+
<Header menuItems={items} size="small" activeMenuItem={active} onMenuItemClick={handle} />
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Behavior Notes
|
|
103
|
+
|
|
104
|
+
- **menuItems:** Required; each item has label, value, optional icon (Material icon name).
|
|
105
|
+
- **headerLeft / headerCenter / headerRight:** When provided, replace the default logo, MenuList, or right slot.
|
|
106
|
+
- **Mobile:** Below 1024px, center nav hides; hamburger shows. Click opens slide-in menu (Animated fade-in-left).
|
|
107
|
+
- **onMenuItemClick:** Called with the clicked item; mobile menu closes on click.
|
|
108
|
+
- **Margin:** Uses the suffix API (e.g. `"0"` → m-0).
|
|
109
|
+
|
|
110
|
+
## Related Components / Links
|
|
111
|
+
|
|
112
|
+
- MenuList (used in center and mobile menu)
|
|
113
|
+
- Avatar (commonly in headerRight)
|
|
114
|
+
- Button, Icon (mobile menu trigger and close)
|
|
115
|
+
- Animated (mobile menu slide-in)
|