@eturnity/eturnity_reusable_components 8.19.8-EPDM-12618.6 → 8.19.8-EPDM-14690.2
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/DemoChart.vue +424 -0
- package/src/TestChart.vue +229 -0
- package/src/components/barchart/BottomFields.vue +121 -37
- package/src/components/barchart/composables/useAxisCalculations.js +1 -1
- package/src/components/barchart/composables/useChartData.js +1 -1
- package/src/components/barchart/composables/useTooltip.js +28 -3
- package/src/components/barchart/index.vue +53 -15
- package/src/components/barchart/styles/bottomFields.js +18 -4
- package/src/components/barchart/styles/chart.js +1 -0
- package/src/components/errorMessage/index.vue +1 -1
- package/src/components/infoCard/index.vue +15 -3
- package/src/components/infoCard/infoCard.spec.js +3 -3
- package/src/components/infoText/index.vue +36 -31
- package/src/components/inputs/inputNumber/index.vue +87 -5
- package/src/components/inputs/inputText/index.vue +3 -1
- package/src/components/pageTitle/index.vue +0 -1
- package/src/components/tableDropdown/index.vue +4 -6
@@ -1,14 +1,14 @@
|
|
1
1
|
<template>
|
2
2
|
<Container :is-chart-controls-shown-in-bottom="isChartControlsShownInBottom">
|
3
3
|
<LabelsColumn :width="yAxisWidth">
|
4
|
-
<LabelRow v-for="series in
|
4
|
+
<LabelRow v-for="series in seriesData" :key="series.name">
|
5
5
|
{{ series.name }}
|
6
6
|
</LabelRow>
|
7
|
-
<TotalRow v-if="
|
8
|
-
{{ $gettext ? $gettext('Total (%)
|
7
|
+
<TotalRow v-if="seriesData.length && fieldMode === 'percentage'">
|
8
|
+
{{ $gettext ? `${$gettext('Total')} (%)` : 'Total (%)' }}
|
9
9
|
</TotalRow>
|
10
|
-
<TotalRow v-if="
|
11
|
-
{{ $gettext ? $gettext('Total (kWh)
|
10
|
+
<TotalRow v-if="seriesData.length">
|
11
|
+
{{ $gettext ? `${$gettext('Total')} (kWh)` : 'Total (kWh)' }}
|
12
12
|
</TotalRow>
|
13
13
|
</LabelsColumn>
|
14
14
|
|
@@ -18,27 +18,35 @@
|
|
18
18
|
>
|
19
19
|
<FieldsWrapper>
|
20
20
|
<!-- For stacked bar chart -->
|
21
|
-
<template v-if="
|
21
|
+
<template v-if="seriesData.length">
|
22
22
|
<InputRow
|
23
|
-
v-for="series in
|
23
|
+
v-for="series in seriesData"
|
24
24
|
:key="series.name"
|
25
25
|
:data-series-name="series.name"
|
26
26
|
>
|
27
27
|
<InputGroup
|
28
28
|
v-for="(item, index) in props.data"
|
29
|
+
:key="index"
|
29
30
|
:bar-width="barWidth"
|
30
31
|
:is-scrollable="isScrollable"
|
31
|
-
:key="index"
|
32
32
|
>
|
33
33
|
<InputNumber
|
34
34
|
:allow-negative="false"
|
35
|
+
:disabled="isInputsDisabled"
|
35
36
|
input-height="36px"
|
36
|
-
:
|
37
|
+
:is-info-border="
|
38
|
+
fieldMode === 'percentage'
|
39
|
+
? calculatePercentageTotal(item.label) !== 100
|
40
|
+
: false
|
41
|
+
"
|
37
42
|
:min-decimals="0"
|
43
|
+
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
38
44
|
text-align="center"
|
39
45
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
40
46
|
:value="getDisplayValue(series.data, item.label)"
|
41
|
-
@input-blur="
|
47
|
+
@input-blur="
|
48
|
+
handleInputBlur($event, series.name, item.label, series.data)
|
49
|
+
"
|
42
50
|
@input-focus="handleInputFocus(series.name, item.label)"
|
43
51
|
/>
|
44
52
|
</InputGroup>
|
@@ -47,16 +55,17 @@
|
|
47
55
|
<TotalInputRow v-if="fieldMode === 'percentage'">
|
48
56
|
<InputGroup
|
49
57
|
v-for="(item, index) in props.data"
|
58
|
+
:key="index"
|
50
59
|
:bar-width="barWidth"
|
51
60
|
:is-scrollable="isScrollable"
|
52
|
-
:key="index"
|
53
61
|
>
|
54
62
|
<InputNumber
|
55
63
|
:allow-negative="false"
|
64
|
+
:disabled="isInputsDisabled"
|
56
65
|
input-height="36px"
|
57
66
|
:is-read-only="true"
|
58
|
-
:number-precision="0"
|
59
67
|
:min-decimals="0"
|
68
|
+
:number-precision="fieldMode === 'percentage' ? 2 : 0"
|
60
69
|
text-align="center"
|
61
70
|
:unit-name="fieldMode === 'percentage' ? '%' : ''"
|
62
71
|
:value="calculatePercentageTotal(item.label)"
|
@@ -67,17 +76,23 @@
|
|
67
76
|
<TotalInputRow>
|
68
77
|
<InputGroup
|
69
78
|
v-for="(item, index) in props.data"
|
79
|
+
:key="index"
|
70
80
|
:bar-width="barWidth"
|
71
81
|
:is-scrollable="isScrollable"
|
72
|
-
:key="index"
|
73
82
|
>
|
74
83
|
<InputNumber
|
75
84
|
input-height="36px"
|
85
|
+
:is-border-error-only="true"
|
86
|
+
:is-info-border="
|
87
|
+
fieldMode === 'percentage'
|
88
|
+
? calculatePercentageTotal(item.label) !== 100
|
89
|
+
: false
|
90
|
+
"
|
76
91
|
:is-read-only="true"
|
77
|
-
:number-precision="2"
|
78
92
|
:min-decimals="0"
|
93
|
+
:number-precision="0"
|
79
94
|
text-align="center"
|
80
|
-
:value="
|
95
|
+
:value="calculateTotalValue(item.label)"
|
81
96
|
/>
|
82
97
|
</InputGroup>
|
83
98
|
</TotalInputRow>
|
@@ -88,17 +103,19 @@
|
|
88
103
|
<InputRow>
|
89
104
|
<InputGroup
|
90
105
|
v-for="(item, index) in props.data"
|
106
|
+
:key="index"
|
91
107
|
:bar-width="barWidth"
|
92
108
|
:is-scrollable="isScrollable"
|
93
|
-
:key="index"
|
94
109
|
>
|
95
110
|
<InputNumber
|
111
|
+
:allow-negative="false"
|
112
|
+
:disabled="isInputsDisabled"
|
96
113
|
input-height="36px"
|
97
114
|
:min-decimals="0"
|
98
|
-
:number-precision="
|
115
|
+
:number-precision="0"
|
99
116
|
text-align="center"
|
100
117
|
:value="item.value"
|
101
|
-
@input-blur="handleInputBlur($event, null, item.label)"
|
118
|
+
@input-blur="handleInputBlur($event, null, item.label, null)"
|
102
119
|
@input-focus="handleInputFocus(null, item.label)"
|
103
120
|
/>
|
104
121
|
</InputGroup>
|
@@ -107,11 +124,26 @@
|
|
107
124
|
</FieldsWrapper>
|
108
125
|
</FieldsContainer>
|
109
126
|
</Container>
|
127
|
+
<InfoCardContainer
|
128
|
+
v-if="hasAnySegmentNotTotatTo100Percent && fieldMode === 'percentage'"
|
129
|
+
:yAxisWidth="yAxisWidth"
|
130
|
+
>
|
131
|
+
<InfoCard align-items="center" type="info">
|
132
|
+
<InfoCardBody>
|
133
|
+
{{
|
134
|
+
$gettext
|
135
|
+
? $gettext('load_profile_not_add_up_to_100')
|
136
|
+
: 'load_profile_not_add_up_to_100'
|
137
|
+
}}
|
138
|
+
</InfoCardBody>
|
139
|
+
</InfoCard>
|
140
|
+
</InfoCardContainer>
|
110
141
|
</template>
|
111
142
|
|
112
143
|
<script setup>
|
113
|
-
import { ref } from 'vue'
|
144
|
+
import { ref, computed, watchEffect } from 'vue'
|
114
145
|
import InputNumber from '../inputs/inputNumber'
|
146
|
+
import InfoCard from '../infoCard'
|
115
147
|
|
116
148
|
import {
|
117
149
|
Container,
|
@@ -123,6 +155,8 @@
|
|
123
155
|
InputRow,
|
124
156
|
TotalInputRow,
|
125
157
|
InputGroup,
|
158
|
+
InfoCardContainer,
|
159
|
+
InfoCardBody,
|
126
160
|
} from './styles/bottomFields'
|
127
161
|
|
128
162
|
const props = defineProps({
|
@@ -159,6 +193,47 @@
|
|
159
193
|
default: 'absolute',
|
160
194
|
validator: (value) => ['absolute', 'percentage'].includes(value),
|
161
195
|
},
|
196
|
+
isInputsDisabled: {
|
197
|
+
type: Boolean,
|
198
|
+
default: false,
|
199
|
+
},
|
200
|
+
})
|
201
|
+
|
202
|
+
const seriesData = ref([])
|
203
|
+
|
204
|
+
watchEffect(() => {
|
205
|
+
let isNewSetOfSeries = false
|
206
|
+
const seriesDataCopy = [...seriesData.value]
|
207
|
+
if (
|
208
|
+
!seriesDataCopy.length ||
|
209
|
+
!props.series.length ||
|
210
|
+
seriesDataCopy.length !== props.series.length ||
|
211
|
+
!seriesDataCopy.some((item) => {
|
212
|
+
return props.series.map((s) => s.name).includes(item.name)
|
213
|
+
})
|
214
|
+
) {
|
215
|
+
isNewSetOfSeries = true
|
216
|
+
}
|
217
|
+
const currentSeriesData = !isNewSetOfSeries ? seriesDataCopy : []
|
218
|
+
const newSeriesData = []
|
219
|
+
|
220
|
+
props.series.forEach((item, itemIndex) => {
|
221
|
+
const data = item.data.map((d, dIndex) => ({
|
222
|
+
label: d.label,
|
223
|
+
value: d.value,
|
224
|
+
percentage: d.percentage,
|
225
|
+
originalValue: currentSeriesData.length
|
226
|
+
? currentSeriesData[itemIndex].data[dIndex].originalValue
|
227
|
+
: d.value,
|
228
|
+
}))
|
229
|
+
|
230
|
+
newSeriesData.push({
|
231
|
+
name: item.name,
|
232
|
+
data,
|
233
|
+
})
|
234
|
+
})
|
235
|
+
|
236
|
+
seriesData.value = [...newSeriesData]
|
162
237
|
})
|
163
238
|
|
164
239
|
const emit = defineEmits([
|
@@ -175,11 +250,13 @@
|
|
175
250
|
emit('input-focus', { seriesName, label })
|
176
251
|
}
|
177
252
|
|
178
|
-
const
|
179
|
-
|
253
|
+
const calculateTotalValue = (label) => {
|
254
|
+
const total = seriesData.value.reduce((sum, series) => {
|
180
255
|
const value = series.data.find((d) => d.label === label)?.value || 0
|
181
256
|
return sum + value
|
182
257
|
}, 0)
|
258
|
+
|
259
|
+
return Math.round(total)
|
183
260
|
}
|
184
261
|
|
185
262
|
const syncScroll = (scrollLeft) => {
|
@@ -190,34 +267,35 @@
|
|
190
267
|
container.scrollLeft = scrollLeft
|
191
268
|
}
|
192
269
|
}
|
193
|
-
|
270
|
+
|
271
|
+
const getDisplayValue = (data, label, shouldRound = true) => {
|
194
272
|
if (props.fieldMode === 'absolute') {
|
195
|
-
return
|
273
|
+
return data.find((d) => d.label === label)?.value
|
196
274
|
}
|
197
275
|
|
198
|
-
|
199
|
-
const total = calculateTotal(label)
|
200
|
-
return total ? Number(((value / total) * 100).toFixed(0)) : 0
|
276
|
+
return data.find((d) => d.label === label)?.percentage
|
201
277
|
}
|
202
278
|
|
203
279
|
const calculatePercentageTotal = (label) => {
|
204
|
-
|
205
|
-
const
|
206
|
-
|
207
|
-
const percentage = total ? Number(((value / total) * 100).toFixed(0)) : 0
|
280
|
+
const percentageTotal = seriesData.value.reduce((sum, series) => {
|
281
|
+
const percentage =
|
282
|
+
series.data.find((d) => d.label === label)?.percentage || 0
|
208
283
|
return sum + percentage
|
209
284
|
}, 0)
|
285
|
+
|
286
|
+
return Math.round(percentageTotal)
|
210
287
|
}
|
211
288
|
|
212
|
-
const handleInputBlur = (_value, seriesName, label) => {
|
289
|
+
const handleInputBlur = (_value, seriesName, label, currentSeriesData) => {
|
213
290
|
let value = Number(_value)
|
214
291
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
292
|
+
const payload = seriesName
|
293
|
+
? {
|
294
|
+
seriesName,
|
295
|
+
label,
|
296
|
+
value,
|
297
|
+
}
|
298
|
+
: { label, value }
|
221
299
|
emit('input-blur', payload)
|
222
300
|
focusedInput.value = null
|
223
301
|
|
@@ -243,6 +321,12 @@
|
|
243
321
|
}
|
244
322
|
}
|
245
323
|
|
324
|
+
const hasAnySegmentNotTotatTo100Percent = computed(() => {
|
325
|
+
return props.data.some((d) => {
|
326
|
+
return calculatePercentageTotal(d.label) !== 100
|
327
|
+
})
|
328
|
+
})
|
329
|
+
|
246
330
|
const handleFieldsScroll = (event) => {
|
247
331
|
emit('sync-scroll', event.target.scrollLeft)
|
248
332
|
}
|
@@ -84,7 +84,7 @@ export function useAxisCalculations(props, maxValue) {
|
|
84
84
|
})
|
85
85
|
|
86
86
|
const yAxisWidth = computed(() => {
|
87
|
-
return !!props.yAxisTitle || props.isBottomFieldsShown ? '
|
87
|
+
return !!props.yAxisTitle || props.isBottomFieldsShown ? '80px' : '60px'
|
88
88
|
})
|
89
89
|
|
90
90
|
const isChartControlsShown = (position) => {
|
@@ -66,7 +66,7 @@ export function useChartData(props, paddedMaxValue) {
|
|
66
66
|
let accumulated = 0
|
67
67
|
return {
|
68
68
|
label: item.label,
|
69
|
-
segments: [...props.series].
|
69
|
+
segments: [...props.series].map((series, index) => {
|
70
70
|
const value =
|
71
71
|
series.data.find((d) => d.label === item.label)?.value || 0
|
72
72
|
accumulated += value
|
@@ -16,7 +16,21 @@ export function useTooltip(chartId, normalizedData) {
|
|
16
16
|
if (!showTooltipContent.value) {
|
17
17
|
showTooltipContent.value = true
|
18
18
|
}
|
19
|
-
if (isObjectEqual(item, tooltipData.value))
|
19
|
+
if (isObjectEqual(item, tooltipData.value)) {
|
20
|
+
return
|
21
|
+
}
|
22
|
+
|
23
|
+
const totalValue = item.segments.reduce((acc, segment) => {
|
24
|
+
return acc + segment.value
|
25
|
+
}, 0)
|
26
|
+
|
27
|
+
const segments = item.segments.map((segment) => {
|
28
|
+
let valuePercentage = (segment.value / totalValue) * 100
|
29
|
+
segment.valuePercentage = Math.round(valuePercentage)
|
30
|
+
|
31
|
+
return segment
|
32
|
+
})
|
33
|
+
item.segments = segments
|
20
34
|
|
21
35
|
tooltipData.value = { ...item }
|
22
36
|
|
@@ -41,16 +55,27 @@ export function useTooltip(chartId, normalizedData) {
|
|
41
55
|
|
42
56
|
isInputFocused.value = true
|
43
57
|
const barData = normalizedData.value.find((item) => item.label === label)
|
44
|
-
|
45
58
|
if (!barData) return
|
59
|
+
|
60
|
+
const totalValue = barData.segments.reduce((acc, segment) => {
|
61
|
+
return acc + segment.value
|
62
|
+
}, 0)
|
63
|
+
const segments = barData.segments.map((segment) => {
|
64
|
+
let valuePercentage = (segment.value / totalValue) * 100
|
65
|
+
segment.valuePercentage = Math.round(valuePercentage)
|
66
|
+
|
67
|
+
return segment
|
68
|
+
})
|
69
|
+
barData.segments = segments
|
46
70
|
focusedBarData.value = barData
|
71
|
+
|
47
72
|
const barElement = document.querySelector(
|
48
73
|
`.barchart-${chartId} .bar-group:nth-child(${
|
49
74
|
normalizedData.value.indexOf(barData) + 1
|
50
75
|
})`
|
51
76
|
)
|
52
|
-
|
53
77
|
if (!barElement) return
|
78
|
+
|
54
79
|
// Get the last bar segment, samee as hover behavior
|
55
80
|
const targetElement = barElement.querySelector('.bar-segment:last-child')
|
56
81
|
const rect = targetElement.getBoundingClientRect()
|
@@ -17,7 +17,7 @@
|
|
17
17
|
/>
|
18
18
|
</ChartControlsWrapper>
|
19
19
|
<GraphSection :height="height" :width="width">
|
20
|
-
<YAxis :
|
20
|
+
<YAxis :height="height" :width="yAxisWidth">
|
21
21
|
<YAxisTitleWrapper v-if="yAxisTitle" :height="yAxisHeight">
|
22
22
|
{{ yAxisTitle }}
|
23
23
|
</YAxisTitleWrapper>
|
@@ -30,15 +30,15 @@
|
|
30
30
|
)
|
31
31
|
"
|
32
32
|
>
|
33
|
-
<YAxisLabel>{{ label }}</YAxisLabel>
|
33
|
+
<YAxisLabel>{{ getYAxisLabel(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
|
-
:is-scrollable="isScrollable"
|
41
40
|
:height="height"
|
41
|
+
:is-scrollable="isScrollable"
|
42
42
|
@scroll="handleChartScroll"
|
43
43
|
>
|
44
44
|
<ChartContent
|
@@ -64,19 +64,19 @@
|
|
64
64
|
<BarsContainer>
|
65
65
|
<BarGroup
|
66
66
|
v-for="(item, index) in normalizedData"
|
67
|
+
:key="index"
|
67
68
|
:bar-width="barWidth"
|
68
69
|
class="bar-group"
|
69
70
|
:is-scrollable="isScrollable"
|
70
|
-
:key="index"
|
71
71
|
>
|
72
72
|
<BarWrapper>
|
73
73
|
<BarSegment
|
74
74
|
v-for="(segment, segIndex) in item.segments"
|
75
|
+
:key="segIndex"
|
75
76
|
class="bar-segment"
|
76
77
|
:gradient-from="getSegmentGradient(index, segment).from"
|
77
78
|
:gradient-to="getSegmentGradient(index, segment).to"
|
78
79
|
:height="`${segment.percentage}%`"
|
79
|
-
:key="segIndex"
|
80
80
|
:z-index="item.segments.length - segIndex"
|
81
81
|
@mouseenter="showTooltip(item, $event, series)"
|
82
82
|
@mouseleave="hideTooltip"
|
@@ -96,7 +96,7 @@
|
|
96
96
|
:left="tooltipStyle.left"
|
97
97
|
:top="tooltipStyle.top"
|
98
98
|
>
|
99
|
-
<slot :item="tooltipData" name="tooltip"
|
99
|
+
<slot :item="tooltipData" name="tooltip"></slot>
|
100
100
|
<TooltipTextWrapper v-if="!slots.tooltip && tooltipData">
|
101
101
|
<template v-if="!series.length">
|
102
102
|
<TooltipText font-weight="500">{{ tooltipData.label }}</TooltipText>
|
@@ -128,7 +128,11 @@
|
|
128
128
|
:gradient-to="segment.gradientTo"
|
129
129
|
/>
|
130
130
|
<TooltipText>
|
131
|
-
{{
|
131
|
+
{{
|
132
|
+
fieldMode === 'absolute' && showPercentageOnTooltip
|
133
|
+
? `${segment.valuePercentage}%`
|
134
|
+
: handleValueFormatter(segment.value)
|
135
|
+
}}
|
132
136
|
</TooltipText>
|
133
137
|
</TooltipRow>
|
134
138
|
</template>
|
@@ -159,6 +163,7 @@
|
|
159
163
|
:data="data"
|
160
164
|
:field-mode="fieldMode"
|
161
165
|
:is-chart-controls-shown-in-bottom="isChartControlsShown('bottom')"
|
166
|
+
:is-inputs-disabled="isLoading"
|
162
167
|
:is-scrollable="isScrollable"
|
163
168
|
:series="series"
|
164
169
|
:y-axis-width="yAxisWidth"
|
@@ -171,12 +176,13 @@
|
|
171
176
|
</template>
|
172
177
|
|
173
178
|
<script setup>
|
174
|
-
import { useSlots, computed } from 'vue'
|
179
|
+
import { useSlots, computed, ref } from 'vue'
|
175
180
|
|
176
181
|
import ChartControls from './ChartControls'
|
177
182
|
import BottomFields from './BottomFields'
|
178
183
|
import SelectionBox from './SelectionBox'
|
179
184
|
import Spinner from '../spinner'
|
185
|
+
import { numberToString } from '../../helpers/numberConverter'
|
180
186
|
|
181
187
|
import {
|
182
188
|
useTooltip,
|
@@ -246,10 +252,6 @@
|
|
246
252
|
type: String,
|
247
253
|
default: '',
|
248
254
|
},
|
249
|
-
valueFormatter: {
|
250
|
-
type: Function,
|
251
|
-
default: null,
|
252
|
-
},
|
253
255
|
isLegendShown: {
|
254
256
|
type: Boolean,
|
255
257
|
default: false,
|
@@ -296,6 +298,10 @@
|
|
296
298
|
type: Boolean,
|
297
299
|
default: false,
|
298
300
|
},
|
301
|
+
showPercentageOnTooltip: {
|
302
|
+
type: Boolean,
|
303
|
+
default: false,
|
304
|
+
},
|
299
305
|
})
|
300
306
|
|
301
307
|
const generateChartId = () =>
|
@@ -378,8 +384,40 @@
|
|
378
384
|
}
|
379
385
|
|
380
386
|
const handleValueFormatter = (value) => {
|
381
|
-
|
382
|
-
|
383
|
-
|
387
|
+
let formattedValue = value
|
388
|
+
if (value < 1000) {
|
389
|
+
formattedValue = numberToString({
|
390
|
+
value: formattedValue,
|
391
|
+
numberPrecision: 0,
|
392
|
+
minDecimals: 0,
|
393
|
+
})
|
394
|
+
} else if (value < 1000000) {
|
395
|
+
formattedValue = numberToString({
|
396
|
+
value: Number(formattedValue / 1000),
|
397
|
+
numberPrecision: 2,
|
398
|
+
minDecimals: 2,
|
399
|
+
})
|
400
|
+
} else {
|
401
|
+
formattedValue = numberToString({
|
402
|
+
value: Number(formattedValue / 1000000),
|
403
|
+
numberPrecision: 2,
|
404
|
+
minDecimals: 2,
|
405
|
+
})
|
406
|
+
}
|
407
|
+
if (value < 1000) {
|
408
|
+
return `${formattedValue} kWh`
|
409
|
+
} else if (value < 1000000) {
|
410
|
+
return `${formattedValue} MWh`
|
411
|
+
} else {
|
412
|
+
return `${formattedValue} GWh`
|
413
|
+
}
|
414
|
+
}
|
415
|
+
|
416
|
+
const getYAxisLabel = (label) => {
|
417
|
+
return numberToString({
|
418
|
+
value: label,
|
419
|
+
numberPrecision: 0,
|
420
|
+
minDecimals: 0,
|
421
|
+
})
|
384
422
|
}
|
385
423
|
</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;
|
20
21
|
font-size: 12px;
|
21
22
|
font-weight: 500;
|
22
23
|
color: ${(props) => props.theme.semanticColors.teal[600]};
|
23
24
|
display: flex;
|
24
|
-
align-items:
|
25
|
+
align-items: center;
|
25
26
|
`
|
26
27
|
|
27
28
|
export const TotalRow = styled(LabelRow)``
|
28
29
|
|
29
30
|
export const FieldsContainer = styled.div`
|
30
31
|
flex: 1;
|
31
|
-
overflow-x: auto;
|
32
32
|
scrollbar-width: none;
|
33
33
|
|
34
34
|
&::-webkit-scrollbar {
|
@@ -59,8 +59,22 @@ export const InputGroup = styled('div', {
|
|
59
59
|
barWidth: Number,
|
60
60
|
isScrollable: Boolean,
|
61
61
|
})`
|
62
|
-
${(props) => (props.isScrollable ? 'min-width' : 'width')}
|
63
|
-
props.barWidth}px;
|
62
|
+
${(props) => (props.isScrollable ? 'min-width' : 'width')}: 70px;
|
64
63
|
display: flex;
|
65
64
|
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;
|
66
80
|
`
|
@@ -73,7 +73,12 @@
|
|
73
73
|
type: {
|
74
74
|
required: false,
|
75
75
|
type: String,
|
76
|
-
default: '
|
76
|
+
default: 'info_simple',
|
77
|
+
validator(value) {
|
78
|
+
return ['info_simple', 'warning', 'error_minor', 'info'].includes(
|
79
|
+
value
|
80
|
+
)
|
81
|
+
},
|
77
82
|
},
|
78
83
|
minWidth: {
|
79
84
|
required: false,
|
@@ -112,8 +117,11 @@
|
|
112
117
|
},
|
113
118
|
},
|
114
119
|
computed: {
|
115
|
-
|
120
|
+
isInfoSimple() {
|
116
121
|
// this property is used for tests
|
122
|
+
return this.type === 'info_simple'
|
123
|
+
},
|
124
|
+
isInfo() {
|
117
125
|
return this.type === 'info'
|
118
126
|
},
|
119
127
|
isWarning() {
|
@@ -148,9 +156,13 @@
|
|
148
156
|
stylesCollection.borderStyle = 'dashed'
|
149
157
|
stylesCollection.borderColor = theme.colors.grey4
|
150
158
|
stylesCollection.iconColor = theme.colors.red
|
151
|
-
} else {
|
159
|
+
} else if (this.isInfoSimple) {
|
152
160
|
stylesCollection.borderStyle = 'dashed'
|
153
161
|
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]
|
154
166
|
}
|
155
167
|
|
156
168
|
return stylesCollection
|
@@ -45,19 +45,19 @@ describe('RCInfoCard.vue', () => {
|
|
45
45
|
},
|
46
46
|
})
|
47
47
|
|
48
|
-
expect(wrapper.vm.
|
48
|
+
expect(wrapper.vm.isInfoSimple).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.
|
54
|
+
expect(wrapper.vm.isInfoSimple).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.
|
60
|
+
expect(wrapper.vm.isInfoSimple).toBe(false)
|
61
61
|
expect(wrapper.vm.isWarning).toBe(false)
|
62
62
|
expect(wrapper.vm.isErrorMinor).toBe(true)
|
63
63
|
})
|