@eturnity/eturnity_reusable_components 8.19.8-EPDM-6306.2 → 8.19.8-EPDM-12618.6

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": "@eturnity/eturnity_reusable_components",
3
- "version": "8.19.8-EPDM-6306.2",
3
+ "version": "8.19.8-EPDM-12618.6",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -61,7 +61,7 @@
61
61
  :show-linear-unit-name="showLinearUnitName"
62
62
  :slot-size="slotSize"
63
63
  :text-align="textAlign"
64
- :value="formattedValue"
64
+ :value="formatWithCurrency(value)"
65
65
  @blur="onInputBlur($event)"
66
66
  @focus="focusInput()"
67
67
  @input="onInput($event)"
@@ -75,7 +75,7 @@
75
75
 
76
76
  <UnitContainer
77
77
  v-if="unitName && showLinearUnitName && !hasSlot"
78
- :has-length="hasLength"
78
+ :has-length="!!textInput.length"
79
79
  :is-error="isError"
80
80
  >{{ unitName }}</UnitContainer
81
81
  >
@@ -92,7 +92,7 @@
92
92
  :disabled="isSelectDisabled"
93
93
  :select-width="`${selectWidth}px`"
94
94
  :show-border="false"
95
- @input-change="handleSelectChange"
95
+ @input-change="$emit('select-change', $event)"
96
96
  >
97
97
  <template #selector>
98
98
  <SelectText>{{ getSelectValue }}</SelectText>
@@ -457,18 +457,8 @@
457
457
  background-color: ${({ theme }) => theme.colors.grey4};
