@fto-consult/expo-ui 5.8.10 → 5.8.11

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": "5.8.10",
3
+ "version": "5.8.11",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,9 +3,10 @@ import KeyboardEventHandler from "../KeyboardEventHandler";
3
3
  const {getActions,getFormFields,Forms} = require("../utils")
4
4
  import TextField,{parseDecimal} from "$ecomponents/TextField";
5
5
  import Icon from "$ecomponents/Icon";
6
- import {extendObj,isBool,isUndefined,uniqid,isValidDataFileName,defaultObj,isObj,defaultFunc,isFunction,isNumber,arrayValueExists,defaultVal,defaultStr,isNonNullString,defaultBool,defaultDecimal} from "$cutils";
6
+ import {extendObj,isBool,isUndefined,uniqid,isValidDataFileName,isValidEmail,defaultObj,isObj,defaultFunc,isFunction,isNumber,arrayValueExists,defaultVal,defaultStr,isNonNullString,defaultBool,defaultDecimal} from "$cutils";
7
7
  import {Component as AppComponent} from "$react";
8
8
  import {observable,addObserver} from "$observable";
9
+ import {isValidPhoneNumber} from "$ecomponents/PhoneInput";
9
10
  import {Validator} from "$validator";
10
11
  import theme,{grid} from "$theme";
11
12
  import React from "$react";
@@ -285,11 +286,23 @@ export default class Field extends AppComponent {
285
286
  });
286
287
  }
