@wso2/oxygen-ui 0.14.0 → 0.16.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.
@@ -18,6 +18,41 @@ description: Generate application layouts with AppShell, Header, and Sidebar. Us
18
18
  - Use compound component pattern for `AppShell`, `Header`, `Sidebar`
19
19
  - Import icons from `@wso2/oxygen-ui-icons-react`
20
20
  - Use theme tokens for all styling
21
+ - Set a browser tab title on every page using `[Specific page/resource] | [Product]` (see below)
22
+
23
+ ## Browser Tab Title
24
+
25
+ Every page must set a browser tab title in this format, so users can tell tabs, bookmarks, and history entries apart. Render a React 19 `<title>` element in the page component rather than assigning `document.title`:
26
+
27
+ ```text
28
+ [Specific page/resource] | [Product]
29
+ ```
30
+
31
+ Examples:
32
+
33
+ ```text
34
+ All Projects | Acme Console
35
+ Environments | Acme Console
36
+ ```
37
+
38
+ - Put the specific page or resource first and the product name last
39
+ - Separate them with ` | ` (space, pipe, space)
40
+ - Use the same product name on every page
41
+ - On the product home or landing page, use the product name only: `Acme Console`
42
+ - For nested resources, go from most to least specific: `Environments | Payments API | Acme Console`
43
+ - For dynamic names, use the resource name once it loads; until then show the page type (`Project | Acme Console`), never `Loading...`
44
+ - On error pages, name the error: `Page Not Found | Acme Console`
45
+
46
+ ```tsx
47
+ function ProjectsPage() {
48
+ return (
49
+ <>
50
+ <title>All Projects | Acme Console</title>
51
+ {/* page content */}
52
+ </>
53
+ );
54
+ }
55
+ ```
21
56
 
22
57
  ## Complete App Shell Layout
23
58
 
@@ -42,6 +77,16 @@ import {
42
77
  FileIcon,
43
78
  } from '@wso2/oxygen-ui-icons-react';
44
79
 
