@principal-ai/subsystems-react 0.53.5 → 0.54.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.
Files changed (108) hide show
  1. package/dist/index.d.ts +8 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/pierre/PierreTrailCodeView.d.ts.map +1 -1
  6. package/dist/pierre/PierreTrailCodeView.js +7 -5
  7. package/dist/pierre/PierreTrailCodeView.js.map +1 -1
  8. package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -1
  9. package/dist/stories/Subsystem/ComponentGraph/fixtures.js +1 -2
  10. package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -1
  11. package/dist/subsystem/C4Graph.d.ts +144 -9
  12. package/dist/subsystem/C4Graph.d.ts.map +1 -1
  13. package/dist/subsystem/C4Graph.js +924 -148
  14. package/dist/subsystem/C4Graph.js.map +1 -1
  15. package/dist/subsystem/C4NodeCard.d.ts +22 -1
  16. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  17. package/dist/subsystem/C4NodeCard.js +10 -2
  18. package/dist/subsystem/C4NodeCard.js.map +1 -1
  19. package/dist/subsystem/ComponentDeclaration.d.ts +5 -4
  20. package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -1
  21. package/dist/subsystem/ComponentDeclaration.js +12 -4
  22. package/dist/subsystem/ComponentDeclaration.js.map +1 -1
  23. package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
  24. package/dist/subsystem/ConstructsCatalog.js +10 -7
  25. package/dist/subsystem/ConstructsCatalog.js.map +1 -1
  26. package/dist/subsystem/GraphSidebar.d.ts +71 -0
  27. package/dist/subsystem/GraphSidebar.d.ts.map +1 -0
  28. package/dist/subsystem/GraphSidebar.js +145 -0
  29. package/dist/subsystem/GraphSidebar.js.map +1 -0
  30. package/dist/subsystem/GraphWithSidebar.d.ts +24 -0
  31. package/dist/subsystem/GraphWithSidebar.d.ts.map +1 -0
  32. package/dist/subsystem/GraphWithSidebar.js +25 -0
  33. package/dist/subsystem/GraphWithSidebar.js.map +1 -0
  34. package/dist/subsystem/SubsystemComponentGraph.d.ts +33 -0
  35. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  36. package/dist/subsystem/SubsystemComponentGraph.js +364 -411
  37. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  38. package/dist/subsystem/TrailStepsNav.d.ts +48 -0
  39. package/dist/subsystem/TrailStepsNav.d.ts.map +1 -0
  40. package/dist/subsystem/TrailStepsNav.js +189 -0
  41. package/dist/subsystem/TrailStepsNav.js.map +1 -0
  42. package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
  43. package/dist/subsystem/TrailsPanel.js +3 -4
  44. package/dist/subsystem/TrailsPanel.js.map +1 -1
  45. package/dist/subsystem/__fixtures__/c4Drilldown.d.ts +151 -0
  46. package/dist/subsystem/__fixtures__/c4Drilldown.d.ts.map +1 -0
  47. package/dist/subsystem/__fixtures__/c4Drilldown.js +783 -0
  48. package/dist/subsystem/__fixtures__/c4Drilldown.js.map +1 -0
  49. package/dist/subsystem/c4.d.ts +39 -8
  50. package/dist/subsystem/c4.d.ts.map +1 -1
  51. package/dist/subsystem/c4.js.map +1 -1
  52. package/dist/subsystem/declarationRef.d.ts +26 -18
  53. package/dist/subsystem/declarationRef.d.ts.map +1 -1
  54. package/dist/subsystem/declarationRef.js +9 -4
  55. package/dist/subsystem/declarationRef.js.map +1 -1
  56. package/dist/subsystem/model.d.ts +19 -1
  57. package/dist/subsystem/model.d.ts.map +1 -1
  58. package/dist/subsystem/model.js +12 -2
  59. package/dist/subsystem/model.js.map +1 -1
  60. package/dist/subsystem/nodes.d.ts.map +1 -1
  61. package/dist/subsystem/nodes.js +24 -4
  62. package/dist/subsystem/nodes.js.map +1 -1
  63. package/dist/subsystem/trailBrief.d.ts.map +1 -1
  64. package/dist/subsystem/trailBrief.js +6 -1
  65. package/dist/subsystem/trailBrief.js.map +1 -1
  66. package/dist/utils/elkLayout.d.ts.map +1 -1
  67. package/dist/utils/elkLayout.js +10 -8
  68. package/dist/utils/elkLayout.js.map +1 -1
  69. package/package.json +3 -3
  70. package/src/index.ts +9 -2
  71. package/src/pierre/PierreTrailCodeView.tsx +9 -13
  72. package/src/stories/Subsystem/C4Graph/C4ToComponentDrill.stories.tsx +496 -0
  73. package/src/stories/Subsystem/ComponentGraph/AnimatedProgression.stories.tsx +7 -7
  74. package/src/stories/Subsystem/ComponentGraph/Constructs.stories.tsx +19 -25
  75. package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +8 -10
  76. package/src/stories/Subsystem/ComponentGraph/Issues.stories.tsx +19 -19
  77. package/src/stories/Subsystem/ComponentGraph/ProposedTrails.stories.tsx +6 -6
  78. package/src/stories/Subsystem/ComponentGraph/TrailAutoplay.stories.tsx +7 -7
  79. package/src/stories/Subsystem/ComponentGraph/Trails.stories.tsx +27 -30
  80. package/src/stories/Subsystem/ComponentGraph/fixtures.ts +1 -2
  81. package/src/stories/Subsystem/ConstructsCatalog.stories.tsx +10 -13
  82. package/src/stories/Subsystem/EgoGraph/EgoGraph.stories.tsx +3 -4
  83. package/src/stories/Subsystem/Sidebar/GraphSidebar.stories.tsx +206 -0
  84. package/src/subsystem/C4Graph.groups.test.ts +96 -2
  85. package/src/subsystem/C4Graph.tsx +1377 -165
  86. package/src/subsystem/C4NodeCard.test.ts +1 -2
  87. package/src/subsystem/C4NodeCard.tsx +24 -2
  88. package/src/subsystem/ComponentDeclaration.tsx +18 -8
  89. package/src/subsystem/ConstructsCatalog.tsx +23 -8
  90. package/src/subsystem/GraphSidebar.test.tsx +152 -0
  91. package/src/subsystem/GraphSidebar.tsx +300 -0
  92. package/src/subsystem/GraphWithSidebar.test.tsx +78 -0
  93. package/src/subsystem/GraphWithSidebar.tsx +60 -0
  94. package/src/subsystem/SubsystemComponentGraph.tsx +284 -370
  95. package/src/subsystem/TrailStepsNav.test.tsx +179 -0
  96. package/src/subsystem/TrailStepsNav.tsx +372 -0
  97. package/src/subsystem/TrailsPanel.tsx +3 -4
  98. package/src/subsystem/__fixtures__/c4Drilldown.test.ts +338 -0
  99. package/src/subsystem/__fixtures__/c4Drilldown.ts +847 -0
  100. package/src/subsystem/c4.ts +41 -8
  101. package/src/subsystem/declarationRef.ts +28 -19
  102. package/src/subsystem/model.test.ts +32 -12
  103. package/src/subsystem/model.ts +30 -1
  104. package/src/subsystem/nodes.group.test.tsx +82 -0
  105. package/src/subsystem/nodes.tsx +30 -2
  106. package/src/subsystem/trailBrief.test.ts +2 -2
  107. package/src/subsystem/trailBrief.ts +6 -1
  108. package/src/utils/elkLayout.ts +10 -8
