@mbao01/common 0.0.44 → 0.0.45

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 (110) hide show
  1. package/dist/types/components/Chart/Chart.d.ts +2 -0
  2. package/dist/types/components/Chart/ChartContext.d.ts +2 -0
  3. package/dist/types/components/Chart/components/ChartLegend.d.ts +4 -0
  4. package/dist/types/components/Chart/components/ChartStyle.d.ts +2 -0
  5. package/dist/types/components/Chart/components/ChartTooltip.d.ts +4 -0
  6. package/dist/types/components/Chart/components/index.d.ts +3 -0
  7. package/dist/types/components/Chart/constants.d.ts +22 -0
  8. package/dist/types/components/Chart/helpers.d.ts +11 -0
  9. package/dist/types/components/Chart/hooks/index.d.ts +1 -0
  10. package/dist/types/components/Chart/hooks/useChart/index.d.ts +1 -0
  11. package/dist/types/components/Chart/hooks/useChart/useChart.d.ts +1 -0
  12. package/dist/types/components/Chart/index.d.ts +2 -0
  13. package/dist/types/components/Chart/stories/args/activeShapeArgs.d.ts +2 -0
  14. package/dist/types/components/Chart/stories/args/animationArgs.d.ts +12 -0
  15. package/dist/types/components/Chart/stories/args/areaArgs.d.ts +2 -0
  16. package/dist/types/components/Chart/stories/args/areaChartArgs.d.ts +2 -0
  17. package/dist/types/components/Chart/stories/args/barArgs.d.ts +5 -0
  18. package/dist/types/components/Chart/stories/args/barChartArgs.d.ts +2 -0
  19. package/dist/types/components/Chart/stories/args/cartesianChartArgs.d.ts +2 -0
  20. package/dist/types/components/Chart/stories/args/cartesianSharedArgs.d.ts +11 -0
  21. package/dist/types/components/Chart/stories/args/chartArgs.d.ts +6 -0
  22. package/dist/types/components/Chart/stories/args/dotArgs.d.ts +10 -0
  23. package/dist/types/components/Chart/stories/args/events.d.ts +804 -0
  24. package/dist/types/components/Chart/stories/args/labelListArgs.d.ts +2 -0
  25. package/dist/types/components/Chart/stories/args/legendArgs.d.ts +3 -0
  26. package/dist/types/components/Chart/stories/args/lineArgs.d.ts +2 -0
  27. package/dist/types/components/Chart/stories/args/lineChartArgs.d.ts +2 -0
  28. package/dist/types/components/Chart/stories/args/pieArgs.d.ts +2 -0
  29. package/dist/types/components/Chart/stories/args/pieChartArgs.d.ts +2 -0
  30. package/dist/types/components/Chart/stories/args/polarChartArgs.d.ts +2 -0
  31. package/dist/types/components/Chart/stories/args/polarSharedArgs.d.ts +2 -0
  32. package/dist/types/components/Chart/stories/args/radarArgs.d.ts +2 -0
  33. package/dist/types/components/Chart/stories/args/radarChartArgs.d.ts +2 -0
  34. package/dist/types/components/Chart/stories/args/radialBarArgs.d.ts +2 -0
  35. package/dist/types/components/Chart/stories/args/radialBarChartArgs.d.ts +2 -0
  36. package/dist/types/components/Chart/stories/args/rectangleArgs.d.ts +9 -0
  37. package/dist/types/components/Chart/stories/args/referenceSharedArgs.d.ts +4 -0
  38. package/dist/types/components/Chart/stories/args/sectorArgs.d.ts +7 -0
  39. package/dist/types/components/Chart/stories/args/sharedAxisArgs.d.ts +2 -0
  40. package/dist/types/components/Chart/stories/args/stylesArgs.d.ts +6 -0
  41. package/dist/types/components/Chart/stories/args/textArgs.d.ts +2 -0
  42. package/dist/types/components/Chart/stories/args/tooltipArgs.d.ts +4 -0
  43. package/dist/types/components/Chart/stories/args/types.d.ts +13 -0
  44. package/dist/types/components/Chart/stories/args/xAxisArgs.d.ts +2 -0
  45. package/dist/types/components/Chart/stories/args/yAxisArgs.d.ts +2 -0
  46. package/dist/types/components/Chart/stories/examples/AreaChart.d.ts +16 -0
  47. package/dist/types/components/Chart/stories/examples/BarChart.d.ts +20 -0
  48. package/dist/types/components/Chart/stories/examples/LineChart.d.ts +16 -0
  49. package/dist/types/components/Chart/stories/examples/PieChart.d.ts +19 -0
  50. package/dist/types/components/Chart/stories/examples/RadarChart.d.ts +24 -0
  51. package/dist/types/components/Chart/stories/examples/RadialChart.d.ts +17 -0
  52. package/dist/types/components/Chart/stories/examples/Tooltip.d.ts +15 -0
  53. package/dist/types/components/Chart/stories/helpers/index.d.ts +9 -0
  54. package/dist/types/components/Chart/types.d.ts +37 -0
  55. package/package.json +5 -3
  56. package/src/components/Chart/Chart.tsx +26 -0
  57. package/src/components/Chart/ChartContext.tsx +4 -0
  58. package/src/components/Chart/components/ChartLegend.tsx +52 -0
  59. package/src/components/Chart/components/ChartStyle.tsx +32 -0
  60. package/src/components/Chart/components/ChartTooltip.tsx +126 -0
  61. package/src/components/Chart/components/index.ts +3 -0
  62. package/src/components/Chart/constants.ts +78 -0
  63. package/src/components/Chart/helpers.ts +27 -0
  64. package/src/components/Chart/hooks/index.ts +1 -0
  65. package/src/components/Chart/hooks/useChart/index.ts +1 -0
  66. package/src/components/Chart/hooks/useChart/useChart.ts +12 -0
  67. package/src/components/Chart/index.ts +2 -0
  68. package/src/components/Chart/stories/args/activeShapeArgs.ts +34 -0
  69. package/src/components/Chart/stories/args/animationArgs.ts +67 -0
  70. package/src/components/Chart/stories/args/areaArgs.ts +16 -0
  71. package/src/components/Chart/stories/args/areaChartArgs.ts +19 -0
  72. package/src/components/Chart/stories/args/barArgs.ts +123 -0
  73. package/src/components/Chart/stories/args/barChartArgs.ts +65 -0
  74. package/src/components/Chart/stories/args/cartesianChartArgs.ts +42 -0
  75. package/src/components/Chart/stories/args/cartesianSharedArgs.ts +136 -0
  76. package/src/components/Chart/stories/args/chartArgs.ts +244 -0
  77. package/src/components/Chart/stories/args/dotArgs.ts +46 -0
  78. package/src/components/Chart/stories/args/events.ts +343 -0
  79. package/src/components/Chart/stories/args/index.ts +178 -0
  80. package/src/components/Chart/stories/args/labelListArgs.ts +124 -0
  81. package/src/components/Chart/stories/args/legendArgs.ts +205 -0
  82. package/src/components/Chart/stories/args/lineArgs.ts +87 -0
  83. package/src/components/Chart/stories/args/lineChartArgs.ts +17 -0
  84. package/src/components/Chart/stories/args/pieArgs.ts +18 -0
  85. package/src/components/Chart/stories/args/pieChartArgs.ts +7 -0
  86. package/src/components/Chart/stories/args/polarChartArgs.ts +86 -0
  87. package/src/components/Chart/stories/args/polarSharedArgs.ts +42 -0
  88. package/src/components/Chart/stories/args/radarArgs.ts +26 -0
  89. package/src/components/Chart/stories/args/radarChartArgs.ts +26 -0
  90. package/src/components/Chart/stories/args/radialBarArgs.ts +36 -0
  91. package/src/components/Chart/stories/args/radialBarChartArgs.ts +16 -0
  92. package/src/components/Chart/stories/args/rectangleArgs.ts +35 -0
  93. package/src/components/Chart/stories/args/referenceSharedArgs.ts +75 -0
  94. package/src/components/Chart/stories/args/sectorArgs.ts +106 -0
  95. package/src/components/Chart/stories/args/sharedAxisArgs.ts +332 -0
  96. package/src/components/Chart/stories/args/stylesArgs.ts +258 -0
  97. package/src/components/Chart/stories/args/textArgs.ts +97 -0
  98. package/src/components/Chart/stories/args/tooltipArgs.ts +41 -0
  99. package/src/components/Chart/stories/args/types.ts +23 -0
  100. package/src/components/Chart/stories/args/xAxisArgs.ts +109 -0
  101. package/src/components/Chart/stories/args/yAxisArgs.ts +73 -0
  102. package/src/components/Chart/stories/examples/AreaChart.tsx +156 -0
  103. package/src/components/Chart/stories/examples/BarChart.tsx +425 -0
  104. package/src/components/Chart/stories/examples/LineChart.tsx +144 -0
  105. package/src/components/Chart/stories/examples/PieChart.tsx +238 -0
  106. package/src/components/Chart/stories/examples/RadarChart.tsx +261 -0
  107. package/src/components/Chart/stories/examples/RadialChart.tsx +239 -0
  108. package/src/components/Chart/stories/examples/Tooltip.tsx +68 -0
  109. package/src/components/Chart/stories/helpers/index.tsx +75 -0
  110. package/src/components/Chart/types.ts +39 -0
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const labelListArgs: ArgTypes;
@@ -0,0 +1,3 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const legendType: ArgTypes[0];
3
+ export declare const legendArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { Args } from '@storybook/react';
2
+ export declare const lineArgs: Args;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const lineChartArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { Args } from '@storybook/react';
2
+ export declare const pieArgs: Args;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const pieChartArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const polarChartArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const polarSharedArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const radarArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const radarChartArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const radialBarArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const radialBarChartArgs: ArgTypes;
@@ -0,0 +1,9 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const radius: ArgTypes[0];
3
+ export declare const isUpdateAnimationActive: ArgTypes[0];
4
+ /**
5
+ * Caveat: If any prop is added here, it would falsely be add to the documentation of the component
6
+ * where this group is used. If the group is to be extended, then only single props should be imported
7
+ * by each component that does not use all of them.
8
+ * */
9
+ export declare const rectangleArgs: ArgTypes;
@@ -0,0 +1,4 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const referenceStyleArgs: ArgTypes;
3
+ export declare const referenceGeneralArgs: ArgTypes;
4
+ export declare const referenceInternalArgs: ArgTypes;
@@ -0,0 +1,7 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ /**
3
+ * Caveat: If any prop is added here, it would falsely be add to the documentation of the component
4
+ * where this group is used. If the group is to be extended, then only single props should be imported
5
+ * by each component that does not use all of them.
6
+ * */
7
+ export declare const sectorArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const sharedAxisArgs: ArgTypes;
@@ -0,0 +1,6 @@
1
+ import { Args, ArgTypes } from '@storybook/react';
2
+ export declare const hide: ArgTypes[0];
3
+ export declare const generalStyleArgs: ArgTypes;
4
+ export declare const labelDescription = "If false set, labels will not be drawn. If true set, labels will be drawn which have\nthe props calculated internally. If object set, labels will be drawn which have the props merged\nby the internal calculated props and the option. If ReactElement set, the option can be the custom\nlabel element. If set a function, the function will be called to render customized label.";
5
+ export declare const labelSummary = "boolean | Object | ReactElement | Function";
6
+ export declare const radialBarStyleArgs: Args;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const textArgs: ArgTypes;
@@ -0,0 +1,4 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const tooltipType: ArgTypes[0];
3
+ export declare const activeDot: ArgTypes[0];
4
+ export declare const tooltipArgs: ArgTypes;
@@ -0,0 +1,13 @@
1
+ import { SVGProps } from 'react';
2
+ type SVGKeys = Exclude<keyof SVGProps<SVGElement>, "type" | "fill" | "fillOpacity" | "stroke" | "strokeWidth" | "className">;
3
+ export type OmitSVGElement<T> = Omit<T, SVGKeys>;
4
+ export type Flatten<T> = NonNullable<{
5
+ [K in keyof T]: T[K] extends never ? never : {
6
+ [P in keyof T[K]]: T[K][P] extends never ? {
7
+ [Q in `${Exclude<K, symbol>} ${Exclude<P, symbol>}`]: never;
8
+ } : {
9
+ [Q in `${Exclude<K, symbol>} ${Exclude<P, symbol>}`]: T[K][P];
10
+ };
11
+ }[keyof T[K]];
12
+ }[keyof T]>;
13
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const xAxisArgs: ArgTypes;
@@ -0,0 +1,2 @@
1
+ import { ArgTypes } from '@storybook/react';
2
+ export declare const yAxisArgs: ArgTypes;
@@ -0,0 +1,16 @@
1
+ import { AreaChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The AreaChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The AreaChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceArea />`,
10
+ * `<Brush />`, `<CartesianGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Area />`, `<Customized />` or valid svg elements.
11
+ */
12
+ export declare const AreaChartExample: (props: Partial<AreaChartProps>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const StackedAreaChartExample: (props: Partial<AreaChartProps>) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const StackedExpandedAreaChartExample: (props: Partial<AreaChartProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const LabeledAreaChartExample: (props: Partial<AreaChartProps>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const WithLegendAreaChartExample: (props: Partial<AreaChartProps>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { BarChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The BarChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The BarChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceLine />`,
10
+ * `<Brush />`, `<CartesianGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Bar />`, `<Customized />` or valid svg elements.
11
+ */
12
+ export declare const BarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const MultipleBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const HorizontalBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const LabelBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const CustomLabelBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const MixedBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const StackedBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const ActiveBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const NegativeBarChartExample: (props: Partial<BarChartProps>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { LineChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The LineChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The LineChart can be used with the following child components: `<XAxis />`, `<YAxis />`, `<ReferenceArea />`, `<ReferenceDot />`, `<ReferenceLine />`,
10
+ * `<Brush />`, `<CartesianGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Line />`, `<Customized />` or valid svg elements.
11
+ */
12
+ export declare const LineChartExample: (props: LineChartProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const StackedLineChartExample: (props: LineChartProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const CustomDotLineChartExample: (props: LineChartProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const LabeledLineChartExample: (props: LineChartProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const WithLegendLineChartExample: (props: LineChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { PieChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The PieChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The PieChart can be used with the following child components: `<PolarAngleAxis />`, `<PolarRadiusAxis />`,
10
+ * `<PolarGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Pie />`, `<Customized />`
11
+ */
12
+ export declare const PieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const LabeledPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const CustomLabeledPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const LabelListPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const WithLegendPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const DonutPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const ActiveDonutPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const StackedPieChartExample: (props: Partial<PieChartProps>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { RadarChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The RadarChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The RadarChart can be used with the following child components: `<PolarAngleAxis />`, `<PolarRadiusAxis />`,
10
+ * `<PolarGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<Radar />`, `<Customized />`
11
+ */
12
+ export declare const RadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const DotRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const MultipleRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const LinesRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const CustomLabeledRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const RadiusAxisRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const GridCustomRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const GridFilledRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
20
+ export declare const NoGridRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
21
+ export declare const GridCircleRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const NoLinesGridCircleRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
23
+ export declare const GridCircleFilledRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const LegendRadarChartExample: (props: Partial<RadarChartProps>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { RadialBarChartProps } from '../args';
2
+ /**
3
+ * ## Parent
4
+ *
5
+ * The RadialBarChart can be used within: `<Chart />`
6
+ *
7
+ * ## Children
8
+ *
9
+ * The RadialBarChart can be used with the following child components: `<PolarAngleAxis />`, `<PolarRadiusAxis />`,
10
+ * `<PolarGrid />`, `<ChartLegend />`, `<ChartTooltip />`, `<RadialBar />`, `<Customized />`
11
+ */
12
+ export declare const RadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const LabeledRadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const GridRadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const TextRadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const ShapeRadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const StackedRadialChartExample: (props: Partial<RadialBarChartProps>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { ChartTooltipContentProps } from '../../types';
2
+ export declare const tooltipChartConfig: {
3
+ activities: {
4
+ label: string;
5
+ };
6
+ running: {
7
+ label: string;
8
+ color: string;
9
+ };
10
+ swimming: {
11
+ label: string;
12
+ color: string;
13
+ };
14
+ };
15
+ export declare const BarChartExample: (props: ChartTooltipContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { ArgTypes, StoryContext, StoryFn } from '@storybook/react';
2
+ import { ElementType } from 'react';
3
+ export declare const categorizeArgs: (args: ArgTypes, category: string) => ArgTypes<import('@storybook/react').Args>;
4
+ export declare const withArgs: <T extends object>(Component: StoryFn, context: StoryContext<T>) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const getArgsFromArgTypes: <T extends ArgTypes>(argsTypes: T) => Record<keyof T, unknown>;
6
+ export declare const renderer: <T extends ElementType>(Component: T) => {
7
+ <G>(props: G): import("react/jsx-runtime").JSX.Element;
8
+ displayName: string;
9
+ };
@@ -0,0 +1,37 @@
1
+ import { ComponentProps, ComponentType, ReactNode } from 'react';
2
+ import { LegendProps, ResponsiveContainer, Tooltip } from 'recharts';
3
+ import { Theme } from '../../utilities';
4
+ export type ChartConfig = {
5
+ [k in string]: {
6
+ label?: ReactNode;
7
+ icon?: ComponentType;
8
+ } & ({
9
+ color?: string;
10
+ theme?: never;
11
+ } | {
12
+ color?: never;
13
+ theme: Record<Theme, string>;
14
+ });
15
+ };
16
+ export type ChartContextProps = {
17
+ config: ChartConfig;
18
+ };
19
+ export type ChartProps = ComponentProps<"div"> & {
20
+ config: ChartConfig;
21
+ children: ComponentProps<typeof ResponsiveContainer>["children"];
22
+ };
23
+ export type ChartStyleProps = {
24
+ id: string;
25
+ config: ChartConfig;
26
+ };
27
+ export type ChartTooltipContentProps = ComponentProps<typeof Tooltip> & ComponentProps<"div"> & {
28
+ hideLabel?: boolean;
29
+ hideIndicator?: boolean;
30
+ indicator?: "line" | "dot" | "dashed";
31
+ nameKey?: string;
32
+ labelKey?: string;
33
+ };
34
+ export type ChartLegendContentProps = ComponentProps<"div"> & Pick<LegendProps, "payload" | "verticalAlign"> & {
35
+ hideIcon?: boolean;
36
+ nameKey?: string;
37
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/common",
3
3
  "private": false,
4
- "version": "0.0.44",
4
+ "version": "0.0.45",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -53,7 +53,7 @@
53
53
  "dev": "storybook dev -p 6006",
54
54
  "build": "tsc && vite build",
55
55
  "build-storybook": "storybook build -o ../../docs/storybook/common",
56
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
56
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 30",
57
57
  "prettier": "prettier --check \"**/*.{ts,tsx}\"",
58
58
  "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
59
59
  "preview": "vite preview",
@@ -102,6 +102,7 @@
102
102
  "react-dropzone": "^14.2.3",
103
103
  "react-international-phone": "^4.3.0",
104
104
  "react-otp-input": "^3.1.1",
105
+ "recharts": "^2.12.7",
105
106
  "sonner": "^1.5.0",
106
107
  "tailwind-merge": "^2.5.2",
107
108
  "tailwindcss-animate": "^1.0.7",
@@ -116,6 +117,7 @@
116
117
  "@storybook/addon-interactions": "^8.3.4",
117
118
  "@storybook/addon-links": "^8.3.4",
118
119
  "@storybook/addon-onboarding": "^8.3.4",
120
+ "@storybook/addon-storysource": "^8.3.4",
119
121
  "@storybook/addon-themes": "^8.3.4",
120
122
  "@storybook/addon-viewport": "^8.3.4",
121
123
  "@storybook/blocks": "^8.3.4",
@@ -165,5 +167,5 @@
165
167
  "react-dom": "^18.2.0",
166
168
  "typescript": "^5.2.2"
167
169
  },
168
- "gitHead": "8e4871acb249c39327ba4a5b8bdb92770d649b4e"
170
+ "gitHead": "097691180db90aaf22c9557d1f2f919246b167c1"
169
171
  }
@@ -0,0 +1,26 @@
1
+ "use client";
2
+
3
+ import { forwardRef, useId } from "react";
4
+ import { ResponsiveContainer } from "recharts";
5
+ import { cn } from "../../utilities";
6
+ import { ChartContext } from "./ChartContext";
7
+ import { ChartStyle } from "./components";
8
+ import { getChartClasses } from "./constants";
9
+ import { type ChartProps } from "./types";
10
+
11
+ export const Chart = forwardRef<HTMLDivElement, ChartProps>(
12
+ ({ id, className, children, config, ...props }, ref) => {
13
+ const uniqueId = useId();
14
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
15
+
16
+ return (
17
+ <ChartContext.Provider value={{ config }}>
18
+ <div ref={ref} data-chart={chartId} className={cn(getChartClasses(), className)} {...props}>
19
+ <ChartStyle id={chartId} config={config} />
20
+ <ResponsiveContainer>{children}</ResponsiveContainer>
21
+ </div>
22
+ </ChartContext.Provider>
23
+ );
24
+ }
25
+ );
26
+ Chart.displayName = "Chart";
@@ -0,0 +1,4 @@
1
+ import { createContext } from "react";
2
+ import { type ChartContextProps } from "./types";
3
+
4
+ export const ChartContext = createContext<ChartContextProps | null>(null);
@@ -0,0 +1,52 @@
1
+ "use client";
2
+
3
+ import { forwardRef } from "react";
4
+ import { Legend } from "recharts";
5
+ import type { ChartLegendContentProps } from "../types";
6
+ import { cn } from "../../../utilities";
7
+ import {
8
+ getChartLegendContainerClasses,
9
+ getChartLegendItemClasses,
10
+ getChartLegendMarkerClasses,
11
+ } from "../constants";
12
+ import { getPayloadConfigFromPayload } from "../helpers";
13
+ import { useChart } from "../hooks";
14
+
15
+ export const ChartLegend = Legend;
16
+ ChartLegend.displayName = "ChartLegend";
17
+
18
+ export const ChartLegendContent = forwardRef<HTMLDivElement, ChartLegendContentProps>(
19
+ ({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
20
+ const { config } = useChart();
21
+
22
+ if (!payload?.length) {
23
+ return null;
24
+ }
25
+
26
+ return (
27
+ <div ref={ref} className={cn(getChartLegendContainerClasses({ verticalAlign }), className)}>
28
+ {payload.map((item) => {
29
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
30
+ const key = `${nameKey || item.dataKey || "value"}`;
31
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
32
+
33
+ return (
34
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
35
+ <div key={item.value} className={getChartLegendItemClasses()}>
36
+ {itemConfig?.icon && !hideIcon ? (
37
+ <itemConfig.icon />
38
+ ) : (
39
+ <div
40
+ style={{ backgroundColor: item.color }}
41
+ className={getChartLegendMarkerClasses()}
42
+ />
43
+ )}
44
+ {itemConfig?.label}
45
+ </div>
46
+ );
47
+ })}
48
+ </div>
49
+ );
50
+ }
51
+ );
52
+ ChartLegendContent.displayName = "ChartLegendContent";
@@ -0,0 +1,32 @@
1
+ import { type Theme } from "../../../utilities";
2
+ import { THEMES } from "../constants";
3
+ import { type ChartStyleProps } from "../types";
4
+
5
+ export const ChartStyle = ({ id, config }: ChartStyleProps) => {
6
+ const colorConfig = Object.entries(config).filter(([, config]) => config.theme || config.color);
7
+
8
+ if (!colorConfig.length) {
9
+ return null;
10
+ }
11
+
12
+ return (
13
+ <style
14
+ dangerouslySetInnerHTML={{
15
+ __html: Object.entries(THEMES)
16
+ .map(
17
+ ([theme, prefix]) => `
18
+ ${prefix} [data-chart=${id}] {
19
+ ${colorConfig
20
+ .map(([key, itemConfig]) => {
21
+ const color = itemConfig.theme?.[theme as Theme] || itemConfig.color;
22
+ return color ? ` --color-${key}: ${color};` : null;
23
+ })
24
+ .join("\n")}
25
+ }
26
+ `
27
+ )
28
+ .join("\n"),
29
+ }}
30
+ />
31
+ );
32
+ };
@@ -0,0 +1,126 @@
1
+ "use client";
2
+
3
+ import { forwardRef, useMemo } from "react";
4
+ import { Tooltip } from "recharts";
5
+ import type { ChartTooltipContentProps } from "../types";
6
+ import { cn } from "../../../utilities";
7
+ import {
8
+ getChartTooltipContainerClasses,
9
+ getChartTooltipItemClasses,
10
+ getChartTooltipItemIndicatorClasses,
11
+ getChartTooltipItemLabelClasses,
12
+ getChartTooltipItemValueClasses,
13
+ } from "../constants";
14
+ import { getPayloadConfigFromPayload } from "../helpers";
15
+ import { useChart } from "../hooks";
16
+
17
+ export const ChartTooltip = Tooltip;
18
+ ChartTooltip.displayName = "ChartTooltip";
19
+
20
+ export const ChartTooltipContent = forwardRef<HTMLDivElement, ChartTooltipContentProps>(
21
+ (
22
+ {
23
+ active,
24
+ payload,
25
+ className,
26
+ indicator = "dot",
27
+ hideLabel = false,
28
+ hideIndicator = false,
29
+ label,
30
+ labelFormatter,
31
+ labelClassName,
32
+ formatter,
33
+ color,
34
+ nameKey,
35
+ labelKey,
36
+ },
37
+ ref
38
+ ) => {
39
+ const { config } = useChart();
40
+
41
+ const tooltipLabel = useMemo(() => {
42
+ if (hideLabel || !payload?.length) {
43
+ return null;
44
+ }
45
+
46
+ const [item] = payload;
47
+ const key = `${labelKey || item.dataKey || item.name || "value"}`;
48
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
49
+ const value =
50
+ !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
51
+
52
+ if (labelFormatter) {
53
+ return (
54
+ <div className={cn("font-medium", labelClassName)}>{labelFormatter(value, payload)}</div>
55
+ );
56
+ }
57
+
58
+ if (!value) {
59
+ return null;
60
+ }
61
+
62
+ return <div className={cn("font-medium", labelClassName)}>{value}</div>;
63
+ }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
64
+
65
+ if (!active || !payload?.length) {
66
+ return null;
67
+ }
68
+
69
+ const nestLabel = payload.length === 1 && indicator !== "dot";
70
+
71
+ return (
72
+ <div ref={ref} className={cn(getChartTooltipContainerClasses(), className)}>
73
+ {!nestLabel ? tooltipLabel : null}
74
+ <div className="grid gap-1.5">
75
+ {payload.map((item, index) => {
76
+ const key = `${nameKey || item.name || item.dataKey || "value"}`;
77
+ const itemConfig = getPayloadConfigFromPayload(config, item, key);
78
+ const indicatorColor =
79
+ color ||
80
+ (item.payload as { fill: string }).fill ||
81
+ item.color ||
82
+ (item as { fill: string }).fill;
83
+
84
+ return (
85
+ <div key={item.dataKey} className={getChartTooltipItemClasses({ indicator })}>
86
+ {formatter && item?.value !== undefined && item.name ? (
87
+ formatter(item.value, item.name, item, index, payload)
88
+ ) : (
89
+ <>
90
+ {itemConfig?.icon ? (
91
+ <itemConfig.icon />
92
+ ) : (
93
+ !hideIndicator && (
94
+ <div
95
+ className={getChartTooltipItemIndicatorClasses({ indicator, nestLabel })}
96
+ style={
97
+ {
98
+ "--color-bg": indicatorColor,
99
+ "--color-border": indicatorColor,
100
+ } as React.CSSProperties
101
+ }
102
+ />
103
+ )
104
+ )}
105
+ <div className={getChartTooltipItemLabelClasses({ nestLabel })}>
106
+ <div className="grid gap-1.5">
107
+ {nestLabel ? tooltipLabel : null}
108
+ <span>{itemConfig?.label || item.name}</span>
109
+ </div>
110
+ {item.value && (
111
+ <span className={getChartTooltipItemValueClasses()}>
112
+ {item.value.toLocaleString()}
113
+ </span>
114
+ )}
115
+ </div>
116
+ </>
117
+ )}
118
+ </div>
119
+ );
120
+ })}
121
+ </div>
122
+ </div>
123
+ );
124
+ }
125
+ );
126
+ ChartTooltipContent.displayName = "ChartTooltipContent";
@@ -0,0 +1,3 @@
1
+ export { ChartLegend, ChartLegendContent } from "./ChartLegend";
2
+ export { ChartStyle } from "./ChartStyle";
3
+ export { ChartTooltip, ChartTooltipContent } from "./ChartTooltip";