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

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-11600.10",
4
4
  "files": [
5
5
  "dist",
6
6
  "src"
@@ -1,4 +1,3 @@
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>
1
+ <svg width="22" height="21" viewBox="0 0 22 21" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M18.4389 3.06113C14.3574 -1.02038 7.64263 -1.02038 3.56113 3.06113C-0.520376 7.14263 -0.520376 13.8574 3.56113 17.9389C7.64263 22.0204 14.3574 22.0204 18.4389 17.9389C22.5204 13.8574 22.5204 7.2743 18.4389 3.06113ZM16.464 14.2524L14.6207 16.0956L10.9342 12.4091L7.24765 16.0956L5.40439 14.2524L9.09091 10.5658L5.40439 6.87931L7.24765 5.03605L10.9342 8.72257L14.6207 5.03605L16.464 6.87931L12.7774 10.5658L16.464 14.2524Z" fill="#FF5656"/>
4
3
  </svg>
@@ -333,7 +333,7 @@ const theme = (() => {
333
333
  borderColor: semanticColors.grey[300],
334
334
  },
335
335
  active: {
336
- backgroundColor: semanticColors.purple[100],
336
+ backgroundColor: semanticColors.purple[50],
337
337
  textColor: semanticColors.purple[600],
338
338
  borderColor: semanticColors.grey[600],
339
339
  },
@@ -17,8 +17,8 @@
17
17
  />
18
18
  </ChartControlsWrapper>
19
19
  <GraphSection :height="height" :width="width">
20
- <YAxis :width="yAxisWidth" :height="height">
21
- <YAxisTitleWrapper v-if="yAxisTitle" :height="yAxisHeight">
20
+ <YAxis :width="yAxisWidth">
21
+ <YAxisTitleWrapper v-if="yAxisTitle">
22
22
  {{ yAxisTitle }}
23
23
  </YAxisTitleWrapper>
24
24
  <YAxisRow
@@ -16,12 +16,9 @@ export const GraphSection = styled('div', { width: String, height: String })`
16
16
  display: flex;
17
17
  `
18
18
 
19
- export const YAxis = styled('div', { width: String, height: String })`
19
+ export const YAxis = styled('div', { width: String })`
20
20
  width: ${(props) => props.width};
21
- display: flex;
22
- flex-direction: column;
23
21
  position: relative;
24
- height: ${(props) => props.height};
25
22
  `
26
23
 
27
24
  export const YAxisRow = styled('div', { percentage: Number })`
@@ -57,18 +54,19 @@ export const YAxisLine = styled('div', { yAxisWidth: String })`
57
54
  transform: translateY(-50%);
58
55
  `
59
56
 
60
- export const YAxisTitleWrapper = styled('div', { height: String })`
61
- position: absolute;
62
- left: -66px;
63
- top: ${(props) => props.height};
64
- transform: rotate(-90deg) translateX(50%);
65
- transform-origin: right;
57
+ export const YAxisTitleWrapper = styled('div')`
66
58
  font-size: 12px;
67
- color: ${(props) => props.theme.semanticColors.teal[600]};
68
- display: flex;
69
- align-items: center;
59
+ font-weight: 500;
60
+ color: ${(props) => props.theme.semanticColors.grey[700]};
70
61
  white-space: nowrap;
71
- font-family: ${(props) => props.theme.fonts.mainFont};
62
+ height: 0;
63
+ width: 0;
64
+ display: flex;
65
+ align-items: flex-start;
66
+ justify-content: center;
67
+ position: absolute;
68
+ top: 50%;
69
+ transform: rotate(-90deg);
72
70
  `
73
71
 
74
72
  export const ScrollContainer = styled('div', {
@@ -3,15 +3,15 @@ import InputNumber from './index.vue'
3
3
  export default {
4
4
  title: 'InputNumber',
5
5
  component: InputNumber,
6
- // argTypes: {},
7
6
  }
8
7
 
9
- const Template = (args, { argTypes }) => ({
8
+ const Template = (args) => ({
10
9
  // Components used in your story `template` are defined in the `components` object
11
10
  components: { InputNumber },
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" />',
11
+ setup() {
12
+ return { args: args }
13
+ },
14
+ template: `<InputNumber v-bind="args" />`,
15
15
 
16
16
  // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
17
17
  // How to use:
@@ -43,7 +43,6 @@
43
43
  :color-mode="colorMode"
44
44
  :data-id="inputDataId"
45
45
  :data-qa-id="dataQaId"
46
- :disabled="disabled"
47
46
  :font-color="colorMode === 'transparent' ? 'white' : fontColor"
48
47
  :font-size="fontSize"
49
48
  :has-label-slot="hasLabelSlot"
@@ -61,7 +60,7 @@
61
60
  :show-linear-unit-name="showLinearUnitName"
62
61
  :slot-size="slotSize"
63
62
  :text-align="textAlign"
64
- :value="formattedValue"
63
+ :value="formatWithCurrency(value)"
65
64
  @blur="onInputBlur($event)"
66
65
  @focus="focusInput()"
67
66
  @input="onInput($event)"
@@ -75,7 +74,7 @@
75
74
 
76
75
  <UnitContainer
77
76
  v-if="unitName && showLinearUnitName && !hasSlot"
78
- :has-length="hasLength"
77
+ :has-length="!!textInput.length"
79
78
  :is-error="isError"
80
79
  >{{ unitName }}</UnitContainer
81
80
  >
@@ -92,7 +91,7 @@
92
91
  :disabled="isSelectDisabled"
93
92
  :select-width="`${selectWidth}px`"
94
93
  :show-border="false"
95
- @input-change="handleSelectChange"
94
+ @input-change="$emit('select-change', $event)"
96
95
  >
97
96
  <template #selector>
98
97
  <SelectText>{{ getSelectValue }}</SelectText>
@@ -134,7 +133,7 @@
134
133
  </ArrowButton>
135
134
  </ArrowControls>
136
135
  </InputWrapper>
137
- <ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
136
+ <ErrorMessage v-if="isError && errorMessage">{{ errorMessage }}</ErrorMessage>
138
137
  </Container>
139
138
  </template>
140
139
 
@@ -457,18 +456,8 @@
457
456
  background-color: ${({ theme }) => theme.colors.grey4};
458
457
  `
459
458
 
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
459
  export default {
470
460
  name: 'InputNumber',
471
- emits: [...Object.values(EVENT_TYPES)],
472
461
  components: {
473
462
  Container,
474
463
  InputContainer,
@@ -668,12 +657,18 @@
668
657
  required: false,
669
658
  default: '',
670
659
  },
660
+ labelDataTestId: {
661
+ type: String,
662
+ required: false,
663
+ default: '',
664
+ },
671
665
  inputDataId: {
672
666
  type: String,
673
667
  required: false,
674
668
  default: '',
675
669
  },
676
670
  dataQaId: {
671
+ type: String,
677
672
  required: false,
678
673
  default: '',
679
674
  },
@@ -712,10 +707,9 @@
712
707
  },
713
708
  data() {
714
709
  return {
710
+ textInput: '',
715
711
  isFocused: false,
716
712
  warningIcon: warningIcon,
717
- inputValue: null,
718
- enteredValue: null,
719
713
  }
720
714
  },
721
715
  computed: {
@@ -738,14 +732,6 @@
738
732
 
739
733
  return item ? item.label : '-'
740
734
  },
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
735
  },
750
736
  watch: {
751
737
  focus(value) {
@@ -756,19 +742,30 @@
756
742
  clearInput: function (value) {
757
743
  if (value) {
758
744
  // If the value is typed, then we should clear the textInput on Continue
759
- this.inputValue = ''
760
- this.enteredValue = ''
745
+ this.textInput = ''
761
746
  }
762
747
  },
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
- },
748
+ },
749
+ created() {
750
+ if (this.value) {
751
+ this.textInput = numberToString({
752
+ value: this.value,
753
+ numberPrecision: this.numberPrecision,
754
+ minDecimals: this.minDecimals,
755
+ })
756
+ } else if (this.defaultNumber !== null) {
757
+ this.textInput = numberToString({
758
+ value: this.defaultNumber,
759
+ numberPrecision: this.numberPrecision,
760
+ minDecimals: this.minDecimals,
761
+ })
762
+ } else if (this.minNumber !== null) {
763
+ this.textInput = numberToString({
764
+ value: this.minNumber,
765
+ numberPrecision: this.numberPrecision,
766
+ minDecimals: this.minDecimals,
767
+ })
768
+ }
772
769
  },
773
770
  mounted() {
774
771
  if (this.focus) {
@@ -807,31 +804,32 @@
807
804
  }
808
805
  },
809
806
  onEnterPress() {
810
- this.$emit(EVENT_TYPES.PRESS_ENTER)
807
+ this.$emit('on-enter-click')
811
808
  this.$refs.inputField1.$el.blur()
812
809
  },
813
- onChangeHandler(value) {
814
- if (isNaN(value) || value === '') {
815
- value = this.defaultNumber
810
+ onChangeHandler(event) {
811
+ if (isNaN(event) || event === '') {
812
+ event = this.defaultNumber
816
813
  ? this.defaultNumber
817
814
  : this.minNumber || this.minNumber === 0
818
815
  ? this.minNumber
819
- : value
816
+ : event
820
817
  }
821
818
  if (!this.allowNegative) {
822
- value = Math.abs(value)
819
+ event = Math.abs(event)
823
820
  }
824
- if (this.minNumber && this.minNumber > value) {
825
- value = this.minNumber
821
+ if (this.minNumber && this.minNumber > event) {
822
+ event = this.minNumber
826
823
  }
824
+ event = parseFloat(event)
827
825
  // Need to return an integer rather than a string
828
- value = parseFloat(value)
829
- return value
826
+ this.$emit('input-change', event)
830
827
  },
831
- onEvaluateCode(value) {
828
+ onEvaluateCode(event) {
832
829
  // function to perform math on the code
833
830
  // filter the string in case of any malicious content
834
- let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
831
+ const val = event.target.value
832
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
835
833
  filtered = filtered.split(/([-+*/()])/)
836
834
  let formatted = filtered.map((item) => {
837
835
  if (
@@ -889,32 +887,48 @@
889
887
  return array
890
888
  },
891
889
  onInput(event) {
892
- console.log('onInput', event.target.value)
893
- this.enteredValue = event.target.value
894
- if (!this.isFocused || this.enteredValue === this.inputValue) {
890
+ if (!this.isFocused) {
895
891
  return
896
892
  }
893
+ if (event.target.value === '') {
894
+ this.$emit('on-input', '')
895
+ }
897
896
  let evaluatedVal
898
897
  try {
899
- evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
898
+ evaluatedVal = this.onEvaluateCode(event)
900
899
  } 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)
900
+ if (evaluatedVal && this.value != evaluatedVal) {
901
+ this.$emit('on-input', evaluatedVal)
905
902
  }
906
903
  }
907
904
  this.textInput = evaluatedVal
908
905
  },
909
906
  onInputBlur(e) {
910
907
  this.isFocused = false
911
- if (!Number.isNaN(this.inputValue)) {
912
- this.enteredValue = this.inputValue
908
+ let value = e.target.value
909
+ let evaluatedInput = this.onEvaluateCode(e)
910
+ this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
911
+ if ((evaluatedInput && value.length) || this.minNumber !== null) {
912
+ this.textInput = numberToString({
913
+ value:
914
+ evaluatedInput && value.length
915
+ ? evaluatedInput
916
+ : this.defaultNumber
917
+ ? this.defaultNumber
918
+ : this.minNumber,
919
+ numberPrecision: this.numberPrecision,
920
+ minDecimals: this.minDecimals,
921
+ })
913
922
  }
914
- this.$emit(
915
- EVENT_TYPES.INPUT_BLUR,
916
- Number(this.onEvaluateCode(String(this.inputValue)))
917
- )
923
+ let adjustedMinValue =
924
+ evaluatedInput && evaluatedInput.length
925
+ ? evaluatedInput
926
+ : this.defaultNumber
927
+ ? this.defaultNumber
928
+ : this.minNumber || this.minNumber === 0
929
+ ? this.minNumber
930
+ : ''
931
+ this.$emit('input-blur', adjustedMinValue)
918
932
  },
919
933
  focusInput() {
920
934
  if (this.disabled) {
@@ -924,7 +938,7 @@
924
938
  this.$nextTick(() => {
925
939
  this.$refs.inputField1.$el.select()
926
940
  })
927
- this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
941
+ this.$emit('input-focus')
928
942
  },
929
943
  blurInput() {
930
944
  if (this.disabled) {
@@ -944,7 +958,7 @@
944
958
  : this.minNumber || this.minNumber === 0
945
959
  ? this.minNumber
946
960
  : ''
947
- if (adjustedMinValue || adjustedMinValue === 0) {
961
+ if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
948
962
  let input = this.numberToStringEnabled
949
963
  ? numberToString({
950
964
  value: adjustedMinValue,
@@ -957,8 +971,6 @@
957
971
  return input + ' ' + unit
958
972
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
959
973
  return ''
960
- } else if (this.isFocused) {
961
- return value
962
974
  } else {
963
975
  return this.numberToStringEnabled
964
976
  ? numberToString({
@@ -979,7 +991,14 @@
979
991
  e.preventDefault()
980
992
  let value = parseFloat(this.value || 0)
981
993
  value += parseFloat(this.interactionStep) * parseInt(e.movementX)
982
- this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
994
+ this.$emit('on-input-drag', value)
995
+
996
+ this.textInput = numberToString({
997
+ value: value && value.length ? value : this.minNumber,
998
+ numberPrecision: this.numberPrecision,
999
+ minDecimals: this.minDecimals,
1000
+ })
1001
+ //this.value=value
983
1002
  },
984
1003
  stopInteract(e) {
985
1004
  e.preventDefault()
@@ -987,9 +1006,6 @@
987
1006
  window.removeEventListener('mouseup', this.stopInteract, false)
988
1007
  this.blurInput()
989
1008
  },
990
- handleSelectChange(value) {
991
- this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
992
- },
993
1009
  },
994
1010
  }
995
1011
  </script>
@@ -5,7 +5,8 @@
5
5
  :has-info-text="!!infoText"
6
6
  :margin-bottom="marginBottom"
7
7
  >
8
- <span data-test-id="page_subtitle_text">
8
+ <span v-if="containsHtml" data-test-id="page_subtitle_text" v-html="text"></span>
9
+ <span v-else data-test-id="page_subtitle_text">
9
10
  {{ text }}
10
11
  </span>
11
12
  <InfoText
@@ -58,6 +59,11 @@
58
59
  required: true,
59
60
  type: String,
60
61
  },
62
+ containsHtml: {
63
+ required: false,
64
+ type: Boolean,
65
+ default: false,
66
+ },
61
67
  color: {
62
68
  required: false,
63
69
  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 = !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: