sag_components 1.0.968 → 1.0.970

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.
@@ -12,10 +12,11 @@ var _TspanTooltip = _interopRequireDefault(require("./TspanTooltip"));
12
12
  var _NoDataFoundMessage = require("./NoDataFoundMessage");
13
13
  var _CommonFunctions = require("./CommonFunctions");
14
14
  var _TotalHorizontalCharts = require("./TotalHorizontalCharts.style");
15
- /* eslint-disable react/destructuring-assignment */
15
+ /* eslint-disable no-unused-vars */
16
+ /* eslint-disable react/prop-types */
16
17
  /* eslint-disable react/no-unstable-nested-components */
17
18
  /* eslint-disable no-shadow */
18
- /* eslint-disable react/prop-types */
19
+ /* eslint-disable react/destructuring-assignment */
19
20
 
20
21
  const TotalHorizontalCharts = props => {
21
22
  const {
@@ -29,6 +30,7 @@ const TotalHorizontalCharts = props => {
29
30
  labelLimitedLetters,
30
31
  width,
31
32
  height,
33
+ barsMargin,
32
34
  rightGap,
33
35
  textColor,
34
36
  noDataText,
@@ -39,21 +41,32 @@ const TotalHorizontalCharts = props => {
39
41
  className
40
42
  } = props;
41
43
  const barBackgrounds = chartsData.map(bg => bg.color);
42
- const [widthChartContainer, setWidthChartContainer] = (0, _react.useState)(0);
43
- const [heightChartContainer, setHeightChartContainer] = (0, _react.useState)(0);
44
- const chartContainerRef = (0, _react.useRef)();
44
+ const topHeader = (0, _react.useRef)();
45
+ const wrapper = (0, _react.useRef)();
46
+ const [chartHeight, setChartHeight] = (0, _react.useState)('100%');
47
+ const calcHeight = () => {
48
+ if (wrapper.current && topHeader.current) {
49
+ const availableHeight = Math.max(wrapper.current.clientHeight - topHeader.current.clientHeight, 0);
50
+ return availableHeight / wrapper.current.clientHeight * 100;
51
+ }
52
+ return 100;
53
+ };
54
+ const updateChartHeight = () => {
55
+ setChartHeight(`${calcHeight()}%`);
56
+ };
57
+ (0, _react.useEffect)(() => {
58
+ updateChartHeight();
59
+ window.addEventListener('resize', updateChartHeight);
60
+ return () => {
61
+ window.removeEventListener('resize', updateChartHeight);
62
+ };
63
+ }, []);
45
64
  const [showLegendTooltip, setShowLegendTooltip] = (0, _react.useState)(false);
46
65
  const [tooltipText, setTooltipText] = (0, _react.useState)({
47
66
  content: '',
48
67
  clientX: 0,
49
68
  clientY: 0
50
69
  });
51
- (0, _react.useEffect)(() => {
52
- if (chartContainerRef.current) {
53
- setWidthChartContainer(chartContainerRef.current.clientWidth);
54
- setHeightChartContainer(chartContainerRef.current.clientHeight);
55
- }
56
- }, [width, height]);
57
70
  const CustomizedLabel = props => showPercentAsideValue ? /*#__PURE__*/_react.default.createElement("text", {
58
71
  x: props.x + (props.width <= 0 ? -12 : props.width) + 56,
59
72
  y: props.y + 4,
@@ -127,29 +140,27 @@ const TotalHorizontalCharts = props => {
127
140
  return null;
128
141
  };
129
142
  return /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.ControlsContainer, {
143
+ ref: wrapper,
130
144
  height: height,
131
145
  width: width,
132
146
  textColor: textColor,
133
147
  className: className
134
- }, (chartsData === null || chartsData === void 0 ? void 0 : chartsData.length) > 0 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.TitleAndValueContainer, {
135
- id: "TitleAndValueContainer"
136
- }, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.Header, null, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.Title, null, title), /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.FormattedValue, {
137
- id: "FormattedValue"
138
- }, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.CurrencySign, {
139
- id: "CurrencySign"
140
- }, currencySign ? (0, _CommonFunctions.getCurrencySign)(currencyType, value) : ''), dotCut ? (0, _CommonFunctions.getFormattedValue)(value && Math.abs(value) > 0 && value % 1 !== 0 ? value === null || value === void 0 ? void 0 : value.toFixed(2) : value) : (0, _CommonFunctions.getNumberWithCommas)(value), dotCut ? (0, _CommonFunctions.getFormattedUnits)(value) : ''))), /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.ChartWrapper, null, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.ChartInner, {
141
- ref: chartContainerRef
142
- }, /*#__PURE__*/_react.default.createElement(_recharts.ResponsiveContainer, {
143
- height: heightChartContainer - 10,
144
- width: widthChartContainer
148
+ }, (chartsData === null || chartsData === void 0 ? void 0 : chartsData.length) > 0 ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.CardHeader, {
149
+ ref: topHeader,
150
+ className: "CardHeader"
151
+ }, /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.Title, null, title), /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.TotalValue, {
152
+ className: "TotalValue"
153
+ }, currencySign && /*#__PURE__*/_react.default.createElement(_TotalHorizontalCharts.CurrencySign, {
154
+ className: "CurrencySign"
155
+ }, (0, _CommonFunctions.getCurrencySign)(currencyType, value)), dotCut ? (0, _CommonFunctions.getFormattedValue)(value && Math.abs(value) > 0 && value % 1 !== 0 ? value === null || value === void 0 ? void 0 : value.toFixed(2) : value) : (0, _CommonFunctions.getNumberWithCommas)(value), dotCut ? (0, _CommonFunctions.getFormattedUnits)(value) : '')), /*#__PURE__*/_react.default.createElement(_recharts.ResponsiveContainer, {
156
+ height: chartHeight
145
157
  }, /*#__PURE__*/_react.default.createElement(_recharts.ComposedChart, {
146
- width: widthChartContainer * 0.4,
147
158
  layout: "vertical",
148
159
  data: chartsData,
149
160
  margin: {
150
161
  top: 10,
151
162
  right: 20,
152
- bottom: 50,
163
+ bottom: barsMargin,
153
164
  left: 10
154
165
  }
155
166
  }, /*#__PURE__*/_react.default.createElement(_recharts.XAxis, {
@@ -160,13 +171,11 @@ const TotalHorizontalCharts = props => {
160
171
  }), /*#__PURE__*/_react.default.createElement(_recharts.YAxis, {
161
172
  dataKey: "name",
162
173
  type: "category",
163
- width: widthChartContainer * 0.3,
174
+ width: labelLimitedLetters * 10,
164
175
  tickLine: false,
176
+ axisLine: false,
165
177
  interval: 0,
166
178
  allowDataOverflow: true,
167
- axisLine: false
168
- // tick={{ fontSize: 12 }}
169
- ,
170
179
  tick: CustomizedTickBarChart
171
180
  }), /*#__PURE__*/_react.default.createElement(_recharts.Bar, {
172
181
  dataKey: "value",
@@ -191,7 +200,7 @@ const TotalHorizontalCharts = props => {
191
200
  style: {
192
201
  pointerEvents: 'none'
193
202
  }
194
- })))))) : /*#__PURE__*/_react.default.createElement(_NoDataFoundMessage.NoDataFoundMessage, {
203
+ })))) : /*#__PURE__*/_react.default.createElement(_NoDataFoundMessage.NoDataFoundMessage, {
195
204
  noDataText: noDataText
196
205
  }));
