@localstack/appinspector-ui 1.0.208 → 1.0.209

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.cjs CHANGED
@@ -2530,6 +2530,8 @@ var TRACE_SIDEBAR_SPLIT_HANDLE_TEST_ID = "trace-sidebar-split-handle";
2530
2530
  var TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID = "trace-sidebar-waterfall-button";
2531
2531
  var TRACE_SIDEBAR_MAP_BUTTON_TEST_ID = "trace-sidebar-map-button";
2532
2532
  var TRACE_SIDEBAR_ROOT_HEADING_TEST_ID = "trace-sidebar-root-heading";
2533
+ var TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID = "trace-sidebar-maximize-button";
2534
+ var TRACE_SIDEBAR_STATS_TEST_ID = "trace-sidebar-stats";
2533
2535
  var WATERFALL_TEST_ID = "waterfall";
2534
2536
  var WATERFALL_ROW_TEST_ID = "waterfall-row";
2535
2537
  var WATERFALL_ROW_TOGGLE_TEST_ID = "waterfall-row-toggle";
@@ -32843,11 +32845,13 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32843
32845
 
32844
32846
  // src/components/trace-panel/trace-sidebar.tsx
32845
32847
  var import_jsx_runtime149 = require("react/jsx-runtime");
32846
- var DEFAULT_WIDTH = 560;
32847
- var MIN_WIDTH = 360;
32848
+ var DEFAULT_WIDTH_SHARE = 0.75;
32848
32849
  var MAX_WIDTH_SHARE = 0.8;
32849
- var KEYBOARD_STEP = 24;
32850
- var WIDTH_STORAGE_KEY = "appinspector-trace-sidebar-width";
32850
+ var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
32851
+ var MIN_WIDTH = 360;
32852
+ var KEYBOARD_STEP = 0.05;
32853
+ var WIDTH_STORAGE_KEY = "appinspector-trace-sidebar-width-share";
32854
+ var MAXIMIZED_STORAGE_KEY = "appinspector-trace-sidebar-maximized";
32851
32855
  var DEFAULT_SPLIT = 0.4;
32852
32856
  var MIN_SPLIT = 0.15;
32853
32857
  var MAX_SPLIT = 0.7;
@@ -32856,23 +32860,39 @@ var SPLIT_STORAGE_KEY = "appinspector-trace-sidebar-split";
32856
32860
  var clampSplit = (split2) => Math.min(MAX_SPLIT, Math.max(MIN_SPLIT, split2));
32857
32861
  var noop = () => void 0;
32858
32862
  var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32859
- const [storedWidth, setStoredWidth] = useLocalStorage(WIDTH_STORAGE_KEY, DEFAULT_WIDTH);
32863
+ const [storedWidth, setStoredWidth] = useLocalStorage(WIDTH_STORAGE_KEY, DEFAULT_WIDTH_SHARE);
32864
+ const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
32860
32865
  const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
32861
32866
  const [view, setView] = React125.useState("waterfall");
32862
32867
  const sidebarRef = React125.useRef(null);
32863
32868
  const traceViewRef = React125.useRef(null);
