@wso2/oxygen-ui 0.14.0 → 0.15.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.
@@ -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;
@@ -41,7 +41,7 @@ export type { SearchBarProps } from './SearchBar/SearchBar';
41
41
  export { Header } from './Header';
42
42
  export type { HeaderProps, HeaderSpacerProps, HeaderToggleProps, HeaderBrandProps, HeaderBrandLogoProps, HeaderBrandTitleProps, HeaderSwitchersProps, HeaderActionsProps, HeaderContextValue, } from './Header';
43
43
  export { AppSwitcher } from './AppSwitcher';
44
- export type { AppSwitcherProps, AppSwitcherTriggerProps, AppSwitcherSectionProps, AppSwitcherAppProps, AppSwitcherAppTone, AppSwitcherFooterProps, AppSwitcherFooterLink, AppSwitcherContextValue, } from './AppSwitcher';
44
+ export type { AppSwitcherProps, AppSwitcherTriggerProps, AppSwitcherSectionProps, AppSwitcherAppProps, AppSwitcherAppItem, AppSwitcherAppTone, AppSwitcherFooterProps, AppSwitcherFooterLink, AppSwitcherContextValue, } from './AppSwitcher';
45
45
  export { Sidebar, useSidebar } from './Sidebar';
46
46
  export type { SidebarProps, SidebarNavProps, SidebarCategoryProps, SidebarCategoryLabelProps, SidebarItemProps, SidebarItemIconProps, SidebarItemLabelProps, SidebarItemBadgeProps, SidebarFooterProps, SidebarUserProps, SidebarUserAvatarProps, SidebarUserNameProps, SidebarUserEmailProps, SidebarContextValue, SidebarItemContextValue, } from './Sidebar';
47
47
  export { NotificationPanel } from './NotificationPanel';