80
+ function ProjectsPage() {
81
+ return (
82
+ <>
83
+ <title>All Projects | My Application</title>
84
+ {/* Page content goes here */}
85
+ <h1>All Projects</h1>
86
+ </>
87
+ );
88
+ }
89
+
45
90
  function App() {
46
91
  const [collapsed, setCollapsed] = useState(false);
47
92
  const [activeItem, setActiveItem] = useState('home');
@@ -116,8 +161,7 @@ function App() {
116
161
 
117
162
  <AppShell.Main>
118
163
  <Box sx={{ p: 3 }}>
119
- {/* Page content goes here */}
120
- <h1>Welcome</h1>
164
+ <ProjectsPage />
121
165
  </Box>
122
166
  </AppShell.Main>
123
167
 
@@ -33,6 +33,10 @@ export interface AppSwitcherProps {
33
33
  'aria-label'?: string;
34
34
  /** Additional sx props applied to the popover */
35
35
  sx?: SxProps<Theme>;
36
+ /** Id of the app the user is in. Its card opens in the same tab and is marked `aria-current`. */
37
+ currentAppId?: string;
38
+ /** Tooltip on unavailable cards, e.g. for localisation (default: `"Coming soon"`) */
39
+ unavailableLabel?: React.ReactNode;
36
40
  }
37
41
  /**
38
42
  * AppSwitcher - Popover for navigating between WSO2 Cloud applications.
@@ -50,7 +54,17 @@ export interface AppSwitcherProps {
50
54
  *
51
55
  * Selecting a card leaves the popover open, since cards open in a new tab, so
52
56
  * the current tab never navigates. The trigger, an outside click or Escape
53
- * dismisses it.
57
+ * dismisses it. The current app (`currentAppId`) is the exception: it opens
58
+ * in the same tab, so selecting it closes the popover.
59
+ *
60
+ * @example
61
+ * ```tsx
62
+ * <AppSwitcher currentAppId="agent-manager">
63
+ * <AppSwitcher.Trigger label="Switch platforms" />
64
+ * <AppSwitcher.Section label="Platforms" apps={platforms} loading={isLoading} />
65
+ * <AppSwitcher.Footer label="Manage" links={manage} loading={isLoading} />
66
+ * </AppSwitcher>
67
+ * ```
54
68
  *
55
69
  * @example
56
70
  * ```tsx
@@ -27,6 +27,10 @@ import * as React from 'react';
27
27
  * Elevation:
28
28
  * - `shadows[2]` - Hover elevation
29
29
  *
30
+ * Brand (see `brand.ts`):
31
+ * - `APP_SWITCHER_BRAND.main` - Hover border
32
+ * - `APP_SWITCHER_BRAND.focus` - Focus ring and the current app's border
33
+ *
30
34
  * Typography / sizing:
31
35
  * - `typography.body2` - Name text
32
36
  * - `spacing()` / `shape.borderRadius` - Card and tile dimensions
@@ -42,14 +46,25 @@ import * as React from 'react';
42
46
  * - `manage` - Smaller neutral mark on a grey disc, used for the manage row
43
47
  */
44
48
  export type AppSwitcherAppTone = 'platform' | 'manage';
49
+ /** Card height per tone, in `theme.spacing` units. Shared with the loading placeholders. */
50
+ export declare const APP_CARD_HEIGHT: Record<AppSwitcherAppTone, number>;
45
51
  /**
46
52
  * Props for the AppSwitcher.App component.
47
53
  */
48
54
  export interface AppSwitcherAppProps {
55
+ /** Identifier matched against the switcher's `currentAppId`. Not set as the DOM `id`. */
56
+ id?: string;
49
57
  /** Application name (e.g. `"API Platform"`) */
50
58
  name: string;
51
- /** Destination URL. The card renders as an anchor pointing at it. */
52
- url?: string;
59
+ /**
60
+ * Destination URL. The card renders as an anchor pointing at it.
61
+ *
62
+ * `null` or a blank string marks the app as unavailable: without `onClick`
63
+ * or `component` it renders disabled with a "Coming soon" tooltip. Only
64
+ * `http:`, `https:` and relative URLs are used; any other scheme renders the
65
+ * card disabled.
66
+ */
67
+ url?: string | null;
53
68
  /** Mark shown above the name (default: the WSO2 logo) */
54
69
  icon?: React.ReactNode;
55
70
  /** Visual treatment (default: `"manage"` inside the footer, `"platform"` elsewhere) */
@@ -74,11 +89,20 @@ export interface AppSwitcherAppProps {
74
89
  * navigation prop instead of `href` (e.g. React Router's `to`).
75
90
  */
76
91
  componentProps?: Record<string, unknown>;
77
- /** Anchor target (default: `"_blank"`, so platforms open in a new tab) */
92
+ /** Anchor target (default: `"_self"` for the current app, `"_blank"` otherwise) */
78
93
  target?: string;
79
- /** Click handler. The popover stays open after it runs. */
94
+ /** Marks this card as the current app, overriding the `currentAppId` match */
95
+ current?: boolean;
96
+ /** Shows progress and ignores clicks while an action runs, e.g. granting access */
97
+ busy?: boolean;
98
+ /** Click handler. The popover stays open after it runs, except on the current app. */
80
99
  onClick?: (event: React.MouseEvent<HTMLElement>) => void;
81
100
  }
101
+ /** A card described as data, for `AppSwitcher.Section`'s `apps`. */
102
+ export interface AppSwitcherAppItem extends Omit<AppSwitcherAppProps, 'id'> {
103
+ /** Stable identifier, used as the React key and to match `currentAppId` */
104
+ id: string;
105
+ }
82
106
  /**
83
107
  * AppSwitcher.App - Card button for a single destination in the switcher.
84
108
  *
@@ -91,10 +115,17 @@ export interface AppSwitcherAppProps {
91
115
  * `aria-disabled` rather than the native `disabled` attribute, they still
92
116
  * receive pointer events, so the tooltip works on them.
93
117
  *
118
+ * An app with `url: null` (or a blank `url`) and no `onClick` or `component`
119
+ * has nothing to offer, so it renders disabled with a "Coming soon" tooltip.
120
+ *
121
+ * The current app (`current`, or `id` matching `currentAppId`) opens in the
122
+ * same tab, so selecting it closes the popover.
123
+ *
94
124
  * @example
95
125
  * ```tsx
96
126
  * <AppSwitcher.App name="API Platform" url="https://api.wso2.com" />
97
127
  * <AppSwitcher.App name="Analytics Platform" disabled tooltip="Coming soon" />
128
+ * <AppSwitcher.App id="agent-manager" name="Agent Manager" url="https://agent.wso2.com" />
98
129
  * ```
99
130
  */
100
131
  export declare const AppSwitcherApp: React.ForwardRefExoticComponent<AppSwitcherAppProps & React.RefAttributes<HTMLElement>>;
@@ -16,6 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import * as React from 'react';
19
+ import type { AppSwitcherAppItem } from './AppSwitcherApp';
19
20
  /**
20
21
  * Theme tokens used in this component:
21
22
  *
@@ -26,31 +27,16 @@ import * as React from 'react';
26
27
  */
27
28
  /**
28
29
  * A single WSO2 Cloud destination in the footer.
30
+ *
31
+ * Same shape as `AppSwitcherAppItem`, but `id` is optional since existing
32
+ * links use `key`. A missing `url` keeps its old behavior, so existing
33
+ * footers do not change; pass `url: null` to mark a link unavailable.
29
34
  */
30
- export interface AppSwitcherFooterLink {
31
- /** Stable identifier, used as the React key */
32
- key: string;
33
- /** Link name (e.g. `"Users & roles"`) */
34
- name: string;
35
- /** Destination URL. Renders the card as an anchor. */
36
- url?: string;
37
- /** Mark shown above the name (default: the WSO2 logo) */
38
- icon?: React.ReactNode;
39
- /** Anchor target (default: `"_blank"`) */
40
- target?: string;
41
- /** Blocks navigation, e.g. for a tab the user cannot reach */
42
- disabled?: boolean;
43
- /** Tooltip shown on hover and focus, e.g. explaining a disabled link */
44
- tooltip?: React.ReactNode;
45
- /** Custom root component, e.g. a router `Link`, for client-side navigation */
46
- component?: React.ElementType;
47
- /**
48
- * Extra props forwarded to `component`, for routers that use their own
49
- * navigation prop instead of `href` (e.g. React Router's `to`).
50
- */
51
- componentProps?: Record<string, unknown>;
52
- /** Click handler. The popover stays open after it runs. */
53
- onClick?: (event: React.MouseEvent<HTMLElement>) => void;
35
+ export interface AppSwitcherFooterLink extends Omit<AppSwitcherAppItem, 'id'> {
36
+ /** Stable identifier, used as the React key and to match `currentAppId` */
37
+ id?: string;
38
+ /** React key. Kept for existing links; prefer `id`. */
39
+ key?: string;
54
40
  }
55
41
  /**
56
42
  * Props for the AppSwitcher.Footer component.
@@ -64,6 +50,10 @@ export interface AppSwitcherFooterProps {
64
50
  label?: string;
65
51
  /** Number of grid columns from the `sm` breakpoint up (default: 3) */
66
52
  columns?: number;
53
+ /** Shows placeholder cards, e.g. while the links are fetched */
54
+ loading?: boolean;
55
+ /** Number of placeholder cards while `loading` (default: one row, `columns`) */
56
+ loadingCount?: number;
67
57
  }
68
58
  /**
69
59
  * AppSwitcher.Footer - Bottom section of the app switcher popover.
@@ -16,16 +16,40 @@
16
16
  * under the License.
17
17
  */
18
18
  import * as React from 'react';
19
+ import type { AppSwitcherAppItem } from './AppSwitcherApp';
20
+ /**
21
+ * Renders data items as cards.
22
+ *
23
+ * `missingUrlIsUnavailable` treats an omitted `url` as `null`. The footer's
24
+ * older `links` turn it off so existing links without a `url` do not change.
25
+ *
26
+ * @internal
27
+ */
28
+ export declare const renderAppItems: (items: ReadonlyArray<Omit<AppSwitcherAppItem, "id"> & {
29
+ id?: string;
30
+ key?: string;
31
+ }>, { missingUrlIsUnavailable }: {
32
+ missingUrlIsUnavailable: boolean;
33
+ }) => React.ReactNode;
19
34
  /**
20
35
  * Props for the AppSwitcher.Section component.
21
36
  */
22
37
  export interface AppSwitcherSectionProps {
23
38
  /** App cards (typically `AppSwitcher.App` elements) */
24
- children: React.ReactNode;
39
+ children?: React.ReactNode;
40
+ /**
41
+ * Apps rendered as cards, as an alternative to `children`. An app with no
42
+ * `url`, `onClick` or `component` renders disabled.
43
+ */
44
+ apps?: AppSwitcherAppItem[];
25
45
  /** Section heading, rendered as an uppercase label (e.g. `"Platforms"`) */
26
46
  label?: string;
27
47
  /** Number of grid columns from the `sm` breakpoint up (default: 3) */
28
48
  columns?: number;
49
+ /** Shows placeholder cards, e.g. while the apps are fetched */
50
+ loading?: boolean;
51
+ /** Number of placeholder cards while `loading` (default: one row, `columns`) */
52
+ loadingCount?: number;
29
53
  }
30
54
  /**
31
55
  * AppSwitcher.Section - Labelled grid of applications inside the popover.
@@ -40,6 +64,8 @@ export interface AppSwitcherSectionProps {
40
64
  * <AppSwitcher.App name="Agent Manager" url="https://agent.wso2.com" />
41
65
  * <AppSwitcher.App name="API Platform" url="https://api.wso2.com" />
42
66
  * </AppSwitcher.Section>
67
+ *
68
+ * <AppSwitcher.Section label="Platforms" apps={platforms} loading={isLoading} />
43
69
  * ```
44
70
  */
45
71
  export declare const AppSwitcherSection: React.FC<AppSwitcherSectionProps>;
@@ -30,7 +30,7 @@
30
30
  * The focus indicator is author-defined, so WCAG 2.1 SC 1.4.11 holds it to
31
31
  * 3:1 against the adjacent surface. `main` misses that, so `focus` (#E56800)
32
32
  * carries the ring instead: 3.33:1 on the light card (#FFFFFF) and 5.63:1 on
33
- * the dark one (#121212).
33
+ * the dark one (#121212). The current app's border needs the same 3:1.
34
34
  *
35
35
  * See https://github.com/wso2/oxygen-ui/issues/558 for the palette-wide
36
36
  * contrast discussion.
@@ -39,8 +39,9 @@ export declare const APP_SWITCHER_BRAND: {
39
39
  /** Full-strength WSO2 orange. Decorative surfaces only. */
40
40
  readonly main: "#FF7300";
41
41
  /**
42
- * Darker orange reserved for the focus ring, where 3:1 against the card
43
- * surface is required. Do not swap it back to `main`.
42
+ * Darker orange reserved for the focus ring and the current app's border,
43
+ * where 3:1 against the card surface is required. Do not swap it back to
44
+ * `main`.
44
45
  */
45
46
  readonly focus: "#E56800";
46
47
  /** Faded orange for the mark of a platform that is not yet available. */
@@ -30,6 +30,10 @@ export interface AppSwitcherContextValue {
30
30
  handleOpen: (event: React.MouseEvent<HTMLElement>) => void;
31
31
  /** Closes the popover */
32
32
  handleClose: () => void;
33
+ /** Id of the app the user is in */
34
+ currentAppId?: string;
35
+ /** Tooltip on unavailable cards */
36
+ unavailableLabel?: React.ReactNode;
33
37
  }
34
38
  /**
35
39
  * Context for sharing state between AppSwitcher compound components.
@@ -22,7 +22,7 @@ export type { AppSwitcherTriggerProps } from './AppSwitcherTrigger';
22
22
  export { AppSwitcherSection } from './AppSwitcherSection';
23
23
  export type { AppSwitcherSectionProps } from './AppSwitcherSection';
24
24
  export { AppSwitcherApp } from './AppSwitcherApp';
25
- export type { AppSwitcherAppProps, AppSwitcherAppTone } from './AppSwitcherApp';
25
+ export type { AppSwitcherAppProps, AppSwitcherAppItem, AppSwitcherAppTone } from './AppSwitcherApp';
26
26
  export { AppSwitcherFooter } from './AppSwitcherFooter';
27
27
  export type { AppSwitcherFooterProps, AppSwitcherFooterLink } from './AppSwitcherFooter';
28
28
  export { AppSwitcherContext, useAppSwitcher } from './context';
@@ -0,0 +1,24 @@
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
+ /**
19
+ * Whether a URL is safe to put into a card's `href`.
20
+ *
21
+ * Card URLs can come from fetched data. Parsing with `URL` sees the scheme as
22
+ * the browser does, so tricks like `" JaVa\tScript:"` cannot slip past.
23
+ */
24
+ export declare const isSafeAppUrl: (url: string) => boolean;
@@ -39,11 +39,11 @@ export interface HeaderToggleProps {
39
39
  /**
40
40
  * HeaderToggle - Sidebar toggle button for the header.
41
41
  *
42
- * Displays an icon that indicates the current sidebar state
42
+ * Displays a hamburger icon; state is conveyed via tooltip and `aria-expanded`
43
43
  * and toggles between expanded/collapsed states.
44
44
  *
45
45
  * Custom icons can be provided via `expandIcon` and `collapseIcon` props.
46
- * Defaults: `Menu` when collapsed (expand), `PanelLeftClose` when expanded (collapse).
46
+ * Defaults to `Menu` in both states.
47
47
  *
48
48
  * Theme tokens used:
49
49
  * - `text.secondary` - Icon color
@@ -1,6 +1,18 @@
1
- import { ReactElement } from 'react';
1
+ import { ReactElement, ReactNode } from 'react';
2
2
  import { TableBodyProps as MuiTableBodyProps } from '@mui/material/TableBody';
3
3
  export interface ListingTableBodyProps extends MuiTableBodyProps {
4
+ /** Active search query; falls back to the ListingTable.Provider value */
5
+ searchValue?: string;
6
+ /** Skips the no-results state while data is loading; falls back to the ListingTable.Provider value */
7
+ loading?: boolean;
8
+ /** @default 'No results found' */
9
+ noSearchResultsText?: string;
10
+ /** @default 'Try a different keyword' */
11
+ noSearchResultsDescription?: string;
12
+ /** @default <Search /> */
13
+ noSearchResultsIcon?: ReactNode;
14
+ /** @default 1000 */
15
+ emptyStateColSpan?: number;
4
16
  }
5
- export declare function ListingTableBody({ children, ...props }: ListingTableBodyProps): ReactElement;
17
+ export declare function ListingTableBody({ children, searchValue, loading, noSearchResultsText, noSearchResultsDescription, noSearchResultsIcon, emptyStateColSpan, ...props }: ListingTableBodyProps): ReactElement;
6
18
  export default ListingTableBody;
@@ -0,0 +1,61 @@
1
+ import * as React from 'react';
2
+ import type { SxProps, Theme } from '@mui/material/styles';
3
+ /**
4
+ * Props for the RelativeTime component
5
+ */
6
+ export interface RelativeTimeProps {
7
+ /**
8
+ * The relative time text to display, provided by the consumer (e.g. "3 weeks ago").
9
+ */
10
+ time: React.ReactNode;
11
+ /**
12
+ * Optional operation shown before the time (e.g. "Created", "Updated", "Deleted").
13
+ */
14
+ action?: React.ReactNode;
15
+ /**
16
+ * Machine-readable date/time for the `<time>` element (e.g. an ISO 8601 string).
17
+ */
18
+ dateTime?: string;
19
+ /**
20
+ * Optional tooltip content, typically the full absolute date.
21
+ */
22
+ tooltip?: React.ReactNode;
23
+ /**
24
+ * Custom icon. Defaults to a clock icon.
25
+ */
26
+ icon?: React.ReactNode;
27
+ /**
28
+ * Hides the icon.
29
+ * @default false
30
+ */
31
+ hideIcon?: boolean;
32
+ /**
33
+ * Size of the text and icon.
34
+ * @default 'medium'
35
+ */
36
+ size?: 'small' | 'medium';
37
+ /**
38
+ * Custom styles for the root element.
39
+ */
40
+ sx?: SxProps<Theme>;
41
+ }
42
+ /**
43
+ * RelativeTime component - Displays a clock icon with an optional action and a relative time
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * <RelativeTime time="3 weeks ago" />
48
+ * ```
49
+ *
50
+ * @example
51
+ * ```tsx
52
+ * <RelativeTime
53
+ * action="Updated"
54
+ * time="5 minutes ago"
55
+ * dateTime="2026-10-08T09:15:00Z"
56
+ * tooltip="October 8, 2026, 9:15 AM"
57
+ * />
58
+ * ```
59
+ */
60
+ declare const RelativeTime: React.FC<RelativeTimeProps>;
61
+ export default RelativeTime;
@@ -0,0 +1,2 @@
1
+ export { default } from './RelativeTime';
2
+ export * from './RelativeTime';
@@ -30,6 +30,8 @@ export { default as PageContent } from './PageContent';
30
30
  export type { PageContentProps } from './PageContent';
31
31
  export { default as PageTitle } from './PageTitle';
32
32
  export type { PageTitleProps, PageTitleAvatarProps, PageTitleHeaderProps, PageTitleSubHeaderProps, PageTitleLinkProps } from './PageTitle';
33
+ export { default as RelativeTime } from './RelativeTime';
34
+ export type { RelativeTimeProps } from './RelativeTime';
33
35
  export { default as StatCard } from './StatCard';
34
36
  export type { StatCardProps } from './StatCard';
35
37
  export { default as ThemeSwitcher, ThemeSelect } from './ThemeSwitcher';
@@ -41,7 +43,7 @@ export type { SearchBarProps } from './SearchBar/SearchBar';
41
43
  export { Header } from './Header';
42
44
  export type { HeaderProps, HeaderSpacerProps, HeaderToggleProps, HeaderBrandProps, HeaderBrandLogoProps, HeaderBrandTitleProps, HeaderSwitchersProps, HeaderActionsProps, HeaderContextValue, } from './Header';
43
45
  export { AppSwitcher } from './AppSwitcher';
44
- export type { AppSwitcherProps, AppSwitcherTriggerProps, AppSwitcherSectionProps, AppSwitcherAppProps, AppSwitcherAppTone, AppSwitcherFooterProps, AppSwitcherFooterLink, AppSwitcherContextValue, } from './AppSwitcher';
46
+ export type { AppSwitcherProps, AppSwitcherTriggerProps, AppSwitcherSectionProps, AppSwitcherAppProps, AppSwitcherAppItem, AppSwitcherAppTone, AppSwitcherFooterProps, AppSwitcherFooterLink, AppSwitcherContextValue, } from './AppSwitcher';
45
47
  export { Sidebar, useSidebar } from './Sidebar';
46
48
  export type { SidebarProps, SidebarNavProps, SidebarCategoryProps, SidebarCategoryLabelProps, SidebarItemProps, SidebarItemIconProps, SidebarItemLabelProps, SidebarItemBadgeProps, SidebarFooterProps, SidebarUserProps, SidebarUserAvatarProps, SidebarUserNameProps, SidebarUserEmailProps, SidebarContextValue, SidebarItemContextValue, } from './Sidebar';
47
49
  export { NotificationPanel } from './NotificationPanel';