@eturnity/eturnity_reusable_components 8.13.13-epic-shading.1 → 8.13.13-qa-16-03-26.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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/DemoCharts.vue +424 -0
  3. package/src/TestChart.vue +241 -0
  4. package/src/assets/svgIcons/refresh.svg +3 -0
  5. package/src/assets/theme.js +16 -1
  6. package/src/components/barchart/BottomFields.vue +253 -0
  7. package/src/components/barchart/ChartControls.vue +113 -0
  8. package/src/components/barchart/SelectionBox.vue +150 -0
  9. package/src/components/barchart/composables/index.js +5 -0
  10. package/src/components/barchart/composables/useAxisCalculations.js +104 -0
  11. package/src/components/barchart/composables/useChartData.js +114 -0
  12. package/src/components/barchart/composables/useChartScroll.js +61 -0
  13. package/src/components/barchart/composables/useSelection.js +75 -0
  14. package/src/components/barchart/composables/useTooltip.js +100 -0
  15. package/src/components/barchart/index.vue +376 -0
  16. package/src/components/barchart/styles/bottomFields.js +66 -0
  17. package/src/components/barchart/styles/chart.js +259 -0
  18. package/src/components/barchart/styles/chartControls.js +59 -0
  19. package/src/components/buttons/splitButtons/index.vue +86 -0
  20. package/src/components/collapsableInfoText/index.vue +2 -2
  21. package/src/components/inputs/checkbox/index.vue +2 -2
  22. package/src/components/inputs/inputNumber/index.vue +78 -80
  23. package/src/components/inputs/select/index.vue +89 -16
  24. package/src/components/modals/modal/index.vue +15 -5
  25. package/src/helpers/isObjectEqual.js +22 -0
  26. package/src/helpers/numberConverter.js +1 -1
  27. package/src/main.js +8 -0
  28. package/src/router/dynamicRoutes.js +12 -0
  29. package/src/assets/icons/collapse_arrow_icon_white.svg +0 -1
  30. package/src/assets/svgIcons/house_sun.svg +0 -3
  31. package/src/components/draggableCard/defaultProps.js +0 -16
  32. package/src/components/draggableCard/draggableCard.spec.js +0 -99
  33. package/src/components/draggableCard/draggableCard.stories.js +0 -79
  34. package/src/components/draggableCard/index.vue +0 -363
