@fto-consult/expo-ui 8.82.3 → 8.82.5

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": "8.82.3",
3
+ "version": "8.82.5",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "react-native-paper-doc": "https://github.com/callstack/react-native-paper/tree/main/docs/docs/guides",
6
6
  "scripts": {
@@ -8,7 +8,7 @@ import BackAction from "./BackAction";
8
8
  import {StyleSheet} from "react-native";
9
9
  import {goBack as navGoBack,useNavigation,useRoute,useScreenOptions } from "$cnavigation";
10
10
  import PropTypes from "prop-types";
11
- import {View,Pressable} from "react-native";
11
+ import {Pressable} from "react-native";
12
12
  import Dimensions from "$cdimensions";
13
13
  import Content from "./Content";
14
14
  import Icon from "$ecomponents/Icon";
@@ -11,7 +11,7 @@ import {
11
11
  import { Portal } from 'react-native-paper';
12
12
  import PropTypes from "prop-types";
13
13
  import View from "$ecomponents/View";
14
- import {defaultStr,defaultObj} from "$cutils";
14
+ import {defaultStr,defaultObj,extendObj} from "$cutils";
15
15
  import theme,{Colors} from "$theme";
16
16
  import {isMobileMedia} from "$cplatform/dimensions";
17
17
  import Preloader from "$epreloader";
@@ -20,6 +20,7 @@ import {HStack} from "$ecomponents/Stack";
20
20
  import Divider from "$ecomponents/Divider";
21
21
  import Label from "$ecomponents/Label";
22
22
  import Icon from "$ecomponents/Icon";
23
+ import AppBar from '$ecomponents/AppBar';
23
24
 
24
25
  const MIN_SWIPE_DISTANCE = 3;
25
26
  const DEVICE_WIDTH = Math.max(Dimensions.get('window').width,280);
@@ -127,30 +128,21 @@ export default class DrawerLayout extends React.PureComponent {
127
128
  return defaultStr(this.state.portalProps.testID,"RN_DrawerLayoutPortal");
128
129
  }
129
130
  renderPortalTitle(){
130
- if(React.isValidElement(this.state.portalProps?.title)) return this.state.portalProps?.title;
131
+ const titleProps = defaultObj(this.state.portalProps.titleProps);
132
+ const testID = this.getPortalTestID();
131
133
  const title = this.state.portalProps?.title;
132
134
  const isPositionRight = this.isPositionRight();
133
- if(typeof title == 'string' && title || typeof title =="number"){
134
- const titleProps = defaultObj(this.state.portalProps.titleProps);
135
- const testID = this.getPortalTestID();
136
- const icon = <Icon
137
- onPress = {this.closeDrawer.bind(this)}
138
- icon = {this.state.portalProps?.closeIcon || !this.isPositionRight() == 'left'? 'chevron-left' : 'chevron-right'}
139
- {...defaultObj(this.state.portalProps.closeIconProps)}
140
- />;
141
- const titleContainerProps = defaultObj(this.state.portalProps?.titleContainerProps);
142
- return <>
143
- <HStack testID={testID+"_TitleContainer"} {...titleContainerProps} style={[styles.portalTitle,titleContainerProps.style]}>
144
- {isPositionRight? icon : null}
145
- <Label testID={testID+"_DrawerLayoutTitle"} {...titleProps} style={[styles.portalTitleText,titleProps.style]} >
146
- {title}
147
- </Label>
148
- {!isPositionRight ? icon : null}
149
- </HStack>
150
- <Divider/>
151
- </>;
152
- }
153
- return null;
135
+ const titleContainerProps = defaultObj(this.state.portalProps?.titleContainerProps);
136
+ return <AppBar
137
+ title={React.isValidElement(title) ? title : title || null}
138
+ testID={testID+"_TitleContainer"}
139
+ onBackActionPress={(...args) =>{
140
+ this.closeDrawer();
141
+ return false;
142
+ }}
143
+ {...titleContainerProps}
144
+ backActionProps = {extendObj(true,{},titleContainerProps.backActionProps,{icon:this.state.portalProps?.closeIcon || !isPositionRight == 'left'? 'chevron-left' : 'chevron-right'})}
145
+ />
154
146
  }
155
147
  renderPortalChildren(){
156
148
  return <>
@@ -573,7 +565,7 @@ DrawerLayout.propTypes = {
573
565
  position : posPropType,
574
566
  drawerWidth : PropTypes.number,
575
567
  titleContainerProps : PropTypes.shape({
576
- ...defaultObj(HStack.propTypes),
568
+ ...defaultObj(AppBar.propTypes),
577
569
  }),
578
570
  }),
579
571
  }
@@ -161,7 +161,7 @@ export default function PhoneInputComponent(props){
161
161
  }}
162
162
  testID = {testID}
163
163
  error = {error}
164
- errorText = {errorText}
164
+ errorText = {state.errorText || errorText}
165
165
  helperText = {helperText}
166
166
  contentContainerProps = {contentContainerProps}
167
167
  label = {label}
@@ -187,19 +187,18 @@ export default function PhoneInputComponent(props){
187
187
  const {value:nValue} = args;
188
188
  const prevState = state;
189
189
  const nState = updateValue(nValue);
190
+ let value = defaultStr(nState.defaultValue).trim();
191
+ if(value =="+" || value =="("){
192
+ value = "";
193
+ }
194
+ const prevVal = defaultStr(prevState.defaultValue).trim();
195
+ if(prevVal.ltrim(dialCodePrefix) === value.ltrim(dialCodePrefix)) return;
196
+ const canChange = value.length < 5 || PhoneNumber.parse(nState.displayValue,nState.countryCode);
197
+ nState.errorText = canChange ? undefined : "Veuillez entrer un numéro de téléphone valide";
190
198
  setState({...state,...nState});
191
199
  const dialCodePrefix = getDialCodePrefix(prevState.countryDialCode) || getDialCodePrefix(state.countryDialCode);
192
- if(onChange){
193
- let value = defaultStr(nState.defaultValue).trim();
194
- if(value =="+" || value =="("){
195
- value = "";
196
- }
197
- const prevVal = defaultStr(prevState.defaultValue).trim();
198
- if(prevVal.ltrim(dialCodePrefix) === value.ltrim(dialCodePrefix)) return;
199
- const canChange = value.length < 5 || PhoneNumber.parse(nState.displayValue,nState.countryCode);
200
- if(canChange) {
201
- onChange({...nState,value,country:nState.country,displayValue:nState.displayValue,realValue:nState.defaultValue})
202
- }
200
+ if(onChange && canChange){
201
+ onChange({...nState,value,country:nState.country,displayValue:nState.displayValue,realValue:nState.defaultValue});
203
202
  }
204
203
  }}
205
204
  ref = {ref}