import React from 'react'; import { IcDelete, IcExpand } from '../res/icons'; import { useAlipayGestures } from '../hooks/useAlipayGestures'; interface AmountKeyboardProps { onInput: (key: string) => void; onDelete: () => void; confirmLabel: string; confirmEnabled?: boolean; onConfirm: () => void; actionPrefix?: string; open: boolean; onToggle: (open: boolean) => void; } /** * 支付宝风格金额输入键盘 — 模拟真实支付宝 App 内部自绘键盘。 * 4×4 网格:左 3 列数字区 + 右 1 列(删除 + 确认按钮)。 * 带 data-hide-on-keyboard,系统键盘弹出时自动隐藏。 * onMouseDown preventDefault 阻止点击按钮时抢夺金额输入框的焦点。 */ export const AmountKeyboard: React.FC = ({ onInput, onDelete, confirmLabel, confirmEnabled = true, onConfirm, actionPrefix = 'amountKeyboard', open, onToggle, }) => { const { bindTap } = useAlipayGestures(); const preventFocusSteal = (e: React.MouseEvent) => { e.preventDefault(); }; const numBtn = (digit: string, extraClassName = '') => ( ); if (!open) return null; return (
{numBtn('1')} {numBtn('2')} {numBtn('3')} {numBtn('4')} {numBtn('5')} {numBtn('6')} {numBtn('7')} {numBtn('8')} {numBtn('9')} {numBtn('0', 'col-span-2')} {numBtn('.')}
); };