@volverjs/ui-vue 0.0.3 → 0.0.5-beta.1

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 (236) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +54 -15
  3. package/auto-imports.d.ts +12 -3
  4. package/bin/icons.cjs +1 -73
  5. package/dist/Volver.d.ts +23 -11
  6. package/dist/components/VvAccordion/VvAccordion.es.js +180 -74
  7. package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
  8. package/dist/components/VvAccordion/VvAccordion.vue.d.ts +4 -1
  9. package/dist/components/VvAccordion/index.d.ts +8 -3
  10. package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +280 -122
  11. package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
  12. package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +15 -12
  13. package/dist/components/VvAccordionGroup/index.d.ts +8 -0
  14. package/dist/components/VvAction/VvAction.es.js +338 -0
  15. package/dist/components/VvAction/VvAction.umd.js +1 -0
  16. package/dist/components/VvAction/VvAction.vue.d.ts +63 -0
  17. package/dist/components/VvAction/index.d.ts +24 -0
  18. package/dist/components/VvBadge/VvBadge.es.js +251 -22
  19. package/dist/components/VvBadge/VvBadge.umd.js +1 -1
  20. package/dist/components/VvBadge/VvBadge.vue.d.ts +2 -2
  21. package/dist/components/VvBadge/index.d.ts +1 -1
  22. package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +280 -62
  23. package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
  24. package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +11 -11
  25. package/dist/components/VvBreadcrumb/index.d.ts +1 -1
  26. package/dist/components/VvButton/VvButton.es.js +720 -261
  27. package/dist/components/VvButton/VvButton.umd.js +1 -1
  28. package/dist/components/VvButton/VvButton.vue.d.ts +54 -54
  29. package/dist/components/VvButton/index.d.ts +30 -75
  30. package/dist/components/VvButtonGroup/VvButtonGroup.es.js +296 -49
  31. package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
  32. package/dist/components/VvButtonGroup/VvButtonGroup.vue.d.ts +2 -2
  33. package/dist/components/VvButtonGroup/index.d.ts +1 -1
  34. package/dist/components/VvCard/VvCard.es.js +60 -28
  35. package/dist/components/VvCard/VvCard.umd.js +1 -1
  36. package/dist/components/VvCheckbox/VvCheckbox.es.js +630 -172
  37. package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
  38. package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
  39. package/dist/components/VvCheckbox/index.d.ts +6 -6
  40. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +736 -228
  41. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
  42. package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +9 -9
  43. package/dist/components/VvCheckboxGroup/index.d.ts +4 -4
  44. package/dist/components/VvCombobox/VvCombobox.es.js +1673 -768
  45. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  46. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +159 -61
  47. package/dist/components/VvCombobox/index.d.ts +54 -23
  48. package/dist/components/VvDialog/VvDialog.es.js +426 -115
  49. package/dist/components/VvDialog/VvDialog.umd.js +1 -1
  50. package/dist/components/VvDialog/VvDialog.vue.d.ts +12 -3
  51. package/dist/components/VvDialog/index.d.ts +4 -1
  52. package/dist/components/VvDropdown/VvDropdown.es.js +504 -190
  53. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  54. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +114 -42
  55. package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +61 -0
  56. package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +52 -0
  57. package/dist/components/VvDropdown/index.d.ts +35 -14
  58. package/dist/components/VvDropdownAction/VvDropdownAction.es.js +454 -0
  59. package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -0
  60. package/dist/components/VvDropdownItem/VvDropdownItem.es.js +48 -18
  61. package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
  62. package/dist/components/VvDropdownOption/VvDropdownOption.es.js +361 -0
  63. package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -0
  64. package/dist/components/VvIcon/VvIcon.es.js +116 -52
  65. package/dist/components/VvIcon/VvIcon.umd.js +1 -1
  66. package/dist/components/VvIcon/VvIcon.vue.d.ts +7 -7
  67. package/dist/components/VvIcon/index.d.ts +2 -2
  68. package/dist/components/VvInputText/VvInputPasswordAction.d.ts +2 -2
  69. package/dist/components/VvInputText/VvInputStepAction.d.ts +1 -1
  70. package/dist/components/VvInputText/VvInputText.es.js +1054 -376
  71. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  72. package/dist/components/VvInputText/VvInputText.vue.d.ts +107 -20
  73. package/dist/components/VvInputText/VvInputTextActions.d.ts +1 -1
  74. package/dist/components/VvInputText/index.d.ts +67 -3
  75. package/dist/components/VvProgress/VvProgress.es.js +254 -23
  76. package/dist/components/VvProgress/VvProgress.umd.js +1 -1
  77. package/dist/components/VvProgress/VvProgress.vue.d.ts +2 -2
  78. package/dist/components/VvProgress/index.d.ts +1 -1
  79. package/dist/components/VvRadio/VvRadio.es.js +568 -137
  80. package/dist/components/VvRadio/VvRadio.umd.js +1 -1
  81. package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
  82. package/dist/components/VvRadio/index.d.ts +6 -6
  83. package/dist/components/VvRadioGroup/VvRadioGroup.es.js +674 -193
  84. package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
  85. package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +9 -9
  86. package/dist/components/VvRadioGroup/index.d.ts +4 -4
  87. package/dist/components/VvSelect/VvSelect.es.js +703 -251
  88. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  89. package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -17
  90. package/dist/components/VvSelect/index.d.ts +8 -8
  91. package/dist/components/VvTextarea/VvTextarea.es.js +747 -272
  92. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  93. package/dist/components/VvTextarea/VvTextarea.vue.d.ts +21 -14
  94. package/dist/components/VvTextarea/index.d.ts +7 -7
  95. package/dist/components/VvTooltip/VvTooltip.es.js +252 -24
  96. package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
  97. package/dist/components/VvTooltip/VvTooltip.vue.d.ts +7 -7
  98. package/dist/components/VvTooltip/index.d.ts +2 -2
  99. package/dist/components/index.es.js +3676 -2007
  100. package/dist/components/index.umd.js +1 -1
  101. package/dist/composables/dropdown/useInjectDropdown.d.ts +1 -1
  102. package/dist/composables/dropdown/useProvideDropdown.d.ts +3 -3
  103. package/dist/composables/group/useInjectedGroupState.d.ts +2 -2
  104. package/dist/composables/group/useProvideGroupState.d.ts +1 -1
  105. package/dist/composables/useComponentFocus.d.ts +1 -1
  106. package/dist/composables/useComponentIcon.d.ts +7 -7
  107. package/dist/composables/useDebouncedInput.d.ts +4 -1
  108. package/dist/composables/useDefaults.d.ts +2 -0
  109. package/dist/composables/useModifiers.d.ts +1 -1
  110. package/dist/composables/useOptions.d.ts +2 -2
  111. package/dist/composables/useTextCount.d.ts +3 -3
  112. package/dist/composables/useUniqueId.d.ts +1 -1
  113. package/dist/composables/useVolver.d.ts +1 -1
  114. package/dist/constants.d.ts +30 -0
  115. package/dist/directives/index.es.js +288 -0
  116. package/dist/directives/index.umd.js +1 -0
  117. package/dist/directives/v-tooltip.es.js +285 -0
  118. package/dist/directives/v-tooltip.umd.js +1 -0
  119. package/dist/icons.es.js +38 -23
  120. package/dist/icons.umd.js +1 -1
  121. package/dist/index.d.ts +0 -1
  122. package/dist/index.es.js +115 -3269
  123. package/dist/index.umd.js +1 -1
  124. package/dist/props/index.d.ts +215 -23
  125. package/dist/resolvers/unplugin.d.ts +14 -8
  126. package/dist/resolvers/unplugin.es.js +94 -33
  127. package/dist/resolvers/unplugin.umd.js +1 -1
  128. package/dist/stories/Combobox/Combobox.settings.d.ts +44 -0
  129. package/dist/stories/Dropdown/Dropdown.settings.d.ts +3 -2
  130. package/dist/stories/InputText/InputText.settings.d.ts +53 -0
  131. package/dist/stories/argTypes.d.ts +1 -1
  132. package/package.json +167 -63
  133. package/src/Volver.ts +60 -26
  134. package/src/assets/icons/detailed.json +1 -1
  135. package/src/assets/icons/normal.json +1 -1
  136. package/src/assets/icons/simple.json +1 -1
  137. package/src/components/VvAccordion/VvAccordion.vue +19 -22
  138. package/src/components/VvAccordion/index.ts +12 -4
  139. package/src/components/VvAccordionGroup/VvAccordionGroup.vue +19 -10
  140. package/src/components/VvAccordionGroup/index.ts +8 -0
  141. package/src/components/VvAction/VvAction.vue +144 -0
  142. package/src/components/VvAction/index.ts +5 -0
  143. package/src/components/VvBadge/VvBadge.vue +2 -2
  144. package/src/components/VvBadge/index.ts +1 -1
  145. package/src/components/VvBreadcrumb/VvBreadcrumb.vue +3 -3
  146. package/src/components/VvButton/VvButton.vue +41 -124
  147. package/src/components/VvButton/index.ts +16 -88
  148. package/src/components/VvButtonGroup/VvButtonGroup.vue +4 -7
  149. package/src/components/VvButtonGroup/index.ts +1 -1
  150. package/src/components/VvCard/VvCard.vue +2 -2
  151. package/src/components/VvCheckbox/VvCheckbox.vue +3 -7
  152. package/src/components/VvCheckbox/index.ts +11 -7
  153. package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +7 -10
  154. package/src/components/VvCheckboxGroup/index.ts +1 -1
  155. package/src/components/VvCombobox/VvCombobox.vue +85 -57
  156. package/src/components/VvCombobox/index.ts +12 -10
  157. package/src/components/VvDialog/VvDialog.vue +28 -11
  158. package/src/components/VvDialog/index.ts +5 -2
  159. package/src/components/VvDropdown/VvDropdown.vue +6 -5
  160. package/src/components/VvDropdown/VvDropdownAction.vue +46 -0
  161. package/src/components/VvDropdown/VvDropdownOption.vue +72 -0
  162. package/src/components/VvDropdown/index.ts +6 -11
  163. package/src/components/VvIcon/VvIcon.vue +3 -3
  164. package/src/components/VvIcon/index.ts +3 -3
  165. package/src/components/VvInputText/VvInputClearAction.ts +2 -2
  166. package/src/components/VvInputText/VvInputPasswordAction.ts +3 -4
  167. package/src/components/VvInputText/VvInputStepAction.ts +3 -2
  168. package/src/components/VvInputText/VvInputText.vue +128 -35
  169. package/src/components/VvInputText/VvInputTextActions.ts +5 -8
  170. package/src/components/VvInputText/index.ts +62 -1
  171. package/src/components/VvProgress/VvProgress.vue +2 -2
  172. package/src/components/VvProgress/index.ts +1 -1
  173. package/src/components/VvRadio/VvRadio.vue +3 -7
  174. package/src/components/VvRadio/index.ts +11 -7
  175. package/src/components/VvRadioGroup/VvRadioGroup.vue +7 -10
  176. package/src/components/VvRadioGroup/index.ts +1 -1
  177. package/src/components/VvSelect/VvSelect.vue +4 -4
  178. package/src/components/VvSelect/index.ts +3 -5
  179. package/src/components/VvTextarea/VvTextarea.vue +4 -4
  180. package/src/components/VvTextarea/index.ts +1 -1
  181. package/src/components/VvTooltip/VvTooltip.vue +2 -2
  182. package/src/components/VvTooltip/index.ts +3 -3
  183. package/src/composables/dropdown/useInjectDropdown.ts +2 -2
  184. package/src/composables/dropdown/useProvideDropdown.ts +9 -11
  185. package/src/composables/group/useInjectedGroupState.ts +1 -1
  186. package/src/composables/group/useProvideGroupState.ts +1 -1
  187. package/src/composables/useComponentIcon.ts +1 -1
  188. package/src/composables/useDebouncedInput.ts +10 -3
  189. package/src/composables/useDefaults.ts +89 -0
  190. package/src/composables/useModifiers.ts +8 -9
  191. package/src/composables/useOptions.ts +1 -1
  192. package/src/composables/useVolver.ts +2 -2
  193. package/src/constants.ts +36 -0
  194. package/src/directives/index.ts +1 -1
  195. package/src/directives/v-tooltip.ts +2 -2
  196. package/src/index.ts +0 -2
  197. package/src/props/index.ts +111 -19
  198. package/src/resolvers/unplugin.ts +96 -49
  199. package/src/stories/Accordion/Accordion.stories.mdx +8 -2
  200. package/src/stories/Accordion/Accordion.test.ts +21 -15
  201. package/src/stories/Accordion/AccordionSlots.stories.mdx +8 -8
  202. package/src/stories/AccordionGroup/AccordionGroup.stories.mdx +17 -1
  203. package/src/stories/AccordionGroup/AccordionGroup.test.ts +18 -12
  204. package/src/stories/AccordionGroup/AccordionGroupSlots.stories.mdx +3 -2
  205. package/src/stories/Breadcrumb/Breadcrumb.stories.mdx +2 -1
  206. package/src/stories/Button/Button.stories.mdx +4 -2
  207. package/src/stories/Button/Button.test.ts +3 -1
  208. package/src/stories/Button/ButtonModifiers.stories.mdx +2 -2
  209. package/src/stories/Button/ButtonSlots.stories.mdx +8 -7
  210. package/src/stories/Button/ButtonState.stories.mdx +2 -11
  211. package/src/stories/Card/Card.stories.mdx +2 -1
  212. package/src/stories/Checkbox/Checkbox.stories.mdx +2 -1
  213. package/src/stories/CheckboxGroup/CheckboxGroup.stories.mdx +2 -1
  214. package/src/stories/CheckboxGroup/CheckboxGroupSlots.stories.mdx +2 -1
  215. package/src/stories/Combobox/Combobox.settings.ts +44 -0
  216. package/src/stories/Combobox/Combobox.stories.mdx +40 -1
  217. package/src/stories/Dialog/Dialog.stories.mdx +2 -1
  218. package/src/stories/Dropdown/Dropdown.settings.ts +3 -2
  219. package/src/stories/Dropdown/Dropdown.stories.mdx +14 -12
  220. package/src/stories/Dropdown/DropdownMultilevel.stories.mdx +56 -0
  221. package/src/stories/Dropdown/DropdownSlots.stories.mdx +14 -13
  222. package/src/stories/Icon/Icon.stories.mdx +2 -1
  223. package/src/stories/Icon/IconsCollection.stories.mdx +2 -1
  224. package/src/stories/InputText/InputText.settings.ts +53 -0
  225. package/src/stories/InputText/InputText.stories.mdx +42 -1
  226. package/src/stories/InputText/InputText.test.ts +5 -2
  227. package/src/stories/Progress/Progress.stories.mdx +2 -1
  228. package/src/stories/Radio/Radio.stories.mdx +2 -1
  229. package/src/stories/RadioGroup/RadioGroup.stories.mdx +2 -1
  230. package/src/stories/RadioGroup/RadioGroupSlots.stories.mdx +2 -1
  231. package/src/stories/Select/Select.stories.mdx +2 -1
  232. package/src/stories/Textarea/Textarea.stories.mdx +2 -1
  233. package/src/stories/Tooltip/Tooltip.stories.mdx +2 -1
  234. package/src/stories/Tooltip/TooltipDirective.stories.mdx +2 -1
  235. package/src/stories/argTypes.ts +2 -2
  236. package/src/types/group.d.ts +5 -0
