@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
|
@@ -27,6 +27,7 @@ import {getRowStyle,styles as rStyles} from "../utils";
|
|
|
27
27
|
import Avatar from "$ecomponents/Avatar";
|
|
28
28
|
import {defaultObj,isOb,isNonNullString} from "$cutils";
|
|
29
29
|
import PropTypes from "prop-types";
|
|
30
|
+
import DatagridProvider from "../hooks/Provider";
|
|
30
31
|
|
|
31
32
|
const DatagridFactory = (Factory)=>{
|
|
32
33
|
Factory = Factory || CommonDatagrid;
|
|
@@ -44,7 +45,6 @@ const DatagridFactory = (Factory)=>{
|
|
|
44
45
|
},
|
|
45
46
|
});
|
|
46
47
|
this.state.refreshing = false;
|
|
47
|
-
//this.state.isReady = !this.bindResizeEvents();
|
|
48
48
|
this.updateLayout = this.updateLayout.bind(this);
|
|
49
49
|
}
|
|
50
50
|
isDatagrid(){
|
|
@@ -67,7 +67,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
67
67
|
const {render,key,style} = super.renderRowCell(arg);
|
|
68
68
|
if(render===null || !React.isValidElement(render)) return null;
|
|
69
69
|
return <Label style={[style,{paddingTop:10,paddingBottom:10}]} key={key}>
|
|
70
|
-
|
|
70
|
+
{render}
|
|
71
71
|
</Label>
|
|
72
72
|
}
|
|
73
73
|
rangeChanged(state){
|
|
@@ -95,19 +95,17 @@ const DatagridFactory = (Factory)=>{
|
|
|
95
95
|
return {...this.getActionsArgs(),valueFormatter:formatValue,formatValue,abreviateValues:this.state.abreviateValues,row:item,items:this.state.data,item,rowData:item,index,rowIndex:index,rowCounterIndex:rowIndexCount,rowIndexCount};
|
|
96
96
|
}
|
|
97
97
|
getRenderingItemProps ({item,rowKey,numColumns,index}){
|
|
98
|
-
const rKey = rowKey;
|
|
99
98
|
this.renderingItemsProps = isObj(this.renderingItemsProps)? this.renderingItemsProps : {};
|
|
100
99
|
const wrapperStyle = getRowStyle({row:item,index,numColumns,isAccordion:true,rowIndex:index});
|
|
101
|
-
if(
|
|
102
|
-
const it = this.renderingItemsProps[
|
|
103
|
-
it.numColumns = numColumns;
|
|
100
|
+
if(this.renderingItemsProps[rowKey]){
|
|
101
|
+
const it = this.renderingItemsProps[rowKey];
|
|
104
102
|
it.wrapperStyle = wrapperStyle;
|
|
105
103
|
return it;
|
|
106
104
|
}
|
|
107
105
|
const callArgs = this.getItemCallArgs({item,index});
|
|
108
106
|
const accordion = this.props.accordion;
|
|
109
107
|
const accordionProps = defaultObj(this.props.accordionProps);
|
|
110
|
-
const testID = "RN_DatagridAccordionRow_"+
|
|
108
|
+
const testID = "RN_DatagridAccordionRow_"+rowKey;
|
|
111
109
|
let renderedContent = isFunction(accordion) ? accordion(callArgs) : isFunction(accordionProps.accordion) ? accordionProps.accordion(callArgs) : isObj(accordion) && accordion ? accordion : isObj(accordionProps.accordion) ? accordionProps.accordion : undefined;;
|
|
112
110
|
let title = null, avatarContent = null,right = null,rightProps={},description = null,rowProps = {},avatarProps = {};
|
|
113
111
|
let descriptionProps = Object.assign({},this.accordionDescriptionProps)
|
|
@@ -131,7 +129,6 @@ const DatagridFactory = (Factory)=>{
|
|
|
131
129
|
} else if(isObj(renderedContent.contentProps)){
|
|
132
130
|
descriptionProps = {...descriptionProps,...renderedContent.contentProps,style:[descriptionProps.style,renderedContent.contentProps.style]}
|
|
133
131
|
}
|
|
134
|
-
//
|
|
135
132
|
rowProps = defaultObj(renderedContent.rowProps);
|
|
136
133
|
avatarProps.color = color;
|
|
137
134
|
if(typeof avatarContent =='function'){
|
|
@@ -170,16 +167,15 @@ const DatagridFactory = (Factory)=>{
|
|
|
170
167
|
} else if(!React.isValidElement(title)){
|
|
171
168
|
title = null;
|
|
172
169
|
}
|
|
173
|
-
this.renderingItemsProps[
|
|
170
|
+
this.renderingItemsProps[rowKey] = {
|
|
174
171
|
testID,
|
|
175
|
-
numColumns,
|
|
176
172
|
wrapperStyle,title,right,rightProps,description,avatarContent,rowProps,avatarProps,
|
|
177
173
|
bottomSheetTitlePrefix : defaultStr(renderedContent?.bottomSheetTitlePrefix,accordionProps.bottomSheetTitlePrefix,accordion?.bottomSheetTitlePrefix)
|
|
178
174
|
}
|
|
179
|
-
return this.renderingItemsProps[
|
|
175
|
+
return this.renderingItemsProps[rowKey];
|
|
180
176
|
}
|
|
181
177
|
renderItem(args){
|
|
182
|
-
const {index,numColumns,item,isSectionListHeader,isScrolling:_isScrolling,style
|
|
178
|
+
const {index,numColumns,item,isSectionListHeader,isScrolling:_isScrolling,style} = args;
|
|
183
179
|
args.isAccordion = true;
|
|
184
180
|
if(isSectionListHeader || item.isSectionListHeader){
|
|
185
181
|
const rowStyle = style ? [style] : [];
|
|
@@ -194,18 +190,19 @@ const DatagridFactory = (Factory)=>{
|
|
|
194
190
|
</View>;
|
|
195
191
|
}
|
|
196
192
|
if(!(item) || typeof item !== 'object') return null;
|
|
197
|
-
const
|
|
193
|
+
const canHandleRow = typeof this.props.filter =='function' ? this.props.filter(this.getItemCallArgs({item,index})) : true;
|
|
194
|
+
if(canHandleRow === false || canHandleRow === null) return null;
|
|
195
|
+
const rowKey = this.getRowKeyByIndex(index);
|
|
198
196
|
return <DatagridAccordionRow
|
|
199
197
|
item = {item}
|
|
200
198
|
index = {index}
|
|
201
|
-
context = {this}
|
|
202
199
|
rowKey = {rowKey}
|
|
203
|
-
isScrolling = {defaultBool(this.isScrolling(),_isScrolling)}
|
|
204
200
|
selectable = {this.props.selectable}
|
|
205
|
-
isRowSelected = {this.isRowSelected.bind(this)}
|
|
206
201
|
{...defaultObj(this.props.accordionProps)}
|
|
202
|
+
accordion = {this.props.accordion}
|
|
203
|
+
numColumns = {numColumns}
|
|
207
204
|
{...this.getRenderingItemProps({item,numColumns,index,rowKey})}
|
|
208
|
-
key = {
|
|
205
|
+
key = {index}
|
|
209
206
|
ref = {(el)=>{
|
|
210
207
|
if(isObj(this.renderingItemsProps) && isObj(this.renderingItemsProps[rowKey]) ){
|
|
211
208
|
this.renderingItemsProps[rowKey].ref = el;
|
|
@@ -253,6 +250,7 @@ const DatagridFactory = (Factory)=>{
|
|
|
253
250
|
return null;
|
|
254
251
|
}
|
|
255
252
|
getItem(index){
|
|
253
|
+
return this.getRowByIndex(index);
|
|
256
254
|
if(typeof index !=='number') return null;
|
|
257
255
|
return isObj(this.state.data[index])? this.state.data[index] : null;
|
|
258
256
|
}
|
|
@@ -507,16 +505,13 @@ const DatagridFactory = (Factory)=>{
|
|
|
507
505
|
</View>
|
|
508
506
|
</ScrollView>
|
|
509
507
|
</View>
|
|
510
|
-
return <
|
|
511
|
-
|
|
512
|
-
|
|
508
|
+
return <DatagridProvider context={this}>
|
|
509
|
+
<View testID={testID+"_Container"} pointerEvents={pointerEvents} style={[styles.container,this.props.style]} collapsable={false}>
|
|
510
|
+
<View testID={testID+"_AccordionHeader"} style={[styles.accordionHeader]} ref={this.layoutRef} onLayout={this.updateLayout.bind(this)}>
|
|
513
511
|
{this.props.showActions !== false ? <DatagridActions
|
|
514
512
|
testID={testID+"_Actions"}
|
|
515
513
|
pointerEvents = {pointerEvents}
|
|
516
514
|
title = {this.renderDataSourceSelector()}
|
|
517
|
-
context = {this}
|
|
518
|
-
selectedRows = {Object.assign({},this.selectedRows)}
|
|
519
|
-
selectedRowsActions = {this.renderSelectedRowsActions.bind(this)}
|
|
520
515
|
actions = {actions}
|
|
521
516
|
/> : null}
|
|
522
517
|
{datagridHeader}
|
|
@@ -545,9 +540,9 @@ const DatagridFactory = (Factory)=>{
|
|
|
545
540
|
</View>
|
|
546
541
|
{hasData && !canRenderChart ? <List
|
|
547
542
|
estimatedItemSize = {150}
|
|
548
|
-
prepareItems = {false}
|
|
549
543
|
{...rest}
|
|
550
544
|
{...accordionProps}
|
|
545
|
+
prepareItems = {false}
|
|
551
546
|
onRender = {this.onRender.bind(this)}
|
|
552
547
|
testID = {testID}
|
|
553
548
|
extraData = {this.state.refresh}
|
|
@@ -569,18 +564,17 @@ const DatagridFactory = (Factory)=>{
|
|
|
569
564
|
</View> : <View onRender = {this.onRender.bind(this)} style={styles.hasNotData}>
|
|
570
565
|
{this.renderEmpty()}
|
|
571
566
|
</View>}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
</
|
|
567
|
+
{!canRenderChart && backToTopRef ? <BackToTop testID={testID+"_BackToTop"} {...backToTopProps} ref={this.backToTopRef} style={[styles.backToTop,backToTopProps.style]} onPress={this.scrollToTop.bind(this)}/>:null}
|
|
568
|
+
<BottomSheet
|
|
569
|
+
testID = {testID+"_BottomSheet"}
|
|
570
|
+
renderMenuContent = {false}
|
|
571
|
+
ref = {(el)=>{
|
|
572
|
+
this.bottomSheetContext = el;
|
|
573
|
+
}}
|
|
574
|
+
/>
|
|
575
|
+
</View>
|
|
576
|
+
</DatagridProvider>
|
|
582
577
|
}
|
|
583
|
-
|
|
584
578
|
}
|
|
585
579
|
clx.propTypes = {
|
|
586
580
|
...Factory.propTypes,
|
|
@@ -619,6 +613,7 @@ const styles = StyleSheet.create({
|
|
|
619
613
|
flexDirection :'column',
|
|
620
614
|
justifyContent : 'flex-start',
|
|
621
615
|
width : '100%',
|
|
616
|
+
flex : 1,
|
|
622
617
|
paddingHorizontal : isNativeMobile()? 5:1,
|
|
623
618
|
},
|
|
624
619
|
accordionHeader : {
|
|
@@ -10,35 +10,13 @@ import Button from "$ecomponents/Button";
|
|
|
10
10
|
import { StyleSheet } from "react-native";
|
|
11
11
|
import Label from "$ecomponents/Label";
|
|
12
12
|
import { useWindowDimensions } from "react-native";
|
|
13
|
-
|
|
14
|
-
export default function DatagridActions (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
const selectedRowsCallBackRef = React.useRef(null);
|
|
22
|
-
const setSelectedRows = (selectedRows,cb)=>{
|
|
23
|
-
if(isObj(selectedRows)){
|
|
24
|
-
selectedRowsCallBackRef.current = cb;
|
|
25
|
-
setState({...state,selectedRows:Object.assign({},selectedRows)})
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const dimensions = bindResizeEvent !== false ? useWindowDimensions() : {};
|
|
29
|
-
React.useEffect(()=>{
|
|
30
|
-
setSelectedRows(_selectedRows,null);
|
|
31
|
-
},[_selectedRows]);
|
|
32
|
-
const selectedRows = state.selectedRows;
|
|
33
|
-
React.useEffect(()=>{
|
|
34
|
-
if(typeof selectedRowsCallBackRef.current =='function'){
|
|
35
|
-
selectedRowsCallBackRef.current({});
|
|
36
|
-
}
|
|
37
|
-
selectedRowsCallBackRef.current = null;
|
|
38
|
-
},[selectedRows]);
|
|
39
|
-
let sCounts = Object.size(selectedRows);
|
|
40
|
-
const selected = sCounts > 0 ? true : false;
|
|
41
|
-
actions = selected ? selectedRowsActions : actions;
|
|
13
|
+
import {useDatagrid,useGetSelectedRowsCount} from "../hooks";
|
|
14
|
+
export default function DatagridActions ({actions,actionProps,...props}){
|
|
15
|
+
const {context} = useDatagrid();
|
|
16
|
+
const selectedRowsCount = useGetSelectedRowsCount();
|
|
17
|
+
useWindowDimensions();
|
|
18
|
+
const selected = !!selectedRowsCount;
|
|
19
|
+
actions = selected ? context?.renderSelectedRowsActions.call(context,actions) : actions;
|
|
42
20
|
if(selected){
|
|
43
21
|
actionProps = Object.assign({},actionProps);
|
|
44
22
|
actionProps.style = Object.assign({},StyleSheet.flatten(actionProps.style));
|
|
@@ -51,18 +29,17 @@ export default function DatagridActions (_props){
|
|
|
51
29
|
if(!sArg || typeof sArg !=='object'){
|
|
52
30
|
sArg = {};
|
|
53
31
|
}
|
|
54
|
-
sArg.selectedRows =
|
|
55
|
-
sArg.size = sArg.selectedRowsCount =
|
|
32
|
+
sArg.selectedRows = context.getSelectedRows();
|
|
33
|
+
sArg.size = sArg.selectedRowsCount = selectedRowsCount;
|
|
56
34
|
sArg.context = context;
|
|
57
35
|
actions = actions.call(context,sArg);
|
|
58
36
|
}
|
|
59
37
|
const splitedActions = isObjOrArray(actions)? splitActions({...props,...sArg,actionProps,actions,isAppBarAction:false,alwaysSplitOnMobile:true}) : undefined;
|
|
60
38
|
let contextualTitle = "";
|
|
61
|
-
if(
|
|
62
|
-
let sLetter = (
|
|
63
|
-
contextualTitle = (
|
|
39
|
+
if(selectedRowsCount > 0){
|
|
40
|
+
let sLetter = (selectedRowsCount>1?'s':'');
|
|
41
|
+
contextualTitle = (selectedRowsCount<10?'0':'')+selectedRowsCount+(' ligne'+sLetter+' sélectionnée'+sLetter),1;
|
|
64
42
|
}
|
|
65
|
-
context.datagridActionsContext = {setSelectedRows};
|
|
66
43
|
const children = renderSplitedActions(splitedActions,{
|
|
67
44
|
anchor : (props)=>{
|
|
68
45
|
return <Button
|
|
@@ -75,10 +52,6 @@ export default function DatagridActions (_props){
|
|
|
75
52
|
/>
|
|
76
53
|
}
|
|
77
54
|
});
|
|
78
|
-
///la fonction updateDatagridActions est définies dans les actions du datagrid
|
|
79
|
-
context.updateDatagridActions = ()=>{
|
|
80
|
-
return setSelectedRows({...selectedRows});
|
|
81
|
-
}
|
|
82
55
|
return <Header
|
|
83
56
|
{...props}
|
|
84
57
|
title = {contextualTitle}
|
|
@@ -95,9 +68,4 @@ DatagridActions.propTypes = {
|
|
|
95
68
|
/*** le tire du menu contextuel */
|
|
96
69
|
title : PropTypes.node,
|
|
97
70
|
visible: PropTypes.bool,
|
|
98
|
-
selectedRowsActions : PropTypes.oneOfType([
|
|
99
|
-
PropTypes.func, PropTypes.object, PropTypes.array,
|
|
100
|
-
]),
|
|
101
|
-
bindResizeEvent : PropTypes.bool,
|
|
102
|
-
context : PropTypes.object.isRequired,///le context d'exécution du datagridAction
|
|
103
71
|
};
|
|
@@ -3,19 +3,16 @@ import React from "$react";
|
|
|
3
3
|
import {defaultObj,isObj} from "$cutils";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import theme from "$theme";
|
|
6
|
+
import {useDatagrid,useIsRowSelected,useIsAllRowsSelected} from "./hooks";
|
|
6
7
|
|
|
7
8
|
const DatagridCheckboxComponent = React.forwardRef((props,ref)=>{
|
|
8
|
-
const {onChange,rowKey,rowData,row,rowIndex,index,
|
|
9
|
+
const {onChange,rowKey,rowData,row,rowIndex,index,toggleAll,...rest} = props;
|
|
10
|
+
const checked = toggleAll ? useIsAllRowsSelected() : useIsRowSelected(rowKey);
|
|
9
11
|
return <Checkbox
|
|
10
12
|
secondaryOnCheck
|
|
11
13
|
{...rest}
|
|
14
|
+
checked = {checked}
|
|
12
15
|
style = {[rest.style,theme.styles.alignItemsCenter]}
|
|
13
|
-
ref = {(el)=>{
|
|
14
|
-
React.setRef(ref,el);
|
|
15
|
-
if(isObj(rowsRefs) && rowKey){
|
|
16
|
-
rowsRefs[rowKey] = el;
|
|
17
|
-
}
|
|
18
|
-
}}
|
|
19
16
|
onChange = {(o)=>{
|
|
20
17
|
if(onChange){
|
|
21
18
|
onChange({...o,row,rowKey,rowData,rowIndex:typeof rowIndex ==='number' ? rowIndex : typeof index =='number'? index : undefined})
|