@eturnity/eturnity_reusable_components 7.48.1-EPDM-12680.24 → 7.48.1-EPDM-13082.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/README.md +29 -29
  2. package/package.json +85 -84
  3. package/src/App.vue +30 -30
  4. package/src/Test.vue +128 -128
  5. package/src/assets/icons/arrow_down.svg +3 -3
  6. package/src/assets/icons/arrow_up_red.svg +3 -3
  7. package/src/assets/icons/black_spinner.svg +35 -35
  8. package/src/assets/icons/delete_icon.svg +11 -11
  9. package/src/assets/icons/delete_icon_gray.svg +11 -11
  10. package/src/assets/icons/drag_icon.svg +8 -8
  11. package/src/assets/icons/external_icon.svg +6 -6
  12. package/src/assets/icons/language_icon.svg +6 -6
  13. package/src/assets/icons/pdf_icon.svg +6 -6
  14. package/src/assets/icons/plus_button.svg +4 -4
  15. package/src/assets/icons/search_icon_black.svg +3 -3
  16. package/src/assets/icons/subposition_icon.svg +3 -3
  17. package/src/assets/icons/subposition_marker.svg +3 -3
  18. package/src/assets/icons/warning_icon.svg +3 -3
  19. package/src/assets/svgIcons/2d_active.svg +7 -7
  20. package/src/assets/svgIcons/2d_inactive.svg +8 -8
  21. package/src/assets/svgIcons/3d_active.svg +7 -7
  22. package/src/assets/svgIcons/3d_inactive.svg +8 -8
  23. package/src/assets/svgIcons/_readme.md +7 -7
  24. package/src/assets/svgIcons/accept.svg +5 -5
  25. package/src/assets/svgIcons/activate_panels_active.svg +22 -22
  26. package/src/assets/svgIcons/activate_panels_inactive.svg +20 -20
  27. package/src/assets/svgIcons/add_icon-1.svg +3 -3
  28. package/src/assets/svgIcons/add_icon.svg +4 -4
  29. package/src/assets/svgIcons/address_book.svg +3 -3
  30. package/src/assets/svgIcons/adjust_roof.svg +6 -6
  31. package/src/assets/svgIcons/after_sale_as_a_service.svg +6 -6
  32. package/src/assets/svgIcons/all_good.svg +3 -3
  33. package/src/assets/svgIcons/angle_active.svg +5 -5
  34. package/src/assets/svgIcons/angle_inactive.svg +4 -4
  35. package/src/assets/svgIcons/area_active.svg +11 -11
  36. package/src/assets/svgIcons/area_inactive.svg +26 -26
  37. package/src/assets/svgIcons/areas_tool.svg +14 -14
  38. package/src/assets/svgIcons/arrow_down.svg +3 -3
  39. package/src/assets/svgIcons/arrow_left.svg +4 -4
  40. package/src/assets/svgIcons/arrow_right.svg +4 -4
  41. package/src/assets/svgIcons/arrow_up.svg +3 -3
  42. package/src/assets/svgIcons/attachment.svg +3 -3
  43. package/src/assets/svgIcons/base_layer.svg +3 -3
  44. package/src/assets/svgIcons/battery.svg +3 -3
  45. package/src/assets/svgIcons/bell.svg +3 -3
  46. package/src/assets/svgIcons/bexio.svg +4 -4
  47. package/src/assets/svgIcons/bold.svg +3 -3
  48. package/src/assets/svgIcons/bom.svg +3 -3
  49. package/src/assets/svgIcons/bom_generation.svg +10 -10
  50. package/src/assets/svgIcons/bookmaker.svg +3 -3
  51. package/src/assets/svgIcons/bubble.svg +3 -3
  52. package/src/assets/svgIcons/bug.svg +5 -5
  53. package/src/assets/svgIcons/buildings.svg +55 -55
  54. package/src/assets/svgIcons/bullet_list.svg +8 -8
  55. package/src/assets/svgIcons/calendar.svg +7 -7
  56. package/src/assets/svgIcons/calendar_icon.svg +7 -7
  57. package/src/assets/svgIcons/call.svg +3 -3
  58. package/src/assets/svgIcons/camera.svg +3 -3
  59. package/src/assets/svgIcons/car.svg +3 -3
  60. package/src/assets/svgIcons/cart.svg +3 -3
  61. package/src/assets/svgIcons/charger_icon_white.svg +44 -44
  62. package/src/assets/svgIcons/checkbox.svg +3 -3
  63. package/src/assets/svgIcons/clear_formatting.svg +7 -7
  64. package/src/assets/svgIcons/clenergy.svg +4 -0
  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/clock_full.svg +3 -3
  69. package/src/assets/svgIcons/close_for_modals,_tool_tips.svg +4 -4
  70. package/src/assets/svgIcons/co_branding.svg +5 -5
  71. package/src/assets/svgIcons/collapse.svg +4 -4
  72. package/src/assets/svgIcons/collections.svg +3 -3
  73. package/src/assets/svgIcons/component_library.svg +7 -7
  74. package/src/assets/svgIcons/consumption_tariffs.svg +43 -43
  75. package/src/assets/svgIcons/context_menu-1.svg +6 -6
  76. package/src/assets/svgIcons/context_menu-2.svg +5 -5
  77. package/src/assets/svgIcons/context_menu.svg +5 -5
  78. package/src/assets/svgIcons/context_menu_tabs.svg +5 -5
  79. package/src/assets/svgIcons/cross.svg +4 -4
  80. package/src/assets/svgIcons/current_variant.svg +4 -4
  81. package/src/assets/svgIcons/dashboard.svg +3 -3
  82. package/src/assets/svgIcons/data_transfer.svg +3 -3
  83. package/src/assets/svgIcons/deadline.svg +4 -4
  84. package/src/assets/svgIcons/deal_flow.svg +5 -5
  85. package/src/assets/svgIcons/delete.svg +4 -4
  86. package/src/assets/svgIcons/delete_area_active.svg +16 -16
  87. package/src/assets/svgIcons/delete_area_inactive.svg +15 -15
  88. package/src/assets/svgIcons/direction_active-1.svg +12 -12
  89. package/src/assets/svgIcons/direction_active.svg +5 -5
  90. package/src/assets/svgIcons/direction_arrow.svg +4 -4
  91. package/src/assets/svgIcons/direction_inactive.svg +4 -4
  92. package/src/assets/svgIcons/dislike.svg +3 -3
  93. package/src/assets/svgIcons/distance_tool.svg +8 -8
  94. package/src/assets/svgIcons/distances_active.svg +9 -9
  95. package/src/assets/svgIcons/distances_inactive.svg +8 -8
  96. package/src/assets/svgIcons/distort_tool.svg +10 -10
  97. package/src/assets/svgIcons/distort_tool2.svg +16 -16
  98. package/src/assets/svgIcons/document.svg +3 -3
  99. package/src/assets/svgIcons/documents.svg +4 -4
  100. package/src/assets/svgIcons/downarrow.svg +3 -3
  101. package/src/assets/svgIcons/download.svg +4 -4
  102. package/src/assets/svgIcons/drag_icon.svg +8 -8
  103. package/src/assets/svgIcons/draggable_corner.svg +5 -5
  104. package/src/assets/svgIcons/draw_tool.svg +3 -3
  105. package/src/assets/svgIcons/duplicate-1.svg +8 -8
  106. package/src/assets/svgIcons/duplicate-2.svg +5 -5
  107. package/src/assets/svgIcons/duplicate.svg +4 -4
  108. package/src/assets/svgIcons/e-mobility_configurator.svg +6 -6
  109. package/src/assets/svgIcons/e_signature.svg +5 -5
  110. package/src/assets/svgIcons/edit_button.svg +3 -3
  111. package/src/assets/svgIcons/electricity_tariff.svg +3 -3
  112. package/src/assets/svgIcons/email.svg +3 -3
  113. package/src/assets/svgIcons/ems-1.svg +3 -3
  114. package/src/assets/svgIcons/ems.svg +3 -3
  115. package/src/assets/svgIcons/end_of_the_list.svg +5 -5
  116. package/src/assets/svgIcons/erase.svg +4 -4
  117. package/src/assets/svgIcons/external_icon.svg +5 -5
  118. package/src/assets/svgIcons/fav_icon.svg +4 -4
  119. package/src/assets/svgIcons/finance.svg +3 -3
  120. package/src/assets/svgIcons/financing_for_pv-1.svg +5 -5
  121. package/src/assets/svgIcons/financing_for_pv-2.svg +3 -3
  122. package/src/assets/svgIcons/financing_for_pv.svg +6 -6
  123. package/src/assets/svgIcons/finish-1.svg +4 -4
  124. package/src/assets/svgIcons/finish.svg +3 -3
  125. package/src/assets/svgIcons/flatten.svg +11 -11
  126. package/src/assets/svgIcons/flatten_roof.svg +20 -20
  127. package/src/assets/svgIcons/folder.svg +3 -3
  128. package/src/assets/svgIcons/free_technology.svg +5 -5
  129. package/src/assets/svgIcons/handle.svg +5 -5
  130. package/src/assets/svgIcons/heat_calc.svg +7 -7
  131. package/src/assets/svgIcons/height_equalize.svg +3 -3
  132. package/src/assets/svgIcons/height_snap.svg +3 -3
  133. package/src/assets/svgIcons/house.svg +3 -3
  134. package/src/assets/svgIcons/house_3d-1.svg +7 -7
  135. package/src/assets/svgIcons/house_3d.svg +7 -7
  136. package/src/assets/svgIcons/inclination.svg +2 -2
  137. package/src/assets/svgIcons/info.svg +3 -3
  138. package/src/assets/svgIcons/initial_situation.svg +3 -3
  139. package/src/assets/svgIcons/integrations.svg +3 -3
  140. package/src/assets/svgIcons/intro-tour-1.svg +3 -3
  141. package/src/assets/svgIcons/intro-tour.svg +3 -3
  142. package/src/assets/svgIcons/inverter-1.svg +5 -5
  143. package/src/assets/svgIcons/inverter.svg +3 -3
  144. package/src/assets/svgIcons/italic.svg +3 -3
  145. package/src/assets/svgIcons/key.svg +3 -3
  146. package/src/assets/svgIcons/lake.svg +29 -29
  147. package/src/assets/svgIcons/layers_close.svg +4 -4
  148. package/src/assets/svgIcons/layers_open.svg +4 -4
  149. package/src/assets/svgIcons/lead_marketplace.svg +6 -6
  150. package/src/assets/svgIcons/lead_provider.svg +4 -4
  151. package/src/assets/svgIcons/length_2d.svg +2 -2
  152. package/src/assets/svgIcons/length_3d.svg +4 -4
  153. package/src/assets/svgIcons/length_calculator.svg +2 -2
  154. package/src/assets/svgIcons/length_in_2d_active.svg +12 -12
  155. package/src/assets/svgIcons/length_in_2d_inctive.svg +13 -13
  156. package/src/assets/svgIcons/light_bulb.svg +3 -3
  157. package/src/assets/svgIcons/like.svg +3 -3
  158. package/src/assets/svgIcons/line_graph.svg +3 -3
  159. package/src/assets/svgIcons/local_subsidies.svg +18 -18
  160. package/src/assets/svgIcons/location.svg +3 -3
  161. package/src/assets/svgIcons/lock.svg +3 -3
  162. package/src/assets/svgIcons/logout.svg +3 -3
  163. package/src/assets/svgIcons/loop.svg +3 -3
  164. package/src/assets/svgIcons/low-vegetation.svg +37 -37
  165. package/src/assets/svgIcons/lunch.svg +4 -4
  166. package/src/assets/svgIcons/magic_tool.svg +6 -6
  167. package/src/assets/svgIcons/map_icon.svg +5 -5
  168. package/src/assets/svgIcons/map_settings.svg +3 -3
  169. package/src/assets/svgIcons/margin_tool.svg +4 -4
  170. package/src/assets/svgIcons/meeting.svg +6 -6
  171. package/src/assets/svgIcons/move_copy.svg +4 -4
  172. package/src/assets/svgIcons/new_area_inactive.svg +11 -11
  173. package/src/assets/svgIcons/next.svg +4 -4
  174. package/src/assets/svgIcons/normal-tg.svg +30 -30
  175. package/src/assets/svgIcons/normal-vegetation.svg +53 -53
  176. package/src/assets/svgIcons/not_equal_to.svg +3 -3
  177. package/src/assets/svgIcons/numbered_list.svg +6 -6
  178. package/src/assets/svgIcons/obstacle_tool.svg +8 -8
  179. package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -3
  180. package/src/assets/svgIcons/offset_tool.svg +8 -8
  181. package/src/assets/svgIcons/open-tg.svg +21 -21
  182. package/src/assets/svgIcons/outline_tool.svg +11 -11
  183. package/src/assets/svgIcons/pan_tool.svg +12 -12
  184. package/src/assets/svgIcons/panels_tool.svg +8 -8
  185. package/src/assets/svgIcons/pen_tool.svg +4 -4
  186. package/src/assets/svgIcons/picker_tool.svg +4 -4
  187. package/src/assets/svgIcons/picture.svg +3 -3
  188. package/src/assets/svgIcons/pin.svg +5 -5
  189. package/src/assets/svgIcons/presentation.svg +3 -3
  190. package/src/assets/svgIcons/previous.svg +4 -4
  191. package/src/assets/svgIcons/profile-1.svg +4 -4
  192. package/src/assets/svgIcons/profile.svg +4 -4
  193. package/src/assets/svgIcons/profitability.svg +3 -3
  194. package/src/assets/svgIcons/project_analysis.svg +4 -4
  195. package/src/assets/svgIcons/project_settings.svg +4 -4
  196. package/src/assets/svgIcons/protected-tg.svg +47 -47
  197. package/src/assets/svgIcons/pv.svg +3 -3
  198. package/src/assets/svgIcons/quotations.svg +6 -6
  199. package/src/assets/svgIcons/redo.svg +6 -6
  200. package/src/assets/svgIcons/resizer.svg +5 -5
  201. package/src/assets/svgIcons/roof_layer.svg +3 -3
  202. package/src/assets/svgIcons/rotate_tool.svg +3 -3
  203. package/src/assets/svgIcons/rotate_view.svg +5 -5
  204. package/src/assets/svgIcons/ruler_tool.svg +3 -3
  205. package/src/assets/svgIcons/run_simulation.svg +3 -3
  206. package/src/assets/svgIcons/save.svg +3 -3
  207. package/src/assets/svgIcons/scaling_tool.svg +8 -8
  208. package/src/assets/svgIcons/sea.svg +34 -34
  209. package/src/assets/svgIcons/search.svg +3 -3
  210. package/src/assets/svgIcons/security.svg +3 -3
  211. package/src/assets/svgIcons/settings.svg +3 -3
  212. package/src/assets/svgIcons/show_in_a_new_tab.svg +12 -12
  213. package/src/assets/svgIcons/smartphone.svg +4 -4
  214. package/src/assets/svgIcons/solar_calc.svg +13 -13
  215. package/src/assets/svgIcons/solarmarkt.svg +3 -0
  216. package/src/assets/svgIcons/sorting.svg +4 -4
  217. package/src/assets/svgIcons/split.svg +12 -12
  218. package/src/assets/svgIcons/start_of_the_list.svg +5 -5
  219. package/src/assets/svgIcons/strikethrough.svg +4 -4
  220. package/src/assets/svgIcons/subscriptions.svg +3 -3
  221. package/src/assets/svgIcons/subsidies-1.svg +5 -5
  222. package/src/assets/svgIcons/subsidies-2.svg +3 -3
  223. package/src/assets/svgIcons/subsidies.svg +3 -3
  224. package/src/assets/svgIcons/subtract_icon.svg +3 -3
  225. package/src/assets/svgIcons/suitcase.svg +3 -3
  226. package/src/assets/svgIcons/summer.svg +3 -3
  227. package/src/assets/svgIcons/template_icon_not_clickable.svg +6 -6
  228. package/src/assets/svgIcons/transfer.svg +4 -4
  229. package/src/assets/svgIcons/trim_tool.svg +4 -4
  230. package/src/assets/svgIcons/truck.svg +3 -3
  231. package/src/assets/svgIcons/underlined.svg +3 -3
  232. package/src/assets/svgIcons/undo.svg +6 -6
  233. package/src/assets/svgIcons/uparrow.svg +3 -3
  234. package/src/assets/svgIcons/update.svg +3 -3
  235. package/src/assets/svgIcons/upload_avatar-1.svg +12 -12
  236. package/src/assets/svgIcons/upload_avatar.svg +5 -5
  237. package/src/assets/svgIcons/upload_image.svg +8 -8
  238. package/src/assets/svgIcons/upload_image_tool.svg +7 -7
  239. package/src/assets/svgIcons/variants.svg +6 -6
  240. package/src/assets/svgIcons/vertical_tool.svg +3 -3
  241. package/src/assets/svgIcons/virtual_storage.svg +4 -4
  242. package/src/assets/svgIcons/warning.svg +4 -4
  243. package/src/assets/svgIcons/way.svg +5 -5
  244. package/src/assets/svgIcons/wifi.svg +3 -3
  245. package/src/assets/svgIcons/winter.svg +3 -3
  246. package/src/assets/svgIcons/workflow_template.svg +11 -11
  247. package/src/assets/tests/__mocks__/iconCache.js +1 -1
  248. package/src/assets/tests/__mocks__/svgMock.js +1 -1
  249. package/src/assets/tests/helpers.js +12 -12
  250. package/src/assets/theme.js +45 -44
  251. package/src/components/addNewButton/AddNewButton.stories.js +17 -17
  252. package/src/components/addNewButton/addNewButton.spec.js +23 -23
  253. package/src/components/addNewButton/index.vue +62 -62
  254. package/src/components/banner/actionBanner/ActionBanner.stories.js +45 -45
  255. package/src/components/banner/actionBanner/actionBanner.spec.js +76 -76
  256. package/src/components/banner/actionBanner/index.vue +86 -86
  257. package/src/components/banner/banner/Banner.stories.js +64 -64
  258. package/src/components/banner/banner/banner.spec.js +149 -149
  259. package/src/components/banner/banner/index.vue +205 -205
  260. package/src/components/banner/infoBanner/InfoBanner.spec.js +70 -70
  261. package/src/components/banner/infoBanner/InfoBanner.stories.js +42 -42
  262. package/src/components/banner/infoBanner/index.vue +97 -97
  263. package/src/components/buttons/buttonIcon/index.vue +145 -147
  264. package/src/components/buttons/closeButton/CloseButton.stories.js +25 -25
  265. package/src/components/buttons/closeButton/index.vue +62 -62
  266. package/src/components/buttons/mainButton/MainButton.stories.js +51 -51
  267. package/src/components/buttons/mainButton/index.vue +150 -164
  268. package/src/components/buttons/mainButton/mainButton.spec.js +35 -35
  269. package/src/components/card/Card.stories.js +79 -79
  270. package/src/components/card/card.spec.js +135 -135
  271. package/src/components/card/index.vue +116 -116
  272. package/src/components/collapsableInfoText/index.vue +127 -127
  273. package/src/components/deleteIcon/DeleteIcon.stories.js +29 -29
  274. package/src/components/deleteIcon/index.vue +78 -78
  275. package/src/components/draggableInputHandle/index.vue +46 -46
  276. package/src/components/dropdown/Dropdown.stories.js +53 -53
  277. package/src/components/dropdown/index.vue +138 -138
  278. package/src/components/errorMessage/index.vue +64 -64
  279. package/src/components/filter/filterSettings.vue +669 -669
  280. package/src/components/filter/index.vue +154 -154
  281. package/src/components/filter/parentDropdown.vue +91 -91
  282. package/src/components/icon/Icons.stories.js +41 -41
  283. package/src/components/icon/iconCache.mjs +23 -23
  284. package/src/components/icon/iconCollection.vue +82 -82
  285. package/src/components/icon/index.vue +140 -141
  286. package/src/components/iconWrapper/index.vue +179 -179
  287. package/src/components/infoCard/InfoCard.stories.js +170 -0
  288. package/src/components/infoCard/defaultProps.js +7 -0
  289. package/src/components/infoCard/index.vue +152 -67
  290. package/src/components/infoCard/infoCard.spec.js +64 -0
  291. package/src/components/infoText/index.vue +190 -379
  292. package/src/components/inputs/checkbox/Checkbox.stories.js +63 -63
  293. package/src/components/inputs/checkbox/checkbox.spec.js +109 -109
  294. package/src/components/inputs/checkbox/index.vue +225 -225
  295. package/src/components/inputs/inputNumber/InputNumber.stories.js +150 -150
  296. package/src/components/inputs/inputNumber/index.vue +789 -977
  297. package/src/components/inputs/inputNumberQuestion/index.vue +218 -218
  298. package/src/components/inputs/inputText/InputText.stories.js +70 -70
  299. package/src/components/inputs/inputText/index.vue +417 -438
  300. package/src/components/inputs/inputText/inputText.spec.js +588 -588
  301. package/src/components/inputs/radioButton/RadioButton.stories.js +77 -77
  302. package/src/components/inputs/radioButton/defaultProps.js +31 -33
  303. package/src/components/inputs/radioButton/index.vue +309 -330
  304. package/src/components/inputs/radioButton/radioButton.spec.js +269 -306
  305. package/src/components/inputs/searchInput/SearchInput.stories.js +66 -66
  306. package/src/components/inputs/searchInput/defaultProps.js +12 -12
  307. package/src/components/inputs/searchInput/index.vue +159 -159
  308. package/src/components/inputs/searchInput/searchInput.spec.js +64 -64
  309. package/src/components/inputs/select/index.vue +918 -958
  310. package/src/components/inputs/select/option/index.vue +156 -165
  311. package/src/components/inputs/select/select.stories.js +58 -58
  312. package/src/components/inputs/slider/index.vue +126 -126
  313. package/src/components/inputs/switchField/index.vue +254 -254
  314. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +127 -127
  315. package/src/components/inputs/textAreaInput/index.vue +198 -198
  316. package/src/components/inputs/toggle/Toggle.stories.js +77 -77
  317. package/src/components/inputs/toggle/index.vue +317 -317
  318. package/src/components/inputs/toggle/toggle.spec.js +102 -102
  319. package/src/components/label/index.vue +99 -99
  320. package/src/components/markerItem/index.vue +88 -95
  321. package/src/components/modals/actionModal/index.vue +64 -64
  322. package/src/components/modals/infoModal/index.vue +52 -52
  323. package/src/components/modals/modal/index.vue +196 -190
  324. package/src/components/modals/modal/modal.stories.js +31 -31
  325. package/src/components/navigationTabs/index.vue +114 -114
  326. package/src/components/pageSubtitle/PageSubtitle.stories.js +59 -59
  327. package/src/components/pageSubtitle/index.vue +78 -78
  328. package/src/components/pageSubtitle/pageSubtitle.spec.js +46 -46
  329. package/src/components/pageTitle/PageTitle.stories.js +95 -95
  330. package/src/components/pageTitle/index.vue +91 -91
  331. package/src/components/pageTitle/pageTitle.spec.js +46 -46
  332. package/src/components/pagination/index.vue +148 -148
  333. package/src/components/progressBar/index.vue +125 -125
  334. package/src/components/projectMarker/index.vue +300 -300
  335. package/src/components/rangeSlider/Slider.vue +573 -573
  336. package/src/components/rangeSlider/index.vue +517 -517
  337. package/src/components/rangeSlider/utils/dom.js +49 -49
  338. package/src/components/rangeSlider/utils/fns.js +26 -26
  339. package/src/components/roundTabs/index.vue +107 -107
  340. package/src/components/selectedOptions/index.vue +471 -471
  341. package/src/components/selectedOptions/selectedOptions.spec.js +176 -176
  342. package/src/components/selectedOptions/selectedOptions.stories.js +155 -155
  343. package/src/components/sideMenu/index.vue +279 -270
  344. package/src/components/spinner/Spinner.stories.js +34 -34
  345. package/src/components/spinner/index.vue +85 -96
  346. package/src/components/spinner/spinner.spec.js +69 -69
  347. package/src/components/tableDropdown/index.vue +638 -638
  348. package/src/components/tables/mainTable/exampleNested.vue +328 -328
  349. package/src/components/tables/mainTable/index.vue +510 -510
  350. package/src/components/tables/viewTable/index.vue +195 -195
  351. package/src/components/tabsHeader/index.vue +83 -83
  352. package/src/components/threeDots/index.vue +413 -413
  353. package/src/components/videoThumbnail/index.vue +103 -103
  354. package/src/components/videoThumbnail/videoThumbnail.stories.js +33 -33
  355. package/src/helpers/currencyMapping.js +28 -28
  356. package/src/helpers/numberConverter.js +103 -103
  357. package/src/helpers/translateLang.js +128 -128
  358. package/src/main.js +7 -7
  359. package/src/mixins/inputValidations.js +97 -97
  360. package/src/router/dynamicRoutes.js +23 -23
  361. package/src/stories/Button.stories.js +48 -48
  362. package/src/stories/Button.vue +52 -52
  363. package/src/stories/Configure.mdx +364 -364
  364. package/src/stories/Header.stories.js +41 -41
  365. package/src/stories/Header.vue +59 -59
  366. package/src/stories/Page.stories.js +30 -30
  367. package/src/stories/Page.vue +83 -83
  368. package/src/stories/button.css +30 -30
  369. package/src/stories/header.css +32 -32
  370. package/src/stories/page.css +69 -69
  371. package/src/utils/index.js +12 -12
  372. package/src/assets/gifs/spinner.gif +0 -0
  373. package/src/assets/svgIcons/collapse_all.svg +0 -4
  374. package/src/assets/svgIcons/export_document.svg +0 -3
  375. package/src/assets/svgIcons/hybrid.svg +0 -4
  376. package/src/assets/svgIcons/module.svg +0 -3
  377. package/src/assets/svgIcons/move_down.svg +0 -3
  378. package/src/assets/svgIcons/move_up.svg +0 -3
  379. package/src/assets/svgIcons/optimizer.svg +0 -6
  380. package/src/assets/svgIcons/string_design.svg +0 -5
  381. package/src/assets/svgIcons/string_directions.svg +0 -10
  382. package/src/components/infoText/placeholder.vue +0 -225
  383. package/src/components/spinnerGif/index.vue +0 -98
  384. package/src/components/stringDesign/DropdownMenu/index.vue +0 -898
