Skip to content

Commit

Permalink
Solve conflicts merging with master
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustoAleGon committed Jul 19, 2019
2 parents b46b777 + f77801c commit 84ba092
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ The component takes 3 compulsory props - `items`, `uniqueKey` and `onSelectedIte
| textInputProps | No | (Object) Properties for the Text Input. Pass any property that is required on the text input |
| uniqueKey | Yes | (String) Unique identifier that is part of each item's properties. Used internally as means of identifying each item (Check sample below) |
|selectedItems | No | (Array, control prop) List of selected items keys . JavaScript Array of strings, that can be instantiated with the component |
| removeSelected | No | (Boolean) Filter selected items from list to be shown in List |

## Note

Expand Down
56 changes: 56 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Type definitions for react-native-multiple-select 0.5

import * as React from "react";
import { ViewStyle, TextStyle, TextInputProps, StyleProp, FlatListProps } from 'react-native';

export interface MultiSelectProps {
single?: boolean;
selectedItems?: any[];
items: any[];
uniqueKey?: string,
tagBorderColor?: string;
tagTextColor?: string;
fontFamily?: string;
tagRemoveIconColor?: string;
onSelectedItemsChange: ((items: any[]) => void),
selectedItemFontFamily?: string;
selectedItemTextColor?: string;
itemFontFamily?: string;
itemTextColor?: string;
itemFontSize?: number;
selectedItemIconColor?: string;
searchIcon?: React.ReactNode;
searchInputPlaceholderText?: string;
searchInputStyle?: StyleProp<TextStyle>;
selectText?: string;
styleDropdownMenu?: StyleProp<ViewStyle>;
styleDropdownMenuSubsection?: StyleProp<ViewStyle>;
styleInputGroup?: StyleProp<ViewStyle>;
styleItemsContainer?: StyleProp<ViewStyle>;
styleListContainer?: StyleProp<ViewStyle>;
styleMainWrapper?: StyleProp<ViewStyle>;
styleRowList?: StyleProp<ViewStyle>;
styleSelectorContainer?: StyleProp<ViewStyle>;
styleTextDropdown?: StyleProp<TextStyle>;
styleTextDropdownSelected?: StyleProp<TextStyle>;
altFontFamily?: string;
hideSubmitButton?: boolean;
hideDropdown?: boolean;
submitButtonColor?: string;
submitButtonText?: string;
textColor?: string;
fontSize?: number;
fixedHeight?: boolean;
hideTags?: boolean,
canAddItems?: boolean;
onAddItem?: (newItems: any[]) => void;
onChangeInput?: (text: string) => void;
displayKey?: string;
textInputProps?: TextInputProps;
flatListProps?: FlatListProps<any>;
filterMethod?: string;
}

export default class MultiSelect extends React.Component<MultiSelectProps> {
getSelectedItemsExt: (items: any[]) => React.ReactNode;
}
18 changes: 14 additions & 4 deletions lib/react-native-multi-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ export default class MultiSelect extends Component {
flatListProps: PropTypes.object,
filterMethod: PropTypes.string,
onClearSelector: PropTypes.func,
onToggleList: PropTypes.func
onToggleList: PropTypes.func,
removeSelected: PropTypes.bool
};

static defaultProps = {
Expand Down Expand Up @@ -115,7 +116,8 @@ export default class MultiSelect extends Component {
canAddItems: false,
onAddItem: () => {},
onClearSelector: () => {},
onToggleList: () => {}
onToggleList: () => {},
removeSelected: false
};

constructor(props) {
Expand Down Expand Up @@ -473,7 +475,8 @@ export default class MultiSelect extends Component {
uniqueKey,
selectedItems,
flatListProps,
styleListContainer
styleListContainer,
removeSelected
} = this.props;
const { searchTerm } = this.state;
let component = null;
Expand All @@ -482,13 +485,20 @@ export default class MultiSelect extends Component {
let searchTermMatch;
let itemList;
let addItemRow;
const renderItems = searchTerm ? this._filterItems(searchTerm) : items;
let renderItems = searchTerm ? this._filterItems(searchTerm) : items;
// Filtering already selected items
if (removeSelected) {
renderItems = renderItems.filter(
item => !selectedItems.includes(item[uniqueKey])
);
}
if (renderItems.length) {
itemList = (
<FlatList
data={renderItems}
extraData={selectedItems}
keyExtractor={item => item[uniqueKey]}
listKey={item => item[uniqueKey]}
renderItem={rowData => this._getRow(rowData.item)}
{...flatListProps}
/>
Expand Down

0 comments on commit 84ba092

Please sign in to comment.