@eturnity/eturnity_reusable_components 8.19.8-EPDM-14690.4 → 8.19.8-EPDM-11600.11

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.
@@ -17,8 +17,8 @@
17
17
  />
18
18
  </ChartControlsWrapper>
19
19
  <GraphSection :height="height" :width="width">
20
- <YAxis :height="height" :width="yAxisWidth">
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
@@ -30,15 +30,15 @@
30
30
  )
31
31
  "
32
32
  >
33
- <YAxisLabel>{{ getYAxisLabel(label) }}</YAxisLabel>
33
+ <YAxisLabel>{{ label }}</YAxisLabel>
34
34
  <YAxisLine :y-axis-width="yAxisWidth" />
35
35
  </YAxisRow>
36
36
  </YAxis>
37
37
 
38
38
  <ScrollContainer
39
39
  :class="`chart-scroll-container-${chartId}`"
40
- :height="height"
41
40
  :is-scrollable="isScrollable"
41
+ :height="height"
42
42
  @scroll="handleChartScroll"
43
43
  >
44
44
  <ChartContent
@@ -51,6 +51,11 @@
51
51
  <LoadingOverlay v-if="isLoading">
52
52
  <Spinner size="60px" />
53
53
  </LoadingOverlay>
54
+ <InfoCardContainer v-else-if="!isDataIssueMessageDisplayed">
55
+ <RCInfoCard align-items="center">
56
+ {{ dataIssueMessage }}
57
+ </RCInfoCard>
58
+ </InfoCardContainer>
54
59
  <SelectionBox
55
60
  v-if="selectionSize && isSelectionEnabled"
56
61
  :bar-width="barWidth"
@@ -64,19 +69,19 @@
64
69
  <BarsContainer>
65
70
  <BarGroup
66
71
  v-for="(item, index) in normalizedData"
67
- :key="index"
68
72
  :bar-width="barWidth"
69
73
  class="bar-group"
70
74
  :is-scrollable="isScrollable"
75
+ :key="index"
71
76
  >
72
77
  <BarWrapper>
73
78
  <BarSegment
74
79
  v-for="(segment, segIndex) in item.segments"
75
- :key="segIndex"
76
80
  class="bar-segment"
77
81
  :gradient-from="getSegmentGradient(index, segment).from"
78
82
  :gradient-to="getSegmentGradient(index, segment).to"
79
83
  :height="`${segment.percentage}%`"
84
+ :key="segIndex"
80
85
  :z-index="item.segments.length - segIndex"
81
86
  @mouseenter="showTooltip(item, $event, series)"
82
87
  @mouseleave="hideTooltip"
@@ -96,7 +101,7 @@
96
101
  :left="tooltipStyle.left"
97
102
  :top="tooltipStyle.top"
98
103
  >
99
- <slot :item="tooltipData" name="tooltip"></slot>
104
+ <slot :item="tooltipData" name="tooltip" />
100
105
  <TooltipTextWrapper v-if="!slots.tooltip && tooltipData">
101
106
  <template v-if="!series.length">
102
107
  <TooltipText font-weight="500">{{ tooltipData.label }}</TooltipText>
@@ -128,11 +133,7 @@
128
133
  :gradient-to="segment.gradientTo"
129
134
  />
130
135
  <TooltipText>
131
- {{
132
- fieldMode === 'absolute' && showPercentageOnTooltip
133
- ? `${segment.valuePercentage}%`
134
- : handleValueFormatter(segment.value)
135
- }}
136
+ {{ handleValueFormatter(segment.value) }}
136
137
  </TooltipText>
137
138
  </TooltipRow>
138
139
  </template>
@@ -163,9 +164,7 @@
163
164
  :data="data"
164
165
  :field-mode="fieldMode"
165
166
  :is-chart-controls-shown-in-bottom="isChartControlsShown('bottom')"
166
- :is-inputs-disabled="isLoading"
167
167
  :is-scrollable="isScrollable"
168
- :percentage-error-message="percentageErrorMessage"
169
168
  :series="series"
170
169
  :y-axis-width="yAxisWidth"
171
170
  @input-blur="handleInputBlur"
@@ -177,13 +176,13 @@
177
176
  </template>
178
177
 
179
178
  <script setup>
