@wso2/oxygen-ui 0.0.1-alpha.9 → 0.1.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 +5172 -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
package/.ai/patterns.md
ADDED
|
@@ -0,0 +1,1185 @@
|
|
|
1
|
+
# Oxygen UI Common Patterns
|
|
2
|
+
|
|
3
|
+
Ready-to-use UI patterns for common application scenarios.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [App Shell Layout](#app-shell-layout)
|
|
8
|
+
- [Authentication Forms](#authentication-forms)
|
|
9
|
+
- [Dashboard Layout](#dashboard-layout)
|
|
10
|
+
- [Data Tables](#data-tables)
|
|
11
|
+
- [Modal Dialogs](#modal-dialogs)
|
|
12
|
+
- [Error States](#error-states)
|
|
13
|
+
- [Form Patterns](#form-patterns)
|
|
14
|
+
- [Navigation Patterns](#navigation-patterns)
|
|
15
|
+
- [Theme Switching](#theme-switching)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## App Shell Layout
|
|
20
|
+
|
|
21
|
+
Complete application shell with header, sidebar, and content area.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { useState } from 'react';
|
|
25
|
+
import {
|
|
26
|
+
OxygenUIThemeProvider,
|
|
27
|
+
OxygenTheme,
|
|
28
|
+
AppShell,
|
|
29
|
+
Header,
|
|
30
|
+
Sidebar,
|
|
31
|
+
Footer,
|
|
32
|
+
ColorSchemeToggle,
|
|
33
|
+
UserMenu,
|
|
34
|
+
} from '@wso2/oxygen-ui';
|
|
35
|
+
import { HomeIcon, DashboardIcon, SettingsIcon } from '@wso2/oxygen-ui-icons-react';
|
|
36
|
+
|
|
37
|
+
function App() {
|
|
38
|
+
const [collapsed, setCollapsed] = useState(false);
|
|
39
|
+
const [activeItem, setActiveItem] = useState('home');
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<OxygenUIThemeProvider theme={OxygenTheme}>
|
|
43
|
+
<AppShell>
|
|
44
|
+
<AppShell.Navbar>
|
|
45
|
+
<Header>
|
|
46
|
+
<Header.Toggle
|
|
47
|
+
collapsed={collapsed}
|
|
48
|
+
onToggle={() => setCollapsed(!collapsed)}
|
|
49
|
+
/>
|
|
50
|
+
<Header.Brand>
|
|
51
|
+
<Header.BrandLogo>
|
|
52
|
+
<img src="/logo.svg" alt="Logo" height={32} />
|
|
53
|
+
</Header.BrandLogo>
|
|
54
|
+
<Header.BrandTitle>My App</Header.BrandTitle>
|
|
55
|
+
</Header.Brand>
|
|
56
|
+
<Header.Spacer />
|
|
57
|
+
<Header.Actions>
|
|
58
|
+
<ColorSchemeToggle />
|
|
59
|
+
<UserMenu
|
|
60
|
+
user={{ name: 'John Doe', email: 'john@example.com' }}
|
|
61
|
+
onSignOut={() => console.log('Sign out')}
|
|
62
|
+
/>
|
|
63
|
+
</Header.Actions>
|
|
64
|
+
</Header>
|
|
65
|
+
</AppShell.Navbar>
|
|
66
|
+
|
|
67
|
+
<AppShell.Sidebar>
|
|
68
|
+
<Sidebar
|
|
69
|
+
collapsed={collapsed}
|
|
70
|
+
activeItem={activeItem}
|
|
71
|
+
onSelect={setActiveItem}
|
|
72
|
+
>
|
|
73
|
+
<Sidebar.Nav>
|
|
74
|
+
<Sidebar.Category>
|
|
75
|
+
<Sidebar.CategoryLabel>Main</Sidebar.CategoryLabel>
|
|
76
|
+
<Sidebar.Item id="home">
|
|
77
|
+
<Sidebar.ItemIcon><HomeIcon size={20} /></Sidebar.ItemIcon>
|
|
78
|
+
<Sidebar.ItemLabel>Home</Sidebar.ItemLabel>
|
|
79
|
+
</Sidebar.Item>
|
|
80
|
+
<Sidebar.Item id="dashboard">
|
|
81
|
+
<Sidebar.ItemIcon><DashboardIcon size={20} /></Sidebar.ItemIcon>
|
|
82
|
+
<Sidebar.ItemLabel>Dashboard</Sidebar.ItemLabel>
|
|
83
|
+
</Sidebar.Item>
|
|
84
|
+
</Sidebar.Category>
|
|
85
|
+
</Sidebar.Nav>
|
|
86
|
+
<Sidebar.Footer>
|
|
87
|
+
<Sidebar.Item id="settings">
|
|
88
|
+
<Sidebar.ItemIcon><SettingsIcon size={20} /></Sidebar.ItemIcon>
|
|
89
|
+
<Sidebar.ItemLabel>Settings</Sidebar.ItemLabel>
|
|
90
|
+
</Sidebar.Item>
|
|
91
|
+
</Sidebar.Footer>
|
|
92
|
+
</Sidebar>
|
|
93
|
+
</AppShell.Sidebar>
|
|
94
|
+
|
|
95
|
+
<AppShell.Main>
|
|
96
|
+
<Box sx={{ p: 3 }}>
|
|
97
|
+
{/* Page content goes here */}
|
|
98
|
+
</Box>
|
|
99
|
+
</AppShell.Main>
|
|
100
|
+
|
|
101
|
+
<AppShell.Footer>
|
|
102
|
+
<Footer companyName="WSO2 LLC" />
|
|
103
|
+
</AppShell.Footer>
|
|
104
|
+
</AppShell>
|
|
105
|
+
</OxygenUIThemeProvider>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Authentication Forms
|
|
113
|
+
|
|
114
|
+
### Login Form
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useState } from 'react';
|
|
118
|
+
import {
|
|
119
|
+
Box,
|
|
120
|
+
Paper,
|
|
121
|
+
Typography,
|
|
122
|
+
TextField,
|
|
123
|
+
Button,
|
|
124
|
+
Link,
|
|
125
|
+
Divider,
|
|
126
|
+
Alert,
|
|
127
|
+
} from '@wso2/oxygen-ui';
|
|
128
|
+
|
|
129
|
+
function LoginForm() {
|
|
130
|
+
const [email, setEmail] = useState('');
|
|
131
|
+
const [password, setPassword] = useState('');
|
|
132
|
+
const [error, setError] = useState('');
|
|
133
|
+
const [loading, setLoading] = useState(false);
|
|
134
|
+
|
|
135
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
setLoading(true);
|
|
138
|
+
setError('');
|
|
139
|
+
try {
|
|
140
|
+
// Login logic here
|
|
141
|
+
} catch (err) {
|
|
142
|
+
setError('Invalid credentials');
|
|
143
|
+
} finally {
|
|
144
|
+
setLoading(false);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return (
|
|
149
|
+
<Box
|
|
150
|
+
sx={{
|
|
151
|
+
minHeight: '100vh',
|
|
152
|
+
display: 'flex',
|
|
153
|
+
alignItems: 'center',
|
|
154
|
+
justifyContent: 'center',
|
|
155
|
+
bgcolor: 'background.default',
|
|
156
|
+
}}
|
|
157
|
+
>
|
|
158
|
+
<Paper sx={{ p: 4, maxWidth: 400, width: '100%' }}>
|
|
159
|
+
<Typography variant="h5" gutterBottom align="center">
|
|
160
|
+
Sign In
|
|
161
|
+
</Typography>
|
|
162
|
+
|
|
163
|
+
{error && (
|
|
164
|
+
<Alert severity="error" sx={{ mb: 2 }}>
|
|
165
|
+
{error}
|
|
166
|
+
</Alert>
|
|
167
|
+
)}
|
|
168
|
+
|
|
169
|
+
<Box component="form" onSubmit={handleSubmit}>
|
|
170
|
+
<TextField
|
|
171
|
+
fullWidth
|
|
172
|
+
label="Email"
|
|
173
|
+
type="email"
|
|
174
|
+
value={email}
|
|
175
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
176
|
+
margin="normal"
|
|
177
|
+
required
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
<TextField
|
|
181
|
+
fullWidth
|
|
182
|
+
label="Password"
|
|
183
|
+
type="password"
|
|
184
|
+
value={password}
|
|
185
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
186
|
+
margin="normal"
|
|
187
|
+
required
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
<Button
|
|
191
|
+
fullWidth
|
|
192
|
+
type="submit"
|
|
193
|
+
variant="contained"
|
|
194
|
+
disabled={loading}
|
|
195
|
+
sx={{ mt: 3, mb: 2 }}
|
|
196
|
+
>
|
|
197
|
+
{loading ? 'Signing in...' : 'Sign In'}
|
|
198
|
+
</Button>
|
|
199
|
+
|
|
200
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
201
|
+
<Link href="/forgot-password" variant="body2">
|
|
202
|
+
Forgot password?
|
|
203
|
+
</Link>
|
|
204
|
+
<Link href="/register" variant="body2">
|
|
205
|
+
Create account
|
|
206
|
+
</Link>
|
|
207
|
+
</Box>
|
|
208
|
+
|
|
209
|
+
<Divider sx={{ my: 3 }}>or</Divider>
|
|
210
|
+
|
|
211
|
+
<Button fullWidth variant="outlined" startIcon={<GoogleIcon />}>
|
|
212
|
+
Continue with Google
|
|
213
|
+
</Button>
|
|
214
|
+
</Box>
|
|
215
|
+
</Paper>
|
|
216
|
+
</Box>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Password Reset Form
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { useState } from 'react';
|
|
225
|
+
import {
|
|
226
|
+
Box,
|
|
227
|
+
Paper,
|
|
228
|
+
Typography,
|
|
229
|
+
TextField,
|
|
230
|
+
Button,
|
|
231
|
+
Alert,
|
|
232
|
+
} from '@wso2/oxygen-ui';
|
|
233
|
+
|
|
234
|
+
function PasswordResetForm() {
|
|
235
|
+
const [email, setEmail] = useState('');
|
|
236
|
+
const [submitted, setSubmitted] = useState(false);
|
|
237
|
+
|
|
238
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
239
|
+
e.preventDefault();
|
|
240
|
+
// Send reset email
|
|
241
|
+
setSubmitted(true);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
if (submitted) {
|
|
245
|
+
return (
|
|
246
|
+
<Paper sx={{ p: 4, maxWidth: 400 }}>
|
|
247
|
+
<Alert severity="success">
|
|
248
|
+
If an account exists for {email}, you will receive a password reset link.
|
|
249
|
+
</Alert>
|
|
250
|
+
<Button href="/login" sx={{ mt: 2 }}>
|
|
251
|
+
Back to Login
|
|
252
|
+
</Button>
|
|
253
|
+
</Paper>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<Paper sx={{ p: 4, maxWidth: 400 }}>
|
|
259
|
+
<Typography variant="h5" gutterBottom>
|
|
260
|
+
Reset Password
|
|
261
|
+
</Typography>
|
|
262
|
+
<Typography color="text.secondary" sx={{ mb: 3 }}>
|
|
263
|
+
Enter your email address and we'll send you a reset link.
|
|
264
|
+
</Typography>
|
|
265
|
+
|
|
266
|
+
<Box component="form" onSubmit={handleSubmit}>
|
|
267
|
+
<TextField
|
|
268
|
+
fullWidth
|
|
269
|
+
label="Email"
|
|
270
|
+
type="email"
|
|
271
|
+
value={email}
|
|
272
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
273
|
+
required
|
|
274
|
+
/>
|
|
275
|
+
<Button fullWidth type="submit" variant="contained" sx={{ mt: 3 }}>
|
|
276
|
+
Send Reset Link
|
|
277
|
+
</Button>
|
|
278
|
+
</Box>
|
|
279
|
+
</Paper>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Dashboard Layout
|
|
287
|
+
|
|
288
|
+
### Stats Cards
|
|
289
|
+
|
|
290
|
+
```tsx
|
|
291
|
+
import { Grid, Paper, Typography, Box } from '@wso2/oxygen-ui';
|
|
292
|
+
import { TrendingUpIcon, TrendingDownIcon } from '@wso2/oxygen-ui-icons-react';
|
|
293
|
+
|
|
294
|
+
interface StatCardProps {
|
|
295
|
+
title: string;
|
|
296
|
+
value: string | number;
|
|
297
|
+
change?: number;
|
|
298
|
+
icon?: React.ReactNode;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function StatCard({ title, value, change, icon }: StatCardProps) {
|
|
302
|
+
const isPositive = change && change > 0;
|
|
303
|
+
|
|
304
|
+
return (
|
|
305
|
+
<Paper sx={{ p: 3 }}>
|
|
306
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 2 }}>
|
|
307
|
+
<Typography color="text.secondary" variant="body2">
|
|
308
|
+
{title}
|
|
309
|
+
</Typography>
|
|
310
|
+
{icon}
|
|
311
|
+
</Box>
|
|
312
|
+
|
|
313
|
+
<Typography variant="h4" fontWeight="bold">
|
|
314
|
+
{value}
|
|
315
|
+
</Typography>
|
|
316
|
+
|
|
317
|
+
{change !== undefined && (
|
|
318
|
+
<Box
|
|
319
|
+
sx={{
|
|
320
|
+
display: 'flex',
|
|
321
|
+
alignItems: 'center',
|
|
322
|
+
mt: 1,
|
|
323
|
+
color: isPositive ? 'success.main' : 'error.main',
|
|
324
|
+
}}
|
|
325
|
+
>
|
|
326
|
+
{isPositive ? <TrendingUpIcon size={16} /> : <TrendingDownIcon size={16} />}
|
|
327
|
+
<Typography variant="body2" sx={{ ml: 0.5 }}>
|
|
328
|
+
{Math.abs(change)}% from last month
|
|
329
|
+
</Typography>
|
|
330
|
+
</Box>
|
|
331
|
+
)}
|
|
332
|
+
</Paper>
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function Dashboard() {
|
|
337
|
+
return (
|
|
338
|
+
<Box sx={{ p: 3 }}>
|
|
339
|
+
<Typography variant="h4" gutterBottom>
|
|
340
|
+
Dashboard
|
|
341
|
+
</Typography>
|
|
342
|
+
|
|
343
|
+
<Grid container spacing={3}>
|
|
344
|
+
<Grid item xs={12} sm={6} md={3}>
|
|
345
|
+
<StatCard title="Total Users" value="12,345" change={12.5} />
|
|
346
|
+
</Grid>
|
|
347
|
+
<Grid item xs={12} sm={6} md={3}>
|
|
348
|
+
<StatCard title="Revenue" value="$45,678" change={8.2} />
|
|
349
|
+
</Grid>
|
|
350
|
+
<Grid item xs={12} sm={6} md={3}>
|
|
351
|
+
<StatCard title="Active Sessions" value="1,234" change={-3.1} />
|
|
352
|
+
</Grid>
|
|
353
|
+
<Grid item xs={12} sm={6} md={3}>
|
|
354
|
+
<StatCard title="Conversion Rate" value="3.2%" change={0.8} />
|
|
355
|
+
</Grid>
|
|
356
|
+
</Grid>
|
|
357
|
+
</Box>
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### Dashboard with Charts
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
import { Grid, Paper, Typography, Box, Charts } from '@wso2/oxygen-ui';
|
|
366
|
+
|
|
367
|
+
function DashboardCharts() {
|
|
368
|
+
const salesData = [
|
|
369
|
+
{ month: 'Jan', sales: 4000, orders: 240 },
|
|
370
|
+
{ month: 'Feb', sales: 3000, orders: 139 },
|
|
371
|
+
{ month: 'Mar', sales: 2000, orders: 980 },
|
|
372
|
+
{ month: 'Apr', sales: 2780, orders: 390 },
|
|
373
|
+
{ month: 'May', sales: 1890, orders: 480 },
|
|
374
|
+
{ month: 'Jun', sales: 2390, orders: 380 },
|
|
375
|
+
];
|
|
376
|
+
|
|
377
|
+
return (
|
|
378
|
+
<Grid container spacing={3}>
|
|
379
|
+
<Grid item xs={12} md={8}>
|
|
380
|
+
<Paper sx={{ p: 3 }}>
|
|
381
|
+
<Typography variant="h6" gutterBottom>
|
|
382
|
+
Sales Overview
|
|
383
|
+
</Typography>
|
|
384
|
+
<Charts.LineChart
|
|
385
|
+
height={300}
|
|
386
|
+
series={[
|
|
387
|
+
{ data: salesData.map((d) => d.sales), label: 'Sales' },
|
|
388
|
+
{ data: salesData.map((d) => d.orders), label: 'Orders' },
|
|
389
|
+
]}
|
|
390
|
+
xAxis={[{ data: salesData.map((d) => d.month), scaleType: 'band' }]}
|
|
391
|
+
/>
|
|
392
|
+
</Paper>
|
|
393
|
+
</Grid>
|
|
394
|
+
|
|
395
|
+
<Grid item xs={12} md={4}>
|
|
396
|
+
<Paper sx={{ p: 3 }}>
|
|
397
|
+
<Typography variant="h6" gutterBottom>
|
|
398
|
+
Traffic Sources
|
|
399
|
+
</Typography>
|
|
400
|
+
<Charts.PieChart
|
|
401
|
+
height={300}
|
|
402
|
+
series={[
|
|
403
|
+
{
|
|
404
|
+
data: [
|
|
405
|
+
{ value: 45, label: 'Organic' },
|
|
406
|
+
{ value: 30, label: 'Direct' },
|
|
407
|
+
{ value: 15, label: 'Referral' },
|
|
408
|
+
{ value: 10, label: 'Social' },
|
|
409
|
+
],
|
|
410
|
+
},
|
|
411
|
+
]}
|
|
412
|
+
/>
|
|
413
|
+
</Paper>
|
|
414
|
+
</Grid>
|
|
415
|
+
</Grid>
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Data Tables
|
|
423
|
+
|
|
424
|
+
### Basic Data Table
|
|
425
|
+
|
|
426
|
+
```tsx
|
|
427
|
+
import { useState, useMemo } from 'react';
|
|
428
|
+
import { ListingTable, Button, IconButton, Chip } from '@wso2/oxygen-ui';
|
|
429
|
+
import { EditIcon, TrashIcon, MoreVerticalIcon } from '@wso2/oxygen-ui-icons-react';
|
|
430
|
+
|
|
431
|
+
interface User {
|
|
432
|
+
id: string;
|
|
433
|
+
name: string;
|
|
434
|
+
email: string;
|
|
435
|
+
role: string;
|
|
436
|
+
status: 'active' | 'inactive';
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function UsersTable({ users }: { users: User[] }) {
|
|
440
|
+
const [search, setSearch] = useState('');
|
|
441
|
+
const [sortField, setSortField] = useState('name');
|
|
442
|
+
const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc');
|
|
443
|
+
const [page, setPage] = useState(0);
|
|
444
|
+
const [rowsPerPage, setRowsPerPage] = useState(10);
|
|
445
|
+
|
|
446
|
+
const filteredData = useMemo(() => {
|
|
447
|
+
let result = [...users];
|
|
448
|
+
|
|
449
|
+
// Filter by search
|
|
450
|
+
if (search) {
|
|
451
|
+
result = result.filter(
|
|
452
|
+
(u) =>
|
|
453
|
+
u.name.toLowerCase().includes(search.toLowerCase()) ||
|
|
454
|
+
u.email.toLowerCase().includes(search.toLowerCase())
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Sort
|
|
459
|
+
result.sort((a, b) => {
|
|
460
|
+
const aVal = a[sortField as keyof User];
|
|
461
|
+
const bVal = b[sortField as keyof User];
|
|
462
|
+
const cmp = aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
|
|
463
|
+
return sortDirection === 'asc' ? cmp : -cmp;
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
return result;
|
|
467
|
+
}, [users, search, sortField, sortDirection]);
|
|
468
|
+
|
|
469
|
+
const paginatedData = filteredData.slice(
|
|
470
|
+
page * rowsPerPage,
|
|
471
|
+
page * rowsPerPage + rowsPerPage
|
|
472
|
+
);
|
|
473
|
+
|
|
474
|
+
return (
|
|
475
|
+
<ListingTable.Provider
|
|
476
|
+
searchValue={search}
|
|
477
|
+
onSearchChange={setSearch}
|
|
478
|
+
sortField={sortField}
|
|
479
|
+
sortDirection={sortDirection}
|
|
480
|
+
onSortChange={(field, dir) => {
|
|
481
|
+
setSortField(field);
|
|
482
|
+
setSortDirection(dir);
|
|
483
|
+
}}
|
|
484
|
+
page={page}
|
|
485
|
+
rowsPerPage={rowsPerPage}
|
|
486
|
+
totalCount={filteredData.length}
|
|
487
|
+
onPageChange={setPage}
|
|
488
|
+
onRowsPerPageChange={setRowsPerPage}
|
|
489
|
+
>
|
|
490
|
+
<ListingTable.Container>
|
|
491
|
+
<ListingTable.Toolbar
|
|
492
|
+
showSearch
|
|
493
|
+
searchPlaceholder="Search users..."
|
|
494
|
+
actions={
|
|
495
|
+
<Button variant="contained" size="small">
|
|
496
|
+
Add User
|
|
497
|
+
</Button>
|
|
498
|
+
}
|
|
499
|
+
/>
|
|
500
|
+
|
|
501
|
+
<ListingTable>
|
|
502
|
+
<ListingTable.Head>
|
|
503
|
+
<ListingTable.Row>
|
|
504
|
+
<ListingTable.Cell>
|
|
505
|
+
<ListingTable.SortLabel field="name">Name</ListingTable.SortLabel>
|
|
506
|
+
</ListingTable.Cell>
|
|
507
|
+
<ListingTable.Cell>
|
|
508
|
+
<ListingTable.SortLabel field="email">Email</ListingTable.SortLabel>
|
|
509
|
+
</ListingTable.Cell>
|
|
510
|
+
<ListingTable.Cell>Role</ListingTable.Cell>
|
|
511
|
+
<ListingTable.Cell>Status</ListingTable.Cell>
|
|
512
|
+
<ListingTable.Cell align="right">Actions</ListingTable.Cell>
|
|
513
|
+
</ListingTable.Row>
|
|
514
|
+
</ListingTable.Head>
|
|
515
|
+
|
|
516
|
+
<ListingTable.Body>
|
|
517
|
+
{paginatedData.length === 0 ? (
|
|
518
|
+
<ListingTable.Row>
|
|
519
|
+
<ListingTable.Cell colSpan={5}>
|
|
520
|
+
<ListingTable.EmptyState message="No users found" />
|
|
521
|
+
</ListingTable.Cell>
|
|
522
|
+
</ListingTable.Row>
|
|
523
|
+
) : (
|
|
524
|
+
paginatedData.map((user) => (
|
|
525
|
+
<ListingTable.Row key={user.id}>
|
|
526
|
+
<ListingTable.Cell>{user.name}</ListingTable.Cell>
|
|
527
|
+
<ListingTable.Cell>{user.email}</ListingTable.Cell>
|
|
528
|
+
<ListingTable.Cell>{user.role}</ListingTable.Cell>
|
|
529
|
+
<ListingTable.Cell>
|
|
530
|
+
<Chip
|
|
531
|
+
label={user.status}
|
|
532
|
+
color={user.status === 'active' ? 'success' : 'default'}
|
|
533
|
+
size="small"
|
|
534
|
+
/>
|
|
535
|
+
</ListingTable.Cell>
|
|
536
|
+
<ListingTable.Cell align="right">
|
|
537
|
+
<IconButton size="small">
|
|
538
|
+
<EditIcon size={18} />
|
|
539
|
+
</IconButton>
|
|
540
|
+
<IconButton size="small" color="error">
|
|
541
|
+
<TrashIcon size={18} />
|
|
542
|
+
</IconButton>
|
|
543
|
+
</ListingTable.Cell>
|
|
544
|
+
</ListingTable.Row>
|
|
545
|
+
))
|
|
546
|
+
)}
|
|
547
|
+
</ListingTable.Body>
|
|
548
|
+
|
|
549
|
+
<ListingTable.Footer />
|
|
550
|
+
</ListingTable>
|
|
551
|
+
</ListingTable.Container>
|
|
552
|
+
</ListingTable.Provider>
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
### Card Variant Table
|
|
558
|
+
|
|
559
|
+
```tsx
|
|
560
|
+
<ListingTable variant="card" density="comfortable">
|
|
561
|
+
<ListingTable.Head>
|
|
562
|
+
<ListingTable.Row>
|
|
563
|
+
<ListingTable.Cell>Project</ListingTable.Cell>
|
|
564
|
+
<ListingTable.Cell>Status</ListingTable.Cell>
|
|
565
|
+
<ListingTable.Cell>Last Updated</ListingTable.Cell>
|
|
566
|
+
<ListingTable.Cell align="right">Actions</ListingTable.Cell>
|
|
567
|
+
</ListingTable.Row>
|
|
568
|
+
</ListingTable.Head>
|
|
569
|
+
<ListingTable.Body>
|
|
570
|
+
{projects.map((project) => (
|
|
571
|
+
<ListingTable.Row key={project.id}>
|
|
572
|
+
<ListingTable.Cell>
|
|
573
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
|
|
574
|
+
<ListingTable.CellIcon>
|
|
575
|
+
<FolderIcon />
|
|
576
|
+
</ListingTable.CellIcon>
|
|
577
|
+
<Box>
|
|
578
|
+
<Typography fontWeight="medium">{project.name}</Typography>
|
|
579
|
+
<Typography variant="body2" color="text.secondary">
|
|
580
|
+
{project.description}
|
|
581
|
+
</Typography>
|
|
582
|
+
</Box>
|
|
583
|
+
</Box>
|
|
584
|
+
</ListingTable.Cell>
|
|
585
|
+
<ListingTable.Cell>
|
|
586
|
+
<Chip label={project.status} size="small" />
|
|
587
|
+
</ListingTable.Cell>
|
|
588
|
+
<ListingTable.Cell>{project.updatedAt}</ListingTable.Cell>
|
|
589
|
+
<ListingTable.Cell align="right">
|
|
590
|
+
<ListingTable.RowActions
|
|
591
|
+
actions={[
|
|
592
|
+
{ id: 'view', label: 'View', onClick: () => {} },
|
|
593
|
+
{ id: 'edit', label: 'Edit', onClick: () => {} },
|
|
594
|
+
{ id: 'delete', label: 'Delete', onClick: () => {}, color: 'error' },
|
|
595
|
+
]}
|
|
596
|
+
/>
|
|
597
|
+
</ListingTable.Cell>
|
|
598
|
+
</ListingTable.Row>
|
|
599
|
+
))}
|
|
600
|
+
</ListingTable.Body>
|
|
601
|
+
</ListingTable>
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
## Modal Dialogs
|
|
607
|
+
|
|
608
|
+
### Confirmation Dialog
|
|
609
|
+
|
|
610
|
+
```tsx
|
|
611
|
+
import {
|
|
612
|
+
Dialog,
|
|
613
|
+
DialogTitle,
|
|
614
|
+
DialogContent,
|
|
615
|
+
DialogContentText,
|
|
616
|
+
DialogActions,
|
|
617
|
+
Button,
|
|
618
|
+
} from '@wso2/oxygen-ui';
|
|
619
|
+
|
|
620
|
+
interface ConfirmDialogProps {
|
|
621
|
+
open: boolean;
|
|
622
|
+
title: string;
|
|
623
|
+
message: string;
|
|
624
|
+
confirmLabel?: string;
|
|
625
|
+
cancelLabel?: string;
|
|
626
|
+
onConfirm: () => void;
|
|
627
|
+
onCancel: () => void;
|
|
628
|
+
loading?: boolean;
|
|
629
|
+
destructive?: boolean;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
function ConfirmDialog({
|
|
633
|
+
open,
|
|
634
|
+
title,
|
|
635
|
+
message,
|
|
636
|
+
confirmLabel = 'Confirm',
|
|
637
|
+
cancelLabel = 'Cancel',
|
|
638
|
+
onConfirm,
|
|
639
|
+
onCancel,
|
|
640
|
+
loading = false,
|
|
641
|
+
destructive = false,
|
|
642
|
+
}: ConfirmDialogProps) {
|
|
643
|
+
return (
|
|
644
|
+
<Dialog open={open} onClose={onCancel} maxWidth="xs" fullWidth>
|
|
645
|
+
<DialogTitle>{title}</DialogTitle>
|
|
646
|
+
<DialogContent>
|
|
647
|
+
<DialogContentText>{message}</DialogContentText>
|
|
648
|
+
</DialogContent>
|
|
649
|
+
<DialogActions>
|
|
650
|
+
<Button onClick={onCancel} disabled={loading}>
|
|
651
|
+
{cancelLabel}
|
|
652
|
+
</Button>
|
|
653
|
+
<Button
|
|
654
|
+
onClick={onConfirm}
|
|
655
|
+
variant="contained"
|
|
656
|
+
color={destructive ? 'error' : 'primary'}
|
|
657
|
+
disabled={loading}
|
|
658
|
+
>
|
|
659
|
+
{loading ? 'Processing...' : confirmLabel}
|
|
660
|
+
</Button>
|
|
661
|
+
</DialogActions>
|
|
662
|
+
</Dialog>
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Usage
|
|
667
|
+
<ConfirmDialog
|
|
668
|
+
open={deleteDialogOpen}
|
|
669
|
+
title="Delete User"
|
|
670
|
+
message="Are you sure you want to delete this user? This action cannot be undone."
|
|
671
|
+
confirmLabel="Delete"
|
|
672
|
+
onConfirm={handleDelete}
|
|
673
|
+
onCancel={() => setDeleteDialogOpen(false)}
|
|
674
|
+
destructive
|
|
675
|
+
/>
|
|
676
|
+
```
|
|
677
|
+
|
|
678
|
+
### Form Dialog
|
|
679
|
+
|
|
680
|
+
```tsx
|
|
681
|
+
import {
|
|
682
|
+
Dialog,
|
|
683
|
+
DialogTitle,
|
|
684
|
+
DialogContent,
|
|
685
|
+
DialogActions,
|
|
686
|
+
Button,
|
|
687
|
+
TextField,
|
|
688
|
+
Box,
|
|
689
|
+
} from '@wso2/oxygen-ui';
|
|
690
|
+
|
|
691
|
+
function CreateUserDialog({ open, onClose, onSubmit }) {
|
|
692
|
+
const [name, setName] = useState('');
|
|
693
|
+
const [email, setEmail] = useState('');
|
|
694
|
+
|
|
695
|
+
const handleSubmit = () => {
|
|
696
|
+
onSubmit({ name, email });
|
|
697
|
+
onClose();
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
return (
|
|
701
|
+
<Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
|
|
702
|
+
<DialogTitle>Create User</DialogTitle>
|
|
703
|
+
<DialogContent>
|
|
704
|
+
<Box sx={{ pt: 1 }}>
|
|
705
|
+
<TextField
|
|
706
|
+
fullWidth
|
|
707
|
+
label="Name"
|
|
708
|
+
value={name}
|
|
709
|
+
onChange={(e) => setName(e.target.value)}
|
|
710
|
+
margin="normal"
|
|
711
|
+
required
|
|
712
|
+
/>
|
|
713
|
+
<TextField
|
|
714
|
+
fullWidth
|
|
715
|
+
label="Email"
|
|
716
|
+
type="email"
|
|
717
|
+
value={email}
|
|
718
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
719
|
+
margin="normal"
|
|
720
|
+
required
|
|
721
|
+
/>
|
|
722
|
+
</Box>
|
|
723
|
+
</DialogContent>
|
|
724
|
+
<DialogActions>
|
|
725
|
+
<Button onClick={onClose}>Cancel</Button>
|
|
726
|
+
<Button onClick={handleSubmit} variant="contained">
|
|
727
|
+
Create
|
|
728
|
+
</Button>
|
|
729
|
+
</DialogActions>
|
|
730
|
+
</Dialog>
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
---
|
|
736
|
+
|
|
737
|
+
## Error States
|
|
738
|
+
|
|
739
|
+
### 404 Page
|
|
740
|
+
|
|
741
|
+
```tsx
|
|
742
|
+
import { Box, Typography, Button } from '@wso2/oxygen-ui';
|
|
743
|
+
|
|
744
|
+
function NotFoundPage() {
|
|
745
|
+
return (
|
|
746
|
+
<Box
|
|
747
|
+
sx={{
|
|
748
|
+
minHeight: '60vh',
|
|
749
|
+
display: 'flex',
|
|
750
|
+
flexDirection: 'column',
|
|
751
|
+
alignItems: 'center',
|
|
752
|
+
justifyContent: 'center',
|
|
753
|
+
textAlign: 'center',
|
|
754
|
+
p: 3,
|
|
755
|
+
}}
|
|
756
|
+
>
|
|
757
|
+
<Typography variant="h1" sx={{ fontSize: '6rem', fontWeight: 'bold', color: 'text.secondary' }}>
|
|
758
|
+
404
|
|
759
|
+
</Typography>
|
|
760
|
+
<Typography variant="h5" gutterBottom>
|
|
761
|
+
Page not found
|
|
762
|
+
</Typography>
|
|
763
|
+
<Typography color="text.secondary" sx={{ mb: 4, maxWidth: 400 }}>
|
|
764
|
+
The page you're looking for doesn't exist or has been moved.
|
|
765
|
+
</Typography>
|
|
766
|
+
<Button variant="contained" href="/">
|
|
767
|
+
Go to Home
|
|
768
|
+
</Button>
|
|
769
|
+
</Box>
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### Error Boundary Fallback
|
|
775
|
+
|
|
776
|
+
```tsx
|
|
777
|
+
import { Box, Typography, Button, Paper } from '@wso2/oxygen-ui';
|
|
778
|
+
import { AlertTriangleIcon } from '@wso2/oxygen-ui-icons-react';
|
|
779
|
+
|
|
780
|
+
function ErrorFallback({ error, resetError }) {
|
|
781
|
+
return (
|
|
782
|
+
<Box
|
|
783
|
+
sx={{
|
|
784
|
+
minHeight: '60vh',
|
|
785
|
+
display: 'flex',
|
|
786
|
+
alignItems: 'center',
|
|
787
|
+
justifyContent: 'center',
|
|
788
|
+
p: 3,
|
|
789
|
+
}}
|
|
790
|
+
>
|
|
791
|
+
<Paper sx={{ p: 4, maxWidth: 500, textAlign: 'center' }}>
|
|
792
|
+
<AlertTriangleIcon size={48} color="error" />
|
|
793
|
+
<Typography variant="h5" sx={{ mt: 2 }} gutterBottom>
|
|
794
|
+
Something went wrong
|
|
795
|
+
</Typography>
|
|
796
|
+
<Typography color="text.secondary" sx={{ mb: 3 }}>
|
|
797
|
+
{error?.message || 'An unexpected error occurred'}
|
|
798
|
+
</Typography>
|
|
799
|
+
<Button variant="contained" onClick={resetError}>
|
|
800
|
+
Try Again
|
|
801
|
+
</Button>
|
|
802
|
+
</Paper>
|
|
803
|
+
</Box>
|
|
804
|
+
);
|
|
805
|
+
}
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
### Empty State
|
|
809
|
+
|
|
810
|
+
```tsx
|
|
811
|
+
import { Box, Typography, Button } from '@wso2/oxygen-ui';
|
|
812
|
+
import { InboxIcon } from '@wso2/oxygen-ui-icons-react';
|
|
813
|
+
|
|
814
|
+
function EmptyState({
|
|
815
|
+
icon = <InboxIcon size={48} />,
|
|
816
|
+
title,
|
|
817
|
+
description,
|
|
818
|
+
action,
|
|
819
|
+
actionLabel,
|
|
820
|
+
}) {
|
|
821
|
+
return (
|
|
822
|
+
<Box
|
|
823
|
+
sx={{
|
|
824
|
+
py: 8,
|
|
825
|
+
display: 'flex',
|
|
826
|
+
flexDirection: 'column',
|
|
827
|
+
alignItems: 'center',
|
|
828
|
+
textAlign: 'center',
|
|
829
|
+
}}
|
|
830
|
+
>
|
|
831
|
+
<Box sx={{ color: 'text.secondary', mb: 2 }}>{icon}</Box>
|
|
832
|
+
<Typography variant="h6" gutterBottom>
|
|
833
|
+
{title}
|
|
834
|
+
</Typography>
|
|
835
|
+
{description && (
|
|
836
|
+
<Typography color="text.secondary" sx={{ mb: 3, maxWidth: 400 }}>
|
|
837
|
+
{description}
|
|
838
|
+
</Typography>
|
|
839
|
+
)}
|
|
840
|
+
{action && actionLabel && (
|
|
841
|
+
<Button variant="contained" onClick={action}>
|
|
842
|
+
{actionLabel}
|
|
843
|
+
</Button>
|
|
844
|
+
)}
|
|
845
|
+
</Box>
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
// Usage
|
|
850
|
+
<EmptyState
|
|
851
|
+
title="No projects yet"
|
|
852
|
+
description="Create your first project to get started"
|
|
853
|
+
actionLabel="Create Project"
|
|
854
|
+
action={() => setCreateDialogOpen(true)}
|
|
855
|
+
/>
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
---
|
|
859
|
+
|
|
860
|
+
## Form Patterns
|
|
861
|
+
|
|
862
|
+
### Multi-Step Wizard
|
|
863
|
+
|
|
864
|
+
```tsx
|
|
865
|
+
import { useState } from 'react';
|
|
866
|
+
import {
|
|
867
|
+
Box,
|
|
868
|
+
Paper,
|
|
869
|
+
Stepper,
|
|
870
|
+
Step,
|
|
871
|
+
StepLabel,
|
|
872
|
+
Button,
|
|
873
|
+
Typography,
|
|
874
|
+
TextField,
|
|
875
|
+
} from '@wso2/oxygen-ui';
|
|
876
|
+
|
|
877
|
+
const steps = ['Account', 'Profile', 'Preferences'];
|
|
878
|
+
|
|
879
|
+
function RegistrationWizard() {
|
|
880
|
+
const [activeStep, setActiveStep] = useState(0);
|
|
881
|
+
const [formData, setFormData] = useState({
|
|
882
|
+
email: '',
|
|
883
|
+
password: '',
|
|
884
|
+
name: '',
|
|
885
|
+
company: '',
|
|
886
|
+
notifications: true,
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
const handleNext = () => {
|
|
890
|
+
setActiveStep((prev) => prev + 1);
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const handleBack = () => {
|
|
894
|
+
setActiveStep((prev) => prev - 1);
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
const handleSubmit = () => {
|
|
898
|
+
console.log('Form submitted:', formData);
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
const renderStepContent = (step: number) => {
|
|
902
|
+
switch (step) {
|
|
903
|
+
case 0:
|
|
904
|
+
return (
|
|
905
|
+
<>
|
|
906
|
+
<TextField
|
|
907
|
+
fullWidth
|
|
908
|
+
label="Email"
|
|
909
|
+
type="email"
|
|
910
|
+
value={formData.email}
|
|
911
|
+
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
|
|
912
|
+
margin="normal"
|
|
913
|
+
/>
|
|
914
|
+
<TextField
|
|
915
|
+
fullWidth
|
|
916
|
+
label="Password"
|
|
917
|
+
type="password"
|
|
918
|
+
value={formData.password}
|
|
919
|
+
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
|
920
|
+
margin="normal"
|
|
921
|
+
/>
|
|
922
|
+
</>
|
|
923
|
+
);
|
|
924
|
+
case 1:
|
|
925
|
+
return (
|
|
926
|
+
<>
|
|
927
|
+
<TextField
|
|
928
|
+
fullWidth
|
|
929
|
+
label="Full Name"
|
|
930
|
+
value={formData.name}
|
|
931
|
+
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
|
|
932
|
+
margin="normal"
|
|
933
|
+
/>
|
|
934
|
+
<TextField
|
|
935
|
+
fullWidth
|
|
936
|
+
label="Company"
|
|
937
|
+
value={formData.company}
|
|
938
|
+
onChange={(e) => setFormData({ ...formData, company: e.target.value })}
|
|
939
|
+
margin="normal"
|
|
940
|
+
/>
|
|
941
|
+
</>
|
|
942
|
+
);
|
|
943
|
+
case 2:
|
|
944
|
+
return (
|
|
945
|
+
<Typography>
|
|
946
|
+
Review your information and click Submit to complete registration.
|
|
947
|
+
</Typography>
|
|
948
|
+
);
|
|
949
|
+
default:
|
|
950
|
+
return null;
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
|
|
954
|
+
return (
|
|
955
|
+
<Paper sx={{ p: 4, maxWidth: 600, mx: 'auto' }}>
|
|
956
|
+
<Stepper activeStep={activeStep} sx={{ mb: 4 }}>
|
|
957
|
+
{steps.map((label) => (
|
|
958
|
+
<Step key={label}>
|
|
959
|
+
<StepLabel>{label}</StepLabel>
|
|
960
|
+
</Step>
|
|
961
|
+
))}
|
|
962
|
+
</Stepper>
|
|
963
|
+
|
|
964
|
+
<Box sx={{ minHeight: 200 }}>{renderStepContent(activeStep)}</Box>
|
|
965
|
+
|
|
966
|
+
<Box sx={{ display: 'flex', justifyContent: 'space-between', mt: 4 }}>
|
|
967
|
+
<Button disabled={activeStep === 0} onClick={handleBack}>
|
|
968
|
+
Back
|
|
969
|
+
</Button>
|
|
970
|
+
{activeStep === steps.length - 1 ? (
|
|
971
|
+
<Button variant="contained" onClick={handleSubmit}>
|
|
972
|
+
Submit
|
|
973
|
+
</Button>
|
|
974
|
+
) : (
|
|
975
|
+
<Button variant="contained" onClick={handleNext}>
|
|
976
|
+
Next
|
|
977
|
+
</Button>
|
|
978
|
+
)}
|
|
979
|
+
</Box>
|
|
980
|
+
</Paper>
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
```
|
|
984
|
+
|
|
985
|
+
### Form with Validation
|
|
986
|
+
|
|
987
|
+
```tsx
|
|
988
|
+
import { useState } from 'react';
|
|
989
|
+
import { Box, TextField, Button, Alert } from '@wso2/oxygen-ui';
|
|
990
|
+
|
|
991
|
+
interface FormErrors {
|
|
992
|
+
[key: string]: string;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
function ValidatedForm() {
|
|
996
|
+
const [email, setEmail] = useState('');
|
|
997
|
+
const [password, setPassword] = useState('');
|
|
998
|
+
const [errors, setErrors] = useState<FormErrors>({});
|
|
999
|
+
|
|
1000
|
+
const validate = (): boolean => {
|
|
1001
|
+
const newErrors: FormErrors = {};
|
|
1002
|
+
|
|
1003
|
+
if (!email) {
|
|
1004
|
+
newErrors.email = 'Email is required';
|
|
1005
|
+
} else if (!/\S+@\S+\.\S+/.test(email)) {
|
|
1006
|
+
newErrors.email = 'Invalid email format';
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
if (!password) {
|
|
1010
|
+
newErrors.password = 'Password is required';
|
|
1011
|
+
} else if (password.length < 8) {
|
|
1012
|
+
newErrors.password = 'Password must be at least 8 characters';
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
setErrors(newErrors);
|
|
1016
|
+
return Object.keys(newErrors).length === 0;
|
|
1017
|
+
};
|
|
1018
|
+
|
|
1019
|
+
const handleSubmit = (e: React.FormEvent) => {
|
|
1020
|
+
e.preventDefault();
|
|
1021
|
+
if (validate()) {
|
|
1022
|
+
// Submit form
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
return (
|
|
1027
|
+
<Box component="form" onSubmit={handleSubmit}>
|
|
1028
|
+
<TextField
|
|
1029
|
+
fullWidth
|
|
1030
|
+
label="Email"
|
|
1031
|
+
type="email"
|
|
1032
|
+
value={email}
|
|
1033
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
1034
|
+
error={!!errors.email}
|
|
1035
|
+
helperText={errors.email}
|
|
1036
|
+
margin="normal"
|
|
1037
|
+
/>
|
|
1038
|
+
|
|
1039
|
+
<TextField
|
|
1040
|
+
fullWidth
|
|
1041
|
+
label="Password"
|
|
1042
|
+
type="password"
|
|
1043
|
+
value={password}
|
|
1044
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
1045
|
+
error={!!errors.password}
|
|
1046
|
+
helperText={errors.password}
|
|
1047
|
+
margin="normal"
|
|
1048
|
+
/>
|
|
1049
|
+
|
|
1050
|
+
<Button type="submit" variant="contained" sx={{ mt: 2 }}>
|
|
1051
|
+
Submit
|
|
1052
|
+
</Button>
|
|
1053
|
+
</Box>
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
---
|
|
1059
|
+
|
|
1060
|
+
## Navigation Patterns
|
|
1061
|
+
|
|
1062
|
+
### Breadcrumbs
|
|
1063
|
+
|
|
1064
|
+
```tsx
|
|
1065
|
+
import { Breadcrumbs, Link, Typography } from '@wso2/oxygen-ui';
|
|
1066
|
+
import { ChevronRightIcon } from '@wso2/oxygen-ui-icons-react';
|
|
1067
|
+
|
|
1068
|
+
function PageBreadcrumbs({ items }: { items: { label: string; href?: string }[] }) {
|
|
1069
|
+
return (
|
|
1070
|
+
<Breadcrumbs
|
|
1071
|
+
separator={<ChevronRightIcon size={16} />}
|
|
1072
|
+
sx={{ mb: 2 }}
|
|
1073
|
+
>
|
|
1074
|
+
{items.map((item, index) => {
|
|
1075
|
+
const isLast = index === items.length - 1;
|
|
1076
|
+
return isLast ? (
|
|
1077
|
+
<Typography key={item.label} color="text.primary">
|
|
1078
|
+
{item.label}
|
|
1079
|
+
</Typography>
|
|
1080
|
+
) : (
|
|
1081
|
+
<Link key={item.label} href={item.href} color="inherit" underline="hover">
|
|
1082
|
+
{item.label}
|
|
1083
|
+
</Link>
|
|
1084
|
+
);
|
|
1085
|
+
})}
|
|
1086
|
+
</Breadcrumbs>
|
|
1087
|
+
);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
// Usage
|
|
1091
|
+
<PageBreadcrumbs
|
|
1092
|
+
items={[
|
|
1093
|
+
{ label: 'Home', href: '/' },
|
|
1094
|
+
{ label: 'Users', href: '/users' },
|
|
1095
|
+
{ label: 'John Doe' },
|
|
1096
|
+
]}
|
|
1097
|
+
/>
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
### Tab Navigation
|
|
1101
|
+
|
|
1102
|
+
```tsx
|
|
1103
|
+
import { useState } from 'react';
|
|
1104
|
+
import { Tabs, Tab, Box } from '@wso2/oxygen-ui';
|
|
1105
|
+
|
|
1106
|
+
function TabNavigation() {
|
|
1107
|
+
const [value, setValue] = useState(0);
|
|
1108
|
+
|
|
1109
|
+
return (
|
|
1110
|
+
<Box>
|
|
1111
|
+
<Tabs value={value} onChange={(_, newValue) => setValue(newValue)}>
|
|
1112
|
+
<Tab label="Overview" />
|
|
1113
|
+
<Tab label="Settings" />
|
|
1114
|
+
<Tab label="Members" />
|
|
1115
|
+
</Tabs>
|
|
1116
|
+
|
|
1117
|
+
<Box sx={{ p: 3 }}>
|
|
1118
|
+
{value === 0 && <div>Overview content</div>}
|
|
1119
|
+
{value === 1 && <div>Settings content</div>}
|
|
1120
|
+
{value === 2 && <div>Members content</div>}
|
|
1121
|
+
</Box>
|
|
1122
|
+
</Box>
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
---
|
|
1128
|
+
|
|
1129
|
+
## Theme Switching
|
|
1130
|
+
|
|
1131
|
+
### Complete Theme Switcher Setup
|
|
1132
|
+
|
|
1133
|
+
```tsx
|
|
1134
|
+
import {
|
|
1135
|
+
OxygenUIThemeProvider,
|
|
1136
|
+
OxygenTheme,
|
|
1137
|
+
AcrylicOrangeTheme,
|
|
1138
|
+
AcrylicPurpleTheme,
|
|
1139
|
+
ClassicTheme,
|
|
1140
|
+
HighContrastTheme,
|
|
1141
|
+
useThemeSwitcher,
|
|
1142
|
+
Select,
|
|
1143
|
+
MenuItem,
|
|
1144
|
+
} from '@wso2/oxygen-ui';
|
|
1145
|
+
|
|
1146
|
+
const themes = [
|
|
1147
|
+
{ key: 'default', label: 'Default', theme: OxygenTheme },
|
|
1148
|
+
{ key: 'orange', label: 'Acrylic Orange', theme: AcrylicOrangeTheme },
|
|
1149
|
+
{ key: 'purple', label: 'Acrylic Purple', theme: AcrylicPurpleTheme },
|
|
1150
|
+
{ key: 'classic', label: 'Classic', theme: ClassicTheme },
|
|
1151
|
+
{ key: 'highContrast', label: 'High Contrast', theme: HighContrastTheme },
|
|
1152
|
+
];
|
|
1153
|
+
|
|
1154
|
+
function ThemeSelector() {
|
|
1155
|
+
const { currentTheme, themes, setTheme } = useThemeSwitcher();
|
|
1156
|
+
|
|
1157
|
+
return (
|
|
1158
|
+
<Select
|
|
1159
|
+
value={currentTheme}
|
|
1160
|
+
onChange={(e) => setTheme(e.target.value as string)}
|
|
1161
|
+
size="small"
|
|
1162
|
+
>
|
|
1163
|
+
{themes.map((t) => (
|
|
1164
|
+
<MenuItem key={t.key} value={t.key}>
|
|
1165
|
+
{t.label}
|
|
1166
|
+
</MenuItem>
|
|
1167
|
+
))}
|
|
1168
|
+
</Select>
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
function App() {
|
|
1173
|
+
return (
|
|
1174
|
+
<OxygenUIThemeProvider themes={themes} initialTheme="default">
|
|
1175
|
+
<Header>
|
|
1176
|
+
<Header.Actions>
|
|
1177
|
+
<ThemeSelector />
|
|
1178
|
+
<ColorSchemeToggle />
|
|
1179
|
+
</Header.Actions>
|
|
1180
|
+
</Header>
|
|
1181
|
+
{/* Rest of app */}
|
|
1182
|
+
</OxygenUIThemeProvider>
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
```
|