@gravitee/graphene-core 2.52.0-feat-layout-content-width-tiers.35c2ff9 → 2.52.0-graphene-142-code-editor.aaa181c

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.
Files changed (43) hide show
  1. package/USAGE_GUIDE.md +11 -145
  2. package/dist/CodeEditor-Cnn11Gx1.js +2010 -0
  3. package/dist/__stories__/fixtures/index.d.ts +1 -1
  4. package/dist/__stories__/fixtures/index.d.ts.map +1 -1
  5. package/dist/__stories__/fixtures/json-schema-form/code-editor.fixture.d.ts +14 -0
  6. package/dist/__stories__/fixtures/json-schema-form/code-editor.fixture.d.ts.map +1 -0
  7. package/dist/__stories__/fixtures/json-schema-form/index.d.ts +1 -0
  8. package/dist/__stories__/fixtures/json-schema-form/index.d.ts.map +1 -1
  9. package/dist/code-editor/index.js +2 -228
  10. package/dist/composed/AppLayout/AppLayout.d.ts +4 -17
  11. package/dist/composed/AppLayout/AppLayout.d.ts.map +1 -1
  12. package/dist/composed/CodeEditor/CodeEditor.d.ts.map +1 -1
  13. package/dist/composed/CodeEditor/setupCodeEditor.d.ts +34 -39
  14. package/dist/composed/CodeEditor/setupCodeEditor.d.ts.map +1 -1
  15. package/dist/composed/JsonSchemaForm/SchemaField.d.ts.map +1 -1
  16. package/dist/composed/JsonSchemaForm/fields/code-editor/CodeEditorField.d.ts +8 -0
  17. package/dist/composed/JsonSchemaForm/fields/code-editor/CodeEditorField.d.ts.map +1 -0
  18. package/dist/composed/JsonSchemaForm/models/json-schema.types.d.ts +5 -5
  19. package/dist/composed/JsonSchemaForm/models/json-schema.types.d.ts.map +1 -1
  20. package/dist/composed/JsonSchemaForm/utils/schemaShape.d.ts +2 -1
  21. package/dist/composed/JsonSchemaForm/utils/schemaShape.d.ts.map +1 -1
  22. package/dist/composed/LayoutSlots/LayoutSlotsContext.d.ts +1 -11
  23. package/dist/composed/LayoutSlots/LayoutSlotsContext.d.ts.map +1 -1
  24. package/dist/composed/LayoutSlots/use-layout-config.d.ts +0 -3
  25. package/dist/composed/LayoutSlots/use-layout-config.d.ts.map +1 -1
  26. package/dist/index.d.ts +0 -2
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +7636 -7626
  29. package/dist/styles/globals.css +1 -1
  30. package/dist/styles/tailwind-theme.css +0 -3
  31. package/dist/tokens/component.css +1 -3
  32. package/package.json +2 -2
  33. package/snippets/context-sidebar-detail-page.tsx +1 -10
  34. package/snippets/data-table-list-page.tsx +0 -5
  35. package/dist/Skeleton-C30qULzD.js +0 -1745
  36. package/dist/composed/PageContent/PageContent.d.ts +0 -60
  37. package/dist/composed/PageContent/PageContent.d.ts.map +0 -1
  38. package/dist/composed/PageContent/index.d.ts +0 -3
  39. package/dist/composed/PageContent/index.d.ts.map +0 -1
  40. package/dist/lib/view-transitions.d.ts +0 -14
  41. package/dist/lib/view-transitions.d.ts.map +0 -1
  42. package/snippets/creation-wizard-page.tsx +0 -121
  43. package/snippets/form-settings-page.tsx +0 -112
package/USAGE_GUIDE.md CHANGED
@@ -141,62 +141,9 @@ Scale: `0`, `0.5`, `1`, `1.5`, `2`, `2.5`, `3`, `3.5`, `4`, `5`, `6`, `7`, `8`,
141
141
 
142
142
  `rounded-sm`, `rounded-md`, `rounded-lg`, `rounded-xl` (mapped to semantic `--radius`).
143
143
 
144
- ### Layout — content width system
144
+ ### Layout
145
145
 
