@fto-consult/expo-ui 5.7.9 → 5.7.10
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
|
@@ -66,10 +66,10 @@ export default function PhoneInputComponent(props){
|
|
|
66
66
|
contentContainerProps.style = [styles.inputContainer,contentContainerProps.style];
|
|
67
67
|
const ref = React.useRef(null);
|
|
68
68
|
const [state,setState] = React.useState({
|
|
69
|
-
visible : false,
|
|
70
69
|
...prepareState({defaultValue,country})
|
|
71
|
-
})
|
|
72
|
-
const
|
|
70
|
+
});
|
|
71
|
+
const [visible,setVisible] = React.useState(false);
|
|
72
|
+
const prevVisible = React.usePrevious(visible);
|
|
73
73
|
label = defaultVal(label,text);
|
|
74
74
|
React.useEffect(()=>{
|
|
75
75
|
React.setRef(ref,ref.current,setRef);
|
|
@@ -82,8 +82,8 @@ export default function PhoneInputComponent(props){
|
|
|
82
82
|
}
|
|
83
83
|
},[defaultValue,country])
|
|
84
84
|
const onPressFlag = (e)=>{
|
|
85
|
-
if(!
|
|
86
|
-
|
|
85
|
+
if(!visible){
|
|
86
|
+
setVisible(true);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
inputProps = defaultObj(inputProps);
|
|
@@ -131,12 +131,17 @@ export default function PhoneInputComponent(props){
|
|
|
131
131
|
return <SelectCountry
|
|
132
132
|
label = {label}
|
|
133
133
|
controlled = {true}
|
|
134
|
-
visible = {
|
|
134
|
+
visible = {visible}
|
|
135
135
|
defaultValue = {state.country}
|
|
136
136
|
testID = {testID+"_SelectCountry"}
|
|
137
137
|
onDismiss = {({value},force) =>{
|
|
138
|
-
if(force !== true && value === state.country &&
|
|
139
|
-
|
|
138
|
+
if(force !== true && value === state.country && visible == prevVisible) return;
|
|
139
|
+
if(visible){
|
|
140
|
+
setVisible(false);
|
|
141
|
+
}
|
|
142
|
+
}}
|
|
143
|
+
onChange = {({value})=>{
|
|
144
|
+
setState({...state,...prepareState({country:value,defaultValue:state.country==value?state.defaultValue:""})});
|
|
140
145
|
}}
|
|
141
146
|
anchor = {
|
|
142
147
|
<>
|
|
@@ -16,13 +16,15 @@ import { matchOperators,getSearchTimeout,canAutoFocusSearchField} from "$ecompon
|
|
|
16
16
|
import Dialog from "$ecomponents/Dialog";
|
|
17
17
|
|
|
18
18
|
const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
19
|
-
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;
|
|
19
|
+
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,editable,readOnly,text,filter,renderItem,itemValue,getItemValue,defaultValue,items:menuItems,onPress,onChange,disabled,...rest} = props;
|
|
20
20
|
const flattenStyle = StyleSheet.flatten(customStyle) || {};
|
|
21
|
+
const controlledRef = React.useRef(typeof controlledVisible ==='boolean'? true : false);
|
|
22
|
+
const controlled = controlledRef.current;
|
|
21
23
|
const [layout,setLayout] = React.useState({
|
|
22
24
|
height: 0,
|
|
23
25
|
width: 0,
|
|
24
26
|
});
|
|
25
|
-
const [visible,setVisible] = React.useState(controlled?controlledVisible:false)
|
|
27
|
+
const [visible,setVisible] = controlled ? [controlledVisible] : React.useState(controlled?controlledVisible:false);
|
|
26
28
|
const [value,setValue] = React.useState(defaultValue !== undefined? defaultValue:undefined);
|
|
27
29
|
contentContainerProps = defaultObj(contentContainerProps);
|
|
28
30
|
const prevLayout = React.usePrevious(layout);
|
|
@@ -94,13 +96,12 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
|
|
|
94
96
|
if(update !== true && compare(value,node.value)) return;
|
|
95
97
|
selectedRef.current = node;
|
|
96
98
|
if(update === true){
|
|
99
|
+
setValue(node.value);
|
|
97
100
|
if(controlled && onDismiss){
|
|
98
101
|
if(onDismiss({visible,value,items,defaultValue},defaultObj(selectedRef.current)) === false) return;
|
|
99
102
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if(typeof vv =='boolean' && vv !==visible){
|
|
103
|
-
setVisible(vv);
|
|
103
|
+
if(!controlled && visible){
|
|
104
|
+
setVisible(false);
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|