@zac-apps/helium 2.0.0-beta.2 → 2.0.0-beta.3

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 (2) hide show
  1. package/dist/index.js +27 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -640,19 +640,19 @@ function HePrognosis(_ref6) {
640
640
  sm: 12
641
641
  },
642
642
  children: [/*#__PURE__*/jsx(Grid, {
643
- xs: 6,
643
+ size: 6,
644
644
  children: /*#__PURE__*/jsx(SelectSpecs, {
645
645
  specs: specs,
646
646
  SetSpecs: SetSpecs
647
647
  })
648
648
  }), /*#__PURE__*/jsx(Grid, {
649
- xs: 6,
649
+ size: 6,
650
650
  children: /*#__PURE__*/jsx(AddPrognoEntry, {
651
651
  increments: increments,
652
652
  SetIncrements: SetIncrements
653
653
  })
654
654
  }), /*#__PURE__*/jsx(Grid, {
655
- xs: 12,
655
+ size: 12,
656
656
  children: /*#__PURE__*/jsxs(AppTable, {
657
657
  children: [/*#__PURE__*/jsxs(TableHead, {
658
658
  children: [/*#__PURE__*/jsxs(TableRow, {
@@ -682,13 +682,13 @@ function HePrognosis(_ref6) {
682
682
  })]
683
683
  })
684
684
  }), /*#__PURE__*/jsxs(Grid, {
685
- xs: 12,
686
685
  sx: {
687
686
  display: "flex",
688
687
  justifyContent: "center",
689
688
  alignItems: "center",
690
689
  pt: 2
691
690
  },
691
+ size: 12,
692
692
  children: [/*#__PURE__*/jsx(Chip, {
693
693
  sx: {
694
694
  backgroundColor: errorBg,
@@ -1045,10 +1045,10 @@ function PairWizard(_ref4) {
1045
1045
  md: 12
1046
1046
  },
1047
1047
  children: [/*#__PURE__*/jsxs(Grid, {
1048
- xs: 6,
1049
1048
  sx: {
1050
1049
  px: 2
1051
1050
  },
1051
+ size: 6,
1052
1052
  children: [/*#__PURE__*/jsx(Divider, {
1053
1053
  textAlign: "left",
1054
1054
  children: /*#__PURE__*/jsx("strong", {
@@ -1076,10 +1076,10 @@ function PairWizard(_ref4) {
1076
1076
  })
1077
1077
  })]
1078
1078
  }), /*#__PURE__*/jsxs(Grid, {
1079
- xs: 6,
1080
1079
  sx: {
1081
1080
  px: 2
1082
1081
  },
1082
+ size: 6,
1083
1083
  children: [/*#__PURE__*/jsx(Divider, {
1084
1084
  textAlign: "left",
1085
1085
  children: /*#__PURE__*/jsx("strong", {
@@ -1135,10 +1135,10 @@ function FillTarget(_ref) {
1135
1135
  md: 12
1136
1136
  },
1137
1137
  children: [/*#__PURE__*/jsxs(Grid, {
1138
- xs: 6,
1139
1138
  sx: {
1140
1139
  px: 2
1141
1140
  },
1141
+ size: 6,
1142
1142
  children: [/*#__PURE__*/jsx(Divider, {
1143
1143
  textAlign: "left",
1144
1144
  children: /*#__PURE__*/jsx("strong", {
@@ -1157,10 +1157,10 @@ function FillTarget(_ref) {
1157
1157
  })
1158
1158
  })]
1159
1159
  }), /*#__PURE__*/jsxs(Grid, {
1160
- xs: 6,
1161
1160
  sx: {
1162
1161
  px: 2
1163
1162
  },
1163
+ size: 6,
1164
1164
  children: [/*#__PURE__*/jsx(Divider, {
1165
1165
  textAlign: "left",
1166
1166
  children: /*#__PURE__*/jsx("strong", {
@@ -1178,10 +1178,10 @@ function FillTarget(_ref) {
1178
1178
  })
1179
1179
  })]
1180
1180
  }), /*#__PURE__*/jsxs(Grid, {
1181
- xs: 6,
1182
1181
  sx: {
1183
1182
  px: 2
1184
1183
  },
1184
+ size: 6,
1185
1185
  children: [/*#__PURE__*/jsx(Divider, {
1186
1186
  textAlign: "left",
1187
1187
  children: /*#__PURE__*/jsx("strong", {
@@ -1204,10 +1204,10 @@ function FillTarget(_ref) {
1204
1204
  })
1205
1205
  })]
1206
1206
  }), /*#__PURE__*/jsxs(Grid, {
1207
- xs: 6,
1208
1207
  sx: {
1209
1208
  px: 2
1210
1209
  },
1210
+ size: 6,
1211
1211
  children: [/*#__PURE__*/jsx(Divider, {
1212
1212
  textAlign: "left",
1213
1213
  children: /*#__PURE__*/jsx("strong", {
@@ -1572,35 +1572,41 @@ function RenderGraph(_ref) {
1572
1572
  showEstimate = _useState6[0],
1573
1573
  setShowEstimate = _useState6[1];
1574
1574
 
1575
- // Add days ago to data
1576
-
1577
- data.map(function (item) {
1578
- item.days = -moment(item.date, "ddd MMM D HH:mm:ss YYYY").diff(moment(), "days");
1575
+ // Add days ago to data (do not mutate props — create a new array)
1576
+ var dataWithDays = (data || []).map(function (item) {
1577
+ return _objectSpread$1(_objectSpread$1({}, item), {}, {
1578
+ days: -moment(item.date, "ddd MMM D HH:mm:ss YYYY").diff(moment(), "days")
1579
+ });
1579
1580
  });
1580
1581
 
1581
1582
  // Get chart data from estimate
1582
1583
 
1583
1584
  // First, get difference between today and last data point
1584
1585
 
1585
- var daysSinceUpate = moment().diff(moment(data[data.length - 1].date, "ddd MMM D HH:mm:ss YYYY"), "days");
1586
+ // Guard against empty data
1587
+ var daysSinceUpate = 0;
1588
+ if (dataWithDays.length > 0) {
1589
+ daysSinceUpate = moment().diff(moment(dataWithDays[dataWithDays.length - 1].date, "ddd MMM D HH:mm:ss YYYY"), "days");
1590
+ }
1586
1591
 
1587
1592
  // Then calculate estimated data points
1588
1593
 
1589
- showEstimate && (data = data.map(function (item) {
1590
- var days = item.days;
1594
+ // Build final dataset (with optional estimate) without mutating original
1595
+ var dataWithEstimate = showEstimate ? dataWithDays.map(function (item) {
1596
+ var itemDays = item.days;
1591
1597
  var level = item.level;
1592
- var estimate = estimatedBoiloff * (data.length - days + daysSinceUpate) + estimatedIntercept;
1598
+ var estimate = estimatedBoiloff * (dataWithDays.length - itemDays + daysSinceUpate) + estimatedIntercept;
1593
1599
  return {
1594
1600
  date: item.date,
1595
- days: days,
1601
+ days: itemDays,
1596
1602
  level: level,
1597
1603
  estimate: estimate
1598
1604
  };
1599
- }));
1605
+ }) : dataWithDays;
1600
1606
 
1601
1607
  // Get last n elements of array
1602
1608
 
1603
- var slicedData = data.slice(Math.max(data.length - days, 0));
1609
+ var slicedData = dataWithEstimate.slice(Math.max(dataWithEstimate.length - days, 0));
1604
1610
 
1605
1611
  // Improve visibility of estimate
1606
1612
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/helium",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",