import React, { useState } from 'react'; import { View, Pressable, ViewStyle, TextStyle } from 'react-native'; import Cascade, { valueType, OptionProps } from '../cascade'; import Popup from '../popup'; import FormValue from '../form-value'; import styles from './style'; const prefixCls = 'cascade-popup'; export interface CascadePopupProps { name?: string; value?: any[]; children?: React.ReactNode; disabled?: boolean; placeholder?: string; options?: any[]; textAlign?: 'left' | 'right'; prompt?: (e: any) => string; onChange: (v: any, s: any) => void; valueStyle?: ViewStyle | TextStyle; placeholderStyle?: ViewStyle | TextStyle; [restProps: string]: any; } const CascadePopup: React.FC = props => { const { value, children, disabled, placeholder, textAlign, onChange, valueStyle, placeholderStyle, } = props; const [show, setShow] = useState(false); const handleTap = () => { if (disabled) { return; } setShow(true); }; const handleClose = () => { setShow(false); }; const handleChange = (v: valueType[], s?: OptionProps[], isLast?: boolean) => { onChange(v, s); if (isLast) { setShow(false); } }; const cascadeValue = value?.map(i => i.value) || []; return ( {children || value?.map(i => i.text).join(' ')} ); }; export default CascadePopup;