180
- import { useSlots, computed, ref } from 'vue'
179
+ import { useSlots, computed } from 'vue'
181
180
 
182
181
  import ChartControls from './ChartControls'
183
182
  import BottomFields from './BottomFields'
184
183
  import SelectionBox from './SelectionBox'
184
+ import RCInfoCard from '../infoCard'
185
185
  import Spinner from '../spinner'
186
- import { numberToString } from '../../helpers/numberConverter'
187
186
 
188
187
  import {
189
188
  useTooltip,
@@ -217,6 +216,7 @@
217
216
  TooltipGradientBox,
218
217
  ChartControlsWrapper,
219
218
  LoadingOverlay,
219
+ InfoCardContainer,
220
220
  } from './styles/chart'
221
221
 
222
222
  const props = defineProps({
@@ -253,6 +253,10 @@
253
253
  type: String,
254
254
  default: '',
255
255
  },
256
+ valueFormatter: {
257
+ type: Function,
258
+ default: null,
259
+ },
256
260
  isLegendShown: {
257
261
  type: Boolean,
258
262
  default: false,
@@ -299,14 +303,14 @@
299
303
  type: Boolean,
300
304
  default: false,
301
305
  },
302
- showPercentageOnTooltip: {
303
- type: Boolean,
304
- default: false,
305
- },
306
- percentageErrorMessage: {
306
+ dataIssueMessage: {
307
307
  type: String,
308
308
  default: '',
309
309
  },
310
+ isDataIssueMessageDisplayed: {
311
+ type: Boolean,
312
+ default: false,
313
+ },
310
314
  })
311
315
 
312
316
  const generateChartId = () =>
@@ -389,40 +393,8 @@
389
393
  }
390
394
 
391
395
  const handleValueFormatter = (value) => {
392
- let formattedValue = value
393
- if (value < 1000) {
394
- formattedValue = numberToString({
395
- value: formattedValue,
396
- numberPrecision: 0,
397
- minDecimals: 0,
398
- })
399
- } else if (value < 1000000) {
400
- formattedValue = numberToString({
401
- value: Number(formattedValue / 1000),
402
- numberPrecision: 2,
403
- minDecimals: 2,
404
- })
405
- } else {
406
- formattedValue = numberToString({
407
- value: Number(formattedValue / 1000000),
408
- numberPrecision: 2,
409
- minDecimals: 2,
410
- })
411
- }
412
- if (value < 1000) {
413
- return `${formattedValue} kWh`
414
- } else if (value < 1000000) {
415
- return `${formattedValue} MWh`
416
- } else {
417
- return `${formattedValue} GWh`
418
- }
419
- }
420
-
421
- const getYAxisLabel = (label) => {
422
- return numberToString({
423
- value: label,
424
- numberPrecision: 0,
425
- minDecimals: 0,
426
- })
396
+ return props.valueFormatter
397
+ ? props.valueFormatter(Math.round(value))
398
+ : value
427
399
  }
428
400
  </script>
@@ -17,18 +17,18 @@ export const LabelsColumn = styled('div', { width: String })`
17
17
 
18
18
  export const LabelRow = styled.div`
19
19
  height: 32px;
20
- padding-top: 5px;
21
20
  font-size: 12px;
22
21
  font-weight: 500;
23
22
  color: ${(props) => props.theme.semanticColors.teal[600]};
24
23
  display: flex;
25
- align-items: center;
24
+ align-items: flex-start;
26
25
  `
27
26
 
28
27
  export const TotalRow = styled(LabelRow)``
29
28
 
30
29
  export const FieldsContainer = styled.div`
31
30
  flex: 1;
31
+ overflow-x: auto;
32
32
  scrollbar-width: none;
33
33
 
