@ds-autonomie/react-native 0.1.0 → 0.2.0
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.
- package/CHANGELOG.md +10 -0
- package/dist/chunks/chunk.2HOUMFYI.js +94 -0
- package/dist/chunks/{chunk.NNC6C337.js → chunk.B2JV2E47.js} +3 -3
- package/dist/chunks/chunk.H2AL2E3A.js +47 -0
- package/dist/chunks/chunk.MCKLJGG3.js +70 -0
- package/dist/chunks/{chunk.4EJ4MEUR.js → chunk.OQSCGAEY.js} +4 -2
- package/dist/chunks/chunk.QOZS5EA3.js +111 -0
- package/dist/chunks/chunk.RNOZ5AW4.js +71 -0
- package/dist/chunks/chunk.YWEWQ2LT.js +39 -0
- package/dist/components/button/Button.d.ts +65 -0
- package/dist/components/button/Button.js +68 -0
- package/dist/components/button/Button.styles.d.ts +38 -0
- package/dist/components/button/Button.styles.js +14 -0
- package/dist/components/checkbox/Checkbox.d.ts +55 -0
- package/dist/components/checkbox/Checkbox.js +71 -0
- package/dist/components/checkbox/Checkbox.styles.d.ts +38 -0
- package/dist/components/checkbox/Checkbox.styles.js +8 -0
- package/dist/components/icon/Icon.d.ts +10 -4
- package/dist/components/icon/Icon.js +1 -1
- package/dist/components/radio/Radio.d.ts +55 -0
- package/dist/components/radio/Radio.js +59 -0
- package/dist/components/radio/Radio.styles.d.ts +30 -0
- package/dist/components/radio/Radio.styles.js +8 -0
- package/dist/components/search/SearchField.d.ts +14 -0
- package/dist/components/search/SearchField.js +72 -0
- package/dist/components/search/SearchField.styles.d.ts +42 -0
- package/dist/components/search/SearchField.styles.js +10 -0
- package/dist/components/text-input/TextInput.d.ts +54 -0
- package/dist/components/text-input/TextInput.js +8 -0
- package/dist/components/text-input/TextInput.styles.d.ts +86 -0
- package/dist/components/text-input/TextInput.styles.js +10 -0
- package/dist/components/toggle/Toggle.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +7 -2
- package/dist/styles/fonts.d.ts +17 -0
- package/dist/utils/device.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @ds-autonomie/react-native
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 711b710: `checkbox`: implémentation du composant
|
|
8
|
+
- 74a9815: `button`: implementation du composant Button
|
|
9
|
+
- a6fe29e: `TextInput`: implémentation du composant
|
|
10
|
+
- e09d454: `Radio`: implémentation du composant
|
|
11
|
+
- 544c8c7: `searchField`: implementation du composant SearchField
|
|
12
|
+
|
|
3
13
|
## 0.1.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCursorColors,
|
|
3
|
+
inputWrapperStyles,
|
|
4
|
+
styles
|
|
5
|
+
} from "./chunk.QOZS5EA3.js";
|
|
6
|
+
import {
|
|
7
|
+
Icon
|
|
8
|
+
} from "./chunk.OQSCGAEY.js";
|
|
9
|
+
|
|
10
|
+
// src/components/text-input/TextInput.tsx
|
|
11
|
+
import React, { useState } from "react";
|
|
12
|
+
import {
|
|
13
|
+
TextInput as NativeTextInput,
|
|
14
|
+
View,
|
|
15
|
+
Text
|
|
16
|
+
} from "react-native";
|
|
17
|
+
var TextInput = React.forwardRef(function TextInput2({
|
|
18
|
+
label,
|
|
19
|
+
required = false,
|
|
20
|
+
error = false,
|
|
21
|
+
errorText,
|
|
22
|
+
disabled = false,
|
|
23
|
+
readOnly = false,
|
|
24
|
+
helpText,
|
|
25
|
+
style,
|
|
26
|
+
onFocus,
|
|
27
|
+
onBlur,
|
|
28
|
+
multiline,
|
|
29
|
+
maxLength,
|
|
30
|
+
value,
|
|
31
|
+
testID,
|
|
32
|
+
...props
|
|
33
|
+
}, ref) {
|
|
34
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
35
|
+
return <View
|
|
36
|
+
style={[style, styles.container]}
|
|
37
|
+
accessibilityState={{ disabled }}
|
|
38
|
+
testID={`${testID}/container`}
|
|
39
|
+
>
|
|
40
|
+
<View style={styles.header}>
|
|
41
|
+
{label !== void 0 && label.length > 0 && <Text
|
|
42
|
+
nativeID="label"
|
|
43
|
+
testID={`${testID}/label`}
|
|
44
|
+
style={styles.label}
|
|
45
|
+
>
|
|
46
|
+
{required && <Text style={styles.labelRequired}>* </Text>}
|
|
47
|
+
{label}
|
|
48
|
+
</Text>}
|
|
49
|
+
{maxLength !== void 0 && <Text style={styles.counter} testID={`${testID}/counter`}>
|
|
50
|
+
{value.length}
|
|
51
|
+
{"/"}
|
|
52
|
+
{maxLength}
|
|
53
|
+
</Text>}
|
|
54
|
+
</View>
|
|
55
|
+
<View
|
|
56
|
+
style={[
|
|
57
|
+
inputWrapperStyles.default,
|
|
58
|
+
isFocused && inputWrapperStyles.focused,
|
|
59
|
+
error && inputWrapperStyles.error,
|
|
60
|
+
readOnly && inputWrapperStyles.readonly,
|
|
61
|
+
disabled && inputWrapperStyles.disabled
|
|
62
|
+
]}
|
|
63
|
+
><NativeTextInput
|
|
64
|
+
aria-label={label}
|
|
65
|
+
aria-labelby="label"
|
|
66
|
+
testID={`${testID}/input`}
|
|
67
|
+
{...props}
|
|
68
|
+
ref={ref}
|
|
69
|
+
value={value}
|
|
70
|
+
multiline={multiline}
|
|
71
|
+
maxLength={maxLength}
|
|
72
|
+
style={styles.input}
|
|
73
|
+
{...getCursorColors(error)}
|
|
74
|
+
onFocus={(e) => {
|
|
75
|
+
setIsFocused(true);
|
|
76
|
+
onFocus?.(e);
|
|
77
|
+
}}
|
|
78
|
+
onBlur={(e) => {
|
|
79
|
+
setIsFocused(false);
|
|
80
|
+
onBlur?.(e);
|
|
81
|
+
}}
|
|
82
|
+
editable={!(readOnly || disabled)}
|
|
83
|
+
/></View>
|
|
84
|
+
{error && errorText !== void 0 && <View style={[styles.bottomMessage]} testID={`${testID}/errorText`}>
|
|
85
|
+
<Icon name="error" style={styles.errorIcon} />
|
|
86
|
+
<Text style={styles.errorText}>{errorText}</Text>
|
|
87
|
+
</View>}
|
|
88
|
+
{helpText !== void 0 && <View style={[styles.bottomMessage]} testID={`${testID}/helpText`}><Text style={styles.helpText}>{helpText}</Text></View>}
|
|
89
|
+
</View>;
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
TextInput
|
|
94
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Icon
|
|
3
|
-
} from "./chunk.4EJ4MEUR.js";
|
|
4
1
|
import {
|
|
5
2
|
getToggleStyle,
|
|
6
3
|
styles
|
|
7
4
|
} from "./chunk.CZ5Y2AVH.js";
|
|
5
|
+
import {
|
|
6
|
+
Icon
|
|
7
|
+
} from "./chunk.OQSCGAEY.js";
|
|
8
8
|
|
|
9
9
|
// src/components/toggle/Toggle.tsx
|
|
10
10
|
import React, { useEffect, useState } from "react";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// src/components/checkbox/Checkbox.styles.ts
|
|
2
|
+
import theme from "@ds-autonomie/assets/js/dsa-theme";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
var checkboxTheme = theme.collection["toggle item"]["toggle item"].checkbox;
|
|
5
|
+
var checkboxContainerStyles = StyleSheet.create({
|
|
6
|
+
default: {
|
|
7
|
+
width: 20,
|
|
8
|
+
height: 20,
|
|
9
|
+
borderWidth: 2,
|
|
10
|
+
borderRadius: 2,
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
borderColor: checkboxTheme.default
|
|
14
|
+
},
|
|
15
|
+
error: {
|
|
16
|
+
borderColor: checkboxTheme.error
|
|
17
|
+
},
|
|
18
|
+
disabled: {
|
|
19
|
+
borderColor: checkboxTheme.disabled
|
|
20
|
+
},
|
|
21
|
+
active: {
|
|
22
|
+
borderColor: checkboxTheme.active
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var checkboxCheckStyles = StyleSheet.create({
|
|
26
|
+
default: {
|
|
27
|
+
width: 20,
|
|
28
|
+
height: 20,
|
|
29
|
+
borderRadius: 2,
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
justifyContent: "center"
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
backgroundColor: checkboxTheme.disabled
|
|
35
|
+
},
|
|
36
|
+
error: {
|
|
37
|
+
backgroundColor: checkboxTheme.error
|
|
38
|
+
},
|
|
39
|
+
active: {
|
|
40
|
+
backgroundColor: checkboxTheme.active
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
checkboxContainerStyles,
|
|
46
|
+
checkboxCheckStyles
|
|
47
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// src/components/search/SearchField.styles.tsx
|
|
2
|
+
import theme from "@ds-autonomie/assets/js/dsa-theme";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
|
|
5
|
+
// src/utils/device.ts
|
|
6
|
+
import { Platform } from "react-native";
|
|
7
|
+
var isIOS = Platform.OS === "ios";
|
|
8
|
+
var isAndroid = Platform.OS === "android";
|
|
9
|
+
|
|
10
|
+
// src/components/search/SearchField.styles.tsx
|
|
11
|
+
var placeholderTextColor = "#3C3C4399";
|
|
12
|
+
var styles = StyleSheet.create({
|
|
13
|
+
container: {
|
|
14
|
+
flexDirection: "row",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
borderRadius: 10,
|
|
17
|
+
backgroundColor: "#7676801F",
|
|
18
|
+
padding: theme.primitives.spacing[8],
|
|
19
|
+
paddingLeft: 0
|
|
20
|
+
},
|
|
21
|
+
iOScontainer: {
|
|
22
|
+
padding: 7,
|
|
23
|
+
paddingLeft: 0
|
|
24
|
+
},
|
|
25
|
+
disabledContainer: {
|
|
26
|
+
backgroundColor: theme.collection.input.background.disabled
|
|
27
|
+
},
|
|
28
|
+
input: {
|
|
29
|
+
flex: 1
|
|
30
|
+
},
|
|
31
|
+
icon: {
|
|
32
|
+
position: "absolute",
|
|
33
|
+
left: theme.primitives.spacing[8]
|
|
34
|
+
},
|
|
35
|
+
iOSInput: {
|
|
36
|
+
paddingLeft: 38
|
|
37
|
+
},
|
|
38
|
+
androidInput: {
|
|
39
|
+
paddingLeft: 56
|
|
40
|
+
},
|
|
41
|
+
iosIcon: {
|
|
42
|
+
top: 5,
|
|
43
|
+
width: 18,
|
|
44
|
+
height: 18,
|
|
45
|
+
marginLeft: theme.primitives.spacing[8]
|
|
46
|
+
},
|
|
47
|
+
androidIcon: {
|
|
48
|
+
marginLeft: theme.primitives.spacing[12]
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
var iconStyleByPlateform = {
|
|
52
|
+
ios: {
|
|
53
|
+
color: "rgba(60, 60, 67, 0.60)",
|
|
54
|
+
size: 22,
|
|
55
|
+
style: [styles.icon, styles.iosIcon]
|
|
56
|
+
},
|
|
57
|
+
android: {
|
|
58
|
+
color: "#000000",
|
|
59
|
+
style: [styles.icon, styles.androidIcon],
|
|
60
|
+
size: 24
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var plateformStyles = isIOS ? iconStyleByPlateform.ios : iconStyleByPlateform.android;
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
isIOS,
|
|
67
|
+
placeholderTextColor,
|
|
68
|
+
styles,
|
|
69
|
+
plateformStyles
|
|
70
|
+
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// src/components/icon/Icon.tsx
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import MaterialIcons from "react-native-vector-icons/MaterialIcons";
|
|
3
|
-
|
|
4
|
+
var Icon = forwardRef(function Icon2({ size = 16, ...restProps }, ref) {
|
|
4
5
|
return <MaterialIcons
|
|
5
6
|
{...restProps}
|
|
7
|
+
ref={ref}
|
|
6
8
|
size={size}
|
|
7
9
|
selectable={false}
|
|
8
10
|
importantForAccessibility="no-hide-descendants"
|
|
9
11
|
accessibilityElementsHidden
|
|
10
12
|
/>;
|
|
11
|
-
}
|
|
13
|
+
});
|
|
12
14
|
|
|
13
15
|
export {
|
|
14
16
|
Icon
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// src/components/text-input/TextInput.styles.ts
|
|
2
|
+
import theme from "@ds-autonomie/assets/js/dsa-theme";
|
|
3
|
+
import { StyleSheet as StyleSheet2 } from "react-native";
|
|
4
|
+
|
|
5
|
+
// src/styles/fonts.ts
|
|
6
|
+
import { StyleSheet } from "react-native";
|
|
7
|
+
var fonts = StyleSheet.create({
|
|
8
|
+
bodyLarge: {
|
|
9
|
+
fontSize: 16,
|
|
10
|
+
fontFamily: "Cabin-Regular",
|
|
11
|
+
letterSpacing: 0.5
|
|
12
|
+
},
|
|
13
|
+
bodyMedium: {
|
|
14
|
+
fontSize: 14,
|
|
15
|
+
fontFamily: "Cabin-Regular",
|
|
16
|
+
letterSpacing: 0.25
|
|
17
|
+
},
|
|
18
|
+
bodySmall: {
|
|
19
|
+
fontSize: 12,
|
|
20
|
+
fontFamily: "Cabin-Regular",
|
|
21
|
+
letterSpacing: 0.36
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// src/components/text-input/TextInput.styles.ts
|
|
26
|
+
var styles = StyleSheet2.create({
|
|
27
|
+
container: {
|
|
28
|
+
display: "flex",
|
|
29
|
+
flex: 1
|
|
30
|
+
},
|
|
31
|
+
header: {
|
|
32
|
+
marginBottom: theme.primitives.spacing["8"],
|
|
33
|
+
display: "flex",
|
|
34
|
+
flexDirection: "row"
|
|
35
|
+
},
|
|
36
|
+
label: {
|
|
37
|
+
...fonts.bodyLarge,
|
|
38
|
+
color: theme.collection.input.title
|
|
39
|
+
},
|
|
40
|
+
counter: {
|
|
41
|
+
marginLeft: "auto",
|
|
42
|
+
...fonts.bodyLarge,
|
|
43
|
+
color: theme.collection.input.title
|
|
44
|
+
},
|
|
45
|
+
labelRequired: {
|
|
46
|
+
color: theme.collection.input["text error"]
|
|
47
|
+
},
|
|
48
|
+
input: {
|
|
49
|
+
paddingTop: theme.primitives.spacing["16"],
|
|
50
|
+
paddingBottom: theme.primitives.spacing["16"],
|
|
51
|
+
paddingRight: theme.primitives.spacing["16"],
|
|
52
|
+
paddingLeft: theme.primitives.spacing["16"],
|
|
53
|
+
borderRadius: theme.primitives.radius["8"],
|
|
54
|
+
...fonts.bodyLarge
|
|
55
|
+
},
|
|
56
|
+
bottomMessage: {
|
|
57
|
+
marginTop: theme.primitives.spacing["8"],
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "row"
|
|
60
|
+
},
|
|
61
|
+
errorText: {
|
|
62
|
+
color: theme.collection.input["text error"]
|
|
63
|
+
},
|
|
64
|
+
errorIcon: {
|
|
65
|
+
...fonts.bodyMedium,
|
|
66
|
+
color: theme.collection.input["text error"],
|
|
67
|
+
marginTop: 3,
|
|
68
|
+
marginRight: theme.primitives.spacing["4"]
|
|
69
|
+
},
|
|
70
|
+
helpText: {
|
|
71
|
+
color: theme.collection.input.hint
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
var inputWrapperStyles = StyleSheet2.create({
|
|
75
|
+
default: {
|
|
76
|
+
backgroundColor: theme.collection.input.background.default,
|
|
77
|
+
borderColor: theme.collection.input.border.default,
|
|
78
|
+
borderWidth: 1,
|
|
79
|
+
borderRadius: theme.primitives.radius["8"]
|
|
80
|
+
},
|
|
81
|
+
focused: {
|
|
82
|
+
borderColor: theme.collection.input.border.active
|
|
83
|
+
},
|
|
84
|
+
error: {
|
|
85
|
+
borderColor: theme.collection.input.border.error,
|
|
86
|
+
backgroundColor: theme.collection.input.background.error,
|
|
87
|
+
color: theme.collection.input.content.error
|
|
88
|
+
},
|
|
89
|
+
readonly: {
|
|
90
|
+
borderColor: theme.collection.input.border["read only"],
|
|
91
|
+
backgroundColor: theme.collection.input.background["read only"],
|
|
92
|
+
color: theme.collection.input.content["read only"]
|
|
93
|
+
},
|
|
94
|
+
disabled: {
|
|
95
|
+
borderColor: theme.collection.input.border.disabled,
|
|
96
|
+
backgroundColor: theme.collection.input.background.disabled,
|
|
97
|
+
color: theme.collection.input.content.disabled
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
function getCursorColors(error) {
|
|
101
|
+
return {
|
|
102
|
+
cursorColor: error ? theme.collection.input.cursor.error : theme.collection.input.cursor.default,
|
|
103
|
+
selectionColor: error ? theme.collection.input.cursor.error : theme.collection.input.cursor.default
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export {
|
|
108
|
+
styles,
|
|
109
|
+
inputWrapperStyles,
|
|
110
|
+
getCursorColors
|
|
111
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/components/button/Button.styles.ts
|
|
2
|
+
import theme from "@ds-autonomie/assets/js/dsa-theme";
|
|
3
|
+
import {
|
|
4
|
+
StyleSheet
|
|
5
|
+
} from "react-native";
|
|
6
|
+
var variants = Object.keys(
|
|
7
|
+
theme.collection.button
|
|
8
|
+
);
|
|
9
|
+
var sizes = ["small", "medium"];
|
|
10
|
+
function getIconColor({ pressed, disabled, variant }) {
|
|
11
|
+
const buttonTheme = theme.collection.button[variant];
|
|
12
|
+
if (disabled)
|
|
13
|
+
return buttonTheme["on-disabled"];
|
|
14
|
+
if (pressed)
|
|
15
|
+
return buttonTheme["on-pressed"];
|
|
16
|
+
return buttonTheme["on-enabled"];
|
|
17
|
+
}
|
|
18
|
+
function getContainerStyle({
|
|
19
|
+
disabled,
|
|
20
|
+
hasOnlyOneIcon,
|
|
21
|
+
pressed,
|
|
22
|
+
size,
|
|
23
|
+
variant
|
|
24
|
+
}) {
|
|
25
|
+
const isMedium = size === "medium";
|
|
26
|
+
const isLink = variant === "link";
|
|
27
|
+
const state = disabled ? "disabled" : pressed ? "pressed" : "enabled";
|
|
28
|
+
const verticalPadding = theme.primitives.spacing[isMedium ? 16 : 8];
|
|
29
|
+
const horizontalPadding = hasOnlyOneIcon ? theme.primitives.spacing[isMedium ? 16 : 8] : theme.primitives.spacing[isMedium ? 24 : 16];
|
|
30
|
+
return StyleSheet.create({
|
|
31
|
+
container: {
|
|
32
|
+
position: "relative",
|
|
33
|
+
flexDirection: "row",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
borderRadius: theme.primitives.radius[8],
|
|
36
|
+
paddingLeft: horizontalPadding,
|
|
37
|
+
paddingRight: horizontalPadding,
|
|
38
|
+
paddingTop: verticalPadding,
|
|
39
|
+
paddingBottom: verticalPadding,
|
|
40
|
+
gap: theme.primitives.spacing[isMedium ? 8 : 4],
|
|
41
|
+
backgroundColor: isLink ? void 0 : theme.collection.button[variant][state],
|
|
42
|
+
opacity: !isLink && disabled ? 0.4 : void 0
|
|
43
|
+
}
|
|
44
|
+
}).container;
|
|
45
|
+
}
|
|
46
|
+
function getTextStyle({
|
|
47
|
+
disabled,
|
|
48
|
+
pressed,
|
|
49
|
+
size,
|
|
50
|
+
variant
|
|
51
|
+
}) {
|
|
52
|
+
const isMedium = size === "medium";
|
|
53
|
+
const state = disabled ? "disabled" : pressed ? "pressed" : "enabled";
|
|
54
|
+
return StyleSheet.create({
|
|
55
|
+
text: {
|
|
56
|
+
fontFamily: "Cabin-Regular",
|
|
57
|
+
fontWeight: "700",
|
|
58
|
+
fontSize: isMedium ? 16 : 14,
|
|
59
|
+
letterSpacing: isMedium ? 0.5 : 0.25,
|
|
60
|
+
color: theme.collection.button[variant][`on-${state}`]
|
|
61
|
+
}
|
|
62
|
+
}).text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
variants,
|
|
67
|
+
sizes,
|
|
68
|
+
getIconColor,
|
|
69
|
+
getContainerStyle,
|
|
70
|
+
getTextStyle
|
|
71
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/components/radio/Radio.styles.ts
|
|
2
|
+
import theme from "@ds-autonomie/assets/js/dsa-theme";
|
|
3
|
+
import { StyleSheet } from "react-native";
|
|
4
|
+
var radioTheme = theme.collection["toggle item"]["toggle item"].radio;
|
|
5
|
+
var radioContainerStyles = StyleSheet.create({
|
|
6
|
+
default: {
|
|
7
|
+
width: 20,
|
|
8
|
+
height: 20,
|
|
9
|
+
borderWidth: 2,
|
|
10
|
+
borderRadius: 20,
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
justifyContent: "center",
|
|
13
|
+
borderColor: radioTheme.default
|
|
14
|
+
},
|
|
15
|
+
active: {
|
|
16
|
+
borderColor: radioTheme.active
|
|
17
|
+
},
|
|
18
|
+
disabled: {
|
|
19
|
+
borderColor: radioTheme.disabled
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var radioDotStyles = StyleSheet.create({
|
|
23
|
+
default: {
|
|
24
|
+
width: 10,
|
|
25
|
+
height: 10,
|
|
26
|
+
borderRadius: 20
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
backgroundColor: radioTheme.disabled
|
|
30
|
+
},
|
|
31
|
+
active: {
|
|
32
|
+
backgroundColor: radioTheme.active
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export {
|
|
37
|
+
radioContainerStyles,
|
|
38
|
+
radioDotStyles
|
|
39
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle, PressableProps, View } from 'react-native';
|
|
3
|
+
import { Size, Variant } from './Button.styles';
|
|
4
|
+
type OmittedPressableProps = 'accessibilityLabel' | 'accessibilityRole' | 'accessibilityState' | 'accessible' | 'aria-disabled' | 'children' | 'disabled' | 'role' | 'style';
|
|
5
|
+
export type ButtonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* Variant of button.
|
|
8
|
+
*/
|
|
9
|
+
variant?: Variant;
|
|
10
|
+
/**
|
|
11
|
+
* If `style` is defined, it will extend the container style.
|
|
12
|
+
*/
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
/**
|
|
15
|
+
* Text displayed in button.
|
|
16
|
+
*/
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Name of element placed before the title.
|
|
20
|
+
*/
|
|
21
|
+
startIcon?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Name of element placed after the title.
|
|
24
|
+
*/
|
|
25
|
+
endIcon?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The size of the component.
|
|
28
|
+
*/
|
|
29
|
+
size?: Size;
|
|
30
|
+
/**
|
|
31
|
+
* Disabled the button.
|
|
32
|
+
*/
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
} & Omit<PressableProps, OmittedPressableProps>;
|
|
35
|
+
export declare const Button: React.ForwardRefExoticComponent<{
|
|
36
|
+
/**
|
|
37
|
+
* Variant of button.
|
|
38
|
+
*/
|
|
39
|
+
variant?: "link" | "primary" | "secondary" | "tertiary" | "destructive" | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* If `style` is defined, it will extend the container style.
|
|
42
|
+
*/
|
|
43
|
+
style?: StyleProp<ViewStyle>;
|
|
44
|
+
/**
|
|
45
|
+
* Text displayed in button.
|
|
46
|
+
*/
|
|
47
|
+
children?: ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Name of element placed before the title.
|
|
50
|
+
*/
|
|
51
|
+
startIcon?: string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Name of element placed after the title.
|
|
54
|
+
*/
|
|
55
|
+
endIcon?: string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* The size of the component.
|
|
58
|
+
*/
|
|
59
|
+
size?: Size | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Disabled the button.
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean | undefined;
|
|
64
|
+
} & Omit<PressableProps, OmittedPressableProps> & React.RefAttributes<View>>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getContainerStyle,
|
|
3
|
+
getIconColor,
|
|
4
|
+
getTextStyle
|
|
5
|
+
} from "../../chunks/chunk.RNOZ5AW4.js";
|
|
6
|
+
import {
|
|
7
|
+
Icon
|
|
8
|
+
} from "../../chunks/chunk.OQSCGAEY.js";
|
|
9
|
+
|
|
10
|
+
// src/components/button/Button.tsx
|
|
11
|
+
import React from "react";
|
|
12
|
+
import {
|
|
13
|
+
Pressable,
|
|
14
|
+
Text
|
|
15
|
+
} from "react-native";
|
|
16
|
+
var Button = React.forwardRef(function Toggle({
|
|
17
|
+
variant = "primary",
|
|
18
|
+
style,
|
|
19
|
+
disabled = false,
|
|
20
|
+
endIcon,
|
|
21
|
+
size = "medium",
|
|
22
|
+
startIcon,
|
|
23
|
+
children,
|
|
24
|
+
...props
|
|
25
|
+
}, ref) {
|
|
26
|
+
const hasOnlyOneIcon = [!!startIcon, !!endIcon].filter(Boolean).length === 1 && !children;
|
|
27
|
+
return <Pressable
|
|
28
|
+
ref={ref}
|
|
29
|
+
{...props}
|
|
30
|
+
accessibilityLabel="button"
|
|
31
|
+
accessibilityRole="button"
|
|
32
|
+
accessible
|
|
33
|
+
aria-disabled={disabled}
|
|
34
|
+
accessibilityState={{
|
|
35
|
+
disabled
|
|
36
|
+
}}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
role="button"
|
|
39
|
+
style={({ pressed }) => [
|
|
40
|
+
style,
|
|
41
|
+
getContainerStyle({ variant, size, hasOnlyOneIcon, disabled, pressed })
|
|
42
|
+
]}
|
|
43
|
+
>{({ pressed }) => {
|
|
44
|
+
const iconColor = getIconColor({
|
|
45
|
+
pressed,
|
|
46
|
+
disabled,
|
|
47
|
+
variant
|
|
48
|
+
});
|
|
49
|
+
return <>
|
|
50
|
+
{startIcon && <Icon name={startIcon} color={iconColor} size={24} />}
|
|
51
|
+
{children !== void 0 && <Text
|
|
52
|
+
style={[
|
|
53
|
+
getTextStyle({
|
|
54
|
+
variant,
|
|
55
|
+
size,
|
|
56
|
+
hasOnlyOneIcon,
|
|
57
|
+
disabled,
|
|
58
|
+
pressed
|
|
59
|
+
})
|
|
60
|
+
]}
|
|
61
|
+
>{children}</Text>}
|
|
62
|
+
{endIcon && <Icon name={endIcon} color={iconColor} size={24} />}
|
|
63
|
+
</>;
|
|
64
|
+
}}</Pressable>;
|
|
65
|
+
});
|
|
66
|
+
export {
|
|
67
|
+
Button
|
|
68
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import theme from '@ds-autonomie/assets/js/dsa-theme';
|
|
2
|
+
import { PressableStateCallbackType } from 'react-native';
|
|
3
|
+
import { ButtonProps } from './Button';
|
|
4
|
+
export type Variant = keyof typeof theme.collection.button;
|
|
5
|
+
export declare const variants: Variant[];
|
|
6
|
+
export type Size = 'small' | 'medium';
|
|
7
|
+
export declare const sizes: Size[];
|
|
8
|
+
type State = {
|
|
9
|
+
pressed: PressableStateCallbackType['pressed'];
|
|
10
|
+
disabled: ButtonProps['disabled'];
|
|
11
|
+
variant: Variant;
|
|
12
|
+
};
|
|
13
|
+
export declare function getIconColor({ pressed, disabled, variant }: State): "#540abdff" | "#ffffffff";
|
|
14
|
+
type GetStylesProps = {
|
|
15
|
+
hasOnlyOneIcon: boolean;
|
|
16
|
+
size: Size;
|
|
17
|
+
} & State;
|
|
18
|
+
export declare function getContainerStyle({ disabled, hasOnlyOneIcon, pressed, size, variant, }: GetStylesProps): {
|
|
19
|
+
position: "relative";
|
|
20
|
+
flexDirection: "row";
|
|
21
|
+
alignItems: "center";
|
|
22
|
+
borderRadius: 8;
|
|
23
|
+
paddingLeft: number;
|
|
24
|
+
paddingRight: number;
|
|
25
|
+
paddingTop: number;
|
|
26
|
+
paddingBottom: number;
|
|
27
|
+
gap: 4 | 8;
|
|
28
|
+
backgroundColor: "#ede4faff" | "#cbb0ecff" | "#540abdff" | "#451292ff" | "#ffffffff" | "#dd1708ff" | "#530000ff" | undefined;
|
|
29
|
+
opacity: number | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare function getTextStyle({ disabled, pressed, size, variant, }: GetStylesProps): {
|
|
32
|
+
fontFamily: string;
|
|
33
|
+
fontWeight: "700";
|
|
34
|
+
fontSize: number;
|
|
35
|
+
letterSpacing: number;
|
|
36
|
+
color: "#540abdff" | "#ffffffff";
|
|
37
|
+
};
|
|
38
|
+
export {};
|