@wso2/oxygen-ui 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppShell/AppShell.d.ts +8 -6
- package/dist/components/AppShell/context.d.ts +64 -0
- package/dist/components/AppShell/index.d.ts +1 -0
- package/dist/components/Header/HeaderToggle.d.ts +4 -4
- package/dist/components/ListingTable/ListingTable/ListingTable.d.ts +2 -0
- package/dist/components/ListingTable/ListingTable/ListingTableDataGrid.d.ts +47 -0
- package/dist/components/ListingTable/ListingTable/index.d.ts +3 -0
- package/dist/components/ListingTable/index.d.ts +1 -0
- package/dist/components/ListingTable/shared/types.d.ts +1 -1
- package/dist/components/NotificationPanel/NotificationPanel.d.ts +4 -4
- package/dist/components/Sidebar/SidebarItem.d.ts +10 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/hooks/useAppShell/useAppShell.d.ts +43 -8
- package/dist/index.js +691 -407
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
|
@@ -22,10 +22,11 @@ import { AppShellSidebar } from './AppShellSidebar';
|
|
|
22
22
|
import { AppShellMain } from './AppShellMain';
|
|
23
23
|
import { AppShellFooter } from './AppShellFooter';
|
|
24
24
|
import { AppShellNotificationPanel } from './AppShellNotificationPanel';
|
|
25
|
+
import { type UseAppShellOptions } from '../../hooks/useAppShell';
|
|
25
26
|
/**
|
|
26
27
|
* Props for AppShell component.
|
|
27
28
|
*/
|
|
28
|
-
export interface AppShellProps {
|
|
29
|
+
export interface AppShellProps extends UseAppShellOptions {
|
|
29
30
|
/** AppShell slot components (Navbar, Sidebar, Main, Footer, NotificationPanel) */
|
|
30
31
|
children: React.ReactNode;
|
|
31
32
|
/** Additional sx props for the root container */
|
|
@@ -37,9 +38,13 @@ export interface AppShellProps {
|
|
|
37
38
|
* Uses a compound component pattern where children define the layout slots.
|
|
38
39
|
* This reduces boilerplate compared to manually composing Layout components.
|
|
39
40
|
*
|
|
41
|
+
* AppShell automatically provides shell state management through context.
|
|
42
|
+
* Child components can use the `useAppShell()` hook to access and control
|
|
43
|
+
* the shell state (sidebar collapse, notification panel, active menu items).
|
|
44
|
+
*
|
|
40
45
|
* @example
|
|
41
46
|
* ```tsx
|
|
42
|
-
* <AppShell>
|
|
47
|
+
* <AppShell initialCollapsed={false} collapseOnSelectOnMobile={true}>
|
|
43
48
|
* <AppShell.Navbar>
|
|
44
49
|
* <Header>...</Header>
|
|
45
50
|
* </AppShell.Navbar>
|
|
@@ -47,14 +52,11 @@ export interface AppShellProps {
|
|
|
47
52
|
* <Sidebar collapsed={collapsed}>...</Sidebar>
|
|
48
53
|
* </AppShell.Sidebar>
|
|
49
54
|
* <AppShell.Main>
|
|
50
|
-
* <
|
|
55
|
+
* <MyPage /> {/* Can use useAppShell()
|
|
51
56
|
* </AppShell.Main>
|
|
52
57
|
* <AppShell.Footer>
|
|
53
58
|
* <Footer companyName="WSO2 LLC" />
|
|
54
59
|
* </AppShell.Footer>
|
|
55
|
-
* <AppShell.NotificationPanel>
|
|
56
|
-
* <NotificationPanel open={open} onClose={onClose}>...</NotificationPanel>
|
|
57
|
-
* </AppShell.NotificationPanel>
|
|
58
60
|
* </AppShell>
|
|
59
61
|
* ```
|
|
60
62
|
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
+
*
|
|
4
|
+
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
+
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
+
* in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing,
|
|
12
|
+
* software distributed under the License is distributed on an
|
|
13
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
+
* KIND, either express or implied. See the License for the
|
|
15
|
+
* specific language governing permissions and limitations
|
|
16
|
+
* under the License.
|
|
17
|
+
*/
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import type { UseAppShellReturn } from '../../hooks/useAppShell/useAppShell';
|
|
20
|
+
/**
|
|
21
|
+
* Context for sharing AppShell state across components.
|
|
22
|
+
* Allows child components to access the same shell state without prop drilling.
|
|
23
|
+
*/
|
|
24
|
+
export declare const AppShellContext: React.Context<UseAppShellReturn | undefined>;
|
|
25
|
+
/**
|
|
26
|
+
* Provider component for AppShell context.
|
|
27
|
+
* Wrap your app shell with this to share state with child components.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* function AppLayout() {
|
|
32
|
+
* const shell = useAppShell({ initialCollapsed: false });
|
|
33
|
+
*
|
|
34
|
+
* return (
|
|
35
|
+
* <AppShellProvider value={shell}>
|
|
36
|
+
* <AppShell>
|
|
37
|
+
* <Sidebar collapsed={shell.state.sidebarCollapsed} />
|
|
38
|
+
* <Outlet />
|
|
39
|
+
* </AppShell>
|
|
40
|
+
* </AppShellProvider>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare const AppShellProvider: React.FC<React.PropsWithChildren<{
|
|
46
|
+
value: UseAppShellReturn;
|
|
47
|
+
}>>;
|
|
48
|
+
/**
|
|
49
|
+
* Hook to access AppShell context with a helpful error message.
|
|
50
|
+
* Throws an error if used outside of AppShell component tree.
|
|
51
|
+
*
|
|
52
|
+
* @param componentName - Name of the component using the context (for error messages)
|
|
53
|
+
* @returns AppShell context value
|
|
54
|
+
* @throws Error if used outside AppShell
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* function MyComponent() {
|
|
59
|
+
* const { state, actions } = useAppShellContext('MyComponent');
|
|
60
|
+
* // ...
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const useAppShellContext: (componentName: string) => UseAppShellReturn;
|
|
@@ -27,3 +27,4 @@ export { AppShellFooter } from './AppShellFooter';
|
|
|
27
27
|
export type { AppShellFooterProps } from './AppShellFooter';
|
|
28
28
|
export { AppShellNotificationPanel } from './AppShellNotificationPanel';
|
|
29
29
|
export type { AppShellNotificationPanelProps } from './AppShellNotificationPanel';
|
|
30
|
+
export { AppShellContext, AppShellProvider, useAppShellContext } from './context';
|
|
@@ -21,10 +21,10 @@ import type { SxProps, Theme } from '@mui/material/styles';
|
|
|
21
21
|
* Props for HeaderToggle component.
|
|
22
22
|
*/
|
|
23
23
|
export interface HeaderToggleProps {
|
|
24
|
-
/** Whether the sidebar is collapsed */
|
|
25
|
-
collapsed
|
|
26
|
-
/** Callback to toggle sidebar */
|
|
27
|
-
onToggle
|
|
24
|
+
/** Whether the sidebar is collapsed (optional, uses AppShell context if available) */
|
|
25
|
+
collapsed?: boolean;
|
|
26
|
+
/** Callback to toggle sidebar (optional, uses AppShell context if available) */
|
|
27
|
+
onToggle?: () => void;
|
|
28
28
|
/** Label for expanded state tooltip */
|
|
29
29
|
expandLabel?: string;
|
|
30
30
|
/** Label for collapsed state tooltip */
|
|
@@ -7,6 +7,7 @@ import ListingTableBody from './ListingTableBody';
|
|
|
7
7
|
import ListingTableFooter from './ListingTableFooter';
|
|
8
8
|
import ListingTableRow from './ListingTableRow';
|
|
9
9
|
import ListingTableCell from './ListingTableCell';
|
|
10
|
+
import ListingTableDataGrid from './ListingTableDataGrid';
|
|
10
11
|
import { ListingTableCellIcon, ListingTableRowActions, ListingTableEmptyState, ListingTableToolbar, ListingTableSortLabel, ListingTableDensityControl } from '../shared';
|
|
11
12
|
import { ListingTableProvider } from '../ListingTableProvider';
|
|
12
13
|
export interface ListingTableProps extends MuiTableProps {
|
|
@@ -49,6 +50,7 @@ interface ListingTableComponent {
|
|
|
49
50
|
Toolbar: typeof ListingTableToolbar;
|
|
50
51
|
SortLabel: typeof ListingTableSortLabel;
|
|
51
52
|
DensityControl: typeof ListingTableDensityControl;
|
|
53
|
+
DataGrid: typeof ListingTableDataGrid;
|
|
52
54
|
}
|
|
53
55
|
declare const ListingTableCompound: ListingTableComponent;
|
|
54
56
|
export default ListingTableCompound;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { DataGridProps } from '@mui/x-data-grid';
|
|
3
|
+
import { ListingTableDensity } from '../shared/types';
|
|
4
|
+
export interface ListingTableDataGridProps extends Omit<DataGridProps, 'density'> {
|
|
5
|
+
/**
|
|
6
|
+
* Density control - affects row padding.
|
|
7
|
+
* Maps directly to DataGrid density values.
|
|
8
|
+
* Falls back to the parent ListingTable.Provider density if not provided.
|
|
9
|
+
* @default 'standard'
|
|
10
|
+
*/
|
|
11
|
+
density?: ListingTableDensity;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A `ListingTable` variant that renders an MUI DataGrid instead of a traditional HTML table.
|
|
15
|
+
* Useful when built-in column sorting, filtering, virtual scrolling, or advanced row selection
|
|
16
|
+
* are needed without manual wiring.
|
|
17
|
+
*
|
|
18
|
+
* Supports two display variants controlled via `ListingTable.Provider`:
|
|
19
|
+
* - **`data-grid`** (default): standard grid rows separated by dividers
|
|
20
|
+
* - **`data-grid-card`**: each row is rendered as a floating card with rounded corners and acrylic background
|
|
21
|
+
*
|
|
22
|
+
* Integrates with `ListingTable.Provider` context:
|
|
23
|
+
* - `density` is read from context when not explicitly provided
|
|
24
|
+
* - `loading` is read from context when not explicitly provided
|
|
25
|
+
* - `variant` is driven by the parent `ListingTable.Provider` — use `'data-grid-card'` for card rows
|
|
26
|
+
*
|
|
27
|
+
* @example Table variant (default)
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <ListingTable.Provider density="compact" loading={isFetching}>
|
|
30
|
+
* <ListingTable.Container>
|
|
31
|
+
* <ListingTable.Toolbar showSearch />
|
|
32
|
+
* <ListingTable.DataGrid rows={rows} columns={columns} autoHeight />
|
|
33
|
+
* </ListingTable.Container>
|
|
34
|
+
* </ListingTable.Provider>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @example Card variant
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <ListingTable.Provider variant="data-grid-card">
|
|
40
|
+
* <ListingTable.Container disablePaper>
|
|
41
|
+
* <ListingTable.DataGrid rows={rows} columns={columns} autoHeight />
|
|
42
|
+
* </ListingTable.Container>
|
|
43
|
+
* </ListingTable.Provider>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function ListingTableDataGrid({ density: densityProp, loading: loadingProp, getRowSpacing: getRowSpacingProp, filterModel: filterModelProp, sx, ...props }: ListingTableDataGridProps): ReactElement;
|
|
47
|
+
export default ListingTableDataGrid;
|
|
@@ -19,3 +19,6 @@ export type { ListingTableRowProps } from './ListingTableRow';
|
|
|
19
19
|
export { default as ListingTableCell } from './ListingTableCell';
|
|
20
20
|
export { ListingTableCell as Cell } from './ListingTableCell';
|
|
21
21
|
export type { ListingTableCellProps } from './ListingTableCell';
|
|
22
|
+
export { default as ListingTableDataGrid } from './ListingTableDataGrid';
|
|
23
|
+
export { ListingTableDataGrid as DataGrid } from './ListingTableDataGrid';
|
|
24
|
+
export type { ListingTableDataGridProps } from './ListingTableDataGrid';
|
|
@@ -7,6 +7,7 @@ export type { ListingTableBodyProps } from './ListingTable';
|
|
|
7
7
|
export type { ListingTableFooterProps } from './ListingTable';
|
|
8
8
|
export type { ListingTableRowProps } from './ListingTable';
|
|
9
9
|
export type { ListingTableCellProps } from './ListingTable';
|
|
10
|
+
export type { ListingTableDataGridProps } from './ListingTable';
|
|
10
11
|
export { ListingTableContext, useListingTable, useListingTableRequired } from './context';
|
|
11
12
|
export type { ListingTableContextValue, ListingTableSortDirection } from './context';
|
|
12
13
|
export { ListingTableProvider } from './ListingTableProvider';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ListingTableDensity = 'compact' | 'standard' | 'comfortable';
|
|
2
|
-
export type ListingTableVariant = 'table' | 'card';
|
|
2
|
+
export type ListingTableVariant = 'table' | 'card' | 'data-grid' | 'data-grid-card';
|
|
3
3
|
export declare const densityStyles: Record<ListingTableDensity, {
|
|
4
4
|
padding: string;
|
|
5
5
|
}>;
|
|
@@ -36,10 +36,10 @@ import { NotificationEmptyState } from './NotificationEmptyState';
|
|
|
36
36
|
* Props for the NotificationPanel component.
|
|
37
37
|
*/
|
|
38
38
|
export interface NotificationPanelProps {
|
|
39
|
-
/** Whether the panel is open */
|
|
40
|
-
open
|
|
41
|
-
/** Callback to close the panel */
|
|
42
|
-
onClose
|
|
39
|
+
/** Whether the panel is open (optional, uses AppShell context if available) */
|
|
40
|
+
open?: boolean;
|
|
41
|
+
/** Callback to close the panel (optional, uses AppShell context if available) */
|
|
42
|
+
onClose?: () => void;
|
|
43
43
|
/** Panel content */
|
|
44
44
|
children: React.ReactNode;
|
|
45
45
|
/** Panel width (default: 380) */
|
|
@@ -33,6 +33,8 @@ export interface SidebarItemProps {
|
|
|
33
33
|
depth?: number;
|
|
34
34
|
/** Additional sx props */
|
|
35
35
|
sx?: SxProps<Theme>;
|
|
36
|
+
/** Optional navigation link component to wrap the item button */
|
|
37
|
+
link?: React.ReactElement;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* SidebarItem - Individual navigation menu item.
|
|
@@ -47,6 +49,14 @@ export interface SidebarItemProps {
|
|
|
47
49
|
* </Sidebar.Item>
|
|
48
50
|
* ```
|
|
49
51
|
*
|
|
52
|
+
* With navigation link:
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <Sidebar.Item id="home" link={<Link to="/home" />}>
|
|
55
|
+
* <Sidebar.ItemIcon><Home size={20} /></Sidebar.ItemIcon>
|
|
56
|
+
* <Sidebar.ItemLabel>Home</Sidebar.ItemLabel>
|
|
57
|
+
* </Sidebar.Item>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
50
60
|
* Theme tokens used:
|
|
51
61
|
* - `action.selected` - Active item background
|
|
52
62
|
* - `primary.main` - Active item icon color
|
|
@@ -51,4 +51,4 @@ export { AppShell } from './AppShell';
|
|
|
51
51
|
export type { AppShellProps } from './AppShell';
|
|
52
52
|
export { default as ListingTable } from './ListingTable';
|
|
53
53
|
export { useListingTable, useListingTableRequired, ListingTableContext, ListingTableProvider, } from './ListingTable';
|
|
54
|
-
export type { ListingTableProps, ListingTableContainerProps, ListingTableHeadProps, ListingTableBodyProps, ListingTableFooterProps, ListingTableRowProps, ListingTableCellProps, ListingTableDensity, ListingTableVariant, ListingTableToolbarProps, ListingTableEmptyStateProps, ListingTableDensityControlProps, ListingTableSortLabelProps, ListingSortDirection, ListingTableRowActionsProps, ListingTableCellIconProps, ListingTableContextValue, ListingTableSortDirection, ListingTableProviderProps, } from './ListingTable';
|
|
54
|
+
export type { ListingTableProps, ListingTableContainerProps, ListingTableHeadProps, ListingTableBodyProps, ListingTableFooterProps, ListingTableRowProps, ListingTableCellProps, ListingTableDensity, ListingTableVariant, ListingTableToolbarProps, ListingTableEmptyStateProps, ListingTableDensityControlProps, ListingTableSortLabelProps, ListingSortDirection, ListingTableRowActionsProps, ListingTableCellIconProps, ListingTableContextValue, ListingTableSortDirection, ListingTableProviderProps, ListingTableDataGridProps, } from './ListingTable';
|
|
@@ -27,12 +27,19 @@ export interface AppShellState {
|
|
|
27
27
|
activeMenuItem: string;
|
|
28
28
|
/** Map of expanded menu IDs */
|
|
29
29
|
expandedMenus: Record<string, boolean>;
|
|
30
|
+
/** Expanded sidebar width in pixels */
|
|
31
|
+
sidebarWidth: number;
|
|
32
|
+
/** Collapsed sidebar width in pixels */
|
|
33
|
+
sidebarCollapsedWidth: number;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* App Shell actions interface.
|
|
33
37
|
*/
|
|
34
38
|
export interface AppShellActions {
|
|
35
39
|
toggleSidebar: () => void;
|
|
40
|
+
setSidebarCollapsed: (collapsed: boolean) => void;
|
|
41
|
+
collapseSidebar: () => void;
|
|
42
|
+
expandSidebar: () => void;
|
|
36
43
|
toggleNotificationPanel: () => void;
|
|
37
44
|
setActiveMenuItem: (id: string) => void;
|
|
38
45
|
toggleMenu: (id: string) => void;
|
|
@@ -45,6 +52,14 @@ export interface UseAppShellOptions {
|
|
|
45
52
|
initialCollapsed?: boolean;
|
|
46
53
|
/** Initial active menu item */
|
|
47
54
|
initialActiveItem?: string;
|
|
55
|
+
/** Auto-collapse sidebar on menu item selection in mobile view (default: true) */
|
|
56
|
+
collapseOnSelectOnMobile?: boolean;
|
|
57
|
+
/** Auto-collapse sidebar on page load when in mobile view (default: false) */
|
|
58
|
+
collapseOnMobile?: boolean;
|
|
59
|
+
/** Expanded sidebar width in pixels (default: 250) */
|
|
60
|
+
sidebarWidth?: number;
|
|
61
|
+
/** Collapsed sidebar width in pixels (default: 64) */
|
|
62
|
+
sidebarCollapsedWidth?: number;
|
|
48
63
|
}
|
|
49
64
|
/**
|
|
50
65
|
* Return type for useAppShell hook.
|
|
@@ -61,20 +76,40 @@ export interface UseAppShellReturn {
|
|
|
61
76
|
* - Notification panel visibility
|
|
62
77
|
* - Active menu item and expanded menus
|
|
63
78
|
*
|
|
79
|
+
* Can be used in two modes:
|
|
80
|
+
* 1. **Create mode** (with options): Creates a new shell state instance
|
|
81
|
+
* 2. **Consume mode** (without options): Consumes shared state from AppShellProvider
|
|
82
|
+
*
|
|
64
83
|
* For notification data management, use the `useNotifications` hook separately.
|
|
65
84
|
*
|
|
66
85
|
* @example
|
|
67
86
|
* ```tsx
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
87
|
+
* // Create mode - in layout component
|
|
88
|
+
* function AppLayout() {
|
|
89
|
+
* const shell = useAppShell({
|
|
90
|
+
* initialCollapsed: false,
|
|
91
|
+
* collapseOnSelectOnMobile: true,
|
|
92
|
+
* sidebarWidth: 280,
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* return (
|
|
96
|
+
* <AppShellProvider value={shell}>
|
|
97
|
+
* <AppShell>
|
|
98
|
+
* <Sidebar collapsed={shell.state.sidebarCollapsed} />
|
|
99
|
+
* <Outlet />
|
|
100
|
+
* </AppShell>
|
|
101
|
+
* </AppShellProvider>
|
|
102
|
+
* );
|
|
103
|
+
* }
|
|
71
104
|
*
|
|
72
|
-
* //
|
|
73
|
-
*
|
|
74
|
-
*
|
|
105
|
+
* // Consume mode - in child page component
|
|
106
|
+
* function MyPage() {
|
|
107
|
+
* const { state, actions } = useAppShell(); // No options = consume from context
|
|
75
108
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
109
|
+
* useEffect(() => {
|
|
110
|
+
* actions.toggleSidebar(); // Control shared sidebar state
|
|
111
|
+
* }, []);
|
|
112
|
+
* }
|
|
78
113
|
* ```
|
|
79
114
|
*/
|
|
80
115
|
export declare const useAppShell: (options?: UseAppShellOptions) => UseAppShellReturn;
|