@eturnity/eturnity_reusable_components 8.19.8-EPDM-13664.0 → 8.19.8-EPDM-6306.2
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
@@ -287,11 +287,6 @@
|
|
287
287
|
default: '',
|
288
288
|
required: false,
|
289
289
|
},
|
290
|
-
contentBackgroundColor: {
|
291
|
-
type: String,
|
292
|
-
default: '',
|
293
|
-
required: false,
|
294
|
-
},
|
295
290
|
borderRadius: {
|
296
291
|
type: String,
|
297
292
|
default: '',
|
@@ -471,9 +466,7 @@
|
|
471
466
|
width: '100%',
|
472
467
|
maxWidth: props.maxWidth,
|
473
468
|
overflowY: 'auto',
|
474
|
-
backgroundColor: props.
|
475
|
-
? props.contentBackgroundColor
|
476
|
-
: props.image
|
469
|
+
backgroundColor: props.image
|
477
470
|
? theme.colors.white
|
478
471
|
: props.appTheme === 'light'
|
479
472
|
? theme.colors.black
|
@@ -61,7 +61,7 @@
|
|
61
61
|
:show-linear-unit-name="showLinearUnitName"
|
62
62
|
:slot-size="slotSize"
|
63
63
|
:text-align="textAlign"
|
64
|
-
: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="
|
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="
|
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,
|
@@ -702,9 +712,10 @@
|
|
702
712
|
},
|
703
713
|
data() {
|
704
714
|
return {
|
705
|
-
textInput: '',
|
706
715
|
isFocused: false,
|
707
716
|
warningIcon: warningIcon,
|
717
|
+
inputValue: null,
|
718
|
+
enteredValue: null,
|
708
719
|
}
|
709
720
|
},
|
710
721
|
computed: {
|
@@ -727,6 +738,14 @@
|
|
727
738
|
|
728
739
|
return item ? item.label : '-'
|
729
740
|
},
|
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
|
+
},
|
730
749
|
},
|
731
750
|
watch: {
|
732
751
|
focus(value) {
|
@@ -737,30 +756,19 @@
|
|
737
756
|
clearInput: function (value) {
|
738
757
|
if (value) {
|
739
758
|
// If the value is typed, then we should clear the textInput on Continue
|
740
|
-
this.
|
759
|
+
this.inputValue = ''
|
760
|
+
this.enteredValue = ''
|
741
761
|
}
|
742
762
|
},
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
}
|
751
|
-
}
|
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
|
-
}
|
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
|
+
},
|
764
772
|
},
|
765
773
|
mounted() {
|
766
774
|
if (this.focus) {
|
@@ -799,32 +807,31 @@
|
|
799
807
|
}
|
800
808
|
},
|
801
809
|
onEnterPress() {
|
802
|
-
this.$emit(
|
810
|
+
this.$emit(EVENT_TYPES.PRESS_ENTER)
|
803
811
|
this.$refs.inputField1.$el.blur()
|
804
812
|
},
|
805
|
-
onChangeHandler(
|
806
|
-
if (isNaN(
|
807
|
-
|
813
|
+
onChangeHandler(value) {
|
814
|
+
if (isNaN(value) || value === '') {
|
815
|
+
value = this.defaultNumber
|
808
816
|
? this.defaultNumber
|
809
817
|
: this.minNumber || this.minNumber === 0
|
810
818
|
? this.minNumber
|
811
|
-
:
|
819
|
+
: value
|
812
820
|
}
|
813
821
|
if (!this.allowNegative) {
|
814
|
-
|
822
|
+
value = Math.abs(value)
|
815
823
|
}
|
816
|
-
if (this.minNumber && this.minNumber >
|
817
|
-
|
824
|
+
if (this.minNumber && this.minNumber > value) {
|
825
|
+
value = this.minNumber
|
818
826
|
}
|
819
|
-
event = parseFloat(event)
|
820
827
|
// Need to return an integer rather than a string
|
821
|
-
|
828
|
+
value = parseFloat(value)
|
829
|
+
return value
|
822
830
|
},
|
823
|
-
onEvaluateCode(
|
831
|
+
onEvaluateCode(value) {
|
824
832
|
// function to perform math on the code
|
825
833
|
// filter the string in case of any malicious content
|
826
|
-
|
827
|
-
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
834
|
+
let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
828
835
|
filtered = filtered.split(/([-+*/()])/)
|
829
836
|
let formatted = filtered.map((item) => {
|
830
837
|
if (
|
@@ -882,48 +889,32 @@
|
|
882
889
|
return array
|
883
890
|
},
|
884
891
|
onInput(event) {
|
885
|
-
|
892
|
+
console.log('onInput', event.target.value)
|
893
|
+
this.enteredValue = event.target.value
|
894
|
+
if (!this.isFocused || this.enteredValue === this.inputValue) {
|
886
895
|
return
|
887
896
|
}
|
888
|
-
if (event.target.value === '') {
|
889
|
-
this.$emit('on-input', '')
|
890
|
-
}
|
891
897
|
let evaluatedVal
|
892
898
|
try {
|
893
|
-
evaluatedVal = this.onEvaluateCode(
|
899
|
+
evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
|
894
900
|
} finally {
|
895
|
-
|
896
|
-
|
901
|
+
this.inputValue = this.onChangeHandler(evaluatedVal)
|
902
|
+
|
903
|
+
if (this.isFocused && typeof this.enteredValue !== 'number') {
|
904
|
+
this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
|
897
905
|
}
|
898
906
|
}
|
899
907
|
this.textInput = evaluatedVal
|
900
908
|
},
|
901
909
|
onInputBlur(e) {
|
902
910
|
this.isFocused = false
|
903
|
-
|
904
|
-
|
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
|
-
})
|
911
|
+
if (!Number.isNaN(this.inputValue)) {
|
912
|
+
this.enteredValue = this.inputValue
|
917
913
|
}
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
? this.defaultNumber
|
923
|
-
: this.minNumber || this.minNumber === 0
|
924
|
-
? this.minNumber
|
925
|
-
: ''
|
926
|
-
this.$emit('input-blur', adjustedMinValue)
|
914
|
+
this.$emit(
|
915
|
+
EVENT_TYPES.INPUT_BLUR,
|
916
|
+
Number(this.onEvaluateCode(String(this.inputValue)))
|
917
|
+
)
|
927
918
|
},
|
928
919
|
focusInput() {
|
929
920
|
if (this.disabled) {
|
@@ -933,7 +924,7 @@
|
|
933
924
|
this.$nextTick(() => {
|
934
925
|
this.$refs.inputField1.$el.select()
|
935
926
|
})
|
936
|
-
this.$emit(
|
927
|
+
this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
|
937
928
|
},
|
938
929
|
blurInput() {
|
939
930
|
if (this.disabled) {
|
@@ -953,7 +944,7 @@
|
|
953
944
|
: this.minNumber || this.minNumber === 0
|
954
945
|
? this.minNumber
|
955
946
|
: ''
|
956
|
-
if (
|
947
|
+
if (adjustedMinValue || adjustedMinValue === 0) {
|
957
948
|
let input = this.numberToStringEnabled
|
958
949
|
? numberToString({
|
959
950
|
value: adjustedMinValue,
|
@@ -966,6 +957,8 @@
|
|
966
957
|
return input + ' ' + unit
|
967
958
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
968
959
|
return ''
|
960
|
+
} else if (this.isFocused) {
|
961
|
+
return value
|
969
962
|
} else {
|
970
963
|
return this.numberToStringEnabled
|
971
964
|
? numberToString({
|
@@ -986,14 +979,7 @@
|
|
986
979
|
e.preventDefault()
|
987
980
|
let value = parseFloat(this.value || 0)
|
988
981
|
value += parseFloat(this.interactionStep) * parseInt(e.movementX)
|
989
|
-
this.$emit(
|
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
|
982
|
+
this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
|
997
983
|
},
|
998
984
|
stopInteract(e) {
|
999
985
|
e.preventDefault()
|
@@ -1001,6 +987,9 @@
|
|
1001
987
|
window.removeEventListener('mouseup', this.stopInteract, false)
|
1002
988
|
this.blurInput()
|
1003
989
|
},
|
990
|
+
handleSelectChange(value) {
|
991
|
+
this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
|
992
|
+
},
|
1004
993
|
},
|
1005
994
|
}
|
1006
995
|
</script>
|
@@ -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,92 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<Container>
|
3
|
-
<RCIcon :color="iconColor" :name="iconName" :size="iconSize" />
|
4
|
-
<TextWrapper>
|
5
|
-
{{ text }}
|
6
|
-
<slot></slot>
|
7
|
-
</TextWrapper>
|
8
|
-
</Container>
|
9
|
-
</template>
|
10
|
-
|
11
|
-
<script>
|
12
|
-
// import InfoText from "@eturnity/eturnity_reusable_components/src/components/infoText"
|
13
|
-
// import IconTextContent from "@eturnity/eturnity_reusable_components/src/components/infoText/templates/iconTextContent"
|
14
|
-
//To use:
|
15
|
-
// <InfoText
|
16
|
-
// icon-color="red"
|
17
|
-
// icon-name="error"
|
18
|
-
// size="20px"
|
19
|
-
// open-trigger="onClick"
|
20
|
-
// >
|
21
|
-
// <IconTextContent
|
22
|
-
// icon-name="error"
|
23
|
-
// text="Text"
|
24
|
-
// icon-size="18px"
|
25
|
-
// icon-color="red"
|
26
|
-
// />
|
27
|
-
// </InfoText>
|
28
|
-
|
29
|
-
import styled from 'vue3-styled-components'
|
30
|
-
import theme from '../../../assets/theme.js'
|
31
|
-
import RCIcon from '../../icon'
|
32
|
-
|
33
|
-
const Container = styled('div')`
|
34
|
-
display: flex;
|
35
|
-
flex-direction: row;
|
36
|
-
align-items: flex-start;
|
37
|
-
gap: 8px;
|
38
|
-
`
|
39
|
-
|
40
|
-
const TextAttrs = {
|
41
|
-
fontSize: String,
|
42
|
-
fontColor: String,
|
43
|
-
}
|
44
|
-
const TextWrapper = styled('div', TextAttrs)`
|
45
|
-
font-size: ${(props) => props.fontSize};
|
46
|
-
color: ${(props) => props.fontColor};
|
47
|
-
overflow: hidden;
|
48
|
-
display: flex;
|
49
|
-
flex-direction: column;
|
50
|
-
align-items: center;
|
51
|
-
gap: 8px;
|
52
|
-
`
|
53
|
-
|
54
|
-
export default {
|
55
|
-
name: 'IconTextContent',
|
56
|
-
components: {
|
57
|
-
Container,
|
58
|
-
TextWrapper,
|
59
|
-
RCIcon,
|
60
|
-
},
|
61
|
-
props: {
|
62
|
-
iconName: {
|
63
|
-
type: String,
|
64
|
-
required: true,
|
65
|
-
},
|
66
|
-
text: {
|
67
|
-
type: String,
|
68
|
-
required: true,
|
69
|
-
},
|
70
|
-
iconSize: {
|
71
|
-
type: String,
|
72
|
-
required: false,
|
73
|
-
default: '18px',
|
74
|
-
},
|
75
|
-
iconColor: {
|
76
|
-
type: String,
|
77
|
-
required: false,
|
78
|
-
default: '',
|
79
|
-
},
|
80
|
-
fontSize: {
|
81
|
-
type: String,
|
82
|
-
required: false,
|
83
|
-
default: '11px',
|
84
|
-
},
|
85
|
-
fontColor: {
|
86
|
-
type: String,
|
87
|
-
required: false,
|
88
|
-
default: theme.colors.white,
|
89
|
-
},
|
90
|
-
},
|
91
|
-
}
|
92
|
-
</script>
|