@eturnity/eturnity_reusable_components 7.24.3-EPDM-11320.2 → 7.24.3-qa-elisee-7.32.0

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 (83) hide show
  1. package/.prettierrc +6 -8
  2. package/package.json +21 -9
  3. package/public/favicon.ico +0 -0
  4. package/public/index.html +17 -0
  5. package/src/App.vue +78 -79
  6. package/src/assets/svgIcons/adjust_roof.svg +6 -0
  7. package/src/assets/svgIcons/copy.svg +10 -0
  8. package/src/assets/theme.js +3 -3
  9. package/src/components/addNewButton/AddNewButton.stories.js +2 -2
  10. package/src/components/addNewButton/index.vue +51 -48
  11. package/src/components/banner/actionBanner/index.vue +55 -54
  12. package/src/components/banner/banner/banner.stories.js +5 -5
  13. package/src/components/banner/banner/index.vue +159 -159
  14. package/src/components/banner/infoBanner/index.vue +53 -41
  15. package/src/components/buttons/buttonIcon/index.vue +122 -125
  16. package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
  17. package/src/components/buttons/closeButton/index.vue +49 -49
  18. package/src/components/buttons/mainButton/index.vue +119 -119
  19. package/src/components/card/index.vue +70 -70
  20. package/src/components/collapsableInfoText/index.vue +94 -96
  21. package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
  22. package/src/components/deleteIcon/index.vue +54 -54
  23. package/src/components/draggableInputHandle/index.vue +37 -37
  24. package/src/components/dropdown/Dropdown.stories.js +10 -9
  25. package/src/components/dropdown/index.vue +106 -106
  26. package/src/components/errorMessage/index.vue +52 -52
  27. package/src/components/filter/filterSettings.vue +433 -439
  28. package/src/components/filter/index.vue +135 -135
  29. package/src/components/filter/parentDropdown.vue +73 -73
  30. package/src/components/icon/Icons.stories.js +7 -7
  31. package/src/components/icon/iconCollection.vue +53 -53
  32. package/src/components/icon/index.vue +121 -121
  33. package/src/components/iconWrapper/index.vue +156 -156
  34. package/src/components/infoCard/index.vue +26 -26
  35. package/src/components/infoText/index.vue +132 -133
  36. package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
  37. package/src/components/inputs/checkbox/index.vue +180 -190
  38. package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
  39. package/src/components/inputs/inputNumber/index.vue +644 -647
  40. package/src/components/inputs/inputNumberQuestion/index.vue +182 -185
  41. package/src/components/inputs/inputText/InputText.stories.js +22 -22
  42. package/src/components/inputs/inputText/index.vue +336 -337
  43. package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
  44. package/src/components/inputs/radioButton/index.vue +219 -221
  45. package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
  46. package/src/components/inputs/searchInput/index.vue +126 -126
  47. package/src/components/inputs/select/index.vue +776 -778
  48. package/src/components/inputs/select/option/index.vue +124 -124
  49. package/src/components/inputs/select/select.stories.js +32 -31
  50. package/src/components/inputs/slider/index.vue +99 -99
  51. package/src/components/inputs/switchField/index.vue +222 -220
  52. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
  53. package/src/components/inputs/textAreaInput/index.vue +173 -171
  54. package/src/components/inputs/toggle/Toggle.stories.js +14 -14
  55. package/src/components/inputs/toggle/index.vue +217 -214
  56. package/src/components/label/index.vue +82 -82
  57. package/src/components/markerItem/index.vue +66 -68
  58. package/src/components/modals/actionModal/index.vue +54 -54
  59. package/src/components/modals/infoModal/index.vue +36 -39
  60. package/src/components/modals/modal/index.vue +134 -134
  61. package/src/components/modals/modal/modal.stories.js +5 -5
  62. package/src/components/navigationTabs/index.vue +94 -96
  63. package/src/components/pageSubtitle/index.vue +49 -55
  64. package/src/components/pageTitle/index.vue +56 -56
  65. package/src/components/pagination/index.vue +89 -92
  66. package/src/components/progressBar/index.vue +107 -107
  67. package/src/components/projectMarker/index.vue +244 -246
  68. package/src/components/rangeSlider/Slider.vue +465 -491
  69. package/src/components/rangeSlider/index.vue +410 -410
  70. package/src/components/rangeSlider/utils/dom.js +5 -5
  71. package/src/components/selectedOptions/index.vue +119 -119
  72. package/src/components/sideMenu/index.vue +199 -199
  73. package/src/components/spinner/index.vue +57 -57
  74. package/src/components/tableDropdown/index.vue +520 -520
  75. package/src/components/tables/mainTable/index.vue +362 -366
  76. package/src/components/tables/viewTable/index.vue +171 -171
  77. package/src/components/threeDots/index.vue +334 -340
  78. package/src/components/videoThumbnail/index.vue +86 -86
  79. package/src/components/videoThumbnail/videoThumbnail.stories.js +16 -14
  80. package/src/helpers/numberConverter.js +2 -2
  81. package/src/helpers/translateLang.js +9 -9
  82. package/src/mixins/inputValidations.js +5 -5
  83. package/.eslintrc.js +0 -184
