@volverjs/ui-vue 0.0.8-beta.6 → 0.0.8-beta.8

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 = () => {
@@ -1109,7 +1142,8 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1109
1142
  ref_key: "floatingEl",
1110
1143
  ref: floatingEl,
1111
1144
  style: normalizeStyle(unref(dropdownPlacement)),
1112
- class: normalizeClass(unref(bemCssClasses))
1145
+ class: normalizeClass(unref(bemCssClasses)),
1146
+ onClick: _cache[0] || (_cache[0] = ($event) => hide())
1113
1147
  }, [
1114
1148
  props.arrow ? (openBlock(), createElementBlock("div", {
1115
1149
  key: 0,
@@ -1131,7 +1165,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1131
1165
  renderSlot(_ctx.$slots, "items", normalizeProps(guardReactiveProps({
1132
1166
  role: unref(itemRole)
1133
1167
  })))
1134
- ], 16, _hoisted_1$4),
1168
+ ], 16, _hoisted_1$5),
1135
1169
  renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps({ expanded: unref(expanded) })))
1136
1170
  ], 6), [
1137
1171
  [vShow, unref(expanded)]
@@ -1143,14 +1177,20 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1143
1177
  };
1144
1178
  }
1145
1179
  });
1180
+ function useInjectedDropdownTrigger() {
1181
+ return inject(INJECTION_KEY_DROPDOWN_TRIGGER, {});
1182
+ }
1146
1183
  function useInjectedDropdownItem() {
1147
1184
  return inject(INJECTION_KEY_DROPDOWN_ITEM, {});
1148
1185
  }
1149
- const __default__$5 = {
1186
+ function useInjectedDropdownAction() {
1187
+ return inject(INJECTION_KEY_DROPDOWN_ACTION, {});
1188
+ }
1189
+ const __default__$7 = {
1150
1190
  name: "VvDropdownItem"
1151
1191
  };
1152
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1153
- ...__default__$5,
1192
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
1193
+ ...__default__$7,
1154
1194
  setup(__props) {
1155
1195
  const { role, expanded } = useInjectedDropdownItem();
1156
1196
  const element = ref(null);
@@ -1174,12 +1214,12 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1174
1214
  };
1175
1215
  }
1176
1216
  });
1177
- const _hoisted_1$3 = ["title"];
1178
- const __default__$4 = {
1217
+ const _hoisted_1$4 = ["title"];
1218
+ const __default__$6 = {
1179
1219
  name: "VvDropdownOption"
1180
1220
  };
1181
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1182
- ...__default__$4,
1221
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
1222
+ ...__default__$6,
1183
1223
  props: {
1184
1224
  ...DisabledProps,
1185
1225
  ...SelectedProps,
@@ -1216,7 +1256,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1216
1256
  }
1217
1257
  });
1218
1258
  return (_ctx, _cache) => {
1219
- return openBlock(), createBlock(_sfc_main$5, {
1259
+ return openBlock(), createBlock(_sfc_main$7, {
1220
1260
  class: normalizeClass(unref(bemCssClasses)),
1221
1261
  tabindex: _ctx.disabled ? -1 : 0,
1222
1262
  "aria-selected": _ctx.selected,
@@ -1231,30 +1271,30 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1231
1271
  renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps({ disabled: _ctx.disabled, selected: _ctx.selected, unselectable: _ctx.unselectable })), () => [
1232
1272
  createTextVNode(toDisplayString(unref(hintLabel)), 1)
1233
1273
  ])
1234
- ], 8, _hoisted_1$3)
1274
+ ], 8, _hoisted_1$4)
1235
1275
  ]),
1236
1276
  _: 3
1237
1277
  }, 8, ["class", "tabindex", "aria-selected", "aria-disabled"]);
1238
1278
  };
1239
1279
  }
1240
1280
  });
1241
- const _hoisted_1$2 = {
1281
+ const _hoisted_1$3 = {
1242
1282
  class: "vv-dropdown-optgroup",
1243
1283
  role: "presentation",
1244
1284
  tabindex: "-1"
1245
1285
  };
1246
- const __default__$3 = {
1286
+ const __default__$5 = {
1247
1287
  name: "VvDropdownOptgroup"
1248
1288
  };
1249
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1250
- ...__default__$3,
1289
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
1290
+ ...__default__$5,
1251
1291
  props: {
1252
1292
  ...LabelProps
1253
1293
  },
1254
1294
  setup(__props) {
1255
1295
  const props = __props;
1256
1296
  return (_ctx, _cache) => {
1257
- return openBlock(), createElementBlock("li", _hoisted_1$2, toDisplayString(props.label), 1);
1297
+ return openBlock(), createElementBlock("li", _hoisted_1$3, toDisplayString(props.label), 1);
1258
1298
  };
1259
1299
  }
1260
1300
  });
