@hedia/recommendation-screen 1.3.0 → 1.3.1

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.
@@ -28,7 +28,9 @@
28
28
  </select>
29
29
  </component>
30
30
  <component name="ChangeListManager">
31
- <list default="true" id="bceba75c-4c15-4bdc-9b41-023f63a30830" name="Default Changelist" comment="" />
31
+ <list default="true" id="bceba75c-4c15-4bdc-9b41-023f63a30830" name="Default Changelist" comment="">
32
+ <change beforePath="$PROJECT_DIR$/src/components/InvisibleNumberInput.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/InvisibleNumberInput.tsx" afterDir="false" />
33
+ </list>
32
34
  <option name="SHOW_DIALOG" value="false" />
33
35
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
34
36
  <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -48,6 +50,7 @@
48
50
  <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
49
51
  <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
50
52
  <property name="TERMINAL_CUSTOM_COMMANDS_GOT_IT" value="true" />
53
+ <property name="ToolWindowGit.ShowToolbar" value="false" />
51
54
  <property name="WebServerToolWindowFactoryState" value="false" />
52
55
  <property name="dart.analysis.tool.window.visible" value="false" />
53
56
  <property name="last_opened_file_path" value="$PROJECT_DIR$/android/app/src/main/res/values" />
@@ -169,7 +172,9 @@
169
172
  <workItem from="1599205746476" duration="8368000" />
170
173
  <workItem from="1599465060245" duration="4905000" />
171
174
  <workItem from="1599554723490" duration="10979000" />
172
- <workItem from="1599637277136" duration="3405000" />
175
+ <workItem from="1599637277136" duration="8223000" />
176
+ <workItem from="1599729519931" duration="17229000" />
177
+ <workItem from="1599810708519" duration="2071000" />
173
178
  </task>
174
179
  <servers />
175
180
  </component>
@@ -229,42 +234,42 @@
229
234
  <state x="0" y="123" width="1792" height="897" key="DiffContextDialog/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597747801467" />
230
235
  <state x="0" y="123" width="1792" height="897" key="DiffContextDialog/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1597836504040" />
231
236
  <state x="1792" y="-314" width="1920" height="865" key="DiffContextDialog/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1598603549140" />
232
- <state width="918" height="257" key="GridCell.Tab.0.bottom" timestamp="1599641656861">
237
+ <state width="1878" height="183" key="GridCell.Tab.0.bottom" timestamp="1599814597572">
233
238
  <screen x="1792" y="-410" width="1920" height="1057" />
234
239
  </state>
235
240
  <state width="1750" height="261" key="GridCell.Tab.0.bottom/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596194051670" />
236
- <state width="1678" height="366" key="GridCell.Tab.0.bottom/0.23.1792.1097@0.23.1792.1097" timestamp="1599585643328" />
241
+ <state width="1678" height="263" key="GridCell.Tab.0.bottom/0.23.1792.1097@0.23.1792.1097" timestamp="1599753977842" />
237
242
  <state width="1750" height="383" key="GridCell.Tab.0.bottom/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597945008184" />
238
- <state width="1678" height="366" key="GridCell.Tab.0.bottom/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599567565615" />
243
+ <state width="1678" height="263" key="GridCell.Tab.0.bottom/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599741473452" />
239
244
  <state width="1276" height="270" key="GridCell.Tab.0.bottom/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599230158300" />
240
- <state width="918" height="257" key="GridCell.Tab.0.bottom/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599641656861" />
241
- <state width="918" height="257" key="GridCell.Tab.0.center" timestamp="1599641656860">
245
+ <state width="1878" height="183" key="GridCell.Tab.0.bottom/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599814597572" />
246
+ <state width="1878" height="183" key="GridCell.Tab.0.center" timestamp="1599814597571">
242
247
  <screen x="1792" y="-410" width="1920" height="1057" />
243
248
  </state>
244
249
  <state width="1750" height="261" key="GridCell.Tab.0.center/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596194051669" />