146
- The layout uses a single default container (100rem / 1600px, left-aligned) with two content wrappers for narrower pages:
147
-
148
- | Layer | Token | Rem | Tailwind class | When to use |
149
- |-------|-------|-----|----------------|-------------|
150
- | Container (default) | `--content-max-width` | `100rem` | `max-w-content` | The shell container. Applied automatically by `AppLayout`. |
151
- | Full-bleed | N/A | none | N/A | Tool layouts (Policy Studio), observability pages. Set via `useLayoutConfig({ contentVariant: 'full-bleed' })`. |
152
- | `<PageSection>` | `--content-form-width` | `80rem` | `max-w-form` | Form pages, settings, config views. Wrap page content in this component. |
153
- | `<PageFocused>` | `--content-focused-width` | `56rem` | `max-w-focused` | Creation wizards, steppers, onboarding flows. Wrap page content in this component. |
154
-
155
- **Decision flowchart:**
156
-
157
- 1. Is this a tool/workspace layout (Policy Studio, LLM Studio, observability)? → `useLayoutConfig({ contentVariant: 'full-bleed' })`
158
- 2. Is this a creation wizard or stepper? → Wrap content in `<PageFocused>`
159
- 3. Is the page primarily forms, settings, or card-based config? → Wrap content in `<PageSection>`
160
- 4. Is the page primarily a DataTable, entity list, or dashboard? → No wrapper needed (fills the 100rem container)
161
- 5. Not sure? → No wrapper. The default container handles most content well.
162
-
163
- Content is **left-aligned** (not centered). Width changes between pages only affect the right edge, keeping the left anchor stable during navigation.
164
-
165
- ```tsx
166
- import { PageSection, PageFocused } from '@gravitee/graphene-core';
167
-
168
- // Form/settings page
169
- function GeneralSettingsPage() {
170
- return (
171
- <PageSection>
172
- <h2>General</h2>
173
- <form>...</form>
174
- </PageSection>
175
- );
176
- }
177
-
178
- // Wizard/creation page
179
- function CreateApiPage() {
180
- return (
181
- <PageFocused>
182
- <StepProgress steps={steps} activeStep={step} />
183
- <StepContent />
184
- </PageFocused>
185
- );
186
- }
187
-
188
- // Table page — no wrapper needed
189
- function ApisPage() {
190
- return (
191
- <div className="space-y-4">
192
- <h2>APIs</h2>
193
- <DataTable ... />
194
- </div>
195
- );
196
- }
197
- ```
198
-
199
- All width values are defined in `rem` so they scale with user font-size preferences and browser zoom. Consumers do not set `max-w-*` classes directly on page wrappers — use the provided components instead.
146
+ - Content max width is defined on the theme token `--container-content` (maps to `--content-max-width`). Use the max-width utility Tailwind emits for that token in your setup.
200
147
 
201
148
  ## Styling
202
149
 
@@ -346,108 +293,27 @@ If you have not migrated to `AppContextBar` yet, keeping the app name as the fir
346
293
 
347
294
  **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`.
348
295
 
349
- ### `contentVariant` — content width tiers
350
-
351
- `AppLayout` accepts `contentVariant` to control content area width and padding:
352
-
353
- - `"default"` (default) — `max-w-content` (80rem) with standard padding. Most pages.
354
- - `"wide"` — `max-w-wide` (100rem) with standard padding. DataTable list pages.
355
- - `"full-bleed"` — no max-width, no padding; content spans edge-to-edge. Tool layouts and observability pages.
356
-
357
- ```tsx
358
- // Default (80rem) — no change needed, AppLayout applies it automatically
359
- <AppLayout>
360
- <DetailPage />
361
- </AppLayout>
362
-
363
- // Wide (100rem) — for DataTable list pages, add one line
364
- useLayoutConfig({ contentVariant: 'wide' }, []);
365
-
366
- // Full-bleed — for tool layouts and observability pages
367
- useLayoutConfig({ contentVariant: 'full-bleed' }, []);
368
- ```
369
-
370
- With `useLayoutConfig` (module federation), a nested page can set `contentVariant` without affecting other layout slots owned by parent components. Each hook only resets the keys it owns on unmount.
371
-
372
- #### Artifact-free page transitions
373
-
374
- When navigating between pages with different `contentVariant` values, wrap the navigation action in `startLayoutTransition` to eliminate visual overlap artifacts during DOM reconciliation:
375
-
376
- ```tsx
377
- import { startLayoutTransition } from '@gravitee/graphene-core';
378
-
379
- // In your router or navigation handler (called once, not per-page):
380
- function useAppNavigate() {
381
- const navigate = useNavigate();
382
- return useCallback((to: string) => {
383
- startLayoutTransition(() => navigate(to));
384
- }, [navigate]);
385
- }
386
- ```
387
-
388
- This uses the View Transitions API to capture the old visual state before applying DOM changes, preventing any intermediate "two pages visible" flash. No visible animation is produced; the swap is perceptually instant. Falls back to direct execution in browsers without View Transitions API support.
296
+ ### `contentVariant` — full-bleed content
389
297
 
390
- When the user has **Reduce motion** enabled at the OS level (`prefers-reduced-motion: reduce`), view-transition animation duration is `0ms` and navigation is fully instant.
298
+ `AppLayout` accepts `contentVariant` to control content area padding:
391
299
 
392
- ### `banner` — full-width status slot
300
+ - `"default"` (default) standard padding on all sides.
301
+ - `"full-bleed"` — no padding; content spans edge-to-edge.
393
302
 
394
- `AppLayout` accepts a `banner` prop that renders a full-width region above the padded content wrapper but inside the scroll container. Use it for persistent status indicators with an action (deploy status, environment warnings).
303
+ Use `full-bleed` for embedded components that manage their own layout grid (Policy Studio, dashboards, full-screen editors):
395
304
 
396
305
  ```tsx
