atlas-design-system 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7,7 +7,7 @@ export type SelectInputProps<T> = {
|
|
|
7
7
|
options: Option<T>[];
|
|
8
8
|
onChange: (newValue: Option<T>) => void;
|
|
9
9
|
error?: string;
|
|
10
|
-
renderOption?: (option: Option<T>) => React.ReactNode;
|
|
10
|
+
renderOption?: (option: Option<T>, onPress: (option: Option<T>) => void) => React.ReactNode;
|
|
11
11
|
containerStyle?: StyleProp<ViewStyle>;
|
|
12
12
|
};
|
|
13
13
|
export declare function SelectInput<T>({ caption, label, options, onChange, error, renderOption, containerStyle, }: SelectInputProps<T>): React.JSX.Element;
|
|
@@ -83,10 +83,10 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
|
|
|
83
83
|
],
|
|
84
84
|
};
|
|
85
85
|
}, [rotation]);
|
|
86
|
-
const handleOptionPress = (option) => {
|
|
86
|
+
const handleOptionPress = (0, react_1.useCallback)((option) => {
|
|
87
87
|
onChange(option);
|
|
88
88
|
setSheetOpen(false);
|
|
89
|
-
};
|
|
89
|
+
}, []);
|
|
90
90
|
return (<react_native_1.View style={containerStyle}>
|
|
91
91
|
<react_native_1.TouchableOpacity onPress={() => setSheetOpen(true)}>
|
|
92
92
|
<react_native_reanimated_1.default.View style={[styles.itemContainer, animatedBorderStyle]}>
|
|
@@ -107,9 +107,9 @@ function SelectInput({ caption, label, options = [], onChange, error, renderOpti
|
|
|
107
107
|
</react_native_1.TouchableOpacity>
|
|
108
108
|
{!!caption && <MenuItemDescription_1.MenuItemDescription description={caption}/>}
|
|
109
109
|
<Sheet_1.default open={sheetOpen} setOpen={setSheetOpen} header={label}>
|
|
110
|
-
{options.map((option, i) => (<react_native_1.TouchableOpacity onPress={() => handleOptionPress(option)} key={i + option.label}>
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
{options.map((option, i) => renderOption ? (renderOption(option, handleOptionPress)) : (<react_native_1.TouchableOpacity onPress={() => handleOptionPress(option)} key={i + option.label}>
|
|
111
|
+
<SelectionItem_1.default option={option}/>
|
|
112
|
+
</react_native_1.TouchableOpacity>))}
|
|
113
113
|
</Sheet_1.default>
|
|
114
114
|
</react_native_1.View>);
|
|
115
115
|
}
|