@volverjs/ui-vue 0.0.8-beta.7 → 0.0.8-beta.9

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.
@@ -1,8 +1,8 @@
1
- import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, provide, h, Fragment, useAttrs, watch, nextTick, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, toHandlers, withDirectives, createElementVNode, normalizeStyle, normalizeClass, vShow, createTextVNode, toDisplayString, useSlots, isRef, renderList, vModelSelect, createSlots, withModifiers, vModelText } from "vue";
1
+ import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, provide, h, Fragment, useAttrs, onMounted, watch, nextTick, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, toHandlers, withDirectives, createElementVNode, normalizeStyle, normalizeClass, vShow, createTextVNode, toDisplayString, useSlots, isRef, renderList, vModelSelect, createSlots, resolveDynamicComponent, toRef, withModifiers, vModelText } from "vue";
2
2
  import { iconExists, Icon, addIcon } from "@iconify/vue";
3
3
  import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
4
4
  import { nanoid } from "nanoid";
5
- import { useVModel, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced } from "@vueuse/core";
5
+ import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced } from "@vueuse/core";
6
6
  import mitt from "mitt";
7
7
  import { get } from "ts-dot-prop";
8
8
  var Side = /* @__PURE__ */ ((Side2) => {
@@ -34,6 +34,13 @@ var ButtonType = /* @__PURE__ */ ((ButtonType2) => {
34
34
  ButtonType2["reset"] = "reset";
35
35
  return ButtonType2;
36
36
  })(ButtonType || {});
37
+ var ActionTag = /* @__PURE__ */ ((ActionTag2) => {
38
+ ActionTag2["nuxtLink"] = "nuxt-link";
39
+ ActionTag2["routerLink"] = "router-link";
40
+ ActionTag2["a"] = "a";
41
+ ActionTag2["button"] = "button";
42
+ return ActionTag2;
43
+ })(ActionTag || {});
37
44
  var ActionRoles = /* @__PURE__ */ ((ActionRoles2) => {
38
45
  ActionRoles2["button"] = "button";
39
46
  ActionRoles2["link"] = "link";
@@ -58,6 +65,7 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
58
65
  return AnchorTarget2;
59
66
  })(AnchorTarget || {});
60
67
  const INJECTION_KEY_VOLVER = Symbol.for("volver");
68
+ const INJECTION_KEY_BUTTON_GROUP = Symbol.for("buttonGroup");
61
69
  const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
62
70
  "dropdownTrigger"
63
71
  );
@@ -353,7 +361,7 @@ const AutocompleteProps = {
353
361
  */
354
362
  autocomplete: { type: String, default: "off" }
355
363
  };
356
- ({
364
+ const ActionProps = {
357
365
  ...DisabledProps,
358
366
  ...LabelProps,
359
367
  ...PressedProps,
@@ -367,7 +375,7 @@ const AutocompleteProps = {
367
375
  default: ButtonType.button,
368
376
  validator: (value) => Object.values(ButtonType).includes(value)
369
377
  }
370
- });
378
+ };
371
379
  const VvComboboxEvents = [
372
380
  "update:modelValue",
373
381
  "change:search",
@@ -481,7 +489,8 @@ const VvComboboxProps = {
481
489
  * Dropdown modifiers
482
490
  */
483
491
  dropdownModifiers: {
484
- type: [String, Array]
492
+ type: [String, Array],
493
+ default: "mobile"
485
494
  },
486
495
  /**
487
496
  * Open dropdown on focus
@@ -618,11 +627,11 @@ function useModifiers(prefix, modifiers, others) {
618
627
  return toReturn;
619
628
  });
620
629
  }
621
- const __default__$7 = {
630
+ const __default__$9 = {
622
631
  name: "VvIcon"
623
632
  };
624
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
625
- ...__default__$7,
633
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
634
+ ...__default__$9,
626
635
  props: VvIconProps,
627
636
  setup(__props) {
628
637
  const props = __props;
@@ -716,8 +725,14 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
716
725
  });
717
726
  const VvDropdownProps = {
718
727
  ...IdProps,
719
- ...ModifiersProps,
720
728
  ...DropdownProps,
729
+ /**
730
+ * Component BEM modifiers
731
+ */
732
+ modifiers: {
733
+ type: [String, Array],
734
+ default: "mobile"
735
+ },
721
736
  /**
722
737
  * Show / hide dropdown programmatically
723
738
  */
@@ -791,13 +806,13 @@ function useProvideDropdownAction({
791
806
  expanded
792
807
  });
793
808
  }
794
- const _hoisted_1$4 = ["id", "tabindex", "role", "aria-labelledby"];
795
- const __default__$6 = {
809
+ const _hoisted_1$5 = ["id", "tabindex", "role", "aria-labelledby"];
810
+ const __default__$8 = {
796
811
  name: "VvDropdown",
797
812
  inheritAttrs: false
798
813
  };
799
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
800
- ...__default__$6,
814
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
815
+ ...__default__$8,
801
816
  props: VvDropdownProps,
802
817
  emits: [
803
818
  "update:modelValue",
@@ -814,7 +829,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
814
829
  const maxWidth = ref("auto");
815
830
  const maxHeight = ref("auto");
816
831
  const localReferenceEl = ref(null);
817
- const floatingEl = ref(null);
832
+ const floatingEl = ref();
818
833
  const arrowEl = ref(null);
819
834
  const listEl = ref(null);
820
835
  const referenceEl = computed({
@@ -823,6 +838,17 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
823
838
  localReferenceEl.value = newValue;
824
839
  }
825
840
  });
841
+ const dropdownCustomPosition = ref();
842
+ const onChangeDropdownCustomPosition = () => {
843
+ var _a;
844
+ dropdownCustomPosition.value = (_a = window.getComputedStyle(floatingEl.value).getPropertyValue("--dropdown-custom-position")) == null ? void 0 : _a.trim();
845
+ };
846
+ onMounted(() => {
847
+ useMutationObserver(floatingEl.value, onChangeDropdownCustomPosition, {
848
+ attributeFilter: ["style"],
849
+ window
850
+ });
851
+ });
826
852
  const middleware = computed(() => {
827
853
  const toReturn = [];
828
854
  if (props.autoPlacement) {
@@ -897,14 +923,19 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
897
923
  middleware
898
924
  }
899
925
  );
900
- const dropdownPlacement = computed(() => ({
901
- position: strategy.value,
902
- top: `${y.value ?? 0}px`,
903
- left: `${x.value ?? 0}px`,
904
- maxWidth: maxWidth.value,
905
- maxHeight: maxHeight.value,
906
- width: props.triggerWidth && referenceEl.value ? `${referenceEl.value.offsetWidth}px` : void 0
907
- }));
926
+ const dropdownPlacement = computed(() => {
927
+ if ((dropdownCustomPosition == null ? void 0 : dropdownCustomPosition.value) === "true") {
928
+ return {};
929
+ }
930
+ return {
931
+ position: strategy.value,
932
+ top: `${y.value ?? 0}px`,
933
+ left: `${x.value ?? 0}px`,
934
+ maxWidth: maxWidth.value,
935
+ maxHeight: maxHeight.value,
936
+ width: props.triggerWidth && referenceEl.value ? `${referenceEl.value.offsetWidth}px` : void 0
937
+ };
938
+ });
908
939
  const side = computed(() => placement.value.split("-")[0]);
909
940
  const staticSide = computed(
910
941
  () => ({
@@ -916,6 +947,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
916
947
  );
917
948
  const arrowPlacement = computed(() => {
918
949
  var _a, _b, _c, _d;
950
+ if ((dropdownCustomPosition == null ? void 0 : dropdownCustomPosition.value) === "true") {
951
+ return {};
952
+ }
919
953
  if (["bottom", "top"].includes(staticSide.value)) {
920
954
  return {
921
955
  right: `${((_a = middlewareData.value.arrow) == null ? void 0 : _a.x) ?? 0}px`,
@@ -951,7 +985,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
951
985
  const init = (el) => {
952
986
  referenceEl.value = el;
953
987
  };
954
- __expose({ toggle, show, hide, init });
988
+ __expose({ toggle, show, hide, init, dropdownCustomPosition });
955
989
  watch(expanded, (newValue) => {
956
990
  if (newValue && props.autofocusFirst) {
957
991
  nextTick(() => {
@@ -1080,10 +1114,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1080
1114
  }
1081
1115
  });
1082
1116
  onKeyStroke([" ", "Enter"], (e) => {
1083
- if (expanded.value && focused.value && e.target !== document.activeElement) {
1084
- e.preventDefault();
1085
- const activeElement = document.activeElement;
1086
- activeElement.click();
1117
+ const htmlEl = e.target;
1118
+ if (expanded.value && focused.value && htmlEl) {
1119
+ htmlEl == null ? void 0 : htmlEl.click();
1087
1120
  }
1088
1121
  });
1089
1122
  const onTransitionBeforeEnter = () => {
@@ -1131,7 +1164,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1131
1164
  renderSlot(_ctx.$slots, "items", normalizeProps(guardReactiveProps({
1132
1165
  role: unref(itemRole)
1133
1166
  })))
1134
- ], 16, _hoisted_1$4),
1167
+ ], 16, _hoisted_1$5),
1135
1168
  renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps({ expanded: unref(expanded) })))
1136
1169
  ], 6), [
1137
1170
  [vShow, unref(expanded)]
@@ -1143,14 +1176,20 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1143
1176
  };
1144
1177
  }
1145
1178
  });
1179
+ function useInjectedDropdownTrigger() {
1180
+ return inject(INJECTION_KEY_DROPDOWN_TRIGGER, {});
1181
+ }
1146
1182
  function useInjectedDropdownItem() {
1147
1183
  return inject(INJECTION_KEY_DROPDOWN_ITEM, {});
1148
1184
  }
1149
- const __default__$5 = {
1185
+ function useInjectedDropdownAction() {
1186
+ return inject(INJECTION_KEY_DROPDOWN_ACTION, {});
1187
+ }
1188
+ const __default__$7 = {
1150
1189
  name: "VvDropdownItem"
1151
1190
  };
1152
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1153
- ...__default__$5,
1191
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1192
+ ...__default__$7,
1154
1193
  setup(__props) {
1155
1194
  const { role, expanded } = useInjectedDropdownItem();
1156
1195
  const element = ref(null);
@@ -1174,12 +1213,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1174
1213
  };
1175
1214
  }
1176
1215
  });
1177
- const _hoisted_1$3 = ["title"];
1178
- const __default__$4 = {
1216
+ const _hoisted_1$4 = ["title"];
1217
+ const __default__$6 = {
1179
1218
  name: "VvDropdownOption"
1180
1219
  };
1181
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1182
- ...__default__$4,
1220
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1221
+ ...__default__$6,
1183
1222
  props: {
1184
1223
  ...DisabledProps,
1185
1224
  ...SelectedProps,
@@ -1216,7 +1255,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1216
1255
  }
1217
1256
  });
