UNPKG

@prosperitainova/dumbo-react-native

Version:
87 lines 3.25 kB
import React from 'react'; import { ViewProps, StyleProp, ViewStyle } from 'react-native'; import { TextBreakModes, TextTypes } from '../Text'; import { CarbonIcon } from '../../types/shared'; /** An item to pass to the Dropdown component */ export type DropdownItem = { /** ID for tracking items */ id?: string; /** Text to render */ text: string; /** Break mode for text. Default is to wrap text */ textBreakMode?: TextBreakModes; /** Indicate if item is disabled */ disabled?: boolean; /** Text type to render (Standard is default. Normally only body 01 or 02 should be used) */ textType?: TextTypes; /** Set to an icon from Carbon (size 20). */ icon?: CarbonIcon; /** Color of the icon (default is primary text) */ iconColor?: string; /** Indicate that divider should be rendered (does not apply to last item) */ divider?: boolean; /** Indicate if keyboard should be dismissed onPress */ dismissKeyboardOnPress?: boolean; }; /** Props for Dropdown component */ export type DropdownProps = { /** Current value to show on dropdown */ value: string; /** Callback to convert value to human readable text */ valueToText?: (value: string) => string; /** Unset text. This should be like "Choose option" or similar based on context */ unsetText: string; /** Items to render in the dropdown */ items: DropdownItem[]; /** On change callback */ onChange: (item: DropdownItem) => void; /** Label string to use */ label?: string; /** Helper string to use */ helperText?: string; /** Indicate if disabled */ disabled?: boolean; /** Indicate if dropdown is used on layer */ light?: boolean; /** Text to use for on close areas (accessibility). Defaults to ENGLISH "Close" */ closeText?: string; /** Height in pixels to max out the menu (defaults to 280) */ maxMenuHeight?: number; /** Style to set on the item */ style?: StyleProp<ViewStyle>; /** Direct props to set on the React Native component (including iOS and Android specific props). Most use cases should not need this. */ componentProps?: ViewProps; }; /** * Dropdown component for rendering a dropdown * * {@link https://github.com/carbon-design-system/carbon-react-native/blob/main/example/src/Views/Dropdown.tsx | Example code} */ export declare class Dropdown extends React.Component<DropdownProps> { state: { open: boolean; renderLeft: number; renderRight: number; renderTop: number; renderBottom: number; inverseMenu: boolean; }; private get itemColor(); private get styles(); private get textInputStyles(); private get dropdownIcon(); private toggleDropdown; private closeDropdown; private getStateStyle; /** * Calculate where to render the overlayed dropdown menu * Sometimes didMount is not called before full render and results in all 0. setTimeout waits for load * * In event measure returns bad it will load to top of page with min width/height. * * @param item - View from reference */ private setFormItemRef; render(): React.ReactNode; } //# sourceMappingURL=index.d.ts.map