UNPKG

alnilam-cli

Version:

Git-native AI career coach that converts multi-year ambitions into weekly execution

57 lines (56 loc) 4.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataState = exports.ProgressIndicator = exports.SkeletonLoader = exports.LoadingState = exports.Loading = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const ink_1 = require("ink"); const ui_1 = require("@inkjs/ui"); // Basic loading spinner with customizable message const Loading = ({ message = 'Loading...', type = 'dots', color = 'blue' }) => { return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", gap: 1, children: [(0, jsx_runtime_1.jsx)(ui_1.Spinner, { type: type }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: color, children: message })] })); }; exports.Loading = Loading; // Loading state wrapper that shows/hides content based on loading state const LoadingState = ({ loading, children, message, error }) => { if (error) { return ((0, jsx_runtime_1.jsx)(ink_1.Box, { flexDirection: "column", children: (0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "red", children: ["\u274C Error: ", error] }) })); } if (loading) { return (0, jsx_runtime_1.jsx)(exports.Loading, { message: message }); } return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }); }; exports.LoadingState = LoadingState; // Skeleton loader for dashboard components const SkeletonLoader = ({ lines = 3, width = 40 }) => { return ((0, jsx_runtime_1.jsx)(ink_1.Box, { flexDirection: "column", children: Array.from({ length: lines }, (_, i) => ((0, jsx_runtime_1.jsx)(ink_1.Box, { marginBottom: 1, children: (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", dimColor: true, children: '▓'.repeat(Math.min(width, 20 + Math.random() * 20)) }) }, i))) })); }; exports.SkeletonLoader = SkeletonLoader; // Progress indicator for long-running operations const ProgressIndicator = ({ current, total, message }) => { const percentage = Math.round((current / total) * 100); const barLength = 30; const filled = Math.round((current / total) * barLength); return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", children: [message && ((0, jsx_runtime_1.jsx)(ink_1.Text, { color: "blue", children: message })), (0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "row", gap: 1, children: [(0, jsx_runtime_1.jsx)(ink_1.Text, { children: "[" }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "green", children: '█'.repeat(filled) }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", children: '░'.repeat(barLength - filled) }), (0, jsx_runtime_1.jsx)(ink_1.Text, { children: "]" }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "blue", children: [percentage, "%"] })] }), (0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "gray", dimColor: true, children: [current, " of ", total, " completed"] })] })); }; exports.ProgressIndicator = ProgressIndicator; // Data fetching states for API calls const DataState = ({ loading, error, empty = false, emptyMessage = 'No data available', children }) => { if (loading) { return (0, jsx_runtime_1.jsx)(exports.SkeletonLoader, {}); } if (error) { return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "red", children: ["\uD83D\uDCA5 ", error] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", dimColor: true, children: "Please try again or check your connection" })] })); } if (empty) { return ((0, jsx_runtime_1.jsxs)(ink_1.Box, { flexDirection: "column", alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsxs)(ink_1.Text, { color: "yellow", children: ["\uD83D\uDCED ", emptyMessage] }), (0, jsx_runtime_1.jsx)(ink_1.Text, { color: "gray", dimColor: true, children: "Start by adding some goals or evidence" })] })); } return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }); }; exports.DataState = DataState; exports.default = { Loading: exports.Loading, LoadingState: exports.LoadingState, SkeletonLoader: exports.SkeletonLoader, ProgressIndicator: exports.ProgressIndicator, DataState: exports.DataState };