@eturnity/eturnity_reusable_components 7.30.3-EPDM-11226.0 → 7.30.3-EPDM-8441.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 (321) 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 +5 -5
  6. package/package.json +62 -62
  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/bexio.svg +4 -4
  51. package/src/assets/svgIcons/bold.svg +3 -3
  52. package/src/assets/svgIcons/bom.svg +3 -3
  53. package/src/assets/svgIcons/bom_generation.svg +10 -10
  54. package/src/assets/svgIcons/bookmaker.svg +3 -3
  55. package/src/assets/svgIcons/bubble.svg +3 -3
  56. package/src/assets/svgIcons/bug.svg +5 -5
  57. package/src/assets/svgIcons/bullet_list.svg +8 -8
  58. package/src/assets/svgIcons/calendar.svg +7 -7
  59. package/src/assets/svgIcons/calendar_icon.svg +7 -7
  60. package/src/assets/svgIcons/call.svg +3 -3
  61. package/src/assets/svgIcons/camera.svg +3 -3
  62. package/src/assets/svgIcons/car.svg +3 -3
  63. package/src/assets/svgIcons/cart.svg +3 -3
  64. package/src/assets/svgIcons/charger_icon_white.svg +44 -44
  65. package/src/assets/svgIcons/checkbox.svg +3 -3
  66. package/src/assets/svgIcons/clear_formatting.svg +7 -7
  67. package/src/assets/svgIcons/clickable_info.svg +4 -4
  68. package/src/assets/svgIcons/clip.svg +3 -3
  69. package/src/assets/svgIcons/clock.svg +17 -17
  70. package/src/assets/svgIcons/clock_full.svg +3 -3
  71. package/src/assets/svgIcons/close_for_modals,_tool_tips.svg +4 -4
  72. package/src/assets/svgIcons/co_branding.svg +5 -5
  73. package/src/assets/svgIcons/collapse.svg +4 -4
  74. package/src/assets/svgIcons/collections.svg +3 -3
  75. package/src/assets/svgIcons/component_library.svg +7 -7
  76. package/src/assets/svgIcons/consumption_tariffs.svg +43 -43
  77. package/src/assets/svgIcons/context_menu-1.svg +6 -6
  78. package/src/assets/svgIcons/context_menu-2.svg +5 -5
  79. package/src/assets/svgIcons/context_menu.svg +5 -5
  80. package/src/assets/svgIcons/context_menu_tabs.svg +5 -5
  81. package/src/assets/svgIcons/cross.svg +4 -4
  82. package/src/assets/svgIcons/current_variant.svg +4 -4
  83. package/src/assets/svgIcons/dashboard.svg +3 -3
  84. package/src/assets/svgIcons/data_transfer.svg +3 -3
  85. package/src/assets/svgIcons/deadline.svg +4 -4
  86. package/src/assets/svgIcons/deal_flow.svg +5 -5
  87. package/src/assets/svgIcons/delete.svg +4 -4
  88. package/src/assets/svgIcons/delete_area_active.svg +16 -16
  89. package/src/assets/svgIcons/delete_area_inactive.svg +15 -15
  90. package/src/assets/svgIcons/direction_active-1.svg +12 -12
  91. package/src/assets/svgIcons/direction_active.svg +5 -5
  92. package/src/assets/svgIcons/direction_arrow.svg +4 -4
  93. package/src/assets/svgIcons/direction_inactive.svg +4 -4
  94. package/src/assets/svgIcons/dislike.svg +3 -3
  95. package/src/assets/svgIcons/distance_tool.svg +8 -8
  96. package/src/assets/svgIcons/distances_active.svg +9 -9
  97. package/src/assets/svgIcons/distances_inactive.svg +8 -8
  98. package/src/assets/svgIcons/distort_tool.svg +10 -10
  99. package/src/assets/svgIcons/distort_tool2.svg +16 -16
  100. package/src/assets/svgIcons/document.svg +3 -3
  101. package/src/assets/svgIcons/documents.svg +4 -4
  102. package/src/assets/svgIcons/downarrow.svg +3 -3
  103. package/src/assets/svgIcons/download.svg +4 -4
  104. package/src/assets/svgIcons/drag_icon.svg +8 -8
  105. package/src/assets/svgIcons/draggable_corner.svg +5 -5
  106. package/src/assets/svgIcons/draw_tool.svg +3 -3
  107. package/src/assets/svgIcons/duplicate-1.svg +8 -8
  108. package/src/assets/svgIcons/duplicate-2.svg +5 -5
  109. package/src/assets/svgIcons/duplicate.svg +4 -4
  110. package/src/assets/svgIcons/e-mobility_configurator.svg +6 -6
  111. package/src/assets/svgIcons/e_signature.svg +5 -5
  112. package/src/assets/svgIcons/edit_button.svg +3 -3
  113. package/src/assets/svgIcons/electricity_tariff.svg +3 -3
  114. package/src/assets/svgIcons/email.svg +3 -3
  115. package/src/assets/svgIcons/ems-1.svg +3 -3
  116. package/src/assets/svgIcons/ems.svg +3 -3
  117. package/src/assets/svgIcons/end_of_the_list.svg +5 -5
  118. package/src/assets/svgIcons/erase.svg +4 -4
  119. package/src/assets/svgIcons/external_icon.svg +5 -5
  120. package/src/assets/svgIcons/fav_icon.svg +4 -4
  121. package/src/assets/svgIcons/finance.svg +3 -3
  122. package/src/assets/svgIcons/financing_for_pv-1.svg +5 -5
  123. package/src/assets/svgIcons/financing_for_pv-2.svg +3 -3
  124. package/src/assets/svgIcons/financing_for_pv.svg +6 -6
  125. package/src/assets/svgIcons/finish-1.svg +4 -4
  126. package/src/assets/svgIcons/finish.svg +3 -3
  127. package/src/assets/svgIcons/flatten.svg +11 -11
  128. package/src/assets/svgIcons/flatten_roof.svg +20 -20
  129. package/src/assets/svgIcons/folder.svg +3 -3
  130. package/src/assets/svgIcons/free_technology.svg +5 -5
  131. package/src/assets/svgIcons/handle.svg +5 -5
  132. package/src/assets/svgIcons/heat_calc.svg +7 -7
  133. package/src/assets/svgIcons/height_equalize.svg +3 -3
  134. package/src/assets/svgIcons/height_snap.svg +3 -3
  135. package/src/assets/svgIcons/house.svg +3 -3
  136. package/src/assets/svgIcons/house_3d-1.svg +7 -7
  137. package/src/assets/svgIcons/house_3d.svg +7 -7
  138. package/src/assets/svgIcons/inclination.svg +2 -2
  139. package/src/assets/svgIcons/info.svg +3 -3
  140. package/src/assets/svgIcons/initial_situation.svg +3 -3
  141. package/src/assets/svgIcons/integrations.svg +3 -3
  142. package/src/assets/svgIcons/intro-tour-1.svg +3 -3
  143. package/src/assets/svgIcons/intro-tour.svg +3 -3
  144. package/src/assets/svgIcons/inverter-1.svg +5 -5
  145. package/src/assets/svgIcons/inverter.svg +3 -3
  146. package/src/assets/svgIcons/italic.svg +3 -3
  147. package/src/assets/svgIcons/key.svg +3 -3
  148. package/src/assets/svgIcons/layers_close.svg +4 -4
  149. package/src/assets/svgIcons/layers_open.svg +4 -4
  150. package/src/assets/svgIcons/lead_marketplace.svg +6 -6
  151. package/src/assets/svgIcons/lead_provider.svg +4 -4
  152. package/src/assets/svgIcons/length_2d.svg +2 -2
  153. package/src/assets/svgIcons/length_3d.svg +4 -4
  154. package/src/assets/svgIcons/length_calculator.svg +2 -2
  155. package/src/assets/svgIcons/length_in_2d_active.svg +12 -12
  156. package/src/assets/svgIcons/length_in_2d_inctive.svg +13 -13
  157. package/src/assets/svgIcons/light_bulb.svg +3 -3
  158. package/src/assets/svgIcons/like.svg +3 -3
  159. package/src/assets/svgIcons/line_graph.svg +3 -3
  160. package/src/assets/svgIcons/local_subsidies.svg +18 -18
  161. package/src/assets/svgIcons/location.svg +3 -3
  162. package/src/assets/svgIcons/lock.svg +3 -3
  163. package/src/assets/svgIcons/logout.svg +3 -3
  164. package/src/assets/svgIcons/loop.svg +3 -3
  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/not_equal_to.svg +3 -3
  175. package/src/assets/svgIcons/numbered_list.svg +6 -6
  176. package/src/assets/svgIcons/obstacle_tool.svg +9 -9
  177. package/src/assets/svgIcons/obstacle_tool_origin.svg +3 -3
  178. package/src/assets/svgIcons/offset_tool.svg +8 -8
  179. package/src/assets/svgIcons/outline_tool.svg +11 -11
  180. package/src/assets/svgIcons/pan_tool.svg +12 -12
  181. package/src/assets/svgIcons/panels_tool.svg +8 -8
  182. package/src/assets/svgIcons/pen_tool.svg +4 -4
  183. package/src/assets/svgIcons/picker_tool.svg +4 -4
  184. package/src/assets/svgIcons/picture.svg +3 -3
  185. package/src/assets/svgIcons/pin.svg +5 -5
  186. package/src/assets/svgIcons/presentation.svg +3 -3
  187. package/src/assets/svgIcons/previous.svg +4 -4
  188. package/src/assets/svgIcons/profile-1.svg +4 -4
  189. package/src/assets/svgIcons/profile.svg +4 -4
  190. package/src/assets/svgIcons/profitability.svg +3 -3
  191. package/src/assets/svgIcons/project_analysis.svg +4 -4
  192. package/src/assets/svgIcons/project_settings.svg +4 -4
  193. package/src/assets/svgIcons/pv.svg +3 -3
  194. package/src/assets/svgIcons/quotations.svg +6 -6
  195. package/src/assets/svgIcons/redo.svg +6 -6
  196. package/src/assets/svgIcons/resizer.svg +5 -5
  197. package/src/assets/svgIcons/roof_layer.svg +3 -3
  198. package/src/assets/svgIcons/rotate_tool.svg +3 -3
  199. package/src/assets/svgIcons/rotate_view.svg +5 -5
  200. package/src/assets/svgIcons/ruler_tool.svg +3 -3
  201. package/src/assets/svgIcons/run_simulation.svg +3 -3
  202. package/src/assets/svgIcons/save.svg +3 -3
  203. package/src/assets/svgIcons/scaling_tool.svg +8 -8
  204. package/src/assets/svgIcons/search.svg +3 -3
  205. package/src/assets/svgIcons/security.svg +3 -3
  206. package/src/assets/svgIcons/settings.svg +3 -3
  207. package/src/assets/svgIcons/show_in_a_new_tab.svg +12 -12
  208. package/src/assets/svgIcons/smartphone.svg +4 -4
  209. package/src/assets/svgIcons/solar_calc.svg +13 -13
  210. package/src/assets/svgIcons/sorting.svg +4 -4
  211. package/src/assets/svgIcons/split.svg +12 -12
  212. package/src/assets/svgIcons/start_of_the_list.svg +5 -5
  213. package/src/assets/svgIcons/strikethrough.svg +4 -4
  214. package/src/assets/svgIcons/subscriptions.svg +3 -3
  215. package/src/assets/svgIcons/subsidies-1.svg +5 -5
  216. package/src/assets/svgIcons/subsidies-2.svg +3 -3
  217. package/src/assets/svgIcons/subsidies.svg +3 -3
  218. package/src/assets/svgIcons/subtract_icon.svg +3 -3
  219. package/src/assets/svgIcons/suitcase.svg +3 -3
  220. package/src/assets/svgIcons/summer.svg +3 -3
  221. package/src/assets/svgIcons/template_icon_not_clickable.svg +6 -6
  222. package/src/assets/svgIcons/transfer.svg +4 -4
  223. package/src/assets/svgIcons/trim_tool.svg +4 -4
  224. package/src/assets/svgIcons/truck.svg +3 -3
  225. package/src/assets/svgIcons/underlined.svg +3 -3
  226. package/src/assets/svgIcons/undo.svg +6 -6
  227. package/src/assets/svgIcons/uparrow.svg +3 -3
  228. package/src/assets/svgIcons/update.svg +3 -3
  229. package/src/assets/svgIcons/upload_avatar-1.svg +12 -12
  230. package/src/assets/svgIcons/upload_avatar.svg +5 -5
  231. package/src/assets/svgIcons/upload_image.svg +8 -8
  232. package/src/assets/svgIcons/upload_image_tool.svg +7 -7
  233. package/src/assets/svgIcons/variants.svg +6 -6
  234. package/src/assets/svgIcons/vertical_tool.svg +3 -3
  235. package/src/assets/svgIcons/virtual_storage.svg +4 -4
  236. package/src/assets/svgIcons/warning.svg +4 -4
  237. package/src/assets/svgIcons/way.svg +5 -5
  238. package/src/assets/svgIcons/wifi.svg +3 -3
  239. package/src/assets/svgIcons/winter.svg +3 -3
  240. package/src/assets/svgIcons/workflow_template.svg +11 -11
  241. package/src/assets/theme.js +41 -41
  242. package/src/components/addNewButton/AddNewButton.stories.js +24 -24
  243. package/src/components/addNewButton/index.vue +64 -64
  244. package/src/components/banner/actionBanner/index.vue +65 -65
  245. package/src/components/banner/banner/banner.stories.js +31 -31
  246. package/src/components/banner/banner/index.vue +188 -188
  247. package/src/components/banner/infoBanner/index.vue +69 -69
  248. package/src/components/buttons/buttonIcon/index.vue +142 -142
  249. package/src/components/buttons/closeButton/CloseButton.stories.js +29 -29
  250. package/src/components/buttons/closeButton/index.vue +61 -61
  251. package/src/components/buttons/mainButton/index.vue +140 -140
  252. package/src/components/card/index.vue +96 -96
  253. package/src/components/collapsableInfoText/index.vue +125 -125
  254. package/src/components/deleteIcon/DeleteIcon.stories.js +29 -29
  255. package/src/components/deleteIcon/index.vue +78 -78
  256. package/src/components/draggableInputHandle/index.vue +46 -46
  257. package/src/components/dropdown/Dropdown.stories.js +54 -54
  258. package/src/components/dropdown/index.vue +138 -138
  259. package/src/components/errorMessage/index.vue +64 -64
  260. package/src/components/filter/filterSettings.vue +633 -633
  261. package/src/components/filter/index.vue +154 -154
  262. package/src/components/filter/parentDropdown.vue +91 -91
  263. package/src/components/icon/Icons.stories.js +41 -41
  264. package/src/components/icon/iconCache.js +23 -23
  265. package/src/components/icon/iconCollection.vue +68 -68
  266. package/src/components/icon/index.vue +140 -140
  267. package/src/components/iconWrapper/index.vue +179 -179
  268. package/src/components/infoCard/index.vue +42 -42
  269. package/src/components/infoText/index.vue +165 -165
  270. package/src/components/inputs/checkbox/Checkbox.stories.js +57 -57
  271. package/src/components/inputs/checkbox/index.vue +214 -214
  272. package/src/components/inputs/inputNumber/InputNumber.stories.js +150 -150
  273. package/src/components/inputs/inputNumber/index.vue +784 -784
  274. package/src/components/inputs/inputNumberQuestion/index.vue +215 -215
  275. package/src/components/inputs/inputText/InputText.stories.js +75 -75
  276. package/src/components/inputs/inputText/index.vue +375 -375
  277. package/src/components/inputs/radioButton/RadioButton.stories.js +58 -58
  278. package/src/components/inputs/radioButton/index.vue +270 -270
  279. package/src/components/inputs/searchInput/SearchInput.stories.js +40 -40
  280. package/src/components/inputs/searchInput/index.vue +150 -150
  281. package/src/components/inputs/select/index.vue +1028 -906
  282. package/src/components/inputs/select/option/index.vue +139 -148
  283. package/src/components/inputs/select/select.stories.js +59 -59
  284. package/src/components/inputs/slider/index.vue +126 -126
  285. package/src/components/inputs/switchField/index.vue +256 -256
  286. package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +127 -127
  287. package/src/components/inputs/textAreaInput/index.vue +200 -200
  288. package/src/components/inputs/toggle/Toggle.stories.js +77 -77
  289. package/src/components/inputs/toggle/index.vue +288 -288
  290. package/src/components/label/index.vue +99 -99
  291. package/src/components/markerItem/index.vue +86 -86
  292. package/src/components/modals/actionModal/index.vue +64 -64
  293. package/src/components/modals/infoModal/index.vue +49 -49
  294. package/src/components/modals/modal/index.vue +188 -188
  295. package/src/components/modals/modal/modal.stories.js +31 -31
  296. package/src/components/navigationTabs/index.vue +112 -112
  297. package/src/components/pageSubtitle/index.vue +61 -61
  298. package/src/components/pageTitle/index.vue +68 -68
  299. package/src/components/pagination/index.vue +145 -145
  300. package/src/components/progressBar/index.vue +125 -125
  301. package/src/components/projectMarker/index.vue +298 -298
  302. package/src/components/rangeSlider/Slider.vue +547 -547
  303. package/src/components/rangeSlider/index.vue +517 -517
  304. package/src/components/rangeSlider/utils/dom.js +49 -49
  305. package/src/components/rangeSlider/utils/fns.js +26 -26
  306. package/src/components/selectedOptions/index.vue +145 -145
  307. package/src/components/sideMenu/index.vue +270 -270
  308. package/src/components/spinner/index.vue +68 -68
  309. package/src/components/tableDropdown/index.vue +638 -638
  310. package/src/components/tables/mainTable/exampleNested.vue +328 -328
  311. package/src/components/tables/mainTable/index.vue +493 -493
  312. package/src/components/tables/viewTable/index.vue +195 -195
  313. package/src/components/tabsHeader/index.vue +83 -83
  314. package/src/components/threeDots/index.vue +407 -407
  315. package/src/components/videoThumbnail/index.vue +103 -103
  316. package/src/components/videoThumbnail/videoThumbnail.stories.js +35 -35
  317. package/src/helpers/currencyMapping.js +28 -28
  318. package/src/helpers/numberConverter.js +103 -103
  319. package/src/helpers/translateLang.js +127 -127
  320. package/src/main.js +6 -6
  321. package/src/mixins/inputValidations.js +97 -97
