@ssa-ui-kit/core 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/components/PieChart/PieChart.d.ts +1 -1
  2. package/dist/components/PieChart/PieChartLegend.d.ts +1 -1
  3. package/dist/components/PieChart/PieChartLegendMarker.d.ts +2 -0
  4. package/dist/components/PieChart/types.d.ts +5 -4
  5. package/dist/components/SegmentedPieChart/SegmentedPieChart.d.ts +2 -0
  6. package/dist/components/SegmentedPieChart/colorPalettes.d.ts +2 -0
  7. package/dist/components/SegmentedPieChart/components/ChartTitle.d.ts +4 -0
  8. package/dist/components/SegmentedPieChart/components/ChartTooltip.d.ts +5 -0
  9. package/dist/components/SegmentedPieChart/components/LegendItem.d.ts +2 -0
  10. package/dist/components/SegmentedPieChart/components/index.d.ts +3 -0
  11. package/dist/components/SegmentedPieChart/hooks/index.d.ts +1 -0
  12. package/dist/components/SegmentedPieChart/hooks/useData.d.ts +5 -0
  13. package/dist/components/SegmentedPieChart/index.d.ts +1 -0
  14. package/dist/components/SegmentedPieChart/stories/fixtures.d.ts +5 -0
  15. package/dist/components/SegmentedPieChart/types.d.ts +50 -0
  16. package/dist/components/SegmentedPieChart/utils.d.ts +1 -0
  17. package/dist/components/index.d.ts +1 -0
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/LinksTabBar/LinksTabBar.spec.tsx +0 -1
  22. package/src/components/PieChart/PieChart.stories.tsx +2 -2
  23. package/src/components/PieChart/PieChart.tsx +1 -3
  24. package/src/components/PieChart/PieChartBases.tsx +1 -0
  25. package/src/components/PieChart/PieChartLegend.tsx +7 -1
  26. package/src/components/PieChart/PieChartLegendMarker.tsx +3 -1
  27. package/src/components/PieChart/types.ts +5 -4
  28. package/src/components/SegmentedPieChart/SegmentedPieChart.spec.tsx +31 -0
  29. package/src/components/SegmentedPieChart/SegmentedPieChart.tsx +89 -0
  30. package/src/components/SegmentedPieChart/colorPalettes.ts +13 -0
  31. package/src/components/SegmentedPieChart/components/ChartTitle.tsx +34 -0
  32. package/src/components/SegmentedPieChart/components/ChartTooltip.tsx +85 -0
  33. package/src/components/SegmentedPieChart/components/LegendItem.tsx +36 -0
  34. package/src/components/SegmentedPieChart/components/index.ts +3 -0
  35. package/src/components/SegmentedPieChart/hooks/index.ts +1 -0
  36. package/src/components/SegmentedPieChart/hooks/useData.ts +71 -0
  37. package/src/components/SegmentedPieChart/index.ts +1 -0
  38. package/src/components/SegmentedPieChart/stories/SegmentedPieChart.stories.tsx +100 -0
  39. package/src/components/SegmentedPieChart/stories/fixtures.ts +174 -0
  40. package/src/components/SegmentedPieChart/types.ts +61 -0
  41. package/src/components/SegmentedPieChart/utils.ts +2 -0
  42. package/src/components/index.ts +1 -0
  43. package/tsbuildcache +1 -1
