@wonderflow/charts 12.8.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.
Files changed (259) hide show
  1. package/dist/components/cartesian-base/cartesian-base-axis.d.ts +15 -0
  2. package/dist/components/cartesian-base/cartesian-base-axis.d.ts.map +1 -0
  3. package/dist/components/cartesian-base/cartesian-base-axis.js +53 -0
  4. package/dist/components/cartesian-base/cartesian-base-grid.d.ts +23 -0
  5. package/dist/components/cartesian-base/cartesian-base-grid.d.ts.map +1 -0
  6. package/dist/components/cartesian-base/cartesian-base-grid.js +35 -0
  7. package/dist/components/cartesian-base/cartesian-base-legend.d.ts +7 -0
  8. package/dist/components/cartesian-base/cartesian-base-legend.d.ts.map +1 -0
  9. package/dist/components/cartesian-base/cartesian-base-legend.js +35 -0
  10. package/dist/components/cartesian-base/cartesian-base.d.ts +78 -0
  11. package/dist/components/cartesian-base/cartesian-base.d.ts.map +1 -0
  12. package/dist/components/cartesian-base/cartesian-base.js +98 -0
  13. package/dist/components/cartesian-base/cartesian-base.module.css +1 -0
  14. package/dist/components/cartesian-base/cartesian-base.test.d.ts +2 -0
  15. package/dist/components/cartesian-base/cartesian-base.test.d.ts.map +1 -0
  16. package/dist/components/cartesian-base/cartesian-base.test.js +51 -0
  17. package/dist/components/cartesian-base/index.d.ts +3 -0
  18. package/dist/components/cartesian-base/index.d.ts.map +1 -0
  19. package/dist/components/cartesian-base/index.js +16 -0
  20. package/dist/components/empty-state/empty-state.d.ts +16 -0
  21. package/dist/components/empty-state/empty-state.d.ts.map +1 -0
  22. package/dist/components/empty-state/empty-state.js +31 -0
  23. package/dist/components/empty-state/empty-state.test.d.ts +2 -0
  24. package/dist/components/empty-state/empty-state.test.d.ts.map +1 -0
  25. package/dist/components/empty-state/empty-state.test.js +67 -0
  26. package/dist/components/empty-state/index.d.ts +2 -0
  27. package/dist/components/empty-state/index.d.ts.map +1 -0
  28. package/dist/components/empty-state/index.js +16 -0
  29. package/dist/components/headings/headings.d.ts +27 -0
  30. package/dist/components/headings/headings.d.ts.map +1 -0
  31. package/dist/components/headings/headings.js +31 -0
  32. package/dist/components/headings/headings.test.d.ts +2 -0
  33. package/dist/components/headings/headings.test.d.ts.map +1 -0
  34. package/dist/components/headings/headings.test.js +14 -0
  35. package/dist/components/headings/index.d.ts +3 -0
  36. package/dist/components/headings/index.d.ts.map +1 -0
  37. package/dist/components/headings/index.js +16 -0
  38. package/dist/components/index.d.ts +7 -0
  39. package/dist/components/index.d.ts.map +1 -0
  40. package/dist/components/index.js +21 -0
  41. package/dist/components/line-chart/index.d.ts +3 -0
  42. package/dist/components/line-chart/index.d.ts.map +1 -0
  43. package/dist/components/line-chart/index.js +16 -0
  44. package/dist/components/line-chart/line-chart.d.ts +57 -0
  45. package/dist/components/line-chart/line-chart.d.ts.map +1 -0
  46. package/dist/components/line-chart/line-chart.js +68 -0
  47. package/dist/components/line-chart/line-chart.test.d.ts +2 -0
  48. package/dist/components/line-chart/line-chart.test.d.ts.map +1 -0
  49. package/dist/components/line-chart/line-chart.test.js +20 -0
  50. package/dist/components/loader/bar-chart-loader.d.ts +11 -0
  51. package/dist/components/loader/bar-chart-loader.d.ts.map +1 -0
  52. package/dist/components/loader/bar-chart-loader.js +3 -0
  53. package/dist/components/loader/index.d.ts +2 -0
  54. package/dist/components/loader/index.d.ts.map +1 -0
  55. package/dist/components/loader/index.js +16 -0
  56. package/dist/components/loader/line-chart-loader.d.ts +11 -0
  57. package/dist/components/loader/line-chart-loader.d.ts.map +1 -0
  58. package/dist/components/loader/line-chart-loader.js +3 -0
  59. package/dist/components/loader/loader.d.ts +10 -0
  60. package/dist/components/loader/loader.d.ts.map +1 -0
  61. package/dist/components/loader/loader.js +35 -0
  62. package/dist/components/loader/loader.test.d.ts +2 -0
  63. package/dist/components/loader/loader.test.d.ts.map +1 -0
  64. package/dist/components/loader/loader.test.js +50 -0
  65. package/dist/components/placeholder/index.d.ts +3 -0
  66. package/dist/components/placeholder/index.d.ts.map +1 -0
  67. package/dist/components/placeholder/index.js +16 -0
  68. package/dist/components/placeholder/placeholder.d.ts +9 -0
  69. package/dist/components/placeholder/placeholder.d.ts.map +1 -0
  70. package/dist/components/placeholder/placeholder.js +19 -0
  71. package/dist/components/placeholder/placeholder.test.d.ts +2 -0
  72. package/dist/components/placeholder/placeholder.test.d.ts.map +1 -0
  73. package/dist/components/placeholder/placeholder.test.js +15 -0
  74. package/dist/components/shapes/index.d.ts +2 -0
  75. package/dist/components/shapes/index.d.ts.map +1 -0
  76. package/dist/components/shapes/index.js +16 -0
  77. package/dist/components/shapes/lines/index.d.ts +2 -0
  78. package/dist/components/shapes/lines/index.d.ts.map +1 -0
  79. package/dist/components/shapes/lines/index.js +16 -0
  80. package/dist/components/shapes/lines/lines-marker-labels.d.ts +3 -0
  81. package/dist/components/shapes/lines/lines-marker-labels.d.ts.map +1 -0
  82. package/dist/components/shapes/lines/lines-marker-labels.js +72 -0
  83. package/dist/components/shapes/lines/lines-overlay.d.ts +3 -0
  84. package/dist/components/shapes/lines/lines-overlay.d.ts.map +1 -0
  85. package/dist/components/shapes/lines/lines-overlay.js +52 -0
  86. package/dist/components/shapes/lines/lines-series.d.ts +3 -0
  87. package/dist/components/shapes/lines/lines-series.d.ts.map +1 -0
  88. package/dist/components/shapes/lines/lines-series.js +58 -0
  89. package/dist/components/shapes/lines/lines-tooltip.d.ts +3 -0
  90. package/dist/components/shapes/lines/lines-tooltip.d.ts.map +1 -0
  91. package/dist/components/shapes/lines/lines-tooltip.js +107 -0
  92. package/dist/components/shapes/lines/lines.d.ts +3 -0
  93. package/dist/components/shapes/lines/lines.d.ts.map +1 -0
  94. package/dist/components/shapes/lines/lines.js +28 -0
  95. package/dist/components/shapes/lines/lines.module.css +1 -0
  96. package/dist/components/shapes/lines/lines.test.d.ts +2 -0
  97. package/dist/components/shapes/lines/lines.test.d.ts.map +1 -0
  98. package/dist/components/shapes/lines/lines.test.js +142 -0
  99. package/dist/components/tooltip/index.d.ts +3 -0
  100. package/dist/components/tooltip/index.d.ts.map +1 -0
  101. package/dist/components/tooltip/index.js +16 -0
  102. package/dist/components/tooltip/tooltip.d.ts +35 -0
  103. package/dist/components/tooltip/tooltip.d.ts.map +1 -0
  104. package/dist/components/tooltip/tooltip.js +37 -0
  105. package/dist/components/tooltip/tooltip.module.css +1 -0
  106. package/dist/components/tooltip/tooltip.test.d.ts +2 -0
  107. package/dist/components/tooltip/tooltip.test.d.ts.map +1 -0
  108. package/dist/components/tooltip/tooltip.test.js +20 -0
  109. package/dist/index.d.ts +5 -0
  110. package/dist/index.d.ts.map +1 -0
  111. package/dist/index.js +19 -0
  112. package/dist/providers/cartesian.d.ts +20 -0
  113. package/dist/providers/cartesian.d.ts.map +1 -0
  114. package/dist/providers/cartesian.js +43 -0
  115. package/dist/providers/data.d.ts +11 -0
  116. package/dist/providers/data.d.ts.map +1 -0
  117. package/dist/providers/data.js +32 -0
  118. package/dist/providers/index.d.ts +6 -0
  119. package/dist/providers/index.d.ts.map +1 -0
  120. package/dist/providers/index.js +20 -0
  121. package/dist/providers/layout.d.ts +14 -0
  122. package/dist/providers/layout.d.ts.map +1 -0
  123. package/dist/providers/layout.js +34 -0
  124. package/dist/providers/style-config.d.ts +11 -0
  125. package/dist/providers/style-config.d.ts.map +1 -0
  126. package/dist/providers/style-config.js +29 -0
  127. package/dist/providers/theme.d.ts +10 -0
  128. package/dist/providers/theme.d.ts.map +1 -0
  129. package/dist/providers/theme.js +29 -0
  130. package/dist/style-config/axis.d.ts +3 -0
  131. package/dist/style-config/axis.d.ts.map +1 -0
  132. package/dist/style-config/axis.js +86 -0
  133. package/dist/style-config/cartesian.d.ts +3 -0
  134. package/dist/style-config/cartesian.d.ts.map +1 -0
  135. package/dist/style-config/cartesian.js +31 -0
  136. package/dist/style-config/colors.d.ts +9 -0
  137. package/dist/style-config/colors.d.ts.map +1 -0
  138. package/dist/style-config/colors.js +271 -0
  139. package/dist/style-config/grid.d.ts +7 -0
  140. package/dist/style-config/grid.d.ts.map +1 -0
  141. package/dist/style-config/grid.js +24 -0
  142. package/dist/style-config/headings.d.ts +3 -0
  143. package/dist/style-config/headings.d.ts.map +1 -0
  144. package/dist/style-config/headings.js +39 -0
  145. package/dist/style-config/index.d.ts +10 -0
  146. package/dist/style-config/index.d.ts.map +1 -0
  147. package/dist/style-config/index.js +24 -0
  148. package/dist/style-config/legend.d.ts +3 -0
  149. package/dist/style-config/legend.d.ts.map +1 -0
  150. package/dist/style-config/legend.js +18 -0
  151. package/dist/style-config/linear-gradient.d.ts +3 -0
  152. package/dist/style-config/linear-gradient.d.ts.map +1 -0
  153. package/dist/style-config/linear-gradient.js +20 -0
  154. package/dist/style-config/lines.d.ts +3 -0
  155. package/dist/style-config/lines.d.ts.map +1 -0
  156. package/dist/style-config/lines.js +39 -0
  157. package/dist/style-config/themes.d.ts +5 -0
  158. package/dist/style-config/themes.d.ts.map +1 -0
  159. package/dist/style-config/themes.js +86 -0
  160. package/dist/style-config/tooltip.d.ts +8 -0
  161. package/dist/style-config/tooltip.d.ts.map +1 -0
  162. package/dist/style-config/tooltip.js +56 -0
  163. package/dist/style-config/viewport.d.ts +3 -0
  164. package/dist/style-config/viewport.d.ts.map +1 -0
  165. package/dist/style-config/viewport.js +30 -0
  166. package/dist/types/axis.d.ts +108 -0
  167. package/dist/types/axis.d.ts.map +1 -0
  168. package/dist/types/axis.js +16 -0
  169. package/dist/types/cartesian.d.ts +58 -0
  170. package/dist/types/cartesian.d.ts.map +1 -0
  171. package/dist/types/cartesian.js +20 -0
  172. package/dist/types/colors.d.ts +9 -0
  173. package/dist/types/colors.d.ts.map +1 -0
  174. package/dist/types/colors.js +16 -0
  175. package/dist/types/grid.d.ts +14 -0
  176. package/dist/types/grid.d.ts.map +1 -0
  177. package/dist/types/grid.js +1 -0
  178. package/dist/types/headings.d.ts +26 -0
  179. package/dist/types/headings.d.ts.map +1 -0
  180. package/dist/types/headings.js +16 -0
  181. package/dist/types/index.d.ts +13 -0
  182. package/dist/types/index.d.ts.map +1 -0
  183. package/dist/types/index.js +27 -0
  184. package/dist/types/legend.d.ts +4 -0
  185. package/dist/types/legend.d.ts.map +1 -0
  186. package/dist/types/legend.js +16 -0
  187. package/dist/types/line-chart.d.ts +53 -0
  188. package/dist/types/line-chart.d.ts.map +1 -0
  189. package/dist/types/line-chart.js +16 -0
  190. package/dist/types/linear-gradient.d.ts +5 -0
  191. package/dist/types/linear-gradient.d.ts.map +1 -0
  192. package/dist/types/linear-gradient.js +16 -0
  193. package/dist/types/lines.d.ts +25 -0
  194. package/dist/types/lines.d.ts.map +1 -0
  195. package/dist/types/lines.js +16 -0
  196. package/dist/types/main.d.ts +11 -0
  197. package/dist/types/main.d.ts.map +1 -0
  198. package/dist/types/main.js +20 -0
  199. package/dist/types/themes.d.ts +31 -0
  200. package/dist/types/themes.d.ts.map +1 -0
  201. package/dist/types/themes.js +16 -0
  202. package/dist/types/tooltip.d.ts +23 -0
  203. package/dist/types/tooltip.d.ts.map +1 -0
  204. package/dist/types/tooltip.js +16 -0
  205. package/dist/types/viewport.d.ts +8 -0
  206. package/dist/types/viewport.d.ts.map +1 -0
  207. package/dist/types/viewport.js +16 -0
  208. package/dist/utils/axis.d.ts +60 -0
  209. package/dist/utils/axis.d.ts.map +1 -0
  210. package/dist/utils/axis.js +401 -0
  211. package/dist/utils/axis.test.d.ts +2 -0
  212. package/dist/utils/axis.test.d.ts.map +1 -0
  213. package/dist/utils/axis.test.js +1071 -0
  214. package/dist/utils/colors.d.ts +8 -0
  215. package/dist/utils/colors.d.ts.map +1 -0
  216. package/dist/utils/colors.js +33 -0
  217. package/dist/utils/colors.test.d.ts +2 -0
  218. package/dist/utils/colors.test.d.ts.map +1 -0
  219. package/dist/utils/colors.test.js +31 -0
  220. package/dist/utils/data.d.ts +14 -0
  221. package/dist/utils/data.d.ts.map +1 -0
  222. package/dist/utils/data.js +116 -0
  223. package/dist/utils/data.test.d.ts +2 -0
  224. package/dist/utils/data.test.d.ts.map +1 -0
  225. package/dist/utils/data.test.js +371 -0
  226. package/dist/utils/format.d.ts +15 -0
  227. package/dist/utils/format.d.ts.map +1 -0
  228. package/dist/utils/format.js +41 -0
  229. package/dist/utils/format.test.d.ts +2 -0
  230. package/dist/utils/format.test.d.ts.map +1 -0
  231. package/dist/utils/format.test.js +101 -0
  232. package/dist/utils/index.d.ts +8 -0
  233. package/dist/utils/index.d.ts.map +1 -0
  234. package/dist/utils/index.js +22 -0
  235. package/dist/utils/lines.d.ts +52 -0
  236. package/dist/utils/lines.d.ts.map +1 -0
  237. package/dist/utils/lines.js +190 -0
  238. package/dist/utils/lines.test.d.ts +2 -0
  239. package/dist/utils/lines.test.d.ts.map +1 -0
  240. package/dist/utils/lines.test.js +498 -0
  241. package/dist/utils/math.d.ts +13 -0
  242. package/dist/utils/math.d.ts.map +1 -0
  243. package/dist/utils/math.js +89 -0
  244. package/dist/utils/math.test.d.ts +2 -0
  245. package/dist/utils/math.test.d.ts.map +1 -0
  246. package/dist/utils/math.test.js +142 -0
  247. package/dist/utils/metadata.d.ts +6 -0
  248. package/dist/utils/metadata.d.ts.map +1 -0
  249. package/dist/utils/metadata.js +36 -0
  250. package/dist/utils/metadata.test.d.ts +2 -0
  251. package/dist/utils/metadata.test.d.ts.map +1 -0
  252. package/dist/utils/metadata.test.js +102 -0
  253. package/dist/utils/viewport.d.ts +3 -0
  254. package/dist/utils/viewport.d.ts.map +1 -0
  255. package/dist/utils/viewport.js +29 -0
  256. package/dist/utils/viewport.test.d.ts +2 -0
  257. package/dist/utils/viewport.test.d.ts.map +1 -0
  258. package/dist/utils/viewport.test.js +63 -0
  259. package/package.json +106 -0
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { TickFormatter } from '@visx/axis';
3
+ import { NumberValue } from '@visx/vendor/d3-scale';
4
+ import { AxisConfig, CartesianxAxisSystem } from '../../types/axis';
5
+ export declare type CartesianBaseAxisProps = {
6
+ axis: CartesianxAxisSystem;
7
+ axisConfig: AxisConfig;
8
+ dimension: {
9
+ maxWidth: number;
10
+ maxHeight: number;
11
+ };
12
+ };
13
+ export declare type TickFormat = TickFormatter<string | NumberValue | Date> | undefined;
14
+ export declare const CartesianBaseAxis: React.FC<CartesianBaseAxisProps>;
15
+ //# sourceMappingURL=cartesian-base-axis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian-base-axis.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/cartesian-base-axis.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAEL,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,UAAU,EAAiB,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AASnF,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAA;AAED,oBAAY,UAAU,GAAG,aAAa,CAAC,MAAM,GAAG,WAAW,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC;AAEhF,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA8D9D,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement as _createElement } from "react";
3
+ /*
4
+ * Copyright 2023 Wonderflow Design Team
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ import { Axis, } from '@visx/axis';
19
+ import { Group } from '@visx/group';
20
+ import { v4 as uuid } from 'uuid';
21
+ import { useStyleConfigContext, useThemeContext } from '../../providers';
22
+ import { handleNumberOfTicks, handleTickFormat, handleVerticalTickLabelOffset, handleVerticalTickLabelTransform, hasVerticalTickLabel, } from '../../utils/axis';
23
+ export const CartesianBaseAxis = ({ axis, axisConfig, dimension, }) => {
24
+ const theme = useThemeContext();
25
+ const styleConfig = useStyleConfigContext();
26
+ const { viewport, themes } = styleConfig;
27
+ const { maxWidth: xMax, maxHeight: yMax } = dimension;
28
+ return (_jsx(Group, { children: Object.values(axis)
29
+ .filter((a) => !!a)
30
+ .map((a) => {
31
+ const orientation = axisConfig[a.orientation];
32
+ const { tickLabel, tick, label, line, } = themes[theme].axis;
33
+ const { tickLabelProps, tickLineProps, labelProps, axisLineProps, } = axisConfig.style;
34
+ const isVertical = hasVerticalTickLabel(xMax, a, viewport);
35
+ const numTicks = handleNumberOfTicks(xMax, yMax, a, viewport);
36
+ const labelOffset = orientation.labelOffset + handleVerticalTickLabelOffset(xMax, styleConfig, a);
37
+ const tickFormat = handleTickFormat(a);
38
+ return (_createElement(Axis, { ...a, key: uuid(), numTicks: numTicks, tickLength: tickLineProps.length, tickLabelProps: v => ({
39
+ ...tickLabelProps,
40
+ ...orientation.tickLabelProps,
41
+ ...handleVerticalTickLabelTransform(v, isVertical, a),
42
+ fill: tickLabel,
43
+ }), tickLineProps: {
44
+ ...tickLineProps,
45
+ stroke: tick,
46
+ }, tickFormat: tickFormat, label: a.label, labelOffset: labelOffset, labelProps: {
47
+ ...labelProps,
48
+ ...orientation.labelProps,
49
+ fill: label,
50
+ }, stroke: line, strokeDasharray: axisLineProps.strokeDasharray, strokeWidth: axisLineProps.strokeWidth }));
51
+ }) }));
52
+ };
53
+ CartesianBaseAxis.displayName = 'CartesianBaseAxis';
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ import { Background, CartesianxAxisSystem } from '../../types';
3
+ export declare type CartesianBaseGridProps = {
4
+ axis: CartesianxAxisSystem;
5
+ position: {
6
+ top?: number;
7
+ right?: number;
8
+ bottom?: number;
9
+ left?: number;
10
+ };
11
+ dimension: {
12
+ maxWidth: number;
13
+ maxHeight: number;
14
+ };
15
+ hideRows?: boolean;
16
+ hideColumns?: boolean;
17
+ tickRows?: number;
18
+ tickColumns?: number;
19
+ background?: Background;
20
+ otherProps?: Record<string, any>;
21
+ };
22
+ export declare const CartesianBaseGrid: React.FC<CartesianBaseGridProps>;
23
+ //# sourceMappingURL=cartesian-base-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian-base-grid.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/cartesian-base-grid.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE/D,oBAAY,sBAAsB,GAAG;IACnC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,QAAQ,EAAE;QACR,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAA;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA0E9D,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { LinearGradient } from '@visx/gradient';
18
+ import { GridColumns, GridRows } from '@visx/grid';
19
+ import { Group } from '@visx/group';
20
+ import { useLayoutContext, useStyleConfigContext } from '../../providers';
21
+ import { useThemeContext } from '../../providers/theme';
22
+ export const CartesianBaseGrid = ({ axis, position, dimension, hideColumns = false, hideRows = false, tickRows = 10, tickColumns = 10, background, otherProps, }) => {
23
+ const theme = useThemeContext();
24
+ const { grid: gStyle, themes } = useStyleConfigContext();
25
+ const { isHorizontal } = useLayoutContext();
26
+ const { maxWidth, maxHeight } = dimension;
27
+ const { left, top } = position;
28
+ const { from, to } = { ...themes[theme].grid.background, ...background };
29
+ const scaleRow = axis.left?.scale ?? axis.right.scale;
30
+ const scaleCols = axis.bottom?.scale ?? axis.top.scale;
31
+ const hasRows = Boolean(!hideRows && scaleRow);
32
+ const hasCols = Boolean(!hideColumns && scaleCols);
33
+ return (_jsxs(Group, { children: [_jsx(LinearGradient, { id: "cartesian-grid-background", from: from, to: to, rotate: isHorizontal ? 0 : 270 }), _jsx("rect", { x: left, y: top, width: maxWidth, height: maxHeight, fill: "url(#cartesian-grid-background)" }), hasRows && (_jsx(GridRows, { left: left, top: top, scale: scaleRow, width: maxWidth, numTicks: tickRows, offset: gStyle.rows?.offset, fill: "", stroke: themes[theme].grid.line, strokeOpacity: gStyle.rows?.strokeOpacity, strokeWidth: gStyle.rows?.strokeWidth, strokeDasharray: gStyle.rows?.strokeDasharray, lineStyle: gStyle.rows?.lineStyle, ...otherProps })), hasCols && (_jsx(GridColumns, { left: left, top: top, scale: scaleCols, height: maxHeight, numTicks: tickColumns, offset: gStyle.columns?.offset, fill: "", stroke: themes[theme].grid.line, strokeOpacity: gStyle.columns?.strokeOpacity, strokeWidth: gStyle.columns?.strokeWidth, strokeDasharray: gStyle.columns?.strokeDasharray, lineStyle: gStyle.columns?.lineStyle, ...otherProps }))] }));
34
+ };
35
+ CartesianBaseGrid.displayName = 'CartesianBaseGrid';
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export declare type CartesianBaseLegendProps = {
3
+ customLegend?: React.ReactNode;
4
+ hideLegend?: boolean;
5
+ };
6
+ export declare const CartesianBaseLegend: React.ForwardRefExoticComponent<CartesianBaseLegendProps & React.RefAttributes<HTMLDivElement>>;
7
+ //# sourceMappingURL=cartesian-base-legend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian-base-legend.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/cartesian-base-legend.tsx"],"names":[],"mappings":";AAyBA,oBAAY,wBAAwB,GAAG;IACrC,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAqCD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,yBAAyB,CACjE,wBAAwB,GAAG,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAiB5D,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { forwardRef, } from 'react';
18
+ import { useDataContext } from '../../providers/data';
19
+ import { Placeholder } from '../placeholder';
20
+ import styles from './cartesian-base.module.css';
21
+ const renderLegendItems = (metadata) => {
22
+ if (metadata) {
23
+ const { names, colors, dataKey: sdk } = metadata.series;
24
+ const { name, color, dataKey: odk } = metadata.overlay;
25
+ return (_jsxs("ul", { children: [sdk.map((s, i) => (_jsx("li", { children: _jsxs("div", { children: [_jsx(Placeholder, { color: colors[i] }), _jsx("span", { children: names[i] })] }) }, s))), odk && (_jsx("li", { children: _jsxs("div", { children: [_jsx(Placeholder, { color: color }), _jsx("span", { children: name })] }) }))] }));
26
+ }
27
+ return null;
28
+ };
29
+ export const CartesianBaseLegend = forwardRef(({ customLegend, hideLegend = false, }, forwardedRef) => {
30
+ const { metadata } = useDataContext();
31
+ if (hideLegend)
32
+ return null;
33
+ return (_jsx("div", { ref: forwardedRef, className: styles.Legend, children: _jsx("div", { className: styles.LegendContent, children: customLegend ?? renderLegendItems(metadata) }) }));
34
+ });
35
+ CartesianBaseLegend.displayName = 'CartesianBaseLegend';
@@ -0,0 +1,78 @@
1
+ /// <reference types="react" />
2
+ import { AxisOrientation } from '../../types';
3
+ import { AxisProps, CartesianStyleConfig, GridProps, MarginProps } from '../../types/cartesian';
4
+ import { Background } from '../../types/linear-gradient';
5
+ import { DeepPartial } from '../../types/main';
6
+ import { HeadingsProps } from '../headings';
7
+ export declare type CartesianBaseProps = {
8
+ /**
9
+ * Set the title in the headings. If no title is set, headings will not be displayed.
10
+ */
11
+ title?: string;
12
+ /**
13
+ * Set an optional subtitle in the headings.
14
+ */
15
+ subtitle?: string;
16
+ /**
17
+ * Set headings custom position and style.
18
+ */
19
+ headings?: Pick<HeadingsProps, 'top' | 'left' | 'config'>;
20
+ /**
21
+ * Set the Cartesian component width. 800px is the default value;
22
+ */
23
+ width?: number;
24
+ /**
25
+ * Set the Cartesian component height. 600px is the default value;
26
+ */
27
+ height?: number;
28
+ /**
29
+ * If true prevent the chart to be responsive.
30
+ */
31
+ preventResponsive?: boolean;
32
+ /**
33
+ * Set the loading state.
34
+ */
35
+ isLoading?: boolean;
36
+ /**
37
+ * Set the Cartesian component background `from` and `to` values.
38
+ */
39
+ background?: Background;
40
+ /**
41
+ * Set margin using an object with `top`, `right`, `bottom` and `left` position.
42
+ */
43
+ margin?: MarginProps;
44
+ /**
45
+ * Set `Grid` properties.
46
+ */
47
+ grid?: GridProps;
48
+ /**
49
+ * Set `Axis System` properties.
50
+ */
51
+ axis: Record<AxisOrientation, AxisProps | undefined>;
52
+ /**
53
+ * Hide `Legend` when set to `true`.
54
+ */
55
+ hideLegend?: boolean;
56
+ /**
57
+ * Set an optional custom `Empty State` component.
58
+ */
59
+ emptyState?: React.ReactNode;
60
+ /**
61
+ * Set an optional `Empty State` message to be displayed under the label 'No Data Available'.
62
+ */
63
+ emptyStateMessage?: string;
64
+ /**
65
+ * Set a custom `Legend` content.
66
+ */
67
+ customLegend?: React.ReactNode;
68
+ /**
69
+ * Set custom styling properties.
70
+ */
71
+ styleConfig?: DeepPartial<CartesianStyleConfig>;
72
+ /**
73
+ * Set other custom properties.
74
+ */
75
+ otherProps?: Record<string, any>;
76
+ };
77
+ export declare const CartesianBase: React.FC<CartesianBaseProps>;
78
+ //# sourceMappingURL=cartesian-base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian-base.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/cartesian-base.tsx"],"names":[],"mappings":";AA+BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,EACxD,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAEL,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAM1B,OAAO,EAAY,aAAa,EAAE,MAAM,aAAa,CAAC;AAQtD,oBAAY,kBAAkB,GAAG;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,GAAE,MAAM,GAAE,QAAQ,CAAC,CAAC;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC,eAAe,EAAE,SAAS,GAAG,SAAS,CAAC,CAAC;IACrD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAChD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4NtD,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { RectClipPath } from '@visx/clip-path';
18
+ import { LinearGradient } from '@visx/gradient';
19
+ import { Group } from '@visx/group';
20
+ import { useSize } from 'ahooks';
21
+ import _ from 'lodash';
22
+ import { useMemo, useRef, } from 'react';
23
+ import { StyleConfigProvider } from '../../providers';
24
+ import { CartesianProvider } from '../../providers/cartesian';
25
+ import { useDataContext } from '../../providers/data';
26
+ import { useThemeContext } from '../../providers/theme';
27
+ import { cartesianStyleConfig, headingsStyleConfig as hStyle } from '../../style-config';
28
+ import { Charts, } from '../../types/main';
29
+ import { computeAxisStyleConfig, computeAxisSystemProperties, handleVerticalTickLabelOffset, } from '../../utils/axis';
30
+ import { EmptyState } from '../empty-state';
31
+ import { Headings } from '../headings';
32
+ import { Loader } from '../loader';
33
+ import { Lines } from '../shapes';
34
+ import styles from './cartesian-base.module.css';
35
+ import { CartesianBaseAxis } from './cartesian-base-axis';
36
+ import { CartesianBaseGrid } from './cartesian-base-grid';
37
+ import { CartesianBaseLegend } from './cartesian-base-legend';
38
+ export const CartesianBase = ({ width = 800, height = 600, preventResponsive, isLoading = false, background, margin = {
39
+ top: 24,
40
+ right: 24,
41
+ bottom: 24,
42
+ left: 24,
43
+ }, grid = {
44
+ hideColumns: false,
45
+ hideRows: false,
46
+ }, title, subtitle, headings, axis, hideLegend = false, emptyState, emptyStateMessage, customLegend, styleConfig, otherProps, }) => {
47
+ const theme = useThemeContext();
48
+ const { metadata, data } = useDataContext();
49
+ const cartesianConfig = _.merge(cartesianStyleConfig, styleConfig);
50
+ const { axis: aStyle, legend: lStyle, themes } = cartesianConfig;
51
+ const { from, to } = _.merge(themes[theme].background, background);
52
+ const ref = useRef(null);
53
+ const size = useSize(ref);
54
+ const refLegend = useRef(null);
55
+ const sizeLegend = useSize(refLegend);
56
+ const hasData = !!data.length;
57
+ const hasEmptyState = !isLoading && !hasData;
58
+ const hasLegend = hasData && !hideLegend && !isLoading;
59
+ const legendHeight = hasLegend ? (sizeLegend?.height ?? 0) : 0;
60
+ const hasHeadings = !!title;
61
+ const headingsHeight = hasHeadings ? hStyle.height : 0;
62
+ const w = size ? size.width : width;
63
+ const h = size ? size.height : height;
64
+ const dynamicWidth = preventResponsive ? width : w;
65
+ const dynamicHeight = preventResponsive ? height : h;
66
+ const dynamicStyle = {
67
+ '--static-width': `${dynamicWidth}px`,
68
+ '--static-height': `${dynamicHeight}px`,
69
+ '--legend-width': `calc(100% - ${margin.left + margin.right}px)`,
70
+ '--legend-top': `calc(100% - ${legendHeight + margin.bottom}px)`,
71
+ '--legend-left': `${margin.left}px`,
72
+ '--legend-padding': lStyle.padding,
73
+ };
74
+ const { top, right, bottom, left, } = axis;
75
+ const axisConfig = useMemo(() => computeAxisStyleConfig(axis, aStyle), [aStyle, axis]);
76
+ const { leftAxisOffset: lOff, topAxisOffset: tOff, verticalAxisOffset: vOff, horizontalAxisOffset: hOff, } = axisConfig.offset;
77
+ const mr = margin.right * (right ? 1 : 2);
78
+ const ml = margin.left * (left ? 1 : 2);
79
+ const xMax = dynamicWidth - ml - mr - vOff;
80
+ const topTickLabelOffset = handleVerticalTickLabelOffset(xMax, cartesianConfig, top);
81
+ const bottomTickLabelOffset = handleVerticalTickLabelOffset(xMax, cartesianConfig, bottom);
82
+ const mt = margin.top * (top ? 1 : 2) + headingsHeight + topTickLabelOffset;
83
+ const mb = margin.bottom * (bottom ? 1 : 2) + legendHeight + bottomTickLabelOffset;
84
+ const yMax = dynamicHeight - mt - mb - hOff;
85
+ const dimension = {
86
+ maxWidth: xMax,
87
+ maxHeight: yMax,
88
+ };
89
+ const position = {
90
+ top: mt + tOff,
91
+ right: ml + lOff + xMax,
92
+ bottom: mt + tOff + yMax,
93
+ left: ml + lOff,
94
+ };
95
+ const axisSystem = computeAxisSystemProperties(axis, dimension, position);
96
+ return (_jsx("div", { className: styles.Wrapper, "data-theme": theme, "data-responsive": !preventResponsive, ref: ref, style: dynamicStyle, "data-testid": "cartesian", children: _jsxs(StyleConfigProvider, { styleConfig: cartesianConfig, children: [_jsxs("svg", { width: dynamicWidth, height: dynamicHeight, viewBox: `0 0 ${dynamicWidth} ${dynamicHeight}`, ...otherProps, children: [_jsx(RectClipPath, { id: "clip-path-cartesian-container", x: 0, y: 0, width: dynamicWidth, height: dynamicHeight }), _jsx(RectClipPath, { id: "clip-path-cartesian-chart", x: position.left, y: position.top, width: dimension.maxWidth, height: dimension.maxHeight }), _jsx(LinearGradient, { id: "cartesian-container", from: from, to: to }), _jsx("rect", { x: 0, y: 0, width: dynamicWidth, height: dynamicHeight, fill: "url(#cartesian-container)", rx: 0, strokeWidth: 0, stroke: "none" }), _jsx(Headings, { title: title, subtitle: subtitle, top: headings?.top ?? margin.top, left: headings?.left ?? ml, config: headings?.config }), _jsx(Loader, { isLoading: isLoading, top: margin.top + headingsHeight, left: margin.left, width: dynamicWidth - margin.left - margin.right, height: dynamicHeight - headingsHeight - margin.top - margin.bottom }), !isLoading && (_jsxs(Group, { clipPath: "url(#clip-path-cartesian-container)", children: [_jsx(CartesianBaseGrid, { position: position, dimension: dimension, axis: axisSystem, hideRows: !hasData || grid.hideRows, hideColumns: !hasData || grid.hideColumns, tickRows: grid.tickRows, tickColumns: grid.tickColumns, background: grid.background, otherProps: grid.otherProps }), _jsx(CartesianBaseAxis, { dimension: dimension, axis: axisSystem, axisConfig: axisConfig }), _jsx(EmptyState, { position: position, dimension: dimension, customEmptyState: emptyState, message: emptyStateMessage, isVisible: hasEmptyState }), hasData && (_jsx(CartesianProvider, { position: position, dimension: dimension, axis: axisSystem, children: _jsx(Group, { clipPath: "url(#clip-path-cartesian-chart)", children: metadata?.type === Charts.LINE_CHART && _jsx(Lines, {}) }) }))] }))] }), hasLegend && (_jsx(CartesianBaseLegend, { customLegend: customLegend, hideLegend: hideLegend, ref: refLegend }))] }) }));
97
+ };
98
+ CartesianBase.displayName = 'CartesianBase';
@@ -0,0 +1 @@
1
+ .Wrapper{align-items:center;display:block;height:var(--static-height);justify-content:center;overflow:hidden;position:relative;resize:none;width:var(--static-width)}.Wrapper[data-responsive=true]{display:flex;height:inherit;justify-content:center;width:inherit}.Legend{left:var(--legend-left);overflow:hidden;padding:var(--legend-padding);position:absolute;top:var(--legend-top);width:var(--legend-width)}.LegendContent{display:flex;flex-direction:column;width:100%}.LegendContent ul{flex-flow:row wrap;gap:1rem;list-style:none;padding:0;width:100%}.LegendContent li>div,.LegendContent ul{align-items:center;display:flex;justify-content:flex-start}.LegendContent li>div{flex-direction:row;font-size:12px;gap:4px}.LegendContent li>div :hover{cursor:pointer}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cartesian-base.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cartesian-base.test.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/cartesian-base.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import { CartesianBase } from './cartesian-base';
4
+ global.ResizeObserver = jest.fn().mockImplementation(() => ({
5
+ observe: jest.fn(),
6
+ unobserve: jest.fn(),
7
+ disconnect: jest.fn(),
8
+ }));
9
+ const mockedAxis = {
10
+ top: {
11
+ domain: [0, 1],
12
+ scaleType: 'linear',
13
+ orientation: 'top',
14
+ },
15
+ right: {
16
+ domain: ['a', 'b'],
17
+ scaleType: 'label',
18
+ orientation: 'right',
19
+ },
20
+ bottom: {
21
+ domain: ['01-01-2020', '01-01-2024'],
22
+ scaleType: 'time',
23
+ orientation: 'bottom',
24
+ },
25
+ left: {
26
+ domain: [0, 1],
27
+ scaleType: 'linear',
28
+ orientation: 'left',
29
+ },
30
+ };
31
+ describe('<LineChart>', () => {
32
+ it('should render the component', () => {
33
+ render(_jsx(CartesianBase, { axis: mockedAxis }));
34
+ const element = screen.getByTestId('cartesian');
35
+ expect(element).toBeDefined();
36
+ });
37
+ it('should render the component w/o R/B axis', () => {
38
+ render(_jsx(CartesianBase, { axis: { ...mockedAxis, right: undefined, bottom: undefined }, title: "Title", preventResponsive: true, margin: {
39
+ top: 0, right: 0, bottom: 0, left: 0,
40
+ } }));
41
+ const element = screen.getByTestId('cartesian');
42
+ expect(element).toBeDefined();
43
+ });
44
+ it('should render the component w props', () => {
45
+ render(_jsx(CartesianBase, { axis: { ...mockedAxis, left: undefined }, title: "Title", preventResponsive: true, margin: {
46
+ top: 12, right: 12, bottom: 12, left: 12,
47
+ } }));
48
+ const element = screen.getByTestId('cartesian');
49
+ expect(element).toBeDefined();
50
+ });
51
+ });
@@ -0,0 +1,3 @@
1
+ export type { CartesianBaseProps } from './cartesian-base';
2
+ export { CartesianBase } from './cartesian-base';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/cartesian-base/index.ts"],"names":[],"mappings":"AAgBA,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2022-2023 Wonderflow Design Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CartesianBase } from './cartesian-base';
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ export declare type EmptyStateProps = {
3
+ position: {
4
+ top: number;
5
+ left: number;
6
+ };
7
+ dimension: {
8
+ maxWidth: number;
9
+ maxHeight: number;
10
+ };
11
+ message?: string;
12
+ customEmptyState?: React.ReactNode;
13
+ isVisible?: boolean;
14
+ };
15
+ export declare const EmptyState: React.FC<EmptyStateProps>;
16
+ //# sourceMappingURL=empty-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-state.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/empty-state.tsx"],"names":[],"mappings":";AAqBA,oBAAY,eAAe,GAAG;IAC5B,QAAQ,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,SAAS,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAwDhD,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2022-2023 Wonderflow Design Team
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Group } from '@visx/group';
18
+ import { Text } from '@visx/text';
19
+ import { useThemeContext } from '../../providers';
20
+ import { themes } from '../../style-config';
21
+ export const EmptyState = ({ position, dimension, message, customEmptyState, isVisible, }) => {
22
+ const theme = useThemeContext();
23
+ const { top, left } = position;
24
+ const { maxWidth, maxHeight } = dimension;
25
+ if (!isVisible)
26
+ return null;
27
+ return (_jsx(Group, { clipPath: "url(#clip-path-cartesian-chart)", children: customEmptyState
28
+ ? (_jsx("foreignObject", { x: left, y: top, width: maxWidth, height: maxHeight, "data-testid": "empty-state-custom", children: customEmptyState }))
29
+ : (_jsxs(Group, { children: [_jsx(Text, { "data-testid": "empty-state", x: left + maxWidth / 2, y: top + maxHeight / 2, textAnchor: "middle", verticalAnchor: "start", fontSize: 14, fontWeight: 600, fill: themes[theme].headings.title, children: "No Data Available" }), message && (_jsx(Text, { "data-testid": "empty-state-message", x: left + maxWidth / 2, y: top + maxHeight / 2, dy: 16, textAnchor: "middle", verticalAnchor: "start", fontSize: 12, fontWeight: 400, width: maxWidth * 0.8, fill: themes[theme].headings.subtitle, children: message }))] })) }));
30
+ };
31
+ EmptyState.displayName = 'EmptyState';
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=empty-state.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"empty-state.test.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/empty-state.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import { EmptyState } from './empty-state';
4
+ describe('<EmptyState>', () => {
5
+ it('should render the component', () => {
6
+ const position = {
7
+ top: 0,
8
+ right: 0,
9
+ bottom: 0,
10
+ left: 0,
11
+ };
12
+ const dimension = {
13
+ maxWidth: 800,
14
+ maxHeight: 600,
15
+ };
16
+ render(_jsx(EmptyState, { position: position, dimension: dimension, isVisible: true }));
17
+ const element = screen.getByTestId('empty-state');
18
+ expect(element).toBeDefined();
19
+ });
20
+ it('should render the component with a custom content', () => {
21
+ const position = {
22
+ top: 0,
23
+ right: 0,
24
+ bottom: 0,
25
+ left: 0,
26
+ };
27
+ const dimension = {
28
+ maxWidth: 800,
29
+ maxHeight: 600,
30
+ };
31
+ const custom = _jsx("div", { children: "test" });
32
+ render(_jsx(EmptyState, { position: position, dimension: dimension, isVisible: true, customEmptyState: custom }));
33
+ const element = screen.getByTestId('empty-state-custom');
34
+ expect(element).toBeDefined();
35
+ });
36
+ it('should render the component w a custom message', () => {
37
+ const position = {
38
+ top: 0,
39
+ right: 0,
40
+ bottom: 0,
41
+ left: 0,
42
+ };
43
+ const dimension = {
44
+ maxWidth: 800,
45
+ maxHeight: 600,
46
+ };
47
+ render(_jsx(EmptyState, { position: position, dimension: dimension, isVisible: true, message: "test message" }));
48
+ const element = screen.getByText('test message');
49
+ const msg = screen.getByTestId('empty-state-message');
50
+ expect(element).toBeDefined();
51
+ expect(msg).toBeDefined();
52
+ });
53
+ it('should render nothing when isVisible prop is false', () => {
54
+ const position = {
55
+ top: 0,
56
+ right: 0,
57
+ bottom: 0,
58
+ left: 0,
59
+ };
60
+ const dimension = {
61
+ maxWidth: 800,
62
+ maxHeight: 600,
63
+ };
64
+ const { container } = render(_jsx(EmptyState, { position: position, dimension: dimension }));
65
+ expect(container.firstChild).toBeNull();
66
+ });
67
+ });
@@ -0,0 +1,2 @@
1
+ export * from './empty-state';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/empty-state/index.ts"],"names":[],"mappings":"AAgBA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright 2022-2023 Wonderflow Design Team
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from './empty-state';
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import { HeadingsStyleConfig } from '../../types';
3
+ import { DeepPartial } from '../../types/main';
4
+ export declare type HeadingsProps = {
5
+ /**
6
+ * Set the title in the heading.
7
+ */
8
+ title?: string;
9
+ /**
10
+ * Set the subtitle in the heading.
11
+ */
12
+ subtitle?: string;
13
+ /**
14
+ * Set the position from top (Y axis).
15
+ */
16
+ top?: number;
17
+ /**
18
+ * Set the position from left (X axis).
19
+ */
20
+ left?: number;
21
+ /**
22
+ * Set custom headings style attributes.
23
+ */
24
+ config?: DeepPartial<HeadingsStyleConfig>;
25
+ };
26
+ export declare const Headings: React.FC<HeadingsProps>;
27
+ //# sourceMappingURL=headings.d.ts.map