pixel-react-excel-sheet 1.0.37 → 1.0.39

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 (150) hide show
  1. package/lib/components/Button/Button.d.ts +2 -2
  2. package/lib/components/Charts/DashboardDonutChart/types.d.ts +3 -0
  3. package/lib/components/Charts/LineChart/types.d.ts +1 -0
  4. package/lib/components/ChooseFile/ChooseFile.d.ts +3 -2
  5. package/lib/components/Comment/Comments.d.ts +1 -1
  6. package/lib/components/Comment/type.d.ts +3 -3
  7. package/lib/components/ConditionalDropdown/types.d.ts +4 -0
  8. package/lib/components/DatePicker/types.d.ts +2 -0
  9. package/lib/components/Drawer/Types.d.ts +4 -1
  10. package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +11 -10
  11. package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +10 -0
  12. package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +1 -1
  13. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +9 -0
  14. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +0 -2
  15. package/lib/components/Excel/Types.d.ts +14 -10
  16. package/lib/components/FF_Captcha/Recaptcha.d.ts +2 -1
  17. package/lib/components/FF_Captcha/types.d.ts +11 -2
  18. package/lib/components/Input/types.d.ts +4 -0
  19. package/lib/components/LabelEditTextField/types.d.ts +2 -0
  20. package/lib/components/MobileSkin/MobileSkin.d.ts +5 -0
  21. package/lib/components/MobileSkin/MobileSkinInterface.d.ts +13 -0
  22. package/lib/components/MobileSkin/index.d.ts +1 -0
  23. package/lib/components/MobileSkin/types.d.ts +32 -0
  24. package/lib/components/Search/Search.d.ts +1 -1
  25. package/lib/components/Search/types.d.ts +1 -0
  26. package/lib/components/Select/components/types.d.ts +3 -2
  27. package/lib/components/Select/types.d.ts +10 -2
  28. package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
  29. package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
  30. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
  31. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
  32. package/lib/components/SequentialConnectingBranch/types.d.ts +1 -0
  33. package/lib/components/TableTree/types.d.ts +4 -4
  34. package/lib/components/Tabs/types.d.ts +1 -0
  35. package/lib/index.d.ts +97 -41
  36. package/lib/index.esm.js +4817 -1673
  37. package/lib/index.esm.js.map +1 -1
  38. package/lib/index.js +4830 -1673
  39. package/lib/index.js.map +1 -1
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/lib/utils/formData/ConvertFormDataToObject.d.ts +1 -0
  42. package/lib/utils/keyBoardActionUtil/UseKeyboardActions.d.ts +2 -0
  43. package/lib/utils/keyBoardActionUtil/types.d.ts +4 -0
  44. package/lib/validations/regex.d.ts +11 -1
  45. package/package.json +6 -1
  46. package/src/assets/Themes/BaseTheme.scss +3 -1
  47. package/src/assets/Themes/DarkTheme.scss +10 -1
  48. package/src/assets/icons/clear_cache.svg +5 -0
  49. package/src/assets/icons/external_user.svg +13 -0
  50. package/src/assets/icons/group_user.svg +12 -0
  51. package/src/assets/icons/single_user.svg +12 -0
  52. package/src/assets/icons/test_freshers_logo.svg +8 -0
  53. package/src/assets/icons/unfollow_icon.svg +3 -0
  54. package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +7 -45
  55. package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +5 -0
  56. package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +76 -64
  57. package/src/components/Button/Button.scss +0 -1
  58. package/src/components/Button/Button.tsx +3 -4
  59. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +38 -6
  60. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
  61. package/src/components/Charts/DashboardDonutChart/types.ts +4 -1
  62. package/src/components/Charts/LineChart/LineChart.stories.tsx +27 -88
  63. package/src/components/Charts/LineChart/LineChart.tsx +138 -42
  64. package/src/components/Charts/LineChart/types.ts +1 -0
  65. package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +3 -3
  66. package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +47 -43
  67. package/src/components/ChooseFile/ChooseFile.tsx +3 -4
  68. package/src/components/Comment/Comments.scss +0 -1
  69. package/src/components/Comment/Comments.stories.tsx +22 -4
  70. package/src/components/Comment/Comments.tsx +20 -1
  71. package/src/components/Comment/type.ts +3 -3
  72. package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +1 -0
  73. package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +2 -1
  74. package/src/components/ConditionalDropdown/types.ts +4 -0
  75. package/src/components/DatePicker/DatePicker.scss +307 -2
  76. package/src/components/DatePicker/DatePicker.tsx +27 -19
  77. package/src/components/DatePicker/types.ts +4 -0
  78. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  79. package/src/components/Drawer/Drawer.tsx +5 -4
  80. package/src/components/Drawer/Types.ts +4 -2
  81. package/src/components/Editor/Editor.scss +23 -18
  82. package/src/components/Editor/Editor.tsx +2 -2
  83. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +6 -3
  84. package/src/components/Excel/ExcelFile/ExcelFile.scss +45 -41
  85. package/src/components/Excel/ExcelFile/ExcelFile.tsx +68 -64
  86. package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +29 -1
  87. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +0 -38
  88. package/src/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.tsx +1 -40
  89. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +3 -3
  90. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +12 -1
  91. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +8 -74
  92. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +0 -3
  93. package/src/components/Excel/ExcelFile.stories.tsx +112 -125
  94. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +10 -11
  95. package/src/components/Excel/Types.ts +17 -15
  96. package/src/components/FF_Captcha/Recaptcha.tsx +19 -9
  97. package/src/components/FF_Captcha/types.ts +12 -4
  98. package/src/components/Icon/Icon.stories.tsx +56 -8
  99. package/src/components/Icon/iconList.ts +13 -1
  100. package/src/components/Input/Input.stories.tsx +12 -0
  101. package/src/components/Input/Input.tsx +3 -1
  102. package/src/components/Input/types.ts +4 -0
  103. package/src/components/InputWithDropdown/types.ts +1 -1
  104. package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
  105. package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +2 -1
  106. package/src/components/LabelEditTextField/LabelEditTextField.tsx +14 -10
  107. package/src/components/LabelEditTextField/types.ts +2 -0
  108. package/src/components/LazyLoad/LazyLoad.stories.tsx +1 -0
  109. package/src/components/LazyLoad/LazyLoading.tsx +10 -1
  110. package/src/components/MachineInputField/MachineInputField.scss +5 -1
  111. package/src/components/MachineInputField/MachineInputField.tsx +1 -0
  112. package/src/components/MobileSkin/MobileSkin.scss +67 -0
  113. package/src/components/MobileSkin/MobileSkin.stories.tsx +93 -0
  114. package/src/components/MobileSkin/MobileSkin.tsx +89 -0
  115. package/src/components/MobileSkin/MobileSkinInterface.ts +13 -0
  116. package/src/components/MobileSkin/index.ts +1 -0
  117. package/src/components/MobileSkin/types.ts +32 -0
  118. package/src/components/Modal/Modal.stories.tsx +7 -0
  119. package/src/components/Modal/Modal.tsx +17 -20
  120. package/src/components/Search/Search.scss +8 -0
  121. package/src/components/Search/Search.tsx +17 -6
  122. package/src/components/Search/types.ts +1 -0
  123. package/src/components/Select/Select.stories.tsx +85 -0
  124. package/src/components/Select/Select.tsx +10 -2
  125. package/src/components/Select/components/Dropdown.tsx +23 -15
  126. package/src/components/Select/components/types.ts +3 -2
  127. package/src/components/Select/types.ts +12 -2
  128. package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
  129. package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +65 -57
  130. package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
  131. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
  132. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
  133. package/src/components/SequentialConnectingBranch/types.ts +5 -1
  134. package/src/components/TableTree/Components/TableCell.tsx +3 -3
  135. package/src/components/TableTree/TableTree.scss +0 -7
  136. package/src/components/TableTree/TableTree.tsx +3 -22
  137. package/src/components/TableTree/types.ts +4 -4
  138. package/src/components/Tabs/Tabs.scss +19 -0
  139. package/src/components/Tabs/Tabs.tsx +9 -0
  140. package/src/components/Tabs/types.ts +1 -0
  141. package/src/index.ts +27 -0
  142. package/src/utils/formData/ConvertFormDataToObject.stories.tsx +27 -0
  143. package/src/utils/formData/ConvertFormDataToObject.ts +14 -0
  144. package/src/utils/getExtension/getExtension.stories.tsx +1 -0
  145. package/src/utils/keyBoardActionUtil/UseKeyboardAction.stories.tsx +53 -0
  146. package/src/utils/keyBoardActionUtil/UseKeyboardActions.tsx +20 -0
  147. package/src/utils/keyBoardActionUtil/types.ts +4 -0
  148. package/src/validations/regex.stories.tsx +63 -0
  149. package/src/validations/regex.ts +34 -0
  150. package/src/assets/images/photo.png +0 -0
