@fto-consult/expo-ui 2.37.7 → 2.38.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/metro.config.js +1 -0
- package/package.json +7 -6
- package/src/components/AutoResizer/index.js +104 -0
- package/src/components/Chart/appexChart/index.native.js +1 -1
- package/src/components/Chart/index.js +2 -1
- package/src/components/Datagrid/Accordion/Filters.js +0 -1
- package/src/components/Datagrid/Accordion/index.js +6 -12
- package/src/components/Datagrid/Common/Common.js +137 -53
- package/src/components/Datagrid/Common/utils.js +4 -1
- package/src/components/Datagrid/IndexComponent.js +1 -4
- package/src/components/Datagrid/SWRDatagrid.js +2 -16
- package/src/components/Datagrid/Table/index.js +10 -39
- package/src/components/Dialog/Dialog.js +0 -1
- package/src/components/Form/FormData/Dialog.js +1 -6
- package/src/components/Form/FormData/FormData.js +1 -2
- package/src/components/Form/FormData/FormDataActions.js +6 -9
- package/src/components/Hashtag/index.js +2 -2
- package/src/components/List/Common.js +0 -1
- package/src/components/Table/AbsoluteScrollView.js +3 -2
- package/src/components/Table/Cell.js +24 -0
- package/src/components/Table/Header.js +25 -0
- package/src/components/Table/List.js +196 -0
- package/src/components/Table/List.native.js +5 -0
- package/src/components/{Datagrid/Common → Table}/ProgressBar.js +0 -0
- package/src/components/Table/Row.js +21 -0
- package/src/components/Table/Test.js +0 -0
- package/src/components/Table/index.js +218 -202
- package/src/layouts/Screen/FormData/FormData.js +6 -15
- package/src/layouts/Screen/FormData/List.js +7 -8
- package/src/layouts/Screen/ScreenWithOrWithoutAuthContainer.js +4 -4
- package/src/layouts/Screen/TableData.js +6 -13
- package/src/media/file-system/utils/write.js +1 -1
- package/src/screens/Auth/Profile.js +2 -3
- package/src/screens/Auth/SignIn.js +1 -3
- package/src/screens/Help/PrivacyPolicy/index.js +1 -3
- package/src/screens/Help/TermsOfUses/index.js +1 -3
- package/src/screens/ScreenWrapper.js +82 -0
- package/src/screens/index.js +10 -68
- package/src/screens/utils.js +2 -0
- package/webpack.config.js +9 -1
- package/src/components/Datagrid/Table/Cell.js +0 -45
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {FlashList} from "$ecomponents/List";
|
|
1
|
+
import {FlashList,BigList,FlatList} from "$ecomponents/List";
|
|
2
2
|
import View from "$ecomponents/View";
|
|
3
3
|
import {defaultObj,defaultStr,debounce,defaultNumber,defaultVal} from "$utils";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
@@ -10,8 +10,10 @@ import { getRowStyle } from "$ecomponents/Datagrid/utils";
|
|
|
10
10
|
import {isMobileNative} from "$cplatform";
|
|
11
11
|
import theme from "$theme";
|
|
12
12
|
import AbsoluteScrollView from "./AbsoluteScrollView";
|
|
13
|
-
import
|
|
14
|
-
|
|
13
|
+
import Cell from "./Cell";
|
|
14
|
+
import Row from "./Row";
|
|
15
|
+
import List from "./List";
|
|
16
|
+
import ProgressBar from "./ProgressBar";
|
|
15
17
|
const isSCrollingRef = React.createRef();
|
|
16
18
|
const scrollLists = (opts,refs)=>{
|
|
17
19
|
refs.map((ref)=>{
|
|
@@ -43,7 +45,7 @@ const getOnScrollCb = (refs,pos,cb2)=>{
|
|
|
43
45
|
return isMobileNative()? cb : debounce(cb,200);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
const TableComponent = React.forwardRef(({containerProps,renderListContent,children,renderEmpty,renderItem,isRowSelected,headerScrollViewProps,footerScrollViewProps,scrollViewProps,showFooters,renderFooterCell,footerCellContainerProps,filterCellContainerProps,headerContainerProps,headerCellContainerProps,headerProps,rowProps:customRowProps,renderCell,cellContainerProps,hasFooters,renderHeaderCell,renderFilterCell,columnProps,getRowKey,columnsWidths,colsWidths,footerContainerProps,showHeaders,showFilters,columns,data,testID,...props},tableRef)=>{
|
|
48
|
+
const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRender,height,progressBar,filter:customFilter,renderListContent,children,renderEmpty,renderItem,isRowSelected,headerScrollViewProps,footerScrollViewProps,scrollViewProps,showFooters,renderFooterCell,footerCellContainerProps,filterCellContainerProps,headerContainerProps,headerCellContainerProps,headerProps,rowProps:customRowProps,renderCell,cellContainerProps,hasFooters,renderHeaderCell,renderFilterCell,columnProps,getRowKey,columnsWidths,colsWidths,footerContainerProps,showHeaders,showFilters,columns,data,testID,...props},tableRef)=>{
|
|
47
49
|
containerProps = defaultObj(containerProps);
|
|
48
50
|
testID = defaultStr(testID,"RN_TableComponent");
|
|
49
51
|
cellContainerProps = defaultObj(cellContainerProps);
|
|
@@ -53,8 +55,13 @@ const TableComponent = React.forwardRef(({containerProps,renderListContent,child
|
|
|
53
55
|
renderCell = typeof renderCell ==="function"? renderCell : undefined;
|
|
54
56
|
const getRowProps = typeof rowProps ==='function'? rowProps : undefined;
|
|
55
57
|
let rowProps = isObj(customRowProps)? customRowProps:{};
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
+
const listRef = React.useRef(null),scrollViewRef = React.useRef(null),headerScrollViewRef = React.useRef(null);
|
|
59
|
+
const emptyData = renderListContent === false ?null : typeof renderEmpty =='function' && !Object.size(data,true)? renderEmpty() : null;
|
|
60
|
+
const hasEmptyData = emptyData && React.isValidElement(emptyData);
|
|
61
|
+
const layoutRef = React.useRef({});
|
|
62
|
+
React.useOnRender(onRender);
|
|
63
|
+
const prepareColumns = React.useCallback(()=>{
|
|
64
|
+
const cols = {},headers = {},footers = {},filters = {},vColumnsMapping = [],visibleColumns = [],columnsNames = [];
|
|
58
65
|
let hasFooters = false;
|
|
59
66
|
columnProps = defaultObj(columnProps);
|
|
60
67
|
let columnIndex = 0;
|
|
@@ -63,104 +70,130 @@ const TableComponent = React.forwardRef(({containerProps,renderListContent,child
|
|
|
63
70
|
footerCellContainerProps = defaultObj(footerCellContainerProps);
|
|
64
71
|
filterCellContainerProps = defaultObj(filterCellContainerProps);
|
|
65
72
|
Object.map(columns,(columnDef,field)=>{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} else if(isObj(colArgs.containerProps)){
|
|
81
|
-
hContainerProps = colArgs.containerProps;
|
|
82
|
-
}
|
|
83
|
-
if(!React.isValidElement(content,true)){
|
|
84
|
-
console.error(content," is not valid element of header ",columnDef," it could not be render on table");
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
headers[columnField] = <View testID={testID+"_HeaderCell_"+columnField} {...headerCellContainerProps} {...hContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,headerCellContainerProps.style,hContainerProps.style,style]}>
|
|
89
|
-
<Label splitText numberOfLines={2} style={[theme.styles.w100,theme.styles.h100,{maxHeight:70}]} textBold primary>{content}</Label>
|
|
90
|
-
</View>;
|
|
91
|
-
if(typeof renderFilterCell =='function'){
|
|
92
|
-
const filterCell = renderFilterCell(colArgs);
|
|
93
|
-
filters[columnField] = <View testID={testID+"_Filter_Cell_"+columnField} {...filterCellContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,styles.filterCell,filterCellContainerProps.style,style]}>
|
|
94
|
-
{React.isValidElement(filterCell)? filterCell : null}
|
|
95
|
-
</View>
|
|
96
|
-
}
|
|
97
|
-
if(typeof renderFooterCell ==='function') {
|
|
98
|
-
const footerProps = {...colArgs,containerProps:{}};
|
|
99
|
-
let cellFooter = renderFooterCell(footerProps);
|
|
100
|
-
let fContainerProps = {};
|
|
101
|
-
if(!React.isValidElement(cellFooter,true) && isObj(cellFooter)){
|
|
102
|
-
fContainerProps = isObj(cellFooter.containerProps)? cellFooter.containerProps : {};
|
|
103
|
-
cellFooter = React.isValidElement(cellFooter.children)? cellFooter.children : React.isValidElement(cellFooter.content)? cellFooter.content : null;
|
|
104
|
-
} else if(isObj(footerProps.containerProps)){
|
|
105
|
-
fContainerProps = footerProps.containerProps;
|
|
73
|
+
if(!isObj(columnDef)) return;
|
|
74
|
+
const columnField = defaultStr(columnDef.field,field);
|
|
75
|
+
let {visible,width,type,...colProps} = columnDef;
|
|
76
|
+
visible = typeof visible =='boolean'? visible : true;
|
|
77
|
+
type = defaultStr(type,"text").toLowerCase().trim();
|
|
78
|
+
colProps = defaultObj(colProps);
|
|
79
|
+
width = defaultDecimal(widths[columnField],width,DEFAULT_COLUMN_WIDTH);
|
|
80
|
+
const style = StyleSheet.flatten([colProps.style,{width}]);
|
|
81
|
+
const colArgs = {width,type,style,columnDef,containerProps:{},columnField,index:columnIndex,columnIndex};
|
|
82
|
+
const content = typeof renderHeaderCell =='function'? renderHeaderCell(colArgs) : defaultVal(columnDef.text,columnDef.label,columnField);
|
|
83
|
+
const hContainerProps = defaultObj(colArgs.containerProps);
|
|
84
|
+
if(!React.isValidElement(content,true)){
|
|
85
|
+
console.error(content," is not valid element of header ",columnDef," it could not be render on table");
|
|
86
|
+
return null;
|
|
106
87
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
88
|
+
headers[columnField] = <View testID={testID+"_HeaderCell_"+columnField} {...headerCellContainerProps} {...hContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,headerCellContainerProps.style,hContainerProps.style,style]}>
|
|
89
|
+
<Label splitText numberOfLines={2} style={[theme.styles.w100,theme.styles.h100,{maxHeight:70}]} textBold primary>{content}</Label>
|
|
90
|
+
</View>;
|
|
91
|
+
if(typeof renderFilterCell =='function'){
|
|
92
|
+
const filterCell = renderFilterCell(colArgs);
|
|
93
|
+
filters[columnField] = <View testID={testID+"_Filter_Cell_"+columnField} {...filterCellContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,styles.filterCell,filterCellContainerProps.style,style]}>
|
|
94
|
+
{React.isValidElement(filterCell)? filterCell : null}
|
|
95
|
+
</View>
|
|
110
96
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
97
|
+
if(typeof renderFooterCell ==='function') {
|
|
98
|
+
const footerProps = {...colArgs,containerProps:{}};
|
|
99
|
+
let cellFooter = renderFooterCell(footerProps);
|
|
100
|
+
let fContainerProps = {};
|
|
101
|
+
if(!React.isValidElement(cellFooter,true) && isObj(cellFooter)){
|
|
102
|
+
fContainerProps = isObj(cellFooter.containerProps)? cellFooter.containerProps : {};
|
|
103
|
+
cellFooter = React.isValidElement(cellFooter.children)? cellFooter.children : React.isValidElement(cellFooter.content)? cellFooter.content : null;
|
|
104
|
+
} else if(isObj(footerProps.containerProps)){
|
|
105
|
+
fContainerProps = footerProps.containerProps;
|
|
106
|
+
}
|
|
107
|
+
cellFooter = React.isValidElement(cellFooter,true)? cellFooter : null;
|
|
108
|
+
if(!hasFooters && cellFooter){
|
|
109
|
+
hasFooters = true;
|
|
110
|
+
}
|
|
111
|
+
footers[columnField] = <View testID={testID+"_Footer_Cell_"+columnField} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,footerCellContainerProps.style,style]}>
|
|
112
|
+
<Label primary children={cellFooter}/>
|
|
113
|
+
</View>
|
|
114
|
+
}
|
|
115
|
+
vColumnsMapping.push(visible);
|
|
116
|
+
if(visible){
|
|
117
|
+
visibleColumns.push(columnField);
|
|
118
|
+
}
|
|
119
|
+
columnsNames.push(columnField);
|
|
115
120
|
cols[columnField] = {
|
|
121
|
+
...columnDef,
|
|
116
122
|
width,
|
|
117
123
|
index : columnIndex,
|
|
118
124
|
field : columnField,
|
|
119
125
|
visible,
|
|
120
126
|
columnField,
|
|
121
|
-
columnDef,
|
|
122
127
|
};
|
|
123
|
-
if(visible){
|
|
124
|
-
visibleColumns.push(columnField);
|
|
125
|
-
}
|
|
126
128
|
columnIndex++;
|
|
127
129
|
});
|
|
128
|
-
return {columns:cols,
|
|
129
|
-
},[columns
|
|
130
|
-
const
|
|
131
|
-
headers : {},
|
|
132
|
-
footers : {},
|
|
133
|
-
hasFooters : false,
|
|
134
|
-
tableRows : [],
|
|
135
|
-
visibleColumns : [],
|
|
136
|
-
});
|
|
137
|
-
const listRef = React.useRef(null),scrollViewRef = React.useRef(null),headerScrollViewRef = React.useRef(null);
|
|
138
|
-
React.useEffect(()=>{
|
|
139
|
-
setState({...state,...prepareState()});
|
|
140
|
-
},[data,columns]);
|
|
141
|
-
const emptyData = renderListContent === false ?null : typeof renderEmpty =='function' && !Object.size(data,true)? renderEmpty() : null;
|
|
142
|
-
const hasEmptyData = emptyData && React.isValidElement(emptyData);
|
|
143
|
-
const {visibleColumns,columns:cols,headers,footers,filters} = state;
|
|
130
|
+
return {columns:cols,columnsNames,headers,visibleColumns,vColumnsMapping,hasFooters,footers,filters};
|
|
131
|
+
},[columns]);
|
|
132
|
+
const {columns:cols,headers,footers,filters,hasFooters:stateHasFooters,columnsNames,vColumnsMapping,visibleColumns} = prepareColumns();
|
|
144
133
|
headerContainerProps = defaultObj(headerContainerProps);
|
|
145
134
|
footerContainerProps = defaultObj(footerContainerProps);
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
135
|
+
const dimensions = Dimensions.get("window");
|
|
136
|
+
const maxHWidth = dimensions.width - defaultNumber(layoutRef.current.left,layoutRef.current.x);
|
|
137
|
+
const {fFilters,headersContent,footersContent,totalWidths} = React.useCallback(()=>{
|
|
138
|
+
const headersContent = [],footersContent = [],fFilters = [];
|
|
139
|
+
let totalWidths = 0;
|
|
140
|
+
visibleColumns.map((i,index)=>{
|
|
141
|
+
headersContent.push(headers[i]);
|
|
142
|
+
totalWidths+=cols[i].width;
|
|
143
|
+
if(showFooters && stateHasFooters){
|
|
144
|
+
footersContent.push(footers[i]);
|
|
145
|
+
}
|
|
146
|
+
if(showFilters && filters[i]){
|
|
147
|
+
fFilters.push(filters[i]);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return {headersContent,totalWidths,footersContent,fFilters};
|
|
152
|
+
},[visibleColumns,showFilters,showFooters,layoutRef.current])();
|
|
153
|
+
const colString = columnsNames.join(",");
|
|
154
|
+
const prevData = React.usePrevious(data);
|
|
155
|
+
const prevColString = React.usePrevious(colString);
|
|
156
|
+
const itemsRef = React.useRef(null);
|
|
157
|
+
const prepareItems = React.useCallback(()=>{
|
|
158
|
+
if(data === prevData && prevColString == colString && Array.isArray(itemsRef.current)){
|
|
159
|
+
return itemsRef.current;
|
|
158
160
|
}
|
|
159
|
-
|
|
161
|
+
const items = [];
|
|
162
|
+
const filter = typeof customFilter =='function'? customFilter : x=>true;
|
|
163
|
+
data.map((item,index)=>{
|
|
164
|
+
const rowIndex = index;
|
|
165
|
+
if(!isObj(item) || filter({item,index,_index:rowIndex}) ===false) return null;
|
|
166
|
+
const rowArgs = {data:item,isTable:true,isAccordion:false,item,row:item,rowData:item,rowIndex,index};
|
|
167
|
+
const rProps = defaultObj(getRowProps ? getRowProps(rowArgs) : {});
|
|
168
|
+
rowArgs.rowProps = rProps;
|
|
169
|
+
rowArgs.rowStyle = rProps.style = StyleSheet.flatten([rowProps.style,getRowStyle(rowArgs),styles.rowNoPadding,rProps.style]);
|
|
170
|
+
if(item.isSectionListHeader){
|
|
171
|
+
rowArgs.isSectionListHeader = true;
|
|
172
|
+
}
|
|
173
|
+
const sItem = typeof renderItem == 'function'? renderItem(rowArgs) : undefined;
|
|
174
|
+
const cells = React.isValidElement(sItem) ? sItem : columnsNames.map((columnField,columnIndex)=>{
|
|
175
|
+
const columnDef = cols[columnField];
|
|
176
|
+
return <Cell
|
|
177
|
+
rowArgs = {rowArgs}
|
|
178
|
+
style = {StyleSheet.flatten([styles.headerItemOrCell,{width:columnDef.width}])}
|
|
179
|
+
//key = {"_Cell_"+columnField+"_"+index}
|
|
180
|
+
cellArgs={{columnIndex,columnDef,columnField:columnField}}
|
|
181
|
+
renderCell = {renderCell}
|
|
182
|
+
rowIndex = {index}
|
|
183
|
+
children = {item[columnField]}
|
|
184
|
+
testID={testID+"_Cell_"+columnField+"_"+index}
|
|
185
|
+
/>
|
|
186
|
+
});
|
|
187
|
+
if(!Array.isArray(cells) && !React.isValidElement(cells)) return null;
|
|
188
|
+
items.push(<Row cells={cells} columns={vColumnsMapping} testID={testID+"_Row_"+index} {...rowProps} {...rProps} style={[styles.row,rProps.style]}/>);
|
|
189
|
+
});
|
|
190
|
+
itemsRef.current = items;
|
|
191
|
+
return items;
|
|
192
|
+
},[data,colString]);
|
|
160
193
|
const scrollContentContainerStyle = {flex:1,width:listWidth,minWidth:totalWidths,height:'100%'};
|
|
161
194
|
const scrollEventThrottle = isMobileNative()?200:50;
|
|
162
195
|
const scrollViewFlexGrow = {flexGrow:0};
|
|
163
|
-
const maxScrollheight =
|
|
196
|
+
const maxScrollheight = footersContent.length && fFilters.length ? 170 : footersContent.length ?120 : fFilters.length ? 140 : 80;
|
|
164
197
|
const allScrollViewProps = {
|
|
165
198
|
scrollEventThrottle,
|
|
166
199
|
horizontal : true,
|
|
@@ -200,20 +233,20 @@ const TableComponent = React.forwardRef(({containerProps,renderListContent,child
|
|
|
200
233
|
get headerScrollViewContext(){return headerScrollViewRef.current},
|
|
201
234
|
}
|
|
202
235
|
const showTableHeaders = showHeaders !== false || showFilters ;
|
|
203
|
-
const hContent = showTableHeaders &&
|
|
204
|
-
{
|
|
236
|
+
const hContent = showTableHeaders && headersContent.length ? <View testID={testID+"_Header"} {...headerContainerProps} style={[styles.header,headerContainerProps.style,footersContent.length]}>
|
|
237
|
+
{headersContent}
|
|
205
238
|
</View> : null,
|
|
206
|
-
fContent = showTableHeaders &&
|
|
207
|
-
{
|
|
239
|
+
fContent = showTableHeaders && footersContent.length ? <View testID={testID+"_Footer"} {...footerContainerProps} style={[styles.header,styles.footers,footerContainerProps.style,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
240
|
+
{footersContent}
|
|
208
241
|
</View> : null,
|
|
209
242
|
filtersContent = fFilters.length ? <View testID={testID+"_Filters"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
210
243
|
{fFilters}
|
|
211
244
|
</View> : null
|
|
212
|
-
|
|
213
245
|
const absoluteScrollViewRefCanScroll = React.useRef(true);
|
|
214
246
|
React.setRef(tableRef,context);
|
|
215
247
|
const cStyle = {width:listWidth}
|
|
216
248
|
const absoluteScrollViewRef = React.useRef(null);
|
|
249
|
+
const absoluteScrollingRef = React.useRef(false);
|
|
217
250
|
const scrollViewLayoutRef = React.useRef({});
|
|
218
251
|
const toggleAbsoluteScrollVisible = ()=>{
|
|
219
252
|
const ref = scrollViewLayoutRef.current;
|
|
@@ -224,15 +257,25 @@ const TableComponent = React.forwardRef(({containerProps,renderListContent,child
|
|
|
224
257
|
}
|
|
225
258
|
}
|
|
226
259
|
}
|
|
227
|
-
|
|
260
|
+
const items = prepareItems();
|
|
261
|
+
return <View testID= {testID+"_Container"} {...containerProps} onLayout={(e)=>{
|
|
262
|
+
layoutRef.current = e.nativeEvent.layout;
|
|
263
|
+
if(containerProps.onLayout){
|
|
264
|
+
containerProps.onLayout(e);
|
|
265
|
+
}
|
|
266
|
+
}} style={[styles.container,{alignItems:'stretch'},containerProps.style]}>
|
|
228
267
|
<RNView style={[cStyle]} testID={testID+"_Headers_ScrollViewContainer"}>
|
|
229
268
|
<ScrollView
|
|
230
269
|
testID={testID+"_HeaderScrollView"}
|
|
231
270
|
{...headerScrollViewProps}
|
|
232
|
-
contentContainerStyle = {[allScrollViewProps.contentContainerStyle,headerScrollViewProps.contentContainerStyle,{
|
|
271
|
+
contentContainerStyle = {[allScrollViewProps.contentContainerStyle,headerScrollViewProps.contentContainerStyle,{flex:1,flexWrap: 'wrap'}]}
|
|
233
272
|
style = {[allScrollViewProps.style,headerScrollViewProps.style,{height:'100%',flex:1,flexWrap:'wrap'}]}
|
|
234
273
|
ref={headerScrollViewRef} horizontal {...allScrollViewProps}
|
|
235
|
-
onScroll = {getOnScrollCb([scrollViewRef,footerScrollViewRef])
|
|
274
|
+
onScroll = {getOnScrollCb([scrollViewRef,footerScrollViewRef],null,(args)=>{
|
|
275
|
+
return;
|
|
276
|
+
const nativeEvent = args.nativeEvent;
|
|
277
|
+
console.log(nativeEvent," is n event");
|
|
278
|
+
})}
|
|
236
279
|
showsHorizontalScrollIndicator
|
|
237
280
|
>
|
|
238
281
|
<View testID={testID+"Header2FootersWrapper"} style={[theme.styles.w100]}>
|
|
@@ -242,119 +285,95 @@ const TableComponent = React.forwardRef(({containerProps,renderListContent,child
|
|
|
242
285
|
</View>
|
|
243
286
|
</ScrollView>
|
|
244
287
|
</RNView>
|
|
245
|
-
{
|
|
246
|
-
hasEmptyData ? <View testID={testID+"_Empty"} style={styles.hasNotData}>
|
|
288
|
+
{hasEmptyData ? <View testID={testID+"_Empty"} style={styles.hasNotData}>
|
|
247
289
|
{emptyData}
|
|
248
|
-
</View> : <ScrollView {...scrollViewProps} scrollEventThrottle = {scrollEventThrottle} horizontal contentContainerStyle={[scrollContentContainerStyle,scrollViewProps.contentContainerStyle]} showsVerticalScrollIndicator={false}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
})}
|
|
255
|
-
onLayout={(args) => {
|
|
256
|
-
const {nativeEvent:{layout}} = args;
|
|
257
|
-
scrollViewLayoutRef.current.layout = layout;
|
|
258
|
-
toggleAbsoluteScrollVisible();
|
|
259
|
-
if(typeof props.onContainerLayout =='function'){
|
|
260
|
-
props.onContainerLayout(args);
|
|
261
|
-
}
|
|
262
|
-
}}
|
|
263
|
-
ref={scrollViewRef}
|
|
264
|
-
testID={testID+"_ScrollView"}
|
|
265
|
-
onContentSizeChange = {(width,height)=>{
|
|
266
|
-
scrollViewLayoutRef.current.content = {width,height};
|
|
267
|
-
toggleAbsoluteScrollVisible();
|
|
268
|
-
}}
|
|
269
|
-
>
|
|
270
|
-
<FlashList
|
|
271
|
-
containerProps = {{style:[cStyle]}}
|
|
272
|
-
estimatedItemSize = {200}
|
|
273
|
-
{...props}
|
|
274
|
-
onContentSizeChange = {(width,height)=>{
|
|
275
|
-
if(props.onContentSizeChange){
|
|
276
|
-
props.onContentSizeChange(width,height);
|
|
290
|
+
</View> : <ScrollView {...scrollViewProps} scrollEventThrottle = {scrollEventThrottle} horizontal contentContainerStyle={[scrollContentContainerStyle,scrollViewProps.contentContainerStyle,{height:'100%'}]} showsVerticalScrollIndicator={false}
|
|
291
|
+
onScroll = {getOnScrollCb([headerScrollViewRef,footerScrollViewRef],null,(args)=>{
|
|
292
|
+
const nativeEvent = args.nativeEvent;
|
|
293
|
+
if(absoluteScrollViewRef.current && absoluteScrollViewRef.current.checkVisibility){
|
|
294
|
+
absoluteScrollViewRef.current.checkVisibility(nativeEvent);
|
|
277
295
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
props.onLayout(args);
|
|
296
|
+
})}
|
|
297
|
+
onLayout={(args) => {
|
|
298
|
+
const {nativeEvent:{layout}} = args;
|
|
299
|
+
scrollViewLayoutRef.current.layout = layout;
|
|
300
|
+
toggleAbsoluteScrollVisible();
|
|
301
|
+
if(typeof props.onContainerLayout =='function'){
|
|
302
|
+
props.onContainerLayout(args);
|
|
286
303
|
}
|
|
287
|
-
if(!absoluteScrollViewRef.current) return;
|
|
288
|
-
const {nativeEvent:{layout}}=args;
|
|
289
|
-
const top = defaultNumber(layout.top,layout.y);
|
|
290
|
-
const height = layout.height;
|
|
291
|
-
absoluteScrollViewRef.current.setStyles({
|
|
292
|
-
container : {top,height},
|
|
293
|
-
contentContainer : {height},
|
|
294
|
-
});
|
|
295
304
|
}}
|
|
296
|
-
ref
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
contentContainerStyle = {[styles.contentContainer,{with:listWidth,minWidth:totalWidths,position:'absolute',right:'0'}]}
|
|
302
|
-
style = {[styles.datagrid,{width:listWidth,minWidth:totalWidths}]}
|
|
303
|
-
keyExtractor = {typeof getRowKey =='function'? getRowKey : React.getKey}
|
|
304
|
-
//stickyHeaderIndices={[0]}
|
|
305
|
-
onScroll = {getOnScrollCb([absoluteScrollViewRef],(args)=>{
|
|
306
|
-
if(!absoluteScrollViewRef.current) return;
|
|
307
|
-
const offset = args?.nativeEvent?.contentOffset.y;
|
|
308
|
-
const scrollViewRef = absoluteScrollViewRef.current?.scrollViewRef;
|
|
309
|
-
if(typeof offset =='number' && scrollViewRef.current && scrollViewRef.current.scrollTo){
|
|
310
|
-
absoluteScrollViewRefCanScroll.current = false;
|
|
311
|
-
scrollViewRef.current.scrollTo({animated:false,y:offset});
|
|
312
|
-
setTimeout(()=>{
|
|
313
|
-
absoluteScrollViewRefCanScroll.current = true;
|
|
314
|
-
},500);
|
|
315
|
-
}
|
|
316
|
-
})}
|
|
317
|
-
renderItem = {(arg)=>{
|
|
318
|
-
const item = arg.item, data = arg.item,allData=Array.isArray(item.items)? item.items : data;
|
|
319
|
-
arg.allData = arg.allData;arg.isTable = true; arg.isAccordion = false;
|
|
320
|
-
arg.columns = visibleColumns;
|
|
321
|
-
const selected = typeof isRowSelected=='function'? isRowSelected(item,arg.index):undefined;
|
|
322
|
-
const rowArgs = {...arg,selected,isTable:true,allData,row:data,rowData:data,rowIndex:arg.index};
|
|
323
|
-
const rProps = getRowProps ? getRowProps(rowArgs) : {};
|
|
324
|
-
const rowStyle = getRowStyle(rowArgs);
|
|
325
|
-
const sItem = typeof renderItem == 'function'? renderItem({...arg,rowProps:rProps,rowStyle}) : undefined;
|
|
326
|
-
const cells = sItem && React.isValidElement(sItem) ? sItem : !isObj(item) ? null : visibleColumns.map((i,index)=>{
|
|
327
|
-
const cellValue = data[i];
|
|
328
|
-
const col = defaultObj(cols[i]);
|
|
329
|
-
const cellArgs = {...col,...arg,containerProps:{},columnIndex:col.index,style:{width:col.width},cellValue,data,rowData:data,row:data,rowIndex:arg.index};
|
|
330
|
-
const cell = renderCell ? renderCell(cellArgs) : cellValue;
|
|
331
|
-
let cContainerProps = {},content = React.isValidElement(cell,true)? <Label children={cell}/> : null;
|
|
332
|
-
if(!content && isObj(cell)){
|
|
333
|
-
content = React.isValidElement(cell.content)? cell.content : React.isValidElement(cell.content)? cell.content : null;
|
|
334
|
-
cContainerProps = isObj(cell.containerProps)? cell.containerProps : {};
|
|
335
|
-
} else if(isObj(cellArgs.containerProps)){
|
|
336
|
-
cContainerProps = cellArgs.containerProps;
|
|
337
|
-
}
|
|
338
|
-
const key = "_Cell_"+i+"_"+arg.index;
|
|
339
|
-
return (<View {...cellContainerProps} {...cContainerProps} key={key} style={[styles.headerItemOrCell,cellContainerProps.style,cContainerProps.style,{width:col.width}]} testID={testID+key}>
|
|
340
|
-
{content}
|
|
341
|
-
</View>);
|
|
342
|
-
});
|
|
343
|
-
return cells ? <View testID={testID+"_Row_"+arg.index} {...rowProps} {...rProps} style={[styles.row,rowProps.style,rowStyle,styles.rowNoPadding,rProps.style]}>
|
|
344
|
-
{cells}
|
|
345
|
-
</View> : null
|
|
305
|
+
ref={scrollViewRef}
|
|
306
|
+
testID={testID+"_ScrollView"}
|
|
307
|
+
onContentSizeChange = {(width,height)=>{
|
|
308
|
+
scrollViewLayoutRef.current.content = {width,height};
|
|
309
|
+
toggleAbsoluteScrollVisible();
|
|
346
310
|
}}
|
|
347
|
-
|
|
311
|
+
>
|
|
312
|
+
{progressBar}
|
|
313
|
+
<List
|
|
314
|
+
containerProps = {{style:[cStyle,listContainerStyle]}}
|
|
315
|
+
estimatedItemSize = {200}
|
|
316
|
+
{...props}
|
|
317
|
+
onContentSizeChange = {(width,height)=>{
|
|
318
|
+
if(props.onContentSizeChange){
|
|
319
|
+
props.onContentSizeChange(width,height);
|
|
320
|
+
}
|
|
321
|
+
if(!absoluteScrollViewRef.current) return;
|
|
322
|
+
absoluteScrollViewRef.current.setStyles({
|
|
323
|
+
content : {height,width}
|
|
324
|
+
});
|
|
325
|
+
}}
|
|
326
|
+
onLayout = {(args)=>{
|
|
327
|
+
if(props.onLayout){
|
|
328
|
+
//props.onLayout(args);
|
|
329
|
+
}
|
|
330
|
+
if(!absoluteScrollViewRef.current) return;
|
|
331
|
+
const {nativeEvent:{layout}}=args;
|
|
332
|
+
const top = defaultNumber(layout.top,layout.y);
|
|
333
|
+
const height = layout.height;
|
|
334
|
+
absoluteScrollViewRef.current.setStyles({
|
|
335
|
+
container : {top,height},
|
|
336
|
+
contentContainer : {height},
|
|
337
|
+
});
|
|
338
|
+
}}
|
|
339
|
+
ref = {listRef}
|
|
340
|
+
numberOfLines = {1}
|
|
341
|
+
responsive = {false}
|
|
342
|
+
testID = {testID}
|
|
343
|
+
prepareItems = {false}
|
|
344
|
+
items = {items}
|
|
345
|
+
contentContainerStyle = {[styles.contentContainer,{with:listWidth,minWidth:totalWidths,position:'absolute',right:'0'}]}
|
|
346
|
+
style = {[styles.datagrid,{width:listWidth,minWidth:totalWidths}]}
|
|
347
|
+
keyExtractor = {typeof getRowKey =='function'? getRowKey : React.getKey}
|
|
348
|
+
onScroll = {getOnScrollCb([absoluteScrollViewRef],(args)=>{
|
|
349
|
+
if(!absoluteScrollViewRef.current) return;
|
|
350
|
+
const offset = args?.nativeEvent?.contentOffset.y;
|
|
351
|
+
const scrollViewRef = absoluteScrollViewRef.current?.scrollViewRef;
|
|
352
|
+
if(typeof offset =='number' && scrollViewRef.current && scrollViewRef.current.scrollTo){
|
|
353
|
+
absoluteScrollViewRefCanScroll.current = false;
|
|
354
|
+
scrollViewRef.current.scrollTo({animated:false,y:offset});
|
|
355
|
+
setTimeout(()=>{
|
|
356
|
+
absoluteScrollViewRefCanScroll.current = true;
|
|
357
|
+
},500);
|
|
358
|
+
}
|
|
359
|
+
})}
|
|
360
|
+
renderItem = {({index})=>items[index]}
|
|
361
|
+
/>
|
|
348
362
|
<AbsoluteScrollView
|
|
349
363
|
ref={absoluteScrollViewRef}
|
|
350
364
|
listRef = {listRef}
|
|
351
365
|
scrollEventThrottle = {scrollEventThrottle}
|
|
352
366
|
onScroll = {(args)=>{
|
|
353
|
-
if(!absoluteScrollViewRefCanScroll.current) return;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
367
|
+
if(!absoluteScrollViewRefCanScroll.current || absoluteScrollingRef.current) return;
|
|
368
|
+
//clearTimeout(absoluteScrollTimeout.current);
|
|
369
|
+
//absoluteScrollTimeout.current = setTimeout(()=>{
|
|
370
|
+
//absoluteScrollingRef.current = true;
|
|
371
|
+
const offset = args?.nativeEvent?.contentOffset.y;
|
|
372
|
+
if(typeof offset =='number' && listRef.current && listRef.current.scrollToOffset){
|
|
373
|
+
listRef.current.scrollToOffset({animated:true,offset});
|
|
374
|
+
}
|
|
375
|
+
//absoluteScrollingRef.current = false;
|
|
376
|
+
//},100);
|
|
358
377
|
}}
|
|
359
378
|
/>
|
|
360
379
|
</ScrollView>}
|
|
@@ -478,10 +497,7 @@ TableComponent.popTypes = {
|
|
|
478
497
|
PropTypes.objectOf(ColumnType),
|
|
479
498
|
PropTypes.arrayOf(ColumnType)
|
|
480
499
|
]).isRequired,
|
|
481
|
-
data : PropTypes.
|
|
482
|
-
PropTypes.objectOf(RowType),
|
|
483
|
-
PropTypes.arrayOf(RowType),
|
|
484
|
-
]),
|
|
500
|
+
data : PropTypes.arrayOf(RowType),
|
|
485
501
|
columnsWidths : PropTypes.object,
|
|
486
502
|
colsWidths : PropTypes.object,//alias à columnsWidths
|
|
487
503
|
columnWidth: PropTypes.number,
|
|
@@ -6,31 +6,22 @@ import ScreenContainer from "../Screen";
|
|
|
6
6
|
import {useRoute} from "$cnavigation";
|
|
7
7
|
import {Form as FormLoader} from "$ecomponents/ContentLoader";
|
|
8
8
|
import HeavyScreen from "$ecomponents/HeavyScreen";
|
|
9
|
-
import {goBack
|
|
9
|
+
import {goBack} from "$cnavigation";
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
export default class FormDataLayout extends FormDataActions {
|
|
13
13
|
getComponentProps(props){
|
|
14
14
|
this.__mainProps = null;
|
|
15
|
-
return super.getComponentProps(
|
|
16
|
-
}
|
|
17
|
-
/***les props à passer au container de la liste à rendre */
|
|
18
|
-
getScreenProps(){
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
getMainProps (){
|
|
22
|
-
if(isObj(this.__mainProps) && Object.size(this.__mainProps,true)) return this.__mainProps;
|
|
23
|
-
this.__mainProps = getScreenProps(this.props);
|
|
24
|
-
return this.__mainProps;
|
|
15
|
+
return super.getComponentProps(props);
|
|
25
16
|
}
|
|
26
17
|
getDataProp(){
|
|
27
|
-
return Object.assign({},this.
|
|
18
|
+
return Object.assign({},this.props.data);
|
|
28
19
|
}
|
|
29
20
|
getAppBarProps(){
|
|
30
21
|
const appBarProps = super.getAppBarProps();
|
|
31
22
|
const {beforeGoBack} = appBarProps;
|
|
32
23
|
const params = defaultObj(useRoute().params);
|
|
33
|
-
const mainProps = this.
|
|
24
|
+
const mainProps = this.props;
|
|
34
25
|
const {onGoBack} = appBarProps;
|
|
35
26
|
appBarProps.onGoBack = (args)=>{
|
|
36
27
|
if(typeof params.onGoBack =='function' && params.onGoBack(args) == false){
|
|
@@ -81,10 +72,10 @@ export default class FormDataLayout extends FormDataActions {
|
|
|
81
72
|
</Wrapper>
|
|
82
73
|
}
|
|
83
74
|
_render (content){
|
|
84
|
-
const {testID,...props} =
|
|
75
|
+
const {testID,...props} = this.props;
|
|
85
76
|
const appBarProps = this.getAppBarActionsProps(props);
|
|
86
77
|
appBarProps.elevation = typeof appBarProps.elevation =='number'? appBarProps.elevation : 5;
|
|
87
|
-
return <ScreenContainer testID={defaultStr(testID,'RN_FormDataLayout')} {...props}
|
|
78
|
+
return <ScreenContainer testID={defaultStr(testID,'RN_FormDataLayout')} {...props} appBarProps={appBarProps}>
|
|
88
79
|
{this.wrapRenderingContent(content)}
|
|
89
80
|
</ScreenContainer>
|
|
90
81
|
}
|
|
@@ -5,7 +5,6 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
export default class FormDataListScreen extends FormData{
|
|
6
6
|
constructor(props){
|
|
7
7
|
super(props);
|
|
8
|
-
const {perm} = this.getMainProps();
|
|
9
8
|
Object.defineProperties(this,{
|
|
10
9
|
isAllowed : {
|
|
11
10
|
value : true
|
|
@@ -14,7 +13,7 @@ export default class FormDataListScreen extends FormData{
|
|
|
14
13
|
}
|
|
15
14
|
isDocEditing(data){
|
|
16
15
|
if(super.isDocEditing(data)) return true;
|
|
17
|
-
const {indexField,isDocUpdate,isDocEditing} = this.
|
|
16
|
+
const {indexField,isDocUpdate,isDocEditing} = this.props;
|
|
18
17
|
if(isObj(data) && typeof isDocUpdate !=='function' && typeof isDocEditing !='function'){
|
|
19
18
|
if(isNonNullString(indexField) && data[indexField]) return true;
|
|
20
19
|
if(data.code) return true;
|
|
@@ -30,9 +29,9 @@ export default class FormDataListScreen extends FormData{
|
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
createNew (){
|
|
33
|
-
const {show} = this.
|
|
32
|
+
const {show} = this.props;
|
|
34
33
|
if(typeof show =='function'){
|
|
35
|
-
show({...this.
|
|
34
|
+
show({...this.props,index:undefined,data:{}});
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
doSave(args){
|
|
@@ -40,7 +39,7 @@ export default class FormDataListScreen extends FormData{
|
|
|
40
39
|
}
|
|
41
40
|
doSave2New(args){
|
|
42
41
|
if(!this.__canSaveListData) return;
|
|
43
|
-
const {show} = this.
|
|
42
|
+
const {show} = this.props;
|
|
44
43
|
if(typeof show =='function'){
|
|
45
44
|
show({...args,index:undefined,data:{}});
|
|
46
45
|
}
|
|
@@ -50,7 +49,7 @@ export default class FormDataListScreen extends FormData{
|
|
|
50
49
|
return this.close();
|
|
51
50
|
}
|
|
52
51
|
onSave(args){
|
|
53
|
-
let {formDataProps} = this.
|
|
52
|
+
let {formDataProps} = this.props;
|
|
54
53
|
this.__canSaveListData = true;
|
|
55
54
|
formDataProps = defaultObj(formDataProps);
|
|
56
55
|
if(typeof formDataProps.onSave =='function' && formDataProps.onSave(args) === false){
|
|
@@ -59,9 +58,9 @@ export default class FormDataListScreen extends FormData{
|
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
60
|
_render(content){
|
|
62
|
-
let {isAllowed} = this.
|
|
61
|
+
let {isAllowed} = this.props;
|
|
63
62
|
if(typeof isAllowed ==='function'){
|
|
64
|
-
isAllowed = isAllowed({data:defaultObj(this.
|
|
63
|
+
isAllowed = isAllowed({data:defaultObj(this.props.data,this.props.data),context:this})
|
|
65
64
|
} else isAllowed = true;
|
|
66
65
|
if(isAllowed === false || !this.isAllowed){
|
|
67
66
|
Auth.showError();
|