@volverjs/ui-vue 0.0.10-beta.24 → 0.0.10-beta.26
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.
- package/auto-imports.d.ts +1 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +14 -12
- package/dist/components/VvAccordion/VvAccordion.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +169 -89
- package/dist/components/VvAccordionGroup/VvAccordionGroup.umd.js +1 -1
- package/dist/components/VvAccordionGroup/VvAccordionGroup.vue.d.ts +31 -5
- package/dist/components/VvAccordionGroup/index.d.ts +7 -4
- package/dist/components/VvAction/VvAction.es.js +14 -12
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +2 -11
- package/dist/components/VvAction/index.d.ts +1 -5
- package/dist/components/VvAlert/VvAlert.es.js +14 -12
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +14 -12
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAvatar/VvAvatar.es.js +14 -12
- package/dist/components/VvAvatar/VvAvatar.umd.js +1 -1
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +14 -12
- package/dist/components/VvAvatarGroup/VvAvatarGroup.umd.js +1 -1
- package/dist/components/VvBadge/VvBadge.es.js +14 -12
- package/dist/components/VvBadge/VvBadge.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +14 -12
- package/dist/components/VvBreadcrumb/VvBreadcrumb.umd.js +1 -1
- package/dist/components/VvBreadcrumb/VvBreadcrumb.vue.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +14 -12
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +2 -19
- package/dist/components/VvButton/index.d.ts +1 -5
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +14 -12
- package/dist/components/VvButtonGroup/VvButtonGroup.umd.js +1 -1
- package/dist/components/VvCard/VvCard.es.js +14 -12
- package/dist/components/VvCard/VvCard.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +14 -12
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +14 -12
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +58 -34
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +2 -8
- package/dist/components/VvCombobox/index.d.ts +9 -2
- package/dist/components/VvDialog/VvDialog.es.js +14 -12
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +24 -16
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +2 -19
- package/dist/components/VvDropdown/VvDropdownItem.vue.d.ts +13 -1
- package/dist/components/VvDropdown/VvDropdownOption.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +37 -0
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +64 -15
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.es.js +322 -1
- package/dist/components/VvDropdownItem/VvDropdownItem.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +14 -12
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.umd.js +1 -1
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +131 -76
- package/dist/components/VvDropdownOption/VvDropdownOption.umd.js +1 -1
- package/dist/components/VvInputFile/VvInputFile.es.js +14 -12
- package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
- package/dist/components/VvInputFile/index.d.ts +5 -5
- package/dist/components/VvInputText/VvInputText.es.js +979 -107
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +44 -1
- package/dist/components/VvInputText/index.d.ts +28 -0
- package/dist/components/VvNav/VvNav.es.js +14 -12
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/VvNav.vue.d.ts +1 -1
- package/dist/components/VvNavItem/VvNavItem.es.js +14 -12
- package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +14 -12
- package/dist/components/VvProgress/VvProgress.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.es.js +14 -12
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +14 -12
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +14 -12
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvTab/VvTab.es.js +14 -12
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTab/VvTab.vue.d.ts +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +14 -12
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.es.js +14 -12
- package/dist/components/VvTooltip/VvTooltip.umd.js +1 -1
- package/dist/components/index.es.js +435 -195
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/dropdown/useInjectDropdown.d.ts +3 -23
- package/dist/composables/dropdown/useProvideDropdown.d.ts +2 -3
- package/dist/composables/usePersistence.d.ts +3 -0
- package/dist/constants.d.ts +24 -21
- package/dist/directives/index.es.js +14 -12
- package/dist/directives/index.umd.js +1 -1
- package/dist/directives/v-tooltip.es.js +14 -12
- package/dist/directives/v-tooltip.umd.js +1 -1
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +11 -11
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +51 -9
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +327 -64
- package/dist/stories/Button/Button.settings.d.ts +0 -1
- package/dist/types/nav.d.ts +1 -2
- package/package.json +1 -1
- package/src/assets/icons/detailed.json +1 -1
- package/src/assets/icons/normal.json +1 -1
- package/src/assets/icons/simple.json +1 -1
- package/src/components/VvAccordionGroup/VvAccordionGroup.vue +86 -69
- package/src/components/VvAccordionGroup/index.ts +3 -5
- package/src/components/VvCombobox/VvCombobox.vue +2 -0
- package/src/components/VvDropdown/VvDropdown.vue +11 -2
- package/src/components/VvDropdown/VvDropdownItem.vue +4 -1
- package/src/components/VvDropdown/VvDropdownOption.vue +3 -21
- package/src/components/VvDropdown/index.ts +35 -1
- package/src/components/VvInputText/VvInputText.vue +98 -3
- package/src/components/VvInputText/index.ts +24 -1
- package/src/composables/dropdown/useProvideDropdown.ts +4 -4
- package/src/composables/usePersistence.ts +76 -0
- package/src/constants.ts +23 -18
- package/src/props/index.ts +12 -7
- package/src/stories/AccordionGroup/AccordionGroup.settings.ts +2 -2
- package/src/stories/AccordionGroup/AccordionGroup.test.ts +5 -5
- package/src/stories/Button/Button.settings.ts +1 -4
- package/src/types/nav.ts +1 -3
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { computed, defineComponent, provide, h, Fragment, unref, toRefs, useAttrs, ref, onMounted, watch, nextTick, openBlock, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, mergeProps, toHandlers, withDirectives, createElementVNode, normalizeStyle, normalizeClass, createCommentVNode, vShow } from "vue";
|
|
2
2
|
import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
|
|
3
3
|
import { uid } from "uid";
|
|
4
|
-
import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, onKeyStroke } from "@vueuse/core";
|
|
4
|
+
import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, useElementHover, onKeyStroke } from "@vueuse/core";
|
|
5
5
|
import mitt from "mitt";
|
|
6
|
+
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
7
|
+
StorageType2["local"] = "local";
|
|
8
|
+
StorageType2["session"] = "session";
|
|
9
|
+
return StorageType2;
|
|
10
|
+
})(StorageType || {});
|
|
6
11
|
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
7
12
|
Strategy2["absolute"] = "absolute";
|
|
8
13
|
Strategy2["fixed"] = "fixed";
|
|
@@ -54,13 +59,6 @@ var DropdownItemRole = /* @__PURE__ */ ((DropdownItemRole2) => {
|
|
|
54
59
|
DropdownItemRole2["presentation"] = "presentation";
|
|
55
60
|
return DropdownItemRole2;
|
|
56
61
|
})(DropdownItemRole || {});
|
|
57
|
-
var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
58
|
-
AnchorTarget2["_blank"] = "_blank";
|
|
59
|
-
AnchorTarget2["_self"] = "_self";
|
|
60
|
-
AnchorTarget2["_parent"] = "_parent";
|
|
61
|
-
AnchorTarget2["_top"] = "_top";
|
|
62
|
-
return AnchorTarget2;
|
|
63
|
-
})(AnchorTarget || {});
|
|
64
62
|
const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
65
63
|
"dropdownTrigger"
|
|
66
64
|
);
|
|
@@ -82,11 +80,7 @@ const LinkProps = {
|
|
|
82
80
|
/**
|
|
83
81
|
* Anchor target
|
|
84
82
|
*/
|
|
85
|
-
target:
|
|
86
|
-
type: String,
|
|
87
|
-
default: void 0,
|
|
88
|
-
validator: (value) => Object.values(AnchorTarget).includes(value)
|
|
89
|
-
},
|
|
83
|
+
target: String,
|
|
90
84
|
/**
|
|
91
85
|
* Anchor rel
|
|
92
86
|
*/
|
|
@@ -298,6 +292,14 @@ const DropdownProps = {
|
|
|
298
292
|
default: ActionTag.button
|
|
299
293
|
}
|
|
300
294
|
});
|
|
295
|
+
({
|
|
296
|
+
storageType: {
|
|
297
|
+
type: String,
|
|
298
|
+
default: StorageType.local,
|
|
299
|
+
validator: (value) => Object.values(StorageType).includes(value)
|
|
300
|
+
},
|
|
301
|
+
storageKey: String
|
|
302
|
+
});
|
|
301
303
|
const VvDropdownProps = {
|
|
302
304
|
...IdProps,
|
|
303
305
|
...DropdownProps,
|
|
@@ -356,14 +358,14 @@ function useProvideDropdownTrigger({
|
|
|
356
358
|
}
|
|
357
359
|
function useProvideDropdownItem({
|
|
358
360
|
role,
|
|
359
|
-
|
|
361
|
+
...others
|
|
360
362
|
}) {
|
|
361
363
|
const itemRole = computed(
|
|
362
364
|
() => role.value === DropdownRole.listbox ? DropdownItemRole.option : DropdownItemRole.presentation
|
|
363
365
|
);
|
|
364
366
|
provide(INJECTION_KEY_DROPDOWN_ITEM, {
|
|
365
367
|
role: itemRole,
|
|
366
|
-
|
|
368
|
+
...others
|
|
367
369
|
});
|
|
368
370
|
return { itemRole };
|
|
369
371
|
}
|
|
@@ -629,7 +631,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
629
631
|
});
|
|
630
632
|
bus.on("click", toggle);
|
|
631
633
|
const { role, modifiers } = toRefs(props);
|
|
632
|
-
const { itemRole } = useProvideDropdownItem({ role, expanded });
|
|
633
634
|
const bemCssClasses = useModifiers(
|
|
634
635
|
"vv-dropdown",
|
|
635
636
|
modifiers,
|
|
@@ -698,6 +699,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
698
699
|
}
|
|
699
700
|
});
|
|
700
701
|
};
|
|
702
|
+
const hovered = useElementHover(floatingEl);
|
|
703
|
+
const { itemRole } = useProvideDropdownItem({
|
|
704
|
+
role,
|
|
705
|
+
expanded,
|
|
706
|
+
focused,
|
|
707
|
+
hovered
|
|
708
|
+
});
|
|
701
709
|
onKeyStroke("Escape", (e) => {
|
|
702
710
|
if (expanded.value) {
|
|
703
711
|
e.preventDefault();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("uid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","uid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.uid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var a=(e=>(e.absolute="absolute",e.fixed="fixed",e))(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("uid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","uid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.uid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var a=(e=>(e.local="local",e.session="session",e))(a||{}),n=(e=>(e.absolute="absolute",e.fixed="fixed",e))(n||{}),u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),i=(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))(i||{}),d=(e=>(e.before="before",e.after="after",e))(d||{}),s=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(s||{}),f=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(f||{}),p=(e=>(e.listbox="listbox",e.menu="menu",e))(p||{}),c=(e=>(e.option="option",e.presentation="presentation",e))(c||{});const v=Symbol.for("dropdownTrigger"),m=Symbol.for("dropdownItem"),b=(Boolean,Boolean,Boolean,Boolean,{modifiers:{type:[String,Array],default:void 0}});d.before;const g={id:[String,Number]},h={placement:{type:String,default:u.bottom,validator:e=>Object.values(u).includes(e)||Object.values(i).includes(e)},strategy:{type:String,default:void 0,validator:e=>Object.values(n).includes(e)},transitionName:{type:String,default:void 0},offset:{type:[Number,String,Object],default:0},shift:{type:[Boolean,Object],default:!1},flip:{type:[Boolean,Object],default:!0},size:{type:[Boolean,Object],default:()=>({padding:10})},autoPlacement:{type:[Boolean,Object],default:!1},arrow:{type:Boolean,default:!1},keepOpen:{type:Boolean,default:!1},autofocusFirst:{type:Boolean,default:!0},triggerWidth:{type:Boolean,default:!1}};s.button,f.button,a.local;const y={...g,...h,...b,modelValue:{type:Boolean,default:void 0},reference:{type:Object,default:null},role:{type:String,default:p.menu,validator:e=>Object.values(p).includes(e)}};const x=["id","tabindex","role","aria-labelledby"];return e.defineComponent({name:"VvDropdown",inheritAttrs:!1,props:y,emits:["update:modelValue","beforeExpand","beforeCollapse","afterExpand","afterCollapse","before-enter","after-leave","enter","after-enter","enter-cancelled","before-leave","leave","leave-cancelled"],setup(a,{expose:i,emit:d}){const s=a,f=d,{id:b}=e.toRefs(s),g=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.uid()))))(b),h=e.useAttrs(),y=e.ref("auto"),w=e.ref("auto"),S=e.ref(null),k=e.ref(),E=e.ref(null),P=e.ref(null),B=e.computed({get:()=>s.reference??S.value,set:e=>{S.value=e}}),O=e.ref(!1);e.onMounted((()=>{r.useMutationObserver(k.value,(()=>{var e;O.value="true"===(null==(e=window.getComputedStyle(k.value).getPropertyValue("--dropdown-custom-position"))?void 0:e.trim())}),{attributeFilter:["style"],window:window})}));const $=e.computed((()=>{const e=[];if(s.autoPlacement?"boolean"==typeof s.autoPlacement?e.push(t.autoPlacement()):e.push(t.autoPlacement(s.autoPlacement)):s.flip&&("boolean"==typeof s.flip?e.push(t.flip({fallbackStrategy:"initialPlacement"})):e.push(t.flip(s.flip))),s.shift&&("boolean"==typeof s.shift?e.push(t.shift()):e.push(t.shift(s.shift))),s.size){const o=({availableWidth:e,availableHeight:t})=>{y.value=`${e}px`,w.value=`${t}px`};"boolean"==typeof s.size?e.push(t.size({apply:o})):e.push(t.size({...s.size,apply:o}))}return s.offset&&(e.push(t.offset(Number(s.offset))),["string","number"].includes(typeof s.offset)?e.push(t.offset(Number(s.offset))):e.push(t.offset(s.offset))),s.arrow&&e.push(t.arrow({element:E})),e})),{x:z,y:V,middlewareData:j,placement:C,strategy:A}=t.useFloating(B,k,{whileElementsMounted:(...e)=>t.autoUpdate(...e,{animationFrame:s.strategy===n.fixed}),placement:e.computed((()=>s.placement)),strategy:e.computed((()=>s.strategy)),middleware:$}),N=e.computed((()=>{var e;if(O.value)return;const t=s.triggerWidth&&B.value?`${null==(e=B.value)?void 0:e.offsetWidth}px`:void 0;return{position:A.value,top:`${V.value??0}px`,left:`${z.value??0}px`,maxWidth:t?void 0:y.value,maxHeight:w.value,width:t}})),D=e.computed((()=>C.value.split("-")[0])),_=e.computed((()=>{var e,t,o,r,l;if(O.value)return;const a={[u.top]:u.bottom,[u.right]:u.left,[u.bottom]:u.top,[u.left]:u.right}[D.value];return{left:void 0!==(null==(e=j.value.arrow)?void 0:e.x)?`${null==(t=j.value.arrow)?void 0:t.x}px`:void 0,top:void 0!==(null==(o=j.value.arrow)?void 0:o.y)?`${null==(r=j.value.arrow)?void 0:r.y}px`:void 0,[a]:-((null==(l=E.value)?void 0:l.offsetWidth)??0)/2+"px"}})),F=r.useVModel(s,"modelValue",f),R=e.ref(!1),T=e.computed({get:()=>F.value??R.value,set:e=>{void 0!==F.value?F.value=e:R.value=e}}),W=()=>{T.value=!0},q=()=>{T.value=!1},H=()=>{T.value=!T.value},K=e=>{B.value=e};i({toggle:H,show:W,hide:q,init:K,customPosition:O}),e.watch(T,(t=>{t&&s.autofocusFirst&&e.nextTick((()=>{const e=Y(k.value);e.length>0&&e[0].focus({preventScroll:!0})}))})),r.onClickOutside(k,(()=>{!s.keepOpen&&T.value&&(T.value=!1)}),{ignore:[B]});const M=e.computed((()=>{var e,t;return(null==(t=null==(e=B.value)?void 0:e.getAttribute)?void 0:t.call(e,"id"))??void 0})),L=e.computed((()=>({"aria-controls":g.value,"aria-haspopup":!0,"aria-expanded":T.value}))),{component:U,bus:I}=function({reference:t,id:o,expanded:r,aria:a}){const n=l(),u=e.defineComponent({name:"VvDropdownTriggerProvider",setup(){e.provide(v,{reference:t,id:o,expanded:r,aria:a,bus:n})},render(){var t,o;return e.h(e.Fragment,{},null==(o=(t=this.$slots).default)?void 0:o.call(t))}});return{bus:n,component:u}}({reference:B,id:g,expanded:T,aria:L});I.on("click",H);const{role:G,modifiers:J}=e.toRefs(s),Q=function(t,o,r){return e.computed((()=>{const l={[t]:!0},a="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return a&&Array.isArray(a)&&a.forEach((e=>{e&&(l[`${t}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((o=>{l[`${t}--${o}`]=e.unref(r.value[o])})),l}))}("vv-dropdown",J,e.computed((()=>({arrow:s.arrow})))),{focused:X}=r.useFocusWithin(k);function Y(e){return e?[...e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter((e=>!e.hasAttribute("disabled")&&!e.getAttribute("aria-hidden"))):[]}const Z=r.useElementHover(k),{itemRole:ee}=function({role:t,...o}){const r=e.computed((()=>t.value===p.listbox?c.option:c.presentation));return e.provide(m,{role:r,...o}),{itemRole:r}}({role:G,expanded:T,focused:X,hovered:Z});r.onKeyStroke("Escape",(e=>{T.value&&(e.preventDefault(),q())})),r.onKeyStroke("ArrowDown",(t=>{T.value&&X.value&&(t.preventDefault(),e.nextTick((()=>{if(X.value){const e=Y(k.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t<e.length-1?e[t+1].focus({preventScroll:!0}):e[0].focus({preventScroll:!0})}})))})),r.onKeyStroke("ArrowUp",(t=>{T.value&&X.value&&(t.preventDefault(),e.nextTick((()=>{if(X.value){const e=Y(k.value);if(0===e.length||!document.activeElement)return;const t=e.indexOf(document.activeElement);t>0?e[t-1].focus({preventScroll:!0}):e[e.length-1].focus({preventScroll:!0})}})))})),r.onKeyStroke([" ","Enter"],(e=>{const t=e.target;T.value&&X.value&&t&&(null==t||t.click())}));const te={"before-enter":()=>{f(T.value?"beforeExpand":"beforeCollapse"),f("before-enter")},"after-leave":()=>{f(T.value?"afterExpand":"afterCollapse"),f("after-leave")},enter:()=>{f("enter")},"after-enter":()=>{f("after-enter")},"enter-cancelled":()=>{f("enter-cancelled")},"before-leave":()=>{f("before-leave")},leave:()=>{f("leave")},"leave-cancelled":()=>{f("leave-cancelled")}};return(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(U),null,{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps({init:K,show:W,hide:q,toggle:H,expanded:e.unref(T),aria:e.unref(L)})))])),_:3}),e.createVNode(e.Transition,e.mergeProps({name:t.transitionName},e.toHandlers(te),{persisted:""}),{default:e.withCtx((()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"floatingEl",ref:k,style:e.normalizeStyle(e.unref(N)),class:e.normalizeClass(e.unref(Q))},[s.arrow?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"arrowEl",ref:E,style:e.normalizeStyle(e.unref(_)),class:"vv-dropdown__arrow"},null,4)):e.createCommentVNode("v-if",!0),e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(T)}))),e.createElementVNode("div",e.mergeProps(e.unref(h),{id:e.unref(g),ref_key:"listEl",ref:P,tabindex:e.unref(T)?void 0:-1,role:e.unref(G),"aria-labelledby":e.unref(M),class:"vv-dropdown__list"}),[e.renderSlot(t.$slots,"items",e.normalizeProps(e.guardReactiveProps({role:e.unref(ee)})))],16,x),e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(T)})))],6),[[e.vShow,e.unref(T)]])])),_:3},16,["name"])],64))}})}));
|
|
@@ -16,19 +16,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
16
16
|
type: StringConstructor;
|
|
17
17
|
default: import("../../constants").ActionTag;
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* @description Define component classes with BEM style.
|
|
21
|
-
* @returns {Array} The component classes.
|
|
22
|
-
*/
|
|
23
19
|
to: {
|
|
24
20
|
type: (ObjectConstructor | StringConstructor)[];
|
|
25
21
|
};
|
|
26
22
|
href: StringConstructor;
|
|
27
|
-
target:
|
|
28
|
-
type: globalThis.PropType<"_blank" | "_self" | "_parent" | "_top">;
|
|
29
|
-
default: undefined;
|
|
30
|
-
validator: (value: import("../../constants").AnchorTarget) => boolean;
|
|
31
|
-
};
|
|
23
|
+
target: StringConstructor;
|
|
32
24
|
rel: {
|
|
33
25
|
type: StringConstructor;
|
|
34
26
|
default: string;
|
|
@@ -71,19 +63,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
71
63
|
type: StringConstructor;
|
|
72
64
|
default: import("../../constants").ActionTag;
|
|
73
65
|
};
|
|
74
|
-
/**
|
|
75
|
-
* @description Define component classes with BEM style.
|
|
76
|
-
* @returns {Array} The component classes.
|
|
77
|
-
*/
|
|
78
66
|
to: {
|
|
79
67
|
type: (ObjectConstructor | StringConstructor)[];
|
|
80
68
|
};
|
|
81
69
|
href: StringConstructor;
|
|
82
|
-
target:
|
|
83
|
-
type: globalThis.PropType<"_blank" | "_self" | "_parent" | "_top">;
|
|
84
|
-
default: undefined;
|
|
85
|
-
validator: (value: import("../../constants").AnchorTarget) => boolean;
|
|
86
|
-
};
|
|
70
|
+
target: StringConstructor;
|
|
87
71
|
rel: {
|
|
88
72
|
type: StringConstructor;
|
|
89
73
|
default: string;
|
|
@@ -113,7 +97,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
113
97
|
disabled: boolean;
|
|
114
98
|
modifiers: string | string[];
|
|
115
99
|
type: "button" | "submit" | "reset";
|
|
116
|
-
target: "_blank" | "_self" | "_parent" | "_top";
|
|
117
100
|
ariaLabel: string;
|
|
118
101
|
defaultTag: string;
|
|
119
102
|
rel: string;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
+
focusOnHover: {
|
|
3
|
+
type: BooleanConstructor;
|
|
4
|
+
default: boolean;
|
|
5
|
+
};
|
|
6
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<globalThis.ExtractPropTypes<{
|
|
7
|
+
focusOnHover: {
|
|
8
|
+
type: BooleanConstructor;
|
|
9
|
+
default: boolean;
|
|
10
|
+
};
|
|
11
|
+
}>>, {
|
|
12
|
+
focusOnHover: boolean;
|
|
13
|
+
}, {}>, {
|
|
2
14
|
default?(_: {}): any;
|
|
3
15
|
}>;
|
|
4
16
|
export default _default;
|
|
@@ -8,6 +8,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
8
8
|
selectedHintLabel: {
|
|
9
9
|
type: StringConstructor;
|
|
10
10
|
};
|
|
11
|
+
focusOnHover: {
|
|
12
|
+
type: BooleanConstructor;
|
|
13
|
+
default: boolean;
|
|
14
|
+
};
|
|
11
15
|
modifiers: {
|
|
12
16
|
type: globalThis.PropType<string | string[]>;
|
|
13
17
|
default: undefined;
|
|
@@ -34,6 +38,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
34
38
|
selectedHintLabel: {
|
|
35
39
|
type: StringConstructor;
|
|
36
40
|
};
|
|
41
|
+
focusOnHover: {
|
|
42
|
+
type: BooleanConstructor;
|
|
43
|
+
default: boolean;
|
|
44
|
+
};
|
|
37
45
|
modifiers: {
|
|
38
46
|
type: globalThis.PropType<string | string[]>;
|
|
39
47
|
default: undefined;
|
|
@@ -54,6 +62,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
54
62
|
disabled: boolean;
|
|
55
63
|
modifiers: string | string[];
|
|
56
64
|
unselectable: boolean;
|
|
65
|
+
focusOnHover: boolean;
|
|
57
66
|
selected: boolean;
|
|
58
67
|
}, {}>, {
|
|
59
68
|
default?(_: {}): any;
|
|
@@ -189,3 +189,40 @@ export declare const VvDropdownProps: {
|
|
|
189
189
|
};
|
|
190
190
|
id: (StringConstructor | NumberConstructor)[];
|
|
191
191
|
};
|
|
192
|
+
export declare const VvDropdownItemProps: {
|
|
193
|
+
focusOnHover: {
|
|
194
|
+
type: BooleanConstructor;
|
|
195
|
+
default: boolean;
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
export declare const VvDropdownOptionProps: {
|
|
199
|
+
deselectHintLabel: {
|
|
200
|
+
type: StringConstructor;
|
|
201
|
+
};
|
|
202
|
+
selectHintLabel: {
|
|
203
|
+
type: StringConstructor;
|
|
204
|
+
};
|
|
205
|
+
selectedHintLabel: {
|
|
206
|
+
type: StringConstructor;
|
|
207
|
+
};
|
|
208
|
+
focusOnHover: {
|
|
209
|
+
type: BooleanConstructor;
|
|
210
|
+
default: boolean;
|
|
211
|
+
};
|
|
212
|
+
modifiers: {
|
|
213
|
+
type: PropType<string | string[]>;
|
|
214
|
+
default: undefined;
|
|
215
|
+
};
|
|
216
|
+
unselectable: {
|
|
217
|
+
type: BooleanConstructor;
|
|
218
|
+
default: boolean;
|
|
219
|
+
};
|
|
220
|
+
selected: {
|
|
221
|
+
type: BooleanConstructor;
|
|
222
|
+
default: boolean;
|
|
223
|
+
};
|
|
224
|
+
disabled: {
|
|
225
|
+
type: BooleanConstructor;
|
|
226
|
+
default: boolean;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { inject, defineComponent, ref, watch, computed, openBlock, createBlock, resolveDynamicComponent, unref, mergeProps, withCtx, renderSlot, createTextVNode, toDisplayString, provide, createElementBlock, toRefs, createVNode } from "vue";
|
|
2
2
|
import "mitt";
|
|
3
3
|
import { useElementHover, useFocus, useFocusWithin } from "@vueuse/core";
|
|
4
|
+
var StorageType = /* @__PURE__ */ ((StorageType2) => {
|
|
5
|
+
StorageType2["local"] = "local";
|
|
6
|
+
StorageType2["session"] = "session";
|
|
7
|
+
return StorageType2;
|
|
8
|
+
})(StorageType || {});
|
|
4
9
|
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
5
10
|
Strategy2["absolute"] = "absolute";
|
|
6
11
|
Strategy2["fixed"] = "fixed";
|
|
@@ -48,13 +53,11 @@ var ActionRoles = /* @__PURE__ */ ((ActionRoles2) => {
|
|
|
48
53
|
ActionRoles2["menuitem"] = "menuitem";
|
|
49
54
|
return ActionRoles2;
|
|
50
55
|
})(ActionRoles || {});
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return AnchorTarget2;
|
|
57
|
-
})(AnchorTarget || {});
|
|
56
|
+
var DropdownRole = /* @__PURE__ */ ((DropdownRole2) => {
|
|
57
|
+
DropdownRole2["listbox"] = "listbox";
|
|
58
|
+
DropdownRole2["menu"] = "menu";
|
|
59
|
+
return DropdownRole2;
|
|
60
|
+
})(DropdownRole || {});
|
|
58
61
|
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
59
62
|
const INJECTION_KEY_DROPDOWN_TRIGGER = Symbol.for(
|
|
60
63
|
"dropdownTrigger"
|
|
@@ -80,11 +83,7 @@ const LinkProps = {
|
|
|
80
83
|
/**
|
|
81
84
|
* Anchor target
|
|
82
85
|
*/
|
|
83
|
-
target:
|
|
84
|
-
type: String,
|
|
85
|
-
default: void 0,
|
|
86
|
-
validator: (value) => Object.values(AnchorTarget).includes(value)
|
|
87
|
-
},
|
|
86
|
+
target: String,
|
|
88
87
|
/**
|
|
89
88
|
* Anchor rel
|
|
90
89
|
*/
|
|
@@ -165,7 +164,14 @@ const ModifiersProps = {
|
|
|
165
164
|
validation: (value) => Object.values(Position).includes(value)
|
|
166
165
|
}
|
|
167
166
|
});
|
|
168
|
-
|
|
167
|
+
const IdProps = {
|
|
168
|
+
/**
|
|
169
|
+
* Global attribute id
|
|
170
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id
|
|
171
|
+
*/
|
|
172
|
+
id: [String, Number]
|
|
173
|
+
};
|
|
174
|
+
const DropdownProps = {
|
|
169
175
|
/**
|
|
170
176
|
* Dropdown placement
|
|
171
177
|
*/
|
|
@@ -258,7 +264,7 @@ const ModifiersProps = {
|
|
|
258
264
|
type: Boolean,
|
|
259
265
|
default: false
|
|
260
266
|
}
|
|
261
|
-
}
|
|
267
|
+
};
|
|
262
268
|
const ActionProps = {
|
|
263
269
|
...DisabledProps,
|
|
264
270
|
...LabelProps,
|
|
@@ -289,6 +295,14 @@ const ActionProps = {
|
|
|
289
295
|
default: ActionTag.button
|
|
290
296
|
}
|
|
291
297
|
};
|
|
298
|
+
({
|
|
299
|
+
storageType: {
|
|
300
|
+
type: String,
|
|
301
|
+
default: StorageType.local,
|
|
302
|
+
validator: (value) => Object.values(StorageType).includes(value)
|
|
303
|
+
},
|
|
304
|
+
storageKey: String
|
|
305
|
+
});
|
|
292
306
|
const VvActionEvents = ["click", "mouseover", "mouseleave"];
|
|
293
307
|
const VvActionProps = ActionProps;
|
|
294
308
|
function useVolver() {
|
|
@@ -423,6 +437,39 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
423
437
|
};
|
|
424
438
|
}
|
|
425
439
|
});
|
|
440
|
+
({
|
|
441
|
+
...IdProps,
|
|
442
|
+
...DropdownProps,
|
|
443
|
+
...ModifiersProps,
|
|
444
|
+
/**
|
|
445
|
+
* Show / hide dropdown programmatically
|
|
446
|
+
*/
|
|
447
|
+
modelValue: {
|
|
448
|
+
type: Boolean,
|
|
449
|
+
default: void 0
|
|
450
|
+
},
|
|
451
|
+
/**
|
|
452
|
+
* Dropdown trigger element
|
|
453
|
+
*/
|
|
454
|
+
reference: {
|
|
455
|
+
type: Object,
|
|
456
|
+
default: null
|
|
457
|
+
},
|
|
458
|
+
/**
|
|
459
|
+
* Dropdown role
|
|
460
|
+
*/
|
|
461
|
+
role: {
|
|
462
|
+
type: String,
|
|
463
|
+
default: DropdownRole.menu,
|
|
464
|
+
validator: (value) => Object.values(DropdownRole).includes(value)
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
const VvDropdownItemProps = {
|
|
468
|
+
focusOnHover: {
|
|
469
|
+
type: Boolean,
|
|
470
|
+
default: false
|
|
471
|
+
}
|
|
472
|
+
};
|
|
426
473
|
function useProvideDropdownAction({
|
|
427
474
|
expanded
|
|
428
475
|
}) {
|
|
@@ -436,7 +483,9 @@ const __default__$1 = {
|
|
|
436
483
|
};
|
|
437
484
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
438
485
|
...__default__$1,
|
|
486
|
+
props: VvDropdownItemProps,
|
|
439
487
|
setup(__props) {
|
|
488
|
+
const props = __props;
|
|
440
489
|
const { role, expanded } = useInjectedDropdownItem();
|
|
441
490
|
const element = ref(null);
|
|
442
491
|
useProvideDropdownAction({ expanded });
|
|
@@ -444,7 +493,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
444
493
|
const { focused } = useFocus(element);
|
|
445
494
|
const { focused: focusedWithin } = useFocusWithin(element);
|
|
446
495
|
watch(hovered, (newValue) => {
|
|
447
|
-
if (newValue) {
|
|
496
|
+
if (newValue && props.focusOnHover) {
|
|
448
497
|
focused.value = true;
|
|
449
498
|
}
|
|
450
499
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("mitt"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","mitt","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdownAction=t(e.vue,null,e.core)}(this,(function(e,t,o){"use strict";var r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("mitt"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","mitt","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdownAction=t(e.vue,null,e.core)}(this,(function(e,t,o){"use strict";var r=(e=>(e.local="local",e.session="session",e))(r||{}),n=(e=>(e.absolute="absolute",e.fixed="fixed",e))(n||{}),l=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(l||{}),a=(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))(a||{}),u=(e=>(e.before="before",e.after="after",e))(u||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),s=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(s||{}),d=(e=>(e.button="button",e.link="link",e.menuitem="menuitem",e))(d||{}),c=(e=>(e.listbox="listbox",e.menu="menu",e))(c||{});const f=Symbol.for("volver"),p=Symbol.for("dropdownTrigger"),v=Symbol.for("dropdownItem"),m=Symbol.for("dropdownAction"),b={to:{type:[String,Object]},href:String,target:String,rel:{type:String,default:"noopener noreferrer"}},y={disabled:{type:Boolean,default:!1}},g={active:{type:Boolean,default:!1}},h={current:{type:Boolean,default:!1}},k={pressed:{type:Boolean,default:!1}},x={label:{type:[String,Number],default:void 0}},S={modifiers:{type:[String,Array],default:void 0}};u.before;l.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const B={...y,...x,...k,...g,...h,...b,type:{type:String,default:i.button,validator:e=>Object.values(i).includes(e)},ariaLabel:{type:String,default:void 0},defaultTag:{type:String,default:s.button}};r.local;const w=B;const L=e.defineComponent({name:"VvAction",props:w,emits:["click","mouseover","mouseleave"],setup(t,{expose:o,emit:r}){const n=t,l=r,a=e.inject(f),u=e.ref(null);o({$el:u});const{reference:i,bus:d,aria:c,expanded:v}=e.inject(p,{});e.watch((()=>u.value),(e=>{i&&(i.value=e)}));const b=e.computed((()=>n.pressed||(null==v?void 0:v.value))),{role:y}=e.inject(m,{}),g=e.computed((()=>{switch(!0){case n.disabled:return s.button;case void 0!==n.to:return(null==a?void 0:a.nuxt)?s.nuxtLink:s.routerLink;case void 0!==n.href:return s.a;default:return n.defaultTag}})),h=e.computed((()=>{const e={...null==c?void 0:c.value,ariaPressed:!!b.value||void 0,ariaLabel:n.ariaLabel,role:null==y?void 0:y.value};switch(g.value){case s.a:return{...e,href:n.href,target:n.target,rel:n.rel};case s.routerLink:case s.nuxtLink:return{...e,to:n.to,target:n.target};case s.button:return{...e,type:n.type,disabled:n.disabled};default:return e}})),k=e=>{n.disabled?e.preventDefault():(null==d||d.emit("click",e),l("click",e))},x=e=>{null==d||d.emit("mouseover",e),l("mouseover",e)},S=e=>{null==d||d.emit("mouseleave",e),l("mouseleave",e)};return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(g)),e.mergeProps(e.unref(h),{ref_key:"element",ref:u,class:{active:t.active,pressed:e.unref(b),disabled:t.disabled,current:t.current},onClickPassive:k,onMouseoverPassive:x,onMouseleavePassive:S}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});Boolean,c.menu;const j={focusOnHover:{type:Boolean,default:!1}};const C=e.defineComponent({name:"VvDropdownItem",props:j,setup(t){const r=t,{role:n,expanded:l}=e.inject(v,{}),a=e.ref(null);!function({expanded:t}){e.provide(m,{role:e.ref(d.menuitem),expanded:t})}({expanded:l});const u=o.useElementHover(a),{focused:i}=o.useFocus(a),{focused:s}=o.useFocusWithin(a);return e.watch(u,(e=>{e&&r.focusOnHover&&(i.value=!0)})),(t,o)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({role:e.unref(n)},{ref_key:"element",ref:a,class:["vv-dropdown__item",{"focus-visible":e.unref(i)||e.unref(s)}]}),[e.renderSlot(t.$slots,"default")],16))}});return e.defineComponent({name:"VvDropdownAction",props:{...B,...S},setup(t){const o=t,{modifiers:r}=e.toRefs(o),n=function(t,o,r){return e.computed((()=>{const n={[t]:!0},l="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(n[`${t}--${e}`]=!0)})),r&&Object.keys(r.value).forEach((o=>{n[`${t}--${o}`]=e.unref(r.value[o])})),n}))}("vv-dropdown-action",r);return(t,o)=>(e.openBlock(),e.createBlock(C,null,{default:e.withCtx((()=>[e.createVNode(L,e.mergeProps({disabled:t.disabled,pressed:t.pressed,active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel},{class:e.unref(n)}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"])])),_:3}))}})}));
|