@eturnity/eturnity_reusable_components 7.12.6-EPDM-7951.3 → 7.12.7

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 (284) hide show
  1. package/.prettierrc +6 -6
  2. package/.storybook/main.js +8 -8
  3. package/.storybook/preview.js +46 -46
  4. package/README.md +29 -29
  5. package/babel.config.js +4 -4
  6. package/package.json +66 -61
  7. package/postcss.config.js +6 -6
  8. package/public/index.html +17 -17
  9. package/src/App.vue +109 -109
  10. package/src/assets/icons/arrow_down.svg +3 -3
  11. package/src/assets/icons/arrow_up_red.svg +3 -3
  12. package/src/assets/icons/black_spinner.svg +35 -35
  13. package/src/assets/icons/delete_icon.svg +11 -11
  14. package/src/assets/icons/delete_icon_gray.svg +11 -11
  15. package/src/assets/icons/drag_icon.svg +8 -8
  16. package/src/assets/icons/external_icon.svg +6 -6
  17. package/src/assets/icons/language_icon.svg +6 -6
  18. package/src/assets/icons/pdf_icon.svg +6 -6
  19. package/src/assets/icons/plus_button.svg +4 -4
  20. package/src/assets/icons/search_icon_black.svg +3 -3
  21. package/src/assets/icons/subposition_icon.svg +3 -3
  22. package/src/assets/icons/subposition_marker.svg +3 -3
  23. package/src/assets/icons/warning_icon.svg +3 -3
  24. package/src/assets/svgIcons/2d_active.svg +7 -7
  25. package/src/assets/svgIcons/2d_inactive.svg +8 -8
  26. package/src/assets/svgIcons/3d_active.svg +7 -7
  27. package/src/assets/svgIcons/3d_inactive.svg +8 -8
  28. package/src/assets/svgIcons/_readme.md +7 -7
  29. package/src/assets/svgIcons/accept.svg +5 -5
  30. package/src/assets/svgIcons/activate_panels_active.svg +22 -22
  31. package/src/assets/svgIcons/activate_panels_inactive.svg +20 -20
  32. package/src/assets/svgIcons/add_icon-1.svg +3 -3
  33. package/src/assets/svgIcons/add_icon.svg +4 -4
  34. package/src/assets/svgIcons/address_book.svg +3 -3
  35. package/src/assets/svgIcons/after_sale_as_a_service.svg +6 -6
  36. package/src/assets/svgIcons/all_good.svg +3 -3
  37. package/src/assets/svgIcons/angle_active.svg +5 -5
  38. package/src/assets/svgIcons/angle_inactive.svg +4 -4
  39. package/src/assets/svgIcons/area_active.svg +11 -11
  40. package/src/assets/svgIcons/area_inactive.svg +26 -26
  41. package/src/assets/svgIcons/areas_tool.svg +14 -14
  42. package/src/assets/svgIcons/arrow_down.svg +3 -3
  43. package/src/assets/svgIcons/arrow_left.svg +4 -4
  44. package/src/assets/svgIcons/arrow_right.svg +4 -4
  45. package/src/assets/svgIcons/arrow_up.svg +3 -3
  46. package/src/assets/svgIcons/attachment.svg +3 -3
  47. package/src/assets/svgIcons/base_layer.svg +3 -3
  48. package/src/assets/svgIcons/battery.svg +3 -3
  49. package/src/assets/svgIcons/bell.svg +3 -3
  50. package/src/assets/svgIcons/bold.svg +3 -3
  51. package/src/assets/svgIcons/bom.svg +3 -3
  52. package/src/assets/svgIcons/bom_generation.svg +10 -10
  53. package/src/assets/svgIcons/bookmaker.svg +3 -3
  54. package/src/assets/svgIcons/bubble.svg +3 -3
  55. package/src/assets/svgIcons/bug.svg +5 -5
  56. package/src/assets/svgIcons/bullet_list.svg +8 -8
  57. package/src/assets/svgIcons/calendar.svg +7 -7
  58. package/src/assets/svgIcons/calendar_icon.svg +7 -7
  59. package/src/assets/svgIcons/call.svg +3 -3
  60. package/src/assets/svgIcons/camera.svg +3 -3
  61. package/src/assets/svgIcons/car.svg +3 -3
  62. package/src/assets/svgIcons/cart.svg +3 -3
  63. package/src/assets/svgIcons/checkbox.svg +3 -3
  64. package/src/assets/svgIcons/clear_formatting.svg +7 -7
  65. package/src/assets/svgIcons/clickable_info.svg +4 -4
  66. package/src/assets/svgIcons/clip.svg +3 -3
  67. package/src/assets/svgIcons/clock.svg +17 -17
  68. package/src/assets/svgIcons/close_for_modals,_tool_tips.svg +4 -4
  69. package/src/assets/svgIcons/co_branding.svg +5 -5
  70. package/src/assets/svgIcons/collapse.svg +4 -4
  71. package/src/assets/svgIcons/collections.svg +3 -3
  72. package/src/assets/svgIcons/component_library.svg +7 -7
  73. package/src/assets/svgIcons/context_menu-1.svg +6 -6
  74. package/src/assets/svgIcons/context_menu-2.svg +5 -5
  75. package/src/assets/svgIcons/context_menu.svg +5 -5
  76. package/src/assets/svgIcons/context_menu_tabs.svg +5 -5
  77. package/src/assets/svgIcons/cross.svg +4 -4
  78. package/src/assets/svgIcons/current_variant.svg +4 -4
  79. package/src/assets/svgIcons/dashboard.svg +3 -3
  80. package/src/assets/svgIcons/deadline.svg +4 -4
  81. package/src/assets/svgIcons/deal_flow.svg +5 -5
  82. package/src/assets/svgIcons/delete.svg +4 -4
  83. package/src/assets/svgIcons/delete_area_active.svg +16 -16
  84. package/src/assets/svgIcons/delete_area_inactive.svg +15 -15
  85. package/src/assets/svgIcons/direction_active-1.svg +12 -12
  86. package/src/assets/svgIcons/direction_active.svg +5 -5
  87. package/src/assets/svgIcons/direction_arrow.svg +4 -4
  88. package/src/assets/svgIcons/direction_inactive.svg +4 -4
  89. package/src/assets/svgIcons/dislike.svg +3 -3
  90. package/src/assets/svgIcons/distance_tool.svg +8 -8
  91. package/src/assets/svgIcons/distances_active.svg +9 -9
  92. package/src/assets/svgIcons/distances_inactive.svg +8 -8
  93. package/src/assets/svgIcons/distort_tool.svg +10 -10
  94. package/src/assets/svgIcons/distort_tool2.svg +16 -16
  95. package/src/assets/svgIcons/document.svg +3 -3
  96. package/src/assets/svgIcons/documents.svg +4 -4
  97. package/src/assets/svgIcons/downarrow.svg +3 -3
  98. package/src/assets/svgIcons/download.svg +4 -4
  99. package/src/assets/svgIcons/draggable_corner.svg +5 -5
  100. package/src/assets/svgIcons/draw_tool.svg +3 -3
  101. package/src/assets/svgIcons/duplicate-1.svg +8 -8
  102. package/src/assets/svgIcons/duplicate-2.svg +5 -5
  103. package/src/assets/svgIcons/duplicate.svg +4 -4
  104. package/src/assets/svgIcons/e-mobility_configurator.svg +6 -6
  105. package/src/assets/svgIcons/e_signature.svg +5 -5
  106. package/src/assets/svgIcons/edit_button.svg +3 -3
  107. package/src/assets/svgIcons/email.svg +3 -3
  108. package/src/assets/svgIcons/ems-1.svg +3 -3
  109. package/src/assets/svgIcons/ems.svg +3 -3
  110. package/src/assets/svgIcons/end_of_the_list.svg +5 -5
  111. package/src/assets/svgIcons/erase.svg +4 -4
  112. package/src/assets/svgIcons/external_icon.svg +5 -5
  113. package/src/assets/svgIcons/fav_icon.svg +4 -4
  114. package/src/assets/svgIcons/finance.svg +3 -3
  115. package/src/assets/svgIcons/financing_for_pv-1.svg +5 -5
  116. package/src/assets/svgIcons/financing_for_pv-2.svg +3 -3
  117. package/src/assets/svgIcons/financing_for_pv.svg +6 -6
  118. package/src/assets/svgIcons/finish-1.svg +4 -4
  119. package/src/assets/svgIcons/finish.svg +3 -3
  120. package/src/assets/svgIcons/flatten.svg +11 -11
  121. package/src/assets/svgIcons/folder.svg +3 -3
  122. package/src/assets/svgIcons/free_technology.svg +5 -5
  123. package/src/assets/svgIcons/heat_calc.svg +7 -7
  124. package/src/assets/svgIcons/house.svg +3 -3
  125. package/src/assets/svgIcons/info.svg +3 -3
  126. package/src/assets/svgIcons/initial_situation.svg +3 -3
  127. package/src/assets/svgIcons/integrations.svg +3 -3
  128. package/src/assets/svgIcons/intro-tour-1.svg +3 -3
  129. package/src/assets/svgIcons/intro-tour.svg +3 -3
  130. package/src/assets/svgIcons/inverter-1.svg +5 -5
  131. package/src/assets/svgIcons/inverter.svg +3 -3
  132. package/src/assets/svgIcons/italic.svg +3 -3
  133. package/src/assets/svgIcons/key.svg +3 -3
  134. package/src/assets/svgIcons/layers_close.svg +4 -4
  135. package/src/assets/svgIcons/layers_open.svg +4 -4
  136. package/src/assets/svgIcons/lead_marketplace.svg +6 -6
  137. package/src/assets/svgIcons/lead_provider.svg +4 -4
  138. package/src/assets/svgIcons/length_in_2d_active.svg +12 -12
  139. package/src/assets/svgIcons/length_in_2d_inctive.svg +13 -13
  140. package/src/assets/svgIcons/light_bulb.svg +3 -3
  141. package/src/assets/svgIcons/like.svg +3 -3
  142. package/src/assets/svgIcons/line_graph.svg +3 -3
  143. package/src/assets/svgIcons/local_subsidies.svg +18 -18
  144. package/src/assets/svgIcons/location.svg +3 -3
  145. package/src/assets/svgIcons/lock.svg +3 -3
  146. package/src/assets/svgIcons/logout.svg +3 -3
  147. package/src/assets/svgIcons/loop.svg +3 -3
  148. package/src/assets/svgIcons/lunch.svg +4 -4
  149. package/src/assets/svgIcons/magic_tool.svg +6 -6
  150. package/src/assets/svgIcons/map_icon.svg +5 -5
  151. package/src/assets/svgIcons/map_settings.svg +3 -3
  152. package/src/assets/svgIcons/margin_tool.svg +4 -4
  153. package/src/assets/svgIcons/meeting.svg +6 -6
  154. package/src/assets/svgIcons/move_copy.svg +4 -4
  155. package/src/assets/svgIcons/new_area_inactive.svg +11 -11
  156. package/src/assets/svgIcons/next.svg +4 -4
  157. package/src/assets/svgIcons/not_equal_to.svg +3 -3
  158. package/src/assets/svgIcons/numbered_list.svg +6 -6
  159. package/src/assets/svgIcons/obstacle_tool.svg +9 -9
  160. package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -3
  161. package/src/assets/svgIcons/offset_tool.svg +8 -8
  162. package/src/assets/svgIcons/outline_tool.svg +11 -11
  163. package/src/assets/svgIcons/pan_tool.svg +12 -12
  164. package/src/assets/svgIcons/panels_tool.svg +8 -8
  165. package/src/assets/svgIcons/pen_tool.svg +4 -4
  166. package/src/assets/svgIcons/picker_tool.svg +4 -4
  167. package/src/assets/svgIcons/picture.svg +3 -3
  168. package/src/assets/svgIcons/pin.svg +5 -5
  169. package/src/assets/svgIcons/presentation.svg +3 -3
  170. package/src/assets/svgIcons/previous.svg +4 -4
  171. package/src/assets/svgIcons/profile-1.svg +4 -4
  172. package/src/assets/svgIcons/profile.svg +4 -4
  173. package/src/assets/svgIcons/profitability.svg +3 -3
  174. package/src/assets/svgIcons/project_analysis.svg +4 -4
  175. package/src/assets/svgIcons/project_settings.svg +4 -4
  176. package/src/assets/svgIcons/pv.svg +3 -3
  177. package/src/assets/svgIcons/quotations.svg +6 -6
  178. package/src/assets/svgIcons/redo.svg +6 -6
  179. package/src/assets/svgIcons/resizer.svg +5 -5
  180. package/src/assets/svgIcons/roof_layer.svg +3 -3
  181. package/src/assets/svgIcons/rotate_tool.svg +3 -3
  182. package/src/assets/svgIcons/rotate_view.svg +5 -5
  183. package/src/assets/svgIcons/ruler_tool.svg +3 -3
  184. package/src/assets/svgIcons/run_simulation.svg +3 -3
  185. package/src/assets/svgIcons/scaling_tool.svg +8 -8
  186. package/src/assets/svgIcons/search.svg +3 -3
  187. package/src/assets/svgIcons/security.svg +3 -3
  188. package/src/assets/svgIcons/settings.svg +3 -3
  189. package/src/assets/svgIcons/show_in_a_new_tab.svg +12 -12
  190. package/src/assets/svgIcons/smartphone.svg +4 -4
  191. package/src/assets/svgIcons/solar_calc.svg +13 -13
  192. package/src/assets/svgIcons/sorting.svg +4 -4
  193. package/src/assets/svgIcons/split.svg +94 -94
  194. package/src/assets/svgIcons/start_of_the_list.svg +5 -5
  195. package/src/assets/svgIcons/strikethrough.svg +4 -4
  196. package/src/assets/svgIcons/subscriptions.svg +3 -3
  197. package/src/assets/svgIcons/subsidies-1.svg +5 -5
  198. package/src/assets/svgIcons/subsidies-2.svg +3 -3
  199. package/src/assets/svgIcons/subsidies.svg +3 -3
  200. package/src/assets/svgIcons/subtract_icon.svg +3 -3
  201. package/src/assets/svgIcons/suitcase.svg +3 -3
  202. package/src/assets/svgIcons/template_icon_not_clickable.svg +6 -6
  203. package/src/assets/svgIcons/transfer.svg +4 -4
  204. package/src/assets/svgIcons/trim_tool.svg +4 -4
  205. package/src/assets/svgIcons/truck.svg +3 -3
  206. package/src/assets/svgIcons/underlined.svg +3 -3
  207. package/src/assets/svgIcons/undo.svg +6 -6
  208. package/src/assets/svgIcons/uparrow.svg +3 -3
  209. package/src/assets/svgIcons/update.svg +3 -3
  210. package/src/assets/svgIcons/upload_avatar-1.svg +12 -12
  211. package/src/assets/svgIcons/upload_avatar.svg +5 -5
  212. package/src/assets/svgIcons/upload_image.svg +8 -8
  213. package/src/assets/svgIcons/upload_image_tool.svg +7 -7
  214. package/src/assets/svgIcons/variants.svg +6 -6
  215. package/src/assets/svgIcons/vertical_tool.svg +3 -3
  216. package/src/assets/svgIcons/virtual_storage.svg +4 -4
  217. package/src/assets/svgIcons/warning.svg +4 -4
  218. package/src/assets/svgIcons/way.svg +5 -5
  219. package/src/assets/svgIcons/wifi.svg +3 -3
  220. package/src/assets/svgIcons/winter.svg +3 -3
  221. package/src/assets/svgIcons/workflow_template.svg +11 -11
  222. package/src/assets/theme.js +41 -41
  223. package/src/components/addNewButton/AddNewButton.stories.js +24 -24
  224. package/src/components/addNewButton/index.vue +62 -64
  225. package/src/components/buttons/buttonIcon/index.vue +142 -142
  226. package/src/components/buttons/closeButton/CloseButton.stories.js +29 -29
  227. package/src/components/buttons/closeButton/index.vue +61 -61
  228. package/src/components/buttons/mainButton/index.vue +107 -112
  229. package/src/components/deleteIcon/DeleteIcon.stories.js +29 -29
  230. package/src/components/deleteIcon/index.vue +61 -65
  231. package/src/components/draggableInputHandle/index.vue +47 -46
  232. package/src/components/dropdown/Dropdown.stories.js +54 -54
  233. package/src/components/dropdown/index.vue +119 -138
  234. package/src/components/errorMessage/index.vue +59 -59
  235. package/src/components/filter/filterSettings.vue +650 -608
  236. package/src/components/filter/index.vue +143 -143
  237. package/src/components/filter/parentDropdown.vue +91 -91
  238. package/src/components/icon/Icons.stories.js +41 -41
  239. package/src/components/icon/iconCollection.vue +68 -68
  240. package/src/components/icon/index.vue +116 -122
  241. package/src/components/iconWrapper/index.vue +156 -153
  242. package/src/components/infoCard/index.vue +36 -35
  243. package/src/components/infoText/index.vue +160 -160
  244. package/src/components/inputs/checkbox/Checkbox.stories.js +57 -57
  245. package/src/components/inputs/checkbox/index.vue +187 -202
  246. package/src/components/inputs/inputNumber/InputNumber.stories.js +150 -150
  247. package/src/components/inputs/inputNumber/index.vue +717 -714
  248. package/src/components/inputs/inputNumberQuestion/index.vue +215 -215
  249. package/src/components/inputs/inputText/InputText.stories.js +75 -75
  250. package/src/components/inputs/inputText/index.vue +359 -359
  251. package/src/components/inputs/radioButton/RadioButton.stories.js +58 -58
  252. package/src/components/inputs/radioButton/index.vue +267 -267
  253. package/src/components/inputs/searchInput/SearchInput.stories.js +40 -40
  254. package/src/components/inputs/searchInput/index.vue +133 -132
  255. package/src/components/inputs/select/index.vue +627 -757
  256. package/src/components/inputs/select/option/index.vue +111 -111
  257. package/src/components/inputs/select/select.stories.js +59 -59
  258. package/src/components/inputs/slider/index.vue +126 -126
  259. package/src/components/inputs/switchField/index.vue +256 -256
  260. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +127 -127
  261. package/src/components/inputs/textAreaInput/index.vue +200 -200
  262. package/src/components/inputs/toggle/Toggle.stories.js +77 -77
  263. package/src/components/inputs/toggle/index.vue +288 -288
  264. package/src/components/label/index.vue +103 -99
  265. package/src/components/modals/modal/index.vue +192 -188
  266. package/src/components/modals/modal/modal.stories.js +31 -31
  267. package/src/components/navigationTabs/index.vue +105 -112
  268. package/src/components/pageSubtitle/index.vue +61 -61
  269. package/src/components/pageTitle/index.vue +73 -73
  270. package/src/components/pagination/index.vue +144 -144
  271. package/src/components/progressBar/index.vue +125 -125
  272. package/src/components/projectMarker/index.vue +291 -294
  273. package/src/components/sideMenu/index.vue +270 -270
  274. package/src/components/spinner/index.vue +72 -67
  275. package/src/components/tableDropdown/index.vue +637 -632
  276. package/src/components/tables/mainTable/exampleNested.vue +328 -328
  277. package/src/components/tables/mainTable/index.vue +446 -447
  278. package/src/components/tables/viewTable/index.vue +195 -195
  279. package/src/components/threeDots/index.vue +393 -393
  280. package/src/components/videoThumbnail/index.vue +108 -103
  281. package/src/components/videoThumbnail/videoThumbnail.stories.js +35 -35
  282. package/src/helpers/numberConverter.js +103 -103
  283. package/src/helpers/translateLang.js +127 -127
  284. package/src/main.js +13 -6
