@gravitee/graphene-core 2.5.0 → 2.6.0-renovate-eslint.e76a4f8

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 CHANGED
@@ -198,6 +198,14 @@ Graphene has two layers:
198
198
 
199
199
  **Linear breadcrumbs:** When each step maps to a **path string** and React Router’s `navigate`, use **`buildLinearBreadcrumbs(navigate, segments)`** so `ContentHeader` / `useLayoutConfig` get consistent `BreadcrumbEntry[]` without copying the same `onClick` wiring. If the first crumb is a **custom action** (e.g. “back” that is not `navigate('/path')`), build that entry by hand or mix with `buildLinearBreadcrumbs`—see Storybook **Composed/ContentHeader → Linear breadcrumbs from builder** for the canonical route-based pattern. API edge cases are covered in `packages/core/src/lib/breadcrumbs/buildLinearBreadcrumbs.test.ts`.
200
200
 
201
+ ### Context sidebar (resource detail pages)
202
+
203
+ Use `ContextSidebar` when a user **drills down from a list into a single resource** (API, Agent, Application…) that has multiple sub-sections. It provides secondary navigation scoped to that entity — set `viewMode: 'context'` on `AppLayout` and wire `ContextToggleButton` in the `leading` slot of `ContentHeader`.
204
+
205
+ **Do not use** on list/index pages or pages with fewer than 3 sub-sections (use `Tabs` instead).
206
+
207
+ **To implement:** copy the snippet from `snippets/context-sidebar-detail-page.tsx` and replace the `{PLACEHOLDER}` markers with your resource data, nav groups, and routes. See Storybook **Composed/ContextSidebar** for interactive examples and **Patterns/Module Federation** for the full federated setup.
208
+
201
209
  Compose with **Card**, **Tabs**, and other primitives inside the regions the layout components provide. Keep page-level spacing on the Graphene scale (`p-4`, `gap-2`, …) from the token table above.
202
210
 
203
211
  For content blocks, prefer Graphene’s primitives over reimplementing them:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravitee/graphene-core",
3
- "version": "2.5.0",
3
+ "version": "2.6.0-renovate-eslint.e76a4f8",
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": [
@@ -53,6 +53,7 @@
53
53
  },
54
54
  "files": [
55
55
  "dist",
56
+ "snippets",
56
57
  "eslint.config.shared.mjs",
57
58
  "eslint.legacy.shared.cjs",
58
59
  "tsconfig.shared.json",
@@ -87,6 +88,7 @@
87
88
  },
