@devrue/rn-select
Version:
Custom typescript only select component for react native
86 lines • 3.18 kB
TypeScript
import React, { type ComponentType, type ReactNode } from 'react';
import { type OptionColors } from './SelectRow';
import type { IconStyle, LayoutRect, Option } from '../types';
import type { TextStyle, ViewStyle } from 'react-native';
interface RenderAnchorProps {
launch: () => void;
remove: (key: string) => void;
clear: () => void;
setRect: (pos: LayoutRect) => void;
}
interface RenderAnchor {
(props: RenderAnchorProps): JSX.Element;
}
interface RenderSearchProps {
search: string;
onChangeSearch: (val: string) => void;
dismiss: () => void;
}
interface RenderSearch {
(props: RenderSearchProps): JSX.Element;
}
interface RenderOptionProps {
optionKey: string;
optionValue: string;
isChecked: boolean;
onPress: () => void;
}
interface RenderOption {
(props: RenderOptionProps): JSX.Element;
}
export interface CommonProps {
placeholder?: string;
listTitle?: string;
searchPlaceholder?: string;
searchPlaceholderTextColor?: string;
showSelectionCount?: boolean;
options: Option[];
reverse?: boolean;
selectionEffectColor?: string;
optionsScrollIndicator?: boolean;
emptyOptionsPlaceholder?: string;
emptySearchMsg?: ReactNode;
value?: string | string[];
clearable?: boolean;
disabled?: boolean;
searchable?: boolean;
createable?: boolean | ((trigger: () => void) => React.ReactElement);
avoidBottom?: 'height' | 'position';
onCreateItem?: (value: string) => void;
onChangeInput?: (value: string) => void;
renderAnchor?: RenderAnchor;
renderSearch?: RenderSearch;
renderOption?: RenderOption;
optionDivider?: ComponentType;
selectStyle?: ViewStyle;
selectPlaceholderTextStyle?: TextStyle;
selectTextStyle?: TextStyle;
selectPillTextStyle?: TextStyle;
selectPillRemoveContainerStyle?: ViewStyle;
selectPillRemoveIconStyle?: IconStyle;
selectIconStyle?: IconStyle;
searchContainerStyle?: ViewStyle;
searchInputStyle?: TextStyle;
searchBackIconStyle?: IconStyle;
searchClearIconStyle?: IconStyle;
statsTextStyle?: TextStyle;
optionListContainerStyle?: ViewStyle;
optionListStyle?: ViewStyle;
optionContainerStyle?: ViewStyle;
optionTextStyle?: TextStyle;
optionCheckColors?: OptionColors;
emptyTextStyle?: TextStyle;
}
export interface SingleSelectProps extends CommonProps {
value?: string;
onChangeValue?: (value: string) => void;
}
export interface MultiSelectProps extends CommonProps {
multi: true;
value?: string[];
onChangeValue?: (value: string[]) => void;
}
export type Props = SingleSelectProps | MultiSelectProps;
export default function Select({ options, value, onChangeInput, onCreateItem, placeholder, searchPlaceholder, searchPlaceholderTextColor, listTitle, showSelectionCount, reverse, selectionEffectColor, optionsScrollIndicator, emptyOptionsPlaceholder, emptySearchMsg, clearable, disabled, searchable, createable, avoidBottom, renderAnchor, renderSearch, renderOption, optionDivider, statsTextStyle, optionCheckColors, emptyTextStyle, ...rest }: Props): JSX.Element;
export {};
//# sourceMappingURL=Select.d.ts.map