@@ -1,4 +1,4 @@
1
- import { forwardRef, memo } from 'react';
1
+ import { forwardRef } from 'react';
2
2
  import './Button.scss';
3
3
  import '../../assets/styles/_colors.scss';
4
4
  import Icon from '../Icon';
@@ -6,8 +6,7 @@ import { ButtonProps } from './types';
6
6
  import classNames from 'classnames';
7
7
  import Typography from '../Typography';
8
8
 
9
- const areEqual = (prevProps: ButtonProps, nextProps: ButtonProps) =>
10
- prevProps.selectedFile?.name === nextProps.selectedFile?.name;
9
+
11
10
 
12
11
  const Button = forwardRef<HTMLButtonElement, ButtonProps>(
13
12
  (
@@ -88,4 +87,4 @@ const Button = forwardRef<HTMLButtonElement, ButtonProps>(
88
87
  );
89
88
  }
90
89
  );
91
- export default memo(Button, areEqual);
90
+ export default Button;
@@ -22,16 +22,47 @@ export const Default: Story = {
22
22
  legendDetailsType: 'Scripts',
23
23
  isLegendDetails: true,
24
24
  statusValues: [
25
- { key: 'Passed', value: 60, color: 'var(--status-success-text-color)' },
26
- { key: 'failed', value: 20, color: 'var(--status-rejected-text-color)' },
27
- { key: 'Warning', value: 10, color: 'var(--status-warning-text-color)' },
28
- { key: 'skipped', value: 10, color: 'var(--status-button-text-skipped)' },
29
- { key: 'Warning', value: 10, color: 'var(--status-warning-text-color)' },
30
- { key: 'skipped', value: 10, color: 'var(--status-button-text-skipped)' },
25
+ {
26
+ key: 'Passed',
27
+ value: 60,
28
+ color: 'var(--status-success-text-color)',
29
+ percentage: '',
30
+ },
31
+ {
32
+ key: 'failed',
33
+ value: 20,
34
+ color: 'var(--status-rejected-text-color)',
35
+ percentage: '',
36
+ },
37
+ {
38
+ key: 'Warning',
39
+ value: 10,
40
+ color: 'var(--status-warning-text-color)',
41
+ percentage: '',
42
+ },
43
+ {
44
+ key: 'skipped',
45
+ value: 10,
46
+ color: 'var(--status-button-text-skipped)',
47
+ percentage: '',
48
+ },
49
+ {
50
+ key: 'Warning',
51
+ value: 0,
52
+ color: 'var(--status-warning-text-color)',
53
+ percentage: '',
54
+ },
55
+ {
56
+ key: 'skipped',
57
+ value: 7,
58
+ color: 'var(--status-button-text-skipped)',
59
+ percentage: '',
60
+ },
31
61
  ],
32
62
  gapAngle: 0,
33
63
  legendType: 'numberLegend',
34
64
  showOnlyLabel: false,
65
+ apiDataLabel:""
35
66
  },
