import React, { useState } from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'; import { Ux4gPanInputField, validatePan } from '../components/pan-input-field/PanInputField'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; /** * **PanInputFieldShowcase** * * Comprehensive demonstration of `Ux4gPanInputField`, showing live auto-uppercase enforcement, * Regex validation (`^[A-Z]{5}[0-9]{4}[A-Z]{1}$`), explicit validation statuses, and sizing options. */ export const PanInputFieldShowcase: React.FC = () => { const { colors, typography, isDark } = useUx4gTheme(); // Interactive state const [panValue, setPanValue] = useState(''); // Sizing variants state const [smallValue, setSmallValue] = useState('ABCDE1234F'); const [mediumValue, setMediumValue] = useState('ABCDE1234F'); const [largeValue, setLargeValue] = useState('ABCDE1234F'); const cardStyle = [ styles.card, { backgroundColor: colors.surface ?? (isDark ? '#18181B' : '#FFFFFF'), borderColor: isDark ? '#27272A' : '#E4E4E7', }, ]; const titleStyle = [styles.cardTitle, { color: colors.onSurface }]; const subtitleStyle = [ styles.cardSubtitle, { color: isDark ? '#A1A1AA' : '#71717A' }, ]; // Quick fill samples for Section 1 const handleSetValidSample = () => { setPanValue('ABCDE1234F'); }; const handleSetInvalidSample = () => { setPanValue('ABC1234DEF'); // Fails Regex (wrong letter/digit order) }; const isCurrentValid = validatePan(panValue); return ( 💳 PAN Input Field (`Ux4gPanInputField`) Specialized 10-character PAN field with auto-uppercase enforcement, alphanumeric filtering, and standard Regex validation (`validatePan`). {/* ── SECTION 1: Interactive Live Checksum & Auto-Formatting ────────── */} 1. Interactive Live Regex Checksum & Formatting Type any 10 characters or click the quick fill buttons below. When 10 characters are reached, it automatically checks against the Regex `{'^[A-Z]{5}[0-9]{4}[A-Z]{1}$'}`. ✓ Fill Valid PAN (ABCDE...) ✕ Fill Invalid PAN (ABC12...) Current Value: {panValue || '(empty)'} Regex Validation Result: {isCurrentValid ? '✓ VALID' : panValue.length === 10 ? '✕ INVALID PAN FORMAT' : '(Enter 10 alphanumeric characters)'} {/* ── SECTION 2: All Validation States (`status` prop) ──────────────── */} 2. All Validation Status States (`status` prop) Illustrating explicit validation statuses (`defaultStatus`, `success`, `error`, `warning`). {}} status="defaultStatus" /> {}} status="success" caption="Valid PAN number verified by central database" /> {}} status="error" caption="Invalid PAN: Expected 5 letters, 4 digits, 1 letter" /> {}} status="warning" caption="PAN is inactive or not linked with Aadhaar" /> {/* ── SECTION 3: All Sizing Variants (`size` prop) ──────────────────── */} 3. All Sizing Variants (`size` prop) Supporting exact heights: `small` (`32px`), `medium` (`40px`), and `large` (`48px`). {/* ── SECTION 4: Read-Only & Disabled States ─────────────────────────── */} 4. Read-Only & Disabled States Locked non-editable states (`readOnly = true` and `enabled = false`). {}} readOnly={true} status="success" caption="Input locked: value is selectable/copyable but cannot be modified" /> {}} enabled={false} caption="Input disabled: opacities dimmed to 0.38 (`disabledTitleColor`)" /> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 64, }, header: { marginBottom: 20, }, title: { fontSize: 22, fontWeight: '800', marginBottom: 6, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, marginBottom: 20, }, cardTitle: { fontSize: 16, fontWeight: '700', marginBottom: 4, }, cardSubtitle: { fontSize: 13, marginBottom: 16, lineHeight: 18, }, quickFillContainer: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginBottom: 16, }, sampleButton: { paddingHorizontal: 12, paddingVertical: 8, borderRadius: 6, }, sampleButtonText: { color: '#FFFFFF', fontSize: 12, fontWeight: '700', }, statusBanner: { marginTop: 14, padding: 12, borderRadius: 8, }, sectionRow: { marginBottom: 16, }, });