458
458
  `
459
459
 
460
- const EVENT_TYPES = {
461
- INPUT_FOCUS: 'input-focus',
462
- INPUT_CHANGE: 'input-change',
463
- INPUT_BLUR: 'input-blur',
464
- PRESS_ENTER: 'on-enter-click',
465
- INPUT_DRAG: 'on-input-drag',
466
- SELECT_CHANGE: 'select-change',
467
- }
468
-
469
460
  export default {
470
461
  name: 'InputNumber',
471
- emits: [...Object.values(EVENT_TYPES)],
472
462
  components: {
473
463
  Container,
474
464
  InputContainer,
@@ -712,10 +702,9 @@
712
702
  },
713
703
  data() {
714
704
  return {
705
+ textInput: '',
715
706
  isFocused: false,
716
707
  warningIcon: warningIcon,
717
- inputValue: null,
718
- enteredValue: null,
719
708
  }
720
709
  },
721
710
  computed: {
@@ -738,14 +727,6 @@
738
727
 
739
728
  return item ? item.label : '-'
740
729
  },
741
- formattedValue() {
742
- return this.isFocused
743
- ? this.enteredValue
744
- : this.formatWithCurrency(this.value)
745
- },
746
- hasLength() {
747
- return this.formattedValue !== null && this.formattedValue.length > 0
748
- },
749
730
  },
750
731
  watch: {
751
732
  focus(value) {
@@ -756,19 +737,30 @@
756
737
  clearInput: function (value) {
757
738
  if (value) {
758
739
  // If the value is typed, then we should clear the textInput on Continue
759
- this.inputValue = ''
760
- this.enteredValue = ''
740
+ this.textInput = ''
761
741
  }
762
742
  },
763
- value: {
764
- immediate: true,
765
- handler(val) {
766
- if (this.value !== this.inputValue && !Number.isNaN(this.value)) {
767
- this.inputValue = this.value
768
- this.enteredValue = Number(this.value.toFixed(this.numberPrecision))
769
- }
770
- },
771
- },
743
+ },
744
+ created() {
745
+ if (this.value) {
746
+ this.textInput = numberToString({
747
+ value: this.value,
748
+ numberPrecision: this.numberPrecision,
749
+ minDecimals: this.minDecimals,
750
+ })
751
+ } else if (this.defaultNumber !== null) {
752
+ this.textInput = numberToString({
753
+ value: this.defaultNumber,
754
+ numberPrecision: this.numberPrecision,
755
+ minDecimals: this.minDecimals,
756
+ })
757
+ } else if (this.minNumber !== null) {
758
+ this.textInput = numberToString({
759
+ value: this.minNumber,
760
+ numberPrecision: this.numberPrecision,
761
+ minDecimals: this.minDecimals,
762
+ })
763
+ }
772
764
  },
773
765
  mounted() {
774
766
  if (this.focus) {
@@ -807,31 +799,32 @@
807
799
  }
808
800
  },
809
801
  onEnterPress() {
810
- this.$emit(EVENT_TYPES.PRESS_ENTER)
802
+ this.$emit('on-enter-click')
811
803
  this.$refs.inputField1.$el.blur()
812
804
  },
813
- onChangeHandler(value) {
814
- if (isNaN(value) || value === '') {
815
- value = this.defaultNumber
805
+ onChangeHandler(event) {
806
+ if (isNaN(event) || event === '') {
807
+ event = this.defaultNumber
816
808
  ? this.defaultNumber
817
809
  : this.minNumber || this.minNumber === 0
818
810
  ? this.minNumber
819
- : value
811
+ : event
820
812
  }
821
813
  if (!this.allowNegative) {
822
- value = Math.abs(value)
814
+ event = Math.abs(event)
823
815
  }
824
- if (this.minNumber && this.minNumber > value) {
825
- value = this.minNumber
816
+ if (this.minNumber && this.minNumber > event) {
817
+ event = this.minNumber
826
818
  }
819
+ event = parseFloat(event)
827
820
  // Need to return an integer rather than a string
828
- value = parseFloat(value)
829
- return value
821
+ this.$emit('input-change', event)
830
822
  },
831
- onEvaluateCode(value) {
823
+ onEvaluateCode(event) {
832
824
  // function to perform math on the code
833
825
  // filter the string in case of any malicious content
834
- let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
826
+ const val = event.target.value
827
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
835
828
  filtered = filtered.split(/([-+*/()])/)
836
829
  let formatted = filtered.map((item) => {
837
830
  if (
@@ -889,32 +882,48 @@
889
882
  return array
890
883
  },
891
884
  onInput(event) {
892
- console.log('onInput', event.target.value)
893
- this.enteredValue = event.target.value
894
- if (!this.isFocused || this.enteredValue === this.inputValue) {
885
+ if (!this.isFocused) {
895
886
  return
896
887
  }
888
+ if (event.target.value === '') {
889
+ this.$emit('on-input', '')
890
+ }
897
891
  let evaluatedVal
898
892
  try {
899
- evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
893
+ evaluatedVal = this.onEvaluateCode(event)
900
894
  } finally {
901
- this.inputValue = this.onChangeHandler(evaluatedVal)
902
-
903
- if (this.isFocused && typeof this.enteredValue !== 'number') {
904
- this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
895
+ if (evaluatedVal && this.value != evaluatedVal) {
896
+ this.$emit('on-input', evaluatedVal)
905
897
  }
906
898
  }
907
899
  this.textInput = evaluatedVal
908
900
  },
909
901
  onInputBlur(e) {
910
902
  this.isFocused = false
911
- if (!Number.isNaN(this.inputValue)) {
912
- this.enteredValue = this.inputValue
903
+ let value = e.target.value
904
+ let evaluatedInput = this.onEvaluateCode(e)
905
+ this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
906
+ if ((evaluatedInput && value.length) || this.minNumber !== null) {
907
+ this.textInput = numberToString({
908
+ value:
909
+ evaluatedInput && value.length
910
+ ? evaluatedInput
911
+ : this.defaultNumber
912
+ ? this.defaultNumber
913
+ : this.minNumber,
914
+ numberPrecision: this.numberPrecision,
915
+ minDecimals: this.minDecimals,
916
+ })
913
917
  }
914
- this.$emit(
915
- EVENT_TYPES.INPUT_BLUR,
916
- Number(this.onEvaluateCode(String(this.inputValue)))
917
- )
918
+ let adjustedMinValue =
919
+ evaluatedInput && evaluatedInput.length
920
+ ? evaluatedInput
921
+ : this.defaultNumber
922
+ ? this.defaultNumber
923
+ : this.minNumber || this.minNumber === 0
924
+ ? this.minNumber
925
+ : ''
926
+ this.$emit('input-blur', adjustedMinValue)
918
927
  },
919
928
  focusInput() {
920
929
  if (this.disabled) {
@@ -924,7 +933,7 @@
924
933
  this.$nextTick(() => {
925
934
  this.$refs.inputField1.$el.select()
926
935
  })
927
- this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
936
+ this.$emit('input-focus')
928
937
  },
929
938
  blurInput() {
930
939
  if (this.disabled) {
@@ -944,7 +953,7 @@
944
953
  : this.minNumber || this.minNumber === 0
945
954
  ? this.minNumber
946
955
  : ''
947
- if (adjustedMinValue || adjustedMinValue === 0) {
956
+ if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
948
957
  let input = this.numberToStringEnabled
949
958
  ? numberToString({
950
959
  value: adjustedMinValue,
@@ -957,8 +966,6 @@
957
966
  return input + ' ' + unit
958
967
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
959
968
  return ''
960
- } else if (this.isFocused) {
961
- return value
962
969
  } else {
963
970
  return this.numberToStringEnabled
964
971
  ? numberToString({
@@ -979,7 +986,14 @@
979
986
  e.preventDefault()
980
987
  let value = parseFloat(this.value || 0)
981
988
  value += parseFloat(this.interactionStep) * parseInt(e.movementX)
982
- this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
989
+ this.$emit('on-input-drag', value)
990
+
991
+ this.textInput = numberToString({
992
+ value: value && value.length ? value : this.minNumber,
993
+ numberPrecision: this.numberPrecision,
994
+ minDecimals: this.minDecimals,
995
+ })
996
+ //this.value=value
983
997
  },
984
998
  stopInteract(e) {
985
999
  e.preventDefault()
@@ -987,9 +1001,6 @@
987
1001
  window.removeEventListener('mouseup', this.stopInteract, false)
988
1002
  this.blurInput()
989
1003
  },
990
- handleSelectChange(value) {
991
- this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
992
- },
993
1004
  },
994
1005
  }
995
1006
  </script>
@@ -179,9 +179,7 @@
179
179
  position: relative;
180
180
  font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
181
181
  color: ${(props) =>
182
- props.isError
183
- ? props.theme.colors.grey6
184
- : props.isDisabled
182
+ props.isDisabled
185
183
  ? props.theme.colors.grey2
186
184
  : props.fontColor
187
185
  ? props.fontColor + ' !important'
@@ -78,10 +78,13 @@
78
78
  v-else
79
79
  class="inputField"
80
80
  :disabled="customInputDisabled"
81
+ :error-message="item.errorMessage"
81
82
  :font-color="showArchived ? theme.colors.red : 'black'"
83
+ :is-error="item.isError"
82
84
  :min-width="item.value.length + 'ch'"
83
85
  :no-border="true"
84
86
  :value="item.value"
87
+ @input-blur="onCustomInputChange($event.trim())"
85
88
  @input-change="onCustomInputChange($event)"
86
89
  />
87
90
  </InputContainer>
@@ -162,7 +165,7 @@
162
165
  </OptionsItem>
163
166
  </OptionsWrapper>
164
167
  <CustomContainer
165
- v-if="inputText.length && allowFreeInputs"
168
+ v-if="getCustomName.length && allowFreeInputs"
166
169
  @click="onCustomNameClick()"
167
170
  >
168
171
  <CustomName>{{ getCustomName }}</CustomName>
@@ -226,7 +229,6 @@
226
229
  const ItemAttrs = { isNested: Boolean, showArchived: Boolean }
227
230
  const ComponentItem = styled('td', ItemAttrs)`
