@fto-consult/expo-ui 6.1.2 → 6.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.1.2",
3
+ "version": "6.1.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readMe.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ## Installation des dépendences, packages de dévéloppement
2
2
 
3
3
  ```javascript
4
- npm i --D @babel/preset-react babel-plugin-inline-dotenv babel-plugin-module-resolver babel-plugin-transform-inline-environment-variables @expo/metro-config @expo/webpack-config
4
+ npm i --D babel-plugin-inline-dotenv babel-plugin-module-resolver babel-plugin-transform-inline-environment-variables @expo/metro-config @expo/webpack-config
5
5
  ```
6
6
 
7
7
  ## **#ELECTRON**
@@ -1,86 +1,127 @@
1
- import React from '$react';
2
- import {Platform,StyleSheet,Pressable,View} from 'react-native';
3
- import Label from "$ecomponents/Label";
4
- import theme,{Colors,StyleProp} from "$theme";
5
- import PropTypes from "prop-types";
1
+ import * as React from 'react';
2
+ import {
3
+ Platform,
4
+ StyleSheet,
5
+ TouchableWithoutFeedback,
6
+ View,
7
+ } from 'react-native';
8
+ import Label from "$comonents/Label";
9
+ import theme,{Colors} from "$theme";
10
+ import {isIos,isWeb} from "$cplatform";
6
11
  import {defaultObj,defaultStr} from "$cutils";
