@fto-consult/expo-ui 2.10.3 → 2.10.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": "2.10.3",
3
+ "version": "2.10.5",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -65,7 +65,7 @@
65
65
  "@expo/metro-config": "^0.4.0",
66
66
  "@expo/vector-icons": "^13.0.0",
67
67
  "@expo/webpack-config": "^0.17.2",
68
- "@fto-consult/common": "^1.19.2",
68
+ "@fto-consult/common": "^1.19.5",
69
69
  "@fto-consult/expo-ui": "^2.9.2",
70
70
  "@gorhom/portal": "^1.0.14",
71
71
  "@react-native-async-storage/async-storage": "~1.17.3",
@@ -952,6 +952,8 @@ export default class CommonDatagridComponent extends AppComponent {
952
952
  width = Math.max(width,mWidth);
953
953
  } else if((type.contains("number") || type.contains("decimal") && this.props.format)){
954
954
  width = Math.max(width,DATE_COLUMN_WIDTH-30);
955
+ } else if(type == "tel"){
956
+ width = Math.max(width,DATE_COLUMN_WIDTH)
955
957
  }
956
958
  totalWidths +=width;
957
959
  widths[header.field] = width;
@@ -1098,7 +1100,6 @@ export default class CommonDatagridComponent extends AppComponent {
1098
1100
  });
1099
1101
  data = newData;
1100
1102
  }