228
231
  padding-left: ${(props) => (props.isNested ? '14px !important' : '0')};
229
- overflow: hidden;
230
232
  text-overflow: ellipsis;
231
233
  padding-right: 0 !important;
232
234
  color: ${(props) =>
@@ -558,7 +560,7 @@
558
560
  },
559
561
  computed: {
560
562
  getCustomName() {
561
- return this.inputText
563
+ return this.inputText.trim()
562
564
  },
563
565
  theme() {
564
566
  return theme
@@ -652,7 +654,7 @@
652
654
  },
653
655
  onCustomNameClick() {
654
656
  this.wasClicked = true
655
- this.$emit('on-custom-input-name', this.inputText)
657
+ this.$emit('on-custom-input-name', this.getCustomName)
656
658
  this.$emit('toggle-dropdown-open', { close: true })
657
659
  this.inputText = ''
658
660
  },
@@ -94,7 +94,7 @@ export const stringToNumber = ({
94
94
 
95
95
  export const numberToString = ({ value, numberPrecision, minDecimals }) => {
96
96
  const minimumRounding = minDecimals ? minDecimals : 0
97
- value = !Number.isNaN(parseFloat(value)) ? parseFloat(value) : 0
97
+ value = parseFloat(value)
98
98
  return value.toLocaleString(langForLocaleString(), {
99
99
  minimumFractionDigits: minimumRounding, // removing this for now. Why do we need this to be a minimum amount?
100
100
  maximumFractionDigits: