@wso2/oxygen-ui 0.0.1-alpha.1 → 0.0.1-alpha.11

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.
Files changed (29) hide show
  1. package/README.md +134 -2
  2. package/dist/components/ComplexSelect/ComplexSelect.d.ts +17 -0
  3. package/dist/components/ComplexSelect/ComplexSelectDivider.d.ts +5 -0
  4. package/dist/components/ComplexSelect/ComplexSelectListHeader.d.ts +7 -0
  5. package/dist/components/ComplexSelect/ComplexSelectMenuItem.d.ts +16 -0
  6. package/dist/components/ComplexSelect/ComplexSelectMenuItemAvatar.d.ts +7 -0
  7. package/dist/components/ComplexSelect/ComplexSelectMenuItemIcon.d.ts +7 -0
  8. package/dist/components/ComplexSelect/ComplexSelectMenuItemText.d.ts +8 -0
  9. package/dist/components/ComplexSelect/index.d.ts +21 -0
  10. package/dist/components/ThemeSwitcher/ThemeSelect.d.ts +37 -0
  11. package/dist/components/ThemeSwitcher/ThemeSwitcher.d.ts +65 -0
  12. package/dist/components/ThemeSwitcher/index.d.ts +4 -0
  13. package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.d.ts +61 -3
  14. package/dist/index.d.ts +7 -1
  15. package/dist/index.js +520 -53
  16. package/dist/index.js.map +4 -4
  17. package/dist/styles/OxygenTheme/OxygenTheme.d.ts +1 -1
  18. package/dist/styles/OxygenTheme/OxygenThemeWithRadialBackground.d.ts +17 -0
  19. package/dist/utils/index.d.ts +18 -0
  20. package/dist/utils/pxToRem.d.ts +23 -0
  21. package/package.json +30 -29
  22. package/dist/components/ColorSchemeImage/ColorSchemeImage.js +0 -57
  23. package/dist/components/ColorSchemeImage/ColorSchemeImage.js.map +0 -7
  24. package/dist/components/ColorSchemeToggle/ColorSchemeToggle.js +0 -76
  25. package/dist/components/ColorSchemeToggle/ColorSchemeToggle.js.map +0 -7
  26. package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.js +0 -227
  27. package/dist/contexts/OxygenUIThemeProvider/OxygenUIThemeProvider.js.map +0 -7
  28. package/dist/styles/OxygenTheme/OxygenTheme.js +0 -214
  29. package/dist/styles/OxygenTheme/OxygenTheme.js.map +0 -7
package/README.md CHANGED
@@ -181,15 +181,147 @@ function MyTreeView() {
181
181
  }
