react-native-form-model
Version:
An easily testable and opinionated React Native form model builder written in pure JavaScript.
47 lines (46 loc) • 1.68 kB
TypeScript
import { StyleProp, TextStyle, ViewProps } from 'react-native';
export interface PickerProps<T = any> extends ViewProps {
possibleValues: T[];
formatValue: (value: T | undefined, index: number) => string;
disabled?: boolean;
align?: 'left' | 'center' | 'right';
/**
* Selected index, correspoding to `possibleValues`.
*/
selectedIndex: number;
/**
* Callback for when an item is selected. This is called with the following parameters:
* - `value`: the value that was selected
* - `index`: the index of the selected value
*/
onValueChange?: (value: T, index: number) => void;
/**
* Specifies how to display the selection items when the user taps on the picker:
*
* - 'dropdown': Shows a dropdown anchored to the picker view. This is the default. Not supported in iOS.
* - 'dialog': Show a modal dialog.
*/
mode?: 'dialog' | 'dropdown';
/**
* Style to apply to each of the item labels.
* @platform ios
*/
itemStyle?: StyleProp<TextStyle>;
/**
* Prompt string for this picker, used in dialog mode as the title of the dialog.
*/
prompt?: string;
/**
* Used to locate this view in end-to-end tests.
*/
testID?: string;
/**
* Color of arrow for spinner dropdown in hexadecimal format
*/
dropdownIconColor?: string;
/**
* Color of the picker items.
*/
itemColor?: string;
}
export default function Picker<T = any>({ possibleValues, formatValue, selectedIndex, onValueChange, disabled, align, mode, prompt, style, itemStyle, itemColor, ...pickerProps }: PickerProps<T>): JSX.Element | null;