36
67
  };
37
68
 
@@ -54,5 +85,6 @@ export const MemoryLegend: Story = {
54
85
  ],
55
86
  gapAngle: 0,
56
87
  legendType: 'memoryLegend',
88
+ apiDataLabel:""
57
89
  },
58
90
  };
@@ -48,6 +48,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
48
48
  isLegendDetails = true,
49
49
  legendType = 'numberLegend',
50
50
  showOnlyLabel = false,
51
+ apiDataLabel,
51
52
  unit,
52
53
  showUnit = true,
53
54
  labelFontSize = 24,
@@ -104,6 +105,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
104
105
  color: item.color,
105
106
  unit: item.unit,
106
107
  labelValue: item.labelValue,
108
+ percentage: item.percentage,
107
109
  }));
108
110
 
109
111
  const total = chartValues?.reduce((acc, { value }) => acc + value, 0);
@@ -368,9 +370,13 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
368
370
  <Typography fontSize={10}>{item.key}</Typography>
369
371
  </td>
370
372
  <td className="ff-legend-percentage">
371
- {typeof item.value === 'string'
372
- ? ((parseFloat(item.value) / total) * 100).toFixed(1)
373
- : ((item.value / total) * 100).toFixed(1)}
373
+ <td className="ff-legend-percentage">
374
+ {item.percentage
375
+ ? item.percentage
376
+ : typeof item.value === 'string'
377
+ ? ((parseFloat(item.value) / total) * 100).toFixed(1)
378
+ : ((item.value / total) * 100).toFixed(1)}
379
+ </td>
374
380
  </td>
