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