@wso2/oxygen-ui 0.0.1-alpha.9 → 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/.ai/AGENTS.md +78 -0
- package/.ai/components.md +798 -0
- package/.ai/migration.md +279 -0
- package/.ai/patterns.md +1185 -0
- package/.ai/theming.md +318 -0
- package/.claude/components.md +798 -0
- package/.claude/migration.md +279 -0
- package/.claude/patterns.md +1185 -0
- package/.claude/skills/oxygen-component/SKILL.md +141 -0
- package/.claude/skills/oxygen-form/SKILL.md +410 -0
- package/.claude/skills/oxygen-layout/SKILL.md +233 -0
- package/.claude/skills/oxygen-migrate/SKILL.md +277 -0
- package/.claude/theming.md +318 -0
- package/README.md +182 -2
- package/bin/cli.js +480 -0
- package/dist/animations/ParticleBackground/ParticleBackground.d.ts +66 -0
- package/dist/animations/ParticleBackground/index.d.ts +19 -0
- package/dist/animations/index.d.ts +18 -0
- package/dist/components/AppShell/AppShell.d.ts +69 -0
- package/dist/components/AppShell/AppShellFooter.d.ts +41 -0
- package/dist/components/AppShell/AppShellMain.d.ts +41 -0
- package/dist/components/AppShell/AppShellNavbar.d.ts +41 -0
- package/dist/components/AppShell/AppShellNotificationPanel.d.ts +41 -0
- package/dist/components/AppShell/AppShellSidebar.d.ts +41 -0
- package/dist/components/AppShell/index.d.ts +29 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +47 -0
- package/dist/components/CodeBlock/index.d.ts +19 -0
- package/dist/components/ColorSchemeImage/index.d.ts +19 -0
- package/dist/components/ColorSchemeToggle/index.d.ts +18 -0
- package/dist/components/ComplexSelect/ComplexSelect.d.ts +25 -0
- package/dist/components/ComplexSelect/ComplexSelectDivider.d.ts +4 -0
- package/dist/components/ComplexSelect/ComplexSelectListHeader.d.ts +7 -0
- package/dist/components/ComplexSelect/ComplexSelectMenuItem.d.ts +16 -0
- package/dist/components/ComplexSelect/ComplexSelectMenuItemAvatar.d.ts +7 -0
- package/dist/components/ComplexSelect/ComplexSelectMenuItemIcon.d.ts +7 -0
- package/dist/components/ComplexSelect/ComplexSelectMenuItemText.d.ts +8 -0
- package/dist/components/ComplexSelect/index.d.ts +21 -0
- package/dist/components/Footer/Footer.d.ts +71 -0
- package/dist/components/Footer/index.d.ts +19 -0
- package/dist/components/Form/CardButton.d.ts +30 -0
- package/dist/components/Form/ElementWrapper.d.ts +24 -0
- package/dist/components/Form/Section.d.ts +21 -0
- package/dist/components/Form/Stack.d.ts +19 -0
- package/dist/components/Form/Typography.d.ts +21 -0
- package/dist/components/Form/Wizard.d.ts +27 -0
- package/dist/components/Form/index.d.ts +38 -0
- package/dist/components/Header/Header.d.ts +89 -0
- package/dist/components/Header/HeaderActions.d.ts +42 -0
- package/dist/components/Header/HeaderBrand.d.ts +48 -0
- package/dist/components/Header/HeaderBrandLogo.d.ts +45 -0
- package/dist/components/Header/HeaderBrandTitle.d.ts +45 -0
- package/dist/components/Header/HeaderSwitchers.d.ts +45 -0
- package/dist/components/Header/HeaderToggle.d.ts +52 -0
- package/dist/components/Header/context.d.ts +34 -0
- package/dist/components/Header/index.d.ts +33 -0
- package/dist/components/ListingTable/ListingTable/ListingTable.d.ts +54 -0
- package/dist/components/ListingTable/ListingTable/ListingTableBody.d.ts +6 -0
- package/dist/components/ListingTable/ListingTable/ListingTableCell.d.ts +15 -0
- package/dist/components/ListingTable/ListingTable/ListingTableContainer.d.ts +17 -0
- package/dist/components/ListingTable/ListingTable/ListingTableFooter.d.ts +6 -0
- package/dist/components/ListingTable/ListingTable/ListingTableHead.d.ts +6 -0
- package/dist/components/ListingTable/ListingTable/ListingTableRow.d.ts +18 -0
- package/dist/components/ListingTable/ListingTable/index.d.ts +21 -0
- package/dist/components/ListingTable/ListingTableProvider.d.ts +28 -0
- package/dist/components/ListingTable/context.d.ts +78 -0
- package/dist/components/ListingTable/index.d.ts +22 -0
- package/dist/components/ListingTable/shared/ListingTableCellIcon.d.ts +31 -0
- package/dist/components/ListingTable/shared/ListingTableDensityControl.d.ts +26 -0
- package/dist/components/ListingTable/shared/ListingTableEmptyState.d.ts +32 -0
- package/dist/components/ListingTable/shared/ListingTableRowActions.d.ts +24 -0
- package/dist/components/ListingTable/shared/ListingTableSortLabel.d.ts +37 -0
- package/dist/components/ListingTable/shared/ListingTableToolbar.d.ts +52 -0
- package/dist/components/ListingTable/shared/index.d.ts +14 -0
- package/dist/components/ListingTable/shared/types.d.ts +5 -0
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +69 -0
- package/dist/components/NotificationBanner/index.d.ts +19 -0
- package/dist/components/NotificationPanel/NotificationActions.d.ts +44 -0
- package/dist/components/NotificationPanel/NotificationEmptyState.d.ts +41 -0
- package/dist/components/NotificationPanel/NotificationHeader.d.ts +47 -0
- package/dist/components/NotificationPanel/NotificationHeaderBadge.d.ts +46 -0
- package/dist/components/NotificationPanel/NotificationHeaderClose.d.ts +46 -0
- package/dist/components/NotificationPanel/NotificationHeaderIcon.d.ts +43 -0
- package/dist/components/NotificationPanel/NotificationHeaderTitle.d.ts +43 -0
- package/dist/components/NotificationPanel/NotificationItem.d.ts +64 -0
- package/dist/components/NotificationPanel/NotificationItemAction.d.ts +46 -0
- package/dist/components/NotificationPanel/NotificationItemAvatar.d.ts +44 -0
- package/dist/components/NotificationPanel/NotificationItemContext.d.ts +52 -0
- package/dist/components/NotificationPanel/NotificationItemMessage.d.ts +47 -0
- package/dist/components/NotificationPanel/NotificationItemTimestamp.d.ts +46 -0
- package/dist/components/NotificationPanel/NotificationItemTitle.d.ts +49 -0
- package/dist/components/NotificationPanel/NotificationList.d.ts +37 -0
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +122 -0
- package/dist/components/NotificationPanel/NotificationTabs.d.ts +51 -0
- package/dist/components/NotificationPanel/context.d.ts +34 -0
- package/dist/components/NotificationPanel/index.d.ts +55 -0
- package/dist/components/NotificationPanel/utils.d.ts +46 -0
- package/dist/components/PageContent/PageContent.d.ts +71 -0
- package/dist/components/PageContent/index.d.ts +2 -0
- package/dist/components/PageTitle/PageTitle.d.ts +34 -0
- package/dist/components/PageTitle/PageTitleAvatar.d.ts +16 -0
- package/dist/components/PageTitle/PageTitleHeader.d.ts +16 -0
- package/dist/components/PageTitle/PageTitleLink.d.ts +20 -0
- package/dist/components/PageTitle/PageTitleSubHeader.d.ts +16 -0
- package/dist/components/PageTitle/index.d.ts +27 -0
- package/dist/components/SearchBar/SearchBar.d.ts +5 -0
- package/dist/components/SearchBar/SearchBarWithAdvancedFilter.d.ts +26 -0
- package/dist/components/Sidebar/Sidebar.d.ts +120 -0
- package/dist/components/Sidebar/SidebarCategory.d.ts +47 -0
- package/dist/components/Sidebar/SidebarCategoryLabel.d.ts +47 -0
- package/dist/components/Sidebar/SidebarFooter.d.ts +38 -0
- package/dist/components/Sidebar/SidebarItem.d.ts +61 -0
- package/dist/components/Sidebar/SidebarItemBadge.d.ts +47 -0
- package/dist/components/Sidebar/SidebarItemContext.d.ts +49 -0
- package/dist/components/Sidebar/SidebarItemIcon.d.ts +47 -0
- package/dist/components/Sidebar/SidebarItemLabel.d.ts +44 -0
- package/dist/components/Sidebar/SidebarNav.d.ts +42 -0
- package/dist/components/Sidebar/SidebarUser.d.ts +57 -0
- package/dist/components/Sidebar/SidebarUserAvatar.d.ts +51 -0
- package/dist/components/Sidebar/SidebarUserEmail.d.ts +48 -0
- package/dist/components/Sidebar/SidebarUserName.d.ts +45 -0
- package/dist/components/Sidebar/context.d.ts +42 -0
- package/dist/components/Sidebar/index.d.ts +47 -0
- package/dist/components/StatCard/StatCard.d.ts +48 -0
- package/dist/components/StatCard/index.d.ts +2 -0
- package/dist/components/ThemeSwitcher/ThemeSelect.d.ts +37 -0
- package/dist/components/ThemeSwitcher/ThemeSwitcher.d.ts +65 -0
- package/dist/components/ThemeSwitcher/index.d.ts +4 -0
- package/dist/components/UserMenu/UserMenu.d.ts +74 -0
- package/dist/components/UserMenu/index.d.ts +19 -0
- package/dist/components/index.d.ts +54 -0
- package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.d.ts +58 -3
- package/dist/contexts/OxygenUIThemeProvider/index.d.ts +20 -0
- package/dist/contexts/index.d.ts +19 -0
- package/dist/hooks/index.d.ts +22 -0
- package/dist/hooks/useAppShell/index.d.ts +19 -0
- package/dist/hooks/useAppShell/useAppShell.d.ts +81 -0
- package/dist/hooks/useNotifications/index.d.ts +19 -0
- package/dist/hooks/useNotifications/useNotifications.d.ts +105 -0
- package/dist/hooks/useThemeContent/index.d.ts +18 -0
- package/dist/hooks/useThemeContent/useThemeContent.d.ts +57 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +5189 -252
- package/dist/index.js.map +4 -4
- package/dist/layouts/Layout.d.ts +3 -0
- package/dist/layouts/LayoutContent.d.ts +3 -0
- package/dist/layouts/LayoutHeader.d.ts +3 -0
- package/dist/layouts/LayoutNavbar.d.ts +3 -0
- package/dist/layouts/LayoutSidebar.d.ts +3 -0
- package/dist/styles/Themes/AcrylicBaseTheme.d.ts +25 -0
- package/dist/styles/Themes/AcrylicOrangeTheme.d.ts +17 -0
- package/dist/styles/Themes/AcrylicPurpleTheme.d.ts +20 -0
- package/dist/styles/Themes/ClassicTheme.d.ts +24 -0
- package/dist/styles/Themes/HighContrastTheme.d.ts +20 -0
- package/dist/styles/Themes/OxygenThemeBase.d.ts +70 -0
- package/dist/styles/Themes/index.d.ts +22 -0
- package/dist/styles/index.d.ts +18 -0
- package/dist/utils/formatRelativeTime.d.ts +34 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/pxToRem.d.ts +23 -0
- package/package.json +20 -12
- package/dist/components/ColorSchemeImage/ColorSchemeImage.js +0 -57
- package/dist/components/ColorSchemeImage/ColorSchemeImage.js.map +0 -7
- package/dist/components/ColorSchemeToggle/ColorSchemeToggle.js +0 -76
- package/dist/components/ColorSchemeToggle/ColorSchemeToggle.js.map +0 -7
- package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.js +0 -378
- package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.js.map +0 -7
- package/dist/styles/OxygenTheme/OxygenTheme.d.ts +0 -38
- package/dist/styles/OxygenTheme/OxygenTheme.js +0 -356
- package/dist/styles/OxygenTheme/OxygenTheme.js.map +0 -7
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oxygen-component
|
|
3
|
+
description: Generate Oxygen UI React components following best practices. Use when creating new components, data tables, cards, or UI elements with the Oxygen UI library.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Generate Oxygen UI Component
|
|
7
|
+
|
|
8
|
+
## Instructions
|
|
9
|
+
|
|
10
|
+
1. Read `.claude/oxygen-ui/CLAUDE.md` for critical rules
|
|
11
|
+
2. Read `.claude/oxygen-ui/components.md` for API reference
|
|
12
|
+
3. Generate component using Oxygen UI patterns
|
|
13
|
+
|
|
14
|
+
## Critical Rules
|
|
15
|
+
|
|
16
|
+
- Import ALL components from `@wso2/oxygen-ui` (never from `@mui/material`)
|
|
17
|
+
- Import icons from `@wso2/oxygen-ui-icons-react`
|
|
18
|
+
- Use theme tokens via `sx` prop (e.g., `p: 2`, `bgcolor: 'background.paper'`)
|
|
19
|
+
- Never hardcode colors or spacing values
|
|
20
|
+
- For data tables, prefer `ListingTable` over MUI's `Table`
|
|
21
|
+
- For layouts, use `AppShell`, `Header`, `Sidebar`
|
|
22
|
+
|
|
23
|
+
## Component Template
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { Box, Typography, Button } from '@wso2/oxygen-ui';
|
|
27
|
+
import { IconName } from '@wso2/oxygen-ui-icons-react';
|
|
28
|
+
|
|
29
|
+
interface MyComponentProps {
|
|
30
|
+
// Define props
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function MyComponent({ ...props }: MyComponentProps) {
|
|
34
|
+
return (
|
|
35
|
+
<Box sx={{ p: 2, bgcolor: 'background.paper' }}>
|
|
36
|
+
{/* Component content */}
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default MyComponent;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Common Patterns
|
|
45
|
+
|
|
46
|
+
### Data Table Component
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { ListingTable, Chip, IconButton } from '@wso2/oxygen-ui';
|
|
50
|
+
import { EditIcon, TrashIcon } from '@wso2/oxygen-ui-icons-react';
|
|
51
|
+
|
|
52
|
+
<ListingTable.Container>
|
|
53
|
+
<ListingTable.Toolbar showSearch actions={<Button>Add Item</Button>} />
|
|
54
|
+
<ListingTable variant="card">
|
|
55
|
+
<ListingTable.Head>
|
|
56
|
+
<ListingTable.Row>
|
|
57
|
+
<ListingTable.Cell>Name</ListingTable.Cell>
|
|
58
|
+
<ListingTable.Cell>Status</ListingTable.Cell>
|
|
59
|
+
<ListingTable.Cell align="right">Actions</ListingTable.Cell>
|
|
60
|
+
</ListingTable.Row>
|
|
61
|
+
</ListingTable.Head>
|
|
62
|
+
<ListingTable.Body>
|
|
63
|
+
{data.map((item) => (
|
|
64
|
+
<ListingTable.Row key={item.id}>
|
|
65
|
+
<ListingTable.Cell>{item.name}</ListingTable.Cell>
|
|
66
|
+
<ListingTable.Cell>
|
|
67
|
+
<Chip label={item.status} color="success" size="small" />
|
|
68
|
+
</ListingTable.Cell>
|
|
69
|
+
<ListingTable.Cell align="right">
|
|
70
|
+
<IconButton size="small"><EditIcon size={18} /></IconButton>
|
|
71
|
+
<IconButton size="small" color="error"><TrashIcon size={18} /></IconButton>
|
|
72
|
+
</ListingTable.Cell>
|
|
73
|
+
</ListingTable.Row>
|
|
74
|
+
))}
|
|
75
|
+
</ListingTable.Body>
|
|
76
|
+
</ListingTable>
|
|
77
|
+
</ListingTable.Container>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Card Component
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { Paper, Typography, Box, Button } from '@wso2/oxygen-ui';
|
|
84
|
+
|
|
85
|
+
<Paper sx={{ p: 3 }}>
|
|
86
|
+
<Typography variant="h6" gutterBottom>Card Title</Typography>
|
|
87
|
+
<Typography color="text.secondary" sx={{ mb: 2 }}>
|
|
88
|
+
Card description text
|
|
89
|
+
</Typography>
|
|
90
|
+
<Box sx={{ display: 'flex', gap: 1 }}>
|
|
91
|
+
<Button variant="contained">Primary</Button>
|
|
92
|
+
<Button variant="outlined">Secondary</Button>
|
|
93
|
+
</Box>
|
|
94
|
+
</Paper>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Dialog Component
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import {
|
|
101
|
+
Dialog,
|
|
102
|
+
DialogTitle,
|
|
103
|
+
DialogContent,
|
|
104
|
+
DialogContentText,
|
|
105
|
+
DialogActions,
|
|
106
|
+
Button,
|
|
107
|
+
} from '@wso2/oxygen-ui';
|
|
108
|
+
|
|
109
|
+
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
|
110
|
+
<DialogTitle>Dialog Title</DialogTitle>
|
|
111
|
+
<DialogContent>
|
|
112
|
+
<DialogContentText>Dialog content goes here.</DialogContentText>
|
|
113
|
+
</DialogContent>
|
|
114
|
+
<DialogActions>
|
|
115
|
+
<Button onClick={onClose}>Cancel</Button>
|
|
116
|
+
<Button variant="contained" onClick={onConfirm}>Confirm</Button>
|
|
117
|
+
</DialogActions>
|
|
118
|
+
</Dialog>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## MUI X Components (Use Namespaces)
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { DataGrid, Charts, DatePickers, TreeView } from '@wso2/oxygen-ui';
|
|
125
|
+
|
|
126
|
+
// DataGrid
|
|
127
|
+
<DataGrid.DataGrid rows={rows} columns={columns} />
|
|
128
|
+
|
|
129
|
+
// Charts
|
|
130
|
+
<Charts.LineChart series={series} />
|
|
131
|
+
<Charts.BarChart series={series} />
|
|
132
|
+
<Charts.PieChart series={series} />
|
|
133
|
+
|
|
134
|
+
// DatePickers
|
|
135
|
+
<DatePickers.DatePicker value={date} onChange={setDate} />
|
|
136
|
+
|
|
137
|
+
// TreeView
|
|
138
|
+
<TreeView.SimpleTreeView>
|
|
139
|
+
<TreeView.TreeItem itemId="1" label="Item 1" />
|
|
140
|
+
</TreeView.SimpleTreeView>
|
|
141
|
+
```
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: oxygen-form
|
|
3
|
+
description: Generate forms with Form.* components and validation. Use when creating input forms, multi-step wizards, or form validation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Generate Oxygen UI Form
|
|
7
|
+
|
|
8
|
+
## Instructions
|
|
9
|
+
|
|
10
|
+
1. Read `.claude/oxygen-ui/components.md` for Form.* API
|
|
11
|
+
2. Use `Form.Section` for grouping fields
|
|
12
|
+
3. Use `Form.Stack` for field layout
|
|
13
|
+
4. Add validation with `error` and `helperText` props
|
|
14
|
+
|
|
15
|
+
## Critical Rules
|
|
16
|
+
|
|
17
|
+
- Import form components from `@wso2/oxygen-ui`
|
|
18
|
+
- Use controlled components with state
|
|
19
|
+
- Show validation errors with `error` and `helperText` props
|
|
20
|
+
- Use theme tokens for spacing
|
|
21
|
+
|
|
22
|
+
## Basic Form
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { useState } from 'react';
|
|
26
|
+
import { Box, TextField, Button, Alert } from '@wso2/oxygen-ui';
|
|
27
|
+
|
|
28
|
+
function BasicForm() {
|
|
29
|
+
const [formData, setFormData] = useState({ name: '', email: '' });
|
|
30
|
+
const [errors, setErrors] = useState<Record<string, string>>({});
|
|
31
|
+
|
|
32
|
+
const validate = () => {
|
|
33
|
+
const newErrors: Record<string, string> = {};
|
|
34
|
+
|
|
35
|
+
if (!formData.name) {
|
|
36
|
+
newErrors.name = 'Name is required';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!formData.email) {
|
|
40
|
+
newErrors.email = 'Email is required';
|
|
41
|
+
} else if (!/\S+@\S+\.\S+/.test(formData.email)) {
|
|
42
|
+
newErrors.email = 'Invalid email format';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setErrors(newErrors);
|
|
46
|
+
return Object.keys(newErrors).length === 0;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
if (validate()) {
|
|
52
|
+
console.log('Form submitted:', formData);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Box component="form" onSubmit={handleSubmit} sx={{ maxWidth: 400 }}>
|
|
58
|
+
<TextField
|
|
59
|
+
fullWidth
|
|
60
|
+
label="Name"
|
|
61
|
+
value={formData.name}
|
|
62
|
+
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
63
|
+
error={!!errors.name}
|
|
64
|
+
helperText={errors.name}
|
|
65
|
+
margin="normal"
|
|
66
|
+
required
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
<TextField
|
|
70
|
+
fullWidth
|
|
71
|
+
label="Email"
|
|
72
|
+
type="email"
|
|
73
|
+
value={formData.email}
|
|
74
|
+
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
|
|
75
|
+
error={!!errors.email}
|
|
76
|
+
helperText={errors.email}
|
|
77
|
+
margin="normal"
|
|
78
|
+
required
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
<Button type="submit" variant="contained" sx={{ mt: 2 }}>
|
|
82
|
+
Submit
|
|
83
|
+
</Button>
|
|
84
|
+
</Box>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Form with Sections
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { Form, TextField, Button, Box } from '@wso2/oxygen-ui';
|
|
93
|
+
|
|
94
|
+
function SectionedForm() {
|
|
95
|
+
return (
|
|
96
|
+
<Box sx={{ maxWidth: 600 }}>
|
|
97
|
+
<Form.Section>
|
|
98
|
+
<Form.Header>Personal Information</Form.Header>
|
|
99
|
+
<Form.Subheader>Enter your basic details</Form.Subheader>
|
|
100
|
+
|
|
101
|
+
<Form.Stack spacing={2}>
|
|
102
|
+
<Form.TextInput label="First Name" required />
|
|
103
|
+
<Form.TextInput label="Last Name" required />
|
|
104
|
+
<Form.TextInput label="Email" type="email" required />
|
|
105
|
+
</Form.Stack>
|
|
106
|
+
</Form.Section>
|
|
107
|
+
|
|
108
|
+
<Form.Section>
|
|
109
|
+
<Form.Header>Company Details</Form.Header>
|
|
110
|
+
<Form.Subheader>Optional information about your organization</Form.Subheader>
|
|
111
|
+
|
|
112
|
+
<Form.Stack spacing={2}>
|
|
113
|
+
<Form.TextInput label="Company Name" />
|
|
114
|
+
<Form.SelectInput label="Role">
|
|
115
|
+
<Form.MenuItem value="developer">Developer</Form.MenuItem>
|
|
116
|
+
<Form.MenuItem value="designer">Designer</Form.MenuItem>
|
|
117
|
+
<Form.MenuItem value="manager">Manager</Form.MenuItem>
|
|
118
|
+
</Form.SelectInput>
|
|
119
|
+
</Form.Stack>
|
|
120
|
+
</Form.Section>
|
|
121
|
+
|
|
122
|
+
<Box sx={{ mt: 3, display: 'flex', gap: 2 }}>
|
|
123
|
+
<Button variant="outlined">Cancel</Button>
|
|
124
|
+
<Button variant="contained">Save</Button>
|
|
125
|
+
</Box>
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Login Form
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { useState } from 'react';
|
|
135
|
+
import {
|
|
136
|
+
Box,
|
|
137
|
+
Paper,
|
|
138
|
+
Typography,
|
|
139
|
+
TextField,
|
|
140
|
+
Button,
|
|
141
|
+
Link,
|
|
142
|
+
Divider,
|
|
143
|
+
Alert,
|
|
144
|
+
} from '@wso2/oxygen-ui';
|
|
145
|
+
|
|
146
|
+
function LoginForm() {
|
|
147
|
+
const [email, setEmail] = useState('');
|
|
148
|
+
const [password, setPassword] = useState('');
|
|
149
|
+
const [error, setError] = useState('');
|
|
150
|
+
const [loading, setLoading] = useState(false);
|
|
151
|
+
|
|
152
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
setLoading(true);
|
|
155
|
+
setError('');
|
|
156
|
+
|
|
157
|
+
try {
|
|
158
|
+
// Login logic here
|
|
159
|
+
await login(email, password);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
setError('Invalid credentials');
|
|
162
|
+
} finally {
|
|
163
|
+
setLoading(false);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<Box
|
|
169
|
+
sx={{
|
|
170
|
+
minHeight: '100vh',
|
|
171
|
+
display: 'flex',
|
|
172
|
+
alignItems: 'center',
|
|
173
|
+
justifyContent: 'center',
|
|
174
|
+
bgcolor: 'background.default',
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
<Paper sx={{ p: 4, maxWidth: 400, width: '100%' }}>
|
|
178
|
+
<Typography variant="h5" gutterBottom align="center">
|
|
179
|
+
Sign In
|
|
180
|
+
</Typography>
|
|
181
|
+
|
|
182
|
+
{error && (
|
|
183
|
+
<Alert severity="error" sx={{ mb: 2 }}>
|
|
184
|
+
{error}
|
|
185
|
+
</Alert>
|
|
186
|
+
)}
|
|
187
|
+
|
|
188
|
+
<Box component="form" onSubmit={handleSubmit}>
|
|
189
|
+
<TextField
|
|
190
|
+
fullWidth
|
|
191
|
+
label="Email"
|
|
192
|
+
type="email"
|
|
193
|
+
value={email}
|
|
194
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
195
|
+
margin="normal"
|
|
196
|
+
required
|
|
197
|
+
/>
|
|
198
|
+
|
|
199
|
+
<TextField
|
|
200
|
+
fullWidth
|
|
201
|
+
label="Password"
|
|
202
|
+
type="password"
|
|
203
|
+
value={password}
|
|
204
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
205
|
+
margin="normal"
|
|
206
|
+
required
|
|
207
|
+
/>
|
|
208
|
+
|
|
209
|
+
<Button
|
|
210
|
+
fullWidth
|
|
211
|
+
type="submit"
|
|
212
|
+
variant="contained"
|
|
213
|
+
disabled={loading}
|
|
214
|
+
sx={{ mt: 3, mb: 2 }}
|
|
215
|
+
>
|
|
216
|
+
{loading ? 'Signing in...' : 'Sign In'}
|
|
217
|
+
</Button>
|
|
218
|
+
|
|
219
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
220
|
+
<Link href="/forgot-password" variant="body2">
|
|
221
|
+
Forgot password?
|
|
222
|
+
</Link>
|
|
223
|
+
<Link href="/register" variant="body2">
|
|
224
|
+
Create account
|
|
225
|
+
</Link>
|
|
226
|
+
</Box>
|
|
227
|
+
</Box>
|
|
228
|
+
</Paper>
|
|
229
|
+
</Box>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Multi-Step Wizard
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { useState } from 'react';
|
|
238
|
+
import {
|
|
239
|
+
Box,
|
|
240
|
+
Paper,
|
|
241
|
+
Stepper,
|
|
242
|
+
Step,
|
|
243
|
+
StepLabel,
|
|
244
|
+
Button,
|
|
245
|
+
Typography,
|
|
246
|
+
TextField,
|
|
247
|
+
} from '@wso2/oxygen-ui';
|
|
248
|
+
|
|
249
|
+
const steps = ['Account', 'Profile', 'Review'];
|
|
250
|
+
|
|
251
|
+
function RegistrationWizard() {
|
|
252
|
+
const [activeStep, setActiveStep] = useState(0);
|
|
253
|
+
const [formData, setFormData] = useState({
|
|
254
|
+
email: '',
|
|
255
|
+
password: '',
|
|
256
|
+
name: '',
|
|
257
|
+
company: '',
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
const handleNext = () => setActiveStep((prev) => prev + 1);
|
|
261
|
+
const handleBack = () => setActiveStep((prev) => prev - 1);
|
|
262
|
+
|
|
263
|
+
const handleSubmit = () => {
|
|
264
|
+
console.log('Form submitted:', formData);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const renderStepContent = (step: number) => {
|
|
268
|
+
switch (step) {
|
|
269
|
+
case 0:
|
|
270
|
+
return (
|
|
271
|
+
<>
|
|
272
|
+
<TextField
|
|
273
|
+
fullWidth
|
|
274
|
+
label="Email"
|
|
275
|
+
type="email"
|
|
276
|
+
value={formData.email}
|
|
277
|
+
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
|
|
278
|
+
margin="normal"
|
|
279
|
+
/>
|
|
280
|
+
<TextField
|
|
281
|
+
fullWidth
|
|
282
|
+
label="Password"
|
|
283
|
+
type="password"
|
|
284
|
+
value={formData.password}
|
|
285
|
+
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
|
286
|
+
margin="normal"
|
|
287
|
+
/>
|
|
288
|
+
</>
|
|
289
|
+
);
|
|
290
|
+
case 1:
|
|
291
|
+
return (
|
|
292
|
+
<>
|
|
293
|
+
<TextField
|
|
294
|
+
fullWidth
|
|
295
|
+
label="Full Name"
|
|
296
|
+
value={formData.name}
|
|
297
|
+
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
298
|
+
margin="normal"
|
|
299
|
+
/>
|
|
300
|
+
<TextField
|
|
301
|
+
fullWidth
|
|
302
|
+
label="Company"
|
|
303
|
+
value={formData.company}
|
|
304
|
+
onChange={(e) => setFormData({ ...formData, company: e.target.value })}
|
|
305
|
+
margin="normal"
|
|
306
|
+
/>
|
|
307
|
+
</>
|
|
308
|
+
);
|
|
309
|
+
case 2:
|
|
310
|
+
return (
|
|
311
|
+
<Box>
|
|
312
|
+
<Typography variant="body1" gutterBottom>
|
|
313
|
+
<strong>Email:</strong> {formData.email}
|
|
314
|
+
</Typography>
|
|
315
|
+
<Typography variant="body1" gutterBottom>
|
|
316
|
+
<strong>Name:</strong> {formData.name}
|
|
317
|
+
</Typography>
|
|
318
|
+
<Typography variant="body1" gutterBottom>
|
|
319
|
+
<strong>Company:</strong> {formData.company}
|
|
320
|
+
</Typography>
|
|
321
|
+
</Box>
|
|
322
|
+
);
|
|
323
|
+
default:
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
return (
|
|
329
|
+
<Paper sx={{ p: 4, maxWidth: 600, mx: 'auto' }}>
|
|
330
|
+
<Stepper activeStep={activeStep} sx={{ mb: 4 }}>
|
|
331
|
+
{steps.map((label) => (
|
|
332
|
+
<Step key={label}>
|
|
333
|
+
<StepLabel>{label}</StepLabel>
|
|
334
|
+
</Step>
|
|
335
|
+
))}
|
|
336
|
+
</Stepper>
|
|
337
|
+
|
|
338
|
+
<Box sx={{ minHeight: 200 }}>{renderStepContent(activeStep)}</Box>
|
|
339
|
+
|
|
340
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 4 }}>
|
|
341
|
+
<Button disabled={activeStep === 0} onClick={handleBack}>
|
|
342
|
+
Back
|
|
343
|
+
</Button>
|
|
344
|
+
{activeStep === steps.length - 1 ? (
|
|
345
|
+
<Button variant="contained" onClick={handleSubmit}>
|
|
346
|
+
Submit
|
|
347
|
+
</Button>
|
|
348
|
+
) : (
|
|
349
|
+
<Button variant="contained" onClick={handleNext}>
|
|
350
|
+
Next
|
|
351
|
+
</Button>
|
|
352
|
+
)}
|
|
353
|
+
</Box>
|
|
354
|
+
</Paper>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## Form with Select and Autocomplete
|
|
360
|
+
|
|
361
|
+
```tsx
|
|
362
|
+
import { useState } from 'react';
|
|
363
|
+
import { Box, TextField, Button, MenuItem, Autocomplete } from '@wso2/oxygen-ui';
|
|
364
|
+
|
|
365
|
+
const countries = [
|
|
366
|
+
{ label: 'United States', code: 'US' },
|
|
367
|
+
{ label: 'United Kingdom', code: 'UK' },
|
|
368
|
+
{ label: 'Canada', code: 'CA' },
|
|
369
|
+
// ...more
|
|
370
|
+
];
|
|
371
|
+
|
|
372
|
+
function AddressForm() {
|
|
373
|
+
const [country, setCountry] = useState<typeof countries[0] | null>(null);
|
|
374
|
+
const [state, setState] = useState('');
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<Box sx={{ maxWidth: 400 }}>
|
|
378
|
+
<Autocomplete
|
|
379
|
+
options={countries}
|
|
380
|
+
value={country}
|
|
381
|
+
onChange={(_, newValue) => setCountry(newValue)}
|
|
382
|
+
renderInput={(params) => (
|
|
383
|
+
<TextField {...params} label="Country" margin="normal" />
|
|
384
|
+
)}
|
|
385
|
+
/>
|
|
386
|
+
|
|
387
|
+
<TextField
|
|
388
|
+
fullWidth
|
|
389
|
+
select
|
|
390
|
+
label="State"
|
|
391
|
+
value={state}
|
|
392
|
+
onChange={(e) => setState(e.target.value)}
|
|
393
|
+
margin="normal"
|
|
394
|
+
>
|
|
395
|
+
<MenuItem value="ca">California</MenuItem>
|
|
396
|
+
<MenuItem value="ny">New York</MenuItem>
|
|
397
|
+
<MenuItem value="tx">Texas</MenuItem>
|
|
398
|
+
</TextField>
|
|
399
|
+
|
|
400
|
+
<TextField fullWidth label="City" margin="normal" />
|
|
401
|
+
<TextField fullWidth label="Address" margin="normal" multiline rows={2} />
|
|
402
|
+
<TextField fullWidth label="Zip Code" margin="normal" />
|
|
403
|
+
|
|
404
|
+
<Button variant="contained" sx={{ mt: 2 }}>
|
|
405
|
+
Save Address
|
|
406
|
+
</Button>
|
|
407
|
+
</Box>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
```
|