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,743 @@
1
+ <template>
2
+ <div ref="wrapperRef" tabindex="1" v-bind="wrapperAttrs" @keydown="onKeydown">
3
+ <div v-bind="navigationAttrs">
4
+ <Teleport
5
+ v-if="rangeSwitchViewContainerRef"
6
+ :to="rangeSwitchViewContainerRef"
7
+ :disabled="!range"
8
+ >
9
+ <UButton
10
+ size="sm"
11
+ color="gray"
12
+ pill
13
+ square
14
+ variant="thirdary"
15
+ v-bind="navigationSwitchViewButtonAttrs"
16
+ @click="onClickViewSwitch"
17
+ @mousedown.prevent.capture
18
+ >
19
+ <span v-if="isCurrentView.day" v-bind="dayViewSwitchLabelAttrs">
20
+ <span v-bind="dayViewSwitchLabelMonthAttrs" v-text="viewSwitchLabel.month" />
21
+ <span v-text="viewSwitchLabel.year" />
22
+ </span>
23
+ <span v-if="isCurrentView.month" v-text="viewSwitchLabel.year" />
24
+ <span v-if="isCurrentView.year" v-text="viewSwitchLabel.yearsRange" />
25
+
26
+ <template #right>
27
+ <UIcon
28
+ v-if="!range"
29
+ size="sm"
30
+ color="gray"
31
+ variant="light"
32
+ :name="config.dayViewSwitchLabelIconName"
33
+ v-bind="dayViewSwitchLabelIconAttrs"
34
+ />
35
+ </template>
36
+ </UButton>
37
+ </Teleport>
38
+
39
+ <div v-bind="nextPrevWrapperAttrs">
40
+ <UButton
41
+ pill
42
+ size="sm"
43
+ square
44
+ variant="thirdary"
45
+ v-bind="nextPrevButtonAttrs"
46
+ @mousedown.prevent.capture
47
+ @click="onClickPrevButton"
48
+ >
49
+ <UIcon
50
+ size="sm"
51
+ color="gray"
52
+ variant="light"
53
+ :name="config.prevIconName"
54
+ v-bind="prevIconAttrs"
55
+ />
56
+ </UButton>
57
+
58
+ <div ref="rangeSwitchViewContainerRef" />
59
+
60
+ <UButton
61
+ pill
62
+ size="sm"
63
+ square
64
+ variant="thirdary"
65
+ v-bind="nextPrevButtonAttrs"
66
+ @mousedown.prevent.capture
67
+ @click="onClickNextButton"
68
+ >
69
+ <UIcon
70
+ size="sm"
71
+ color="gray"
72
+ variant="light"
73
+ :name="config.nextIconName"
74
+ v-bind="nextIconAttrs"
75
+ />
76
+ </UButton>
77
+ </div>
78
+ </div>
79
+
80
+ <DayView
81
+ v-if="isCurrentView.day"
82
+ :selected-date="selectedDate"
83
+ :selected-date-to="selectedDateTo"
84
+ :range="range"
85
+ :active-month="activeMonth"
86
+ :active-date="activeDate"
87
+ :min-date="minDate"
88
+ :max-date="maxDate"
89
+ :date-format="dateFormat"
90
+ :locale="locale"
91
+ :config="config"
92
+ @input="onInputDate"
93
+ />
94
+
95
+ <MonthView
96
+ v-if="isCurrentView.month"
97
+ :selected-date="selectedDate"
98
+ :active-month="activeMonth"
99
+ :active-date="activeDate"
100
+ :min-date="minDate"
101
+ :max-date="maxDate"
102
+ :date-format="dateFormat"
103
+ :locale="locale"
104
+ :config="config"
105
+ @input="onInput"
106
+ />
107
+
108
+ <YearView
109
+ v-if="isCurrentView.year"
110
+ :selected-date="selectedDate"
111
+ :active-month="activeMonth"
112
+ :active-date="activeDate"
113
+ :min-date="minDate"
114
+ :max-date="maxDate"
115
+ :date-format="dateFormat"
116
+ :locale="locale"
117
+ :config="config"
118
+ @input="onInput"
119
+ />
120
+
121
+ <div v-if="isTimepickerEnabled" v-bind="timepickerWrapperAttrs">
122
+ <span v-bind="timepickerLabelAttrs" v-text="locale.timeLabel" />
123
+
124
+ <div v-bind="timepickerInputWrapperAttrs">
125
+ <input
126
+ ref="hoursRef"
127
+ type="text"
128
+ v-bind="timepickerLeftInputAttrs"
129
+ @input.prevent="onTimeInput($event, INPUT_TYPE.hours, MAX_HOURS, MIN_HOURS)"
130
+ @keydown="onTimeKeydown"
131
+ />
132
+ &#8282;
133
+ <input
134
+ ref="minutesRef"
135
+ type="text"
136
+ v-bind="timepickerRightInputAttrs"
137
+ @input.prevent="onTimeInput($event, INPUT_TYPE.minutes, MAX_MINUTES, MIN_MINUTES)"
138
+ @keydown="onTimeKeydown"
139
+ />
140
+ </div>
141
+
142
+ <UButton v-bind="submitButtonAttrs" @click="onClickSubmit">
143
+ {{ locale.okLabel }}
144
+ </UButton>
145
+ </div>
146
+ </div>
147
+ </template>
148
+
149
+ <script setup>
150
+ import { computed, onMounted, ref, watch } from "vue";
151
+
152
+ import UIcon from "../ui.image-icon";
153
+ import UButton from "../ui.button";
154
+
155
+ import UIService from "../service.ui";
156
+
157
+ import {
158
+ parseDate,
159
+ formatDate,
160
+ getYearsRange,
161
+ dateIsOutOfRange,
162
+ isNumeric,
163
+ } from "./services/calendar.service";
164
+
165
+ import {
166
+ getUnixTimestampFromDate,
167
+ getDateWithoutTime,
168
+ addMonths,
169
+ addDays,
170
+ addYears,
171
+ getSortedLocale,
172
+ } from "./services/date.service";
173
+
174
+ import useAttrs from "./composables/attrs.composable";
175
+
176
+ import {
177
+ UCalendar,
178
+ VIEW,
179
+ KEY_CODE,
180
+ YEARS_PER_VIEW,
181
+ MAX_HOURS,
182
+ MIN_HOURS,
183
+ MAX_MINUTES,
184
+ MIN_MINUTES,
185
+ SEPARATOR,
186
+ INPUT_TYPE,
187
+ LOCALE_TYPE,
188
+ } from "./constants";
189
+
190
+ import defaultConfig from "./configs/default.config";
191
+
192
+ import DayView from "./components/DayView.vue";
193
+ import MonthView from "./components/MonthView.vue";
194
+ import YearView from "./components/YearView.vue";
195
+
196
+ defineOptions({ name: "UCalendar" });
197
+
198
+ const props = defineProps({
199
+ /**
200
+ * Calendar value (timestamp).
201
+ */
202
+ modelValue: {
203
+ type: [Number, Object],
204
+ default: null,
205
+ },
206
+
207
+ /**
208
+ * Calendar view.
209
+ * @values day, month, year
210
+ */
211
+ view: {
212
+ type: String,
213
+ default: VIEW.day,
214
+ },
215
+
216
+ /**
217
+ * Enable range selection.
218
+ */
219
+ range: {
220
+ type: Boolean,
221
+ default: UIService.get(defaultConfig, UCalendar).default.range,
222
+ },
223
+
224
+ /**
225
+ * Enable timepicker.
226
+ */
227
+ timepicker: {
228
+ type: Boolean,
229
+ default: UIService.get(defaultConfig, UCalendar).default.timepicker,
230
+ },
231
+
232
+ /**
233
+ * Date format.
234
+ */
235
+ dateFormat: {
236
+ type: String,
237
+ default: UIService.get(defaultConfig, UCalendar).default.dateFormat,
238
+ },
239
+
240
+ /**
241
+ * User friendly date format.
242
+ */
243
+ userFormat: {
244
+ type: String,
245
+ default: UIService.get(defaultConfig, UCalendar).default.userFormat,
246
+ },
247
+
248
+ /**
249
+ * Min date in format date string or Date.
250
+ */
251
+ minDate: {
252
+ type: [Date, String],
253
+ default: UIService.get(defaultConfig, UCalendar).default.minDate,
254
+ },
255
+
256
+ /**
257
+ * Max date in format date string or Date.
258
+ */
259
+ maxDate: {
260
+ type: [Date, String],
261
+ default: UIService.get(defaultConfig, UCalendar).default.maxDate,
262
+ },
263
+
264
+ /**
265
+ * Component ui config object.
266
+ */
267
+ config: {
268
+ type: Object,
269
+ default: () => ({}),
270
+ },
271
+
272
+ /**
273
+ * Data-cy attribute for automated testing.
274
+ */
275
+ dataCy: {
276
+ type: String,
277
+ default: "",
278
+ },
279
+ });
280
+
281
+ const emit = defineEmits([
282
+ "update:modelValue",
283
+ "update:view",
284
+ "input",
285
+ "submit",
286
+ "keydown",
287
+ "userDateChange",
288
+ "formattedDateChange",
289
+ ]);
290
+
291
+ const {
292
+ config,
293
+ wrapperAttrs,
294
+ navigationAttrs,
295
+ navigationSwitchViewButtonAttrs,
296
+ dayViewSwitchLabelAttrs,
297
+ dayViewSwitchLabelMonthAttrs,
298
+ dayViewSwitchLabelIconAttrs,
299
+ nextIconAttrs,
300
+ nextPrevButtonAttrs,
301
+ prevIconAttrs,
302
+ timepickerWrapperAttrs,
303
+ timepickerLabelAttrs,
304
+ timepickerInputWrapperAttrs,
305
+ timepickerLeftInputAttrs,
306
+ timepickerRightInputAttrs,
307
+ submitButtonAttrs,
308
+ nextPrevWrapperAttrs,
309
+ } = useAttrs(props);
310
+
311
+ const wrapperRef = ref(null);
312
+ const hoursRef = ref(null);
313
+ const minutesRef = ref(null);
314
+ const rangeSwitchViewContainerRef = ref(null);
315
+
316
+ const activeDate = ref(null);
317
+ const activeMonth = ref(null);
318
+
319
+ defineExpose({ wrapperRef });
320
+
321
+ const currentView = ref(props.view);
322
+
323
+ watch(
324
+ () => props.view,
325
+ () => {
326
+ if (props.view !== currentView.value) {
327
+ currentView.value = props.view;
328
+ }
329
+ },
330
+ );
331
+
332
+ watch(currentView, () => {
333
+ if (props.view !== currentView.value) {
334
+ emit("update:view", currentView.value);
335
+ }
336
+ });
337
+
338
+ const isCurrentView = computed(() => ({
339
+ day: currentView.value === VIEW.day,
340
+ month: currentView.value === VIEW.month,
341
+ year: currentView.value === VIEW.year,
342
+ }));
343
+
344
+ const locale = computed(() => {
345
+ const currentLocale = props.config.i18n || config.value.i18n;
346
+ const formattedLocale = {
347
+ ...currentLocale,
348
+ months: {
349
+ shorthand: getSortedLocale(currentLocale.months.shorthand, LOCALE_TYPE.month),
350
+ longhand: getSortedLocale(currentLocale.months.longhand, LOCALE_TYPE.month),
351
+ },
352
+ weekdays: {
353
+ shorthand: getSortedLocale(currentLocale.weekdays.shorthand, LOCALE_TYPE.day),
354
+ longhand: getSortedLocale(currentLocale.weekdays.longhand, LOCALE_TYPE.day),
355
+ },
356
+ };
357
+
358
+ return formattedLocale;
359
+ });
360
+
361
+ const isTimepickerEnabled = computed(() => {
362
+ return props.timepicker && !props.range;
363
+ });
364
+
365
+ const isModelRangeType = computed(() => {
366
+ return (
367
+ props.modelValue !== null &&
368
+ !isNumeric(props.modelValue) &&
369
+ typeof props.modelValue === "object"
370
+ );
371
+ });
372
+
373
+ const localValue = computed({
374
+ get: () => {
375
+ if (props.range) {
376
+ const from = isModelRangeType.value ? props.modelValue.from : props.modelValue || null;
377
+
378
+ const to = isModelRangeType.value ? props.modelValue.to : null;
379
+
380
+ return { from, to };
381
+ }
382
+
383
+ return isModelRangeType.value ? props.modelValue.from : props.modelValue;
384
+ },
385
+ set(value) {
386
+ value = getCurrentValueType(value);
387
+
388
+ const parsedDate = parseDate(props.range ? value.from : value, props.dateFormat, locale.value);
389
+ const parsedDateTo =
390
+ isModelRangeType.value && props.range
391
+ ? parseDate(value.to, props.dateFormat, locale.value)
392
+ : undefined;
393
+
394
+ if (parsedDate && isTimepickerEnabled.value) {
395
+ parsedDate.setHours(Number(hoursRef.value.value));
396
+ parsedDate.setMinutes(Number(minutesRef.value.value));
397
+ }
398
+
399
+ const timestamp = parsedDate ? getUnixTimestampFromDate(parsedDate) : null;
400
+ const timestampTo = parsedDateTo ? getUnixTimestampFromDate(parsedDateTo) : null;
401
+
402
+ const isOutOfRange = dateIsOutOfRange(
403
+ parsedDate || new Date(),
404
+ props.minDate,
405
+ props.maxDate,
406
+ locale.value,
407
+ props.dateFormat,
408
+ );
409
+
410
+ if (isOutOfRange) {
411
+ return;
412
+ }
413
+
414
+ emit("update:modelValue", props.range ? { from: timestamp, to: timestampTo } : timestamp);
415
+
416
+ if (parsedDate === null && isTimepickerEnabled.value) {
417
+ const currentDate = new Date();
418
+
419
+ hoursRef.value.value = String(currentDate.getHours()).padStart(2, "0");
420
+ minutesRef.value.value = String(currentDate.getMinutes()).padStart(2, "0");
421
+ }
422
+ },
423
+ });
424
+
425
+ const selectedDate = computed(() => {
426
+ return parseDate(
427
+ props.range ? localValue.value.from : localValue.value,
428
+ props.dateFormat,
429
+ locale.value,
430
+ );
431
+ });
432
+
433
+ const selectedDateTo = computed(() => {
434
+ return props.range ? parseDate(localValue.value.to, props.dateFormat, locale.value) : undefined;
435
+ });
436
+
437
+ const formattedDate = computed(() => {
438
+ return formatDate(selectedDate.value, props.dateFormat, locale.value);
439
+ });
440
+
441
+ const formattedTime = computed(() => {
442
+ if (!isTimepickerEnabled.value) return undefined;
443
+
444
+ const hours = String(selectedDate.value?.getHours()).padStart(2, "0");
445
+ const minutes = String(selectedDate.value?.getMinutes()).padStart(2, "0");
446
+
447
+ return selectedDate.value ? `${hours}:${minutes}` : "";
448
+ });
449
+
450
+ const userFormattedDate = computed(() => {
451
+ const date = formatDate(selectedDate.value, props.userFormat, locale.value);
452
+ const dateTo = props.range
453
+ ? formatDate(selectedDateTo.value, props.userFormat, locale.value)
454
+ : undefined;
455
+
456
+ if (isTimepickerEnabled.value && selectedDate.value) {
457
+ return `${date} ${SEPARATOR} ${formattedTime.value}`;
458
+ }
459
+
460
+ return props.range ? `${date} ${SEPARATOR} ${dateTo}` : date;
461
+ });
462
+
463
+ const viewSwitchLabel = computed(() => {
464
+ const localValue =
465
+ activeDate.value || activeMonth.value || selectedDate.value || getDateWithoutTime();
466
+
467
+ return {
468
+ year: formatDate(localValue, "Y", locale.value),
469
+ month: formatDate(localValue, "F", locale.value),
470
+ yearsRange: getYearsRange(localValue || getDateWithoutTime()).join(` ${SEPARATOR} `),
471
+ };
472
+ });
473
+
474
+ watch(userFormattedDate, () => {
475
+ emit("userDateChange", userFormattedDate.value);
476
+ });
477
+
478
+ watch(formattedDate, () => {
479
+ emit("formattedDateChange", userFormattedDate.value);
480
+ });
481
+
482
+ // This watcher force updates value when range props changed
483
+ watch(
484
+ () => props.range,
485
+ (newValue, oldValue) => {
486
+ if (newValue !== oldValue) {
487
+ localValue.value = getCurrentValueType(localValue.value);
488
+ }
489
+ },
490
+ );
491
+
492
+ onMounted(() => {
493
+ if (selectedDate.value && isTimepickerEnabled.value) {
494
+ hoursRef.value.value = String(selectedDate.value.getHours()).padStart(2, "0");
495
+ minutesRef.value.value = String(selectedDate.value.getMinutes()).padStart(2, "0");
496
+ }
497
+
498
+ emit("userDateChange", userFormattedDate.value);
499
+ emit("formattedDateChange", userFormattedDate.value);
500
+ });
501
+
502
+ function getCurrentValueType(value) {
503
+ if (props.range && value === null) {
504
+ value = { from: null, to: null };
505
+ }
506
+
507
+ if (isModelRangeType.value && !props.range) {
508
+ value = value.from || value;
509
+ }
510
+
511
+ if (typeof value !== "object" && value !== null && props.range) {
512
+ value = { from: value, to: null };
513
+ }
514
+
515
+ return value;
516
+ }
517
+
518
+ function onInputDate(newDate) {
519
+ if (newDate === null) {
520
+ localValue.value = newDate;
521
+
522
+ activeDate.value = null;
523
+ activeMonth.value = null;
524
+
525
+ emit("input", localValue.value);
526
+
527
+ return;
528
+ }
529
+
530
+ const date = new Date(newDate.valueOf());
531
+
532
+ if (props.range) {
533
+ const isFullReset =
534
+ localValue.value.to ||
535
+ !localValue.value.from ||
536
+ getUnixTimestampFromDate(date) <= localValue.value.from;
537
+
538
+ localValue.value = isFullReset
539
+ ? { from: date, to: null }
540
+ : { from: localValue.value.from, to: date };
541
+ } else {
542
+ localValue.value = date;
543
+ }
544
+
545
+ activeDate.value = null;
546
+ activeMonth.value = null;
547
+
548
+ emit("input", localValue.value);
549
+
550
+ wrapperRef.value.focus();
551
+ }
552
+
553
+ function onKeydown(event) {
554
+ if (props.range) {
555
+ emit("keydown", event);
556
+
557
+ return;
558
+ }
559
+
560
+ if ([KEY_CODE.left, KEY_CODE.up, KEY_CODE.right, KEY_CODE.down].includes(event.keyCode)) {
561
+ arrowKeyHandler(event);
562
+
563
+ minutesRef.value?.blur();
564
+ hoursRef.value?.blur();
565
+ }
566
+
567
+ if (event.keyCode === KEY_CODE.enter) {
568
+ enterKeyHandler(event);
569
+ }
570
+
571
+ if (isNumeric(event.key) && document.activeElement !== minutesRef.value) {
572
+ hoursRef.value?.focus();
573
+ }
574
+
575
+ emit("keydown", event);
576
+ }
577
+
578
+ function onInput(date) {
579
+ activeDate.value = null;
580
+ activeMonth.value = date;
581
+
582
+ if (isCurrentView.value.month) currentView.value = VIEW.day;
583
+ if (isCurrentView.value.year) currentView.value = VIEW.month;
584
+ }
585
+
586
+ function arrowKeyHandler(event) {
587
+ const currentActiveDate =
588
+ activeDate.value || activeMonth.value || selectedDate.value || getDateWithoutTime();
589
+
590
+ let newActiveDate;
591
+
592
+ if (currentView.value === VIEW.day) {
593
+ if (event.keyCode === KEY_CODE.down) {
594
+ newActiveDate = addDays(currentActiveDate, 7);
595
+ } else if (event.keyCode === KEY_CODE.left) {
596
+ newActiveDate = addDays(currentActiveDate, -1);
597
+ } else if (event.keyCode === KEY_CODE.up) {
598
+ newActiveDate = addDays(currentActiveDate, -7);
599
+ } else if (event.keyCode === KEY_CODE.right) {
600
+ newActiveDate = addDays(currentActiveDate, 1);
601
+ }
602
+ } else if (currentView.value === VIEW.month) {
603
+ if (event.keyCode === KEY_CODE.down) {
604
+ newActiveDate = addMonths(currentActiveDate, 4);
605
+ } else if (event.keyCode === KEY_CODE.left) {
606
+ newActiveDate = addMonths(currentActiveDate, -1);
607
+ } else if (event.keyCode === KEY_CODE.up) {
608
+ newActiveDate = addMonths(currentActiveDate, -4);
609
+ } else if (event.keyCode === KEY_CODE.right) {
610
+ newActiveDate = addMonths(currentActiveDate, 1);
611
+ }
612
+ } else if (currentView.value === VIEW.year) {
613
+ if (event.keyCode === KEY_CODE.down) {
614
+ newActiveDate = addYears(currentActiveDate, 4);
615
+ } else if (event.keyCode === KEY_CODE.left) {
616
+ newActiveDate = addYears(currentActiveDate, -1);
617
+ } else if (event.keyCode === KEY_CODE.up) {
618
+ newActiveDate = addYears(currentActiveDate, -4);
619
+ } else if (event.keyCode === KEY_CODE.right) {
620
+ newActiveDate = addYears(currentActiveDate, 1);
621
+ }
622
+ }
623
+
624
+ const isOutOfRange = dateIsOutOfRange(
625
+ newActiveDate,
626
+ props.minDate,
627
+ props.maxDate,
628
+ locale.value,
629
+ props.dateFormat,
630
+ );
631
+
632
+ if (newActiveDate && !isOutOfRange) {
633
+ activeDate.value = newActiveDate;
634
+ activeMonth.value = newActiveDate;
635
+ }
636
+ }
637
+
638
+ function addActiveMonth(amount) {
639
+ const currentActiveMonth = activeMonth.value || selectedDate.value || getDateWithoutTime();
640
+ const newActiveMonth = addMonths(currentActiveMonth, amount);
641
+
642
+ activeMonth.value = newActiveMonth;
643
+ }
644
+
645
+ function addActiveYear(amount) {
646
+ const currentActiveMonth = activeMonth.value || selectedDate.value || getDateWithoutTime();
647
+ const newActiveMonth = addYears(currentActiveMonth, amount);
648
+
649
+ activeMonth.value = newActiveMonth;
650
+ }
651
+
652
+ function onClickNextButton() {
653
+ activeDate.value = null;
654
+
655
+ if (isCurrentView.value.day) addActiveMonth(1);
656
+ if (isCurrentView.value.month) addActiveYear(1);
657
+ if (isCurrentView.value.year) addActiveYear(YEARS_PER_VIEW);
658
+ }
659
+
660
+ function onClickPrevButton() {
661
+ activeDate.value = null;
662
+
663
+ if (isCurrentView.value.day) addActiveMonth(-1);
664
+ if (isCurrentView.value.month) addActiveYear(-1);
665
+ if (isCurrentView.value.year) addActiveYear(YEARS_PER_VIEW * -1);
666
+ }
667
+
668
+ function enterKeyHandler() {
669
+ if (activeDate.value !== null && isCurrentView.value.day) {
670
+ localValue.value = activeDate.value;
671
+
672
+ activeDate.value = null;
673
+ activeMonth.value = null;
674
+
675
+ emit("input", localValue.value);
676
+ }
677
+
678
+ if (isCurrentView.value.month) currentView.value = VIEW.day;
679
+ if (isCurrentView.value.year) currentView.value = VIEW.month;
680
+ }
681
+
682
+ function onClickViewSwitch() {
683
+ const views = Object.values(VIEW);
684
+ const currentViewIndex = views.indexOf(currentView.value);
685
+ const nextViewIndex = currentViewIndex + 1;
686
+
687
+ activeDate.value = null;
688
+
689
+ currentView.value = views[nextViewIndex] || views.at(0);
690
+ }
691
+
692
+ let lastValidHourValue = "";
693
+ let lastValidMinuteValue = "";
694
+
695
+ function onTimeKeydown(event) {
696
+ if ([KEY_CODE.left, KEY_CODE.up, KEY_CODE.right, KEY_CODE.down].includes(event.keyCode)) {
697
+ wrapperRef.value.focus();
698
+
699
+ return;
700
+ }
701
+
702
+ if (event.keyCode === KEY_CODE.enter) {
703
+ enterKeyHandler(event);
704
+
705
+ emit("submit");
706
+ }
707
+ }
708
+
709
+ function onClickSubmit() {
710
+ emit("submit");
711
+ }
712
+
713
+ function onTimeInput(event, type, maxValue, minValue) {
714
+ const input = event.target;
715
+ const value = input.value;
716
+ const numericValue = Number(value);
717
+
718
+ const isHours = type === INPUT_TYPE.hours;
719
+
720
+ if (!isNumeric(event.data)) {
721
+ input.value = isHours ? lastValidHourValue : lastValidMinuteValue;
722
+
723
+ return;
724
+ }
725
+
726
+ if (numericValue > maxValue || numericValue < minValue) {
727
+ input.value = "0".padStart(2, "0");
728
+
729
+ return;
730
+ }
731
+
732
+ isHours ? (lastValidHourValue = numericValue) : (lastValidMinuteValue = numericValue);
733
+
734
+ if (selectedDate.value) {
735
+ const date = new Date(selectedDate.value.valueOf());
736
+
737
+ date.setHours(lastValidHourValue, lastValidMinuteValue);
738
+ localValue.value = date;
739
+ }
740
+
741
+ input.value = String(numericValue).padStart(2, "0");
742
+ }
743
+ </script>