@industry-theme/principal-view-panels 0.12.1 → 0.12.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"CanvasEditorPanel.d.ts","sourceRoot":"","sources":["../../src/panels/CanvasEditorPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAI5D,OAAO,KAAK,EAAyE,gBAAgB,EAAoC,MAAM,mCAAmC,CAAC;AAKnL,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AA6BrE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,2BAA2B;IACzE;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE3C;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEnC;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAioC9D,CAAC"}
1
+ {"version":3,"file":"CanvasEditorPanel.d.ts","sourceRoot":"","sources":["../../src/panels/CanvasEditorPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAI5D,OAAO,KAAK,EAAyE,gBAAgB,EAAoC,MAAM,mCAAmC,CAAC;AAKnL,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AA6BrE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,2BAA2B;IACzE;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEjC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAE3C;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B;;OAEG;IACH,gBAAgB,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAEnC;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;QAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;CACJ;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAs7B9D,CAAC"}
@@ -94246,11 +94246,9 @@ const CanvasEditorPanel = ({
94246
94246
  workflowFileInfo: _workflowFileInfo,
94247
94247
  traceMatchInfo
94248
94248
  }) => {
94249
- var _a, _b, _c, _d, _e2;
94249
+ var _a, _b, _c;
94250
94250
  const { theme: theme2 } = useTheme();
94251
94251
  const graphRef = useRef(null);
94252
- const [dimensions, setDimensions] = useState({ width: 800, height: 600 });
94253
- const resizeObserverRef = useRef(null);
94254
94252
  const [state, setState] = useState({
94255
94253
  canvas: null,
94256
94254
  library: null,
@@ -94270,6 +94268,7 @@ const CanvasEditorPanel = ({
94270
94268
  highlightedNodeId: null
94271
94269
  });
94272
94270
  const [shouldFitToNodes, setShouldFitToNodes] = useState(false);
94271
+ const [fitCounter, setFitCounter] = useState(0);
94273
94272
  const [isCarouselExpanded, setIsCarouselExpanded] = useState(false);
94274
94273
  const contextRef = useRef(context2);
94275
94274
  const actionsRef = useRef(actions);
@@ -94285,32 +94284,6 @@ const CanvasEditorPanel = ({
94285
94284
  return ((_a2 = slice == null ? void 0 : slice.data) == null ? void 0 : _a2.sha) || null;
94286
94285
  }, [context2]);
94287
94286
  const [pathCopied, setPathCopied] = useState(false);
94288
- const containerRef = useCallback((container) => {
94289
- if (resizeObserverRef.current) {
94290
- resizeObserverRef.current.disconnect();
94291
- resizeObserverRef.current = null;
94292
- }
94293
- if (!container) {
94294
- return;
94295
- }
94296
- const updateDimensions = () => {
94297
- const { width, height } = container.getBoundingClientRect();
94298
- setDimensions((prev) => {
94299
- const newWidth = Math.round(width);
94300
- const newHeight = Math.round(height);
94301
- if (prev.width === newWidth && prev.height === newHeight) {
94302
- return prev;
94303
- }
94304
- return { width: newWidth, height: newHeight };
94305
- });
94306
- };
94307
- updateDimensions();
94308
- const resizeObserver = new ResizeObserver(() => {
94309
- requestAnimationFrame(updateDimensions);
94310
- });
94311
- resizeObserver.observe(container);
94312
- resizeObserverRef.current = resizeObserver;
94313
- }, []);
94314
94287
  const loadConfiguration = useCallback(async () => {
94315
94288
  if (!canvasPath) {
94316
94289
  setState((prev) => ({ ...prev, canvas: null, library: null, loading: false, error: null }));
@@ -94409,6 +94382,7 @@ const CanvasEditorPanel = ({
94409
94382
  hoveredScenarioEventNames: eventNames
94410
94383
  }));
94411
94384
  if (eventNames && eventNames.length > 0) {
94385
+ setFitCounter((c2) => c2 + 1);
94412
94386
  setShouldFitToNodes(true);
94413
94387
  }
94414
94388
  }, []);
@@ -94421,6 +94395,7 @@ const CanvasEditorPanel = ({
94421
94395
  highlightedNodeId: null
94422
94396
  }));
94423
94397
  setIsCarouselExpanded(true);
94398
+ setFitCounter((c2) => c2 + 1);
94424
94399
  setShouldFitToNodes(true);
94425
94400
  }, []);
94426
94401
  const handleNarrativeEventClick = useCallback((event, eventIndex) => {
@@ -94432,6 +94407,7 @@ const CanvasEditorPanel = ({
94432
94407
  currentEventIndex: eventIndex
94433
94408
  };
94434
94409
  });
94410
+ setFitCounter((c2) => c2 + 1);
94435
94411
  setShouldFitToNodes(true);
94436
94412
  }, []);
