UNPKG

emv

Version:

EMV / Chip and PIN CLI and library for PC/SC card readers

34 lines 2.28 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Box, Text, useInput } from 'ink'; import SelectInput from 'ink-select-input'; import { Header, Footer, CardBox, StatusBar, LoadingSpinner } from '../components/index.js'; export function AppsScreen({ apps, readerName, atr, onSelect, onBack, loading, }) { useInput((_input, key) => { if (key.escape) { onBack(); } }); if (loading) { return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, {}), _jsx(LoadingSpinner, { message: "Reading card applications..." })] })); } if (apps.length === 0) { return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, {}), _jsxs(CardBox, { title: "Card Information", children: [_jsxs(Text, { color: "gray", children: ["Reader: ", readerName] }), _jsxs(Text, { color: "gray", children: ["ATR: ", atr] })] }), _jsx(StatusBar, { message: "No applications found on this card.", type: "warning" }), _jsx(Footer, { hints: [ { keys: 'Esc', description: 'Back' }, { keys: 'q', description: 'Quit' }, ] })] })); } const items = apps.map((app) => ({ key: app.aid, label: `${app.label ?? 'Unknown'} (${app.aid})`, value: app, })); return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Header, {}), _jsxs(CardBox, { title: "Card Information", children: [_jsxs(Text, { color: "gray", children: ["Reader: ", readerName] }), _jsxs(Text, { color: "gray", children: ["ATR: ", atr] })] }), _jsx(CardBox, { title: "Select an Application", children: _jsx(SelectInput, { items: items, onSelect: (item) => { onSelect(item.value); }, itemComponent: ({ isSelected, label }) => isSelected ? (_jsxs(Text, { color: "cyan", bold: true, children: ['▸ ', label] })) : (_jsxs(Text, { children: [' ', label] })) }) }), _jsx(Footer, { hints: [ { keys: '↑↓', description: 'Navigate' }, { keys: 'Enter', description: 'Select' }, { keys: 'Esc', description: 'Back' }, { keys: 'q', description: 'Quit' }, ] })] })); } //# sourceMappingURL=AppsScreen.js.map