@fto-consult/expo-ui 2.41.0 → 2.42.0
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
|
@@ -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
|
|
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?
|
|
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
|
|
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
|
|
69
|
-
const
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
},[
|
|
111
|
-
const {items} = state;
|
|
93
|
+
return items;
|
|
94
|
+
//return ({...state,value:currentSelectedValue,items});
|
|
95
|
+
},[menuItemsHash])
|
|
112
96
|
React.useEffect(()=>{
|
|
113
|
-
if(compare(defaultValue == value)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
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}]}
|