ag-common 0.0.759 → 0.0.761

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.
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.LegendY = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
8
  const react_1 = __importDefault(require("react"));
9
+ const math_1 = require("../../../common/helpers/math");
9
10
  const Base = styled_1.default.div `
10
11
  display: flex;
11
12
  flex-flow: row;
@@ -33,19 +34,12 @@ const LegendY = ({ data, style, }) => {
33
34
  }
34
35
  items.push(maxY);
35
36
  const ch = maxY.toString().length;
36
- const roundNumber = (num) => {
37
- // Round to 2 decimal places and remove trailing zeros
38
- const rounded = Math.round(num * 100) / 100;
39
- return rounded % 1 === 0
40
- ? rounded.toString()
41
- : rounded.toFixed(2).replace(/\.?0+$/, '');
42
- };
43
- return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { maxWidth: `${ch}ch`, paddingRight: '1ch' }) },
37
+ return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { maxWidth: `${ch}ch`, paddingRight: '1ch', flexBasis: '1%' }) },
44
38
  react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
45
39
  // eslint-disable-next-line react/no-array-index-key
46
40
  key: i + i2, style: {
47
41
  color: style.color,
48
42
  backgroundColor: style.backgroundColor,
49
- } }, roundNumber(i)))))));
43
+ } }, (0, math_1.toFixed)(i, 2)))))));
50
44
  };
51
45
  exports.LegendY = LegendY;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TooltipContent = void 0;
7
7
  const styled_1 = __importDefault(require("@emotion/styled"));
8
8
  const react_1 = __importDefault(require("react"));
9
+ const math_1 = require("../../../common/helpers/math");
9
10
  const Base = styled_1.default.div `
10
11
  padding: 0.5rem;
11
12
  `;
@@ -34,25 +35,18 @@ const Total = styled_1.default.span `
34
35
  const TooltipContent = (p) => {
35
36
  var _a, _b;
36
37
  const name = p.tt((_b = (_a = p.selectedXs) === null || _a === void 0 ? void 0 : _a[0].x) !== null && _b !== void 0 ? _b : 0);
37
- const roundNumber = (num) => {
38
- // Round to 2 decimal places and remove trailing zeros
39
- const rounded = Math.round(num * 100) / 100;
40
- return rounded % 1 === 0
41
- ? rounded.toString()
42
- : rounded.toFixed(2).replace(/\.?0+$/, '');
43
- };
44
38
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, p.style), { border: `solid 1px ${p.style.borderColor}` }) },
45
39
  react_1.default.createElement(Title, null, name),
46
40
  react_1.default.createElement(Row, null,
47
41
  react_1.default.createElement("span", null, "total"),
48
- react_1.default.createElement(Total, null, roundNumber(p.legendItems.total))),
42
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.total, 2))),
49
43
  p.legendItems.part.map((v) => (react_1.default.createElement(Row, { key: v.name + v.y, style: { color: v.colour } },
50
44
  react_1.default.createElement(ItemTitle, null, v.name),
51
- react_1.default.createElement(Total, null, roundNumber(v.y))))),
45
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(v.y, 2))))),
52
46
  p.legendItems.rest.length > 0 && (react_1.default.createElement(Row, null,
53
47
  react_1.default.createElement("span", null,
54
48
  p.legendItems.rest.length,
55
49
  " more"),
56
- react_1.default.createElement(Total, null, roundNumber(p.legendItems.restTotal))))));
50
+ react_1.default.createElement(Total, null, (0, math_1.toFixed)(p.legendItems.restTotal, 2))))));
57
51
  };
58
52
  exports.TooltipContent = TooltipContent;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.759",
2
+ "version": "0.0.761",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "cross-env": "^10.0.0",
63
63
  "eslint": "^9.33.0",
64
64
  "eslint-config-e7npm": "^0.1.24",
65
- "eslint-plugin-storybook": "9.1.2",
65
+ "eslint-plugin-storybook": "9.1.3",
66
66
  "globstar": "^1.0.0",
67
67
  "rimraf": "^6.0.1",
68
68
  "storybook": "^9.1.2",