397
- // Direct prop usage
398
- <AppLayout banner={<DeployStrip />} bannerSticky>
399
- <PageContent />
306
+ <AppLayout contentVariant="full-bleed">
307
+ <PolicyStudio {...props} />
400
308
  </AppLayout>
401
-
402
- // Module federation via useLayoutConfig
403
- useLayoutConfig({
404
- banner: deployState === 'NEED_REDEPLOY' ? (
405
- <DeployStrip onDeploy={handleDeploy} isPending={isPending} />
406
- ) : null,
407
- bannerSticky: true,
408
- }, [deployState, handleDeploy, isPending]);
409
309
  ```
410
310
 
411
- The banner spans full width regardless of `contentVariant`. When `bannerSticky` is true, it sticks to the top of the scroll area so the action remains reachable while scrolling.
412
-
413
- **Button hierarchy:** When a banner contains an action button alongside page content that has its own primary buttons, use an outline treatment on the banner button to avoid competing with the page's primary CTA:
311
+ With `useLayoutConfig` (module federation), a nested page can set `contentVariant` without affecting other layout slots owned by parent components:
414
312
 
415
313
  ```tsx
416
- function DeployStrip({ onDeploy, isPending }) {
417
- return (
418
- <div className="flex items-center gap-2 border-b border-border px-5 py-1.5">
419
- <span className="size-1.5 shrink-0 rounded-full bg-warning" />
420
- <span className="text-sm text-muted-foreground">Undeployed changes</span>
421
- <div className="flex-1" />
422
- <button
423
- type="button"
424
- className="rounded-md border border-warning/25 bg-warning/5 px-2.5 py-0.5 text-sm font-semibold text-warning-foreground transition-colors hover:bg-warning/10 disabled:opacity-50"
425
- onClick={onDeploy}
426
- disabled={isPending}
427
- >
428
- {isPending ? 'Deploying…' : 'Deploy API'}
429
- </button>
430
- </div>
431
- );
432
- }
314
+ useLayoutConfig({ contentVariant: 'full-bleed' }, []);
433
315
  ```
434
316
 
435
- See Storybook **Composed/AppLayout → BannerSlot** for the full interactive example.
436
-
437
- ### Adopting content width tiers in consumer modules
438
-
439
- Follow these steps to apply the layout tier system to an existing consumer module:
440
-
441
- 1. **Identify all pages** in your module that render inside `AppLayout`.
442
- 2. **Categorize each page:**
443
- - **Default** — detail views, edit forms, overviews, settings, creation wizards. No change needed; `AppLayout` applies `max-w-content` (80rem) automatically.
444
- - **Wide** — any page whose primary content is a `DataTable`. Add `useLayoutConfig({ contentVariant: 'wide' }, [])` at the top of the component.
445
- - **Full-bleed** — tool layouts (Policy Studio) or observability pages (dashboards, explorers). Add `useLayoutConfig({ contentVariant: 'full-bleed' }, [])` if not already set.
446
- 3. **Remove ad-hoc width constraints** — delete any `max-w-*` classes on page-level wrapper divs. The design system owns content width.
447
- 4. **Verify** — resize the browser to confirm content centers correctly on wide viewports and doesn't clip on narrow ones.
448
-
449
- See `packages/core/snippets/data-table-list-page.tsx` for a complete list-page example with `useLayoutConfig`.
450
-
451
317
  ### Data table (entity list pages)
452
318
 
453
319
  Use `DataTable` for any entity list — whether the data is fetched page-by-page from an API or loaded in full on the client. The component provides sorting, filtering, pagination, column visibility, row selection, and bulk actions through a composable slot API.