1101
- const beforeS = data;
1102
1103
  if(this.isDatagrid() && isNonNullString(this._sort.column)){
1103
1104
  if(isObj(this.state.columns) && this.state.columns[this._sort.column]){
1104
1105
  let field = this.state.columns[this._sort.column];
@@ -1505,7 +1506,7 @@ export default class CommonDatagridComponent extends AppComponent {
1505
1506
  }
1506
1507
  UNSAFE_componentWillReceiveProps(nextProps){
1507
1508
  if(!isObjOrArray(nextProps.data) || nextProps.data == this.props.data || stableHash(nextProps.data) == stableHash(this.props.data)) return;
1508
- this.prepareData({data:nextProps.data,force:true},(state)=>{
1509
+ this.prepareData({...nextProps,force:true},(state)=>{
1509
1510
  this.setState(state)
1510
1511
  });
1511
1512
  }
@@ -177,6 +177,7 @@ export default class Filter extends AppComponent {
177
177
  }
178
178
  const prev = JSON.stringify(defaultObj(this.previousRef.current)), current = {value,operator,action,ignoreCase};
179
179
  let tV = isArray(value) && value.length <= 0 ? undefined : value;
180
+
180
181
  this.isInitializedRef.current = this.props.dynamicRendered || this.isInitializedRef.current;
181
182
  if(prev == "{}" && (isNullOrEmpty(tV) || value === 0) && (!this.isInitializedRef.current) && (force !== true)) {
182
183
  return this;
@@ -203,7 +204,10 @@ export default class Filter extends AppComponent {
203
204
  value = f(value);
204
205
  }
205
206
  if(isNonNullString(value) && this.state.ignoreCase){
206
- value = RegExp(value.ltrim("/").rtrim("/"),'i');
207
+ try {
208
+ const v = RegExp(value.ltrim("/").rtrim("/"),'i');
209
+ value = v;
210
+ } catch{}
207
211
  }
208
212
  action = "$regex";
209
213
  }
@@ -771,6 +771,7 @@ export default class Field extends AppComponent {
771
771
  usePlaceholderWhenEmpty,
772
772
  width,
773
773
  height,
774
+ jsType,
774
775
  ...rest
775
776
  } = this.props;
776
777
  if(this.state.caughtAnError){
@@ -863,7 +864,7 @@ export default class Field extends AppComponent {
863
864
  delete rest.archivable;
864
865
 
865
866
  this.___formattedField = undefined;
866
- let _type = this.type = defaultStr(this.props.jsType,this.props.type,this.type,"text").trim().toLowerCase();
867
+ let _type = this.type = defaultStr(jsType,this.props.type,this.type,"text").trim().toLowerCase();
867
868
  format = defaultStr(format).toLowerCase().trim();
868
869
  tooltip = defaultVal(tooltip,title);
869
870
 
@@ -2,6 +2,7 @@ import {defaultStr,defaultObj,defaultVal,isObj} from "$utils";
2
2
  import Fields from "../Fields";
3
3
  //import dataFileManager from "$dataFileManager";
4
4
  import i18n from "$i18n";
5
+ import React from "$react";
5
6
 
6
7
  const componentTypes = {
7
8
  ...Fields,
@@ -58,11 +59,12 @@ export const getFilterComponentProps = (_props)=>{
58
59
  check,
59
60
  width,
60
61
  type,
62
+ jsType,
61
63
  ...props
62
64
  } = _props;
63
65
  props = defaultObj(props);
64
66
  let component = Fields.TextField;
65
- type = defaultStr(type,'text').toLowerCase().replaceAll("_","").replaceAll("-","").trim();
67
+ type = defaultStr(jsType,type,'text').toLowerCase().replaceAll("_","").replaceAll("-","").trim();
66
68
  props = defaultObj(props);
67
69
  /*if(type =='datafile'){
68
70
  type = 'select';
@@ -88,8 +90,8 @@ export const getFilterComponentProps = (_props)=>{
88
90
  } else if(type == 'switch' || type =='radio' || type ==='checkbox') {
89
91
  type = 'select';
90
92
  let {checkedLabel,checkedTooltip,uncheckedTooltip,checkedValue,uncheckedLabel,uncheckedValue,label,text,...pR} = props;
91
- checkedLabel = defaultVal(checkedLabel,checkedTooltip,'Désactivé/Désélectionné')
92
- uncheckedLabel = defaultVal(uncheckedLabel,uncheckedTooltip,'Activé/Sélectionné')
93
+ checkedLabel = defaultVal(checkedLabel,checkedTooltip,'Inactif/Désélectionné')
94
+ uncheckedLabel = defaultVal(uncheckedLabel,uncheckedTooltip,'Actif/Sélectionné')
93
95
  checkedValue = defaultVal(checkedValue,1); uncheckedValue = defaultVal(uncheckedValue,0)
94
96
  props = pR;
95
97
  props.items = [{code:checkedValue,label:checkedLabel},{code:uncheckedValue,label:uncheckedLabel}];
@@ -98,7 +100,9 @@ export const getFilterComponentProps = (_props)=>{
98
100
  component = type == 'datetime' ? Fields.DateTime : type === 'date'? Fields.Date : Fields.Time;
99
101
  } else if(type == 'color' || type =='colorpicker') {
100
102
  component = Fields.ColorPicker;
101
- } else {
103
+ } else if(React.isComponent(componentTypes[type])) {
104
+ component = componentTypes[type];
105
+ }else {
102
106
  delete props.dbName;
103
107
  delete props.tableName;
104
108
  props.label = label;
@@ -9,7 +9,6 @@ import Icon from "$ecomponents/Icon";
9
9
  import PhoneNumber from "./PhoneNumber";
10
10
  import SelectCountry from "$ecomponents/Countries/SelectCountry";
11
11
  import {getFlag} from "$ecomponents/Countries";
12
- import View from "$ecomponents/View";
13
12
 
14
13
  import libPhoneNumber from 'google-libphonenumber';
15
14
  const asYouTypeFormatter = libPhoneNumber.AsYouTypeFormatter;
@@ -19,20 +19,18 @@ import stableHash from "stable-hash";
19
19
  const SimpleSelect = React.forwardRef((props,ref)=>{
20
20
  let {style : customStyle,onMount,mode,showSearch,anchorContainerProps,renderText,contentContainerProps,withCheckedIcon,testID,selectionColor,dialogProps,onShow,anchor,onUnmont,controlled,onDismiss,visible:controlledVisible,selectedColor,inputProps,itemProps,itemContainerProps,label,listProps,editable,readOnly,text,filter,renderItem,itemValue,getItemValue,defaultValue,items:menuItems,onPress,onChange,disabled,...rest} = props;
21
21
  const flattenStyle = StyleSheet.flatten(customStyle) || {};
22
+ const [layout,setLayout] = React.useState({
23
+ height: 0,
24
+ width: 0,
25
+ });
22
26
  const [state,setState] = React.useState({
23
27
  value : defaultValue !== undefined? defaultValue:undefined,
24
28
  visible : controlled?undefined:false,
25
29
  items : [],
26
- layout : {
27
- height: 0,
28
- width: 0,
29
- },
30
30
  });
31
31
  contentContainerProps = defaultObj(contentContainerProps);
32
- const inputLayout = state.layout;
33
- const prevLayout = React.usePrevious(inputLayout);
32
+ const prevLayout = React.usePrevious(layout);
34
33
  filter = defaultFunc(filter,x=>true);
35
- const {items} = state;
36
34
  const value = state.value,
37
35
  visible = controlled? controlledVisible : state.visible;
38
36
  compare = defaultFunc(compare,(a,b)=> a === b);
@@ -68,7 +66,8 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
68
66
  return React.getTextContent(content);
69
67
  }
70
68
  const prevMenuItems = React.usePrevious(menuItems,stableHash);
71
- const areItemsEquals = prevMenuItems == menuItems;//JSON.stringify(prevMenuItems) == JSON.stringify(menuItems);
69
+ const hasInitializedRef = React.useRef(false);
70
+ const areItemsEquals = hasInitializedRef.current && prevMenuItems == menuItems;//JSON.stringify(prevMenuItems) == JSON.stringify(menuItems);
72
71
  const prepareItems = React.useCallback(()=>{
73
72
  const items = [];
74
73
  selectedRef.current = null;
@@ -96,7 +95,7 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
96
95
  if(isDecimal(content)) content+="";
97
96
  if(!React.isValidElement(content,true)) return null;
98
97
  mItem.content = content;
99
- mItem.textContent = rText;
98
+ mItem.textContent = React.getTextContent(rText) || React.getTextContent(content);
100
99
  if(isValueDifferent && itValue !== undefined && compare(defaultValue,itValue)){
101
100
  selectedRef.current = mItem;
102
101
  currentSelectedValue = defaultValue;
@@ -106,8 +105,10 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
106
105
  }
107
106
  items.push(mItem);
108
107
  });
108
+ hasInitializedRef.current = true;
109
109
  setState({...state,value:currentSelectedValue,items});
110
110
  },[stableHash(menuItems)])
111
+ const {items} = state;
111
112
  React.useEffect(()=>{
112
113
  if(compare(defaultValue == value) && areItemsEquals) return;
113
114
  if(!areItemsEquals){
@@ -199,22 +200,17 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
199
200
  itemContainerProps = defaultObj(itemContainerProps);
200
201
  const onLayout = (event) => {
201
202
  const layout = event.nativeEvent.layout;
202
- if(prevIsMob === isMob && layout.height == prevLayout.height && layout.width == prevLayout.width) return;
203
+ if(prevIsMob === isMob && Math.abs(layout.height - prevLayout.height) <=50 && Math.abs(layout.width == prevLayout.width)<=50) return;
203
204
  const isDiff = prevIsMob !== isMob;
204
- const nState = {
205
- ...state,
206
- layout,
207
- //visible : controlled ? undefined : isDiff ? false : visible
208
- };
209
- setState(nState);
205
+ setLayout(layout);
210
206
  if(controlled && onDismiss){
211
207
  if(isDiff){
212
- onDismiss(nState,true);
208
+ onDismiss(state,true);
213
209
  }
214
210
  }
215
211
  };
216
212
  const dimensions = Dimensions.get("window");// useWindowDimensions();
217
- let contentContainerHeight = dimensions.height - defaultDecimal(inputLayout?.top) - defaultDecimal(inputLayout?.height)-20;
213
+ let contentContainerHeight = dimensions.height - defaultDecimal(layout?.top) - defaultDecimal(layout?.height)-20;
218
214
  contentContainerHeight = Math.max(contentContainerHeight,200);
219
215
  let marginTop = 0;
220
216
  const Component = isMob ? Dialog : Menu;
@@ -341,7 +337,7 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
341
337
  paddingHorizontal : 10,
342
338
  paddingVertical:0,
343
339
  height : !isMob?contentContainerHeight:'90%',
344
- width : !isMob ? inputLayout.width : undefined,
340
+ width : !isMob ? layout.width : undefined,
345
341
  },
346
342
  isMob && {flex:1},
347
343
  !isMob && {paddingRight : 0},