@fto-consult/expo-ui 2.41.0 → 2.42.1

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.41.0",
3
+ "version": "2.42.1",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,6 @@ export const canAutoFocusSearchField = ({visible,items})=>{
17
17
  const count = typeof items =='number'? items : typeof (items) === 'object' ? Object.size(items) : 0;
18
18
  if(!visible) return false;
19
19
  const ret = count > MAX_AUTO_FOCUS_ITEMS && true || false;
20
- if(!isNativeMobile() && !isTouchDevice()) return ret;
20
+ if(!isNativeMobile() && !isTouchDevice()) return true;
21
21
  return isNativeMobile()? ret : false;
22
22
  }
@@ -25,27 +25,15 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
25
25
  });
26
26
  const [state,setState] = React.useState({
27
27
  value : defaultValue !== undefined? defaultValue:undefined,
28
- visible : controlled?undefined:false,
28
+ visible : controlled?controlledVisible:false,
29
29
  items : [],
30
30
  });
31
31
  contentContainerProps = defaultObj(contentContainerProps);
32
32
  const prevLayout = React.usePrevious(layout);
33
33
  filter = defaultFunc(filter,x=>true);
34
- const value = state.value,
35
- visible = controlled? controlledVisible : state.visible;
34
+ const {value,visible} = state;
36
35
  compare = defaultFunc(compare,(a,b)=> a === b);
37
36
  const prevValue = React.usePrevious(value,compare);
38
- const setSelected = (node,update)=>{
39
- if(update !== true && compare(value,node.value)) return;
40
- selectedRef.current = node;
41
- if(update === true){
42
- const nState = {...state,value:node.value,visible:controlled?undefined:false};
43
- if(controlled && onDismiss){
44
- if(onDismiss(nState,defaultObj(selectedRef.current)) === false) return;
45
- }
46
- setState(nState);
47
- }
48
- }
49
37
  const selectedRef = React.useRef(undefined);
50
38
  const listRef = React.useRef(null);
51
39
  const isSelected = (itValue,index)=> {
@@ -65,13 +53,11 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
65
53
  renderText = typeof renderText ==='function'? renderText : ({item,content,index})=>{
66
54
  return React.getTextContent(content);
67
55
  }
68
- const prevMenuItems = React.usePrevious(menuItems,stableHash);
69
- const hasInitializedRef = React.useRef(false);
70
- const areItemsEquals = hasInitializedRef.current && prevMenuItems == menuItems;//JSON.stringify(prevMenuItems) == JSON.stringify(menuItems);
71
- const prepareItems = React.useCallback(()=>{
56
+ const menuItemsHash = stableHash(menuItems);
57
+ const items = React.useMemo(()=>{
72
58
  const items = [];
73
59
  selectedRef.current = null;
74
- let currentSelectedValue = value;
60
+ //let currentSelectedValue = value;
75
61
  const isValueDifferent = !compare(defaultValue,value);
76
62
  Object.map(menuItems,(item,index,_index)=>{
77
63
  if(React.isValidElement(item) || !filter({items:menuItems,item,_index,index})) return null;
@@ -98,26 +84,30 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
98
84
  mItem.textContent = React.getTextContent(rText) || React.getTextContent(content);
99
85
  if(isValueDifferent && itValue !== undefined && compare(defaultValue,itValue)){
100
86
  selectedRef.current = mItem;
101
- currentSelectedValue = defaultValue;
102
-
87
+ //currentSelectedValue = defaultValue;
103
88
  } else if(isSelected(itValue,index)){
104
89
  selectedRef.current = mItem;
105
90
  }
106
91
  items.push(mItem);
107
92
  });
108
- hasInitializedRef.current = true;
109
- setState({...state,value:currentSelectedValue,items});
110
- },[stableHash(menuItems)])
111
- const {items} = state;
93
+ return items;
94
+ //return ({...state,value:currentSelectedValue,items});
95
+ },[menuItemsHash])
112
96
  React.useEffect(()=>{
113
- if(compare(defaultValue == value) && areItemsEquals) return;
114
- if(!areItemsEquals){
115
- prepareItems();
116
- } else {
117
- selectValue(defaultValue);
97
+ if(compare(defaultValue == value)) return;
98
+ selectValue(defaultValue);
99
+ },[defaultValue]);
100
+ const setSelected = (node,update)=>{
101
+ if(update !== true && compare(value,node.value)) return;
102
+ selectedRef.current = node;
103
+ if(update === true){
104
+ const nState = {...state,value:node.value,visible:controlled?undefined:false};
105
+ if(controlled && onDismiss){
106
+ if(onDismiss(nState,defaultObj(selectedRef.current)) === false) return;
107
+ }
108
+ setState(nState);
118
109
  }
119
- },[menuItems,defaultValue]);
120
-
110
+ }
121
111
  const context = {};