@@ -0,0 +1,174 @@
1
+ import { SegmentedDataSet } from '../types';
2
+
3
+ const RATE = {
4
+ BTC: 63972.97,
5
+ ETH: 2649.84,
6
+ FDUSD: 0.9991,
7
+ USDT: 1,
8
+ };
9
+
10
+ export const balanceData: SegmentedDataSet = [
11
+ {
12
+ id: 1,
13
+ value: 5843.37,
14
+ legendValue: 5843.37 / RATE.BTC,
15
+ legendLabel: 'BTC',
16
+ label: 'BTC',
17
+ legendValueRoundingDigits: 6,
18
+ parts: [
19
+ {
20
+ label: 'Option 1',
21
+ value: 2300,
22
+ legendValue: 2300 / RATE.BTC,
23
+ },
24
+ {
25
+ label: 'Option 2',
26
+ value: 1800,
27
+ legendValue: 1800 / RATE.BTC,
28
+ },
29
+ {
30
+ label: 'Option 3',
31
+ value: 1743.37,
32
+ legendValue: 1743.37 / RATE.BTC,
33
+ },
34
+ ],
35
+ },
36
+ {
37
+ id: 2,
38
+ value: 5249.25,
39
+ legendValue: 5249.25 / RATE.ETH,
40
+ legendLabel: 'ETH',
41
+ label: 'ETH',
42
+ legendValueRoundingDigits: 2,
43
+ parts: [
44
+ {
45
+ label: 'Option 1',
46
+ value: 2800,
47
+ legendValue: 2800 / RATE.ETH,
48
+ },
49
+ {
50
+ label: 'Option 2',
51
+ value: 2449.25,
52
+ legendValue: 2449.25 / RATE.ETH,
53
+ },
54
+ ],
55
+ },
56
+ {
57
+ id: 3,
58
+ value: 3825.55,
59
+ legendValue: 3825.55 / RATE.FDUSD,
60
+ legendLabel: 'FDUSD',
61
+ label: 'FDUSD',
62
+ legendValueRoundingDigits: 2,
63
+ parts: [
64
+ {
65
+ label: 'Option 1',
66
+ value: 1000,
67
+ legendValue: 1000 / RATE.FDUSD,
68
+ },
69
+ {
70
+ label: 'Option 2',
71
+ value: 1840,
72
+ legendValue: 1840 / RATE.FDUSD,
73
+ },
74
+ {
75
+ label: 'Option 3',
76
+ value: 985.55,
77
+ legendValue: 985.55 / RATE.FDUSD,
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ id: 4,
83
+ value: 2818.83,
84
+ legendValue: 2818.83 / RATE.USDT,
85
+ label: 'Other',
86
+ legendLabel: 'USDT',
87
+ legendValueRoundingDigits: 0,
88
+ parts: [
89
+ {
90
+ label: 'Option 1',
91
+ value: 1400,
92
+ legendValue: 1400 / RATE.USDT,
93
+ },
94
+ {
95
+ label: 'Option 2',
96
+ value: 1418.83,
97
+ legendValue: 1418.83 / RATE.USDT,
98
+ },
99
+ ],
100
+ },
101
+ ];
102
+
103
+ export const balanceTotalAmount = balanceData
104
+ .map((item) => Number(item.value))
105
+ .reduce((acc, currentValue) => acc + currentValue, 0);
106
+
107
+ export const balanceMissedPartsData: SegmentedDataSet = [
108
+ {
109
+ id: 1,
110
+ value: 5843.37,
111
+ legendValue: 5843.37 / RATE.BTC,
112
+ label: 'BTC',
113
+ legendValueRoundingDigits: 6,
114
+ parts: [
115
+ {
116
+ label: 'Option 1',
117
+ value: 2300,
118
+ legendValue: 2300 / RATE.BTC,
119
+ },
120
+ {
121
+ label: 'Option 2',
122
+ value: 1800,
123
+ legendValue: 1800 / RATE.BTC,
124
+ },
125
+ {
126
+ label: 'Option 3',
127
+ value: 1743.37,
128
+ legendValue: 1743.37 / RATE.BTC,
129
+ },
130
+ ],
131
+ },
132
+ {
133
+ id: 2,
134
+ value: 5249.25,
135
+ legendValue: 5249.25 / RATE.ETH,
136
+ label: 'ETH',
137
+ legendValueRoundingDigits: 2,
138
+ },
139
+ {
140
+ id: 3,
141
+ value: 3825.55,
142
+ legendValue: 3825.55 / RATE.FDUSD,
143
+ label: 'FDUSD',
144
+ legendValueRoundingDigits: 2,
145
+ parts: [
146
+ {
147
+ label: 'Option 1',
148
+ value: 1000,
149
+ legendValue: 1000 / RATE.FDUSD,
150
+ },
151
+ {
152
+ label: 'Option 2',
153
+ value: 1840,
154
+ legendValue: 1840 / RATE.FDUSD,
155
+ },
156
+ {
157
+ label: 'Option 3',
158
+ value: 985.55,
159
+ legendValue: 985.55 / RATE.FDUSD,
160
+ },
161
+ ],
162
+ },
163
+ {
164
+ id: 4,
165
+ value: 2818.83,
166
+ legendValue: 2818.83 / RATE.USDT,
167
+ label: 'Other',
168
+ legendValueRoundingDigits: 0,
169
+ },
170
+ ];
171
+
172
+ export const balanceMissedPartsDataTotalAmount = balanceMissedPartsData
173
+ .map((item) => Number(item.value))
174
+ .reduce((acc, currentValue) => acc + currentValue, 0);
@@ -0,0 +1,61 @@
1
+ import { CommonProps } from '@global-types/emotion';
2
+ import { PieChartLegend, PieChartLegendItem, PieChartProps } from '@components';
3
+
4
+ type SegmentedDataMainInfo = {
5
+ label: string;
6
+ value: number;
7
+ legendValue: number;
8
+ };
9
+
10
+ export interface SegmentedDataItem extends PieChartLegendItem {
11
+ legendValue: number;
12
+ legendLabel?: string;
13
+ parts?: SegmentedDataMainInfo[];
14
+ }
15
+
16
+ export type SegmentedDataSet = Array<SegmentedDataItem>;
17
+
18
+ export interface SegmentedPieChartProps extends CommonProps {
19
+ data: SegmentedDataSet;
20
+ totalAmount: number;
21
+ totalDimension: string;
22
+ pieChartProps?: Partial<PieChartProps>;
23
+ pieChartLegendProps?: Partial<React.ComponentProps<typeof PieChartLegend>>;
24
+ legendBackgrounds?: string[];
25
+ pieChartColors?: string[][];
26
+ currency?: string;
27
+ otherLabel?: string;
28
+ legendValueRoundingDigits?: number;
29
+ legendPercentageRoundingDigits?: number;
30
+ showDimensions?: boolean;
31
+ showPercentage?: boolean;
32
+ }
33
+
34
+ export interface BalanceDataForGraph extends PieChartLegendItem {
35
+ label: string;
36
+ legendLabel?: string;
37
+ legendValueRoundingDigits: number;
38
+ percentage: number;
39
+ partIndex?: number;
40
+ partLabel?: string;
41
+ partPercentage?: number;
42
+ id: number | string;
43
+ mainId: number;
44
+ value: number | string;
45
+ color: string;
46
+ }
47
+
48
+ export type LegendItemProps = {
49
+ label: string;
50
+ legendLabel?: string;
51
+ percentage?: number;
52
+ legendValue?: number;
53
+ legendValueRoundingDigits: number;
54
+ } & Pick<
55
+ SegmentedPieChartProps,
56
+ | 'showDimensions'
57
+ | 'legendPercentageRoundingDigits'
58
+ | 'otherLabel'
59
+ | 'currency'
60
+ | 'showPercentage'
61
+ >;
@@ -0,0 +1,2 @@
1
+ export const getRoundedNumber = (number: unknown, roundingDigits: number) =>
2
+ Number(Number(number).toFixed(roundingDigits));
@@ -97,6 +97,7 @@ export * from './SearchBox';
97
97
  export * from './UserProfile';
98
98
  export * from './AddNewAccountCard';
99
99
  export * from './PieChart';
100
+ export * from './SegmentedPieChart';
100
101
  export * from './CollapsibleNavBar';
101
102
  export * from './Filters';
102
103
  export * from './TableFilters';