@@ -1598,8 +1638,8 @@ function useOptions(props) {
1598
1638
  getOptionGrouped
1599
1639
  };
1600
1640
  }
1601
- const _hoisted_1$1 = ["for"];
1602
- const _hoisted_2$1 = { class: "vv-select__wrapper" };
1641
+ const _hoisted_1$2 = ["for"];
1642
+ const _hoisted_2$2 = { class: "vv-select__wrapper" };
1603
1643
  const _hoisted_3$1 = {
1604
1644
  key: 0,
1605
1645
  class: "vv-select__input-before"
@@ -1614,11 +1654,11 @@ const _hoisted_10 = {
1614
1654
  key: 1,
1615
1655
  class: "vv-select__input-after"
1616
1656
  };
1617
- const __default__$2 = {
1657
+ const __default__$4 = {
1618
1658
  name: "VvSelect"
1619
1659
  };
1620
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1621
- ...__default__$2,
1660
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
1661
+ ...__default__$4,
1622
1662
  props: VvSelectProps,
1623
1663
  emits: VvSelectEmits,
1624
1664
  setup(__props, { emit }) {
@@ -1736,13 +1776,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1736
1776
  _ctx.label ? (openBlock(), createElementBlock("label", {
1737
1777
  key: 0,
1738
1778
  for: unref(hasId)
1739
- }, toDisplayString(_ctx.label), 9, _hoisted_1$1)) : createCommentVNode("", true),
1740
- createElementVNode("div", _hoisted_2$1, [
1779
+ }, toDisplayString(_ctx.label), 9, _hoisted_1$2)) : createCommentVNode("", true),
1780
+ createElementVNode("div", _hoisted_2$2, [
1741
1781
  _ctx.$slots.before ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
1742
1782
  renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps(unref(slotProps))))
1743
1783
  ])) : createCommentVNode("", true),
1744
1784
  createElementVNode("div", _hoisted_4$1, [
1745
- unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
1785
+ unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
1746
1786
  key: 0,
1747
1787
  class: "vv-select__icon"
1748
1788
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true),
@@ -1782,7 +1822,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1782
1822
  ], 16, _hoisted_5$1), [
1783
1823
  [vModelSelect, unref(localModelValue)]
1784
1824
  ]),
1785
- unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
1825
+ unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
1786
1826
  key: 1,
1787
1827
  class: "vv-select__icon vv-select__icon-after"
1788
1828
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true)
@@ -1832,11 +1872,11 @@ const VvBadgeProps = {
1832
1872
  ...ModifiersProps,
1833
1873
  value: [String, Number]
1834
1874
  };
1835
- const __default__$1 = {
1875
+ const __default__$3 = {
1836
1876
  name: "VvBadge"
1837
1877
  };
1838
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1839
- ...__default__$1,
1878
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
1879
+ ...__default__$3,
1840
1880
  props: VvBadgeProps,
1841
1881
  setup(__props) {
1842
1882
  const props = __props;
@@ -1854,6 +1894,389 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
1854
1894
  };
1855
1895
  }
1856
1896
  });
