@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
@@ -5,72 +5,121 @@
5
5
  </script>
6
6
 
7
7
  <script setup lang="ts">
8
- import { nanoid } from 'nanoid'
8
+ import { uid } from 'uid'
9
9
  import { VvAccordionEvents, VvAccordionProps, useGroupProps } from '.'
10
10
 
11
11
  // props, attrs and emit
12
12
  const props = defineProps(VvAccordionProps)
13
13
  const attrs = useAttrs()
14
14
  const emit = defineEmits(VvAccordionEvents)
15
+ const modelValue = useVModel(props, 'modelValue', emit)
15
16
 
16
17
  // data
17
18
  const accordionName = computed(
18
- () => props.name || (attrs?.id as string) || nanoid(),
19
+ () => props.name || (attrs?.id as string) || uid(),
19
20
  )
20
- const {
21
- modifiers,
22
- title,
23
- content,
24
- disabled,
25
- collapse,
21
+ const { title, content, not } = toRefs(props)
22
+ const { isInGroup, modifiers, disabled, bus } = useGroupProps(props)
23
+
24
+ // state
25
+ const isExpanded = ref(false)
26
+ watch(
26
27
  modelValue,
27
- isInGroup,
28
- not,
29
- } = useGroupProps(props, emit)
30
- const localModelValue = ref(false)
31
- const isOpen = computed({
32
- get: () => {
33
- let toReturn = modelValue.value as boolean
34
- if (isInGroup.value) {
35
- if (collapse.value && Array.isArray(modelValue.value)) {
36
- toReturn = modelValue.value.includes(accordionName.value)
37
- } else {
38
- toReturn = modelValue.value === accordionName.value
39
- }
40
- } else if (modelValue.value === undefined) {
41
- // localModelValue is used when the accordion is not in a group
42
- toReturn = localModelValue.value
28
+ (newValue) => {
29
+ if (typeof newValue === 'boolean') {
30
+ isExpanded.value = not.value ? !newValue : newValue
43
31
  }
44
- return not.value ? !toReturn : toReturn
45
32
  },
46
- set: (newValue) => {
47
- if (not.value) {
48
- newValue = !newValue
49
- }
50
- if (isInGroup.value) {
51
- if (collapse.value && Array.isArray(modelValue.value)) {
52
- if (newValue) {
53
- modelValue.value.push(accordionName.value)
54
- return
55
- }
56
- modelValue.value = modelValue.value.filter(
57
- (name: string) => name !== accordionName.value,
58
- )
59
- return
33
+ { immediate: true },
34
+ )
35
+ watch(isExpanded, (newValue) => {
36
+ modelValue.value = not.value ? !newValue : newValue
37
+ })
38
+ bus?.on('toggle', ({ name, value }) => {
39
+ if (name !== accordionName.value) {
40
+ return
41
+ }
42
+ isExpanded.value = value
43
+ })
44
+ const onClick = () => {
45
+ if (disabled.value) {
46
+ return
47
+ }
48
+ if (isInGroup.value) {
49
+ bus?.emit('toggle', {
50
+ name: accordionName.value,
51
+ value: !isExpanded.value,
52
+ })
53
+ return
54
+ }
55
+ isExpanded.value = !isExpanded.value
56
+ }
57
+
58
+ // register / unregister
59
+ watch(
60
+ accordionName,
61
+ (newValue, oldValue) => {
62
+ if (bus) {
63
+ if (oldValue && oldValue !== newValue) {
64
+ bus.emit('unregister', { name: oldValue })
60
65
  }
61
- modelValue.value = newValue ? accordionName.value : null
62
- return
63
- }
64
- // localModelValue is used when the accordion is not in a group
65
- if (
66
- modelValue.value === undefined &&
67
- typeof newValue === 'boolean'
68
- ) {
69
- localModelValue.value = newValue
70
- return
66
+ bus.emit('register', { name: newValue })
71
67
  }
72
- modelValue.value = newValue
73
68
  },
69
+ {
70
+ immediate: true,
71
+ },
72
+ )
73
+ onBeforeUnmount(() => {
74
+ if (bus) {
75
+ bus.emit('unregister', { name: accordionName.value })
76
+ }
77
+ })
78
+
79
+ // methods
80
+ const expand = () => {
81
+ if (isExpanded.value) {
82
+ return
83
+ }
84
+ onClick()
85
+ }
86
+
87
+ const collapse = () => {
88
+ if (!isExpanded.value) {
89
+ return
90
+ }
91
+ onClick()
92
+ }
93
+
94
+ const groupExpand = (name?: string | string[]) => {
95
+ if (!bus) {
96
+ // eslint-disable-next-line no-console
97
+ console.warn(
98
+ `[VvAccordion]: You are trying to expand accordion group of "${accordionName.value}" but it is not in a group`,
99
+ )
100
+ return
101
+ }
102
+ bus.emit('expand', { name })
103
+ }
104
+
105
+ const groupCollapse = (name?: string | string[]) => {
106
+ if (!bus) {
107
+ // eslint-disable-next-line no-console
108
+ console.warn(
109
+ `[VvAccordion]: You are trying to collapse accordion group of "${accordionName.value}" but it is not in a group`,
110
+ )
111
+ return
112
+ }
113
+ bus?.emit('collapse', { name })
114
+ }
115
+
116
+ // expose
117
+ defineExpose({
118
+ isExpanded,
119
+ expand,
120
+ collapse,
121
+ groupExpand,
122
+ groupCollapse,
74
123
  })
75
124
 
76
125
  // styles
@@ -81,27 +130,41 @@
81
130
  disabled: disabled.value,
82
131
  })),
83
132
  )
84
-
85
- // methods
86
- const onClick = useToggle(isOpen)
87
133
  </script>
88
134
 
89
135
  <template>
90
- <details :id="accordionName" :class="bemCssClasses" :open="isOpen">
136
+ <details :id="accordionName" :class="bemCssClasses" :open="isExpanded">
91
137
  <summary
92
138
  :aria-controls="accordionName"
93
- :aria-expanded="isOpen"
139
+ :aria-expanded="isExpanded"
94
140
  class="vv-accordion__summary"
95
141
  @click.prevent="onClick()"
96
142
  >
97
143
  <!-- @slot Slot for title -->
98
- <slot name="summary" v-bind="{ open: isOpen }">
144
+ <slot
145
+ name="summary"
146
+ v-bind="{
147
+ isExpanded,
148
+ expand,
149
+ collapse,
150
+ groupExpand,
151
+ groupCollapse,
152
+ }"
153
+ >
99
154
  {{ title }}
100
155
  </slot>
101
156
  </summary>
102
- <div :aria-hidden="!isOpen" class="vv-accordion__content">
157
+ <div :aria-hidden="!isExpanded" class="vv-accordion__content">
103
158
  <!-- @slot Slot for content -->
104
- <slot name="default" v-bind="{ open: isOpen }">
159
+ <slot
160
+ v-bind="{
161
+ isExpanded,
162
+ expand,
163
+ collapse,
164
+ groupExpand,
165
+ groupCollapse,
166
+ }"
167
+ >
105
168
  {{ content }}
106
169
  </slot>
107
170
  </div>
@@ -1,4 +1,4 @@
1
- import type { ExtractPropTypes, Ref } from 'vue'
1
+ import type { ExtractPropTypes } from 'vue'
2
2
  import type { AccordionGroupState } from '../../types/group'
3
3
  import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
4
4
  import { ModifiersProps } from '@/props'
@@ -40,29 +40,19 @@ export type VvAccordionPropsTypes = ExtractPropTypes<typeof VvAccordionProps>
40
40
  /**
41
41
  * Merges local and group props
42
42
  */
43
- export function useGroupProps(
44
- props: VvAccordionPropsTypes,
45
- emit: (event: string, value: unknown) => void,
46
- ) {
47
- const { group, isInGroup, getGroupOrLocalRef } =
48
- useInjectedGroupState<AccordionGroupState>(
49
- INJECTION_KEY_ACCORDION_GROUP,
50
- )
51
-
52
- // local props
53
- const { title, content } = toRefs(props)
43
+ export function useGroupProps(props: VvAccordionPropsTypes) {
44
+ const { group, isInGroup } = useInjectedGroupState<AccordionGroupState>(
45
+ INJECTION_KEY_ACCORDION_GROUP,
46
+ )
54
47
 
55
48
  // group props
56
- const modelValue = getGroupOrLocalRef('modelValue', props, emit)
57
- const not = getGroupOrLocalRef('not', props) as Ref<boolean>
58
- const collapse = getGroupOrLocalRef('collapse', props) as Ref<boolean>
59
49
  const disabled = computed(() =>
60
- Boolean(props.disabled || group?.value?.disabled.value),
50
+ Boolean(props.disabled || group?.disabled.value),
61
51
  )
62
52
  // merge local and group modifiers
63
53
  const modifiers = computed(() => {
64
54
  let localModifiers = props.modifiers
65
- let groupModifiers = group?.value.modifiers.value
55
+ let groupModifiers = group?.modifiers.value
66
56
 
67
57
  const toReturn = new Set<string>()
68
58
  if (localModifiers) {
@@ -82,15 +72,10 @@ export function useGroupProps(
82
72
 
83
73
  return {
84
74
  // group props
85
- modelValue,
86
- not,
87
75
  isInGroup,
88
76
  group,
89
- collapse,
90
77
  modifiers,
91
78
  disabled,
92
- // local props
93
- title,
94
- content,
79
+ bus: group?.bus,
95
80
  }
96
81
  }
@@ -5,78 +5,183 @@
5
5
  </script>
6
6
 
7
7
  <script setup lang="ts">
8
- import type { Ref } from 'vue'
9
- import type { AccordionGroupState } from '../../types/group'
8
+ import mitt from 'mitt'
9
+ import type {
10
+ AccordionGroupState,
11
+ AccordionGroupBusEvents,
12
+ } from '../../types/group'
10
13
  import { INJECTION_KEY_ACCORDION_GROUP } from '../../constants'
11
14
  import VvAccordion from '../VvAccordion/VvAccordion.vue'
12
15
  import { VvAccordionGroupProps, VvAccordionGroupEvents } from '.'
13
16
 
14
17
  // props and emit
15
18
  const props = defineProps(VvAccordionGroupProps)
19
+ // eslint-disable-next-line
16
20
  const emit = defineEmits(VvAccordionGroupEvents)
17
21
 
18
22
  // data
19
- const { disabled, collapse, modifiers, itemModifiers, items, not } =
20
- toRefs(props)
23
+ const {
24
+ disabled,
25
+ modifiers,
26
+ itemModifiers,
27
+ items,
28
+ storageKey,
29
+ storageType,
30
+ } = toRefs(props)
21
31
  watchEffect(() => {
22
- if (typeof props.modelValue === 'string' && collapse.value) {
23
- // eslint-disable-next-line
32
+ if (typeof props.modelValue === 'string' && props.collapse) {
33
+ // eslint-disable-next-line no-console
24
34
  console.warn(
25
35
  `[VvAccordionGroup]: modelValue is a string but collapse is true.`,
26
36
  )
27
37
  }
28
38
  })
29
- let localModelValue: Ref<string[]> = ref([])
30
- watch(
31
- () => props.storeKey,
32
- (newKey) => {
33
- if (newKey) {
34
- localModelValue = useStorage(newKey, localModelValue.value)
35
- } else {
36
- localModelValue = ref([])
37
- }
38
- },
39
- { immediate: true },
39
+
40
+ const accordionNames = reactive(new Set<string>())
41
+ const storageModelValue = usePersistence<string | string[] | undefined>(
42
+ storageKey,
43
+ storageType,
44
+ [],
40
45
  )
41
- const modelValue = computed({
46
+ const localModelValue = computed({
42
47
  get: () => {
43
- if (props.modelValue !== undefined) {
44
- if (!collapse.value) {
45
- return Array.isArray(props.modelValue)
46
- ? props.modelValue[0]
47
- : props.modelValue
48
- }
48
+ if (props.modelValue !== null && props.modelValue !== undefined) {
49
49
  return props.modelValue
50
50
  }
51
- return !collapse.value
52
- ? localModelValue.value?.[0]
53
- : localModelValue.value
51
+ return storageModelValue.value
54
52
  },
55
53
  set: (newValue) => {
56
- if (props.modelValue !== undefined) {
57
- if (
58
- (Array.isArray(props.modelValue) || collapse.value) &&
59
- !Array.isArray(newValue)
60
- ) {
61
- newValue = [newValue]
54
+ emit('update:modelValue', newValue)
55
+ storageModelValue.value = newValue
56
+ },
57
+ })
58
+ const expandedAccordions = computed<Set<string>>({
59
+ get: () => {
60
+ if (localModelValue.value === undefined) {
61
+ return new Set<string>()
62
+ }
63
+ let toReturn = new Set<string>()
64
+ if (props.not) {
65
+ if (typeof localModelValue.value === 'string') {
66
+ toReturn = new Set<string>(
67
+ [...accordionNames].filter(
68
+ (name) => name !== localModelValue.value,
69
+ ),
70
+ )
71
+ } else if (Array.isArray(localModelValue.value)) {
72
+ toReturn = new Set<string>(
73
+ [...accordionNames].filter(
74
+ (name) =>
75
+ !(localModelValue.value as string[]).includes(
76
+ name,
77
+ ),
78
+ ),
79
+ )
62
80
  }
63
- return emit('update:modelValue', newValue)
81
+ } else if (typeof localModelValue.value === 'string') {
82
+ toReturn = new Set<string>([localModelValue.value])
83
+ } else if (Array.isArray(localModelValue.value)) {
84
+ toReturn = new Set<string>(localModelValue.value)
85
+ }
86
+ return toReturn
87
+ },
88
+ set: (newValue) => {
89
+ if (props.not) {
90
+ localModelValue.value = [...accordionNames].filter(
91
+ (name) => !newValue.has(name),
92
+ )
93
+ return
94
+ }
95
+ if (props.collapse) {
96
+ localModelValue.value = [...newValue]
97
+ return
64
98
  }
65
- localModelValue.value = Array.isArray(newValue)
66
- ? newValue
67
- : [newValue]
99
+ localModelValue.value = newValue.values().next().value
68
100
  },
69
101
  })
102
+ onMounted(() => {
103
+ if (props.not && localModelValue.value === undefined) {
104
+ localModelValue.value = props.collapse
105
+ ? []
106
+ : [...accordionNames.values()].splice(1, accordionNames.size)
107
+ }
108
+ nextTick(() => {
109
+ for (const name of accordionNames) {
110
+ bus.emit('toggle', {
111
+ name,
112
+ value: expandedAccordions.value.has(name),
113
+ })
114
+ }
115
+ })
116
+ })
70
117
 
71
118
  // provide
72
- useProvideGroupState<AccordionGroupState>({
73
- key: INJECTION_KEY_ACCORDION_GROUP,
74
- modelValue,
119
+ const bus = mitt<AccordionGroupBusEvents>()
120
+ useProvideGroupState<AccordionGroupState>(INJECTION_KEY_ACCORDION_GROUP, {
75
121
  disabled,
76
- collapse,
77
122
  modifiers: itemModifiers,
78
- not,
123
+ bus,
124
+ })
125
+ bus.on('register', ({ name }) => {
126
+ accordionNames.add(name)
79
127
  })
128
+ bus.on('unregister', ({ name }) => {
129
+ accordionNames.delete(name)
130
+ })
131
+ bus.on('toggle', ({ name, value }) => {
132
+ const newValue = new Set<string>(expandedAccordions.value)
133
+ if (value) {
134
+ if (!props.collapse) {
135
+ for (const item of newValue) {
136
+ if (item !== name) {
137
+ bus.emit('toggle', { name: item, value: false })
138
+ }
139
+ }
140
+ newValue.clear()
141
+ }
142
+ newValue.add(name)
143
+ expandedAccordions.value = newValue
144
+ return
145
+ }
146
+ newValue.delete(name)
147
+ expandedAccordions.value = newValue
148
+ })
149
+ const expand = (name?: string | string[]) => {
150
+ if (typeof name === 'string') {
151
+ bus.emit('toggle', { name, value: true })
152
+ return
153
+ }
154
+ if (Array.isArray(name)) {
155
+ for (const item of name) {
156
+ bus.emit('toggle', { name: item, value: true })
157
+ }
158
+ return
159
+ }
160
+ for (const item of accordionNames) {
161
+ bus.emit('toggle', { name: item, value: true })
162
+ }
163
+ }
164
+ bus.on('expand', ({ name }) => expand(name))
165
+
166
+ const collapse = (name?: string | string[]) => {
167
+ if (typeof name === 'string') {
168
+ bus.emit('toggle', { name, value: false })
169
+ return
170
+ }
171
+ if (Array.isArray(name)) {
172
+ for (const item of name) {
173
+ bus.emit('toggle', { name: item, value: false })
174
+ }
175
+ return
176
+ }
177
+ for (const item of accordionNames) {
178
+ bus.emit('toggle', { name: item, value: false })
179
+ }
180
+ }
181
+ bus.on('collapse', ({ name }) => collapse(name))
182
+
183
+ // expose
184
+ defineExpose({ expandedAccordions, expand, collapse })
80
185
 
81
186
  // styles
82
187
  const bemCssClasses = useModifiers(
@@ -91,7 +196,13 @@
91
196
  <template>
92
197
  <div :class="bemCssClasses">
93
198
  <!-- @slot Default slot -->
94
- <slot>
199
+ <slot
200
+ v-bind="{
201
+ expandedAccordions,
202
+ expand,
203
+ collapse,
204
+ }"
205
+ >
95
206
  <VvAccordion
96
207
  v-for="item in items"
97
208
  :key="item.title"
@@ -101,13 +212,19 @@
101
212
  content: item.content,
102
213
  }"
103
214
  >
104
- <template #header="data">
215
+ <template
216
+ v-if="$slots[`summary::${item.name}`]"
217
+ #summary="data"
218
+ >
105
219
  <!-- @slot Slot for accordion header -->
106
- <slot v-bind="data" :name="`header::${item.name}`" />
220
+ <slot v-bind="data" :name="`summary::${item.name}`" />
107
221
  </template>
108
- <template #details="data">
222
+ <template
223
+ v-if="$slots[`content::${item.name}`]"
224
+ #default="data"
225
+ >
109
226
  <!-- @slot Slot for accordion details -->
110
- <slot v-bind="data" :name="`details::${item.name}`" />
227
+ <slot v-bind="data" :name="`content::${item.name}`" />
111
228
  </template>
112
229
  </VvAccordion>
113
230
  </slot>
@@ -1,4 +1,4 @@
1
- import { ModifiersProps } from '@/props'
1
+ import { ModifiersProps, StorageProps } from '@/props'
2
2
 
3
3
  export interface VvAccordionGroupItem {
4
4
  title: string
@@ -10,10 +10,14 @@ export interface VvAccordionGroupItem {
10
10
 
11
11
  export const VvAccordionGroupProps = {
12
12
  ...ModifiersProps,
13
+ ...StorageProps,
13
14
  /**
14
15
  * VModel
15
16
  */
16
- modelValue: [String, Array],
17
+ modelValue: {
18
+ type: [String, Array] as PropType<string | string[] | undefined>,
19
+ default: undefined,
20
+ },
17
21
  /**
18
22
  * Accordion items
19
23
  * @type VvAccordionGroupItem
@@ -41,10 +45,6 @@ export const VvAccordionGroupProps = {
41
45
  * If true, the accordion items will be opened by default
42
46
  */
43
47
  not: Boolean,
44
- /**
45
- * Enable local storage persistence
46
- */
47
- storeKey: String,
48
48
  }
49
49
 
50
50
  export const VvAccordionGroupEvents = ['update:modelValue']
@@ -11,6 +11,7 @@
11
11
  // props and emit
12
12
  const props = defineProps(VvActionProps)
13
13
  const emit = defineEmits(VvActionEvents)
14
+ const instance = getCurrentInstance()
14
15
 
15
16
  // inject plugin
16
17
  const volver = useVolver()
@@ -55,7 +56,7 @@
55
56
  case props.href !== undefined:
56
57
  return ActionTag.a
57
58
  default:
58
- return ActionTag.button
59
+ return props.defaultTag // button
59
60
  }
60
61
  })
61
62
 
@@ -85,12 +86,14 @@
85
86
  to: props.to,
86
87
  target: props.target,
87
88
  }
88
- default:
89
+ case ActionTag.button:
89
90
  return {
90
91
  ...toReturn,
91
92
  type: props.type,
92
93
  disabled: props.disabled,
93
94
  }
95
+ default:
96
+ return toReturn
94
97
  }
95
98
  })
96
99
 
@@ -102,24 +105,33 @@
102
105
  e.preventDefault()
103
106
  return
104
107
  }
108
+ if (instance?.vnode.props?.onClick) {
109
+ emit('click', e)
110
+ return
111
+ }
105
112
  dropdownEventBus?.emit('click', e)
106
- emit('click', e)
107
113
  }
108
114
 
109
115
  /**
110
116
  * @description Catch mouseover event
111
117
  */
112
118
  const onMouseover = (e: Event) => {
119
+ if (instance?.vnode.props?.onMouseover) {
120
+ emit('mouseover', e)
121
+ return
122
+ }
113
123
  dropdownEventBus?.emit('mouseover', e)
114
- emit('mouseover', e)
115
124
  }
116
125
 
117
126
  /**
118
127
  * @description Catch mouseleave event
119
128
  */
120
129
  const onMouseleave = (e: Event) => {
130
+ if (instance?.vnode.props?.onMouseleave) {
131
+ emit('mouseleave', e)
132
+ return
133
+ }
121
134
  dropdownEventBus?.emit('mouseleave', e)
122
- emit('mouseleave', e)
123
135
  }
124
136
  </script>
125
137
 
@@ -1,11 +1,18 @@
1
- import { IconProps, IdProps, ModifiersProps } from '@/props'
2
- import type { ExtractPropTypes, PropType } from 'vue'
3
- import { withModifiers } from 'vue'
1
+ import { type ExtractPropTypes, type PropType, withModifiers } from 'vue'
2
+ import { AlertRole } from '@/constants'
3
+ import { IconProps, IdProps } from '@/props'
4
+ import type { AlertModifier } from '@/types'
4
5
 
5
6
  export const VvAlertProps = {
6
7
  ...IdProps,
7
- ...ModifiersProps,
8
8
  ...IconProps,
9
+ /**
10
+ * Component BEM modifiers
11
+ */
12
+ modifiers: {
13
+ type: [String, Array] as PropType<AlertModifier | AlertModifier[]>,
14
+ default: undefined,
15
+ },
9
16
  /**
10
17
  * The alert is dismissable
11
18
  * @default false
@@ -69,8 +76,8 @@ export const VvAlertProps = {
69
76
  * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alertdialog_role
70
77
  */
71
78
  role: {
72
- type: String as PropType<'alert' | 'alertdialog'>,
73
- default: 'alert',
79
+ type: String as PropType<`${AlertRole}`>,
80
+ default: AlertRole.alert,
74
81
  },
75
82
  }
76
83
 
@@ -86,9 +93,7 @@ export const useVvAlert = (
86
93
  const hasTitleId = computed(() => `${hasId.value}-title`)
87
94
 
88
95
  // icon
89
- const hasIcon = computed(() =>
90
- typeof props.icon === 'string' ? { name: props.icon } : props.icon,
91
- )
96
+ const { hasIcon } = useComponentIcon(computed(() => props.icon))
92
97
 
93
98
  // props
94
99
  const hasClass = useModifiers(