@principal-ai/subsystems-react 0.53.6 → 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.
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/pierre/PierreTrailCodeView.d.ts.map +1 -1
- package/dist/pierre/PierreTrailCodeView.js +7 -5
- package/dist/pierre/PierreTrailCodeView.js.map +1 -1
- package/dist/stories/Subsystem/ComponentGraph/fixtures.d.ts.map +1 -1
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js +1 -2
- package/dist/stories/Subsystem/ComponentGraph/fixtures.js.map +1 -1
- package/dist/subsystem/C4Graph.d.ts +144 -9
- package/dist/subsystem/C4Graph.d.ts.map +1 -1
- package/dist/subsystem/C4Graph.js +924 -148
- package/dist/subsystem/C4Graph.js.map +1 -1
- package/dist/subsystem/C4NodeCard.d.ts +22 -1
- package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
- package/dist/subsystem/C4NodeCard.js +10 -2
- package/dist/subsystem/C4NodeCard.js.map +1 -1
- package/dist/subsystem/ComponentDeclaration.d.ts +5 -4
- package/dist/subsystem/ComponentDeclaration.d.ts.map +1 -1
- package/dist/subsystem/ComponentDeclaration.js +12 -4
- package/dist/subsystem/ComponentDeclaration.js.map +1 -1
- package/dist/subsystem/ConstructsCatalog.d.ts.map +1 -1
- package/dist/subsystem/ConstructsCatalog.js +10 -7
- package/dist/subsystem/ConstructsCatalog.js.map +1 -1
- package/dist/subsystem/GraphSidebar.d.ts +71 -0
- package/dist/subsystem/GraphSidebar.d.ts.map +1 -0
- package/dist/subsystem/GraphSidebar.js +145 -0
- package/dist/subsystem/GraphSidebar.js.map +1 -0
- package/dist/subsystem/GraphWithSidebar.d.ts +24 -0
- package/dist/subsystem/GraphWithSidebar.d.ts.map +1 -0
- package/dist/subsystem/GraphWithSidebar.js +25 -0
- package/dist/subsystem/GraphWithSidebar.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts +33 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +364 -411
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailStepsNav.d.ts +48 -0
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -0
- package/dist/subsystem/TrailStepsNav.js +189 -0
- package/dist/subsystem/TrailStepsNav.js.map +1 -0
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +3 -4
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Drilldown.d.ts +151 -0
- package/dist/subsystem/__fixtures__/c4Drilldown.d.ts.map +1 -0
- package/dist/subsystem/__fixtures__/c4Drilldown.js +783 -0
- package/dist/subsystem/__fixtures__/c4Drilldown.js.map +1 -0
- package/dist/subsystem/c4.d.ts +39 -8
- package/dist/subsystem/c4.d.ts.map +1 -1
- package/dist/subsystem/c4.js.map +1 -1
- package/dist/subsystem/declarationRef.d.ts +26 -18
- package/dist/subsystem/declarationRef.d.ts.map +1 -1
- package/dist/subsystem/declarationRef.js +9 -4
- package/dist/subsystem/declarationRef.js.map +1 -1
- package/dist/subsystem/model.d.ts +19 -1
- package/dist/subsystem/model.d.ts.map +1 -1
- package/dist/subsystem/model.js +12 -2
- package/dist/subsystem/model.js.map +1 -1
- package/dist/subsystem/nodes.d.ts.map +1 -1
- package/dist/subsystem/nodes.js +24 -4
- package/dist/subsystem/nodes.js.map +1 -1
- package/dist/subsystem/trailBrief.d.ts.map +1 -1
- package/dist/subsystem/trailBrief.js +6 -1
- package/dist/subsystem/trailBrief.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +9 -2
- package/src/pierre/PierreTrailCodeView.tsx +9 -13
- package/src/stories/Subsystem/C4Graph/C4ToComponentDrill.stories.tsx +496 -0
- package/src/stories/Subsystem/ComponentGraph/AnimatedProgression.stories.tsx +7 -7
- package/src/stories/Subsystem/ComponentGraph/Constructs.stories.tsx +19 -25
- package/src/stories/Subsystem/ComponentGraph/DetailPanel.stories.tsx +8 -10
- package/src/stories/Subsystem/ComponentGraph/Issues.stories.tsx +19 -19
- package/src/stories/Subsystem/ComponentGraph/ProposedTrails.stories.tsx +6 -6
- package/src/stories/Subsystem/ComponentGraph/TrailAutoplay.stories.tsx +7 -7
- package/src/stories/Subsystem/ComponentGraph/Trails.stories.tsx +27 -30
- package/src/stories/Subsystem/ComponentGraph/fixtures.ts +1 -2
- package/src/stories/Subsystem/ConstructsCatalog.stories.tsx +10 -13
- package/src/stories/Subsystem/EgoGraph/EgoGraph.stories.tsx +3 -4
- package/src/stories/Subsystem/Sidebar/GraphSidebar.stories.tsx +206 -0
- package/src/subsystem/C4Graph.groups.test.ts +96 -2
- package/src/subsystem/C4Graph.tsx +1377 -165
- package/src/subsystem/C4NodeCard.test.ts +1 -2
- package/src/subsystem/C4NodeCard.tsx +24 -2
- package/src/subsystem/ComponentDeclaration.tsx +18 -8
- package/src/subsystem/ConstructsCatalog.tsx +23 -8
- package/src/subsystem/GraphSidebar.test.tsx +152 -0
- package/src/subsystem/GraphSidebar.tsx +300 -0
- package/src/subsystem/GraphWithSidebar.test.tsx +78 -0
- package/src/subsystem/GraphWithSidebar.tsx +60 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +284 -370
- package/src/subsystem/TrailStepsNav.test.tsx +179 -0
- package/src/subsystem/TrailStepsNav.tsx +372 -0
- package/src/subsystem/TrailsPanel.tsx +3 -4
- package/src/subsystem/__fixtures__/c4Drilldown.test.ts +338 -0
- package/src/subsystem/__fixtures__/c4Drilldown.ts +847 -0
- package/src/subsystem/c4.ts +41 -8
- package/src/subsystem/declarationRef.ts +28 -19
- package/src/subsystem/model.test.ts +32 -12
- package/src/subsystem/model.ts +30 -1
- package/src/subsystem/nodes.group.test.tsx +82 -0
- package/src/subsystem/nodes.tsx +30 -2
- package/src/subsystem/trailBrief.test.ts +2 -2
- package/src/subsystem/trailBrief.ts +6 -1
|
@@ -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
|
+
}
|