UNPKG

@unito/integration-debugger

Version:

The Unito Integration Debugger

51 lines (50 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const styles_1 = require("../../styles"); const store_1 = require("../../store"); const blessed_1 = require("../../resources/blessed"); const CallsPane = () => { const listRef = (0, react_1.useRef)(null); const debuggerState = (0, store_1.useDebuggerState)(); const items = (0, react_1.useCallback)(() => { return debuggerState.steps.map(step => (0, styles_1.renderCallEntry)(step)); }, [debuggerState.steps.length]); (0, react_1.useEffect)(() => { if (listRef.current && debuggerState.selectedPane === store_1.Pane.Calls) { listRef.current.focus(); } }, [listRef, debuggerState.selectedPane]); (0, react_1.useEffect)(() => { if (listRef.current) { (0, blessed_1.enableListScrolling)(listRef.current); listRef.current.key(['left', 'right'], () => { debuggerState.selectedPane = store_1.Pane.Output; }); } return () => { if (listRef.current) { listRef.current.free(); } }; }, [listRef]); // When a step is added or removed, always select the last step in the list. (0, react_1.useEffect)(() => { if (listRef.current) { const index = debuggerState.steps.length - 1; listRef.current.select(index); } }, [listRef, debuggerState.steps.length]); return ((0, jsx_runtime_1.jsx)("list", { ref: listRef, label: (0, styles_1.paneTitle)('calls ↓'), width: "40%", height: "100%-21", border: styles_1.paneBorder, left: 0, top: 0, scrollbar: styles_1.scrollbar, scrollable: true, focusable: true, keys: true, items: items(), style: debuggerState.selectedPane === store_1.Pane.Calls ? styles_1.focusedList : styles_1.unfocusedList, // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore not supported in @types/react-blessed onSelectItem: (_item, index) => { const step = debuggerState.steps.at(index); if (step) { debuggerState.selected = step; debuggerState.selectedStack = undefined; } } })); }; exports.default = CallsPane;