@zac-apps/helium 1.0.0-beta.2 → 1.0.0

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 +174 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import TableRow from '@mui/material/TableRow';
12
12
  import IconButton from '@mui/material/IconButton';
13
13
  import SaveIcon from '@mui/icons-material/Save';
14
14
  import EditIcon from '@mui/icons-material/Edit';
15
- import { ErrorAlert, AppTable, TableHeadCell, Percentage, AppTheme, DivTitle, PublicFetch, Progress, AppGrid, AppCard } from '@zac-apps/commons';
15
+ import { ErrorAlert, AppTable, TableHeadCell, Percentage, AppTheme, SpecSwitch, DivTitle, PublicFetch, Progress, AppGrid, AppCard } from '@zac-apps/commons';
16
16
  import TextField from '@mui/material/TextField';
17
17
  import InputAdornment from '@mui/material/InputAdornment';
18
18
  import { jsxs, jsx } from 'react/jsx-runtime';
@@ -121,6 +121,36 @@ function CalcLiters(_ref) {
121
121
  return returnVal;
122
122
  }
123
123
 
124
+ // Look up percentage for liter value in specific spectrometer
125
+
126
+ function CalcPercent(_ref2) {
127
+ var spec = _ref2.spec,
128
+ value = _ref2.value;
129
+ var heliumLookup = useContext(LookupContext).lookup;
130
+ var returnVal = 0;
131
+
132
+ // Catch values out of boundary
133
+
134
+ if (value < 0 || !value) {
135
+ value = 0;
136
+ } else {
137
+ value = Number(value);
138
+ }
139
+ if (value > heliumLookup[spec].find(function (m) {
140
+ return m.level === 100;
141
+ }).liters) {
142
+ returnVal = 100;
143
+ } else {
144
+ var closestLiters = heliumLookup[spec].reduce(function (prev, curr) {
145
+ return Math.abs(curr.liters - value) < Math.abs(prev.liters - value) ? curr : prev;
146
+ }).liters;
147
+ returnVal = heliumLookup[spec].find(function (m) {
148
+ return m.liters === closestLiters;
149
+ }).level;
150
+ }
151
+ return returnVal;
152
+ }
153
+
124
154
  // Look up difference from maximum
125
155
 
126
156
  function CalcToMax(_ref3) {
@@ -1068,6 +1098,143 @@ function PairWizard(_ref4) {
1068
1098
  });
1069
1099
  }
1070
1100
 
