@volverjs/ui-vue 0.0.10-beta.3 → 0.0.10-beta.31

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 (294) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +106 -10
  3. package/auto-imports.d.ts +7 -2
  4. package/bin/icons.cjs +1 -1
  5. package/bin/icons.js +22 -15
  6. package/dist/Volver.d.ts +1 -1
  7. package/dist/components/VvAccordion/VvAccordion.es.js +192 -103
  8. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  9. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +160 -8
  10. package/dist/components/VvAccordion/index.d.ts +8 -9
  11. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +451 -172
  12. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  13. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +58 -13
  14. package/dist/components/VvAccordionGroup/index.d.ts +14 -6
  15. package/dist/components/VvAction/VvAction.es.js +78 -27
  16. package/dist/components/VvAction/VvAction.umd.js +1 -1
  17. package/dist/components/VvAction/VvAction.vue.d.ts +57 -22
  18. package/dist/components/VvAction/index.d.ts +25 -9
  19. package/dist/components/VvAlert/VvAlert.es.js +204 -171
  20. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  21. package/dist/components/VvAlert/VvAlert.vue.d.ts +24 -14
  22. package/dist/components/VvAlert/index.d.ts +17 -9
  23. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +250 -188
  24. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  25. package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +16 -9
  26. package/dist/components/VvAlertGroup/index.d.ts +6 -14
  27. package/dist/components/VvAvatar/VvAvatar.es.js +61 -21
  28. package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
  29. package/dist/components/VvAvatar/VvAvatar.vue.d.ts +12 -4
  30. package/dist/components/VvAvatar/index.d.ts +4 -1
  31. package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +118 -48
  32. package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
  33. package/dist/components/VvAvatarGroup/VvAvatarGroup.vue.d.ts +10 -3
  34. package/dist/components/VvAvatarGroup/index.d.ts +4 -1
  35. package/dist/components/VvBadge/VvBadge.es.js +78 -28
  36. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  37. package/dist/components/VvBadge/VvBadge.vue.d.ts +12 -4
  38. package/dist/components/VvBadge/index.d.ts +4 -1
  39. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +276 -60
  40. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  41. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +27 -7
  42. package/dist/components/VvBreadcrumb/index.d.ts +6 -10
  43. package/dist/components/VvButton/VvButton.es.js +291 -252
  44. package/dist/components/VvButton/VvButton.umd.js +1 -1
  45. package/dist/components/VvButton/VvButton.vue.d.ts +94 -40
  46. package/dist/components/VvButton/index.d.ts +51 -29
  47. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +81 -40
  48. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  49. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +24 -11
  50. package/dist/components/VvButtonGroup/index.d.ts +8 -2
  51. package/dist/components/VvCard/VvCard.es.js +86 -36
  52. package/dist/components/VvCard/VvCard.umd.js +1 -1
  53. package/dist/components/VvCard/VvCard.vue.d.ts +12 -4
  54. package/dist/components/VvCard/index.d.ts +4 -1
  55. package/dist/components/VvCheckbox/VvCheckbox.es.js +177 -120
  56. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  57. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +105 -33
  58. package/dist/components/VvCheckbox/index.d.ts +47 -14
  59. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +190 -107
  60. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  61. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +101 -30
  62. package/dist/components/VvCheckboxGroup/index.d.ts +45 -12
  63. package/dist/components/VvCombobox/VvCombobox.es.js +806 -581
  64. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  65. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +171 -104
  66. package/dist/components/VvCombobox/index.d.ts +62 -26
  67. package/dist/components/VvDialog/VvDialog.es.js +140 -153
  68. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  69. package/dist/components/VvDialog/VvDialog.vue.d.ts +4 -4
  70. package/dist/components/VvDropdown/VvDropdown.es.js +138 -71
  71. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  72. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +101 -75
  73. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +66 -25
  74. package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +13 -1
  75. package/dist/components/VvDropdown/VvDropdownOptgroup.vue.d.ts +12 -4
  76. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +35 -7
  77. package/dist/components/VvDropdown/index.d.ts +52 -10
  78. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +152 -39
  79. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
  80. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +335 -8
  81. package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
  82. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +63 -20
  83. package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
  84. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +188 -80
  85. package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
  86. package/dist/components/VvIcon/VvIcon.es.js +23 -96
  87. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  88. package/dist/components/VvIcon/VvIcon.vue.d.ts +23 -66
  89. package/dist/components/VvIcon/index.d.ts +33 -48
  90. package/dist/components/VvInputFile/VvInputFile.es.js +1777 -0
  91. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -0
  92. package/dist/components/VvInputFile/VvInputFile.vue.d.ts +359 -0
  93. package/dist/components/VvInputFile/index.d.ts +200 -0
  94. package/dist/components/VvInputText/VvInputClearAction.d.ts +7 -5
  95. package/dist/components/VvInputText/VvInputPasswordAction.d.ts +10 -8
  96. package/dist/components/VvInputText/VvInputStepAction.d.ts +2 -2
  97. package/dist/components/VvInputText/VvInputText.es.js +1237 -324
  98. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  99. package/dist/components/VvInputText/VvInputText.vue.d.ts +207 -57
  100. package/dist/components/VvInputText/index.d.ts +99 -29
  101. package/dist/components/VvNav/VvNav.es.js +135 -56
  102. package/dist/components/VvNav/VvNav.umd.js +1 -1
  103. package/dist/components/VvNav/VvNav.vue.d.ts +32 -9
  104. package/dist/components/VvNav/VvNavItem.vue.d.ts +1 -1
  105. package/dist/components/VvNav/VvNavSeparator.vue.d.ts +1 -1
  106. package/dist/components/VvNav/index.d.ts +5 -2
  107. package/dist/components/VvNavItem/VvNavItem.es.js +91 -33
  108. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  109. package/dist/components/VvProgress/VvProgress.es.js +72 -26
  110. package/dist/components/VvProgress/VvProgress.umd.js +1 -1
  111. package/dist/components/VvProgress/VvProgress.vue.d.ts +10 -3
  112. package/dist/components/VvProgress/index.d.ts +4 -1
  113. package/dist/components/VvRadio/VvRadio.es.js +160 -103
  114. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  115. package/dist/components/VvRadio/VvRadio.vue.d.ts +103 -31
  116. package/dist/components/VvRadio/index.d.ts +50 -17
  117. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +190 -107
  118. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  119. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +101 -30
  120. package/dist/components/VvRadioGroup/index.d.ts +45 -12
  121. package/dist/components/VvSelect/VvSelect.es.js +251 -238
  122. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  123. package/dist/components/VvSelect/VvSelect.vue.d.ts +117 -44
  124. package/dist/components/VvSelect/index.d.ts +48 -14
  125. package/dist/components/VvTab/VvTab.es.js +191 -75
  126. package/dist/components/VvTab/VvTab.umd.js +1 -1
  127. package/dist/components/VvTab/VvTab.vue.d.ts +31 -7
  128. package/dist/components/VvTab/index.d.ts +4 -1
  129. package/dist/components/VvTextarea/VvTextarea.es.js +232 -224
  130. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  131. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +156 -49
  132. package/dist/components/VvTextarea/index.d.ts +68 -19
  133. package/dist/components/VvTooltip/VvTooltip.es.js +79 -29
  134. package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
  135. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +13 -6
  136. package/dist/components/VvTooltip/index.d.ts +5 -2
  137. package/dist/components/common/HintSlot.d.ts +1 -1
  138. package/dist/components/index.d.ts +10 -0
  139. package/dist/components/index.es.js +3534 -1650
  140. package/dist/components/index.umd.js +1 -1
  141. package/dist/composables/alert/useAlert.d.ts +99 -4
  142. package/dist/composables/alert/useInjectAlert.d.ts +1 -6
  143. package/dist/composables/dropdown/useInjectDropdown.d.ts +3 -23
  144. package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -4
  145. package/dist/composables/group/useInjectedGroupState.d.ts +4 -5
  146. package/dist/composables/group/useProvideGroupState.d.ts +3 -3
  147. package/dist/composables/index.d.ts +1 -0
  148. package/dist/composables/index.es.js +92 -3
  149. package/dist/composables/index.umd.js +1 -1
  150. package/dist/composables/useBlurhash.d.ts +7 -0
  151. package/dist/composables/useComponentIcon.d.ts +9 -8
  152. package/dist/composables/usePersistence.d.ts +2 -0
  153. package/dist/composables/useVolver.d.ts +1 -1
  154. package/dist/constants.d.ts +34 -32
  155. package/dist/directives/index.d.ts +3 -5
  156. package/dist/directives/index.es.js +99 -43
  157. package/dist/directives/index.umd.js +1 -1
  158. package/dist/directives/v-tooltip.es.js +97 -38
  159. package/dist/directives/v-tooltip.umd.js +1 -1
  160. package/dist/icons.es.js +267 -267
  161. package/dist/icons.umd.js +1 -1
  162. package/dist/index.d.ts +3 -1
  163. package/dist/index.es.js +90 -16
  164. package/dist/index.umd.js +1 -1
  165. package/dist/props/index.d.ts +272 -81
  166. package/dist/resolvers/unplugin.d.ts +6 -1
  167. package/dist/resolvers/unplugin.es.js +87 -10
  168. package/dist/resolvers/unplugin.umd.js +1 -1
  169. package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +143 -89
  170. package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +1075 -492
  171. package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +1 -1
  172. package/dist/stories/Blurhash/BlurhashComposable.stories.d.ts +4 -0
  173. package/dist/stories/Button/Button.settings.d.ts +0 -1
  174. package/dist/stories/Combobox/Combobox.settings.d.ts +8 -0
  175. package/dist/stories/Icon/Icon.settings.d.ts +1 -0
  176. package/dist/stories/InputFile/InputFile.settings.d.ts +56 -0
  177. package/dist/stories/InputFile/InputFile.stories.d.ts +12 -0
  178. package/dist/stories/InputFile/InputFileDropArea.stories.d.ts +9 -0
  179. package/dist/stories/InputFile/InputFileIconPosition.stories.d.ts +8 -0
  180. package/dist/stories/InputFile/InputFileSlots.stories.d.ts +7 -0
  181. package/dist/stories/Tab/Tab.settings.d.ts +2 -15
  182. package/dist/test/expect.d.ts +1 -1
  183. package/dist/types/alert.d.ts +9 -7
  184. package/dist/types/blurhash.d.ts +12 -0
  185. package/dist/types/generic.d.ts +1 -2
  186. package/dist/types/group.d.ts +37 -15
  187. package/dist/types/index.d.ts +7 -0
  188. package/dist/types/input-file.d.ts +16 -0
  189. package/dist/types/nav.d.ts +2 -2
  190. package/dist/utils/ObjectUtilities.d.ts +0 -1
  191. package/dist/workers/blurhash.d.ts +1 -0
  192. package/package.json +78 -78
  193. package/src/Volver.ts +31 -20
  194. package/src/assets/icons/detailed.json +1 -1
  195. package/src/assets/icons/normal.json +1 -1
  196. package/src/assets/icons/simple.json +1 -1
  197. package/src/components/VvAccordion/VvAccordion.vue +121 -58
  198. package/src/components/VvAccordion/index.ts +8 -23
  199. package/src/components/VvAccordionGroup/VvAccordionGroup.vue +164 -47
  200. package/src/components/VvAccordionGroup/index.ts +6 -6
  201. package/src/components/VvAction/VvAction.vue +17 -5
  202. package/src/components/VvAlert/index.ts +14 -9
  203. package/src/components/VvAlertGroup/index.ts +3 -15
  204. package/src/components/VvBreadcrumb/VvBreadcrumb.vue +20 -19
  205. package/src/components/VvBreadcrumb/index.ts +2 -8
  206. package/src/components/VvButton/VvButton.vue +17 -7
  207. package/src/components/VvButton/index.ts +9 -16
  208. package/src/components/VvButtonGroup/VvButtonGroup.vue +1 -2
  209. package/src/components/VvCheckbox/index.ts +2 -2
  210. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +1 -2
  211. package/src/components/VvCombobox/VvCombobox.vue +15 -12
  212. package/src/components/VvCombobox/index.ts +4 -0
  213. package/src/components/VvDropdown/VvDropdown.vue +11 -2
  214. package/src/components/VvDropdown/VvDropdownItem.vue +4 -1
  215. package/src/components/VvDropdown/VvDropdownOption.vue +4 -21
  216. package/src/components/VvDropdown/index.ts +35 -1
  217. package/src/components/VvIcon/VvIcon.vue +2 -2
  218. package/src/components/VvIcon/index.ts +35 -48
  219. package/src/components/VvInputFile/VvInputFile.vue +395 -0
  220. package/src/components/VvInputFile/index.ts +135 -0
  221. package/src/components/VvInputText/VvInputClearAction.ts +10 -6
  222. package/src/components/VvInputText/VvInputPasswordAction.ts +13 -9
  223. package/src/components/VvInputText/VvInputText.vue +141 -33
  224. package/src/components/VvInputText/index.ts +31 -16
  225. package/src/components/VvNav/VvNav.vue +4 -2
  226. package/src/components/VvRadio/index.ts +5 -5
  227. package/src/components/VvRadioGroup/VvRadioGroup.vue +1 -2
  228. package/src/components/VvSelect/VvSelect.vue +5 -8
  229. package/src/components/VvTab/VvTab.vue +5 -1
  230. package/src/components/VvTextarea/VvTextarea.vue +6 -9
  231. package/src/components/index.ts +10 -0
  232. package/src/composables/alert/useAlert.ts +12 -9
  233. package/src/composables/dropdown/useProvideDropdown.ts +4 -4
  234. package/src/composables/group/useInjectedGroupState.ts +20 -16
  235. package/src/composables/group/useProvideGroupState.ts +10 -15
  236. package/src/composables/index.ts +1 -0
  237. package/src/composables/useBlurhash.ts +76 -0
  238. package/src/composables/useComponentIcon.ts +15 -14
  239. package/src/composables/usePersistence.ts +76 -0
  240. package/src/composables/useUniqueId.ts +2 -2
  241. package/src/constants.ts +47 -32
  242. package/src/directives/index.ts +3 -6
  243. package/src/directives/v-tooltip.ts +19 -10
  244. package/src/index.ts +3 -1
  245. package/src/props/index.ts +108 -31
  246. package/src/resolvers/unplugin.ts +24 -14
  247. package/src/stories/Accordion/Accordion.test.ts +1 -1
  248. package/src/stories/AccordionGroup/AccordionGroup.settings.ts +2 -2
  249. package/src/stories/AccordionGroup/AccordionGroup.test.ts +17 -11
  250. package/src/stories/AccordionGroup/AccordionGroupSlots.stories.ts +1 -1
  251. package/src/stories/Alert/Alert.test.ts +1 -1
  252. package/src/stories/AlertGroup/AlertGroup.test.ts +1 -1
  253. package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +2 -2
  254. package/src/stories/Avatar/Avatar.test.ts +1 -1
  255. package/src/stories/AvatarGroup/AvatarGroup.test.ts +1 -1
  256. package/src/stories/Badge/Badge.test.ts +1 -1
  257. package/src/stories/Blurhash/BlurhashComposable.stories.ts +195 -0
  258. package/src/stories/Button/Button.settings.ts +1 -4
  259. package/src/stories/Button/Button.test.ts +1 -1
  260. package/src/stories/ButtonGroup/ButtonGroup.test.ts +1 -1
  261. package/src/stories/Card/Card.test.ts +1 -1
  262. package/src/stories/Checkbox/Checkbox.test.ts +1 -1
  263. package/src/stories/CheckboxGroup/CheckboxGroup.test.ts +1 -1
  264. package/src/stories/Combobox/Combobox.settings.ts +8 -0
  265. package/src/stories/Combobox/Combobox.test.ts +1 -1
  266. package/src/stories/Dialog/Dialog.test.ts +2 -2
  267. package/src/stories/Dropdown/Dropdown.test.ts +1 -1
  268. package/src/stories/Icon/Icon.settings.ts +3 -3
  269. package/src/stories/InputFile/InputFile.settings.ts +36 -0
  270. package/src/stories/InputFile/InputFile.stories.ts +89 -0
  271. package/src/stories/InputFile/InputFileDropArea.stories.ts +56 -0
  272. package/src/stories/InputFile/InputFileIconPosition.stories.ts +43 -0
  273. package/src/stories/InputFile/InputFileSlots.stories.ts +33 -0
  274. package/src/stories/InputText/InputText.test.ts +1 -1
  275. package/src/stories/Nav/Nav.test.ts +1 -1
  276. package/src/stories/Progress/Progress.test.ts +1 -1
  277. package/src/stories/Radio/Radio.test.ts +1 -1
  278. package/src/stories/RadioGroup/RadioGroup.test.ts +1 -1
  279. package/src/stories/Select/Select.test.ts +1 -1
  280. package/src/stories/Tab/Tab.settings.ts +2 -2
  281. package/src/stories/Tab/Tab.test.ts +1 -1
  282. package/src/stories/Textarea/Textarea.test.ts +1 -1
  283. package/src/stories/Tooltip/Tooltip.test.ts +1 -1
  284. package/src/stories/argTypes.ts +1 -1
  285. package/src/test/expect.ts +2 -4
  286. package/src/types/alert.ts +11 -7
  287. package/src/types/blurhash.ts +21 -0
  288. package/src/types/generic.ts +3 -3
  289. package/src/types/group.ts +22 -14
  290. package/src/types/index.ts +7 -0
  291. package/src/types/input-file.ts +18 -0
  292. package/src/types/nav.ts +2 -3
  293. package/src/utils/ObjectUtilities.ts +0 -11
  294. package/src/workers/blurhash.ts +9 -0
