@ledgerhq/lumen-ui-react-visualization 0.1.2 → 0.1.4

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.
Files changed (123) hide show
  1. package/dist/lib/Components/Axis/Axis.types.d.ts +33 -0
  2. package/dist/lib/Components/Axis/Axis.types.d.ts.map +1 -0
  3. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts +4 -0
  4. package/dist/lib/Components/Axis/XAxis/XAxis.d.ts.map +1 -0
  5. package/dist/lib/Components/Axis/XAxis/XAxis.js +84 -0
  6. package/dist/lib/Components/Axis/XAxis/index.d.ts +3 -0
  7. package/dist/lib/Components/Axis/XAxis/index.d.ts.map +1 -0
  8. package/dist/lib/Components/Axis/XAxis/types.d.ts +9 -0
  9. package/dist/lib/Components/Axis/XAxis/types.d.ts.map +1 -0
  10. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts +4 -0
  11. package/dist/lib/Components/Axis/YAxis/YAxis.d.ts.map +1 -0
  12. package/dist/lib/Components/Axis/YAxis/YAxis.js +81 -0
  13. package/dist/lib/Components/Axis/YAxis/index.d.ts +3 -0
  14. package/dist/lib/Components/Axis/YAxis/index.d.ts.map +1 -0
  15. package/dist/lib/Components/Axis/YAxis/types.d.ts +14 -0
  16. package/dist/lib/Components/Axis/YAxis/types.d.ts.map +1 -0
  17. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts +3 -0
  18. package/dist/lib/Components/CartesianChart/CartesianChart.d.ts.map +1 -0
  19. package/dist/lib/Components/CartesianChart/CartesianChart.js +79 -0
  20. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.d.ts +8 -0
  21. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.d.ts.map +1 -0
  22. package/dist/lib/Components/CartesianChart/context/cartesianChartContext.js +9 -0
  23. package/dist/lib/Components/CartesianChart/context/index.d.ts +3 -0
  24. package/dist/lib/Components/CartesianChart/context/index.d.ts.map +1 -0
  25. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts +23 -0
  26. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.d.ts.map +1 -0
  27. package/dist/lib/Components/CartesianChart/context/useBuildChartContext.js +61 -0
  28. package/dist/lib/Components/CartesianChart/index.d.ts +4 -0
  29. package/dist/lib/Components/CartesianChart/index.d.ts.map +1 -0
  30. package/dist/lib/Components/CartesianChart/types.d.ts +48 -0
  31. package/dist/lib/Components/CartesianChart/types.d.ts.map +1 -0
  32. package/dist/lib/Components/Line/Line.d.ts +3 -0
  33. package/dist/lib/Components/Line/Line.d.ts.map +1 -0
  34. package/dist/lib/Components/Line/Line.js +73 -0
  35. package/dist/lib/Components/Line/index.d.ts +3 -0
  36. package/dist/lib/Components/Line/index.d.ts.map +1 -0
  37. package/dist/lib/Components/Line/types.d.ts +24 -0
  38. package/dist/lib/Components/Line/types.d.ts.map +1 -0
  39. package/dist/lib/Components/Line/utils.d.ts +19 -0
  40. package/dist/lib/Components/Line/utils.d.ts.map +1 -0
  41. package/dist/lib/Components/Line/utils.js +22 -0
  42. package/dist/lib/Components/LineChart/LineChart.d.ts +2 -8
  43. package/dist/lib/Components/LineChart/LineChart.d.ts.map +1 -1
  44. package/dist/lib/Components/LineChart/LineChart.js +79 -23
  45. package/dist/lib/Components/LineChart/index.d.ts +1 -0
  46. package/dist/lib/Components/LineChart/index.d.ts.map +1 -1
  47. package/dist/lib/Components/LineChart/types.d.ts +63 -0
  48. package/dist/lib/Components/LineChart/types.d.ts.map +1 -0
  49. package/dist/lib/utils/domain/domain.d.ts +17 -0
  50. package/dist/lib/utils/domain/domain.d.ts.map +1 -0
  51. package/dist/lib/utils/domain/domain.js +38 -0
  52. package/dist/lib/utils/index.d.ts +1 -1
  53. package/dist/lib/utils/index.d.ts.map +1 -1
  54. package/dist/lib/utils/scales/scales.d.ts +24 -0
  55. package/dist/lib/utils/scales/scales.d.ts.map +1 -0
  56. package/dist/lib/utils/scales/scales.js +25 -0
  57. package/dist/lib/utils/ticks/ticks.d.ts +27 -0
  58. package/dist/lib/utils/ticks/ticks.d.ts.map +1 -0
  59. package/dist/lib/utils/ticks/ticks.js +23 -0
  60. package/dist/lib/utils/types.d.ts +90 -6
  61. package/dist/lib/utils/types.d.ts.map +1 -1
  62. package/dist/libs/ui-react/dist/lib/Components/ThemeProvider/ThemeProvider.js +8 -0
  63. package/dist/libs/ui-react/dist/libs/utils-shared/dist/index.js +35 -0
  64. package/dist/libs/utils-shared/dist/index.js +35 -0
  65. package/dist/node_modules/d3-array/src/ascending.js +6 -0
  66. package/dist/node_modules/d3-array/src/bisect.js +9 -0
  67. package/dist/node_modules/d3-array/src/bisector.js +37 -0
  68. package/dist/node_modules/d3-array/src/descending.js +6 -0
  69. package/dist/node_modules/d3-array/src/number.js +6 -0
  70. package/dist/node_modules/d3-array/src/range.js +9 -0
  71. package/dist/node_modules/d3-array/src/ticks.js +32 -0
  72. package/dist/node_modules/d3-color/src/color.js +305 -0
  73. package/dist/node_modules/d3-color/src/define.js +12 -0
  74. package/dist/node_modules/d3-format/src/defaultLocale.js +15 -0
  75. package/dist/node_modules/d3-format/src/exponent.js +7 -0
  76. package/dist/node_modules/d3-format/src/formatDecimal.js +15 -0
  77. package/dist/node_modules/d3-format/src/formatGroup.js +10 -0
  78. package/dist/node_modules/d3-format/src/formatNumerals.js +10 -0
  79. package/dist/node_modules/d3-format/src/formatPrefixAuto.js +12 -0
  80. package/dist/node_modules/d3-format/src/formatRounded.js +10 -0
  81. package/dist/node_modules/d3-format/src/formatSpecifier.js +28 -0
  82. package/dist/node_modules/d3-format/src/formatTrim.js +19 -0
  83. package/dist/node_modules/d3-format/src/formatTypes.js +21 -0
  84. package/dist/node_modules/d3-format/src/identity.js +6 -0
  85. package/dist/node_modules/d3-format/src/locale.js +68 -0
  86. package/dist/node_modules/d3-format/src/precisionFixed.js +7 -0
  87. package/dist/node_modules/d3-format/src/precisionPrefix.js +7 -0
  88. package/dist/node_modules/d3-format/src/precisionRound.js +7 -0
  89. package/dist/node_modules/d3-interpolate/src/array.js +13 -0
  90. package/dist/node_modules/d3-interpolate/src/color.js +24 -0
  91. package/dist/node_modules/d3-interpolate/src/constant.js +4 -0
  92. package/dist/node_modules/d3-interpolate/src/date.js +9 -0
  93. package/dist/node_modules/d3-interpolate/src/number.js +8 -0
  94. package/dist/node_modules/d3-interpolate/src/numberArray.js +15 -0
  95. package/dist/node_modules/d3-interpolate/src/object.js +14 -0
  96. package/dist/node_modules/d3-interpolate/src/rgb.js +15 -0
  97. package/dist/node_modules/d3-interpolate/src/round.js +8 -0
  98. package/dist/node_modules/d3-interpolate/src/string.js +24 -0
  99. package/dist/node_modules/d3-interpolate/src/value.js +16 -0
  100. package/dist/node_modules/d3-path/src/path.js +64 -0
  101. package/dist/node_modules/d3-scale/src/band.js +41 -0
  102. package/dist/node_modules/d3-scale/src/constant.js +8 -0
  103. package/dist/node_modules/d3-scale/src/continuous.js +75 -0
  104. package/dist/node_modules/d3-scale/src/init.js +16 -0
  105. package/dist/node_modules/d3-scale/src/linear.js +39 -0
  106. package/dist/node_modules/d3-scale/src/log.js +86 -0
  107. package/dist/node_modules/d3-scale/src/nice.js +8 -0
  108. package/dist/node_modules/d3-scale/src/number.js +6 -0
  109. package/dist/node_modules/d3-scale/src/ordinal.js +31 -0
  110. package/dist/node_modules/d3-scale/src/tickFormat.js +32 -0
  111. package/dist/node_modules/d3-shape/src/area.js +56 -0
  112. package/dist/node_modules/d3-shape/src/array.js +6 -0
  113. package/dist/node_modules/d3-shape/src/constant.js +8 -0
  114. package/dist/node_modules/d3-shape/src/curve/bump.js +39 -0
  115. package/dist/node_modules/d3-shape/src/curve/linear.js +36 -0
  116. package/dist/node_modules/d3-shape/src/line.js +29 -0
  117. package/dist/node_modules/d3-shape/src/path.js +18 -0
  118. package/dist/node_modules/d3-shape/src/point.js +10 -0
  119. package/dist/node_modules/internmap/src/index.js +35 -0
  120. package/dist/package.json +15 -3
  121. package/package.json +13 -1
  122. package/dist/lib/utils/math/index.d.ts +0 -1
  123. package/dist/lib/utils/math/index.d.ts.map +0 -1