@@ -11,50 +11,50 @@
11
11
  <VerticalLabel>{{ label.name }}</VerticalLabel>
12
12
  <BarSlider>
13
13
  <Bar
14
- :data-id="`slider_bar_${dataLocation}_${label.id}`"
15
14
  @click.native.stop="
16
15
  onBarRightClick({ event: $event, label, type: 'add' })
17
16
  "
17
+ :data-id="`slider_bar_${dataLocation}_${label.id}`"
18
18
  >
19
19
  <SliderWrapper>
20
20
  <Slider
21
21
  v-for="(bar, index) in label.selectedTariffs"
22
+ :dataId="`slider_bar_item_${dataLocation}_${label.id}_${bar.name}`"
22
23
  :key="bar.id"
24
+ :draggable="!disabled"
25
+ :resizable="!disabled"
23
26
  :color="
24
27
  hasOverlap && OverlapId.includes(label.id)
25
28
  ? '#ff5656'
26
29
  : bar.color
27
30
  "
28
- :data-id="`slider_bar_item_${dataLocation}_${label.id}_${bar.name}`"
29
- :draggable="!disabled"
30
- :max="bar.max"
31
+ :minWidth="minWidth"
31
32
  :min="bar.min"
32
- :min-width="minWidth"
33
- :resizable="!disabled"
34
- :step="step"
35
- :step-count="stepCount"
36
- :sub-step-count="subStepCount"
33
+ :max="bar.max"
37
34
  :z="index"
38
- @activated="onActivateBar({ item: bar })"
39
- @click.native.stop="
40
- onBarTariffClick({ item: bar, type: 'delete', label })
41
- "
42
- @deactivated="onDeactivateBar()"
43
- @drag-stop="
35
+ :step="step"
36
+ :stepCount="stepCount"
37
+ :subStepCount="subStepCount"
38
+ @dragStop="
44
39
  onChange('drag', {
45
40
  itemId: bar.id,
46
41
  parentId: bar.parentId,
47
42
  entityId: label.id,
48
- ...$event,
43
+ ...$event
49
44
  })
50
45
  "
51
- @resize-stop="
46
+ @resizeStop="
52
47
  onChange('resize', {
53
48
  itemId: bar.id,
54
49
  entityId: label.id,
55
- ...$event,
50
+ ...$event
56
51
  })
57
52
  "
53
+ @click.native.stop="
54
+ onBarTariffClick({ item: bar, type: 'delete', label })
55
+ "
56
+ @activated="onActivateBar({ item: bar })"
57
+ @deactivated="onDeactivateBar()"
58
58
  >
59
59
  <template #mr>
60
60
  <HandleIcon />
@@ -66,10 +66,10 @@
66
66
  </SliderWrapper>
67
67
  </Bar>
68
68
  <Ruler>
69
- <RulerRule v-for="n in stepCount" :key="n" />
69
+ <RulerRule v-for="n in stepCount" :key="n"></RulerRule>
70
70
  </Ruler>
71
71
  <SubRuler>
72
- <RulerSubRule v-for="n in subStepCount" :key="n" />
72
+ <RulerSubRule v-for="n in subStepCount" :key="n"></RulerSubRule>
73
73
  </SubRuler>
74
74
  <ErrorMessage
75
75
  v-if="!canOverlap && hasOverlap && OverlapId.includes(label.id)"
@@ -79,13 +79,13 @@
79
79
  </BarSlider>
80
80
  </BarWrapper>
81
81
  </BarContainer>
82
- <BarOptionsContainer
82
+ <bar-options-container
83
83
  v-if="showBarOptions"
84
- ref="barDropdown"
85
- :left="barOptionsPosition.x"
86
84
  :top="barOptionsPosition.y"
