@gravitee/graphene-core 3.26.3 → 3.27.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/USAGE_GUIDE.md +4 -2
- package/dist/composed/AppSidebar/SidebarNavigation.d.ts.map +1 -1
- package/dist/composed/AppSidebar/types.d.ts +6 -0
- package/dist/composed/AppSidebar/types.d.ts.map +1 -1
- package/dist/composed/AppSwitcher/AppSwitcher.d.ts +6 -0
- package/dist/composed/AppSwitcher/AppSwitcher.d.ts.map +1 -1
- package/dist/composed/ContentHeader/ContentHeader.d.ts.map +1 -1
- package/dist/composed/ContentHeader/breadcrumb-entry.d.ts +4 -0
- package/dist/composed/ContentHeader/breadcrumb-entry.d.ts.map +1 -1
- package/dist/composed/SelectorDropdown/SelectorDropdown.d.ts +6 -0
- package/dist/composed/SelectorDropdown/SelectorDropdown.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1017 -970
- package/dist/lib/breadcrumbs/buildLinearBreadcrumbs.d.ts +11 -2
- package/dist/lib/breadcrumbs/buildLinearBreadcrumbs.d.ts.map +1 -1
- package/dist/lib/links/NavLink.d.ts +33 -0
- package/dist/lib/links/NavLink.d.ts.map +1 -0
- package/dist/testing/menuLinkActions.d.ts +19 -0
- package/dist/testing/menuLinkActions.d.ts.map +1 -0
- package/package.json +1 -1
- package/snippets/context-sidebar-detail-page.tsx +7 -4
|
@@ -10,11 +10,20 @@ export interface LinearBreadcrumbSegment {
|
|
|
10
10
|
* Router-agnostic navigation (e.g. React Router `navigate` from `useNavigate()`).
|
|
11
11
|
*/
|
|
12
12
|
export type LinearBreadcrumbNavigate = (to: string) => void | Promise<void>;
|
|
13
|
+
export interface LinearBreadcrumbOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Turns a segment's `to` into the URL the browser opens, which makes the crumb a link that can be opened in a new
|
|
16
|
+
* tab. `to` is what `navigate` receives, so it may be relative or leave out the router's `basename`: this must
|
|
17
|
+
* resolve it the same way `navigate` does. Without it, crumbs stay buttons and cannot be opened in a new tab.
|
|
18
|
+
*/
|
|
19
|
+
readonly toHref?: (to: string) => string;
|
|
20
|
+
}
|
|
13
21
|
/**
|
|
14
22
|
* Builds {@link BreadcrumbEntry} values for `ContentHeader` and `useLayoutConfig` from ordered segments.
|
|
15
|
-
* The last segment is always label-only; earlier segments with `to` receive `onClick` that calls `navigate(to)
|
|
23
|
+
* The last segment is always label-only; earlier segments with `to` receive `onClick` that calls `navigate(to)`,
|
|
24
|
+
* and `href: toHref(to)` when {@link LinearBreadcrumbOptions.toHref} is given, so they can be opened in a new tab.
|
|
16
25
|
* Non-final segments without `to` are label-only (no link).
|
|
17
26
|
*/
|
|
18
|
-
declare function buildLinearBreadcrumbs(navigate: LinearBreadcrumbNavigate, segments: readonly LinearBreadcrumbSegment[]): BreadcrumbEntry[];
|
|
27
|
+
declare function buildLinearBreadcrumbs(navigate: LinearBreadcrumbNavigate, segments: readonly LinearBreadcrumbSegment[], options?: LinearBreadcrumbOptions): BreadcrumbEntry[];
|
|
19
28
|
export { buildLinearBreadcrumbs };
|
|
20
29
|
//# sourceMappingURL=buildLinearBreadcrumbs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildLinearBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/lib/breadcrumbs/buildLinearBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5E;;;;
|
|
1
|
+
{"version":3,"file":"buildLinearBreadcrumbs.d.ts","sourceRoot":"","sources":["../../../src/lib/breadcrumbs/buildLinearBreadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAErF;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5E,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CAC1C;AAED;;;;;GAKG;AACH,iBAAS,sBAAsB,CAC7B,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,EAAE,SAAS,uBAAuB,EAAE,EAC5C,OAAO,GAAE,uBAA4B,GACpC,eAAe,EAAE,CAqBnB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HTMLAttributes, Ref } from 'react';
|
|
2
|
+
interface NavLinkProps extends HTMLAttributes<HTMLElement> {
|
|
3
|
+
/** Renders a real link, so the browser can open it in a new tab. Without it, renders `fallback`. */
|
|
4
|
+
readonly href?: string;
|
|
5
|
+
/** Element rendered when there is no `href`. */
|
|
6
|
+
readonly fallback?: 'button' | 'div';
|
|
7
|
+
/**
|
|
8
|
+
* Lets the browser follow `href` after a plain click instead of cancelling it. For when no `onClick` navigates
|
|
9
|
+
* client-side but an `asChild` parent still merges one in (e.g. a Radix menu item closing its menu).
|
|
10
|
+
*/
|
|
11
|
+
readonly followHref?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Set when an `asChild` Radix menu item renders this link. Radix turns Enter into a click without its modifiers and
|
|
14
|
+
* cancels the key, so the link's own cmd/ctrl/shift+Enter never reaches the browser: NavLink opens the new tab itself.
|
|
15
|
+
*/
|
|
16
|
+
readonly menuItem?: boolean;
|
|
17
|
+
readonly ref?: Ref<HTMLElement>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A nav target that is a real `<a href>` when it has a URL, so right-click, middle-click and
|
|
21
|
+
* cmd/ctrl-click open it in a new tab. A plain left click runs `onClick` (client-side navigation)
|
|
22
|
+
* and then cancels the browser's own navigation, so there is no page reload. A modified click
|
|
23
|
+
* skips `onClick` entirely and is left to the browser, so the current tab does not navigate too.
|
|
24
|
+
*
|
|
25
|
+
* With `followHref`, a plain click runs `onClick` and then lets the browser load `href`.
|
|
26
|
+
*
|
|
27
|
+
* `onClick` runs before `preventDefault()` on purpose: handlers merged in by an `asChild` parent
|
|
28
|
+
* (e.g. Radix's menu-item select) skip their work when the event is already prevented.
|
|
29
|
+
*/
|
|
30
|
+
declare function NavLink({ href, fallback, followHref, menuItem, ref, ...props }: NavLinkProps): import("react").JSX.Element;
|
|
31
|
+
export { NavLink };
|
|
32
|
+
export type { NavLinkProps };
|
|
33
|
+
//# sourceMappingURL=NavLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavLink.d.ts","sourceRoot":"","sources":["../../../src/lib/links/NavLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,GAAG,EAAE,MAAM,OAAO,CAAC;AAE7D,UAAU,YAAa,SAAQ,cAAc,CAAC,WAAW,CAAC;IACxD,oGAAoG;IACpG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACjC;AAaD;;;;;;;;;;GAUG;AACH,iBAAS,OAAO,CAAC,EAAE,IAAI,EAAE,QAAmB,EAAE,UAAkB,EAAE,QAAgB,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,+BA+BhH;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,YAAY,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UserEvent } from '@testing-library/user-event';
|
|
2
|
+
/**
|
|
3
|
+
* Runs `click` and reports whether the browser navigation of the click it triggers was cancelled.
|
|
4
|
+
* Internal: not exported from `@gravitee/graphene-core/testing`.
|
|
5
|
+
*/
|
|
6
|
+
declare function isClickCancelled(click: () => Promise<void>): Promise<boolean | undefined>;
|
|
7
|
+
/**
|
|
8
|
+
* Actions on the link items of an open Radix menu (`AppSwitcher`, `SelectorDropdown`), found by accessible name.
|
|
9
|
+
* Internal: not exported from `@gravitee/graphene-core/testing`.
|
|
10
|
+
*/
|
|
11
|
+
declare function menuLinkActions(user: UserEvent): {
|
|
12
|
+
cmdSelect: (label: string) => Promise<void>;
|
|
13
|
+
selectWithKeyboard: (label: string) => Promise<void>;
|
|
14
|
+
selectWithModifiedEnter: (label: string, modifier: string) => Promise<void>;
|
|
15
|
+
/** Clicks the item and reports whether its browser navigation was cancelled. */
|
|
16
|
+
selectAndCheckCancelled: (label: string) => Promise<boolean | undefined>;
|
|
17
|
+
};
|
|
18
|
+
export { isClickCancelled, menuLinkActions };
|
|
19
|
+
//# sourceMappingURL=menuLinkActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menuLinkActions.d.ts","sourceRoot":"","sources":["../../src/testing/menuLinkActions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;;GAGG;AACH,iBAAe,gBAAgB,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAWxF;AAED;;;GAGG;AACH,iBAAS,eAAe,CAAC,IAAI,EAAE,SAAS;uBAIX,MAAM;gCAKG,MAAM;qCAID,MAAM,YAAY,MAAM;IAI/D,gFAAgF;qCAC/C,MAAM;EAE1C;AAED,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravitee/graphene-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Gravitee's Graphene design system: accessible React components, design tokens, icons, and shared ESLint/TypeScript configs. Built on shadcn/ui and Tailwind.",
|
|
6
6
|
"keywords": [
|
|
@@ -13,13 +13,15 @@ import { FileTextIcon, SettingsIcon, UsersIcon } from '@gravitee/graphene-core/i
|
|
|
13
13
|
import { useState } from 'react';
|
|
14
14
|
|
|
15
15
|
// 1. Define the sub-sections for your resource type.
|
|
16
|
+
// `href` is each section's full URL (with the router's basename, if any), so users can open it
|
|
17
|
+
// in a new tab. A plain click still goes through onItemSelect and navigates without a reload.
|
|
16
18
|
const resourceNavGroups: NavGroup[] = [
|
|
17
19
|
{
|
|
18
20
|
label: '{GROUP_LABEL}',
|
|
19
21
|
items: [
|
|
20
|
-
{ key: 'overview', title: 'Overview', icon: FileTextIcon },
|
|
21
|
-
{ key: 'settings', title: 'Settings', icon: SettingsIcon },
|
|
22
|
-
{ key: 'members', title: 'Members', icon: UsersIcon },
|
|
22
|
+
{ key: 'overview', title: 'Overview', icon: FileTextIcon, href: '{RESOURCE_URL}/overview' },
|
|
23
|
+
{ key: 'settings', title: 'Settings', icon: SettingsIcon, href: '{RESOURCE_URL}/settings' },
|
|
24
|
+
{ key: 'members', title: 'Members', icon: UsersIcon, href: '{RESOURCE_URL}/members' },
|
|
23
25
|
],
|
|
24
26
|
},
|
|
25
27
|
];
|
|
@@ -28,6 +30,7 @@ const resourceNavGroups: NavGroup[] = [
|
|
|
28
30
|
// The host provides <AppContextBar /> in ContentHeader's appContext slot.
|
|
29
31
|
// Do NOT include the application/module name as the first breadcrumb —
|
|
30
32
|
// it is already shown by AppContextBar. Start at the page level.
|
|
33
|
+
// Give each crumb with onClick an `href` (its full URL) too, so it can be opened in a new tab.
|
|
31
34
|
export function ResourceDetailPage({
|
|
32
35
|
resource,
|
|
33
36
|
onBack,
|
|
@@ -63,7 +66,7 @@ export function ResourceDetailPage({
|
|
|
63
66
|
leading={<ContextToggleButton expanded={contextExpanded} onToggle={() => setContextExpanded((v) => !v)} />}
|
|
64
67
|
appContext={null /* replace with <AppContextBar apps={...} activeAppKey={...} ... /> */}
|
|
65
68
|
breadcrumbs={[
|
|
66
|
-
{ label: '{LIST_PAGE_LABEL}', onClick: onBack },
|
|
69
|
+
{ label: '{LIST_PAGE_LABEL}', href: '{LIST_PAGE_URL}', onClick: onBack },
|
|
67
70
|
{ label: resource.name },
|
|
68
71
|
{ label: sectionLabel },
|
|
69
72
|
]}
|