@fto-consult/expo-ui 2.21.2 → 2.22.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,11 @@
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.21.2",
3
+ "version": "2.22.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,7 +61,7 @@
61
61
  "@emotion/native": "^11.10.0",
62
62
  "@expo/html-elements": "^0.2.0",
63
63
  "@expo/vector-icons": "^13.0.0",
64
- "@fto-consult/common": "^1.23.9",
64
+ "@fto-consult/common": "^1.23.10",
65
65
  "@fto-consult/expo-ui": "^2.21.0",
66
66
  "@gorhom/portal": "^1.0.14",
67
67
  "@react-native-async-storage/async-storage": "~1.17.3",
@@ -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
  }