85
+ :left="barOptionsPosition.x"
86
+ ref="barDropdown"
87
87
  >
88
- <BarItemContainer
88
+ <bar-item-container
89
89
  v-for="item in barOptionsList"
90
90
  :key="item.id"
91
91
  @click="
@@ -93,143 +93,143 @@
93
93
  "
94
94
  >
95
95
  <AddIcon />
96
- <BarItemText>{{ item.name }}</BarItemText>
97
- </BarItemContainer>
98
- </BarOptionsContainer>
96
+ <bar-item-text>{{ item.name }}</bar-item-text>
97
+ </bar-item-container>
98
+ </bar-options-container>
99
99
  </RangeSliderContainer>
100
100
  </template>
101
101
 
102
102
  <script>
103
- import styled from 'vue3-styled-components'
104
- import handleSVG from '../../assets/svgIcons/handle.svg'
105
- import add from '../../assets/svgIcons/add_icon.svg'
106
-
107
- import SliderComponent from './Slider'
108
-
109
- const wrapperAttrs = { width: String, height: String }
110
- const SliderWrapper = styled('div', wrapperAttrs)`
111
- position: relative;
112
- display: flex;
113
- height: ${(props) => props.height || '24px'};
114
- width: ${(props) => props.width || '100%'};
115
- `
116
-
117
- const sliderAttrs = { color: String, draggable: Boolean }
118
- const Slider = styled(SliderComponent, sliderAttrs)`
119
- cursor: ${(props) => (props.draggable ? 'pointer' : 'not-allowed')};
120
- opacity: 0.7;
121
- display: flex;
122
- justify-content: space-between;
123
- align-items: center;
124
- border: unset !important;
125
- background-color: ${(props) => props.color};
126
- `
127
-
128
- const ErrorMessage = styled.p`
129
- color: ${(props) => props.theme.colors.red};
130
- font-style: italic;
131
- font-size: 13px;
132
- margin-top: 5px;
133
- `
134
-
135
- const Bar = styled.div`
136
- display: flex;
137
- margin-bottom: -30px;
138
- margin-left: 1px;
139
- background-color: #f6faff;
140
- width: 100%;
141
- background-color: ${(props) => props.theme.colors.gray1};
142
- `
143
-
144
- const Ruler = styled.div`
145
- margin: 10px 0px -5px 0px;
146
- display: flex;
147
- overflow: hidden;
148
- `
149
-
150
- const RulerRule = styled.div`
151
- border-left: solid 1px ${(props) => props.theme.colors.grey2};
152
- border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
153
- display: flex;
154
- flex-grow: 1;
155
- flex-shrink: 1;
156
- padding: 10px 0px;
157
-
158
- &:last-child {
159
- border-right: solid 1px ${(props) => props.theme.colors.grey2};
160
- }
161
- `
162
-
163
- const SubRuler = styled.div`
164
- margin: -7px 0px -5px 0px;
165
- display: flex;
166
- `
167
-
168
- const RulerSubRule = styled.div`
169
- border-left: solid 1px ${(props) => props.theme.colors.grey2};
170
- border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
171
- display: flex;
172
- flex-grow: 1;
173
- flex-shrink: 1;
174
- padding: 3px 0px;
175
-
176
- &:last-child {
177
- border-right: solid 1px ${(props) => props.theme.colors.grey2};
178
- }
103
+ import styled from 'vue3-styled-components'
104
+ import handleSVG from '../../assets/svgIcons/handle.svg'
105
+ import add from '../../assets/svgIcons/add_icon.svg'
106
+
107
+ import SliderComponent from './Slider'
108
+
109
+ const wrapperAttrs = { width: String, height: String }
110
+ const SliderWrapper = styled('div', wrapperAttrs)`
111
+ position: relative;
112
+ display: flex;
113
+ height: ${(props) => props.height || '24px'};
114
+ width: ${(props) => props.width || '100%'};
115
+ `
179
116
 
180
- &:nth-child(odd) {
181
- margin-top: -5px;
182
- padding: 5px 0px;
183
- }
184
- `
185
-
186
- const BarSlider = styled.div`
187
- width: 100%;
188
- `
189
-
190
- const BarContainer = styled.div`
191
- display: flex;
192
- flex-direction: column;
193
- `
194
-
195
- const BarWrapper = styled.div`
196
- display: flex;
197
- flex-direction: row;
198
- margin: 20px 0px;
199
- align-items: center;
200
- `
201
-
202
- const RangeSliderContainer = styled.div`
203
- display: flex;
204
- position: relative;
205
- padding: 20px 10px;
206
- flex-direction: column;
207
- user-select: none;
208
- width: 100%;
209
- `
210
-
211
- const Labels = styled.div`
212
- display: flex;
213
- justify-content: space-between;
214
- padding: 0px;
215
- margin: 10px -100px 0px 100px;
216
- width: calc(100% - 100px);
217
- `
218
-
219
- const Label = styled.div`
220
- font-size: 80%;
221
- display: flex;
222
- width: 1px;
223
- justify-content: center;
224
- `
225
-
226
- const VerticalLabel = styled.div`
227
- text-align: left;
228
- min-width: 100px;
229
- font-size: 13px;
230
- `
231
-
232
- const AddIcon = styled(add)`
117
+ const sliderAttrs = { color: String, draggable: Boolean }
118
+ const Slider = styled(SliderComponent, sliderAttrs)`
119
+ cursor: ${(props) => (props.draggable ? 'pointer' : 'not-allowed')};
120
+ opacity: 0.7;
121
+ display: flex;
122
+ justify-content: space-between;
123
+ align-items: center;
124
+ border: unset !important;
125
+ background-color: ${(props) => props.color};
126
+ `
127
+
128
+ const ErrorMessage = styled.p`
129
+ color: ${(props) => props.theme.colors.red};
130
+ font-style: italic;
131
+ font-size: 13px;
132
+ margin-top: 5px;
133
+ `
134
+
135
+ const Bar = styled.div`
136
+ display: flex;
137
+ margin-bottom: -30px;
138
+ margin-left: 1px;
139
+ background-color: #f6faff;
140
+ width: 100%;
141
+ background-color: ${(props) => props.theme.colors.gray1};
142
+ `
143
+
144
+ const Ruler = styled.div`
145
+ margin: 10px 0px -5px 0px;
146
+ display: flex;
147
+ overflow: hidden;
148
+ `
149
+
150
+ const RulerRule = styled.div`
151
+ border-left: solid 1px ${(props) => props.theme.colors.grey2};
152
+ border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
153
+ display: flex;
154
+ flex-grow: 1;
155
+ flex-shrink: 1;
156
+ padding: 10px 0px;
157
+
158
+ &:last-child {
159
+ border-right: solid 1px ${(props) => props.theme.colors.grey2};
160
+ }
161
+ `
162
+
163
+ const SubRuler = styled.div`
164
+ margin: -7px 0px -5px 0px;
165
+ display: flex;
166
+ `
167
+
168
+ const RulerSubRule = styled.div`
169
+ border-left: solid 1px ${(props) => props.theme.colors.grey2};
170
+ border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
171
+ display: flex;
172
+ flex-grow: 1;
173
+ flex-shrink: 1;
174
+ padding: 3px 0px;
175
+
176
+ &:last-child {
177
+ border-right: solid 1px ${(props) => props.theme.colors.grey2};
178
+ }
179
+
180
+ &:nth-child(odd) {
181
+ margin-top: -5px;
182
+ padding: 5px 0px;
183
+ }
184
+ `
185
+
186
+ const BarSlider = styled.div`
187
+ width: 100%;
188
+ `
189
+
190
+ const BarContainer = styled.div`
191
+ display: flex;
192
+ flex-direction: column;
193
+ `
194
+
195
+ const BarWrapper = styled.div`
196
+ display: flex;
197
+ flex-direction: row;
198
+ margin: 20px 0px;
199
+ align-items: center;
200
+ `
201
+
202
+ const RangeSliderContainer = styled.div`
203
+ display: flex;
204
+ position: relative;
205
+ padding: 20px 10px;
206
+ flex-direction: column;
207
+ user-select: none;
208
+ width: 100%;
209
+ `
210
+
211
+ const Labels = styled.div`
212
+ display: flex;
213
+ justify-content: space-between;
214
+ padding: 0px;
215
+ margin: 10px -100px 0px 100px;
216
+ width: calc(100% - 100px);
217
+ `
218
+
219
+ const Label = styled.div`
220
+ font-size: 80%;
221
+ display: flex;
222
+ width: 1px;
223
+ justify-content: center;
224
+ `
225
+
226
+ const VerticalLabel = styled.div`
227
+ text-align: left;
228
+ min-width: 100px;
229
+ font-size: 13px;
230
+ `
231
+
232
+ const AddIcon = styled(add)`
233
233
  width: 33px;