1218
1257
  return (_ctx, _cache) => {
1219
- return openBlock(), createBlock(_sfc_main$5, {
1258
+ return openBlock(), createBlock(_sfc_main$7, {
1220
1259
  class: normalizeClass(unref(bemCssClasses)),
1221
1260
  tabindex: _ctx.disabled ? -1 : 0,
1222
1261
  "aria-selected": _ctx.selected,
@@ -1231,30 +1270,30 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1231
1270
  renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps({ disabled: _ctx.disabled, selected: _ctx.selected, unselectable: _ctx.unselectable })), () => [
1232
1271
  createTextVNode(toDisplayString(unref(hintLabel)), 1)
1233
1272
  ])
1234
- ], 8, _hoisted_1$3)
1273
+ ], 8, _hoisted_1$4)
1235
1274
  ]),
1236
1275
  _: 3
1237
1276
  }, 8, ["class", "tabindex", "aria-selected", "aria-disabled"]);
1238
1277
  };
1239
1278
  }
1240
1279
  });
1241
- const _hoisted_1$2 = {
1280
+ const _hoisted_1$3 = {
1242
1281
  class: "vv-dropdown-optgroup",
1243
1282
  role: "presentation",
1244
1283
  tabindex: "-1"
1245
1284
  };
1246
- const __default__$3 = {
1285
+ const __default__$5 = {
1247
1286
  name: "VvDropdownOptgroup"
1248
1287
  };
1249
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1250
- ...__default__$3,
1288
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1289
+ ...__default__$5,
1251
1290
  props: {
1252
1291
  ...LabelProps
1253
1292
  },
1254
1293
  setup(__props) {
1255
1294
  const props = __props;
1256
1295
  return (_ctx, _cache) => {
1257
- return openBlock(), createElementBlock("li", _hoisted_1$2, toDisplayString(props.label), 1);
1296
+ return openBlock(), createElementBlock("li", _hoisted_1$3, toDisplayString(props.label), 1);
1258
1297
  };
1259
1298
  }
1260
1299
  });
