vueless 0.0.4 → 0.0.6

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/.eslintrc.js +7 -0
  2. package/package.json +3 -2
  3. package/postcss.config.js +1 -1
  4. package/src/service.storybook/index.js +91 -0
  5. package/src/service.tailwind/index.js +1 -1
  6. package/src/service.ui/index.js +1 -1
  7. package/src/ui.button/Docs.mdx +16 -0
  8. package/src/ui.button/composables/attrs.composable.js +41 -0
  9. package/src/ui.button/configs/default.config.js +165 -0
  10. package/src/ui.button/constants/index.js +5 -0
  11. package/src/ui.button/index.stories.js +166 -0
  12. package/src/ui.button/index.vue +151 -0
  13. package/src/ui.button-link/Docs.mdx +16 -0
  14. package/src/ui.button-link/composables/attrs.composable.js +99 -0
  15. package/src/ui.button-link/configs/default.config.js +80 -0
  16. package/src/ui.button-link/constants/index.js +5 -0
  17. package/src/ui.button-link/index.stories.js +158 -0
  18. package/src/ui.button-link/index.vue +226 -0
  19. package/src/ui.button-toggle/Docs.mdx +16 -0
  20. package/src/ui.button-toggle/composables/attrs.composable.js +16 -0
  21. package/src/ui.button-toggle/configs/default.config.js +12 -0
  22. package/src/ui.button-toggle/constants/index.js +7 -0
  23. package/src/ui.button-toggle/index.stories.js +155 -0
  24. package/src/ui.button-toggle/index.vue +128 -0
  25. package/src/ui.button-toggle-item/Docs.mdx +16 -0
  26. package/src/ui.button-toggle-item/composables/attrs.composable.js +53 -0
  27. package/src/ui.button-toggle-item/configs/default.config.js +58 -0
  28. package/src/ui.button-toggle-item/constants/index.js +5 -0
  29. package/src/ui.button-toggle-item/index.stories.js +77 -0
  30. package/src/ui.button-toggle-item/index.vue +147 -0
  31. package/src/ui.container-accordion/composables/attrs.composable.js +45 -0
  32. package/src/ui.container-accordion/configs/default.config.js +32 -0
  33. package/src/ui.container-accordion/constants/index.js +5 -0
  34. package/src/ui.container-accordion/index.stories.js +89 -0
  35. package/src/ui.container-accordion/index.vue +95 -0
  36. package/src/ui.container-card/Docs.mdx +16 -0
  37. package/src/ui.container-card/composable/attrs.composable.js +56 -0
  38. package/src/ui.container-card/configs/default.config.js +31 -0
  39. package/src/ui.container-card/constants/index.js +5 -0
  40. package/src/ui.container-card/index.stories.js +170 -0
  41. package/src/ui.container-card/index.vue +146 -0
  42. package/src/ui.container-divider/Docs.mdx +16 -0
  43. package/src/ui.container-divider/configs/default.config.js +79 -0
  44. package/src/ui.container-divider/index.stories.js +124 -0
  45. package/src/ui.container-group/Docs.mdx +16 -0
  46. package/src/ui.container-group/composables/attrs.composable.js +44 -0
  47. package/src/ui.container-group/configs/default.config.js +29 -0
  48. package/src/ui.container-group/constants/index.js +5 -0
  49. package/src/ui.container-group/index.stories.js +88 -0
  50. package/src/ui.container-group/index.vue +106 -0
  51. package/src/ui.container-groups/Docs.mdx +16 -0
  52. package/src/ui.container-groups/composables/attrs.composable.js +12 -0
  53. package/src/ui.container-groups/configs/default.config.js +3 -0
  54. package/src/ui.container-groups/index.stories.js +45 -0
  55. package/src/ui.container-groups/index.vue +33 -0
  56. package/src/ui.container-modal/Docs.mdx +16 -0
  57. package/src/ui.container-modal/composables/attrs.composable.js +90 -0
  58. package/src/ui.container-modal/configs/default.config.js +69 -0
  59. package/src/ui.container-modal/constants/index.js +5 -0
  60. package/src/ui.container-modal/index.stories.js +170 -0
  61. package/src/ui.container-modal/index.vue +336 -0
  62. package/src/ui.container-modal-confirm/Docs.mdx +16 -0
  63. package/src/ui.container-modal-confirm/composable/attrs.composable.js +20 -0
  64. package/src/ui.container-modal-confirm/configs/default.config.js +15 -0
  65. package/src/ui.container-modal-confirm/constants/index.js +5 -0
  66. package/src/ui.container-modal-confirm/index.stories.js +209 -0
  67. package/src/ui.container-modal-confirm/index.vue +182 -0
  68. package/src/ui.container-page/Docs.mdx +16 -0
  69. package/src/ui.container-page/composables/attrs.composable.js +96 -0
  70. package/src/ui.container-page/configs/default.config.js +71 -0
  71. package/src/ui.container-page/constants/index.js +5 -0
  72. package/src/ui.container-page/index.stories.js +147 -0
  73. package/src/ui.container-page/index.vue +275 -0
  74. package/src/ui.container-row/Docs.mdx +16 -0
  75. package/src/ui.container-row/composables/attrs.composable.js +23 -0
  76. package/src/ui.container-row/configs/default.config.js +14 -0
  77. package/src/ui.container-row/constants/index.js +5 -0
  78. package/src/ui.container-row/index.stories.js +81 -0
  79. package/src/ui.container-row/index.vue +45 -0
  80. package/src/ui.data-list/composables/attrs.composable.js +45 -0
  81. package/src/ui.data-list/configs/default.config.js +32 -0
  82. package/src/ui.data-list/constants/index.js +5 -0
  83. package/src/ui.data-list/index.stories.js +91 -0
  84. package/src/ui.data-list/index.vue +259 -0
  85. package/src/ui.data-table/Docs.mdx +16 -0
  86. package/src/ui.data-table/index.vue +5 -0
  87. package/src/ui.data-table-cell/configs/default.config.js +19 -0
  88. package/src/ui.dropdown-badge/Docs.mdx +16 -0
  89. package/src/ui.dropdown-badge/composables/attrs.composable.js +63 -0
  90. package/src/ui.dropdown-badge/configs/default.config.js +34 -0
  91. package/src/ui.dropdown-badge/constants/index.js +5 -0
  92. package/src/ui.dropdown-badge/index.stories.js +126 -0
  93. package/src/ui.dropdown-badge/index.vue +234 -0
  94. package/src/ui.dropdown-button/Docs.mdx +16 -0
  95. package/src/ui.dropdown-button/composables/attrs.composable.js +63 -0
  96. package/src/ui.dropdown-button/configs/default.config.js +37 -0
  97. package/src/ui.dropdown-button/constants/index.js +14 -0
  98. package/src/ui.dropdown-button/index.stories.js +158 -0
  99. package/src/ui.dropdown-button/index.vue +271 -0
  100. package/src/ui.dropdown-item/Docs.mdx +16 -0
  101. package/src/ui.dropdown-item/composables/attrs.composable.js +13 -0
  102. package/src/ui.dropdown-item/configs/default.config.js +16 -0
  103. package/src/ui.dropdown-item/index.stories.js +30 -0
  104. package/src/ui.dropdown-item/index.vue +53 -0
  105. package/src/ui.dropdown-link/Docs.mdx +16 -0
  106. package/src/ui.dropdown-link/composables/attrs.composable.js +65 -0
  107. package/src/ui.dropdown-link/configs/default.config.js +37 -0
  108. package/src/ui.dropdown-link/constants/index.js +5 -0
  109. package/src/ui.dropdown-link/index.stories.js +127 -0
  110. package/src/ui.dropdown-link/index.vue +261 -0
  111. package/src/ui.dropdown-list/Docs.mdx +16 -0
  112. package/src/ui.dropdown-list/composables/attrs.composable.js +93 -0
  113. package/src/ui.dropdown-list/composables/usePointer.js +77 -0
  114. package/src/ui.dropdown-list/configs/default.config.js +74 -0
  115. package/src/ui.dropdown-list/constants/index.js +5 -0
  116. package/src/ui.dropdown-list/index.stories.js +76 -0
  117. package/src/ui.dropdown-list/index.vue +284 -0
  118. package/src/ui.form-calendar/Docs.mdx +52 -0
  119. package/src/ui.form-calendar/components/DayView.vue +268 -0
  120. package/src/ui.form-calendar/components/MonthView.vue +114 -0
  121. package/src/ui.form-calendar/components/YearView.vue +118 -0
  122. package/src/ui.form-calendar/constants/index.js +71 -0
  123. package/src/ui.form-calendar/index.stories.js +59 -0
  124. package/src/ui.form-calendar/index.vue +743 -0
  125. package/src/ui.form-calendar/services/calendar.service.js +189 -0
  126. package/src/ui.form-calendar/services/formatting.service.js +180 -0
  127. package/src/ui.form-checkbox/Docs.mdx +16 -0
  128. package/src/ui.form-checkbox/configs/default.config.js +69 -0
  129. package/src/ui.form-checkbox/index.stories.js +147 -0
  130. package/src/ui.form-checkbox/index.vue +3 -2
  131. package/src/ui.form-checkbox-group/Docs.mdx +16 -0
  132. package/src/ui.form-checkbox-group/composables/attrs.composable.js +17 -0
  133. package/src/ui.form-checkbox-group/configs/default.config.js +5 -0
  134. package/src/ui.form-checkbox-group/constants/index.js +5 -0
  135. package/src/ui.form-checkbox-group/index.stories.js +45 -0
  136. package/src/ui.form-checkbox-group/index.vue +145 -0
  137. package/src/ui.form-checkbox-multi-state/Docs.mdx +16 -0
  138. package/src/ui.form-checkbox-multi-state/composables/attrs.composable.js +24 -0
  139. package/src/ui.form-checkbox-multi-state/configs/default.config.js +9 -0
  140. package/src/ui.form-checkbox-multi-state/constants/index.js +5 -0
  141. package/src/ui.form-checkbox-multi-state/index.stories.js +59 -0
  142. package/src/ui.form-checkbox-multi-state/index.vue +134 -0
  143. package/src/ui.form-color-picker/composables/attrs.composable.js +44 -0
  144. package/src/ui.form-color-picker/configs/default.config.js +52 -0
  145. package/src/ui.form-color-picker/constants/index.js +5 -0
  146. package/src/ui.form-color-picker/index.stories.js +63 -0
  147. package/src/ui.form-color-picker/index.vue +171 -0
  148. package/src/ui.form-date-picker/Docs.mdx +52 -0
  149. package/src/ui.form-date-picker/composables/attrs.composable.js +22 -0
  150. package/src/ui.form-date-picker/configs/default.config.js +26 -0
  151. package/src/ui.form-date-picker/constants/index.js +5 -0
  152. package/src/ui.form-date-picker/index.stories.js +132 -0
  153. package/src/ui.form-date-picker/index.vue +256 -0
  154. package/src/ui.form-date-picker-range/constants/index.js +23 -0
  155. package/src/ui.form-date-picker-range/index.stories.js +135 -0
  156. package/src/ui.form-date-picker-range/index.vue +937 -0
  157. package/src/ui.form-date-picker-range/services/dateRange.service.js +116 -0
  158. package/src/ui.form-input/Docs.mdx +16 -0
  159. package/src/ui.form-input/assets/fonts/text-security-disc.woff +0 -0
  160. package/src/ui.form-input/composables/attrs.composable.js +66 -0
  161. package/src/ui.form-input/configs/default.config.js +72 -0
  162. package/src/ui.form-input/constants/index.js +5 -0
  163. package/src/ui.form-input/index.stories.js +166 -0
  164. package/src/ui.form-input/index.vue +388 -0
  165. package/src/ui.form-input-file/composables/attrs.composable.js +82 -0
  166. package/src/ui.form-input-file/configs/default.config.js +59 -0
  167. package/src/ui.form-input-file/constants/index.js +5 -0
  168. package/src/ui.form-input-file/index.stories.js +86 -0
  169. package/src/ui.form-input-file/index.vue +387 -0
  170. package/src/ui.form-input-money/Docs.mdx +16 -0
  171. package/src/ui.form-input-money/composables/attrs.composable.js +13 -0
  172. package/src/ui.form-input-money/composables/useFormatCurrency.js +82 -0
  173. package/src/ui.form-input-money/configs/default.config.js +16 -0
  174. package/src/ui.form-input-money/constants/index.js +5 -0
  175. package/src/ui.form-input-money/index.stories.js +126 -0
  176. package/src/ui.form-input-money/index.vue +263 -0
  177. package/src/ui.form-input-money/services/format.service.js +72 -0
  178. package/src/ui.form-input-number/Docs.mdx +16 -0
  179. package/src/ui.form-input-number/composables/attrs.composable.js +47 -0
  180. package/src/ui.form-input-number/configs/default.config.js +33 -0
  181. package/src/ui.form-input-number/constants/index.js +5 -0
  182. package/src/ui.form-input-number/index.stories.js +103 -0
  183. package/src/ui.form-input-number/index.vue +162 -0
  184. package/src/ui.form-input-rating/composables/attrs.composable.js +34 -0
  185. package/src/ui.form-input-rating/constants/index.js +5 -0
  186. package/src/ui.form-input-rating/index.vue +1 -0
  187. package/src/ui.form-input-search/composables/attrs.composable.js +21 -0
  188. package/src/ui.form-input-search/configs/default.config.js +20 -0
  189. package/src/ui.form-input-search/constants/index.js +5 -0
  190. package/src/ui.form-input-search/index.stories.js +90 -0
  191. package/src/ui.form-input-search/index.vue +215 -0
  192. package/src/ui.form-label/Docs.mdx +16 -0
  193. package/src/ui.form-label/composables/attrs.composable.js +65 -0
  194. package/src/ui.form-label/configs/default.config.js +95 -0
  195. package/src/ui.form-label/constants/index.js +13 -0
  196. package/src/ui.form-label/index.stories.js +107 -0
  197. package/src/ui.form-label/index.vue +170 -0
  198. package/src/ui.form-radio/Docs.mdx +16 -0
  199. package/src/ui.form-radio/composables/attrs.composable.js +34 -0
  200. package/src/ui.form-radio/configs/default.config.js +47 -0
  201. package/src/ui.form-radio/constants/index.js +5 -0
  202. package/src/ui.form-radio/index.stories.js +71 -0
  203. package/src/ui.form-radio/index.vue +170 -0
  204. package/src/ui.form-radio-card/Docs.mdx +16 -0
  205. package/src/ui.form-radio-card/constants/index.js +5 -0
  206. package/src/ui.form-radio-card/index.stories.js +149 -0
  207. package/src/ui.form-radio-card/index.vue +1 -0
  208. package/src/ui.form-radio-card/services/variant.service.js +15 -0
  209. package/src/ui.form-radio-group/Docs.mdx +16 -0
  210. package/src/ui.form-radio-group/composables/attrs.composable.js +27 -0
  211. package/src/ui.form-radio-group/configs/default.config.js +18 -0
  212. package/src/ui.form-radio-group/constants/index.js +5 -0
  213. package/src/ui.form-radio-group/index.stories.js +42 -0
  214. package/src/ui.form-radio-group/index.vue +127 -0
  215. package/src/ui.form-select/Docs.mdx +16 -0
  216. package/src/ui.form-select/composables/attrs.composable.js +172 -0
  217. package/src/ui.form-select/configs/default.config.js +138 -0
  218. package/src/ui.form-select/constants/index.js +19 -0
  219. package/src/ui.form-select/index.stories.js +339 -0
  220. package/src/ui.form-select/index.vue +722 -0
  221. package/src/ui.form-select/services/select.service.js +98 -0
  222. package/src/ui.form-switch/composables/attrs.composable.js +77 -0
  223. package/src/ui.form-switch/configs/default.config.js +76 -0
  224. package/src/ui.form-switch/constants/index.js +5 -0
  225. package/src/ui.form-switch/index.stories.js +93 -0
  226. package/src/ui.form-switch/index.vue +199 -0
  227. package/src/ui.form-switch/services/variant.service.js +31 -0
  228. package/src/ui.form-textarea/Docs.mdx +16 -0
  229. package/src/ui.form-textarea/composables/attrs.composable.js +52 -0
  230. package/src/ui.form-textarea/configs/default.config.js +68 -0
  231. package/src/ui.form-textarea/constants/index.js +5 -0
  232. package/src/ui.form-textarea/index.stories.js +151 -0
  233. package/src/ui.form-textarea/index.vue +284 -0
  234. package/src/ui.image-avatar/composables/attrs.composable.js +34 -0
  235. package/src/ui.image-avatar/configs/default.config.js +42 -0
  236. package/src/ui.image-avatar/constants/index.js +5 -0
  237. package/src/ui.image-avatar/default-avatar.png +0 -0
  238. package/src/ui.image-avatar/index.stories.js +107 -0
  239. package/src/ui.image-avatar/index.vue +121 -0
  240. package/src/ui.image-icon/Docs.mdx +16 -0
  241. package/src/ui.image-icon/index.stories.js +110 -0
  242. package/src/ui.image-logo/configs/default.config.js +38 -0
  243. package/src/ui.image-logo/index.stories.js +84 -0
  244. package/src/ui.loader-top/components/TopProgress.vue +277 -0
  245. package/src/ui.navigation-pagination/composables/attrs.composable.js +41 -0
  246. package/src/ui.navigation-pagination/configs/default.config.js +24 -0
  247. package/src/ui.navigation-pagination/constants/index.js +8 -0
  248. package/src/ui.navigation-pagination/index.stories.js +52 -0
  249. package/src/ui.navigation-pagination/index.vue +276 -0
  250. package/src/ui.navigation-stepper/composables/attrs.composable.js +25 -0
  251. package/src/ui.navigation-stepper/configs/default.config.js +13 -0
  252. package/src/ui.navigation-stepper/constants/index.js +5 -0
  253. package/src/ui.navigation-stepper/index.stories.js +30 -0
  254. package/src/ui.navigation-stepper/index.vue +126 -0
  255. package/src/ui.navigation-tab/composables/attrs.composable.js +30 -0
  256. package/src/ui.navigation-tab/configs/default.config.js +22 -0
  257. package/src/ui.navigation-tab/constants/index.js +5 -0
  258. package/src/ui.navigation-tab/index.stories.js +57 -0
  259. package/src/ui.navigation-tab/index.vue +85 -0
  260. package/src/ui.navigation-tabs/composables/attrs.composable.js +24 -0
  261. package/src/ui.navigation-tabs/configs/default.config.js +14 -0
  262. package/src/ui.navigation-tabs/constants/index.js +5 -0
  263. package/src/ui.navigation-tabs/index.stories.js +69 -0
  264. package/src/ui.navigation-tabs/index.vue +99 -0
  265. package/src/ui.notify/index.stories.js +102 -0
  266. package/src/ui.other-dot/composables/attrs.composable.js +32 -0
  267. package/src/ui.other-dot/configs/default.config.js +21 -0
  268. package/src/ui.other-dot/constants/index.js +5 -0
  269. package/src/ui.other-dot/index.stories.js +77 -0
  270. package/src/ui.other-dot/index.vue +52 -0
  271. package/src/ui.other-loader/composables/attrs.composable.js +51 -0
  272. package/src/ui.other-loader/configs/default.config.js +47 -0
  273. package/src/ui.other-loader/constants/index.js +5 -0
  274. package/src/ui.other-loader/index.stories.js +78 -0
  275. package/src/ui.other-loader/index.vue +136 -0
  276. package/src/ui.text-alert/composables/attrs.composable.js +48 -0
  277. package/src/ui.text-alert/configs/default.config.js +51 -0
  278. package/src/ui.text-alert/constatns/index.js +5 -0
  279. package/src/ui.text-alert/index.stories.js +157 -0
  280. package/src/ui.text-alert/index.vue +122 -0
  281. package/src/ui.text-badge/Docs.mdx +16 -0
  282. package/src/ui.text-badge/composables/attrs.composable.js +49 -0
  283. package/src/ui.text-badge/configs/default.config.js +51 -0
  284. package/src/ui.text-badge/constants/index.js +5 -0
  285. package/src/ui.text-badge/index.stories.js +190 -0
  286. package/src/ui.text-badge/index.vue +120 -0
  287. package/src/ui.text-block/composables/attrs.composable.js +31 -0
  288. package/src/ui.text-block/configs/default.config.js +35 -0
  289. package/src/ui.text-block/constatns/index.js +5 -0
  290. package/src/ui.text-block/index.stories.js +112 -0
  291. package/src/ui.text-block/index.vue +76 -0
  292. package/src/ui.text-empty/Docs.mdx +16 -0
  293. package/src/ui.text-empty/configs/default.config.js +30 -0
  294. package/src/ui.text-empty/index.stories.js +106 -0
  295. package/src/ui.text-empty/index.vue +1 -0
  296. package/src/ui.text-file/composables/attrs.composable.js +37 -0
  297. package/src/ui.text-file/configs/default.config.js +15 -0
  298. package/src/ui.text-file/index.stories.js +29 -0
  299. package/src/ui.text-file/index.vue +93 -0
  300. package/src/ui.text-files/composables/attrs.composable.js +19 -0
  301. package/src/ui.text-files/configs/default.config.js +9 -0
  302. package/src/ui.text-files/constants/index.js +5 -0
  303. package/src/ui.text-files/index.stories.js +32 -0
  304. package/src/ui.text-files/index.vue +87 -0
  305. package/src/ui.text-header/Docs.mdx +16 -0
  306. package/src/ui.text-header/composables/attrs.composable.js +34 -0
  307. package/src/ui.text-header/constants/index.js +5 -0
  308. package/src/ui.text-header/index.stories.js +106 -0
  309. package/src/ui.text-header/index.vue +83 -0
  310. package/src/ui.text-money/Docs.mdx +16 -0
  311. package/src/ui.text-money/assets/credit.svg +7 -0
  312. package/src/ui.text-money/assets/debit.svg +12 -0
  313. package/src/ui.text-money/composables/attrs.composable.js +65 -0
  314. package/src/ui.text-money/constants/index.js +7 -0
  315. package/src/ui.text-money/index.stories.js +265 -0
  316. package/src/ui.text-money/index.vue +204 -0
  317. package/src/ui.text-money/services/money.services.js +24 -0
  318. package/src/ui.viewport/index.vue +78 -0
  319. package/vite.config.mjs +5 -4
  320. package/web-types.json +1 -1
  321. package/.web-types-gen/package.json +0 -3