@@ -1,46 +1,50 @@
1
- import type { Ref } from 'vue'
2
- import type GroupState from '../../types/group'
1
+ import type { Ref, InjectionKey } from 'vue'
3
2
 
4
3
  /**
5
4
  * Injects a group state
6
5
  */
7
- export function useInjectedGroupState<GroupStateType extends GroupState>(
8
- groupKey: string | symbol,
6
+ export function useInjectedGroupState<GroupStateType>(
7
+ groupKey: InjectionKey<GroupStateType>,
9
8
  ) {
10
9
  // Get group state
11
- const group = inject<Ref<GroupStateType> | undefined>(groupKey, undefined)
10
+ const group = inject<GroupStateType | undefined>(groupKey, undefined)
12
11
 
13
12
  // Check if component is in group
14
- const isInGroup = computed(() => !isEmpty(group))
13
+ const isInGroup = computed(() => group !== undefined)
15
14
 
16
15
  /**
17
16
  * Get a group or local property
18
17
  */
19
- function getGroupOrLocalRef<PropsType extends object>(
20
- propName: keyof GroupStateType,
21
- props: PropsType,
18
+ function getGroupOrLocalRef<
19
+ TProps extends object,
20
+ TName extends keyof GroupStateType,
21
+ >(
22
+ propName: TName,
23
+ props: TProps,
22
24
  emit?: (event: string, ...args: unknown[]) => void,
23
25
  ) {
24
- if (group?.value) {
25
- const groupPropValue = unref(group.value)[propName] as Ref<unknown>
26
+ const groupPropValue = group?.[propName] as Ref | undefined
27
+ if (groupPropValue) {
26
28
  return computed({
27
29
  get() {
28
- return groupPropValue?.value
30
+ return groupPropValue.value
29
31
  },
30
32
  set(value: unknown) {
31
33
  groupPropValue.value = value
32
34
  },
33
- })
35
+ }) as GroupStateType[TName]
34
36
  }
35
- const propRef = toRef(props, propName as keyof PropsType)
37
+ const propRef = toRef(props, propName as unknown as keyof TProps)
36
38
  return computed({
37
39
  get() {
38
40
  return propRef.value
39
41
  },
40
42
  set(value: unknown) {
41
- if (emit) emit(`update:${propName as string}`, value)
43
+ if (emit) {
44
+ emit(`update:${propName as string}`, value)
45
+ }
42
46
  },
43
- })
47
+ }) as GroupStateType[TName]
44
48
  }
