Skip to content

Commit

Permalink
Merge branch 'main' into fix/reset-option-on-search-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kofiarkoh committed Dec 2, 2024
2 parents 6ad889d + 5ad0b8c commit 41661fc
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 30 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: ['push', 'pull_request']

name: Test Coveralls

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 20.x

- name: npm install, make test-coverage
run: |
npm install
make test-coverage
- name: Coveralls
uses: coverallsapp/github-action@v2
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v2.0.0](https://github.com/azeezat/react-native-select/compare/v1.3.18...v2.0.0)
#### [v2.1.0](https://github.com/azeezat/react-native-select/compare/v2.0.0...v2.1.0)

- Fix: Handle zero and boolean values properly in options array [`#92`](https://github.com/azeezat/react-native-select/pull/92)
- fix: enforce label to a string, so we avoid the issue of a label being numerical 0 [`#91`](https://github.com/azeezat/react-native-select/pull/91)
- chore: removed deprecated props [`#89`](https://github.com/azeezat/react-native-select/pull/89)
- option type fixes [`927ab7b`](https://github.com/azeezat/react-native-select/commit/927ab7b0a4475a70132d768bd2e8338aa9be1f51)
- fix: type fixes [`a24ddac`](https://github.com/azeezat/react-native-select/commit/a24ddacd0b71febd0889a675c0492888fcdcd0cb)
- additional fix for single selection [`6e109fb`](https://github.com/azeezat/react-native-select/commit/6e109fbe3fa3bb1869c443efd9f58e5bd9697109)

### [v2.0.0](https://github.com/azeezat/react-native-select/compare/v1.3.18...v2.0.0)

> 4 October 2024
- chore: refactored code to use custom hooks [`#86`](https://github.com/azeezat/react-native-select/pull/86)
- chore: release v2.0.0 [`f142ce6`](https://github.com/azeezat/react-native-select/commit/f142ce602fac1b9e3845a32d81df745b6122c91e)

#### [v1.3.18](https://github.com/azeezat/react-native-select/compare/v1.3.17...v1.3.18)

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the

Made with [contrib.rocks](https://contrib.rocks).

## Discussion

For discussion and feedback on this library. You can access it by heading over to the [Discussions Tab on Github](https://github.com/azeezat/react-native-select/discussions). We've created some sections to keep the discussion focused.

| Title | Topic |
| ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| [Announcements 📣](https://github.com/azeezat/react-native-select/discussions/categories/announcements) | General announcements about this library. |
| [Show and tell 🙌](https://github.com/azeezat/react-native-select/discussions/categories/show-and-tell) | Show off something you've made out of this library |
| [Ideas 💡](https://github.com/azeezat/react-native-select/discussions/categories/ideas) | A place to Share ideas for new features. |
| [Polls 🗳️](https://github.com/azeezat/react-native-select/discussions/categories/polls) | Take a vote from the community |
| [Q&A 🤝](https://github.com/azeezat/react-native-select/discussions/categories/q-a) | A place to ask the community for help on the New Architecture topics |
| [General 💬](https://github.com/azeezat/react-native-select/discussions/categories/general) | Chat about anything and everything here |

## License

MIT
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ currently being supported with security updates.

| Version | Supported |
| ---------- | ------------------ |
| 0.22.x | :white_check_mark: |
| < 0.20.x | :x: |
| 2.1.x | :white_check_mark: |
| < 2.1.x | :x: |

## Reporting a Vulnerability

Expand Down
16 changes: 7 additions & 9 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ import {DropdownSelectHandle} from '../../src/types/index.types';
export default function App() {
const [user, setUser] = useState<string>('');
const [country, setCountry] = useState<any>('');
const [gender, setGender] = useState<number>(0);
const [gender, setGender] = useState<number>();
const [currency, setCurrency] = useState<string[]>([]);
const [meals, setMeals] = useState<string[]>([]);
const [item, setItem] = useState<any>('');
const [menu, setMenu] = useState<string[]>([]);
const [searchTerm, setSearchTerm] = useState<string>('');

const [ingredients, setIngredients] = useState<string[]>([]);
const [ingredientOptions, setIngredientOptions] = useState<any[]>([
{label: 'Pepper', value: '1'},
{label: 'Oil', value: '2'},
{label: 'Fish', value: '3', disabled: true},
{label: 0, value: 0},
{label: 1, value: false},
{label: 2, value: 2, disabled: true},
]);

useEffect(() => {
setCurrency(['NGN']);
setMenu(['F']);
Expand Down Expand Up @@ -90,7 +88,7 @@ export default function App() {
<Text>Male</Text>
</View>
),
id: 1,
id: 0,
},
{
name: (
Expand All @@ -105,7 +103,7 @@ export default function App() {
<Text>Female</Text>
</View>
),
id: 2,
id: 1,
},
]}
optionLabel={'name'}
Expand All @@ -118,7 +116,7 @@ export default function App() {
borderStyle: 'solid',
}}
dropdownErrorTextStyle={{color: 'red', fontWeight: '500'}}
error={gender ? '' : 'Gender is required'}
error={gender === undefined ? 'Gender is required' : ''}
modalControls={{
modalProps: {
onShow: () => logMovies(),
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-input-select",
"version": "2.0.0",
"version": "2.1.0",
"description": "A customizable dropdown selection package for react-native for android and iOS with multiple select and search capabilities.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -43,7 +43,12 @@
"android",
"dropdown",
"selection",
"multiple select"
"dropdown menu",
"multiple select",
"picker",
"pull-down menu",
"combo box",
"list box"
],
"repository": "https://github.com/azeezat/react-native-select",
"author": "Azeezat <azeezat94@gmail.com> (https://github.com/azeezat)",
Expand Down
1 change: 0 additions & 1 deletion pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

18 changes: 9 additions & 9 deletions src/__tests__/section-list-dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@ describe('Section list', () => {
{
title: 'Main dishes',
data: [
{ label: 'Pizza', value: 'A' },
{ label: 'Burger', value: 'B' },
{ label: 'Risotto', value: 'C' },
{ label: 'Pizza', value: 0 },
{ label: 'Burger', value: 1 },
{ label: 'Risotto', value: 2 },
],
},
{
title: 'Sides',
data: [
{ label: 'Ice cream', value: 'D' },
{ label: 'Cheesecake', value: 'E' },
{ label: 'Ice cream', value: 3 },
{ label: 'Cheesecake', value: 4 },
],
},
{
title: 'Drinks',
data: [
{ label: 'Water', value: 'F', disabled: true },
{ label: 'Coke', value: 'G' },
{ label: 'Juice', value: 'H' },
{ label: 'Water', value: 5, disabled: true },
{ label: 'Coke', value: 6 },
{ label: 'Juice', value: 7 },
],
},
];
Expand Down Expand Up @@ -175,7 +175,7 @@ describe('Section list', () => {
// if there is a disabled item in the list, expect no call
options.map(async (section) => {
section.data.map(async (item) => {
const listItem = screen.getByText(item.label.toString());
const listItem = screen.getByText(item?.label as string);
expect(listItem);
await user.press(listItem);
if (!item.disabled) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/CheckBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const CheckBox = ({
? checkboxDisabledStyle?.borderColor || colors.disabled
: checkboxStyle?.borderColor || styles.checkbox.borderColor,
};

label = typeof label === 'object' ? label : String(label);
return (
<Pressable
onPress={onChange ? () => onChange(!value) : null}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/DropdownSelectedItemsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const DropdownSelectedItemsView = ({
disabled={disabled}
/>
)}
{!selectedItem && selectedItems?.length === 0 && (
{selectedItem === '' && selectedItems?.length === 0 && (
<DropdownContent
onPress={() => openModal()}
style={[styles.blackText, placeholderStyle]}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ export const useSearch = ({
(flatList: TFlatList, regexFilter: RegExp) => {
return flatList.filter((item: TFlatListItem) => {
return (
item[optionLabel].toString().toLowerCase().search(regexFilter) !==
item[optionLabel]?.toString().toLowerCase().search(regexFilter) !==
-1 ||
item[optionValue].toString().toLowerCase().search(regexFilter) !== -1
item[optionValue]?.toString().toLowerCase().search(regexFilter) !== -1
);
});
},
Expand Down
2 changes: 1 addition & 1 deletion src/types/index.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ type TListControls = {
emptyListMessage?: string;
};

export type TSelectedItem = string | number | boolean;
export type TSelectedItem = string | number | boolean | undefined;
export type TSelectedItemWithReactComponent =
| TSelectedItem
| React.ReactElement;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const getLabelsOfSelectedItems = ({
(item: TFlatListItem) => item[optionValue] === element
)?.[optionLabel];

if (selectedItemLabel) {
if (selectedItemLabel !== '') {
selectedLabels.push(selectedItemLabel);
}
});
Expand Down

0 comments on commit 41661fc

Please sign in to comment.