@fto-consult/expo-ui 6.24.2 → 6.25.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/app.config.json +1 -1
- package/babel.config.alias.js +2 -1
- package/babel.config.js +1 -1
- package/electron/utils/env.js +80 -0
- package/expo-ui-path.js +2 -2
- package/index.js +14 -13
- package/is-local-dev.js +5 -0
- package/metro.config.js +3 -2
- package/package.json +6 -3
- package/src/App.js +3 -3
- package/src/components/Datagrid/Accordion/Row.js +74 -100
- package/src/components/Datagrid/Accordion/ToogleRow.js +9 -0
- package/src/components/Datagrid/Accordion/index.js +30 -35
- package/src/components/Datagrid/Actions/index.js +12 -44
- package/src/components/Datagrid/Checkbox.js +4 -7
- package/src/components/Datagrid/Common/Common.js +112 -148
- package/src/components/Datagrid/Dashboard/index.js +2 -2
- package/src/components/Datagrid/IndexComponent.js +8 -13
- package/src/components/Datagrid/Table/index.js +53 -51
- package/src/components/Datagrid/Test/index.js +10 -3
- package/src/components/Datagrid/events/evx.js +7 -0
- package/src/components/Datagrid/events/index.js +11 -0
- package/src/components/Datagrid/hooks/Provider.js +6 -0
- package/src/components/Datagrid/hooks/context.js +5 -0
- package/src/components/Datagrid/hooks/index.js +104 -0
- package/src/components/Datagrid/utils.js +6 -4
- package/src/components/Dialog/Dialog.js +13 -12
- package/src/components/Dialog/DialogContent.js +11 -0
- package/src/components/KeyboardAvoidingView/index.js +7 -3
- package/src/components/List/Common.js +5 -3
- package/src/components/List/FlashList.js +13 -13
- package/src/components/List/Virtuoso/index.js +29 -8
- package/src/components/List/Virtuoso/index.native.js +6 -1
- package/src/components/Table/FiltersOrFooters.js +11 -3
- package/src/components/Table/Header/Cell/index.js +10 -0
- package/src/components/Table/Header/Cell/index.native.js +7 -0
- package/src/components/Table/{Header.js → Header/Component.js} +0 -4
- package/src/components/Table/{Row.js → Header/Component.native.js} +3 -3
- package/src/components/Table/Header/index.js +12 -0
- package/src/components/Table/List/index.js +3 -1
- package/src/components/Table/List/index.native.js +2 -1
- package/src/components/Table/Row/Cell/Content.js +17 -0
- package/src/components/Table/Row/Cell/Content.native.js +15 -0
- package/src/components/Table/Row/Cell/index.js +29 -0
- package/src/components/Table/Row/RowWrapper.js +7 -0
- package/src/components/Table/Row/RowWrapper.native.js +10 -0
- package/src/components/Table/Row/index.js +38 -0
- package/src/components/Table/RowTemplate/index.js +10 -0
- package/src/components/Table/RowTemplate/index.web.js +9 -0
- package/src/components/Table/ScrollNative/index.js +7 -0
- package/src/components/Table/ScrollNative/index.native.js +8 -0
- package/src/components/Table/VirtuosoTable/index.js +5 -0
- package/src/components/Table/VirtuosoTable/index.native.js +3 -0
- package/src/components/Table/hooks.js +84 -0
- package/src/components/Table/index.js +88 -247
- package/src/components/Table/styles.js +88 -0
- package/src/components/Table/utils.js +1 -0
- package/src/layouts/AppBar/index.js +11 -10
- package/src/layouts/Screen/ScreenWithoutAuthContainer.js +14 -6
- package/src/navigation/Drawer/items/index.js +2 -1
- package/src/navigation/index.js +11 -3
- package/src/screens/Help/About.js +1 -1
- package/src/screens/Help/openLibraries.js +1 -1
- package/src/test-screens/Home.js +4 -1
- package/webpack.config.js +4 -2
- package/src/components/Table/Cell.js +0 -24
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import View from "$ecomponents/View";
|
|
2
|
-
import {defaultObj,defaultStr,debounce,defaultNumber,defaultVal} from "$cutils";
|
|
2
|
+
import {defaultObj,defaultStr,debounce,defaultNumber,isObj,defaultVal} from "$cutils";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
-
export const DEFAULT_COLUMN_WIDTH = 60;
|
|
5
4
|
import React from "$react";
|
|
6
|
-
import Label from "$ecomponents/Label";
|
|
7
5
|
import { StyleSheet,View as RNView,ScrollView,Dimensions} from "react-native";
|
|
8
|
-
import { getRowStyle } from "$ecomponents/Datagrid/utils";
|
|
9
6
|
import {isMobileNative} from "$cplatform";
|
|
10
7
|
import theme from "$theme";
|
|
11
8
|
import AbsoluteScrollView from "./AbsoluteScrollView";
|
|
12
|
-
import Cell from "./Cell";
|
|
13
9
|
import Row from "./Row";
|
|
14
|
-
import List from "./List";
|
|
10
|
+
import List,{TableRowComponent} from "./List";
|
|
15
11
|
import FiltersOrFooters from "./FiltersOrFooters";
|
|
12
|
+
import { usePrepareColumns,TableContext,useTable} from "./hooks";
|
|
13
|
+
import styles from "./styles";
|
|
14
|
+
import {useIsRowSelected} from "$ecomponents/Datagrid/hooks";
|
|
15
|
+
import {getRowStyle} from "$ecomponents/Datagrid/utils";
|
|
16
|
+
import ScrollNative from "./ScrollNative";
|
|
17
|
+
import VituosoTableComonent from "./VirtuosoTable";
|
|
18
|
+
export {styles};
|
|
19
|
+
|
|
16
20
|
const isSCrollingRef = React.createRef();
|
|
21
|
+
const isNative = isMobileNative();
|
|
22
|
+
|
|
23
|
+
export * from "./utils";
|
|
17
24
|
const scrollLists = (opts,refs)=>{
|
|
18
25
|
refs.map((ref)=>{
|
|
19
26
|
if(ref && ref.current && ref.current.scrollTo){
|
|
@@ -44,99 +51,24 @@ const getOnScrollCb = (refs,pos,cb2)=>{
|
|
|
44
51
|
return isMobileNative()? cb : debounce(cb,200);
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
const TableComponent = React.forwardRef(({containerProps,
|
|
54
|
+
const TableComponent = React.forwardRef(({containerProps,listContainerStyle,onRender,height,progressBar,renderListContent,children,renderEmpty,renderItem,isRowSelected,headerScrollViewProps,footerScrollViewProps,scrollViewProps,showFooters,renderFooterCell,footerCellContainerProps,filterCellContainerProps,headerContainerProps,headerCellContainerProps,headerProps,rowProps:customRowProps,cellContainerProps,hasFooters,renderHeaderCell,renderFilterCell,columnProps,getRowKey,columnsWidths,colsWidths,footerContainerProps,showHeaders,showFilters,columns,...props},tableRef)=>{
|
|
48
55
|
containerProps = defaultObj(containerProps);
|
|
49
|
-
testID = defaultStr(testID,"RN_TableComponent");
|
|
50
56
|
cellContainerProps = defaultObj(cellContainerProps);
|
|
51
57
|
scrollViewProps = defaultObj(scrollViewProps);
|
|
52
58
|
headerScrollViewProps = defaultObj(headerScrollViewProps);
|
|
53
59
|
footerScrollViewProps = defaultObj(footerScrollViewProps);
|
|
54
|
-
renderCell = typeof renderCell ==="function"? renderCell : undefined;
|
|
55
|
-
const getRowProps = typeof rowProps ==='function'? rowProps : undefined;
|
|
56
|
-
let rowProps = isObj(customRowProps)? customRowProps:{};
|
|
57
60
|
const listRef = React.useRef(null),scrollViewRef = React.useRef(null),headerScrollViewRef = React.useRef(null);
|
|
58
|
-
const emptyData = renderListContent === false ?null : typeof renderEmpty =='function' && !Object.size(data,true)? renderEmpty() : null;
|
|
59
|
-
const hasEmptyData = emptyData && React.isValidElement(emptyData);
|
|
60
61
|
const layoutRef = React.useRef({});
|
|
61
|
-
|
|
62
|
-
const preparedColumns = React.useMemo(()=>{
|
|
63
|
-
const cols = {},headers = {},footers = {},filters = {},vColumnsMapping = [],visibleColumns = [],columnsNames = [];
|
|
64
|
-
let hasFooters = false;
|
|
65
|
-
columnProps = defaultObj(columnProps);
|
|
66
|
-
let columnIndex = 0;
|
|
67
|
-
const widths = defaultObj(columnsWidths,colsWidths);
|
|
68
|
-
headerCellContainerProps = defaultObj(headerCellContainerProps);
|
|
69
|
-
footerCellContainerProps = defaultObj(footerCellContainerProps);
|
|
70
|
-
filterCellContainerProps = defaultObj(filterCellContainerProps);
|
|
71
|
-
Object.map(columns,(columnDef,field)=>{
|
|
72
|
-
if(!isObj(columnDef)) return;
|
|
73
|
-
const columnField = defaultStr(columnDef.field,field);
|
|
74
|
-
let {visible,width,type,...colProps} = columnDef;
|
|
75
|
-
visible = typeof visible =='boolean'? visible : true;
|
|
76
|
-
type = defaultStr(type,"text").toLowerCase().trim();
|
|
77
|
-
colProps = defaultObj(colProps);
|
|
78
|
-
width = defaultDecimal(widths[columnField],width,DEFAULT_COLUMN_WIDTH);
|
|
79
|
-
const style = StyleSheet.flatten([colProps.style,{width}]);
|
|
80
|
-
const colArgs = {width,type,style,columnDef,containerProps:{},columnField,index:columnIndex,columnIndex};
|
|
81
|
-
const content = typeof renderHeaderCell =='function'? renderHeaderCell(colArgs) : defaultVal(columnDef.text,columnDef.label,columnField);
|
|
82
|
-
const hContainerProps = defaultObj(colArgs.containerProps);
|
|
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
|
-
headers[columnField] = <View testID={testID+"_HeaderCell_"+columnField} {...headerCellContainerProps} {...hContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,headerCellContainerProps.style,hContainerProps.style,style]}>
|
|
88
|
-
<Label splitText numberOfLines={2} style={[theme.styles.w100,theme.styles.h100,{maxHeight:70}]} textBold primary>{content}</Label>
|
|
89
|
-
</View>;
|
|
90
|
-
if(typeof renderFilterCell =='function'){
|
|
91
|
-
const filterCell = renderFilterCell(colArgs);
|
|
92
|
-
filters[columnField] = <View testID={testID+"_Filter_Cell_"+columnField} {...filterCellContainerProps} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,styles.filterCell,filterCellContainerProps.style,style]}>
|
|
93
|
-
{React.isValidElement(filterCell)? filterCell : null}
|
|
94
|
-
</View>
|
|
95
|
-
}
|
|
96
|
-
if(typeof renderFooterCell ==='function') {
|
|
97
|
-
const footerProps = {...colArgs,containerProps:{}};
|
|
98
|
-
let cellFooter = renderFooterCell(footerProps);
|
|
99
|
-
let fContainerProps = {};
|
|
100
|
-
if(!React.isValidElement(cellFooter,true) && isObj(cellFooter)){
|
|
101
|
-
fContainerProps = isObj(cellFooter.containerProps)? cellFooter.containerProps : {};
|
|
102
|
-
cellFooter = React.isValidElement(cellFooter.children)? cellFooter.children : React.isValidElement(cellFooter.content)? cellFooter.content : null;
|
|
103
|
-
} else if(isObj(footerProps.containerProps)){
|
|
104
|
-
fContainerProps = footerProps.containerProps;
|
|
105
|
-
}
|
|
106
|
-
cellFooter = React.isValidElement(cellFooter,true)? cellFooter : null;
|
|
107
|
-
if(!hasFooters && cellFooter){
|
|
108
|
-
hasFooters = true;
|
|
109
|
-
}
|
|
110
|
-
footers[columnField] = <View testID={testID+"_Footer_Cell_"+columnField} key={columnField} style={[styles.headerItem,styles.headerItemOrCell,footerCellContainerProps.style,style]}>
|
|
111
|
-
<Label primary children={cellFooter}/>
|
|
112
|
-
</View>
|
|
113
|
-
}
|
|
114
|
-
vColumnsMapping.push(visible);
|
|
115
|
-
if(visible){
|
|
116
|
-
visibleColumns.push(columnField);
|
|
117
|
-
}
|
|
118
|
-
columnsNames.push(columnField);
|
|
119
|
-
cols[columnField] = {
|
|
120
|
-
...columnDef,
|
|
121
|
-
width,
|
|
122
|
-
index : columnIndex,
|
|
123
|
-
field : columnField,
|
|
124
|
-
visible,
|
|
125
|
-
columnField,
|
|
126
|
-
};
|
|
127
|
-
columnIndex++;
|
|
128
|
-
});
|
|
129
|
-
return {columns:cols,columnsNames,headers,visibleColumns,vColumnsMapping,hasFooters,footers,filters};
|
|
130
|
-
},[columns,sortedColumn,props.footers]);
|
|
131
|
-
const {columns:cols,headers,footers,filters,hasFooters:stateHasFooters,columnsNames,vColumnsMapping,visibleColumns} = preparedColumns;
|
|
62
|
+
const {columns:cols,testID,headers,footers,getItem,withDatagridContext,filters,getRowByIndex,itemsChanged,hasFooters:stateHasFooters,visibleColsNames,keyExtractor,items,data} = useTable();
|
|
132
63
|
headerContainerProps = defaultObj(headerContainerProps);
|
|
133
64
|
footerContainerProps = defaultObj(footerContainerProps);
|
|
134
|
-
const
|
|
135
|
-
const
|
|
65
|
+
const emptyData = renderListContent === false ?null : typeof renderEmpty =='function' && !Object.size(data,true)? renderEmpty() : null;
|
|
66
|
+
const hasEmptyData = emptyData && React.isValidElement(emptyData);
|
|
67
|
+
|
|
136
68
|
const {fFilters,headersContent,footersContent,totalWidths} = React.useMemo(()=>{
|
|
137
69
|
const headersContent = [],footersContent = [],fFilters = [];
|
|
138
70
|
let totalWidths = 0;
|
|
139
|
-
|
|
71
|
+
visibleColsNames.map((i,index)=>{
|
|
140
72
|
headersContent.push(headers[i]);
|
|
141
73
|
totalWidths+=cols[i].width;
|
|
142
74
|
if(showFooters && stateHasFooters){
|
|
@@ -148,50 +80,9 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
148
80
|
});
|
|
149
81
|
|
|
150
82
|
return {headersContent,totalWidths,footersContent,fFilters};
|
|
151
|
-
},[
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const itemsRef = React.useRef(null);
|
|
155
|
-
const hasChangedDataRef = React.useRef(false);
|
|
156
|
-
hasChangedDataRef.current = false;
|
|
157
|
-
const items = React.useMemo(()=>{
|
|
158
|
-
if(data === prevData && prevColumns == columns && Array.isArray(itemsRef.current)){
|
|
159
|
-
hasChangedDataRef.current = false;
|
|
160
|
-
return itemsRef.current;
|
|
161
|
-
}
|
|
162
|
-
hasChangedDataRef.current = true;
|
|
163
|
-
const items = [];
|
|
164
|
-
const filter = typeof customFilter =='function'? customFilter : x=>true;
|
|
165
|
-
data.map((item,index)=>{
|
|
166
|
-
const rowIndex = index;
|
|
167
|
-
if(!isObj(item) || filter({item,index,_index:rowIndex}) ===false) return null;
|
|
168
|
-
const rowArgs = {data:item,isTable:true,isAccordion:false,item,row:item,rowData:item,rowIndex,index};
|
|
169
|
-
const rProps = defaultObj(getRowProps ? getRowProps(rowArgs) : {});
|
|
170
|
-
rowArgs.rowProps = rProps;
|
|
171
|
-
rowArgs.rowStyle = rProps.style = StyleSheet.flatten([rowProps.style,getRowStyle(rowArgs),styles.rowNoPadding,rProps.style]);
|
|
172
|
-
if(item.isSectionListHeader){
|
|
173
|
-
rowArgs.isSectionListHeader = true;
|
|
174
|
-
}
|
|
175
|
-
const sItem = typeof renderItem == 'function'? renderItem(rowArgs) : undefined;
|
|
176
|
-
const cells = React.isValidElement(sItem) ? sItem : columnsNames.map((columnField,columnIndex)=>{
|
|
177
|
-
const columnDef = cols[columnField];
|
|
178
|
-
return <Cell
|
|
179
|
-
rowArgs = {rowArgs}
|
|
180
|
-
style = {StyleSheet.flatten([styles.headerItemOrCell,{width:columnDef.width}])}
|
|
181
|
-
//key = {"_Cell_"+columnField+"_"+index}
|
|
182
|
-
cellArgs={{columnIndex,columnDef,columnField:columnField}}
|
|
183
|
-
renderCell = {renderCell}
|
|
184
|
-
rowIndex = {index}
|
|
185
|
-
children = {item[columnField]}
|
|
186
|
-
testID={testID+"_Cell_"+columnField+"_"+index}
|
|
187
|
-
/>
|
|
188
|
-
});
|
|
189
|
-
if(!Array.isArray(cells) && !React.isValidElement(cells)) return null;
|
|
190
|
-
items.push(<Row cells={cells} columns={vColumnsMapping} testID={testID+"_Row_"+index} {...rowProps} {...rProps} style={[styles.row,rProps.style]}/>);
|
|
191
|
-
});
|
|
192
|
-
itemsRef.current = items;
|
|
193
|
-
return items;
|
|
194
|
-
},[data,columns]);
|
|
83
|
+
},[visibleColsNames,showFilters,showFooters,layoutRef.current]);
|
|
84
|
+
|
|
85
|
+
|
|
195
86
|
const scrollContentContainerStyle = {flex:1,width:listWidth,minWidth:totalWidths,height:'100%'};
|
|
196
87
|
const scrollEventThrottle = isMobileNative()?200:50;
|
|
197
88
|
const scrollViewFlexGrow = {flexGrow:0};
|
|
@@ -255,7 +146,7 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
255
146
|
onRender(a,b,c);
|
|
256
147
|
}
|
|
257
148
|
//au paravant il était possible de faire scroller le composant Table lorsque les données sont raffraichies, ce qui n'avait pas un bon impact sur le rendu de la table de données
|
|
258
|
-
if(false &&
|
|
149
|
+
if(false && itemsChanged){
|
|
259
150
|
//permet de restaurer la position scrollé où scroll initial à chaque fois que le composant est re render
|
|
260
151
|
//ce qui n'est pas très interessant
|
|
261
152
|
if(headerScrollViewRef.current && headerScrollViewRef.current.scrollTo){
|
|
@@ -267,14 +158,25 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
267
158
|
}
|
|
268
159
|
}
|
|
269
160
|
};
|
|
161
|
+
const headerFootersFilters = <>
|
|
162
|
+
<FiltersOrFooters visible={!!(showTableHeaders && headersContent.length)} testID={testID+"_Header"} {...headerContainerProps} style={[styles.header,headerContainerProps.style,footersContent.length]}>
|
|
163
|
+
{headersContent}
|
|
164
|
+
</FiltersOrFooters>
|
|
165
|
+
<FiltersOrFooters visible = {!!fFilters.length} testID={testID+"_Filters"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
166
|
+
{fFilters}
|
|
167
|
+
</FiltersOrFooters>
|
|
168
|
+
<FiltersOrFooters visible={!!(showTableHeaders && footersContent.length)} testID={testID+"_Footer"} {...footerContainerProps} style={[styles.header,styles.footers,footerContainerProps.style,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
169
|
+
{footersContent}
|
|
170
|
+
</FiltersOrFooters>
|
|
171
|
+
</>
|
|
270
172
|
return <View testID= {testID+"_Container"} {...containerProps} onLayout={(e)=>{
|
|
271
173
|
layoutRef.current = e.nativeEvent.layout;
|
|
272
174
|
if(containerProps.onLayout){
|
|
273
175
|
containerProps.onLayout(e);
|
|
274
176
|
}
|
|
275
177
|
}} style={[styles.container,{alignItems:'stretch'},containerProps.style]}>
|
|
276
|
-
<RNView style={[cStyle]} testID={testID+"_Headers_ScrollViewContainer"}>
|
|
277
|
-
|
|
178
|
+
{isNative && <RNView style={[cStyle]} testID={testID+"_Headers_ScrollViewContainer"}>
|
|
179
|
+
<ScrollView
|
|
278
180
|
testID={testID+"_HeaderScrollView"}
|
|
279
181
|
{...headerScrollViewProps}
|
|
280
182
|
contentContainerStyle = {[allScrollViewProps.contentContainerStyle,headerScrollViewProps.contentContainerStyle,{flex:1,flexWrap: 'wrap'}]}
|
|
@@ -285,21 +187,13 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
285
187
|
showsHorizontalScrollIndicator
|
|
286
188
|
>
|
|
287
189
|
<View testID={testID+"Header2FootersWrapper"} style={[theme.styles.w100]}>
|
|
288
|
-
|
|
289
|
-
{headersContent}
|
|
290
|
-
</FiltersOrFooters>
|
|
291
|
-
<FiltersOrFooters visible = {!!fFilters.length} testID={testID+"_Filters"} style={[styles.header,styles.footers,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
292
|
-
{fFilters}
|
|
293
|
-
</FiltersOrFooters>
|
|
294
|
-
<FiltersOrFooters visible={!!(showTableHeaders && footersContent.length)} testID={testID+"_Footer"} {...footerContainerProps} style={[styles.header,styles.footers,footerContainerProps.style,theme.styles.pt0,theme.styles.pb0,theme.styles.ml0,theme.styles.mr0]}>
|
|
295
|
-
{footersContent}
|
|
296
|
-
</FiltersOrFooters>
|
|
190
|
+
{headerFootersFilters}
|
|
297
191
|
</View>
|
|
298
192
|
</ScrollView>
|
|
299
|
-
</RNView>
|
|
193
|
+
</RNView>}
|
|
300
194
|
{hasEmptyData ? <View onRender={onComponentRender} testID={testID+"_Empty"} style={styles.hasNotData}>
|
|
301
195
|
{emptyData}
|
|
302
|
-
</View> : <
|
|
196
|
+
</View> : <ScrollNative {...scrollViewProps} scrollEventThrottle = {scrollEventThrottle} horizontal contentContainerStyle={[scrollContentContainerStyle,scrollViewProps.contentContainerStyle,{height:'100%'}]} showsVerticalScrollIndicator={false}
|
|
303
197
|
onScroll = {getOnScrollCb([headerScrollViewRef,footerScrollViewRef],null,(args)=>{
|
|
304
198
|
const nativeEvent = args.nativeEvent;
|
|
305
199
|
if(absoluteScrollViewRef.current && absoluteScrollViewRef.current.checkVisibility){
|
|
@@ -325,6 +219,8 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
325
219
|
<List
|
|
326
220
|
containerProps = {{style:[cStyle,listContainerStyle]}}
|
|
327
221
|
estimatedItemSize = {200}
|
|
222
|
+
renderTable
|
|
223
|
+
columns = {columns}
|
|
328
224
|
{...props}
|
|
329
225
|
onContentSizeChange = {(width,height)=>{
|
|
330
226
|
if(props.onContentSizeChange){
|
|
@@ -357,7 +253,7 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
357
253
|
items = {items}
|
|
358
254
|
contentContainerStyle = {[styles.contentContainer,{width:listWidth,minWidth:totalWidths}]}
|
|
359
255
|
style = {[styles.datagrid,{width:listWidth,minWidth:totalWidths}]}
|
|
360
|
-
keyExtractor = {
|
|
256
|
+
keyExtractor = {keyExtractor}
|
|
361
257
|
onScroll = {getOnScrollCb([absoluteScrollViewRef],(args)=>{
|
|
362
258
|
if(!absoluteScrollViewRef.current) return;
|
|
363
259
|
const offset = args?.nativeEvent?.contentOffset.y;
|
|
@@ -370,26 +266,37 @@ const TableComponent = React.forwardRef(({containerProps,sortedColumn,listContai
|
|
|
370
266
|
},500);
|
|
371
267
|
}
|
|
372
268
|
})}
|
|
373
|
-
renderItem = {({index})=>
|
|
269
|
+
renderItem = {({item,index})=>{
|
|
270
|
+
return <Row rowData={item} index={index} testID={testID+"_Row_"+index}/>
|
|
271
|
+
}}
|
|
272
|
+
fixedHeaderContent={(index, user) => {
|
|
273
|
+
return headerFootersFilters;
|
|
274
|
+
}}
|
|
275
|
+
components = {{
|
|
276
|
+
TableRow: (props) => {
|
|
277
|
+
const index = props['data-index'];
|
|
278
|
+
const item = getRowByIndex(index) || props?.item || null;
|
|
279
|
+
if(!item) return null;
|
|
280
|
+
const args = {rowData:item,rowIndex:index,bordered:true,isTable:true};
|
|
281
|
+
args.isSelected = withDatagridContext ? isRowSelected(args) : false;
|
|
282
|
+
return <TableRowComponent {...props} style={[getRowStyle(args),props.style]}/>
|
|
283
|
+
},
|
|
284
|
+
Table: VituosoTableComonent,
|
|
285
|
+
}}
|
|
374
286
|
/>
|
|
375
|
-
<AbsoluteScrollView
|
|
287
|
+
{isNative ? <AbsoluteScrollView
|
|
376
288
|
ref={absoluteScrollViewRef}
|
|
377
289
|
listRef = {listRef}
|
|
378
290
|
scrollEventThrottle = {scrollEventThrottle}
|
|
379
291
|
onScroll = {(args)=>{
|
|
380
292
|
if(!absoluteScrollViewRefCanScroll.current || absoluteScrollingRef.current) return;
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
if(typeof offset =='number' && listRef.current && listRef.current.scrollToOffset){
|
|
386
|
-
listRef.current.scrollToOffset({animated:true,offset});
|
|
387
|
-
}
|
|
388
|
-
//absoluteScrollingRef.current = false;
|
|
389
|
-
//},100);
|
|
293
|
+
const offset = args?.nativeEvent?.contentOffset.y;
|
|
294
|
+
if(typeof offset =='number' && listRef.current && listRef.current.scrollToOffset){
|
|
295
|
+
listRef.current.scrollToOffset({animated:true,offset});
|
|
296
|
+
}
|
|
390
297
|
}}
|
|
391
|
-
|
|
392
|
-
</
|
|
298
|
+
/>:null}
|
|
299
|
+
</ScrollNative>}
|
|
393
300
|
|
|
394
301
|
</View>
|
|
395
302
|
});
|
|
@@ -403,96 +310,11 @@ const RowType = PropTypes.shape({
|
|
|
403
310
|
|
|
404
311
|
});
|
|
405
312
|
|
|
406
|
-
|
|
407
|
-
datagrid : {
|
|
408
|
-
flex:1,
|
|
409
|
-
},
|
|
410
|
-
contentContainer : {
|
|
411
|
-
flex:1,
|
|
412
|
-
},
|
|
413
|
-
container : {
|
|
414
|
-
width : '100%',
|
|
415
|
-
minHeight : 300,
|
|
416
|
-
paddingBottom : 10,
|
|
417
|
-
paddingLeft : 10,
|
|
418
|
-
paddingRight : 0,
|
|
419
|
-
flex : 1,
|
|
420
|
-
position : 'relative',
|
|
421
|
-
},
|
|
422
|
-
header2footerContainer:{
|
|
423
|
-
flexDirection : 'column',
|
|
424
|
-
width : '100%',
|
|
425
|
-
height : '100%',
|
|
426
|
-
minHeight : 50,
|
|
427
|
-
},
|
|
428
|
-
headerContainer : {
|
|
429
|
-
width : '100%',
|
|
430
|
-
flexDirection : 'row',
|
|
431
|
-
},
|
|
432
|
-
header: {
|
|
433
|
-
flexDirection: 'row',
|
|
434
|
-
paddingVertical : 7,
|
|
435
|
-
alignItems : 'center',
|
|
436
|
-
width : '100%',
|
|
437
|
-
},
|
|
438
|
-
footerContainer : {
|
|
439
|
-
width : '100%',
|
|
440
|
-
flexDirection : 'row',
|
|
441
|
-
flexWrap : 'wrap',
|
|
442
|
-
},
|
|
443
|
-
footers : {
|
|
444
|
-
minHeight : 40,
|
|
445
|
-
},
|
|
446
|
-
headerItemOrCell : {
|
|
447
|
-
alignItems: 'flex-start',
|
|
448
|
-
alignSelf : 'center',
|
|
449
|
-
height : '100%',
|
|
450
|
-
justifyContent: 'center',
|
|
451
|
-
textAlign : 'left',
|
|
452
|
-
flexWrap : 'wrap',
|
|
453
|
-
paddingHorizontal:5,
|
|
454
|
-
paddingVertical : 0,
|
|
455
|
-
},
|
|
456
|
-
filterCell : {
|
|
457
|
-
alignSelf : "flex-start",
|
|
458
|
-
textAlign : "left",
|
|
459
|
-
paddingHorizontal : 2,
|
|
460
|
-
paddingVertical : 0,
|
|
461
|
-
marginVertical : 0,
|
|
462
|
-
marginHorizontal : 0,
|
|
463
|
-
justifyContent : 'flex-start',
|
|
464
|
-
},
|
|
465
|
-
headerItem: {
|
|
466
|
-
minHeight: 30,
|
|
467
|
-
},
|
|
468
|
-
column : {
|
|
469
|
-
flexDirection : 'row',
|
|
470
|
-
justifyContent : 'center',
|
|
471
|
-
alignItems : 'flex-start',
|
|
472
|
-
},
|
|
473
|
-
row : {
|
|
474
|
-
flexDirection : "row",
|
|
475
|
-
justifyContent : "flex-start",
|
|
476
|
-
alignItems : 'flex-start',
|
|
477
|
-
width : '100%',
|
|
478
|
-
},
|
|
479
|
-
rowNoPadding : {
|
|
480
|
-
paddingHorizontal:0,
|
|
481
|
-
marginHorizontal : 0,
|
|
482
|
-
marginVertical : 0,
|
|
483
|
-
},
|
|
484
|
-
hasNotData : {
|
|
485
|
-
flexDirection : 'column',
|
|
486
|
-
width : '100%',
|
|
487
|
-
justifyContent : 'center',
|
|
488
|
-
alignItems : 'center'
|
|
489
|
-
}
|
|
490
|
-
})
|
|
313
|
+
|
|
491
314
|
TableComponent.popTypes = {
|
|
492
315
|
containerProps : PropTypes.object,
|
|
493
316
|
renderHeaderCell : PropTypes.func,
|
|
494
317
|
renderFilterCell : PropTypes.func,
|
|
495
|
-
renderRow : PropTypes.func,
|
|
496
318
|
renderCell : PropTypes.func,
|
|
497
319
|
renderFooterCell : PropTypes.func,///la fonction appelée pour le rendu des entêtes du footer
|
|
498
320
|
footerCellContainerProps : PropTypes.object,
|
|
@@ -510,7 +332,7 @@ TableComponent.popTypes = {
|
|
|
510
332
|
PropTypes.objectOf(ColumnType),
|
|
511
333
|
PropTypes.arrayOf(ColumnType)
|
|
512
334
|
]).isRequired,
|
|
513
|
-
data : PropTypes.
|
|
335
|
+
data : PropTypes.array,
|
|
514
336
|
columnsWidths : PropTypes.object,
|
|
515
337
|
colsWidths : PropTypes.object,//alias à columnsWidths
|
|
516
338
|
columnWidth: PropTypes.number,
|
|
@@ -537,4 +359,23 @@ TableComponent.popTypes = {
|
|
|
537
359
|
|
|
538
360
|
TableComponent.displayName = "TableComponent";
|
|
539
361
|
|
|
540
|
-
|
|
362
|
+
const TableComponentProvider = React.forwardRef(({children,renderCell,testID,withDatagridContext,getRowKey,filter,data,...props},ref)=>{
|
|
363
|
+
testID = props.testID = defaultStr(testID,"RN_TableComponent");
|
|
364
|
+
const prepatedColumns = usePrepareColumns(props);
|
|
365
|
+
const keyExtractor = typeof getRowKey =='function'? getRowKey : React.getKey;
|
|
366
|
+
const items = React.useMemo(()=>{
|
|
367
|
+
filter = typeof filter =='function'? filter : x=>true;
|
|
368
|
+
return data.filter((i,...rest)=>isObj(i) && !!filter(i,...rest));
|
|
369
|
+
},[data]);
|
|
370
|
+
const getItem = (index)=>items[index]||null;
|
|
371
|
+
return <TableContext.Provider value={{...props,...prepatedColumns,getItem,getRowByIndex:getItem,testID,data,withDatagridContext,keyExtractor,
|
|
372
|
+
renderCell,
|
|
373
|
+
items
|
|
374
|
+
}}>
|
|
375
|
+
<TableComponent {...props} ref={ref}/>
|
|
376
|
+
</TableContext.Provider>
|
|
377
|
+
});
|
|
378
|
+
TableComponentProvider.displayName = "TableComponentProvider";
|
|
379
|
+
TableComponentProvider.propTypes = TableComponent.propTypes;
|
|
380
|
+
|
|
381
|
+
export default TableComponentProvider;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
datagrid : {
|
|
5
|
+
flex:1,
|
|
6
|
+
},
|
|
7
|
+
contentContainer : {
|
|
8
|
+
flex:1,
|
|
9
|
+
},
|
|
10
|
+
container : {
|
|
11
|
+
width : '100%',
|
|
12
|
+
minHeight : 300,
|
|
13
|
+
paddingBottom : 10,
|
|
14
|
+
paddingLeft : 10,
|
|
15
|
+
paddingRight : 0,
|
|
16
|
+
flex : 1,
|
|
17
|
+
position : 'relative',
|
|
18
|
+
},
|
|
19
|
+
header2footerContainer:{
|
|
20
|
+
flexDirection : 'column',
|
|
21
|
+
width : '100%',
|
|
22
|
+
height : '100%',
|
|
23
|
+
minHeight : 50,
|
|
24
|
+
},
|
|
25
|
+
headerContainer : {
|
|
26
|
+
width : '100%',
|
|
27
|
+
flexDirection : 'row',
|
|
28
|
+
},
|
|
29
|
+
header: {
|
|
30
|
+
flexDirection: 'row',
|
|
31
|
+
paddingVertical : 7,
|
|
32
|
+
alignItems : 'center',
|
|
33
|
+
width : '100%',
|
|
34
|
+
},
|
|
35
|
+
footerContainer : {
|
|
36
|
+
width : '100%',
|
|
37
|
+
flexDirection : 'row',
|
|
38
|
+
flexWrap : 'wrap',
|
|
39
|
+
},
|
|
40
|
+
footers : {
|
|
41
|
+
minHeight : 40,
|
|
42
|
+
},
|
|
43
|
+
headerItemOrCell : {
|
|
44
|
+
alignItems: 'flex-start',
|
|
45
|
+
alignSelf : 'center',
|
|
46
|
+
height : '100%',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
textAlign : 'left',
|
|
49
|
+
flexWrap : 'wrap',
|
|
50
|
+
paddingHorizontal:5,
|
|
51
|
+
paddingVertical : 0,
|
|
52
|
+
},
|
|
53
|
+
filterCell : {
|
|
54
|
+
alignSelf : "flex-start",
|
|
55
|
+
textAlign : "left",
|
|
56
|
+
paddingHorizontal : 2,
|
|
57
|
+
paddingVertical : 0,
|
|
58
|
+
marginVertical : 0,
|
|
59
|
+
marginHorizontal : 0,
|
|
60
|
+
justifyContent : 'flex-start',
|
|
61
|
+
},
|
|
62
|
+
headerItem: {
|
|
63
|
+
minHeight: 30,
|
|
64
|
+
},
|
|
65
|
+
column : {
|
|
66
|
+
flexDirection : 'row',
|
|
67
|
+
justifyContent : 'center',
|
|
68
|
+
alignItems : 'flex-start',
|
|
69
|
+
},
|
|
70
|
+
row : {
|
|
71
|
+
flexDirection : "row",
|
|
72
|
+
justifyContent : "flex-start",
|
|
73
|
+
alignItems : 'flex-start',
|
|
74
|
+
width : '100%',
|
|
75
|
+
},
|
|
76
|
+
rowNoPadding : {
|
|
77
|
+
paddingHorizontal:0,
|
|
78
|
+
marginHorizontal : 0,
|
|
79
|
+
marginVertical : 0,
|
|
80
|
+
},
|
|
81
|
+
hasNotData : {
|
|
82
|
+
flexDirection : 'column',
|
|
83
|
+
width : '100%',
|
|
84
|
+
justifyContent : 'center',
|
|
85
|
+
alignItems : 'center'
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
export default styles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_COLUMN_WIDTH = 60;
|
|
@@ -23,17 +23,18 @@ const AppBarLayout = React.forwardRef(({backActionProps,withDrawer,backAction,ba
|
|
|
23
23
|
goBack();
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
|
-
if(drawerRef
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
drawerRef?.current?.open();
|
|
35
|
-
}
|
|
26
|
+
if(!drawerRef || !drawerRef?.current) return false;
|
|
27
|
+
if(!drawerRef?.current?.isOpen()){
|
|
28
|
+
drawerRef.current.toggle();
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if(drawerRef?.current?.isMinimized()){
|
|
32
|
+
drawerRef?.current?.restore();
|
|
33
|
+
return false;
|
|
36
34
|
}
|
|
35
|
+
if(!drawerRef?.current?.isPermanent()){
|
|
36
|
+
drawerRef?.current?.toggle();
|
|
37
|
+
}
|
|
37
38
|
return false;
|
|
38
39
|
}}
|
|
39
40
|
ref = {mergedRef}
|
|
@@ -51,9 +51,11 @@ export default function MainScreenScreenWithoutAuthContainer(props) {
|
|
|
51
51
|
containerProps,
|
|
52
52
|
testID,
|
|
53
53
|
right,
|
|
54
|
+
keyboardAvoidingViewProps,
|
|
54
55
|
...rest
|
|
55
56
|
} = props;
|
|
56
57
|
const insets = useSafeAreaInsets();
|
|
58
|
+
keyboardAvoidingViewProps = defaultObj(keyboardAvoidingViewProps);
|
|
57
59
|
testID = defaultStr(testID,"RN_MainScreenScreenWithoutAuthContainer")
|
|
58
60
|
containerProps = defaultObj(containerProps);
|
|
59
61
|
const backgroundColor = theme.colors.background;
|
|
@@ -106,7 +108,8 @@ export default function MainScreenScreenWithoutAuthContainer(props) {
|
|
|
106
108
|
const WrapperProps = modal? {screenName} : {};
|
|
107
109
|
const portalId = uniqid("screeen-container-"+screenName);
|
|
108
110
|
return <Wrapper {...WrapperProps}>
|
|
109
|
-
|
|
111
|
+
<View testID={testID+"_ScreenContentContainer"} id={portalId} style={[containerStyle,{backgroundColor},modal && styles.modal,containerProps.style]} {...containerProps}>
|
|
112
|
+
<KeyboardAvoidingView testID={testID} {...keyboardAvoidingViewProps} style={[styles.keyboardAvoidingView,keyboardAvoidingViewProps.style]}>
|
|
110
113
|
{withStatusBar !== false ? <StatusBar/> : null}
|
|
111
114
|
{appBar === false ? null : React.isValidElement(appBar)? state.AppBar : <AppBar
|
|
112
115
|
testID={testID+'_AppBar'} {...appBarProps}
|
|
@@ -121,19 +124,20 @@ export default function MainScreenScreenWithoutAuthContainer(props) {
|
|
|
121
124
|
<ScrollView
|
|
122
125
|
testID = {testID+'_ScreenContentScrollView'}
|
|
123
126
|
{...rest}
|
|
124
|
-
contentContainerStyle={[contentContainerStyle]}
|
|
125
|
-
style={[
|
|
127
|
+
contentContainerStyle={[contentContainerStyle,styles.container]}
|
|
128
|
+
style={[style]}
|
|
126
129
|
>
|
|
127
130
|
{children}
|
|
128
131
|
{fab}
|
|
129
132
|
</ScrollView>
|
|
130
133
|
) : (
|
|
131
|
-
<View testID={testID+'_ScreenContent'} {...rest} style={[
|
|
134
|
+
<View testID={testID+'_ScreenContent'} {...rest} style={[styles.container, style]}>
|
|
132
135
|
{children}
|
|
133
136
|
{fab}
|
|
134
137
|
</View>
|
|
135
138
|
)}
|
|
136
|
-
|
|
139
|
+
</KeyboardAvoidingView>
|
|
140
|
+
</View>
|
|
137
141
|
</Wrapper>
|
|
138
142
|
}
|
|
139
143
|
|
|
@@ -147,8 +151,12 @@ const styles = StyleSheet.create({
|
|
|
147
151
|
container: {
|
|
148
152
|
flex: 1,
|
|
149
153
|
},
|
|
154
|
+
keyboardAvoidingView : {
|
|
155
|
+
flex : 1,
|
|
156
|
+
backgroundColor : "transparent",
|
|
157
|
+
},
|
|
150
158
|
wrapper : {
|
|
151
|
-
|
|
159
|
+
flex : 1,
|
|
152
160
|
/*flex : 1,
|
|
153
161
|
flexGrow : 1,
|
|
154
162
|
alignItems:'center'*/
|
|
@@ -29,11 +29,12 @@ const useGetItems = (options)=>{
|
|
|
29
29
|
APP.on(APP.EVENTS.REFRESH_MAIN_DRAWER,refreshItems);
|
|
30
30
|
APP.on(APP.EVENTS.AUTH_LOGIN_USER,refreshItems);
|
|
31
31
|
APP.on(APP.EVENTS.AUTH_LOGOUT_USER,refreshItems);
|
|
32
|
+
APP.on(APP.EVENTS.UPDATE_THEME,refreshItems);
|
|
32
33
|
return ()=>{
|
|
33
34
|
APP.off(APP.EVENTS.REFRESH_MAIN_DRAWER,refreshItems);
|
|
34
35
|
APP.off(APP.EVENTS.AUTH_LOGIN_USER,refreshItems);
|
|
35
36
|
APP.off(APP.EVENTS.AUTH_LOGOUT_USER,refreshItems);
|
|
36
|
-
APP.off(APP.EVENTS.UPDATE_THEME,
|
|
37
|
+
APP.off(APP.EVENTS.UPDATE_THEME,refreshItems);
|
|
37
38
|
}
|
|
38
39
|
},[])
|
|
39
40
|
return useMemo(()=>{
|