@mbao01/common 0.0.43 → 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 (172) 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/dist/types/components/DatetimePicker/DatetimeGrid.d.ts +26 -0
  56. package/dist/types/components/DatetimePicker/DatetimePicker.d.ts +13 -0
  57. package/dist/types/components/DatetimePicker/constants.d.ts +15 -0
  58. package/dist/types/components/DatetimePicker/index.d.ts +1 -0
  59. package/dist/types/components/DatetimePicker/types.d.ts +25 -0
  60. package/dist/types/components/Form/DatetimeInput/DatetimeCalendar.d.ts +5 -0
  61. package/dist/types/components/Form/DatetimeInput/DatetimeInput.d.ts +83 -0
  62. package/dist/types/components/Form/DatetimeInput/DatetimeInputContext.d.ts +2 -0
  63. package/dist/types/components/Form/DatetimeInput/NaturalLanguageInput.d.ts +5 -0
  64. package/dist/types/components/Form/DatetimeInput/TimePicker.d.ts +1 -0
  65. package/dist/types/components/Form/DatetimeInput/constants.d.ts +24 -0
  66. package/dist/types/components/Form/DatetimeInput/helpers.d.ts +27 -0
  67. package/dist/types/components/Form/DatetimeInput/hooks/index.d.ts +1 -0
  68. package/dist/types/components/Form/DatetimeInput/hooks/useDateInput/index.d.ts +1 -0
  69. package/dist/types/components/Form/DatetimeInput/hooks/useDateInput/useDateInput.d.ts +1 -0
  70. package/dist/types/components/Form/DatetimeInput/index.d.ts +1 -0
  71. package/dist/types/components/Form/DatetimeInput/types.d.ts +31 -0
  72. package/dist/types/components/Form/MultiSelect/MultiSelect.d.ts +46 -0
  73. package/dist/types/components/Form/MultiSelect/MultiSelectContext.d.ts +2 -0
  74. package/dist/types/components/Form/MultiSelect/constants.d.ts +19 -0
  75. package/dist/types/components/Form/MultiSelect/hooks/index.d.ts +1 -0
  76. package/dist/types/components/Form/MultiSelect/hooks/useMultiSelect/index.d.ts +1 -0
  77. package/dist/types/components/Form/MultiSelect/hooks/useMultiSelect/useMultiSelect.d.ts +1 -0
  78. package/dist/types/components/Form/MultiSelect/index.d.ts +1 -0
  79. package/dist/types/components/Form/MultiSelect/types.d.ts +31 -0
  80. package/dist/types/components/Form/TagsInput/TagsInput.d.ts +13 -0
  81. package/dist/types/components/Form/TagsInput/constants.d.ts +16 -0
  82. package/dist/types/components/Form/TagsInput/index.d.ts +1 -0
  83. package/dist/types/components/Form/TagsInput/types.d.ts +9 -0
  84. package/dist/types/components/Form/index.d.ts +2 -0
  85. package/dist/types/index.d.ts +1 -0
  86. package/package.json +7 -3
  87. package/src/components/Chart/Chart.tsx +26 -0
  88. package/src/components/Chart/ChartContext.tsx +4 -0
  89. package/src/components/Chart/components/ChartLegend.tsx +52 -0
  90. package/src/components/Chart/components/ChartStyle.tsx +32 -0
  91. package/src/components/Chart/components/ChartTooltip.tsx +126 -0
  92. package/src/components/Chart/components/index.ts +3 -0
  93. package/src/components/Chart/constants.ts +78 -0
  94. package/src/components/Chart/helpers.ts +27 -0
  95. package/src/components/Chart/hooks/index.ts +1 -0
  96. package/src/components/Chart/hooks/useChart/index.ts +1 -0
  97. package/src/components/Chart/hooks/useChart/useChart.ts +12 -0
  98. package/src/components/Chart/index.ts +2 -0
  99. package/src/components/Chart/stories/args/activeShapeArgs.ts +34 -0
  100. package/src/components/Chart/stories/args/animationArgs.ts +67 -0
  101. package/src/components/Chart/stories/args/areaArgs.ts +16 -0
  102. package/src/components/Chart/stories/args/areaChartArgs.ts +19 -0
  103. package/src/components/Chart/stories/args/barArgs.ts +123 -0
  104. package/src/components/Chart/stories/args/barChartArgs.ts +65 -0
  105. package/src/components/Chart/stories/args/cartesianChartArgs.ts +42 -0
  106. package/src/components/Chart/stories/args/cartesianSharedArgs.ts +136 -0
  107. package/src/components/Chart/stories/args/chartArgs.ts +244 -0
  108. package/src/components/Chart/stories/args/dotArgs.ts +46 -0
  109. package/src/components/Chart/stories/args/events.ts +343 -0
  110. package/src/components/Chart/stories/args/index.ts +178 -0
  111. package/src/components/Chart/stories/args/labelListArgs.ts +124 -0
  112. package/src/components/Chart/stories/args/legendArgs.ts +205 -0
  113. package/src/components/Chart/stories/args/lineArgs.ts +87 -0
  114. package/src/components/Chart/stories/args/lineChartArgs.ts +17 -0
  115. package/src/components/Chart/stories/args/pieArgs.ts +18 -0
  116. package/src/components/Chart/stories/args/pieChartArgs.ts +7 -0
  117. package/src/components/Chart/stories/args/polarChartArgs.ts +86 -0
  118. package/src/components/Chart/stories/args/polarSharedArgs.ts +42 -0
  119. package/src/components/Chart/stories/args/radarArgs.ts +26 -0
  120. package/src/components/Chart/stories/args/radarChartArgs.ts +26 -0
  121. package/src/components/Chart/stories/args/radialBarArgs.ts +36 -0
  122. package/src/components/Chart/stories/args/radialBarChartArgs.ts +16 -0
  123. package/src/components/Chart/stories/args/rectangleArgs.ts +35 -0
  124. package/src/components/Chart/stories/args/referenceSharedArgs.ts +75 -0
  125. package/src/components/Chart/stories/args/sectorArgs.ts +106 -0
  126. package/src/components/Chart/stories/args/sharedAxisArgs.ts +332 -0
  127. package/src/components/Chart/stories/args/stylesArgs.ts +258 -0
  128. package/src/components/Chart/stories/args/textArgs.ts +97 -0
  129. package/src/components/Chart/stories/args/tooltipArgs.ts +41 -0
  130. package/src/components/Chart/stories/args/types.ts +23 -0
  131. package/src/components/Chart/stories/args/xAxisArgs.ts +109 -0
  132. package/src/components/Chart/stories/args/yAxisArgs.ts +73 -0
  133. package/src/components/Chart/stories/examples/AreaChart.tsx +156 -0
  134. package/src/components/Chart/stories/examples/BarChart.tsx +425 -0
  135. package/src/components/Chart/stories/examples/LineChart.tsx +144 -0
  136. package/src/components/Chart/stories/examples/PieChart.tsx +238 -0
  137. package/src/components/Chart/stories/examples/RadarChart.tsx +261 -0
  138. package/src/components/Chart/stories/examples/RadialChart.tsx +239 -0
  139. package/src/components/Chart/stories/examples/Tooltip.tsx +68 -0
  140. package/src/components/Chart/stories/helpers/index.tsx +75 -0
  141. package/src/components/Chart/types.ts +39 -0
  142. package/src/components/DatetimePicker/DatetimeGrid.tsx +59 -0
  143. package/src/components/DatetimePicker/DatetimePicker.tsx +59 -0
  144. package/src/components/DatetimePicker/constants.ts +102 -0
  145. package/src/components/DatetimePicker/index.ts +1 -0
  146. package/src/components/DatetimePicker/types.ts +36 -0
  147. package/src/components/Form/DatetimeInput/DatetimeCalendar.tsx +68 -0
  148. package/src/components/Form/DatetimeInput/DatetimeInput.tsx +90 -0
  149. package/src/components/Form/DatetimeInput/DatetimeInputContext.tsx +4 -0
  150. package/src/components/Form/DatetimeInput/NaturalLanguageInput.tsx +73 -0
  151. package/src/components/Form/DatetimeInput/TimePicker.tsx +202 -0
  152. package/src/components/Form/DatetimeInput/constants.ts +135 -0
  153. package/src/components/Form/DatetimeInput/helpers.ts +93 -0
  154. package/src/components/Form/DatetimeInput/hooks/index.ts +1 -0
  155. package/src/components/Form/DatetimeInput/hooks/useDateInput/index.ts +1 -0
  156. package/src/components/Form/DatetimeInput/hooks/useDateInput/useDateInput.ts +10 -0
  157. package/src/components/Form/DatetimeInput/index.ts +1 -0
  158. package/src/components/Form/DatetimeInput/types.ts +36 -0
  159. package/src/components/Form/MultiSelect/MultiSelect.tsx +348 -0
  160. package/src/components/Form/MultiSelect/MultiSelectContext.tsx +4 -0
  161. package/src/components/Form/MultiSelect/constants.ts +103 -0
  162. package/src/components/Form/MultiSelect/hooks/index.ts +1 -0
  163. package/src/components/Form/MultiSelect/hooks/useMultiSelect/index.ts +1 -0
  164. package/src/components/Form/MultiSelect/hooks/useMultiSelect/useMultiSelect.ts +10 -0
  165. package/src/components/Form/MultiSelect/index.ts +1 -0
  166. package/src/components/Form/MultiSelect/types.ts +46 -0
  167. package/src/components/Form/TagsInput/TagsInput.tsx +278 -0
  168. package/src/components/Form/TagsInput/constants.ts +87 -0
  169. package/src/components/Form/TagsInput/index.ts +1 -0
  170. package/src/components/Form/TagsInput/types.ts +10 -0
  171. package/src/components/Form/index.ts +2 -0
  172. package/src/index.ts +1 -0