245
- <state width="1678" height="366" key="GridCell.Tab.0.center/0.23.1792.1097@0.23.1792.1097" timestamp="1599585643327" />
250
+ <state width="1678" height="263" key="GridCell.Tab.0.center/0.23.1792.1097@0.23.1792.1097" timestamp="1599753977841" />
246
251
  <state width="1750" height="383" key="GridCell.Tab.0.center/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597945008183" />
247
- <state width="1678" height="366" key="GridCell.Tab.0.center/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599567565614" />
252
+ <state width="1678" height="263" key="GridCell.Tab.0.center/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599741473451" />
248
253
  <state width="1276" height="270" key="GridCell.Tab.0.center/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599230158300" />
249
- <state width="918" height="257" key="GridCell.Tab.0.center/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599641656860" />
250
- <state width="918" height="257" key="GridCell.Tab.0.left" timestamp="1599641656860">
254
+ <state width="1878" height="183" key="GridCell.Tab.0.center/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599814597571" />
255
+ <state width="1878" height="183" key="GridCell.Tab.0.left" timestamp="1599814597571">
251
256
  <screen x="1792" y="-410" width="1920" height="1057" />
252
257
  </state>
253
258
  <state width="1750" height="261" key="GridCell.Tab.0.left/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596194051668" />
254
- <state width="1678" height="366" key="GridCell.Tab.0.left/0.23.1792.1097@0.23.1792.1097" timestamp="1599585643327" />
259
+ <state width="1678" height="263" key="GridCell.Tab.0.left/0.23.1792.1097@0.23.1792.1097" timestamp="1599753977841" />
255
260
  <state width="1750" height="383" key="GridCell.Tab.0.left/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597945008182" />
256
- <state width="1678" height="366" key="GridCell.Tab.0.left/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599567565614" />
261
+ <state width="1678" height="263" key="GridCell.Tab.0.left/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599741473451" />
257
262
  <state width="1276" height="270" key="GridCell.Tab.0.left/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599230158299" />
258
- <state width="918" height="257" key="GridCell.Tab.0.left/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599641656860" />
259
- <state width="918" height="257" key="GridCell.Tab.0.right" timestamp="1599641656861">
263
+ <state width="1878" height="183" key="GridCell.Tab.0.left/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599814597571" />
264
+ <state width="1878" height="183" key="GridCell.Tab.0.right" timestamp="1599814597572">
260
265
  <screen x="1792" y="-410" width="1920" height="1057" />
261
266
  </state>
262
267
  <state width="1750" height="261" key="GridCell.Tab.0.right/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596194051669" />
263
- <state width="1678" height="366" key="GridCell.Tab.0.right/0.23.1792.1097@0.23.1792.1097" timestamp="1599585643328" />
268
+ <state width="1678" height="263" key="GridCell.Tab.0.right/0.23.1792.1097@0.23.1792.1097" timestamp="1599753977842" />
264
269
  <state width="1750" height="383" key="GridCell.Tab.0.right/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597945008183" />
265
- <state width="1678" height="366" key="GridCell.Tab.0.right/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599567565614" />
270
+ <state width="1678" height="263" key="GridCell.Tab.0.right/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599741473452" />
266
271
  <state width="1276" height="270" key="GridCell.Tab.0.right/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599230158300" />
267
- <state width="918" height="257" key="GridCell.Tab.0.right/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599641656861" />
272
+ <state width="1878" height="183" key="GridCell.Tab.0.right/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599814597572" />
268
273
  <state x="2340" y="-140" key="IDE.errors.dialog" timestamp="1599637300780">
269
274
  <screen x="1792" y="-410" width="1920" height="1057" />
270
275
  </state>
@@ -294,27 +299,27 @@
294
299
  <screen x="0" y="23" width="1792" height="1097" />
295
300
  </state>
296
301
  <state x="428" y="230" key="com.intellij.openapi.vcs.changes.SpecificFilesViewDialog/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596103115204" />
297
- <state x="558" y="310" width="1234" height="580" key="find.popup" timestamp="1599469543819">
298
- <screen x="0" y="23" width="1792" height="1097" />
302
+ <state x="2390" y="-133" width="1322" height="582" key="find.popup" timestamp="1599811241735">
303
+ <screen x="1792" y="-410" width="1920" height="1057" />
299
304
  </state>