287
288
  onValidatorValid(args){
288
- if(!this.isFilter() && ((this.props.allowWhiteSpaces === false) || ((this.type ==='id' || this.type =='piece') && this.props.allowWhiteSpaces !== true))){
289
- const value = isNonNullString(args.value) && args.value.replaceAll("/","").replaceAll("\\",'') || undefined;
290
-
291
- if(value && this.type !=='email' && !defaultStr(this.getValidRule()).toLowerCase().contains('email') && (value.contains(" ") || !isValidDataFileName(value.replaceAll("@","")))){
292
- return "Veuillez renseigner une valeur ne contenant pas d'espace ou de caractère accentués";
289
+ if(!this.isFilter()){
290
+ const vRule =defaultStr(this.getValidRule()).toLowerCase();
291
+ const value = typeof args.value == "undefined" || args.value == null ? "" : String(args.value).replaceAll("/","").replaceAll("\\",'').trim();
292
+ if(value){
293
+ if(this.type ==='email' || vRule.contains('email')){
294
+ if(!isValidEmail(value)){
295
+ return "Veuillez saisir une addresse email valide";
296
+ }
297
+ } else if(this.type ==="tel" || this.type =="phone"){
298
+ if(!isValidPhoneNumber(value)){
299
+ return "Merci d'entrer un numéro de téléphone valide";
300
+ }
301
+ } else if(((this.props.allowWhiteSpaces === false) || ((this.type ==='id' || this.type =='piece') && this.props.allowWhiteSpaces !== true))){
302
+ if((value.contains(" ") || !isValidDataFileName(value.replaceAll("@","").replaceAll(".","")))){
303
+ return "Veuillez renseigner une valeur ne contenant pas d'espace ou de caractère accentués";
304
+ }
305
+ }
293
306
  }
294
307
  }
295
308
  if(isFunction(this.props.onValidatorValid)){
@@ -33,7 +33,8 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,bindUpsert2Remo
33
33
  }
34
34
  convertFiltersToSQL = defaultVal(convertFiltersToSQL,willConvertFiltersToSQL());
35
35
  getForeignKeyTable = getForeignKeyTable || appConfig.getTableData;
36
- let fKeyTable = typeof getForeignKeyTable =='function' ? getForeignKeyTable(foreignKeyTable,props) : undefined;
36
+ const foreignKeyTableStr = defaultStr(foreignKeyTable,props.table,props.tableName);
37
+ let fKeyTable = typeof getForeignKeyTable =='function' ? getForeignKeyTable(foreignKeyTableStr,props) : undefined;
37
38
  fetchItemsPath = defaultStr(fetchItemsPath).trim();
38
39
 
39
40
  if(!fetchItemsPath && (!isObj(fKeyTable) || !(defaultStr(fKeyTable.tableName,fKeyTable.table)))){
@@ -67,8 +68,8 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,bindUpsert2Remo
67
68
  const defaultFields = Array.isArray(foreignKeyColumn)? foreignKeyColumn : [foreignKeyColumn];
68
69
  if(Array.isArray(foreignKeyLabel)){
69
70
  foreignKeyLabel.map(f=>{
70
- if(isNonNullString(f)){
71
- defaultFields.push(f);
71
+ if(isNonNullString(f) && !defaultFields.includes(f.trim())){
72
+ defaultFields.push(f.trim());
72
73
  }
73
74
  })
74
75
  }
@@ -94,6 +94,9 @@ export default class FormDataComponent extends AppComponent{
94
94
  savedArgs = {...savedArgs,data}
95
95
  }
96
96
  }
97
+ if(typeof saveDataMutator =='function'){
98
+ saveDataMutator(savedArgs);
99
+ }
97
100
  return handleBeforeSaveCallback(this.beforeSave.bind(this),()=>{
98
101
  return handleBeforeSaveCallback(beforeSave,()=>{
99
102
  return handleBeforeSaveCallback(this.onSave.bind(this),()=>{
@@ -5,7 +5,7 @@ import {defaultObj,defaultVal} from "$cutils";
5
5
  import {isMobileMedia} from "$cplatform/dimensions";
6
6
  import TextFieldComponent from "$ecomponents/TextField";
7
7
  import { StyleSheet } from "react-native";
8
-
8
+ import {METRICS_UNITS,WEIGHTS_UNITS} from "./utils";
9
9
 
10
10
  export {Select};
11
11
 
@@ -45,7 +45,7 @@ export const MetricUnit = React.forwardRef((props,ref)=>{
45
45
  inputProps.style = [styles.metricUnit,inputProps.style];
46
46
  rest = defaultObj(rest);
47
47
  return <Select
48
- items = {PRODUCTS_CONSTANTS.METRICS_UNITS}
48
+ items = {METRICS_UNITS}
49
49
  withCheckedIcon = {isMob}
50
50
  {...rest}
51
51
  inputProps = {inputProps}
@@ -67,7 +67,7 @@ export const WeightUnit = React.forwardRef((props,ref)=>{
67
67
  inputProps.style = [styles.weightUnit,inputProps.style];
68
68
  rest = defaultObj(rest);
69
69
  return <Select
70
- items = {PRODUCTS_CONSTANTS.WEIGHTS_UNITS}
70
+ items = {WEIGHTS_UNITS}
71
71
  renderItem = {({item,index})=>index}
72
72
  withCheckedIcon = {isMob}
73
73
  {...rest}
@@ -102,7 +102,7 @@ export const TextField = TextInput;
102
102
  WeightUnit.displayName = "WeightUnitInlineIndicatorComponent";
103
103
 
104
104
  export const Text = React.forwardRef((props,ref)=>{
105
- return <LabelComponent.withRef ref={ref} {...props} {...state} style={[styles.text,props.style]}/>
105
+ return <LabelComponent.withRef ref={ref} {...props} style={[styles.text,props.style]}/>
106
106
  });
107
107
 
108
108
  export const Label = Text;
@@ -0,0 +1,15 @@
1
+ export const WEIGHTS_UNITS = {
2
+ t : 'Tonne',
3
+ kg : 'Kilogramme',
4
+ g : 'Gramme',
5
+ mg : 'Milligramme',
6
+ cg : 'Centigramme',
7
+ dg : 'Decigramme',
8
+ };
9
+
10
+ export const METRICS_UNITS = {
11
+ m : 'm',
12
+ dm : 'dm',
13
+ cm : 'cm',
14
+ mm : 'mm'
15
+ };
@@ -26,6 +26,7 @@ export const isValidNumber = (number,iso2)=>{
26
26
  }
27
27
  return false;
28
28
  }
29
+ export const isValidPhoneNumber = isValidNumber;
29
30
 
30
31
  class PhoneNumber {
31
32
  // eslint-disable-next-line class-methods-use-this
@@ -322,7 +322,7 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
322
322
  paddingHorizontal : 10,
323
323
  paddingVertical:0,
324
324
  height : !isMob?contentContainerHeight:'90%',
325
- width : !isMob ? layout.width : undefined,
325
+ width : !isMob ? Math.max(layout.width,150) : undefined,
326
326
  },
327
327
  isMob && {flex:1},
328
328
  !isMob && {paddingRight : 0},
@@ -33,30 +33,16 @@ export default class FormDataListScreen extends FormData{
33
33
  if(typeof show =='function'){
34
34
  show({...this.props,index:undefined,data:{}});
35
35
  }
36
- }
37
- doSave(args){
38
-
39
36
  }
40
37
  doSave2New(args){
41
- if(!this.__canSaveListData) return;
42
38
  const {show} = this.props;
43
39
  if(typeof show =='function'){
44
40
  show({...args,index:undefined,data:{}});
45
41
  }
46
42
  }
47
43
  doSave2Close(args){
48
- if(!this.__canSaveListData) return;
49
44
  return this.close();
50
45
  }
51
- onSave(args){
52
- let {formDataProps} = this.props;
53
- this.__canSaveListData = true;
54
- formDataProps = defaultObj(formDataProps);
55
- if(typeof formDataProps.onSave =='function' && formDataProps.onSave(args) === false){
56
- this.__canSaveListData = false;
57
- return;
58
- }
59
- }
60
46
  _render(content){
61
47
  let {isAllowed} = this.props;
62
48
  if(typeof isAllowed ==='function'){