sag_components 1.0.24 → 1.0.26

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.
@@ -117,8 +117,8 @@ TotalCost.args = {
117
117
  currency: true,
118
118
  currencyType: "USD",
119
119
  legendData: arrLegendData,
120
- width: 336,
121
- height: 374,
120
+ width: 260,
121
+ height: 350,
122
122
  textColor: "#212121"
123
123
  };
124
124
  var TotalCost3rows = Template.bind({});
@@ -130,7 +130,7 @@ TotalCost3rows.args = {
130
130
  currency: true,
131
131
  currencyType: "USD",
132
132
  legendData: arrLegendDat3rows,
133
- width: 336,
134
- height: 374,
133
+ width: 260,
134
+ height: 350,
135
135
  textColor: "#212121"
136
136
  };
@@ -28,15 +28,23 @@ var CurrencySign = _styledComponents.default.div(_templateObject4 || (_templateO
28
28
  exports.CurrencySign = CurrencySign;
29
29
  var FormattedValue = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 200px;\n height: 48px;\n left: 57px;\n top: 115px;\n font-weight: 500;\n font-size: 40px;\n line-height: 48px;\n //border: 1px solid red;\n"])));
30
30
  exports.FormattedValue = FormattedValue;
31
- var DoughnutChart = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 95px;\n height: 95px;\n left: 40px;\n top: 221px;\n //border: 1px solid red;\n"])));
31
+ var DoughnutChart = _styledComponents.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 95px;\n height: 95px;\n left: ", ";\n top: ", "; \n //border: 1px solid red;\n"])), function (props) {
32
+ return props.left.toString().concat("", "px"); //10px
33
+ }, function (props) {
34
+ return props.top.toString().concat("", "px"); //top: 221px;
35
+ });
32
36
  exports.DoughnutChart = DoughnutChart;
33
- var LegendControls = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n border-radius: 12px;\n width: 180px;\n height: 47px;\n left: 150px;\n top: 221px; \n background: #ffffff;\n //border: 1px solid blue;\n"])));
37
+ var LegendControls = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n border-radius: 12px;\n width: 150px;\n height: 47px; \n left: ", ";\n top: ", "; \n background: #ffffff;\n //border: 1px solid blue;\n"])), function (props) {
38
+ return props.left.toString().concat("", "px"); //100px
39
+ }, function (props) {
40
+ return props.top.toString().concat("", "px"); //top: 221px;
41
+ });
34
42
  exports.LegendControls = LegendControls;
35
43
  var LegendColorRectangle = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 16px;\n height: 16px;\n left: 14px;\n top: 14px;\n background: ", ";\n"])), function (props) {
36
44
  return props.color;
37
45
  });
38
46
  exports.LegendColorRectangle = LegendColorRectangle;
39
- var LegendTitle = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 120px;\n height: 18px;\n left: 40px;\n top: 1px;\n font-weight: 400;\n font-size: 14px;\n line-height: 17px;\n //border: 1px solid red;\n"])));
47
+ var LegendTitle = _styledComponents.default.div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 110px;\n height: 18px;\n left: 40px;\n top: 1px;\n font-weight: 400;\n font-size: 14px;\n line-height: 17px;\n //border: 1px solid red;\n"])));
40
48
  exports.LegendTitle = LegendTitle;
41
49
  var LegendCurrencySign = _styledComponents.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 11px;\n height: 19px;\n left: 42px;\n top: 21px;\n font-weight: 600;\n font-size: 16px;\n line-height: 19px;\n //border: 1px solid red;\n"])));
42
50
  exports.LegendCurrencySign = LegendCurrencySign;
@@ -13,7 +13,7 @@ var _OneColumnContainer = require("../OneColumnContainer.style");
13
13
  var _InfoIcon = require("./InfoIcon");
14
14
  var _core = require("@dnd-kit/core");
15
15
  var _classnames = _interopRequireDefault(require("classnames"));
16
- var _excluded = ["children", "nodeRef", "itemClass", "overStyle", "draggingStyle", "droppedStyle", "refId", "width", "height", "infoText"];
16
+ var _excluded = ["children", "nodeRef", "itemClass", "divStyle", "overStyle", "draggingStyle", "droppedStyle", "refId", "width", "height", "infoText"];
17
17
  /**
18
18
  * Primary UI component for user interaction
19
19
  */