@@ -0,0 +1,59 @@
1
+ import styled from 'vue3-styled-components'
2
+
3
+ export const Container = styled.div`
4
+ width: 100%;
5
+ `
6
+
7
+ export const LegendAndControlsWrapper = styled('div', { leftMargin: String })`
8
+ margin-left: ${(props) => props.leftMargin};
9
+ display: flex;
10
+ justify-content: space-between;
11
+ align-items: center;
12
+ `
13
+
14
+ export const LeftSection = styled.div`
15
+ flex: 1;
16
+ `
17
+
18
+ export const SplitButtonsContainer = styled('div', { position: String })`
19
+ align-self: ${(props) =>
20
+ props.position === 'top' ? 'flex-end' : 'flex-start'};
21
+ `
22
+
23
+ export const LegendGroups = styled.div`
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 8px;
27
+ `
28
+
29
+ export const LegendRow = styled('div', { rowIndex: Number })`
30
+ display: flex;
31
+ gap: 10px;
32
+ align-items: center;
33
+ justify-content: ${(props) =>
34
+ props.rowIndex === 0 ? 'flex-start' : 'flex-end'};
35
+ `
36
+
37
+ export const LegendItem = styled.div`
38
+ display: flex;
39
+ align-items: center;
40
+ gap: 8px;
41
+ `
42
+
43
+ export const LegendColor = styled('div', {
44
+ gradientFrom: String,
45
+ gradientTo: String,
46
+ })`
47
+ width: 16px;
48
+ height: 16px;
49
+ border-radius: 4px;
50
+ background: ${(props) =>
51
+ `linear-gradient(180deg, ${props.gradientFrom} 0%, ${props.gradientTo} 100%)`};
52
+ `
53
+
54
+ export const LegendText = styled.span`
55
+ font-size: 12px;
56
+ font-weight: 400;
57
+ color: ${(props) => props.theme.semanticColors.teal[800]};
58
+ white-space: nowrap;
59
+ `
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <Container>
3
+ <SplitButton
4
+ v-for="(option, index) in options"
5
+ :data-id-key="`${dataIdKey}_${option.value}`"
6
+ :key="index"
7
+ :length="options.length"
8
+ :position="getButtonPosition(index)"
9
+ :selected="modelValue === option.value"
10
+ @click.stop="handleSelect(option.value)"
11
+ >
12
+ {{ option.label }}
13
+ </SplitButton>
14
+ </Container>
15
+ </template>
16
+
17
+ <script setup>
18
+ import styled from 'vue3-styled-components'
19
+ import { computed } from 'vue'
20
+
21
+ const Container = styled.div`
22
+ display: flex;
23
+ width: fit-content;
24
+ `
25
+ const SplitButton = styled('button', {
26
+ selected: Boolean,
27
+ position: String,
28
+ length: Number,
29
+ })`
30
+ padding: 8px 16px;
31
+ border: 1px solid ${(props) => props.theme.semanticColors.teal[100]};
32
+ ${(props) =>
33
+ props.position === 'middle'
34
+ ? `
35
+ border-left: none;
36
+ border-right: none;
37
+ `
38
+ : props.length === 2 && props.position === 'first'
39
+ ? 'border-right: none;'
40
+ : ''}
41
+ border-radius: ${(props) =>
42
+ props.position === 'first'
43
+ ? '4px 0 0 4px'
44
+ : props.position === 'last'
45
+ ? '0 4px 4px 0'
46
+ : '0'};
47
+ font-family: ${(props) => props.theme.fonts.mainFont};
48
+ font-size: 14px;
49
+ font-weight: 400;
50
+ line-height: 100%;
51
+ cursor: pointer;
52
+ background: ${(props) =>
53
+ props.selected ? props.theme.semanticColors.purple[50] : 'transparent'};
54
+ color: ${(props) => props.theme.semanticColors.purple[500]};
55
+ `
56
+
57
+ const props = defineProps({
58
+ options: {
59
+ type: Array,
60
+ required: true,
61
+ // expects array of {label: string, value: string}
62
+ },
63
+ modelValue: {
64
+ type: String,
65
+ required: true,
66
+ },
67
+ dataIdKey: {
68
+ type: String,
69
+ default: '',
70
+ },
71
+ })
72
+
73
+ const emit = defineEmits(['update:modelValue'])
74
+
75
+ const getButtonPosition = computed(() => (index) => {
76
+ if (index === 0) return 'first'
77
+ if (index === props.options.length - 1) return 'last'
78
+
79
+ return 'middle'
80
+ })
81
+
82
+ const handleSelect = (value) => {
83
+ emit('update:modelValue', value)
84
+ emit('click', value)
85
+ }
86
+ </script>
@@ -33,7 +33,7 @@
33
33
  const Text = styled('p', TextAttrs)`
34
34
  display: block;
35
35
  display: -webkit-box;
36
- line-height: 1.3em;
36
+ line-height: 1.5;
37
37
  -webkit-line-clamp: ${(props) => (props.expand ? 'unset' : '4')};
38
38
  -webkit-box-orient: vertical;
39
39
  overflow: hidden;
@@ -49,7 +49,7 @@
49
49
  const ToggleButton = styled('p', TextAttrs)`
50
50
  font-size: ${(props) => props.fontSize}px;
51
51
  cursor: pointer;
52
- color: ${(props) => props.theme.colors.blue};
52
+ color: ${(props) => props.theme.semanticColors.purple[500]};
53
53
  `
54
54
 
55
55
  export default {
@@ -44,7 +44,7 @@
44
44
  import styled from 'vue3-styled-components'
45
45
 
46
46
  const ComponentWrapper = styled.div`
