|
@@ -59,6 +59,7 @@ function SelectBox<T>({
|
|
|
renderLoadingIcon : LoadingIconComponentProp,
|
|
renderLoadingIcon : LoadingIconComponentProp,
|
|
|
rightIcon: RightIconComponentProp,
|
|
rightIcon: RightIconComponentProp,
|
|
|
hintTextIcon: HintTextIconProp,
|
|
hintTextIcon: HintTextIconProp,
|
|
|
|
|
+ isShowSelectSheetTools = true,
|
|
|
spreadBehaviour = "baseline",
|
|
spreadBehaviour = "baseline",
|
|
|
isShowHintTextIcon = false,
|
|
isShowHintTextIcon = false,
|
|
|
customSelectSheetLocalize,
|
|
customSelectSheetLocalize,
|
|
@@ -89,6 +90,7 @@ function SelectBox<T>({
|
|
|
isShowSubTitle,
|
|
isShowSubTitle,
|
|
|
cleanIconStyle,
|
|
cleanIconStyle,
|
|
|
titleExtractor,
|
|
titleExtractor,
|
|
|
|
|
+ maxChoice = -1,
|
|
|
keyExtractor,
|
|
keyExtractor,
|
|
|
contentStyle,
|
|
contentStyle,
|
|
|
customTheme,
|
|
customTheme,
|
|
@@ -97,7 +99,6 @@ function SelectBox<T>({
|
|
|
isOptional,
|
|
isOptional,
|
|
|
renderItem,
|
|
renderItem,
|
|
|
customKey,
|
|
customKey,
|
|
|
- maxChoice,
|
|
|
|
|
minChoice,
|
|
minChoice,
|
|
|
iconStyle,
|
|
iconStyle,
|
|
|
onChange,
|
|
onChange,
|
|
@@ -425,10 +426,6 @@ function SelectBox<T>({
|
|
|
let isProcessPerm = false;
|
|
let isProcessPerm = false;
|
|
|
|
|
|
|
|
if(isMultipleSelect) {
|
|
if(isMultipleSelect) {
|
|
|
- if(!maxChoice) {
|
|
|
|
|
- throw new Error("If you want to use the \"isMultipleSelect\" prop, you must be provide \"maxChoice\" prop.");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
if(_selectedItems.length < maxChoice || maxChoice === -1) {
|
|
if(_selectedItems.length < maxChoice || maxChoice === -1) {
|
|
|
isProcessPerm = true;
|
|
isProcessPerm = true;
|
|
|
} else {
|
|
} else {
|
|
@@ -463,6 +460,54 @@ function SelectBox<T>({
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const cleanAll = () => {
|
|
|
|
|
+ if(minChoice) {
|
|
|
|
|
+ console.error("minChoice must be 0 or undefined for cleanAll function.");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isWorkWithRealtime) {
|
|
|
|
|
+ setSelectedItems([]);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setTempSelectedItems([]);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const selectAll = () => {
|
|
|
|
|
+ if(maxChoice !== -1) {
|
|
|
|
|
+ console.error("maxChoice must be -1 for selectAll function.");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const _selectedItems = JSON.parse(JSON.stringify(mainSelectedItems));
|
|
|
|
|
+
|
|
|
|
|
+ if(searchText && searchText.length) {
|
|
|
|
|
+ searchedData.forEach(searchedItem => {
|
|
|
|
|
+ if(mainSelectedItems.findIndex(sI => sI.__key === searchedItem.__key) === -1) {
|
|
|
|
|
+ _selectedItems.push({
|
|
|
|
|
+ __title: searchedItem.__title,
|
|
|
|
|
+ __key: searchedItem.__key
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ data.forEach(dataItem => {
|
|
|
|
|
+ if(mainSelectedItems.findIndex(sI => sI.__key === dataItem.__key) === -1) {
|
|
|
|
|
+ _selectedItems.push({
|
|
|
|
|
+ __title: dataItem.__title,
|
|
|
|
|
+ __key: dataItem.__key
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(isWorkWithRealtime) {
|
|
|
|
|
+ setSelectedItems(_selectedItems);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setTempSelectedItems(_selectedItems);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
const onFocus = () => {
|
|
const onFocus = () => {
|
|
|
if(onFocusProp) onFocusProp();
|
|
if(onFocusProp) onFocusProp();
|
|
|
};
|
|
};
|
|
@@ -754,6 +799,7 @@ function SelectBox<T>({
|
|
|
customLocalize={customSelectSheetLocalize}
|
|
customLocalize={customSelectSheetLocalize}
|
|
|
isWorkWithRealtime={isWorkWithRealtime}
|
|
isWorkWithRealtime={isWorkWithRealtime}
|
|
|
mainSelectedItems={mainSelectedItems}
|
|
mainSelectedItems={mainSelectedItems}
|
|
|
|
|
+ isShowTools={isShowSelectSheetTools}
|
|
|
customTheme={customSelectSheetTheme}
|
|
customTheme={customSelectSheetTheme}
|
|
|
isMultipleSelect={isMultipleSelect}
|
|
isMultipleSelect={isMultipleSelect}
|
|
|
renderOptionIcon={renderOptionIcon}
|
|
renderOptionIcon={renderOptionIcon}
|
|
@@ -769,7 +815,10 @@ function SelectBox<T>({
|
|
|
searchText={searchText}
|
|
searchText={searchText}
|
|
|
renderItem={renderItem}
|
|
renderItem={renderItem}
|
|
|
maxChoice={maxChoice}
|
|
maxChoice={maxChoice}
|
|
|
|
|
+ minChoice={minChoice}
|
|
|
isLoading={isLoading}
|
|
isLoading={isLoading}
|
|
|
|
|
+ selectAll={selectAll}
|
|
|
|
|
+ cleanAll={cleanAll}
|
|
|
isActive={isActive}
|
|
isActive={isActive}
|
|
|
cancel={cancel}
|
|
cancel={cancel}
|
|
|
title={title}
|
|
title={title}
|