@eturnity/eturnity_reusable_components 8.7.5-EPDM-6306.0 → 8.7.5-EPDM-12618.3
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
@@ -59,7 +59,7 @@
|
|
59
59
|
:show-linear-unit-name="showLinearUnitName"
|
60
60
|
:slot-size="slotSize"
|
61
61
|
:text-align="textAlign"
|
62
|
-
:value="
|
62
|
+
:value="formatWithCurrency(value)"
|
63
63
|
@blur="onInputBlur($event)"
|
64
64
|
@focus="focusInput()"
|
65
65
|
@input="onInput($event)"
|
@@ -73,7 +73,7 @@
|
|
73
73
|
|
74
74
|
<UnitContainer
|
75
75
|
v-if="unitName && showLinearUnitName && !hasSlot"
|
76
|
-
:has-length="
|
76
|
+
:has-length="!!textInput.length"
|
77
77
|
:is-error="isError"
|
78
78
|
>{{ unitName }}</UnitContainer
|
79
79
|
>
|
@@ -90,7 +90,7 @@
|
|
90
90
|
:disabled="isSelectDisabled"
|
91
91
|
:select-width="`${selectWidth}px`"
|
92
92
|
:show-border="false"
|
93
|
-
@input-change="
|
93
|
+
@input-change="$emit('select-change', $event)"
|
94
94
|
>
|
95
95
|
<template #selector>
|
96
96
|
<SelectText>{{ getSelectValue }}</SelectText>
|
@@ -448,18 +448,8 @@
|
|
448
448
|
background-color: ${({ theme }) => theme.colors.grey4};
|
449
449
|
`
|
450
450
|
|
451
|
-
const EVENT_TYPES = {
|
452
|
-
INPUT_FOCUS: 'input-focus',
|
453
|
-
INPUT_CHANGE: 'input-change',
|
454
|
-
INPUT_BLUR: 'input-blur',
|
455
|
-
PRESS_ENTER: 'on-enter-click',
|
456
|
-
INPUT_DRAG: 'on-input-drag',
|
457
|
-
SELECT_CHANGE: 'select-change',
|
458
|
-
}
|
459
|
-
|
460
451
|
export default {
|
461
452
|
name: 'InputNumber',
|
462
|
-
emits: [...Object.values(EVENT_TYPES)],
|
463
453
|
components: {
|
464
454
|
Container,
|
465
455
|
InputContainer,
|
@@ -694,10 +684,9 @@
|
|
694
684
|
},
|
695
685
|
data() {
|
696
686
|
return {
|
687
|
+
textInput: '',
|
697
688
|
isFocused: false,
|
698
689
|
warningIcon: warningIcon,
|
699
|
-
inputValue: null,
|
700
|
-
enteredValue: null,
|
701
690
|
}
|
702
691
|
},
|
703
692
|
computed: {
|
@@ -720,14 +709,6 @@
|
|
720
709
|
|
721
710
|
return item ? item.label : '-'
|
722
711
|
},
|
723
|
-
formattedValue() {
|
724
|
-
return this.isFocused
|
725
|
-
? this.enteredValue
|
726
|
-
: this.formatWithCurrency(this.value)
|
727
|
-
},
|
728
|
-
hasLength() {
|
729
|
-
return this.formattedValue !== null && this.formattedValue.length > 0
|
730
|
-
},
|
731
712
|
},
|
732
713
|
watch: {
|
733
714
|
focus(value) {
|
@@ -738,19 +719,30 @@
|
|
738
719
|
clearInput: function (value) {
|
739
720
|
if (value) {
|
740
721
|
// If the value is typed, then we should clear the textInput on Continue
|
741
|
-
this.
|
742
|
-
this.enteredValue = ''
|
722
|
+
this.textInput = ''
|
743
723
|
}
|
744
724
|
},
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
}
|
753
|
-
}
|
725
|
+
},
|
726
|
+
created() {
|
727
|
+
if (this.value) {
|
728
|
+
this.textInput = numberToString({
|
729
|
+
value: this.value,
|
730
|
+
numberPrecision: this.numberPrecision,
|
731
|
+
minDecimals: this.minDecimals,
|
732
|
+
})
|
733
|
+
} else if (this.defaultNumber !== null) {
|
734
|
+
this.textInput = numberToString({
|
735
|
+
value: this.defaultNumber,
|
736
|
+
numberPrecision: this.numberPrecision,
|
737
|
+
minDecimals: this.minDecimals,
|
738
|
+
})
|
739
|
+
} else if (this.minNumber !== null) {
|
740
|
+
this.textInput = numberToString({
|
741
|
+
value: this.minNumber,
|
742
|
+
numberPrecision: this.numberPrecision,
|
743
|
+
minDecimals: this.minDecimals,
|
744
|
+
})
|
745
|
+
}
|
754
746
|
},
|
755
747
|
mounted() {
|
756
748
|
if (this.focus) {
|
@@ -789,28 +781,29 @@
|
|
789
781
|
}
|
790
782
|
},
|
791
783
|
onEnterPress() {
|
792
|
-
this.$emit(
|
784
|
+
this.$emit('on-enter-click')
|
793
785
|
this.$refs.inputField1.$el.blur()
|
794
786
|
},
|
795
|
-
onChangeHandler(
|
796
|
-
if (isNaN(
|
797
|
-
|
787
|
+
onChangeHandler(event) {
|
788
|
+
if (isNaN(event) || event === '') {
|
789
|
+
event = this.defaultNumber
|
798
790
|
? this.defaultNumber
|
799
791
|
: this.minNumber || this.minNumber === 0
|
800
792
|
? this.minNumber
|
801
|
-
:
|
793
|
+
: event
|
802
794
|
}
|
803
795
|
if (!this.allowNegative) {
|
804
|
-
|
796
|
+
event = Math.abs(event)
|
805
797
|
}
|
806
|
-
|
798
|
+
event = parseFloat(event)
|
807
799
|
// Need to return an integer rather than a string
|
808
|
-
|
800
|
+
this.$emit('input-change', event)
|
809
801
|
},
|
810
|
-
onEvaluateCode(
|
802
|
+
onEvaluateCode(event) {
|
811
803
|
// function to perform math on the code
|
812
804
|
// filter the string in case of any malicious content
|
813
|
-
|
805
|
+
const val = event.target.value
|
806
|
+
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
814
807
|
filtered = filtered.split(/([-+*/()])/)
|
815
808
|
let formatted = filtered.map((item) => {
|
816
809
|
if (
|
@@ -868,29 +861,48 @@
|
|
868
861
|
return array
|
869
862
|
},
|
870
863
|
onInput(event) {
|
871
|
-
this.
|
872
|
-
if (!this.isFocused || this.enteredValue === this.inputValue) {
|
864
|
+
if (!this.isFocused) {
|
873
865
|
return
|
874
866
|
}
|
867
|
+
if (event.target.value === '') {
|
868
|
+
this.$emit('on-input', '')
|
869
|
+
}
|
875
870
|
let evaluatedVal
|
876
871
|
try {
|
877
|
-
evaluatedVal = this.onEvaluateCode(
|
872
|
+
evaluatedVal = this.onEvaluateCode(event)
|
878
873
|
} finally {
|
879
|
-
this.
|
880
|
-
|
881
|
-
if (this.isFocused && typeof this.enteredValue !== 'number') {
|
882
|
-
this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
|
874
|
+
if (evaluatedVal && this.value != evaluatedVal) {
|
875
|
+
this.$emit('on-input', evaluatedVal)
|
883
876
|
}
|
884
877
|
}
|
885
878
|
this.textInput = evaluatedVal
|
886
879
|
},
|
887
880
|
onInputBlur(e) {
|
888
881
|
this.isFocused = false
|
889
|
-
|
890
|
-
this
|
891
|
-
|
892
|
-
|
893
|
-
|
882
|
+
let value = e.target.value
|
883
|
+
let evaluatedInput = this.onEvaluateCode(e)
|
884
|
+
this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
|
885
|
+
if ((evaluatedInput && value.length) || this.minNumber !== null) {
|
886
|
+
this.textInput = numberToString({
|
887
|
+
value:
|
888
|
+
evaluatedInput && value.length
|
889
|
+
? evaluatedInput
|
890
|
+
: this.defaultNumber
|
891
|
+
? this.defaultNumber
|
892
|
+
: this.minNumber,
|
893
|
+
numberPrecision: this.numberPrecision,
|
894
|
+
minDecimals: this.minDecimals,
|
895
|
+
})
|
896
|
+
}
|
897
|
+
let adjustedMinValue =
|
898
|
+
evaluatedInput && evaluatedInput.length
|
899
|
+
? evaluatedInput
|
900
|
+
: this.defaultNumber
|
901
|
+
? this.defaultNumber
|
902
|
+
: this.minNumber || this.minNumber === 0
|
903
|
+
? this.minNumber
|
904
|
+
: ''
|
905
|
+
this.$emit('input-blur', adjustedMinValue)
|
894
906
|
},
|
895
907
|
focusInput() {
|
896
908
|
if (this.disabled) {
|
@@ -900,7 +912,7 @@
|
|
900
912
|
this.$nextTick(() => {
|
901
913
|
this.$refs.inputField1.$el.select()
|
902
914
|
})
|
903
|
-
this.$emit(
|
915
|
+
this.$emit('input-focus')
|
904
916
|
},
|
905
917
|
blurInput() {
|
906
918
|
if (this.disabled) {
|
@@ -920,7 +932,7 @@
|
|
920
932
|
: this.minNumber || this.minNumber === 0
|
921
933
|
? this.minNumber
|
922
934
|
: ''
|
923
|
-
if (adjustedMinValue || adjustedMinValue === 0) {
|
935
|
+
if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
|
924
936
|
let input = this.numberToStringEnabled
|
925
937
|
? numberToString({
|
926
938
|
value: adjustedMinValue,
|
@@ -933,8 +945,6 @@
|
|
933
945
|
return input + ' ' + unit
|
934
946
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
935
947
|
return ''
|
936
|
-
} else if (this.isFocused) {
|
937
|
-
return value
|
938
948
|
} else {
|
939
949
|
return this.numberToStringEnabled
|
940
950
|
? numberToString({
|
@@ -955,7 +965,14 @@
|
|
955
965
|
e.preventDefault()
|
956
966
|
let value = parseFloat(this.value || 0)
|
957
967
|
value += parseFloat(this.interactionStep) * parseInt(e.movementX)
|
958
|
-
this.$emit(
|
968
|
+
this.$emit('on-input-drag', value)
|
969
|
+
|
970
|
+
this.textInput = numberToString({
|
971
|
+
value: value && value.length ? value : this.minNumber,
|
972
|
+
numberPrecision: this.numberPrecision,
|
973
|
+
minDecimals: this.minDecimals,
|
974
|
+
})
|
975
|
+
//this.value=value
|
959
976
|
},
|
960
977
|
stopInteract(e) {
|
961
978
|
e.preventDefault()
|
@@ -963,9 +980,6 @@
|
|
963
980
|
window.removeEventListener('mouseup', this.stopInteract, false)
|
964
981
|
this.blurInput()
|
965
982
|
},
|
966
|
-
handleSelectChange(value) {
|
967
|
-
this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
|
968
|
-
},
|
969
983
|
},
|
970
984
|
}
|
971
985
|
</script>
|
@@ -168,9 +168,7 @@
|
|
168
168
|
position: relative;
|
169
169
|
font-size: ${(props) => (props.fontSize ? props.fontSize : '16px')};
|
170
170
|
color: ${(props) =>
|
171
|
-
props.
|
172
|
-
? props.theme.colors.grey6
|
173
|
-
: props.isDisabled
|
171
|
+
props.isDisabled
|
174
172
|
? props.theme.colors.grey2
|
175
173
|
: props.fontColor
|
176
174
|
? props.fontColor + ' !important'
|
@@ -38,18 +38,18 @@
|
|
38
38
|
|
39
39
|
const pageAttrs = { backdrop: String, position: String }
|
40
40
|
const PageWrapper = styled('div', pageAttrs)`
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
position: ${(props) => props.position}
|
42
|
+
display: grid;
|
43
|
+
top: 0;
|
44
|
+
left: 0;
|
45
|
+
width: 100%;
|
46
|
+
height: 100%;
|
47
|
+
background-color: ${(props) =>
|
48
|
+
props.backdrop == 'dark'
|
49
|
+
? 'rgba(0, 0, 0, 0.4)'
|
50
|
+
: 'rgba(255, 255, 255, 0.9)'};
|
51
|
+
z-index: 99999;
|
52
|
+
overflow: auto;
|
53
53
|
|
54
54
|
@media (max-width: 425px) {
|
55
55
|
background: white;
|
@@ -74,10 +74,13 @@
|
|
74
74
|
v-else
|
75
75
|
class="inputField"
|
76
76
|
:disabled="customInputDisabled"
|
77
|
+
:error-message="item.errorMessage"
|
77
78
|
:font-color="showArchived ? theme.colors.red : 'black'"
|
79
|
+
:is-error="item.isError"
|
78
80
|
:min-width="item.value.length + 'ch'"
|
79
81
|
:no-border="true"
|
80
82
|
:value="item.value"
|
83
|
+
@input-blur="onCustomInputChange($event.trim())"
|
81
84
|
@input-change="onCustomInputChange($event)"
|
82
85
|
/>
|
83
86
|
</InputContainer>
|
@@ -154,7 +157,7 @@
|
|
154
157
|
</OptionsItem>
|
155
158
|
</OptionsWrapper>
|
156
159
|
<CustomContainer
|
157
|
-
v-if="
|
160
|
+
v-if="getCustomName.length && allowFreeInputs"
|
158
161
|
@click="onCustomNameClick()"
|
159
162
|
>
|
160
163
|
<CustomName>{{ getCustomName }}</CustomName>
|
@@ -217,7 +220,6 @@
|
|
217
220
|
const ItemAttrs = { isNested: Boolean, showArchived: Boolean }
|
218
221
|
const ComponentItem = styled('td', ItemAttrs)`
|
219
222
|
padding-left: ${(props) => (props.isNested ? '14px !important' : '0')};
|
220
|
-
overflow: hidden;
|
221
223
|
text-overflow: ellipsis;
|
222
224
|
padding-right: 0 !important;
|
223
225
|
color: ${(props) =>
|
@@ -551,7 +553,7 @@
|
|
551
553
|
},
|
552
554
|
computed: {
|
553
555
|
getCustomName() {
|
554
|
-
return this.inputText
|
556
|
+
return this.inputText.trim()
|
555
557
|
},
|
556
558
|
theme() {
|
557
559
|
return theme
|
@@ -645,7 +647,7 @@
|
|
645
647
|
},
|
646
648
|
onCustomNameClick() {
|
647
649
|
this.wasClicked = true
|
648
|
-
this.$emit('on-custom-input-name', this.
|
650
|
+
this.$emit('on-custom-input-name', this.getCustomName)
|
649
651
|
this.$emit('toggle-dropdown-open', { close: true })
|
650
652
|
this.inputText = ''
|
651
653
|
},
|
@@ -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 =
|
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:
|