UNPKG

@gordon1210/depup

Version:

a dependency upgrade tool for node projects

15 lines (14 loc) 1.68 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Box, Text } from "ink"; import { progressBar } from "../utils.js"; import { PackageRow } from "./PackageRow.js"; export function PackageList({ packages, cursor, visibleCount, checkDivergingVersions, areVersionsEqual, hasHigherUpdates, }) { const start = Math.min(Math.max(0, cursor - Math.floor(visibleCount / 2)), Math.max(0, packages.length - visibleCount)); const visible = packages.slice(start, start + visibleCount); return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { flexDirection: "row", children: [_jsx(Box, { width: 3 }), _jsx(Box, { width: 32, children: _jsx(Text, { bold: true, children: "Name" }) }), _jsx(Box, { width: 14, children: _jsx(Text, { bold: true, children: "Current" }) }), _jsx(Box, { width: 19, children: _jsx(Text, { bold: true, children: "Target" }) }), _jsx(Box, { width: 12, children: _jsx(Text, { bold: true, children: "Strategy" }) }), _jsx(Box, { flexGrow: 1, children: _jsx(Text, { bold: true, children: "Location" }) })] }), visible.map((pkg, i) => { const absoluteIndex = start + i; const unchanged = areVersionsEqual(pkg); const isDiverging = checkDivergingVersions(pkg.name); return (_jsx(PackageRow, { pkg: pkg, isSelected: absoluteIndex === cursor, isDiverging: isDiverging, isVersionUnchanged: unchanged, hasHigherUpdates: hasHigherUpdates(pkg) }, `${pkg.packagePath}-${pkg.name}`)); }), packages.length > visibleCount && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: progressBar(cursor + 1, packages.length) }) }))] })); }