197
206
  };
@@ -205,14 +214,15 @@ TotalHorizontalCharts.defaultProps = {
205
214
  currencySign: false,
206
215
  currencyType: 'USD',
207
216
  chartsData: [],
217
+ showPercentAsideValue: false,
208
218
  labelFontSize: 10,
209
219
  labelLimitedLetters: 12,
210
220
  width: '100%',
211
221
  height: '100%',
212
- rightGap: 1.25,
222
+ barsMargin: 0,
223
+ rightGap: 1,
213
224
  textColor: '#212121',
214
225
  noDataText: 'No Data',
215
- showPercentAsideValue: false,
216
226
  isDollar: true,
217
227
  isPercentage: false,
218
228
  showDollarSign: true
@@ -4,73 +4,24 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TitleAndValueContainer = exports.Title = exports.OutBanner = exports.Header = exports.FormattedValue = exports.CurrencySign = exports.ControlsContainer = exports.ChartWrapper = exports.ChartInner = void 0;
7
+ exports.TotalValue = exports.Title = exports.CurrencySign = exports.ControlsContainer = exports.CardHeader = void 0;
8
8
  var _styledComponents = _interopRequireDefault(require("styled-components"));
9
- const scrollableStyles = `
10
- overflow-y: auto;
11
-
12
- &::-webkit-scrollbar {
13
- width: 5px;
14
- }
15
-
16
- &::-webkit-scrollbar-track {
17
- background: #E8E8E8;
18
- border-radius: 5px;
19
- }
20
-
21
- &::-webkit-scrollbar-thumb {
22
- background: #D0D0D0;
23
- border-radius: 5px;
24
- }
25
- `;
26
9
  const ControlsContainer = exports.ControlsContainer = _styledComponents.default.div`
27
- position: relative;
28
10
  font-family: "Poppins", sans-serif;
11
+ position: relative;
12
+ background-color: white;
29
13
  color: ${props => props.textColor};
30
14
  width: ${props => props.width};
31
15
  height: ${props => props.height};
32
- background-color: white;
33
- display: flex;
34
- flex-direction: column;
35
- // justify-content: center;
36
- .top {
37
- text-align: center;
38
- white-space: normal;
39
- &:before {
40
- display: none;
41
- }
42
- }
43
- `;
44
- const ChartWrapper = exports.ChartWrapper = _styledComponents.default.div`
45
- flex-grow: 1;
46
- width: 100%;
47
- ${scrollableStyles}
48
- overflow-x: hidden;
49
- `;
50
- const ChartInner = exports.ChartInner = _styledComponents.default.div`
51
- min-height: 120%;
52
- width: 100%;
53
16
  `;
54
- const TitleAndValueContainer = exports.TitleAndValueContainer = _styledComponents.default.div`
55
- display: flex;
56
- align-items: baseline;
57
- justify-content: space-between;
17
+ const CardHeader = exports.CardHeader = _styledComponents.default.div`
58
18
  padding: 16px;
19
+ position: sticky;
20
+ top: 0;
21
+ z-index: 10;
22
+ background-color: white;
59
23
  `;
60
- const Header = exports.Header = _styledComponents.default.div``;
61
- const Title = exports.Title = _styledComponents.default.h4`
62
- font-size: 18px;
63
- font-weight: 400;
64
- line-height: 1;
65
- margin: 0 0 8px;
66
- @media (max-width: 1536px) {
67
- font-size: 14px;
68
- }
69
- @media (max-width: 1366px) {
70
- font-size: 12px;
71
- }
72
- `;
73
- const FormattedValue = exports.FormattedValue = _styledComponents.default.div`
24
+ const TotalValue = exports.TotalValue = _styledComponents.default.div`
74
25
  font-weight: 500;
75
26
  font-size: 40px;
76
27
  display: flex;
@@ -83,31 +34,16 @@ const FormattedValue = exports.FormattedValue = _styledComponents.default.div`
83
34
  font-size: 20px;
84
35
  }
85
36
  `;
86
- const OutBanner = exports.OutBanner = _styledComponents.default.div`
87
- display: flex;
88
- gap: 8px;
89
- align-items: baseline;
90
- font-size: 14px;
37
+ const Title = exports.Title = _styledComponents.default.h4`
38
+ font-size: 18px;
91
39
  font-weight: 400;
92
- color: ${props => props.textColor};
93
- cursor: pointer;
40
+ line-height: 1;
41
+ margin: 0 0 8px;
94
42
  @media (max-width: 1536px) {
95
- font-size: 10px;
43
+ font-size: 14px;
96
44
  }
97
45
  @media (max-width: 1366px) {
98
- font-size: 8px;
99
- }
100
- > svg {
101
- width: 14px;
102
- height: 14px;
103
- @media (max-width: 1536px) {
104
- width: 12px;
105
- height: 12px;
106
- }
107
- @media (max-width: 1366px) {
108
- width: 8px;
109
- height: 8px;
110
- }
46
+ font-size: 12px;
111
47
  }
112
48
  `;
113
49
  const CurrencySign = exports.CurrencySign = _styledComponents.default.span`