bento-charts 1.0.3 → 1.0.5
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { ChartTheme, LngDictionary, TranslationObject } from
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChartTheme, LngDictionary, TranslationObject } from "./types/chartTypes";
|
|
3
|
+
export declare function useChartTheme(): ChartTheme;
|
|
4
|
+
export declare function useChartTranslation(): LngDictionary;
|
|
5
5
|
declare const ChartConfigProvider: ({ theme, Lng, translationMap, children, }: {
|
|
6
6
|
theme?: ChartTheme | undefined;
|
|
7
7
|
Lng: string;
|
|
@@ -10,20 +10,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import React, { useContext } from
|
|
14
|
-
import { DEFAULT_CHART_THEME, defaultTranslationObject } from
|
|
13
|
+
import React, { useContext } from "react";
|
|
14
|
+
import { DEFAULT_CHART_THEME, defaultTranslationObject, } from "./constants/chartConstants";
|
|
15
15
|
var ChartThemeContext = React.createContext(DEFAULT_CHART_THEME);
|
|
16
|
-
export
|
|
16
|
+
export function useChartTheme() {
|
|
17
|
+
return useContext(ChartThemeContext);
|
|
18
|
+
}
|
|
17
19
|
var ChartTranslationContext = React.createContext(defaultTranslationObject.en);
|
|
18
|
-
export
|
|
20
|
+
export function useChartTranslation() {
|
|
21
|
+
return useContext(ChartTranslationContext);
|
|
22
|
+
}
|
|
19
23
|
var ChartConfigProvider = function (_a) {
|
|
20
|
-
var _b = _a.theme, theme = _b === void 0 ?
|
|
21
|
-
var lang =
|
|
24
|
+
var _b = _a.theme, theme = _b === void 0 ? DEFAULT_CHART_THEME : _b, Lng = _a.Lng, translationMap = _a.translationMap, children = _a.children;
|
|
25
|
+
var lang = "en";
|
|
22
26
|
try {
|
|
23
27
|
lang = Lng;
|
|
24
28
|
}
|
|
25
29
|
catch (e) {
|
|
26
|
-
console.error(
|
|
30
|
+
console.error("Lng is not a supported language");
|
|
27
31
|
}
|
|
28
32
|
return (_jsx(ChartThemeContext.Provider, __assign({ value: theme }, { children: _jsx(ChartTranslationContext.Provider, __assign({ value: translationMap ? translationMap[lang] : defaultTranslationObject[lang] }, { children: children })) })));
|
|
29
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartConfigProvider.js","sourceRoot":"","sources":["../src/ChartConfigProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartConfigProvider.js","sourceRoot":"","sources":["../src/ChartConfigProvider.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAQpC,IAAM,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAa,mBAAmB,CAAC,CAAC;AAC/E,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACvC,CAAC;AAED,IAAM,uBAAuB,GAAG,KAAK,CAAC,aAAa,CACjD,wBAAwB,CAAC,EAAE,CAC5B,CAAC;AACF,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAC7C,CAAC;AAED,IAAM,mBAAmB,GAAG,UAAC,EAU5B;QATC,aAA2B,EAA3B,KAAK,mBAAG,mBAAmB,KAAA,EAC3B,GAAG,SAAA,EACH,cAAc,oBAAA,EACd,QAAQ,cAAA;IAOR,IAAI,IAAI,GAAiB,IAAI,CAAC;IAC9B,IAAI;QACF,IAAI,GAAG,GAAmB,CAAC;KAC5B;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC;KAClD;IACD,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,aAAC,KAAK,EAAE,KAAK,gBACtC,KAAC,uBAAuB,CAAC,QAAQ,aAC/B,KAAK,EACH,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,gBAGvE,QAAQ,IACwB,IACR,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import React, { useContext } from
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_CHART_THEME,
|
|
5
|
+
defaultTranslationObject,
|
|
6
|
+
} from "./constants/chartConstants";
|
|
7
|
+
import {
|
|
8
|
+
ChartTheme,
|
|
9
|
+
LngDictionary,
|
|
10
|
+
SupportedLng,
|
|
11
|
+
TranslationObject,
|
|
12
|
+
} from "./types/chartTypes";
|
|
5
13
|
|
|
6
14
|
const ChartThemeContext = React.createContext<ChartTheme>(DEFAULT_CHART_THEME);
|
|
7
|
-
export
|
|
15
|
+
export function useChartTheme() {
|
|
16
|
+
return useContext(ChartThemeContext);
|
|
17
|
+
}
|
|
8
18
|
|
|
9
|
-
const ChartTranslationContext = React.createContext<LngDictionary>(
|
|
10
|
-
|
|
19
|
+
const ChartTranslationContext = React.createContext<LngDictionary>(
|
|
20
|
+
defaultTranslationObject.en
|
|
21
|
+
);
|
|
22
|
+
export function useChartTranslation() {
|
|
23
|
+
return useContext(ChartTranslationContext);
|
|
24
|
+
}
|
|
11
25
|
|
|
12
26
|
const ChartConfigProvider = ({
|
|
13
|
-
theme =
|
|
27
|
+
theme = DEFAULT_CHART_THEME,
|
|
14
28
|
Lng,
|
|
15
29
|
translationMap,
|
|
16
30
|
children,
|
|
@@ -20,15 +34,19 @@ const ChartConfigProvider = ({
|
|
|
20
34
|
translationMap?: TranslationObject;
|
|
21
35
|
children: React.ReactElement;
|
|
22
36
|
}) => {
|
|
23
|
-
let lang: SupportedLng =
|
|
37
|
+
let lang: SupportedLng = "en";
|
|
24
38
|
try {
|
|
25
39
|
lang = Lng as SupportedLng;
|
|
26
40
|
} catch (e) {
|
|
27
|
-
console.error(
|
|
41
|
+
console.error("Lng is not a supported language");
|
|
28
42
|
}
|
|
29
43
|
return (
|
|
30
44
|
<ChartThemeContext.Provider value={theme}>
|
|
31
|
-
<ChartTranslationContext.Provider
|
|
45
|
+
<ChartTranslationContext.Provider
|
|
46
|
+
value={
|
|
47
|
+
translationMap ? translationMap[lang] : defaultTranslationObject[lang]
|
|
48
|
+
}
|
|
49
|
+
>
|
|
32
50
|
{children}
|
|
33
51
|
</ChartTranslationContext.Provider>
|
|
34
52
|
</ChartThemeContext.Provider>
|