@eturnity/eturnity_reusable_components 8.16.9-SLD.1 → 8.16.9-qa-16-03-26.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "8.16.9-SLD.1",
3
+ "version": "8.16.9-qa-16-03-26.0",
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="formatWithCurrency(value)"
64
+ :value="formattedValue"
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="!!textInput.length"
78
+ :has-length="hasLength"
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="$emit('select-change', $event)"
95
+ @input-change="handleSelectChange"
96
96
  >
97
97
  <template #selector>
98
98
  <SelectText>{{ getSelectValue }}</SelectText>
@@ -457,8 +457,18 @@
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
+
460
469
  export default {
461
470
  name: 'InputNumber',
471
+ emits: [...Object.values(EVENT_TYPES)],
462
472
  components: {
463
473
  Container,
464
474
  InputContainer,
@@ -701,9 +711,10 @@
701
711
  },
702
712
  data() {
703
713
  return {
704
- textInput: '',
705
714
  isFocused: false,
706
715
  warningIcon: warningIcon,
716
+ inputValue: null,
717
+ enteredValue: null,
707
718
  }
708
719
  },
709
720
  computed: {
@@ -726,6 +737,14 @@
726
737
 
727
738
  return item ? item.label : '-'
728
739
  },
740
+ formattedValue() {
741
+ return this.isFocused
742
+ ? this.enteredValue
743
+ : this.formatWithCurrency(this.value)
744
+ },
745
+ hasLength() {
746
+ return this.formattedValue !== null && this.formattedValue.length > 0
747
+ },
729
748
  },
