From 92bb6c4b41ce2600ef71f165e9dfacec738166ec Mon Sep 17 00:00:00 2001 From: Azeezat Raheem Date: Wed, 13 Sep 2023 18:30:20 -0700 Subject: [PATCH] feat: hide select all control (#46) --- README.md | 2 +- example/src/App.tsx | 5 ++--- src/index.tsx | 44 +++++++++++++++++++++------------------- src/types/index.types.ts | 1 + 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 4c4a8db..cd7ae02 100644 --- a/README.md +++ b/README.md @@ -274,7 +274,7 @@ For more examples visit our [wiki page](https://github.com/azeezat/react-native- | listComponentStyles | `Object` | `{listEmptyComponentStyle: ViewStyle, itemSeparatorStyle: ViewStyle, sectionHeaderStyle: TextStyle}` | | checkboxComponentStyles | `Object` | `{checkboxSize: number, checkboxStyle: ViewStyle, checkboxLabelStyle: TextStyle}` | | checkboxComponent | `React Component` | `` | -| listControls | `Object` | `{ selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, emptyListMessage: 'No record found'}` | +| listControls | `Object` | `{ selectAllText: 'Choose all', unselectAllText: 'Remove all', selectAllCallback: () => {}, unselectAllCallback: () => {}, hideSelectAll: boolean, emptyListMessage: 'No record found'}` | | searchControls | `Object` | `{ textInputStyle: ViewStyle \| TextStyle, textInputContainerStyle: ViewStyle, textInputProps: TextInputProps}` | ## Deprecation Notice diff --git a/example/src/App.tsx b/example/src/App.tsx index 54ac90e..4c7e4f5 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -155,8 +155,7 @@ export default function App() { checkboxLabelStyle: { color: 'green', fontSize: 20 }, }} listControls={{ - selectAllText: 'Select all that applies', - unselectAllText: 'Remove all', + hideSelectAll: true, }} /> @@ -278,7 +277,7 @@ export default function App() { }, }} listControls={{ - selectAllText: 'Choose everything', + selectAllText: 'Select all that applies', unselectAllText: 'Remove everything', selectAllCallback: () => Alert.alert('You selected everything'), unselectAllCallback: () => Alert.alert('You removed everything'), diff --git a/src/index.tsx b/src/index.tsx index 06638e8..18047e4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -368,27 +368,29 @@ export const DropdownSelect: React.FC = ({ /> )} {listHeaderComponent} - {isMultiple && modifiedOptions?.length > 1 && ( - - {}}> - handleSelectAll()} - primaryColor={primary} - checkboxSize={checkboxSize} - checkboxStyle={checkboxStyle} - checkboxLabelStyle={checkboxLabelStyle} - checkboxComponentStyles={checkboxComponentStyles} - checkboxComponent={checkboxComponent} - /> - - - )} + {!listControls?.hideSelectAll && + isMultiple && + modifiedOptions?.length > 1 && ( + + {}}> + handleSelectAll()} + primaryColor={primary} + checkboxSize={checkboxSize} + checkboxStyle={checkboxStyle} + checkboxLabelStyle={checkboxLabelStyle} + checkboxComponentStyles={checkboxComponentStyles} + checkboxComponent={checkboxComponent} + /> + + + )} } ListFooterComponent={listFooterComponent} diff --git a/src/types/index.types.ts b/src/types/index.types.ts index 7d6831e..a64022f 100644 --- a/src/types/index.types.ts +++ b/src/types/index.types.ts @@ -64,6 +64,7 @@ export type DropdownProps = { unselectAllText?: string; selectAllCallback?: () => void; unselectAllCallback?: () => void; + hideSelectAll?: boolean; emptyListMessage?: string; }; searchControls?: {