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