88
89
  "peerDependencies": {
89
90
  "@fontsource/dm-sans": ">=5.0.0",
91
+ "@gravitee/graphene-core": "2.6.0-renovate-eslint.e76a4f8",
90
92
  "@tanstack/react-table": "^8.0.0",
91
93
  "@testing-library/dom": ">=10.0.0",
92
94
  "@testing-library/react": ">=16.0.0",
@@ -1,39 +1,62 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { appendFileSync, copyFileSync, existsSync, readFileSync } from 'fs';
3
+ import { appendFileSync, copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'fs';
4
4
  import { dirname, join, resolve } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
 
7
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ const pkgRoot = join(__dirname, '..');
8
9
  const projectRoot = resolve(process.cwd());
9
- const src = join(__dirname, '..', 'USAGE_GUIDE.md');
10
10
 
11
- if (!existsSync(src)) {
11
+ const usageGuide = join(pkgRoot, 'USAGE_GUIDE.md');
12
+ if (!existsSync(usageGuide)) {
12
13
  console.error('USAGE_GUIDE.md not found. Make sure @gravitee/graphene-core is installed.');
13
14
  process.exit(1);
14
15
  }
15
16
 
17
+ const snippetsDir = join(pkgRoot, 'snippets');
18
+ const snippetFiles = existsSync(snippetsDir)
19
+ ? readdirSync(snippetsDir).filter((f) => f.endsWith('.tsx') || f.endsWith('.ts'))
20
+ : [];
21
+
16
22
  const destinations = [
17
- { dir: '.claude', file: '.claude/graphene.md' },
18
- { dir: '.cursor/rules', file: '.cursor/rules/graphene.md' },
23
+ { dir: '.claude', rulesFile: '.claude/graphene.md', snippetsDir: '.claude/graphene-snippets' },
24
+ { dir: '.cursor/rules', rulesFile: '.cursor/rules/graphene.md', snippetsDir: '.cursor/rules/graphene-snippets' },
19
25
  ];
20
26
 
21
27
  let copied = false;
22
28
 
23
- for (const { dir, file } of destinations) {
24
- if (!existsSync(join(projectRoot, dir))) continue;
29
+ for (const dest of destinations) {
30
+ if (!existsSync(join(projectRoot, dest.dir))) continue;
25
31
 
26
- const dest = join(projectRoot, file);
27
- copyFileSync(src, dest);
28
- console.log(`Copied ${file}`);
32
+ const rulesPath = join(projectRoot, dest.rulesFile);
33
+ copyFileSync(usageGuide, rulesPath);
34
+ console.log(`Copied ${dest.rulesFile}`);
29
35
  copied = true;
30
36
 
37
+ if (snippetFiles.length > 0) {
38
+ const snippetsDest = join(projectRoot, dest.snippetsDir);
39
+ mkdirSync(snippetsDest, { recursive: true });
40
+ for (const file of snippetFiles) {
41
+ copyFileSync(join(snippetsDir, file), join(snippetsDest, file));
42
+ }
43
+ for (const existing of readdirSync(snippetsDest)) {
44
+ if ((existing.endsWith('.tsx') || existing.endsWith('.ts')) && !snippetFiles.includes(existing)) {
45
+ rmSync(join(snippetsDest, existing));
46
+ console.log(`Removed orphaned snippet ${dest.snippetsDir}/${existing}`);
47
+ }
48
+ }
49
+ console.log(`Synced ${snippetFiles.length} snippet(s) to ${dest.snippetsDir}/`);
50
+ }
51
+
31
52
  const gitignorePath = join(projectRoot, '.gitignore');
32
53
  if (existsSync(gitignorePath)) {
33
54
  const content = readFileSync(gitignorePath, 'utf8');
34
- if (!content.includes(file)) {
35
- appendFileSync(gitignorePath, `\n${file}\n`);
36
- console.log(`Added ${file} to .gitignore`);
55
+ for (const entry of [dest.rulesFile, dest.snippetsDir]) {
56
+ if (!content.includes(entry)) {
57
+ appendFileSync(gitignorePath, `\n${entry}\n`);
58
+ console.log(`Added ${entry} to .gitignore`);
59
+ }
37
60
  }
38
61
  }
39
62
  }
@@ -0,0 +1,91 @@
1
+ // Snippet: Resource detail page with ContextSidebar
2
+ //
3
+ // Use when a user drills down from a list into a single resource (API, Agent,
4
+ // Application…) that has enough sub-sections to warrant its own navigation.
5
+ // Do NOT use on list pages or pages with fewer than 3 sub-sections (use Tabs).
6
+ //
7
+ // Replace {PLACEHOLDERS} with your actual values.
8
+ // See Storybook "Composed/ContextSidebar" for interactive examples.
9
+
10
+ import { useState } from 'react';
11
+ import { AppLayout, ContentHeader, ContextSidebar, ContextToggleButton } from '@gravitee/graphene-core';
12
+ import type { NavGroup } from '@gravitee/graphene-core';
13
+ import { FileTextIcon, SettingsIcon, UsersIcon } from '@gravitee/graphene-core/icons';
14
+
15
+ // 1. Define the sub-sections for your resource type.
16
+ const resourceNavGroups: NavGroup[] = [
17
+ {
18
+ label: '{GROUP_LABEL}',
19
+ items: [
20
+ { key: 'overview', title: 'Overview', icon: FileTextIcon },
21
+ { key: 'settings', title: 'Settings', icon: SettingsIcon },
22
+ { key: 'members', title: 'Members', icon: UsersIcon },
23
+ ],
24
+ },
25
+ ];
26
+
27
+ // 2. Build your detail page component.
28
+ export function ResourceDetailPage({
29
+ resource,
30
+ onBack,
31
+ }: {
32
+ resource: { name: string; status: string };
33
+ onBack: () => void;
34
+ }) {
35
+ const [section, setSection] = useState('overview');
36
+ const [contextExpanded, setContextExpanded] = useState(true);
37
+
38
+ const sectionLabel = resourceNavGroups.flatMap((g) => g.items).find((i) => i.key === section)?.title ?? 'Overview';
39
+
40
+ return (
41
+ <AppLayout
42
+ viewMode="context"
43
+ contextExpanded={contextExpanded}
44
+ sidebar={null /* replace with your <AppSidebar /> */}
45
+ contextSidebar={
46
+ <ContextSidebar
47
+ header={
48
+ <>
49
+ <p className="truncate text-sm font-semibold">{resource.name}</p>
50
+ <p className="text-xs text-muted-foreground">{resource.status}</p>
51
+ </>
52
+ }
53
+ groups={resourceNavGroups}
54
+ activeItemKey={section}
55
+ onItemSelect={setSection}
56
+ />
57
+ }
58
+ subheader={
59
+ <ContentHeader
60
+ leading={<ContextToggleButton expanded={contextExpanded} onToggle={() => setContextExpanded((v) => !v)} />}
61
+ breadcrumbs={[
62
+ { label: '{LIST_PAGE_LABEL}', onClick: onBack },
63
+ { label: resource.name },
64
+ { label: sectionLabel },
65
+ ]}
66
+ trailing={null /* replace with your trailing (search, user avatar, etc.) */}
67
+ />
68
+ }
69
+ >
70
+ {/* Page content for the active section */}
71
+ <h1>{sectionLabel}</h1>
72
+ </AppLayout>
73
+ );
74
+ }
75
+
76
+ // 3. With LayoutSlots (module federation):
77
+ // If using useLayoutConfig instead of direct props, push the sidebar from
78
+ // inside your module component:
79
+ //
80
+ // useLayoutConfig(
81
+ // {
82
+ // viewMode: 'context',
83
+ // contextExpanded,
84
+ // contextSidebar: <ContextSidebar header={...} groups={...} ... />,
85
+ // leading: <ContextToggleButton expanded={contextExpanded} onToggle={...} />,
86
+ // breadcrumbs: [...],
87
+ // },
88
+ // [section, contextExpanded],
89
+ // );
90
+ //
91
+ // See Storybook "Patterns/Module Federation" for the full setup.