234
234
  height: 29px;
235
235
  fill: black
@@ -237,281 +237,281 @@
237
237
  margin-top: -10px;
238
238
  `
239
239
 
240
- const HandleIcon = styled(handleSVG)`
241
- width: 13px;
242
- min-width: 0;
243
- margin: -6px;
244
- `
245
-
246
- const BarOptionAttrs = { top: Number, left: Number }
247
- const BarOptionsContainer = styled('div', BarOptionAttrs)`
248
- display: grid;
249
- position: fixed;
250
- z-index: 9999;
251
- border-radius: 4px;
252
- background-color: ${(props) => props.theme.colors.white};
253
- padding: 6px 10px;
254
- border: 1px solid ${(props) => props.theme.colors.grey4};
255
- top: ${(props) => props.top + 'px'};
256
- left: ${(props) => props.left + 'px'};
257
- `
258
-
259
- const BarItemContainer = styled.div`
260
- display: grid;
261
- grid-template-columns: auto 1fr;
262
- grid-gap: 12px;
263
- align-items: center;
264
- cursor: pointer;
265
- padding: 6px 10px;
266
- border-radius: 4px;
267
-
268
- &:hover {
269
- background-color: ${(props) => props.theme.colors.lightGray};
240
+ const HandleIcon = styled(handleSVG)`
241
+ width: 13px;
242
+ min-width: 0;
243
+ margin: -6px;
244
+ `
245
+
246
+ const BarOptionAttrs = { top: Number, left: Number }
247
+ const BarOptionsContainer = styled('div', BarOptionAttrs)`
248
+ display: grid;
249
+ position: fixed;
250
+ z-index: 9999;
251
+ border-radius: 4px;
252
+ background-color: ${(props) => props.theme.colors.white};
253
+ padding: 6px 10px;
254
+ border: 1px solid ${(props) => props.theme.colors.grey4};
255
+ top: ${(props) => props.top + 'px'};
256
+ left: ${(props) => props.left + 'px'};
257
+ `
258
+
259
+ const BarItemContainer = styled.div`
260
+ display: grid;
261
+ grid-template-columns: auto 1fr;
262
+ grid-gap: 12px;
263
+ align-items: center;
264
+ cursor: pointer;
265
+ padding: 6px 10px;
266
+ border-radius: 4px;
267
+
268
+ &:hover {
269
+ background-color: ${(props) => props.theme.colors.lightGray};
270
+ }
271
+ `
272
+
273
+ const BarItemText = styled.div`
274
+ font-size: 13px;
275
+ `
276
+
277
+ export default {
278
+ name: 'RangeSlider',
279
+ props: {
280
+ dataLocation: { type: String, default: '' },
281
+ tariffItems: { type: Array, default: () => [] },
282
+ labels: { type: Array, default: () => [] },
283
+ rangeMargin: { type: Number, default: 1 },
284
+ step: { type: Number, default: 1 },
285
+ minWidth: { type: Number, default: 1 },
286
+ canOverlap: { type: Boolean, default: true },
287
+ disabled: { type: Boolean, default: false }
288
+ },
289
+ components: {
290
+ Bar,
291
+ Label,
292
+ Labels,
293
+ Ruler,
294
+ Slider,
295
+ AddIcon,
296
+ SubRuler,
297
+ BarSlider,
298
+ RulerRule,
299
+ HandleIcon,
300
+ BarWrapper,
301
+ ErrorMessage,
302
+ RulerSubRule,
303
+ BarContainer,
304
+ SliderWrapper,
305
+ VerticalLabel,
306
+ RangeSliderContainer,
307
+ BarOptionsContainer,
308
+ BarItemContainer,
309
+ BarItemText
310
+ },
311
+ data() {
312
+ return {
313
+ showBarOptions: false,
314
+ barOptionsPosition: { x: 0, y: 0 },
315
+ barOptionsList: [],
316
+ barOptionsType: null, // can be "add" or "delete"
317
+ activeLabel: null,
318
+ activeItem: null,
319
+ OverlapId: [],
320
+ hasOverlap: false
270
321
  }
271
- `
272
-
273
- const BarItemText = styled.div`
274
- font-size: 13px;
275
- `
276
-
277
- export default {
278
- name: 'RangeSlider',
279
- components: {
280
- Bar,
281
- Label,
282
- Labels,
283
- Ruler,
284
- Slider,
285
- AddIcon,
286
- SubRuler,
287
- BarSlider,
288
- RulerRule,
289
- HandleIcon,
290
- BarWrapper,
291
- ErrorMessage,
292
- RulerSubRule,
293
- BarContainer,
294
- SliderWrapper,
295
- VerticalLabel,
296
- RangeSliderContainer,
297
- BarOptionsContainer,
298
- BarItemContainer,
299
- BarItemText,
300
- },
301
- props: {
302
- dataLocation: { type: String, default: '' },
303
- tariffItems: { type: Array, default: () => [] },
304
- labels: { type: Array, default: () => [] },
305
- rangeMargin: { type: Number, default: 1 },
306
- step: { type: Number, default: 1 },
307
- minWidth: { type: Number, default: 1 },
308
- canOverlap: { type: Boolean, default: true },
309
- disabled: { type: Boolean, default: false },
322
+ },
323
+ computed: {
324
+ maximum() {
325
+ if (!this.labels.length) return
326
+
327
+ return this.topLabels.at(-1)
310
328
  },
311
- data() {
312
- return {
313
- showBarOptions: false,
314
- barOptionsPosition: { x: 0, y: 0 },
315
- barOptionsList: [],
316
- barOptionsType: null, // can be "add" or "delete"
317
- activeLabel: null,
318
- activeItem: null,
319
- OverlapId: [],
320
- hasOverlap: false,
321
- }
329
+ minimum() {
330
+ if (!this.labels.length) return
331
+
332
+ return this.topLabels[0]
322
333
  },
323
- computed: {
324
- maximum() {
325
- if (!this.labels.length) return
326
-
327
- return this.topLabels.at(-1)
328
- },
329
- minimum() {
330
- if (!this.labels.length) return
331
-
332
- return this.topLabels[0]
333
- },
334
- topLabels() {
335
- if (!this.labels.length) return
336
- const labels = this.labels.find((label) => label.placement === 'top')
337
-
338
- return labels ? labels.value : []
339
- },
340
- leftLabels() {
341
- if (!this.labels.length) return
342
- const labels = this.labels.find((label) => label.placement === 'left')
343
- return labels ? labels.value : []
344
- },
345
- stepCount() {
346
- let labels = this.topLabels || []
347
-
348
- if (labels.length) {
349
- return labels.length - 1
350
- }
334
+ topLabels() {
335
+ if (!this.labels.length) return
336
+ const labels = this.labels.find((label) => label.placement === 'top')
351
337
 
352
- return Math.floor((this.maximum - this.minimum) / this.step)
353
- },
354
- subStepCount() {
355
- let labels = this.topLabels || []
338
+ return labels ? labels.value : []
339
+ },
340
+ leftLabels() {
341
+ if (!this.labels.length) return
342
+ const labels = this.labels.find((label) => label.placement === 'left')
343
+ return labels ? labels.value : []
344
+ },
345
+ stepCount() {
346
+ let labels = this.topLabels || []
356
347
 
357
- if (labels.length && this.step) {
358
- return (this.maximum - this.minimum) / this.step
359
- }
348
+ if (labels.length) {
349
+ return labels.length - 1
350
+ }
360
351
 
361
- return 0
362
- },
352
+ return Math.floor((this.maximum - this.minimum) / this.step)
363
353
  },
364
- watch: {
365
- labels(newVal, oldVal) {
366
- const overlapContainer = []
367
-
368
- //check items for overlap
369
- if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
370
- const labels = newVal.find((label) => label.placement === 'left')
371
-
372
- if (labels) {
373
- labels.value.forEach((label) => {
374
- label.selectedTariffs.forEach((tariff) => {
375
- const hasOverlap = this.checkOverlap(
376
- tariff,
377
- label.selectedTariffs
378
- )
379
-
380
- if (hasOverlap) overlapContainer.push(label.id)
381
- })
382
- })
383
- }
354
+ subStepCount() {
355
+ let labels = this.topLabels || []
384
356
 
385
- const hasOverlap = overlapContainer.length > 0
357
+ if (labels.length && this.step) {
358
+ return (this.maximum - this.minimum) / this.step
359
+ }
386
360
 
387
- if (!hasOverlap) {
388
- this.OverlapId = []
389
- } else {
390
- this.OverlapId = [...new Set(overlapContainer)]
391
- }
361
+ return 0
362
+ }
363
+ },
364
+ methods: {
365
+ onChange(type, value) {
366
+ this.$emit(type, value)
367
+ },
368
+ checkOverlap(value, tariffs) {
369
+ // Check if the tariffs overlap
370
+ const min = parseFloat(value.min)
371
+ const max = parseFloat(value.max)
372
+
373
+ return tariffs.some((tariff) => {
374
+ if (tariff.id === value.itemId || tariff.id === value.id) return false
375
+
376
+ return (
377
+ min === tariff.min ||
378
+ max === tariff.max ||
379
+ (min > tariff.min && min < tariff.max) ||
380
+ (max > tariff.min && max < tariff.max) ||
381
+ (min < tariff.min && max > tariff.max)
382
+ )
383
+ })
384
+ },
385
+ barOptionLabel(value) {
386
+ if (this.barOptionsType === 'add')
387
+ return `${this.$gettext('Add')} ${value}`
392
388
 
393
- this.hasOverlap = hasOverlap
394
- this.$emit('has-overlap', hasOverlap)
395
- }
396
- },
389
+ return `${this.$gettext('Remove')} ${value}`
390
+ },
391
+ onActivateBar({ item }) {
392
+ this.$emit('activate')
393
+ this.activeItem = item
394
+ document.addEventListener('keydown', this.onKeyDownDelete)
397
395
  },
398
- beforeDestroy() {
399
- // Remove the global click event listener to prevent memory leaks
400
- document.removeEventListener('click', this.handleOutsideClick)
396
+ onDeactivateBar() {
397
+ this.$emit('deactivate')
398
+ this.activeItem = null
401
399
  document.removeEventListener('keydown', this.onKeyDownDelete)
402
400
  },
403
- methods: {
404
- onChange(type, value) {
405
- this.$emit(type, value)
406
- },
407
- checkOverlap(value, tariffs) {
408
- // Check if the tariffs overlap
409
- const min = parseFloat(value.min)
410
- const max = parseFloat(value.max)
411
-
412
- return tariffs.some((tariff) => {
413
- if (tariff.id === value.itemId || tariff.id === value.id) return false
414
-
415
- return (
416
- min === tariff.min ||
417
- max === tariff.max ||
418
- (min > tariff.min && min < tariff.max) ||
419
- (max > tariff.min && max < tariff.max) ||
420
- (min < tariff.min && max > tariff.max)
421
- )
401
+ onKeyDownDelete(event) {
402
+ // Check if the pressed key is the Delete or Backspace key
403
+ if (
404
+ (event.key === 'Delete' || event.key === 'Backspace') &&
405
+ this.activeItem
406
+ ) {
407
+ this.$emit('on-bar-tariff-click', {
408
+ type: 'delete',
409
+ item: this.activeItem,
410
+ label: this.activeLabel
422
411
  })
423
- },
424
- barOptionLabel(value) {
425
- if (this.barOptionsType === 'add')
426
- return `${this.$gettext('Add')} ${value}`
427
-
428
- return `${this.$gettext('Remove')} ${value}`
429
- },
430
- onActivateBar({ item }) {
431
- this.$emit('activate')
432
- this.activeItem = item
433
- document.addEventListener('keydown', this.onKeyDownDelete)
434
- },
435
- onDeactivateBar() {
436
- this.$emit('deactivate')
437
412
  this.activeItem = null
438
- document.removeEventListener('keydown', this.onKeyDownDelete)
439
- },
440
- onKeyDownDelete(event) {
441
- // Check if the pressed key is the Delete or Backspace key
442
- if (
443
- (event.key === 'Delete' || event.key === 'Backspace') &&
444
- this.activeItem
445
- ) {
446
- this.$emit('on-bar-tariff-click', {
447
- type: 'delete',
448
- item: this.activeItem,
449
- label: this.activeLabel,
450
- })
451
- this.activeItem = null
452
- }
453
- },
454
- onBarTariffClick({ item, type, label }) {
455
- if (this.disabled) return
413
+ }
414
+ },
415
+ onBarTariffClick({ item, type, label }) {
416
+ if (this.disabled) return
417
+
418
+ this.$emit('on-bar-tariff-click', {
419
+ type,
420
+ item,
421
+ label
422
+ })
423
+
424
+ this.activeLabel = label
425
+ this.barOptionsType = type
426
+ this.showBarOptions = false
427
+ },
428
+ setBarOptions(bar) {
429
+ this.barOptionsList = []
456
430
 
457
- this.$emit('on-bar-tariff-click', {
458
- type,
459
- item,
460
- label,
431
+ if (this.barOptionsType === 'add') {
432
+ this.tariffItems.forEach((item) => {
433
+ if (item.name && item.name.length) {
434
+ this.barOptionsList.push(item)
435
+ }
461
436
  })
462
-
463
- this.activeLabel = label
464
- this.barOptionsType = type
437
+ } else {
438
+ // add based on the index in the chart.
439
+ this.barOptionsList.push({
440
+ name: bar.name,
441
+ id: bar.id
442
+ })
443
+ }
444
+ },
445
+ onBarRightClick({ event, label, type, bar }) {
446
+ if (this.disabled) return
447
+
448
+ // type can be "add", "delete"
449
+ // if "add", show all tariffItems for the group
450
+ // if "delete", only show the delete with the tariff name
451
+ event.preventDefault()
452
+ this.activeLabel = label
453
+ this.barOptionsType = type
454
+ this.setBarOptions(bar)
455
+
456
+ if (this.barOptionsList.length) {
457
+ this.showBarOptions = true
458
+ this.barOptionsPosition = { x: event.clientX, y: event.clientY }
459
+ document.addEventListener('click', this.handleOutsideClick)
460
+ } else {
465
461
  this.showBarOptions = false
466
- },
467
- setBarOptions(bar) {
468
- this.barOptionsList = []
469
-
470
- if (this.barOptionsType === 'add') {
471
- this.tariffItems.forEach((item) => {
472
- if (item.name && item.name.length) {
473
- this.barOptionsList.push(item)
474
- }
475
- })
476
- } else {
477
- // add based on the index in the chart.
478
- this.barOptionsList.push({
479
- name: bar.name,
480
- id: bar.id,
462
+ }
463
+ },
464
+ handleOutsideClick(event) {
465
+ // Check if the click occurred outside the dropdown
466
+ if (
467
+ this.$refs.barDropdown &&
468
+ !this.$refs.barDropdown.$el.contains(event.target)
469
+ ) {
470
+ // Hide the dropdown
471
+ this.showBarOptions = false
472
+ // Remove the global click event listener
473
+ document.removeEventListener('click', this.handleOutsideClick)
474
+ }
475
+ }
476
+ },
477
+ beforeDestroy() {
478
+ // Remove the global click event listener to prevent memory leaks
479
+ document.removeEventListener('click', this.handleOutsideClick)
480
+ document.removeEventListener('keydown', this.onKeyDownDelete)
481
+ },
482
+ watch: {
483
+ labels(newVal, oldVal) {
484
+ const overlapContainer = []
485
+
486
+ //check items for overlap
487
+ if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
488
+ const labels = newVal.find((label) => label.placement === 'left')
489
+
490
+ if (labels) {
491
+ labels.value.forEach((label) => {
492
+ label.selectedTariffs.forEach((tariff) => {
493
+ const hasOverlap = this.checkOverlap(
494
+ tariff,
495
+ label.selectedTariffs
496
+ )
497
+
498
+ if (hasOverlap) overlapContainer.push(label.id)
499
+ })
481
500
  })
482
501
  }
483
- },
484
- onBarRightClick({ event, label, type, bar }) {
485
- if (this.disabled) return
486
-
487
- // type can be "add", "delete"
488
- // if "add", show all tariffItems for the group
489
- // if "delete", only show the delete with the tariff name
490
- event.preventDefault()
491
- this.activeLabel = label
492
- this.barOptionsType = type
493
- this.setBarOptions(bar)
494
-
495
- if (this.barOptionsList.length) {
496
- this.showBarOptions = true
497
- this.barOptionsPosition = { x: event.clientX, y: event.clientY }
498
- document.addEventListener('click', this.handleOutsideClick)
502
+
503
+ const hasOverlap = overlapContainer.length > 0
504
+
505
+ if (!hasOverlap) {
506
+ this.OverlapId = []
499
507
  } else {
500
- this.showBarOptions = false
508
+ this.OverlapId = [...new Set(overlapContainer)]
501
509
  }
502
- },
503
- handleOutsideClick(event) {
504
- // Check if the click occurred outside the dropdown
505
- if (
506
- this.$refs.barDropdown &&
507
- !this.$refs.barDropdown.$el.contains(event.target)
508
- ) {
509
- // Hide the dropdown
510
- this.showBarOptions = false
511
- // Remove the global click event listener
512
- document.removeEventListener('click', this.handleOutsideClick)
513
- }
514
- },
515
- },
510
+
511
+ this.hasOverlap = hasOverlap
512
+ this.$emit('has-overlap', hasOverlap)
513
+ }
514
+ }
516
515
  }
516
+ }
517
517
  </script>