atlas-design-system 1.8.0 → 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.
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
3
|
export type NavigationListRowProps = {
|
|
3
4
|
label: string;
|
|
4
5
|
caption?: string;
|
|
5
6
|
onPress?: () => void;
|
|
6
7
|
disabled?: boolean;
|
|
8
|
+
defaultPadding?: boolean;
|
|
9
|
+
containerStyle?: StyleProp<ViewStyle>;
|
|
7
10
|
};
|
|
8
|
-
export declare const NavigationListRow: ({ label, caption, onPress, disabled, }: NavigationListRowProps) => React.JSX.Element;
|
|
11
|
+
export declare const NavigationListRow: ({ label, caption, onPress, disabled, defaultPadding, containerStyle, }: NavigationListRowProps) => React.JSX.Element;
|
|
9
12
|
export default NavigationListRow;
|
|
@@ -32,9 +32,9 @@ const react_native_1 = require("react-native");
|
|
|
32
32
|
const Ionicons_1 = __importDefault(require("react-native-vector-icons/Ionicons"));
|
|
33
33
|
const Text_1 = __importDefault(require("../Text"));
|
|
34
34
|
const useThemedStyle_1 = require("../../hooks/useThemedStyle");
|
|
35
|
-
const NavigationListRow = ({ label, caption, onPress, disabled, }) => {
|
|
36
|
-
const styles = useStyles().styles;
|
|
37
|
-
return (<react_native_1.TouchableOpacity disabled={disabled} style={styles.container} onPress={onPress}>
|
|
35
|
+
const NavigationListRow = ({ label, caption, onPress, disabled, defaultPadding = true, containerStyle = {}, }) => {
|
|
36
|
+
const styles = useStyles(defaultPadding).styles;
|
|
37
|
+
return (<react_native_1.TouchableOpacity disabled={disabled} style={[styles.container, containerStyle]} onPress={onPress}>
|
|
38
38
|
<react_native_1.View style={styles.content}>
|
|
39
39
|
<Text_1.default category="h3">{label}</Text_1.default>
|
|
40
40
|
{caption && <Text_1.default contrast="low">{caption}</Text_1.default>}
|
|
@@ -44,7 +44,7 @@ const NavigationListRow = ({ label, caption, onPress, disabled, }) => {
|
|
|
44
44
|
};
|
|
45
45
|
exports.NavigationListRow = NavigationListRow;
|
|
46
46
|
exports.default = exports.NavigationListRow;
|
|
47
|
-
const useStyles = () => (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
|
|
47
|
+
const useStyles = (defaultPadding) => (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCallback)((t) => react_native_1.StyleSheet.create({
|
|
48
48
|
content: {
|
|
49
49
|
flexGrow: 1,
|
|
50
50
|
},
|
|
@@ -52,7 +52,7 @@ const useStyles = () => (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCall
|
|
|
52
52
|
width: "100%",
|
|
53
53
|
flexDirection: "row",
|
|
54
54
|
paddingVertical: t.size.baseSize * 2,
|
|
55
|
-
paddingHorizontal: t.size.baseSize * 4,
|
|
55
|
+
paddingHorizontal: defaultPadding ? t.size.baseSize * 4 : 0,
|
|
56
56
|
},
|
|
57
57
|
chevronRight: {
|
|
58
58
|
height: "100%",
|
|
@@ -61,4 +61,4 @@ const useStyles = () => (0, useThemedStyle_1.useThemedStyle)((0, react_1.useCall
|
|
|
61
61
|
chevronRightTint: {
|
|
62
62
|
color: t.colors.foregroundLowContrast,
|
|
63
63
|
},
|
|
64
|
-
}), []));
|
|
64
|
+
}), [defaultPadding]));
|
|
@@ -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
|
}
|