300
305
  <state x="559" y="310" width="1233" height="522" key="find.popup/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596116959250" />
301
306
  <state x="559" y="310" width="1233" height="522" key="find.popup/0.23.1792.1097@0.23.1792.1097" timestamp="1596191045450" />
302
307
  <state x="558" y="310" width="1234" height="580" key="find.popup/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597748403272" />
303
- <state x="2863" y="176" width="2369" height="738" key="find.popup/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599137555658" />
308
+ <state x="2491" y="140" width="2369" height="738" key="find.popup/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599749408344" />
304
309
  <state x="558" y="310" width="1234" height="580" key="find.popup/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599469543819" />
305
- <state x="2390" y="-133" width="1322" height="582" key="find.popup/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599038215964" />
310
+ <state x="2390" y="-133" width="1322" height="582" key="find.popup/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599811241735" />
306
311
  <state x="2477" y="-143" key="refactoring.ChangeSignatureDialog" timestamp="1599040674381">
307
312
  <screen x="1792" y="-410" width="1920" height="1057" />
308
313
  </state>
309
314
  <state x="2477" y="-143" key="refactoring.ChangeSignatureDialog/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599040674381" />
310
- <state x="2178" y="-174" width="718" height="652" key="search.everywhere.popup" timestamp="1599645055979">
315
+ <state x="2178" y="-174" width="718" height="652" key="search.everywhere.popup" timestamp="1599814957048">
311
316
  <screen x="1792" y="-410" width="1920" height="1057" />
312
317
  </state>
313
318
  <state x="360" y="268" width="670" height="676" key="search.everywhere.popup/-1920.-66.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1596101738778" />
314
319
  <state x="360" y="268" width="670" height="676" key="search.everywhere.popup/0.23.1792.1097@0.23.1792.1097" timestamp="1596191050648" />
315
320
  <state x="360" y="268" width="671" height="677" key="search.everywhere.popup/1792.-195.3440.1417/0.23.1792.1097@0.23.1792.1097" timestamp="1597748285464" />
316
- <state x="2484" y="121" width="1287" height="875" key="search.everywhere.popup/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599560052196" />
321
+ <state x="2484" y="121" width="1287" height="875" key="search.everywhere.popup/1792.-195.3440.1417/0.23.1792.1097@1792.-195.3440.1417" timestamp="1599744384312" />
317
322
  <state x="360" y="268" width="671" height="677" key="search.everywhere.popup/1792.-410.1920.1057/0.23.1792.1097@0.23.1792.1097" timestamp="1599216348282" />
318
- <state x="2178" y="-174" width="718" height="652" key="search.everywhere.popup/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599645055979" />
323
+ <state x="2178" y="-174" width="718" height="652" key="search.everywhere.popup/1792.-410.1920.1057/0.23.1792.1097@1792.-410.1920.1057" timestamp="1599814957048" />
319
324
  </component>