@@ -1,27 +1,145 @@
1
- import { defineComponent as de, openBlock as A, createElementBlock as N, Fragment as ce, createVNode as V, unref as r, withCtx as j, renderSlot as c, normalizeProps as p, guardReactiveProps as v, Transition as pe, withDirectives as ve, createElementVNode as C, normalizeStyle as W, normalizeClass as me, createCommentVNode as he, mergeProps as be, vShow as ge } from "vue";
2
- import { autoPlacement as z, flip as R, shift as F, size as I, offset as y, arrow as ye, useFloating as we, autoUpdate as xe } from "@floating-ui/vue";
3
- var w = /* @__PURE__ */ ((t) => (t.left = "left", t.right = "right", t.top = "top", t.bottom = "bottom", t))(w || {}), K = /* @__PURE__ */ ((t) => (t.topStart = "top-start", t.topEnd = "top-end", t.bottomStart = "bottom-start", t.bottomEnd = "bottom-end", t.leftStart = "left-start", t.leftEnd = "left-end", t.rightStart = "right-start", t.rightEnd = "right-end", t))(K || {}), x = /* @__PURE__ */ ((t) => (t.before = "before", t.after = "after", t))(x || {});
4
- const Ee = {
1
+ import { computed, defineComponent, h, Fragment, provide, unref, toRefs, useAttrs, ref, watch, nextTick, openBlock, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, withDirectives, createElementVNode, normalizeStyle, normalizeClass, createCommentVNode, mergeProps, vShow } from "vue";
2
+ import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
3
+ import { nanoid } from "nanoid";
4
+ import { useVModel, onClickOutside, useFocusWithin, onKeyStroke } from "@vueuse/core";
5
+ import mitt from "mitt";
6
+ var Side = /* @__PURE__ */ ((Side2) => {
7
+ Side2["left"] = "left";
8
+ Side2["right"] = "right";
9
+ Side2["top"] = "top";
10
+ Side2["bottom"] = "bottom";
11
+ return Side2;
12
+ })(Side || {});
13
+ var Placement = /* @__PURE__ */ ((Placement2) => {
14
+ Placement2["topStart"] = "top-start";
15
+ Placement2["topEnd"] = "top-end";
16
+ Placement2["bottomStart"] = "bottom-start";
17
+ Placement2["bottomEnd"] = "bottom-end";
18
+ Placement2["leftStart"] = "left-start";
19
+ Placement2["leftEnd"] = "left-end";
20
+ Placement2["rightStart"] = "right-start";
21
+ Placement2["rightEnd"] = "right-end";
22
+ return Placement2;
23
+ })(Placement || {});
24
+ var Position = /* @__PURE__ */ ((Position2) => {
25
+ Position2["before"] = "before";
26
+ Position2["after"] = "after";
27
+ return Position2;
28
+ })(Position || {});
29
+ var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
30
+ ButtonType2["button"] = "button";
31
+ ButtonType2["submit"] = "submit";
32
+ ButtonType2["reset"] = "reset";
33
+ return ButtonType2;
34
+ })(ButtonType || {});
35
+ var DropdownRole = /* @__PURE__ */ ((DropdownRole2) => {
36
+ DropdownRole2["listbox"] = "listbox";
37
+ DropdownRole2["menu"] = "menu";
38
+ return DropdownRole2;
39
+ })(DropdownRole || {});
40
+ var DropdownItemRole = /* @__PURE__ */ ((DropdownItemRole2) => {
41
+ DropdownItemRole2["option"] = "option";
42
+ DropdownItemRole2["presentation"] = "presentation";
43
+ return DropdownItemRole2;
44
+ })(DropdownItemRole || {});
45
+ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
46
+ AnchorTarget2["_blank"] = "_blank";
47
+ AnchorTarget2["_self"] = "_self";
48
+ AnchorTarget2["_parent"] = "_parent";
49
+ AnchorTarget2["_top"] = "_top";
50
+ return AnchorTarget2;
51
+ })(AnchorTarget || {});
52
+ const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for("dropdownTrigger");
53
+ const INJECTION_KEY_DROPDOWN_ITEM = Symbol.for("dropdownItem");
54
+ const LinkProps = {
55
+ /**
56
+ * The router-link/nuxt-link property, if it is defined the button is rendered as a ruouter-link or nuxt-link.
57
+ * @see Documentation of [router-link](https://router.vuejs.org/api/#router-link) and [nuxt-link](https://nuxtjs.org/api/components-nuxt-link/)
58
+ */
59
+ to: {
60
+ type: [String, Object]
61
+ },
62
+ /**
63
+ * Anchor href
64
+ */
65
+ href: String,
66
+ /**
67
+ * Anchor target
68
+ */
69
+ target: {
70
+ type: String,
71
+ validator: (value) => Object.values(AnchorTarget).includes(value)
72
+ },
73
+ /**
74
+ * Anchor rel
75
+ */
76
+ rel: {
77
+ type: String,
78
+ default: "noopener noreferrer"
79
+ }
80
+ };
81
+ const DisabledProps = {
82
+ /**
83
+ * Whether the form control is disabled
84
+ */
85
+ disabled: Boolean
86
+ };
87
+ const ActiveProps = {
88
+ /**
89
+ * Whether the item is active
90
+ */
91
+ active: Boolean
92
+ };
93
+ const PressedProps = {
94
+ /**
95
+ * Whether the item is pressed
96
+ */
97
+ pressed: Boolean
98
+ };
99
+ const LabelProps = {
100
+ /**
101
+ * The item label
102
+ */
103
+ label: [String, Number]
104
+ };
105
+ const ModifiersProps = {
5
106
  /**
6
107
  * Component BEM modifiers
7
108
  */
8
109
  modifiers: [String, Array]
9
110
  };