@@ -1,977 +1,789 @@
1
- <template>
2
- <Container :align-items="alignItems" :input-width="inputWidth">
3
- <LabelSlotWrapper
4
- v-if="hasLabelSlot"
5
- :align-items="alignItems"
6
- :border-color="borderColor"
7
- :is-error="isError"
8
- :is-interactive="isInteractive"
9
- :no-border="noBorder"
10
- @mousedown="initInteraction"
11
- >
12
- <slot name="label"></slot>
13
- </LabelSlotWrapper>
14
-
15
- <LabelWrapper v-if="labelText">
16
- <LabelText
17
- :data-id="labelDataId"
18
- :label-font-color="labelFontColor"
19
- :label-font-weight="labelFontWeight"
20
- >
21
- {{ labelText }}
22
- </LabelText>
23
-
24
- <InfoText
25
- v-if="labelInfoText"
26
- :align-arrow="labelInfoAlign"
27
- :text="labelInfoText"
28
- />
29
- </LabelWrapper>
30
- <InputWrapper>
31
- <InputContainer
32
- v-bind="$attrs"
33
- ref="inputField1"
34
- :align-items="alignItems"
35
- :background-color="
36
- colorMode === 'transparent' ? 'transparent' : backgroundColor
37
- "
38
- :border-color="colorMode === 'transparent' ? 'white' : borderColor"
39
- :color-mode="colorMode"
40
- :data-id="inputDataId"
41
- :disabled="disabled"
42
- :font-color="colorMode === 'transparent' ? 'white' : fontColor"
43
- :font-size="fontSize"
44
- :has-label-slot="hasLabelSlot"
45
- :has-slot="hasSlot"
46
- :has-unit="unitName && !!unitName.length"
47
- :input-height="inputHeight"
48
- :is-disabled="disabled"
49
- :is-error="isError"
50
- :is-interactive="isInteractive"
51
- :min-width="minWidth"
52
- :no-border="noBorder"
53
- :placeholder="displayedPlaceholder"
54
- :show-arrow-controls="showArrowControls"
55
- :show-linear-unit-name="showLinearUnitName"
56
- :slot-size="slotSize"
57
- :text-align="textAlign"
58
- :value="formatWithCurrency(value)"
59
- @blur="onInputBlur($event)"
60
- @focus="focusInput()"
61
- @input="onInput($event)"
62
- @keydown.down="decrementValue"
63
- @keydown.up="incrementValue"
64
- @keyup.enter="onEnterPress"
65
- />
66
- <SlotContainer v-if="hasSlot" :is-error="isError" :slot-size="slotSize">
67
- <slot></slot>
68
- </SlotContainer>
69
-
70
- <UnitContainer
71
- v-if="unitName && showLinearUnitName && !hasSlot"
72
- :has-length="!!textInput.length"
73
- :is-error="isError"
74
- >{{ unitName }}</UnitContainer
75
- >
76
- <IconWrapper
77
- v-if="isError && !showLinearUnitName"
78
- :margin-right="showSelect ? selectWidth : 0"
79
- size="16px"
80
- >
81
- <Icon cursor="default" name="warning" size="16px" />
82
- </IconWrapper>
83
- <SelectWrapper v-if="showSelect">
84
- <Divider />
85
- <RCSelect
86
- :disabled="isSelectDisabled"
87
- :select-width="`${selectWidth}px`"
88
- :show-border="false"
89
- @input-change="$emit('select-change', $event)"
90
- >
91
- <template #selector>
92
- <SelectText>{{ getSelectValue }}</SelectText>
93
- </template>
94
- <template #dropdown>
95
- <RCOption
96
- v-for="item in selectOptions"
97
- :key="item.value"
98
- :value="item.value"
99
- >
100
- {{ item.label }}
101
- </RCOption>
102
- </template>
103
- </RCSelect>
104
- </SelectWrapper>
105
-
106
- <ArrowControls
107
- v-if="!disabled && showArrowControls"
108
- :color-mode="colorMode"
109
- >
110
- <ArrowButton @click="incrementValue">
111
- <Icon
112
- :color="colorMode === 'transparent' ? 'white' : undefined"
113
- name="arrow_up"
114
- size="8px"
115
- />
116
- </ArrowButton>
117
- <ArrowDivider :color-mode="colorMode" />
118
- <ArrowButton
119
- :is-disabled="textInput <= minNumber"
120
- @click="decrementValue"
121
- >
122
- <Icon
123
- :color="colorMode === 'transparent' ? 'white' : undefined"
124
- :disabled="textInput <= minNumber"
125
- name="arrow_down"
126
- size="8px"
127
- />
128
- </ArrowButton>
129
- </ArrowControls>
130
- </InputWrapper>
131
- <ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
132
- </Container>
133
- </template>
134
-
135
- <script>
136
- // import InputNumber from "@eturnity/eturnity_reusable_components/src/components/inputs/inputNumber"
137
- //This component should be used for questions with input fields only
138
- //How to use:
139
- // <input-number
140
- // placeholder="Enter distance"
141
- // :isError="false" //default is false
142
- // inputWidth="150px" //by default, this is 100%
143
- // minWidth="100px"
144
- // :numberPrecision="3"
145
- // minDecimals="2"
146
- // unitName="pc"
147
- // :value="inputValue" //required -- String
148
- // @input-change="onInputChange($event)" //required
149
- // @on-enter-click="onInputSubmit()"
150
- // :errorMessage="Enter a number between 1 and 10"
151
- // :disabled="false"
152
- // :noBorder="true"
153
- // textAlign="left" // "left, right, center"
154
- // :showLinearUnitName="true"
155
- // fontSize="13px"
156
- // labelText="Number of Modules"
157
- // labelInfoText="Here is some information for you..."
158
- // labelInfoAlign="left"
159
- // :minNumber="0"
160
- // fontColor="blue"
161
- // colorMode="transparent" // Makes background transparent, border white, and font white
162
- // >
163
- //<template name=label><img>....</template>
164
- //</inputNumber>
165
- import styled from 'vue3-styled-components'
166
- import {
167
- stringToNumber,
168
- numberToString,
169
- } from '../../../helpers/numberConverter'
170
- import InfoText from '../../infoText'
171
- import ErrorMessage from '../../errorMessage'
172
- import RCSelect from '../select'
173
- import RCOption from '../select/option'
174
- import warningIcon from '../../../assets/icons/error_icon.png'
175
- import Icon from '../../icon'
176
-
177
- const inputProps = {
178
- isError: Boolean,
179
- hasUnit: Boolean,
180
- inputWidth: String,
181
- minWidth: String,
182
- isDisabled: Boolean,
183
- noBorder: Boolean,
184
- textAlign: String,
185
- fontSize: String,
186
- fontColor: String,
187
- backgroundColor: String,
188
- hasSlot: Boolean,
189
- hasLabelSlot: Boolean,
190
- slotSize: String,
191
- inputHeight: String,
192
- isInteractive: Boolean,
193
- alignItems: String,
194
- labelFontColor: String,
195
- labelFontWeight: String,
196
- borderColor: String,
197
- showLinearUnitName: Boolean,
198
- colorMode: String,
199
- showArrowControls: Boolean,
200
- }
201
-
202
- const Container = styled('div', inputProps)`
203
- width: ${(props) => (props.inputWidth ? props.inputWidth : '100%')};
204
- position: relative;
205
- display: grid;
206
- grid-template-columns: ${(props) =>
207
- props.alignItems === 'vertical' ? '1fr' : 'auto 1fr'};
208
- `
209
-
210
- const InputContainer = styled('input', inputProps)`
211
- border: ${(props) =>
212
- props.isError
213
- ? '1px solid ' + props.theme.colors.red
214
- : props.noBorder
215
- ? 'none'
216
- : props.borderColor
217
- ? props.theme.colors[props.borderColor]
218
- ? '1px solid ' + props.theme.colors[props.borderColor]
219
- : '1px solid ' + props.borderColor
220
- : '1px solid ' + props.theme.colors.grey4};
221
- height: ${(props) => props.inputHeight};
222
- max-height: ${(props) => props.inputHeight};
223
- padding: ${({ colorMode }) =>
224
- colorMode === 'transparent' ? '10px 15px' : '0 10px'};
225
- padding-right: ${({
226
- slotSize,
227
- isError,
228
- showLinearUnitName,
229
- colorMode,
230
- showArrowControls,
231
- }) =>
232
- showArrowControls
233
- ? '40px'
234
- : colorMode === 'transparent'
235
- ? '0'
236
- : slotSize
237
- ? isError && !showLinearUnitName
238
- ? 'calc(' + slotSize + ' + 24px)'
239
- : 'calc(' + slotSize + ' + 10px)'
240
- : isError && !showLinearUnitName
241
- ? '24px'
242
- : '5px'};
243
- border-radius: ${(props) =>
244
- props.isInteractive && props.alignItems != 'vertical'
245
- ? '0 4px 4px 0'
246
- : '4px'};
247
- text-align: ${(props) => props.textAlign};
248
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'auto')};
249
- font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
250
- color: ${(props) =>
251
- props.isError
252
- ? props.theme.colors.grey6
253
- : props.isDisabled
254
- ? props.colorMode === 'transparent'
255
- ? props.theme.colors.white
256
- : props.theme.colors.grey2
257
- : props.fontColor
258
- ? props.fontColor + ' !important'
259
- : props.theme.colors.black};
260
- background-color: ${(props) =>
261
- props.isDisabled
262
- ? props.colorMode === 'transparent'
263
- ? 'transparent'
264
- : props.theme.colors.disabled
265
- : props.backgroundColor
266
- ? props.backgroundColor + ' !important'
267
- : props.theme.colors.white};
268
- width: ${(props) =>
269
- props.inputWidth && !props.hasLabelSlot ? props.inputWidth : '100%'};
270
- min-width: ${(props) => (props.minWidth ? props.minWidth : 'unset')};
271
- box-sizing: border-box;
272
- opacity: ${(props) =>
273
- props.isDisabled && props.colorMode === 'transparent' ? '0.4' : '1'};
274
-
275
- &::placeholder {
276
- color: ${(props) => props.theme.colors.grey2};
277
- }
278
-
279
- &:focus {
280
- outline: none;
281
- }
282
- `
283
-
284
- const ArrowControlsProps = {
285
- colorMode: String,
286
- }
287
- const ArrowControls = styled('div', ArrowControlsProps)`
288
- position: absolute;
289
- right: 0;
290
- top: 0;
291
- bottom: 0;
292
- display: grid;
293
- grid-template-rows: 1fr auto 1fr;
294
- align-items: center;
295
- justify-items: center;
296
- cursor: pointer;
297
- width: 30px;
298
- background-color: ${(props) =>
299
- props.colorMode === 'transparent'
300
- ? 'transparent'
301
- : props.theme.colors.white};
302
- border-left: 1px solid
303
- ${(props) =>
304
- props.colorMode === 'transparent'
305
- ? props.theme.colors.white
306
- : props.theme.colors.black};
307
- `
308
-
309
- const ArrowButtonProps = {
310
- isDisabled: Boolean,
311
- }
312
- const ArrowButton = styled('button', ArrowButtonProps)`
313
- background: transparent;
314
- opacity: ${(props) => (props.isDisabled ? '0.2' : '1')};
315
- cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
316
- display: flex;
317
- align-items: center;
318
- justify-content: center;
319
- padding: 0;
320
- width: 100%;
321
- height: 100%;
322
- `
323
-
324
- const ArrowDivider = styled('div', ArrowControlsProps)`
325
- width: 100%;
326
- height: 1px;
327
- background-color: ${(props) =>
328
- props.colorMode === 'transparent'
329
- ? props.theme.colors.white
330
- : props.theme.colors.black};
331
- `
332
-
333
- const InputWrapper = styled.span`
334
- position: relative;
335
- `
336
-
337
- const UnitContainer = styled('span', inputProps)`
338
- border-left: 1px solid
339
- ${(props) =>
340
- props.isError
341
- ? props.theme.colors.red
342
- : props.hasLength
343
- ? props.theme.colors.black
344
- : props.theme.colors.mediumGray};
345
- position: absolute;
346
- right: 10px;
347
- top: 10px;
348
- padding-left: 10px;
349
- text-align: right;
350
- color: ${(props) =>
351
- props.isError
352
- ? props.theme.colors.red
353
- : props.hasLength
354
- ? props.theme.colors.black
355
- : props.theme.colors.mediumGray};
356
- `
357
-
358
- const SlotContainer = styled('span', inputProps)`
359
- text-align: right;
360
- border-left: 1px solid
361
- ${(props) =>
362
- props.isError
363
- ? props.theme.colors.red
364
- : props.hasLength
365
- ? props.theme.colors.black
366
- : props.theme.colors.mediumGray};
367
- position: absolute;
368
- width: ${(props) =>
369
- props.slotSize ? 'calc(' + props.slotSize + ' - 10px)' : 'fit-content'};
370
- right: 10px;
371
- top: 10px;
372
- padding-left: 10px;
373
- color: ${(props) =>
374
- props.isError
375
- ? props.theme.colors.red
376
- : props.hasLength
377
- ? props.theme.colors.black
378
- : props.theme.colors.mediumGray};
379
- `
380
-
381
- const LabelWrapper = styled('div', inputProps)`
382
- display: flex;
383
- align-items: center;
384
- gap: 10px;
385
- margin-bottom: 8px;
386
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
387
- `
388
- const LabelSlotWrapper = styled('div', inputProps)`
389
- display: flex;
390
- gap: 10px;
391
- align-items: center;
392
- cursor: ${(props) => (props.isInteractive ? 'ew-resize' : 'auto')};
393
- border: ${(props) =>
394
- props.alignItems == 'vertical'
395
- ? 'none'
396
- : props.isError
397
- ? '1px solid ' + props.theme.colors.red
398
- : props.noBorder
399
- ? 'none'
400
- : props.borderColor
401
- ? props.theme.colors[props.borderColor]
402
- ? '1px solid ' + props.theme.colors[props.borderColor]
403
- : '1px solid ' + props.borderColor
404
- : '1px solid ' + props.theme.colors.grey4};
405
- border-radius: 4px 0 0 4px;
406
- border-right: none;
407
- `
408
-
409
- const LabelText = styled('div', inputProps)`
410
- font-size: 13px;
411
- color: ${(props) =>
412
- props.theme.colors[props.labelFontColor]
413
- ? props.theme.colors[props.labelFontColor]
414
- : props.labelFontColor};
415
- font-weight: ${(props) => props.labelFontWeight};
416
- `
417
-
418
- const IconAttrs = { size: String, marginRight: Number }
419
- const IconWrapper = styled('div', IconAttrs)`
420
- position: absolute;
421
- top: 0;
422
- bottom: 0;
423
- margin: auto;
424
- right: ${(props) => props.marginRight + 10}px;
425
- height: ${(props) => (props.size ? props.size : 'auto')};
426
- `
427
-
428
- const SelectText = styled.div`
429
- font-size: 13px;
430
- `
431
-
432
- const SelectWrapper = styled.div`
433
- position: absolute;
434
- top: 2px;
435
- right: 2px;
436
- display: flex;
437
- height: 100%;
438
- `
439
-
440
- const Divider = styled.div`
441
- margin-top: 6px;
442
- height: calc(100% - 16px);
443
- width: 1px;
444
- background-color: ${({ theme }) => theme.colors.grey4};
445
- `
446
-
447
- export default {
448
- name: 'InputNumber',
449
- components: {
450
- Container,
451
- InputContainer,
452
- InputWrapper,
453
- UnitContainer,
454
- ErrorMessage,
455
- LabelWrapper,
456
- LabelSlotWrapper,
457
- LabelText,
458
- InfoText,
459
- Icon,
460
- SlotContainer,
461
- IconWrapper,
462
- RCSelect,
463
- RCOption,
464
- SelectWrapper,
465
- SelectText,
466
- Divider,
467
- ArrowControls,
468
- ArrowButton,
469
- ArrowDivider,
470
- },
471
- inheritAttrs: false,
472
- props: {
473
- placeholder: {
474
- type: String,
475
- required: false,
476
- default: '',
477
- },
478
- isError: {
479
- type: Boolean,
480
- required: false,
481
- default: false,
482
- },
483
- inputWidth: {
484
- type: String,
485
- required: false,
486
- default: null,
487
- },
488
- minWidth: {
489
- type: String,
490
- required: false,
491
- default: null,
492
- },
493
- inputHeight: {
494
- type: String,
495
- required: false,
496
- default: '40px',
497
- },
498
- value: {
499
- type: [String, Number],
500
- required: true,
501
- default: null,
502
- },
503
- clearInput: {
504
- type: Boolean,
505
- required: false,
506
- default: false,
507
- },
508
- alignItems: {
509
- type: String,
510
- required: false,
511
- default: 'vertical',
512
- },
513
- errorMessage: {
514
- type: String,
515
- required: false,
516
- default: 'Please insert a correct number',
517
- },
518
- numberPrecision: {
519
- type: Number,
520
- required: false,
521
- default: 0,
522
- },
523
- minDecimals: {
524
- type: Number,
525
- required: false,
526
- default: 0,
527
- },
528
- unitName: {
529
- type: String,
530
- required: false,
531
- default: '',
532
- },
533
- showLinearUnitName: {
534
- type: Boolean,
535
- required: false,
536
- default: false,
537
- },
538
- disabled: {
539
- type: Boolean,
540
- required: false,
541
- default: false,
542
- },
543
- noBorder: {
544
- type: Boolean,
545
- required: false,
546
- default: false,
547
- },
548
- borderColor: {
549
- type: String,
550
- required: false,
551
- default: null,
552
- },
553
- textAlign: {
554
- type: String,
555
- required: false,
556
- default: 'left',
557
- },
558
- fontSize: {
559
- type: String,
560
- required: false,
561
- default: '13px',
562
- },
563
- isInteractive: {
564
- type: Boolean,
565
- required: false,
566
- default: false,
567
- },
568
- interactionStep: {
569
- type: Number,
570
- required: false,
571
- default: 1,
572
- },
573
- labelText: {
574
- type: String,
575
- required: false,
576
- default: null,
577
- },
578
- labelInfoText: {
579
- type: String,
580
- required: false,
581
- default: null,
582
- },
583
- labelInfoAlign: {
584
- type: String,
585
- required: false,
586
- default: 'left',
587
- },
588
- defaultNumber: {
589
- type: Number,
590
- required: false,
591
- default: null,
592
- },
593
- minNumber: {
594
- type: Number,
595
- required: false,
596
- default: null,
597
- },
598
- fontColor: {
599
- type: String,
600
- required: false,
601
- default: null,
602
- },
603
- backgroundColor: {
604
- type: String,
605
- required: false,
606
- default: null,
607
- },
608
- numberToStringEnabled: {
609
- type: Boolean,
610
- required: false,
611
- default: true,
612
- },
613
- allowNegative: {
614
- type: Boolean,
615
- required: false,
616
- default: true,
617
- },
618
- slotSize: {
619
- type: String,
620
- required: false,
621
- default: null,
622
- },
623
- labelFontColor: {
624
- type: String,
625
- required: false,
626
- default: 'eturnityGrey',
627
- },
628
- labelFontWeight: {
629
- type: String,
630
- required: false,
631
- default: '700',
632
- },
633
- focus: {
634
- type: Boolean,
635
- required: false,
636
- default: false,
637
- },
638
- labelDataId: {
639
- type: String,
640
- required: false,
641
- default: '',
642
- },
643
- inputDataId: {
644
- type: String,
645
- required: false,
646
- default: '',
647
- },
648
- showSelect: {
649
- type: Boolean,
650
- default: false,
651
- },
652
- selectWidth: {
653
- type: Number,
654
- default: 70,
655
- },
656
- selectOptions: {
657
- type: Array,
658
- default: () => [],
659
- },
660
- selectValue: {
661
- type: [String, Number],
662
- default: null,
663
- },
664
- isSelectDisabled: {
665
- type: Boolean,
666
- default: false,
667
- },
668
- colorMode: {
669
- type: String,
670
- default: '',
671
- },
672
- showArrowControls: {
673
- type: Boolean,
674
- default: false,
675
- },
676
- },
677
- data() {
678
- return {
679
- textInput: '',
680
- isFocused: false,
681
- warningIcon: warningIcon,
682
- }
683
- },
684
- computed: {
685
- displayedPlaceholder() {
686
- if (this.placeholder) return this.placeholder
687
- if (this.defaultNumber)
688
- return `${this.defaultNumber} ${this.unitName ? this.unitName : ''}`
689
- return `${this.minNumber || 0} ${this.unitName ? this.unitName : ''}`
690
- },
691
- hasSlot() {
692
- return !!this.$slots.default
693
- },
694
- hasLabelSlot() {
695
- return !!this.$slots.label
696
- },
697
- getSelectValue() {
698
- const item = this.selectOptions.find(
699
- ({ value }) => value === this.selectValue
700
- )
701
-
702
- return item ? item.label : '-'
703
- },
704
- },
705
- watch: {
706
- focus(value) {
707
- if (value) {
708
- this.focusInput()
709
- }
710
- },
711
- clearInput: function (value) {
712
- if (value) {
713
- // If the value is typed, then we should clear the textInput on Continue
714
- this.textInput = ''
715
- }
716
- },
717
- },
718
- created() {
719
- if (this.value) {
720
- this.textInput = numberToString({
721
- value: this.value,
722
- numberPrecision: this.numberPrecision,
723
- minDecimals: this.minDecimals,
724
- })
725
- } else if (this.defaultNumber !== null) {
726
- this.textInput = numberToString({
727
- value: this.defaultNumber,
728
- numberPrecision: this.numberPrecision,
729
- minDecimals: this.minDecimals,
730
- })
731
- } else if (this.minNumber !== null) {
732
- this.textInput = numberToString({
733
- value: this.minNumber,
734
- numberPrecision: this.numberPrecision,
735
- minDecimals: this.minDecimals,
736
- })
737
- }
738
- },
739
- mounted() {
740
- if (this.focus) {
741
- this.focusInput()
742
- }
743
- },
744
- methods: {
745
- incrementValue() {
746
- const currentValue = Math.max(
747
- parseFloat(this.textInput || 0),
748
- this.minNumber || 0
749
- )
750
- const newValue = currentValue + this.interactionStep
751
- this.textInput = numberToString({
752
- value: newValue,
753
- numberPrecision: this.numberPrecision,
754
- minDecimals: this.minDecimals,
755
- })
756
- this.$emit('on-input', newValue)
757
- this.$emit('input-change', newValue)
758
- },
759
- decrementValue() {
760
- const currentValue = Math.max(
761
- parseFloat(this.textInput || 0),
762
- this.minNumber || 0
763
- )
764
- const newValue = currentValue - this.interactionStep
765
- if (this.allowNegative || newValue >= 0) {
766
- this.textInput = numberToString({
767
- value: newValue,
768
- numberPrecision: this.numberPrecision,
769
- minDecimals: this.minDecimals,
770
- })
771
- this.$emit('on-input', newValue)
772
- this.$emit('input-change', newValue)
773
- }
774
- },
775
- onEnterPress() {
776
- this.$emit('on-enter-click')
777
- this.$refs.inputField1.$el.blur()
778
- },
779
- onChangeHandler(event) {
780
- if (isNaN(event) || event === '') {
781
- event = this.defaultNumber
782
- ? this.defaultNumber
783
- : this.minNumber || this.minNumber === 0
784
- ? this.minNumber
785
- : event
786
- }
787
- if (!this.allowNegative) {
788
- event = Math.abs(event)
789
- }
790
- event = parseFloat(event)
791
- // Need to return an integer rather than a string
792
- this.$emit('input-change', event)
793
- },
794
- onEvaluateCode(event) {
795
- // function to perform math on the code
796
- // filter the string in case of any malicious content
797
- const val = event.target.value
798
- let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
799
- filtered = filtered.split(/([-+*/()])/)
800
- let formatted = filtered.map((item) => {
801
- if (
802
- item === '+' ||
803
- item === '-' ||
804
- item === '*' ||
805
- item === '/' ||
806
- item === '(' ||
807
- item === ')' ||
808
- item === ''
809
- ) {
810
- return item
811
- } else {
812
- let num = stringToNumber({
813
- value: item,
814
- numberPrecision: false,
815
- minDecimals: this.minDecimals,
816
- })
817
- return num
818
- }
819
- })
820
- let evaluated
821
- formatted = this.removeStringItemsAfterLastNumber(formatted)
822
- evaluated = eval(formatted.join(' '))
823
- if (typeof evaluated === 'string') {
824
- evaluated = stringToNumber({
825
- value: evaluated,
826
- numberPrecision: this.numberPrecision,
827
- minDecimals: this.minDecimals,
828
- })
829
- } else if (typeof evaluated === 'number') {
830
- evaluated = evaluated.toFixed(this.numberPrecision)
831
- }
832
- return evaluated
833
- },
834
- removeStringItemsAfterLastNumber(array) {
835
- // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
836
- let lastNumberIndex = -1
837
- // Find the index of the last number in the array
838
- for (let i = array.length - 1; i >= 0; i--) {
839
- if (typeof array[i] === 'number') {
840
- lastNumberIndex = i
841
- break
842
- }
843
- }
844
- // if there are no numbers, return an empty array
845
- if (lastNumberIndex === -1) {
846
- return []
847
- }
848
- // Remove non-numeric items after the last number
849
- if (lastNumberIndex !== -1) {
850
- const newArray = array.slice(0, lastNumberIndex + 1)
851
- return newArray
852
- }
853
- return array
854
- },
855
- onInput(event) {
856
- if (!this.isFocused) {
857
- return
858
- }
859
- if (event.target.value === '') {
860
- this.$emit('on-input', '')
861
- }
862
- let evaluatedVal
863
- try {
864
- evaluatedVal = this.onEvaluateCode(event)
865
- } finally {
866
- if (evaluatedVal && this.value != evaluatedVal) {
867
- this.$emit('on-input', evaluatedVal)
868
- }
869
- }
870
- this.textInput = evaluatedVal
871
- },
872
- onInputBlur(e) {
873
- this.isFocused = false
874
- let value = e.target.value
875
- let evaluatedInput = this.onEvaluateCode(e)
876
- this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
877
- if ((evaluatedInput && value.length) || this.minNumber !== null) {
878
- this.textInput = numberToString({
879
- value:
880
- evaluatedInput && value.length
881
- ? evaluatedInput
882
- : this.defaultNumber
883
- ? this.defaultNumber
884
- : this.minNumber,
885
- numberPrecision: this.numberPrecision,
886
- minDecimals: this.minDecimals,
887
- })
888
- }
889
- let adjustedMinValue =
890
- evaluatedInput && evaluatedInput.length
891
- ? evaluatedInput
892
- : this.defaultNumber
893
- ? this.defaultNumber
894
- : this.minNumber || this.minNumber === 0
895
- ? this.minNumber
896
- : ''
897
- this.$emit('input-blur', adjustedMinValue)
898
- },
899
- focusInput() {
900
- if (this.disabled) {
901
- return
902
- }
903
- this.isFocused = true
904
- this.$nextTick(() => {
905
- this.$refs.inputField1.$el.select()
906
- })
907
- this.$emit('input-focus')
908
- },
909
- blurInput() {
910
- if (this.disabled) {
911
- return
912
- }
913
- this.isFocused = false
914
- this.$nextTick(() => {
915
- this.$refs.inputField1.$el.blur()
916
- })
917
- },
918
- formatWithCurrency(value) {
919
- let adjustedMinValue =
920
- value || value === 0
921
- ? value
922
- : this.defaultNumber
923
- ? this.defaultNumber
924
- : this.minNumber || this.minNumber === 0
925
- ? this.minNumber
926
- : ''
927
- if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
928
- let input = this.numberToStringEnabled
929
- ? numberToString({
930
- value: adjustedMinValue,
931
- numberPrecision: this.numberPrecision,
932
- minDecimals: this.minDecimals,
933
- })
934
- : adjustedMinValue
935
- let unit = this.showLinearUnitName ? '' : this.unitName
936
- //return input + ' ' + unit
937
- return input + ' ' + unit
938
- } else if (!adjustedMinValue && adjustedMinValue !== 0) {
939
- return ''
940
- } else {
941
- return this.numberToStringEnabled
942
- ? numberToString({
943
- value: adjustedMinValue,
944
- numberPrecision: this.numberPrecision,
945
- minDecimals: this.minDecimals,
946
- })
947
- : adjustedMinValue
948
- }
949
- },
950
- initInteraction(e) {
951
- this.focusInput()
952
- e.preventDefault()
953
- window.addEventListener('mousemove', this.interact, false)
954
- window.addEventListener('mouseup', this.stopInteract, false)
955
- },
956
- interact(e) {
957
- e.preventDefault()
958
- let value = parseFloat(this.value || 0)
959
- value += parseFloat(this.interactionStep) * parseInt(e.movementX)
960
- this.$emit('on-input-drag', value)
961
-
962
- this.textInput = numberToString({
963
- value: value && value.length ? value : this.minNumber,
964
- numberPrecision: this.numberPrecision,
965
- minDecimals: this.minDecimals,
966
- })
967
- //this.value=value
968
- },
969
- stopInteract(e) {
970
- e.preventDefault()
971
- window.removeEventListener('mousemove', this.interact, false)
972
- window.removeEventListener('mouseup', this.stopInteract, false)
973
- this.blurInput()
974
- },
975
- },
976
- }
977
- </script>
1
+ <template>
2
+ <Container :align-items="alignItems" :input-width="inputWidth">
3
+ <LabelSlotWrapper
4
+ v-if="hasLabelSlot"
5
+ :align-items="alignItems"
6
+ :border-color="borderColor"
7
+ :is-error="isError"
8
+ :is-interactive="isInteractive"
9
+ :no-border="noBorder"
10
+ @mousedown="initInteraction"
11
+ >
12
+ <slot name="label"></slot>
13
+ </LabelSlotWrapper>
14
+
15
+ <LabelWrapper v-if="labelText">
16
+ <LabelText :data-id="labelDataId" :label-font-color="labelFontColor">
17
+ {{ labelText }}
18
+ </LabelText>
19
+
20
+ <InfoText
21
+ v-if="labelInfoText"
22
+ :align-arrow="labelInfoAlign"
23
+ :text="labelInfoText"
24
+ />
25
+ </LabelWrapper>
26
+ <InputWrapper>
27
+ <InputContainer
28
+ v-bind="$attrs"
29
+ ref="inputField1"
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"
46
+ :placeholder="displayedPlaceholder"
47
+ :show-linear-unit-name="showLinearUnitName"
48
+ :slot-size="slotSize"
49
+ :text-align="textAlign"
50
+ :value="formatWithCurrency(value)"
51
+ @blur="onInputBlur($event)"
52
+ @focus="focusInput()"
53
+ @input="onInput($event)"
54
+ @keyup.enter="onEnterPress"
55
+ />
56
+ <SlotContainer v-if="hasSlot" :is-error="isError" :slot-size="slotSize">
57
+ <slot></slot>
58
+ </SlotContainer>
59
+
60
+ <UnitContainer
61
+ v-if="unitName && showLinearUnitName && !hasSlot"
62
+ :has-length="!!textInput.length"
63
+ :is-error="isError"
64
+ >{{ unitName }}</UnitContainer
65
+ >
66
+ <IconWrapper
67
+ v-if="isError && !showLinearUnitName"
68
+ :margin-right="showSelect ? selectWidth : 0"
69
+ size="16px"
70
+ >
71
+ <Icon cursor="default" name="warning" size="16px" />
72
+ </IconWrapper>
73
+ <SelectWrapper v-if="showSelect">
74
+ <Divider />
75
+ <RCSelect
76
+ :disabled="isSelectDisabled"
77
+ :select-width="`${selectWidth}px`"
78
+ :show-border="false"
79
+ @input-change="$emit('select-change', $event)"
80
+ >
81
+ <template #selector>
82
+ <SelectText>{{ getSelectValue }}</SelectText>
83
+ </template>
84
+ <template #dropdown>
85
+ <RCOption
86
+ v-for="item in selectOptions"
87
+ :key="item.value"
88
+ :value="item.value"
89
+ >
90
+ {{ item.label }}
91
+ </RCOption>
92
+ </template>
93
+ </RCSelect>
94
+ </SelectWrapper>
95
+ </InputWrapper>
96
+ <ErrorMessage v-if="isError">{{ errorMessage }}</ErrorMessage>
97
+ </Container>
98
+ </template>
99
+
100
+ <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 RCSelect from '../select'
137
+ import RCOption from '../select/option'
138
+ import warningIcon from '../../../assets/icons/error_icon.png'
139
+ import Icon from '../../icon'
140
+
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
+ }
162
+
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
+ `
170
+
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;
218
+
219
+ &::placeholder {
220
+ color: ${(props) => props.theme.colors.grey2};
221
+ }
222
+
223
+ &:focus {
224
+ outline: none;
225
+ }
226
+ `
227
+
228
+ const InputWrapper = styled.span`
229
+ position: relative;
230
+ `
231
+
232
+ const UnitContainer = styled('span', inputProps)`
233
+ border-left: 1px solid
234
+ ${(props) =>
235
+ props.isError
236
+ ? props.theme.colors.red
237
+ : props.hasLength
238
+ ? props.theme.colors.black
239
+ : 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
+ `
252
+
253
+ const SlotContainer = styled('span', inputProps)`
254
+ text-align: right;
255
+ border-left: 1px solid
256
+ ${(props) =>
257
+ props.isError
258
+ ? props.theme.colors.red
259
+ : props.hasLength
260
+ ? props.theme.colors.black
261
+ : 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
+ `
312
+
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
+ `
322
+
323
+ const SelectText = styled.div`
324
+ font-size: 13px;
325
+ `
326
+
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: 'InputNumber',
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
+ RCSelect,
358
+ RCOption,
359
+ SelectWrapper,
360
+ SelectText,
361
+ Divider,
362
+ },
363
+ inheritAttrs: false,
364
+ props: {
365
+ placeholder: {
366
+ required: false,
367
+ default: '',
368
+ },
369
+ isError: {
370
+ required: false,
371
+ default: false,
372
+ },
373
+ inputWidth: {
374
+ required: false,
375
+ default: null,
376
+ },
377
+ minWidth: {
378
+ required: false,
379
+ default: null,
380
+ },
381
+ inputHeight: {
382
+ required: false,
383
+ default: '40px',
384
+ },
385
+ value: {
386
+ required: true,
387
+ default: null,
388
+ },
389
+ clearInput: {
390
+ required: false,
391
+ default: false,
392
+ },
393
+ alignItems: {
394
+ required: false,
395
+ default: 'vertical',
396
+ },
397
+ errorMessage: {
398
+ required: false,
399
+ default: 'Please insert a correct number',
400
+ },
401
+ numberPrecision: {
402
+ required: false,
403
+ default: 0,
404
+ },
405
+ minDecimals: {
406
+ required: false,
407
+ default: 0,
408
+ },
409
+ unitName: {
410
+ required: false,
411
+ default: '',
412
+ },
413
+ showLinearUnitName: {
414
+ required: false,
415
+ default: false,
416
+ },
417
+ disabled: {
418
+ required: false,
419
+ default: false,
420
+ },
421
+ noBorder: {
422
+ required: false,
423
+ default: false,
424
+ },
425
+ borderColor: {
426
+ required: false,
427
+ },
428
+ textAlign: {
429
+ required: false,
430
+ default: 'left',
431
+ },
432
+ fontSize: {
433
+ required: false,
434
+ default: '13px',
435
+ },
436
+ isInteractive: {
437
+ required: false,
438
+ default: false,
439
+ },
440
+ interactionStep: {
441
+ required: false,
442
+ default: 1,
443
+ },
444
+ labelText: {
445
+ required: false,
446
+ default: null,
447
+ },
448
+ labelInfoText: {
449
+ required: false,
450
+ default: null,
451
+ },
452
+ labelInfoAlign: {
453
+ required: false,
454
+ default: 'left',
455
+ },
456
+ defaultNumber: {
457
+ required: false,
458
+ default: null,
459
+ },
460
+ minNumber: {
461
+ required: false,
462
+ default: null,
463
+ },
464
+ fontColor: {
465
+ required: false,
466
+ default: null,
467
+ },
468
+ backgroundColor: {
469
+ required: false,
470
+ default: null,
471
+ },
472
+ numberToStringEnabled: {
473
+ required: false,
474
+ default: true,
475
+ },
476
+ allowNegative: {
477
+ required: false,
478
+ default: true,
479
+ },
480
+ slotSize: {
481
+ required: false,
482
+ },
483
+ labelFontColor: {
484
+ required: false,
485
+ default: 'eturnityGrey',
486
+ },
487
+ focus: {
488
+ required: false,
489
+ default: false,
490
+ },
491
+ labelDataId: {
492
+ required: false,
493
+ default: '',
494
+ },
495
+ inputDataId: {
496
+ required: false,
497
+ default: '',
498
+ },
499
+ showSelect: {
500
+ type: Boolean,
501
+ default: false,
502
+ },
503
+ selectWidth: {
504
+ type: Number,
505
+ default: 70,
506
+ },
507
+ selectOptions: {
508
+ type: Array,
509
+ default: () => [],
510
+ },
511
+ selectValue: {
512
+ type: [String, Number],
513
+ default: null,
514
+ },
515
+ isSelectDisabled: {
516
+ type: Boolean,
517
+ default: false,
518
+ },
519
+ },
520
+ data() {
521
+ return {
522
+ textInput: '',
523
+ isFocused: false,
524
+ warningIcon: warningIcon,
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
+ )
544
+
545
+ return item ? item.label : '-'
546
+ },
547
+ },
548
+ watch: {
549
+ focus(value) {
550
+ if (value) {
551
+ this.focusInput()
552
+ }
553
+ },
554
+ clearInput: function (value) {
555
+ if (value) {
556
+ // If the value is typed, then we should clear the textInput on Continue
557
+ this.textInput = ''
558
+ }
559
+ },
560
+ },
561
+ created() {
562
+ if (this.value) {
563
+ this.textInput = numberToString({
564
+ value: this.value,
565
+ numberPrecision: this.numberPrecision,
566
+ minDecimals: this.minDecimals,
567
+ })
568
+ } else if (this.defaultNumber !== null) {
569
+ this.textInput = numberToString({
570
+ value: this.defaultNumber,
571
+ numberPrecision: this.numberPrecision,
572
+ minDecimals: this.minDecimals,
573
+ })
574
+ } else if (this.minNumber !== null) {
575
+ this.textInput = numberToString({
576
+ value: this.minNumber,
577
+ numberPrecision: this.numberPrecision,
578
+ minDecimals: this.minDecimals,
579
+ })
580
+ }
581
+ },
582
+ mounted() {
583
+ if (this.focus) {
584
+ this.focusInput()
585
+ }
586
+ },
587
+ methods: {
588
+ onEnterPress() {
589
+ this.$emit('on-enter-click')
590
+ this.$refs.inputField1.$el.blur()
591
+ },
592
+ onChangeHandler(event) {
593
+ if (isNaN(event) || event === '') {
594
+ event = this.defaultNumber
595
+ ? this.defaultNumber
596
+ : this.minNumber || this.minNumber === 0
597
+ ? this.minNumber
598
+ : event
599
+ }
600
+ if (!this.allowNegative) {
601
+ event = Math.abs(event)
602
+ }
603
+ event = parseFloat(event)
604
+ // Need to return an integer rather than a string
605
+ this.$emit('input-change', event)
606
+ },
607
+ onEvaluateCode(event) {
608
+ // function to perform math on the code
609
+ // filter the string in case of any malicious content
610
+ const val = event.target.value
611
+ let filtered = val.replace('(auto)', '').replace(/[^-()\d/*+.,]/g, '')
612
+ filtered = filtered.split(/([-+*/()])/)
613
+ let formatted = filtered.map((item) => {
614
+ if (
615
+ item === '+' ||
616
+ item === '-' ||
617
+ item === '*' ||
618
+ item === '/' ||
619
+ item === '(' ||
620
+ item === ')' ||
621
+ item === ''
622
+ ) {
623
+ return item
624
+ } else {
625
+ let num = stringToNumber({
626
+ value: item,
627
+ numberPrecision: false,
628
+ minDecimals: this.minDecimals,
629
+ })
630
+ return num
631
+ }
632
+ })
633
+ let evaluated
634
+ formatted = this.removeStringItemsAfterLastNumber(formatted)
635
+ evaluated = eval(formatted.join(' '))
636
+ if (typeof evaluated === 'string') {
637
+ evaluated = stringToNumber({
638
+ value: evaluated,
639
+ numberPrecision: this.numberPrecision,
640
+ minDecimals: this.minDecimals,
641
+ })
642
+ } else if (typeof evaluated === 'number') {
643
+ evaluated = evaluated.toFixed(this.numberPrecision)
644
+ }
645
+ return evaluated
646
+ },
647
+ removeStringItemsAfterLastNumber(array) {
648
+ // fixed in EPDM-6487, in order to prevent 'Unexpected end of input'
649
+ let lastNumberIndex = -1
650
+ // Find the index of the last number in the array
651
+ for (let i = array.length - 1; i >= 0; i--) {
652
+ if (typeof array[i] === 'number') {
653
+ lastNumberIndex = i
654
+ break
655
+ }
656
+ }
657
+ // if there are no numbers, return an empty array
658
+ if (lastNumberIndex === -1) {
659
+ return []
660
+ }
661
+ // Remove non-numeric items after the last number
662
+ if (lastNumberIndex !== -1) {
663
+ const newArray = array.slice(0, lastNumberIndex + 1)
664
+ return newArray
665
+ }
666
+ return array
667
+ },
668
+ onInput(event) {
669
+ if (!this.isFocused) {
670
+ return
671
+ }
672
+ if (event.target.value === '') {
673
+ this.$emit('on-input', '')
674
+ }
675
+ let evaluatedVal
676
+ try {
677
+ evaluatedVal = this.onEvaluateCode(event)
678
+ } finally {
679
+ if (evaluatedVal && this.value != evaluatedVal) {
680
+ this.$emit('on-input', evaluatedVal)
681
+ }
682
+ }
683
+ },
684
+ onInputBlur(e) {
685
+ this.isFocused = false
686
+ let value = e.target.value
687
+ let evaluatedInput = this.onEvaluateCode(e)
688
+ this.onChangeHandler(evaluatedInput ? evaluatedInput : value)
689
+ if ((evaluatedInput && value.length) || this.minNumber !== null) {
690
+ this.textInput = numberToString({
691
+ value:
692
+ evaluatedInput && value.length
693
+ ? evaluatedInput
694
+ : this.defaultNumber
695
+ ? this.defaultNumber
696
+ : this.minNumber,
697
+ numberPrecision: this.numberPrecision,
698
+ minDecimals: this.minDecimals,
699
+ })
700
+ }
701
+ let adjustedMinValue =
702
+ evaluatedInput && evaluatedInput.length
703
+ ? evaluatedInput
704
+ : this.defaultNumber
705
+ ? this.defaultNumber
706
+ : this.minNumber || this.minNumber === 0
707
+ ? this.minNumber
708
+ : ''
709
+ this.$emit('input-blur', adjustedMinValue)
710
+ },
711
+ focusInput() {
712
+ if (this.disabled) {
713
+ return
714
+ }
715
+ this.isFocused = true
716
+ this.$nextTick(() => {
717
+ this.$refs.inputField1.$el.select()
718
+ })
719
+ this.$emit('input-focus')
720
+ },
721
+ blurInput() {
722
+ if (this.disabled) {
723
+ return
724
+ }
725
+ this.isFocused = false
726
+ this.$nextTick(() => {
727
+ this.$refs.inputField1.$el.blur()
728
+ })
729
+ },
730
+ formatWithCurrency(value) {
731
+ let adjustedMinValue =
732
+ value || value === 0
733
+ ? value
734
+ : this.defaultNumber
735
+ ? this.defaultNumber
736
+ : this.minNumber || this.minNumber === 0
737
+ ? this.minNumber
738
+ : ''
739
+ if ((adjustedMinValue || adjustedMinValue === 0) && !this.isFocused) {
740
+ let input = this.numberToStringEnabled
741
+ ? numberToString({
742
+ value: adjustedMinValue,
743
+ numberPrecision: this.numberPrecision,
744
+ minDecimals: this.minDecimals,
745
+ })
746
+ : adjustedMinValue
747
+ let unit = this.showLinearUnitName ? '' : this.unitName
748
+ //return input + ' ' + unit
749
+ return input + ' ' + unit
750
+ } else if (!adjustedMinValue && adjustedMinValue !== 0) {
751
+ return ''
752
+ } else {
753
+ return this.numberToStringEnabled
754
+ ? numberToString({
755
+ value: adjustedMinValue,
756
+ numberPrecision: this.numberPrecision,
757
+ minDecimals: this.minDecimals,
758
+ })
759
+ : adjustedMinValue
760
+ }
761
+ },
762
+ initInteraction(e) {
763
+ this.focusInput()
764
+ e.preventDefault()
765
+ window.addEventListener('mousemove', this.interact, false)
766
+ window.addEventListener('mouseup', this.stopInteract, false)
767
+ },
768
+ interact(e) {
769
+ e.preventDefault()
770
+ let value = parseFloat(this.value || 0)
771
+ value += parseFloat(this.interactionStep) * parseInt(e.movementX)
772
+ this.$emit('on-input-drag', value)
773
+
774
+ this.textInput = numberToString({
775
+ value: value && value.length ? value : this.minNumber,
776
+ numberPrecision: this.numberPrecision,
777
+ minDecimals: this.minDecimals,
778
+ })
779
+ //this.value=value
780
+ },
781
+ stopInteract(e) {
782
+ e.preventDefault()
783
+ window.removeEventListener('mousemove', this.interact, false)
784
+ window.removeEventListener('mouseup', this.stopInteract, false)
785
+ this.blurInput()
786
+ },
787
+ },
788
+ }
789
+ </script>