45
49
 
46
50
  return {
@@ -1,20 +1,15 @@
1
- import type GroupState from '../../types/group'
1
+ import type { Ref, InjectionKey } from 'vue'
2
+ import type { Emitter } from 'mitt'
2
3
 
3
4
  /**
4
5
  * Share part of the state of the component with all its children.
5
- * @param {IGroupState} groupState the group state with all group options
6
6
  */
7
- export function useProvideGroupState<GroupStateType extends GroupState>(
8
- groupState: GroupStateType,
9
- ) {
10
- if (
11
- Object.keys(groupState).some(
12
- (k) => k !== 'key' && !isRef(groupState[k]),
13
- )
14
- )
15
- throw Error("One or more groupState props aren't ref.")
16
- provide(
17
- groupState.key,
18
- computed(() => groupState),
19
- )
7
+ export function useProvideGroupState<
8
+ TGroupState extends Record<
9
+ string,
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ Ref<unknown> | Emitter<any>
12
+ >,
13
+ >(key: InjectionKey<TGroupState>, groupState: TGroupState) {
14
+ provide(key, groupState)
20
15
  }
@@ -1 +1,2 @@
1
1
  export { useAlert } from './alert/useAlert'
2
+ export { useBlurhash } from './useBlurhash'
@@ -0,0 +1,76 @@
1
+ import { wrap } from 'comlink'
2
+ import pica from 'pica'
3
+ import type { BlurhashWorkerType } from '@/types/blurhash'
4
+ import BlurhashWorker from '@/workers/blurhash?worker&inline'
5
+
6
+ const remoteFunction = wrap<BlurhashWorkerType>(new BlurhashWorker())
7
+
8
+ function loadImage(src: string): Promise<CanvasImageSource> {
9
+ return new Promise((resolve, reject) => {
10
+ const img = new Image()
11
+ img.onload = () => resolve(img)
12
+ img.onerror = (...args) => reject(args)
13
+ img.src = src
14
+ })
15
+ }
16
+
17
+ const getWidthHeightFromMaxSize = (
18
+ width: number,
19
+ height: number,
20
+ maxSize: number,
21
+ ) => {
22
+ if (width > height) {
23
+ return {
24
+ width: maxSize,
25
+ height: Math.round(maxSize * (height / width)),
26
+ }
27
+ }
28
+ return {
29
+ width: Math.round(maxSize * (width / height)),
30
+ height: maxSize,
31
+ }
32
+ }
33
+
34
+ const resizeImage = async (
35
+ image: ImageBitmap | HTMLImageElement | HTMLCanvasElement | File | Blob,
36
+ width: number,
37
+ height: number,
38
+ ) => {
39
+ const resizer = new pica()
40
+ const canvas = document.createElement('canvas')
41
+ canvas.width = width
42
+ canvas.height = height
43
+ const result = await resizer.resize(image, canvas)
44
+ return result.getContext('2d')?.getImageData(0, 0, width, height).data
45
+ }
46
+
47
+ export const useBlurhash = () => {
48
+ async function encode(file: File) {
49
+ const imageUrl = URL.createObjectURL(file)
50
+ const image = await loadImage(imageUrl)
51
+ if ('width' in image && 'height' in image) {
52
+ const { width: newWidth, height: newHeight } =
53
+ getWidthHeightFromMaxSize(
54
+ image.width as number,
55
+ image.height as number,
56
+ 32,
57
+ )
58
+ const imageData = await resizeImage(
59
+ image as ImageBitmap,
60
+ newWidth,
61
+ newHeight,
62
+ )
63
+ if (imageData) {
64
+ return remoteFunction.encode(
65
+ imageData,
66
+ newWidth,
67
+ newHeight,
68
+ 4,
69
+ 4,
70
+ )
71
+ }
72
+ }
73
+ }
74
+
75
+ return { encode, decode: remoteFunction.decode, loadImage }
76
+ }
@@ -1,34 +1,35 @@
1
1
  import type { Ref } from 'vue'
2
+ import type { VvIconProps } from '../components/VvIcon'
2
3
  import { Position, Side } from '../constants'
3
4
 
4
5
  export function useComponentIcon(
5
- icon: Ref<string | object | undefined> | undefined,
6
- iconPosition: Ref<string>,
6
+ icon?: Ref<string | VvIconProps | undefined>,
7
+ iconPosition?: Ref<string | undefined>,
7
8
  ) {
9
+ const hasIcon = computed(() => {
10
+ if (typeof icon?.value === 'string') {
11
+ return { name: icon?.value }
12
+ }
13
+ return icon?.value
14
+ })
8
15
  const hasIconBefore = computed(() =>
9
- Boolean(icon?.value && iconPosition.value === Position.before),
16
+ iconPosition?.value === Position.before ? hasIcon.value : undefined,
10
17
  )
11
18
  const hasIconAfter = computed(() =>
12
- Boolean(icon?.value && iconPosition.value === Position.after),
19
+ iconPosition?.value === Position.after ? hasIcon.value : undefined,
13
20
  )
14
21
  const hasIconLeft = computed(() =>
15
- Boolean(icon?.value && iconPosition.value === Side.left),
22
+ iconPosition?.value === Side.left ? hasIcon.value : undefined,
16
23
  )
17
24
  const hasIconRight = computed(() =>
18
- Boolean(icon?.value && iconPosition.value === Side.right),
25
+ iconPosition?.value === Side.right ? hasIcon.value : undefined,
19
26
  )
20
27
  const hasIconTop = computed(() =>
21
- Boolean(icon?.value && iconPosition.value === Side.top),
28
+ iconPosition?.value === Side.top ? hasIcon.value : undefined,
22
29
  )
23
30
  const hasIconBottom = computed(() =>
24
- Boolean(icon?.value && iconPosition.value === Side.bottom),
31
+ iconPosition?.value === Side.bottom ? hasIcon.value : undefined,
25
32
  )
26
- const hasIcon = computed(() => {
27
- if (typeof icon?.value === 'string') {
28
- return { name: icon?.value }
29
- }
30
- return icon?.value
31
- })
32
33
  return {
33
34
  hasIcon,
34
35
  hasIconLeft,
@@ -0,0 +1,76 @@
1
+ import { StorageType } from '@/constants'
2
+
3
+ export const usePersistence = <T>(
4
+ storageKey: Ref<string | undefined> | undefined,
5
+ storageType: Ref<`${StorageType}`> | `${StorageType}` = StorageType.local,
6
+ defaultValue?: T,
7
+ ) => {
8
+ const localValue: Ref<T | undefined> = ref()
9
+ if (defaultValue) {
10
+ localValue.value = defaultValue
11
+ }
12
+ let storageValue: Ref<T | undefined> | undefined
13
+ if (storageKey) {
14
+ watch(
15
+ storageKey,
16
+ (newKey, oldKey) => {
17
+ const storage =
18
+ unref(storageType) === StorageType.session
19
+ ? sessionStorage
20
+ : localStorage
21
+ if (oldKey && oldKey !== newKey) {
22
+ storage.removeItem(oldKey)
23
+ }
24
+ if (newKey) {
25
+ storageValue = useStorage(
26
+ newKey,
27
+ storageValue?.value ?? localValue.value,
28
+ storage,
29
+ )
30
+ return
31
+ }
32
+ storageValue = undefined
33
+ },
34
+ {
35
+ immediate: true,
36
+ },
37
+ )
38
+ }
39
+ if (isRef(storageType)) {
40
+ watch(storageType, (newType, oldType) => {
41
+ if (storageKey?.value) {
42
+ if (newType) {
43
+ const storage =
44
+ newType === StorageType.session
45
+ ? sessionStorage
46
+ : localStorage
47
+ storageValue = useStorage(
48
+ storageKey.value,
49
+ storageValue?.value ?? localValue.value,
50
+ storage,
51
+ )
52
+ }
53
+ if (oldType && oldType !== newType) {
54
+ const oldStorage =
55
+ oldType === StorageType.session
56
+ ? sessionStorage
57
+ : localStorage
58
+ oldStorage.removeItem(storageKey.value)
59
+ }
60
+ }
61
+ })
62
+ }
63
+
64
+ return computed<T | undefined>({
65
+ get: () => {
66
+ return storageValue?.value ?? localValue.value
67
+ },
68
+ set: (value) => {
69
+ if (storageValue) {
70
+ storageValue.value = value
71
+ return
72
+ }
73
+ localValue.value = value
74
+ },
75
+ })
76
+ }
@@ -1,5 +1,5 @@
1
- import { nanoid } from 'nanoid'
1
+ import { uid } from 'uid'
2
2
  import type { Ref } from 'vue'
3
3
 
4
4
  export const useUniqueId = (id?: Ref<string | number | undefined>) =>
5
- computed(() => String(id?.value || nanoid()))
5
+ computed(() => String(id?.value || uid()))
package/src/constants.ts CHANGED
@@ -1,10 +1,21 @@
1
1
  import type { InjectionKey, Ref } from 'vue'
2
2
  import type { Emitter } from 'mitt'
3
3
  import type { Volver } from './Volver'
4
- import type { AlertModifiers } from './types/alert'
4
+ import type {
5
+ AccordionGroupState,
6
+ InputGroupState,
7
+ ButtonGroupState,
8
+ AlertGroupState,
9
+ AlertModifier,
10
+ } from './types'
5
11
 
6
12
  export const DEFAULT_ICONIFY_PROVIDER = 'vv'
7
13
 
14
+ export enum StorageType {
15
+ local = 'local',
16
+ session = 'session',
17
+ }
18
+
8
19
  export enum Strategy {
9
20
  absolute = 'absolute',
10
21
  fixed = 'fixed',
@@ -62,26 +73,30 @@ export enum DropdownItemRole {
62
73
  presentation = 'presentation',
63
74
  }
64
75
 
65
- export enum AnchorTarget {
66
- _blank = '_blank',
67
- _self = '_self',
68
- _parent = '_parent',
69
- _top = '_top',
76
+ export enum AlertRole {
77
+ alert = 'alert',
78
+ alertdialog = 'alertdialog',
70
79
  }
71
80
 
72
81
  // volver
73
82
  export const INJECTION_KEY_VOLVER = Symbol.for('volver') as InjectionKey<Volver>
74
83
 
75
84
  // groups
76
- export const INJECTION_KEY_BUTTON_GROUP = Symbol.for('buttonGroup')
77
- export const INJECTION_KEY_RADIO_GROUP = Symbol.for('radioGroup')
78
- export const INJECTION_KEY_CHECK_GROUP = Symbol.for('checkGroup')
79
- export const INJECTION_KEY_ACCORDION_GROUP = Symbol.for('accordionGroup')
85
+ export const INJECTION_KEY_BUTTON_GROUP = Symbol.for(
86
+ 'buttonGroup',
87
+ ) as InjectionKey<ButtonGroupState>
88
+ export const INJECTION_KEY_RADIO_GROUP = Symbol.for(
89
+ 'radioGroup',
90
+ ) as InjectionKey<InputGroupState>
91
+ export const INJECTION_KEY_CHECK_GROUP = Symbol.for(
92
+ 'checkGroup',
93
+ ) as InjectionKey<InputGroupState>
94
+ export const INJECTION_KEY_ACCORDION_GROUP = Symbol.for(
95
+ 'accordionGroup',
96
+ ) as InjectionKey<AccordionGroupState>
80
97
 
81
98
  // dropdown
82
- export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
83
- 'dropdownTrigger',
84
- ) as InjectionKey<{
99
+ export type DropdownTriggerState = {
85
100
  id?: Ref<string | number>
86
101
  reference?: Ref<HTMLElement | null>
87
102
  bus?: Emitter<{
@@ -95,27 +110,33 @@ export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
95
110
  'aria-haspopup': boolean
96
111
  'aria-expanded': boolean
97
112
  }>
98
- }>
113
+ }
114
+ export const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
115
+ 'dropdownTrigger',
116
+ ) as InjectionKey<DropdownTriggerState>
117
+
118
+ export type DropdownItemState = {
119
+ role?: Ref<`${DropdownItemRole}`>
120
+ expanded?: Ref<boolean>
121
+ focused?: Ref<boolean>
122
+ hovered?: Ref<boolean>
123
+ }
99
124
  export const INJECTION_KEY_DROPDOWN_ITEM = Symbol.for(
100
125
  'dropdownItem',
101
- ) as InjectionKey<{
102
- role?: Ref<`${DropdownItemRole}`>
126
+ ) as InjectionKey<DropdownItemState>
127
+
128
+ export type DropdownActionState = {
129
+ role?: Ref<`${ActionRoles}`>
103
130
  expanded?: Ref<boolean>
104
- }>
131
+ }
105
132
  export const INJECTION_KEY_DROPDOWN_ACTION = Symbol.for(
106
133
  'dropdownAction',
107
- ) as InjectionKey<{
108
- role?: Ref<`${ActionRoles}`>
109
- expanded?: Ref<boolean>
110
- }>
134
+ ) as InjectionKey<DropdownActionState>
111
135
 
112
136
  // alert
113
137
  export const INJECTION_KEY_ALERT_GROUP = Symbol.for(
114
138
  'alertGroup',
115
- ) as InjectionKey<{
116
- name?: Ref<string | undefined>
117
- bus?: Emitter<{ close: string }>
118
- }>
139
+ ) as InjectionKey<AlertGroupState>
119
140
  export const DEFAULT_ALERT_AUTO_CLOSE = 10000
120
141
  export const DEFAULT_ALERT_MODIFIERS = 'info'
121
142
  export const DEFAULT_ALERT_DISMISSABLE = true
@@ -124,15 +145,9 @@ export const DEFAULT_ALERT_INFO_ICON = 'information'
124
145
  export const DEFAULT_ALERT_SUCCESS_ICON = 'check-circle'
125
146
  export const DEFAULT_ALERT_WARNING_ICON = 'warning'
126
147
  export const DEFAULT_ALERT_DANGER_ICON = 'error'
127
- export const DefaultAlertIconMap = new Map<AlertModifiers, string>([
148
+ export const DefaultAlertIconMap = new Map<AlertModifier, string>([
128
149
  ['success', DEFAULT_ALERT_SUCCESS_ICON],
129
150
  ['info', DEFAULT_ALERT_INFO_ICON],
130
151
  ['warning', DEFAULT_ALERT_WARNING_ICON],
131
152
  ['danger', DEFAULT_ALERT_DANGER_ICON],
132
153
  ])
133
- // {
134
- // success: DEFAULT_ALERT_SUCCESS_ICON,
135
- // info: DEFAULT_ALERT_INFO_ICON,
136
- // warning: DEFAULT_ALERT_WARNING_ICON,
137
- // danger: DEFAULT_ALERT_DANGER_ICON,
138
- // }
@@ -1,7 +1,4 @@
1
- import tooltip from '../directives/v-tooltip'
2
- import contextmenu from '../directives/v-contextmenu'
1
+ import vTooltip from '../directives/v-tooltip'
2
+ import vContextmenu from '../directives/v-contextmenu'
3
3
 
4
- export default {
5
- tooltip,
6
- contextmenu,
7
- }
4
+ export { vTooltip, vContextmenu }
@@ -1,15 +1,24 @@
1
1
  import { render, type Directive, type DirectiveBinding } from 'vue'
2
2
  import VvTooltip from '../components/VvTooltip/VvTooltip.vue'
3
- import type { Side } from '../constants'
3
+ import { Side } from '../constants'
4
4
 
5
- const tooltip: Directive = {
6
- beforeMount(el: HTMLElement, binding: DirectiveBinding) {
7
- const tooltip = h(VvTooltip, {
8
- value: binding.value,
9
- position: binding.arg as Side,
10
- })
11
- render(tooltip, el)
12
- },
13
- }
5
+ const tooltip: Directive = (() => {
6
+ return {
7
+ beforeMount(el: HTMLElement, binding: DirectiveBinding) {
8
+ const tooltip = h(VvTooltip, {
9
+ value: binding.value,
10
+ position: binding.arg as Side,
11
+ })
12
+ render(tooltip, el)
13
+ },
14
+ updated(el: HTMLElement, binding: DirectiveBinding) {
15
+ const tooltip = h(VvTooltip, {
16
+ value: binding.value,
17
+ position: binding.arg as Side,
18
+ })
19
+ render(tooltip, el)
20
+ },
21
+ }
22
+ })()
14
23
 
15
24
  export default tooltip
package/src/index.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import VolverPlugin from './Volver'
2
- import type { Volver } from './Volver'
2
+ import type { Volver, VolverOptions } from './Volver'
3
3
 
4
4
  export { VolverPlugin }
5
+ export * from './types'
6
+ export type { Volver, VolverOptions }
5
7
 
6
8
  // https://vuejs.org/guide/typescript/options-api.html#augmenting-global-properties
7
9
  // Add custom property and extend vue type definition