@@ -0,0 +1,78 @@
1
+ import { afterEach, describe, expect, test } from 'bun:test';
2
+ import { createElement } from 'react';
3
+ import { Window } from 'happy-dom';
4
+ import { cleanup, render } from '@testing-library/react/pure';
5
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
+ import { GraphWithSidebar, GraphSidebar } from './GraphWithSidebar';
7
+
8
+ // Bun's happy-dom test environment isn't registered (no @happy-dom/global-
9
+ // registrator), so wire the DOM primitives React DOM needs before rendering.
10
+ const dom = new Window();
11
+ const globals = globalThis as unknown as Record<string, unknown>;
12
+ globals.window = dom;
13
+ globals.document = dom.document;
14
+ globals.navigator = dom.navigator;
15
+ globals.HTMLElement = dom.HTMLElement;
16
+ globals.Node = dom.Node;
17
+ globals.Element = dom.Element;
18
+ globals.Event = dom.Event;
19
+ globals.getComputedStyle = dom.getComputedStyle.bind(dom);
20
+ globals.requestAnimationFrame = dom.requestAnimationFrame.bind(dom);
21
+ globals.cancelAnimationFrame = dom.cancelAnimationFrame.bind(dom);
22
+ globals.localStorage = dom.localStorage;
23
+ globals.matchMedia = dom.matchMedia.bind(dom);
24
+
25
+ afterEach(cleanup);
26
+
27
+ function renderWrapper(props: Record<string, unknown>) {
28
+ return render(
29
+ createElement(
30
+ ThemeProvider,
31
+ { theme: defaultEditorTheme },
32
+ createElement(GraphWithSidebar as never, props as never),
33
+ ),
34
+ );
35
+ }
36
+
37
+ describe('GraphWithSidebar composition', () => {
38
+ test('composes GraphSidebar next to graph content', () => {
39
+ const { getByText, getByLabelText } = renderWrapper({
40
+ header: createElement('span', null, 'title'),
41
+ sidebarBody: createElement('span', null, 'panel'),
42
+ children: createElement('div', null, 'canvas'),
43
+ });
44
+ expect(getByText('title')).toBeTruthy();
45
+ expect(getByText('panel')).toBeTruthy();
46
+ expect(getByText('canvas')).toBeTruthy();
47
+ expect(getByLabelText('Resize sidebar')).toBeTruthy();
48
+ });
49
+
50
+ test('hidden renders only the content — no sidebar, no handle', () => {
51
+ const { queryByLabelText, getByText } = renderWrapper({
52
+ hidden: true,
53
+ header: createElement('span', null, 'title'),
54
+ children: createElement('div', null, 'canvas'),
55
+ });
56
+ expect(getByText('canvas')).toBeTruthy();
57
+ expect(queryByLabelText('Resize sidebar')).toBeNull();
58
+ expect(() => getByText('title')).toThrow();
59
+ });
60
+
61
+ test('wrapper exposes GraphSidebar as its own export', () => {
62
+ expect(GraphSidebar).toBeTypeOf('function');
63
+ });
64
+
65
+ test('the content slot is a flex column so a flex-filling child can size', () => {
66
+ // The component graph's canvas fills the pane with `flex: 1 1 0%`, which
67
+ // only resolves against a flex parent — a block slot collapses it to 0 and
68
+ // the canvas renders blank.
69
+ const { container } = renderWrapper({
70
+ sidebarBody: createElement('span', null, 'panel'),
71
+ children: createElement('div', null, 'canvas'),
72
+ });
73
+ const root = container.firstElementChild as HTMLElement;
74
+ const content = root.lastElementChild as HTMLElement;
75
+ expect(content.style.display).toBe('flex');
76
+ expect(content.style.flexDirection).toBe('column');
77
+ });
78
+ });
@@ -0,0 +1,60 @@
1
+ import { useState } from 'react';
2
+ import type { ReactNode } from 'react';
3
+ import { GraphSidebar } from './GraphSidebar';
4
+ import type { GraphSidebarProps } from './GraphSidebar';
5
+
6
+ /**
7
+ * GraphWithSidebar — a graph laid out beside its own sidebar.
8
+ *
9
+ * A flex row: `[GraphSidebar][graph content]`. The sidebar is the standalone
10
+ * `GraphSidebar` panel (its right edge is the resize handle, and it owns the
11
+ * width drag + persistence); this component only composes it next to a graph
12
+ * and locks the row against text selection while a resize is in progress.
13
+ *
14
+ * Every sidebar prop is forwarded straight to `GraphSidebar`: `header`,
15
+ * `tabs`/`activeTab`/`onTabChange`, `sidebarBody`, `footer`, `hidden`,
16
+ * `bodyHidden`, `stretchHeader`, `width`/`onWidthChange`, `defaultWidth`,
17
+ * `minWidth`/`maxWidth`, `onResizeEnd`, `persistKey`. See GraphSidebar for the
18
+ * semantics.
19
+ */
20
+
21
+ export interface GraphWithSidebarProps extends GraphSidebarProps {
22
+ /** The graph content to the right of the sidebar. */
23
+ children?: ReactNode;
24
+ }
25
+
26
+ export { GraphSidebar } from './GraphSidebar';
27
+ export type { GraphSidebarProps, GraphSidebarTab } from './GraphSidebar';
28
+
29
+ export function GraphWithSidebar({ children, ...sidebarProps }: GraphWithSidebarProps) {
30
+ const [dragging, setDragging] = useState(false);
31
+
32
+ return (
33
+ <div
34
+ style={{
35
+ width: '100%',
36
+ height: '100%',
37
+ display: 'flex',
38
+ flexDirection: 'row',
39
+ userSelect: dragging ? 'none' : undefined,
40
+ }}
41
+ >
42
+ <GraphSidebar {...sidebarProps} onDraggingChange={setDragging} />
43
+ <div
44
+ style={{
45
+ flex: 1,
46
+ minWidth: 0,
47
+ position: 'relative',
48
+ minHeight: 0,
49
+ // A flex column so a child that fills the pane with flex-grow (the
50
+ // component graph's canvas tree) resolves against a real flex
51
+ // parent instead of collapsing to 0.
52
+ display: 'flex',
53
+ flexDirection: 'column',
54
+ }}
55
+ >
56
+ {children}
57
+ </div>
58
+ </div>
59
+ );
60
+ }