@@ -1,547 +1,547 @@
1
- <template>
2
- <div
3
- :data-id="dataId"
4
- :style="style"
5
- :class="className"
6
- @mousedown="elementMouseDown"
7
- @touchstart="elementTouchDown"
8
- >
9
- <div
10
- v-for="handle in actualHandles"
11
- :key="handle"
12
- :style="{ display: enabled ? 'block' : 'none' }"
13
- @mousedown.stop.prevent="handleDown(handle, $event)"
14
- @touchstart.stop.prevent="handleTouchDown(handle, $event)"
15
- >
16
- <slot :name="handle"></slot>
17
- </div>
18
- <slot></slot>
19
- </div>
20
- </template>
21
-
22
- <script>
23
- import {
24
- matchesSelectorToParentElements,
25
- addEvent,
26
- removeEvent
27
- } from './utils/dom'
28
- import { computeWidth, restrictToBounds, snapToGrid } from './utils/fns'
29
-
30
- const events = {
31
- mouse: {
32
- start: 'mousedown',
33
- move: 'mousemove',
34
- stop: 'mouseup'
35
- },
36
- touch: {
37
- start: 'touchstart',
38
- move: 'touchmove',
39
- stop: 'touchend'
40
- }
41
- }
42
-
43
- const userSelectNone = {
44
- userSelect: 'none',
45
- MozUserSelect: 'none',
46
- WebkitUserSelect: 'none',
47
- MsUserSelect: 'none'
48
- }
49
-
50
- const userSelectAuto = {
51
- userSelect: 'auto',
52
- MozUserSelect: 'auto',
53
- WebkitUserSelect: 'auto',
54
- MsUserSelect: 'auto'
55
- }
56
-
57
- let eventsFor = events.mouse
58
-
59
- export default {
60
- replace: true,
61
- name: 'SliderComponent',
62
- props: {
63
- dataId: {
64
- type: String,
65
- default: ''
66
- },
67
- className: {
68
- type: String,
69
- default: 'vdr'
70
- },
71
- disableUserSelect: {
72
- type: Boolean,
73
- default: true
74
- },
75
- preventDeactivation: {
76
- type: Boolean,
77
- default: false
78
- },
79
- active: {
80
- type: Boolean,
81
- default: false
82
- },
83
- draggable: {
84
- type: Boolean,
85
- default: true
86
- },
87
- resizable: {
88
- type: Boolean,
89
- default: true
90
- },
91
- minWidth: {
92
- type: Number,
93
- default: 1,
94
- validator: (val) => val >= 0
95
- },
96
- step: {
97
- type: Number,
98
- default: 1,
99
- validator: (val) => val > 0
100
- },
101
- stepCount: {
102
- type: Number,
103
- default: 0,
104
- validator: (val) => val > 0
105
- },
106
- subStepCount: {
107
- type: Number,
108
- default: 0,
109
- validator: (val) => val >= 0
110
- },
111
- h: {
112
- type: [Number, String],
113
- default: 'auto',
114
- validator: (val) => {
115
- if (typeof val === 'number') {
116
- return val > 0
117
- }
118
-
119
- return val === 'auto'
120
- }
121
- },
122
- z: {
123
- type: [String, Number],
124
- default: 'auto',
125
- validator: (val) => (typeof val === 'string' ? val === 'auto' : val >= 0)
126
- },
127
- min: {
128
- type: Number,
129
- default: 0,
130
- validator: (val) => val >= 0
131
- },
132
- max: {
133
- type: Number,
134
- default: 0,
135
- validator: (val) => val >= 0
136
- },
137
- dragHandle: {
138
- type: String,
139
- default: null
140
- },
141
- dragCancel: {
142
- type: String,
143
- default: null
144
- },
145
- onDrag: {
146
- type: Function,
147
- default: () => true
148
- },
149
- onResize: {
150
- type: Function,
151
- default: () => true
152
- }
153
- },
154
-
155
- data: function () {
156
- return {
157
- left: null,
158
- right: null,
159
- width: null,
160
- height: null,
161
- parentWidth: null,
162
- parentHeight: null,
163
- widthTouched: false,
164
- heightTouched: false,
165
-
166
- handle: null,
167
- resizing: false,
168
- dragging: false,
169
- dragEnable: false,
170
- resizeEnable: false,
171
- enabled: this.active,
172
-
173
- zIndex: this.z,
174
- handles: ['ml', 'mr']
175
- }
176
- },
177
-
178
- created: function () {
179
- this.resetBoundsAndMouseState()
180
- },
181
- mounted: function () {
182
- const [parentWidth, parentHeight] = this.getParentSize()
183
-
184
- this.parentWidth = parentWidth
185
- this.parentHeight = parentHeight
186
-
187
- this.left = this.min * this.pxPerStep
188
- this.right = this.max * this.pxPerStep
189
- this.width = computeWidth(this.left, this.right)
190
- this.height = this.h !== 'auto' ? this.h : parentHeight
191
-
192
- if (this.active) {
193
- this.$emit('activated')
194
- }
195
-
196
- addEvent(document.documentElement, 'mousedown', this.deselect)
197
- addEvent(document.documentElement, 'touchend touchcancel', this.deselect)
198
-
199
- addEvent(window, 'resize', this.checkParentSize)
200
- },
201
- beforeUnmount: function () {
202
- removeEvent(document.documentElement, 'mousedown', this.deselect)
203
- removeEvent(document.documentElement, 'touchstart', this.handleUp)
204
- removeEvent(document.documentElement, 'mousemove', this.move)
205
- removeEvent(document.documentElement, 'touchmove', this.move)
206
- removeEvent(document.documentElement, 'mouseup', this.handleUp)
207
- removeEvent(document.documentElement, 'touchend touchcancel', this.deselect)
208
-
209
- removeEvent(window, 'resize', this.checkParentSize)
210
- },
211
-
212
- methods: {
213
- resetBoundsAndMouseState() {
214
- this.mouseClickPosition = { mouseX: 0, mouseY: 0, x: 0, y: 0, w: 0, h: 0 }
215
-
216
- this.bounds = {
217
- minLeft: null,
218
- maxLeft: null,
219
- minRight: null,
220
- maxRight: null
221
- }
222
- },
223
- checkParentSize() {
224
- const [newParentWidth, newParentHeight] = this.getParentSize()
225
-
226
- this.parentWidth = newParentWidth
227
- this.parentHeight = newParentHeight
228
- },
229
- getParentSize() {
230
- const style = window.getComputedStyle(this.$el.parentNode, null)
231
-
232
- return [
233
- parseInt(style.getPropertyValue('width'), 10),
234
- parseInt(style.getPropertyValue('height'), 10)
235
- ]
236
- },
237
- elementTouchDown(e) {
238
- eventsFor = events.touch
239
-
240
- this.elementDown(e)
241
- },
242
- elementMouseDown(e) {
243
- eventsFor = events.mouse
244
-
245
- this.elementDown(e)
246
- },
247
- elementDown(e) {
248
- if (e instanceof MouseEvent && e.button !== 0) {
249
- return
250
- }
251
-
252
- const target = e.target || e.srcElement
253
-
254
- if (this.$el.contains(target)) {
255
- if (
256
- (this.dragHandle &&
257
- !matchesSelectorToParentElements(
258
- target,
259
- this.dragHandle,
260
- this.$el
261
- )) ||
262
- (this.dragCancel &&
263
- matchesSelectorToParentElements(target, this.dragCancel, this.$el))
264
- ) {
265
- this.dragging = false
266
-
267
- return
268
- }
269
-
270
- if (!this.enabled) {
271
- this.enabled = true
272
-
273
- this.$emit('activated')
274
- this.$emit('update:active', true)
275
- }
276
-
277
- if (this.draggable) {
278
- this.dragEnable = true
279
- }
280
-
281
- const newPosition = {
282
- ...this.mouseClickPosition,
283
- mouseX: e.touches ? e.touches[0].pageX : e.pageX,
284
- left: this.left,
285
- right: this.right
286
- }
287
-
288
- this.mouseClickPosition = newPosition
289
- this.bounds = this.calcDragLimits()
290
-
291
- addEvent(document.documentElement, eventsFor.move, this.move)
292
- addEvent(document.documentElement, eventsFor.stop, this.handleUp)
293
- }
294
- },
295
- calcDragLimits() {
296
- const limits = {
297
- minLeft: null,
298
- maxLeft: null,
299
- minRight: null,
300
- maxRight: null
301
- }
302
-
303
- limits.minLeft = 0
304
- limits.maxLeft = this.parentWidth - this.width
305
- limits.minRight = this.width
306
- limits.maxRight = this.parentWidth
307
-
308
- return limits
309
- },
310
- deselect(e) {
311
- const target = e.target || e.srcElement
312
- const regex = new RegExp(this.className + '-([trmbl]{2})', '')
313
-
314
- if (!this.$el.contains(target) && !regex.test(target.className)) {
315
- if (this.enabled && !this.preventDeactivation) {
316
- this.enabled = false
317
-
318
- this.$emit('deactivated')
319
- this.$emit('update:active', false)
320
- }
321
-
322
- removeEvent(document.documentElement, eventsFor.move, this.handleResize)
323
- }
324
-
325
- this.resetBoundsAndMouseState()
326
- },
327
- handleTouchDown(handle, e) {
328
- eventsFor = events.touch
329
-
330
- this.handleDown(handle, e)
331
- },
332
- handleDown(handle, e) {
333
- if (e instanceof MouseEvent && e.which !== 1) {
334
- return
335
- }
336
-
337
- if (e.stopPropagation) e.stopPropagation()
338
-
339
- this.handle = handle
340
- this.resizeEnable = true
341
-
342
- const newPosition = {
343
- ...this.mouseClickPosition,
344
- mouseX: e.touches ? e.touches[0].pageX : e.pageX,
345
- left: this.left,
346
- right: this.right
347
- }
348
-
349
- this.mouseClickPosition = newPosition
350
- this.bounds = this.calcResizeLimits()
351
-
352
- addEvent(document.documentElement, eventsFor.move, this.handleResize)
353
- addEvent(document.documentElement, eventsFor.stop, this.handleUp)
354
- },
355
- calcResizeLimits() {
356
- const limits = {
357
- minLeft: null,
358
- maxLeft: null,
359
- minRight: null,
360
- maxRight: null
361
- }
362
-
363
- limits.minLeft = 0
364
- limits.maxLeft = this.right - this.minWidthByPx
365
- limits.minRight = this.left + this.minWidthByPx
366
- limits.maxRight = this.parentWidth
367
-
368
- return limits
369
- },
370
- move(e) {
371
- if (this.resizing) {
372
- this.handleResize(e)
373
- } else if (this.dragEnable) {
374
- this.handleDrag(e)
375
- }
376
- },
377
- handleDrag(e) {
378
- let left = this.left
379
- let right = this.right
380
- const bounds = this.bounds
381
- const mouseClickPosition = this.mouseClickPosition
382
-
383
- const tmpDeltaX =
384
- mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
385
-
386
- const deltaX = snapToGrid(this.parentWidth / this.subStepCount, tmpDeltaX)
387
-
388
- left = restrictToBounds(
389
- mouseClickPosition.left - deltaX,
390
- bounds.minLeft,
391
- bounds.maxLeft
392
- )
393
-
394
- right = restrictToBounds(
395
- mouseClickPosition.right - deltaX,
396
- bounds.minRight,
397
- bounds.maxRight
398
- )
399
-
400
- this.left = left
401
- this.right = right
402
-
403
- this.$emit('dragging', this.left, this.right)
404
- this.dragging = true
405
- },
406
- handleResize(e) {
407
- let left = this.left
408
- let right = this.right
409
- const bounds = this.bounds
410
- const mouseClickPosition = this.mouseClickPosition
411
-
412
- const tmpDeltaX =
413
- mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
414
-
415
- if (!this.widthTouched && tmpDeltaX) {
416
- this.widthTouched = true
417
- }
418
-
419
- const deltaX = snapToGrid(this.parentWidth / this.subStepCount, tmpDeltaX)
420
-
421
- if (this.handle.includes('r')) {
422
- right = restrictToBounds(
423
- mouseClickPosition.right - deltaX,
424
- bounds.minRight,
425
- bounds.maxRight
426
- )
427
- } else if (this.handle.includes('l')) {
428
- left = restrictToBounds(
429
- mouseClickPosition.left - deltaX,
430
- bounds.minLeft,
431
- bounds.maxLeft
432
- )
433
- }
434
-
435
- const width = computeWidth(left, right)
436
-
437
- if (this.onResize(this.handle, left, width, this.height) === false) {
438
- return
439
- }
440
-
441
- this.left = left
442
- this.right = right
443
- this.width = width
444
-
445
- this.$emit('resizing', this.left, this.right)
446
- this.resizing = true
447
- },
448
- handleUp() {
449
- this.handle = null
450
-
451
- this.dragEnable = false
452
- this.resizeEnable = false
453
-
454
- if (this.resizing) {
455
- this.resizing = false
456
- this.$emit('resizeStop', {
457
- min: this.roundToNearestStep(this.left),
458
- max: this.roundToNearestStep(this.right)
459
- })
460
- }
461
-
462
- if (this.dragging) {
463
- this.dragging = false
464
- this.$emit('dragStop', {
465
- min: this.roundToNearestStep(this.left),
466
- max: this.roundToNearestStep(this.right)
467
- })
468
- }
469
-
470
- removeEvent(document.documentElement, eventsFor.move, this.handleResize)
471
- },
472
- roundToNearestStep(value) {
473
- const val = value / this.pxPerStep
474
-
475
- const int = 1.0 / this.step
476
- return (Math.round(val * int) / int).toFixed(2)
477
- }
478
- },
479
- computed: {
480
- style() {
481
- return {
482
- transform: `translate(${this.left}px, 0px)`,
483
- width: this.computedWidth,
484
- height: this.computedHeight,
485
- zIndex: this.zIndex,
486
- ...(this.dragging && this.disableUserSelect
487
- ? userSelectNone
488
- : userSelectAuto)
489
- }
490
- },
491
- actualHandles() {
492
- if (!this.resizable) return []
493
-
494
- return this.handles
495
- },
496
- pxPerStep() {
497
- return this.parentWidth / this.stepCount
498
- },
499
- minWidthByPx() {
500
- return this.minWidth * this.pxPerStep
501
- },
502
- computedWidth() {
503
- if (this.width === 'auto') {
504
- if (!this.widthTouched) {
505
- return 'auto'
506
- }
507
- }
508
-
509
- return this.width + 'px'
510
- },
511
- computedHeight() {
512
- if (this.height === 'auto') {
513
- if (!this.heightTouched) {
514
- return 'auto'
515
- }
516
- }
517
-
518
- return this.height + 'px'
519
- }
520
- },
521
-
522
- watch: {
523
- active(val) {
524
- this.enabled = val
525
-
526
- if (val) {
527
- this.$emit('activated')
528
- } else {
529
- this.$emit('deactivated')
530
- }
531
- },
532
- z(val) {
533
- if (val >= 0 || val === 'auto') {
534
- this.zIndex = val
535
- }
536
- }
537
- }
538
- }
539
- </script>
540
- <style scoped>
541
- .vdr {
542
- touch-action: none;
543
- position: absolute;
544
- box-sizing: border-box;
545
- border: 1px dashed black;
546
- }
547
- </style>
1
+ <template>
2
+ <div
3
+ :data-id="dataId"
4
+ :style="style"
5
+ :class="className"
6
+ @mousedown="elementMouseDown"
7
+ @touchstart="elementTouchDown"
8
+ >
9
+ <div
10
+ v-for="handle in actualHandles"
11
+ :key="handle"
12
+ :style="{ display: enabled ? 'block' : 'none' }"
13
+ @mousedown.stop.prevent="handleDown(handle, $event)"
14
+ @touchstart.stop.prevent="handleTouchDown(handle, $event)"
15
+ >
16
+ <slot :name="handle"></slot>
17
+ </div>
18
+ <slot></slot>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ import {
24
+ matchesSelectorToParentElements,
25
+ addEvent,
26
+ removeEvent
27
+ } from './utils/dom'
28
+ import { computeWidth, restrictToBounds, snapToGrid } from './utils/fns'
29
+
30
+ const events = {
31
+ mouse: {
32
+ start: 'mousedown',
33
+ move: 'mousemove',
34
+ stop: 'mouseup'
35
+ },
36
+ touch: {
37
+ start: 'touchstart',
38
+ move: 'touchmove',
39
+ stop: 'touchend'
40
+ }
41
+ }
42
+
43
+ const userSelectNone = {
44
+ userSelect: 'none',
45
+ MozUserSelect: 'none',
46
+ WebkitUserSelect: 'none',
47
+ MsUserSelect: 'none'
48
+ }
49
+
50
+ const userSelectAuto = {
51
+ userSelect: 'auto',
52
+ MozUserSelect: 'auto',
53
+ WebkitUserSelect: 'auto',
54
+ MsUserSelect: 'auto'
55
+ }
56
+
57
+ let eventsFor = events.mouse
58
+
59
+ export default {
60
+ replace: true,
61
+ name: 'SliderComponent',
62
+ props: {
63
+ dataId: {
64
+ type: String,
65
+ default: ''
66
+ },
67
+ className: {
68
+ type: String,
69
+ default: 'vdr'
70
+ },
71
+ disableUserSelect: {
72
+ type: Boolean,
73
+ default: true
74
+ },
75
+ preventDeactivation: {
76
+ type: Boolean,
77
+ default: false
78
+ },
79
+ active: {
80
+ type: Boolean,
81
+ default: false
82
+ },
83
+ draggable: {
84
+ type: Boolean,
85
+ default: true
86
+ },
87
+ resizable: {
88
+ type: Boolean,
89
+ default: true
90
+ },
91
+ minWidth: {
92
+ type: Number,
93
+ default: 1,
94
+ validator: (val) => val >= 0
95
+ },
96
+ step: {
97
+ type: Number,
98
+ default: 1,
99
+ validator: (val) => val > 0
100
+ },
101
+ stepCount: {
102
+ type: Number,
103
+ default: 0,
104
+ validator: (val) => val > 0
105
+ },
106
+ subStepCount: {
107
+ type: Number,
108
+ default: 0,
109
+ validator: (val) => val >= 0
110
+ },
111
+ h: {
112
+ type: [Number, String],
113
+ default: 'auto',
114
+ validator: (val) => {
115
+ if (typeof val === 'number') {
116
+ return val > 0
117
+ }
118
+
119
+ return val === 'auto'
120
+ }
121
+ },
122
+ z: {
123
+ type: [String, Number],
124
+ default: 'auto',
125
+ validator: (val) => (typeof val === 'string' ? val === 'auto' : val >= 0)
126
+ },
127
+ min: {
128
+ type: Number,
129
+ default: 0,
130
+ validator: (val) => val >= 0
131
+ },
132
+ max: {
133
+ type: Number,
134
+ default: 0,
135
+ validator: (val) => val >= 0
136
+ },
137
+ dragHandle: {
138
+ type: String,
139
+ default: null
140
+ },
141
+ dragCancel: {
142
+ type: String,
143
+ default: null
144
+ },
145
+ onDrag: {
146
+ type: Function,
147
+ default: () => true
148
+ },
149
+ onResize: {
150
+ type: Function,
151
+ default: () => true
152
+ }
153
+ },
154
+
155
+ data: function () {
156
+ return {
157
+ left: null,
158
+ right: null,
159
+ width: null,
160
+ height: null,
161
+ parentWidth: null,
162
+ parentHeight: null,
163
+ widthTouched: false,
164
+ heightTouched: false,
165
+
166
+ handle: null,
167
+ resizing: false,
168
+ dragging: false,
169
+ dragEnable: false,
170
+ resizeEnable: false,
171
+ enabled: this.active,
172
+
173
+ zIndex: this.z,
174
+ handles: ['ml', 'mr']
175
+ }
176
+ },
177
+
178
+ created: function () {
179
+ this.resetBoundsAndMouseState()
180
+ },
181
+ mounted: function () {
182
+ const [parentWidth, parentHeight] = this.getParentSize()
183
+
184
+ this.parentWidth = parentWidth
185
+ this.parentHeight = parentHeight
186
+
187
+ this.left = this.min * this.pxPerStep
188
+ this.right = this.max * this.pxPerStep
189
+ this.width = computeWidth(this.left, this.right)
190
+ this.height = this.h !== 'auto' ? this.h : parentHeight
191
+
192
+ if (this.active) {
193
+ this.$emit('activated')
194
+ }
195
+
196
+ addEvent(document.documentElement, 'mousedown', this.deselect)
197
+ addEvent(document.documentElement, 'touchend touchcancel', this.deselect)
198
+
199
+ addEvent(window, 'resize', this.checkParentSize)
200
+ },
201
+ beforeUnmount: function () {
202
+ removeEvent(document.documentElement, 'mousedown', this.deselect)
203
+ removeEvent(document.documentElement, 'touchstart', this.handleUp)
204
+ removeEvent(document.documentElement, 'mousemove', this.move)
205
+ removeEvent(document.documentElement, 'touchmove', this.move)
206
+ removeEvent(document.documentElement, 'mouseup', this.handleUp)
207
+ removeEvent(document.documentElement, 'touchend touchcancel', this.deselect)
208
+
209
+ removeEvent(window, 'resize', this.checkParentSize)
210
+ },
211
+
212
+ methods: {
213
+ resetBoundsAndMouseState() {
214
+ this.mouseClickPosition = { mouseX: 0, mouseY: 0, x: 0, y: 0, w: 0, h: 0 }
215
+
216
+ this.bounds = {
217
+ minLeft: null,
218
+ maxLeft: null,
219
+ minRight: null,
220
+ maxRight: null
221
+ }
222
+ },
223
+ checkParentSize() {
224
+ const [newParentWidth, newParentHeight] = this.getParentSize()
225
+
226
+ this.parentWidth = newParentWidth
227
+ this.parentHeight = newParentHeight
228
+ },
229
+ getParentSize() {
230
+ const style = window.getComputedStyle(this.$el.parentNode, null)
231
+
232
+ return [
233
+ parseInt(style.getPropertyValue('width'), 10),
234
+ parseInt(style.getPropertyValue('height'), 10)
235
+ ]
236
+ },
237
+ elementTouchDown(e) {
238
+ eventsFor = events.touch
239
+
240
+ this.elementDown(e)
241
+ },
242
+ elementMouseDown(e) {
243
+ eventsFor = events.mouse
244
+
245
+ this.elementDown(e)
246
+ },
247
+ elementDown(e) {
248
+ if (e instanceof MouseEvent && e.button !== 0) {
249
+ return
250
+ }
251
+
252
+ const target = e.target || e.srcElement
253
+
254
+ if (this.$el.contains(target)) {
255
+ if (
256
+ (this.dragHandle &&
257
+ !matchesSelectorToParentElements(
258
+ target,
259
+ this.dragHandle,
260
+ this.$el
261
+ )) ||
262
+ (this.dragCancel &&
263
+ matchesSelectorToParentElements(target, this.dragCancel, this.$el))
264
+ ) {
265
+ this.dragging = false
266
+
267
+ return
268
+ }
269
+
270
+ if (!this.enabled) {
271
+ this.enabled = true
272
+
273
+ this.$emit('activated')
274
+ this.$emit('update:active', true)
275
+ }
276
+
277
+ if (this.draggable) {
278
+ this.dragEnable = true
279
+ }
280
+
281
+ const newPosition = {
282
+ ...this.mouseClickPosition,
283
+ mouseX: e.touches ? e.touches[0].pageX : e.pageX,
284
+ left: this.left,
285
+ right: this.right
286
+ }
287
+
288
+ this.mouseClickPosition = newPosition
289
+ this.bounds = this.calcDragLimits()
290
+
291
+ addEvent(document.documentElement, eventsFor.move, this.move)
292
+ addEvent(document.documentElement, eventsFor.stop, this.handleUp)
293
+ }
294
+ },
295
+ calcDragLimits() {
296
+ const limits = {
297
+ minLeft: null,
298
+ maxLeft: null,
299
+ minRight: null,
300
+ maxRight: null
301
+ }
302
+
303
+ limits.minLeft = 0
304
+ limits.maxLeft = this.parentWidth - this.width
305
+ limits.minRight = this.width
306
+ limits.maxRight = this.parentWidth
307
+
308
+ return limits
309
+ },
310
+ deselect(e) {
311
+ const target = e.target || e.srcElement
312
+ const regex = new RegExp(this.className + '-([trmbl]{2})', '')
313
+
314
+ if (!this.$el.contains(target) && !regex.test(target.className)) {
315
+ if (this.enabled && !this.preventDeactivation) {
316
+ this.enabled = false
317
+
318
+ this.$emit('deactivated')
319
+ this.$emit('update:active', false)
320
+ }
321
+
322
+ removeEvent(document.documentElement, eventsFor.move, this.handleResize)
323
+ }
324
+
325
+ this.resetBoundsAndMouseState()
326
+ },
327
+ handleTouchDown(handle, e) {
328
+ eventsFor = events.touch
329
+
330
+ this.handleDown(handle, e)
331
+ },
332
+ handleDown(handle, e) {
333
+ if (e instanceof MouseEvent && e.which !== 1) {
334
+ return
335
+ }
336
+
337
+ if (e.stopPropagation) e.stopPropagation()
338
+
339
+ this.handle = handle
340
+ this.resizeEnable = true
341
+
342
+ const newPosition = {
343
+ ...this.mouseClickPosition,
344
+ mouseX: e.touches ? e.touches[0].pageX : e.pageX,
345
+ left: this.left,
346
+ right: this.right
347
+ }
348
+
349
+ this.mouseClickPosition = newPosition
350
+ this.bounds = this.calcResizeLimits()
351
+
352
+ addEvent(document.documentElement, eventsFor.move, this.handleResize)
353
+ addEvent(document.documentElement, eventsFor.stop, this.handleUp)
354
+ },
355
+ calcResizeLimits() {
356
+ const limits = {
357
+ minLeft: null,
358
+ maxLeft: null,
359
+ minRight: null,
360
+ maxRight: null
361
+ }
362
+
363
+ limits.minLeft = 0
364
+ limits.maxLeft = this.right - this.minWidthByPx
365
+ limits.minRight = this.left + this.minWidthByPx
366
+ limits.maxRight = this.parentWidth
367
+
368
+ return limits
369
+ },
370
+ move(e) {
371
+ if (this.resizing) {
372
+ this.handleResize(e)
373
+ } else if (this.dragEnable) {
374
+ this.handleDrag(e)
375
+ }
376
+ },
377
+ handleDrag(e) {
378
+ let left = this.left
379
+ let right = this.right
380
+ const bounds = this.bounds
381
+ const mouseClickPosition = this.mouseClickPosition
382
+
383
+ const tmpDeltaX =
384
+ mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
385
+
386
+ const deltaX = snapToGrid(this.parentWidth / this.subStepCount, tmpDeltaX)
387
+
388
+ left = restrictToBounds(
389
+ mouseClickPosition.left - deltaX,
390
+ bounds.minLeft,
391
+ bounds.maxLeft
392
+ )
393
+
394
+ right = restrictToBounds(
395
+ mouseClickPosition.right - deltaX,
396
+ bounds.minRight,
397
+ bounds.maxRight
398
+ )
399
+
400
+ this.left = left
401
+ this.right = right
402
+
403
+ this.$emit('dragging', this.left, this.right)
404
+ this.dragging = true
405
+ },
406
+ handleResize(e) {
407
+ let left = this.left
408
+ let right = this.right
409
+ const bounds = this.bounds
410
+ const mouseClickPosition = this.mouseClickPosition
411
+
412
+ const tmpDeltaX =
413
+ mouseClickPosition.mouseX - (e.touches ? e.touches[0].pageX : e.pageX)
414
+
415
+ if (!this.widthTouched && tmpDeltaX) {
416
+ this.widthTouched = true
417
+ }
418
+
419
+ const deltaX = snapToGrid(this.parentWidth / this.subStepCount, tmpDeltaX)
420
+
421
+ if (this.handle.includes('r')) {
422
+ right = restrictToBounds(
423
+ mouseClickPosition.right - deltaX,
424
+ bounds.minRight,
425
+ bounds.maxRight
426
+ )
427
+ } else if (this.handle.includes('l')) {
428
+ left = restrictToBounds(
429
+ mouseClickPosition.left - deltaX,
430
+ bounds.minLeft,
431
+ bounds.maxLeft
432
+ )
433
+ }
434
+
435
+ const width = computeWidth(left, right)
436
+
437
+ if (this.onResize(this.handle, left, width, this.height) === false) {
438
+ return
439
+ }
440
+
441
+ this.left = left
442
+ this.right = right
443
+ this.width = width
444
+
445
+ this.$emit('resizing', this.left, this.right)
446
+ this.resizing = true
447
+ },
448
+ handleUp() {
449
+ this.handle = null
450
+
451
+ this.dragEnable = false
452
+ this.resizeEnable = false
453
+
454
+ if (this.resizing) {
455
+ this.resizing = false
456
+ this.$emit('resizeStop', {
457
+ min: this.roundToNearestStep(this.left),
458
+ max: this.roundToNearestStep(this.right)
459
+ })
460
+ }
461
+
462
+ if (this.dragging) {
463
+ this.dragging = false
464
+ this.$emit('dragStop', {
465
+ min: this.roundToNearestStep(this.left),
466
+ max: this.roundToNearestStep(this.right)
467
+ })
468
+ }
469
+
470
+ removeEvent(document.documentElement, eventsFor.move, this.handleResize)
471
+ },
472
+ roundToNearestStep(value) {
473
+ const val = value / this.pxPerStep
474
+
475
+ const int = 1.0 / this.step
476
+ return (Math.round(val * int) / int).toFixed(2)
477
+ }
478
+ },
479
+ computed: {
480
+ style() {
481
+ return {
482
+ transform: `translate(${this.left}px, 0px)`,
483
+ width: this.computedWidth,
484
+ height: this.computedHeight,
485
+ zIndex: this.zIndex,
486
+ ...(this.dragging && this.disableUserSelect
487
+ ? userSelectNone
488
+ : userSelectAuto)
489
+ }
490
+ },
491
+ actualHandles() {
492
+ if (!this.resizable) return []
493
+
494
+ return this.handles
495
+ },
496
+ pxPerStep() {
497
+ return this.parentWidth / this.stepCount
498
+ },
499
+ minWidthByPx() {
500
+ return this.minWidth * this.pxPerStep
501
+ },
502
+ computedWidth() {
503
+ if (this.width === 'auto') {
504
+ if (!this.widthTouched) {
505
+ return 'auto'
506
+ }
507
+ }
508
+
509
+ return this.width + 'px'
510
+ },
511
+ computedHeight() {
512
+ if (this.height === 'auto') {
513
+ if (!this.heightTouched) {
514
+ return 'auto'
515
+ }
516
+ }
517
+
518
+ return this.height + 'px'
519
+ }
520
+ },
521
+
522
+ watch: {
523
+ active(val) {
524
+ this.enabled = val
525
+
526
+ if (val) {
527
+ this.$emit('activated')
528
+ } else {
529
+ this.$emit('deactivated')
530
+ }
531
+ },
532
+ z(val) {
533
+ if (val >= 0 || val === 'auto') {
534
+ this.zIndex = val
535
+ }
536
+ }
537
+ }
538
+ }
539
+ </script>
540
+ <style scoped>
541
+ .vdr {
542
+ touch-action: none;
543
+ position: absolute;
544
+ box-sizing: border-box;
545
+ border: 1px dashed black;
546
+ }
547
+ </style>