@wso2/oxygen-ui 0.23.1 → 0.25.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 +1 -2
- package/.ai/patterns.md +0 -2
- package/.ai/theming.md +1 -5
- package/.claude/components.md +80 -0
- package/.claude/patterns.md +0 -2
- package/.claude/skills/oxygen-select/SKILL.md +1 -1
- package/.claude/theming.md +1 -5
- package/README.md +1 -1
- package/dist/components/Footer/Footer.d.ts +35 -0
- package/dist/components/HeaderBreadcrumbs/HeaderBreadcrumbs.d.ts +100 -0
- package/dist/components/HeaderBreadcrumbs/HeaderBreadcrumbsSegment.d.ts +54 -0
- package/dist/components/HeaderBreadcrumbs/index.d.ts +26 -0
- package/dist/components/HeaderBreadcrumbs/persistence.d.ts +87 -0
- package/dist/components/HeaderBreadcrumbs/types.d.ts +125 -0
- package/dist/components/HeaderBreadcrumbs/useHeaderBreadcrumbs.d.ts +150 -0
- package/dist/components/LogViewer/LogViewer.d.ts +7 -0
- package/dist/components/LogViewer/context.d.ts +2 -0
- package/dist/components/PageContent/PageContent.d.ts +13 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/index.js +3202 -2106
- package/dist/index.js.map +4 -4
- package/dist/styles/Themes/{ChoreoLabsTheme.d.ts → DefaultTheme.d.ts} +11 -11
- package/dist/styles/Themes/index.d.ts +1 -2
- package/package.json +2 -2
package/.ai/AGENTS.md
CHANGED
|
@@ -54,10 +54,9 @@ import { DataGrid, DatePickers, TreeView } from '@wso2/oxygen-ui';
|
|
|
54
54
|
|
|
55
55
|
## Available Themes
|
|
56
56
|
|
|
57
|
-
- `OxygenTheme` - Default theme (recommended)
|
|
57
|
+
- `OxygenTheme` - Default theme (recommended): brand colours, Sora font and flat surfaces
|
|
58
58
|
- `AcrylicOrangeTheme` - Orange accent variant
|
|
59
59
|
- `AcrylicPurpleTheme` - Purple accent variant
|
|
60
|
-
- `ChoreoLabsTheme` - Choreo Labs brand theme (Acrylic look with Choreo Labs colours and Sora font)
|
|
61
60
|
- `ClassicTheme` - Traditional styling
|
|
62
61
|
- `HighContrastTheme` - Accessibility-focused
|
|
63
62
|
- `PaleBaseTheme` - Minimal color palette
|
package/.ai/patterns.md
CHANGED
|
@@ -1144,7 +1144,6 @@ import {
|
|
|
1144
1144
|
OxygenTheme,
|
|
1145
1145
|
AcrylicOrangeTheme,
|
|
1146
1146
|
AcrylicPurpleTheme,
|
|
1147
|
-
ChoreoLabsTheme,
|
|
1148
1147
|
ClassicTheme,
|
|
1149
1148
|
HighContrastTheme,
|
|
1150
1149
|
PaleBaseTheme,
|
|
@@ -1159,7 +1158,6 @@ const themes = [
|
|
|
1159
1158
|
{ key: 'default', label: 'Default', theme: OxygenTheme },
|
|
1160
1159
|
{ key: 'orange', label: 'Acrylic Orange', theme: AcrylicOrangeTheme },
|
|
1161
1160
|
{ key: 'purple', label: 'Acrylic Purple', theme: AcrylicPurpleTheme },
|
|
1162
|
-
{ key: 'choreoLabs', label: 'Choreo Labs', theme: ChoreoLabsTheme },
|
|
1163
1161
|
{ key: 'classic', label: 'Classic', theme: ClassicTheme },
|
|
1164
1162
|
{ key: 'highContrast', label: 'High Contrast', theme: HighContrastTheme },
|
|
1165
1163
|
{ key: 'paleBase', label: 'Pale Base', theme: PaleBaseTheme },
|
package/.ai/theming.md
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
| Theme | Import | Description |
|
|
16
16
|
|-------|--------|-------------|
|
|
17
|
-
| OxygenTheme | `OxygenTheme` | Default theme (
|
|
17
|
+
| OxygenTheme | `OxygenTheme` | Default theme (brand colours, Sora font and flat surfaces) |
|
|
18
18
|
| Acrylic Orange | `AcrylicOrangeTheme` | Glass-morphism effects, orange primary |
|
|
19
19
|
| Acrylic Purple | `AcrylicPurpleTheme` | Glass-morphism with purple accents |
|
|
20
|
-
| Choreo Labs | `ChoreoLabsTheme` | Choreo Labs brand theme (Acrylic look with Choreo Labs colours and Sora font) |
|
|
21
20
|
| Classic | `ClassicTheme` | Standard flat design |
|
|
22
21
|
| High Contrast | `HighContrastTheme` | Accessibility-focused with high contrast colors |
|
|
23
22
|
| Pale Base | `PaleBaseTheme` | Minimal color palette for subtle interfaces |
|
|
@@ -29,7 +28,6 @@ import {
|
|
|
29
28
|
OxygenTheme,
|
|
30
29
|
AcrylicOrangeTheme,
|
|
31
30
|
AcrylicPurpleTheme,
|
|
32
|
-
ChoreoLabsTheme,
|
|
33
31
|
ClassicTheme,
|
|
34
32
|
HighContrastTheme,
|
|
35
33
|
PaleBaseTheme,
|
|
@@ -67,7 +65,6 @@ import {
|
|
|
67
65
|
OxygenTheme,
|
|
68
66
|
AcrylicOrangeTheme,
|
|
69
67
|
AcrylicPurpleTheme,
|
|
70
|
-
ChoreoLabsTheme,
|
|
71
68
|
ClassicTheme,
|
|
72
69
|
HighContrastTheme,
|
|
73
70
|
PaleBaseTheme,
|
|
@@ -80,7 +77,6 @@ import {
|
|
|
80
77
|
{ key: 'default', label: 'Default', theme: OxygenTheme },
|
|
81
78
|
{ key: 'orange', label: 'Acrylic Orange', theme: AcrylicOrangeTheme },
|
|
82
79
|
{ key: 'purple', label: 'Acrylic Purple', theme: AcrylicPurpleTheme },
|
|
83
|
-
{ key: 'choreoLabs', label: 'Choreo Labs', theme: ChoreoLabsTheme },
|
|
84
80
|
{ key: 'classic', label: 'Classic', theme: ClassicTheme },
|
|
85
81
|
{ key: 'highContrast', label: 'High Contrast', theme: HighContrastTheme },
|
|
86
82
|
{ key: 'paleBase', label: 'Pale Base', theme: PaleBaseTheme },
|
package/.claude/components.md
CHANGED
|
@@ -13,6 +13,7 @@ Complete API reference for custom Oxygen UI components. For MUI components, refe
|
|
|
13
13
|
- [Footer](#footer)
|
|
14
14
|
- [UserMenu](#usermenu)
|
|
15
15
|
- [ContextSwitcher](#contextswitcher)
|
|
16
|
+
- [HeaderBreadcrumbs](#headerbreadcrumbs)
|
|
16
17
|
- [AppSwitcher](#appswitcher)
|
|
17
18
|
- [Form](#form)
|
|
18
19
|
- [FullScreenWizard](#fullscreenwizard)
|
|
@@ -1361,6 +1362,85 @@ const [value, setValue] = useState<ContextSwitcherValue>({
|
|
|
1361
1362
|
</ContextSwitcher>
|
|
1362
1363
|
```
|
|
1363
1364
|
|
|
1365
|
+
## HeaderBreadcrumbs
|
|
1366
|
+
|
|
1367
|
+
A trail of the current organization / project / component, like `thunder-id / thunderid ▾`. Each segment has two targets: the name goes to that entry's page, and the caret opens a menu to switch to another entry of the same level. After the trail, a › button opens the next level's menu; its tooltip and accessible name are "Open project" (on an organization) or "Open component" (on a project). Use it when the header should read as plain text. Use `ContextSwitcher` when each level should be a labeled field.
|
|
1368
|
+
|
|
1369
|
+
```tsx
|
|
1370
|
+
import { HeaderBreadcrumbs, useHeaderBreadcrumbs, readHeaderBreadcrumbsState, clearHeaderBreadcrumbsState } from '@wso2/oxygen-ui';
|
|
1371
|
+
import type { HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel, HeaderBreadcrumbsValue } from '@wso2/oxygen-ui';
|
|
1372
|
+
```
|
|
1373
|
+
|
|
1374
|
+
### HeaderBreadcrumbs Props
|
|
1375
|
+
|
|
1376
|
+
| Prop | Type | Default | Description |
|
|
1377
|
+
|------|------|---------|-------------|
|
|
1378
|
+
| `levels` | `HeaderBreadcrumbsLevel[]` | required | Levels in order. The trail runs up to the first level without `selectedId`, which shows as a › button. Leave a level out to remove it |
|
|
1379
|
+
| `onNavigate` | `(levelId, item) => void` | - | A name was clicked |
|
|
1380
|
+
| `onSelect` | `(levelId, item) => void` | - | A different entry was picked in a switch menu |
|
|
1381
|
+
| `onOpen` | `(levelId) => void` | - | A switch menu opened |
|
|
1382
|
+
| `onCreate` | `(levelId, { levelId, value }) => void` | - | Adds "New {label}" to every level's menu, such as "New project" |
|
|
1383
|
+
| `onManage` | `(levelId, { levelId, value }) => void` | - | Adds "Manage {pluralLabel}" to every level's menu, such as "Manage projects" |
|
|
1384
|
+
| `showLabels` | `boolean` | `false` | Show each level's name (Organization, Project) in small text above it |
|
|
1385
|
+
| `showIcons` | `boolean` | `true` | Show each level's `icon` before its name. Set `false` to hide them; `showLabels` replaces them. Hovering the icon shows the level name; screen readers hear it through `aria-describedby` |
|
|
1386
|
+
| `linkComponent` | `ElementType` | `'a'` | Used for items with `href`, such as a router `Link` |
|
|
1387
|
+
| `separator` | `ReactNode` | `'/'` | Node between segments |
|
|
1388
|
+
|
|
1389
|
+
`HeaderBreadcrumbsLevel`: `id`, `label`, `icon`, `items`, `selectedId`, `selectedItem` (name fallback before items load), `openLabel`, `loading`, `error`, `emptyText`, `menuTitle`, `searchPlaceholder`, `searchable` (`'auto'` shows search above 6 items), `pluralLabel`, `createAction` and `manageAction` (relabel, add `href`, own `onClick`, or `false` to hide the built-in action for that level), and `actions` (more `{ key, label, icon, href, onClick }` items).
|
|
1390
|
+
|
|
1391
|
+
Every action's `onClick(event, { levelId, value })` runs after the menu closes. With `href`, the action renders through `linkComponent`; call `event.preventDefault()` to run your own logic instead of navigating. A level's own `onClick` wins over `onCreate` / `onManage`.
|
|
1392
|
+
|
|
1393
|
+
`HeaderBreadcrumbsItem`: `id`, `name`, `description`, `avatar`, `href`, `disabled`.
|
|
1394
|
+
|
|
1395
|
+
### useHeaderBreadcrumbs
|
|
1396
|
+
|
|
1397
|
+
Holds the selection, fetches each level from its parents' selection, and aborts stale requests. Picking a different entry clears the levels under it. Clicking a name drops the levels under it (`truncateOnNavigate`, default `true`).
|
|
1398
|
+
|
|
1399
|
+
| Option | Type | Description |
|
|
1400
|
+
|--------|------|-------------|
|
|
1401
|
+
| `levels` | `HeaderBreadcrumbsLevelConfig[]` | Level display props plus `fetchItems({ parents, signal })` or fixed `items` |
|
|
1402
|
+
| `value` / `defaultValue` | `HeaderBreadcrumbsValue` | Controlled or initial selection (`Record<levelId, itemId>`) |
|
|
1403
|
+
| `onChange` | `(value, change) => void` | `change.type` is `select`, `navigate`, `clear` or `set` |
|
|
1404
|
+
| `onNavigate` | `(levelId, item) => void` | A name was clicked |
|
|
1405
|
+
| `refreshOnOpen` | `boolean` | Fetch a level again each time its menu opens |
|
|
1406
|
+
| `formatError` | `(error, levelId) => ReactNode` | Message for a failed fetch |
|
|
1407
|
+
| `persist` | `boolean \| { key?, storage?, sync? }` | Keep the selected ids (not the items) in `localStorage` (default key `oxygen-ui:header-breadcrumbs`). Apps on the same origin share it and, with `sync` (default `true`), follow each other's changes; `onChange` gets type `sync`. Uncontrolled, the stored value wins over `defaultValue` |
|
|
1408
|
+
|
|
1409
|
+
Returns `value`, `levels`, `selected` (item per level), `select`, `clear`, `setValue`, `refresh`, `setItems`, `addItem`, `updateItem`, `removeItem`, and `breadcrumbProps` to spread on `HeaderBreadcrumbs`.
|
|
1410
|
+
|
|
1411
|
+
### Usage
|
|
1412
|
+
|
|
1413
|
+
```tsx
|
|
1414
|
+
const breadcrumb = useHeaderBreadcrumbs({
|
|
1415
|
+
levels: [
|
|
1416
|
+
{ id: 'organization', label: 'Organization', fetchItems: ({ signal }) => api.organizations({ signal }) },
|
|
1417
|
+
{ id: 'project', label: 'Project', fetchItems: ({ parents, signal }) => api.projects(parents.organization, { signal }) },
|
|
1418
|
+
{ id: 'component', label: 'Component', fetchItems: ({ parents, signal }) => api.components(parents.project, { signal }) },
|
|
1419
|
+
],
|
|
1420
|
+
value: valueFromRoute,
|
|
1421
|
+
onChange: (next) => navigate(routeFor(next)),
|
|
1422
|
+
});
|
|
1423
|
+
|
|
1424
|
+
<Header.Switchers>
|
|
1425
|
+
<HeaderBreadcrumbs {...breadcrumb.breadcrumbProps} />
|
|
1426
|
+
</Header.Switchers>
|
|
1427
|
+
|
|
1428
|
+
// After creating, renaming or deleting:
|
|
1429
|
+
breadcrumb.addItem('project', created);
|
|
1430
|
+
breadcrumb.updateItem('project', id, { name: 'New name' });
|
|
1431
|
+
breadcrumb.removeItem('project', id);
|
|
1432
|
+
|
|
1433
|
+
// Share the selection across apps on the same origin:
|
|
1434
|
+
useHeaderBreadcrumbs({ levels, persist: true });
|
|
1435
|
+
const { organization, project } = useHeaderBreadcrumbsValue(); // from any app, re-renders on change
|
|
1436
|
+
readHeaderBreadcrumbsState()?.value.organization; // outside React
|
|
1437
|
+
clearHeaderBreadcrumbsState(); // on sign-out
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
localStorage is per origin (protocol, host and port), so apps on different subdomains do not share it.
|
|
1441
|
+
|
|
1442
|
+
---
|
|
1443
|
+
|
|
1364
1444
|
## AppSwitcher
|
|
1365
1445
|
|
|
1366
1446
|
Popover for navigating between WSO2 Cloud platforms.
|
package/.claude/patterns.md
CHANGED
|
@@ -1144,7 +1144,6 @@ import {
|
|
|
1144
1144
|
OxygenTheme,
|
|
1145
1145
|
AcrylicOrangeTheme,
|
|
1146
1146
|
AcrylicPurpleTheme,
|
|
1147
|
-
ChoreoLabsTheme,
|
|
1148
1147
|
ClassicTheme,
|
|
1149
1148
|
HighContrastTheme,
|
|
1150
1149
|
PaleBaseTheme,
|
|
@@ -1159,7 +1158,6 @@ const themes = [
|
|
|
1159
1158
|
{ key: 'default', label: 'Default', theme: OxygenTheme },
|
|
1160
1159
|
{ key: 'orange', label: 'Acrylic Orange', theme: AcrylicOrangeTheme },
|
|
1161
1160
|
{ key: 'purple', label: 'Acrylic Purple', theme: AcrylicPurpleTheme },
|
|
1162
|
-
{ key: 'choreoLabs', label: 'Choreo Labs', theme: ChoreoLabsTheme },
|
|
1163
1161
|
{ key: 'classic', label: 'Classic', theme: ClassicTheme },
|
|
1164
1162
|
{ key: 'highContrast', label: 'High Contrast', theme: HighContrastTheme },
|
|
1165
1163
|
{ key: 'paleBase', label: 'Pale Base', theme: PaleBaseTheme },
|
|
@@ -86,7 +86,7 @@ Suggestions follow these rules:
|
|
|
86
86
|
|
|
87
87
|
## How it behaves
|
|
88
88
|
|
|
89
|
-
- The label renders as a `FormLabel` above the select and keeps its colour on focus and in the error state; the error shows on the field's border and in helper text. Focus shows only on the field: in the
|
|
89
|
+
- The label renders as a `FormLabel` above the select and keeps its colour on focus and in the error state; the error shows on the field's border and in helper text. Focus shows only on the field: in the default theme, a text-colour border with a Cobalt ring, the same as fixed-label text fields.
|
|
90
90
|
- The label names the combobox through `labelId` (or `htmlFor` with `native`), so screen readers announce it. Do not add your own `aria-label` when a label is set.
|
|
91
91
|
- `sx`, `className`, `style`, `fullWidth` and `ref` apply to the outer wrapper that holds the label and the select. `size`, `variant`, `required`, `error` and `disabled` apply to both.
|
|
92
92
|
- `placeholder` shows text in the field while nothing is selected (an empty value: `''`, `null`, `undefined` or `[]`), in the secondary text colour so it meets contrast requirements. It works with a custom `renderValue`. Native selects ignore it, so give them an empty option with the developer's placeholder text instead: `<option value="">Select a role</option>`.
|
package/.claude/theming.md
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
| Theme | Import | Description |
|
|
16
16
|
|-------|--------|-------------|
|
|
17
|
-
| OxygenTheme | `OxygenTheme` | Default theme (
|
|
17
|
+
| OxygenTheme | `OxygenTheme` | Default theme (brand colours, Sora font and flat surfaces) |
|
|
18
18
|
| Acrylic Orange | `AcrylicOrangeTheme` | Glass-morphism effects, orange primary |
|
|
19
19
|
| Acrylic Purple | `AcrylicPurpleTheme` | Glass-morphism with purple accents |
|
|
20
|
-
| Choreo Labs | `ChoreoLabsTheme` | Choreo Labs brand theme (Acrylic look with Choreo Labs colours and Sora font) |
|
|
21
20
|
| Classic | `ClassicTheme` | Standard flat design |
|
|
22
21
|
| High Contrast | `HighContrastTheme` | Accessibility-focused with high contrast colors |
|
|
23
22
|
| Pale Base | `PaleBaseTheme` | Minimal color palette for subtle interfaces |
|
|
@@ -29,7 +28,6 @@ import {
|
|
|
29
28
|
OxygenTheme,
|
|
30
29
|
AcrylicOrangeTheme,
|
|
31
30
|
AcrylicPurpleTheme,
|
|
32
|
-
ChoreoLabsTheme,
|
|
33
31
|
ClassicTheme,
|
|
34
32
|
HighContrastTheme,
|
|
35
33
|
PaleBaseTheme,
|
|
@@ -67,7 +65,6 @@ import {
|
|
|
67
65
|
OxygenTheme,
|
|
68
66
|
AcrylicOrangeTheme,
|
|
69
67
|
AcrylicPurpleTheme,
|
|
70
|
-
ChoreoLabsTheme,
|
|
71
68
|
ClassicTheme,
|
|
72
69
|
HighContrastTheme,
|
|
73
70
|
PaleBaseTheme,
|
|
@@ -80,7 +77,6 @@ import {
|
|
|
80
77
|
{ key: 'default', label: 'Default', theme: OxygenTheme },
|
|
81
78
|
{ key: 'orange', label: 'Acrylic Orange', theme: AcrylicOrangeTheme },
|
|
82
79
|
{ key: 'purple', label: 'Acrylic Purple', theme: AcrylicPurpleTheme },
|
|
83
|
-
{ key: 'choreoLabs', label: 'Choreo Labs', theme: ChoreoLabsTheme },
|
|
84
80
|
{ key: 'classic', label: 'Classic', theme: ClassicTheme },
|
|
85
81
|
{ key: 'highContrast', label: 'High Contrast', theme: HighContrastTheme },
|
|
86
82
|
{ key: 'paleBase', label: 'Pale Base', theme: PaleBaseTheme },
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ yarn add @wso2/oxygen-ui @emotion/react @emotion/styled @mui/material
|
|
|
12
12
|
pnpm add @wso2/oxygen-ui @emotion/react @emotion/styled @mui/material
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
**Note:** The Inter Variable and Sora Variable (used by
|
|
15
|
+
**Note:** The Inter Variable and Sora Variable (used by the default theme) fonts are automatically bundled and loaded when you import from `@wso2/oxygen-ui`. No additional setup required!
|
|
16
16
|
|
|
17
17
|
### Peer Dependencies
|
|
18
18
|
|
|
@@ -21,12 +21,47 @@ import { FooterCopyright } from './FooterCopyright';
|
|
|
21
21
|
import { FooterVersion } from './FooterVersion';
|
|
22
22
|
import { FooterLink } from './FooterLink';
|
|
23
23
|
import { FooterDivider } from './FooterDivider';
|
|
24
|
+
/**
|
|
25
|
+
* Theme tokens used in this component:
|
|
26
|
+
*
|
|
27
|
+
* Text Hierarchy:
|
|
28
|
+
* - `text.secondary` - Copyright text, link default color
|
|
29
|
+
* - `text.primary` - Link hover color
|
|
30
|
+
* - `text.disabled` - Version number (lowest emphasis)
|
|
31
|
+
*
|
|
32
|
+
* Background & Borders:
|
|
33
|
+
* - `background.paper` - Footer background
|
|
34
|
+
* - `divider` - Top border color
|
|
35
|
+
*
|
|
36
|
+
* Typography variants:
|
|
37
|
+
* - variant="caption" - Small footer text (12px default)
|
|
38
|
+
*
|
|
39
|
+
* Link component:
|
|
40
|
+
* - underline="hover" - Only show underline on hover
|
|
41
|
+
* - Custom fontSize: 12 for consistent sizing
|
|
42
|
+
*
|
|
43
|
+
* Responsive Layout:
|
|
44
|
+
* - flexDirection: { xs: 'column', sm: 'row' }
|
|
45
|
+
* - alignItems: { xs: 'flex-start', sm: 'center' }
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* `bar` is a full-width bar with a top border and a paper background, with the copyright on the left
|
|
49
|
+
* and the links on the right. `plain` has no background, and an inset divider set to the height of the
|
|
50
|
+
* sidebar's footer row so it lines up with the divider above `Sidebar.CollapseToggle`.
|
|
51
|
+
*/
|
|
52
|
+
export type FooterVariant = 'bar' | 'plain';
|
|
24
53
|
/**
|
|
25
54
|
* Props for the Footer root component.
|
|
26
55
|
*/
|
|
27
56
|
export interface FooterProps {
|
|
28
57
|
/** Child elements (Copyright, Version, Link, Divider components) */
|
|
29
58
|
children: React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Look of the footer: `bar` (default), or `plain` (no bar, with an inset divider that lines up with the
|
|
61
|
+
* sidebar's collapse toggle divider).
|
|
62
|
+
* @default 'bar'
|
|
63
|
+
*/
|
|
64
|
+
variant?: FooterVariant;
|
|
30
65
|
/** Additional sx props */
|
|
31
66
|
sx?: SxProps<Theme>;
|
|
32
67
|
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { SxProps, Theme } from '@mui/material/styles';
|
|
20
|
+
import type { HeaderBreadcrumbsActionContext, HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel } from './types';
|
|
21
|
+
/**
|
|
22
|
+
* Props for HeaderBreadcrumbs.
|
|
23
|
+
*/
|
|
24
|
+
export interface HeaderBreadcrumbsProps extends Omit<React.ComponentPropsWithoutRef<'nav'>, 'onSelect'> {
|
|
25
|
+
/**
|
|
26
|
+
* Levels in order, for example organization, project and component. The trail
|
|
27
|
+
* runs up to the first level without a selection, which shows as a › button. Leave
|
|
28
|
+
* a level out to remove it, such as the component level in an app without one.
|
|
29
|
+
*/
|
|
30
|
+
levels: HeaderBreadcrumbsLevel[];
|
|
31
|
+
/** Called when a name is clicked, to go to that entry's page. */
|
|
32
|
+
onNavigate?: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
33
|
+
/** Called when a different entry is picked in a level's switch menu. */
|
|
34
|
+
onSelect?: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
35
|
+
/** Called when a level's switch menu opens. Use it to load or refresh that level. */
|
|
36
|
+
onOpen?: (levelId: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Adds "New {label}" to every level's menu, such as "New project". Called with the
|
|
39
|
+
* level and the current selection, so you can open a dialog or navigate. A level's
|
|
40
|
+
* `createAction` can relabel, link or hide it.
|
|
41
|
+
*/
|
|
42
|
+
onCreate?: (levelId: string, context: HeaderBreadcrumbsActionContext) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Adds "Manage {pluralLabel}" to every level's menu, such as "Manage projects". A
|
|
45
|
+
* level's `manageAction` can relabel, link or hide it.
|
|
46
|
+
*/
|
|
47
|
+
onManage?: (levelId: string, context: HeaderBreadcrumbsActionContext) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Show each level's name (such as "Organization") in small text above it, so users
|
|
50
|
+
* can tell the levels apart.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
showLabels?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Show each level's `icon` before its name, so users can tell the levels apart
|
|
56
|
+
* without labels. Hovering an icon shows the level name. Levels without an `icon`
|
|
57
|
+
* show none, and `showLabels` replaces the icons.
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
showIcons?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Element used for items with an `href`, such as a router `Link`.
|
|
63
|
+
* @default 'a'
|
|
64
|
+
*/
|
|
65
|
+
linkComponent?: React.ElementType;
|
|
66
|
+
/**
|
|
67
|
+
* Node between segments.
|
|
68
|
+
* @default '/'
|
|
69
|
+
*/
|
|
70
|
+
separator?: React.ReactNode;
|
|
71
|
+
/** The sx prop for styling with the MUI system. */
|
|
72
|
+
sx?: SxProps<Theme>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* HeaderBreadcrumbs - A trail of the current organization, project and component.
|
|
76
|
+
*
|
|
77
|
+
* Each segment has two targets. The name goes to that entry's page. The caret opens a
|
|
78
|
+
* menu to switch to another entry of the same level. The last segment is the current
|
|
79
|
+
* page. While a level has no selection, it shows as a › button after the trail,
|
|
80
|
+
* named "Open {label}", such as "Open project" on an organization page. Pair it with `useHeaderBreadcrumbs` to fetch each level's items and keep the
|
|
81
|
+
* selection, and place it in `Header.Switchers`.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const breadcrumb = useHeaderBreadcrumbs({
|
|
86
|
+
* levels: [
|
|
87
|
+
* { id: 'organization', label: 'Organization', fetchItems: fetchOrganizations },
|
|
88
|
+
* { id: 'project', label: 'Project', fetchItems: ({ parents }) => fetchProjects(parents.organization) },
|
|
89
|
+
* ],
|
|
90
|
+
* defaultValue: { organization: 'thunder-id', project: 'thunderid' },
|
|
91
|
+
* onNavigate: (levelId, item) => navigate(item.href!),
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* <Header.Switchers>
|
|
95
|
+
* <HeaderBreadcrumbs {...breadcrumb.breadcrumbProps} />
|
|
96
|
+
* </Header.Switchers>
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare const HeaderBreadcrumbs: React.ForwardRefExoticComponent<HeaderBreadcrumbsProps & React.RefAttributes<HTMLElement>>;
|
|
100
|
+
export default HeaderBreadcrumbs;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { HeaderBreadcrumbsActionContext, HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel, HeaderBreadcrumbsValue } from './types';
|
|
20
|
+
/** Height of the name row with labels, so names, carets and the open button line up. */
|
|
21
|
+
export declare const LABELED_ROW_HEIGHT = 32;
|
|
22
|
+
/**
|
|
23
|
+
* Props for one segment of the trail.
|
|
24
|
+
*/
|
|
25
|
+
export interface HeaderBreadcrumbsSegmentProps {
|
|
26
|
+
/** The level this segment shows. */
|
|
27
|
+
level: HeaderBreadcrumbsLevel;
|
|
28
|
+
/** The last segment is the current page, marked with `aria-current="page"`. */
|
|
29
|
+
current: boolean;
|
|
30
|
+
/** Element used for items with an `href`. */
|
|
31
|
+
linkComponent: React.ElementType;
|
|
32
|
+
/** Called when the name is clicked. */
|
|
33
|
+
onNavigate?: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
34
|
+
/** Called when an entry in the switch menu is picked. */
|
|
35
|
+
onSelect?: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
36
|
+
/** Called when the switch menu opens. */
|
|
37
|
+
onOpen?: (levelId: string) => void;
|
|
38
|
+
/** Show the level name in small text above the segment. */
|
|
39
|
+
showLabel?: boolean;
|
|
40
|
+
/** Show the level's `icon` before the name. Hovering the icon shows the level name. */
|
|
41
|
+
showIcon?: boolean;
|
|
42
|
+
/** Selected id of every level, passed to action handlers. */
|
|
43
|
+
value?: HeaderBreadcrumbsValue;
|
|
44
|
+
/** Adds "New {label}" to the menu. */
|
|
45
|
+
onCreate?: (levelId: string, context: HeaderBreadcrumbsActionContext) => void;
|
|
46
|
+
/** Adds "Manage {pluralLabel}" to the menu. */
|
|
47
|
+
onManage?: (levelId: string, context: HeaderBreadcrumbsActionContext) => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* HeaderBreadcrumbsSegment - The name of the selected entry, and a caret that opens
|
|
51
|
+
* a menu to switch to another entry of the same level.
|
|
52
|
+
*/
|
|
53
|
+
export declare const HeaderBreadcrumbsSegment: React.FC<HeaderBreadcrumbsSegmentProps>;
|
|
54
|
+
export default HeaderBreadcrumbsSegment;
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
export { HeaderBreadcrumbs, default } from './HeaderBreadcrumbs';
|
|
19
|
+
export type { HeaderBreadcrumbsProps } from './HeaderBreadcrumbs';
|
|
20
|
+
export { HeaderBreadcrumbsSegment } from './HeaderBreadcrumbsSegment';
|
|
21
|
+
export type { HeaderBreadcrumbsSegmentProps } from './HeaderBreadcrumbsSegment';
|
|
22
|
+
export { useHeaderBreadcrumbs } from './useHeaderBreadcrumbs';
|
|
23
|
+
export type { HeaderBreadcrumbsChange, HeaderBreadcrumbsFetchContext, HeaderBreadcrumbsLevelConfig, UseHeaderBreadcrumbsOptions, UseHeaderBreadcrumbsReturn, } from './useHeaderBreadcrumbs';
|
|
24
|
+
export { HEADER_BREADCRUMBS_STORAGE_KEY, useHeaderBreadcrumbsValue, readHeaderBreadcrumbsState, writeHeaderBreadcrumbsState, clearHeaderBreadcrumbsState, subscribeHeaderBreadcrumbsState, } from './persistence';
|
|
25
|
+
export type { HeaderBreadcrumbsPersistOptions, HeaderBreadcrumbsStoredState, } from './persistence';
|
|
26
|
+
export type { HeaderBreadcrumbsAction, HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel, HeaderBreadcrumbsValue, } from './types';
|
|
@@ -0,0 +1,87 @@
|
|
|
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 type { HeaderBreadcrumbsValue } from './types';
|
|
19
|
+
/** Default storage key. Every app that uses the same key shares one selection. */
|
|
20
|
+
export declare const HEADER_BREADCRUMBS_STORAGE_KEY = "oxygen-ui:header-breadcrumbs";
|
|
21
|
+
/**
|
|
22
|
+
* What is kept in storage: the selected id of each level, never the items. Readable by
|
|
23
|
+
* any app on the same origin, with or without HeaderBreadcrumbs, through
|
|
24
|
+
* `useHeaderBreadcrumbsValue` or `readHeaderBreadcrumbsState`.
|
|
25
|
+
*/
|
|
26
|
+
export interface HeaderBreadcrumbsStoredState {
|
|
27
|
+
version: 1;
|
|
28
|
+
/** Selected id of each level. */
|
|
29
|
+
value: HeaderBreadcrumbsValue;
|
|
30
|
+
/** When the state was written, in milliseconds since the epoch. */
|
|
31
|
+
updatedAt: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Where and how the state is kept.
|
|
35
|
+
*/
|
|
36
|
+
export interface HeaderBreadcrumbsPersistOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Storage key. Apps that share a key share the selection.
|
|
39
|
+
* @default 'oxygen-ui:header-breadcrumbs'
|
|
40
|
+
*/
|
|
41
|
+
key?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Storage area. Pass `sessionStorage` to keep it per tab.
|
|
44
|
+
* @default window.localStorage
|
|
45
|
+
*/
|
|
46
|
+
storage?: Storage;
|
|
47
|
+
/**
|
|
48
|
+
* Follow changes made by other tabs, windows and apps on the same origin, and by
|
|
49
|
+
* other breadcrumbs on the same page.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
sync?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reads the stored breadcrumb state, or `null` when there is none or it cannot be read.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const organizationId = readHeaderBreadcrumbsState()?.value.organization;
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const readHeaderBreadcrumbsState: (options?: HeaderBreadcrumbsPersistOptions) => HeaderBreadcrumbsStoredState | null;
|
|
63
|
+
/**
|
|
64
|
+
* Writes the selection and tells listeners on this page.
|
|
65
|
+
*/
|
|
66
|
+
export declare const writeHeaderBreadcrumbsState: (value: HeaderBreadcrumbsValue, options?: HeaderBreadcrumbsPersistOptions) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Removes the stored breadcrumb state, such as on sign-out.
|
|
69
|
+
*/
|
|
70
|
+
export declare const clearHeaderBreadcrumbsState: (options?: HeaderBreadcrumbsPersistOptions) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Calls `listener` when the stored state changes, from another tab, window or app on
|
|
73
|
+
* the same origin, or from this page. Returns a function that stops listening.
|
|
74
|
+
*/
|
|
75
|
+
export declare const subscribeHeaderBreadcrumbsState: (listener: (state: HeaderBreadcrumbsStoredState | null) => void, options?: HeaderBreadcrumbsPersistOptions) => (() => void);
|
|
76
|
+
/**
|
|
77
|
+
* Returns the stored selection, such as `{ organization: 'wso2', project: 'oxygen-ui' }`,
|
|
78
|
+
* and re-renders when it changes in this page, another tab or another app on the same
|
|
79
|
+
* origin. Returns an empty object when nothing is stored. Works without rendering
|
|
80
|
+
* HeaderBreadcrumbs, so any app can read the current context.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```tsx
|
|
84
|
+
* const { organization, project } = useHeaderBreadcrumbsValue();
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare const useHeaderBreadcrumbsValue: (options?: HeaderBreadcrumbsPersistOptions) => HeaderBreadcrumbsValue;
|