@eturnity/eturnity_reusable_components 7.24.3-EPDM-10647.1 → 7.24.3-EPDM-11320.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 (82) hide show
  1. package/.eslintrc.js +184 -0
  2. package/.prettierrc +8 -6
  3. package/package.json +9 -21
  4. package/src/App.vue +79 -78
  5. package/src/assets/theme.js +3 -3
  6. package/src/components/addNewButton/AddNewButton.stories.js +2 -2
  7. package/src/components/addNewButton/index.vue +48 -51
  8. package/src/components/banner/actionBanner/index.vue +54 -55
  9. package/src/components/banner/banner/banner.stories.js +5 -5
  10. package/src/components/banner/banner/index.vue +159 -159
  11. package/src/components/banner/infoBanner/index.vue +41 -53
  12. package/src/components/buttons/buttonIcon/index.vue +125 -122
  13. package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
  14. package/src/components/buttons/closeButton/index.vue +49 -49
  15. package/src/components/buttons/mainButton/index.vue +119 -119
  16. package/src/components/card/index.vue +70 -70
  17. package/src/components/collapsableInfoText/index.vue +96 -94
  18. package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
  19. package/src/components/deleteIcon/index.vue +54 -54
  20. package/src/components/draggableInputHandle/index.vue +37 -37
  21. package/src/components/dropdown/Dropdown.stories.js +9 -10
  22. package/src/components/dropdown/index.vue +106 -106
  23. package/src/components/errorMessage/index.vue +52 -52
  24. package/src/components/filter/filterSettings.vue +439 -433
  25. package/src/components/filter/index.vue +135 -135
  26. package/src/components/filter/parentDropdown.vue +73 -73
  27. package/src/components/icon/Icons.stories.js +7 -7
  28. package/src/components/icon/iconCollection.vue +53 -53
  29. package/src/components/icon/index.vue +121 -121
  30. package/src/components/iconWrapper/index.vue +156 -156
  31. package/src/components/infoCard/index.vue +26 -26
  32. package/src/components/infoText/index.vue +133 -137
  33. package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
  34. package/src/components/inputs/checkbox/index.vue +190 -180
  35. package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
  36. package/src/components/inputs/inputNumber/index.vue +647 -723
  37. package/src/components/inputs/inputNumberQuestion/index.vue +185 -182
  38. package/src/components/inputs/inputText/InputText.stories.js +22 -22
  39. package/src/components/inputs/inputText/index.vue +337 -336
  40. package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
  41. package/src/components/inputs/radioButton/index.vue +221 -219
  42. package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
  43. package/src/components/inputs/searchInput/index.vue +126 -126
  44. package/src/components/inputs/select/index.vue +780 -792
  45. package/src/components/inputs/select/option/index.vue +124 -124
  46. package/src/components/inputs/select/select.stories.js +31 -32
  47. package/src/components/inputs/slider/index.vue +99 -99
  48. package/src/components/inputs/switchField/index.vue +220 -222
  49. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
  50. package/src/components/inputs/textAreaInput/index.vue +171 -173
  51. package/src/components/inputs/toggle/Toggle.stories.js +14 -14
  52. package/src/components/inputs/toggle/index.vue +214 -217
  53. package/src/components/label/index.vue +82 -82
  54. package/src/components/markerItem/index.vue +68 -66
  55. package/src/components/modals/actionModal/index.vue +54 -54
  56. package/src/components/modals/infoModal/index.vue +39 -36
  57. package/src/components/modals/modal/index.vue +134 -134
  58. package/src/components/modals/modal/modal.stories.js +5 -5
  59. package/src/components/navigationTabs/index.vue +96 -94
  60. package/src/components/pageSubtitle/index.vue +55 -49
  61. package/src/components/pageTitle/index.vue +56 -56
  62. package/src/components/pagination/index.vue +92 -89
  63. package/src/components/progressBar/index.vue +107 -107
  64. package/src/components/projectMarker/index.vue +246 -244
  65. package/src/components/rangeSlider/Slider.vue +491 -465
  66. package/src/components/rangeSlider/index.vue +410 -410
  67. package/src/components/rangeSlider/utils/dom.js +5 -5
  68. package/src/components/selectedOptions/index.vue +119 -119
  69. package/src/components/sideMenu/index.vue +199 -199
  70. package/src/components/spinner/index.vue +57 -57
  71. package/src/components/tableDropdown/index.vue +520 -520
  72. package/src/components/tables/mainTable/index.vue +366 -362
  73. package/src/components/tables/viewTable/index.vue +171 -171
  74. package/src/components/threeDots/index.vue +340 -334
  75. package/src/components/videoThumbnail/index.vue +86 -86
  76. package/src/components/videoThumbnail/videoThumbnail.stories.js +14 -16
  77. package/src/helpers/numberConverter.js +2 -2
  78. package/src/helpers/translateLang.js +9 -9
  79. package/src/mixins/inputValidations.js +5 -5
  80. package/public/favicon.ico +0 -0
  81. package/public/index.html +0 -17
  82. package/src/utils/index.js +0 -12
@@ -1,789 +1,713 @@
1
1
  <template>
2
- <container :inputWidth="inputWidth" :alignItems="alignItems">
3
- <label-slot-wrapper
2
+ <Container :align-items="alignItems" :input-width="inputWidth">
3
+ <LabelSlotWrapper
4
4
  v-if="hasLabelSlot"
5
- :isInteractive="isInteractive"
6
- :alignItems="alignItems"
7
- :noBorder="noBorder"
8
- :isError="isError"
9
- :borderColor="borderColor"
5
+ :align-items="alignItems"
6
+ :border-color="borderColor"
7
+ :is-error="isError"
8
+ :is-interactive="isInteractive"
9
+ :no-border="noBorder"
10
10
  @mousedown="initInteraction"
11
11
  >
12
12
  <slot name="label"></slot>
13
- </label-slot-wrapper>
13
+ </LabelSlotWrapper>
14
14
 
15
- <label-wrapper v-if="labelText">
16
- <label-text :labelFontColor="labelFontColor" :data-id="labelDataId">
15
+ <LabelWrapper v-if="labelText">
16
+ <LabelText :data-id="labelDataId" :label-font-color="labelFontColor">
17
17
  {{ labelText }}
