@fto-consult/expo-ui 8.83.1 → 8.83.3
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.83.
|
3
|
+
"version": "8.83.3",
|
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": {
|
@@ -70,7 +70,7 @@
|
|
70
70
|
"dependencies": {
|
71
71
|
"@emotion/react": "^11.11.1",
|
72
72
|
"@faker-js/faker": "^8.0.2",
|
73
|
-
"@fto-consult/common": "^4.
|
73
|
+
"@fto-consult/common": "^4.52.0",
|
74
74
|
"@fto-consult/expo-ui": "^8.73.1",
|
75
75
|
"apexcharts": "^3.49.0",
|
76
76
|
"file-saver": "^2.0.5",
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from "$react";
|
2
|
-
import {defaultObj,
|
2
|
+
import {defaultObj,defaultStr,debounce,extendObj,defaultVal,defaultFunc} from "$cutils";
|
3
3
|
import {compare as compareUtil} from "$cutils";
|
4
4
|
import TextField,{flatMode} from "$ecomponents/TextField";
|
5
5
|
import {Pressable,Dimensions,StyleSheet} from "react-native";
|
@@ -16,6 +16,8 @@ import {isDesktopMedia} from "$cplatform/dimensions";
|
|
16
16
|
import { matchOperators,getSearchTimeout,canAutoFocusSearchField} from "$ecomponents/Dropdown/utils";
|
17
17
|
import Dialog from "$ecomponents/Dialog";
|
18
18
|
|
19
|
+
const isValidValue =(value)=> typeof value === "string" || typeof value === "number" || typeof value =="boolean" || isObj(value) || Array.isArray(value);
|
20
|
+
|
19
21
|
const SimpleSelect = React.forwardRef((props,ref)=>{
|
20
22
|
let {style : customStyle,onMount,mode,showSearch,anchorContainerProps,renderText,contentContainerProps,withCheckedIcon,testID,selectionColor,dialogProps,onShow,anchor,onUnmont,controlled:cr,onDismiss,visible:controlledVisible,selectedColor,inputProps,itemProps,itemContainerProps,label,listProps,readOnly,text,filter,renderItem,itemValue,getItemValue,defaultValue,items:menuItems,onPress,onChange,disabled,...rest} = props;
|
21
23
|
const flattenStyle = StyleSheet.flatten(customStyle) || {};
|
@@ -42,8 +44,8 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
42
44
|
return index;
|
43
45
|
}
|
44
46
|
if(isObj(item)) {
|
45
|
-
if(isNonNullString(item._id)) return item._id;
|
46
|
-
if(isNonNullString(item.code)) return item.code;
|
47
|
+
if(isNonNullString(item._id) || typeof item._id =="number") return item._id;
|
48
|
+
if(isNonNullString(item.code) || typeof item.code =="number") return item.code;
|
47
49
|
return index;
|
48
50
|
}
|
49
51
|
return index;
|
@@ -58,16 +60,16 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
58
60
|
const isValueDifferent = !compare(defaultValue,value);
|
59
61
|
Object.map(menuItems,(item,index,_index)=>{
|
60
62
|
if(React.isValidElement(item) || !filter({items:menuItems,item,_index,index})) return null;
|
61
|
-
const backupItem = item;
|
62
63
|
if(!isObj(item)) {
|
63
|
-
if(
|
64
|
-
item = {label:item
|
64
|
+
if(isValidValue(item)){
|
65
|
+
item = {label:String(item),code:item};
|
65
66
|
} else return null;
|
66
67
|
}
|
68
|
+
const backupItem = item;
|
67
69
|
const {code,label,text} = item;
|
68
70
|
let itValue = itemValue({item:backupItem,index,_index});
|
69
71
|
if(itValue === undefined){
|
70
|
-
itValue =
|
72
|
+
itValue = isValidValue(code)? code : index;
|
71
73
|
}
|
72
74
|
const mItem = {item:backupItem,value:itValue,index,_index};
|
73
75
|
let content = renderItem ? renderItem({item:backupItem,index,_index,value:itValue}) : defaultVal(label,text,code);
|
@@ -75,8 +77,11 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
75
77
|
if(!content && typeof content != "number"){
|
76
78
|
content = rText;
|
77
79
|
}
|
78
|
-
if(
|
79
|
-
if(!React.isValidElement(content,true))
|
80
|
+
if(typeof content !="string") content = String(content);
|
81
|
+
if(!React.isValidElement(content,true)) {
|
82
|
+
console.warn("Simple select, invalid meuitem content: ",content,mItem,props);
|
83
|
+
return null;
|
84
|
+
}
|
80
85
|
mItem.content = content;
|
81
86
|
mItem.textContent = React.getTextContent(rText) || React.getTextContent(content);
|
82
87
|
if(isValueDifferent && itValue !== undefined && compare(defaultValue,itValue)){
|
@@ -88,9 +93,11 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
88
93
|
items.push(mItem);
|
89
94
|
});
|
90
95
|
return items;
|
91
|
-
},[menuItems])
|
96
|
+
},[menuItems,defaultValue,value]);
|
92
97
|
React.useEffect(()=>{
|
93
|
-
if(compare(defaultValue,value))
|
98
|
+
if(compare(defaultValue,value)) {
|
99
|
+
return;
|
100
|
+
}
|
94
101
|
selectValue(defaultValue);
|
95
102
|
},[defaultValue]);
|
96
103
|
const setSelected = (node,update)=>{
|