1897
+ const VvActionEvents = ["click", "mouseover", "mouseleave"];
1898
+ const VvActionProps = ActionProps;
1899
+ const __default__$2 = {
1900
+ name: "VvAction"
1901
+ };
1902
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
1903
+ ...__default__$2,
1904
+ props: VvActionProps,
1905
+ emits: VvActionEvents,
1906
+ setup(__props, { expose: __expose, emit }) {
1907
+ const props = __props;
1908
+ const volver = useVolver();
1909
+ const element = ref(null);
1910
+ __expose({ $el: element });
1911
+ const {
1912
+ reference: dropdownTriggerReference,
1913
+ bus: dropdownEventBus,
1914
+ aria: dropdownAria,
1915
+ expanded: dropdownExpanded
1916
+ } = useInjectedDropdownTrigger();
1917
+ watch(
1918
+ () => element.value,
1919
+ (newValue) => {
1920
+ if (dropdownTriggerReference) {
1921
+ dropdownTriggerReference.value = newValue;
1922
+ }
1923
+ }
1924
+ );
1925
+ const pressed = computed(() => {
1926
+ return props.pressed || (dropdownExpanded == null ? void 0 : dropdownExpanded.value);
1927
+ });
1928
+ const { role } = useInjectedDropdownAction();
1929
+ const hasTag = computed(() => {
1930
+ switch (true) {
1931
+ case props.disabled:
1932
+ return ActionTag.button;
1933
+ case props.to !== void 0:
1934
+ return (volver == null ? void 0 : volver.nuxt) ? ActionTag.nuxtLink : ActionTag.routerLink;
1935
+ case props.href !== void 0:
1936
+ return ActionTag.a;
1937
+ default:
1938
+ return ActionTag.button;
1939
+ }
1940
+ });
1941
+ const hasProps = computed(() => {
1942
+ const toReturn = {
1943
+ ...dropdownAria == null ? void 0 : dropdownAria.value,
1944
+ "aria-pressed": pressed.value ? true : void 0,
1945
+ role: role == null ? void 0 : role.value
1946
+ };
1947
+ switch (hasTag.value) {
1948
+ case ActionTag.a:
1949
+ return {
1950
+ ...toReturn,
1951
+ href: props.href,
1952
+ target: props.target,
1953
+ rel: props.rel
1954
+ };
1955
+ case ActionTag.routerLink:
1956
+ case ActionTag.nuxtLink:
1957
+ return {
1958
+ ...toReturn,
1959
+ to: props.to,
1960
+ target: props.target
1961
+ };
1962
+ default:
1963
+ return {
1964
+ ...toReturn,
1965
+ type: props.type,
1966
+ disabled: props.disabled
1967
+ };
1968
+ }
1969
+ });
1970
+ const onClick = (e) => {
1971
+ if (props.disabled) {
1972
+ e.preventDefault();
1973
+ return;
1974
+ }
1975
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("click", e);
1976
+ emit("click", e);
1977
+ };
1978
+ const onMouseover = (e) => {
1979
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseover", e);
1980
+ emit("mouseover", e);
1981
+ };
1982
+ const onMouseleave = (e) => {
1983
+ dropdownEventBus == null ? void 0 : dropdownEventBus.emit("mouseleave", e);
1984
+ emit("mouseleave", e);
1985
+ };
1986
+ return (_ctx, _cache) => {
1987
+ return openBlock(), createBlock(resolveDynamicComponent(unref(hasTag)), mergeProps(unref(hasProps), {
1988
+ ref_key: "element",
1989
+ ref: element,
1990
+ class: {
1991
+ active: _ctx.active,
1992
+ pressed: unref(pressed),
1993
+ disabled: _ctx.disabled
1994
+ },
1995
+ onClickPassive: onClick,
1996
+ onMouseoverPassive: onMouseover,
1997
+ onMouseleavePassive: onMouseleave
1998
+ }), {
1999
+ default: withCtx(() => [
2000
+ renderSlot(_ctx.$slots, "default", {}, () => [
2001
+ createTextVNode(toDisplayString(_ctx.label), 1)
2002
+ ])
2003
+ ]),
2004
+ _: 3
2005
+ }, 16, ["class"]);
2006
+ };
2007
+ }
2008
+ });
2009
+ function useInjectedGroupState(groupKey) {
2010
+ const group = inject(groupKey, void 0);
2011
+ const isInGroup = computed(() => !isEmpty(group));
2012
+ function getGroupOrLocalRef(propName, props, emit) {
2013
+ if (group == null ? void 0 : group.value) {
2014
+ const groupPropValue = unref(group.value)[propName];
2015
+ return computed({
2016
+ get() {
2017
+ return groupPropValue == null ? void 0 : groupPropValue.value;
2018
+ },
2019
+ set(value) {
2020
+ groupPropValue.value = value;
2021
+ }
2022
+ });
2023
+ }
2024
+ const propRef = toRef(props, propName);
2025
+ return computed({
2026
+ get() {
2027
+ return propRef.value;
2028
+ },
2029
+ set(value) {
2030
+ if (emit)
2031
+ emit(`update:${propName}`, value);
2032
+ }
2033
+ });
2034
+ }
2035
+ return {
2036
+ group,
2037
+ isInGroup,
2038
+ getGroupOrLocalRef
2039
+ };
2040
+ }
2041
+ const VvButtonEvents = ["update:modelValue"];
2042
+ const VvButtonProps = {
2043
+ ...ActionProps,
2044
+ ...IdProps,
2045
+ ...ModifiersProps,
2046
+ ...UnselectableProps,
2047
+ ...LoadingProps,
2048
+ /**
2049
+ * Button icon
2050
+ */
2051
+ icon: [String, Object],
2052
+ /**
2053
+ * Button icon position
2054
+ */
2055
+ iconPosition: {
2056
+ type: String,
2057
+ default: Side.left,
2058
+ validator: (value) => Object.values(Side).includes(value)
2059
+ },
2060
+ /**
2061
+ * Loading icon
2062
+ */
2063
+ loadingIcon: { type: String, default: "eos-icons:bubble-loading" },
2064
+ /**
2065
+ * Enable button toggle
2066
+ */
2067
+ toggle: {
2068
+ type: Boolean,
2069
+ default: false
2070
+ },
2071
+ /**
2072
+ * Button toggle value
2073
+ */
2074
+ value: {
2075
+ type: [String, Number, Boolean],
2076
+ default: void 0
2077
+ },
2078
+ /**
2079
+ * Value associated with the unchecked state
2080
+ */
2081
+ uncheckedValue: {
2082
+ type: [String, Number, Boolean],
2083
+ default: void 0
2084
+ },
2085
+ /**
2086
+ * Button toggle model value
2087
+ */
2088
+ modelValue: {
2089
+ type: [String, Number, Boolean],
2090
+ default: void 0
2091
+ }
2092
+ };
2093
+ function useGroupProps(props, emit) {
2094
+ const { group, isInGroup, getGroupOrLocalRef } = useInjectedGroupState(INJECTION_KEY_BUTTON_GROUP);
2095
+ const { id, iconPosition, icon, label, pressed } = toRefs(props);
2096
+ const modelValue = getGroupOrLocalRef("modelValue", props, emit);
2097
+ const toggle = getGroupOrLocalRef("toggle", props);
2098
+ const unselectable = getGroupOrLocalRef(
2099
+ "unselectable",
2100
+ props
2101
+ );
2102
+ const multiple = computed(() => (group == null ? void 0 : group.value.multiple.value) ?? false);
2103
+ const modifiers = computed(() => {
2104
+ let localModifiers = props.modifiers;
2105
+ let groupModifiers = group == null ? void 0 : group.value.modifiers.value;
2106
+ const toReturn = /* @__PURE__ */ new Set();
2107
+ if (localModifiers) {
2108
+ if (!Array.isArray(localModifiers)) {
2109
+ localModifiers = localModifiers.split(" ");
2110
+ }
2111
+ localModifiers.forEach((modifier) => toReturn.add(modifier));
2112
+ }
2113
+ if (groupModifiers) {
2114
+ if (!Array.isArray(groupModifiers)) {
2115
+ groupModifiers = groupModifiers.split(" ");
2116
+ }
2117
+ groupModifiers.forEach((modifier) => toReturn.add(modifier));
2118
+ }
2119
+ return Array.from(toReturn);
2120
+ });
2121
+ const disabled = computed(
2122
+ () => {
2123
+ var _a;
2124
+ return Boolean(props.disabled || ((_a = group == null ? void 0 : group.value) == null ? void 0 : _a.disabled.value));
2125
+ }
2126
+ );
2127
+ return {
2128
+ // group props
2129
+ group,
2130
+ isInGroup,
2131
+ modelValue,
2132
+ toggle,
2133
+ unselectable,
2134
+ multiple,
2135
+ modifiers,
2136
+ disabled,
2137
+ // local props
2138
+ id,
2139
+ pressed,
2140
+ iconPosition,
2141
+ icon,
2142
+ label
2143
+ };
2144
+ }
2145
+ const _hoisted_1$1 = {
2146
+ key: 1,
2147
+ class: "vv-button__label"
2148
+ };
2149
+ const _hoisted_2$1 = {
2150
+ key: 1,
2151
+ class: "vv-button__label"
2152
+ };
2153
+ const __default__$1 = {
2154
+ name: "VvButton"
2155
+ };
2156
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
2157
+ ...__default__$1,
2158
+ props: VvButtonProps,
2159
+ emits: VvButtonEvents,
2160
+ setup(__props, { expose: __expose, emit }) {
2161
+ const props = __props;
2162
+ const attrs = useAttrs();
2163
+ const slots = useSlots();
2164
+ const {
2165
+ id,
2166
+ modifiers,
2167
+ iconPosition,
2168
+ icon,
2169
+ label,
2170
+ modelValue,
2171
+ disabled,
2172
+ toggle,
2173
+ unselectable
2174
+ } = useGroupProps(props, emit);
2175
+ const hasId = useUniqueId(id);
2176
+ const name = computed(() => (attrs == null ? void 0 : attrs.name) || hasId.value);
2177
+ const element = ref(null);
2178
+ const $el = computed(() => {
2179
+ var _a;
2180
+ return (_a = element.value) == null ? void 0 : _a.$el;
2181
+ });
2182
+ __expose({ $el });
2183
+ const pressed = computed(() => {
2184
+ if (!toggle.value) {
2185
+ return props.pressed;
2186
+ }
2187
+ if (Array.isArray(modelValue.value)) {
2188
+ return contains(name.value, modelValue.value);
2189
+ }
2190
+ return equals(name.value, modelValue.value);
2191
+ });
2192
+ const bemCssClasses = useModifiers(
2193
+ "vv-button",
2194
+ modifiers,
2195
+ computed(() => ({
2196
+ reverse: [Side.right, Side.bottom].includes(
2197
+ iconPosition.value
2198
+ ),
2199
+ column: [Side.top, Side.bottom].includes(
2200
+ iconPosition.value
2201
+ ),
2202
+ "icon-only": Boolean(
2203
+ (icon == null ? void 0 : icon.value) && !(label == null ? void 0 : label.value) && !slots.default
2204
+ )
2205
+ }))
2206
+ );
2207
+ const hasIconProps = computed(
2208
+ () => typeof (icon == null ? void 0 : icon.value) === "string" ? { name: icon == null ? void 0 : icon.value } : icon == null ? void 0 : icon.value
2209
+ );
2210
+ const toggleValue = computed(() => {
2211
+ return props.value !== void 0 ? props.value : name.value;
2212
+ });
2213
+ const onClick = () => {
2214
+ if (toggle.value) {
2215
+ if (Array.isArray(modelValue.value)) {
2216
+ if (contains(toggleValue.value, modelValue.value)) {
2217
+ if (unselectable.value) {
2218
+ modelValue.value = modelValue.value.filter(
2219
+ (n) => n !== toggleValue.value
2220
+ );
2221
+ }
2222
+ return;
2223
+ }
2224
+ modelValue.value.push(toggleValue.value);
2225
+ return;
2226
+ }
2227
+ if (toggleValue.value === modelValue.value && unselectable.value) {
2228
+ modelValue.value = props.uncheckedValue;
2229
+ return;
2230
+ }
2231
+ modelValue.value = toggleValue.value;
2232
+ }
2233
+ };
2234
+ return (_ctx, _cache) => {
2235
+ return openBlock(), createBlock(_sfc_main$2, mergeProps({
2236
+ disabled: unref(disabled),
2237
+ pressed: unref(pressed),
2238
+ active: _ctx.active,
2239
+ type: _ctx.type,
2240
+ to: _ctx.to,
2241
+ href: _ctx.href,
2242
+ target: _ctx.target,
2243
+ rel: _ctx.rel
2244
+ }, {
2245
+ id: unref(hasId),
2246
+ ref_key: "element",
2247
+ ref: element,
2248
+ class: unref(bemCssClasses),
2249
+ onClick
2250
+ }), {
2251
+ default: withCtx(() => [
2252
+ renderSlot(_ctx.$slots, "default", {}, () => [
2253
+ _ctx.loading ? renderSlot(_ctx.$slots, "loading", { key: 0 }, () => [
2254
+ _ctx.loadingIcon ? (openBlock(), createBlock(_sfc_main$9, {
2255
+ key: 0,
2256
+ class: "vv-button__loading-icon",
2257
+ name: _ctx.loadingIcon
2258
+ }, null, 8, ["name"])) : createCommentVNode("", true),
2259
+ _ctx.loadingLabel ? (openBlock(), createElementBlock("span", _hoisted_1$1, toDisplayString(_ctx.loadingLabel), 1)) : createCommentVNode("", true)
2260
+ ]) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2261
+ renderSlot(_ctx.$slots, "before"),
2262
+ unref(icon) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2263
+ key: 0,
2264
+ class: "vv-button__icon"
2265
+ }, unref(hasIconProps)), null, 16)) : createCommentVNode("", true),
2266
+ unref(label) ? (openBlock(), createElementBlock("span", _hoisted_2$1, [
2267
+ renderSlot(_ctx.$slots, "label", {}, () => [
2268
+ createTextVNode(toDisplayString(unref(label)), 1)
2269
+ ])
2270
+ ])) : createCommentVNode("", true),
2271
+ renderSlot(_ctx.$slots, "after")
2272
+ ], 64))
2273
+ ])
2274
+ ]),
2275
+ _: 3
2276
+ }, 16, ["id", "class"]);
2277
+ };
2278
+ }
2279
+ });
1857
2280
  function useDefaults(componentName, propsDefinition, props) {
1858
2281
  const volver = useVolver();
1859
2282
  const volverComponentDefaults = computed(() => {
@@ -1927,7 +2350,12 @@ const _hoisted_9 = {
1927
2350
  };
1928
2351
  const __default__ = {
1929
2352
  name: "VvCombobox",
1930
- components: { VvDropdown: _sfc_main$6, VvDropdownOption: _sfc_main$4, VvDropdownOptgroup: _sfc_main$3 }
2353
+ components: {
2354
+ VvDropdown: _sfc_main$8,
2355
+ VvDropdownOption: _sfc_main$6,
2356
+ VvDropdownOptgroup: _sfc_main$5,
2357
+ VvButton: _sfc_main$1
2358
+ }
1931
2359
  };
1932
2360
  const _sfc_main = /* @__PURE__ */ defineComponent({
1933
2361
  ...__default__,
@@ -2032,6 +2460,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2032
2460
  const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
2033
2461
  const hasSearchId = computed(() => `${hasId.value}-search`);
2034
2462
  const hasLabelId = computed(() => `${hasId.value}-label`);
2463
+ const dropdownEl = ref();
2035
2464
  const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
2036
2465
  icon,
2037
2466
  iconPosition
@@ -2208,20 +2637,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2208
2637
  ref: wrapperEl,
2209
2638
  class: "vv-select__wrapper"
2210
2639
  }, [
2211
- createVNode(_sfc_main$6, mergeProps({
2640
+ createVNode(_sfc_main$8, mergeProps({
2641
+ ref_key: "dropdownEl",
2642
+ ref: dropdownEl,
2212
2643
  modelValue: unref(expanded),
2213
2644
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(expanded) ? expanded.value = $event : null)
2214
2645
  }, unref(dropdownProps), {
2215
2646
  role: unref(DropdownRole).listbox,
2216
2647
  onAfterExpand,
2217
- onAfterCollapse
2648
+ onAfterCollapse,
2649
+ onClick: _cache[2] || (_cache[2] = ($event) => $event.stopPropagation())
2218
2650
  }), createSlots({
2219
2651
  default: withCtx(({ aria }) => [
2220
2652
  _ctx.$slots.before ? (openBlock(), createElementBlock("div", _hoisted_4, [
2221
2653
  renderSlot(_ctx.$slots, "before", normalizeProps(guardReactiveProps(unref(slotProps))))
2222
2654
  ])) : createCommentVNode("", true),
2223
2655
  createElementVNode("div", _hoisted_5, [
2224
- unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
2656
+ unref(hasIconBefore) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2225
2657
  key: 0,
2226
2658
  class: "vv-select__icon"
2227
2659
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true),
@@ -2241,7 +2673,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2241
2673
  renderSlot(_ctx.$slots, "value", normalizeProps(guardReactiveProps({ selectedOptions: unref(selectedOptions), onInput })), () => [
2242
2674
  unref(hasValue) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2243
2675
  !_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, {
2676
+ return openBlock(), createBlock(_sfc_main$3, {
2245
2677
  key: index,
2246
2678
  modifiers: _ctx.badgeModifiers,
2247
2679
  class: "vv-select__badge"
@@ -2253,7 +2685,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2253
2685
  "aria-label": unref(propsDefaults).deselectActionLabel,
2254
2686
  onClick: withModifiers(($event) => onInput(option), ["stop"])
2255
2687
  }, [
2256
- createVNode(_sfc_main$7, { name: "close" })
2688
+ createVNode(_sfc_main$9, { name: "close" })
2257
2689
  ], 8, _hoisted_8)) : createCommentVNode("", true)
2258
2690
  ]),
2259
2691
  _: 2
@@ -2264,7 +2696,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2264
2696
  ], 64))
2265
2697
  ])
2266
2698
  ], 16, _hoisted_6),
2267
- unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$7, mergeProps({
2699
+ unref(hasIconAfter) ? (openBlock(), createBlock(_sfc_main$9, mergeProps({
2268
2700
  key: 1,
2269
2701
  class: "vv-select__icon vv-select__icon-after"
2270
2702
  }, unref(hasIcon)), null, 16)) : createCommentVNode("", true)
@@ -2277,13 +2709,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2277
2709
  unref(filteredOptions).length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(filteredOptions), (option, index) => {
2278
2710
  return openBlock(), createElementBlock(Fragment, { key: index }, [
2279
2711
  isGroup(option) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2280
- createVNode(_sfc_main$3, {
2712
+ createVNode(_sfc_main$5, {
2281
2713
  label: unref(getOptionLabel)(option)
2282
2714
  }, null, 8, ["label"]),
2283
2715
  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(
2284
2716
  option
2285
2717
  ), (item, i) => {
2286
- return openBlock(), createBlock(_sfc_main$4, mergeProps({
2718
+ return openBlock(), createBlock(_sfc_main$6, mergeProps({
2287
2719
  disabled: unref(getOptionDisabled)(item),
2288
2720
  selected: getOptionSelected(item),
2289
2721
  unselectable: _ctx.unselectable,
@@ -2308,7 +2740,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2308
2740
  _: 2
2309
2741
  }, 1040, ["onClickPassive"]);
2310
2742
  }), 128))
2311
- ], 64)) : (openBlock(), createBlock(_sfc_main$4, mergeProps({ key: 1 }, {
2743
+ ], 64)) : (openBlock(), createBlock(_sfc_main$6, mergeProps({ key: 1 }, {
2312
2744
  disabled: unref(getOptionDisabled)(option),
2313
2745
  selected: getOptionSelected(option),
2314
2746
  unselectable: _ctx.unselectable,
@@ -2332,7 +2764,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2332
2764
  _: 2
2333
2765
  }, 1040, ["onClickPassive"]))
2334
2766
  ], 64);
2335
- }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$4, {
2767
+ }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$6, {
2336
2768
  key: 1,
2337
2769
  modifiers: "inert"
2338
2770
  }, {
@@ -2342,7 +2774,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2342
2774
  ])
2343
2775
  ]),
2344
2776
  _: 3
2345
- })) : (openBlock(), createBlock(_sfc_main$4, {
2777
+ })) : (openBlock(), createBlock(_sfc_main$6, {
2346
2778
  key: 2,
2347
2779
  modifiers: "inert"
2348
2780
  }, {
@@ -2354,6 +2786,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2354
2786
  _: 3
2355
2787
  }))
2356
2788
  ]),
2789
+ after: withCtx(() => [
2790
+ renderSlot(_ctx.$slots, "dropdown::after", {}, () => {
2791
+ var _a;
2792
+ return [
2793
+ ((_a = unref(dropdownEl)) == null ? void 0 : _a.dropdownCustomPosition) === "true" ? (openBlock(), createBlock(_sfc_main$1, {
2794
+ key: 0,
2795
+ label: "Close",
2796
+ modifiers: "secondary"
2797
+ })) : createCommentVNode("", true)
2798
+ ];
2799
+ })
2800
+ ]),
2357
2801
  _: 2
2358
2802
  }, [
2359
2803
  unref(searchable) || _ctx.$slots["dropdown::before"] ? {
@@ -2379,13 +2823,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2379
2823
  ]) : createCommentVNode("", true)
2380
2824
  ]),
2381
2825
  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
2826
  } : void 0
2390
2827
  ]), 1040, ["modelValue", "role"])
2391
2828
  ], 512),
@@ -2422,8 +2859,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
2422
2859
  key: "3"
2423
2860
  } : void 0
2424
2861
  ]), 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))
2862
+ ], 10, _hoisted_1)) : (openBlock(), createBlock(_sfc_main$4, mergeProps({ key: 1 }, unref(selectProps), {
2863
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => emit("update:modelValue", $event))
2427
2864
  }), null, 16));
2428
2865
  };
2429
2866
  }