@@ -1598,8 +1637,8 @@ function useOptions(props) {
1598
1637
  getOptionGrouped
1599
1638
  };
1600
1639
  }
1601
- const _hoisted_1$1 = ["for"];
1602
- const _hoisted_2$1 = { class: "vv-select__wrapper" };
1640
+ const _hoisted_1$2 = ["for"];
1641
+ const _hoisted_2$2 = { class: "vv-select__wrapper" };
1603
1642
  const _hoisted_3$1 = {
1604
1643
  key: 0,
1605
1644
  class: "vv-select__input-before"
@@ -1614,11 +1653,11 @@ const _hoisted_10 = {
1614
1653
  key: 1,
1615
1654
  class: "vv-select__input-after"
1616
1655
  };
1617
- const __default__$2 = {
1656
+ const __default__$4 = {
1618
1657
  name: "VvSelect"
1619
1658
  };
1620
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1621
- ...__default__$2,
1659
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1660
+ ...__default__$4,
1622
1661
  props: VvSelectProps,
1623
1662
  emits: VvSelectEmits,
1624
1663
  setup(__props, { emit }) {
@@ -1736,13 +1775,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1736
1775
  _ctx.label ? (openBlock(), createElementBlock("label", {
1737
1776
  key: 0,
1738
1777
  for: unref(hasId)
1739
- }, toDisplayString(_ctx.label), 9, _hoisted_1$1)) : createCommentVNode("", true),
1740
- createElementVNode("div", _hoisted_2$1, [
1778
+ }, toDisplayString(_ctx.label), 9, _hoisted_1$2)) : createCommentVNode("", true),
1779
+ createElementVNode("div", _hoisted_2$2, [
1741
1780
  _ctx.$slots.before ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
1742
1781
  renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps(unref(slotProps))))
1743
1782
  ])) : createCommentVNode("", true),
