UNPKG

vanta-auditor-tui

Version:

Beautiful terminal UI for exporting Vanta audit evidence with ZIP support and progress tracking

75 lines 4.28 kB
import React from 'react'; import { Box, Text } from 'ink'; import { ProgressBar, Spinner } from '../lib/inkModules.js'; import figures from 'figures'; import { theme } from '../theme.js'; export function CustomProgressBar({ label, value, total, current, showPercentage = true, showSpinner = false, color = theme.colors.primary, width = 30 }) { const percentage = Math.min(100, Math.max(0, value)); return (React.createElement(Box, { flexDirection: "column" }, label && (React.createElement(Box, { marginBottom: 1 }, React.createElement(Text, { color: theme.colors.text }, label))), React.createElement(Box, null, showSpinner && percentage < 100 && (React.createElement(Box, { marginRight: 1 }, React.createElement(Spinner, { type: "dots" }))), percentage === 100 && (React.createElement(Box, { marginRight: 1 }, React.createElement(Text, { color: theme.colors.success }, figures.tick))), React.createElement(Box, { width: width }, React.createElement(ProgressBar, { percent: percentage / 100, left: `[`, right: `]`, character: "\u2588" })), React.createElement(Box, { marginLeft: 1 }, showPercentage && (React.createElement(Text, { color: color }, percentage.toFixed(0), "%")), current !== undefined && total !== undefined && (React.createElement(Text, { color: theme.colors.dim }, " (", current, "/", total, ")")))))); } export function MultiProgressBar({ overall, current, stats }) { return (React.createElement(Box, { flexDirection: "column", paddingY: 1 }, React.createElement(Box, { flexDirection: "column", marginBottom: 1 }, React.createElement(Text, { color: theme.colors.primary, bold: true }, "\uD83E\uDD99 ", overall.label), React.createElement(CustomProgressBar, { value: overall.value, current: overall.current, total: overall.total, showSpinner: true, width: 40 })), current && (React.createElement(Box, { flexDirection: "column", marginBottom: 1, paddingLeft: 2 }, React.createElement(Text, { color: theme.colors.primaryLight }, figures.arrowRight, " Current: ", current.fileName), React.createElement(Box, { paddingLeft: 2 }, React.createElement(CustomProgressBar, { value: current.value, width: 30, color: theme.colors.primaryLight, showSpinner: false }), (current.size || current.speed) && (React.createElement(Box, { marginLeft: 1 }, current.size && React.createElement(Text, { color: theme.colors.dim }, current.size), current.speed && React.createElement(Text, { color: theme.colors.dim }, " @ ", current.speed)))))), stats && (React.createElement(Box, { flexDirection: "column", paddingLeft: 2 }, React.createElement(Box, null, React.createElement(Text, { color: theme.colors.success }, figures.tick, " Completed: ", stats.completed), stats.failed > 0 && (React.createElement(Text, { color: theme.colors.error }, " ", figures.cross, " Failed: ", stats.failed)), stats.skipped > 0 && (React.createElement(Text, { color: theme.colors.warning }, " ", figures.arrowUp, " Skipped: ", stats.skipped))), React.createElement(Box, null, React.createElement(Text, { color: theme.colors.dim }, figures.ellipsis, " Remaining: ", stats.remaining, " files"), stats.totalSize && (React.createElement(Text, { color: theme.colors.dim }, " | Total: ", stats.totalSize))))))); } export default CustomProgressBar; //# sourceMappingURL=ProgressBar.js.map