32864
- const clampWidth = (width) => {
32865
- const parentWidth = sidebarRef.current?.parentElement?.clientWidth;
32866
- const max2 = parentWidth === void 0 || parentWidth === 0 ? Number.POSITIVE_INFINITY : Math.max(MIN_WIDTH, parentWidth * MAX_WIDTH_SHARE);
32867
- return Math.round(Math.min(max2, Math.max(MIN_WIDTH, width)));
32869
+ const width = maximized ? 1 : storedWidth;
32870
+ const [parentWidth, setParentWidth] = React125.useState(0);
32871
+ React125.useLayoutEffect(() => {
32872
+ const parent = sidebarRef.current?.parentElement;
32873
+ if (!parent) return;
32874
+ const observer = new ResizeObserver(([entry]) => {
32875
+ if (entry) setParentWidth(entry.contentRect.width);
32876
+ });
32877
+ observer.observe(parent);
32878
+ return () => {
32879
+ observer.disconnect();
32880
+ };
32881
+ }, []);
32882
+ const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
32883
+ const resize = (share) => {
32884
+ const snap = share > SNAP_WIDTH_SHARE;
32885
+ setMaximized(snap);
32886
+ if (!snap) setStoredWidth(Math.min(MAX_WIDTH_SHARE, Math.max(minWidth, share)));
32868
32887
  };
32869
32888
  const handlePointerDown = (event) => {
32870
32889
  event.currentTarget.setPointerCapture(event.pointerId);
32871
32890
  };
32872
32891
  const handlePointerMove = (event) => {
32873
32892
  if (!event.currentTarget.hasPointerCapture(event.pointerId)) return;
32874
- const right = sidebarRef.current?.getBoundingClientRect().right ?? event.clientX;
32875
- setStoredWidth(clampWidth(right - event.clientX));
32893
+ const right = sidebarRef.current?.getBoundingClientRect().right;
32894
+ if (right === void 0 || parentWidth === 0) return;
32895
+ resize((right - event.clientX) / parentWidth);
32876
32896
  };
32877
32897
  const handlePointerUp = (event) => {
32878
32898
  event.currentTarget.releasePointerCapture(event.pointerId);
@@ -32881,7 +32901,8 @@ var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans
32881
32901
  const delta = event.key === "ArrowLeft" ? KEYBOARD_STEP : event.key === "ArrowRight" ? -KEYBOARD_STEP : 0;
32882
32902
  if (delta === 0) return;
32883
32903
  event.preventDefault();
32884
- setStoredWidth(clampWidth(storedWidth + delta));
32904
+ const next = Math.round((width + delta) * 100) / 100;
32905
+ resize(maximized ? delta < 0 ? MAX_WIDTH_SHARE : 1 : next > MAX_WIDTH_SHARE ? 1 : next);
32885
32906
  };
32886
32907
  const handleSplitPointerMove = (event) => {
32887
32908
  if (!event.currentTarget.hasPointerCapture(event.pointerId)) return;
@@ -32927,10 +32948,10 @@ var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans
32927
32948
  flexDirection: "column",
32928
32949
  flexShrink: 0,
32929
32950
  height: "100%",
32930
- maxWidth: `${String(MAX_WIDTH_SHARE * 100)}%`,
32951
+ maxWidth: "100%",
32931
32952
  minWidth: MIN_WIDTH,
32932
32953
  position: "relative",
32933
- width: storedWidth
32954
+ width: `${String(width * 100)}%`
32934
32955
  },
32935
32956
  children: [
32936
32957
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
@@ -32938,8 +32959,9 @@ var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans
32938
32959
  {
32939
32960
  "aria-label": "Resize the sidebar",
32940
32961
  "aria-orientation": "vertical",
32941
- "aria-valuemin": MIN_WIDTH,
32942
- "aria-valuenow": storedWidth,
32962
+ "aria-valuemax": maximized ? 100 : MAX_WIDTH_SHARE * 100,
32963
+ "aria-valuemin": Math.round(minWidth * 100),
32964
+ "aria-valuenow": Math.round(width * 100),
32943
32965
  "data-testid": TRACE_SIDEBAR_RESIZE_HANDLE_TEST_ID,
32944
32966
  onKeyDown: handleKeyDown,
32945
32967
  onPointerDown: handlePointerDown,
@@ -32969,7 +32991,7 @@ var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans
32969
32991
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Typography, { noWrap: true, sx: { flex: "0 1 auto", fontWeight: 600, minWidth: 0 }, title: root2.operation_name, variant: "subtitle1", children: root2.operation_name }),
32970
32992
  rootResource !== "" && rootResource !== "*" && /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Typography, { color: "text.secondary", noWrap: true, sx: { flex: "1 1 0", minWidth: 0 }, title: rootResource, variant: "body2", children: rootResource })
32971
32993
  ] }),
32972
- /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Typography, { color: "text.secondary", variant: "caption", children: [
32994
+ /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Typography, { color: "text.secondary", component: "div", "data-testid": TRACE_SIDEBAR_STATS_TEST_ID, variant: "caption", children: [
32973
32995
  formatDuration(stats.durationMs),
32974
32996
  pluralize(spans.length, "op"),
32975
32997
  ...stats.errors > 0 ? [pluralize(stats.errors, "error")] : [],
@@ -32992,6 +33014,9 @@ var TraceSidebar = ({ onClose, onSelectSpan, selectedSpanId, spanMatches, spans
32992
33014
  ]
32993
33015
  }
32994
33016
  ),
33017
+ /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.IconButton, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
33018
+ setMaximized(!maximized);
33019
+ }, size: "small", children: maximized ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_icons_material15.CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_icons_material15.OpenInFull, { fontSize: "small" }) }),
32995
33020
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.IconButton, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_icons_material15.Close, {}) })
32996
33021
  ] }),
32997
33022
  /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Box, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: view === "waterfall" ? /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }) : /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_material25.Box, { sx: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_react62.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(
@@ -33915,7 +33940,9 @@ var SpansListPage = () => {
33915
33940
  display: "flex",
33916
33941
  flexDirection: "column",
33917
33942
  flexGrow: 1,
33918
- minWidth: 0
33943
+ minWidth: 0,
33944
+ // A full-width trace sidebar leaves the list no width: clip it rather than let it spill under.
33945
+ overflow: "hidden"
33919
33946
  },
33920
33947
  children: [
33921
33948
  /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(