730
749
  watch: {
731
750
  focus(value) {
@@ -736,30 +755,19 @@
736
755
  clearInput: function (value) {
737
756
  if (value) {
738
757
  // If the value is typed, then we should clear the textInput on Continue
739
- this.textInput = ''
758
+ this.inputValue = ''
759
+ this.enteredValue = ''
740
760
  }
741
761
  },
742
- },
743
- created() {
744
- if (this.value) {
745
- this.textInput = numberToString({
746
- value: this.value,
747
- numberPrecision: this.numberPrecision,
748
- minDecimals: this.minDecimals,
749
- })
750
- } else if (this.defaultNumber !== null) {
751
- this.textInput = numberToString({
752
- value: this.defaultNumber,
753
- numberPrecision: this.numberPrecision,
754
- minDecimals: this.minDecimals,
755
- })
756
- } else if (this.minNumber !== null) {
757
- this.textInput = numberToString({
758
- value: this.minNumber,
759
- numberPrecision: this.numberPrecision,
760
- minDecimals: this.minDecimals,
761
- })
762
- }
762
+ value: {
763
+ immediate: true,
764
+ handler(val) {
765
+ if (this.value !== this.inputValue && !Number.isNaN(this.value)) {
766
+ this.inputValue = this.value
767
+ this.enteredValue = Number(this.value.toFixed(this.numberPrecision))
768
+ }
769
+ },
770
+ },
763
771
  },
764
772
  mounted() {
765
773
  if (this.focus) {
@@ -798,32 +806,28 @@
798
806
  }
799
807
  },
800
808
  onEnterPress() {
801
- this.$emit('on-enter-click')
809
+ this.$emit(EVENT_TYPES.PRESS_ENTER)
802
810
  this.$refs.inputField1.$el.blur()
803
811
  },
804
- onChangeHandler(event) {
805
- if (isNaN(event) || event === '') {
806
- event = this.defaultNumber
812
+ onChangeHandler(value) {
813
+ if (isNaN(value) || value === '') {
814
+ value = this.defaultNumber
807
815
  ? this.defaultNumber
808
816
  : this.minNumber || this.minNumber === 0
809
817
  ? this.minNumber
810
- : event
818
+ : value
811
819
  }
812
820
  if (!this.allowNegative) {
813
- event = Math.abs(event)
821
+ value = Math.abs(value)
814
822
  }
815
- if (this.minNumber && this.minNumber > event) {
816
- event = this.minNumber
817
- }
818
- event = parseFloat(event)
823
+ value = parseFloat(value)
819
824
  // Need to return an integer rather than a string
820
- this.$emit('input-change', event)
825
+ return parseFloat(value)
821
826
  },
822
- onEvaluateCode(event) {
827
+ onEvaluateCode(value) {
823
828
  // function to perform math on the code
824
829
  // filter the string in case of any malicious content
825
- const val = event.target.value
826
- let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
830
+ let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
827
831
  filtered = filtered.split(/([-+*/()])/)
828
832
  let formatted = filtered.map((item) => {
829
833
  if (
@@ -881,48 +885,32 @@
881
885
  return array
882
886
  },
883
887
  onInput(event) {
884
- if (!this.isFocused) {
888
+ console.log('onInput', event.target.value)
889
+ this.enteredValue = event.target.value
890
+ if (!this.isFocused || this.enteredValue === this.inputValue) {
885
891
  return
886
892
  }
887
- if (event.target.value === '') {
888
- this.$emit('on-input', '')
889
- }
890
893
  let evaluatedVal
891
894
  try {
892
- evaluatedVal = this.onEvaluateCode(event)
895
+ evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
893
896
  } finally {
894
- if (evaluatedVal && this.value != evaluatedVal) {
895
- this.$emit('on-input', evaluatedVal)
897
+ this.inputValue = this.onChangeHandler(evaluatedVal)
898
+
899
+ if (this.isFocused && typeof this.enteredValue !== 'number') {
900
+ this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
896
901
  }
897
902
  }
898
903
  this.textInput = evaluatedVal
899
904
  },
900
905
  onInputBlur(e) {
901
906
  this.isFocused = false
902
- let value = e.target.value
903
- let evaluatedInput = this.onEvaluateCode(e)
904
- this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
905
- if ((evaluatedInput && value.length) || this.minNumber !== null) {
906
- this.textInput = numberToString({
907
- value:
908
- evaluatedInput && value.length
909
- ? evaluatedInput
910
- : this.defaultNumber
911
- ? this.defaultNumber
912
- : this.minNumber,
913
- numberPrecision: this.numberPrecision,
914
- minDecimals: this.minDecimals,
915
- })
907
+ if (!Number.isNaN(this.inputValue)) {
908
+ this.enteredValue = this.inputValue
916
909
  }
917
- let adjustedMinValue =
918
- evaluatedInput && evaluatedInput.length
919
- ? evaluatedInput
920
- : this.defaultNumber
921
- ? this.defaultNumber
922
- : this.minNumber || this.minNumber === 0
923
- ? this.minNumber
924
- : ''
925
- this.$emit('input-blur', adjustedMinValue)
910
+ this.$emit(
911
+ EVENT_TYPES.INPUT_BLUR,
912
+ Number(this.onEvaluateCode(String(this.inputValue)))
913
+ )
926
914
  },
927
915
  focusInput() {
928
916
  if (this.disabled) {
@@ -932,7 +920,7 @@
932
920
  this.$nextTick(() => {
933
921
  this.$refs.inputField1.$el.select()
934
922
  })
935
- this.$emit('input-focus')
923
+ this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
936
924
  },
937
925
  blurInput() {
938
926
  if (this.disabled) {
@@ -952,7 +940,7 @@
952
940
  : this.minNumber || this.minNumber === 0
953
941
  ? this.minNumber
954
942
  : ''
955
- if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
943
+ if (adjustedMinValue || adjustedMinValue === 0) {
956
944
  let input = this.numberToStringEnabled
957
945
  ? numberToString({
958
946
  value: adjustedMinValue,
@@ -965,6 +953,8 @@
965
953
  return input + ' ' + unit
966
954
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
967
955
  return ''
956
+ } else if (this.isFocused) {
957
+ return value
968
958
  } else {
969
959
  return this.numberToStringEnabled
970
960
  ? numberToString({
@@ -985,14 +975,7 @@
985
975
  e.preventDefault()
986
976
  let value = parseFloat(this.value || 0)
987
977
  value += parseFloat(this.interactionStep) * parseInt(e.movementX)
988
- this.$emit('on-input-drag', value)
989
-
990
- this.textInput = numberToString({
991
- value: value && value.length ? value : this.minNumber,
992
- numberPrecision: this.numberPrecision,
993
- minDecimals: this.minDecimals,
994
- })
995
- //this.value=value
978
+ this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
996
979
  },
997
980
  stopInteract(e) {
998
981
  e.preventDefault()
@@ -1000,6 +983,9 @@
1000
983
  window.removeEventListener('mouseup', this.stopInteract, false)
1001
984
  this.blurInput()
1002
985
  },
986
+ handleSelectChange(value) {
987
+ this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
988
+ },
1003
989
  },
1004
990
  }
1005
991
  </script>
@@ -2,19 +2,18 @@
2
2
  <OptionContainer
3
3
  :background-color="
4
4
  colorMode == 'dark'
5
- ? theme.semanticColors.teal[900]
5
+ ? '#000000'
6
6
  : colorMode == 'transparent'
7
7
  ? 'black'
8
8
  : backgroundColor
9
9
  "
10
- :color-mode="colorMode"
11
10
  :cursor-type="cursorType"
12
11
  :data-value="value"
13
12
  :disabled-bg-color="disabledBgColor"
14
13
  :disabled-text-color="disabledTextColor"
15
14
  :hovered-bg-color="
16
15
  colorMode == 'dark'
17
- ? theme.semanticColors.teal[800]
16
+ ? '#000000'
18
17
  : colorMode == 'transparent'
19
18
  ? 'grey6'
20
19
  : hoveredBgColor
@@ -37,7 +36,6 @@
37
36
  // import selectButton from './selectButton'
38
37
  // import selectDropdown from './selectDropDown'
39
38
  import styled from 'vue3-styled-components'
40
- import theme from '@/assets/theme'
41
39
  const optionProps = {
42
40
  isDisabled: Boolean,
43
41
  hoveredBgColor: String,
@@ -48,7 +46,6 @@
48
46
  disabledTextColor: String,
49
47
  padding: String,
50
48
  textColor: String,
51
- colorMode: String,
52
49
  }
53
50
  const OptionContainer = styled('div', optionProps)`
54
51
  display: flex;
@@ -80,8 +77,6 @@
80
77
  ? props.theme.colors[props.disabledTextColor]
81
78
  : props.disabledTextColor
82
79
  : props.theme.colors.grey3
83
- : props.colorMode == 'dark'
84
- ? props.theme.colors['white']
85
80
  : props.theme.colors[props.textColor]
86
81
  ? props.theme.colors[props.textColor]
87
82
  : props.textColor};
@@ -150,9 +145,7 @@
150
145
  },
151
146
  emits: ['option-hovered', 'option-selected'],
152
147
  data() {
153
- return {
154
- theme,
155
- }
148
+ return {}
156
149
  },
157
150
  computed: {},
158
151
  methods: {
@@ -33,18 +33,8 @@
33
33
  :is-active="selectedValue == item.value"
34
34
  :primary-color="primaryColor"
35
35
  :secondary-color="secondaryColor"
36
- :size="size"
37
36
  @click="selectItem(item.value)"
38
37
  >
39
- <OptionIconContainer v-if="item.icon">
40
- <RCIcon
41
- :color="
42
- selectedValue == item.value ? primaryColor : secondaryColor
43
- "
44
- :name="item.icon"
45
- :size="item.iconSize"
46
- />
47
- </OptionIconContainer>
48
38
  {{ item.content }}
49
39
  </SwitchOption>
50
40
  </SwitchWrapper>
@@ -80,12 +70,6 @@
80
70
  import styled from 'vue3-styled-components'
81
71
  import InfoText from '../../infoText'
82
72
  import theme from '../../../assets/theme'
83
- import RCIcon from '../../icon'
84
- const OptionIconContainer = styled.div`
85
- display: flex;
86
- align-items: center;
87
- margin-right: 5px;
88
- `
89
73
  const Container = styled.div``
90
74
 
91
75
  const flexAttrs = {
@@ -105,6 +89,7 @@
105
89
  `
106
90
 
107
91
  const toggleAttrs = {
92
+ size: String,
108
93
  fontColor: String,
109
94
  disabled: Boolean,
110
95
  backgroundColor: String,
@@ -120,16 +105,20 @@
120
105
 
121
106
  const SwitchWrapper = styled('span', toggleAttrs)`
122
107
  display: flex;
123
- align-items: center
124
108
  position: relative;
125
109
  cursor: ${(props) => (props.disabled ? 'not-allowed' : 'pointer')};
110
+ height: ${(props) =>
111
+ props.size === 'medium'
112
+ ? '24px'
113
+ : props.size === 'small'
114
+ ? '16px'
115
+ : '24px'};
126
116
  `
127
117
  const optionAttrs = {
128
118
  isActive: Boolean,
129
119
  primaryColor: String,
130
120
  secondaryColor: String,
131
121
  inactiveColor: String,
132
- size: String,
133
122
  }
134
123
  const SwitchOption = styled('div', optionAttrs)`
135
124
  color: ${(props) =>
@@ -146,13 +135,7 @@
146
135
  font-size: 13px;
147
136
  line-height: 1;
148
137
  text-align: center;
149
- height: ${(props) =>
150
- props.size === 'medium'
151
- ? '24px'
152
- : props.size === 'small'
153
- ? '16px'
154
- : '24px'};
155
- padding: 0 10px;
138
+ padding: 10px;
156
139
  margin-right: -1px;
157
140
  transition: all 0.1s ease-in-out;
158
141
  overflow: hidden;
@@ -186,8 +169,6 @@
186
169
  InfoText,
187
170
  LabelContainer,
188
171
  SwitchOption,
189
- OptionIconContainer,
190
- RCIcon,
191
172
  },
192
173
  props: {
193
174
  label: {
@@ -124,7 +124,6 @@
124
124
  : props.size === 'small'
125
125
  ? '13px'
126
126
  : '16px'};
127
- font-weight: 700;
128
127
  `
129
128
 
130
129
  const ToggleWrapper = styled('span', toggleAttrs)`
@@ -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 = parseFloat(value)
97
+ value = !Number.isNaN(parseFloat(value)) ? parseFloat(value) : 0
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:
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
- <path d="M5 5.75C5 5.33579 5.33579 5 5.75 5H18.25C18.6642 5 19 5.33579 19 5.75C19 6.16421 18.6642 6.5 18.25 6.5H5.75C5.33579 6.5 5 6.16421 5 5.75Z" fill="white"/>
4
- <path d="M5 9.75C5 9.33579 5.33579 9 5.75 9H18.25C18.6642 9 19 9.33579 19 9.75C19 10.1642 18.6642 10.5 18.25 10.5H5.75C5.33579 10.5 5 10.1642 5 9.75Z" fill="white"/>
5
- <path d="M5 13.75C5 13.3358 5.33579 13 5.75 13H18.25C18.6642 13 19 13.3358 19 13.75C19 14.1642 18.6642 14.5 18.25 14.5H5.75C5.33579 14.5 5 14.1642 5 13.75Z" fill="white"/>
6
- <path d="M5 17.75C5 17.3358 5.33579 17 5.75 17H18.25C18.6642 17 19 17.3358 19 17.75C19 18.1642 18.6642 18.5 18.25 18.5H5.75C5.33579 18.5 5 18.1642 5 17.75Z" fill="white"/>
7
- </svg>
@@ -1,15 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
- <path d="M3 6C3 5.44772 3.44772 5 4 5H7C7.55228 5 8 5.44772 8 6C8 6.55228 7.55228 7 7 7H4C3.44772 7 3 6.55228 3 6Z" fill="#212121"/>
4
- <path d="M9.58 6C9.58 5.44772 10.0277 5 10.58 5H13.58C14.1323 5 14.58 5.44772 14.58 6C14.58 6.55228 14.1323 7 13.58 7H10.58C10.0277 7 9.58 6.55228 9.58 6Z" fill="#212121"/>
5
- <path d="M16 6C16 5.44772 16.4477 5 17 5H20C20.5523 5 21 5.44772 21 6C21 6.55228 20.5523 7 20 7H17C16.4477 7 16 6.55228 16 6Z" fill="#212121"/>
6
- <path d="M3 10C3 9.44772 3.44772 9 4 9H7C7.55228 9 8 9.44772 8 10C8 10.5523 7.55228 11 7 11H4C3.44772 11 3 10.5523 3 10Z" fill="#212121"/>
7
- <path d="M9.58 10C9.58 9.44772 10.0277 9 10.58 9H13.58C14.1323 9 14.58 9.44772 14.58 10C14.58 10.5523 14.1323 11 13.58 11H10.58C10.0277 11 9.58 10.5523 9.58 10Z" fill="#212121"/>
8
- <path d="M16 10C16 9.44772 16.4477 9 17 9H20C20.5523 9 21 9.44772 21 10C21 10.5523 20.5523 11 20 11H17C16.4477 11 16 10.5523 16 10Z" fill="#212121"/>
9
- <path d="M3 14C3 13.4477 3.44772 13 4 13H7C7.55228 13 8 13.4477 8 14C8 14.5523 7.55228 15 7 15H4C3.44772 15 3 14.5523 3 14Z" fill="#212121"/>
10
- <path d="M9.58 14C9.58 13.4477 10.0277 13 10.58 13H13.58C14.1323 13 14.58 13.4477 14.58 14C14.58 14.5523 14.1323 15 13.58 15H10.58C10.0277 15 9.58 14.5523 9.58 14Z" fill="#212121"/>
11
- <path d="M16 14C16 13.4477 16.4477 13 17 13H20C20.5523 13 21 13.4477 21 14C21 14.5523 20.5523 15 20 15H17C16.4477 15 16 14.5523 16 14Z" fill="#212121"/>
12
- <path d="M3 18C3 17.4477 3.44772 17 4 17H7C7.55228 17 8 17.4477 8 18C8 18.5523 7.55228 19 7 19H4C3.44772 19 3 18.5523 3 18Z" fill="#212121"/>
13
- <path d="M9.58 18C9.58 17.4477 10.0277 17 10.58 17H13.58C14.1323 17 14.58 17.4477 14.58 18C14.58 18.5523 14.1323 19 13.58 19H10.58C10.0277 19 9.58 18.5523 9.58 18Z" fill="#212121"/>
14
- <path d="M16 18C16 17.4477 16.4477 17 17 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H17C16.4477 19 16 18.5523 16 18Z" fill="#212121"/>
15
- </svg>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
- <path d="M3 6C3 5.44772 3.44772 5 4 5H10C10.5523 5 11 5.44772 11 6C11 6.55228 10.5523 7 10 7H4C3.44772 7 3 6.55228 3 6Z" fill="white"/>
4
- <path d="M3 10C3 9.44772 3.44772 9 4 9H10C10.5523 9 11 9.44772 11 10C11 10.5523 10.5523 11 10 11H4C3.44772 11 3 10.5523 3 10Z" fill="white"/>
5
- <path d="M3 14C3 13.4477 3.44772 13 4 13H10C10.5523 13 11 13.4477 11 14C11 14.5523 10.5523 15 10 15H4C3.44772 15 3 14.5523 3 14Z" fill="white"/>
6
- <path d="M3 18C3 17.4477 3.44772 17 4 17H10C10.5523 17 11 17.4477 11 18C11 18.5523 10.5523 19 10 19H4C3.44772 19 3 18.5523 3 18Z" fill="white"/>
7
- <path d="M13 6C13 5.44772 13.4477 5 14 5H20C20.5523 5 21 5.44772 21 6C21 6.55228 20.5523 7 20 7H14C13.4477 7 13 6.55228 13 6Z" fill="white"/>
8
- <path d="M13 10C13 9.44772 13.4477 9 14 9H20C20.5523 9 21 9.44772 21 10C21 10.5523 20.5523 11 20 11H14C13.4477 11 13 10.5523 13 10Z" fill="white"/>
9
- <path d="M13 14C13 13.4477 13.4477 13 14 13H20C20.5523 13 21 13.4477 21 14C21 14.5523 20.5523 15 20 15H14C13.4477 15 13 14.5523 13 14Z" fill="white"/>
10
- <path d="M13 18C13 17.4477 13.4477 17 14 17H20C20.5523 17 21 17.4477 21 18C21 18.5523 20.5523 19 20 19H14C13.4477 19 13 18.5523 13 18Z" fill="white"/>
11
- </svg>