@wso2/oxygen-ui 0.24.0 → 0.26.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 +2 -7
- package/.ai/components.md +4 -4
- package/.ai/patterns.md +0 -4
- package/.ai/theming.md +0 -11
- package/.claude/components.md +128 -4
- package/.claude/patterns.md +0 -4
- package/.claude/theming.md +0 -8
- package/README.md +1 -1
- package/bin/cli.js +1 -1
- package/dist/animations/PageLoader/PageLoader.d.ts +92 -0
- package/dist/animations/PageLoader/PageLoaderIcon.d.ts +20 -0
- package/dist/animations/PageLoader/PageLoaderWordmark.d.ts +19 -0
- package/dist/animations/PageLoader/index.d.ts +4 -0
- package/dist/animations/index.d.ts +2 -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/index.d.ts +2 -0
- package/dist/index.js +3001 -2388
- package/dist/index.js.map +4 -4
- package/dist/styles/OxygenThemeBase.d.ts +16 -1
- package/dist/styles/Themes/index.d.ts +0 -3
- package/dist/utils/createOxygenTheme.d.ts +2 -2
- package/package.json +5 -3
- package/dist/styles/Themes/WSO2Theme.d.ts +0 -20
|
@@ -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;
|
|
@@ -0,0 +1,125 @@
|
|
|
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 * as React from 'react';
|
|
19
|
+
/**
|
|
20
|
+
* One entry a level can switch to, such as an organization, a project or a component.
|
|
21
|
+
*/
|
|
22
|
+
export interface HeaderBreadcrumbsItem {
|
|
23
|
+
/** Stable identifier. Stored in the breadcrumb value. */
|
|
24
|
+
id: string;
|
|
25
|
+
/** Display name, shown in the trail and in the switch menu. */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Secondary text under the name in the switch menu. */
|
|
28
|
+
description?: string;
|
|
29
|
+
/** Leading node in the switch menu, such as an Avatar or an icon. */
|
|
30
|
+
avatar?: React.ReactNode;
|
|
31
|
+
/** When set, the trail name and the menu entry render as links to this URL. */
|
|
32
|
+
href?: string;
|
|
33
|
+
/** A disabled entry is listed but cannot be picked. */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What an action handler receives.
|
|
38
|
+
*/
|
|
39
|
+
export interface HeaderBreadcrumbsActionContext {
|
|
40
|
+
/** The level whose menu holds the action. */
|
|
41
|
+
levelId: string;
|
|
42
|
+
/** Selected id of every level, such as the organization a new project goes into. */
|
|
43
|
+
value: HeaderBreadcrumbsValue;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An action at the bottom of a level's menu, such as "New project" or "Manage projects".
|
|
47
|
+
*/
|
|
48
|
+
export interface HeaderBreadcrumbsAction {
|
|
49
|
+
/** Stable key. */
|
|
50
|
+
key: string;
|
|
51
|
+
/** Visible label. */
|
|
52
|
+
label: React.ReactNode;
|
|
53
|
+
/** Leading icon. */
|
|
54
|
+
icon?: React.ReactNode;
|
|
55
|
+
/** Renders the action as a link to this URL, through `linkComponent`. */
|
|
56
|
+
href?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Called after the menu closes. With `href`, call `event.preventDefault()` to run
|
|
59
|
+
* your own logic in place of following the link.
|
|
60
|
+
*/
|
|
61
|
+
onClick?: (event: React.MouseEvent<HTMLElement>, context: HeaderBreadcrumbsActionContext) => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Changes to a built-in action for one level. `false` hides it.
|
|
65
|
+
*/
|
|
66
|
+
export type HeaderBreadcrumbsActionOverride = false | Partial<Omit<HeaderBreadcrumbsAction, 'key'>>;
|
|
67
|
+
/**
|
|
68
|
+
* One level of the trail, ready to render. `useHeaderBreadcrumbs` builds these.
|
|
69
|
+
*/
|
|
70
|
+
export interface HeaderBreadcrumbsLevel {
|
|
71
|
+
/** Level key, for example `organization`. */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Level name, for example `Organization`. Used in menu titles and accessible names. */
|
|
74
|
+
label: string;
|
|
75
|
+
/**
|
|
76
|
+
* Icon for the level, such as a building for organizations. Shown before the name
|
|
77
|
+
* unless `showIcons` is `false`.
|
|
78
|
+
*/
|
|
79
|
+
icon?: React.ReactNode;
|
|
80
|
+
/** Entries the level can switch to. */
|
|
81
|
+
items: HeaderBreadcrumbsItem[];
|
|
82
|
+
/** Selected entry id. A level without a selection ends the trail. */
|
|
83
|
+
selectedId?: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* The selected entry, used for its name while `items` does not include it yet,
|
|
86
|
+
* such as a name kept in storage by another app.
|
|
87
|
+
*/
|
|
88
|
+
selectedItem?: HeaderBreadcrumbsItem | null;
|
|
89
|
+
/** Items are being fetched. The menu shows a progress indicator. */
|
|
90
|
+
loading?: boolean;
|
|
91
|
+
/** Fetching failed. Shown in the menu in place of the list. */
|
|
92
|
+
error?: React.ReactNode;
|
|
93
|
+
/** Shown in the menu when there are no items. Defaults to "No {label} found". */
|
|
94
|
+
emptyText?: React.ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* Tooltip and accessible name of the › button shown while this level has no
|
|
97
|
+
* selection, such as on an organization page. Defaults to "Open {label}".
|
|
98
|
+
*/
|
|
99
|
+
openLabel?: string;
|
|
100
|
+
/** Title over the menu. Defaults to "Switch {label}", or `openLabel` with no selection. */
|
|
101
|
+
menuTitle?: React.ReactNode;
|
|
102
|
+
/** Placeholder for the search field. Defaults to "Find {label}…". */
|
|
103
|
+
searchPlaceholder?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Show a search field in the menu. Defaults to `'auto'`, which shows it when the
|
|
106
|
+
* level has more than 6 items.
|
|
107
|
+
*/
|
|
108
|
+
searchable?: boolean | 'auto';
|
|
109
|
+
/** Plural level name for "Manage {pluralLabel}". Defaults to `label` plus "s". */
|
|
110
|
+
pluralLabel?: string;
|
|
111
|
+
/**
|
|
112
|
+
* "New {label}" for this level. Shown when HeaderBreadcrumbs has `onCreate`, or
|
|
113
|
+
* when this sets `onClick` or `href`. `false` hides it.
|
|
114
|
+
*/
|
|
115
|
+
createAction?: HeaderBreadcrumbsActionOverride;
|
|
116
|
+
/**
|
|
117
|
+
* "Manage {pluralLabel}" for this level. Shown when HeaderBreadcrumbs has
|
|
118
|
+
* `onManage`, or when this sets `onClick` or `href`. `false` hides it.
|
|
119
|
+
*/
|
|
120
|
+
manageAction?: HeaderBreadcrumbsActionOverride;
|
|
121
|
+
/** More actions, after "New" and "Manage". */
|
|
122
|
+
actions?: HeaderBreadcrumbsAction[];
|
|
123
|
+
}
|
|
124
|
+
/** Selected item id for each level id. */
|
|
125
|
+
export type HeaderBreadcrumbsValue = Record<string, string>;
|
|
@@ -0,0 +1,150 @@
|
|
|
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 { HeaderBreadcrumbsProps } from './HeaderBreadcrumbs';
|
|
20
|
+
import { type HeaderBreadcrumbsPersistOptions } from './persistence';
|
|
21
|
+
import type { HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel, HeaderBreadcrumbsValue } from './types';
|
|
22
|
+
/**
|
|
23
|
+
* What `fetchItems` receives.
|
|
24
|
+
*/
|
|
25
|
+
export interface HeaderBreadcrumbsFetchContext {
|
|
26
|
+
/** Selected ids of the levels above this one, for example `{ organization: 'wso2' }`. */
|
|
27
|
+
parents: HeaderBreadcrumbsValue;
|
|
28
|
+
/** Aborted when the parents change, the level is refreshed again, or the hook unmounts. */
|
|
29
|
+
signal: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One level the hook manages.
|
|
33
|
+
*/
|
|
34
|
+
export interface HeaderBreadcrumbsLevelConfig extends Omit<HeaderBreadcrumbsLevel, 'items' | 'selectedId' | 'loading' | 'error'> {
|
|
35
|
+
/**
|
|
36
|
+
* Loads the level's items. Called when every level above it has a selection, and
|
|
37
|
+
* again when one of those selections changes. The first level without a selection
|
|
38
|
+
* is fetched too, so its "Open {label}" menu is ready.
|
|
39
|
+
*/
|
|
40
|
+
fetchItems?: (context: HeaderBreadcrumbsFetchContext) => Promise<HeaderBreadcrumbsItem[]>;
|
|
41
|
+
/** Fixed items, used when there is no `fetchItems` or before it resolves. */
|
|
42
|
+
items?: HeaderBreadcrumbsItem[];
|
|
43
|
+
}
|
|
44
|
+
/** Why the value changed. */
|
|
45
|
+
export interface HeaderBreadcrumbsChange {
|
|
46
|
+
/** `sync` means another tab, app or breadcrumb changed the stored state. */
|
|
47
|
+
type: 'select' | 'navigate' | 'clear' | 'set' | 'sync';
|
|
48
|
+
/** The level that was acted on. Absent for `set`. */
|
|
49
|
+
levelId?: string;
|
|
50
|
+
/** The picked or clicked item, for `select` and `navigate`. */
|
|
51
|
+
item?: HeaderBreadcrumbsItem;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for useHeaderBreadcrumbs.
|
|
55
|
+
*/
|
|
56
|
+
export interface UseHeaderBreadcrumbsOptions {
|
|
57
|
+
/** Levels in order. */
|
|
58
|
+
levels: HeaderBreadcrumbsLevelConfig[];
|
|
59
|
+
/** Controlled selection. Pair with `onChange`. */
|
|
60
|
+
value?: HeaderBreadcrumbsValue;
|
|
61
|
+
/** Initial selection when uncontrolled. */
|
|
62
|
+
defaultValue?: HeaderBreadcrumbsValue;
|
|
63
|
+
/** Called with the next selection, such as to route to the new context. */
|
|
64
|
+
onChange?: (value: HeaderBreadcrumbsValue, change: HeaderBreadcrumbsChange) => void;
|
|
65
|
+
/** Called when a name in the trail is clicked. */
|
|
66
|
+
onNavigate?: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Clicking a name drops the levels under it, because the user is now on that
|
|
69
|
+
* entry's page.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
truncateOnNavigate?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Fetch a level again each time its menu opens.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
refreshOnOpen?: boolean;
|
|
78
|
+
/** Message for a failed fetch. Defaults to the error's `message`. */
|
|
79
|
+
formatError?: (error: unknown, levelId: string) => React.ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* Keep the selection in `localStorage` (or the given storage) so other apps on the
|
|
82
|
+
* same origin can read it and start where the user left off. Only the selected ids
|
|
83
|
+
* are stored; each app fetches its own items. Read the value anywhere with
|
|
84
|
+
* `useHeaderBreadcrumbsValue`.
|
|
85
|
+
*
|
|
86
|
+
* Uncontrolled, the stored selection wins over `defaultValue`. Controlled, `value`
|
|
87
|
+
* wins and is written to storage. With `sync` (on by default), a change from another
|
|
88
|
+
* tab, app or breadcrumb updates this one and calls `onChange` with type `sync`.
|
|
89
|
+
* Read the state elsewhere with `readHeaderBreadcrumbsState`.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
persist?: boolean | HeaderBreadcrumbsPersistOptions;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* What useHeaderBreadcrumbs returns.
|
|
96
|
+
*/
|
|
97
|
+
export interface UseHeaderBreadcrumbsReturn {
|
|
98
|
+
/** Current selection. */
|
|
99
|
+
value: HeaderBreadcrumbsValue;
|
|
100
|
+
/** Levels with their items, selection and loading state, ready for HeaderBreadcrumbs. */
|
|
101
|
+
levels: HeaderBreadcrumbsLevel[];
|
|
102
|
+
/** The selected item of each level, or `null` while it is not selected or not loaded. */
|
|
103
|
+
selected: Record<string, HeaderBreadcrumbsItem | null>;
|
|
104
|
+
/** Select an item. Levels under it are cleared when the id changes. */
|
|
105
|
+
select: (levelId: string, itemId: string) => void;
|
|
106
|
+
/** Clear a level and every level under it. */
|
|
107
|
+
clear: (levelId: string) => void;
|
|
108
|
+
/** Replace the whole selection, for example from the URL. */
|
|
109
|
+
setValue: (value: HeaderBreadcrumbsValue) => void;
|
|
110
|
+
/** Fetch one level again, or every reachable level when no id is given. */
|
|
111
|
+
refresh: (levelId?: string) => Promise<void>;
|
|
112
|
+
/** Replace a level's items, for example after a mutation. */
|
|
113
|
+
setItems: (levelId: string, items: HeaderBreadcrumbsItem[] | ((items: HeaderBreadcrumbsItem[]) => HeaderBreadcrumbsItem[])) => void;
|
|
114
|
+
/** Add an item to a level, such as a newly created project. */
|
|
115
|
+
addItem: (levelId: string, item: HeaderBreadcrumbsItem) => void;
|
|
116
|
+
/** Change fields of one item, such as after a rename. */
|
|
117
|
+
updateItem: (levelId: string, itemId: string, patch: Partial<HeaderBreadcrumbsItem>) => void;
|
|
118
|
+
/** Remove an item. Removing the selected item clears that level and those under it. */
|
|
119
|
+
removeItem: (levelId: string, itemId: string) => void;
|
|
120
|
+
/** Spread onto HeaderBreadcrumbs. */
|
|
121
|
+
breadcrumbProps: Pick<HeaderBreadcrumbsProps, 'levels' | 'onNavigate' | 'onSelect' | 'onOpen'>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* useHeaderBreadcrumbs - Fetches and keeps the data behind a HeaderBreadcrumbs.
|
|
125
|
+
*
|
|
126
|
+
* Holds the selected id of each level, loads each level's items from its parents'
|
|
127
|
+
* selection, and drops stale responses when the parents change. Picking a different
|
|
128
|
+
* item clears the levels under it. Clicking a name drops the levels under it. Use the
|
|
129
|
+
* item helpers to keep the menus current after creating, renaming or deleting.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```tsx
|
|
133
|
+
* const breadcrumb = useHeaderBreadcrumbs({
|
|
134
|
+
* levels: [
|
|
135
|
+
* { id: 'organization', label: 'Organization', fetchItems: () => api.organizations() },
|
|
136
|
+
* {
|
|
137
|
+
* id: 'project',
|
|
138
|
+
* label: 'Project',
|
|
139
|
+
* fetchItems: ({ parents, signal }) => api.projects(parents.organization, { signal }),
|
|
140
|
+
* },
|
|
141
|
+
* ],
|
|
142
|
+
* value: fromRoute,
|
|
143
|
+
* onChange: (next) => navigate(toRoute(next)),
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* <HeaderBreadcrumbs {...breadcrumb.breadcrumbProps} />
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare const useHeaderBreadcrumbs: (options: UseHeaderBreadcrumbsOptions) => UseHeaderBreadcrumbsReturn;
|
|
150
|
+
export default useHeaderBreadcrumbs;
|
|
@@ -56,6 +56,8 @@ export { Header } from './Header';
|
|
|
56
56
|
export type { HeaderProps, HeaderSpacerProps, HeaderToggleProps, HeaderBrandProps, HeaderBrandLogoProps, HeaderBrandTitleProps, HeaderSwitchersProps, HeaderActionsProps, HeaderContextValue, } from './Header';
|
|
57
57
|
export { ContextSwitcher } from './ContextSwitcher';
|
|
58
58
|
export type { ContextSwitcherProps, ContextSwitcherValue, ContextSwitcherLevelProps, ContextSwitcherGroupProps, ContextSwitcherOptionProps, } from './ContextSwitcher';
|
|
59
|
+
export { HeaderBreadcrumbs, useHeaderBreadcrumbs, useHeaderBreadcrumbsValue, HEADER_BREADCRUMBS_STORAGE_KEY, readHeaderBreadcrumbsState, writeHeaderBreadcrumbsState, clearHeaderBreadcrumbsState, subscribeHeaderBreadcrumbsState, } from './HeaderBreadcrumbs';
|
|
60
|
+
export type { HeaderBreadcrumbsProps, HeaderBreadcrumbsItem, HeaderBreadcrumbsLevel, HeaderBreadcrumbsAction, HeaderBreadcrumbsValue, HeaderBreadcrumbsChange, HeaderBreadcrumbsFetchContext, HeaderBreadcrumbsLevelConfig, UseHeaderBreadcrumbsOptions, UseHeaderBreadcrumbsReturn, HeaderBreadcrumbsPersistOptions, HeaderBreadcrumbsStoredState, } from './HeaderBreadcrumbs';
|
|
59
61
|
export { AppSwitcher } from './AppSwitcher';
|
|
60
62
|
export type { AppSwitcherProps, AppSwitcherTriggerProps, AppSwitcherSectionProps, AppSwitcherAppProps, AppSwitcherAppItem, AppSwitcherAppTone, AppSwitcherFooterProps, AppSwitcherFooterLink, AppSwitcherContextValue, } from './AppSwitcher';
|
|
61
63
|
export { Sidebar, useSidebar } from './Sidebar';
|