1744
1783
  createElementVNode("div", _hoisted_4$1, [
1745
- unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
1784
+ unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
1746
1785
  key: 0,
1747
1786
  class: "vv-select__icon"
1748
1787
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true),
@@ -1782,7 +1821,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1782
1821
  ], 16, _hoisted_5$1), [
1783
1822
  [vModelSelect, unref(localModelValue)]
1784
1823
  ]),
1785
- unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
1824
+ unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
1786
1825
  key: 1,
1787
1826
  class: "vv-select__icon vv-select__icon-after"
1788
1827
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true)
@@ -1832,11 +1871,11 @@ const VvBadgeProps = {
1832
1871
  ...ModifiersProps,
1833
1872
  value: [String, Number]
1834
1873
  };
1835
- const __default__$1 = {
1874
+ const __default__$3 = {
1836
1875
  name: "VvBadge"
1837
1876
  };
1838
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1839
- ...__default__$1,
1877
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1878
+ ...__default__$3,
1840
1879
  props: VvBadgeProps,
1841
1880
  setup(__props) {
1842
1881
  const props = __props;
@@ -1854,6 +1893,389 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1854
1893
  };
1855
1894
  }
1856
1895
  });
1896
+ const VvActionEvents = ["click", "mouseover", "mouseleave"];
1897
+ const VvActionProps = ActionProps;
1898
+ const __default__$2 = {
1899
+ name: "VvAction"
1900
+ };
1901
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1902
+ ...__default__$2,
1903
+ props: VvActionProps,
1904
+ emits: VvActionEvents,
1905
+ setup(__props, { expose: __expose, emit }) {
1906
+ const props = __props;
1907
+ const volver = useVolver();
1908
+ const element = ref(null);
1909
+ __expose({ $el: element });
1910
+ const {
1911
+ reference: dropdownTriggerReference,
1912
+ bus: dropdownEventBus,
1913
+ aria: dropdownAria,
1914
+ expanded: dropdownExpanded
1915
+ } = useInjectedDropdownTrigger();
1916
+ watch(
1917
+ () => element.value,
1918
+ (newValue) => {
1919
+ if (dropdownTriggerReference) {
1920
+ dropdownTriggerReference.value = newValue;
1921
+ }
1922
+ }
1923
+ );
1924
+ const pressed = computed(() => {
1925
+ return props.pressed || (dropdownExpanded == null ? void 0 : dropdownExpanded.value);
1926
+ });
1927
+ const { role } = useInjectedDropdownAction();
1928
+ const hasTag = computed(() => {
1929
+ switch (true) {
1930
+ case props.disabled:
1931
+ return ActionTag.button;
1932
+ case props.to !== void 0:
1933
+ return (volver == null ? void 0 : volver.nuxt) ? ActionTag.nuxtLink : ActionTag.routerLink;
1934
+ case props.href !== void 0:
1935
+ return ActionTag.a;
1936
+ default:
1937
+ return ActionTag.button;
1938
+ }
1939
+ });
1940
+ const hasProps = computed(() => {
1941
+ const toReturn = {
1942
+ ...dropdownAria == null ? void 0 : dropdownAria.value,
1943
+ "aria-pressed": pressed.value ? true : void 0,
1944
+ role: role == null ? void 0 : role.value
1945
+ };
1946
+ switch (hasTag.value) {
1947
+ case ActionTag.a:
1948
+ return {
1949
+ ...toReturn,
1950
+ href: props.href,
1951
+ target: props.target,
1952
+ rel: props.rel
1953
+ };
1954
+ case ActionTag.routerLink:
1955
+ case ActionTag.nuxtLink:
1956
+ return {
1957
+ ...toReturn,
1958
+ to: props.to,
1959
+ target: props.target
1960
+ };
1961
+ default:
1962
+ return {
1963
+ ...toReturn,
1964
+ type: props.type,
1965
+ disabled: props.disabled
1966
+ };
1967
+ }
1968
+ });
1969
+ const onClick = (e) => {
1970
+ if (props.disabled) {
1971
+ e.preventDefault();
1972
+ return;
1973
+ }
1974
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("click", e);
1975
+ emit("click", e);
1976
+ };
1977
+ const onMouseover = (e) => {
1978
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseover", e);
1979
+ emit("mouseover", e);
1980
+ };
1981
+ const onMouseleave = (e) => {
1982
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseleave", e);
1983
+ emit("mouseleave", e);
1984
+ };
1985
+ return (_ctx, _cache) => {
1986
+ return openBlock(), createBlock(resolveDynamicComponent(unref(hasTag)), mergeProps(unref(hasProps), {
1987
+ ref_key: "element",
1988
+ ref: element,
1989
+ class: {
1990
+ active: _ctx.active,
1991
+ pressed: unref(pressed),
1992
+ disabled: _ctx.disabled
1993
+ },
1994
+ onClickPassive: onClick,
1995
+ onMouseoverPassive: onMouseover,
1996
+ onMouseleavePassive: onMouseleave
1997
+ }), {
1998
+ default: withCtx(() => [
1999
+ renderSlot(_ctx.$slots, "default", {}, () => [
2000
+ createTextVNode(toDisplayString(_ctx.label), 1)
2001
+ ])
2002
+ ]),
2003
+ _: 3
2004
+ }, 16, ["class"]);
2005
+ };
2006
+ }
2007
+ });
2008
+ function useInjectedGroupState(groupKey) {
2009
+ const group = inject(groupKey, void 0);
2010
+ const isInGroup = computed(() => !isEmpty(group));
2011
+ function getGroupOrLocalRef(propName, props, emit) {
2012
+ if (group == null ? void 0 : group.value) {
2013
+ const groupPropValue = unref(group.value)[propName];
2014
+ return computed({
2015
+ get() {
2016
+ return groupPropValue == null ? void 0 : groupPropValue.value;
2017
+ },
2018
+ set(value) {
2019
+ groupPropValue.value = value;
2020
+ }
2021
+ });
2022
+ }
2023
+ const propRef = toRef(props, propName);
2024
+ return computed({
2025
+ get() {
2026
+ return propRef.value;
2027
+ },
2028
+ set(value) {
2029
+ if (emit)
2030
+ emit(`update:${propName}`, value);
2031
+ }
2032
+ });
2033
+ }
2034
+ return {
2035
+ group,
2036
+ isInGroup,
2037
+ getGroupOrLocalRef
2038
+ };
2039
+ }
2040
+ const VvButtonEvents = ["update:modelValue"];
2041
+ const VvButtonProps = {
2042
+ ...ActionProps,
2043
+ ...IdProps,
2044
+ ...ModifiersProps,
2045
+ ...UnselectableProps,
2046
+ ...LoadingProps,
2047
+ /**
2048
+ * Button icon
2049
+ */
2050
+ icon: [String, Object],
2051
+ /**
2052
+ * Button icon position
2053
+ */
2054
+ iconPosition: {
2055
+ type: String,
2056
+ default: Side.left,
2057
+ validator: (value) => Object.values(Side).includes(value)
2058
+ },
2059
+ /**
2060
+ * Loading icon
2061
+ */
2062
+ loadingIcon: { type: String, default: "eos-icons:bubble-loading" },
2063
+ /**
2064
+ * Enable button toggle
2065
+ */
2066
+ toggle: {
2067
+ type: Boolean,
2068
+ default: false
2069
+ },
2070
+ /**
2071
+ * Button toggle value
2072
+ */
2073
+ value: {
2074
+ type: [String, Number, Boolean],
2075
+ default: void 0
2076
+ },
2077
+ /**
2078
+ * Value associated with the unchecked state
2079
+ */
2080
+ uncheckedValue: {
2081
+ type: [String, Number, Boolean],
2082
+ default: void 0
2083
+ },
2084
+ /**
2085
+ * Button toggle model value
2086
+ */
2087
+ modelValue: {
2088
+ type: [String, Number, Boolean],
2089
+ default: void 0
2090
+ }
2091
+ };
2092
+ function useGroupProps(props, emit) {
2093
+ const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_BUTTON_GROUP);
2094
+ const { id, iconPosition, icon, label, pressed } = toRefs(props);
2095
+ const modelValue = getGroupOrLocalRef("modelValue", props, emit);
2096
+ const toggle = getGroupOrLocalRef("toggle", props);
2097
+ const unselectable = getGroupOrLocalRef(
2098
+ "unselectable",
2099
+ props
2100
+ );
2101
+ const multiple = computed(() => (group == null ? void 0 : group.value.multiple.value) ?? false);
2102
+ const modifiers = computed(() => {
2103
+ let localModifiers = props.modifiers;
2104
+ let groupModifiers = group == null ? void 0 : group.value.modifiers.value;
2105
+ const toReturn = /* @__PURE__ */ new Set();
2106
+ if (localModifiers) {
2107
+ if (!Array.isArray(localModifiers)) {
2108
+ localModifiers = localModifiers.split(" ");
2109
+ }
2110
+ localModifiers.forEach((modifier) => toReturn.add(modifier));
2111
+ }
2112
+ if (groupModifiers) {
2113
+ if (!Array.isArray(groupModifiers)) {
2114
+ groupModifiers = groupModifiers.split(" ");
2115
+ }
2116
+ groupModifiers.forEach((modifier) => toReturn.add(modifier));
2117
+ }
2118
+ return Array.from(toReturn);
2119
+ });
2120
+ const disabled = computed(
2121
+ () => {
2122
+ var _a;
2123
+ return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
2124
+ }
2125
+ );
2126
+ return {
2127
+ // group props
2128
+ group,
2129
+ isInGroup,
2130
+ modelValue,
2131
+ toggle,
2132
+ unselectable,
2133
+ multiple,
2134
+ modifiers,
2135
+ disabled,
2136
+ // local props
2137
+ id,
2138
+ pressed,
2139
+ iconPosition,
2140
+ icon,
2141
+ label
2142
+ };
2143
+ }
2144
+ const _hoisted_1$1 = {
2145
+ key: 1,
2146
+ class: "vv-button__label"
2147
+ };
2148
+ const _hoisted_2$1 = {
2149
+ key: 1,
2150
+ class: "vv-button__label"
2151
+ };
2152
+ const __default__$1 = {
2153
+ name: "VvButton"
2154
+ };
2155
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2156
+ ...__default__$1,
2157
+ props: VvButtonProps,
2158
+ emits: VvButtonEvents,
2159
+ setup(__props, { expose: __expose, emit }) {
2160
+ const props = __props;
2161
+ const attrs = useAttrs();
2162
+ const slots = useSlots();
2163
+ const {
2164
+ id,
2165
+ modifiers,
2166
+ iconPosition,
2167
+ icon,
2168
+ label,
2169
+ modelValue,
2170
+ disabled,
2171
+ toggle,
2172
+ unselectable
2173
+ } = useGroupProps(props, emit);
2174
+ const hasId = useUniqueId(id);
2175
+ const name = computed(() => (attrs == null ? void 0 : attrs.name) || hasId.value);
2176
+ const element = ref(null);
2177
+ const $el = computed(() => {
2178
+ var _a;
2179
+ return (_a = element.value) == null ? void 0 : _a.$el;
2180
+ });
2181
+ __expose({ $el });
2182
+ const pressed = computed(() => {
2183
+ if (!toggle.value) {
2184
+ return props.pressed;
2185
+ }
2186
+ if (Array.isArray(modelValue.value)) {
2187
+ return contains(name.value, modelValue.value);
2188
+ }
2189
+ return equals(name.value, modelValue.value);
2190
+ });
2191
+ const bemCssClasses = useModifiers(
2192
+ "vv-button",
2193
+ modifiers,
2194
+ computed(() => ({
2195
+ reverse: [Side.right, Side.bottom].includes(
2196
+ iconPosition.value
2197
+ ),
2198
+ column: [Side.top, Side.bottom].includes(
2199
+ iconPosition.value
2200
+ ),
2201
+ "icon-only": Boolean(
2202
+ (icon == null ? void 0 : icon.value) && !(label == null ? void 0 : label.value) && !slots.default
2203
+ )
2204
+ }))
2205
+ );
2206
+ const hasIconProps = computed(
2207
+ () => typeof (icon == null ? void 0 : icon.value) === "string" ? { name: icon == null ? void 0 : icon.value } : icon == null ? void 0 : icon.value
2208
+ );
2209
+ const toggleValue = computed(() => {
2210
+ return props.value !== void 0 ? props.value : name.value;
2211
+ });
2212
+ const onClick = () => {
2213
+ if (toggle.value) {
2214
+ if (Array.isArray(modelValue.value)) {
2215
+ if (contains(toggleValue.value, modelValue.value)) {
2216
+ if (unselectable.value) {
2217
+ modelValue.value = modelValue.value.filter(
2218
+ (n) => n !== toggleValue.value
2219
+ );
2220
+ }
2221
+ return;
2222
+ }
2223
+ modelValue.value.push(toggleValue.value);
2224
+ return;
2225
+ }
2226
+ if (toggleValue.value === modelValue.value && unselectable.value) {
2227
+ modelValue.value = props.uncheckedValue;
2228
+ return;
2229
+ }
2230
+ modelValue.value = toggleValue.value;
2231
+ }
2232
+ };
2233
+ return (_ctx, _cache) => {
2234
+ return openBlock(), createBlock(_sfc_main$2, mergeProps({
2235
+ disabled: unref(disabled),
2236
+ pressed: unref(pressed),
2237
+ active: _ctx.active,
2238
+ type: _ctx.type,
2239
+ to: _ctx.to,
2240
+ href: _ctx.href,
2241
+ target: _ctx.target,
2242
+ rel: _ctx.rel
2243
+ }, {
2244
+ id: unref(hasId),
2245
+ ref_key: "element",
2246
+ ref: element,
2247
+ class: unref(bemCssClasses),
2248
+ onClick
2249
+ }), {
2250
+ default: withCtx(() => [
2251
+ renderSlot(_ctx.$slots, "default", {}, () => [
2252
+ _ctx.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
2253
+ _ctx.loadingIcon ? (openBlock(), createBlock(_sfc_main$9, {
2254
+ key: 0,
2255
+ class: "vv-button__loading-icon",
2256
+ name: _ctx.loadingIcon
2257
+ }, null, 8, ["name"])) : createCommentVNode("", true),
2258
+ _ctx.loadingLabel ? (openBlock(), createElementBlock("span", _hoisted_1$1, toDisplayString(_ctx.loadingLabel), 1)) : createCommentVNode("", true)
2259
+ ]) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2260
+ renderSlot(_ctx.$slots, "before"),
2261
+ unref(icon) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2262
+ key: 0,
2263
+ class: "vv-button__icon"
2264
+ }, unref(hasIconProps)), null, 16)) : createCommentVNode("", true),
2265
+ unref(label) ? (openBlock(), createElementBlock("span", _hoisted_2$1, [
2266
+ renderSlot(_ctx.$slots, "label", {}, () => [
2267
+ createTextVNode(toDisplayString(unref(label)), 1)
2268
+ ])
2269
+ ])) : createCommentVNode("", true),
2270
+ renderSlot(_ctx.$slots, "after")
2271
+ ], 64))
2272
+ ])
2273
+ ]),
2274
+ _: 3
2275
+ }, 16, ["id", "class"]);
2276
+ };
2277
+ }
2278
+ });
1857
2279
  function useDefaults(componentName, propsDefinition, props) {
1858
2280
  const volver = useVolver();
1859
2281
  const volverComponentDefaults = computed(() => {
@@ -1927,7 +2349,12 @@ const _hoisted_9 = {
1927
2349
  };
1928
2350
  const __default__ = {
1929
2351
  name: "VvCombobox",
1930
- components: { VvDropdown: _sfc_main$6, VvDropdownOption: _sfc_main$4, VvDropdownOptgroup: _sfc_main$3 }
2352
+ components: {
2353
+ VvDropdown: _sfc_main$8,
2354
+ VvDropdownOption: _sfc_main$6,
2355
+ VvDropdownOptgroup: _sfc_main$5,
2356
+ VvButton: _sfc_main$1
2357
+ }
1931
2358
  };
1932
2359
  const _sfc_main = /* @__PURE__ */ defineComponent({
1933
2360
  ...__default__,
@@ -2032,6 +2459,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2032
2459
  const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
2033
2460
  const hasSearchId = computed(() => `${hasId.value}-search`);
2034
2461
  const hasLabelId = computed(() => `${hasId.value}-label`);
2462
+ const dropdownEl = ref();
2035
2463
  const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
2036
2464
  icon,
2037
2465
  iconPosition
@@ -2208,9 +2636,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2208
2636
  ref: wrapperEl,
2209
2637
  class: "vv-select__wrapper"
2210
2638
  }, [
2211
- createVNode(_sfc_main$6, mergeProps({
2639
+ createVNode(_sfc_main$8, mergeProps({
2640
+ ref_key: "dropdownEl",
2641
+ ref: dropdownEl,
2212
2642
  modelValue: unref(expanded),
2213
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(expanded) ? expanded.value = $event : null)
2643
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(expanded) ? expanded.value = $event : null)
2214
2644
  }, unref(dropdownProps), {
2215
2645
  role: unref(DropdownRole).listbox,
2216
2646
  onAfterExpand,
@@ -2221,7 +2651,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2221
2651
  renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps(unref(slotProps))))
2222
2652
  ])) : createCommentVNode("", true),
2223
2653
  createElementVNode("div", _hoisted_5, [
2224
- unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
2654
+ unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2225
2655
  key: 0,
2226
2656
  class: "vv-select__icon"
2227
2657
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true),
@@ -2241,7 +2671,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2241
2671
  renderSlot(_ctx.$slots, "value", normalizeProps(guardReactiveProps({ selectedOptions: unref(selectedOptions), onInput })), () => [
2242
2672
  unref(hasValue) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2243
2673
  !_ctx.badges ? (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(unref(hasValue)), 1)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(unref(selectedOptions), (option, index) => {
2244
- return openBlock(), createBlock(_sfc_main$1, {
2674
+ return openBlock(), createBlock(_sfc_main$3, {
2245
2675
  key: index,
2246
2676
  modifiers: _ctx.badgeModifiers,
2247
2677
  class: "vv-select__badge"
@@ -2253,7 +2683,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2253
2683
  "aria-label": unref(propsDefaults).deselectActionLabel,
2254
2684
  onClick: withModifiers(($event) => onInput(option), ["stop"])
2255
2685
  }, [
2256
- createVNode(_sfc_main$7, { name: "close" })
2686
+ createVNode(_sfc_main$9, { name: "close" })
2257
2687
  ], 8, _hoisted_8)) : createCommentVNode("", true)
2258
2688
  ]),
2259
2689
  _: 2
@@ -2264,7 +2694,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2264
2694
  ], 64))
2265
2695
  ])
2266
2696
  ], 16, _hoisted_6),
2267
- unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
2697
+ unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2268
2698
  key: 1,
2269
2699
  class: "vv-select__icon vv-select__icon-after"
2270
2700
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true)
@@ -2277,13 +2707,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2277
2707
  unref(filteredOptions).length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(filteredOptions), (option, index) => {
2278
2708
  return openBlock(), createElementBlock(Fragment, { key: index }, [
2279
2709
  isGroup(option) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2280
- createVNode(_sfc_main$3, {
2710
+ createVNode(_sfc_main$5, {
2281
2711
  label: unref(getOptionLabel)(option)
2282
2712
  }, null, 8, ["label"]),
2283
2713
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(
2284
2714
  option
2285
2715
  ), (item, i) => {
2286
- return openBlock(), createBlock(_sfc_main$4, mergeProps({
2716
+ return openBlock(), createBlock(_sfc_main$6, mergeProps({
2287
2717
  disabled: unref(getOptionDisabled)(item),
2288
2718
  selected: getOptionSelected(item),
2289
2719
  unselectable: _ctx.unselectable,
@@ -2308,7 +2738,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2308
2738
  _: 2
2309
2739
  }, 1040, ["onClickPassive"]);
2310
2740
  }), 128))
2311
- ], 64)) : (openBlock(), createBlock(_sfc_main$4, mergeProps({ key: 1 }, {
2741
+ ], 64)) : (openBlock(), createBlock(_sfc_main$6, mergeProps({ key: 1 }, {
2312
2742
  disabled: unref(getOptionDisabled)(option),
2313
2743
  selected: getOptionSelected(option),
2314
2744
  unselectable: _ctx.unselectable,
@@ -2332,7 +2762,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2332
2762
  _: 2
2333
2763
  }, 1040, ["onClickPassive"]))
2334
2764
  ], 64);
2335
- }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$4, {
2765
+ }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$6, {
2336
2766
  key: 1,
2337
2767
  modifiers: "inert"
2338
2768
  }, {
@@ -2342,7 +2772,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2342
2772
  ])
2343
2773
  ]),
