@fto-consult/expo-ui 2.21.3 → 2.23.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/appConfig.txt ADDED
@@ -0,0 +1,14 @@
1
+ // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ /**** l'ENSEMBLE DES CONFIGURATIONS SUPPORTES, fichier appConfig***/
6
+
7
+ {
8
+
9
+ /*** le nombre maximal de courbes qu'on peut afficher sur le même graphe***/
10
+ maxSupportedChartSeries {number}
11
+
12
+ /***les fonctions d'aggregations du datagrid**/
13
+ datagridAggregatorFunctions : {objectOf({code:{string},label:{string},eval:{function}})|| arrayOf({code:{string},label:{string},eval:{function}})}
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.21.3",
3
+ "version": "2.23.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,7 +10,9 @@ const AppexChartComponent = React.forwardRef(({chartContext,options,...props},re
10
10
  return ()=>{
11
11
  if (chartContext.current && typeof chartContext.current.destroy === 'function') {
12
12
  setTimeout(()=>{
13
- try {chartContext.current.destroy();} catch{}
13
+ try {
14
+ if(typeof chartContext.current?.destroy =='function') chartContext.current.destroy();
15
+ } catch{}
14
16
  },1000);
15
17
  }
16
18
  }
@@ -1,10 +1,11 @@
1
1
  import React from '$react'
2
2
  import PropTypes from 'prop-types'
3
3
  import {defaultStr,defaultVal,extendObj,defaultObj,uniqid,defaultNumber} from "$utils";
4
- import {extend} from "./utils"
5
4
  import stableHash from 'stable-hash';
6
5
  import Chart from "./appexChart";
7
6
 
7
+ export * from "./utils";
8
+
8
9
  /**** pour le rendu webview chart, voir : https://github.com/flexmonster/react-native-flexmonster/blob/master/src/index.js */
9
10
  /**** le composant Chart s'appuie sur le composant appexChart : https://apexcharts.com/
10
11
  * pour le formattage des date, voir : https://apexcharts.com/docs/datetime/
@@ -16,35 +17,23 @@ import Chart from "./appexChart";
16
17
  * options {number} - les options supplémentaires au chart
17
18
  *
18
19
  */
19
- const ChartComponent = React.forwardRef(({options,height,width,chartId,testID,webViewProps, ...props },ref)=>{
20
+ const ChartComponent = React.forwardRef(({options:customOptions,height,width,chartId,testID,webViewProps, ...props },ref)=>{
20
21
  const chartContext = React.useRef(null);
21
- options = defaultObj(options);
22
- const series = options.series;
22
+ const {series,xaxis:customXaxis,...options} = customOptions;
23
+ const xaxis = defaultObj(customXaxis);
23
24
  options.chart = defaultObj(options.chart);
24
25
  const chartIdRef = React.useRef(defaultStr(chartId,options.chart.id,uniqid("chart-id")));
25
26
  width = options.chart.width = defaultVal(options.chart.width,width);
26
27
  height = options.chart.height = defaultVal(options.chart.height,height)
27
28
  options.chart.id = chartIdRef.current;
28
29
  testID = defaultStr(testID,"RN_ChartComponent");
29
- const prevWidth = React.usePrevious(width), prevHeight = React.usePrevious(height);
30
- const prevOptions = React.usePrevious(options,JSON.stringify);
31
- const prevSeries = React.usePrevious(series,JSON.stringify);
32
- /***change size chart, @see : https://apexcharts.com/docs/chart-types/line-chart/ */
33
- options.xaxis = defaultObj(options.xaxis);
34
- options.xaxis.stroke = defaultObj(options.xaxis.stroke);
35
- options.xaxis.stroke.width = defaultNumber(options.xaxis.stroke.width,2);
36
- options.xaxis.stroke.height = defaultNumber(options.xaxis.height,1);
37
-
38
- console.log(options,' is optssss');
30
+ options.xaxis = xaxis;
31
+ options.series = series;
39
32
  React.useEffect(()=>{
40
33
  if(chartContext.current && chartContext.current.updateOptions){
41
- if((prevSeries == series) || width != prevWidth || height != prevHeight){
42
- chartContext.current.updateOptions(options);
43
- } else if(prevOptions != options){
44
- chartContext.current.updateSeries(series);
45
- }
34
+ chartContext.current.updateOptions(options);
46
35
  }
47
- },[stableHash({options,series,width,height})])
36
+ },[stableHash(options)])
48
37
  return <Chart {...props} options={options} chartId={chartIdRef.current} chartContext={chartContext} testID={testID} ref={ref}/>
49
38
  });
50
39
 
@@ -1,25 +1,14 @@
1
1
  // Copyright 2022 @fto-consult/Boris Fouomene. All rights reserved.
2
2
  // Use of this source code is governed by a BSD-style
3
3
  // license that can be found in the LICENSE file.
4
- import {isObj} from "$utils";
5
- export function extend (target,source){
6
- const output = Object.assign({}, target);
7
- if (isObj(target) && isObj(source)) {
8
- Object.keys(source).forEach((key) => {
9
- if (isObj(source[key])) {
10
- if (!(key in target)) {
11
- Object.assign(output, {
12
- [key]: source[key]
13
- })
14
- } else {
15
- output[key] = this.extend(target[key], source[key])
16
- }
17
- } else {
18
- Object.assign(output, {
19
- [key]: source[key]
20
- })
21
- }
22
- })
23
- }
24
- return output
4
+ import {isObj,defaultNumber} from "$utils";
5
+ import appConfig from "$app/config";
6
+
7
+ /*** retourne le nombre maximal de courbes pouvant s'afficher sur un même graphe
8
+ * exempt du graphe de type pie/donut
9
+ * par défaut, on peut afficher au maximum 5 courbes sur le même graphe
10
+ */
11
+ export const getMaxSupportedSeriesSize = ()=>{
12
+ const m = defaultNumber(appConfig.get("maxSupportedChartSeries"));
13
+ return m > 3 ? m : 5;
25
14
  }
@@ -263,13 +263,13 @@ const DatagridFactory = (Factory)=>{
263
263
  this.isUpdating = false;
264
264
  return;
265
265
  }
266
- this.setSessionData({showFilter:true});
266
+ this.setSessionData({showFilters:true});
267
267
  }
268
268
  hideFilters (){
269
269
  if(!this._isMounted()) {
270
270
  return;
271
271
  }
272
- this.setSessionData({showFilter:false});
272
+ this.setSessionData({showFilters:false});
273
273
  }
274
274
  toggleFilterColumnVisibility(field,visible){
275
275
  if(!isNonNullString(field)) return;
@@ -344,7 +344,7 @@ const DatagridFactory = (Factory)=>{
344
344
  } = this.props
345
345
  chartContainerProps = defaultObj(chartContainerProps);
346
346
  const canRenderChart = this.canRenderChart();
347
- const hasData = this.state.data.length ? true : false;
347
+ const hasData = this.getStateDataSize(false) ? true : false;
348
348
  testID = defaultStr(testID,"RN_DatagridAccordion");
349
349
  backToTopProps = defaultObj(backToTopProps);
350
350
  accordionProps = defaultObj(accordionProps);
@@ -399,7 +399,8 @@ const DatagridFactory = (Factory)=>{
399
399
  let exportTableProps = this.getExportableProps();
400
400
 
401
401
  filter = defaultFunc(filter,x=>true);
402
- let {showFilters,showFooters} = this.state;
402
+ const showFooters = this.canShowFooters();
403
+ const showFilters = this.canShowFilters();
403
404
  let max = this.getMaxSelectableRows();
404
405
  let restItems = [];
405
406
 
@@ -438,13 +439,13 @@ const DatagridFactory = (Factory)=>{
438
439
  filteredColumns,
439
440
  filters :headerFilters,
440
441
  } = this.preparedColumns;
441
- const hasFooterFields = this.hasFooterFields();
442
+ const hasFootersFields = this.hasFootersFields();
442
443
  const datagridHeader = <View testID={testID+"_HeaderContainer"} pointerEvents={pointerEvents} style={[styles.datagridHeader]}>
443
444
  <ScrollView testID={testID+"_HeaderScrollView"} horizontal contentContainerStyle={StyleSheet.flatten([styles.contentContainerStyle,styles.minW100])}>
444
445
  <View testID={testID+"_HeaderContentCntainer"} style={[styles.table,styles.pullRight]}>
445
446
  {dbSelector}
446
447
  <View testID={testID+"_HeaderQueryLimit"} style={[styles.paginationItem]}>
447
- {this.renderQueryLimit(this.state.data.length.formatNumber())}
448
+ {this.renderQueryLimit(this.getStateDataSize().formatNumber())}
448
449
  </View>
449
450
  {this.renderCustomPagination()}
450
451
  {sortedColumnsLength ? <View testID={testID+"_HeaderSortedColumns"} style={[styles.sortableItems,styles.paginationItem,{paddingRight:10}]}>
@@ -513,11 +514,12 @@ const DatagridFactory = (Factory)=>{
513
514
  items : visibleColumns,
514
515
  closeOnPress : false,
515
516
  } : null,
516
- !canRenderChart && hasFooterFields ? {
517
+ !canRenderChart && hasFootersFields ? {
517
518
  onPress : ()=>{this.toggleFooters(!showFooters)}
518
519
  ,icon : showFooters?'view-column':'view-module'
519
- ,text : (showFooters?'Masquer/Ligne des totaux':'Afficher/Ligne des totaux')
520
+ ,text : (showFooters?'Masquer les totaux':'Afficher les totaux')
520
521
  }:null,
522
+ ...this.getAggregatorFunctionsMenuItems(),
521
523
  ...this.renderCustomMenu(),
522
524
  ...restItems,
523
525
  !canRenderChart && this.canScrollTo() && {
@@ -583,6 +585,8 @@ const DatagridFactory = (Factory)=>{
583
585
  key = {field}
584
586
  testID={testID+"_FooterItem_"+field}
585
587
  {...footer}
588
+ aggregatorFunction = {this.getActiveAggregatorFunction().code}
589
+ aggregatorFunctions = {this.aggregatorFunctions}
586
590
  anchorProps = {{style:[theme.styles.ph1,theme.styles.mh05]}}
587
591
  />
588
592
  })}