182
182
  ```
183
183
 
184
+ ## Theme Switching
185
+
186
+ Oxygen UI provides built-in theme switching capabilities through `OxygenUIThemeProvider` and UI components for easy theme selection.
187
+
188
+ ### Basic Setup
189
+
190
+ Pass a `themes` array to `OxygenUIThemeProvider`:
191
+
192
+ ```typescript
193
+ import {
194
+ OxygenUIThemeProvider,
195
+ OxygenTheme,
196
+ OxygenThemeWithRadialBackground
197
+ } from '@wso2/oxygen-ui';
198
+
199
+ function App() {
200
+ return (
201
+ <OxygenUIThemeProvider
202
+ themes={[
203
+ { key: 'default', label: 'Default', theme: OxygenTheme },
204
+ { key: 'radial', label: 'Radial Background', theme: OxygenThemeWithRadialBackground },
205
+ ]}
206
+ initialTheme="default"
207
+ >
208
+ <YourApp />
209
+ </OxygenUIThemeProvider>
210
+ );
211
+ }
212
+ ```
213
+
214
+ ### Using ThemeSwitcher Component
215
+
216
+ Add the `ThemeSwitcher` component to provide a select dropdown:
217
+
218
+ ```typescript
219
+ import {
220
+ OxygenUIThemeProvider,
221
+ ThemeSwitcher,
222
+ OxygenTheme,
223
+ OxygenThemeWithRadialBackground
224
+ } from '@wso2/oxygen-ui';
225
+
226
+ function App() {
227
+ return (
228
+ <OxygenUIThemeProvider
229
+ themes={[
230
+ { key: 'default', label: 'Default', theme: OxygenTheme },
231
+ { key: 'radial', label: 'Radial Background', theme: OxygenThemeWithRadialBackground },
232
+ ]}
233
+ >
234
+ <header>
235
+ <ThemeSwitcher /> {/* Default select dropdown */}
236
+ </header>
237
+ <YourApp />
238
+ </OxygenUIThemeProvider>
239
+ );
240
+ }
241
+ ```
242
+
243
+ ### Custom Theme Switcher UI
244
+
245
+ Use render props for custom UI:
246
+
247
+ ```typescript
248
+ <ThemeSwitcher>
249
+ {({ currentTheme, themes, setTheme, isActive }) => (
250
+ <ButtonGroup>
251
+ {themes.map(theme => (
252
+ <Button
253
+ key={theme.key}
254
+ variant={isActive(theme.key) ? 'contained' : 'outlined'}
255
+ onClick={() => setTheme(theme.key)}
256
+ >
257
+ {theme.label}
258
+ </Button>
259
+ ))}
260
+ </ButtonGroup>
261
+ )}
262
+ </ThemeSwitcher>
263
+ ```
264
+
265
+ ### Custom Themes
266
+
267
+ Add your own custom themes:
268
+
269
+ ```typescript
270
+ import { extendTheme } from '@mui/material/styles';
271
+
272
+ const customTheme = extendTheme({
273
+ palette: {
274
+ primary: { main: '#ff0000' },
275
+ },
276
+ });
277
+
278
+ function App() {
279
+ return (
280
+ <OxygenUIThemeProvider
281
+ themes={[
282
+ { key: 'default', label: 'Default', theme: OxygenTheme },
283
+ { key: 'custom', label: 'Custom Theme', theme: customTheme },
284
+ ]}
285
+ >
286
+ <ThemeSwitcher showLabel label="Select Theme" />
287
+ <YourApp />
288
+ </OxygenUIThemeProvider>
289
+ );
290
+ }
291
+ ```
292
+
293
+ ### Programmatic Access
294
+
295
+ Use the `useThemeSwitcher` hook to access theme state:
296
+
297
+ ```typescript
298
+ import { useThemeSwitcher } from '@wso2/oxygen-ui';
299
+
300
+ function MyComponent() {
301
+ const { currentTheme, themes, setTheme, isActive } = useThemeSwitcher();
302
+
303
+ return (
304
+ <div>
305
+ <p>Current theme: {currentTheme}</p>
306
+ <button onClick={() => setTheme('radial')}>Switch to Radial</button>
307
+ </div>
308
+ );
309
+ }
310
+ ```
311
+
184
312
  ## Available Exports
185
313
 
186
314
  ### Custom Oxygen UI Components
187
315
 
188
- - `OxygenTheme` - Theme configuration
189
- - `OxygenUIThemeProvider` - Theme provider component
316
+ - `OxygenTheme` - Default theme configuration
317
+ - `OxygenThemeWithRadialBackground` - Theme variant with radial gradient backgrounds
318
+ - `OxygenUIThemeProvider` - Theme provider component with theme switching support
319
+ - `ThemeSwitcher` - Theme selection component (default select dropdown or render props)
320
+ - `ThemeSelect` - Standalone theme select dropdown component
190
321
  - `ColorSchemeImage` - Image component that adapts to color scheme
191
322
  - `ColorSchemeToggle` - Toggle for light/dark mode
192
323
  - `Layout` - Layout components
324
+ - `useThemeSwitcher` - Hook to access theme switcher context
193
325
 
194
326
  ### Material-UI Components
195
327
 
@@ -0,0 +1,17 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ import { SelectProps } from '@mui/material/Select';
3
+ import ComplexSelectListHeader from './ComplexSelectListHeader';
4
+ import ComplexSelectMenuItem from './ComplexSelectMenuItem';
5
+ import ComplexSelectDivider from './ComplexSelectDivider';
6
+ export interface ComplexSelectProps extends Omit<SelectProps, 'children'> {
7
+ children: ReactNode;
8
+ }
9
+ export declare function ComplexSelect({ children, sx, label, labelId, ...props }: ComplexSelectProps): import("react/jsx-runtime").JSX.Element;
10
+ interface ComplexSelectComponent {
11
+ (props: ComplexSelectProps): ReactElement;
12
+ ListHeader: typeof ComplexSelectListHeader;
13
+ MenuItem: typeof ComplexSelectMenuItem;
14
+ Divider: typeof ComplexSelectDivider;
15
+ }
16
+ declare const ComplexSelectCompound: ComplexSelectComponent;
17
+ export default ComplexSelectCompound;
@@ -0,0 +1,5 @@
1
+ import { DividerProps } from '@mui/material/Divider';
2
+ export interface ComplexSelectDividerProps extends DividerProps {
3
+ }
4
+ export declare function ComplexSelectDivider({ sx, ...props }: ComplexSelectDividerProps): import("react/jsx-runtime").JSX.Element;
5
+ export default ComplexSelectDivider;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ import { ListSubheaderProps } from '@mui/material/ListSubheader';
3
+ export interface ComplexSelectListHeaderProps extends ListSubheaderProps {
4
+ children: ReactNode;
5
+ }
6
+ export declare function ComplexSelectListHeader({ children, sx, ...props }: ComplexSelectListHeaderProps): import("react/jsx-runtime").JSX.Element;
7
+ export default ComplexSelectListHeader;
@@ -0,0 +1,16 @@
1
+ import { ReactNode, ReactElement } from 'react';
2
+ import { MenuItemProps } from '@mui/material/MenuItem';
3
+ import ComplexSelectMenuItemAvatar from './ComplexSelectMenuItemAvatar';
4
+ import ComplexSelectMenuItemText from './ComplexSelectMenuItemText';
5
+ import ComplexSelectMenuItemIcon from './ComplexSelectMenuItemIcon';
6
+ export interface ComplexSelectMenuItemProps extends MenuItemProps {
7
+ children: ReactNode;
8
+ }
9
+ interface ComplexSelectMenuItemComponent {
10
+ (props: ComplexSelectMenuItemProps): ReactElement;
11
+ Avatar: typeof ComplexSelectMenuItemAvatar;
12
+ Text: typeof ComplexSelectMenuItemText;
13
+ Icon: typeof ComplexSelectMenuItemIcon;
14
+ }
15
+ export declare const ComplexSelectMenuItem: ComplexSelectMenuItemComponent;
16
+ export default ComplexSelectMenuItem;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ import { AvatarProps } from '@mui/material/Avatar';
3
+ export interface ComplexSelectMenuItemAvatarProps extends AvatarProps {
4
+ children?: ReactNode;
5
+ }
6
+ export declare function ComplexSelectMenuItemAvatar({ children, ...props }: ComplexSelectMenuItemAvatarProps): import("react/jsx-runtime").JSX.Element;
7
+ export default ComplexSelectMenuItemAvatar;
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ import { ListItemIconProps } from '@mui/material/ListItemIcon';
3
+ export interface ComplexSelectMenuItemIconProps extends ListItemIconProps {
4
+ children: ReactNode;
5
+ }
6
+ export declare function ComplexSelectMenuItemIcon({ children, ...props }: ComplexSelectMenuItemIconProps): import("react/jsx-runtime").JSX.Element;
7
+ export default ComplexSelectMenuItemIcon;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from 'react';
2
+ import { ListItemTextProps } from '@mui/material/ListItemText';
3
+ export interface ComplexSelectMenuItemTextProps extends ListItemTextProps {
4
+ primary: ReactNode;
5
+ secondary?: ReactNode;
6
+ }
7
+ export declare function ComplexSelectMenuItemText({ primary, secondary, ...props }: ComplexSelectMenuItemTextProps): import("react/jsx-runtime").JSX.Element;
8
+ export default ComplexSelectMenuItemText;
@@ -0,0 +1,21 @@
1
+ export { default } from './ComplexSelect';
2
+ export { ComplexSelect } from './ComplexSelect';
3
+ export type { ComplexSelectProps } from './ComplexSelect';
4
+ export { default as ComplexSelectListHeader } from './ComplexSelectListHeader';
5
+ export { ComplexSelectListHeader as ListHeader } from './ComplexSelectListHeader';
6
+ export type { ComplexSelectListHeaderProps } from './ComplexSelectListHeader';
7
+ export { default as ComplexSelectMenuItem } from './ComplexSelectMenuItem';
8
+ export { ComplexSelectMenuItem as MenuItem } from './ComplexSelectMenuItem';
9
+ export type { ComplexSelectMenuItemProps } from './ComplexSelectMenuItem';
10
+ export { default as ComplexSelectMenuItemAvatar } from './ComplexSelectMenuItemAvatar';
11
+ export { ComplexSelectMenuItemAvatar as MenuItemAvatar } from './ComplexSelectMenuItemAvatar';
12
+ export type { ComplexSelectMenuItemAvatarProps } from './ComplexSelectMenuItemAvatar';
13
+ export { default as ComplexSelectMenuItemText } from './ComplexSelectMenuItemText';
14
+ export { ComplexSelectMenuItemText as MenuItemText } from './ComplexSelectMenuItemText';
15
+ export type { ComplexSelectMenuItemTextProps } from './ComplexSelectMenuItemText';
16
+ export { default as ComplexSelectMenuItemIcon } from './ComplexSelectMenuItemIcon';
17
+ export { ComplexSelectMenuItemIcon as MenuItemIcon } from './ComplexSelectMenuItemIcon';
18
+ export type { ComplexSelectMenuItemIconProps } from './ComplexSelectMenuItemIcon';
19
+ export { default as ComplexSelectDivider } from './ComplexSelectDivider';
20
+ export { ComplexSelectDivider as Divider } from './ComplexSelectDivider';
21
+ export type { ComplexSelectDividerProps } from './ComplexSelectDivider';
@@ -0,0 +1,37 @@
1
+ export interface ThemeSelectProps {
2
+ /**
3
+ * Size of the select component
4
+ */
5
+ size?: 'small' | 'medium';
6
+ /**
7
+ * Show label for the select
8
+ */
9
+ showLabel?: boolean;
10
+ /**
11
+ * Custom label text
12
+ */
13
+ label?: string;
14
+ /**
15
+ * Variant of the select component
16
+ */
17
+ variant?: 'outlined' | 'filled' | 'standard';
18
+ /**
19
+ * Additional sx prop for styling
20
+ */
21
+ sx?: object;
22
+ }
23
+ /**
24
+ * ThemeSelect - A select box component for theme switching
25
+ *
26
+ * Must be used within OxygenUIThemeProvider with themes prop.
27
+ * Provides a dropdown select interface for switching between available themes.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * <OxygenUIThemeProvider themes={myThemes}>
32
+ * <ThemeSelect />
33
+ * <App />
34
+ * </OxygenUIThemeProvider>
35
+ * ```
36
+ */
37
+ export default function ThemeSelect({ size, showLabel, label, variant, sx, }: ThemeSelectProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,65 @@
1
+ import { ReactNode } from 'react';
2
+ import { type ThemeSwitcherContextValue } from '../../contexts/OxygenUIThemeProvider/OxygenUIThemeProvider';
3
+ export interface ThemeSwitcherProps {
4
+ /**
5
+ * Optional render props function for custom UI.
6
+ * If not provided, renders the default ThemeSelect component.
7
+ */
8
+ children?: (props: ThemeSwitcherContextValue) => ReactNode;
9
+ /**
10
+ * Size of the default select component (when not using render props)
11
+ */
12
+ size?: 'small' | 'medium';
13
+ /**
14
+ * Show label for the default select (when not using render props)
15
+ */
16
+ showLabel?: boolean;
17
+ /**
18
+ * Custom label text for the default select (when not using render props)
19
+ */
20
+ label?: string;
21
+ /**
22
+ * Variant of the default select (when not using render props)
23
+ */
24
+ variant?: 'outlined' | 'filled' | 'standard';
25
+ /**
26
+ * Additional sx prop for styling the default select (when not using render props)
27
+ */
28
+ sx?: object;
29
+ }
30
+ /**
31
+ * ThemeSwitcher - UI component for theme switching
32
+ *
33
+ * Must be used within OxygenUIThemeProvider with themes prop.
34
+ *
35
+ * Default Usage (renders a select dropdown):
36
+ * ```tsx
37
+ * <OxygenUIThemeProvider themes={myThemes}>
38
+ * <ThemeSwitcher />
39
+ * <App />
40
+ * </OxygenUIThemeProvider>
41
+ * ```
42
+ *
43
+ * Custom UI with Render Props:
44
+ * ```tsx
45
+ * <OxygenUIThemeProvider themes={myThemes}>
46
+ * <ThemeSwitcher>
47
+ * {({ currentTheme, themes, setTheme, isActive }) => (
48
+ * <div>
49
+ * {themes.map(t => (
50
+ * <button
51
+ * key={t.key}
52
+ * onClick={() => setTheme(t.key)}
53
+ * style={{ fontWeight: isActive(t.key) ? 'bold' : 'normal' }}
54
+ * >
55
+ * {t.label}
56
+ * </button>
57
+ * ))}
58
+ * </div>
59
+ * )}
60
+ * </ThemeSwitcher>
61
+ * <App />
62
+ * </OxygenUIThemeProvider>
63
+ * ```
64
+ */
65
+ export default function ThemeSwitcher({ children, size, showLabel, label, variant, sx, }: ThemeSwitcherProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export { default } from './ThemeSwitcher';
2
+ export { default as ThemeSelect } from './ThemeSelect';
3
+ export type { ThemeSwitcherProps } from './ThemeSwitcher';
4
+ export type { ThemeSelectProps } from './ThemeSelect';
@@ -1,5 +1,63 @@
1
1
  import { Theme } from '@mui/material/styles';
2
- export default function OxygenUIThemeProvider({ children, theme }: {
3
- children: React.ReactNode;
2
+ import { ReactNode } from 'react';
3
+ export interface ThemeOption {
4
+ /**
5
+ * Unique key for the theme
6
+ */
7
+ key: string;
8
+ /**
9
+ * Display label for the theme
10
+ */
11
+ label: string;
12
+ /**
13
+ * The theme object
14
+ */
15
+ theme: Theme;
16
+ }
17
+ export interface ThemeSwitcherContextValue {
18
+ /**
19
+ * The current active theme object
20
+ */
21
+ theme: Theme;
22
+ /**
23
+ * The current theme key
24
+ */
25
+ currentTheme: string;
26
+ /**
27
+ * All available theme options
28
+ */
29
+ themes: ThemeOption[];
30
+ /**
31
+ * Function to switch to a specific theme by key
32
+ */
33
+ setTheme: (themeKey: string) => void;
34
+ /**
35
+ * Check if a specific theme is active
36
+ */
37
+ isActive: (themeKey: string) => boolean;
38
+ }
39
+ /**
40
+ * Hook to access theme switcher context
41
+ */
42
+ export declare const useThemeSwitcher: () => ThemeSwitcherContextValue;
43
+ interface OxygenUIThemeProviderProps {
44
+ children: ReactNode;
45
+ /**
46
+ * Optional single theme object. If provided, theme switching will be disabled.
47
+ * Use this for simple single-theme applications.
48
+ */
4
49
  theme?: Theme;
5
- }): import("react/jsx-runtime").JSX.Element;
50
+ /**
51
+ * Array of theme options for theme switching.
52
+ * If provided, enables theme switching functionality.
53
+ * Takes precedence over the `theme` prop.
54
+ */
55
+ themes?: ThemeOption[];
56
+ /**
57
+ * Initial theme key when using theme switching.
58
+ * Defaults to the first theme in the themes array.
59
+ */
60
+ initialTheme?: string;
61
+ }
62
+ export default function OxygenUIThemeProvider({ children, theme, themes, initialTheme, }: OxygenUIThemeProviderProps): import("react/jsx-runtime").JSX.Element;
63
+ export {};
package/dist/index.d.ts CHANGED
@@ -17,9 +17,15 @@
17
17
  */
18
18
  import './fonts.css';
19
19
  export { default as OxygenTheme } from "./styles/OxygenTheme/OxygenTheme";
20
- export { default as OxygenUIThemeProvider } from "./contexts/OxygenUIThemeProvider/OxygenUIThemeProvider";
20
+ export { default as OxygenThemeWithRadialBackground } from "./styles/OxygenTheme/OxygenThemeWithRadialBackground";
21
+ export { default as OxygenUIThemeProvider, useThemeSwitcher } from "./contexts/OxygenUIThemeProvider/OxygenUIThemeProvider";
22
+ export type { ThemeOption, ThemeSwitcherContextValue } from "./contexts/OxygenUIThemeProvider/OxygenUIThemeProvider";
21
23
  export { default as ColorSchemeImage } from "./components/ColorSchemeImage/ColorSchemeImage";
22
24
  export { default as ColorSchemeToggle } from "./components/ColorSchemeToggle/ColorSchemeToggle";
25
+ export { default as ComplexSelect } from "./components/ComplexSelect";
26
+ export type { ComplexSelectProps } from "./components/ComplexSelect";
27
+ export { default as ThemeSwitcher, ThemeSelect } from "./components/ThemeSwitcher";
28
+ export type { ThemeSwitcherProps, ThemeSelectProps } from "./components/ThemeSwitcher";
23
29
  export { default as Layout } from "./layouts";
24
30
  export * from '@mui/material';
25
31
  export * as Charts from '@mui/x-charts';