@@ -21,6 +21,7 @@ var OneColumnContainer = function OneColumnContainer(_ref) {
21
21
  var children = _ref.children,
22
22
  nodeRef = _ref.nodeRef,
23
23
  itemClass = _ref.itemClass,
24
+ divStyle = _ref.divStyle,
24
25
  overStyle = _ref.overStyle,
25
26
  draggingStyle = _ref.draggingStyle,
26
27
  droppedStyle = _ref.droppedStyle,
@@ -41,13 +42,8 @@ var OneColumnContainer = function OneColumnContainer(_ref) {
41
42
  width: width,
42
43
  height: height
43
44
  }, /*#__PURE__*/_react.default.createElement("div", {
44
- ref: nodeRef,
45
- style: {
46
- width: "100%",
47
- height: "100%",
48
- display: "grid",
49
- gridTemplateColumns: "repeat(2, 1fr)"
50
- }
45
+ className: (0, _classnames.default)(divStyle),
46
+ ref: nodeRef
51
47
  }, children, /*#__PURE__*/_react.default.createElement(_OneColumnContainer.InfoTextContainer, {
52
48
  clicked: clicked,
53
49
  width: width,
@@ -24,12 +24,14 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
24
24
  currencyType = _ref$currencyType === void 0 ? "USD" : _ref$currencyType,
25
25
  legendData = _ref.legendData,
26
26
  _ref$width = _ref.width,
27
- width = _ref$width === void 0 ? 336 : _ref$width,
27
+ width = _ref$width === void 0 ? 260 : _ref$width,
28
28
  _ref$height = _ref.height,
29
- height = _ref$height === void 0 ? 374 : _ref$height,
29
+ height = _ref$height === void 0 ? 350 : _ref$height,
30
30
  _ref$textColor = _ref.textColor,
31
31
  textColor = _ref$textColor === void 0 ? "black" : _ref$textColor,
32
32
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
33
+ var MIN_WIDTH = 260;
34
+ var MIN_HEIGHT = 300;
33
35
  var getCurrencySign = function getCurrencySign(currencyTypeToConvert) {
34
36
  if (!currencyTypeToConvert) return "";
35
37
  var currencySign = "";
@@ -70,19 +72,83 @@ var TotalDoughnutChart = function TotalDoughnutChart(_ref) {
70
72
  while (pattern.test(x)) x = x.replace(pattern, "$1,$2");
71
73
  return x;
72
74
  };
75
+ var getDoughnutChartLeft = function getDoughnutChartLeft() {
76
+ if (width <= 260) {
77
+ return 10;
78
+ }
79
+ ;
80
+ if (width >= 290) {
81
+ return 40;
82
+ }
83
+ ;
84
+ return 10 + (width - MIN_WIDTH);
85
+ };
86
+ var getLegendControlsLeft = function getLegendControlsLeft() {
87
+ if (width <= 260) {
88
+ return 100;
89
+ }
90
+ ;
91
+ if (width >= 300) {
92
+ return 140;
93
+ }
94
+ ;
95
+ return 100 + (width - MIN_WIDTH);
96
+ };
97
+ var getDoughnutChartTop = function getDoughnutChartTop() {
98
+ if (height <= 300) {
99
+ return 180;
100
+ }
101
+ ;
102
+ if (height >= 340) {
103
+ return 220;
104
+ }
105
+ ;
106
+ return 180 + (height - MIN_HEIGHT);
107
+ };
108
+ var getLegendControlsTop = function getLegendControlsTop() {
109
+ if (height <= 300) {
110
+ return 180;
111
+ }
112
+ ;
113
+ if (height >= 340) {
114
+ return 220;
115
+ }
116
+ ;
117
+ return 180 + (height - MIN_HEIGHT);
118
+ };
119
+ var getControlsLeft = function getControlsLeft() {
120
+ if (width - MIN_WIDTH <= 0) {
121
+ return MIN_WIDTH;
122
+ }
123
+ ;
124
+ return width;
125
+ };
126
+ var getControlsTop = function getControlsTop() {
127
+ if (height - MIN_HEIGHT <= 0) {
128
+ return MIN_HEIGHT;
129
+ }
130
+ ;
131
+ return height;
132
+ };
73
133
  var onPieEnterHandler = function onPieEnterHandler() {};
74
134
  return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.ControlsContainer, {
75
- height: height,
76
- width: width,
135
+ height: getControlsTop(),
136
+ width: getControlsLeft(),
77
137
  textColor: textColor
78
138
  }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.Controls, {
79
139
  height: height,
80
- width: width
140
+ width: getControlsLeft
81
141
  }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.Title, null, title), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.CurrencySign, null, "".concat(currency ? getCurrencySign(currencyType) : "")), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.FormattedValue, null, "".concat(dotCut ? getFormattedValue(value) : getNumberWithCommas(value)), "".concat(dotCut ? getFormattedUnits(value) : "")), legendData.map(function (row, index) {
82
- return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendControls, null, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendColorRectangle, {
142
+ return /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendControls, {
143
+ left: getLegendControlsLeft(),
144
+ top: getLegendControlsTop()
145
+ }, /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendColorRectangle, {
83
146
  color: row.color
84
147
  }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendTitle, null, row.name), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendCurrencySign, null, "".concat(currency ? getCurrencySign(currencyType) : "")), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.LegendFormattedValue, null, "".concat(dotCut ? getFormattedValue(row.value) : getNumberWithCommas(row.value)), "".concat(dotCut ? getFormattedUnits(row.value) : "")));
85
- }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.DoughnutChart, null, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, {
148
+ }), /*#__PURE__*/_react.default.createElement(_TotalDoughnutChartStyle.DoughnutChart, {
149
+ left: getDoughnutChartLeft(),
150
+ top: getDoughnutChartTop()
151
+ }, /*#__PURE__*/_react.default.createElement(_recharts.PieChart, {
86
152
  width: 93,
87
153
  height: 93,
88
154
  onMouseEnter: onPieEnterHandler
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sag_components",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -92,8 +92,8 @@ TotalCost.args = {
92
92
  currency: true,
93
93
  currencyType: "USD",
94
94
  legendData: arrLegendData,
95
- width: 336,
96
- height: 374,
95
+ width: 260,
96
+ height: 350,
97
97
  textColor: "#212121",
98
98
  };
99
99
 
@@ -106,7 +106,7 @@ TotalCost3rows.args = {
106
106
  currency: true,
107
107
  currencyType: "USD",
108
108
  legendData: arrLegendDat3rows,
109
- width: 336,
110
- height: 374,
109
+ width: 260,
110
+ height: 350,
111
111
  textColor: "#212121",
112
112
  };
@@ -73,18 +73,26 @@ export const DoughnutChart = styled.div`
73
73
  position: absolute;
74
74
  width: 95px;
75
75
  height: 95px;
76
- left: 40px;
77
- top: 221px;
76
+ left: ${(props) => {
77
+ return props.left.toString().concat("", "px"); //10px
78
+ }};
79
+ top: ${(props) => {
80
+ return props.top.toString().concat("", "px"); //top: 221px;
81
+ }};
78
82
  //border: 1px solid red;
79
83
  `;
80
84
 
81
85
  export const LegendControls = styled.div`
82
86
  position: relative;
83
87
  border-radius: 12px;
84
- width: 180px;
85
- height: 47px;
86
- left: 150px;
87
- top: 221px;
88
+ width: 150px;
89
+ height: 47px;
90
+ left: ${(props) => {
91
+ return props.left.toString().concat("", "px"); //100px
92
+ }};
93
+ top: ${(props) => {
94
+ return props.top.toString().concat("", "px"); //top: 221px;
95
+ }};
88
96
  background: #ffffff;
89
97
  //border: 1px solid blue;
90
98
  `;
@@ -100,7 +108,7 @@ export const LegendColorRectangle = styled.div`
100
108
 
101
109
  export const LegendTitle = styled.div`
102
110
  position: absolute;
103
- width: 120px;
111
+ width: 110px;
104
112
  height: 18px;
105
113
  left: 40px;
106
114
  top: 1px;
@@ -7,7 +7,7 @@ import classNames from "classnames";
7
7
  /**
8
8
  * Primary UI component for user interaction
9
9
  */
10
- export const OneColumnContainer = ({ children,nodeRef,itemClass,overStyle,draggingStyle,droppedStyle,refId,width,height,infoText,...props }) => {
10
+ export const OneColumnContainer = ({ children,nodeRef,itemClass,divStyle,overStyle,draggingStyle,droppedStyle,refId,width,height,infoText,...props }) => {
11
11
  const [clicked, setClicked] = useState(false);
12
12
  const onInfoClick = ()=>{
13
13
  setClicked(!clicked)
@@ -21,13 +21,7 @@ export const OneColumnContainer = ({ children,nodeRef,itemClass,overStyle,draggi
21
21
  draggingStyle,
22
22
  children && droppedStyle
23
23
  )} width={width} height={height}>
24
- <div ref={nodeRef} style={{
25
-
26
- width: "100%",
27
- height: "100%",
28
- display: "grid",
29
- gridTemplateColumns: "repeat(2, 1fr)"
30
- }}>
24
+ <div className={classNames(divStyle)} ref={nodeRef} >
31
25
  {children}
32
26
  <InfoTextContainer clicked={clicked} width={width} height={height}>
33
27
  <InfoTextLabel>{infoText}</InfoTextLabel>
@@ -24,11 +24,14 @@ export const TotalDoughnutChart = ({
24
24
  currency = true,
25
25
  currencyType = "USD",
26
26
  legendData,
27
- width = 336,
28
- height = 374,
27
+ width = 260,
28
+ height = 350,
29
29
  textColor = "black",
30
30
  ...props
31
31
  }) => {
32
+ const MIN_WIDTH = 260;
33
+ const MIN_HEIGHT = 300;
34
+
32
35
  const getCurrencySign = (currencyTypeToConvert) => {
33
36
  if (!currencyTypeToConvert) return "";
34
37
  let currencySign = "";
@@ -73,11 +76,46 @@ export const TotalDoughnutChart = ({
73
76
  return x;
74
77
  };
75
78
 
79
+ const getDoughnutChartLeft = () => {
80
+ if( width <= 260) { return 10};
81
+ if( width >= 290) { return 40};
82
+ return 10 + (width - MIN_WIDTH) ;
83
+ };
84
+
85
+ const getLegendControlsLeft = () => {
86
+ if( width <= 260) { return 100};
87
+ if( width >= 300) { return 140};
88
+ return 100 + (width - MIN_WIDTH) ;
89
+ };
90
+
91
+ const getDoughnutChartTop = () => {
92
+ if( height <= 300) { return 180};
93
+ if( height >= 340) { return 220};
94
+ return 180 + (height - MIN_HEIGHT) ;
95
+ };
96
+
97
+ const getLegendControlsTop = () => {
98
+ if( height <= 300) { return 180};
99
+ if( height >= 340) { return 220};
100
+ return 180 + (height - MIN_HEIGHT) ;
101
+ };
102
+
103
+
104
+ const getControlsLeft = () => {
105
+ if( (width - MIN_WIDTH)<= 0) { return MIN_WIDTH};
106
+ return width ;
107
+ };
108
+
109
+ const getControlsTop = () => {
110
+ if( (height - MIN_HEIGHT)<= 0) { return MIN_HEIGHT};
111
+ return height ;
112
+ };
113
+
76
114
  const onPieEnterHandler = () => {};
77
115
 
78
116
  return (
79
- <ControlsContainer height={height} width={width} textColor={textColor}>
80
- <Controls height={height} width={width}>
117
+ <ControlsContainer height={getControlsTop()} width={getControlsLeft()} textColor={textColor}>
118
+ <Controls height={height} width={getControlsLeft}>
81
119
  <Title>{title}</Title>
82
120
 
83
121
  <CurrencySign>
@@ -89,7 +127,10 @@ export const TotalDoughnutChart = ({
89
127
  </FormattedValue>
90
128
 
91
129
  {legendData.map((row, index) => (
92
- <LegendControls>
130
+ <LegendControls
131
+ left={getLegendControlsLeft()}
132
+ top={getLegendControlsTop()}
133
+ >
93
134
  <LegendColorRectangle color={row.color}></LegendColorRectangle>
94
135
  <LegendTitle>{row.name}</LegendTitle>
95
136
  <LegendCurrencySign>
@@ -106,7 +147,9 @@ export const TotalDoughnutChart = ({
106
147
  </LegendControls>
107
148
  ))}
108
149
 
109
- <DoughnutChart>
150
+ <DoughnutChart
151
+ left={getDoughnutChartLeft() }
152
+ top={getDoughnutChartTop()}>
110
153
  <SourcePieChart
111
154
  width={93}
112
155
  height={93}
@@ -124,7 +167,7 @@ export const TotalDoughnutChart = ({
124
167
  ))}
125
168
  </Pie>
126
169
 
127
- <Tooltip/>
170
+ <Tooltip />
128
171
  </SourcePieChart>
129
172
  </DoughnutChart>
130
173
  </Controls>