@eturnity/eturnity_reusable_components 8.16.9-EPDM-11600.7 → 8.16.9-EPDM-6306.1
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 +1 -1
- package/src/assets/svgIcons/erase.svg +3 -2
- package/src/assets/theme.js +1 -1
- package/src/components/infoCard/index.vue +3 -7
- package/src/components/inputs/inputNumber/InputNumber.stories.js +5 -19
- package/src/components/inputs/inputNumber/index.vue +69 -92
- package/src/components/pageSubtitle/index.vue +1 -7
- package/src/helpers/numberConverter.js +1 -1
package/package.json
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
<svg
|
2
|
-
|
1
|
+
<svg fill="none" height="16" viewbox="12 12 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<circle cx="20" cy="20" r="7"></circle>
|
3
|
+
<path d="M24.9592 15.0408C22.2382 12.3197 17.7618 12.3197 15.0408 15.0408C12.3197 17.7618 12.3197 22.2382 15.0408 24.9592C17.7618 27.6803 22.2382 27.6803 24.9592 24.9592C27.6803 22.2382 27.6803 17.8495 24.9592 15.0408ZM23.6426 22.5016L22.4138 23.7304L19.9561 21.2727L17.4984 23.7304L16.2696 22.5016L18.7273 20.0439L16.2696 17.5862L17.4984 16.3574L19.9561 18.815L22.4138 16.3574L23.6426 17.5862L21.185 20.0439L23.6426 22.5016Z" fill="#FF5656"></path>
|
3
4
|
</svg>
|
package/src/assets/theme.js
CHANGED
@@ -333,7 +333,7 @@ const theme = (() => {
|
|
333
333
|
borderColor: semanticColors.grey[300],
|
334
334
|
},
|
335
335
|
active: {
|
336
|
-
backgroundColor: semanticColors.
|
336
|
+
backgroundColor: semanticColors.blue[100],
|
337
337
|
textColor: semanticColors.purple[600],
|
338
338
|
borderColor: semanticColors.grey[600],
|
339
339
|
},
|
@@ -123,11 +123,7 @@
|
|
123
123
|
return this.type === 'error_minor'
|
124
124
|
},
|
125
125
|
iconName() {
|
126
|
-
return this.type === 'warning'
|
127
|
-
? 'warning_triangle'
|
128
|
-
: this.isErrorMinor
|
129
|
-
? 'erase'
|
130
|
-
: 'info'
|
126
|
+
return this.type === 'warning' ? 'warning_triangle' : 'info'
|
131
127
|
},
|
132
128
|
presetStyles() {
|
133
129
|
// the types that doesn't have explicit border anyway have it transparent
|
@@ -146,8 +142,8 @@
|
|
146
142
|
stylesCollection.iconColor = theme.semanticColors.teal[800]
|
147
143
|
} else if (this.isErrorMinor) {
|
148
144
|
stylesCollection.borderStyle = 'dashed'
|
149
|
-
stylesCollection.borderColor = theme.colors.
|
150
|
-
stylesCollection.iconColor = theme.colors.
|
145
|
+
stylesCollection.borderColor = theme.colors.pureRed
|
146
|
+
stylesCollection.iconColor = theme.colors.pureRed
|
151
147
|
} else {
|
152
148
|
stylesCollection.borderStyle = 'dashed'
|
153
149
|
stylesCollection.borderColor = theme.colors.grey4
|
@@ -3,15 +3,15 @@ import InputNumber from './index.vue'
|
|
3
3
|
export default {
|
4
4
|
title: 'InputNumber',
|
5
5
|
component: InputNumber,
|
6
|
+
// argTypes: {},
|
6
7
|
}
|
7
8
|
|
8
|
-
const Template = (args) => ({
|
9
|
+
const Template = (args, { argTypes }) => ({
|
9
10
|
// Components used in your story `template` are defined in the `components` object
|
10
11
|
components: { InputNumber },
|
11
|
-
setup()
|
12
|
-
|
13
|
-
|
14
|
-
template: `<InputNumber v-bind="args" />`,
|
12
|
+
// The story's `args` need to be mapped into the template through the `setup()` method
|
13
|
+
props: Object.keys(argTypes),
|
14
|
+
template: '<input-number v-bind="$props" />',
|
15
15
|
|
16
16
|
// import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
|
17
17
|
// How to use:
|
@@ -73,20 +73,6 @@ Disabled.args = {
|
|
73
73
|
showLinearUnitName: false,
|
74
74
|
}
|
75
75
|
|
76
|
-
export const DisabledAndPreDefined = Template.bind({})
|
77
|
-
DisabledAndPreDefined.args = {
|
78
|
-
placeholder: 'Enter Value',
|
79
|
-
disabled: true,
|
80
|
-
isPreDefined: true,
|
81
|
-
value: '',
|
82
|
-
inputWidth: '200px',
|
83
|
-
isError: false,
|
84
|
-
numberPrecision: 0,
|
85
|
-
noBorder: false,
|
86
|
-
textAlign: 'left',
|
87
|
-
showLinearUnitName: false,
|
88
|
-
}
|
89
|
-
|
90
76
|
export const LinearUnit = Template.bind({})
|
91
77
|
LinearUnit.args = {
|
92
78
|
placeholder: 'Enter Value',
|
@@ -43,6 +43,7 @@
|
|
43
43
|
:color-mode="colorMode"
|
44
44
|
:data-id="inputDataId"
|
45
45
|
:data-qa-id="dataQaId"
|
46
|
+
:disabled="disabled"
|
46
47
|
:font-color="colorMode === 'transparent' ? 'white' : fontColor"
|
47
48
|
:font-size="fontSize"
|
48
49
|
:has-label-slot="hasLabelSlot"
|
@@ -52,7 +53,6 @@
|
|
52
53
|
:is-disabled="disabled"
|
53
54
|
:is-error="isError"
|
54
55
|
:is-interactive="isInteractive"
|
55
|
-
:is-pre-defined="isPreDefined"
|
56
56
|
:min-width="minWidth"
|
57
57
|
:no-border="noBorder"
|
58
58
|
:placeholder="displayedPlaceholder"
|
@@ -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>
|
@@ -134,7 +134,7 @@
|
|
134
134
|
</ArrowButton>
|
135
135
|
</ArrowControls>
|
136
136
|
</InputWrapper>
|
137
|
-
<ErrorMessage v-if="isError
|
137
|
+
<ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
|
138
138
|
</Container>
|
139
139
|
</template>
|
140
140
|
|
@@ -197,7 +197,6 @@
|
|
197
197
|
slotSize: String,
|
198
198
|
inputHeight: String,
|
199
199
|
isInteractive: Boolean,
|
200
|
-
isPreDefined: Boolean,
|
201
200
|
alignItems: String,
|
202
201
|
labelFontColor: String,
|
203
202
|
labelFontWeight: String,
|
@@ -260,7 +259,7 @@
|
|
260
259
|
color: ${(props) =>
|
261
260
|
props.isError
|
262
261
|
? props.theme.colors.grey6
|
263
|
-
: props.isDisabled
|
262
|
+
: props.isDisabled
|
264
263
|
? props.colorMode === 'transparent'
|
265
264
|
? props.theme.colors.white
|
266
265
|
: props.theme.colors.grey2
|
@@ -458,8 +457,18 @@
|
|
458
457
|
background-color: ${({ theme }) => theme.colors.grey4};
|
459
458
|
`
|
460
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
|
+
|
461
469
|
export default {
|
462
470
|
name: 'InputNumber',
|
471
|
+
emits: [...Object.values(EVENT_TYPES)],
|
463
472
|
components: {
|
464
473
|
Container,
|
465
474
|
InputContainer,
|
@@ -538,11 +547,6 @@
|
|
538
547
|
required: false,
|
539
548
|
default: 0,
|
540
549
|
},
|
541
|
-
isPreDefined: {
|
542
|
-
type: Boolean,
|
543
|
-
required: false,
|
544
|
-
default: false,
|
545
|
-
},
|
546
550
|
minDecimals: {
|
547
551
|
type: Number,
|
548
552
|
required: false,
|
@@ -663,18 +667,12 @@
|
|
663
667
|
required: false,
|
664
668
|
default: '',
|
665
669
|
},
|
666
|
-
labelDataTestId: {
|
667
|
-
type: String,
|
668
|
-
required: false,
|
669
|
-
default: '',
|
670
|
-
},
|
671
670
|
inputDataId: {
|
672
671
|
type: String,
|
673
672
|
required: false,
|
674
673
|
default: '',
|
675
674
|
},
|
676
675
|
dataQaId: {
|
677
|
-
type: String,
|
678
676
|
required: false,
|
679
677
|
default: '',
|
680
678
|
},
|
@@ -713,9 +711,10 @@
|
|
713
711
|
},
|
714
712
|
data() {
|
715
713
|
return {
|
716
|
-
textInput: '',
|
717
714
|
isFocused: false,
|
718
715
|
warningIcon: warningIcon,
|
716
|
+
inputValue: null,
|
717
|
+
enteredValue: null,
|
719
718
|
}
|
720
719
|
},
|
721
720
|
computed: {
|
@@ -738,6 +737,14 @@
|
|
738
737
|
|
739
738
|
return item ? item.label : '-'
|
740
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
|
+
},
|
741
748
|
},
|
742
749
|
watch: {
|
743
750
|
focus(value) {
|
@@ -748,30 +755,19 @@
|
|
748
755
|
clearInput: function (value) {
|
749
756
|
if (value) {
|
750
757
|
// If the value is typed, then we should clear the textInput on Continue
|
751
|
-
this.
|
758
|
+
this.inputValue = ''
|
759
|
+
this.enteredValue = ''
|
752
760
|
}
|
753
761
|
},
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
}
|
762
|
-
}
|
763
|
-
this.textInput = numberToString({
|
764
|
-
value: this.defaultNumber,
|
765
|
-
numberPrecision: this.numberPrecision,
|
766
|
-
minDecimals: this.minDecimals,
|
767
|
-
})
|
768
|
-
} else if (this.minNumber !== null) {
|
769
|
-
this.textInput = numberToString({
|
770
|
-
value: this.minNumber,
|
771
|
-
numberPrecision: this.numberPrecision,
|
772
|
-
minDecimals: this.minDecimals,
|
773
|
-
})
|
774
|
-
}
|
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
|
+
},
|
775
771
|
},
|
776
772
|
mounted() {
|
777
773
|
if (this.focus) {
|
@@ -810,29 +806,28 @@
|
|
810
806
|
}
|
811
807
|
},
|
812
808
|
onEnterPress() {
|
813
|
-
this.$emit(
|
809
|
+
this.$emit(EVENT_TYPES.PRESS_ENTER)
|
814
810
|
this.$refs.inputField1.$el.blur()
|
815
811
|
},
|
816
|
-
onChangeHandler(
|
817
|
-
if (isNaN(
|
818
|
-
|
812
|
+
onChangeHandler(value) {
|
813
|
+
if (isNaN(value) || value === '') {
|
814
|
+
value = this.defaultNumber
|
819
815
|
? this.defaultNumber
|
820
816
|
: this.minNumber || this.minNumber === 0
|
821
817
|
? this.minNumber
|
822
|
-
:
|
818
|
+
: value
|
823
819
|
}
|
824
820
|
if (!this.allowNegative) {
|
825
|
-
|
821
|
+
value = Math.abs(value)
|
826
822
|
}
|
827
|
-
|
823
|
+
value = parseFloat(value)
|
828
824
|
// Need to return an integer rather than a string
|
829
|
-
|
825
|
+
return parseFloat(value)
|
830
826
|
},
|
831
|
-
onEvaluateCode(
|
827
|
+
onEvaluateCode(value) {
|
832
828
|
// function to perform math on the code
|
833
829
|
// filter the string in case of any malicious content
|
834
|
-
|
835
|
-
let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
830
|
+
let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
|
836
831
|
filtered = filtered.split(/([-+*/()])/)
|
837
832
|
let formatted = filtered.map((item) => {
|
838
833
|
if (
|
@@ -890,48 +885,32 @@
|
|
890
885
|
return array
|
891
886
|
},
|
892
887
|
onInput(event) {
|
893
|
-
|
888
|
+
console.log('onInput', event.target.value)
|
889
|
+
this.enteredValue = event.target.value
|
890
|
+
if (!this.isFocused || this.enteredValue === this.inputValue) {
|
894
891
|
return
|
895
892
|
}
|
896
|
-
if (event.target.value === '') {
|
897
|
-
this.$emit('on-input', '')
|
898
|
-
}
|
899
893
|
let evaluatedVal
|
900
894
|
try {
|
901
|
-
evaluatedVal = this.onEvaluateCode(
|
895
|
+
evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
|
902
896
|
} finally {
|
903
|
-
|
904
|
-
|
897
|
+
this.inputValue = this.onChangeHandler(evaluatedVal)
|
898
|
+
|
899
|
+
if (this.isFocused && typeof this.enteredValue !== 'number') {
|
900
|
+
this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
|
905
901
|
}
|
906
902
|
}
|
907
903
|
this.textInput = evaluatedVal
|
908
904
|
},
|
909
905
|
onInputBlur(e) {
|
910
906
|
this.isFocused = false
|
911
|
-
|
912
|
-
|
913
|
-
this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
|
914
|
-
if ((evaluatedInput && value.length) || this.minNumber !== null) {
|
915
|
-
this.textInput = numberToString({
|
916
|
-
value:
|
917
|
-
evaluatedInput && value.length
|
918
|
-
? evaluatedInput
|
919
|
-
: this.defaultNumber
|
920
|
-
? this.defaultNumber
|
921
|
-
: this.minNumber,
|
922
|
-
numberPrecision: this.numberPrecision,
|
923
|
-
minDecimals: this.minDecimals,
|
924
|
-
})
|
907
|
+
if (!Number.isNaN(this.inputValue)) {
|
908
|
+
this.enteredValue = this.inputValue
|
925
909
|
}
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
? this.defaultNumber
|
931
|
-
: this.minNumber || this.minNumber === 0
|
932
|
-
? this.minNumber
|
933
|
-
: ''
|
934
|
-
this.$emit('input-blur', adjustedMinValue)
|
910
|
+
this.$emit(
|
911
|
+
EVENT_TYPES.INPUT_BLUR,
|
912
|
+
Number(this.onEvaluateCode(String(this.inputValue)))
|
913
|
+
)
|
935
914
|
},
|
936
915
|
focusInput() {
|
937
916
|
if (this.disabled) {
|
@@ -941,7 +920,7 @@
|
|
941
920
|
this.$nextTick(() => {
|
942
921
|
this.$refs.inputField1.$el.select()
|
943
922
|
})
|
944
|
-
this.$emit(
|
923
|
+
this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
|
945
924
|
},
|
946
925
|
blurInput() {
|
947
926
|
if (this.disabled) {
|
@@ -961,7 +940,7 @@
|
|
961
940
|
: this.minNumber || this.minNumber === 0
|
962
941
|
? this.minNumber
|
963
942
|
: ''
|
964
|
-
if (
|
943
|
+
if (adjustedMinValue || adjustedMinValue === 0) {
|
965
944
|
let input = this.numberToStringEnabled
|
966
945
|
? numberToString({
|
967
946
|
value: adjustedMinValue,
|
@@ -974,6 +953,8 @@
|
|
974
953
|
return input + ' ' + unit
|
975
954
|
} else if (!adjustedMinValue && adjustedMinValue !== 0) {
|
976
955
|
return ''
|
956
|
+
} else if (this.isFocused) {
|
957
|
+
return value
|
977
958
|
} else {
|
978
959
|
return this.numberToStringEnabled
|
979
960
|
? numberToString({
|
@@ -994,14 +975,7 @@
|
|
994
975
|
e.preventDefault()
|
995
976
|
let value = parseFloat(this.value || 0)
|
996
977
|
value += parseFloat(this.interactionStep) * parseInt(e.movementX)
|
997
|
-
this.$emit(
|
998
|
-
|
999
|
-
this.textInput = numberToString({
|
1000
|
-
value: value && value.length ? value : this.minNumber,
|
1001
|
-
numberPrecision: this.numberPrecision,
|
1002
|
-
minDecimals: this.minDecimals,
|
1003
|
-
})
|
1004
|
-
//this.value=value
|
978
|
+
this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
|
1005
979
|
},
|
1006
980
|
stopInteract(e) {
|
1007
981
|
e.preventDefault()
|
@@ -1009,6 +983,9 @@
|
|
1009
983
|
window.removeEventListener('mouseup', this.stopInteract, false)
|
1010
984
|
this.blurInput()
|
1011
985
|
},
|
986
|
+
handleSelectChange(value) {
|
987
|
+
this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
|
988
|
+
},
|
1012
989
|
},
|
1013
990
|
}
|
1014
991
|
</script>
|
@@ -5,8 +5,7 @@
|
|
5
5
|
:has-info-text="!!infoText"
|
6
6
|
:margin-bottom="marginBottom"
|
7
7
|
>
|
8
|
-
<span
|
9
|
-
<span v-else data-test-id="page_subtitle_text">
|
8
|
+
<span data-test-id="page_subtitle_text">
|
10
9
|
{{ text }}
|
11
10
|
</span>
|
12
11
|
<InfoText
|
@@ -59,11 +58,6 @@
|
|
59
58
|
required: true,
|
60
59
|
type: String,
|
61
60
|
},
|
62
|
-
containsHtml: {
|
63
|
-
required: false,
|
64
|
-
type: Boolean,
|
65
|
-
default: false,
|
66
|
-
},
|
67
61
|
color: {
|
68
62
|
required: false,
|
69
63
|
type: String,
|
@@ -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:
|