320
325
  </project>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hedia/recommendation-screen",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Hedia Recommendation Screen for Bolus and Carbohydrates",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,10 +16,7 @@ class InvisibleNumberInput extends react_1.default.Component {
16
16
  const round = (value) => {
17
17
  const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
18
18
  const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
19
- if (this.props.negativeAllowed) {
20
- return rounded.toFixed(this.props.decimalPlaces);
21
- }
22
- return Math.abs(rounded).toFixed(this.props.decimalPlaces);
19
+ return rounded.toFixed(this.props.decimalPlaces);
23
20
  };
24
21
  if (!isNaN(Number(replaced))) {
25
22
  return round(replaced);
@@ -28,11 +25,14 @@ class InvisibleNumberInput extends react_1.default.Component {
28
25
  };
29
26
  this.handleOnChangeText = (text) => {
30
27
  const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
31
- const replacedSeperator = cleaned.replace(/\.+/g, `.`);
28
+ let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
29
+ if (!this.props.negativeAllowed) {
30
+ replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
31
+ }
32
32
  this.setState({
33
- value: `${replacedSeperator}`,
33
+ value: `${replacedSeparator}`,
34
34
  });
35
- this.props.partialInput?.(`${replacedSeperator}`);
35
+ this.props.partialInput?.(`${replacedSeparator}`);
36
36
  };
37
37
  this.onEndEdit = () => {
38
38
  const cleaned = this.cleanInput(this.state.value);
@@ -40,10 +40,7 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
40
40
  const round = (value: string): string => {
41
41
  const temp = Number(value) * Math.pow(10, this.props.decimalPlaces);
42
42
  const rounded = Math.round(temp) / Math.pow(10, this.props.decimalPlaces);
43
- if (this.props.negativeAllowed) {
44
- return rounded.toFixed(this.props.decimalPlaces);
45
- }
46
- return Math.abs(rounded).toFixed(this.props.decimalPlaces);
43
+ return rounded.toFixed(this.props.decimalPlaces);
47
44
  };
48
45
  if (!isNaN(Number(replaced))) {
49
46
  return round(replaced);
@@ -53,11 +50,14 @@ export default class InvisibleNumberInput extends React.Component<IProps, IState
53
50
 
54
51
  public handleOnChangeText = (text: string): void => {
55
52
  const cleaned = this.props.cleanPartialInput ? this.cleanInput(text) : text.replace(/\,/g, `.`);
56
- const replacedSeperator = cleaned.replace(/\.+/g, `.`);
53
+ let replacedSeparator = cleaned.replace(/\.+/g, `.`).replace(/(\d*\.\d*).*/, `$1`);
54
+ if (!this.props.negativeAllowed) {
55
+ replacedSeparator = replacedSeparator.replace(/[^0-9.]/g, ``);
56
+ }
57
57
  this.setState({
58
- value: `${replacedSeperator}`,
58
+ value: `${replacedSeparator}`,
59
59
  });
60
- this.props.partialInput?.(`${replacedSeperator}`);
60
+ this.props.partialInput?.(`${replacedSeparator}`);
61
61
  };
62
62
 
63
63
  public onEndEdit = (): void => {
@@ -30,9 +30,10 @@ class RecommendedInsulin extends react_1.default.Component {
30
30
  this.handleUpdatedInsulin = (value) => {
31
31
  const rounded = Utils_1.Utils.roundValue(value, this.props.injectionMethod);
32
32
  // https://hedia.atlassian.net/browse/HDA-795
33
- const limited = (1 - this.props.activityReduction) * recommendation_calculator_1.SAFETY_INSULIN_LIMIT;
33
+ const limited = (1 - (this.props.activityReduction ?? 0)) * recommendation_calculator_1.SAFETY_INSULIN_LIMIT;
34
34
  if (rounded > limited) {
35
- this.updatePartially(`${limited}`);
35
+ this.setState({ partialInput: this.props.insulinRecommendation?.toString() });
36
+ this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
36
37
  return react_native_1.Alert.alert(i18nUtils_1.i18n._(`Attention`), AttentionMessages_1.Messages.InsulinInputWasLimited(this.props.activityReduction), [
37
38
  {
38
39
  text: i18nUtils_1.i18n._(`OK`),
@@ -61,17 +61,17 @@ export default class RecommendedInsulin extends React.Component<IProps, IState>
61
61
  const rounded = Utils.roundValue(value, this.props.injectionMethod);
62
62
 
63
63
  // https://hedia.atlassian.net/browse/HDA-795
64
- const limited = (1 - this.props.activityReduction) * SAFETY_INSULIN_LIMIT;
64
+ const limited = (1 - (this.props.activityReduction ?? 0)) * SAFETY_INSULIN_LIMIT;
65
65
 
66
66
  if (rounded > limited) {
67
- this.updatePartially(`${limited}`);
67
+ this.setState({ partialInput: this.props.insulinRecommendation?.toString() });
68
+ this.props.updateRecommendedInsulin(this.props.insulinRecommendation);
68
69
  return Alert.alert(i18n._(`Attention`), Messages.InsulinInputWasLimited(this.props.activityReduction), [
69
70
  {
70
71
  text: i18n._(`OK`),
71
72
  },
72
73
  ]);
73
74
  }
74
-
75
75
  this.updatePartially(`${rounded}`);
76
76
  this.props.updateRecommendedInsulin(rounded);
77
77
  };