@@ -0,0 +1,178 @@
1
+ import type {
2
+ AreaProps,
3
+ BarProps,
4
+ LineProps,
5
+ PieProps,
6
+ RadarProps,
7
+ RadialBarProps,
8
+ XAxisProps,
9
+ YAxisProps,
10
+ } from "recharts";
11
+ import { type ArgTypes } from "@storybook/react";
12
+ import { type CategoricalChartProps } from "recharts/types/chart/generateCategoricalChart";
13
+ import type { Flatten } from "./types";
14
+ import { categorizeArgs } from "../helpers";
15
+ import { areaArgs } from "./areaArgs";
16
+ import { areaChartArgs as areaChartComponentArgs } from "./areaChartArgs";
17
+ import { barArgs } from "./barArgs";
18
+ import { barChartArgs as barChartComponentArgs } from "./barChartArgs";
19
+ import { lineArgs } from "./lineArgs";
20
+ import { lineChartArgs as lineChartComponentArgs } from "./lineChartArgs";
21
+ import { pieArgs } from "./pieArgs";
22
+ import { pieChartArgs as pieChartComponentArgs } from "./pieChartArgs";
23
+ import { radarArgs } from "./radarArgs";
24
+ import { radarChartArgs as radarChartComponentArgs } from "./radarChartArgs";
25
+ import { radialBarArgs } from "./radialBarArgs";
26
+ import { radialBarChartArgs as radialBarChartComponentArgs } from "./radialBarChartArgs";
27
+ import { OmitSVGElement } from "./types";
28
+ import { xAxisArgs } from "./xAxisArgs";
29
+ import { yAxisArgs } from "./yAxisArgs";
30
+
31
+ type AxisProps = {
32
+ xAxis: OmitSVGElement<XAxisProps>;
33
+ yAxis: OmitSVGElement<YAxisProps>;
34
+ };
35
+
36
+ /**
37
+ * Bar chart
38
+ */
39
+ type BarArgKey = "bar" | "barChart" | "xAxis" | "yAxis";
40
+
41
+ export type BarChartProps = {
42
+ bar: OmitSVGElement<BarProps>;
43
+ barChart: CategoricalChartProps;
44
+ } & AxisProps;
45
+
46
+ export type BarChartArgs = Partial<Flatten<BarChartProps>> & {};
47
+
48
+ const barArgKey = {
49
+ bar: "bar",
50
+ barChart: "barChart",
51
+ xAxis: "xAxis",
52
+ yAxis: "yAxis",
53
+ } satisfies Record<string, BarArgKey>;
54
+
55
+ export const barChartArgs = {
56
+ ...categorizeArgs(barChartComponentArgs, barArgKey.barChart),
57
+ ...categorizeArgs(xAxisArgs, barArgKey.xAxis),
58
+ ...categorizeArgs(yAxisArgs, barArgKey.yAxis),
59
+ ...categorizeArgs(barArgs, barArgKey.bar),
60
+ } satisfies ArgTypes;
61
+
62
+ /**
63
+ * Line chart
64
+ */
65
+ type LineArgKey = "line" | "lineChart" | "xAxis" | "yAxis";
66
+
67
+ export type LineChartProps = {
68
+ line: OmitSVGElement<LineProps>;
69
+ lineChart: CategoricalChartProps;
70
+ } & AxisProps;
71
+
72
+ export type LineChartArgs = Partial<Flatten<LineChartProps>> & {};
73
+
74
+ const lineArgKey = {
75
+ line: "line",
76
+ lineChart: "lineChart",
77
+ xAxis: "xAxis",
78
+ yAxis: "yAxis",
79
+ } satisfies Record<string, LineArgKey>;
80
+
81
+ export const lineChartArgs = {
82
+ ...categorizeArgs(lineChartComponentArgs, lineArgKey.lineChart),
83
+ ...categorizeArgs(xAxisArgs, lineArgKey.xAxis),
84
+ ...categorizeArgs(yAxisArgs, lineArgKey.yAxis),
85
+ ...categorizeArgs(lineArgs, lineArgKey.line),
86
+ } satisfies ArgTypes;
87
+
88
+ /**
89
+ * Area chart
90
+ */
91
+ type AreaArgKey = "area" | "areaChart" | "xAxis" | "yAxis";
92
+
93
+ export type AreaChartProps = {
94
+ area: OmitSVGElement<AreaProps>;
95
+ areaChart: CategoricalChartProps;
96
+ } & AxisProps;
97
+
98
+ export type AreaChartArgs = Partial<Flatten<AreaChartProps>> & {};
99
+
100
+ export const areaArgKey = {
101
+ area: "area",
102
+ areaChart: "areaChart",
103
+ xAxis: "xAxis",
104
+ yAxis: "yAxis",
105
+ } satisfies Record<string, AreaArgKey>;
106
+
107
+ export const areaChartArgs = {
108
+ ...categorizeArgs(areaChartComponentArgs, areaArgKey.areaChart),
109
+ ...categorizeArgs(xAxisArgs, areaArgKey.xAxis),
110
+ ...categorizeArgs(yAxisArgs, areaArgKey.yAxis),
111
+ ...categorizeArgs(areaArgs, areaArgKey.area),
112
+ } satisfies ArgTypes;
113
+
114
+ /**
115
+ * Pie chart
116
+ */
117
+ type PieArgKey = "pie" | "pieChart";
118
+
119
+ export type PieChartProps = {
120
+ pie: OmitSVGElement<PieProps>;
121
+ pieChart: CategoricalChartProps;
122
+ };
123
+
124
+ export type PieChartArgs = Partial<Flatten<PieChartProps>> & {};
125
+
126
+ export const pieArgKey = {
127
+ pie: "pie",
128
+ pieChart: "pieChart",
129
+ } satisfies Record<string, PieArgKey>;
130
+
131
+ export const pieChartArgs = {
132
+ ...categorizeArgs(pieChartComponentArgs, pieArgKey.pieChart),
133
+ ...categorizeArgs(pieArgs, pieArgKey.pie),
134
+ } satisfies ArgTypes;
135
+
136
+ /**
137
+ * RadialBar chart
138
+ */
139
+ type RadialBarArgKey = "radialBar" | "radialBarChart";
140
+
141
+ export type RadialBarChartProps = {
142
+ radialBar: OmitSVGElement<RadialBarProps>;
143
+ radialBarChart: CategoricalChartProps;
144
+ };
145
+
146
+ export type RadialBarChartArgs = Partial<Flatten<RadialBarChartProps>> & {};
147
+
148
+ export const radialBarArgKey = {
149
+ radialBar: "radialBar",
150
+ radialBarChart: "radialBarChart",
151
+ } satisfies Record<string, RadialBarArgKey>;
152
+
153
+ export const radialBarChartArgs = {
154
+ ...categorizeArgs(radialBarChartComponentArgs, radialBarArgKey.radialBarChart),
155
+ ...categorizeArgs(radialBarArgs, radialBarArgKey.radialBar),
156
+ } satisfies ArgTypes;
157
+
158
+ /**
159
+ * Radar chart
160
+ */
161
+ type RadarArgKey = "radar" | "radarChart";
162
+
163
+ export type RadarChartProps = {
164
+ radar: OmitSVGElement<RadarProps>;
165
+ radarChart: CategoricalChartProps;
166
+ };
167
+
168
+ export type RadarChartArgs = Partial<Flatten<RadarChartProps>> & {};
169
+
170
+ export const radarArgKey = {
171
+ radar: "radar",
172
+ radarChart: "radarChart",
173
+ } satisfies Record<string, RadarArgKey>;
174
+
175
+ export const radarChartArgs = {
176
+ ...categorizeArgs(radarChartComponentArgs, radarArgKey.radarChart),
177
+ ...categorizeArgs(radarArgs, radarArgKey.radar),
178
+ } satisfies ArgTypes;
@@ -0,0 +1,124 @@
1
+ import { type ArgTypes } from "@storybook/react";
2
+
3
+ export const labelListArgs: ArgTypes = {
4
+ dataKey: {
5
+ description: "The key of a group of label values in data.",
6
+ table: {
7
+ type: {
8
+ summary: "String | Number | Function",
9
+ },
10
+ category: "General",
11
+ },
12
+ control: "text",
13
+ },
14
+ valueAccessor: {
15
+ description: "The accessor function to get the value of each label.",
16
+ table: {
17
+ category: "General",
18
+ },
19
+ },
20
+ content: {
21
+ description:
22
+ "If set a React element, the option is the customized react element of rendering each label. " +
23
+ "If set a function, the function will be called to render each label content.",
24
+ defaultValue: null,
25
+ table: {
26
+ category: "General",
27
+ type: {
28
+ summary: "ReactElement | Function",
29
+ detail:
30
+ "<Label content={<CustomizedLabel external={external} />} />\n<Label content={renderLabel} />",
31
+ },
32
+ },
33
+ },
34
+ position: {
35
+ description: "The position of each label relative to it view box.",
36
+ table: {
37
+ type: {
38
+ summary: `'top' | 'left' | 'right' | 'bottom' | 'inside' | 'outside' | 'insideLeft' |
39
+ 'insideRight' | 'insideTop' | 'insideBottom' | 'insideTopLeft' |
40
+ 'insideBottomLeft' | 'insideTopRight' | 'insideBottomRight' |
41
+ 'insideStart' | 'insideEnd' | 'end' | 'center' | 'centerTop' | 'centerBottom' | 'middle'`,
42
+ },
43
+ category: "General",
44
+ },
45
+ control: "select",
46
+ options: [
47
+ "top",
48
+ "left",
49
+ "right",
50
+ "bottom",
51
+ "inside",
52
+ "outside",
53
+ "insideLeft",
54
+ "insideRight",
55
+ "insideTop",
56
+ "insideBottom",
57
+ "insideTopLeft",
58
+ "insideBottomLeft",
59
+ "insideTopRight",
60
+ "insideBottomRight",
61
+ "insideStart",
62
+ "insideEnd",
63
+ "end",
64
+ "center",
65
+ "centerTop",
66
+ "centerBottom",
67
+ "middle",
68
+ ],
69
+ },
70
+ offset: {
71
+ description: 'The offset to the specified "position"',
72
+ table: {
73
+ type: {
74
+ summary: "number",
75
+ },
76
+ defaultValue: {
77
+ summary: "5",
78
+ },
79
+ category: "General",
80
+ },
81
+ control: "number",
82
+ },
83
+ formatter: {
84
+ description:
85
+ "The formatter function of label value which has only one parameter - the value of label.",
86
+ table: {
87
+ type: {
88
+ summary: "Function",
89
+ },
90
+ category: "General",
91
+ },
92
+ },
93
+ data: {
94
+ description: "The data input to the charts.",
95
+ table: {
96
+ type: {
97
+ summary: "number",
98
+ },
99
+ defaultValue: {
100
+ summary: "5",
101
+ },
102
+ category: "General",
103
+ },
104
+ control: "number",
105
+ },
106
+ clockWise: {
107
+ description: "The parameter to calculate the view box of label in radial charts.",
108
+ table: {
109
+ type: {
110
+ summary: "boolean",
111
+ },
112
+ category: "General",
113
+ },
114
+ control: "boolean",
115
+ },
116
+ id: {
117
+ description:
118
+ "The unique id of this component, which will be used to generate " +
119
+ "unique clip path id internally. This props is suggested to be set in SSR.",
120
+ table: {
121
+ category: "General",
122
+ },
123
+ },
124
+ };
@@ -0,0 +1,205 @@
1
+ import { type ArgTypes } from "@storybook/react";
2
+
3
+ export const legendType: ArgTypes[0] = {
4
+ description: "The type of icon in legend. If set to 'none', no legend item will be rendered.",
5
+ table: {
6
+ type: {
7
+ summary:
8
+ "'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'",
9
+ },
10
+ defaultValue: {
11
+ summary: "'line'",
12
+ },
13
+ category: "Style",
14
+ },
15
+ control: "select",
16
+ options: [
17
+ "line",
18
+ "plainline",
19
+ "square",
20
+ "rect",
21
+ "circle",
22
+ "cross",
23
+ "diamond",
24
+ "square",
25
+ "star",
26
+ "triangle",
27
+ "wye",
28
+ "none",
29
+ ],
30
+ };
31
+
32
+ // Caveat: If any prop is added here, it would falsely be add to the documentation of the component
33
+ // where this group is used. If the group is to be extended, then only single props should be imported
34
+ // by each component that does not use all of them.
35
+ export const legendArgs: ArgTypes = {
36
+ width: {
37
+ description: "The width of legend.",
38
+ table: {
39
+ type: {
40
+ summary: "number",
41
+ },
42
+ category: "General",
43
+ },
44
+ control: "number",
45
+ },
46
+ height: {
47
+ description: "The height of legend.",
48
+ table: {
49
+ type: {
50
+ summary: "number",
51
+ },
52
+ category: "General",
53
+ },
54
+ control: "number",
55
+ },
56
+ layout: {
57
+ description: "The layout of legend items.",
58
+ table: {
59
+ type: {
60
+ summary: "'horizontal' | 'vertical'",
61
+ },
62
+ defaultValue: {
63
+ summary: "'horizontal'",
64
+ },
65
+ category: "General",
66
+ },
67
+ control: "inline-radio",
68
+ options: ["horizontal", "vertical"],
69
+ },
70
+ align: {
71
+ description: `Sets horizontal position of the Legend relative to the chart:
72
+
73
+ - \`left\` shows the Legend to the left of the chart, and chart width reduces automatically to make space for it.
74
+ - \`right\` shows the Legend to the right of the chart, and chart width reduces automatically.
75
+ - \`center\` shows the Legend in the middle of chart, and chart width remains unchanged.
76
+
77
+ The exact behavior changes depending on \`verticalAlign\` prop.`,
78
+ table: {
79
+ type: {
80
+ summary: "'left' | 'center' | 'right'",
81
+ },
82
+ defaultValue: {
83
+ summary: "'center'",
84
+ },
85
+ category: "General",
86
+ },
87
+ control: "radio",
88
+ options: ["left", "center", "right"],
89
+ },
90
+ verticalAlign: {
91
+ description: `Sets vertical position of the Legend relative to the chart:
92
+
93
+ - \`bottom\` shows the Legend below chart, and chart height reduces automatically to make space for it.
94
+ - \`top\` shows the Legend above chart, and chart height reduces automatically.
95
+ - \`middle\` shows the Legend in the middle of chart, covering other content, and chart height remains unchanged.
96
+
97
+ The exact behavior changes depending on \`align\` prop.`,
98
+ table: {
99
+ type: {
100
+ summary: "'top' | 'middle' | 'bottom'",
101
+ },
102
+ category: "General",
103
+ },
104
+ control: "radio",
105
+ options: ["top", "middle", "bottom"],
106
+ },
107
+ iconSize: {
108
+ description: "The size of icon in each legend item.",
109
+ table: {
110
+ type: {
111
+ summary: "number",
112
+ },
113
+ defaultValue: {
114
+ summary: "14",
115
+ },
116
+ category: "General",
117
+ },
118
+ control: "number",
119
+ },
120
+ iconType: {
121
+ description: "The type of icon in each legend item.",
122
+ table: {
123
+ type: {
124
+ summary:
125
+ "'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye'",
126
+ },
127
+ defaultValue: {
128
+ summary: "line",
129
+ },
130
+ category: "General",
131
+ },
132
+ control: "select",
133
+ options: [
134
+ "line",
135
+ "plainline",
136
+ "square",
137
+ "rect",
138
+ "circle",
139
+ "cross",
140
+ "diamond",
141
+ "star",
142
+ "triangle",
143
+ "wye",
144
+ ],
145
+ },
146
+ content: {
147
+ description: `If set to a React element, the option will be used to render the legend.
148
+ If set to a function, the function will be called to render the legend's content.`,
149
+ table: {
150
+ type: {
151
+ summary: "ReactElement | Function",
152
+ detail: `<ChartLegend content={<CustomizedLegend external={external} />} />
153
+
154
+ const renderLegend = (props) => {
155
+ const { payload } = props;
156
+
157
+ return (
158
+ <ul>
159
+ {
160
+ payload.map((entry, index) => (
161
+ <li key={'item'-index}>{entry.value}</li>
162
+ ))
163
+ }
164
+ </ul>
165
+ );
166
+ }
167
+ <Legend content={renderLegend} />`,
168
+ },
169
+ category: "General",
170
+ },
171
+ },
172
+ formatter: {
173
+ description: "The formatter function of each text in legend.",
174
+ table: {
175
+ type: {
176
+ summary: "Function",
177
+ detail: "(value, entry, index) => ()",
178
+ },
179
+ category: "General",
180
+ },
181
+ },
182
+ wrapperStyle: {
183
+ description: `The style of legend container which is a "position: absolute;" div element.
184
+ Because the position of legend is quite flexible, so you can change the position by the value of top, left, right, bottom in this option.
185
+ And the format of wrapperStyle is the same as React inline style.`,
186
+ table: {
187
+ type: {
188
+ summary: "Object",
189
+ },
190
+ category: "General",
191
+ },
192
+ control: "object",
193
+ },
194
+ portal: {
195
+ description: `If portal is defined, then Legend will use this element as a target
196
+ for rendering using React Portal: https://react.dev/reference/react-dom/createPortal.
197
+ If this is undefined then Legend renders inside the recharts-wrapper element with absolute positioning.`,
198
+ table: {
199
+ category: "Position",
200
+ type: {
201
+ summary: "HTMLElement | null",
202
+ },
203
+ },
204
+ },
205
+ };
@@ -0,0 +1,87 @@
1
+ import { type Args } from "@storybook/react";
2
+ import { dataKey } from "./chartArgs";
3
+ import { generalStyleArgs, hide, labelDescription, labelSummary } from "./stylesArgs";
4
+
5
+ export const lineArgs: Args = {
6
+ ...generalStyleArgs,
7
+ dataKey,
8
+ connectNulls: {
9
+ description: "Whether to connect a graph line across null points.",
10
+ table: {
11
+ type: {
12
+ summary: "boolean",
13
+ },
14
+ category: "Style",
15
+ defaultValue: {
16
+ summary: "false",
17
+ },
18
+ },
19
+ control: "boolean",
20
+ },
21
+ dot: {
22
+ description: `If false set, dots will not be drawn. If true set, dots will be drawn which have the props
23
+ calculated internally. If object set, dots will be drawn which have the props merged by the internal
24
+ calculated props and the option. If ReactElement set, the option can be the custom dot element.If set
25
+ a function, the function will be called to render customized dot.`,
26
+ table: {
27
+ type: {
28
+ summary: "Boolean | Object | ReactElement | Function",
29
+ detail:
30
+ '<Line dataKey="value" dot={false} />\n' +
31
+ "<Line dataKey=\"value\" dot={{ stroke: 'red', strokeWidth: 2 }} />\n" +
32
+ '<Line dataKey="value" dot={<CustomizedDot />} />\n' +
33
+ '<Line dataKey="value" dot={renderDot} />',
34
+ },
35
+ defaultValue: {
36
+ summary: "true",
37
+ },
38
+ category: "Style",
39
+ },
40
+ control: "boolean",
41
+ },
42
+ hide,
43
+ label: {
44
+ description: labelDescription,
45
+ table: {
46
+ type: {
47
+ summary: labelSummary,
48
+ detail:
49
+ '<Line dataKey="value" label />\n' +
50
+ "<Line dataKey=\"value\" label={{ fill: 'red', fontSize: 20 }} />\n" +
51
+ '<Line dataKey="value" label={<CustomizedLabel />} />\n' +
52
+ '<Line dataKey="value" label={renderLabel} />',
53
+ },
54
+ defaultValue: {
55
+ summary: "false",
56
+ },
57
+ category: "Style",
58
+ },
59
+ control: "boolean",
60
+ },
61
+ type: {
62
+ description: `The interpolation type of line. It's the same as type in Area.
63
+ And customized interpolation function can be set to type. https://github.com/d3/d3-shape#curves`,
64
+ default: "linear",
65
+ table: {
66
+ category: "Style",
67
+ },
68
+ control: "select",
69
+ options: [
70
+ "basis",
71
+ "basisClosed",
72
+ "basisOpen",
73
+ "bumpX",
74
+ "bumpY",
75
+ "bump",
76
+ "linear",
77
+ "linearClosed",
78
+ "natural",
79
+ "monotoneX",
80
+ "monotoneY",
81
+ "monotone",
82
+ "step",
83
+ "stepBefore",
84
+ "stepAfter",
85
+ ],
86
+ },
87
+ };
@@ -0,0 +1,17 @@
1
+ import { type ArgTypes } from "@storybook/react";
2
+ import { categoricalChartArgs } from "./chartArgs";
3
+
4
+ export const lineChartArgs: ArgTypes = {
5
+ ...categoricalChartArgs,
6
+ layout: {
7
+ description: "The layout of line in the chart, usually inherited from parent.",
8
+ table: {
9
+ type: {
10
+ summary: "'horizontal' | 'vertical'",
11
+ },
12
+ category: "Bar",
13
+ },
14
+ control: "radio",
15
+ options: ["horizontal", "vertical"],
16
+ },
17
+ };
@@ -0,0 +1,18 @@
1
+ import { type Args } from "@storybook/react";
2
+ import { polarChartArgs } from "./polarChartArgs";
3
+ import { polarSharedArgs } from "./polarSharedArgs";
4
+
5
+ export const pieArgs: Args = {
6
+ ...polarSharedArgs,
7
+ ...polarChartArgs,
8
+ fillOpacity: {
9
+ description: "The opacity of the fill.",
10
+ table: {
11
+ type: {
12
+ summary: "number",
13
+ },
14
+ category: "Style",
15
+ },
16
+ control: "number",
17
+ },
18
+ };
@@ -0,0 +1,7 @@
1
+ import { type ArgTypes } from "@storybook/react";
2
+ import { chartSizeArgs, margin } from "./chartArgs";
3
+
4
+ export const pieChartArgs: ArgTypes = {
5
+ ...chartSizeArgs,
6
+ margin,
7
+ };