@@ -0,0 +1,33 @@
1
+ export type BaseAxisProps = {
2
+ /**
3
+ * Whether to render grid lines at each tick.
4
+ * @default false
5
+ */
6
+ showGrid?: boolean;
7
+ /**
8
+ * Appearance of the grid lines.
9
+ * @default 'dashed'
10
+ */
11
+ gridLineStyle?: 'solid' | 'dashed';
12
+ /**
13
+ * Whether to render the axis baseline.
14
+ * @default false
15
+ */
16
+ showLine?: boolean;
17
+ /**
18
+ * Whether to render tick marks at each tick position.
19
+ * @default false
20
+ */
21
+ showTickMark?: boolean;
22
+ /**
23
+ * Explicit tick positions along the axis.
24
+ * When omitted, ticks are computed automatically from the scale.
25
+ */
26
+ ticks?: number[];
27
+ /**
28
+ * Formats a tick value into its display label.
29
+ * Receives the raw tick value (number or string label) and must return a string.
30
+ */
31
+ tickLabelFormatter?: (value: number | string) => string;
32
+ };
33
+ //# sourceMappingURL=Axis.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Axis.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Axis/Axis.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;CACzD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { XAxisProps } from './types';
2
+ export declare const DEFAULT_AXIS_HEIGHT = 28;
3
+ export declare function XAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: XAxisProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=XAxis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/XAxis.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,wBAAgB,KAAK,CAAC,EACpB,aAAwB,EACxB,QAAmB,EACnB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAqFZ"}
@@ -0,0 +1,84 @@
1
+ import { jsxs as y, jsx as r, Fragment as C } from "react/jsx-runtime";
2
+ import { useTheme as _ } from "../../../../libs/ui-react/dist/lib/Components/ThemeProvider/ThemeProvider.js";
3
+ import { useMemo as D } from "react";
4
+ import { buildTicksData as I } from "../../../utils/ticks/ticks.js";
5
+ import { useCartesianChartContext as $ } from "../../CartesianChart/context/cartesianChartContext.js";
6
+ const l = 1, u = 4, k = 6, w = 28;
7
+ function H({
8
+ gridLineStyle: f = "dashed",
9
+ position: d = "bottom",
10
+ showGrid: g = !1,
11
+ showLine: b = !1,
12
+ showTickMark: T = !1,
13
+ ticks: m,
14
+ tickLabelFormatter: x
15
+ }) {
16
+ const { theme: o } = _(), { getXScale: A, getXAxisConfig: S, drawingArea: e } = $(), n = A(), c = S(), a = D(
17
+ () => n ? I(n, c, m, x) : [],
18
+ [n, c, m, x]
19
+ );
20
+ if (!n || e.width <= 0)
21
+ return null;
22
+ const h = d === "top", s = h ? e.y : e.y + e.height, p = h ? -1 : 1, E = s + p * (u + k);
23
+ return /* @__PURE__ */ y("g", { "data-testid": "x-axis", children: [
24
+ g && a.map((t, i) => /* @__PURE__ */ r(
25
+ "line",
26
+ {
27
+ x1: t.position,
28
+ y1: e.y,
29
+ x2: t.position,
30
+ y2: e.y + e.height,
31
+ style: { stroke: o.colors.border.mutedSubtle },
32
+ strokeWidth: l,
33
+ strokeDasharray: f === "dashed" ? "3 3" : void 0
34
+ },
35
+ `grid-${t.value}-${i}`
36
+ )),
37
+ b && /* @__PURE__ */ r(
38
+ "line",
39
+ {
40
+ x1: e.x,
41
+ y1: s,
42
+ x2: e.x + e.width,
43
+ y2: s,
44
+ style: { stroke: o.colors.border.muted },
45
+ strokeWidth: l,
46
+ shapeRendering: "crispEdges",
47
+ strokeLinecap: "square"
48
+ }
49
+ ),
50
+ T && a.map((t, i) => /* @__PURE__ */ r(
51
+ "line",
52
+ {
53
+ x1: t.position,
54
+ y1: s,
55
+ x2: t.position,
56
+ y2: s + p * u,
57
+ style: { stroke: o.colors.border.muted },
58
+ strokeWidth: l
59
+ },
60
+ `tick-${t.value}-${i}`
61
+ )),
62
+ a.map((t, i) => /* @__PURE__ */ y(C, { children: [
63
+ " ",
64
+ /* @__PURE__ */ r(
65
+ "text",
66
+ {
67
+ x: t.position,
68
+ y: E,
69
+ textAnchor: "middle",
70
+ dominantBaseline: d === "top" ? "auto" : "hanging",
71
+ style: { fill: o.colors.text.muted },
72
+ fontSize: o.typographies.xs.body.body4.fontSize,
73
+ fontFamily: o.fontFamilies.sans,
74
+ children: t.label
75
+ },
76
+ `label-${t.value}-${i}`
77
+ )
78
+ ] }))
79
+ ] });
80
+ }
81
+ export {
82
+ w as DEFAULT_AXIS_HEIGHT,
83
+ H as XAxis
84
+ };
@@ -0,0 +1,3 @@
1
+ export { XAxis, DEFAULT_AXIS_HEIGHT } from './XAxis';
2
+ export type { XAxisProps } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACrD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { BaseAxisProps } from '../Axis.types';
2
+ export type XAxisProps = BaseAxisProps & {
3
+ /**
4
+ * Where the x-axis is rendered relative to the drawing area.
5
+ * @default 'bottom'
6
+ */
7
+ position?: 'top' | 'bottom';
8
+ };
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/XAxis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;CAC7B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { YAxisProps } from './types';
2
+ export declare const DEFAULT_AXIS_WIDTH = 40;
3
+ export declare function YAxis({ gridLineStyle, position, showGrid, showLine, showTickMark, ticks: ticksProp, tickLabelFormatter, }: YAxisProps): import("react/jsx-runtime").JSX.Element | null;
4
+ //# sourceMappingURL=YAxis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxis.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/YAxis.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,wBAAgB,KAAK,CAAC,EACpB,aAAwB,EACxB,QAAkB,EAClB,QAAgB,EAChB,QAAgB,EAChB,YAAoB,EACpB,KAAK,EAAE,SAAS,EAChB,kBAAkB,GACnB,EAAE,UAAU,kDAkFZ"}
@@ -0,0 +1,81 @@
1
+ import { jsxs as C, jsx as n } from "react/jsx-runtime";
2
+ import { useTheme as D } from "../../../../libs/ui-react/dist/lib/Components/ThemeProvider/ThemeProvider.js";
3
+ import { useMemo as E } from "react";
4
+ import { buildTicksData as _ } from "../../../utils/ticks/ticks.js";
5
+ import { useCartesianChartContext as I } from "../../CartesianChart/context/cartesianChartContext.js";
6
+ const l = 1, f = 4, $ = 6, w = 40;
7
+ function L({
8
+ gridLineStyle: p = "dashed",
9
+ position: d = "start",
10
+ showGrid: u = !1,
11
+ showLine: g = !1,
12
+ showTickMark: S = !1,
13
+ ticks: c,
14
+ tickLabelFormatter: x
15
+ }) {
16
+ const { theme: s } = D(), { getYScale: b, getYAxisConfig: A, drawingArea: e } = I(), r = b(), m = A(), a = E(
17
+ () => r ? _(r, m, c, x) : [],
18
+ [r, m, c, x]
19
+ );
20
+ if (!r || e.height <= 0)
21
+ return null;
22
+ const y = d === "start", o = y ? e.x : e.x + e.width, h = y ? -1 : 1, T = o + h * (f + $);
23
+ return /* @__PURE__ */ C("g", { "data-testid": "y-axis", children: [
24
+ u && a.map((t, i) => /* @__PURE__ */ n(
25
+ "line",
26
+ {
27
+ x1: e.x,
28
+ y1: t.position,
29
+ x2: e.x + e.width,
30
+ y2: t.position,
31
+ style: { stroke: s.colors.border.mutedSubtle },
32
+ strokeWidth: l,
33
+ strokeDasharray: p === "dashed" ? "3 3" : void 0
34
+ },
35
+ `grid-${t.value}-${i}`
36
+ )),
37
+ g && /* @__PURE__ */ n(
38
+ "line",
39
+ {
40
+ x1: o,
41
+ y1: e.y,
42
+ x2: o,
43
+ y2: e.y + e.height,
44
+ style: { stroke: s.colors.border.muted },
45
+ strokeWidth: l,
46
+ shapeRendering: "crispEdges",
47
+ strokeLinecap: "square"
48
+ }
49
+ ),
50
+ S && a.map((t, i) => /* @__PURE__ */ n(
51
+ "line",
52
+ {
53
+ x1: o,
54
+ y1: t.position,
55
+ x2: o + h * f,
56
+ y2: t.position,
57
+ style: { stroke: s.colors.border.muted },
58
+ strokeWidth: l
59
+ },
60
+ `tick-${t.value}-${i}`
61
+ )),
62
+ a.map((t, i) => /* @__PURE__ */ n(
63
+ "text",
64
+ {
65
+ x: T,
66
+ y: t.position,
67
+ textAnchor: d === "start" ? "end" : "start",
68
+ dominantBaseline: "central",
69
+ style: { fill: s.colors.text.muted },
70
+ fontSize: s.typographies.xs.body.body4.fontSize,
71
+ fontFamily: s.fontFamilies.sans,
72
+ children: t.label
73
+ },
74
+ `label-${t.value}-${i}`
75
+ ))
76
+ ] });
77
+ }
78
+ export {
79
+ w as DEFAULT_AXIS_WIDTH,
80
+ L as YAxis
81
+ };
@@ -0,0 +1,3 @@
1
+ export { YAxis, DEFAULT_AXIS_WIDTH } from './YAxis';
2
+ export type { YAxisProps } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { BaseAxisProps } from '../Axis.types';
2
+ export type YAxisProps = BaseAxisProps & {
3
+ /**
4
+ * Where the y-axis is rendered relative to the drawing area.
5
+ * @default 'start'
6
+ */
7
+ position?: 'start' | 'end';
8
+ /**
9
+ * Width of the axis in pixels.
10
+ * @default 40
11
+ */
12
+ width?: number;
13
+ };
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Axis/YAxis/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG;IACvC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC3B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { CartesianChartProps } from './types';
2
+ export declare function CartesianChart({ series, xAxis, yAxis, width, height, inset, axisPadding, ariaLabel, children, }: CartesianChartProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=CartesianChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CartesianChart.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/CartesianChart.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAoCnD,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,KAAK,EACL,KAAK,EACL,KAAc,EACd,MAAuB,EACvB,KAAK,EACL,WAAW,EACX,SAAmB,EACnB,QAAQ,GACT,EAAE,mBAAmB,2CA4ErB"}
@@ -0,0 +1,79 @@
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import { useRef as A, useState as I, useCallback as D, useEffect as P, useMemo as b } from "react";
3
+ import { useBuildChartContext as T } from "./context/useBuildChartContext.js";
4
+ import { CartesianChartProvider as z } from "./context/cartesianChartContext.js";
5
+ const M = 160, o = {
6
+ top: 8,
7
+ right: 0,
8
+ bottom: 0,
9
+ left: 0
10
+ }, O = { top: 0, right: 0, bottom: 0, left: 0 }, W = (t) => t === void 0 ? o : typeof t == "number" ? { top: t, right: t, bottom: t, left: t } : {
11
+ top: t.top ?? o.top,
12
+ right: t.right ?? o.right,
13
+ bottom: t.bottom ?? o.bottom,
14
+ left: t.left ?? o.left
15
+ }, _ = (t) => t === void 0 ? O : {
16
+ top: t.top ?? 0,
17
+ right: t.right ?? 0,
18
+ bottom: t.bottom ?? 0,
19
+ left: t.left ?? 0
20
+ };
21
+ function L({
22
+ series: t,
23
+ xAxis: h,
24
+ yAxis: p,
25
+ width: e = "100%",
26
+ height: n = M,
27
+ inset: l,
28
+ axisPadding: f,
29
+ ariaLabel: C = "Chart",
30
+ children: y
31
+ }) {
32
+ const s = A(null), [u, g] = I(
33
+ typeof e == "number" ? e : void 0
34
+ ), i = typeof e != "number", a = D((r) => {
35
+ const [v] = r;
36
+ v && g(v.contentRect.width);
37
+ }, []);
38
+ P(() => {
39
+ if (!i || !s.current || typeof ResizeObserver > "u")
40
+ return;
41
+ const r = new ResizeObserver(a);
42
+ return r.observe(s.current), () => r.disconnect();
43
+ }, [i, a]);
44
+ const m = typeof e == "number" ? e : u ?? 0, R = b(() => W(l), [l]), x = b(
45
+ () => _(f),
46
+ [f]
47
+ ), E = T({
48
+ series: t,
49
+ xAxis: h,
50
+ yAxis: p,
51
+ width: m,
52
+ height: n,
53
+ inset: R,
54
+ axisPadding: x
55
+ }), d = /* @__PURE__ */ c(
56
+ "svg",
57
+ {
58
+ "data-testid": "chart-svg",
59
+ width: m,
60
+ height: n,
61
+ role: "img",
62
+ "aria-label": C || "Chart",
63
+ style: { display: "block", overflow: "visible" },
64
+ children: /* @__PURE__ */ c(z, { value: E, children: y })
65
+ }
66
+ );
67
+ return i ? /* @__PURE__ */ c(
68
+ "div",
69
+ {
70
+ ref: s,
71
+ "data-testid": "chart-container",
72
+ style: { width: e, height: n },
73
+ children: u !== void 0 && d
74
+ }
75
+ ) : d;
76
+ }
77
+ export {
78
+ L as CartesianChart
79
+ };
@@ -0,0 +1,8 @@
1
+ import { CartesianChartContextValue } from '../../../utils/types';
2
+ declare const CartesianChartProvider: import('react').FC<{
3
+ children: import('react').ReactNode;
4
+ value: CartesianChartContextValue;
5
+ }>;
6
+ export declare const useCartesianChartContext: () => CartesianChartContextValue;
7
+ export { CartesianChartProvider };
8
+ //# sourceMappingURL=cartesianChartContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesianChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/cartesianChartContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAEvE,QAAA,MAAO,sBAAsB;;;EACoC,CAAC;AAElE,eAAO,MAAM,wBAAwB,kCAIjC,CAAC;AAEL,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { createSafeContext as t } from "../../../../libs/utils-shared/dist/index.js";
2
+ const [r, e] = t("CartesianChart"), C = () => e({
3
+ consumerName: "useCartesianChartContext",
4
+ contextRequired: !0
5
+ });
6
+ export {
7
+ r as CartesianChartProvider,
8
+ C as useCartesianChartContext
9
+ };
@@ -0,0 +1,3 @@
1
+ export { CartesianChartProvider, useCartesianChartContext, } from './cartesianChartContext';
2
+ export { buildScale, computeAxisRange, computeDrawingArea, useBuildChartContext, } from './useBuildChartContext';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { AxisBounds, AxisConfigProps, CartesianChartContextValue, ChartInset, ChartScaleFunction, DrawingArea, Series } from '../../../utils/types';
2
+ type UseBuildChartContextParams = {
3
+ series: Series[];
4
+ xAxis?: Partial<AxisConfigProps>;
5
+ yAxis?: Partial<AxisConfigProps>;
6
+ width: number;
7
+ height: number;
8
+ inset: ChartInset;
9
+ axisPadding: ChartInset;
10
+ };
11
+ type AxisRange = {
12
+ min: number;
13
+ max: number;
14
+ };
15
+ export declare const computeAxisRange: (drawingArea: DrawingArea) => {
16
+ xRange: AxisRange;
17
+ yRange: AxisRange;
18
+ };
19
+ export declare const buildScale: (domain: AxisBounds, range: AxisRange, scaleType?: AxisConfigProps["scaleType"]) => ChartScaleFunction;
20
+ export declare const computeDrawingArea: (width: number, height: number, inset: ChartInset, axisPadding: ChartInset) => DrawingArea;
21
+ export declare const useBuildChartContext: ({ series, xAxis, yAxis, width, height, inset, axisPadding, }: UseBuildChartContextParams) => CartesianChartContextValue;
22
+ export {};
23
+ //# sourceMappingURL=useBuildChartContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBuildChartContext.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/CartesianChart/context/useBuildChartContext.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,0BAA0B,EAC1B,UAAU,EACV,kBAAkB,EAClB,WAAW,EACX,MAAM,EACP,MAAM,sBAAsB,CAAC;AAE9B,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9C,eAAO,MAAM,gBAAgB,GAC3B,aAAa,WAAW,KACvB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,SAAS,CAAA;CAMvC,CAAC;AAEH,eAAO,MAAM,UAAU,GACrB,QAAQ,UAAU,EAClB,OAAO,SAAS,EAChB,YAAW,eAAe,CAAC,WAAW,CAAY,KACjD,kBAGgD,CAAC;AAEpD,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,EACb,QAAQ,MAAM,EACd,OAAO,UAAU,EACjB,aAAa,UAAU,KACtB,WAaF,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,8DAQlC,0BAA0B,KAAG,0BAiC/B,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { useMemo as u } from "react";
2
+ import { computeXDomain as b, computeYDomain as C, computeDataLength as M } from "../../../utils/domain/domain.js";
3
+ import { getCategoricalScale as R, getNumericScale as _, isBandScaleType as X } from "../../../utils/scales/scales.js";
4
+ const Y = (t) => ({
5
+ xRange: { min: t.x, max: t.x + t.width },
6
+ yRange: {
7
+ min: t.y + t.height,
8
+ max: t.y
9
+ }
10
+ }), f = (t, e, o = "linear") => X(o) ? R({ domain: t, range: e }) : _({ scaleType: o, domain: t, range: e }), B = (t, e, o, a) => {
11
+ const c = {
12
+ top: o.top + a.top,
13
+ right: o.right + a.right,
14
+ bottom: o.bottom + a.bottom,
15
+ left: o.left + a.left
16
+ };
17
+ return {
18
+ x: c.left,
19
+ y: c.top,
20
+ width: Math.max(0, t - c.left - c.right),
21
+ height: Math.max(0, e - c.top - c.bottom)
22
+ };
23
+ }, I = ({
24
+ series: t,
25
+ xAxis: e,
26
+ yAxis: o,
27
+ width: a,
28
+ height: c,
29
+ inset: n,
30
+ axisPadding: p
31
+ }) => {
32
+ const l = u(
33
+ () => B(a, c, n, p),
34
+ [a, c, n, p]
35
+ );
36
+ return u(() => {
37
+ const { xRange: r, yRange: S } = Y(l);
38
+ let h, g;
39
+ if (l.width > 0 && l.height > 0) {
40
+ const m = b(t, e), D = C(t, o);
41
+ h = f(m, r, e?.scaleType), g = f(D, S, o?.scaleType);
42
+ }
43
+ const i = M(t, e), y = new Map(t.map((m) => [m.id, m]));
44
+ return {
45
+ series: t,
46
+ seriesMap: y,
47
+ getXScale: (m) => h,
48
+ getYScale: (m) => g,
49
+ getXAxisConfig: (m) => e,
50
+ getYAxisConfig: (m) => o,
51
+ drawingArea: l,
52
+ dataLength: i
53
+ };
54
+ }, [t, e, o, l]);
55
+ };
56
+ export {
57
+ f as buildScale,
58
+ Y as computeAxisRange,
59
+ B as computeDrawingArea,
60
+ I as useBuildChartContext
61
+ };
@@ -0,0 +1,4 @@
1
+ export { CartesianChart } from './CartesianChart';
2
+ export { useCartesianChartContext } from './context';
3
+ export type { CartesianChartProps } from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from 'react';
2
+ import { AxisConfigProps, ChartInset, Series } from '../../utils/types';
3
+ export type CartesianChartProps = {
4
+ /**
5
+ * Data series provided to child components via context.
6
+ */
7
+ series: Series[];
8
+ /**
9
+ * Scale and domain configuration for the x-axis.
10
+ */
11
+ xAxis?: Partial<AxisConfigProps>;
12
+ /**
13
+ * Scale and domain configuration for the y-axis.
14
+ */
15
+ yAxis?: Partial<AxisConfigProps>;
16
+ /**
17
+ * Width of the chart.
18
+ * A number is treated as pixels; a string (e.g. `'100%'`) fills the container
19
+ * and enables auto-measurement via `ResizeObserver`.
20
+ * @default '100%'
21
+ */
22
+ width?: number | string;
23
+ /**
24
+ * Height of the chart in pixels.
25
+ * @default 160
26
+ */
27
+ height?: number;
28
+ /**
29
+ * Padding between the SVG edge and the drawing area.
30
+ * A number applies uniformly; a partial object overrides individual sides.
31
+ */
32
+ inset?: number | Partial<ChartInset>;
33
+ /**
34
+ * Space reserved for axes around the drawing area.
35
+ * Shrinks the drawing area by the specified amount on each side.
36
+ */
37
+ axisPadding?: Partial<ChartInset>;
38
+ /**
39
+ * Accessible label for the chart SVG.
40
+ * @default 'Chart'
41
+ */
42
+ ariaLabel?: string;
43
+ /**
44
+ * SVG content rendered inside the chart's context provider.
45
+ */
46
+ children?: ReactNode;
47
+ };
48
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/CartesianChart/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE7E,MAAM,MAAM,mBAAmB,GAAG;IAChC;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IACjC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { LineProps } from './types';
2
+ export declare function Line({ seriesId, stroke, showArea, areaType: _areaType, }: LineProps): import("react/jsx-runtime").JSX.Element | null;
3
+ //# sourceMappingURL=Line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Line.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/Line.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMzC,wBAAgB,IAAI,CAAC,EACnB,QAAQ,EACR,MAAM,EACN,QAAgB,EAChB,QAAQ,EAAE,SAAsB,GACjC,EAAE,SAAS,kDA6EX"}
@@ -0,0 +1,73 @@
1
+ import { jsxs as l, Fragment as m, jsx as e } from "react/jsx-runtime";
2
+ import { useId as y, useMemo as d } from "react";
3
+ import { isNumericScale as A } from "../../utils/scales/scales.js";
4
+ import { toScaledPoints as P, buildLinePath as T, buildAreaPath as I } from "./utils.js";
5
+ import { useCartesianChartContext as L } from "../CartesianChart/context/cartesianChartContext.js";
6
+ const O = 2, _ = 0.2;
7
+ function M({
8
+ seriesId: g,
9
+ stroke: h,
10
+ showArea: i = !1,
11
+ areaType: j = "gradient"
12
+ }) {
13
+ const { getXScale: x, getYScale: C, getXAxisConfig: S, drawingArea: r, seriesMap: k } = L(), s = x(), o = C(), c = S(), p = y(), n = k.get(g), a = h ?? n?.stroke, t = d(
14
+ () => n?.data && s && o && A(o) ? P(n.data, s, o, c?.data) : null,
15
+ [n, s, o, c]
16
+ ), f = d(
17
+ () => t ? T(t) : null,
18
+ [t]
19
+ ), u = d(
20
+ () => i && t && r ? I(t, r) : null,
21
+ [i, t, r]
22
+ );
23
+ return f ? /* @__PURE__ */ l(m, { children: [
24
+ i && u && a && /* @__PURE__ */ l(m, { children: [
25
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ l(
26
+ "linearGradient",
27
+ {
28
+ "data-testid": "line-gradient",
29
+ id: p,
30
+ x1: "0",
31
+ y1: "0",
32
+ x2: "0",
33
+ y2: "1",
34
+ children: [
35
+ /* @__PURE__ */ e(
36
+ "stop",
37
+ {
38
+ offset: "0%",
39
+ stopColor: a,
40
+ stopOpacity: _
41
+ }
42
+ ),
43
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: a, stopOpacity: 0 })
44
+ ]
45
+ }
46
+ ) }),
47
+ /* @__PURE__ */ e(
48
+ "path",
49
+ {
50
+ "data-testid": "line-area",
51
+ d: u,
52
+ fill: `url(#${p})`,
53
+ stroke: "none"
54
+ }
55
+ )
56
+ ] }),
57
+ /* @__PURE__ */ e(
58
+ "path",
59
+ {
60
+ "data-testid": "line-path",
61
+ d: f,
62
+ fill: "none",
63
+ stroke: a,
64
+ strokeWidth: O,
65
+ strokeLinecap: "round",
66
+ strokeLinejoin: "round"
67
+ }
68
+ )
69
+ ] }) : null;
70
+ }
71
+ export {
72
+ M as Line
73
+ };
@@ -0,0 +1,3 @@
1
+ export { Line } from './Line';
2
+ export type { LineProps } from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/Components/Line/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}