vueless 0.0.4 → 0.0.5

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