@itfin/components 1.2.117 → 1.2.118

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.2.117",
3
+ "version": "1.2.118",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
 
3
3
  <itf-text-field
4
- ref="input"
5
- v-bind="$props"
6
- @input="onValueChange"
7
- @blur="onBlur"
4
+ ref="input"
5
+ v-bind="$props"
6
+ @input="onValueChange"
7
+ @blur="onBlur"
8
8
  />
9
9
 
10
10
  </template>
@@ -28,6 +28,7 @@ class itfHoursField extends Vue {
28
28
  @Prop(Boolean) clearable;
29
29
  @Prop(Boolean) disabled;
30
30
  @Prop(Boolean) readonly;
31
+ @Prop(Boolean) negative;
31
32
  @Prop({ type: [Number, String], default: 0 }) delayInput;
32
33
 
33
34
  mounted() {
@@ -36,7 +37,6 @@ class itfHoursField extends Vue {
36
37
 
37
38
  @Watch('hours')
38
39
  onHoursChanged() {
39
- console.info(formatHours(this.hours),this.hours)
40
40
  this.$emit('input', formatHours(this.hours));
41
41
  }
42
42
 
@@ -53,6 +53,7 @@ class itfHoursField extends Vue {
53
53
 
54
54
  onBlur(e) {
55
55
  const hours = parseHours(e.target.value) / 60;
56
+ console.info(hours);
56
57
  this.$emit('update:hours', hours);
57
58
  }
58
59
  }
@@ -2,15 +2,16 @@ import { DateTime } from 'luxon';
2
2
  import ITFSettings from '../ITFSettings';
3
3
 
4
4
  export function parseHours (str, { hoursInDay } = { hoursInDay: 8 }) {
5
- const source = (str || '').toString();
5
+ let source = (str || '').toString();
6
+ const isNegative = str[0] === '-' ? -1 : 1;
7
+ source = source.replace('-', '');
6
8
 
7
9
  const SECONDS_IN_MINUTE = 60;
8
10
  const MINUTES_IN_HOUR = 60;
9
-
10
11
  // try parse decimal
11
12
  const matchDecimal = source.match(/^(\d+([.,]\d+)?)$/);
12
13
  if (matchDecimal) {
13
- return Math.round(parseFloat(source.replace(',', '.')) * MINUTES_IN_HOUR * SECONDS_IN_MINUTE);
14
+ return isNegative * Math.round(parseFloat(source.replace(',', '.')) * MINUTES_IN_HOUR * SECONDS_IN_MINUTE);
14
15
  }
15
16
 
16
17
  const match = source.match(/^((\d+)d)?\s*((\d+)h)?\s*((\d+)m)?$/);
@@ -29,7 +30,7 @@ export function parseHours (str, { hoursInDay } = { hoursInDay: 8 }) {
29
30
  if (minutes) {
30
31
  seconds += Number(minutes) * SECONDS_IN_MINUTE;
31
32
  }
32
- return seconds;
33
+ return isNegative * seconds;
33
34
  }
34
35
 
35
36
  export function formatDate (date, inputFormat = 'yyyy-MM-dd', toFormat) {