From 6d106f01935ad318fab3cf80999f57664a3c8c0d Mon Sep 17 00:00:00 2001 From: Gregory <117281520+gca-axelor@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:07:45 +0100 Subject: [PATCH 1/5] feat: add clear all on ChipSelect --- .../organisms/ChipSelect/ChipSelect.tsx | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/organisms/ChipSelect/ChipSelect.tsx b/packages/ui/src/components/organisms/ChipSelect/ChipSelect.tsx index 6e4ae29bf..3675ec684 100644 --- a/packages/ui/src/components/organisms/ChipSelect/ChipSelect.tsx +++ b/packages/ui/src/components/organisms/ChipSelect/ChipSelect.tsx @@ -18,8 +18,8 @@ import React, {useEffect, useMemo, useState} from 'react'; import {Dimensions, StyleSheet, View, ScrollView} from 'react-native'; -import {Color} from '../../../theme/themes'; -import {Chip} from '../../molecules'; +import {Button, Chip} from '../../molecules'; +import {useThemeColor, Color} from '../../../theme'; const CHIP_CONTAINER_MARGIN = 16; const CHIP_MARGIN = 2; @@ -46,6 +46,7 @@ interface ChipSelectProps { readonly?: boolean; chipNumberOfLines?: number; onChangeValue?: (value: any) => void; + showClearButton?: boolean; } const ChipSelect = ({ @@ -58,7 +59,10 @@ const ChipSelect = ({ readonly = false, chipNumberOfLines, onChangeValue = () => {}, + showClearButton = false, }: ChipSelectProps) => { + const Colors = useThemeColor(); + const [selectedChip, setSelectedChip] = useState( selectionItems.filter(item => item.isActive === true), ); @@ -127,6 +131,11 @@ const ChipSelect = ({ ); }; + const clearAllChips = () => { + setSelectedChip([]); + onChangeValue([]); + }; + if ( selectionItems.length < 2 || (mode !== MODES.multi && mode !== MODES.switch) @@ -136,7 +145,24 @@ const ChipSelect = ({ return ( - + + {showClearButton && ( +