375
381
  <td className="ff-legend-count">{item.value}</td>
376
382
  </tr>
@@ -509,7 +515,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
509
515
  dy={index === 0 ? 0 : labelFontSize}
510
516
  key={index}
511
517
  >
512
- {line}
518
+ {apiDataLabel ? apiDataLabel : line}
513
519
  </tspan>
514
520
  ))}
515
521
  </text>
@@ -17,6 +17,7 @@ export type ChartItem = {
17
17
  key: string;
18
18
  value: string | number;
19
19
  color?: string;
20
+ percentage?: string | number;
20
21
  };
21
22
 
22
23
  export type NormalizedChartItem = {
@@ -26,6 +27,7 @@ export type NormalizedChartItem = {
26
27
  normalizedValue?: number;
27
28
  unit?: string;
28
29
  labelValue?: number;
30
+ percentage?: string | number;
29
31
  };
30
32
 
31
33
  export type LegendType =
@@ -42,6 +44,7 @@ export type DashboardDonutChartProps = {
42
44
  isLegendDetails: boolean;
43
45
  gapAngle?: number;
44
46
  legendType: LegendType;
47
+ apiDataLabel: string | number;
45
48
  showOnlyLabel?: boolean;
46
49
  unit?: string;
47
50
  showUnit?: boolean;
@@ -51,7 +54,7 @@ export type DashboardDonutChartProps = {
51
54
  chartGap?: number;
52
55
  legendGap?: number;
53
56
  tableWidth?: number;
54
- tableHeight?:number;
57
+ tableHeight?: number;
55
58
  legendValueFontSize?: number;
56
59
  legendKeyFontSize?: number;
57
60
  labelYoffSet?: number;
@@ -22,31 +22,24 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
22
22
  data: [
23
23
  {
24
24
  date: '25 Oct',
25
- totalMemory: 9.86,
26
- },
27
- {
28
- date: '26 Oct',
29
- totalMemory: 9.86,
30
- },
31
- {
32
- date: '27 Oct',
33
- totalMemory: 9.86,
25
+ totalMemory: '1 GB',
34
26
  },
27
+
35
28
  {
36
- date: '28 Oct',
37
- totalMemory: 9.9,
29
+ date: '29 Oct',
30
+ totalMemory: '200 KB',
38
31
  },
39
32
  {
40
- date: '29 Oct',
41
- totalMemory: 100,
33
+ date: '30 Oct',
34
+ totalMemory: '40 MB',
42
35
  },
43
36
  {
44
37
  date: '3 Nov',
45
- totalMemory: 10.12,
38
+ totalMemory: '20 MB',
46
39
  },
47
40
  {
48
41
  date: '23 Nov',
49
- totalMemory: 10.1,
42
+ totalMemory: '90 MB',
50
43
  },
51
44
  ],
52
45
  },
@@ -60,7 +53,8 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
60
53
  xAxisColor: '#D9D9D9',
61
54
  yAxisColor: '#252C37',
62
55
  numberSize: '10px',
63
- proportionalSpacing :false,
56
+ proportionalSpacing: false,
57
+ chartName: 'memory',
64
58
  },
65
59
  render: (args) => (
66
60
  <div className="linechart-container">
@@ -72,74 +66,18 @@ export const DefaultLineChart: StoryObj<LineChartProps> = {
72
66
  export const multiLineScriptsChart: StoryObj<LineChartProps> = {
73
67
  args: {
74
68
  data: [
75
- {
76
- color: '#179C5F',
77
- name: 'Success',
78
- show: true,
79
- data: [
80
- { date: '1 oct', value: 10 },
81
- { date: '2 oct', value: 20 },
82
- { date: '3 oct', value: 30 },
83
- { date: '4 oct', value: 26 },
84
- { date: '5 oct', value: 90 },
85
- { date: '6 oct', value: 10 },
86
- { date: '7 oct', value: 12 },
87
- ],
88
- },
89
- {
90
- color: '#9C1732',
91
- name: 'Failed',
92
- show: true,
93
- data: [
94
- { date: '1 oct', value: 50 },
95
- { date: '2 oct', value: 30 },
96
- { date: '3 oct', value: 40 },
97
- { date: '4 oct', value: 20 },
98
- { date: '5 oct', value: 90 },
99
- { date: '6 oct', value: 70 },
100
- { date: '7 oct', value: 30 },
101
- ],
102
- },
103
- {
104
- color: '#E2750F',
105
- name: 'Warning',
106
- show: true,
107
- data: [
108
- { date: '1 oct', value: 10 },
109
- { date: '2 oct', value: 20 },
110
- { date: '3 oct', value: 99 },
111
- { date: '4 oct', value: 20 },
112
- { date: '5 oct', value: 10 },
113
- { date: '6 oct', value: 10 },
114
- { date: '7 oct', value: 10 },
115
- ],
116
- },
117
- {
118
- color: '#A83FC4',
119
- name: 'Skipped',
120
- show: true,
121
- data: [
122
- { date: '1 oct', value: 40 },
123
- { date: '2 oct', value: 10 },
124
- { date: '3 oct', value: 10 },
125
- { date: '4 oct', value: 20 },
126
- { date: '5 oct', value: 10 },
127
- { date: '6 oct', value: 30 },
128
- { date: '7 oct', value: 10 },
129
- ],
130
- },
131
69
  {
132
70
  color: '#3F5AC4',
133
71
  name: 'Flaky',
134
72
  show: true,
135
73
  data: [
136
- { date: '1 oct', value: 20 },
137
- { date: '2 oct', value: 40 },
138
- { date: '3 oct', value: 30 },
139
- { date: '4 oct', value: 10 },
140
- { date: '5 oct', value: 10 },
141
- { date: '6 oct', value: 20 },
142
- { date: '7 oct', value: 40 },
74
+ { date: '1 oct', value: 10 },
75
+ { date: '2 oct', value: 0 },
76
+ { date: '3 oct', value: 0 },
77
+ { date: '4 oct', value: 0 },
78
+ { date: '5 oct', value: 0 },
79
+ { date: '6 oct', value: 0 },
80
+ { date: '7 oct', value: 0 },
143
81
  ],
144
82
  },
145
83
  ],
@@ -154,8 +92,8 @@ export const multiLineScriptsChart: StoryObj<LineChartProps> = {
154
92
  yAxisColor: '#252C37',
155
93
  yAxisLabelColor: '#252C37',
156
94
  textSize: '12px',
157
- proportionalSpacing :false,
158
-
95
+ proportionalSpacing: false,
96
+ chartName: 'scripts',
159
97
  },
160
98
  render: (args) => (
161
99
  <div className="linechart-container">
@@ -186,12 +124,12 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
186
124
  show: true,
187
125
  data: [
188
126
  { date: '1 oct', value: 50 },
189
- { date: '2 oct', value: 30 },
127
+ { date: '2 oct', value: 0 },
190
128
  { date: '3 oct', value: 40 },
191
129
  { date: '4 oct', value: 20 },
192
130
  { date: '5 oct', value: 90 },
193
131
  { date: '6 oct', value: 70 },
194
- { date: '7 oct', value: 30 },
132
+ { date: '7 oct', value: 0 },
195
133
  ],
196
134
  },
197
135
  {
@@ -201,7 +139,7 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
201
139
  data: [
202
140
  { date: '1 oct', value: 10 },
203
141
  { date: '2 oct', value: 20 },
204
- { date: '3 oct', value: 90 },
142
+ { date: '3 oct', value: 0 },
205
143
  { date: '4 oct', value: 20 },
206
144
  { date: '5 oct', value: 10 },
207
145
  { date: '6 oct', value: 10 },
@@ -213,13 +151,13 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
213
151
  name: 'Skipped',
214
152
  show: true,
215
153
  data: [
216
- { date: '1 oct', value: 40 },
154
+ { date: '1 oct', value: 0 },
217
155
  { date: '2 oct', value: 20 },
218
156
  { date: '3 oct', value: 10 },
219
157
  { date: '4 oct', value: 20 },
220
158
  { date: '5 oct', value: 10 },
221
159
  { date: '6 oct', value: 30 },
222
- { date: '7 oct', value: 10 },
160
+ { date: '7 oct', value: 0 },
223
161
  ],
224
162
  },
225
163
  {
@@ -231,7 +169,7 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
231
169
  { date: '2 oct', value: 40 },
232
170
  { date: '3 oct', value: 30 },
233
171
  { date: '4 oct', value: 20 },
234
- { date: '5 oct', value: 10 },
172
+ { date: '5 oct', value: 0 },
235
173
  { date: '6 oct', value: 40 },
236
174
  { date: '7 oct', value: 20 },
237
175
  ],
@@ -249,7 +187,8 @@ export const multiLineDefectsChart: StoryObj<LineChartProps> = {
249
187
  yAxisLabelColor: '#252C37',
250
188
  textSize: '12px',
251
189
  fontWeight: 'semi-bold',
252
- proportionalSpacing :false,
190
+ proportionalSpacing: false,
191
+ chartName: 'defects',
253
192
  },
254
193
  render: (args) => (
255
194
  <div className="linechart-container">
@@ -2,6 +2,11 @@ import React, { useState } from 'react';
2
2
  import { LineChartProps } from './types';
3
3
  import './LineChart.scss';
4
4
  import Typography from '../../Typography';
5
+ import {
6
+ MEMORY_VALIDATION_REGEX,
7
+ NUMBER_REGEX,
8
+ UNIT_REGEX,
9
+ } from '../../../validations/regex';
5
10
 
6
11
  interface HoverState {
7
12
  cursorX: number | null;
@@ -26,53 +31,121 @@ const LineChart: React.FC<LineChartProps> = ({
26
31
  fontWeight,
27
32
  numberSize,
28
33
  proportionalSpacing,
34
+ chartName,
29
35
  }) => {
30
36
  const margin = 40;
31
37
  const xMax = width - margin * 2;
32
38
  const yMax = height - margin * 2;
33
39
 
40
+ const roundUp = (value: any, decimals = 2) => {
41
+ let unit = '';
42
+
43
+ if (typeof value === 'string') {
44
+ const match = value.match(NUMBER_REGEX);
45
+ const unitMatch = value.match(UNIT_REGEX);
46
+ if (match) {
47
+ value = parseFloat(match[0]);
48
+ }
49
+ if (unitMatch) {
50
+ unit = unitMatch[0];
51
+ }
52
+ }
53
+
54
+ const multiplier = Math.pow(10, decimals);
55
+ const roundedValue = Math.ceil(value * multiplier) / multiplier;
56
+
57
+ return `${roundedValue} ${unit}`.trim();
58
+ };
59
+ function convertToMB(input: any) {
60
+ if (!isNaN(input)) {
61
+ return parseFloat(input);
62
+ }
63
+
64
+ const regex = MEMORY_VALIDATION_REGEX;
65
+ const match = input.match(regex);
66
+
67
+ if (!match) {
68
+ throw new Error(
69
+ "Invalid input format. Use '<value> <unit>' format (e.g., '10.9580078125 KB') or just a number."
70
+ );
71
+ }
72
+
73
+ const value = parseFloat(match[1]);
74
+ const unit = match[2] ? match[2].toUpperCase() : null;
75
+
76
+ switch (unit) {
77
+ case 'GB':
78
+ return parseFloat((value * 1024).toFixed(2));
79
+ case 'MB':
80
+ return parseFloat(value.toFixed(2));
81
+ case 'KB':
82
+ return parseFloat((value / 1024).toFixed(2));
83
+ default:
84
+ throw new Error('Invalid unit. Supported units are GB, MB, and KB.');
85
+ }
86
+ }
87
+
34
88
  const isDefaultLineChart =
35
89
  data[0]?.data[0]?.hasOwnProperty('date') &&
36
90
  data[0]?.data[0]?.hasOwnProperty('totalMemory');
37
91
  const xKey = isDefaultLineChart ? 'date' : 'date';
38
92
  const yKey = isDefaultLineChart ? 'totalMemory' : 'value';
39
93
  const xScale = (x: string) => {
40
- if (proportionalSpacing) {
41
- const date = new Date(x);
42
- const time = date.getTime();
43
- const minDate = new Date(
44
- Math.min(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
45
- );
46
- const maxDate = new Date(
47
- Math.max(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
48
- );
49
-
50
- return (
51
- ((time - minDate.getTime()) / (maxDate.getTime() - minDate.getTime())) *
52
- xMax
53
- );
54
- } else {
55
- const index = data[0].data.findIndex((point: any) => point[xKey] === x);
56
- if (index === -1) return 0;
57
- const totalPoints = data[0].data.length;
58
- return (index / (totalPoints - 1)) * xMax;
59
- }
60
- };
94
+ if (proportionalSpacing) {
95
+ const date = new Date(x);
96
+ const time = date.getTime();
97
+ const minDate = new Date(
98
+ Math.min(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
99
+ );
100
+ const maxDate = new Date(
101
+ Math.max(...data[0].data.map((d: any) => new Date(d[xKey]).getTime()))
102
+ );
103
+
104
+ return (
105
+ ((time - minDate.getTime()) / (maxDate.getTime() - minDate.getTime())) *
106
+ xMax
107
+ );
108
+ } else {
109
+ const index = data[0].data.findIndex((point: any) => point[xKey] === x);
110
+ if (index === -1) return 0;
111
+ const totalPoints = data[0].data.length;
112
+ return (index / (totalPoints - 1)) * xMax;
113
+ }
114
+ };
61
115
 
116
+ const maxValue = Math.max(
117
+ ...data.flatMap((line) =>
118
+ line.data.map((point: any) => convertToMB(point[yKey]))
119
+ )
120
+ );
62
121
 
63
- const yScale = (y: number) => yMax - (y * yMax) / 1024;
122
+ const yScale = (y: number) => {
123
+ if (chartName === 'memory') {
124
+ const maxMemoryValue = Math.max(
125
+ ...data.flatMap((line) =>
126
+ line.data.map((point: any) => convertToMB(point[yKey]))
127
+ )
128
+ );
129
+
130
+ const scaleMax = maxMemoryValue > 1024 ? maxMemoryValue : 1024;
131
+
132
+ return yMax - (y * yMax) / scaleMax;
133
+ } else {
134
+ return yMax - (y * yMax) / (maxValue === 0 ? 1024 : maxValue);
135
+ }
136
+ };
64
137
 
65
138
  const generateLinePath = (lineData: { [key: string]: any }[]) =>
66
139
  lineData.reduce((path, point, i) => {
67
140
  const x = xScale(point[xKey]);
68
- const y = yScale(point[yKey]);
141
+ const y = yScale(convertToMB(point[yKey]));
69
142
  if (i === 0) {
70
143
  return `M ${x} ${y}`;
71
144
  }
72
145
 
73
146
  const prevPoint = lineData[i - 1];
74
147
  const prevX = prevPoint ? xScale(prevPoint[xKey]) : 0;
75
- const prevY = prevPoint ? yScale(prevPoint[yKey]) : 0;
148
+ const prevY = prevPoint ? yScale(convertToMB(prevPoint[yKey])) : 0;
76
149
 
77
150
  return `${path} C ${prevX + (x - prevX) / 2} ${prevY}, ${
78
151
  x - (x - prevX) / 2
@@ -108,10 +181,10 @@ const LineChart: React.FC<LineChartProps> = ({
108
181
 
109
182
  if (nearestPoint) {
110
183
  nearestXValue = nearestPoint[xKey];
111
- nearestValues.hoverValues[lineIndex] = nearestPoint[yKey];
184
+ nearestValues.hoverValues[lineIndex] = roundUp(nearestPoint[yKey]);
112
185
  nearestValues.dotPositions[lineIndex] = {
113
186
  x: nearestXValue ? xScale(nearestXValue) : 0,
114
- y: yScale(nearestPoint[yKey]),
187
+ y: yScale(convertToMB(nearestPoint[yKey])),
115
188
  };
116
189
  }
117
190
  });
@@ -243,22 +316,45 @@ const LineChart: React.FC<LineChartProps> = ({
243
316
  </text>
244
317
  ))}
245
318
 
246
- {Array.from({ length: 6 }).map((_, i) => {
247
- const yValueInGB = i * 0.2;
248
- return (
249
- <text
250
- key={yValueInGB}
251
- x={-15}
252
- y={yScale(yValueInGB * 1024)}
253
- textAnchor="middle"
254
- fill={yAxisValueColor}
255
- className="ff-line-chart-y-axis-text"
256
- style={{ fontSize: numberSize }}
257
- >
258
- {yValueInGB.toFixed(1)}
259
- </text>
260
- );
261
- })}
319
+ {chartName === 'memory'
320
+ ? Array.from({ length: 6 }).map((_, i) => {
321
+ const dynamicMaxValue = maxValue < 1024 ? 1024 : maxValue;
322
+ const isSmallScale = maxValue < 1024;
323
+ const yValue = (i * dynamicMaxValue) / 5;
324
+ const displayValue = isSmallScale
325
+ ? yValue / 1024
326
+ : yValue / 1024;
327
+
328
+ return (
329
+ <text
330
+ key={yValue}
331
+ x={-10}
332
+ y={yScale(yValue)}
333
+ textAnchor="end"
334
+ fill={yAxisValueColor}
335
+ className="ff-line-chart-y-axis-text"
336
+ style={{ fontSize: numberSize }}
337
+ >
338
+ {displayValue.toFixed(1)}
339
+ </text>
340
+ );
341
+ })
342
+ : Array.from({ length: 6 }).map((_, i) => {
343
+ const yValue = (i * maxValue) / 5;
344
+ return (
345
+ <text
346
+ key={yValue}
347
+ x={-10}
348
+ y={yScale(yValue)}
349
+ textAnchor="end"
350
+ fill={yAxisValueColor}
351
+ className="ff-line-chart-y-axis-text"
352
+ style={{ fontSize: numberSize }}
353
+ >
354
+ {yValue.toFixed(0)}
355
+ </text>
356
+ );
357
+ })}
262
358
  </g>
263
359
  </svg>
264
360
  {hoverState.tooltip.visible && (
@@ -27,4 +27,5 @@ export interface LineChartProps {
27
27
  fontWeight?: string | number;
28
28
  numberSize?: string | number;
29
29
  proportionalSpacing?: boolean;
30
+ chartName?: string;
30
31
  }
@@ -4,7 +4,7 @@
4
4
  cursor: pointer;
5
5
  display: flex;
6
6
  align-items: center;
7
-
7
+ gap: 16px;
8
8
  &.ff-multi-radial-chart-number {
9
9
  flex-direction: column;
10
10
  }
@@ -68,8 +68,8 @@
68
68
  background-color: var(--status-success-text-color);
69
69
  color: var(--text-color);
70
70
  border-radius: 15px;
71
- min-width: 25px;
72
- height: 18px;
71
+ min-width: 21px;
72
+ height: 15px;
73
73
  display: flex;
74
74
  justify-content: center;
75
75
  align-items: center;