1101
+ function FillTarget(_ref) {
1102
+ var heliumData = _ref.heliumData;
1103
+ var heliumLookupData = useContext(LookupContext);
1104
+ var boilOff = heliumLookupData.boilOff;
1105
+ var lookup = heliumLookupData.lookup;
1106
+ var _useState = useState(false),
1107
+ _useState2 = _slicedToArray(_useState, 2),
1108
+ error = _useState2[0],
1109
+ SetError = _useState2[1];
1110
+ var _useState3 = useState(25),
1111
+ _useState4 = _slicedToArray(_useState3, 2),
1112
+ amount = _useState4[0],
1113
+ SetAmount = _useState4[1];
1114
+ var _useState5 = useState(Object.keys(lookup)[0]),
1115
+ _useState6 = _slicedToArray(_useState5, 2),
1116
+ spec = _useState6[0],
1117
+ SetSpec = _useState6[1];
1118
+ var currLevel = heliumData.helium[spec];
1119
+ var currLiter = CalcLiters({
1120
+ value: currLevel,
1121
+ spec: spec
1122
+ });
1123
+ var finalLiter = currLiter + amount;
1124
+ var finalLevel = CalcPercent({
1125
+ value: finalLiter,
1126
+ spec: spec
1127
+ });
1128
+ return /*#__PURE__*/jsx(React.Fragment, {
1129
+ children: /*#__PURE__*/jsxs(Grid, {
1130
+ container: true,
1131
+ columns: {
1132
+ xs: 6,
1133
+ md: 12
1134
+ },
1135
+ children: [/*#__PURE__*/jsxs(Grid, {
1136
+ xs: 6,
1137
+ sx: {
1138
+ px: 2
1139
+ },
1140
+ children: [/*#__PURE__*/jsx(Divider, {
1141
+ textAlign: "left",
1142
+ children: /*#__PURE__*/jsx("strong", {
1143
+ children: "Select Spectrometer"
1144
+ })
1145
+ }), /*#__PURE__*/jsx(Grid, {
1146
+ sx: {
1147
+ padding: 2,
1148
+ display: "flex",
1149
+ justifyContent: "center"
1150
+ },
1151
+ children: /*#__PURE__*/jsx(SpecSwitch, {
1152
+ setup: boilOff,
1153
+ spec: spec,
1154
+ SetSpec: SetSpec
1155
+ })
1156
+ })]
1157
+ }), /*#__PURE__*/jsxs(Grid, {
1158
+ xs: 6,
1159
+ sx: {
1160
+ px: 2
1161
+ },
1162
+ children: [/*#__PURE__*/jsx(Divider, {
1163
+ textAlign: "left",
1164
+ children: /*#__PURE__*/jsx("strong", {
1165
+ children: "Current status"
1166
+ })
1167
+ }), /*#__PURE__*/jsx(Grid, {
1168
+ sx: {
1169
+ padding: 2,
1170
+ display: "flex",
1171
+ justifyContent: "center"
1172
+ },
1173
+ children: /*#__PURE__*/jsxs(Typography, {
1174
+ variant: "h4",
1175
+ children: [currLevel, " % (", currLiter, " L)"]
1176
+ })
1177
+ })]
1178
+ }), /*#__PURE__*/jsxs(Grid, {
1179
+ xs: 6,
1180
+ sx: {
1181
+ px: 2
1182
+ },
1183
+ children: [/*#__PURE__*/jsx(Divider, {
1184
+ textAlign: "left",
1185
+ children: /*#__PURE__*/jsx("strong", {
1186
+ children: "Helium fill amount"
1187
+ })
1188
+ }), /*#__PURE__*/jsx(Grid, {
1189
+ sx: {
1190
+ padding: 2,
1191
+ display: "flex",
1192
+ justifyContent: "center"
1193
+ },
1194
+ children: /*#__PURE__*/jsx(Typography, {
1195
+ variant: "h4",
1196
+ children: /*#__PURE__*/jsx(LiterInput, {
1197
+ error: error,
1198
+ SetError: SetError,
1199
+ limit: amount,
1200
+ SetLimit: SetAmount
1201
+ })
1202
+ })
1203
+ })]
1204
+ }), /*#__PURE__*/jsxs(Grid, {
1205
+ xs: 6,
1206
+ sx: {
1207
+ px: 2
1208
+ },
1209
+ children: [/*#__PURE__*/jsx(Divider, {
1210
+ textAlign: "left",
1211
+ children: /*#__PURE__*/jsx("strong", {
1212
+ children: "After filling"
1213
+ })
1214
+ }), /*#__PURE__*/jsx(Grid, {
1215
+ sx: {
1216
+ padding: 2,
1217
+ display: "flex",
1218
+ justifyContent: "center"
1219
+ },
1220
+ children: /*#__PURE__*/jsx(Typography, {
1221
+ variant: "h4",
1222
+ children: /*#__PURE__*/jsxs("em", {
1223
+ style: {
1224
+ color: AppTheme.palette.warning.main
1225
+ },
1226
+ children: ["~ ", finalLevel, " % (", CalcLiters({
1227
+ value: finalLevel,
1228
+ spec: spec
1229
+ }), " L)"]
1230
+ })
1231
+ })
1232
+ })]
1233
+ })]
1234
+ })
1235
+ });
1236
+ }
1237
+
1071
1238
  function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1072
1239
  function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1073
1240
  function EstimateConsumption() {
@@ -1493,6 +1660,12 @@ function Helium(props) {
1493
1660
  heliumData: heliumData,
1494
1661
  heliumLookupData: heliumLookupData
1495
1662
  })
1663
+ }), /*#__PURE__*/jsx(AppCard, {
1664
+ title: "Fill Target",
1665
+ size: cardSize,
1666
+ children: /*#__PURE__*/jsx(FillTarget, {
1667
+ heliumData: heliumData
1668
+ })
1496
1669
  })]
1497
1670
  })]
1498
1671
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/helium",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@mui/icons-material": "^5.15.13",
32
32
  "@mui/material": "^5.15.13",
33
- "@zac-apps/commons": "^1.3.2",
33
+ "@zac-apps/commons": "^1.3.3",
34
34
  "moment": "^2.30.1",
35
35
  "recharts": "^2.12.3",
36
36
  "use-immer": "^0.9.0"