@fto-consult/expo-ui 5.7.8 → 5.7.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "5.7.8",
3
+ "version": "5.7.10",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -152,6 +152,9 @@ Object.map(displayTypes,(c,k)=>{
152
152
  const dataSourceArgs = {};
153
153
  export const footerFieldName = "dgrid-fters-fields";
154
154
 
155
+ const checkPerm = (perm,args)=>{
156
+ return typeof perm ==='function'? perm(args) : isNonNullString(perm) ? Auth.isAllowedFromStr(perm) : typeof perm =='boolean'? perm : true;
157
+ }
155
158
 
156
159
  /*****
157
160
  * Pour spécifier qu'un champ du datagrid n'existe pas en bd il s'ufit de suffixer le nom du champ par le suffix : "FoundInDB" et de renseigner false comme valeur
@@ -165,9 +168,10 @@ export default class CommonDatagridComponent extends AppComponent {
165
168
  let {
166
169
  data,
167
170
  selectedRows,
168
- chartAllowedPerm,
169
- exportToPDFAllowedPerm,
170
- exportToExcelAllowedPerm,
171
+ renderChartIsAllowed,
172
+ exportToPDFIsAllowed,
173
+ exportToExcelIsAllowed,
174
+ renderSectionListIsAllowed,
171
175
  ...rest
172
176
  } = props;
173
177
  if(this.bindResizeEvents()){
@@ -198,9 +202,11 @@ export default class CommonDatagridComponent extends AppComponent {
198
202
  });
199
203
  const disTypes = {};
200
204
  let hasFoundDisplayTypes = false;
201
- const perm = isNonNullString(chartAllowedPerm)? Auth.isAllowedFromStr(chartAllowedPerm) : true;
202
- const ePDFIsAllowed = isNonNullString(exportToPDFAllowedPerm)? Auth.isAllowedFromStr(exportToPDFAllowedPerm) : true;
203
- const eExcelISAllowed = isNonNullString(exportToExcelAllowedPerm)? Auth.isAllowedFromStr(exportToExcelAllowedPerm) : true;
205
+ const pArgs = {context:this,data,props:this.props}
206
+ const perm = checkPerm(renderChartIsAllowed,pArgs)
207
+ const ePDFIsAllowed = checkPerm(exportToPDFIsAllowed,pArgs);
208
+ const eExcelISAllowed = checkPerm(exportToExcelIsAllowed,pArgs);
209
+ const renderSectionListIsAllowedP = checkPerm(renderSectionListIsAllowed,pArgs);
204
210
  Object.map(this.props.displayTypes,(dType,v)=>{
205
211
  if(isNonNullString(dType)){
206
212
  dType = dType.toLowerCase().trim();
@@ -247,6 +253,7 @@ export default class CommonDatagridComponent extends AppComponent {
247
253
  isChartAllowed : {value : perm},
248
254
  isExcellExportAllowed : {value:eExcelISAllowed},
249
255
  isPDFExportAllowed : {value: ePDFIsAllowed},
256
+ renderSectionListIsAllowed : {value:renderSectionListIsAllowedP},
250
257
  currentFilteringColumns : {value:{}},
251
258
  emptySectionListHeaderValue : {value : uniqid("empty-section-list-header-val").toUpperCase()},
252
259
  getSectionListHeaderProp : {value : typeof this.props.getSectionListHeader =='function'? this.props.getSectionListHeader : undefined},
@@ -2367,6 +2374,7 @@ export default class CommonDatagridComponent extends AppComponent {
2367
2374
  }
2368
2375
  /*** permet d'effectuer le rendu des colonnes groupable dans le menu item */
2369
2376
  renderSectionListMenu(){
2377
+ if(!this.renderSectionListIsAllowed) return null;
2370
2378
  const m = Array.isArray(this.preparedColumns?.sectionListColumnsMenuItems)? this.preparedColumns?.sectionListColumnsMenuItems : [];
2371
2379
  const mm = [];
2372
2380
  Object.map(m,(_)=>{
@@ -2744,7 +2752,7 @@ export default class CommonDatagridComponent extends AppComponent {
2744
2752
  if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
2745
2753
  return;
2746
2754
  }
2747
- if(hasSectionColumns){
2755
+ if(hasSectionColumns && this.renderSectionListIsAllowed){
2748
2756
  let sHeader = this.getSectionListHeader({config,data:d,columnsLength : sectionListColumnsSize,fieldsSize:sectionListColumnsSize,sectionListColumnsLength:sectionListColumnsSize,sectionListColumnsSize,allData:data,rowData:d,index:i,rowIndex,context:this,columns,fields:columns});
2749
2757
  if(sHeader === false) return;//on omet la donnée si la fonction de récupération de son header retourne false
2750
2758
  if(!isNonNullString(sHeader) || sHeader.toLowerCase().trim() =="undefined"){
@@ -3995,11 +4003,28 @@ CommonDatagridComponent.propTypes = {
3995
4003
  sectionListHeadersSeries : PropTypes.arrayOf(PropTypes.string),
3996
4004
  }),
3997
4005
  /*** la permission autorisée pour l'export en pdf */
3998
- exportToPDFAllowedPerm : PropTypes.string,
4006
+ exportToPDFIsAllowed : PropTypes.oneOfType([
4007
+ PropTypes.string,
4008
+ PropTypes.func,
4009
+ PropTypes.bool,
4010
+ ]),
3999
4011
  /*** la permission autorisée pour l'export en excel*/
4000
- exportToExcelAllowedPerm : PropTypes.string,
4012
+ exportToExcelIsAllowed : PropTypes.oneOfType([
4013
+ PropTypes.string,
4014
+ PropTypes.func,
4015
+ PropTypes.bool,
4016
+ ]),
4017
+ renderSectionListIsAllowed : PropTypes.oneOfType([
4018
+ PropTypes.string,
4019
+ PropTypes.func,
4020
+ PropTypes.bool,
4021
+ ]),
4001
4022
  /*** la permission que doit avoir l'utilisateur pour pouvoir visualiser les graphes à partir du diagrame */
4002
- chartAllowedPerm : PropTypes.string,
4023
+ renderChartIsAllowed : PropTypes.oneOfType([
4024
+ PropTypes.string,
4025
+ PropTypes.func,
4026
+ PropTypes.bool,
4027
+ ]),
4003
4028
  displayType : chartDisplayType,
4004
4029
  /*** les types d'afichates supportés par l'application */
4005
4030
  displayTypes : PropTypes.arrayOf(chartDisplayType),
@@ -66,10 +66,10 @@ export default function PhoneInputComponent(props){
66
66
  contentContainerProps.style = [styles.inputContainer,contentContainerProps.style];
67
67
  const ref = React.useRef(null);
68
68
  const [state,setState] = React.useState({
69
- visible : false,
70
69
  ...prepareState({defaultValue,country})
71
- })
72
- const prevVisible = React.usePrevious(state.visible);
70
+ });
71
+ const [visible,setVisible] = React.useState(false);
72
+ const prevVisible = React.usePrevious(visible);
73
73
  label = defaultVal(label,text);
74
74
  React.useEffect(()=>{
75
75
  React.setRef(ref,ref.current,setRef);
@@ -82,8 +82,8 @@ export default function PhoneInputComponent(props){
82
82
  }
83
83
  },[defaultValue,country])
84
84
  const onPressFlag = (e)=>{
85
- if(!state.visible){
86
- setState({...state,visible:true})
85
+ if(!visible){
86
+ setVisible(true);
87
87
  }
88
88
  }
89
89
  inputProps = defaultObj(inputProps);
@@ -131,12 +131,17 @@ export default function PhoneInputComponent(props){
131
131
  return <SelectCountry
132
132
  label = {label}
133
133
  controlled = {true}
134
- visible = {state.visible}
134
+ visible = {visible}
135
135
  defaultValue = {state.country}
136
136
  testID = {testID+"_SelectCountry"}
137
137
  onDismiss = {({value},force) =>{
138
- if(force !== true && value === state.country && state.visible == prevVisible) return;
139
- setState({...state,...prepareState({country:value,defaultValue:state.country==value?state.defaultValue:""}),visible:false})
138
+ if(force !== true && value === state.country && visible == prevVisible) return;
139
+ if(visible){
140
+ setVisible(false);
141
+ }
142
+ }}
143
+ onChange = {({value})=>{
144
+ setState({...state,...prepareState({country:value,defaultValue:state.country==value?state.defaultValue:""})});
140
145
  }}
141
146
  anchor = {
142
147
  <>
@@ -16,13 +16,15 @@ import { matchOperators,getSearchTimeout,canAutoFocusSearchField} from "$ecompon
16
16
  import Dialog from "$ecomponents/Dialog";
17
17
 
18
18
  const SimpleSelect = React.forwardRef((props,ref)=>{
19
- let {style : customStyle,onMount,mode,showSearch,anchorContainerProps,renderText,contentContainerProps,withCheckedIcon,testID,selectionColor,dialogProps,onShow,anchor,onUnmont,controlled,onDismiss,visible:controlledVisible,selectedColor,inputProps,itemProps,itemContainerProps,label,listProps,editable,readOnly,text,filter,renderItem,itemValue,getItemValue,defaultValue,items:menuItems,onPress,onChange,disabled,...rest} = props;
19
+ let {style : customStyle,onMount,mode,showSearch,anchorContainerProps,renderText,contentContainerProps,withCheckedIcon,testID,selectionColor,dialogProps,onShow,anchor,onUnmont,controlled:cr,onDismiss,visible:controlledVisible,selectedColor,inputProps,itemProps,itemContainerProps,label,listProps,editable,readOnly,text,filter,renderItem,itemValue,getItemValue,defaultValue,items:menuItems,onPress,onChange,disabled,...rest} = props;
20
20
  const flattenStyle = StyleSheet.flatten(customStyle) || {};
21
+ const controlledRef = React.useRef(typeof controlledVisible ==='boolean'? true : false);
22
+ const controlled = controlledRef.current;
21
23
  const [layout,setLayout] = React.useState({
22
24
  height: 0,
23
25
  width: 0,
24
26
  });
25
- const [visible,setVisible] = React.useState(controlled?controlledVisible:false)
27
+ const [visible,setVisible] = controlled ? [controlledVisible] : React.useState(controlled?controlledVisible:false);
26
28
  const [value,setValue] = React.useState(defaultValue !== undefined? defaultValue:undefined);
27
29
  contentContainerProps = defaultObj(contentContainerProps);
28
30
  const prevLayout = React.usePrevious(layout);
@@ -94,13 +96,12 @@ const SimpleSelect = React.forwardRef((props,ref)=>{
94
96
  if(update !== true && compare(value,node.value)) return;
95
97
  selectedRef.current = node;
96
98
  if(update === true){
99
+ setValue(node.value);
97
100
  if(controlled && onDismiss){
98
101
  if(onDismiss({visible,value,items,defaultValue},defaultObj(selectedRef.current)) === false) return;
99
102
  }
100
- setValue(node.value);
101
- const vv = controlled?undefined:false;
102
- if(typeof vv =='boolean' && vv !==visible){
103
- setVisible(vv);
103
+ if(!controlled && visible){
104
+ setVisible(false);
104
105
  }
105
106
  }
106
107
  }