18
- </label-text>
18
+ </LabelText>
19
19
 
20
- <info-text
20
+ <InfoText
21
21
  v-if="labelInfoText"
22
+ :align-arrow="labelInfoAlign"
22
23
  :text="labelInfoText"
23
- :alignArrow="labelInfoAlign"
24
24
  />
25
- </label-wrapper>
26
- <input-wrapper>
27
- <input-container
25
+ </LabelWrapper>
26
+ <InputWrapper>
27
+ <InputContainer
28
28
  v-bind="$attrs"
29
29
  ref="inputField1"
30
- :hasUnit="unitName && !!unitName.length"
30
+ :align-items="alignItems"
31
+ :background-color="backgroundColor"
32
+ :border-color="borderColor"
33
+ :data-id="inputDataId"
34
+ :disabled="disabled"
35
+ :font-color="fontColor"
36
+ :font-size="fontSize"
37
+ :has-label-slot="hasLabelSlot"
38
+ :has-slot="hasSlot"
39
+ :has-unit="unitName && !!unitName.length"
40
+ :input-height="inputHeight"
41
+ :is-disabled="disabled"
42
+ :is-error="isError"
43
+ :is-interactive="isInteractive"
44
+ :min-width="minWidth"
45
+ :no-border="noBorder"
31
46
  :placeholder="displayedPlaceholder"
32
- :isError="isError"
33
- :inputHeight="inputHeight"
34
- :minWidth="minWidth"
35
- :isInteractive="isInteractive"
47
+ :show-linear-unit-name="showLinearUnitName"
48
+ :slot-size="slotSize"
49
+ :text-align="textAlign"
36
50
  :value="formatWithCurrency(value)"
37
51
  @blur="onInputBlur($event)"
38
52
  @focus="focusInput()"
39
- @keyup.enter="onEnterPress"
40
53
  @input="onInput($event)"
41
- :disabled="disabled"
42
- :isDisabled="disabled"
43
- :alignItems="alignItems"
44
- :noBorder="noBorder"
45
- :borderColor="borderColor"
46
- :textAlign="textAlign"
47
- :fontSize="fontSize"
48
- :fontColor="fontColor"
49
- :backgroundColor="backgroundColor"
50
- :hasSlot="hasSlot"
51
- :hasLabelSlot="hasLabelSlot"
52
- :slotSize="slotSize"
53
- :showLinearUnitName="showLinearUnitName"
54
- :data-id="inputDataId"
54
+ @keyup.enter="onEnterPress"
55
55
  />
56
- <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
56
+ <SlotContainer v-if="hasSlot" :is-error="isError" :slot-size="slotSize">
57
57
  <slot></slot>
58
- </slot-container>
58
+ </SlotContainer>
59
59
 
60
- <unit-container
60
+ <UnitContainer
61
61
  v-if="unitName && showLinearUnitName && !hasSlot"
62
- :hasLength="!!textInput.length"
63
- :isError="isError"
64
- >{{ unitName }}</unit-container
62
+ :has-length="!!textInput.length"
63
+ :is-error="isError"
65
64
  >
66
- <icon-wrapper
67
- v-if="isError && !showLinearUnitName"
68
- size="16px"
69
- :marginRight="showSelect ? selectWidth : 0"
70
- >
71
- <icon name="warning" size="16px" cursor="default" />
72
- </icon-wrapper>
73
- <select-wrapper v-if="showSelect">
74
- <divider />
75
- <Select
76
- :showBorder="false"
77
- :selectWidth="`${selectWidth}px`"
78
- :disabled="isSelectDisabled"
79
- @input-change="$emit('select-change', $event)"
80
- >
81
- <template #selector>
82
- <select-text>{{ getSelectValue }}</select-text>
83
- </template>
84
- <template #dropdown>
85
- <Option
86
- v-for="item in selectOptions"
87
- :key="item.value"
88
- :value="item.value"
89
- >
90
- {{ item.label }}
91
- </Option>
92
- </template>
93
- </Select>
94
- </select-wrapper>
95
- </input-wrapper>
96
- <error-message v-if="isError">{{ errorMessage }}</error-message>
97
- </container>
65
+ {{ unitName }}
66
+ </UnitContainer>
67
+ <IconWrapper v-if="isError && !showLinearUnitName" size="16px">
68
+ <Icon cursor="default" name="warning" size="16px" />
69
+ </IconWrapper>
70
+ </InputWrapper>
71
+ <ErrorMessage v-if="isError">
72
+ {{ errorMessage }}
73
+ </ErrorMessage>
74
+ </Container>
98
75
  </template>
99
76
 
100
77
  <script>
101
- // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
102
- //This component should be used for questions with input fields only
103
- //How to use:
104
- // <input-number
105
- // placeholder="Enter distance"
106
- // :isError="false" //default is false
107
- // inputWidth="150px" //by default, this is 100%
108
- // minWidth="100px"
109
- // :numberPrecision="3"
110
- // minDecimals="2"
111
- // unitName="pc"
112
- // :value="inputValue" //required -- String
113
- // @input-change="onInputChange($event)" //required
114
- // @on-enter-click="onInputSubmit()"
115
- // :errorMessage="Enter a number between 1 and 10"
116
- // :disabled="false"
117
- // :noBorder="true"
118
- // textAlign="left" // "left, right, center"
119
- // :showLinearUnitName="true"
120
- // fontSize="13px"
121
- // labelText="Number of Modules"
122
- // labelInfoText="Here is some information for you..."
123
- // labelInfoAlign="left"
124
- // :minNumber="0"
125
- // fontColor="blue"
126
- // >
127
- //<template name=label><img>....</template>
128
- //</inputNumber>
129
- import styled from 'vue3-styled-components'
130
- import {
131
- stringToNumber,
132
- numberToString
133
- } from '../../../helpers/numberConverter'
134
- import InfoText from '../../infoText'
135
- import ErrorMessage from '../../errorMessage'
136
- import Select from '../select'
137
- import Option from '../select/option'
138
- import warningIcon from '../../../assets/icons/error_icon.png'
139
- import Icon from '../../icon'
78
+ // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
79
+ //This component should be used for questions with input fields only
80
+ //How to use:
81
+ // <input-number
82
+ // placeholder="Enter distance"
83
+ // :isError="false" //default is false
84
+ // inputWidth="150px" //by default, this is 100%
85
+ // minWidth="100px"
86
+ // :numberPrecision="3"
87
+ // minDecimals="2"
88
+ // unitName="pc"
89
+ // :value="inputValue" //required -- String
90
+ // @input-change="onInputChange($event)" //required
91
+ // @on-enter-click="onInputSubmit()"
92
+ // :errorMessage="Enter a number between 1 and 10"
93
+ // :disabled="false"
94
+ // :noBorder="true"
95
+ // textAlign="left" // "left, right, center"
96
+ // :showLinearUnitName="true"
97
+ // fontSize="13px"
98
+ // labelText="Number of Modules"
99
+ // labelInfoText="Here is some information for you..."
100
+ // labelInfoAlign="left"
101
+ // :minNumber="0"
102
+ // fontColor="blue"
103
+ // >
104
+ //<template name=label><img>....</template>
105
+ //</inputNumber>
106
+ import styled from 'vue3-styled-components'
107
+ import {
108
+ stringToNumber,
109
+ numberToString,
110
+ } from '../../../helpers/numberConverter'
111
+ import InfoText from '../../infoText'
112
+ import ErrorMessage from '../../errorMessage'
113
+ import warningIcon from '../../../assets/icons/error_icon.png'
114
+ import Icon from '../../icon'
140
115
 