@@ -1,714 +1,717 @@
1
- <template>
2
- <container :inputWidth="inputWidth" :alignItems="alignItems">
3
- <label-slot-wrapper
4
- v-if="hasLabelSlot"
5
- :isInteractive="isInteractive"
6
- :alignItems="alignItems"
7
- :noBorder="noBorder"
8
- :isError="isError"
9
- :borderColor="borderColor"
10
- @mousedown="initInteraction"
11
- >
12
- <slot name="label"></slot>
13
- </label-slot-wrapper>
14
-
15
- <label-wrapper v-if="labelText">
16
- <label-text :labelFontColor="labelFontColor" :data-id="labelDataId">
17
- {{ labelText }}
18
- </label-text>
19
-
20
- <info-text
21
- v-if="labelInfoText"
22
- :text="labelInfoText"
23
- :alignArrow="labelInfoAlign"
24
- />
25
- </label-wrapper>
26
- <input-wrapper>
27
- <input-container
28
- v-bind="$attrs"
29
- ref="inputField1"
30
- :hasUnit="unitName && !!unitName.length"
31
- :placeholder="displayedPlaceholder"
32
- :isError="isError"
33
- :inputHeight="inputHeight"
34
- :minWidth="minWidth"
35
- :isInteractive="isInteractive"
36
- :value="formatWithCurrency(value)"
37
- @blur="onInputBlur($event)"
38
- @focus="focusInput()"
39
- @keyup.enter="onEnterPress"
40
- @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"
55
- />
56
- <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
57
- <slot></slot>
58
- </slot-container>
59
-
60
- <unit-container
61
- v-if="unitName && showLinearUnitName && !hasSlot"
62
- :hasLength="!!textInput.length"
63
- :isError="isError"
64
- >{{ unitName }}</unit-container
65
- >
66
- <icon-wrapper v-if="isError && !showLinearUnitName" size="16px">
67
- <icon name="warning" size="16px" cursor="default" />
68
- </icon-wrapper>
69
- </input-wrapper>
70
- <error-message v-if="isError">{{ errorMessage }}</error-message>
71
- </container>
72
- </template>
73
-
74
- <script>
75
- // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
76
- //This component should be used for questions with input fields only
77
- //How to use:
78
- // <input-number
79
- // placeholder="Enter distance"
80
- // :isError="false" //default is false
81
- // inputWidth="150px" //by default, this is 100%
82
- // minWidth="100px"
83
- // :numberPrecision="3"
84
- // minDecimals="2"
85
- // unitName="pc"
86
- // :value="inputValue" //required -- String
87
- // @input-change="onInputChange($event)" //required
88
- // @on-enter-click="onInputSubmit()"
89
- // :errorMessage="Enter a number between 1 and 10"
90
- // :disabled="false"
91
- // :noBorder="true"
92
- // textAlign="left" // "left, right, center"
93
- // :showLinearUnitName="true"
94
- // fontSize="13px"
95
- // labelText="Number of Modules"
96
- // labelInfoText="Here is some information for you..."
97
- // labelInfoAlign="left"
98
- // :minNumber="0"
99
- // fontColor="blue"
100
- // >
101
- //<template name=label><img>....</template>
102
- //</inputNumber>
103
- import styled from 'vue3-styled-components'
104
- import {
105
- stringToNumber,
106
- numberToString
107
- } from '../../../helpers/numberConverter'
108
- import InfoText from '../../infoText'
109
- import ErrorMessage from '../../errorMessage'
110
- import warningIcon from '../../../assets/icons/error_icon.png'
111
- import Icon from '../../icon'
112
-
113
- const inputProps = {
114
- isError: Boolean,
115
- hasUnit: Boolean,
116
- inputWidth: String,
117
- minWidth: String,
118
- isDisabled: Boolean,
119
- noBorder: Boolean,
120
- textAlign: String,
121
- fontSize: String,
122
- fontColor: String,
123
- backgroundColor: String,
124
- hasSlot: Boolean,
125
- hasLabelSlot: Boolean,
126
- slotSize: String,
127
- inputHeight: String,
128
- isInteractive: Boolean,
129
- alignItems: String,
130
- labelFontColor: String,
131
- borderColor: String,
132
- showLinearUnitName: Boolean
133
- }
134
-
135
- const Container = styled('div', inputProps)`
136
- width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
137
- position: relative;
138
- display: grid;
139
- grid-template-columns: ${(props) =>
140
- props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
141
- `
142
-
143
- const InputContainer = styled('input', inputProps)`
144
- border: ${(props) =>
145
- props.isError
146
- ? '1px solid ' + props.theme.colors.red
147
- : props.noBorder
148
- ? 'none'
149
- : props.borderColor
150
- ? props.theme.colors[props.borderColor]
151
- ? '1px solid ' + props.theme.colors[props.borderColor]
152
- : '1px solid ' + props.borderColor
153
- : '1px solid ' + props.theme.colors.grey4};
154
- height: ${(props) => props.inputHeight};
155
- max-height: ${(props) => props.inputHeight};
156
- padding: 0 10px;
157
- padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
158
- slotSize
159
- ? isError && !showLinearUnitName
160
- ? 'calc(' + slotSize + ' + 24px)'
161
- : 'calc(' + slotSize + ' + 10px)'
162
- : isError && !showLinearUnitName
163
- ? '24px'
164
- : '5px'};
165
- border-radius: ${(props) =>
166
- props.isInteractive && props.alignItems != 'vertical'
167
- ? '0 4px 4px 0'
168
- : '4px'};
169
- text-align: ${(props) => props.textAlign};
170
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
171
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
172
- color: ${(props) =>
173
- props.isError
174
- ? props.theme.colors.grey6
175
- : props.isDisabled
176
- ? props.theme.colors.grey2
177
- : props.fontColor
178
- ? props.fontColor + ' !important'
179
- : props.theme.colors.black};
180
- background-color: ${(props) =>
181
- props.backgroundColor
182
- ? props.backgroundColor + ' !important'
183
- : props.theme.colors.white};
184
- width: ${(props) =>
185
- props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
186
- min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
187
- background-color: ${(props) =>
188
- props.isDisabled ? props.theme.colors.grey5 : '#fff'};
189
- box-sizing: border-box;
190
-
191
- &::placeholder {
192
- color: ${(props) => props.theme.colors.grey2};
193
- }
194
-
195
- &:focus {
196
- outline: none;
197
- }
198
- `
199
-
200
- const InputWrapper = styled.span`
201
- position: relative;
202
- `
203
-
204
- const UnitContainer = styled('span', inputProps)`
205
- border-left: 1px solid
206
- ${(props) =>
207
- props.isError
208
- ? props.theme.colors.red
209
- : props.hasLength
210
- ? props.theme.colors.black
211
- : props.theme.colors.mediumGray};
212
- position: absolute;
213
- right: 10px;
214
- top: 10px;
215
- padding-left: 10px;
216
- text-align: right;
217
- color: ${(props) =>
218
- props.isError
219
- ? props.theme.colors.red
220
- : props.hasLength
221
- ? props.theme.colors.black
222
- : props.theme.colors.mediumGray};
223
- `
224
-
225
- const SlotContainer = styled('span', inputProps)`
226
- text-align: right;
227
- border-left: 1px solid
228
- ${(props) =>
229
- props.isError
230
- ? props.theme.colors.red
231
- : props.hasLength
232
- ? props.theme.colors.black
233
- : props.theme.colors.mediumGray};
234
- position: absolute;
235
- width: ${(props) =>
236
- props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
237
- right: 10px;
238
- top: 10px;
239
- padding-left: 10px;
240
- color: ${(props) =>
241
- props.isError
242
- ? props.theme.colors.red
243
- : props.hasLength
244
- ? props.theme.colors.black
245
- : props.theme.colors.mediumGray};
246
- `
247
-
248
- const LabelWrapper = styled('div', inputProps)`
249
- display: flex;
250
- align-items: center;
251
- gap: 10px;
252
- margin-bottom: 8px;
253
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
254
- `
255
- const LabelSlotWrapper = styled('div', inputProps)`
256
- display: flex;
257
- gap: 10px;
258
- align-items: center;
259
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
260
- border: ${(props) =>
261
- props.alignItems == 'vertical'
262
- ? 'none'
263
- : props.isError
264
- ? '1px solid ' + props.theme.colors.red
265
- : props.noBorder
266
- ? 'none'
267
- : props.borderColor
268
- ? props.theme.colors[props.borderColor]
269
- ? '1px solid ' + props.theme.colors[props.borderColor]
270
- : '1px solid ' + props.borderColor
271
- : '1px solid ' + props.theme.colors.grey4};
272
- border-radius: 4px 0 0 4px;
273
- border-right: none;
274
- `
275
-
276
- const LabelText = styled('div', inputProps)`
277
- font-size: 13px;
278
- color: ${(props) =>
279
- props.theme.colors[props.labelFontColor]
280
- ? props.theme.colors[props.labelFontColor]
281
- : props.labelFontColor};
282
- font-weight: 700;
283
- `
284
-
285
- const IconAttrs = { size: String }
286
- const IconWrapper = styled('div', IconAttrs)`
287
- position: absolute;
288
- top: 0;
289
- bottom: 0;
290
- margin: auto;
291
- right: 5px;
292
- height: ${(props) => (props.size ? props.size : 'auto')};
293
- `
294
-
295
- export default {
296
- name: 'input-number',
297
- components: {
298
- Container,
299
- InputContainer,
300
- InputWrapper,
301
- UnitContainer,
302
- ErrorMessage,
303
- LabelWrapper,
304
- LabelSlotWrapper,
305
- LabelText,
306
- InfoText,
307
- Icon,
308
- SlotContainer,
309
- IconWrapper
310
- },
311
- inheritAttrs: false,
312
- data() {
313
- return {
314
- textInput: '',
315
- isFocused: false,
316
- warningIcon: warningIcon,
317
- isBlurred: false
318
- }
319
- },
320
- props: {
321
- placeholder: {
322
- required: false,
323
- default: ''
324
- },
325
- isError: {
326
- required: false,
327
- default: false
328
- },
329
- inputWidth: {
330
- required: false,
331
- default: null
332
- },
333
- minWidth: {
334
- required: false,
335
- default: null
336
- },
337
- inputHeight: {
338
- required: false,
339
- default: '40px'
340
- },
341
- value: {
342
- required: true,
343
- default: null
344
- },
345
- clearInput: {
346
- required: false,
347
- default: false
348
- },
349
- alignItems: {
350
- required: false,
351
- default: 'vertical'
352
- },
353
- errorMessage: {
354
- required: false,
355
- default: 'Please insert a correct number'
356
- },
357
- numberPrecision: {
358
- required: false,
359
- default: 0
360
- },
361
- minDecimals: {
362
- required: false,
363
- default: 0
364
- },
365
- unitName: {
366
- required: false,
367
- default: ''
368
- },
369
- showLinearUnitName: {
370
- required: false,
371
- default: false
372
- },
373
- disabled: {
374
- required: false,
375
- default: false
376
- },
377
- noBorder: {
378
- required: false,
379
- default: false
380
- },
381
- borderColor: {
382
- required: false
383
- },
384
- textAlign: {
385
- required: false,
386
- default: 'left'
387
- },
388
- fontSize: {
389
- required: false,
390
- default: '13px'
391
- },
392
- isInteractive: {
393
- required: false,
394
- default: false
395
- },
396
- interactionStep: {
397
- required: false,
398
- default: 1
399
- },
400
- labelText: {
401
- required: false,
402
- default: null
403
- },
404
- labelInfoText: {
405
- required: false,
406
- default: null
407
- },
408
- labelInfoAlign: {
409
- required: false,
410
- default: 'left'
411
- },
412
- defaultNumber: {
413
- required: false,
414
- default: null
415
- },
416
- minNumber: {
417
- required: false,
418
- default: null
419
- },
420
- fontColor: {
421
- required: false,
422
- default: null
423
- },
424
- backgroundColor: {
425
- required: false,
426
- default: null
427
- },
428
- numberToStringEnabled: {
429
- required: false,
430
- default: true
431
- },
432
- allowNegative: {
433
- required: false,
434
- default: true
435
- },
436
- slotSize: {
437
- required: false
438
- },
439
- labelFontColor: {
440
- required: false,
441
- default: 'eturnityGrey'
442
- },
443
- focus: {
444
- required: false,
445
- default: false
446
- },
447
- labelDataId: {
448
- required: false,
449
- default: ''
450
- },
451
- inputDataId: {
452
- required: false,
453
- default: ''
454
- }
455
- },
456
- computed: {
457
- displayedPlaceholder() {
458
- if (this.placeholder) return this.placeholder
459
- if (this.defaultNumber)
460
- return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
461
- return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
462
- },
463
- hasSlot() {
464
- return !!this.$slots.default
465
- },
466
- hasLabelSlot() {
467
- return !!this.$slots.label
468
- }
469
- },
470
- methods: {
471
- onEnterPress() {
472
- this.$emit('on-enter-click')
473
- this.$refs.inputField1.$el.blur()
474
- },
475
- onChangeHandler(event) {
476
- if (isNaN(event) || event === '') {
477
- event = this.defaultNumber
478
- ? this.defaultNumber
479
- : this.minNumber || this.minNumber === 0
480
- ? this.minNumber
481
- : event
482
- }
483
- if (!this.allowNegative) {
484
- event = Math.abs(event)
485
- }
486
- event = parseFloat(event)
487
- // Need to return an integer rather than a string
488
- this.$emit('input-change', event)
489
- },
490
- onEvaluateCode(event) {
491
- // function to perform math on the code
492
- // filter the string in case of any malicious content
493
- const val = event.target.value
494
- let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
495
- filtered = filtered.split(/([-+*/()])/)
496
- let formatted = filtered.map((item) => {
497
- if (
498
- item === '+' ||
499
- item === '-' ||
500
- item === '*' ||
501
- item === '/' ||
502
- item === '(' ||
503
- item === ')' ||
504
- item === ''
505
- ) {
506
- return item
507
- } else {
508
- let num = stringToNumber({
509
- value: item,
510
- numberPrecision: false,
511
- minDecimals: this.minDecimals
512
- })
513
- return num
514
- }
515
- })
516
- let evaluated
517
- formatted = this.removeStringItemsAfterLastNumber(formatted)
518
- evaluated = eval(formatted.join(' '))
519
- if (typeof evaluated === 'string') {
520
- evaluated = stringToNumber({
521
- value: evaluated,
522
- numberPrecision: this.numberPrecision,
523
- minDecimals: this.minDecimals
524
- })
525
- } else if (typeof evaluated === 'number') {
526
- evaluated = evaluated.toFixed(this.numberPrecision)
527
- }
528
- return evaluated
529
- },
530
- removeStringItemsAfterLastNumber(array) {
531
- // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
532
- let lastNumberIndex = -1
533
- // Find the index of the last number in the array
534
- for (let i = array.length - 1; i >= 0; i--) {
535
- if (typeof array[i] === 'number') {
536
- lastNumberIndex = i
537
- break
538
- }
539
- }
540
- // if there are no numbers, return an empty array
541
- if (lastNumberIndex === -1) {
542
- return []
543
- }
544
- // Remove non-numeric items after the last number
545
- if (lastNumberIndex !== -1) {
546
- const newArray = array.slice(0, lastNumberIndex + 1)
547
- return newArray
548
- }
549
- return array
550
- },
551
- onInput(event) {
552
- if (this.isBlurred) {
553
- this.isBlurred = false
554
- return
555
- }
556
- if (event.target.value === '') {
557
- this.$emit('on-input', '')
558
- }
559
- let evaluatedVal
560
- try {
561
- evaluatedVal = this.onEvaluateCode(event)
562
- } finally {
563
- if (evaluatedVal) {
564
- this.$emit('on-input', evaluatedVal)
565
- }
566
- }
567
- },
568
- onInputBlur(e) {
569
- this.isFocused = false
570
- // setting isBlurred so we don't trigger onInput as well
571
- this.isBlurred = true
572
- let value = e.target.value
573
- let evaluatedInput = this.onEvaluateCode(e)
574
- this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
575
- if ((evaluatedInput && value.length) || this.minNumber !== null) {
576
- this.textInput = numberToString({
577
- value:
578
- evaluatedInput && value.length
579
- ? evaluatedInput
580
- : this.defaultNumber
581
- ? this.defaultNumber
582
- : this.minNumber,
583
- numberPrecision: this.numberPrecision,
584
- minDecimals: this.minDecimals
585
- })
586
- }
587
- let adjustedMinValue =
588
- evaluatedInput && evaluatedInput.length
589
- ? evaluatedInput
590
- : this.defaultNumber
591
- ? this.defaultNumber
592
- : this.minNumber || this.minNumber === 0
593
- ? this.minNumber
594
- : ''
595
- this.$emit('input-blur', adjustedMinValue)
596
- },
597
- focusInput() {
598
- if (this.disabled) {
599
- return
600
- }
601
- this.isFocused = true
602
- this.$nextTick(() => {
603
- this.$refs.inputField1.$el.select()
604
- })
605
- this.$emit('input-focus')
606
- },
607
- blurInput() {
608
- if (this.disabled) {
609
- return
610
- }
611
- this.isFocused = false
612
- this.$nextTick(() => {
613
- this.$refs.inputField1.$el.blur()
614
- })
615
- },
616
- formatWithCurrency(value) {
617
- let adjustedMinValue =
618
- value || value === 0
619
- ? value
620
- : this.defaultNumber
621
- ? this.defaultNumber
622
- : this.minNumber || this.minNumber === 0
623
- ? this.minNumber
624
- : ''
625
- if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
626
- let input = this.numberToStringEnabled
627
- ? numberToString({
628
- value: adjustedMinValue,
629
- numberPrecision: this.numberPrecision,
630
- minDecimals: this.minDecimals
631
- })
632
- : adjustedMinValue
633
- let unit = this.showLinearUnitName ? '' : this.unitName
634
- //return input + ' ' + unit
635
- return input + ' ' + unit
636
- } else if (!adjustedMinValue && adjustedMinValue !== 0) {
637
- return ''
638
- } else {
639
- return this.numberToStringEnabled
640
- ? numberToString({
641
- value: adjustedMinValue,
642
- numberPrecision: this.numberPrecision,
643
- minDecimals: this.minDecimals
644
- })
645
- : adjustedMinValue
646
- }
647
- },
648
- initInteraction(e) {
649
- window.addEventListener('mousemove', this.interact, false)
650
- window.addEventListener('mouseup', this.stopInteract, false)
651
- e.preventDefault()
652
- this.focusInput()
653
- },
654
- interact(e) {
655
- e.preventDefault()
656
- let value = parseFloat(this.value || 0)
657
- value += parseFloat(this.interactionStep) * parseInt(e.movementX)
658
- this.$emit('on-input-drag', value)
659
-
660
- this.textInput = numberToString({
661
- value: value && value.length ? value : this.minNumber,
662
- numberPrecision: this.numberPrecision,
663
- minDecimals: this.minDecimals
664
- })
665
- //this.value=value
666
- },
667
- stopInteract(e) {
668
- e.preventDefault()
669
- window.removeEventListener('mousemove', this.interact, false)
670
- window.removeEventListener('mouseup', this.stopInteract, false)
671
- this.blurInput()
672
- }
673
- },
674
- created() {
675
- if (this.value) {
676
- this.textInput = numberToString({
677
- value: this.value,
678
- numberPrecision: this.numberPrecision,
679
- minDecimals: this.minDecimals
680
- })
681
- } else if (this.defaultNumber !== null) {
682
- this.textInput = numberToString({
683
- value: this.defaultNumber,
684
- numberPrecision: this.numberPrecision,
685
- minDecimals: this.minDecimals
686
- })
687
- } else if (this.minNumber !== null) {
688
- this.textInput = numberToString({
689
- value: this.minNumber,
690
- numberPrecision: this.numberPrecision,
691
- minDecimals: this.minDecimals
692
- })
693
- }
694
- },
695
- mounted() {
696
- if (this.focus) {
697
- this.focusInput()
698
- }
699
- },
700
- watch: {
701
- focus(value) {
702
- if (value) {
703
- this.focusInput()
704
- }
705
- },
706
- clearInput: function (value) {
707
- if (value) {
708
- // If the value is typed, then we should clear the textInput on Continue
709
- this.textInput = ''
710
- }
711
- }
712
- }
713
- }
714
- </script>
1
+ <template>
2
+ <container :inputWidth="inputWidth" :alignItems="alignItems">
3
+ <label-slot-wrapper
4
+ v-if="hasLabelSlot"
5
+ :isInteractive="isInteractive"
6
+ :alignItems="alignItems"
7
+ :noBorder="noBorder"
8
+ :isError="isError"
9
+ :borderColor="borderColor"
10
+ @mousedown="initInteraction"
11
+ >
12
+ <slot name="label"></slot>
13
+ </label-slot-wrapper>
14
+
15
+ <label-wrapper v-if="labelText">
16
+ <label-text :labelFontColor="labelFontColor" :data-id="labelDataId">
17
+ {{ labelText }}
18
+ </label-text>
19
+
20
+ <info-text
21
+ v-if="labelInfoText"
22
+ :text="labelInfoText"
23
+ :alignArrow="labelInfoAlign"
24
+ />
25
+ </label-wrapper>
26
+ <input-wrapper>
27
+ <input-container
28
+ v-bind="$attrs"
29
+ ref="inputField1"
30
+ :hasUnit="unitName && !!unitName.length"
31
+ :placeholder="displayedPlaceholder"
32
+ :isError="isError"
33
+ :inputHeight="inputHeight"
34
+ :minWidth="minWidth"
35
+ :isInteractive="isInteractive"
36
+ :value="formatWithCurrency(value)"
37
+ @blur="onInputBlur($event)"
38
+ @focus="focusInput()"
39
+ @keyup.enter="onEnterPress"
40
+ @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
+ v-on="$listeners"
51
+ :hasSlot="hasSlot"
52
+ :hasLabelSlot="hasLabelSlot"
53
+ :slotSize="slotSize"
54
+ :showLinearUnitName="showLinearUnitName"
55
+ :data-id="inputDataId"
56
+ />
57
+ <slot-container v-if="hasSlot" :slotSize="slotSize" :isError="isError">
58
+ <slot></slot>
59
+ </slot-container>
60
+
61
+ <unit-container
62
+ v-if="unitName && showLinearUnitName && !hasSlot"
63
+ :hasLength="!!textInput.length"
64
+ :isError="isError"
65
+ >{{ unitName }}</unit-container
66
+ >
67
+ <icon-wrapper v-if="isError && !showLinearUnitName" size="16px">
68
+ <icon name="warning" size="16px" cursor="default" />
69
+ </icon-wrapper>
70
+ </input-wrapper>
71
+ <error-message v-if="isError">{{ errorMessage }}</error-message>
72
+ </container>
73
+ </template>
74
+
75
+ <script>
76
+ // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
77
+ //This component should be used for questions with input fields only
78
+ //How to use:
79
+ // <input-number
80
+ // placeholder="Enter distance"
81
+ // :isError="false" //default is false
82
+ // inputWidth="150px" //by default, this is 100%
83
+ // minWidth="100px"
84
+ // :numberPrecision="3"
85
+ // minDecimals="2"
86
+ // unitName="pc"
87
+ // :value="inputValue" //required -- String
88
+ // @input-change="onInputChange($event)" //required
89
+ // @on-enter-click="onInputSubmit()"
90
+ // :errorMessage="Enter a number between 1 and 10"
91
+ // :disabled="false"
92
+ // :noBorder="true"
93
+ // textAlign="left" // "left, right, center"
94
+ // :showLinearUnitName="true"
95
+ // fontSize="13px"
96
+ // labelText="Number of Modules"
97
+ // labelInfoText="Here is some information for you..."
98
+ // labelInfoAlign="left"
99
+ // :minNumber="0"
100
+ // fontColor="blue"
101
+ // >
102
+ //<template name=label><img>....</template>
103
+ //</inputNumber>
104
+ import styled from 'vue-styled-components'
105
+ import {
106
+ stringToNumber,
107
+ numberToString
108
+ } from '../../../helpers/numberConverter'
109
+ import InfoText from '../../infoText'
110
+ import ErrorMessage from '../../errorMessage'
111
+ import warningIcon from '../../../assets/icons/error_icon.png'
112
+ import Icon from '../../icon'
113
+
114
+ const inputProps = {
115
+ isError: Boolean,
116
+ hasUnit: Boolean,
117
+ inputWidth: String,
118
+ minWidth: String,
119
+ isDisabled: Boolean,
120
+ noBorder: Boolean,
121
+ textAlign: String,
122
+ fontSize: String,
123
+ fontColor: String,
124
+ backgroundColor: String,
125
+ hasSlot: Boolean,
126
+ hasLabelSlot: Boolean,
127
+ slotSize: String,
128
+ inputHeight: String,
129
+ isInteractive: Boolean,
130
+ alignItems: String,
131
+ labelFontColor: String,
132
+ borderColor: String,
133
+ showLinearUnitName: Boolean
134
+ }
135
+
136
+ const Container = styled('div', inputProps)`
137
+ width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
138
+ position: relative;
139
+ display: grid;
140
+ grid-template-columns: ${(props) =>
141
+ props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
142
+ `
143
+
144
+ const InputContainer = styled('input', inputProps)`
145
+ border: ${(props) =>
146
+ props.isError
147
+ ? '1px solid ' + props.theme.colors.red
148
+ : props.noBorder
149
+ ? 'none'
150
+ : props.borderColor
151
+ ? props.theme.colors[props.borderColor]
152
+ ? '1px solid ' + props.theme.colors[props.borderColor]
153
+ : '1px solid ' + props.borderColor
154
+ : '1px solid ' + props.theme.colors.grey4};
155
+ height: ${(props) => props.inputHeight};
156
+ max-height: ${(props) => props.inputHeight};
157
+ padding: 0 10px;
158
+ padding-right: ${({ slotSize, isError, showLinearUnitName }) =>
159
+ slotSize
160
+ ? isError && !showLinearUnitName
161
+ ? 'calc(' + slotSize + ' + 24px)'
162
+ : 'calc(' + slotSize + ' + 10px)'
163
+ : isError && !showLinearUnitName
164
+ ? '24px'
165
+ : '5px'};
166
+ border-radius: ${(props) =>
167
+ props.isInteractive && props.alignItems != 'vertical'
168
+ ? '0 4px 4px 0'
169
+ : '4px'};
170
+ text-align: ${(props) => props.textAlign};
171
+ cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
172
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
173
+ color: ${(props) =>
174
+ props.isError
175
+ ? props.theme.colors.grey6
176
+ : props.isDisabled
177
+ ? props.theme.colors.grey2
178
+ : props.fontColor
179
+ ? props.fontColor + ' !important'
180
+ : props.theme.colors.black};
181
+ background-color: ${(props) =>
182
+ props.backgroundColor
183
+ ? props.backgroundColor + ' !important'
184
+ : props.theme.colors.white};
185
+ width: ${(props) =>
186
+ props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
187
+ min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
188
+ background-color: ${(props) =>
189
+ props.isDisabled ? props.theme.colors.grey5 : '#fff'};
190
+ box-sizing: border-box;
191
+
192
+ &::placeholder {
193
+ color: ${(props) => props.theme.colors.grey2};
194
+ }
195
+
196
+ &:focus {
197
+ outline: none;
198
+ }
199
+ `
200
+
201
+ const InputWrapper = styled.span`
202
+ position: relative;
203
+ `
204
+
205
+ const UnitContainer = styled('span', inputProps)`
206
+ border-left: 1px solid
207
+ ${(props) =>
208
+ props.isError
209
+ ? props.theme.colors.red
210
+ : props.hasLength
211
+ ? props.theme.colors.black
212
+ : props.theme.colors.mediumGray};
213
+ position: absolute;
214
+ right: 10px;
215
+ top: 10px;
216
+ padding-left: 10px;
217
+ text-align: right;
218
+ color: ${(props) =>
219
+ props.isError
220
+ ? props.theme.colors.red
221
+ : props.hasLength
222
+ ? props.theme.colors.black
223
+ : props.theme.colors.mediumGray};
224
+ `
225
+
226
+ const SlotContainer = styled('span', inputProps)`
227
+ text-align: right;
228
+ border-left: 1px solid
229
+ ${(props) =>
230
+ props.isError
231
+ ? props.theme.colors.red
232
+ : props.hasLength
233
+ ? props.theme.colors.black
234
+ : props.theme.colors.mediumGray};
235
+ position: absolute;
236
+ width: ${(props) =>
237
+ props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
238
+ right: 10px;
239
+ top: 10px;
240
+ padding-left: 10px;
241
+ color: ${(props) =>
242
+ props.isError
243
+ ? props.theme.colors.red
244
+ : props.hasLength
245
+ ? props.theme.colors.black
246
+ : props.theme.colors.mediumGray};
247
+ `
248
+
249
+ const LabelWrapper = styled('div', inputProps)`
250
+ display: flex;
251
+ align-items: center;
252
+ gap: 10px;
253
+ margin-bottom: 8px;
254
+ cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
255
+ `
256
+ const LabelSlotWrapper = styled('div', inputProps)`
257
+ display: flex;
258
+ gap: 10px;
259
+ align-items: center;
260
+ cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
261
+ border: ${(props) =>
262
+ props.alignItems == 'vertical'
263
+ ? 'none'
264
+ : props.isError
265
+ ? '1px solid ' + props.theme.colors.red
266
+ : props.noBorder
267
+ ? 'none'
268
+ : props.borderColor
269
+ ? props.theme.colors[props.borderColor]
270
+ ? '1px solid ' + props.theme.colors[props.borderColor]
271
+ : '1px solid ' + props.borderColor
272
+ : '1px solid ' + props.theme.colors.grey4};
273
+ border-radius: 4px 0 0 4px;
274
+ border-right: none;
275
+ `
276
+
277
+ const LabelText = styled('div', inputProps)`
278
+ font-size: 13px;
279
+ color: ${(props) =>
280
+ props.theme.colors[props.labelFontColor]
281
+ ? props.theme.colors[props.labelFontColor]
282
+ : props.labelFontColor};
283
+ font-weight: 700;
284
+ `
285
+
286
+ const IconAttrs = { size: String }
287
+ const IconWrapper = styled('div', IconAttrs)`
288
+ position: absolute;
289
+ top: 0;
290
+ bottom: 0;
291
+ margin: auto;
292
+ right: 5px;
293
+ height: ${(props) => (props.size ? props.size : 'auto')};
294
+ `
295
+
296
+ export default {
297
+ name: 'input-number',
298
+ components: {
299
+ Container,
300
+ InputContainer,
301
+ InputWrapper,
302
+ UnitContainer,
303
+ ErrorMessage,
304
+ LabelWrapper,
305
+ LabelSlotWrapper,
306
+ LabelText,
307
+ InfoText,
308
+ Icon,
309
+ SlotContainer,
310
+ IconWrapper
311
+ },
312
+ inheritAttrs: false,
313
+ data() {
314
+ return {
315
+ textInput: '',
316
+ isFocused: false,
317
+ warningIcon: warningIcon,
318
+ isBlurred: false
319
+ }
320
+ },
321
+ props: {
322
+ placeholder: {
323
+ required: false,
324
+ default: ''
325
+ },
326
+ isError: {
327
+ required: false,
328
+ default: false
329
+ },
330
+ inputWidth: {
331
+ required: false,
332
+ default: null
333
+ },
334
+ minWidth: {
335
+ required: false,
336
+ default: null
337
+ },
338
+ inputHeight: {
339
+ required: false,
340
+ default: '40px'
341
+ },
342
+ value: {
343
+ required: true,
344
+ default: null
345
+ },
346
+ clearInput: {
347
+ required: false,
348
+ default: false
349
+ },
350
+ alignItems: {
351
+ required: false,
352
+ default: 'vertical'
353
+ },
354
+ errorMessage: {
355
+ required: false,
356
+ default: 'Please insert a correct number'
357
+ },
358
+ numberPrecision: {
359
+ required: false,
360
+ default: 0
361
+ },
362
+ minDecimals: {
363
+ required: false,
364
+ default: 0
365
+ },
366
+ unitName: {
367
+ required: false,
368
+ default: ''
369
+ },
370
+ showLinearUnitName: {
371
+ required: false,
372
+ default: false
373
+ },
374
+ disabled: {
375
+ required: false,
376
+ default: false
377
+ },
378
+ noBorder: {
379
+ required: false,
380
+ default: false
381
+ },
382
+ borderColor: {
383
+ required: false
384
+ },
385
+ textAlign: {
386
+ required: false,
387
+ default: 'left'
388
+ },
389
+ fontSize: {
390
+ required: false,
391
+ default: '13px'
392
+ },
393
+ isInteractive: {
394
+ required: false,
395
+ default: false
396
+ },
397
+ interactionStep: {
398
+ required: false,
399
+ default: 1
400
+ },
401
+ labelText: {
402
+ required: false,
403
+ default: null
404
+ },
405
+ labelInfoText: {
406
+ required: false,
407
+ default: null
408
+ },
409
+ labelInfoAlign: {
410
+ required: false,
411
+ default: 'left'
412
+ },
413
+ defaultNumber: {
414
+ required: false,
415
+ default: null
416
+ },
417
+ minNumber: {
418
+ required: false,
419
+ default: null
420
+ },
421
+ fontColor: {
422
+ required: false,
423
+ default: null
424
+ },
425
+ backgroundColor: {
426
+ required: false,
427
+ default: null
428
+ },
429
+ numberToStringEnabled: {
430
+ required: false,
431
+ default: true
432
+ },
433
+ allowNegative: {
434
+ required: false,
435
+ default: true
436
+ },
437
+ slotSize: {
438
+ required: false
439
+ },
440
+ labelFontColor: {
441
+ required: false,
442
+ default: 'eturnityGrey'
443
+ },
444
+ focus: {
445
+ required: false,
446
+ default: false
447
+ },
448
+ labelDataId: {
449
+ required: false,
450
+ default: ''
451
+ },
452
+ inputDataId: {
453
+ required: false,
454
+ default: ''
455
+ }
456
+ },
457
+ computed: {
458
+ displayedPlaceholder() {
459
+ if (this.placeholder) return this.placeholder
460
+ if (this.defaultNumber)
461
+ return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
462
+ return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
463
+ },
464
+ hasSlot() {
465
+ return !!this.$slots.default
466
+ },
467
+ hasLabelSlot() {
468
+ return !!this.$slots.label
469
+ }
470
+ },
471
+ methods: {
472
+ onEnterPress(){
473
+ this.$emit('on-enter-click')
474
+ this.$refs.inputField1.$el.blur()
475
+ },
476
+ onChangeHandler(event) {
477
+ if (isNaN(event) || event === '') {
478
+ event = this.defaultNumber
479
+ ? this.defaultNumber
480
+ : this.minNumber || this.minNumber === 0
481
+ ? this.minNumber
482
+ : event
483
+ }
484
+ if (!this.allowNegative) {
485
+ event = Math.abs(event)
486
+ }
487
+ event = parseFloat(event)
488
+ // Need to return an integer rather than a string
489
+ this.$emit('input-change', event)
490
+ },
491
+ onEvaluateCode(val) {
492
+ // function to perform math on the code
493
+ // filter the string in case of any malicious content
494
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
495
+ filtered = filtered.split(/([-+*/()])/)
496
+ let formatted = filtered.map((item) => {
497
+ if (
498
+ item === '+' ||
499
+ item === '-' ||
500
+ item === '*' ||
501
+ item === '/' ||
502
+ item === '(' ||
503
+ item === ')' ||
504
+ item === ''
505
+ ) {
506
+ return item
507
+ } else {
508
+ let num = stringToNumber({
509
+ value: item,
510
+ numberPrecision: false,
511
+ minDecimals: this.minDecimals
512
+ })
513
+ return num
514
+ }
515
+ })
516
+ let evaluated
517
+ formatted = this.removeStringItemsAfterLastNumber(formatted)
518
+ evaluated = eval(formatted.join(' '))
519
+ if (typeof evaluated === 'string') {
520
+ evaluated = stringToNumber({
521
+ value: evaluated,
522
+ numberPrecision: this.numberPrecision,
523
+ minDecimals: this.minDecimals
524
+ })
525
+ } else if (typeof evaluated === 'number') {
526
+ evaluated = evaluated.toFixed(this.numberPrecision)
527
+ }
528
+ return evaluated
529
+ },
530
+ removeStringItemsAfterLastNumber(array) {
531
+ // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
532
+ let lastNumberIndex = -1
533
+ // Find the index of the last number in the array
534
+ for (let i = array.length - 1; i >= 0; i--) {
535
+ if (typeof array[i] === 'number') {
536
+ lastNumberIndex = i
537
+ break
538
+ }
539
+ }
540
+ // if there are no numbers, return an empty array
541
+ if (lastNumberIndex === -1) {
542
+ return []
543
+ }
544
+ // Remove non-numeric items after the last number
545
+ if (lastNumberIndex !== -1) {
546
+ const newArray = array.slice(0, lastNumberIndex + 1)
547
+ return newArray
548
+ }
549
+ return array
550
+ },
551
+ onInput(value) {
552
+ // if(!this.isFocused){
553
+ // return
554
+ // }
555
+ if (this.isBlurred) {
556
+ this.isBlurred = false
557
+ return
558
+ }
559
+ if (value === '') {
560
+ this.$emit('on-input', '')
561
+ }
562
+ let evaluatedVal
563
+ try {
564
+ evaluatedVal = this.onEvaluateCode(value)
565
+ } finally {
566
+ if (evaluatedVal) {
567
+ this.$emit('on-input', evaluatedVal)
568
+ }
569
+ }
570
+ },
571
+ onInputBlur(e) {
572
+ this.isFocused = false
573
+ // setting isBlurred so we don't trigger onInput as well
574
+ this.isBlurred = true
575
+ let value = e.target.value
576
+ let evaluatedInput = this.onEvaluateCode(value)
577
+ this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
578
+ if ((evaluatedInput && value.length) || this.minNumber !== null) {
579
+ this.textInput = numberToString({
580
+ value:
581
+ evaluatedInput && value.length
582
+ ? evaluatedInput
583
+ : this.defaultNumber
584
+ ? this.defaultNumber
585
+ : this.minNumber,
586
+ numberPrecision: this.numberPrecision,
587
+ minDecimals: this.minDecimals
588
+ })
589
+ }
590
+ let adjustedMinValue =
591
+ evaluatedInput && evaluatedInput.length
592
+ ? evaluatedInput
593
+ : this.defaultNumber
594
+ ? this.defaultNumber
595
+ : this.minNumber || this.minNumber === 0
596
+ ? this.minNumber
597
+ : ''
598
+ this.$emit('input-blur', adjustedMinValue)
599
+ },
600
+ focusInput() {
601
+ if (this.disabled) {
602
+ return
603
+ }
604
+ this.isFocused = true
605
+ this.$nextTick(() => {
606
+ this.$refs.inputField1.$el.select()
607
+ })
608
+ this.$emit('input-focus')
609
+ },
610
+ blurInput() {
611
+ if (this.disabled) {
612
+ return
613
+ }
614
+ this.isFocused = false
615
+ this.$nextTick(() => {
616
+ this.$refs.inputField1.$el.blur()
617
+ })
618
+ },
619
+ formatWithCurrency(value) {
620
+ let adjustedMinValue =
621
+ value || value === 0
622
+ ? value
623
+ : this.defaultNumber
624
+ ? this.defaultNumber
625
+ : this.minNumber || this.minNumber === 0
626
+ ? this.minNumber
627
+ : ''
628
+ if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
629
+ let input = this.numberToStringEnabled
630
+ ? numberToString({
631
+ value: adjustedMinValue,
632
+ numberPrecision: this.numberPrecision,
633
+ minDecimals: this.minDecimals
634
+ })
635
+ : adjustedMinValue
636
+ let unit = this.showLinearUnitName ? '' : this.unitName
637
+ //return input + ' ' + unit
638
+ return input + ' ' + unit
639
+ } else if (!adjustedMinValue && adjustedMinValue !== 0) {
640
+ return ''
641
+ } else {
642
+ return this.numberToStringEnabled
643
+ ? numberToString({
644
+ value: adjustedMinValue,
645
+ numberPrecision: this.numberPrecision,
646
+ minDecimals: this.minDecimals
647
+ })
648
+ : adjustedMinValue
649
+ }
650
+ },
651
+ initInteraction(e) {
652
+ window.addEventListener('mousemove', this.interact, false)
653
+ window.addEventListener('mouseup', this.stopInteract, false)
654
+ e.preventDefault()
655
+ this.focusInput()
656
+ },
657
+ interact(e) {
658
+ e.preventDefault()
659
+ let value = parseFloat(this.value || 0)
660
+ value += parseFloat(this.interactionStep) * parseInt(e.movementX)
661
+ this.$emit('on-input-drag', value)
662
+
663
+ this.textInput = numberToString({
664
+ value: value && value.length ? value : this.minNumber,
665
+ numberPrecision: this.numberPrecision,
666
+ minDecimals: this.minDecimals
667
+ })
668
+ //this.value=value
669
+ },
670
+ stopInteract(e) {
671
+ e.preventDefault()
672
+ window.removeEventListener('mousemove', this.interact, false)
673
+ window.removeEventListener('mouseup', this.stopInteract, false)
674
+ this.blurInput()
675
+ }
676
+ },
677
+ created() {
678
+ if (this.value) {
679
+ this.textInput = numberToString({
680
+ value: this.value,
681
+ numberPrecision: this.numberPrecision,
682
+ minDecimals: this.minDecimals
683
+ })
684
+ } else if (this.defaultNumber !== null) {
685
+ this.textInput = numberToString({
686
+ value: this.defaultNumber,
687
+ numberPrecision: this.numberPrecision,
688
+ minDecimals: this.minDecimals
689
+ })
690
+ } else if (this.minNumber !== null) {
691
+ this.textInput = numberToString({
692
+ value: this.minNumber,
693
+ numberPrecision: this.numberPrecision,
694
+ minDecimals: this.minDecimals
695
+ })
696
+ }
697
+ },
698
+ mounted() {
699
+ if (this.focus) {
700
+ this.focusInput()
701
+ }
702
+ },
703
+ watch: {
704
+ focus(value) {
705
+ if (value) {
706
+ this.focusInput()
707
+ }
708
+ },
709
+ clearInput: function (value) {
710
+ if (value) {
711
+ // If the value is typed, then we should clear the textInput on Continue
712
+ this.textInput = ''
713
+ }
714
+ }
715
+ }
716
+ }
717
+ </script>