@@ -0,0 +1,937 @@
1
+ <template>
2
+ <div>
3
+ <UInput
4
+ v-if="isVariant.input"
5
+ :id="id"
6
+ v-model="userFormatDate"
7
+ :label="label"
8
+ :placeholder="placeholder"
9
+ :error="error"
10
+ :description="description"
11
+ readonly
12
+ :disabled="disabled"
13
+ :size="size"
14
+ v-bind="inputAttrs"
15
+ @focus="activate"
16
+ >
17
+ <template #left>
18
+ <slot name="left" />
19
+ </template>
20
+
21
+ <template #right-icon>
22
+ <slot name="right-icon" />
23
+ </template>
24
+
25
+ <template #right>
26
+ <slot name="right" />
27
+ </template>
28
+ </UInput>
29
+
30
+ <div v-if="isVariant.button" v-bind="buttonWrapperAttrs">
31
+ <UButton
32
+ :disabled="disabled"
33
+ :size="size"
34
+ v-bind="shiftRangeButtonAttrs"
35
+ @click="onClickShiftRange('prev')"
36
+ >
37
+ <UIcon interactive size="sm" :name="config.prevIconName" v-bind="prevIconAttrs" />
38
+ </UButton>
39
+
40
+ <UButton
41
+ :id="id"
42
+ :disabled="disabled"
43
+ :size="size"
44
+ :label="userFormatDate"
45
+ v-bind="buttonAttrs"
46
+ @click="activate"
47
+ />
48
+
49
+ <UButton
50
+ :disabled="disabled"
51
+ :size="size"
52
+ v-bind="shiftRangeButtonAttrs"
53
+ @click="onClickShiftRange('next')"
54
+ >
55
+ <UIcon interactive size="sm" :name="config.nextIconName" v-bind="nextIconAttrs" />
56
+ </UButton>
57
+ </div>
58
+
59
+ <Transition v-bind="config.menuTransition">
60
+ <div
61
+ v-if="isShownMenu"
62
+ ref="menuRef"
63
+ tabindex="-1"
64
+ v-bind="menuAttrs"
65
+ @blur="onBlur"
66
+ @keydown.esc="deactivate"
67
+ @mouseleave="onMouseoutMenu"
68
+ >
69
+ <div v-bind="periodsRowAttrs">
70
+ <div
71
+ v-for="periodButton in periods"
72
+ :key="periodButton.name"
73
+ v-bind="periodButtonAttrs(getPeriodButtonsClasses(periodButton.name))"
74
+ @click="onClickPeriodButton(periodButton.name)"
75
+ >
76
+ {{ periodButton.title }}
77
+ </div>
78
+ </div>
79
+
80
+ <div v-bind="periodsRowAttrs">
81
+ <div
82
+ v-if="customRangeButton.range.to && customRangeButton.range.from"
83
+ v-bind="periodButtonAttrs(getPeriodButtonsClasses(PERIOD.custom))"
84
+ @click="onClickCustomRangeButton"
85
+ >
86
+ {{ customRangeButton.label }}
87
+ <span v-if="customRangeButton.description" v-text="customRangeButton.description" />
88
+ </div>
89
+
90
+ <div
91
+ v-bind="periodButtonAttrs(getPeriodButtonsClasses(PERIOD.ownRange))"
92
+ @click="onClickOwnRange"
93
+ >
94
+ <UIcon name="apps" size="xs" />
95
+
96
+ {{ locale.ownRange }}
97
+ </div>
98
+ </div>
99
+
100
+ <template v-if="!isPeriod.ownRange && !isPeriod.custom">
101
+ <div v-bind="rangeSwitchWrapperAttrs">
102
+ <UIcon
103
+ interactive
104
+ color="grayscale"
105
+ size="sm"
106
+ :name="config.prevIconName"
107
+ v-bind="prevIconAttrs"
108
+ @click="onClickShiftDatesList('prev')"
109
+ />
110
+
111
+ <div v-bind="rangeSwitchTitleAttrs">
112
+ {{ rangeSwitchTitle }}
113
+ </div>
114
+ <UIcon
115
+ interactive
116
+ class="icon"
117
+ size="sm"
118
+ :name="config.nextIconName"
119
+ v-bind="nextIconAttrs"
120
+ @click="onClickShiftDatesList('next')"
121
+ />
122
+ </div>
123
+
124
+ <div v-bind="periodDateListAttrs(getPeriodDateListClasses())">
125
+ <button
126
+ v-for="date in periodDateList"
127
+ :key="date.title"
128
+ :disabled="isDatePeriodOutOfRange(date)"
129
+ v-bind="periodDateAttrs(getPeriodDateClasses(date))"
130
+ @click="selectDate(date), toggleMenu()"
131
+ >
132
+ {{ date.title }}
133
+ </button>
134
+ </div>
135
+ </template>
136
+
137
+ <div v-if="isPeriod.ownRange" v-bind="rangeInputWrapperAttrs">
138
+ <UInput
139
+ ref="rangeInputStartRef"
140
+ v-model="rangeStart"
141
+ :error="inputRangeStartError"
142
+ v-bind="rangeInputAttrs"
143
+ :name="rangeInputName"
144
+ @input="onInputRangeInput($event, INPUT_RANGE_TYPE.start)"
145
+ @blur="onBlurRangeInput"
146
+ />
147
+
148
+ <UInput
149
+ ref="rangeInputEndRef"
150
+ v-model="rangeEnd"
151
+ :error="inputRangeEndError"
152
+ v-bind="rangeInputAttrs"
153
+ :name="rangeInputName"
154
+ @input="onInputRangeInput($event, INPUT_RANGE_TYPE.end)"
155
+ @blur="onBlurRangeInput"
156
+ />
157
+ </div>
158
+
159
+ <div v-bind="inputRangeErrorAttrs">
160
+ {{ inputRangeEndError || inputRangeStartError }}
161
+ </div>
162
+
163
+ <UCalendar
164
+ v-if="isPeriod.ownRange"
165
+ v-model="calendarValue"
166
+ :min-date="minDate"
167
+ :max-date="maxDate"
168
+ v-bind="calendarAttrs"
169
+ :date-format="RANGE_INPUT_FORMAT"
170
+ range
171
+ @mouseenter="onMouseoverCalendar"
172
+ />
173
+ </div>
174
+ </Transition>
175
+ </div>
176
+ </template>
177
+
178
+ <script setup>
179
+ import { computed, watch, ref, nextTick } from "vue";
180
+ import { useStore } from "vuex";
181
+
182
+ import UIcon from "../ui.image-icon";
183
+ import UInput from "../ui.form-input";
184
+ import UButton from "../ui.button";
185
+ import UCalendar from "../ui.form-calendar";
186
+ import { LOCALE_TYPE } from "../ui.form-calendar/constants";
187
+
188
+ import UIService, { getRandomId } from "../service.ui";
189
+
190
+ import {
191
+ addDays,
192
+ gmtToUTC,
193
+ getUnixTimestampFromDate,
194
+ addMonths,
195
+ addYears,
196
+ getDateFromUnixTimestamp,
197
+ getSortedLocale,
198
+ utcToGMT,
199
+ getEndOfMonth,
200
+ getEndOfQuarter,
201
+ getEndOfWeek,
202
+ getEndOfYear,
203
+ getStartOfMonth,
204
+ getStartOfQuarter,
205
+ getStartOfWeek,
206
+ getStartOfYear,
207
+ getDatesDifference,
208
+ } from "../ui.form-calendar/services/date.service";
209
+
210
+ import {
211
+ dateIsOutOfRange,
212
+ formatDate,
213
+ parseDate,
214
+ } from "../ui.form-calendar/services/calendar.service";
215
+
216
+ import {
217
+ getWeekDateList,
218
+ getYearDateList,
219
+ getQuartersDateList,
220
+ getMonthsDateList,
221
+ } from "./services/dateRange.service";
222
+
223
+ import { wrongDateFormat, wrongMonthNumber, wrongDayNumber } from "./services/validation.service";
224
+ import useAttrs from "./composables/attrs.composable";
225
+ import defaultConfig from "./configs/default.config";
226
+ import {
227
+ UDatePickerRange,
228
+ DATE_PICKER_BUTTON_TYPE,
229
+ DATE_PICKER_INPUT_TYPE,
230
+ PERIOD,
231
+ RANGE_INPUT_FORMAT,
232
+ INPUT_RANGE_TYPE,
233
+ } from "./constants";
234
+
235
+ /* Should be a string for correct web-types gen */
236
+ defineOptions({ name: "UDatePickerRange", inheritAttrs: false });
237
+
238
+ const props = defineProps({
239
+ /**
240
+ * Dater picker range value as object with from and to keys (timestamp).
241
+ */
242
+ modelValue: {
243
+ type: Object,
244
+ default: () => ({
245
+ from: null,
246
+ to: null,
247
+ }),
248
+ },
249
+
250
+ /**
251
+ * Custom range button.
252
+ */
253
+ customRangeButton: {
254
+ type: Object,
255
+ default: () => UIService.get(defaultConfig, UDatePickerRange).default.customRangeButton,
256
+ },
257
+
258
+ /**
259
+ * The variant of the date picker.
260
+ * @values button, input
261
+ */
262
+ variant: {
263
+ type: String,
264
+ default: UIService.get(defaultConfig, UDatePickerRange).default.variant,
265
+ },
266
+
267
+ /**
268
+ * Min date in format date string or Date.
269
+ */
270
+ minDate: {
271
+ type: [String, Date],
272
+ default: UIService.get(defaultConfig, UDatePickerRange).default.minDate,
273
+ },
274
+
275
+ /**
276
+ * Max date in format date string or Date.
277
+ */
278
+ maxDate: {
279
+ type: [String, Date],
280
+ default: UIService.get(defaultConfig, UDatePickerRange).default.maxDate,
281
+ },
282
+
283
+ /**
284
+ * Datepicker size.
285
+ * @values sm, md, lg
286
+ */
287
+ size: {
288
+ type: String,
289
+ default: UIService.get(defaultConfig, UDatePickerRange).default.size,
290
+ },
291
+
292
+ /**
293
+ * Label text for input type.
294
+ */
295
+ label: {
296
+ type: String,
297
+ default: "",
298
+ },
299
+
300
+ /**
301
+ * Input placeholder for input type.
302
+ */
303
+ placeholder: {
304
+ type: String,
305
+ default: "",
306
+ },
307
+
308
+ /**
309
+ * Datepicker description for input type.
310
+ */
311
+ description: {
312
+ type: String,
313
+ default: "",
314
+ },
315
+
316
+ /**
317
+ * Error message for input type.
318
+ */
319
+ error: {
320
+ type: String,
321
+ default: "",
322
+ },
323
+
324
+ /**
325
+ * Disable component.
326
+ */
327
+ disabled: {
328
+ type: Boolean,
329
+ default: UIService.get(defaultConfig, UDatePickerRange).default.disabled,
330
+ },
331
+
332
+ /**
333
+ * Unique element id.
334
+ * @ignore
335
+ */
336
+ id: {
337
+ type: String,
338
+ default: () => getRandomId(),
339
+ },
340
+
341
+ /**
342
+ * Component ui config object.
343
+ */
344
+ config: {
345
+ type: Object,
346
+ default: () => ({}),
347
+ },
348
+
349
+ /**
350
+ * Data-cy attribute for automated testing.
351
+ */
352
+ dataCy: {
353
+ type: String,
354
+ default: "",
355
+ },
356
+ });
357
+
358
+ const emit = defineEmits(["update:modelValue"]);
359
+
360
+ const isShownMenu = ref(false);
361
+
362
+ const {
363
+ config,
364
+ calendarAttrs,
365
+ inputAttrs,
366
+ menuAttrs,
367
+ periodsRowAttrs,
368
+ periodButtonAttrs,
369
+ rangeSwitchWrapperAttrs,
370
+ nextIconAttrs,
371
+ prevIconAttrs,
372
+ periodDateAttrs,
373
+ periodDateListAttrs,
374
+ rangeSwitchTitleAttrs,
375
+ buttonWrapperAttrs,
376
+ buttonAttrs,
377
+ shiftRangeButtonAttrs,
378
+ rangeInputAttrs,
379
+ rangeInputWrapperAttrs,
380
+ inputRangeErrorAttrs,
381
+ } = useAttrs(props, { isShownMenu });
382
+ const store = useStore();
383
+
384
+ const calendarValue = ref(props.modelValue);
385
+ const activeDate = ref(
386
+ props.modelValue.from !== null ? getDateFromUnixTimestamp(props.modelValue.from) : new Date(),
387
+ );
388
+ const period = ref(PERIOD.ownRange);
389
+ const periodDateList = ref(null);
390
+ const rangeStart = ref("");
391
+ const rangeEnd = ref("");
392
+ const inputRangeStartError = ref("");
393
+ const inputRangeEndError = ref("");
394
+ const isHoverEvent = ref(false);
395
+
396
+ const menuRef = ref(null);
397
+ const rangeInputStartRef = ref(null);
398
+ const rangeInputEndRef = ref(null);
399
+
400
+ const localValue = computed({
401
+ get: () => props.modelValue,
402
+ set: (value) => {
403
+ emit("update:modelValue", value);
404
+
405
+ activeDate.value = getDateFromUnixTimestamp(value.from || new Date());
406
+ },
407
+ });
408
+
409
+ const isMobileDevice = computed(() => store.getters["breakpoint/isMobileDevice"]);
410
+
411
+ const rangeInputName = computed(() => `rangeInput-${props.id}`);
412
+
413
+ const locale = computed(() => {
414
+ const currentLocale = props.config.i18n || config.value.i18n;
415
+ const formattedLocale = {
416
+ ...currentLocale,
417
+ months: {
418
+ shorthand: getSortedLocale(currentLocale.months.shorthand, LOCALE_TYPE.month),
419
+ longhand: getSortedLocale(currentLocale.months.longhand, LOCALE_TYPE.month),
420
+ },
421
+ weekdays: {
422
+ shorthand: getSortedLocale(currentLocale.weekdays.shorthand, LOCALE_TYPE.day),
423
+ longhand: getSortedLocale(currentLocale.weekdays.longhand, LOCALE_TYPE.day),
424
+ },
425
+ };
426
+
427
+ return formattedLocale;
428
+ });
429
+
430
+ const periods = computed(() => [
431
+ {
432
+ name: PERIOD.week,
433
+ title: locale.value.week,
434
+ },
435
+ {
436
+ name: PERIOD.month,
437
+ title: locale.value.month,
438
+ },
439
+ {
440
+ name: PERIOD.quarter,
441
+ title: locale.value.quarter,
442
+ },
443
+ {
444
+ name: PERIOD.year,
445
+ title: locale.value.year,
446
+ },
447
+ ]);
448
+
449
+ const isPeriod = computed(() => {
450
+ return {
451
+ week: period.value === PERIOD.week,
452
+ month: period.value === PERIOD.month,
453
+ quarter: period.value === PERIOD.quarter,
454
+ year: period.value === PERIOD.year,
455
+ ownRange: period.value === PERIOD.ownRange,
456
+ custom: period.value === PERIOD.custom,
457
+ };
458
+ });
459
+
460
+ const rangeSwitchTitle = computed(() => {
461
+ if (isPeriod.value.month || isPeriod.value.quarter) {
462
+ return String(activeDate.value.getFullYear());
463
+ }
464
+
465
+ if (isPeriod.value.year) {
466
+ return `${periodDateList.value.at(0).title} – ${periodDateList.value.at(-1).title}`;
467
+ }
468
+
469
+ if (isPeriod.value.week) {
470
+ return `${locale.value.months.longhand[activeDate.value.getMonth()]} ${activeDate.value.getFullYear()}`;
471
+ }
472
+
473
+ return "";
474
+ });
475
+
476
+ const isVariant = computed(() => ({
477
+ button: props.variant === DATE_PICKER_BUTTON_TYPE,
478
+ input: props.variant === DATE_PICKER_INPUT_TYPE,
479
+ }));
480
+
481
+ const userFormatDate = computed(() => {
482
+ if ((!localValue.value.from && !localValue.value.to) || !localValue.value.from) return "";
483
+
484
+ let title = "";
485
+
486
+ const isDefaultTitle = isPeriod.value.week || isPeriod.value.custom || isPeriod.value.ownRange;
487
+
488
+ const from = getDateFromUnixTimestamp(localValue.value.from);
489
+ const to = localValue.value.to !== null ? getDateFromUnixTimestamp(localValue.value.to) : null;
490
+
491
+ if (isDefaultTitle) {
492
+ let startMonthName = locale.value.months.longhand[from.getMonth()];
493
+ let startYear = from.getFullYear();
494
+ let endMonthName = locale.value.months.longhand[to?.getMonth()];
495
+ let endYear = to?.getFullYear();
496
+
497
+ if (startMonthName === endMonthName && endMonthName === endYear) {
498
+ startMonthName = "";
499
+ }
500
+
501
+ if (startYear.year === endYear) {
502
+ startYear = "";
503
+ }
504
+
505
+ const fromTitle = `${from.getDate()} ${startMonthName} ${startYear}`;
506
+ const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
507
+
508
+ title = `${fromTitle} – ${toTitle}`;
509
+ }
510
+
511
+ if (isPeriod.value.month) {
512
+ const startMonthName = locale.value.months.longhand[from.getMonth()];
513
+ const startYear = from.getFullYear();
514
+
515
+ title = `${startMonthName} ${startYear}`;
516
+ }
517
+
518
+ if (isPeriod.value.quarter || isPeriod.value.year) {
519
+ const startMonthName = locale.value.months.longhand[from.getMonth()];
520
+ const endMonthName = locale.value.months.longhand[to?.getMonth()];
521
+ const endYear = to?.getFullYear();
522
+
523
+ const fromTitle = `${from.getDate()} ${startMonthName}`;
524
+ const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
525
+
526
+ title = `${fromTitle} – ${toTitle}`;
527
+ }
528
+
529
+ if (isMobileDevice.value && !isPeriod.value.month && isVariant.value.button) {
530
+ const startDay = String(from.getDate()).padStart(2, "0");
531
+ const endDay = String(to?.getDate())?.padStart(2, "0");
532
+ const startMonth = String(from.getMonth()).padStart(2, "0");
533
+ const endMonth = String(to?.getMonth())?.padStart(2, "0");
534
+
535
+ const fromTitle = `${startDay}.${startMonth}`;
536
+ const toTitle = to ? `${endDay}.${endMonth} / ${to.getFullYear}` : "";
537
+
538
+ title = `${fromTitle} – ${toTitle}`;
539
+ }
540
+
541
+ return title;
542
+ });
543
+
544
+ watch(
545
+ calendarValue,
546
+ () => {
547
+ localValue.value = {
548
+ from:
549
+ calendarValue.value.from === null
550
+ ? calendarValue.value.from
551
+ : getUnixTimestampFromDate(gmtToUTC(getDateFromUnixTimestamp(calendarValue.value.from))),
552
+ to:
553
+ calendarValue.value.to === null
554
+ ? calendarValue.value.to
555
+ : getUnixTimestampFromDate(gmtToUTC(getDateFromUnixTimestamp(calendarValue.value.to))),
556
+ };
557
+
558
+ nextTick(() => menuRef.value?.focus());
559
+ },
560
+ { deep: true },
561
+ );
562
+
563
+ watch(
564
+ () => props.modelValue,
565
+ () => {
566
+ if (props.modelValue.to !== calendarValue.value.to) {
567
+ calendarValue.value.to = props.modelValue.to;
568
+ }
569
+
570
+ if (props.modelValue.from !== calendarValue.value.from) {
571
+ calendarValue.value.from = props.modelValue.from;
572
+ }
573
+
574
+ rangeStart.value = props.modelValue.from
575
+ ? formatDate(
576
+ getDateFromUnixTimestamp(props.modelValue.from),
577
+ RANGE_INPUT_FORMAT,
578
+ locale.value,
579
+ )
580
+ : "";
581
+
582
+ rangeEnd.value = props.modelValue.to
583
+ ? formatDate(getDateFromUnixTimestamp(props.modelValue.to), RANGE_INPUT_FORMAT, locale.value)
584
+ : "";
585
+
586
+ inputRangeStartError.value = "";
587
+ inputRangeEndError.value = "";
588
+ },
589
+ { deep: true, immediate: true },
590
+ );
591
+
592
+ watch(period, () => {
593
+ activeDate.value =
594
+ localValue.value.from !== null ? getDateFromUnixTimestamp(localValue.value.from) : new Date();
595
+ });
596
+
597
+ function onClickPeriodButton(periodName) {
598
+ const localDate =
599
+ localValue.value.from !== null ? getDateFromUnixTimestamp(localValue.value.from) : new Date();
600
+
601
+ if (periodName === PERIOD.week) {
602
+ periodDateList.value = getWeekDateList(localDate, config.value.i18n.months.shorthand);
603
+
604
+ period.value = PERIOD.week;
605
+ }
606
+
607
+ if (periodName === PERIOD.month) {
608
+ periodDateList.value = getMonthsDateList(localDate, locale.value.months.longhand);
609
+
610
+ period.value = PERIOD.month;
611
+ }
612
+
613
+ if (periodName === PERIOD.quarter) {
614
+ periodDateList.value = getQuartersDateList(localDate, locale.value.quarter);
615
+
616
+ period.value = PERIOD.quarter;
617
+ }
618
+
619
+ if (periodName === PERIOD.year) {
620
+ periodDateList.value = getYearDateList(localDate);
621
+
622
+ period.value = PERIOD.year;
623
+ }
624
+
625
+ selectDate(periodDateList.value.at(0));
626
+ }
627
+
628
+ function onClickOwnRange() {
629
+ period.value = PERIOD.ownRange;
630
+ }
631
+
632
+ function selectDate(date) {
633
+ localValue.value = {
634
+ from: date.startRange,
635
+ to: date.endRange,
636
+ };
637
+ }
638
+
639
+ function toggleMenu() {
640
+ isShownMenu.value = !isShownMenu.value;
641
+ }
642
+
643
+ function onClickCustomRangeButton() {
644
+ selectCustomRange();
645
+
646
+ isShownMenu.value = false;
647
+ period.value = PERIOD.custom;
648
+ }
649
+
650
+ function selectCustomRange() {
651
+ const from =
652
+ typeof props.customRangeButton.range.from === "number"
653
+ ? getDateFromUnixTimestamp(props.customRangeButton.range.from)
654
+ : props.customRangeButton.range.from;
655
+
656
+ const to =
657
+ typeof props.customRangeButton.range.to === "number"
658
+ ? getDateFromUnixTimestamp(props.customRangeButton.range.to)
659
+ : props.customRangeButton.range.to;
660
+
661
+ localValue.value = {
662
+ from: getUnixTimestampFromDate(gmtToUTC(from)),
663
+ to: getUnixTimestampFromDate(gmtToUTC(to)),
664
+ };
665
+ }
666
+
667
+ function isDatePeriodOutOfRange(datePeriod) {
668
+ return (
669
+ dateIsOutOfRange(
670
+ getDateFromUnixTimestamp(datePeriod.startRange),
671
+ props.minDate,
672
+ props.maxDate,
673
+ locale.value,
674
+ RANGE_INPUT_FORMAT,
675
+ ) ||
676
+ dateIsOutOfRange(
677
+ getDateFromUnixTimestamp(datePeriod.endRange),
678
+ props.minDate,
679
+ props.maxDate,
680
+ RANGE_INPUT_FORMAT,
681
+ )
682
+ );
683
+ }
684
+
685
+ function onClickShiftDatesList(action) {
686
+ const defaultRange = action === "prev" ? -1 : 1;
687
+ const yearRange = action === "prev" ? -12 : 12;
688
+
689
+ if (isPeriod.value.week) {
690
+ activeDate.value = addMonths(activeDate.value, defaultRange);
691
+ periodDateList.value = getWeekDateList(activeDate.value, config.value.i18n.months.shorthand);
692
+ }
693
+
694
+ if (isPeriod.value.month) {
695
+ activeDate.value = addYears(activeDate.value, defaultRange);
696
+ periodDateList.value = getMonthsDateList(activeDate.value, locale.value.months.longhand);
697
+ }
698
+
699
+ if (isPeriod.value.quarter) {
700
+ activeDate.value = addYears(activeDate.value, defaultRange);
701
+ periodDateList.value = getQuartersDateList(activeDate.value, locale.value.quarter);
702
+ }
703
+
704
+ if (isPeriod.value.year) {
705
+ activeDate.value = addYears(activeDate.value, yearRange);
706
+ periodDateList.value = getYearDateList(activeDate.value);
707
+ }
708
+ }
709
+
710
+ function getPeriodButtonsClasses(periodName) {
711
+ return period.value === periodName ? [config.value.periodButtonActive] : [];
712
+ }
713
+
714
+ function getPeriodDateClasses(date) {
715
+ return localValue.value.from === date.startRange ? [config.value.periodDateActive] : [];
716
+ }
717
+
718
+ function getPeriodDateListClasses() {
719
+ if (isPeriod.value.ownRange) return [];
720
+ if (isPeriod.value.week) return [config.value.periodDateWeekList];
721
+ if (isPeriod.value.month) return [config.value.periodDateMonthList];
722
+ if (isPeriod.value.quarter) return [config.value.periodDateQuarterList];
723
+ if (isPeriod.value.year) return [config.value.periodDateYearList];
724
+ }
725
+
726
+ function activate() {
727
+ isShownMenu.value = true;
728
+
729
+ nextTick(() => menuRef.value.focus());
730
+ }
731
+
732
+ function deactivate() {
733
+ isShownMenu.value = false;
734
+
735
+ isHoverEvent.value = false;
736
+ }
737
+
738
+ function onBlur(event) {
739
+ const { relatedTarget } = event;
740
+
741
+ if (!menuRef.value.contains(relatedTarget)) {
742
+ deactivate();
743
+ }
744
+ }
745
+
746
+ function onBlurRangeInput(event) {
747
+ const { relatedTarget } = event;
748
+
749
+ menuRef.value.focus();
750
+
751
+ if (!menuRef.value.contains(relatedTarget) && !isHoverEvent.value) {
752
+ deactivate();
753
+ }
754
+
755
+ isHoverEvent.value = false;
756
+ }
757
+
758
+ function onInputRangeInput(value, type) {
759
+ const isInvalidDateFormat = !wrongDateFormat(value);
760
+ const isInvalidMonthNumber = !wrongMonthNumber(value);
761
+ const isInvalidDayNumber = !wrongDayNumber(value);
762
+
763
+ let error = "";
764
+
765
+ if (isInvalidDateFormat && value) {
766
+ error = locale.value.dateFormatWithDot;
767
+ } else if (isInvalidMonthNumber && value) {
768
+ error = locale.value.notCorrectMonthNumber;
769
+ } else if (isInvalidDayNumber && value) {
770
+ error = locale.value.notCorrectDayNumber;
771
+ }
772
+
773
+ if (type === INPUT_RANGE_TYPE.start) {
774
+ inputRangeStartError.value = error;
775
+ }
776
+
777
+ if (type === INPUT_RANGE_TYPE.end) {
778
+ inputRangeEndError.value = error;
779
+ }
780
+
781
+ const parsedValue = gmtToUTC(parseDate(value || new Date(), RANGE_INPUT_FORMAT, locale.value));
782
+ const unixTimeValue = getUnixTimestampFromDate(parsedValue);
783
+ const isOutOfRange = dateIsOutOfRange(
784
+ parsedValue,
785
+ props.minDate,
786
+ props.maxDate,
787
+ locale.value,
788
+ RANGE_INPUT_FORMAT,
789
+ );
790
+ const isToLessThanFrom = unixTimeValue <= localValue.value.from;
791
+
792
+ if (type === INPUT_RANGE_TYPE.start && !error && !isOutOfRange) {
793
+ localValue.value.from = value ? unixTimeValue : "";
794
+ }
795
+
796
+ if (type === INPUT_RANGE_TYPE.end && !error && !isOutOfRange && !isToLessThanFrom) {
797
+ localValue.value.to = value ? unixTimeValue : "";
798
+ }
799
+ }
800
+
801
+ setDefaultPeriodForButton();
802
+
803
+ function setDefaultPeriodForButton() {
804
+ const from = utcToGMT(getDateFromUnixTimestamp(props.modelValue.to || new Date()));
805
+ const to = utcToGMT(getDateFromUnixTimestamp(props.modelValue.from || new Date()));
806
+
807
+ const isWeekPeriod =
808
+ String(from) === String(getStartOfWeek(from, { weekStartsOn: 1 })) &&
809
+ String(to) === String(getEndOfWeek(to, { weekStartsOn: 1 }));
810
+ const isMonthPeriod =
811
+ String(from) === String(getStartOfMonth(from)) &&
812
+ String(to) === String(getEndOfMonth(to)) &&
813
+ from.getMonth() === to.getMonth();
814
+ const isQuarterPeriod =
815
+ String(from) === String(getStartOfQuarter(from)) && String(to) === String(getEndOfQuarter(to));
816
+ const isYearPeriod =
817
+ String(from) === String(getStartOfYear(from)) && String(to) === String(getEndOfYear(to));
818
+
819
+ if (!props.modelValue.from && !props.modelValue.to) {
820
+ period.value = PERIOD.ownRange;
821
+ } else if (isYearPeriod) {
822
+ period.value = PERIOD.year;
823
+ } else if (isMonthPeriod) {
824
+ period.value = PERIOD.month;
825
+ } else if (isQuarterPeriod) {
826
+ period.value = PERIOD.quarter;
827
+ } else if (isWeekPeriod) {
828
+ period.value = PERIOD.week;
829
+ } else {
830
+ period.value = PERIOD.ownRange;
831
+ }
832
+ }
833
+
834
+ function onClickShiftRange(action) {
835
+ if (isPeriod.value.custom) {
836
+ period.value = PERIOD.ownRange;
837
+ }
838
+
839
+ const millisecondsPerSecond = 1000;
840
+ const secondsPerMinute = 60;
841
+ const minutesPerHour = 60;
842
+ const hoursPerDay = 24;
843
+
844
+ const millisecondsPerDay =
845
+ millisecondsPerSecond * secondsPerMinute * minutesPerHour * hoursPerDay;
846
+
847
+ const from = getDateFromUnixTimestamp(localValue.value.from);
848
+ const to = localValue.value.to ? getDateFromUnixTimestamp(localValue.value.to) : addDays(from, 1);
849
+ const daysDifference = Math.ceil(Math.abs(getDatesDifference(from, to)) / millisecondsPerDay);
850
+
851
+ if (action === "next") {
852
+ if (isPeriod.value.ownRange) {
853
+ const nextDate = {
854
+ to: getUnixTimestampFromDate(addDays(to, daysDifference)),
855
+ from: getUnixTimestampFromDate(addDays(from, daysDifference)),
856
+ };
857
+
858
+ if (isDatePeriodOutOfRange(nextDate)) return;
859
+
860
+ localValue.value = nextDate;
861
+ } else {
862
+ let nextDate = periodDateList.value.find((item) => item.endRange > localValue.value.to);
863
+
864
+ if (!nextDate) {
865
+ onClickShiftDatesList(action);
866
+
867
+ nextDate = periodDateList.value.find((item) => item.endRange > localValue.value.to);
868
+ }
869
+
870
+ if (isDatePeriodOutOfRange(nextDate)) return;
871
+
872
+ localValue.value = {
873
+ from: nextDate.startRange,
874
+ to: nextDate.endRange,
875
+ };
876
+ }
877
+ } else {
878
+ if (isPeriod.value.ownRange) {
879
+ const previousDate = {
880
+ to: getUnixTimestampFromDate(gmtToUTC(addDays(to, daysDifference * -1))),
881
+ from: getUnixTimestampFromDate(gmtToUTC(addDays(from, daysDifference * -1))),
882
+ };
883
+
884
+ if (isDatePeriodOutOfRange(previousDate)) return;
885
+
886
+ localValue.value = previousDate;
887
+ } else {
888
+ const reverseDatesList = [...periodDateList.value].reverse();
889
+
890
+ let previousDate = reverseDatesList.find((item) => item.endRange < localValue.value.to);
891
+
892
+ if (!previousDate) {
893
+ onClickShiftDatesList(action);
894
+
895
+ const reverseDatesList = [...periodDateList.value].reverse();
896
+
897
+ previousDate = reverseDatesList.find((item) => item.endRange < localValue.value.to);
898
+ }
899
+
900
+ if (isDatePeriodOutOfRange(previousDate)) return;
901
+
902
+ localValue.value = {
903
+ from: previousDate.startRange,
904
+ to: previousDate.endRange,
905
+ };
906
+ }
907
+ }
908
+ }
909
+
910
+ function onMouseoverCalendar() {
911
+ const isRangeInputFocus = document.activeElement.name === rangeInputName.value;
912
+
913
+ if (isRangeInputFocus || !rangeInputStartRef.value || !rangeInputEndRef.value) return;
914
+
915
+ if ((rangeStart.value && rangeEnd.value && !inputRangeEndError.value) || !rangeStart.value) {
916
+ rangeInputStartRef.value.input.focus();
917
+
918
+ return;
919
+ }
920
+
921
+ if (rangeStart.value && !rangeEnd.value && !inputRangeStartError.value) {
922
+ rangeInputEndRef.value.input.focus();
923
+
924
+ return;
925
+ }
926
+ }
927
+
928
+ function onMouseoutMenu() {
929
+ const isRangeInputFocus = document.activeElement.name === rangeInputName.value;
930
+
931
+ if (isRangeInputFocus) {
932
+ isHoverEvent.value = true;
933
+
934
+ document.activeElement.blur();
935
+ }
936
+ }
937
+ </script>