@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.
Files changed (66) hide show
  1. package/app.config.json +1 -1
  2. package/babel.config.alias.js +2 -1
  3. package/babel.config.js +1 -1
  4. package/electron/utils/env.js +80 -0
  5. package/expo-ui-path.js +2 -2
  6. package/index.js +14 -13
  7. package/is-local-dev.js +5 -0
  8. package/metro.config.js +3 -2
  9. package/package.json +6 -3
  10. package/src/App.js +3 -3
  11. package/src/components/Datagrid/Accordion/Row.js +74 -100
  12. package/src/components/Datagrid/Accordion/ToogleRow.js +9 -0
  13. package/src/components/Datagrid/Accordion/index.js +30 -35
  14. package/src/components/Datagrid/Actions/index.js +12 -44
  15. package/src/components/Datagrid/Checkbox.js +4 -7
  16. package/src/components/Datagrid/Common/Common.js +112 -148
  17. package/src/components/Datagrid/Dashboard/index.js +2 -2
  18. package/src/components/Datagrid/IndexComponent.js +8 -13
  19. package/src/components/Datagrid/Table/index.js +53 -51
  20. package/src/components/Datagrid/Test/index.js +10 -3
  21. package/src/components/Datagrid/events/evx.js +7 -0
  22. package/src/components/Datagrid/events/index.js +11 -0
  23. package/src/components/Datagrid/hooks/Provider.js +6 -0
  24. package/src/components/Datagrid/hooks/context.js +5 -0
  25. package/src/components/Datagrid/hooks/index.js +104 -0
  26. package/src/components/Datagrid/utils.js +6 -4
  27. package/src/components/Dialog/Dialog.js +13 -12
  28. package/src/components/Dialog/DialogContent.js +11 -0
  29. package/src/components/KeyboardAvoidingView/index.js +7 -3
  30. package/src/components/List/Common.js +5 -3
  31. package/src/components/List/FlashList.js +13 -13
  32. package/src/components/List/Virtuoso/index.js +29 -8
  33. package/src/components/List/Virtuoso/index.native.js +6 -1
  34. package/src/components/Table/FiltersOrFooters.js +11 -3
  35. package/src/components/Table/Header/Cell/index.js +10 -0
  36. package/src/components/Table/Header/Cell/index.native.js +7 -0
  37. package/src/components/Table/{Header.js → Header/Component.js} +0 -4
  38. package/src/components/Table/{Row.js → Header/Component.native.js} +3 -3
  39. package/src/components/Table/Header/index.js +12 -0
  40. package/src/components/Table/List/index.js +3 -1
  41. package/src/components/Table/List/index.native.js +2 -1
  42. package/src/components/Table/Row/Cell/Content.js +17 -0
  43. package/src/components/Table/Row/Cell/Content.native.js +15 -0
  44. package/src/components/Table/Row/Cell/index.js +29 -0
  45. package/src/components/Table/Row/RowWrapper.js +7 -0
  46. package/src/components/Table/Row/RowWrapper.native.js +10 -0
  47. package/src/components/Table/Row/index.js +38 -0
  48. package/src/components/Table/RowTemplate/index.js +10 -0
  49. package/src/components/Table/RowTemplate/index.web.js +9 -0
  50. package/src/components/Table/ScrollNative/index.js +7 -0
  51. package/src/components/Table/ScrollNative/index.native.js +8 -0
  52. package/src/components/Table/VirtuosoTable/index.js +5 -0
  53. package/src/components/Table/VirtuosoTable/index.native.js +3 -0
  54. package/src/components/Table/hooks.js +84 -0
  55. package/src/components/Table/index.js +88 -247
  56. package/src/components/Table/styles.js +88 -0
  57. package/src/components/Table/utils.js +1 -0
  58. package/src/layouts/AppBar/index.js +11 -10
  59. package/src/layouts/Screen/ScreenWithoutAuthContainer.js +14 -6
  60. package/src/navigation/Drawer/items/index.js +2 -1
  61. package/src/navigation/index.js +11 -3
  62. package/src/screens/Help/About.js +1 -1
  63. package/src/screens/Help/openLibraries.js +1 -1
  64. package/src/test-screens/Home.js +4 -1
  65. package/webpack.config.js +4 -2
  66. 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
- {render}
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(isObj(this.renderingItemsProps) && isObj(this.renderingItemsProps[rKey]) && this.renderingItemsProps[rKey].title){
102
- const it = this.renderingItemsProps[rKey];
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_"+rKey;
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[rKey] = {
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[rKey];
175
+ return this.renderingItemsProps[rowKey];
180
176
  }
181
177
  renderItem(args){
182
- const {index,numColumns,item,isSectionListHeader,isScrolling:_isScrolling,style,setSize} = args;
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 rowKey = this.getRowKey(item,index);
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 = {rowKey}
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 <View testID={testID+"_Container"} pointerEvents={pointerEvents} style={[styles.container]} collapsable={false}>
511
- { <View testID={testID+"_ContentContainer"}>
512
- <View testID={testID+"_AccordionHeader"} style={[styles.accordionHeader]} ref={this.layoutRef} onLayout={this.updateLayout.bind(this)}>
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
- </View>}
573
- {!canRenderChart && backToTopRef ? <BackToTop testID={testID+"_BackToTop"} {...backToTopProps} ref={this.backToTopRef} style={[styles.backToTop,backToTopProps.style]} onPress={this.scrollToTop.bind(this)}/>:null}
574
- <BottomSheet
575
- testID = {testID+"_BottomSheet"}
576
- renderMenuContent = {false}
577
- ref = {(el)=>{
578
- this.bottomSheetContext = el;
579
- }}
580
- />
581
- </View>
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 (_props){
15
- let {actions,actionProps,selectedRowsActions,bindResizeEvent,context,selectedRows:_selectedRows,...props} = _props;
16
- props = defaultObj(props);
17
- context = defaultObj(context);
18
- const [state,setState] = React.useState({
19
- selectedRows : defaultObj(_selectedRows),
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 = selectedRows;
55
- sArg.size = sArg.selectedRowsCount = sCounts;
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(sCounts > 0){
62
- let sLetter = (sCounts>1?'s':'');
63
- contextualTitle = (sCounts<10?'0':'')+sCounts+(' ligne'+sLetter+' sélectionnée'+sLetter),1;
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,rowsRefs,...rest} = props;
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})