47
- min-height: 16px;
47
+ min-height: 18px;
48
48
  `
49
49
 
50
50
  const CheckWrapper = styled('div', { hasLabel: Boolean })`
@@ -179,7 +179,7 @@
179
179
  font-size: 13px;
180
180
  display: grid;
181
181
  align-items: center;
182
- min-height: 16px;
182
+ min-height: 18px;
183
183
  color: ${(props) =>
184
184
  props.isDisabled ? props.theme.colors.grey2 : 'unset'};
185
185
  `
@@ -56,11 +56,12 @@
56
56
  :min-width="minWidth"
57
57
  :no-border="noBorder"
58
58
  :placeholder="displayedPlaceholder"
59
+ :read-only="isReadOnly"
59
60
  :show-arrow-controls="showArrowControls"
60
61
  :show-linear-unit-name="showLinearUnitName"
61
62
  :slot-size="slotSize"
62
63
  :text-align="textAlign"
63
- :value="formatWithCurrency(value)"
64
+ :value="formattedValue"
64
65
  @blur="onInputBlur($event)"
65
66
  @focus="focusInput()"
66
67
  @input="onInput($event)"
@@ -74,7 +75,7 @@
74
75
 
75
76
  <UnitContainer
76
77
  v-if="unitName && showLinearUnitName && !hasSlot"
77
- :has-length="!!textInput.length"
78
+ :has-length="hasLength"
78
79
  :is-error="isError"
79
80
  >{{ unitName }}</UnitContainer
80
81
  >
@@ -91,7 +92,7 @@
91
92
  :disabled="isSelectDisabled"
92
93
  :select-width="`${selectWidth}px`"
93
94
  :show-border="false"
94
- @input-change="$emit('select-change', $event)"
95
+ @input-change="handleSelectChange"
95
96
  >
96
97
  <template #selector>
97
98
  <SelectText>{{ getSelectValue }}</SelectText>
@@ -163,6 +164,7 @@
163
164
  // labelInfoAlign="left"
164
165
  // :minNumber="0"
165
166
  // fontColor="blue"
167
+ // :isReadOnly="true"
166
168
  // colorMode="transparent" // Makes background transparent, border white, and font white
167
169
  // >
168
170
  //<template name=label><img>....</template>
@@ -202,6 +204,7 @@
202
204
  showLinearUnitName: Boolean,
203
205
  colorMode: String,
204
206
  showArrowControls: Boolean,
207
+ readOnly: Boolean,
205
208
  }
206
209
 
207
210
  const Container = styled('div', inputProps)`
@@ -250,7 +253,8 @@
250
253
  ? '0 4px 4px 0'
251
254
  : '4px'};
252
255
  text-align: ${(props) => props.textAlign};
253
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
256
+ cursor: ${(props) =>
257
+ props.isDisabled || props.readOnly ? 'not-allowed' : 'auto'};
254
258
  font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
255
259
  color: ${(props) =>
256
260
  props.isError
@@ -263,7 +267,9 @@
263
267
  ? props.fontColor + ' !important'
264
268
  : props.theme.colors.black};