94437
94413
  const handleEventCarouselDismiss = useCallback(() => {
@@ -94519,20 +94495,37 @@ const CanvasEditorPanel = ({
94519
94495
  return [state.highlightedNodeId];
94520
94496
  }
94521
94497
  if (activeNodeIds && activeNodeIds.length > 0) {
94522
- return activeNodeIds;
94498
+ return [...activeNodeIds];
94523
94499
  }
94524
94500
  if (((_a2 = state.canvas) == null ? void 0 : _a2.nodes) && state.canvas.nodes.length > 0) {
94525
94501
  return state.canvas.nodes.map((n) => n.id);
94526
94502
  }
94527
94503
  }
94528
94504
  return void 0;
94529
- }, [shouldFitToNodes, activeNodeIds, (_a = state.canvas) == null ? void 0 : _a.nodes, state.highlightedNodeId]);
94505
+ }, [shouldFitToNodes, activeNodeIds, (_a = state.canvas) == null ? void 0 : _a.nodes, state.highlightedNodeId, fitCounter]);
94530
94506
  useEffect(() => {
94531
94507
  if (shouldFitToNodes) {
94532
- const timer2 = setTimeout(() => setShouldFitToNodes(false), 100);
94508
+ const timer2 = setTimeout(() => setShouldFitToNodes(false), 300);
94533
94509
  return () => clearTimeout(timer2);
94534
94510
  }
94535
94511
  }, [shouldFitToNodes]);
94512
+ const prevWorkflowTemplateRef = useRef(workflowTemplate);
94513
+ useEffect(() => {
94514
+ const hadWorkflow = !!prevWorkflowTemplateRef.current;
94515
+ const hasWorkflow = !!workflowTemplate;
94516
+ prevWorkflowTemplateRef.current = workflowTemplate;
94517
+ if (hadWorkflow !== hasWorkflow) {
94518
+ setState((prev) => ({
94519
+ ...prev,
94520
+ selectedScenarioId: null,
94521
+ selectedScenario: null,
94522
+ hoveredScenarioEventNames: null,
94523
+ highlightedNodeId: null,
94524
+ currentEventIndex: 0
94525
+ }));
94526
+ setIsCarouselExpanded(false);
94527
+ }
94528
+ }, [workflowTemplate]);
94536
94529
  useEffect(() => {
94537
94530
  loadConfiguration();
94538
94531
  }, [canvasPath, loadConfiguration]);
@@ -94761,11 +94754,13 @@ const CanvasEditorPanel = ({
94761
94754
  }
94762
94755
  )
94763
94756
  ] }),
