UNPKG

faj-cli

Version:

FAJ - A powerful CLI resume builder with AI enhancement and multi-format export

187 lines 6.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.MenuHelper = void 0; exports.menuSeparator = menuSeparator; exports.menuItem = menuItem; const chalk_1 = __importDefault(require("chalk")); const inquirer_1 = __importDefault(require("inquirer")); class MenuHelper { static menuStack = []; /** * Push current menu to stack */ static pushMenu(menuName) { this.menuStack.push(menuName); } /** * Pop from menu stack */ static popMenu() { return this.menuStack.pop(); } /** * Get current menu depth */ static getDepth() { return this.menuStack.length; } /** * Clear menu stack */ static clearStack() { this.menuStack = []; } /** * Show breadcrumb navigation */ static showBreadcrumb() { if (this.menuStack.length > 0) { const breadcrumb = this.menuStack.join(' > '); console.log(chalk_1.default.gray(`\n 📍 ${breadcrumb}\n`)); } } /** * Show navigation hints based on menu level */ static showNavigationHints(isMainMenu = false) { if (isMainMenu) { console.log(chalk_1.default.gray('\n Navigation: ↑↓ Select | Enter Confirm | Ctrl+C Exit\n')); } else { console.log(chalk_1.default.gray('\n Navigation: ↑↓ Select | Enter Confirm | Select "← Back" to return\n')); } } /** * Format menu choices with consistent styling */ static formatChoices(choices, includeBack = true, backText = 'Back to Previous Menu') { const formatted = choices.map(choice => { if (choice.icon) { return { name: `${choice.icon} ${choice.name}`, value: choice.value }; } return { name: choice.name, value: choice.value }; }); if (includeBack) { formatted.push(new inquirer_1.default.Separator('──────────────')); formatted.push({ name: `← ${backText}`, value: 'back' }); } return formatted; } /** * Create a standard submenu */ static async showSubmenu(title, choices, options = {}) { const { parentMenu, includeBack = true, backText = 'Back', pageSize = 12 } = options; // Push to stack if parent menu specified if (parentMenu) { this.pushMenu(parentMenu); } // Show breadcrumb and hints this.showBreadcrumb(); this.showNavigationHints(false); const formattedChoices = this.formatChoices(choices, includeBack, backText); const { selection } = await inquirer_1.default.prompt([ { type: 'list', name: 'selection', message: title, choices: formattedChoices, loop: false, pageSize } ]); // Pop from stack if going back if (selection === 'back' && parentMenu) { this.popMenu(); } return selection; } /** * Quick action menu with shortcuts */ static async quickActionMenu(title, actions) { console.log(chalk_1.default.cyan(`\n${title}\n`)); // Show shortcuts console.log(chalk_1.default.gray(' Quick Actions:')); actions.forEach(action => { const icon = action.icon || ''; console.log(chalk_1.default.gray(` [${action.key}] ${icon} ${action.name}`)); }); console.log(); const choices = actions.map(a => ({ name: `[${a.key}] ${a.icon || ''} ${a.name}`, value: a.value, short: a.name })); choices.push(new inquirer_1.default.Separator('──────────────')); choices.push({ name: '← Cancel', value: 'cancel', short: 'Cancel' }); const { action } = await inquirer_1.default.prompt([ { type: 'list', name: 'action', message: 'Choose action:', choices, loop: false } ]); return action; } /** * Create a wizard-style navigation */ static createWizard(steps) { let currentStep = 0; return { current: () => currentStep, next: () => { if (currentStep < steps.length - 1) { currentStep++; return true; } return false; }, previous: () => { if (currentStep > 0) { currentStep--; return true; } return false; }, isFirst: () => currentStep === 0, isLast: () => currentStep === steps.length - 1, getStepName: () => steps[currentStep], showProgress: () => { const progress = `Step ${currentStep + 1} of ${steps.length}: ${steps[currentStep]}`; console.log(chalk_1.default.cyan(`\n${progress}`)); // Show progress bar const filled = '█'.repeat(currentStep + 1); const empty = '░'.repeat(steps.length - currentStep - 1); console.log(chalk_1.default.gray(` [${filled}${empty}]\n`)); } }; } } exports.MenuHelper = MenuHelper; /** * Helper function to create consistent menu separators */ function menuSeparator(text) { if (text) { return new inquirer_1.default.Separator(chalk_1.default.gray(`─── ${text} ───`)); } return new inquirer_1.default.Separator('──────────────'); } /** * Helper to create menu item with icon */ function menuItem(icon, name, value) { return { name: `${icon} ${name}`, value, short: name }; } //# sourceMappingURL=MenuHelper.js.map