@fto-consult/expo-ui 2.40.1 → 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 +1 -1
- package/src/components/Drawer/DrawerItems/index.js +1 -0
- package/src/components/Dropdown/utils.js +1 -1
- package/src/components/Fab/Group.js +2 -2
- package/src/components/SimpleSelect/index.js +23 -35
- package/src/components/Tab/index.js +2 -2
- package/src/components/Table/Cell.js +2 -2
- package/src/components/Table/Header.js +2 -2
- package/src/components/Table/Row.js +2 -2
- package/src/components/Table/index.js +8 -10
- package/src/layouts/DatabaseStatistics/DatabaseStatistic.js +2 -2
- package/src/layouts/Fab/index.js +2 -2
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
|
}
|
|
@@ -170,7 +170,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
|
|
|
170
170
|
backgroundColor = theme.colors.secondary;
|
|
171
171
|
color = theme.colors.secondaryText;
|
|
172
172
|
}
|
|
173
|
-
const actions = React.
|
|
173
|
+
const actions = React.useMemo(()=>{
|
|
174
174
|
if(!open) return []
|
|
175
175
|
const actions = prepareActions === false && Array.isArray(customActions)? customActions : [];
|
|
176
176
|
if((prepareActions !== false || !actions.length)){
|
|
@@ -192,7 +192,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
|
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
return actions;
|
|
195
|
-
},[customActions,prepareActions,open])
|
|
195
|
+
},[customActions,prepareActions,open]);
|
|
196
196
|
|
|
197
197
|
React.useEffect(()=>{
|
|
198
198
|
onMount && onMount(context);
|
|
@@ -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
|
}
|
|
@@ -58,7 +58,7 @@ const TabComponent = React.forwardRef((props,ref)=>{
|
|
|
58
58
|
}
|
|
59
59
|
},[children,activeIndex]);
|
|
60
60
|
testID = defaultStr(testID,"RN_TabComponentComponent");
|
|
61
|
-
const {tabs,contents,childrenProps} = React.
|
|
61
|
+
const {tabs,contents,childrenProps} = React.useMemo(()=>{
|
|
62
62
|
const tabs = [],contents = [],childrenProps=[];
|
|
63
63
|
React.Children.map(children,(child,index)=>{
|
|
64
64
|
if(!isObj(child)) return null;
|
|
@@ -78,7 +78,7 @@ const TabComponent = React.forwardRef((props,ref)=>{
|
|
|
78
78
|
</React.Fragment>)
|
|
79
79
|
})
|
|
80
80
|
return {tabs,contents,childrenProps}
|
|
81
|
-
},[children])
|
|
81
|
+
},[children]);
|
|
82
82
|
return <View {...rest} testID={testID} style={[styles.container,tabItemsProps.style]}>
|
|
83
83
|
<TabItems testID={testID+"_TabItems"} {...tabItemsProps} activeIndex={index} style={[styles.tab,rest.style]} onChange={setActiveIndex}>
|
|
84
84
|
{tabs}
|
|
@@ -7,14 +7,14 @@ import {defaultObj} from "$utils";
|
|
|
7
7
|
import Label from "$ecomponents/Label";
|
|
8
8
|
|
|
9
9
|
function TableCellComponent({cellArgs,rowArgs,children,renderCell,rowIndex,style,...rest}){
|
|
10
|
-
const {content,containerProps} = React.
|
|
10
|
+
const {content,containerProps} = React.useMemo(()=>{
|
|
11
11
|
const rArgs = {...cellArgs,...rowArgs,containerProps : {}};
|
|
12
12
|
const r = typeof renderCell =='function' && renderCell (rArgs) || children;
|
|
13
13
|
return {
|
|
14
14
|
content : typeof r =='string' || typeof r =='number'? <Label children={r}/> : React.isValidElement(r)? r : null,
|
|
15
15
|
containerProps : defaultObj(rArgs.containerProps)
|
|
16
16
|
}
|
|
17
|
-
},[children])
|
|
17
|
+
},[children]);
|
|
18
18
|
return (<View {...containerProps} {...rest} style={[style,containerProps.style]} >
|
|
19
19
|
{content}
|
|
20
20
|
</View>);
|
|
@@ -9,12 +9,12 @@ import React from "$react";
|
|
|
9
9
|
import { View } from "react-native";
|
|
10
10
|
import PropTypes from "prop-types";
|
|
11
11
|
export default function TableHeaderComponent({cells,columns,...rest}){
|
|
12
|
-
const children = React.
|
|
12
|
+
const children = React.useMemo(()=>{
|
|
13
13
|
if(Array.isArray(cells)){
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
16
|
return cells;
|
|
17
|
-
},[cells,columns])
|
|
17
|
+
},[cells,columns]);
|
|
18
18
|
return <View {...rest}>
|
|
19
19
|
{children}
|
|
20
20
|
</View>
|
|
@@ -5,12 +5,12 @@ import React from "$react";
|
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
export default function TableRowComponent({cells,columns,...rest}){
|
|
8
|
-
const children = React.
|
|
8
|
+
const children = React.useMemo(()=>{
|
|
9
9
|
if(Array.isArray(cells)){
|
|
10
10
|
return cells.map((cell,index)=>columns[index]? <React.Fragment key={index}>{cell}</React.Fragment> : null )
|
|
11
11
|
}
|
|
12
12
|
return cells;
|
|
13
|
-
},[cells,columns])
|
|
13
|
+
},[cells,columns]);
|
|
14
14
|
return <View {...rest}>
|
|
15
15
|
{children}
|
|
16
16
|
</View>
|
|
@@ -60,7 +60,7 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
|
|
|
60
60
|
const hasEmptyData = emptyData && React.isValidElement(emptyData);
|
|
61
61
|
const layoutRef = React.useRef({});
|
|
62
62
|
React.useOnRender(onRender);
|
|
63
|
-
const
|
|
63
|
+
const preparedColumns = React.useMemo(()=>{
|
|
64
64
|
const cols = {},headers = {},footers = {},filters = {},vColumnsMapping = [],visibleColumns = [],columnsNames = [];
|
|
65
65
|
let hasFooters = false;
|
|
66
66
|
columnProps = defaultObj(columnProps);
|
|
@@ -129,12 +129,12 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
|
|
|
129
129
|
});
|
|
130
130
|
return {columns:cols,columnsNames,headers,visibleColumns,vColumnsMapping,hasFooters,footers,filters};
|
|
131
131
|
},[columns]);
|
|
132
|
-
const {columns:cols,headers,footers,filters,hasFooters:stateHasFooters,columnsNames,vColumnsMapping,visibleColumns} =
|
|
132
|
+
const {columns:cols,headers,footers,filters,hasFooters:stateHasFooters,columnsNames,vColumnsMapping,visibleColumns} = preparedColumns;
|
|
133
133
|
headerContainerProps = defaultObj(headerContainerProps);
|
|
134
134
|
footerContainerProps = defaultObj(footerContainerProps);
|
|
135
135
|
const dimensions = Dimensions.get("window");
|
|
136
136
|
const maxHWidth = dimensions.width - defaultNumber(layoutRef.current.left,layoutRef.current.x);
|
|
137
|
-
const {fFilters,headersContent,footersContent,totalWidths} = React.
|
|
137
|
+
const {fFilters,headersContent,footersContent,totalWidths} = React.useMemo(()=>{
|
|
138
138
|
const headersContent = [],footersContent = [],fFilters = [];
|
|
139
139
|
let totalWidths = 0;
|
|
140
140
|
visibleColumns.map((i,index)=>{
|
|
@@ -149,13 +149,12 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
|
|
|
149
149
|
});
|
|
150
150
|
|
|
151
151
|
return {headersContent,totalWidths,footersContent,fFilters};
|
|
152
|
-
},[visibleColumns,showFilters,showFooters,layoutRef.current])
|
|
153
|
-
const colString = columnsNames.join(",");
|
|
152
|
+
},[visibleColumns,showFilters,showFooters,layoutRef.current]);
|
|
154
153
|
const prevData = React.usePrevious(data);
|
|
155
|
-
const
|
|
154
|
+
const prevColumns = React.usePrevious(columns);
|
|
156
155
|
const itemsRef = React.useRef(null);
|
|
157
|
-
const
|
|
158
|
-
if(data === prevData &&
|
|
156
|
+
const items = React.useMemo(()=>{
|
|
157
|
+
if(data === prevData && prevColumns == columns && Array.isArray(itemsRef.current)){
|
|
159
158
|
return itemsRef.current;
|
|
160
159
|
}
|
|
161
160
|
const items = [];
|
|
@@ -189,7 +188,7 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
|
|
|
189
188
|
});
|
|
190
189
|
itemsRef.current = items;
|
|
191
190
|
return items;
|
|
192
|
-
},[data,
|
|
191
|
+
},[data,columns]);
|
|
193
192
|
const scrollContentContainerStyle = {flex:1,width:listWidth,minWidth:totalWidths,height:'100%'};
|
|
194
193
|
const scrollEventThrottle = isMobileNative()?200:50;
|
|
195
194
|
const scrollViewFlexGrow = {flexGrow:0};
|
|
@@ -257,7 +256,6 @@ const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRe
|
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
|
-
const items = prepareItems();
|
|
261
259
|
return <View testID= {testID+"_Container"} {...containerProps} onLayout={(e)=>{
|
|
262
260
|
layoutRef.current = e.nativeEvent.layout;
|
|
263
261
|
if(containerProps.onLayout){
|
|
@@ -93,7 +93,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,onRefreshAll
|
|
|
93
93
|
tableName
|
|
94
94
|
})
|
|
95
95
|
};
|
|
96
|
-
const fetchFields = React.
|
|
96
|
+
const fetchFields = React.useMemo(()=>{
|
|
97
97
|
const fetchFields = [];
|
|
98
98
|
Object.map(columns,(field,f)=>{
|
|
99
99
|
const ff = defaultStr(isObj(field) && field.filter !== false? field.field: undefined,f);
|
|
@@ -102,7 +102,7 @@ export default function DatabaseStatisticContainer ({dashboardProps,onRefreshAll
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
return fetchFields;
|
|
105
|
-
},[columns])
|
|
105
|
+
},[columns]);
|
|
106
106
|
const counUpStyle = {fontSize:20,fontWeight:'bold',color:theme.colors.secondaryOnSurface};
|
|
107
107
|
title = React.isValidElement(title,true)?<Label splitText numberOfLines={1} color={theme.colors.primaryOnSurface} style={[{fontSize:15}]}>{title}</Label>: null;
|
|
108
108
|
const titleText = title && React.getTextContent(title) || null;
|
package/src/layouts/Fab/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export * from "./utils";
|
|
|
13
13
|
const FabLayoutComponent = React.forwardRef(({style,screenName,tables,...props},ref)=>{
|
|
14
14
|
const [isLoggedIn,setIsLoggedIn] = React.useState(isAuthLoggedIn());
|
|
15
15
|
const isMounted = React.useIsMounted();
|
|
16
|
-
const actions = React.
|
|
16
|
+
const actions = React.useMemo(()=>{
|
|
17
17
|
if(!isLoggedIn) return null;
|
|
18
18
|
const a = [];
|
|
19
19
|
Object.map(tables,(table,i,index)=>{
|
|
@@ -48,7 +48,7 @@ const FabLayoutComponent = React.forwardRef(({style,screenName,tables,...props},
|
|
|
48
48
|
})
|
|
49
49
|
})
|
|
50
50
|
return a.length ? a : null;
|
|
51
|
-
},[isLoggedIn])
|
|
51
|
+
},[isLoggedIn]);
|
|
52
52
|
React.useEffect(()=>{
|
|
53
53
|
const onLogin = ()=>{
|
|
54
54
|
if(!isMounted())return;
|