@gravitee/graphene-core 2.52.0-feat-layout-content-width-tiers.41415b9 → 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 (42) hide show
  1. package/USAGE_GUIDE.md +11 -130
  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 +7639 -7622
  29. package/dist/styles/globals.css +1 -1
  30. package/dist/styles/tailwind-theme.css +0 -2
  31. package/dist/tokens/component.css +1 -2
  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 -32
  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
package/USAGE_GUIDE.md CHANGED
@@ -141,47 +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
- All pages share a single uniform container (100rem / 1600px, centered). No per-page width decisions needed — the container never changes between sibling pages, eliminating layout shifts during navigation.
147
-
148
- | Layer | Token | Rem | When to use |
149
- |-------|-------|-----|-------------|
150
- | Container (default) | `--content-max-width` | `100rem` | Everything. Applied automatically by `AppLayout`. |
151
- | Full-bleed | N/A | none | Tool layouts (Policy Studio, LLM Studio). Set via `useLayoutConfig({ contentVariant: 'full-bleed' })`. |
152
- | `<PageFocused>` | `--content-focused-width` | `56rem` | Optional. Creation wizards, steppers, onboarding flows. |
153
-
154
- **Decision rule:**
155
-
156
- 1. Is this a tool/workspace layout? → `useLayoutConfig({ contentVariant: 'full-bleed' })`
157
- 2. Is this a single-column creation wizard or stepper? → Wrap content in `<PageFocused>`
158
- 3. Everything else → Do nothing. The 100rem centered container handles tables, forms, dashboards, and settings equally.
159
-
160
- ```tsx
161
- import { PageFocused } from '@gravitee/graphene-core';
162
-
163
- // Wizard/creation page — focused and centered
164
- function CreateApiPage() {
165
- return (
166
- <PageFocused>
167
- <StepProgress steps={steps} activeStep={step} />
168
- <StepContent />
169
- </PageFocused>
170
- );
171
- }
172
-
173
- // Everything else — just render content directly
174
- function ApisPage() {
175
- return (
176
- <div className="space-y-4">
177
- <h2>APIs</h2>
178
- <DataTable ... />
179
- </div>
180
- );
181
- }
182
- ```
183
-
184
- All width values are in `rem` so they scale with user font-size preferences and browser zoom. Do NOT set `max-w-*` classes on page wrappers — the design system handles it via `AppLayout`.
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.
185
147
 
186
148
  ## Styling
187
149
 
@@ -331,108 +293,27 @@ If you have not migrated to `AppContextBar` yet, keeping the app name as the fir
331
293
 
332
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`.
333
295
 
334
- ### `contentVariant` — content width tiers
335
-
336
- `AppLayout` accepts `contentVariant` to control content area width and padding:
296
+ ### `contentVariant` — full-bleed content
337
297
 
338
- - `"default"` (default) — `max-w-content` (80rem) with standard padding. Most pages.
339
- - `"wide"` — `max-w-wide` (100rem) with standard padding. DataTable list pages.
340
- - `"full-bleed"` — no max-width, no padding; content spans edge-to-edge. Tool layouts and observability pages.
298
+ `AppLayout` accepts `contentVariant` to control content area padding:
341
299
 
342
- ```tsx
343
- // Default (80rem) — no change needed, AppLayout applies it automatically
344
- <AppLayout>
345
- <DetailPage />
346
- </AppLayout>
347
-
348
- // Wide (100rem) — for DataTable list pages, add one line
349
- useLayoutConfig({ contentVariant: 'wide' }, []);
350
-
351
- // Full-bleed — for tool layouts and observability pages
352
- useLayoutConfig({ contentVariant: 'full-bleed' }, []);
353
- ```
300
+ - `"default"` (default) — standard padding on all sides.
301
+ - `"full-bleed"` — no padding; content spans edge-to-edge.
354
302
 
355
- 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.
356
-
357
- #### Artifact-free page transitions
358
-
359
- When navigating between pages with different `contentVariant` values, wrap the navigation action in `startLayoutTransition` to eliminate visual overlap artifacts during DOM reconciliation:
303
+ Use `full-bleed` for embedded components that manage their own layout grid (Policy Studio, dashboards, full-screen editors):
360
304
 
361
305
  ```tsx
362
- import { startLayoutTransition } from '@gravitee/graphene-core';
363
-
364
- // In your router or navigation handler (called once, not per-page):
365
- function useAppNavigate() {
366
- const navigate = useNavigate();
367
- return useCallback((to: string) => {
368
- startLayoutTransition(() => navigate(to));
369
- }, [navigate]);
370
- }
371
- ```
372
-
373
- 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.
374
-
375
- 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.
376
-
377
- ### `banner` — full-width status slot
378
-
379
- `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).
380
-
381
- ```tsx
382
- // Direct prop usage
383
- <AppLayout banner={<DeployStrip />} bannerSticky>
384
- <PageContent />
306
+ <AppLayout contentVariant="full-bleed">
307
+ <PolicyStudio {...props} />
385
308
  </AppLayout>
386
-
387
- // Module federation via useLayoutConfig
388
- useLayoutConfig({
389
- banner: deployState === 'NEED_REDEPLOY' ? (
390
- <DeployStrip onDeploy={handleDeploy} isPending={isPending} />
391
- ) : null,
392
- bannerSticky: true,
393
- }, [deployState, handleDeploy, isPending]);
394
309
  ```
395
310
 
396
- 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.
397
-
398
- **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:
399
312
 
400
313
  ```tsx
401
- function DeployStrip({ onDeploy, isPending }) {
402
- return (
403
- <div className="flex items-center gap-2 border-b border-border px-5 py-1.5">
404
- <span className="size-1.5 shrink-0 rounded-full bg-warning" />
405
- <span className="text-sm text-muted-foreground">Undeployed changes</span>
406
- <div className="flex-1" />
407
- <button
408
- type="button"
409
- 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"
410
- onClick={onDeploy}
411
- disabled={isPending}
412
- >
413
- {isPending ? 'Deploying…' : 'Deploy API'}
414
- </button>
415
- </div>
416
- );
417
- }
314
+ useLayoutConfig({ contentVariant: 'full-bleed' }, []);
418
315
  ```
419
316
 
420
- See Storybook **Composed/AppLayout → BannerSlot** for the full interactive example.
421
-
422
- ### Adopting content width tiers in consumer modules
423
-
424
- Follow these steps to apply the layout tier system to an existing consumer module:
425
-
426
- 1. **Identify all pages** in your module that render inside `AppLayout`.
427
- 2. **Categorize each page:**
428
- - **Default** — detail views, edit forms, overviews, settings, creation wizards. No change needed; `AppLayout` applies `max-w-content` (80rem) automatically.
429
- - **Wide** — any page whose primary content is a `DataTable`. Add `useLayoutConfig({ contentVariant: 'wide' }, [])` at the top of the component.
430
- - **Full-bleed** — tool layouts (Policy Studio) or observability pages (dashboards, explorers). Add `useLayoutConfig({ contentVariant: 'full-bleed' }, [])` if not already set.
431
- 3. **Remove ad-hoc width constraints** — delete any `max-w-*` classes on page-level wrapper divs. The design system owns content width.
432
- 4. **Verify** — resize the browser to confirm content centers correctly on wide viewports and doesn't clip on narrow ones.
433
-
434
- See `packages/core/snippets/data-table-list-page.tsx` for a complete list-page example with `useLayoutConfig`.
435
-
436
317
  ### Data table (entity list pages)
437
318
 
438
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.