7
- import {isIos,isAndroid,isWeb} from "$cplatform";
8
-
9
- const AppbarContent = React.forwardRef(({
12
+ const AppbarContent = ({
10
13
  color: titleColor,
11
14
  subtitle,
12
- subtitleProps,
13
15
  subtitleStyle,
14
16
  onPress,
17
+ disabled,
15
18
  style,
16
- titleProps,
17
19
  titleRef,
18
20
  titleStyle,
19
21
  title,
20
- testID,
22
+ theme: themeOverrides,
21
23
  containerProps,
24
+ titleProps,
25
+ subtitleProps,
22
26
  ...rest
23
- },ref) => {
27
+ }) => {
28
+
29
+ const titleTextColor = Colors.isValid(titleColor) ? titleColor : theme.colors.primaryText;
30
+ titleProps = defaultObj(titleProps);
31
+ subtitleProps = defaultObj(subtitleProps);
32
+ testID = defaultStr(testID,"RN_AppBarContentComponent")
33
+ subtitle = subtitle === false ? null : subtitle;
34
+ const subtitleColor = Colors.setAlpha(titleTextColor,0.7);
24
35
 
25
- const titleTextColor = titleColor ? titleColor : theme.colors.primaryText;
26
- titleProps = defaultObj(titleProps);
27
- subtitleProps = defaultObj(subtitleProps);
28
- testID = defaultStr(testID,"RN_AppBarContentComponent")
29
- subtitle = subtitle === false ? null : subtitle;
30
- const subtitleColor = Colors.setAlpha(titleTextColor,0.7);
31
-
32
- return (
33
- <Pressable testID={testID+"_Container"} {...defaultObj(containerProps)} onPress={onPress} disabled={!onPress}>
34
- <View
35
- pointerEvents="box-none"
36
- style={[styles.container, style]}
37
- {...rest}
38
- testID = {testID}
39
- ref = {ref}
40
- >
36
+ const content = (
37
+ <View
38
+ pointerEvents="box-none"
39
+ style={[styles.container, style]}
40
+ testID={testID}
41
+ {...rest}
42
+ >
43
+ {typeof title === 'string' ? (
41
44
  <Label
42
45
  ref={titleRef}
43
- testID = {testID+"_Title"}
44
46
  {...titleProps}
45
47
  style={[
48
+ styles.title,
46
49
  {
47
- color: titleTextColor,
48
- ...(isIos()? theme.fonts.regular: theme.fonts.medium),
50
+ color: titleTextColor,
51
+ ...(isIos()? theme.fonts.regular: theme.fonts.medium),
49
52
  },
50
53
  isWeb() && theme.styles.webFontFamilly,
51
- titleProps.style,
52
54
  titleStyle,
53
55
  ]}
54
56
  numberOfLines={1}
55
57
  accessible
56
- // @ts-ignore Type '"heading"' is not assignable to type ...
57
- role={Platform.OS === 'web' ? 'heading' : 'header'}
58
+ accessibilityRole={
59
+ onPress
60
+ ? 'none'
61
+ : Platform.OS === 'web'
62
+ ? ('heading')
63
+ : 'header'
64
+ }
65
+ // @ts-expect-error We keep old a11y props for backwards compat with old RN versions
66
+ accessibilityTraits="header"
67
+ testID={`${testID}-title-text`}
58
68
  >
59
69
  {title}
60
70
  </Label>
61
- {subtitle ? (
62
- <Label
63
- testID = {testID+"_Subtitle"}
64
- {...subtitleProps}
65
- style={[styles.subtitle, { color: subtitleColor }, subtitleProps.style, subtitleStyle]}
66
- numberOfLines={1}
67
- >
68
- {subtitle}
69
- </Label>
70
- ) : null}
71
- </View>
72
- </Pressable>
71
+ ) : (
72
+ title
73
+ )}
74
+ {subtitle ? (
75
+ <Label
76
+ testID = {testID+"_Subtitle"}
77
+ {...subtitleProps}
78
+ style={[styles.subtitle, { color: subtitleColor }, subtitleStyle]}
79
+ numberOfLines={1}
80
+ >
81
+ {subtitle}
82
+ </Label>
83
+ ) : null}
84
+ </View>
73
85
  );
74
- });
75
86
 
76
- AppbarContent.displayName = 'Appbar.Content';
87
+ if (onPress) {
88
+ return (
89
+ <TouchableWithoutFeedback
90
+ testID={testID+"_Container"}
91
+ {...containerProps}
92
+ accessibilityRole={touchableRole}
93
+ accessibilityTraits={touchableRole}
94
+ accessibilityComponentType="button"
95
+ onPress={onPress}
96
+ disabled={disabled}
97
+ >
98
+ {content}
99
+ </TouchableWithoutFeedback>
100
+ );
101
+ }
102
+ return content;
103
+ };
104
+
105
+ AppbarContent.displayName = 'AppbarComponent.Content';
77
106
 
78
107
  const styles = StyleSheet.create({
79
108
  container: {
80
109
  flex: 1,
81
- paddingHorizontal: 5,
82
- justifyContent : 'center',
83
- alignItems : 'flex-start',
110
+ paddingHorizontal: 12,
111
+ },
112
+ v3DefaultContainer: {
113
+ paddingHorizontal: 0,
114
+ },
115
+ v3MediumContainer: {
116
+ paddingHorizontal: 0,
117
+ justifyContent: 'flex-end',
118
+ paddingBottom: 24,
119
+ },
120
+ v3LargeContainer: {
121
+ paddingHorizontal: 0,
122
+ paddingTop: 36,
123
+ justifyContent: 'flex-end',
124
+ paddingBottom: 28,
84
125
  },
85
126
  title: {
86
127
  fontSize: Platform.OS === 'ios' ? 17 : 20,
@@ -90,43 +131,8 @@ const styles = StyleSheet.create({
90
131
  },
91
132
  });
92
133
 
93
- export default AppbarContent;
94
- const titleType = PropTypes.oneOfType([
95
- PropTypes.string,
96
- PropTypes.node,
97
- PropTypes.bool,
98
- ])
99
-
100
- AppbarContent.propTypes = {
101
- /**
102
- * Custom StyleProp for the text.
103
- */
104
- StyleProp: PropTypes.string,
105
- /**
106
- * Text for the title.
107
- */
108
- title: titleType,
109
- /**
110
- * Style for the title.
111
- */
112
- titleStyle: StyleProp,
113
- /**
114
- * Reference for the title.
115
- */
116
- titleRef : PropTypes.any,
117
- /**
118
- * @deprecated Deprecated in v5.x
119
- * Text for the subtitle.
120
- */
121
- subtitle : titleType,
122
- /**
123
- * @deprecated Deprecated in v5.x
124
- * Style for the subtitle.
125
- */
126
- subtitleStyle: StyleProp,
127
- /**
128
- * Function to execute on press.
129
- */
130
- onPress : PropTypes.func,
131
- style : StyleProp
132
- }
134
+ const iosTouchableRole = ['button', 'header'];
135
+ const touchableRole = Platform.select({
136
+ ios: iosTouchableRole,
137
+ default: iosTouchableRole[0],
138
+ });
@@ -0,0 +1,132 @@
1
+ import React from '$react';
2
+ import {Platform,StyleSheet,Pressable,View} from 'react-native';
3
+ import Label from "$ecomponents/Label";
4
+ import theme,{Colors,StyleProp} from "$theme";
5
+ import PropTypes from "prop-types";
6
+ import {defaultObj,defaultStr} from "$cutils";
7
+ import {isIos,isAndroid,isWeb} from "$cplatform";
8
+
9
+ const AppbarContent = React.forwardRef(({
10
+ color: titleColor,
11
+ subtitle,
12
+ subtitleProps,
13
+ subtitleStyle,
14
+ onPress,
15
+ style,
16
+ titleProps,
17
+ titleRef,
18
+ titleStyle,
19
+ title,
20
+ testID,
21
+ containerProps,
22
+ ...rest
23
+ },ref) => {
24
+
25
+ const titleTextColor = titleColor ? titleColor : theme.colors.primaryText;
26
+ titleProps = defaultObj(titleProps);
27
+ subtitleProps = defaultObj(subtitleProps);
28
+ testID = defaultStr(testID,"RN_AppBarContentComponent")
29
+ subtitle = subtitle === false ? null : subtitle;
30
+ const subtitleColor = Colors.setAlpha(titleTextColor,0.7);
31
+
32
+ return (
33
+ <Pressable testID={testID+"_Container"} {...defaultObj(containerProps)} onPress={onPress} disabled={!onPress}>
34
+ <View
35
+ pointerEvents="box-none"
36
+ style={[styles.container, style]}
37
+ {...rest}
38
+ testID = {testID}
39
+ ref = {ref}
40
+ >
41
+ <Label
42
+ ref={titleRef}
43
+ testID = {testID+"_Title"}
44
+ {...titleProps}
45
+ style={[
46
+ {
47
+ color: titleTextColor,
48
+ ...(isIos()? theme.fonts.regular: theme.fonts.medium),
49
+ },
50
+ isWeb() && theme.styles.webFontFamilly,
51
+ titleProps.style,
52
+ titleStyle,
53
+ ]}
54
+ numberOfLines={1}
55
+ accessible
56
+ // @ts-ignore Type '"heading"' is not assignable to type ...
57
+ role={Platform.OS === 'web' ? 'heading' : 'header'}
58
+ >
59
+ {title}
60
+ </Label>
61
+ {subtitle ? (
62
+ <Label
63
+ testID = {testID+"_Subtitle"}
64
+ {...subtitleProps}
65
+ style={[styles.subtitle, { color: subtitleColor }, subtitleProps.style, subtitleStyle]}
66
+ numberOfLines={1}
67
+ >
68
+ {subtitle}
69
+ </Label>
70
+ ) : null}
71
+ </View>
72
+ </Pressable>
73
+ );
74
+ });
75
+
76
+ AppbarContent.displayName = 'Appbar.Content';
77
+
78
+ const styles = StyleSheet.create({
79
+ container: {
80
+ flex: 1,
81
+ paddingHorizontal: 5,
82
+ justifyContent : 'center',
83
+ alignItems : 'flex-start',
84
+ },
85
+ title: {
86
+ fontSize: Platform.OS === 'ios' ? 17 : 20,
87
+ },
88
+ subtitle: {
89
+ fontSize: Platform.OS === 'ios' ? 11 : 14,
90
+ },
91
+ });
92
+
93
+ export default AppbarContent;
94
+ const titleType = PropTypes.oneOfType([
95
+ PropTypes.string,
96
+ PropTypes.node,
97
+ PropTypes.bool,
98
+ ])
99
+
100
+ AppbarContent.propTypes = {
101
+ /**
102
+ * Custom StyleProp for the text.
103
+ */
104
+ StyleProp: PropTypes.string,
105
+ /**
106
+ * Text for the title.
107
+ */
108
+ title: titleType,
109
+ /**
110
+ * Style for the title.
111
+ */
112
+ titleStyle: StyleProp,
113
+ /**
114
+ * Reference for the title.
115
+ */
116
+ titleRef : PropTypes.any,
117
+ /**
118
+ * @deprecated Deprecated in v5.x
119
+ * Text for the subtitle.
120
+ */
121
+ subtitle : titleType,
122
+ /**
123
+ * @deprecated Deprecated in v5.x
124
+ * Style for the subtitle.
125
+ */
126
+ subtitleStyle: StyleProp,
127
+ /**
128
+ * Function to execute on press.
129
+ */
130
+ onPress : PropTypes.func,
131
+ style : StyleProp
132
+ }