265
269
  background-color: ${(props) =>
266
- props.isDisabled
270
+ props.readOnly
271
+ ? props.theme.semanticColors.grey[300]
272
+ : props.isDisabled
267
273
  ? props.colorMode === 'transparent'
268
274
  ? 'transparent'
269
275
  : props.theme.colors.grey5
@@ -276,6 +282,8 @@
276
282
  box-sizing: border-box;
277
283
  opacity: ${(props) =>
278
284
  props.isDisabled && props.colorMode === 'transparent' ? '0.4' : '1'};
285
+ pointer-events: ${(props) => (props.readOnly ? 'none' : 'auto')};
286
+ user-select: ${(props) => (props.readOnly ? 'none' : 'auto')};
279
287
 
280
288
  &::placeholder {
281
289
  color: ${(props) => props.theme.colors.grey2};
@@ -449,8 +457,18 @@
449
457
  background-color: ${({ theme }) => theme.colors.grey4};
450
458
  `
451
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
+
452
469
  export default {
453
470
  name: 'InputNumber',
471
+ emits: [...Object.values(EVENT_TYPES)],
454
472
  components: {
455
473
  Container,
456
474
  InputContainer,
@@ -686,12 +704,17 @@
686
704
  type: Boolean,
687
705
  default: false,
688
706
  },
707
+ isReadOnly: {
708
+ type: Boolean,
709
+ default: false,
710
+ },
689
711
  },
690
712
  data() {
691
713
  return {
692
- textInput: '',
693
714
  isFocused: false,
694
715
  warningIcon: warningIcon,
716
+ inputValue: null,
717
+ enteredValue: null,
695
718
  }
696
719
  },
697
720
  computed: {
@@ -714,6 +737,14 @@
714
737
 
715
738
  return item ? item.label : '-'
716
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
+ },
717
748
  },
718
749
  watch: {
719
750
  focus(value) {
@@ -724,30 +755,19 @@
724
755
  clearInput: function (value) {
725
756
  if (value) {
726
757
  // If the value is typed, then we should clear the textInput on Continue
727
- this.textInput = ''
758
+ this.inputValue = ''
759
+ this.enteredValue = ''
728
760
  }
729
761
  },
730
- },
731
- created() {
732
- if (this.value) {
733
- this.textInput = numberToString({
734
- value: this.value,
735
- numberPrecision: this.numberPrecision,
736
- minDecimals: this.minDecimals,
737
- })
738
- } else if (this.defaultNumber !== null) {
739
- this.textInput = numberToString({
740
- value: this.defaultNumber,
741
- numberPrecision: this.numberPrecision,
742
- minDecimals: this.minDecimals,
743
- })
744
- } else if (this.minNumber !== null) {
745
- this.textInput = numberToString({
746
- value: this.minNumber,
747
- numberPrecision: this.numberPrecision,
748
- minDecimals: this.minDecimals,
749
- })
750
- }
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 = this.value
768
+ }
769
+ },
770
+ },
751
771
  },
752
772
  mounted() {
753
773
  if (this.focus) {
@@ -786,29 +806,28 @@
786
806
  }
787
807
  },
788
808
  onEnterPress() {
789
- this.$emit('on-enter-click')
809
+ this.$emit(EVENT_TYPES.PRESS_ENTER)
790
810
  this.$refs.inputField1.$el.blur()
791
811
  },
792
- onChangeHandler(event) {
793
- if (isNaN(event) || event === '') {
794
- event = this.defaultNumber
812
+ onChangeHandler(value) {
813
+ if (isNaN(value) || value === '') {
814
+ value = this.defaultNumber
795
815
  ? this.defaultNumber
796
816
  : this.minNumber || this.minNumber === 0
797
817
  ? this.minNumber
798
- : event
818
+ : value
799
819
  }
800
820
  if (!this.allowNegative) {
801
- event = Math.abs(event)
821
+ value = Math.abs(value)
802
822
  }
803
- event = parseFloat(event)
823
+ value = parseFloat(value)
804
824
  // Need to return an integer rather than a string
805
- this.$emit('input-change', event)
825
+ return parseFloat(value)
806
826
  },
807
- onEvaluateCode(event) {
827
+ onEvaluateCode(value) {
808
828
  // function to perform math on the code
809
829
  // filter the string in case of any malicious content
810
- const val = event.target.value
811
- let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
830
+ let filtered = value.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
812
831
  filtered = filtered.split(/([-+*/()])/)
813
832
  let formatted = filtered.map((item) => {
814
833
  if (
@@ -866,48 +885,29 @@
866
885
  return array
867
886
  },
868
887
  onInput(event) {
869
- if (!this.isFocused) {
888
+ this.enteredValue = event.target.value
889
+ if (!this.isFocused || this.enteredValue === this.inputValue) {
870
890
  return
871
891
  }
872
- if (event.target.value === '') {
873
- this.$emit('on-input', '')
874
- }
875
892
  let evaluatedVal
876
893
  try {
877
- evaluatedVal = this.onEvaluateCode(event)
894
+ evaluatedVal = this.onEvaluateCode(String(this.enteredValue))
878
895
  } finally {
879
- if (evaluatedVal && this.value != evaluatedVal) {
880
- this.$emit('on-input', evaluatedVal)
896
+ this.inputValue = this.onChangeHandler(evaluatedVal)
897
+
898
+ if (this.isFocused && typeof this.enteredValue !== 'number') {
899
+ this.$emit(EVENT_TYPES.INPUT_CHANGE, this.inputValue)
881
900
  }
882
901
  }
883
902
  this.textInput = evaluatedVal
884
903
  },
885
904
  onInputBlur(e) {
886
905
  this.isFocused = false
887
- let value = e.target.value
888
- let evaluatedInput = this.onEvaluateCode(e)
889
- this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
890
- if ((evaluatedInput && value.length) || this.minNumber !== null) {
891
- this.textInput = numberToString({
892
- value:
893
- evaluatedInput && value.length
894
- ? evaluatedInput
895
- : this.defaultNumber
896
- ? this.defaultNumber
897
- : this.minNumber,
898
- numberPrecision: this.numberPrecision,
899
- minDecimals: this.minDecimals,
900
- })
901
- }
902
- let adjustedMinValue =
903
- evaluatedInput && evaluatedInput.length
904
- ? evaluatedInput
905
- : this.defaultNumber
906
- ? this.defaultNumber
907
- : this.minNumber || this.minNumber === 0
908
- ? this.minNumber
909
- : ''
910
- this.$emit('input-blur', adjustedMinValue)
906
+ this.enteredValue = this.inputValue
907
+ this.$emit(
908
+ EVENT_TYPES.INPUT_BLUR,
909
+ this.onEvaluateCode(String(this.inputValue))
910
+ )
911
911
  },
912
912
  focusInput() {
913
913
  if (this.disabled) {
@@ -917,7 +917,7 @@
917
917
  this.$nextTick(() => {
918
918
  this.$refs.inputField1.$el.select()
919
919
  })
920
- this.$emit('input-focus')
920
+ this.$emit(EVENT_TYPES.INPUT_FOCUS, this.inputValue)
921
921
  },
922
922
  blurInput() {
923
923
  if (this.disabled) {
@@ -937,7 +937,7 @@
937
937
  : this.minNumber || this.minNumber === 0
938
938
  ? this.minNumber
939
939
  : ''
940
- if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
940
+ if (adjustedMinValue || adjustedMinValue === 0) {
941
941
  let input = this.numberToStringEnabled
942
942
  ? numberToString({
943
943
  value: adjustedMinValue,
@@ -950,6 +950,8 @@
950
950
  return input + ' ' + unit
951
951
  } else if (!adjustedMinValue && adjustedMinValue !== 0) {
952
952
  return ''
953
+ } else if (this.isFocused) {
954
+ return value
953
955
  } else {
954
956
  return this.numberToStringEnabled
955
957
  ? numberToString({
@@ -970,14 +972,7 @@
970
972
  e.preventDefault()
971
973
  let value = parseFloat(this.value || 0)
972
974
  value += parseFloat(this.interactionStep) * parseInt(e.movementX)
973
- this.$emit('on-input-drag', value)
974
-
975
- this.textInput = numberToString({
976
- value: value && value.length ? value : this.minNumber,
977
- numberPrecision: this.numberPrecision,
978
- minDecimals: this.minDecimals,
979
- })
980
- //this.value=value
975
+ this.$emit(EVENT_TYPES.INPUT_DRAG, this.onChangeHandler(value))
981
976
  },
982
977
  stopInteract(e) {
983
978
  e.preventDefault()
@@ -985,6 +980,9 @@
985
980
  window.removeEventListener('mouseup', this.stopInteract, false)
986
981
  this.blurInput()
987
982
  },
983
+ handleSelectChange(value) {
984
+ this.$emit(EVENT_TYPES.SELECT_CHANGE, value)
985
+ },
988
986
  },
989
987
  }
990
988
  </script>