@principal-ai/subsystems-react 0.56.38 → 0.56.39
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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.d.ts +7 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +2 -2
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/TrailIcon.d.ts +22 -0
- package/dist/subsystem/TrailIcon.d.ts.map +1 -0
- package/dist/subsystem/TrailIcon.js +50 -0
- package/dist/subsystem/TrailIcon.js.map +1 -0
- package/dist/subsystem/TrailStepsNav.d.ts +4 -1
- package/dist/subsystem/TrailStepsNav.d.ts.map +1 -1
- package/dist/subsystem/TrailStepsNav.js +6 -16
- package/dist/subsystem/TrailStepsNav.js.map +1 -1
- package/dist/subsystem/TrailsPanel.d.ts +4 -1
- package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
- package/dist/subsystem/TrailsPanel.js +11 -14
- package/dist/subsystem/TrailsPanel.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/subsystem/SubsystemComponentGraph.tsx +9 -1
- package/src/subsystem/TrailIcon.tsx +90 -0
- package/src/subsystem/TrailStepsNav.tsx +13 -18
- package/src/subsystem/TrailsPanel.test.tsx +51 -0
- package/src/subsystem/TrailsPanel.tsx +17 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import type { CSSProperties, ReactNode } from 'react';
|
|
3
|
-
import { ChevronRight,
|
|
3
|
+
import { ChevronRight, X } from 'lucide-react';
|
|
4
4
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
5
5
|
import { HOST_PROPOSAL_COLOR, type SubsystemTrail } from './model';
|
|
6
6
|
import {
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type TrailComponentLabels,
|
|
9
9
|
} from './trailStepDisplay';
|
|
10
10
|
import { buildTrailStack } from './trailStack';
|
|
11
|
+
import { TrailIcon, type TrailChange } from './TrailIcon';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* TrailStepsNav — the trails side panel as a two-step slide: a list of trails,
|
|
@@ -58,6 +59,8 @@ export interface TrailStepsNavProps {
|
|
|
58
59
|
detailContent?: ReactNode;
|
|
59
60
|
/** Host-local trails awaiting confirmation; their header icon uses proposal color. */
|
|
60
61
|
proposedTrailIds?: Set<string>;
|
|
62
|
+
/** What the host says is happening to each trail, by id. Marks the trail's icon. */
|
|
63
|
+
trailChanges?: ReadonlyMap<string, TrailChange>;
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
const PANE: CSSProperties = {
|
|
@@ -86,6 +89,7 @@ export function TrailStepsNav({
|
|
|
86
89
|
renderSteps,
|
|
87
90
|
detailContent,
|
|
88
91
|
proposedTrailIds,
|
|
92
|
+
trailChanges,
|
|
89
93
|
}: TrailStepsNavProps) {
|
|
90
94
|
const { theme } = useTheme();
|
|
91
95
|
const muted = theme.colors.textMuted ?? theme.colors.textSecondary;
|
|
@@ -171,16 +175,12 @@ export function TrailStepsNav({
|
|
|
171
175
|
transition: 'background 120ms ease',
|
|
172
176
|
}}
|
|
173
177
|
>
|
|
174
|
-
<
|
|
178
|
+
<TrailIcon
|
|
179
|
+
change={trailChanges?.get(trail.id)}
|
|
175
180
|
size={14}
|
|
176
181
|
strokeWidth={2}
|
|
177
|
-
|
|
178
|
-
style={{
|
|
179
|
-
flexShrink: 0,
|
|
180
|
-
marginTop: 3,
|
|
181
|
-
color: focusedRow || hovered ? theme.colors.primary : muted,
|
|
182
|
-
transition: 'color 120ms ease',
|
|
183
|
-
}}
|
|
182
|
+
color={focusedRow || hovered ? theme.colors.primary : muted}
|
|
183
|
+
style={{ flexShrink: 0, marginTop: 3, transition: 'color 120ms ease' }}
|
|
184
184
|
/>
|
|
185
185
|
<span
|
|
186
186
|
style={{
|
|
@@ -236,19 +236,14 @@ export function TrailStepsNav({
|
|
|
236
236
|
padding: '14px 12px',
|
|
237
237
|
}}
|
|
238
238
|
>
|
|
239
|
-
<
|
|
239
|
+
<TrailIcon
|
|
240
|
+
change={displayedTrail ? trailChanges?.get(displayedTrail.id) : undefined}
|
|
240
241
|
size={14}
|
|
241
242
|
strokeWidth={2}
|
|
242
|
-
aria-hidden
|
|
243
243
|
// A proposed trail keeps the proposal colour here too, matching
|
|
244
244
|
// its row icon in the list it came from.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
marginTop: 3,
|
|
248
|
-
color: proposed
|
|
249
|
-
? HOST_PROPOSAL_COLOR
|
|
250
|
-
: theme.colors.primary,
|
|
251
|
-
}}
|
|
245
|
+
color={proposed ? HOST_PROPOSAL_COLOR : theme.colors.primary}
|
|
246
|
+
style={{ flexShrink: 0, marginTop: 3 }}
|
|
252
247
|
/>
|
|
253
248
|
{/* The title is the back affordance too: clicking it goes back to
|
|
254
249
|
the list, like the trailing close. */}
|
|
@@ -555,3 +555,54 @@ describe('TrailsPanel host emphasis', () => {
|
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
557
|
});
|
|
558
|
+
|
|
559
|
+
describe('TrailsPanel trail changes', () => {
|
|
560
|
+
test('a trail with a change gets a labelled, coloured icon in the list; others keep the plain one', () => {
|
|
561
|
+
const { getAllByLabelText, queryAllByLabelText, getByText } = renderPanel({
|
|
562
|
+
trails: [trails[0]!, usesTrail],
|
|
563
|
+
expandedTrails: new Set(),
|
|
564
|
+
trailChanges: new Map([['auth-flow', 'added']]),
|
|
565
|
+
});
|
|
566
|
+
expect(getAllByLabelText('Added trail')).toHaveLength(1);
|
|
567
|
+
expect(queryAllByLabelText('Removed trail')).toHaveLength(0);
|
|
568
|
+
expect(queryAllByLabelText('Changed trail')).toHaveLength(0);
|
|
569
|
+
// The marked trail's icon is wrapped; the unmarked one is still the bare icon.
|
|
570
|
+
const marked = getByText('Auth flow').closest('button')!.firstElementChild as HTMLElement;
|
|
571
|
+
expect(marked.getAttribute('aria-label')).toBe('Added trail');
|
|
572
|
+
const plain = getByText('Uses flow').closest('button')!.firstElementChild as SVGElement;
|
|
573
|
+
expect(plain.tagName.toLowerCase()).toBe('svg');
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test('each change has its own label and colour', () => {
|
|
577
|
+
const { getByLabelText } = renderPanel({
|
|
578
|
+
trails: [trails[0]!, usesTrail, { ...usesTrail, id: 'third', title: 'Third flow' }],
|
|
579
|
+
expandedTrails: new Set(),
|
|
580
|
+
trailChanges: new Map([
|
|
581
|
+
['auth-flow', 'added'],
|
|
582
|
+
['uses-flow', 'removed'],
|
|
583
|
+
['third', 'changed'],
|
|
584
|
+
]),
|
|
585
|
+
});
|
|
586
|
+
const colours = ['Added trail', 'Removed trail', 'Changed trail'].map(
|
|
587
|
+
(label) => getByLabelText(label).style.color,
|
|
588
|
+
);
|
|
589
|
+
expect(new Set(colours).size).toBe(3);
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
test('the selected trail header shows its change', () => {
|
|
593
|
+
const { getAllByLabelText } = renderPanel({
|
|
594
|
+
drilldown: true,
|
|
595
|
+
focusedTrailId: 'auth-flow',
|
|
596
|
+
trailChanges: new Map([['auth-flow', 'changed']]),
|
|
597
|
+
});
|
|
598
|
+
// One in the list pane (the slid-out list), one in the step pane's header.
|
|
599
|
+
expect(getAllByLabelText('Changed trail').length).toBeGreaterThanOrEqual(1);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test('no trailChanges, no marks', () => {
|
|
603
|
+
const { queryAllByLabelText } = renderPanel({ trails: [trails[0]!, usesTrail], expandedTrails: new Set() });
|
|
604
|
+
for (const label of ['Added trail', 'Removed trail', 'Changed trail']) {
|
|
605
|
+
expect(queryAllByLabelText(label)).toHaveLength(0);
|
|
606
|
+
}
|
|
607
|
+
});
|
|
608
|
+
});
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
14
14
|
import type { DragEvent as ReactDragEvent, ReactNode } from 'react';
|
|
15
15
|
import { useTheme } from '@principal-ade/industry-theme';
|
|
16
|
-
import { Check, ChevronDown, Focus, GripVertical, Minimize2, Pause, Play,
|
|
16
|
+
import { Check, ChevronDown, Focus, GripVertical, Minimize2, Pause, Play, Star } from 'lucide-react';
|
|
17
17
|
import { IndustryMarkdownSlide } from 'themed-markdown';
|
|
18
18
|
import {
|
|
19
19
|
reorderTargetIndex,
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from './trailStepDisplay';
|
|
32
32
|
import { buildTrailStack } from './trailStack';
|
|
33
33
|
import { TrailStepsNav } from './TrailStepsNav';
|
|
34
|
+
import { TrailIcon, type TrailChange } from './TrailIcon';
|
|
34
35
|
|
|
35
36
|
/** Pause (ms) between steps when a trail autoplays. */
|
|
36
37
|
export const TRAIL_PLAY_PAUSE_MS = 2500;
|
|
@@ -95,6 +96,7 @@ function TrailFlow({
|
|
|
95
96
|
componentByAlias,
|
|
96
97
|
hideHeader = false,
|
|
97
98
|
proposed = false,
|
|
99
|
+
change,
|
|
98
100
|
proposedStepKeys,
|
|
99
101
|
focusedVariationStepIndexes,
|
|
100
102
|
stepNumberLabels,
|
|
@@ -141,6 +143,8 @@ function TrailFlow({
|
|
|
141
143
|
hideHeader?: boolean;
|
|
142
144
|
/** Host-local proposal: colour the flow icon without changing the title. */
|
|
143
145
|
proposed?: boolean;
|
|
146
|
+
/** What the host says is happening to this trail; its icon shows it. */
|
|
147
|
+
change?: TrailChange;
|
|
144
148
|
/** Host-local proposed steps, keyed by `emphasisKey(trailId, step)`. */
|
|
145
149
|
proposedStepKeys?: Set<string>;
|
|
146
150
|
/** Step indexes that belong to one focused variation group in this flow. */
|
|
@@ -347,19 +351,18 @@ function TrailFlow({
|
|
|
347
351
|
cursor: 'pointer',
|
|
348
352
|
}}
|
|
349
353
|
>
|
|
350
|
-
<
|
|
354
|
+
<TrailIcon
|
|
355
|
+
change={change}
|
|
351
356
|
size={14}
|
|
352
357
|
strokeWidth={2}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
marginTop: 3,
|
|
357
|
-
color: proposed
|
|
358
|
+
style={{ flexShrink: 0, marginTop: 3 }}
|
|
359
|
+
color={
|
|
360
|
+
proposed
|
|
358
361
|
? proposalColor
|
|
359
362
|
: headerHover || (!collapsed && wholeFlowActive)
|
|
360
363
|
? theme.colors.primary
|
|
361
|
-
: muted
|
|
362
|
-
}
|
|
364
|
+
: muted
|
|
365
|
+
}
|
|
363
366
|
/>
|
|
364
367
|
<span
|
|
365
368
|
style={{
|
|
@@ -796,6 +799,8 @@ export interface TrailsPanelProps {
|
|
|
796
799
|
* recede. Rows are never hidden or reordered.
|
|
797
800
|
*/
|
|
798
801
|
highlightedTrailIds?: ReadonlySet<string>;
|
|
802
|
+
/** What the host says is happening to each trail, by id. Marks the trail's icon. */
|
|
803
|
+
trailChanges?: ReadonlyMap<string, TrailChange>;
|
|
799
804
|
/** Host-local steps awaiting confirmation, keyed by `emphasisKey`. */
|
|
800
805
|
proposedStepKeys?: Set<string>;
|
|
801
806
|
/** Step indexes that belong to one focused variation group, by trail id. */
|
|
@@ -834,6 +839,7 @@ export function TrailsPanel({
|
|
|
834
839
|
detailContent,
|
|
835
840
|
proposedTrailIds,
|
|
836
841
|
highlightedTrailIds,
|
|
842
|
+
trailChanges,
|
|
837
843
|
proposedStepKeys,
|
|
838
844
|
focusedVariationStepIndexes,
|
|
839
845
|
stepNumberLabels,
|
|
@@ -1030,6 +1036,7 @@ export function TrailsPanel({
|
|
|
1030
1036
|
stepEmphasis={stepEmphasis}
|
|
1031
1037
|
onRemoveStepEmphasis={onRemoveStepEmphasis}
|
|
1032
1038
|
proposed={proposedTrailIds?.has(tl.id) ?? false}
|
|
1039
|
+
change={trailChanges?.get(tl.id)}
|
|
1033
1040
|
proposedStepKeys={proposedStepKeys}
|
|
1034
1041
|
focusedVariationStepIndexes={focusedVariationStepIndexes?.get(tl.id)}
|
|
1035
1042
|
stepNumberLabels={stepNumberLabels}
|
|
@@ -1059,6 +1066,7 @@ export function TrailsPanel({
|
|
|
1059
1066
|
listContent={list}
|
|
1060
1067
|
detailContent={detailContent}
|
|
1061
1068
|
proposedTrailIds={proposedTrailIds}
|
|
1069
|
+
trailChanges={trailChanges}
|
|
1062
1070
|
renderSteps={(trail) => (
|
|
1063
1071
|
<TrailFlow
|
|
1064
1072
|
key={trail.id}
|