141
- const inputProps = {
142
- isError: Boolean,
143
- hasUnit: Boolean,
144
- inputWidth: String,
145
- minWidth: String,
146
- isDisabled: Boolean,
147
- noBorder: Boolean,
148
- textAlign: String,
149
- fontSize: String,
150
- fontColor: String,
151
- backgroundColor: String,
152
- hasSlot: Boolean,
153
- hasLabelSlot: Boolean,
154
- slotSize: String,
155
- inputHeight: String,
156
- isInteractive: Boolean,
157
- alignItems: String,
158
- labelFontColor: String,
159
- borderColor: String,
160
- showLinearUnitName: Boolean
161
- }
116
+ const inputProps = {
117
+ isError: Boolean,
118
+ hasUnit: Boolean,
119
+ inputWidth: String,
120
+ minWidth: String,
121
+ isDisabled: Boolean,
122
+ noBorder: Boolean,
123
+ textAlign: String,
124
+ fontSize: String,
125
+ fontColor: String,
126
+ backgroundColor: String,
127
+ hasSlot: Boolean,
128
+ hasLabelSlot: Boolean,
129
+ slotSize: String,
130
+ inputHeight: String,
131
+ isInteractive: Boolean,
132
+ alignItems: String,
133
+ labelFontColor: String,
134
+ borderColor: String,
135
+ showLinearUnitName: Boolean,
136
+ }
162
137
 
163
- const Container = styled('div', inputProps)`
164
- width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
165
- position: relative;
166
- display: grid;
167
- grid-template-columns: ${(props) =>
168
- props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
169
- `
138
+ const Container = styled('div', inputProps)`
139
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
140
+ position: relative;
141
+ display: grid;
142
+ grid-template-columns: ${(props) =>
143
+ props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
144
+ `
170
145
 