122
112
  const selectValue = context.selectValue = context.setValue = (defaultValue)=>{
123
113
  if(compare(defaultValue,value)) return;
@@ -133,7 +123,6 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
133
123
  }
134
124
  }
135
125
  context.getValue = ()=> value;
136
-
137
126
  React.useEffect(()=>{
138
127
  if(compare(value,prevValue)) return;
139
128
  if(onChange){
@@ -178,9 +167,8 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
178
167
  }
179
168
  context.disabled = !isEditable;
180
169
  context.enabled = isEditable;
181
-
170
+ React.setRef(ref,context);
182
171
  React.useEffect(()=>{
183
- React.setRef(ref,context);
184
172
  if(onMount ==='function'){
185
173
  onMount({context})
186
174
  }
@@ -338,7 +338,7 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
338
338
  numberOfLines = {1}
339
339
  responsive = {false}
340
340
  testID = {testID}
341
- preparedItems = {false}
341
+ prepareItems = {false}
342
342
  items = {items}
343
343
  contentContainerStyle = {[styles.contentContainer,{with:listWidth,minWidth:totalWidths,position:'absolute',right:'0'}]}
344
344
  style = {[styles.datagrid,{width:listWidth,minWidth:totalWidths}]}
@@ -2,7 +2,7 @@
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
4
  import {navigate,sanitizeName} from "$cnavigation";
5
- import {isNonNullString,defaultObj,isObj} from "$utils";
5
+ import {isNonNullString,defaultStr,defaultObj,isObj} from "$utils";
6
6
  export const tableDataRouteName = 'TableData';
7
7
 
8
8
  export const navigateToTableData = function(tableName,params,actionType){
@@ -33,6 +33,9 @@ export const navigateToTableData = function(tableName,params,actionType){
33
33
  }
34
34
 
35
35
  export const buildScreenRoute = function(tableName,parent){
36
+ if(isObj(tableName)){
37
+ tableName = defaultStr(tableName.tableName,tableName.table);
38
+ }
36
39
  if(!isNonNullString(tableName)) return undefined;
37
40
  parent = defaultStr(parent,tableDataRouteName);
38
41
  if(parent){
@@ -45,11 +48,15 @@ export const getTableDataRouteName = function(tableName){
45
48
  return buildScreenRoute(tableName,tableDataRouteName);
46
49
  }
47
50
 
51
+ export const getTableDataScreenName = getTableDataRouteName;
52
+
48
53
  /*** permet d'obtenir le lien vers l'écran table data permettant de lister les données de la table data */
49
54
  export const getTableDataListRouteName = function(tableName){
50
55
  return buildScreenRoute(tableName,tableDataRouteName+"/LIST/");
51
56
  }
52
57
 
58
+ export const getTableDataListScreenName = getTableDataListRouteName;
59
+
53
60
  export const navigateToTableDataList = function (tableName,params){
54
61
  const route = getTableDataListRouteName(tableName);
55
62
  if(isNonNullString(route)){