@fto-consult/expo-ui 2.24.0 → 2.24.1
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 +1 -1
- package/src/components/Chart/appexChart/index.js +10 -12
- package/src/components/Chart/appexChart/index.native.js +9 -6
- package/src/components/Chart/appexChart/utils.js +15 -0
- package/src/components/Chart/index.js +17 -10
- package/src/components/Countries/resources/countries-normalized.json +1987 -1987
- package/src/components/Countries/resources/countries-with-not-extra.json +1211 -1211
- package/src/components/Countries/resources/countries.sql +243 -243
- package/src/components/Datagrid/Common/Common.js +95 -48
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import ApexChart from 'apexcharts/dist/apexcharts.common';
|
|
2
2
|
import React from "$react";
|
|
3
|
-
import View from "$components/View"
|
|
3
|
+
import View from "$components/View";
|
|
4
|
+
import { destroyChart } from './utils';
|
|
5
|
+
import theme from "$theme";
|
|
4
6
|
|
|
5
|
-
const AppexChartComponent = React.forwardRef(({chartContext,options,...props},ref)=>{
|
|
6
|
-
const
|
|
7
|
+
const AppexChartComponent = React.forwardRef(({chartContext,style,options,...props},ref)=>{
|
|
8
|
+
const viewRef = React.useRef(null);
|
|
7
9
|
React.useEffect(()=>{
|
|
8
|
-
chartContext.current = new ApexChart(
|
|
10
|
+
chartContext.current = new ApexChart(viewRef.current,options)
|
|
9
11
|
chartContext.current.render();
|
|
12
|
+
React.setRef(ref,chartContext.current)
|
|
10
13
|
return ()=>{
|
|
11
|
-
|
|
12
|
-
setTimeout(()=>{
|
|
13
|
-
try {
|
|
14
|
-
if(typeof chartContext.current?.destroy =='function') chartContext.current.destroy();
|
|
15
|
-
} catch{}
|
|
16
|
-
},1000);
|
|
17
|
-
}
|
|
14
|
+
destroyChart(chartContext.current);
|
|
18
15
|
}
|
|
19
16
|
},[]);
|
|
20
17
|
return <View
|
|
21
18
|
{...props}
|
|
22
|
-
|
|
19
|
+
style = {[theme.styles.pb1,style]}
|
|
20
|
+
ref = {viewRef}
|
|
23
21
|
/>
|
|
24
22
|
});
|
|
25
23
|
|
|
@@ -3,11 +3,12 @@ import React from "$react";
|
|
|
3
3
|
import WebView from "$ecomponents/WebView";
|
|
4
4
|
import {defaultStr,defaultObj,uniqid} from "$utils";
|
|
5
5
|
import View from "$ecomponents/View";
|
|
6
|
+
import { methodsNames } from "./utils";
|
|
6
7
|
|
|
7
|
-
export const ChartComponent = React.forwardRef(({chartContext,testID,webViewProps,options,...props},ref)=>{
|
|
8
|
+
export const ChartComponent = React.forwardRef(({chartContext,testID,chartId,id,webViewProps,options,...props},ref)=>{
|
|
8
9
|
webViewProps = defaultObj(webViewProps);
|
|
9
10
|
const webViewRef = React.useRef(null);
|
|
10
|
-
const chartId = React.useRef(uniqid("chart-webview-id"));
|
|
11
|
+
const chartId = React.useRef(defaultStr(chartId,id,options?.chart?.id,uniqid("chart-webview-id")));
|
|
11
12
|
const jsonOptions = JSON.stringify(options);
|
|
12
13
|
const exec = (method,a)=>{
|
|
13
14
|
if(!webViewRef.current) return;
|
|
@@ -33,12 +34,14 @@ export const ChartComponent = React.forwardRef(({chartContext,testID,webViewProp
|
|
|
33
34
|
testID = defaultStr(testID,"RN_AppexChartComponentNative");
|
|
34
35
|
chartContext.current = React.useRef({});
|
|
35
36
|
chartContext.current.exec = exec;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
//@see : https://apexcharts.com/docs/methods/
|
|
38
|
+
methodsNames.map((cb)=>{
|
|
39
|
+
if(cb !=='exec'){
|
|
40
|
+
chartContext.current[cb]=(a,b,c,d,e)=>{
|
|
41
|
+
return exec(cb,a,b,c,d,e);
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
});
|
|
41
|
-
|
|
42
45
|
return <View ref={ref} {...props} testID={testID} style={[{flex:1},props.style]}>
|
|
43
46
|
<WebView.Local
|
|
44
47
|
originWhitelist={["*"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
import {defaultNumber} from "$utils";
|
|
5
|
+
export const methodsNames = ["updateOptions","updateSeries","destroy","render","exec","appendSeries","toggleSeries","showSeries","hideSeries","zoomX","resetSeries","appendData","toggleDataPointSelection","addXaxisAnnotation","addYaxisAnnotation","addPointAnnotation","removeAnnotation","clearAnnotations","dataURI","clearAnnotations",""];
|
|
6
|
+
|
|
7
|
+
export const destroyChart = (chartContext,timeout)=>{
|
|
8
|
+
if (chartContext && typeof chartContext =='object' && typeof chartContext.destroy === 'function') {
|
|
9
|
+
setTimeout(()=>{
|
|
10
|
+
try {
|
|
11
|
+
chartContext.destroy();
|
|
12
|
+
} catch{}
|
|
13
|
+
},defaultNumber(timeout,1000));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -3,12 +3,15 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import {defaultStr,defaultVal,extendObj,defaultObj,uniqid,defaultNumber} from "$utils";
|
|
4
4
|
import stableHash from 'stable-hash';
|
|
5
5
|
import Chart from "./appexChart";
|
|
6
|
+
import theme from "$theme";
|
|
7
|
+
import { destroyChart } from './appexChart/utils';
|
|
6
8
|
|
|
7
9
|
export * from "./utils";
|
|
8
10
|
|
|
9
11
|
/**** pour le rendu webview chart, voir : https://github.com/flexmonster/react-native-flexmonster/blob/master/src/index.js */
|
|
10
12
|
/**** le composant Chart s'appuie sur le composant appexChart : https://apexcharts.com/
|
|
11
13
|
* pour le formattage des date, voir : https://apexcharts.com/docs/datetime/
|
|
14
|
+
* @see : https://apexcharts.com/docs/methods/
|
|
12
15
|
* les props requis duduit composant sont :
|
|
13
16
|
* type {string}, le type de chart
|
|
14
17
|
* series {array} - //les series appexchart
|
|
@@ -17,24 +20,28 @@ export * from "./utils";
|
|
|
17
20
|
* options {number} - les options supplémentaires au chart
|
|
18
21
|
*
|
|
19
22
|
*/
|
|
20
|
-
const ChartComponent = React.forwardRef(({options
|
|
23
|
+
const ChartComponent = React.forwardRef(({options,style,height,width,chartId:customChartID,testID,webViewProps, ...props },ref)=>{
|
|
21
24
|
const chartContext = React.useRef(null);
|
|
22
|
-
const {series,xaxis:customXaxis,...options} = customOptions;
|
|
23
|
-
const xaxis = defaultObj(customXaxis);
|
|
24
25
|
options.chart = defaultObj(options.chart);
|
|
25
|
-
const chartIdRef = React.useRef(
|
|
26
|
+
const chartIdRef = React.useRef(options.chart.id,customChartID,uniqid("chart-id"));
|
|
27
|
+
const chartId = chartIdRef.current;
|
|
26
28
|
width = options.chart.width = defaultVal(options.chart.width,width);
|
|
27
29
|
height = options.chart.height = defaultVal(options.chart.height,height)
|
|
28
|
-
options.chart.id =
|
|
30
|
+
options.chart.id = chartId;
|
|
29
31
|
testID = defaultStr(testID,"RN_ChartComponent");
|
|
30
|
-
options.xaxis = xaxis;
|
|
31
|
-
options.series = series;
|
|
32
32
|
React.useEffect(()=>{
|
|
33
|
-
if(chartContext.current
|
|
33
|
+
if(chartContext.current){
|
|
34
|
+
if(chartContext.current.updateOptions){
|
|
34
35
|
chartContext.current.updateOptions(options);
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
|
-
},[stableHash(options)])
|
|
37
|
-
|
|
38
|
+
},[stableHash(options)]);
|
|
39
|
+
React.useEffect(()=>{
|
|
40
|
+
return ()=>{
|
|
41
|
+
destroyChart(chartContext.current);
|
|
42
|
+
}
|
|
43
|
+
},[])
|
|
44
|
+
return <Chart {...props} ref={ref} chartId={chartId} style={[theme.styles.pb1,style]} options={options} chartContext={chartContext} testID={testID}/>
|
|
38
45
|
});
|
|
39
46
|
|
|
40
47
|
|