171
- const InputContainer = styled('input', inputProps)`
172
- border: ${(props) =>
173
- props.isError
174
- ? '1px solid ' + props.theme.colors.red
175
- : props.noBorder
176
- ? 'none'
177
- : props.borderColor
178
- ? props.theme.colors[props.borderColor]
179
- ? '1px solid ' + props.theme.colors[props.borderColor]
180
- : '1px solid ' + props.borderColor
181
- : '1px solid ' + props.theme.colors.grey4};
182
- height: ${(props) => props.inputHeight};
183
- max-height: ${(props) => props.inputHeight};
184
- padding: 0 10px;
185
- padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
186
- slotSize
187
- ? isError && !showLinearUnitName
188
- ? 'calc(' + slotSize + ' + 24px)'
189
- : 'calc(' + slotSize + ' + 10px)'
190
- : isError && !showLinearUnitName
191
- ? '24px'
192
- : '5px'};
193
- border-radius: ${(props) =>
194
- props.isInteractive && props.alignItems != 'vertical'
195
- ? '0 4px 4px 0'
196
- : '4px'};
197
- text-align: ${(props) => props.textAlign};
198
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
199
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
200
- color: ${(props) =>
201
- props.isError
202
- ? props.theme.colors.grey6
203
- : props.isDisabled
204
- ? props.theme.colors.grey2
205
- : props.fontColor
206
- ? props.fontColor + ' !important'
207
- : props.theme.colors.black};
208
- background-color: ${(props) =>
209
- props.backgroundColor
210
- ? props.backgroundColor + ' !important'
211
- : props.theme.colors.white};
212
- width: ${(props) =>
213
- props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
214
- min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
215
- background-color: ${(props) =>
216
- props.isDisabled ? props.theme.colors.grey5 : '#fff'};
217
- box-sizing: border-box;
146
+ const InputContainer = styled('input', inputProps)`
147
+ border: ${(props) =>
148
+ props.isError
149
+ ? '1px solid ' + props.theme.colors.red
150
+ : props.noBorder
151
+ ? 'none'
152
+ : props.borderColor
153
+ ? props.theme.colors[props.borderColor]
154
+ ? '1px solid ' + props.theme.colors[props.borderColor]
155
+ : '1px solid ' + props.borderColor
156
+ : '1px solid ' + props.theme.colors.grey4};
157
+ height: ${(props) => props.inputHeight};
158
+ max-height: ${(props) => props.inputHeight};
159
+ padding: 0 10px;
160
+ padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
161
+ slotSize
162
+ ? isError && !showLinearUnitName
163
+ ? 'calc(' + slotSize + ' + 24px)'
164
+ : 'calc(' + slotSize + ' + 10px)'
165
+ : isError && !showLinearUnitName
166
+ ? '24px'
167
+ : '5px'};
168
+ border-radius: ${(props) =>
169
+ props.isInteractive && props.alignItems != 'vertical'
170
+ ? '0 4px 4px 0'
171
+ : '4px'};
172
+ text-align: ${(props) => props.textAlign};
173
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
174
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
175
+ color: ${(props) =>
176
+ props.isError
177
+ ? props.theme.colors.grey6
178
+ : props.isDisabled
179
+ ? props.theme.colors.grey2
180
+ : props.fontColor
181
+ ? props.fontColor + ' !important'
182
+ : props.theme.colors.black};
183
+ background-color: ${(props) =>
184
+ props.backgroundColor
185
+ ? props.backgroundColor + ' !important'
186
+ : props.theme.colors.white};
187
+ width: ${(props) =>
188
+ props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
189
+ min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
190
+ background-color: ${(props) =>
191
+ props.isDisabled ? props.theme.colors.grey5 : '#fff'};
192
+ box-sizing: border-box;
218
193
 
219
- &::placeholder {
220
- color: ${(props) => props.theme.colors.grey2};
221
- }
194
+ &::placeholder {
195
+ color: ${(props) => props.theme.colors.grey2};
196
+ }
222
197
 
223
- &:focus {
224
- outline: none;
225
- }
226
- `
198
+ &:focus {
199
+ outline: none;
200
+ }
201
+ `
227
202
 
228
- const InputWrapper = styled.span`
229
- position: relative;
230
- `
203
+ const InputWrapper = styled.span`
204
+ position: relative;
205
+ `
231
206
 
232
- const UnitContainer = styled('span', inputProps)`
233
- border-left: 1px solid
234
- ${(props) =>
207
+ const UnitContainer = styled('span', inputProps)`
208
+ border-left: 1px solid
209
+ ${(props) =>
210
+ props.isError
211
+ ? props.theme.colors.red
212
+ : props.hasLength
213
+ ? props.theme.colors.black
214
+ : props.theme.colors.mediumGray};
215
+ position: absolute;
216
+ right: 10px;
217
+ top: 10px;
218
+ padding-left: 10px;
219
+ text-align: right;
220
+ color: ${(props) =>
235
221
  props.isError
236
222
  ? props.theme.colors.red
237
223
  : props.hasLength
238
224
  ? props.theme.colors.black
239
225
  : props.theme.colors.mediumGray};
240
- position: absolute;
241
- right: 10px;
242
- top: 10px;
243
- padding-left: 10px;
244
- text-align: right;
245
- color: ${(props) =>
246
- props.isError
247
- ? props.theme.colors.red
248
- : props.hasLength
249
- ? props.theme.colors.black
250
- : props.theme.colors.mediumGray};
251
- `
226
+ `
252
227
 
253
- const SlotContainer = styled('span', inputProps)`
254
- text-align: right;
255
- border-left: 1px solid
256
- ${(props) =>
228
+ const SlotContainer = styled('span', inputProps)`
229
+ text-align: right;
230
+ border-left: 1px solid
231
+ ${(props) =>
232
+ props.isError
233
+ ? props.theme.colors.red
234
+ : props.hasLength
235
+ ? props.theme.colors.black
236
+ : props.theme.colors.mediumGray};
237
+ position: absolute;
238
+ width: ${(props) =>
239
+ props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
240
+ right: 10px;
241
+ top: 10px;
242
+ padding-left: 10px;
243
+ color: ${(props) =>
257
244
  props.isError
258
245
  ? props.theme.colors.red
259
246
  : props.hasLength
260
247
  ? props.theme.colors.black
261
248
  : props.theme.colors.mediumGray};
262
- position: absolute;
263
- width: ${(props) =>
264
- props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
265
- right: 10px;
266
- top: 10px;
267
- padding-left: 10px;
268
- color: ${(props) =>
269
- props.isError
270
- ? props.theme.colors.red
271
- : props.hasLength
272
- ? props.theme.colors.black
273
- : props.theme.colors.mediumGray};
274
- `
275
-
276
- const LabelWrapper = styled('div', inputProps)`
277
- display: flex;
278
- align-items: center;
279
- gap: 10px;
280
- margin-bottom: 8px;
281
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
282
- `
283
- const LabelSlotWrapper = styled('div', inputProps)`
284
- display: flex;
285
- gap: 10px;
286
- align-items: center;
287
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
288
- border: ${(props) =>
289
- props.alignItems == 'vertical'
290
- ? 'none'
291
- : props.isError
292
- ? '1px solid ' + props.theme.colors.red
293
- : props.noBorder
294
- ? 'none'
295
- : props.borderColor
296
- ? props.theme.colors[props.borderColor]
297
- ? '1px solid ' + props.theme.colors[props.borderColor]
298
- : '1px solid ' + props.borderColor
299
- : '1px solid ' + props.theme.colors.grey4};
300
- border-radius: 4px 0 0 4px;
301
- border-right: none;
302
- `
303
-
304
- const LabelText = styled('div', inputProps)`
305
- font-size: 13px;
306
- color: ${(props) =>
307
- props.theme.colors[props.labelFontColor]
308
- ? props.theme.colors[props.labelFontColor]
309
- : props.labelFontColor};
310
- font-weight: 700;
311
- `
249
+ `
312
250
 
313
- const IconAttrs = { size: String, marginRight: Number }
314
- const IconWrapper = styled('div', IconAttrs)`
315
- position: absolute;
316
- top: 0;
317
- bottom: 0;
318
- margin: auto;
319
- right: ${(props) => props.marginRight + 10}px;
320
- height: ${(props) => (props.size ? props.size : 'auto')};
321
- `
251
+ const LabelWrapper = styled('div', inputProps)`
252
+ display: flex;
253
+ align-items: center;
254
+ gap: 10px;
255
+ margin-bottom: 8px;
256
+ cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
257
+ `
258
+ const LabelSlotWrapper = styled('div', inputProps)`
259
+ display: flex;
260
+ gap: 10px;
261
+ align-items: center;
262
+ cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
263
+ border: ${(props) =>
264
+ props.alignItems == 'vertical'
265
+ ? 'none'
266
+ : props.isError
267
+ ? '1px solid ' + props.theme.colors.red
268
+ : props.noBorder
269
+ ? 'none'
270
+ : props.borderColor
271
+ ? props.theme.colors[props.borderColor]
272
+ ? '1px solid ' + props.theme.colors[props.borderColor]
273
+ : '1px solid ' + props.borderColor
274
+ : '1px solid ' + props.theme.colors.grey4};
275
+ border-radius: 4px 0 0 4px;
276
+ border-right: none;
277
+ `
322
278
 
323
- const SelectText = styled.div`
324
- font-size: 13px;
325
- `
279
+ const LabelText = styled('div', inputProps)`
280
+ font-size: 13px;
281
+ color: ${(props) =>
282
+ props.theme.colors[props.labelFontColor]
283
+ ? props.theme.colors[props.labelFontColor]
284
+ : props.labelFontColor};
285
+ font-weight: 700;
286
+ `
326
287
 
327
- const SelectWrapper = styled.div`
328
- position: absolute;
329
- top: 2px;
330
- right: 2px;
331
- display: flex;
332
- height: 100%;
333
- `
334
-
335
- const Divider = styled.div`
336
- margin-top: 6px;
337
- height: calc(100% - 16px);
338
- width: 1px;
339
- background-color: ${({ theme }) => theme.colors.grey4};
340
- `
341
-
342
- export default {
343
- name: 'input-number',
344
- components: {
345
- Container,
346
- InputContainer,
347
- InputWrapper,
348
- UnitContainer,
349
- ErrorMessage,
350
- LabelWrapper,
351
- LabelSlotWrapper,
352
- LabelText,
353
- InfoText,
354
- Icon,
355
- SlotContainer,
356
- IconWrapper,
357
- Select,
358
- Option,
359
- SelectWrapper,
360
- SelectText,
361
- Divider
362
- },
363
- inheritAttrs: false,
364
- data() {
365
- return {
366
- textInput: '',
367
- isFocused: false,
368
- warningIcon: warningIcon
369
- }
370
- },
371
- props: {
372
- placeholder: {
373
- required: false,
374
- default: ''
375
- },
376
- isError: {
377
- required: false,
378
- default: false
379
- },
380
- inputWidth: {
381
- required: false,
382
- default: null
383
- },
384
- minWidth: {
385
- required: false,
386
- default: null
387
- },
388
- inputHeight: {
389
- required: false,
390
- default: '40px'
391
- },
392
- value: {
393
- required: true,
394
- default: null
395
- },
396
- clearInput: {
397
- required: false,
398
- default: false
399
- },
400
- alignItems: {
401
- required: false,
402
- default: 'vertical'
403
- },
404
- errorMessage: {
405
- required: false,
406
- default: 'Please insert a correct number'
407
- },
408
- numberPrecision: {
409
- required: false,
410
- default: 0
411
- },
412
- minDecimals: {
413
- required: false,
414
- default: 0
415
- },
416
- unitName: {
417
- required: false,
418
- default: ''
419
- },
420
- showLinearUnitName: {
421
- required: false,
422
- default: false
423
- },
424
- disabled: {
425
- required: false,
426
- default: false
427
- },
428
- noBorder: {
429
- required: false,
430
- default: false
431
- },
432
- borderColor: {
433
- required: false
434
- },
435
- textAlign: {
436
- required: false,
437
- default: 'left'
438
- },
439
- fontSize: {
440
- required: false,
441
- default: '13px'
442
- },
443
- isInteractive: {
444
- required: false,
445
- default: false
446
- },
447
- interactionStep: {
448
- required: false,
449
- default: 1
450
- },
451
- labelText: {
452
- required: false,
453
- default: null
454
- },
455
- labelInfoText: {
456
- required: false,
457
- default: null
458
- },
459
- labelInfoAlign: {
460
- required: false,
461
- default: 'left'
462
- },
463
- defaultNumber: {
464
- required: false,
465
- default: null
466
- },
467
- minNumber: {
468
- required: false,
469
- default: null
470
- },
471
- fontColor: {
472
- required: false,
473
- default: null
474
- },
475
- backgroundColor: {
476
- required: false,
477
- default: null
478
- },
479
- numberToStringEnabled: {
480
- required: false,
481
- default: true
482
- },
483
- allowNegative: {
484
- required: false,
485
- default: true
486
- },
487
- slotSize: {
488
- required: false
489
- },
490
- labelFontColor: {
491
- required: false,
492
- default: 'eturnityGrey'
493
- },
494
- focus: {
495
- required: false,
496
- default: false
497
- },
498
- labelDataId: {
499
- required: false,
500
- default: ''
501
- },
502
- inputDataId: {
503
- required: false,
504
- default: ''
505
- },
506
- showSelect: {
507
- type: Boolean,
508
- default: false
509
- },
510
- selectWidth: {
511
- type: Number,
512
- default: 70
513
- },
514
- selectOptions: {
515
- type: Array,
516
- default: () => []
517
- },
518
- selectValue: {
519
- type: [String, Number],
520
- default: null
521
- },
522
- isSelectDisabled: {
523
- type: Boolean,
524
- default: false
525
- }
526
- },
527
- computed: {
528
- displayedPlaceholder() {
529
- if (this.placeholder) return this.placeholder
530
- if (this.defaultNumber)
531
- return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
532
- return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
533
- },
534
- hasSlot() {
535
- return !!this.$slots.default
536
- },
537
- hasLabelSlot() {
538
- return !!this.$slots.label
539
- },
540
- getSelectValue() {
541
- const item = this.selectOptions.find(
542
- ({ value }) => value === this.selectValue
543
- )
288
+ const IconAttrs = { size: String }
289
+ const IconWrapper = styled('div', IconAttrs)`
290
+ position: absolute;
291
+ top: 0;
292
+ bottom: 0;
293
+ margin: auto;
294
+ right: 5px;
295
+ height: ${(props) => (props.size ? props.size : 'auto')};
296
+ `
544
297
 
545
- return item ? item.label : '-'
546
- }
547
- },
548
- methods: {
549
- onEnterPress() {
550
- this.$emit('on-enter-click')
551
- this.$refs.inputField1.$el.blur()
552
- },
553
- onChangeHandler(event) {
554
- if (isNaN(event) || event === '') {
555
- event = this.defaultNumber
556
- ? this.defaultNumber
557
- : this.minNumber || this.minNumber === 0
558
- ? this.minNumber
559
- : event
298
+ export default {
299
+ name: 'InputNumber',
300
+ components: {
301
+ Container,
302
+ InputContainer,
303
+ InputWrapper,
304
+ UnitContainer,
305
+ ErrorMessage,
306
+ LabelWrapper,
307
+ LabelSlotWrapper,
308
+ LabelText,
309
+ InfoText,
310
+ Icon,
311
+ SlotContainer,
312
+ IconWrapper,
313
+ },
314
+ inheritAttrs: false,
315
+ props: {
316
+ placeholder: {
317
+ required: false,
318
+ default: '',
319
+ },
320
+ isError: {
321
+ required: false,
322
+ default: false,
323
+ },
324
+ inputWidth: {
325
+ required: false,
326
+ default: null,
327
+ },
328
+ minWidth: {
329
+ required: false,
330
+ default: null,
331
+ },
332
+ inputHeight: {
333
+ required: false,
334
+ default: '40px',
335
+ },
336
+ value: {
337
+ required: true,
338
+ default: null,
339
+ },
340
+ clearInput: {
341
+ required: false,
342
+ default: false,
343
+ },
344
+ alignItems: {
345
+ required: false,
346
+ default: 'vertical',
347
+ },
348
+ errorMessage: {
349
+ required: false,
350
+ default: 'Please insert a correct number',
351
+ },
352
+ numberPrecision: {
353
+ required: false,
354
+ default: 0,
355
+ },
356
+ minDecimals: {
357
+ required: false,
358
+ default: 0,
359
+ },
360
+ unitName: {
361
+ required: false,
362
+ default: '',
363
+ },
364
+ showLinearUnitName: {
365
+ required: false,
366
+ default: false,
367
+ },
368
+ disabled: {
369
+ required: false,
370
+ default: false,
371
+ },
372
+ noBorder: {
373
+ required: false,
374
+ default: false,
375
+ },
376
+ borderColor: {
377
+ required: false,
378
+ },
379
+ textAlign: {
380
+ required: false,
381
+ default: 'left',
382
+ },
383
+ fontSize: {
384
+ required: false,
385
+ default: '13px',
386
+ },
387
+ isInteractive: {
388
+ required: false,
389
+ default: false,
390
+ },
391
+ interactionStep: {
392
+ required: false,
393
+ default: 1,
394
+ },
395
+ labelText: {
396
+ required: false,
397
+ default: null,
398
+ },
399
+ labelInfoText: {
400
+ required: false,
401
+ default: null,
402
+ },
403
+ labelInfoAlign: {
404
+ required: false,
405
+ default: 'left',
406
+ },
407
+ defaultNumber: {
408
+ required: false,
409
+ default: null,
410
+ },
411
+ minNumber: {
412
+ required: false,
413
+ default: null,
414
+ },
415
+ fontColor: {
416
+ required: false,
417
+ default: null,
418
+ },
419
+ backgroundColor: {
420
+ required: false,
421
+ default: null,
422
+ },
423
+ numberToStringEnabled: {
424
+ required: false,
425
+ default: true,
426
+ },
427
+ allowNegative: {
428
+ required: false,
429
+ default: true,
430
+ },
431
+ slotSize: {
432
+ required: false,
433
+ },
434
+ labelFontColor: {
435
+ required: false,
436
+ default: 'eturnityGrey',
437
+ },
438
+ focus: {
439
+ required: false,
440
+ default: false,
441
+ },
442
+ labelDataId: {
443
+ required: false,
444
+ default: '',
445
+ },
446
+ inputDataId: {
447
+ required: false,
448
+ default: '',
449
+ },
450
+ },
451
+ data() {
452
+ return {
453
+ textInput: '',
454
+ isFocused: false,
455
+ warningIcon: warningIcon,
560
456
  }
561
- if (!this.allowNegative) {
562
- event = Math.abs(event)
563
- }
564
- event = parseFloat(event)
565
- // Need to return an integer rather than a string
566
- this.$emit('input-change', event)
567
457
  },
568
- onEvaluateCode(event) {
569
- // function to perform math on the code
570
- // filter the string in case of any malicious content
571
- const val = event.target.value
572
- let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
573
- filtered = filtered.split(/([-+*/()])/)
574
- let formatted = filtered.map((item) => {
575
- if (
576
- item === '+' ||
577
- item === '-' ||
578
- item === '*' ||
579
- item === '/' ||
580
- item === '(' ||
581
- item === ')' ||
582
- item === ''
583
- ) {
584
- return item
585
- } else {
586
- let num = stringToNumber({
587
- value: item,
588
- numberPrecision: false,
589
- minDecimals: this.minDecimals
590
- })
591
- return num
458
+ computed: {
459
+ displayedPlaceholder() {
460
+ if (this.placeholder) return this.placeholder
461
+ if (this.defaultNumber)
462
+ return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
463
+ return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
464
+ },
465
+ hasSlot() {
466
+ return !!this.$slots.default
467
+ },
468
+ hasLabelSlot() {
469
+ return !!this.$slots.label
470
+ },
471
+ },
472
+ watch: {
473
+ focus(value) {
474
+ if (value) {
475
+ this.focusInput()
592
476
  }
593
- })
594
- let evaluated
595
- formatted = this.removeStringItemsAfterLastNumber(formatted)
596
- evaluated = eval(formatted.join(' '))
597
- if (typeof evaluated === 'string') {
598
- evaluated = stringToNumber({
599
- value: evaluated,
600
- numberPrecision: this.numberPrecision,
601
- minDecimals: this.minDecimals
602
- })
603
- } else if (typeof evaluated === 'number') {
604
- evaluated = evaluated.toFixed(this.numberPrecision)
605
- }
606
- return evaluated
607
- },
608
- removeStringItemsAfterLastNumber(array) {
609
- // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
610
- let lastNumberIndex = -1
611
- // Find the index of the last number in the array
612
- for (let i = array.length - 1; i >= 0; i--) {
613
- if (typeof array[i] === 'number') {
614
- lastNumberIndex = i
615
- break
477
+ },
478
+ clearInput: function (value) {
479
+ if (value) {
480
+ // If the value is typed, then we should clear the textInput on Continue
481
+ this.textInput = ''
616
482
  }
617
- }
618
- // if there are no numbers, return an empty array
619
- if (lastNumberIndex === -1) {
620
- return []
621
- }
622
- // Remove non-numeric items after the last number
623
- if (lastNumberIndex !== -1) {
624
- const newArray = array.slice(0, lastNumberIndex + 1)
625
- return newArray
626
- }
627
- return array
483
+ },
628
484
  },
629
- onInput(event) {
630
- if (!this.isFocused) {
631
- return
632
- }
633
- if (event.target.value === '') {
634
- this.$emit('on-input', '')
635
- }
636
- let evaluatedVal
637
- try {
638
- evaluatedVal = this.onEvaluateCode(event)
639
- } finally {
640
- if (evaluatedVal && this.value != evaluatedVal) {
641
- this.$emit('on-input', evaluatedVal)
642
- }
643
- }
644
- },
645
- onInputBlur(e) {
646
- this.isFocused = false
647
- let value = e.target.value
648
- let evaluatedInput = this.onEvaluateCode(e)
649
- this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
650
- if ((evaluatedInput && value.length) || this.minNumber !== null) {
485
+ created() {
486
+ if (this.value) {
487
+ this.textInput = numberToString({
488
+ value: this.value,
489
+ numberPrecision: this.numberPrecision,
490
+ minDecimals: this.minDecimals,
491
+ })
492
+ } else if (this.defaultNumber !== null) {
651
493
  this.textInput = numberToString({
652
- value:
653
- evaluatedInput && value.length
654
- ? evaluatedInput
655
- : this.defaultNumber
656
- ? this.defaultNumber
657
- : this.minNumber,
494
+ value: this.defaultNumber,
658
495
  numberPrecision: this.numberPrecision,
659
- minDecimals: this.minDecimals
496
+ minDecimals: this.minDecimals,
497
+ })
498
+ } else if (this.minNumber !== null) {
499
+ this.textInput = numberToString({
500
+ value: this.minNumber,
501
+ numberPrecision: this.numberPrecision,
502
+ minDecimals: this.minDecimals,
660
503
  })
661
504
  }
662
- let adjustedMinValue =
663
- evaluatedInput && evaluatedInput.length
664
- ? evaluatedInput
665
- : this.defaultNumber
666
- ? this.defaultNumber
667
- : this.minNumber || this.minNumber === 0
668
- ? this.minNumber
669
- : ''
670
- this.$emit('input-blur', adjustedMinValue)
671
505
  },
672
- focusInput() {
673
- if (this.disabled) {
674
- return
506
+ mounted() {
507
+ if (this.focus) {
508
+ this.focusInput()
675
509
  }
676
- this.isFocused = true
677
- this.$nextTick(() => {
678
- this.$refs.inputField1.$el.select()
679
- })
680
- this.$emit('input-focus')
681
510
  },
682
- blurInput() {
683
- if (this.disabled) {
684
- return
685
- }
686
- this.isFocused = false
687
- this.$nextTick(() => {
511
+ methods: {
512
+ onEnterPress() {
513
+ this.$emit('on-enter-click')
688
514
  this.$refs.inputField1.$el.blur()
689
- })
690
- },
691
- formatWithCurrency(value) {
692
- let adjustedMinValue =
693
- value || value === 0
694
- ? value
695
- : this.defaultNumber
696
- ? this.defaultNumber
697
- : this.minNumber || this.minNumber === 0
698
- ? this.minNumber
699
- : ''
700
- if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
701
- let input = this.numberToStringEnabled
702
- ? numberToString({
703
- value: adjustedMinValue,
704
- numberPrecision: this.numberPrecision,
705
- minDecimals: this.minDecimals
706
- })
707
- : adjustedMinValue
708
- let unit = this.showLinearUnitName ? '' : this.unitName
709
- //return input + ' ' + unit
710
- return input + ' ' + unit
711
- } else if (!adjustedMinValue && adjustedMinValue !== 0) {
712
- return ''
713
- } else {
714
- return this.numberToStringEnabled
715
- ? numberToString({
716
- value: adjustedMinValue,
717
- numberPrecision: this.numberPrecision,
718
- minDecimals: this.minDecimals
515
+ },
516
+ onChangeHandler(event) {
517
+ if (isNaN(event) || event === '') {
518
+ event = this.defaultNumber
519
+ ? this.defaultNumber
520
+ : this.minNumber || this.minNumber === 0
521
+ ? this.minNumber
522
+ : event
523
+ }
524
+ if (!this.allowNegative) {
525
+ event = Math.abs(event)
526
+ }
527
+ event = parseFloat(event)
528
+ // Need to return an integer rather than a string
529
+ this.$emit('input-change', event)
530
+ },
531
+ onEvaluateCode(event) {
532
+ // function to perform math on the code
533
+ // filter the string in case of any malicious content
534
+ const val = event.target.value
535
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
536
+ filtered = filtered.split(/([-+*/()])/)
537
+ let formatted = filtered.map((item) => {
538
+ if (
539
+ item === '+' ||
540
+ item === '-' ||
541
+ item === '*' ||
542
+ item === '/' ||
543
+ item === '(' ||
544
+ item === ')' ||
545
+ item === ''
546
+ ) {
547
+ return item
548
+ } else {
549
+ let num = stringToNumber({
550
+ value: item,
551
+ numberPrecision: false,
552
+ minDecimals: this.minDecimals,
719
553
  })
720
- : adjustedMinValue
721
- }
722
- },
723
- initInteraction(e) {
724
- this.focusInput()
725
- e.preventDefault()
726
- window.addEventListener('mousemove', this.interact, false)
727
- window.addEventListener('mouseup', this.stopInteract, false)
728
- },
729
- interact(e) {
730
- e.preventDefault()
731
- let value = parseFloat(this.value || 0)
732
- value += parseFloat(this.interactionStep) * parseInt(e.movementX)
733
- this.$emit('on-input-drag', value)
734
-
735
- this.textInput = numberToString({
736
- value: value && value.length ? value : this.minNumber,
737
- numberPrecision: this.numberPrecision,
738
- minDecimals: this.minDecimals
739
- })
740
- //this.value=value
741
- },
742
- stopInteract(e) {
743
- e.preventDefault()
744
- window.removeEventListener('mousemove', this.interact, false)
745
- window.removeEventListener('mouseup', this.stopInteract, false)
746
- this.blurInput()
747
- }
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
- }
769
- },
770
- mounted() {
771
- if (this.focus) {
772
- this.focusInput()
773
- }
774
- },
775
- watch: {
776
- focus(value) {
777
- if (value) {
554
+ return num
555
+ }
556
+ })
557
+ let evaluated
558
+ formatted = this.removeStringItemsAfterLastNumber(formatted)
559
+ evaluated = eval(formatted.join(' '))
560
+ if (typeof evaluated === 'string') {
561
+ evaluated = stringToNumber({
562
+ value: evaluated,
563
+ numberPrecision: this.numberPrecision,
564
+ minDecimals: this.minDecimals,
565
+ })
566
+ } else if (typeof evaluated === 'number') {
567
+ evaluated = evaluated.toFixed(this.numberPrecision)
568
+ }
569
+ return evaluated
570
+ },
571
+ removeStringItemsAfterLastNumber(array) {
572
+ // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
573
+ let lastNumberIndex = -1
574
+ // Find the index of the last number in the array
575
+ for (let i = array.length - 1; i >= 0; i--) {
576
+ if (typeof array[i] === 'number') {
577
+ lastNumberIndex = i
578
+ break
579
+ }
580
+ }
581
+ // if there are no numbers, return an empty array
582
+ if (lastNumberIndex === -1) {
583
+ return []
584
+ }
585
+ // Remove non-numeric items after the last number
586
+ if (lastNumberIndex !== -1) {
587
+ const newArray = array.slice(0, lastNumberIndex + 1)
588
+ return newArray
589
+ }
590
+ return array
591
+ },
592
+ onInput(event) {
593
+ if (!this.isFocused) {
594
+ return
595
+ }
596
+ if (event.target.value === '') {
597
+ this.$emit('on-input', '')
598
+ }
599
+ let evaluatedVal
600
+ try {
601
+ evaluatedVal = this.onEvaluateCode(event)
602
+ } finally {
603
+ if (evaluatedVal && this.value != evaluatedVal) {
604
+ this.$emit('on-input', evaluatedVal)
605
+ }
606
+ }
607
+ },
608
+ onInputBlur(e) {
609
+ this.isFocused = false
610
+ let value = e.target.value
611
+ let evaluatedInput = this.onEvaluateCode(e)
612
+ this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
613
+ if ((evaluatedInput && value.length) || this.minNumber !== null) {
614
+ this.textInput = numberToString({
615
+ value:
616
+ evaluatedInput && value.length
617
+ ? evaluatedInput
618
+ : this.defaultNumber
619
+ ? this.defaultNumber
620
+ : this.minNumber,
621
+ numberPrecision: this.numberPrecision,
622
+ minDecimals: this.minDecimals,
623
+ })
624
+ }
625
+ let adjustedMinValue =
626
+ evaluatedInput && evaluatedInput.length
627
+ ? evaluatedInput
628
+ : this.defaultNumber
629
+ ? this.defaultNumber
630
+ : this.minNumber || this.minNumber === 0
631
+ ? this.minNumber
632
+ : ''
633
+ this.$emit('input-blur', adjustedMinValue)
634
+ },
635
+ focusInput() {
636
+ if (this.disabled) {
637
+ return
638
+ }
639
+ this.isFocused = true
640
+ this.$nextTick(() => {
641
+ this.$refs.inputField1.$el.select()
642
+ })
643
+ this.$emit('input-focus')
644
+ },
645
+ blurInput() {
646
+ if (this.disabled) {
647
+ return
648
+ }
649
+ this.isFocused = false
650
+ this.$nextTick(() => {
651
+ this.$refs.inputField1.$el.blur()
652
+ })
653
+ },
654
+ formatWithCurrency(value) {
655
+ let adjustedMinValue =
656
+ value || value === 0
657
+ ? value
658
+ : this.defaultNumber
659
+ ? this.defaultNumber
660
+ : this.minNumber || this.minNumber === 0
661
+ ? this.minNumber
662
+ : ''
663
+ if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
664
+ let input = this.numberToStringEnabled
665
+ ? numberToString({
666
+ value: adjustedMinValue,
667
+ numberPrecision: this.numberPrecision,
668
+ minDecimals: this.minDecimals,
669
+ })
670
+ : adjustedMinValue
671
+ let unit = this.showLinearUnitName ? '' : this.unitName
672
+ //return input + ' ' + unit
673
+ return input + ' ' + unit
674
+ } else if (!adjustedMinValue && adjustedMinValue !== 0) {
675
+ return ''
676
+ } else {
677
+ return this.numberToStringEnabled
678
+ ? numberToString({
679
+ value: adjustedMinValue,
680
+ numberPrecision: this.numberPrecision,
681
+ minDecimals: this.minDecimals,
682
+ })
683
+ : adjustedMinValue
684
+ }
685
+ },
686
+ initInteraction(e) {
778
687
  this.focusInput()
779
- }
688
+ e.preventDefault()
689
+ window.addEventListener('mousemove', this.interact, false)
690
+ window.addEventListener('mouseup', this.stopInteract, false)
691
+ },
692
+ interact(e) {
693
+ e.preventDefault()
694
+ let value = parseFloat(this.value || 0)
695
+ value += parseFloat(this.interactionStep) * parseInt(e.movementX)
696
+ this.$emit('on-input-drag', value)
697
+
698
+ this.textInput = numberToString({
699
+ value: value && value.length ? value : this.minNumber,
700
+ numberPrecision: this.numberPrecision,
701
+ minDecimals: this.minDecimals,
702
+ })
703
+ //this.value=value
704
+ },
705
+ stopInteract(e) {
706
+ e.preventDefault()
707
+ window.removeEventListener('mousemove', this.interact, false)
708
+ window.removeEventListener('mouseup', this.stopInteract, false)
709
+ this.blurInput()
710
+ },
780
711
  },
781
- clearInput: function (value) {
782
- if (value) {
783
- // If the value is typed, then we should clear the textInput on Continue
784
- this.textInput = ''
785
- }
786
- }
787
712
  }
788
- }
789
713
  </script>