ag-common 0.0.747 → 0.0.749

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.
@@ -128,7 +128,13 @@ function getS3Objects(_a) {
128
128
  }
129
129
  const putS3Object = (_a) => __awaiter(void 0, [_a], void 0, function* ({ Body, Bucket, Key, ContentType, CacheControl = 'public, max-age=300', }) {
130
130
  try {
131
- yield s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType, CacheControl }));
131
+ const r = yield s3.send(new client_s3_1.PutObjectCommand({ Body, Bucket, Key, ContentType, CacheControl }));
132
+ const code = r.$metadata.httpStatusCode;
133
+ if (code !== 200) {
134
+ return {
135
+ error: `failed to upload file to s3. code=${code}. ${JSON.stringify(r.$metadata)}`,
136
+ };
137
+ }
132
138
  return {};
133
139
  }
134
140
  catch (e) {
@@ -50,16 +50,12 @@ const LineChart = (p) => {
50
50
  if (!tt && xTime) {
51
51
  tt = dateHelpers_1.timeTooltipTitle;
52
52
  }
53
- if (!tt) {
54
- tt = (s) => s.toString();
55
- }
53
+ tt !== null && tt !== void 0 ? tt : (tt = (s) => s.toString());
56
54
  let lt = p.legendTitle;
57
55
  if (!lt && xTime) {
58
56
  lt = dateHelpers_1.timeLegendTitle;
59
57
  }
60
- if (!lt) {
61
- lt = (s) => s.toString();
62
- }
58
+ lt !== null && lt !== void 0 ? lt : (lt = (s) => s.toString());
63
59
  const lt2 = lt;
64
60
  const tt2 = tt;
65
61
  const legendItems = (0, getLegendItems_1.getLegendItems)(Object.assign(Object.assign({ colours: p.colours, data: p.data, tt: tt2, lt: lt2 }, (_a = UT.pos) === null || _a === void 0 ? void 0 : _a.data), { fixed: false }));
@@ -33,12 +33,19 @@ const LegendY = ({ data, style, }) => {
33
33
  }
34
34
  items.push(maxY);
35
35
  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
+ };
36
43
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, style), { maxWidth: `${ch}ch`, paddingRight: '1ch' }) },
37
44
  react_1.default.createElement(Numbers, null, items.map((i, i2) => (react_1.default.createElement("span", {
38
45
  // eslint-disable-next-line react/no-array-index-key
39
46
  key: i + i2, style: {
40
47
  color: style.color,
41
48
  backgroundColor: style.backgroundColor,
42
- } }, i))))));
49
+ } }, roundNumber(i)))))));
43
50
  };
44
51
  exports.LegendY = LegendY;
@@ -34,18 +34,25 @@ const Total = styled_1.default.span `
34
34
  const TooltipContent = (p) => {
35
35
  var _a, _b;
36
36
  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
+ };
37
44
  return (react_1.default.createElement(Base, { style: Object.assign(Object.assign({}, p.style), { border: `solid 1px ${p.style.borderColor}` }) },
38
45
  react_1.default.createElement(Title, null, name),
39
46
  react_1.default.createElement(Row, null,
40
47
  react_1.default.createElement("span", null, "total"),
41
- react_1.default.createElement(Total, null, p.legendItems.total)),
48
+ react_1.default.createElement(Total, null, roundNumber(p.legendItems.total))),
42
49
  p.legendItems.part.map((v) => (react_1.default.createElement(Row, { key: v.name + v.y, style: { color: v.colour } },
43
50
  react_1.default.createElement(ItemTitle, null, v.name),
44
- react_1.default.createElement(Total, null, v.y)))),
51
+ react_1.default.createElement(Total, null, roundNumber(v.y))))),
45
52
  p.legendItems.rest.length > 0 && (react_1.default.createElement(Row, null,
46
53
  react_1.default.createElement("span", null,
47
54
  p.legendItems.rest.length,
48
55
  " more"),
49
- react_1.default.createElement(Total, null, p.legendItems.restTotal)))));
56
+ react_1.default.createElement(Total, null, roundNumber(p.legendItems.restTotal))))));
50
57
  };
51
58
  exports.TooltipContent = TooltipContent;
@@ -54,7 +54,7 @@ function useOnScroll({ onScroll, element, } = {}) {
54
54
  };
55
55
  }, [element], [element, onScroll, startScrollTopY]);
56
56
  (0, react_1.useEffect)(() => {
57
- if (startScrollTopY === -1 && (element === null || element === void 0 ? void 0 : element.current.scrollTop)) {
57
+ if (startScrollTopY === -1 && !!(element === null || element === void 0 ? void 0 : element.current)) {
58
58
  setStartScrollTopY(element.current.scrollTop);
59
59
  }
60
60
  }, [element, startScrollTopY]);
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.747",
2
+ "version": "0.0.749",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",