Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function App() {
const [searchTerm, setSearchTerm] = useState<string>('');
const [ingredients, setIngredients] = useState<string[]>([]);
const [ingredientOptions, setIngredientOptions] = useState<any[]>([
{ label: 0, value: 0 },
{ label: 1, value: false },
{ label: 0, value: 0, disabled: true },
{ label: 1, value: false, disabled: true },
{ label: 2, value: 2, disabled: true },
]);
useEffect(() => {
Expand Down Expand Up @@ -190,9 +190,9 @@ export default function App() {
label="Meal preferences"
placeholder="Select your meal preferences"
options={[
{ name: '🍛 Rice', value: '1', disabled: false },
{ name: '🍛 Rice', value: '1' },
{ name: '🍗 Chicken', value: '2' },
{ name: '🥦 Brocoli', value: '3', disabled: false },
{ name: '🥦 Brocoli', value: '3' },
{ name: '🍕 Pizza', value: '4' },
]}
maxSelectableItems={2}
Expand Down
31 changes: 19 additions & 12 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import type {
DropdownSelectHandle,
TSelectedItem,
} from './types/index.types';
import { extractPropertyFromArray, getSelectionsData } from './utils';
import {
extractPropertyFromArray,
getSelectionsData,
removeDisabledItems,
} from './utils';
import {
useSelectionHandler,
useModal,
Expand Down Expand Up @@ -259,17 +263,20 @@ export const DropdownSelect = forwardRef<DropdownSelectHandle, DropdownProps>(
modifiedOptions?.length > 1 && (
<View style={styles.optionsContainerStyle}>
<TouchableOpacity accessible={false}>
<CheckBox
value={selectAll}
label={
selectAll
? listControls?.unselectAllText || 'Clear all'
: listControls?.selectAllText || 'Select all'
}
onChange={() => handleSelectAll()}
primaryColor={primaryColor}
checkboxControls={checkboxControls}
/>
{/* only show this if all the items in the list are not disabled */}
{removeDisabledItems(modifiedOptions)?.length !== 0 && (
<CheckBox
value={selectAll}
label={
selectAll
? listControls?.unselectAllText || 'Clear all'
: listControls?.selectAllText || 'Select all'
}
onChange={() => handleSelectAll()}
primaryColor={primaryColor}
checkboxControls={checkboxControls}
/>
)}
</TouchableOpacity>
</View>
)}
Expand Down
Loading