qaema-ui 0.0.10 → 0.0.12
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/dist/components/Chart.d.ts +9 -3
- package/dist/components/Chart.d.ts.map +1 -1
- package/dist/components/Chart.js +153 -164
- package/dist/components/ChartLegend/ChartLegend.d.ts +10 -0
- package/dist/components/ChartLegend/ChartLegend.d.ts.map +1 -0
- package/dist/components/ChartLegend/ChartLegend.js +28 -0
- package/dist/components/ChartLegend/PieChartLegend.d.ts +14 -0
- package/dist/components/ChartLegend/PieChartLegend.d.ts.map +1 -0
- package/dist/components/ChartLegend/PieChartLegend.js +27 -0
- package/dist/components/ChartLegend/index.d.ts +4 -0
- package/dist/components/ChartLegend/index.d.ts.map +1 -0
- package/dist/components/ChartLegend/styles.d.ts +6 -0
- package/dist/components/ChartLegend/styles.d.ts.map +1 -0
- package/dist/components/ChartLegend/styles.js +107 -0
- package/package.json +1 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { default as React, ReactElement } from 'react';
|
|
2
2
|
type ChartType = 'area' | 'line' | 'bar' | 'pie';
|
|
3
3
|
type ChartDataType = {
|
|
4
|
-
|
|
5
|
-
y: string | number;
|
|
6
|
-
yy?: string | number;
|
|
4
|
+
[key: string]: string | number | undefined;
|
|
7
5
|
};
|
|
8
6
|
type PieDataType = {
|
|
9
7
|
name: string;
|
|
@@ -13,6 +11,12 @@ type PieDataType = {
|
|
|
13
11
|
export type ChartVariants = {
|
|
14
12
|
[key in ChartType]: React.ElementType;
|
|
15
13
|
};
|
|
14
|
+
export type LegendItem = {
|
|
15
|
+
name: string;
|
|
16
|
+
value?: string | number;
|
|
17
|
+
color?: string;
|
|
18
|
+
showRiyal?: boolean;
|
|
19
|
+
};
|
|
16
20
|
type BaseChartProps = {
|
|
17
21
|
xLabel?: string;
|
|
18
22
|
yLabel?: string;
|
|
@@ -27,6 +31,8 @@ type BaseChartProps = {
|
|
|
27
31
|
showLabels?: boolean;
|
|
28
32
|
showYYAxis?: boolean;
|
|
29
33
|
dateFormat?: 'dayMonth' | 'monthOnly';
|
|
34
|
+
yAxisId?: string | number;
|
|
35
|
+
legendItems?: Array<LegendItem>;
|
|
30
36
|
};
|
|
31
37
|
type PieChartProps = BaseChartProps & {
|
|
32
38
|
data: Array<PieDataType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/lib/components/Chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAgC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/lib/components/Chart.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,KAAK,YAAY,EAAgC,MAAM,OAAO,CAAC;AAuB/E,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjD,KAAK,aAAa,GAAG;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;KACzB,GAAG,IAAI,SAAS,GAAG,KAAK,CAAC,WAAW;CACtC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AASF,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CACjC,CAAC;AAMF,KAAK,aAAa,GAAG,cAAc,GAAG;IACpC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACvB,CAAC;AAEF,KAAK,eAAe,GAAG,cAAc,GAAG;IACtC,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IAC3B,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAsCzD,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAiQ/B,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/components/Chart.js
CHANGED
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
import { j as t } from "../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, E = W(U)`
|
|
28
|
-
direction: ltr;
|
|
29
|
-
margin-top: ${({ theme: l }) => l.spacing.sm};
|
|
30
|
-
margin-right: 0 !important;
|
|
31
|
-
margin-bottom: 0;
|
|
32
|
-
`, xt = ({ active: l, payload: m, label: u }) => l && m && m.length ? /* @__PURE__ */ t.jsxs(
|
|
2
|
+
import { useState as _, useMemo as T, useEffect as tt } from "react";
|
|
3
|
+
import et, { useTheme as rt } from "styled-components";
|
|
4
|
+
import { PieChart as B } from "../node_modules/recharts/es6/chart/PieChart.js";
|
|
5
|
+
import { BarChart as ot } from "../node_modules/recharts/es6/chart/BarChart.js";
|
|
6
|
+
import { LineChart as at } from "../node_modules/recharts/es6/chart/LineChart.js";
|
|
7
|
+
import { AreaChart as nt } from "../node_modules/recharts/es6/chart/AreaChart.js";
|
|
8
|
+
import { Pie as it } from "../node_modules/recharts/es6/polar/Pie.js";
|
|
9
|
+
import { Cell as st } from "../node_modules/recharts/es6/component/Cell.js";
|
|
10
|
+
import { Tooltip as P } from "../node_modules/recharts/es6/component/Tooltip.js";
|
|
11
|
+
import { PieChartLegend as lt } from "./ChartLegend/PieChartLegend.js";
|
|
12
|
+
import { ResponsiveContainer as dt } from "../node_modules/recharts/es6/component/ResponsiveContainer.js";
|
|
13
|
+
import { CartesianGrid as mt } from "../node_modules/recharts/es6/cartesian/CartesianGrid.js";
|
|
14
|
+
import { XAxis as ht } from "../node_modules/recharts/es6/cartesian/XAxis.js";
|
|
15
|
+
import { YAxis as U } from "../node_modules/recharts/es6/cartesian/YAxis.js";
|
|
16
|
+
import { Legend as ct } from "../node_modules/recharts/es6/component/Legend.js";
|
|
17
|
+
import { ChartLegend as pt } from "./ChartLegend/ChartLegend.js";
|
|
18
|
+
import { Area as ft } from "../node_modules/recharts/es6/cartesian/Area.js";
|
|
19
|
+
import { Line as v } from "../node_modules/recharts/es6/cartesian/Line.js";
|
|
20
|
+
import { Bar as W } from "../node_modules/recharts/es6/cartesian/Bar.js";
|
|
21
|
+
const gt = {
|
|
22
|
+
area: nt,
|
|
23
|
+
line: at,
|
|
24
|
+
bar: ot,
|
|
25
|
+
pie: B
|
|
26
|
+
}, xt = ({ active: m, payload: l, label: u }) => m && l && l.length ? /* @__PURE__ */ t.jsxs(
|
|
33
27
|
"div",
|
|
34
28
|
{
|
|
35
29
|
style: {
|
|
@@ -41,86 +35,87 @@ const ft = {
|
|
|
41
35
|
},
|
|
42
36
|
children: [
|
|
43
37
|
/* @__PURE__ */ t.jsx("p", { style: { margin: "0 0 5px 0", fontWeight: "bold" }, children: u }),
|
|
44
|
-
|
|
45
|
-
const
|
|
38
|
+
l.map((e, d) => {
|
|
39
|
+
const i = e.value || 0, b = Math.abs(i || 0), h = `${i < 0 ? "-" : ""}${b.toLocaleString("en-US", {
|
|
46
40
|
minimumFractionDigits: 2,
|
|
47
41
|
maximumFractionDigits: 2
|
|
48
42
|
})}`;
|
|
49
|
-
return /* @__PURE__ */ t.jsxs("p", { style: { margin: "3px 0", color:
|
|
50
|
-
|
|
43
|
+
return /* @__PURE__ */ t.jsxs("p", { style: { margin: "3px 0", color: e.color || "#7259FF" }, children: [
|
|
44
|
+
e.name,
|
|
51
45
|
": ",
|
|
52
|
-
|
|
53
|
-
] },
|
|
46
|
+
h
|
|
47
|
+
] }, d);
|
|
54
48
|
})
|
|
55
49
|
]
|
|
56
50
|
}
|
|
57
|
-
) : null,
|
|
58
|
-
var M, K, R, I, z, V;
|
|
59
|
-
const [
|
|
60
|
-
data:
|
|
61
|
-
type:
|
|
62
|
-
xLabel:
|
|
63
|
-
yLabel:
|
|
64
|
-
yyLabel:
|
|
65
|
-
strokeColor:
|
|
66
|
-
biaxialStrokeColor:
|
|
67
|
-
fillColor:
|
|
68
|
-
colors:
|
|
69
|
-
UserLegend:
|
|
70
|
-
barRadius:
|
|
51
|
+
) : null, Vt = (m) => {
|
|
52
|
+
var M, K, $, R, I, z, E, V;
|
|
53
|
+
const [l, u] = _(!1), e = rt(), {
|
|
54
|
+
data: d,
|
|
55
|
+
type: i,
|
|
56
|
+
xLabel: b,
|
|
57
|
+
yLabel: C,
|
|
58
|
+
yyLabel: h,
|
|
59
|
+
strokeColor: c = (($ = (K = (M = e == null ? void 0 : e.colors) == null ? void 0 : M.primary) == null ? void 0 : K.purple) == null ? void 0 : $.n450) || "#7259FF",
|
|
60
|
+
biaxialStrokeColor: j = e.colors.secondary.orange.n450,
|
|
61
|
+
fillColor: g = ((z = (I = (R = e == null ? void 0 : e.colors) == null ? void 0 : R.primary) == null ? void 0 : I.purple) == null ? void 0 : z.n100) || "red",
|
|
62
|
+
colors: a,
|
|
63
|
+
UserLegend: G,
|
|
64
|
+
barRadius: w = [10, 10, 10, 10],
|
|
71
65
|
yyDataKey: k = "yy",
|
|
72
|
-
yDataKey:
|
|
73
|
-
showLabels:
|
|
74
|
-
showYYAxis:
|
|
75
|
-
dateFormat:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
yDataKey: x = "y",
|
|
67
|
+
showLabels: F = !0,
|
|
68
|
+
showYYAxis: p = !0,
|
|
69
|
+
dateFormat: N = "dayMonth",
|
|
70
|
+
yAxisId: D,
|
|
71
|
+
legendItems: Y
|
|
72
|
+
} = m, y = T(() => i === "pie" ? [] : d.map((r) => ({
|
|
73
|
+
x: r.x,
|
|
74
|
+
y: typeof r.y == "string" ? Number.parseFloat(r.y.toString().replace(/,/g, "")) : r.y
|
|
75
|
+
})), [d, i]), f = y.length > 5;
|
|
76
|
+
tt(() => {
|
|
77
|
+
const r = () => {
|
|
82
78
|
u(window.innerWidth < 768);
|
|
83
79
|
};
|
|
84
|
-
return
|
|
80
|
+
return r(), window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
|
|
85
81
|
}, []);
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
return
|
|
89
|
-
}, X = () =>
|
|
90
|
-
if (!d
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const J = Math.min(r - y, 0), N = i + y;
|
|
82
|
+
const O = (r) => {
|
|
83
|
+
const o = new Date(r.toString());
|
|
84
|
+
return N === "monthOnly" ? o.toLocaleDateString(e.dir === "ltr" ? "en-US" : "ar-EG", { month: "short" }) : l ? `${o.getDate()}/${o.getMonth() + 1}` : o.toLocaleDateString(e.dir === "ltr" ? "en-US" : "ar-EG", { month: "short", day: "numeric" });
|
|
85
|
+
}, X = () => l ? Math.ceil(y.length / 4) : y.length > 10 ? 1 : 0, { domain: L } = T(() => {
|
|
86
|
+
if (!d.length) return { domain: ["auto", "auto"] };
|
|
87
|
+
const r = d.map((Z) => Number(Z[x] || 0)), o = Math.min(...r), n = Math.max(...r);
|
|
88
|
+
let s = (n - o) * 0.1;
|
|
89
|
+
s === 0 && (s = Math.abs(o) * 0.1 || 1e3);
|
|
90
|
+
const J = Math.min(o - s, 0), Q = n + s;
|
|
96
91
|
return {
|
|
97
|
-
domain: [J,
|
|
92
|
+
domain: [J, Q]
|
|
98
93
|
};
|
|
99
|
-
}, [
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
}, q = ({ x:
|
|
94
|
+
}, [y]), S = (r) => {
|
|
95
|
+
const o = Math.abs(r), n = r < 0 ? "-" : "";
|
|
96
|
+
return o >= 1e6 ? `${n}${(o / 1e6).toFixed(1)}M` : o >= 1e3 ? `${n}${(o / 1e3).toFixed(1)}K` : `${n}${o.toFixed(0)}`;
|
|
97
|
+
}, q = ({ x: r, y: o, payload: n }) => /* @__PURE__ */ t.jsx("g", { transform: `translate(${r},${o})`, children: /* @__PURE__ */ t.jsx(
|
|
103
98
|
"text",
|
|
104
99
|
{
|
|
105
100
|
x: 0,
|
|
106
101
|
y: 0,
|
|
107
|
-
dy:
|
|
108
|
-
dx:
|
|
109
|
-
fontSize:
|
|
102
|
+
dy: f ? 25 : 16,
|
|
103
|
+
dx: f ? -8 : 0,
|
|
104
|
+
fontSize: l ? 9 : 10,
|
|
110
105
|
fill: "#666",
|
|
111
|
-
textAnchor:
|
|
112
|
-
transform:
|
|
106
|
+
textAnchor: f ? "end" : "middle",
|
|
107
|
+
transform: f ? "rotate(-45)" : void 0,
|
|
113
108
|
dominantBaseline: "middle",
|
|
114
|
-
children:
|
|
109
|
+
children: O(n.value)
|
|
115
110
|
}
|
|
116
|
-
) }), H =
|
|
111
|
+
) }), H = et(gt[i])`
|
|
117
112
|
direction: ltr;
|
|
118
113
|
/* width: 100% !important;
|
|
119
114
|
height: 100% !important; */
|
|
120
|
-
`,
|
|
115
|
+
`, A = {
|
|
121
116
|
width: 500,
|
|
122
117
|
height: 400,
|
|
123
|
-
data:
|
|
118
|
+
data: d,
|
|
124
119
|
margin: {
|
|
125
120
|
top: 10,
|
|
126
121
|
right: 30,
|
|
@@ -128,124 +123,118 @@ height: 100% !important; */
|
|
|
128
123
|
bottom: 0
|
|
129
124
|
}
|
|
130
125
|
};
|
|
131
|
-
if (
|
|
132
|
-
const
|
|
126
|
+
if (i === "pie") {
|
|
127
|
+
const r = d, o = r.map((n, s) => ({
|
|
128
|
+
name: n.name,
|
|
129
|
+
value: Number(n.value),
|
|
130
|
+
color: (a == null ? void 0 : a[s % ((a == null ? void 0 : a.length) || 1)]) || n.color
|
|
131
|
+
}));
|
|
133
132
|
return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
134
|
-
/* @__PURE__ */ t.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
133
|
+
/* @__PURE__ */ t.jsxs(B, { ...A, children: [
|
|
134
|
+
/* @__PURE__ */ t.jsx(
|
|
135
|
+
it,
|
|
136
|
+
{
|
|
137
|
+
data: r,
|
|
138
|
+
cx: "50%",
|
|
139
|
+
cy: "50%",
|
|
140
|
+
innerRadius: 90,
|
|
141
|
+
outerRadius: 110,
|
|
142
|
+
startAngle: 90,
|
|
143
|
+
endAngle: -270,
|
|
144
|
+
cornerRadius: 40,
|
|
145
|
+
paddingAngle: 2,
|
|
146
|
+
dataKey: "value",
|
|
147
|
+
fill: g,
|
|
148
|
+
stroke: c,
|
|
149
|
+
children: r.map((n, s) => /* @__PURE__ */ t.jsx(st, { fill: a == null ? void 0 : a[s % ((a == null ? void 0 : a.length) || 1)] }, `cell-${n.name}-${s}`))
|
|
150
|
+
}
|
|
151
|
+
),
|
|
152
|
+
/* @__PURE__ */ t.jsx(P, {})
|
|
153
|
+
] }),
|
|
154
|
+
/* @__PURE__ */ t.jsx(lt, { data: o })
|
|
153
155
|
] });
|
|
154
156
|
}
|
|
155
|
-
return /* @__PURE__ */ t.jsx(
|
|
156
|
-
/* @__PURE__ */ t.jsx(
|
|
157
|
+
return /* @__PURE__ */ t.jsx(dt, { initialDimension: { width: 500, height: 600 }, width: "100%", height: "100%", children: /* @__PURE__ */ t.jsxs(H, { ...A, children: [
|
|
158
|
+
/* @__PURE__ */ t.jsx(mt, { strokeDasharray: "3 3", stroke: "#f0f0f0" }),
|
|
157
159
|
/* @__PURE__ */ t.jsx(
|
|
158
|
-
|
|
160
|
+
ht,
|
|
159
161
|
{
|
|
160
|
-
label: { value:
|
|
162
|
+
label: { value: b, angle: 0, position: "bottom" },
|
|
161
163
|
dataKey: "x",
|
|
162
164
|
tick: q,
|
|
163
165
|
interval: X(),
|
|
164
|
-
height:
|
|
166
|
+
height: f ? 100 : 50
|
|
165
167
|
}
|
|
166
168
|
),
|
|
167
169
|
/* @__PURE__ */ t.jsx(
|
|
168
|
-
|
|
170
|
+
U,
|
|
169
171
|
{
|
|
170
|
-
domain:
|
|
172
|
+
domain: L,
|
|
171
173
|
tickCount: 10,
|
|
172
|
-
orientation:
|
|
173
|
-
yAxisId:
|
|
174
|
-
label:
|
|
174
|
+
orientation: p ? "right" : "left",
|
|
175
|
+
yAxisId: p ? "right" : void 0,
|
|
176
|
+
label: F ? { value: C, angle: -90, position: "insideRight" } : void 0,
|
|
175
177
|
tick: {
|
|
176
|
-
fontFamily:
|
|
177
|
-
fontSize:
|
|
178
|
-
fontWeight:
|
|
179
|
-
fill:
|
|
178
|
+
fontFamily: e.dir === "ltr" ? e.fonts.english : e.fonts.arabic,
|
|
179
|
+
fontSize: e.typography.sizes.s2,
|
|
180
|
+
fontWeight: e.typography.weights.regular,
|
|
181
|
+
fill: e.colors.grey.n400
|
|
180
182
|
},
|
|
181
183
|
reversed: !1,
|
|
182
|
-
tickFormatter:
|
|
184
|
+
tickFormatter: S
|
|
183
185
|
}
|
|
184
186
|
),
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
h && /* @__PURE__ */ t.jsx(
|
|
188
|
+
U,
|
|
187
189
|
{
|
|
188
|
-
domain:
|
|
190
|
+
domain: L,
|
|
189
191
|
tickCount: 10,
|
|
190
192
|
orientation: "left",
|
|
191
|
-
yAxisId:
|
|
192
|
-
label:
|
|
193
|
-
tickFormatter:
|
|
193
|
+
yAxisId: p ? "left" : void 0,
|
|
194
|
+
label: F ? { value: h, angle: -90, position: "insideLeft" } : void 0,
|
|
195
|
+
tickFormatter: S,
|
|
194
196
|
allowDataOverflow: !0,
|
|
195
197
|
tick: {
|
|
196
|
-
fontFamily:
|
|
197
|
-
fontSize:
|
|
198
|
-
fontWeight:
|
|
199
|
-
fill:
|
|
198
|
+
fontFamily: e.dir === "ltr" ? e.fonts.english : e.fonts.arabic,
|
|
199
|
+
fontSize: e.typography.sizes.s2,
|
|
200
|
+
fontWeight: e.typography.weights.regular,
|
|
201
|
+
fill: e.colors.grey.n400
|
|
200
202
|
},
|
|
201
203
|
reversed: !1
|
|
202
204
|
}
|
|
203
205
|
),
|
|
204
|
-
/* @__PURE__ */ t.jsx(
|
|
206
|
+
/* @__PURE__ */ t.jsx(P, { content: /* @__PURE__ */ t.jsx(xt, {}) }),
|
|
205
207
|
/* @__PURE__ */ t.jsx(
|
|
206
|
-
|
|
208
|
+
ct,
|
|
207
209
|
{
|
|
208
|
-
content: /* @__PURE__ */ t.jsx(
|
|
209
|
-
/* @__PURE__ */ t.jsx(E, { children: /* @__PURE__ */ t.jsx(w, { segment: { color: h, name: b ?? "Y" } }) }),
|
|
210
|
-
s && /* @__PURE__ */ t.jsx(E, { children: /* @__PURE__ */ t.jsx(w, { segment: { color: v, name: s ?? "Y" } }) })
|
|
211
|
-
] }) }),
|
|
210
|
+
content: G || /* @__PURE__ */ t.jsx(pt, { yColor: c, yyColor: j, legendItems: Y }),
|
|
212
211
|
wrapperStyle: {
|
|
213
|
-
paddingTop:
|
|
212
|
+
paddingTop: l ? "20px" : "10px"
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
215
|
),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
/* @__PURE__ */ t.jsx(
|
|
220
|
-
|
|
216
|
+
i === "area" && /* @__PURE__ */ t.jsx(ft, { type: "monotone", dataKey: x, stroke: c, fill: g }),
|
|
217
|
+
i === "line" && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
218
|
+
/* @__PURE__ */ t.jsx(v, { type: "monotone", dataKey: x, yAxisId: p ? "right" : void 0, stroke: c }),
|
|
219
|
+
h && /* @__PURE__ */ t.jsx(v, { type: "monotone", yAxisId: p ? "left" : void 0, dataKey: k, stroke: j })
|
|
221
220
|
] }),
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
i === "bar" && /* @__PURE__ */ t.jsx(t.Fragment, { children: (E = m.barKeys) != null && E.length && ((V = m.barKeys) == null ? void 0 : V.length) > 0 ? m.barKeys.map((r, o) => /* @__PURE__ */ t.jsx(
|
|
222
|
+
W,
|
|
224
223
|
{
|
|
225
224
|
type: "monotone",
|
|
226
|
-
dataKey:
|
|
227
|
-
yAxisId:
|
|
228
|
-
stroke: (
|
|
229
|
-
fill: (
|
|
230
|
-
radius:
|
|
225
|
+
dataKey: r,
|
|
226
|
+
yAxisId: D,
|
|
227
|
+
stroke: (a == null ? void 0 : a[o]) || c,
|
|
228
|
+
fill: (a == null ? void 0 : a[o]) || g,
|
|
229
|
+
radius: w
|
|
231
230
|
},
|
|
232
|
-
|
|
231
|
+
r
|
|
233
232
|
)) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
234
|
-
/* @__PURE__ */ t.jsx(
|
|
235
|
-
|
|
236
|
-
{
|
|
237
|
-
type: "monotone",
|
|
238
|
-
dataKey: L,
|
|
239
|
-
yAxisId: s ? "right" : void 0,
|
|
240
|
-
stroke: h,
|
|
241
|
-
fill: f,
|
|
242
|
-
radius: F
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
s && /* @__PURE__ */ t.jsx(C, { type: "monotone", yAxisId: "left", dataKey: k, stroke: v })
|
|
233
|
+
/* @__PURE__ */ t.jsx(W, { type: "monotone", dataKey: x, yAxisId: D, stroke: c, fill: g, radius: w }),
|
|
234
|
+
h && /* @__PURE__ */ t.jsx(v, { type: "monotone", yAxisId: "left", dataKey: k, stroke: j })
|
|
246
235
|
] }) })
|
|
247
236
|
] }) });
|
|
248
237
|
};
|
|
249
238
|
export {
|
|
250
|
-
|
|
239
|
+
Vt as default
|
|
251
240
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { LegendItem } from '../Chart';
|
|
3
|
+
interface ChartLegendProps {
|
|
4
|
+
yColor: string;
|
|
5
|
+
yyColor?: string;
|
|
6
|
+
legendItems?: LegendItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare const ChartLegend: React.FC<ChartLegendProps>;
|
|
9
|
+
export default ChartLegend;
|
|
10
|
+
//# sourceMappingURL=ChartLegend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ChartLegend/ChartLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAOpD,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAmClD,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { j as e } from "../../_virtual/jsx-runtime.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useTheme as c } from "styled-components";
|
|
4
|
+
import h from "../../assets/svg/Riyal.svg.js";
|
|
5
|
+
import g from "../Image.js";
|
|
6
|
+
import i from "../Typography.js";
|
|
7
|
+
import { StyledLegendContainer as p, LegendRow as x, LegendName as j, LegendValue as u } from "./styles.js";
|
|
8
|
+
const C = ({ yColor: s, yyColor: m, legendItems: n }) => {
|
|
9
|
+
const o = c();
|
|
10
|
+
if (n && n.length)
|
|
11
|
+
return /* @__PURE__ */ e.jsx(p, { children: n.map((r, t) => {
|
|
12
|
+
const l = r.showRiyal ?? !0, a = r.value, d = r.color ?? (t === 1 ? m ?? s : s);
|
|
13
|
+
return /* @__PURE__ */ e.jsxs(x, { children: [
|
|
14
|
+
/* @__PURE__ */ e.jsxs(j, { children: [
|
|
15
|
+
/* @__PURE__ */ e.jsx("span", { className: "legend-dot", style: { background: d } }),
|
|
16
|
+
/* @__PURE__ */ e.jsx(i, { variant: "mdText", weight: "semiBold", children: r.name })
|
|
17
|
+
] }),
|
|
18
|
+
/* @__PURE__ */ e.jsx(u, { children: a && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
19
|
+
l && /* @__PURE__ */ e.jsx(g, { src: h, style: { verticalAlign: "middle" }, width: o.spacing.sm, height: o.spacing.sm }),
|
|
20
|
+
/* @__PURE__ */ e.jsx(i, { variant: "mdText", children: a })
|
|
21
|
+
] }) })
|
|
22
|
+
] }, `${r.name}-${t}`);
|
|
23
|
+
}) });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
C as ChartLegend,
|
|
27
|
+
C as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
type PieChartLegendItem = {
|
|
3
|
+
name: string;
|
|
4
|
+
value: number;
|
|
5
|
+
color: string;
|
|
6
|
+
};
|
|
7
|
+
interface PieChartLegendProps {
|
|
8
|
+
data: PieChartLegendItem[];
|
|
9
|
+
maxNameLength?: number;
|
|
10
|
+
showRiyal?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const PieChartLegend: React.FC<PieChartLegendProps>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=PieChartLegend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PieChartLegend.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ChartLegend/PieChartLegend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,mBAAmB;IAC3B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA4BxD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { j as n } from "../../_virtual/jsx-runtime.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { useTheme as h } from "styled-components";
|
|
4
|
+
import a from "../../assets/svg/Riyal.svg.js";
|
|
5
|
+
import x from "../Image.js";
|
|
6
|
+
import p from "../Typography.js";
|
|
7
|
+
import { PieLegendContainer as j, LegendRow as u, LegendName as f, LegendValue as y } from "./styles.js";
|
|
8
|
+
const N = ({ data: s, maxNameLength: o = 18, showRiyal: d = !0 }) => {
|
|
9
|
+
const l = h();
|
|
10
|
+
return !s || (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ n.jsx(j, { children: s.map((r) => {
|
|
11
|
+
var e, c;
|
|
12
|
+
const g = ((e = r == null ? void 0 : r.name) == null ? void 0 : e.length) > o ? ((c = r == null ? void 0 : r.name) == null ? void 0 : c.slice(0, o)) + "..." : r == null ? void 0 : r.name;
|
|
13
|
+
return /* @__PURE__ */ n.jsxs(u, { children: [
|
|
14
|
+
/* @__PURE__ */ n.jsxs(f, { children: [
|
|
15
|
+
/* @__PURE__ */ n.jsx("span", { className: "legend-dot", style: { background: r == null ? void 0 : r.color } }),
|
|
16
|
+
/* @__PURE__ */ n.jsx(p, { variant: "mdText", weight: "semiBold", children: g })
|
|
17
|
+
] }),
|
|
18
|
+
/* @__PURE__ */ n.jsxs(y, { children: [
|
|
19
|
+
d && /* @__PURE__ */ n.jsx(x, { src: a, style: { verticalAlign: "middle" }, width: l.spacing.sm, height: l.spacing.sm }),
|
|
20
|
+
/* @__PURE__ */ n.jsx(p, { variant: "mdText", children: r == null ? void 0 : r.value })
|
|
21
|
+
] })
|
|
22
|
+
] }, r == null ? void 0 : r.name);
|
|
23
|
+
}) });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
N as PieChartLegend
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ChartLegend/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const StyledLegendContainer: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
|
+
export declare const PieLegendContainer: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const LegendRow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
4
|
+
export declare const LegendName: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
5
|
+
export declare const LegendValue: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
6
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/lib/components/ChartLegend/styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,6NAuBjC,CAAC;AACF,eAAO,MAAM,kBAAkB,6NAgB9B,CAAC;AAEF,eAAO,MAAM,SAAS,6NAsBrB,CAAC;AAEF,eAAO,MAAM,UAAU,+NAwBtB,CAAC;AAEF,eAAO,MAAM,WAAW,6NAWvB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import n from "styled-components";
|
|
2
|
+
import { device as e } from "../../constants/breakPoints.constant.js";
|
|
3
|
+
import { coreI18n as t } from "../../i18n/i18n.js";
|
|
4
|
+
const r = n.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
padding-right: ${({ theme: i }) => i.spacing.m};
|
|
7
|
+
padding-left: ${({ theme: i }) => i.spacing.m};
|
|
8
|
+
gap: ${({ theme: i }) => i.spacing.l};
|
|
9
|
+
direction: ltr;
|
|
10
|
+
margin-top: ${({ theme: i }) => i.spacing.sm};
|
|
11
|
+
margin-right: 0;
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
|
|
14
|
+
@media ${e.tablet} {
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: ${({ theme: i }) => i.spacing.sm};
|
|
17
|
+
padding-right: ${({ theme: i }) => i.spacing.sm};
|
|
18
|
+
padding-left: ${({ theme: i }) => i.spacing.sm};
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@media ${e.mobile} {
|
|
23
|
+
gap: ${({ theme: i }) => i.spacing.xs};
|
|
24
|
+
padding-right: ${({ theme: i }) => i.spacing.xs};
|
|
25
|
+
padding-left: ${({ theme: i }) => i.spacing.xs};
|
|
26
|
+
}
|
|
27
|
+
`, p = n.div`
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
display: flex;
|
|
30
|
+
padding-right: ${({ theme: i }) => i.spacing.m};
|
|
31
|
+
padding-left: ${({ theme: i }) => i.spacing.m};
|
|
32
|
+
gap: ${({ theme: i }) => i.spacing.l};
|
|
33
|
+
direction: ltr;
|
|
34
|
+
margin-top: ${({ theme: i }) => i.spacing.sm};
|
|
35
|
+
margin-right: 0;
|
|
36
|
+
margin-bottom: 0;
|
|
37
|
+
|
|
38
|
+
@media ${e.mobile} {
|
|
39
|
+
gap: ${({ theme: i }) => i.spacing.xs};
|
|
40
|
+
padding-right: ${({ theme: i }) => i.spacing.xs};
|
|
41
|
+
padding-left: ${({ theme: i }) => i.spacing.xs};
|
|
42
|
+
}
|
|
43
|
+
`, s = n.div`
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: space-between;
|
|
46
|
+
align-items: center;
|
|
47
|
+
width: 100%;
|
|
48
|
+
gap: 1rem;
|
|
49
|
+
box-sizing: border-box;
|
|
50
|
+
min-width: 0;
|
|
51
|
+
padding: 0.25rem 0;
|
|
52
|
+
flex-direction: ${({ theme: i }) => i.dir == "rtl" && "row-reverse"};
|
|
53
|
+
@media ${e.tablet} {
|
|
54
|
+
gap: 0.5rem;
|
|
55
|
+
padding: 0.15rem 0;
|
|
56
|
+
min-width: 150px;
|
|
57
|
+
width: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media ${e.mobile} {
|
|
61
|
+
width: 100%;
|
|
62
|
+
gap: 0.25rem;
|
|
63
|
+
padding: 0.1rem 0;
|
|
64
|
+
}
|
|
65
|
+
`, m = n.span`
|
|
66
|
+
display: flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
gap: 0.5rem;
|
|
69
|
+
min-width: 0;
|
|
70
|
+
flex-direction: ${({ theme: i }) => i.dir == "rtl" && "row-reverse"};
|
|
71
|
+
.legend-dot {
|
|
72
|
+
width: 12px;
|
|
73
|
+
height: 12px;
|
|
74
|
+
display: inline-block;
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
margin: ${() => t.language === "en" ? "0 0.3rem 0 0" : "0 0 0 0.3rem"};
|
|
77
|
+
}
|
|
78
|
+
.legend-text {
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
text-overflow: ellipsis;
|
|
82
|
+
max-width: 7.5rem;
|
|
83
|
+
font-size: ${({ theme: i }) => i.typography.sizes.s3};
|
|
84
|
+
@media ${e.tablet} {
|
|
85
|
+
max-width: 5rem;
|
|
86
|
+
font-size: ${({ theme: i }) => i.typography.sizes.s2};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`, o = n.div`
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: row;
|
|
92
|
+
gap: 0.25rem;
|
|
93
|
+
justify-content: flex-end;
|
|
94
|
+
align-items: center;
|
|
95
|
+
font-weight: 600;
|
|
96
|
+
@media ${e.tablet} {
|
|
97
|
+
min-width: 2.5rem;
|
|
98
|
+
font-size: ${({ theme: i }) => i.typography.sizes.s2};
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
export {
|
|
102
|
+
m as LegendName,
|
|
103
|
+
s as LegendRow,
|
|
104
|
+
o as LegendValue,
|
|
105
|
+
p as PieLegendContainer,
|
|
106
|
+
r as StyledLegendContainer
|
|
107
|
+
};
|