94764
- /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "hidden" }, children: workflowTemplate ? /* @__PURE__ */ jsx(
94757
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, overflow: "hidden" }, children: /* @__PURE__ */ jsx(
94765
94758
  AnimatedResizableLayout,
94766
94759
  {
94767
94760
  theme: theme2,
94768
- leftPanel: /* @__PURE__ */ jsx("div", { style: { height: "100%", overflow: "hidden", background: theme2.colors.background }, children: /* @__PURE__ */ jsx(
94761
+ collapsed: !workflowTemplate,
94762
+ showCollapseButton: !!workflowTemplate,
94763
+ leftPanel: workflowTemplate ? /* @__PURE__ */ jsx("div", { style: { height: "100%", overflow: "hidden", background: theme2.colors.background }, children: /* @__PURE__ */ jsx(
94769
94764
  ScenariosList,
94770
94765
  {
94771
94766
  workflowTemplate,
@@ -94774,7 +94769,7 @@ const CanvasEditorPanel = ({
94774
94769
  selectedScenarioId: state.selectedScenarioId ?? void 0,
94775
94770
  traceMatchInfo
94776
94771
  }
94777
- ) }),
94772
+ ) }) : /* @__PURE__ */ jsx("div", {}),
94778
94773
  rightPanel: /* @__PURE__ */ jsxs("div", { style: { height: "100%", display: "flex", flexDirection: "column", background: theme2.colors.background, position: "relative" }, children: [
94779
94774
  /* @__PURE__ */ jsxs("div", { style: { flex: 1, position: "relative", minHeight: 0 }, children: [
94780
94775
  /* @__PURE__ */ jsx(
@@ -95010,189 +95005,6 @@ const CanvasEditorPanel = ({
95010
95005
  )
95011
95006
  ] })
95012
95007
  }
95013
- ) : (
95014
- /* Original editor layout when no workflow is present */
95015
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", position: "relative", height: "100%", overflow: "hidden" }, children: [
95016
- /* @__PURE__ */ jsx("div", { ref: containerRef, style: { flex: 1, position: "relative" }, children: /* @__PURE__ */ jsx(
95017
- GraphRenderer,
95018
- {
95019
- ref: graphRef,
95020
- canvas: state.canvas,
95021
- library: state.library ?? void 0,
95022
- width: dimensions.width,
95023
- height: dimensions.height,
95024
- editable: state.isEditMode,
95025
- onPendingChangesChange: (hasChanges) => {
95026
- setState((prev) => ({ ...prev, hasUnsavedChanges: hasChanges }));
95027
- },
95028
- showBackground: state.showGridLines,
95029
- backgroundVariant: "lines",
95030
- highlightedNodeId: state.highlightedNodeId,
95031
- activeNodeIds,
95032
- fitViewToNodeIds,
95033
- fitViewPadding: 0.15
95034
- }
95035
- ) }),
95036
- state.isEditMode && state.hasUnsavedChanges && /* @__PURE__ */ jsxs("div", { style: {
95037
- position: "absolute",
95038
- top: 0,
95039
- right: 0,
95040
- height: 40,
95041
- display: "flex",
95042
- alignItems: "stretch",
95043
- backgroundColor: theme2.colors.background,
95044
- border: `1px solid ${theme2.colors.border}`,
95045
- borderRadius: 0,
95046
- boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
95047
- zIndex: 40
95048
- }, children: [
95049
- /* @__PURE__ */ jsx("div", { style: {
95050
- display: "flex",
95051
- alignItems: "center",
95052
- padding: theme2.space[3],
95053
- fontSize: theme2.fontSizes[1],
95054
- color: theme2.colors.warning || "#f59e0b",
95055
- fontStyle: "italic",
95056
- fontWeight: theme2.fontWeights.medium
95057
- }, children: "Unsaved changes" }),
95058
- /* @__PURE__ */ jsxs(
95059
- "button",
95060
- {
95061
- onClick: saveAllChanges,
95062
- disabled: state.isSaving,
95063
- style: {
95064
- display: "flex",
95065
- alignItems: "center",
95066
- justifyContent: "center",
95067
- gap: theme2.space[1],
95068
- padding: `0 ${theme2.space[3]}`,
95069
- fontSize: theme2.fontSizes[1],
95070
- fontFamily: theme2.fonts.body,
95071
- color: "white",
95072
- backgroundColor: theme2.colors.primary,
95073
- border: "none",
95074
- borderRadius: 0,
95075
- cursor: state.isSaving ? "wait" : "pointer",
95076
- opacity: state.isSaving ? 0.7 : 1,
95077
- transition: "all 0.2s",
95078
- minWidth: 80
95079
- },
95080
- children: [
95081
- state.isSaving ? /* @__PURE__ */ jsx(Loader, { size: 14, style: { animation: "spin 1s linear infinite" } }) : /* @__PURE__ */ jsx(Save, { size: 14 }),
95082
- /* @__PURE__ */ jsx("span", { children: "Save" })
95083
- ]
95084
- }
95085
- ),
95086
- /* @__PURE__ */ jsxs(
95087
- "button",
95088
- {
95089
- onClick: discardChanges,
95090
- disabled: state.isSaving,
95091
- style: {
95092
- display: "flex",
95093
- alignItems: "center",
95094
- justifyContent: "center",
95095
- gap: theme2.space[1],
95096
- padding: `0 ${theme2.space[3]}`,
95097
- fontSize: theme2.fontSizes[1],
95098
- fontFamily: theme2.fonts.body,
95099
- color: theme2.colors.text,
95100
- backgroundColor: theme2.colors.backgroundSecondary,
95101
- border: "none",
95102
- borderLeft: `1px solid ${theme2.colors.border}`,
95103
- borderRadius: 0,
95104
- cursor: state.isSaving ? "wait" : "pointer",
95105
- opacity: state.isSaving ? 0.7 : 1,
95106
- transition: "all 0.2s",
95107
- minWidth: 80
95108
- },
95109
- children: [
95110
- /* @__PURE__ */ jsx(X, { size: 14 }),
95111
- /* @__PURE__ */ jsx("span", { children: "Discard" })
95112
- ]
95113
- }
95114
- )
95115
- ] }),
95116
- state.showLegend && /* @__PURE__ */ jsxs("div", { style: {
95117
- position: "absolute",
95118
- top: 0,
95119
- left: 0,
95120
- right: 0,
95121
- height: 40,
95122
- backgroundColor: theme2.colors.background,
95123
- borderBottom: `1px solid ${theme2.colors.border}`,
95124
- padding: `0 ${theme2.space[3]}`,
95125
- display: "flex",
95126
- alignItems: "center",
95127
- gap: theme2.space[4],
95128
- overflowX: "auto",
95129
- zIndex: 50,
95130
- boxSizing: "border-box"
95131
- }, children: [
95132
- /* @__PURE__ */ jsx("span", { style: {
95133
- fontSize: theme2.fontSizes[1],
95134
- fontWeight: theme2.fontWeights.medium,
95135
- color: theme2.colors.textMuted,
95136
- flexShrink: 0
95137
- }, children: "Edges:" }),
95138
- ((_e2 = (_d = state.canvas) == null ? void 0 : _d.pv) == null ? void 0 : _e2.edgeTypes) && Object.keys(state.canvas.pv.edgeTypes).length > 0 ? /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", gap: theme2.space[4], flexWrap: "wrap" }, children: Object.entries(state.canvas.pv.edgeTypes).map(([typeName, edgeType]) => /* @__PURE__ */ jsxs(
95139
- "div",
95140
- {
95141
- style: {
95142
- display: "flex",
95143
- alignItems: "center",
95144
- gap: theme2.space[2]
95145
- },
95146
- children: [
95147
- /* @__PURE__ */ jsxs("svg", { width: "40", height: "12", style: { flexShrink: 0 }, children: [
95148
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx(
95149
- "marker",
95150
- {
95151
- id: `legend-arrow-${typeName}`,
95152
- markerWidth: "8",
95153
- markerHeight: "6",
95154
- refX: "7",
95155
- refY: "3",
95156
- orient: "auto",
95157
- children: /* @__PURE__ */ jsx(
95158
- "polygon",
95159
- {
95160
- points: "0 0, 8 3, 0 6",
95161
- fill: edgeType.color || "#64748b"
95162
- }
95163
- )
95164
- }
95165
- ) }),
95166
- /* @__PURE__ */ jsx(
95167
- "line",
95168
- {
95169
- x1: "2",
95170
- y1: "6",
95171
- x2: "32",
95172
- y2: "6",
95173
- stroke: edgeType.color || "#64748b",
95174
- strokeWidth: Math.min(edgeType.width || 2, 3),
95175
- strokeDasharray: edgeType.style === "dashed" ? "4,2" : edgeType.style === "dotted" ? "2,2" : void 0,
95176
- markerEnd: edgeType.directed ? `url(#legend-arrow-${typeName})` : void 0
95177
- }
95178
- )
95179
- ] }),
95180
- /* @__PURE__ */ jsx("span", { style: {
95181
- fontSize: theme2.fontSizes[1],
95182
- color: theme2.colors.text,
95183
- textTransform: "capitalize",
95184
- whiteSpace: "nowrap"
95185
- }, children: typeName.replace(/-/g, " ") })
95186
- ]
95187
- },
95188
- typeName
95189
- )) }) : /* @__PURE__ */ jsx("span", { style: {
95190
- fontSize: theme2.fontSizes[1],
95191
- color: theme2.colors.textMuted,
95192
- fontStyle: "italic"
95193
- }, children: "No edge types defined" })
95194
- ] })
95195
- ] })
95196
95008
  ) })
95197
95009
  ] });
95198
95010
  };