2344
2774
  _: 3
2345
- })) : (openBlock(), createBlock(_sfc_main$4, {
2775
+ })) : (openBlock(), createBlock(_sfc_main$6, {
2346
2776
  key: 2,
2347
2777
  modifiers: "inert"
2348
2778
  }, {
@@ -2354,6 +2784,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2354
2784
  _: 3
2355
2785
  }))
2356
2786
  ]),
2787
+ after: withCtx(() => [
2788
+ renderSlot(_ctx.$slots, "dropdown::after", {}, () => {
2789
+ var _a;
2790
+ return [
2791
+ ((_a = unref(dropdownEl)) == null ? void 0 : _a.dropdownCustomPosition) === "true" ? (openBlock(), createBlock(_sfc_main$1, {
2792
+ key: 0,
2793
+ label: "Close",
2794
+ modifiers: "secondary",
2795
+ onClick: _cache[1] || (_cache[1] = ($event) => unref(dropdownEl).hide())
2796
+ })) : createCommentVNode("", true)
2797
+ ];
2798
+ })
2799
+ ]),
2357
2800
  _: 2
2358
2801
  }, [
2359
2802
  unref(searchable) || _ctx.$slots["dropdown::before"] ? {
@@ -2379,13 +2822,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2379
2822
  ]) : createCommentVNode("", true)
2380
2823
  ]),
2381
2824
  key: "0"
2382
- } : void 0,
2383
- _ctx.$slots["dropdown::after"] ? {
2384
- name: "after",
2385
- fn: withCtx(() => [
2386
- renderSlot(_ctx.$slots, "dropdown::after")
2387
- ]),
2388
- key: "1"
2389
2825
  } : void 0
2390
2826
  ]), 1040, ["modelValue", "role"])
2391
2827
  ], 512),
@@ -2422,8 +2858,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2422
2858
  key: "3"
2423
2859
  } : void 0
2424
2860
  ]), 1032, ["id"])
2425
- ], 10, _hoisted_1)) : (openBlock(), createBlock(_sfc_main$2, mergeProps({ key: 1 }, unref(selectProps), {
2426
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => emit("update:modelValue", $event))
2861
+ ], 10, _hoisted_1)) : (openBlock(), createBlock(_sfc_main$4, mergeProps({ key: 1 }, unref(selectProps), {
2862
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => emit("update:modelValue", $event))
2427
2863
  }), null, 16));
2428
2864
  };
2429
2865
  }