10
- x.before;
11
- const Se = {
111
+ ({
112
+ /**
113
+ * VvIcon name or props
114
+ * @see VVIcon
115
+ */
116
+ icon: { type: [String, Object] },
117
+ /**
118
+ * VvIcon position
119
+ */
120
+ iconPosition: {
121
+ type: String,
122
+ default: Position.before,
123
+ validation: (value) => Object.values(Position).includes(value)
124
+ }
125
+ });
126
+ const IdProps = {
12
127
  /**
13
128
  * Global attribute id
14
129
  * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
15
130
  */
16
131
  id: [String, Number]
17
- }, ke = {
132
+ };
133
+ const DropdownProps = {
18
134
  /**
19
135
  * Dropdown placement
20
136
  */
21
137
  placement: {
22
138
  type: String,
23
- default: w.bottom,
24
- validator: (t) => Object.values(w).includes(t) || Object.values(K).includes(t)
139
+ default: Side.bottom,
140
+ validator: (value) => {
141
+ return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
142
+ }
25
143
  },
26
144
  /**
27
145
  * Dropdown show / hide transition name
@@ -43,7 +161,7 @@ const Se = {
43
161
  */
44
162
  shift: {
45
163
  type: [Boolean, Object],
46
- default: !1
164
+ default: false
47
165
  },
48
166
  /**
49
167
  * Flip dropdown position if there is no space in the default position
@@ -51,7 +169,7 @@ const Se = {
51
169
  */
52
170
  flip: {
53
171
  type: [Boolean, Object],
54
- default: !0
172
+ default: true
55
173
  },
56
174
  /**
57
175
  * Size of the dropdown
@@ -67,7 +185,7 @@ const Se = {
67
185
  */
68
186
  autoPlacement: {
69
187
  type: [Boolean, Object],
70
- default: !1
188
+ default: false
71
189
  },
72
190
  /**
73
191
  * Add arrow to the dropdown
@@ -75,21 +193,21 @@ const Se = {
75
193
  */
76
194
  arrow: {
77
195
  type: Boolean,
78
- default: !1
196
+ default: false
79
197
  },
80
198
  /**
81
199
  * Close dropdown on click outside
82
200
  */
83
201
  autoClose: {
84
202
  type: Boolean,
85
- default: !0
203
+ default: true
86
204
  },
87
205
  /**
88
206
  * Autofocus first item on dropdown open
89
207
  */
90
208
  autofocusFirst: {
91
209
  type: Boolean,
92
- default: !0
210
+ default: true
93
211
  },
94
212
  /**
95
213
  * Set dropdown width to the same as the trigger
@@ -97,10 +215,26 @@ const Se = {
97
215
  triggerWidth: {
98
216
  type: Boolean
99
217
  }
100
- }, T = ["listbox", "menu"], Oe = {
101
- ...Se,
102
- ...Ee,
103
- ...ke,
218
+ };
219
+ ({
220
+ ...DisabledProps,
221
+ ...LabelProps,
222
+ ...PressedProps,
223
+ ...ActiveProps,
224
+ ...LinkProps,
225
+ /**
226
+ * Button type
227
+ */
228
+ type: {
229
+ type: String,
230
+ default: ButtonType.button,
231
+ validator: (value) => Object.values(ButtonType).includes(value)
232
+ }
233
+ });
234
+ const VvDropdownProps = {
235
+ ...IdProps,
236
+ ...ModifiersProps,
237
+ ...DropdownProps,
104
238
  /**
105
239
  * Show / hide dropdown programmatically
106
240
  */
@@ -120,225 +254,405 @@ const Se = {
120
254
  */
121
255
  role: {
122
256
  type: String,
123
- default: T[1],
124
- validator: (t) => T.includes(t)
257
+ default: DropdownRole.menu,
258
+ validator: (value) => Object.values(DropdownRole).includes(value)
125
259
  }
126
- }, De = ["id", "tabindex", "role", "aria-labelledby"], _e = {
260
+ };
261
+ const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
262
+ function useProvideDropdownTrigger({
263
+ reference,
264
+ id,
265
+ expanded,
266
+ aria
267
+ }) {
268
+ const bus = mitt();
269
+ const component = defineComponent({
270
+ name: "VvDropdownTriggerProvider",
271
+ provide() {
272
+ return {
273
+ [INJECTION_KEY_DROPDOWN_TRIGGER]: {
274
+ reference,
275
+ id,
276
+ expanded,
277
+ aria,
278
+ bus
279
+ }
280
+ };
281
+ },
282
+ setup() {
283
+ return {};
284
+ },
285
+ render() {
286
+ var _a, _b;
287
+ return h(Fragment, {}, (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a));
288
+ }
289
+ });
290
+ return {
291
+ bus,
292
+ component
293
+ };
294
+ }
295
+ function useProvideDropdownItem({
296
+ role,
297
+ expanded
298
+ }) {
299
+ const itemRole = computed(
300
+ () => role.value === DropdownRole.listbox ? DropdownItemRole.option : DropdownItemRole.presentation
301
+ );
302
+ provide(INJECTION_KEY_DROPDOWN_ITEM, {
303
+ role: itemRole,
304
+ expanded
305
+ });
306
+ return { itemRole };
307
+ }
308
+ function useModifiers(prefix, modifiers, others) {
309
+ return computed(() => {
310
+ const toReturn = {
311
+ [prefix]: true
312
+ };
313
+ const modifiersArray = typeof (modifiers == null ? void 0 : modifiers.value) === "string" ? modifiers.value.split(" ") : modifiers == null ? void 0 : modifiers.value;
314
+ if (modifiersArray) {
315
+ if (Array.isArray(modifiersArray)) {
316
+ modifiersArray.forEach((modifier) => {
317
+ if (modifier) {
318
+ toReturn[`${prefix}--${modifier}`] = true;
319
+ }
320
+ });
321
+ }
322
+ }
323
+ if (others) {
324
+ Object.keys(others.value).forEach((key) => {
325
+ toReturn[`${prefix}--${key}`] = unref(others.value[key]);
326
+ });
327
+ }
328
+ return toReturn;
329
+ });
330
+ }
331
+ const _hoisted_1 = ["id", "tabindex", "role", "aria-labelledby"];
332
+ const __default__ = {
127
333
  name: "VvDropdown",
128
- inheritAttrs: !1
129
- }, Pe = /* @__PURE__ */ de({
130
- ..._e,
131
- props: Oe,
334
+ inheritAttrs: false
335
+ };
336
+ const _sfc_main = /* @__PURE__ */ defineComponent({
337
+ ...__default__,
338
+ props: VvDropdownProps,
132
339
  emits: ["update:modelValue"],
133
- setup(t, { emit: M }) {
134
- const o = t, { id: U } = toRefs(o), m = useUniqueId(U), q = useAttrs(), E = ref("auto"), S = ref("auto"), k = ref(null), n = ref(null), u = ref(null), H = ref(null), s = computed({
135
- get: () => o.reference ?? k.value,
136
- set: (e) => {
137
- k.value = e;
340
+ setup(__props, { emit }) {
341
+ const props = __props;
342
+ const { id } = toRefs(props);
343
+ const hasId = useUniqueId(id);
344
+ const attrs = useAttrs();
345
+ const maxWidth = ref("auto");
346
+ const maxHeight = ref("auto");
347
+ const localReferenceEl = ref(null);
348
+ const floatingEl = ref(null);
349
+ const arrowEl = ref(null);
350
+ const listEl = ref(null);
351
+ const referenceEl = computed({
352
+ get: () => props.reference ?? localReferenceEl.value,
353
+ set: (newValue) => {
354
+ localReferenceEl.value = newValue;
355
+ }
356
+ });
357
+ const middleware = computed(() => {
358
+ const toReturn = [];
359
+ if (props.autoPlacement) {
360
+ if (typeof props.autoPlacement === "boolean") {
361
+ toReturn.push(autoPlacement());
362
+ } else {
363
+ toReturn.push(
364
+ autoPlacement(props.autoPlacement)
365
+ );
366
+ }
367
+ } else if (props.flip) {
368
+ if (typeof props.flip === "boolean") {
369
+ toReturn.push(flip());
370
+ } else {
371
+ toReturn.push(flip(props.flip));
372
+ }
138
373
  }
139
- }), L = computed(() => {
140
- const e = [];
141
- if (o.autoPlacement ? typeof o.autoPlacement == "boolean" ? e.push(z()) : e.push(
142
- z(o.autoPlacement)
143
- ) : o.flip && (typeof o.flip == "boolean" ? e.push(R()) : e.push(R(o.flip))), o.shift && (typeof o.shift == "boolean" ? e.push(F()) : e.push(F(o.shift))), o.size) {
144
- const l = ({
145
- availableWidth: f,
146
- availableHeight: d
374
+ if (props.shift) {
375
+ if (typeof props.shift === "boolean") {
376
+ toReturn.push(shift());
377
+ } else {
378
+ toReturn.push(shift(props.shift));
379
+ }
380
+ }
381
+ if (props.size) {
382
+ const apply = ({
383
+ availableWidth,
384
+ availableHeight
147
385
  }) => {
148
- E.value = `${f}px`, S.value = `${d}px`;
386
+ maxWidth.value = `${availableWidth}px`;
387
+ maxHeight.value = `${availableHeight}px`;
149
388
  };
150
- typeof o.size == "boolean" ? e.push(
151
- I({
152
- apply: l
153
- })
154
- ) : e.push(
155
- I({
156
- ...o.size,
157
- apply: l
389
+ if (typeof props.size === "boolean") {
390
+ toReturn.push(
391
+ size({
392
+ apply
393
+ })
394
+ );
395
+ } else {
396
+ toReturn.push(
397
+ size({
398
+ ...props.size,
399
+ apply
400
+ })
401
+ );
402
+ }
403
+ }
404
+ if (props.offset) {
405
+ toReturn.push(offset(Number(props.offset)));
406
+ if (["string", "number"].includes(typeof props.offset)) {
407
+ toReturn.push(offset(Number(props.offset)));
408
+ } else {
409
+ toReturn.push(offset(props.offset));
410
+ }
411
+ }
412
+ if (props.arrow) {
413
+ toReturn.push(
414
+ arrow({
415
+ element: arrowEl
158
416
  })
159
417
  );
160
418
  }
161
- return o.offset && (e.push(y(Number(o.offset))), ["string", "number"].includes(typeof o.offset) ? e.push(y(Number(o.offset))) : e.push(y(o.offset))), o.arrow && e.push(
162
- ye({
163
- element: u
164
- })
165
- ), e;
166
- }), { x: G, y: J, strategy: Q, middlewareData: O, placement: X } = we(
167
- s,
168
- n,
419
+ return toReturn;
420
+ });
421
+ const { x, y, strategy, middlewareData, placement } = useFloating(
422
+ referenceEl,
423
+ floatingEl,
169
424
  {
170
- whileElementsMounted: xe,
171
- placement: o.placement,
172
- middleware: L
425
+ whileElementsMounted: autoUpdate,
426
+ placement: props.placement,
427
+ middleware
173
428
  }
174
- ), Y = computed(() => ({
175
- position: Q.value,
176
- top: `${J.value ?? 0}px`,
177
- left: `${G.value ?? 0}px`,
178
- maxWidth: E.value,
179
- maxHeight: S.value,
180
- width: o.triggerWidth && s.value ? `${s.value.offsetWidth}px` : void 0
181
- })), Z = computed(() => X.value.split("-")[0]), h = computed(
429
+ );
430
+ const dropdownPlacement = computed(() => ({
431
+ position: strategy.value,
432
+ top: `${y.value ?? 0}px`,
433
+ left: `${x.value ?? 0}px`,
434
+ maxWidth: maxWidth.value,
435
+ maxHeight: maxHeight.value,
436
+ width: props.triggerWidth && referenceEl.value ? `${referenceEl.value.offsetWidth}px` : void 0
437
+ }));
438
+ const side = computed(() => placement.value.split("-")[0]);
439
+ const staticSide = computed(
182
440
  () => ({
183
441
  top: "bottom",
184
442
  right: "left",
185
443
  bottom: "top",
186
444
  left: "right"
187
- })[Z.value] ?? "bottom"
188
- ), ee = computed(() => {
189
- var e, l, f, d;
190
- return ["bottom", "top"].includes(h.value) ? {
191
- right: `${((e = O.value.arrow) == null ? void 0 : e.x) ?? 0}px`,
192
- [h.value]: `${-(((l = u.value) == null ? void 0 : l.offsetWidth) ?? 0) / 2}px`
193
- } : {
194
- top: `${((f = O.value.arrow) == null ? void 0 : f.y) ?? 0}px`,
195
- [h.value]: `${-(((d = u.value) == null ? void 0 : d.offsetWidth) ?? 0) / 2}px`
445
+ })[side.value] ?? "bottom"
446
+ );
447
+ const arrowPlacement = computed(() => {
448
+ var _a, _b, _c, _d;
449
+ if (["bottom", "top"].includes(staticSide.value)) {
450
+ return {
451
+ right: `${((_a = middlewareData.value.arrow) == null ? void 0 : _a.x) ?? 0}px`,
452
+ [staticSide.value]: `${-(((_b = arrowEl.value) == null ? void 0 : _b.offsetWidth) ?? 0) / 2}px`
453
+ };
454
+ }
455
+ return {
456
+ top: `${((_c = middlewareData.value.arrow) == null ? void 0 : _c.y) ?? 0}px`,
457
+ [staticSide.value]: `${-(((_d = arrowEl.value) == null ? void 0 : _d.offsetWidth) ?? 0) / 2}px`
196
458
  };
197
- }), b = useVModel(o, "modelValue", M), D = ref(!1), a = computed({
198
- get: () => b.value ?? D.value,
199
- set: (e) => {
200
- if (b.value === void 0) {
201
- D.value = e;
459
+ });
460
+ const modelValue = useVModel(props, "modelValue", emit);
461
+ const localModelValue = ref(false);
462
+ const expanded = computed({
463
+ get: () => modelValue.value ?? localModelValue.value,
464
+ set: (newValue) => {
465
+ if (modelValue.value === void 0) {
466
+ localModelValue.value = newValue;
202
467
  return;
203
468
  }
204
- b.value = e;
469
+ modelValue.value = newValue;
205
470
  }
206
- }), te = () => {
207
- a.value = !0;
208
- }, _ = () => {
209
- a.value = !1;
210
- }, $ = () => {
211
- a.value = !a.value;
212
- }, oe = (e) => {
213
- s.value = e;
471
+ });
472
+ const show = () => {
473
+ expanded.value = true;
214
474
  };
215
- watch(a, (e) => {
216
- e && o.autofocusFirst && nextTick(() => {
217
- const l = g(
218
- n.value
219
- );
220
- l.length > 0 && l[0].focus();
221
- });
222
- }), onClickOutside(
223
- n,
475
+ const hide = () => {
476
+ expanded.value = false;
477
+ };
478
+ const toggle = () => {
479
+ expanded.value = !expanded.value;
480
+ };
481
+ const init = (el) => {
482
+ referenceEl.value = el;
483
+ };
484
+ watch(expanded, (newValue) => {
485
+ if (newValue && props.autofocusFirst) {
486
+ nextTick(() => {
487
+ const focusableElements = getKeyboardFocusableElements(
488
+ floatingEl.value
489
+ );
490
+ if (focusableElements.length > 0) {
491
+ focusableElements[0].focus();
492
+ }
493
+ });
494
+ }
495
+ });
496
+ onClickOutside(
497
+ floatingEl,
224
498
  () => {
225
- o.autoClose && (a.value = !1);
499
+ if (props.autoClose) {
500
+ expanded.value = false;
501
+ }
226
502
  },
227
- { ignore: [s] }
503
+ { ignore: [referenceEl] }
228
504
  );
229
- const le = computed(() => {
230
- var e;
231
- return ((e = s.value) == null ? void 0 : e.getAttribute("id")) ?? void 0;
232
- }), B = computed(() => ({
233
- "aria-controls": m.value,
234
- "aria-haspopup": !0,
235
- "aria-expanded": a.value
236
- })), { component: ae, bus: re } = useProvideDropdownTrigger({
237
- reference: s,
238
- id: m,
239
- expanded: a,
240
- aria: B
505
+ const hasAriaLabelledby = computed(() => {
506
+ var _a, _b;
507
+ return ((_b = (_a = referenceEl.value) == null ? void 0 : _a.getAttribute) == null ? void 0 : _b.call(_a, "id")) ?? void 0;
508
+ });
509
+ const referenceAria = computed(() => ({
510
+ "aria-controls": hasId.value,
511
+ "aria-haspopup": true,
512
+ "aria-expanded": expanded.value
513
+ }));
514
+ const { component: VvDropdownTriggerProvider, bus } = useProvideDropdownTrigger({
515
+ reference: referenceEl,
516
+ id: hasId,
517
+ expanded,
518
+ aria: referenceAria
241
519
  });
242
- re.on("click", $);
243
- const { role: P, modifiers: ne } = toRefs(o), { itemRole: se } = useProvideDropdownItem({ role: P, expanded: a }), ie = useBemModifiers(
520
+ bus.on("click", toggle);
521
+ const { role, modifiers } = toRefs(props);
522
+ const { itemRole } = useProvideDropdownItem({ role, expanded });
523
+ const bemCssClasses = useModifiers(
244
524
  "vv-dropdown",
245
- ne,
525
+ modifiers,
246
526
  computed(() => ({
247
- arrow: o.arrow
527
+ arrow: props.arrow
248
528
  }))
249
- ), { focused: i } = useFocusWithin(n);
250
- function g(e) {
251
- return e ? [
252
- ...e.querySelectorAll(
529
+ );
530
+ const { focused } = useFocusWithin(floatingEl);
531
+ function getKeyboardFocusableElements(element) {
532
+ if (!element) {
533
+ return [];
534
+ }
535
+ return [
536
+ ...element.querySelectorAll(
253
537
  'a[href], button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
254
538
  )
255
539
  ].filter(
256
- (l) => !l.hasAttribute("disabled") && !l.getAttribute("aria-hidden")
257
- ) : [];
540
+ (el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
541
+ );
258
542
  }
259
- const ue = () => {
543
+ const focusNext = () => {
260
544
  nextTick(() => {
261
- if (i.value) {
262
- const e = g(
263
- n.value
545
+ if (focused.value) {
546
+ const focusableElements = getKeyboardFocusableElements(
547
+ floatingEl.value
264
548
  );
265
- if (e.length === 0 || !document.activeElement)
549
+ if (focusableElements.length === 0 || !document.activeElement) {
266
550
  return;
267
- const l = e.indexOf(
551
+ }
552
+ const activeElementIndex = focusableElements.indexOf(
268
553
  document.activeElement
269
554
  );
270
- l < e.length - 1 ? e[l + 1].focus() : e[0].focus();
555
+ if (activeElementIndex < focusableElements.length - 1) {
556
+ focusableElements[activeElementIndex + 1].focus();
557
+ } else {
558
+ focusableElements[0].focus();
559
+ }
271
560
  }
272
561
  });
273
- }, fe = () => {
562
+ };
563
+ const focusPrev = () => {
274
564
  nextTick(() => {
275
- if (i.value) {
276
- const e = g(
277
- n.value
565
+ if (focused.value) {
566
+ const focusableElements = getKeyboardFocusableElements(
567
+ floatingEl.value
278
568
  );
279
- if (e.length === 0 || !document.activeElement)
569
+ if (focusableElements.length === 0 || !document.activeElement) {
280
570
  return;
281
- const l = e.indexOf(
571
+ }
572
+ const activeElementIndex = focusableElements.indexOf(
282
573
  document.activeElement
283
574
  );
284
- l > 0 ? e[l - 1].focus() : e[e.length - 1].focus();
575
+ if (activeElementIndex > 0) {
576
+ focusableElements[activeElementIndex - 1].focus();
577
+ } else {
578
+ focusableElements[focusableElements.length - 1].focus();
579
+ }
285
580
  }
286
581
  });
287
582
  };
288
- return onKeyStroke("Escape", (e) => {
289
- a.value && (e.preventDefault(), _());
290
- }), onKeyStroke("ArrowDown", (e) => {
291
- a.value && i.value && (e.preventDefault(), ue());
292
- }), onKeyStroke("ArrowUp", (e) => {
293
- a.value && i.value && (e.preventDefault(), fe());
294
- }), onKeyStroke([" ", "Enter"], (e) => {
295
- a.value && i.value && (e.preventDefault(), document.activeElement.click());
296
- }), (e, l) => (A(), N(ce, null, [
297
- V(r(ae), null, {
298
- default: j(() => [
299
- c(e.$slots, "default", p(v({ init: oe, show: te, hide: _, toggle: $, expanded: r(a), aria: r(B) })))
300
- ]),
301
- _: 3
302
- }),
303
- V(pe, { name: e.transitionName }, {
304
- default: j(() => [
305
- ve(C("div", {
306
- ref_key: "floatingEl",
307
- ref: n,
308
- style: W(r(Y)),
309
- class: me(r(ie))
310
- }, [
311
- o.arrow ? (A(), N("div", {
312
- key: 0,
313
- ref_key: "arrowEl",
314
- ref: u,
315
- style: W(r(ee)),
316
- class: "vv-dropdown__arrow"
317
- }, null, 4)) : he("", !0),
318
- c(e.$slots, "before", p(v({ expanded: r(a) }))),
319
- C("ul", be(r(q), {
320
- id: r(m),
321
- ref_key: "listEl",
322
- ref: H,
323
- tabindex: r(a) ? void 0 : -1,
324
- role: r(P),
325
- "aria-labelledby": r(le),
326
- class: "vv-dropdown__list"
327
- }), [
328
- c(e.$slots, "items", p(v({
329
- role: r(se)
330
- })))
331
- ], 16, De),
332
- c(e.$slots, "after", p(v({ expanded: r(a) })))
333
- ], 6), [
334
- [ge, r(a)]
335
- ])
336
- ]),
337
- _: 3
338
- }, 8, ["name"])
339
- ], 64));
583
+ onKeyStroke("Escape", (e) => {
584
+ if (expanded.value) {
585
+ e.preventDefault();
586
+ hide();
587
+ }
588
+ });
589
+ onKeyStroke("ArrowDown", (e) => {
590
+ if (expanded.value && focused.value) {
591
+ e.preventDefault();
592
+ focusNext();
593
+ }
594
+ });
595
+ onKeyStroke("ArrowUp", (e) => {
596
+ if (expanded.value && focused.value) {
597
+ e.preventDefault();
598
+ focusPrev();
599
+ }
600
+ });
601
+ onKeyStroke([" ", "Enter"], (e) => {
602
+ if (expanded.value && focused.value) {
603
+ e.preventDefault();
604
+ const activeElement = document.activeElement;
605
+ activeElement.click();
606
+ }
607
+ });
608
+ return (_ctx, _cache) => {
609
+ return openBlock(), createElementBlock(Fragment, null, [
610
+ createVNode(unref(VvDropdownTriggerProvider), null, {
611
+ default: withCtx(() => [
612
+ renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ init, show, hide, toggle, expanded: unref(expanded), aria: unref(referenceAria) })))
613
+ ]),
614
+ _: 3
615
+ }),
616
+ createVNode(Transition, { name: _ctx.transitionName }, {
617
+ default: withCtx(() => [
618
+ withDirectives(createElementVNode("div", {
619
+ ref_key: "floatingEl",
620
+ ref: floatingEl,
621
+ style: normalizeStyle(unref(dropdownPlacement)),
622
+ class: normalizeClass(unref(bemCssClasses))
623
+ }, [
624
+ props.arrow ? (openBlock(), createElementBlock("div", {
625
+ key: 0,
626
+ ref_key: "arrowEl",
627
+ ref: arrowEl,
628
+ style: normalizeStyle(unref(arrowPlacement)),
629
+ class: "vv-dropdown__arrow"
630
+ }, null, 4)) : createCommentVNode("", true),
631
+ renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps({ expanded: unref(expanded) }))),
632
+ createElementVNode("ul", mergeProps(unref(attrs), {
633
+ id: unref(hasId),
634
+ ref_key: "listEl",
635
+ ref: listEl,
636
+ tabindex: !unref(expanded) ? -1 : void 0,
637
+ role: unref(role),
638
+ "aria-labelledby": unref(hasAriaLabelledby),
639
+ class: "vv-dropdown__list"
640
+ }), [
641
+ renderSlot(_ctx.$slots, "items", normalizeProps(guardReactiveProps({
642
+ role: unref(itemRole)
643
+ })))
644
+ ], 16, _hoisted_1),
645
+ renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps({ expanded: unref(expanded) })))
646
+ ], 6), [
647
+ [vShow, unref(expanded)]
648
+ ])
649
+ ]),
650
+ _: 3
651
+ }, 8, ["name"])
652
+ ], 64);
653
+ };
340
654
  }
341
655
  });
342
656
  export {
343
- Pe as default
657
+ _sfc_main as default
344
658
  };