34
34
  &::-webkit-scrollbar {
@@ -59,22 +59,8 @@ export const InputGroup = styled('div', {
59
59
  barWidth: Number,
60
60
  isScrollable: Boolean,
61
61
  })`
62
- ${(props) => (props.isScrollable ? 'min-width' : 'width')}: 70px;
62
+ ${(props) => (props.isScrollable ? 'min-width' : 'width')}:${(props) =>
63
+ props.barWidth}px;
63
64
  display: flex;
64
65
  justify-content: center;
65
- position: relative;
66
-
67
- input[readonly] {
68
- border: 1px solid ${(props) => props.theme.colors.grey4} !important;
69
- }
70
- `
71
-
72
- export const InfoCardContainer = styled('div', { yAxisWidth: String })`
73
- margin-left: ${(props) => props.yAxisWidth};
74
- padding: 12px;
75
- margin-top: 12px;
76
- `
77
-
78
- export const InfoCardBody = styled.div`
79
- padding: 8px 0;
80
66
  `
@@ -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', {
@@ -127,7 +125,6 @@ export const BarWrapper = styled.div`
127
125
  height: 100%;
128
126
  width: 100%;
129
127
  position: relative;
130
- overflow: hidden;
131
128
  `
132
129
 
133
130
  export const BarSegment = styled('div', {
@@ -271,3 +268,12 @@ export const LoadingOverlay = styled('div')`
271
268
  align-items: center;
272
269
  z-index: 2;
273
270
  `
271
+
272
+ export const InfoCardContainer = styled('div')`
273
+ position: absolute;
274
+ top: 50%;
275
+ left: 50%;
276
+ transform: translate(-50%, -50%);
277
+ max-width: 500px;
278
+ z-index: 2;
279
+ `
@@ -240,8 +240,6 @@
240
240
  return this.isDisabled
241
241
  ? this.theme.mainButton[this.appTheme][this.type][this.variant]
242
242
  .disabled.textColor
243
- : this.iconColor
244
- ? this.iconColor
245
243
  : this.theme.mainButton[this.appTheme][this.type][this.variant]
246
244
  .default.textColor
247
245
  },
@@ -19,7 +19,7 @@
19
19
  background: ${(props) => props.theme.colors.red};
20
20
  padding: 10px;
21
21
  width: max-content;
22
- /* max-width: 100%; */
22
+ max-width: 100%;
23
23
  min-width: min-content;
24
24
  font-size: 11px;
25
25
  font-weight: 400;
@@ -208,11 +208,9 @@
208
208
  !props.disableHover &&
209
209
  `
210
210
  &:hover svg path:not(.fix, .isStrokePath) {
211
- ${`${props.fillType}: ${
212
- props.theme.colors[props.hoveredColor] || props.color
213
- };`}
211
+ ${`${props.fillType}: ${props.hoveredColor || props.color};`}
214
212
  &:hover svg isStrokePath:not(.fix) {
215
- ${`stroke: ${props.theme.colors[props.hoveredColor] || props.color};`}
213
+ ${`stroke: ${props.hoveredColor || props.color};`}
216
214
  }
217
215
  &:hover + div {
218
216
  background-color: ${props.hoveredColor};
@@ -73,12 +73,7 @@
73
73
  type: {
74
74
  required: false,
75
75
  type: String,
76
- default: 'info_simple',
77
- validator(value) {
78
- return ['info_simple', 'warning', 'error_minor', 'info'].includes(
79
- value
80
- )
81
- },
76
+ default: 'info',
82
77
  },
83
78
  minWidth: {
84
79
  required: false,
@@ -117,11 +112,8 @@
117
112
  },
118
113
  },
119
114
  computed: {
120
- isInfoSimple() {
121
- // this property is used for tests
122
- return this.type === 'info_simple'
123
- },
124
115
  isInfo() {
116
+ // this property is used for tests
125
117
  return this.type === 'info'
126
118
  },
127
119
  isWarning() {
@@ -156,13 +148,9 @@
156
148
  stylesCollection.borderStyle = 'dashed'
157
149
  stylesCollection.borderColor = theme.colors.grey4
158
150
  stylesCollection.iconColor = theme.colors.red
159
- } else if (this.isInfoSimple) {
151
+ } else {
160
152
  stylesCollection.borderStyle = 'dashed'
161
153
  stylesCollection.borderColor = theme.colors.grey4
162
- } else {
163
- stylesCollection.color = theme.semanticColors.teal[800]
164
- stylesCollection.backgroundColor = theme.semanticColors.blue[300]
165
- stylesCollection.iconColor = theme.semanticColors.teal[800]
166
154
  }
167
155
 
168
156
  return stylesCollection
@@ -45,19 +45,19 @@ describe('RCInfoCard.vue', () => {
45
45
  },
46
46
  })
47
47
 
48
- expect(wrapper.vm.isInfoSimple).toBe(true)
48
+ expect(wrapper.vm.isInfo).toBe(true)
49
49
  expect(wrapper.vm.isWarning).toBe(false)
50
50
  expect(wrapper.vm.isErrorMinor).toBe(false)
51
51
 
52
52
  await wrapper.setProps({ type: 'warning' })
53
53
 
54
- expect(wrapper.vm.isInfoSimple).toBe(false)
54
+ expect(wrapper.vm.isInfo).toBe(false)
55
55
  expect(wrapper.vm.isWarning).toBe(true)
56
56
  expect(wrapper.vm.isErrorMinor).toBe(false)
57
57
 
58
58
  await wrapper.setProps({ type: 'error_minor' })
59
59
 
60
- expect(wrapper.vm.isInfoSimple).toBe(false)
60
+ expect(wrapper.vm.isInfo).toBe(false)
61
61
  expect(wrapper.vm.isWarning).toBe(false)
62
62
  expect(wrapper.vm.isErrorMinor).toBe(true)
63
63
  })
@@ -15,40 +15,37 @@
15
15
  :is-disabled="isDisabled"
16
16
  :padding="padding"
17
17
  >
18
- <template v-if="!$slots.trigger">
19
- <LabelWrapper
20
- v-if="labelText && labelAlign === 'left'"
21
- :color="iconColor || computedIconColor"
22
- :size="labelSize"
23
- >
24
- {{ labelText }}
25
- </LabelWrapper>
26
- <Dot
27
- v-if="type === 'dot'"
28
- :color="dotColor"
29
- data-test-id="infoText_dot"
30
- />
31
- <IconComponent
32
- v-else-if="!noIcon"
33
- :color="iconColor || computedIconColor"
34
- :cursor="isDisabled ? 'not-allowed' : 'pointer'"
35
- :disabled="isDisabled"
36
- :hovered-color="iconColor || computedIconColor"
37
- :name="iconName"
38
- :size="size"
39
- />
40
- <LabelWrapper
41
- v-if="labelText && labelAlign === 'right'"
42
- :color="iconColor || computedIconColor"
43
- :size="labelSize"
44
- >
45
- {{ labelText }}
46
- </LabelWrapper>
47
- </template>
48
- <slot name="trigger"></slot>
18
+ <LabelWrapper
19
+ v-if="labelText && labelAlign === 'left'"
20
+ :color="iconColor || computedIconColor"
21
+ :size="labelSize"
22
+ >
23
+ {{ labelText }}
24
+ </LabelWrapper>
25
+ <Dot
26
+ v-if="type === 'dot'"
27
+ :color="dotColor"
28
+ data-test-id="infoText_dot"
29
+ />
30
+ <IconComponent
31
+ v-else-if="!noIcon"
32
+ :color="iconColor || computedIconColor"
33
+ :cursor="isDisabled ? 'not-allowed' : 'pointer'"
34
+ :disabled="isDisabled"
35
+ :hovered-color="iconColor || computedIconColor"
36
+ :name="iconName"
37
+ :size="size"
38
+ />
39
+ <LabelWrapper
40
+ v-if="labelText && labelAlign === 'right'"
41
+ :color="iconColor || computedIconColor"
42
+ :size="labelSize"
43
+ >
44
+ {{ labelText }}
45
+ </LabelWrapper>
49
46
  </IconWrapper>
50
47
  </div>
51
- <Teleport v-if="isVisible && !!text" to="body">
48
+ <Teleport v-if="isVisible" to="body">
52
49
  <TextWrapper data-test-id="info_text_wrapper" :style="wrapperStyle">
53
50
  <TextOverlay
54
51
  ref="infoBox"
@@ -230,7 +227,7 @@
230
227
  },
231
228
  infoPosition: {
232
229
  required: false,
233
- default: null,
230
+ default: 'bottom',
234
231
  type: String,
235
232
  },
236
233
  maxWidth: {
@@ -366,9 +363,7 @@
366
363
  { position: 'left', space: spaceLeft },
367
364
  ].sort((a, b) => b.space - a.space)
368
365
 
369
- const bestPosition = props.infoPosition
370
- ? props.infoPosition
371
- : positions[0].position
366
+ const bestPosition = positions[0].position
372
367
 
373
368
  let top, left, arrowPosition
374
369
 
@@ -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: