@volverjs/ui-vue 0.0.8 → 0.0.9-beta.10
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/README.md +4 -4
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +7 -0
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +7 -0
- package/dist/components/VvAction/VvAction.es.js +9 -1
- package/dist/components/VvAction/VvAction.umd.js +1 -1
- package/dist/components/VvAction/VvAction.vue.d.ts +9 -0
- package/dist/components/VvAction/index.d.ts +4 -0
- package/dist/components/VvAlert/VvAlert.es.js +14 -6
- package/dist/components/VvAlert/VvAlert.umd.js +1 -1
- package/dist/components/VvAlert/VvAlert.vue.d.ts +6 -6
- package/dist/components/VvAlert/index.d.ts +3 -3
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +54 -10
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAvatar/VvAvatar.es.js +7 -0
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +7 -0
- package/dist/components/VvBadge/VvBadge.es.js +7 -0
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +7 -0
- package/dist/components/VvButton/VvButton.es.js +11 -2
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvButton/VvButton.vue.d.ts +9 -0
- package/dist/components/VvButton/index.d.ts +4 -0
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +7 -0
- package/dist/components/VvCard/VvCard.es.js +7 -0
- package/dist/components/VvCheckbox/VvCheckbox.es.js +91 -14
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +4 -4
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +97 -15
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +4 -4
- package/dist/components/VvCombobox/VvCombobox.es.js +164 -94
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +35 -14
- package/dist/components/VvCombobox/index.d.ts +24 -7
- package/dist/components/VvDialog/VvDialog.es.js +67 -27
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +58 -20
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +13 -12
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +1 -7
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +9 -1
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +7 -0
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +7 -0
- package/dist/components/VvInputText/VvInputText.es.js +87 -14
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +4 -4
- package/dist/components/VvNav/VvNav.es.js +10 -2
- package/dist/components/VvNav/VvNav.umd.js +1 -1
- package/dist/components/VvNav/index.d.ts +1 -1
- package/dist/components/VvProgress/VvProgress.es.js +7 -0
- package/dist/components/VvRadio/VvRadio.es.js +91 -14
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +4 -4
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +97 -15
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +4 -4
- package/dist/components/VvSelect/VvSelect.es.js +87 -14
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +4 -4
- package/dist/components/VvTab/VvTab.es.js +10 -2
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +87 -14
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +4 -4
- package/dist/components/VvTooltip/VvTooltip.es.js +7 -0
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +958 -431
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/alert/useAlert.d.ts +27 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/index.es.js +81 -0
- package/dist/composables/index.umd.js +1 -0
- package/dist/constants.d.ts +10 -0
- package/dist/directives/index.es.js +7 -0
- package/dist/directives/v-tooltip.es.js +7 -0
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +7 -0
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +43 -258
- package/dist/stories/Alert/Alert.settings.d.ts +3 -7
- package/dist/stories/AlertGroup/AlertGroupSlots.stories.d.ts +2 -2
- package/dist/stories/AlertGroup/AlertGroupWithComposable.stories.d.ts +6 -0
- package/dist/stories/Button/Button.settings.d.ts +3 -13
- package/dist/stories/Combobox/Combobox.settings.d.ts +117 -19
- package/dist/stories/Nav/Nav.settings.d.ts +3 -21
- package/package.json +54 -46
- 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/VvAction/VvAction.vue +2 -1
- package/src/components/VvAlert/VvAlert.vue +5 -1
- package/src/components/VvAlert/index.ts +3 -3
- package/src/components/VvAlertGroup/VvAlertGroup.vue +30 -0
- package/src/components/VvAlertGroup/index.ts +11 -1
- package/src/components/VvButton/VvButton.vue +1 -0
- package/src/components/VvCheckbox/VvCheckbox.vue +8 -1
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +8 -1
- package/src/components/VvCombobox/VvCombobox.vue +9 -4
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +36 -17
- package/src/components/VvDialog/index.ts +13 -1
- package/src/components/VvDropdown/VvDropdown.vue +44 -15
- package/src/components/VvDropdown/index.ts +2 -8
- package/src/components/VvInputText/VvInputText.vue +8 -1
- package/src/components/VvNav/VvNav.vue +1 -1
- package/src/components/VvNav/index.ts +1 -1
- package/src/components/VvRadio/VvRadio.vue +8 -1
- package/src/components/VvRadioGroup/VvRadioGroup.vue +8 -1
- package/src/components/VvSelect/VvSelect.vue +8 -1
- package/src/components/VvTextarea/VvTextarea.vue +8 -1
- package/src/components/common/HintSlot.ts +26 -13
- package/src/components/index.ts +5 -0
- package/src/composables/alert/useAlert.ts +103 -0
- package/src/composables/index.ts +1 -0
- package/src/constants.ts +21 -0
- package/src/props/index.ts +7 -0
- package/src/resolvers/unplugin.ts +3 -0
- package/src/stories/Alert/Alert.settings.ts +3 -1
- package/src/stories/AlertGroup/AlertGroup.test.ts +13 -0
- package/src/stories/AlertGroup/AlertGroupSlots.stories.ts +3 -3
- package/src/stories/AlertGroup/AlertGroupWithComposable.stories.ts +118 -0
- package/src/stories/Button/Button.settings.ts +5 -3
- package/src/stories/Combobox/Combobox.settings.ts +119 -2
- package/src/stories/Nav/Nav.settings.ts +3 -1
- package/src/stories/Tab/Tab.stories.ts +3 -3
- package/src/stories/Textarea/TextareaLength.stories.ts +1 -1
- package/src/types/alert.d.ts +20 -0
- /package/dist/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue.d.ts +0 -0
- /package/dist/components/{VvNavSeparator → VvNav}/VvNavSeparator.d.ts +0 -0
- /package/src/components/{VvNavItemTitle → VvNav}/VvNavItemTitle.vue +0 -0
- /package/src/components/{VvNavSeparator → VvNav}/VvNavSeparator.ts +0 -0
|
@@ -106,6 +106,12 @@ const LabelProps = {
|
|
|
106
106
|
*/
|
|
107
107
|
label: [String, Number]
|
|
108
108
|
};
|
|
109
|
+
const ModifiersProps = {
|
|
110
|
+
/**
|
|
111
|
+
* Component BEM modifiers
|
|
112
|
+
*/
|
|
113
|
+
modifiers: [String, Array]
|
|
114
|
+
};
|
|
109
115
|
({
|
|
110
116
|
/**
|
|
111
117
|
* VvIcon name or props
|
|
@@ -237,18 +243,19 @@ const DropdownProps = {
|
|
|
237
243
|
type: String,
|
|
238
244
|
default: ButtonType.button,
|
|
239
245
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
246
|
+
},
|
|
247
|
+
/**
|
|
248
|
+
* Button aria-label
|
|
249
|
+
*/
|
|
250
|
+
ariaLabel: {
|
|
251
|
+
type: String,
|
|
252
|
+
default: void 0
|
|
240
253
|
}
|
|
241
254
|
});
|
|
242
255
|
const VvDropdownProps = {
|
|
243
256
|
...IdProps,
|
|
244
257
|
...DropdownProps,
|
|
245
|
-
|
|
246
|
-
* Component BEM modifiers
|
|
247
|
-
*/
|
|
248
|
-
modifiers: {
|
|
249
|
-
type: [String, Array],
|
|
250
|
-
default: "mobile"
|
|
251
|
-
},
|
|
258
|
+
...ModifiersProps,
|
|
252
259
|
/**
|
|
253
260
|
* Show / hide dropdown programmatically
|
|
254
261
|
*/
|
|
@@ -350,7 +357,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
350
357
|
"beforeExpand",
|
|
351
358
|
"beforeCollapse",
|
|
352
359
|
"afterExpand",
|
|
353
|
-
"afterCollapse"
|
|
360
|
+
"afterCollapse",
|
|
361
|
+
"before-enter",
|
|
362
|
+
"after-leave",
|
|
363
|
+
"enter",
|
|
364
|
+
"after-enter",
|
|
365
|
+
"enter-cancelled",
|
|
366
|
+
"before-leave",
|
|
367
|
+
"leave",
|
|
368
|
+
"leave-cancelled"
|
|
354
369
|
],
|
|
355
370
|
setup(__props, { expose: __expose, emit }) {
|
|
356
371
|
const props = __props;
|
|
@@ -451,7 +466,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
451
466
|
referenceEl,
|
|
452
467
|
floatingEl,
|
|
453
468
|
{
|
|
454
|
-
whileElementsMounted:
|
|
469
|
+
whileElementsMounted: (...args) => {
|
|
470
|
+
return autoUpdate(...args, {
|
|
471
|
+
animationFrame: props.strategy === "fixed"
|
|
472
|
+
});
|
|
473
|
+
},
|
|
455
474
|
placement: computed(() => props.placement),
|
|
456
475
|
strategy: computed(() => props.strategy),
|
|
457
476
|
middleware
|
|
@@ -538,7 +557,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
538
557
|
onClickOutside(
|
|
539
558
|
floatingEl,
|
|
540
559
|
() => {
|
|
541
|
-
if (!props.keepOpen) {
|
|
560
|
+
if (!props.keepOpen && expanded.value) {
|
|
542
561
|
expanded.value = false;
|
|
543
562
|
}
|
|
544
563
|
},
|
|
@@ -576,7 +595,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
576
595
|
}
|
|
577
596
|
return [
|
|
578
597
|
...element.querySelectorAll(
|
|
579
|
-
'a[href], button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
|
|
598
|
+
'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
|
580
599
|
)
|
|
581
600
|
].filter(
|
|
582
601
|
(el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
|
|
@@ -654,11 +673,33 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
654
673
|
htmlEl == null ? void 0 : htmlEl.click();
|
|
655
674
|
}
|
|
656
675
|
});
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
676
|
+
const dropdownTransitionHandlers = {
|
|
677
|
+
"before-enter": () => {
|
|
678
|
+
emit(expanded.value ? "beforeExpand" : "beforeCollapse");
|
|
679
|
+
emit("before-enter");
|
|
680
|
+
},
|
|
681
|
+
"after-leave": () => {
|
|
682
|
+
emit(expanded.value ? "afterExpand" : "afterCollapse");
|
|
683
|
+
emit("after-leave");
|
|
684
|
+
},
|
|
685
|
+
enter: () => {
|
|
686
|
+
emit("enter");
|
|
687
|
+
},
|
|
688
|
+
"after-enter": () => {
|
|
689
|
+
emit("after-enter");
|
|
690
|
+
},
|
|
691
|
+
"enter-cancelled": () => {
|
|
692
|
+
emit("enter-cancelled");
|
|
693
|
+
},
|
|
694
|
+
"before-leave": () => {
|
|
695
|
+
emit("before-leave");
|
|
696
|
+
},
|
|
697
|
+
leave: () => {
|
|
698
|
+
emit("leave");
|
|
699
|
+
},
|
|
700
|
+
"leave-cancelled": () => {
|
|
701
|
+
emit("leave-cancelled");
|
|
702
|
+
}
|
|
662
703
|
};
|
|
663
704
|
return (_ctx, _cache) => {
|
|
664
705
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
@@ -668,10 +709,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
668
709
|
]),
|
|
669
710
|
_: 3
|
|
670
711
|
}),
|
|
671
|
-
createVNode(Transition, mergeProps({ name: _ctx.transitionName }, toHandlers({
|
|
672
|
-
beforeEnter: onTransitionBeforeEnter,
|
|
673
|
-
onAfterLeave: onTransitionAfterLeave
|
|
674
|
-
})), {
|
|
712
|
+
createVNode(Transition, mergeProps({ name: _ctx.transitionName }, toHandlers(dropdownTransitionHandlers)), {
|
|
675
713
|
default: withCtx(() => [
|
|
676
714
|
withDirectives(createElementVNode("div", {
|
|
677
715
|
ref_key: "floatingEl",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("nanoid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","nanoid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.nanoid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@floating-ui/vue"),require("nanoid"),require("@vueuse/core"),require("mitt")):"function"==typeof define&&define.amd?define(["vue","@floating-ui/vue","nanoid","@vueuse/core","mitt"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvDropdown=t(e.vue,e.vue$1,e.nanoid,e.core,e.mitt)}(this,(function(e,t,o,r,l){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),n=(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))(n||{}),u=(e=>(e.before="before",e.after="after",e))(u||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),d=(e=>(e.listbox="listbox",e.menu="menu",e))(d||{}),s=(e=>(e.option="option",e.presentation="presentation",e))(s||{});const f=Symbol.for("dropdownTrigger"),p=Symbol.for("dropdownItem"),c=(Boolean,Boolean,Boolean,{modifiers:[String,Array]});u.before;const v={id:[String,Number]},m={placement:{type:String,default:a.bottom,validator:e=>Object.values(a).includes(e)||Object.values(n).includes(e)},strategy:{type:String,default:"absolute",validator:e=>["fixed","absolute"].includes(e)},transitionName:{type:String},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}};i.button;const b={...v,...m,...c,modelValue:{type:Boolean,default:void 0},reference:{type:Object,default:null},role:{type:String,default:d.menu,validator:e=>Object.values(d).includes(e)}};const g=["id","tabindex","role","aria-labelledby"];return e.defineComponent({name:"VvDropdown",inheritAttrs:!1,props:b,emits:["update:modelValue","beforeExpand","beforeCollapse","afterExpand","afterCollapse","before-enter","after-leave","enter","after-enter","enter-cancelled","before-leave","leave","leave-cancelled"],setup(a,{expose:n,emit:u}){const i=a,{id:c}=e.toRefs(i),v=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(c),m=e.useAttrs(),b=e.ref("auto"),h=e.ref("auto"),y=e.ref(null),x=e.ref(),w=e.ref(null),S=e.ref(null),E=e.computed({get:()=>i.reference??y.value,set:e=>{y.value=e}}),k=e.ref(!1);e.onMounted((()=>{r.useMutationObserver(x.value,(()=>{var e;k.value="true"===(null==(e=window.getComputedStyle(x.value).getPropertyValue("--dropdown-custom-position"))?void 0:e.trim())}),{attributeFilter:["style"],window:window})}));const P=e.computed((()=>{const e=[];if(i.autoPlacement?"boolean"==typeof i.autoPlacement?e.push(t.autoPlacement()):e.push(t.autoPlacement(i.autoPlacement)):i.flip&&("boolean"==typeof i.flip?e.push(t.flip()):e.push(t.flip(i.flip))),i.shift&&("boolean"==typeof i.shift?e.push(t.shift()):e.push(t.shift(i.shift))),i.size){const o=({availableWidth:e,availableHeight:t})=>{b.value=`${e}px`,h.value=`${t}px`};"boolean"==typeof i.size?e.push(t.size({apply:o})):e.push(t.size({...i.size,apply:o}))}return i.offset&&(e.push(t.offset(Number(i.offset))),["string","number"].includes(typeof i.offset)?e.push(t.offset(Number(i.offset))):e.push(t.offset(i.offset))),i.arrow&&e.push(t.arrow({element:w})),e})),{x:$,y:B,strategy:O,middlewareData:z,placement:V}=t.useFloating(E,x,{whileElementsMounted:(...e)=>t.autoUpdate(...e,{animationFrame:"fixed"===i.strategy}),placement:e.computed((()=>i.placement)),strategy:e.computed((()=>i.strategy)),middleware:P}),C=e.computed((()=>{if(!k.value)return{position:O.value,top:`${B.value??0}px`,left:`${$.value??0}px`,maxWidth:b.value,maxHeight:h.value,width:i.triggerWidth&&E.value?`${E.value.offsetWidth}px`:void 0}})),j=e.computed((()=>V.value.split("-")[0])),A=e.computed((()=>{var e,t,o,r,l;if(k.value)return;const a={top:"bottom",right:"left",bottom:"top",left:"right"}[j.value];return{left:void 0!==(null==(e=z.value.arrow)?void 0:e.x)?`${null==(t=z.value.arrow)?void 0:t.x}px`:void 0,top:void 0!==(null==(o=z.value.arrow)?void 0:o.y)?`${null==(r=z.value.arrow)?void 0:r.y}px`:void 0,[a]:-((null==(l=w.value)?void 0:l.offsetWidth)??0)/2+"px"}})),N=r.useVModel(i,"modelValue",u),D=e.ref(!1),_=e.computed({get:()=>N.value??D.value,set:e=>{void 0!==N.value?N.value=e:D.value=e}}),F=()=>{_.value=!0},R=()=>{_.value=!1},T=()=>{_.value=!_.value},W=e=>{E.value=e};n({toggle:T,show:F,hide:R,init:W,customPosition:k}),e.watch(_,(t=>{t&&i.autofocusFirst&&e.nextTick((()=>{const e=Q(x.value);e.length>0&&e[0].focus({preventScroll:!0})}))})),r.onClickOutside(x,(()=>{!i.keepOpen&&_.value&&(_.value=!1)}),{ignore:[E]});const q=e.computed((()=>{var e,t;return(null==(t=null==(e=E.value)?void 0:e.getAttribute)?void 0:t.call(e,"id"))??void 0})),K=e.computed((()=>({"aria-controls":v.value,"aria-haspopup":!0,"aria-expanded":_.value}))),{component:M,bus:H}=function({reference:t,id:o,expanded:r,aria:a}){const n=l(),u=e.defineComponent({name:"VvDropdownTriggerProvider",setup(){e.provide(f,{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:E,id:v,expanded:_,aria:K});H.on("click",T);const{role:U,modifiers:I}=e.toRefs(i),{itemRole:G}=function({role:t,expanded:o}){const r=e.computed((()=>t.value===d.listbox?s.option:s.presentation));return e.provide(p,{role:r,expanded:o}),{itemRole:r}}({role:U,expanded:_}),J=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",I,e.computed((()=>({arrow:i.arrow})))),{focused:L}=r.useFocusWithin(x);function Q(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"))):[]}r.onKeyStroke("Escape",(e=>{_.value&&(e.preventDefault(),R())})),r.onKeyStroke("ArrowDown",(t=>{_.value&&L.value&&(t.preventDefault(),e.nextTick((()=>{if(L.value){const e=Q(x.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=>{_.value&&L.value&&(t.preventDefault(),e.nextTick((()=>{if(L.value){const e=Q(x.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;_.value&&L.value&&t&&(null==t||t.click())}));const X={"before-enter":()=>{u(_.value?"beforeExpand":"beforeCollapse"),u("before-enter")},"after-leave":()=>{u(_.value?"afterExpand":"afterCollapse"),u("after-leave")},enter:()=>{u("enter")},"after-enter":()=>{u("after-enter")},"enter-cancelled":()=>{u("enter-cancelled")},"before-leave":()=>{u("before-leave")},leave:()=>{u("leave")},"leave-cancelled":()=>{u("leave-cancelled")}};return(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(M),null,{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps({init:W,show:F,hide:R,toggle:T,expanded:e.unref(_),aria:e.unref(K)})))])),_:3}),e.createVNode(e.Transition,e.mergeProps({name:t.transitionName},e.toHandlers(X)),{default:e.withCtx((()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"floatingEl",ref:x,style:e.normalizeStyle(e.unref(C)),class:e.normalizeClass(e.unref(J))},[i.arrow?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"arrowEl",ref:w,style:e.normalizeStyle(e.unref(A)),class:"vv-dropdown__arrow"},null,4)):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(_)}))),e.createElementVNode("div",e.mergeProps(e.unref(m),{id:e.unref(v),ref_key:"listEl",ref:S,tabindex:e.unref(_)?void 0:-1,role:e.unref(U),"aria-labelledby":e.unref(q),class:"vv-dropdown__list"}),[e.renderSlot(t.$slots,"items",e.normalizeProps(e.guardReactiveProps({role:e.unref(G)})))],16,g),e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps({expanded:e.unref(_)})))],6),[[e.vShow,e.unref(_)]])])),_:3},16,["name"])],64))}})}));
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
2
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
3
|
-
modifiers: {
|
|
4
|
-
type: globalThis.PropType<string | string[]>;
|
|
5
|
-
default: string;
|
|
6
|
-
};
|
|
7
3
|
modelValue: {
|
|
8
4
|
type: BooleanConstructor;
|
|
9
5
|
default: undefined;
|
|
@@ -17,6 +13,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
17
13
|
default: import("../../constants").DropdownRole;
|
|
18
14
|
validator: (value: import("../../constants").DropdownRole) => boolean;
|
|
19
15
|
};
|
|
16
|
+
modifiers: globalThis.PropType<string | string[]>;
|
|
20
17
|
placement: {
|
|
21
18
|
type: globalThis.PropType<"left" | "right" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end">;
|
|
22
19
|
default: import("../../constants").Side;
|
|
@@ -113,11 +110,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
113
110
|
hide: () => void;
|
|
114
111
|
init: (el: HTMLElement) => void;
|
|
115
112
|
customPosition: Ref<boolean>;
|
|
116
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "beforeExpand" | "beforeCollapse" | "afterExpand" | "afterCollapse")[], "update:modelValue" | "beforeExpand" | "beforeCollapse" | "afterExpand" | "afterCollapse", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
117
|
-
modifiers: {
|
|
118
|
-
type: globalThis.PropType<string | string[]>;
|
|
119
|
-
default: string;
|
|
120
|
-
};
|
|
113
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "before-enter" | "after-leave" | "enter" | "after-enter" | "enter-cancelled" | "before-leave" | "leave" | "leave-cancelled" | "beforeExpand" | "beforeCollapse" | "afterExpand" | "afterCollapse")[], "update:modelValue" | "before-enter" | "after-leave" | "enter" | "after-enter" | "enter-cancelled" | "before-leave" | "leave" | "leave-cancelled" | "beforeExpand" | "beforeCollapse" | "afterExpand" | "afterCollapse", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
121
114
|
modelValue: {
|
|
122
115
|
type: BooleanConstructor;
|
|
123
116
|
default: undefined;
|
|
@@ -131,6 +124,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
131
124
|
default: import("../../constants").DropdownRole;
|
|
132
125
|
validator: (value: import("../../constants").DropdownRole) => boolean;
|
|
133
126
|
};
|
|
127
|
+
modifiers: globalThis.PropType<string | string[]>;
|
|
134
128
|
placement: {
|
|
135
129
|
type: globalThis.PropType<"left" | "right" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end">;
|
|
136
130
|
default: import("../../constants").Side;
|
|
@@ -222,12 +216,22 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
222
216
|
};
|
|
223
217
|
id: (StringConstructor | NumberConstructor)[];
|
|
224
218
|
}>> & {
|
|
219
|
+
onEnter?: ((...args: any[]) => any) | undefined;
|
|
220
|
+
onLeave?: ((...args: any[]) => any) | undefined;
|
|
225
221
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
222
|
+
"onBefore-enter"?: ((...args: any[]) => any) | undefined;
|
|
223
|
+
"onAfter-leave"?: ((...args: any[]) => any) | undefined;
|
|
224
|
+
"onAfter-enter"?: ((...args: any[]) => any) | undefined;
|
|
225
|
+
"onEnter-cancelled"?: ((...args: any[]) => any) | undefined;
|
|
226
|
+
"onBefore-leave"?: ((...args: any[]) => any) | undefined;
|
|
227
|
+
"onLeave-cancelled"?: ((...args: any[]) => any) | undefined;
|
|
226
228
|
onBeforeExpand?: ((...args: any[]) => any) | undefined;
|
|
227
229
|
onBeforeCollapse?: ((...args: any[]) => any) | undefined;
|
|
228
230
|
onAfterExpand?: ((...args: any[]) => any) | undefined;
|
|
229
231
|
onAfterCollapse?: ((...args: any[]) => any) | undefined;
|
|
230
232
|
}, {
|
|
233
|
+
reference: HTMLElement | null;
|
|
234
|
+
modelValue: boolean;
|
|
231
235
|
shift: boolean | Partial<import("@floating-ui/vue").ShiftOptions & {
|
|
232
236
|
rootBoundary: import("@floating-ui/vue").RootBoundary;
|
|
233
237
|
elementContext: import("@floating-ui/vue").ElementContext;
|
|
@@ -235,9 +239,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
235
239
|
padding: import("@floating-ui/vue").Padding;
|
|
236
240
|
boundary: import("@floating-ui/vue").Boundary;
|
|
237
241
|
}> | undefined;
|
|
238
|
-
reference: HTMLElement | null;
|
|
239
|
-
modelValue: boolean;
|
|
240
|
-
modifiers: string | string[];
|
|
241
242
|
role: "listbox" | "menu";
|
|
242
243
|
flip: boolean | Partial<import("@floating-ui/vue").FlipOptions & {
|
|
243
244
|
rootBoundary: import("@floating-ui/vue").RootBoundary;
|
|
@@ -5,6 +5,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
5
5
|
default: import("../../constants").ButtonType;
|
|
6
6
|
validator: (value: import("../../constants").ButtonType) => boolean;
|
|
7
7
|
};
|
|
8
|
+
ariaLabel: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
default: undefined;
|
|
11
|
+
};
|
|
8
12
|
to: {
|
|
9
13
|
type: (ObjectConstructor | StringConstructor)[];
|
|
10
14
|
};
|
|
@@ -28,6 +32,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
28
32
|
default: import("../../constants").ButtonType;
|
|
29
33
|
validator: (value: import("../../constants").ButtonType) => boolean;
|
|
30
34
|
};
|
|
35
|
+
ariaLabel: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
31
39
|
to: {
|
|
32
40
|
type: (ObjectConstructor | StringConstructor)[];
|
|
33
41
|
};
|
|
@@ -47,6 +55,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
47
55
|
}>>, {
|
|
48
56
|
disabled: boolean;
|
|
49
57
|
type: "button" | "submit" | "reset";
|
|
58
|
+
ariaLabel: string;
|
|
50
59
|
rel: string;
|
|
51
60
|
active: boolean;
|
|
52
61
|
pressed: boolean;
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import { DropdownRole } from '../../constants';
|
|
3
3
|
export declare const VvDropdownProps: {
|
|
4
|
-
/**
|
|
5
|
-
* Component BEM modifiers
|
|
6
|
-
*/
|
|
7
|
-
modifiers: {
|
|
8
|
-
type: PropType<string | string[]>;
|
|
9
|
-
default: string;
|
|
10
|
-
};
|
|
11
4
|
/**
|
|
12
5
|
* Show / hide dropdown programmatically
|
|
13
6
|
*/
|
|
@@ -30,6 +23,7 @@ export declare const VvDropdownProps: {
|
|
|
30
23
|
default: DropdownRole;
|
|
31
24
|
validator: (value: DropdownRole) => boolean;
|
|
32
25
|
};
|
|
26
|
+
modifiers: PropType<string | string[]>;
|
|
33
27
|
placement: {
|
|
34
28
|
type: PropType<"left" | "right" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end" | "right-start" | "right-end">;
|
|
35
29
|
default: import("../../constants").Side;
|
|
@@ -241,6 +241,13 @@ const ActionProps = {
|
|
|
241
241
|
type: String,
|
|
242
242
|
default: ButtonType.button,
|
|
243
243
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
244
|
+
},
|
|
245
|
+
/**
|
|
246
|
+
* Button aria-label
|
|
247
|
+
*/
|
|
248
|
+
ariaLabel: {
|
|
249
|
+
type: String,
|
|
250
|
+
default: void 0
|
|
244
251
|
}
|
|
245
252
|
};
|
|
246
253
|
const VvActionEvents = ["click", "mouseover", "mouseleave"];
|
|
@@ -302,7 +309,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
302
309
|
const hasProps = computed(() => {
|
|
303
310
|
const toReturn = {
|
|
304
311
|
...dropdownAria == null ? void 0 : dropdownAria.value,
|
|
305
|
-
|
|
312
|
+
ariaPressed: pressed.value ? true : void 0,
|
|
313
|
+
ariaLabel: props.ariaLabel,
|
|
306
314
|
role: role == null ? void 0 : role.value
|
|
307
315
|
};
|
|
308
316
|
switch (hasTag.value) {
|
|
@@ -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))(r||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),l=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(l||{}),
|
|
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))(r||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),l=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(l||{}),a=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(a||{}),u=(e=>(e.button="button",e.link="link",e.menuitem="menuitem",e))(u||{}),i=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(i||{});const s=Symbol.for("volver"),d=Symbol.for("dropdownTrigger"),c=Symbol.for("dropdownItem"),f=Symbol.for("dropdownAction"),p={to:{type:[String,Object]},href:String,target:{type:String,validator:e=>Object.values(i).includes(e)},rel:{type:String,default:"noopener noreferrer"}},v={disabled:Boolean},m={active:Boolean},b={pressed:Boolean},y={label:[String,Number]},g={modifiers:[String,Array]};n.before,r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const k={...v,...y,...b,...m,...p,type:{type:String,default:l.button,validator:e=>Object.values(l).includes(e)},ariaLabel:{type:String,default:void 0}},h=k;const x=e.defineComponent({name:"VvAction",props:h,emits:["click","mouseover","mouseleave"],setup(t,{expose:o,emit:r}){const n=t,l=e.inject(s),u=e.ref(null);o({$el:u});const{reference:i,bus:c,aria:p,expanded:v}=e.inject(d,{});e.watch((()=>u.value),(e=>{i&&(i.value=e)}));const m=e.computed((()=>n.pressed||(null==v?void 0:v.value))),{role:b}=e.inject(f,{}),y=e.computed((()=>{switch(!0){case n.disabled:return a.button;case void 0!==n.to:return(null==l?void 0:l.nuxt)?a.nuxtLink:a.routerLink;case void 0!==n.href:return a.a;default:return a.button}})),g=e.computed((()=>{const e={...null==p?void 0:p.value,ariaPressed:!!m.value||void 0,ariaLabel:n.ariaLabel,role:null==b?void 0:b.value};switch(y.value){case a.a:return{...e,href:n.href,target:n.target,rel:n.rel};case a.routerLink:case a.nuxtLink:return{...e,to:n.to,target:n.target};default:return{...e,type:n.type,disabled:n.disabled}}})),k=e=>{n.disabled?e.preventDefault():(null==c||c.emit("click",e),r("click",e))},h=e=>{null==c||c.emit("mouseover",e),r("mouseover",e)},x=e=>{null==c||c.emit("mouseleave",e),r("mouseleave",e)};return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(y)),e.mergeProps(e.unref(g),{ref_key:"element",ref:u,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled},onClickPassive:k,onMouseoverPassive:h,onMouseleavePassive:x}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});const B=e.defineComponent({name:"VvDropdownItem",setup(t){const{role:r,expanded:n}=e.inject(c,{}),l=e.ref(null);!function({expanded:t}){e.provide(f,{role:e.ref(u.menuitem),expanded:t})}({expanded:n});const a=o.useElementHover(l),{focused:i}=o.useFocus(l),{focused:s}=o.useFocusWithin(l);return e.watch(a,(e=>{e&&(i.value=!0)})),(t,o)=>(e.openBlock(),e.createElementBlock("div",e.mergeProps({role:e.unref(r)},{ref_key:"element",ref:l,class:["vv-dropdown__item",{"focus-visible":e.unref(i)||e.unref(s)}]}),[e.renderSlot(t.$slots,"default")],16))}});return e.defineComponent({name:"VvDropdownAction",props:{...k,...g},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(B,null,{default:e.withCtx((()=>[e.createVNode(x,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}))}})}));
|
|
@@ -210,6 +210,13 @@ const LabelProps = {
|
|
|
210
210
|
type: String,
|
|
211
211
|
default: ButtonType.button,
|
|
212
212
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
213
|
+
},
|
|
214
|
+
/**
|
|
215
|
+
* Button aria-label
|
|
216
|
+
*/
|
|
217
|
+
ariaLabel: {
|
|
218
|
+
type: String,
|
|
219
|
+
default: void 0
|
|
213
220
|
}
|
|
214
221
|
});
|
|
215
222
|
const _hoisted_1 = {
|
|
@@ -281,6 +281,13 @@ const UnselectableProps = {
|
|
|
281
281
|
type: String,
|
|
282
282
|
default: ButtonType.button,
|
|
283
283
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
284
|
+
},
|
|
285
|
+
/**
|
|
286
|
+
* Button aria-label
|
|
287
|
+
*/
|
|
288
|
+
ariaLabel: {
|
|
289
|
+
type: String,
|
|
290
|
+
default: void 0
|
|
284
291
|
}
|
|
285
292
|
});
|
|
286
293
|
function useModifiers(prefix, modifiers, others) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { unref, computed, defineComponent, h, inject, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withModifiers, withDirectives,
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withModifiers, withDirectives, vModelDynamic, createTextVNode, createVNode, createSlots, withCtx } from "vue";
|
|
2
2
|
import { Mask } from "maska";
|
|
3
3
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
@@ -15,19 +15,27 @@ function joinLines(items) {
|
|
|
15
15
|
}
|
|
16
16
|
return items;
|
|
17
17
|
}
|
|
18
|
-
function HintSlotFactory(
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
19
|
+
const props = computed(() => {
|
|
20
|
+
if (isRef(propsOrRef)) {
|
|
21
|
+
return propsOrRef.value;
|
|
22
|
+
}
|
|
23
|
+
return propsOrRef;
|
|
24
|
+
});
|
|
25
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
26
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
27
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
28
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
23
29
|
const hasLoadingLabelOrSlot = computed(
|
|
24
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
30
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
25
31
|
);
|
|
26
32
|
const hasInvalidLabelOrSlot = computed(
|
|
27
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
33
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
34
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
35
|
+
)
|
|
28
36
|
);
|
|
29
37
|
const hasValidLabelOrSlot = computed(
|
|
30
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
38
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
31
39
|
);
|
|
32
40
|
const hasHintLabelOrSlot = computed(
|
|
33
41
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -36,10 +44,10 @@ function HintSlotFactory(props, slots) {
|
|
|
36
44
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
37
45
|
);
|
|
38
46
|
const hintSlotScope = computed(() => ({
|
|
39
|
-
modelValue: props.modelValue,
|
|
40
|
-
valid: props.valid,
|
|
41
|
-
invalid: props.invalid,
|
|
42
|
-
loading: props.loading
|
|
47
|
+
modelValue: props.value.modelValue,
|
|
48
|
+
valid: props.value.valid,
|
|
49
|
+
invalid: props.value.invalid,
|
|
50
|
+
loading: props.value.loading
|
|
43
51
|
}));
|
|
44
52
|
const HintSlot = defineComponent({
|
|
45
53
|
name: "HintSlot",
|
|
@@ -700,6 +708,13 @@ const InputTextareaProps = {
|
|
|
700
708
|
type: String,
|
|
701
709
|
default: ButtonType.button,
|
|
702
710
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
711
|
+
},
|
|
712
|
+
/**
|
|
713
|
+
* Button aria-label
|
|
714
|
+
*/
|
|
715
|
+
ariaLabel: {
|
|
716
|
+
type: String,
|
|
717
|
+
default: void 0
|
|
703
718
|
}
|
|
704
719
|
});
|
|
705
720
|
const INPUT_TYPES = {
|
|
@@ -1125,6 +1140,59 @@ function VvInputTextActionsFactory(type, parentProps) {
|
|
|
1125
1140
|
}
|
|
1126
1141
|
};
|
|
1127
1142
|
}
|
|
1143
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
1144
|
+
const volver = useVolver();
|
|
1145
|
+
const volverComponentDefaults = computed(() => {
|
|
1146
|
+
var _a;
|
|
1147
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
1148
|
+
return void 0;
|
|
1149
|
+
}
|
|
1150
|
+
return volver.defaults.value[componentName];
|
|
1151
|
+
});
|
|
1152
|
+
return computed(() => {
|
|
1153
|
+
if (volverComponentDefaults.value === void 0) {
|
|
1154
|
+
return props;
|
|
1155
|
+
}
|
|
1156
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
1157
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
1158
|
+
const simplifiedProps = props;
|
|
1159
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
1160
|
+
const propValue = simplifiedProps[key];
|
|
1161
|
+
acc[key] = propValue;
|
|
1162
|
+
if (key in componentDefaults) {
|
|
1163
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
1164
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
1165
|
+
if (typeArray.length) {
|
|
1166
|
+
const typeFunction = typeArray[0];
|
|
1167
|
+
if (typeFunction === propValue) {
|
|
1168
|
+
acc[key] = componentDefaults[key];
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
1173
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
1174
|
+
if (typeFunction() === propValue) {
|
|
1175
|
+
acc[key] = componentDefaults[key];
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
1179
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
1180
|
+
if (typeof defaultValue === "function") {
|
|
1181
|
+
defaultValue = defaultValue();
|
|
1182
|
+
}
|
|
1183
|
+
if (typeof defaultValue === "object") {
|
|
1184
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
1185
|
+
acc[key] = componentDefaults[key];
|
|
1186
|
+
}
|
|
1187
|
+
} else if (defaultValue === propValue) {
|
|
1188
|
+
acc[key] = componentDefaults[key];
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
return acc;
|
|
1193
|
+
}, {});
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1128
1196
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
1129
1197
|
function useDebouncedInput(modelValue, emit, ms = 0, {
|
|
1130
1198
|
getter = (value) => value,
|
|
@@ -1254,6 +1322,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1254
1322
|
setup(__props, { expose: __expose, emit }) {
|
|
1255
1323
|
const props = __props;
|
|
1256
1324
|
const slots = useSlots();
|
|
1325
|
+
const propsDefaults = useDefaults(
|
|
1326
|
+
"VvInputText",
|
|
1327
|
+
VvInputTextProps,
|
|
1328
|
+
props
|
|
1329
|
+
);
|
|
1257
1330
|
const inputEl = ref();
|
|
1258
1331
|
const innerEl = ref();
|
|
1259
1332
|
__expose({ $inner: innerEl });
|
|
@@ -1440,7 +1513,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
1440
1513
|
hasHintLabelOrSlot,
|
|
1441
1514
|
hasInvalidLabelOrSlot,
|
|
1442
1515
|
hintSlotScope
|
|
1443
|
-
} = HintSlotFactory(
|
|
1516
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
1444
1517
|
const PasswordInputActions = VvInputTextActionsFactory(
|
|
1445
1518
|
INPUT_TYPES.PASSWORD,
|
|
1446
1519
|
props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("maska"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","maska","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.maska,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l,n){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function p(t,o,l){return e.computed((()=>{const n={[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&&(n[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{n[`${t}--${o}`]=e.unref(l.value[o])})),n}))}const v=e.defineComponent({name:"VvIcon",props:r,setup(t){const l=t,n=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),a=e.ref(!0),i=e.inject(c),{modifiers:r}=e.toRefs(l),u=p("vv-icon",r),s=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=l.name??"",t=`@${s.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t;const n=null==i?void 0:i.iconsCollections.find((t=>{const l=`@${s.value}:${t.prefix}:${e}`;return o.iconExists(l)}));return n?`@${s.value}:${n.prefix}:${e}`:e}));function v(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==t?void 0:t.innerHTML.trim())||"";t&&n&&o.addIcon(`@${s.value}:${l.prefix}:${l.name}`,{body:n,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&l.src&&!o.iconExists(`@${s.value}:${l.prefix}:${l.name}`)&&(a.value=!1,i.fetchIcon(l.src).then((e=>{e&&(v(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&v(l.svg),(t,l)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(n),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),m={valid:Boolean,validLabel:[String,Array]},f={invalid:Boolean,invalidLabel:[String,Array]},h={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},b={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),S={readonly:Boolean},y={modifiers:[String,Array]},w={hintLabel:{type:String,default:""}},k={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},B={debounce:[Number,String]},L={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},E={tabindex:{type:[String,Number],default:0}},x={floating:Boolean},P={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const T={...{...P,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...E,...b,...S,...m,...f,...w,...h,...y,...k,...B,...L,...x,...g,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const C={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},$="eye-on",A="eye-off",I="calendar",V="time",_="color",O={...T,modelValue:[String,Number],type:{type:String,default:C.TEXT,validator:e=>Object.values(C).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:$},iconHidePassword:{type:String,default:A},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},mask:{type:String,default:void 0},maskEager:{type:Boolean,default:!1},maskReversed:{type:Boolean,default:!1},maskTokens:{type:Object,default:void 0},maskTokensReplace:{type:Boolean,default:!1},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String}},R=e.defineComponent({components:{VvIcon:v},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:$},iconHide:{type:String,default:A}},emits:["toggle-password"],setup(t,{emit:o}){const l=e.ref(!1),n=e.computed((()=>l.value?t.iconHide:t.iconShow));return{active:l,activeIcon:n,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(l.value=!l.value,o("toggle-password",l.value))}}},render(){const t=e.h(v,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),D=e.defineComponent({components:{VvIcon:v},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:o}){const l=e.computed((()=>"up"===t.mode));return{isUp:l,onClick:e=>{null==e||e.stopPropagation(),t.disabled||o(l.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),N=e.defineComponent({components:{VvIcon:v},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(o){null==o||o.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(v,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function H(t,o){return{name:"VvInputTextActions",components:{VvIcon:v,VvInputPasswordAction:R,VvInputStepAction:D,VvInputClearAction:N},setup:()=>({isDisabled:e.computed((()=>o.disabled||o.readonly)),labelStepUp:o.labelStepUp,labelStepDown:o.labelStepDown,labelShowPassword:o.labelShowPassword,labelHidePassword:o.labelHidePassword,labelClear:o.labelClear,iconShowPassword:o.iconShowPassword,iconHidePassword:o.iconHidePassword}),render(){let l=null;switch(t){case C.SEARCH:{const{onClear:t}=this.$attrs;l=[e.h(N,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case C.PASSWORD:{const{onTogglePassword:t}=this.$attrs;l=[e.h(R,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case C.NUMBER:{const{onStepUp:t,onStepDown:n}=this.$attrs;l=[e.h(D,{mode:"up",disabled:this.isDisabled||void 0!==o.max&&o.modelValue===o.max,label:this.labelStepUp,onStepUp:t,onStepDown:n}),e.h(D,{mode:"down",disabled:this.isDisabled||void 0!==o.min&&o.modelValue===o.min,label:this.labelStepDown,onStepUp:t,onStepDown:n})];break}}return Array.isArray(l)?e.h("div",{class:"vv-input-text__actions-group"},l):l}}}const M=["for"],U={class:"vv-input-text__wrapper"},W={key:0,class:"vv-input-text__input-before"},q=["onClick"],z=["id"],j={key:1,class:"vv-input-text__unit"},F={key:5,class:"vv-input-text__input-after"},X={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:O,emits:["update:modelValue","focus","blur","keyup"],setup(o,{expose:r,emit:d}){const c=o,m=e.useSlots(),f=e.ref(),h=e.ref();r({$inner:h});const{id:b,icon:g,iconPosition:S,label:y,modelValue:w,count:k,valid:B,invalid:L,loading:E}=e.toRefs(c),x=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(b),P=e.computed((()=>`${x.value}-hint`)),T=e.computed((()=>c.floating&&a(c.placeholder)?" ":c.placeholder)),$=function(t,o,l=0,{getter:n=(e=>e),setter:a=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>n(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",a(e))}),l)}})}(w,d,c.debounce,{getter:e=>we.value?we.value.masked(e??""):e,setter:e=>(we.value&&(e=we.value.unmasked(e)),c.type===C.NUMBER?Number(e):e)}),{focused:A}=function(t,o){const{focused:l}=n.useFocus(t);return e.watch(l,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:l}}(f,d),O=e.computed((()=>A.value&&!c.disabled&&!c.readonly)),R=n.useElementVisibility(f);e.watch(R,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(A.value=!0)}));const D=e.ref(!1),N=e.computed((()=>c.type===C.PASSWORD)),K=()=>{D.value=!D.value},J=e.computed((()=>c.type===C.TIME||c.type===C.DATETIME_LOCAL||c.type===C.DATE||c.type===C.WEEK||c.type===C.MONTH)),G=e.computed((()=>c.type===C.NUMBER)),Q=()=>{ie.value&&(f.value.stepUp(),$.value=e.unref(f).value)},Y=()=>{ie.value&&(f.value.stepDown(),$.value=e.unref(f).value)},Z=e.computed((()=>c.type===C.SEARCH)),ee=()=>{$.value=void 0},{hasIcon:te,hasIconBefore:oe,hasIconAfter:le}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.before))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.after))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:a,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:l,hasIconAfter:n}}(g,S),ne=e.computed((()=>{switch(c.type){case C.COLOR:return{name:_};case C.DATE:case C.DATETIME_LOCAL:case C.WEEK:case C.MONTH:return{name:I};case C.TIME:return{name:V};default:return""}})),{formatted:ae}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),n=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),a=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===n.value)return;return n}return l.value}));return{length:l,gap:n,formatted:a}}($,{mode:c.count,upperLimit:Number(c.maxlength),lowerLimit:Number(c.minlength)}),ie=e.computed((()=>!c.disabled&&!c.readonly)),re=e.computed((()=>ie.value?c.tabindex:-1)),ue=e.computed((()=>!a(w))),se=e.computed((()=>!0===L.value||!0!==B.value&&void 0)),{modifiers:de}=e.toRefs(c),ce=p("vv-input-text",de,e.computed((()=>({valid:B.value,invalid:L.value,loading:E.value,disabled:c.disabled,readonly:c.readonly,"icon-before":oe.value,"icon-after":le.value||!a(ne),floating:c.floating&&!a(c.label),dirty:ue.value,focus:O.value,"auto-width":c.autoWidth})))),pe=e.computed((()=>{const e=N.value&&D.value?C.TEXT:!J.value||ue.value||A.value?c.type:C.TEXT,t={type:e,name:c.name,tabindex:re.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":se.value,"aria-describedby":fe.value?P.value:void 0,"aria-errormessage":he.value?P.value:void 0};return e!==C.DATE&&e!==C.MONTH&&e!==C.WEEK&&e!==C.TIME&&e!==C.DATETIME_LOCAL&&e!==C.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==C.TEXT&&e!==C.SEARCH&&e!==C.URL&&e!==C.TEL&&e!==C.EMAIL&&e!==C.PASSWORD&&e!==C.NUMBER||(t.placeholder=T.value),e!==C.TEXT&&e!==C.SEARCH&&e!==C.URL&&e!==C.TEL&&e!==C.EMAIL&&e!==C.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===C.EMAIL&&(t.multiple=c.multiple),t})),ve=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:K,stepUp:Q,stepDown:Y,clear:ee}))),{HintSlot:me,hasHintLabelOrSlot:fe,hasInvalidLabelOrSlot:he,hintSlotScope:be}=function(t,o){const l=e.computed((()=>i(t.invalidLabel))),n=e.computed((()=>i(t.validLabel))),a=e.computed((()=>t.loadingLabel)),r=e.computed((()=>t.hintLabel)),u=e.computed((()=>Boolean(t.loading&&(o.loading||a.value)))),s=e.computed((()=>!u.value&&Boolean(t.invalid&&(o.invalid||l.value)))),d=e.computed((()=>!u.value&&!s.value&&Boolean(t.valid&&(o.valid||n.value)))),c=e.computed((()=>!u.value&&!s.value&&!d.value&&Boolean(o.hint||r.value))),p=e.computed((()=>s.value||d.value||u.value||c.value)),v=e.computed((()=>({modelValue:t.modelValue,valid:t.valid,invalid:t.invalid,loading:t.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:p,invalidLabel:l,validLabel:n,loadingLabel:a,hintLabel:r,hasInvalidLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:c}),render(){var t,o,l,n,a,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(n=(l=this.$slots).invalid)?void 0:n.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:s,hasHintLabelOrSlot:c,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:u,hintSlotScope:v,HintSlot:m}}(c,m),ge=H(C.PASSWORD,c),Se=H(C.NUMBER,c),ye=H(C.SEARCH,c),we=e.ref();e.watch([()=>c.mask,()=>c.type,()=>c.maskEager,()=>c.maskReversed,()=>c.maskTokens,()=>c.maskTokensReplace],(([e,o,l,n,a,i])=>{we.value=e&&o===C.TEXT?new t.Mask({mask:e,eager:l,reversed:n,tokens:a,tokensReplace:i}):void 0}),{immediate:!0});const ke=()=>{ie.value&&(A.value=!0)},Be=e.computed((()=>{if(c.autoWidth)return{width:void 0!==$.value?`${String($.value).length+1}ch`:void 0}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(ce))},[e.unref(y)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(x),class:"vv-input-text__label"},e.toDisplayString(e.unref(y)),9,M)):e.createCommentVNode("",!0),e.createElementVNode("div",U,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",W,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(ve))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:h,class:"vv-input-text__inner",onClick:e.withModifiers(ke,["stop"])},[e.unref(oe)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(te)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({id:e.unref(x),ref_key:"inputEl",ref:f,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef($)?$.value=t:null)},e.unref(pe),{style:e.unref(Be),onKeyup:o[1]||(o[1]=e=>d("keyup",e))}),null,16,z),[[e.vModelDynamic,e.unref($)]]),(t.unit||t.$slots.unit)&&e.unref(ue)?(e.openBlock(),e.createElementBlock("div",j,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(ve))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,q),e.unref(le)||e.unref(ne)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(le)?e.unref(te):e.unref(ne)),null,16)):e.unref(N)&&!t.hideActions&&e.unref(ie)?(e.openBlock(),e.createBlock(e.unref(ge),{key:2,onTogglePassword:K})):e.unref(G)&&!t.hideActions&&e.unref(ie)?(e.openBlock(),e.createBlock(e.unref(Se),{key:3,onStepUp:Q,onStepDown:Y})):e.unref(Z)&&!t.hideActions&&e.unref(ie)?(e.openBlock(),e.createBlock(e.unref(ye),{key:4,onClear:ee})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(ve))))])):e.createCommentVNode("",!0),e.unref(k)?(e.openBlock(),e.createElementBlock("span",X,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(ve))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ae)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(me),{id:e.unref(P),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(be))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(be))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(be))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(be))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("maska"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core")):"function"==typeof define&&define.amd?define(["vue","maska","@iconify/vue","nanoid","@vueuse/core"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvInputText=t(e.vue,e.maska,e.vue$1,e.nanoid,e.core)}(this,(function(e,t,o,l,n){"use strict";function a(t){return null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length;var o}function i(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}const r={color:String,width:{type:[String,Number]},height:{type:[String,Number]},name:{type:String,required:!0},provider:{type:String},prefix:{type:String,default:"normal"},src:String,horizontalFlip:Boolean,verticalFlip:Boolean,flip:String,mode:String,inline:Boolean,rotate:[Number,String],onLoad:Function,svg:String,modifiers:{type:[String,Array]}};var u=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(u||{}),s=(e=>(e.before="before",e.after="after",e))(s||{}),d=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(d||{});const c=Symbol.for("volver");function p(){return e.inject(c)}function v(t,o,l){return e.computed((()=>{const n={[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&&(n[`${t}--${e}`]=!0)})),l&&Object.keys(l.value).forEach((o=>{n[`${t}--${o}`]=e.unref(l.value[o])})),n}))}const m=e.defineComponent({name:"VvIcon",props:r,setup(t){const l=t,n=e.computed((()=>"string"==typeof l.rotate?parseFloat(l.rotate):l.rotate)),a=e.ref(!0),i=p(),{modifiers:r}=e.toRefs(l),u=v("vv-icon",r),s=e.computed((()=>l.provider||(null==i?void 0:i.iconsProvider))),d=e.computed((()=>{const e=l.name??"",t=`@${s.value}:${l.prefix}:${e}`;if(o.iconExists(t))return t;const n=null==i?void 0:i.iconsCollections.find((t=>{const l=`@${s.value}:${t.prefix}:${e}`;return o.iconExists(l)}));return n?`@${s.value}:${n.prefix}:${e}`:e}));function c(e){const t=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==t?void 0:t.innerHTML.trim())||"";t&&n&&o.addIcon(`@${s.value}:${l.prefix}:${l.name}`,{body:n,height:t.viewBox.baseVal.height,width:t.viewBox.baseVal.width})}return i&&l.src&&!o.iconExists(`@${s.value}:${l.prefix}:${l.name}`)&&(a.value=!1,i.fetchIcon(l.src).then((e=>{e&&(c(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),l.svg&&c(l.svg),(t,l)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(o.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:t.inline,width:t.width,height:t.height,horizontalFlip:t.horizontalFlip,verticalFlip:t.verticalFlip,flip:t.flip,rotate:e.unref(n),color:t.color,onLoad:t.onLoad,icon:e.unref(d)}),null,16,["class"])):e.createCommentVNode("",!0)}}),f={valid:Boolean,validLabel:[String,Array]},h={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},S=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},w={modifiers:[String,Array]},k={hintLabel:{type:String,default:""}},B={count:{type:[Boolean,String],default:!1,validator:e=>[!0,!1,"limit","countdown"].includes(e)}},L={debounce:[Number,String]},E={icon:{type:[String,Object]},iconPosition:{type:String,default:s.before,validation:e=>Object.values(s).includes(e)}},x={tabindex:{type:[String,Number],default:0}},P={floating:Boolean},T={id:[String,Number]};u.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const C={...{...T,name:{type:String,required:!0}},...{autofocus:Boolean},...{autocomplete:{type:String,default:"off"}},...x,...g,...y,...f,...h,...k,...b,...w,...B,...L,...E,...P,...S,minlength:[String,Number],maxlength:[String,Number],placeholder:String,required:Boolean};d.button;const A={TEXT:"text",PASSWORD:"password",NUMBER:"number",EMAIL:"email",TEL:"tel",URL:"url",COLOR:"color",SEARCH:"search",DATE:"date",TIME:"time",DATETIME_LOCAL:"datetime-local",MONTH:"month",WEEK:"week"},$="eye-on",I="eye-off",V="calendar",O="time",_="color",N={...C,modelValue:[String,Number],type:{type:String,default:A.TEXT,validator:e=>Object.values(A).includes(e)},min:[Number,Date,String],max:[Number,Date,String],step:{type:[String,Number],default:1},pattern:String,multiple:Boolean,iconShowPassword:{type:String,default:$},iconHidePassword:{type:String,default:I},iconClear:{type:String,default:"close"},labelStepUp:{type:String,default:"Increase value"},labelStepDown:{type:String,default:"Decrease value"},labelShowPassword:{type:String,default:"Show password"},labelHidePassword:{type:String,default:"Hide password"},labelClear:{type:String,default:"Clear"},mask:{type:String,default:void 0},maskEager:{type:Boolean,default:!1},maskReversed:{type:Boolean,default:!1},maskTokens:{type:Object,default:void 0},maskTokensReplace:{type:Boolean,default:!1},autoWidth:{type:Boolean,default:!1},hideActions:{type:Boolean,default:!1},unit:{type:String}},R=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},labelShow:{type:String,default:"Show password"},labelHide:{type:String,default:"Hide password"},iconShow:{type:String,default:$},iconHide:{type:String,default:I}},emits:["toggle-password"],setup(t,{emit:o}){const l=e.ref(!1),n=e.computed((()=>l.value?t.iconHide:t.iconShow));return{active:l,activeIcon:n,onClick:function(e){null==e||e.stopPropagation(),t.disabled||(l.value=!l.value,o("toggle-password",l.value))}}},render(){const t=e.h(m,{name:this.activeIcon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.active?this.labelHide:this.labelShow,type:"button",onClick:this.onClick},t)}}),D=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String},mode:{type:String,validator:e=>["up","down"].includes(e),default:"up"}},emits:["step-up","step-down"],setup(t,{emit:o}){const l=e.computed((()=>"up"===t.mode));return{isUp:l,onClick:e=>{null==e||e.stopPropagation(),t.disabled||o(l.value?"step-up":"step-down")}}},render(){return e.h("button",{class:["vv-input-text__action vv-input-text__action-chevron",this.isUp&&"vv-input-text__action-chevron-up"],disabled:this.disabled,ariaLabel:this.label,type:"button",onClick:this.onClick})}}),H=e.defineComponent({components:{VvIcon:m},props:{disabled:{type:Boolean,default:!1},label:{type:String,default:"Clear"},icon:{type:String,default:"close"}},emits:["clear"],setup:(e,{emit:t})=>({onClick:function(o){null==o||o.stopPropagation(),e.disabled||t("clear")}}),render(){const t=e.h(m,{name:this.icon,class:"vv-input-text__icon"});return e.h("button",{disabled:this.disabled,class:"vv-input-text__action",ariaLabel:this.label,type:"button",onClick:this.onClick},t)}});function M(t,o){return{name:"VvInputTextActions",components:{VvIcon:m,VvInputPasswordAction:R,VvInputStepAction:D,VvInputClearAction:H},setup:()=>({isDisabled:e.computed((()=>o.disabled||o.readonly)),labelStepUp:o.labelStepUp,labelStepDown:o.labelStepDown,labelShowPassword:o.labelShowPassword,labelHidePassword:o.labelHidePassword,labelClear:o.labelClear,iconShowPassword:o.iconShowPassword,iconHidePassword:o.iconHidePassword}),render(){let l=null;switch(t){case A.SEARCH:{const{onClear:t}=this.$attrs;l=[e.h(H,{disabled:this.isDisabled,label:this.labelShowPassword,onClear:t})];break}case A.PASSWORD:{const{onTogglePassword:t}=this.$attrs;l=[e.h(R,{disabled:this.isDisabled,onTogglePassword:t,labelShow:this.labelShowPassword,labelHide:this.labelHidePassword,iconShow:this.iconShowPassword,iconHide:this.iconHidePassword})];break}case A.NUMBER:{const{onStepUp:t,onStepDown:n}=this.$attrs;l=[e.h(D,{mode:"up",disabled:this.isDisabled||void 0!==o.max&&o.modelValue===o.max,label:this.labelStepUp,onStepUp:t,onStepDown:n}),e.h(D,{mode:"down",disabled:this.isDisabled||void 0!==o.min&&o.modelValue===o.min,label:this.labelStepDown,onStepUp:t,onStepDown:n})];break}}return Array.isArray(l)?e.h("div",{class:"vv-input-text__actions-group"},l):l}}}const U=["for"],j={class:"vv-input-text__wrapper"},W={key:0,class:"vv-input-text__input-before"},q=["onClick"],z=["id"],F={key:1,class:"vv-input-text__unit"},X={key:5,class:"vv-input-text__input-after"},K={key:6,class:"vv-input-text__limit"};return e.defineComponent({name:"VvInputText",props:N,emits:["update:modelValue","focus","blur","keyup"],setup(o,{expose:r,emit:d}){const c=o,f=e.useSlots(),h=function(t,o,l){const n=p(),a=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[t]))return n.defaults.value[t]}));return e.computed((()=>{if(void 0===a.value)return l;const e=a.value,t=o,n=l;return Object.keys(t).reduce(((o,l)=>{const a=n[l];if(o[l]=a,l in e){if(Array.isArray(t[l])){const n=t[l];n.length&&n[0]===a&&(o[l]=e[l])}if("function"==typeof t[l]&&(0,t[l])()===a&&(o[l]=e[l]),"object"==typeof t[l]){let n=t[l].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(a)&&(o[l]=e[l]):n===a&&(o[l]=e[l])}}return o}),{})}))}("VvInputText",N,c),b=e.ref(),g=e.ref();r({$inner:g});const{id:S,icon:y,iconPosition:w,label:k,modelValue:B,count:L,valid:E,invalid:x,loading:P}=e.toRefs(c),T=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(S),C=e.computed((()=>`${T.value}-hint`)),$=e.computed((()=>c.floating&&a(c.placeholder)?" ":c.placeholder)),I=function(t,o,l=0,{getter:n=(e=>e),setter:a=(e=>e)}={}){let i;return"string"==typeof l&&(l=parseInt(l)),e.computed({get:()=>n(null==t?void 0:t.value),set:e=>{i&&clearTimeout(i),i=setTimeout((()=>{o("update:modelValue",a(e))}),l)}})}(B,d,c.debounce,{getter:e=>Le.value?Le.value.masked(e??""):e,setter:e=>(Le.value&&(e=Le.value.unmasked(e)),c.type===A.NUMBER?Number(e):e)}),{focused:R}=function(t,o){const{focused:l}=n.useFocus(t);return e.watch(l,(l=>{o(l?"focus":"blur",e.unref(t))})),{focused:l}}(b,d),D=e.computed((()=>R.value&&!c.disabled&&!c.readonly)),H=n.useElementVisibility(b);e.watch(H,(e=>{e&&c.autofocus&&!c.disabled&&!c.readonly&&(R.value=!0)}));const J=e.ref(!1),G=e.computed((()=>c.type===A.PASSWORD)),Q=()=>{J.value=!J.value},Y=e.computed((()=>c.type===A.TIME||c.type===A.DATETIME_LOCAL||c.type===A.DATE||c.type===A.WEEK||c.type===A.MONTH)),Z=e.computed((()=>c.type===A.NUMBER)),ee=()=>{se.value&&(b.value.stepUp(),I.value=e.unref(b).value)},te=()=>{se.value&&(b.value.stepDown(),I.value=e.unref(b).value)},oe=e.computed((()=>c.type===A.SEARCH)),le=()=>{I.value=void 0},{hasIcon:ne,hasIconBefore:ae,hasIconAfter:ie}=function(t,o){const l=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.before))),n=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===s.after))),a=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.left))),i=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.right))),r=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.top))),d=e.computed((()=>Boolean((null==t?void 0:t.value)&&o.value===u.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==t?void 0:t.value)?{name:null==t?void 0:t.value}:null==t?void 0:t.value)),hasIconLeft:a,hasIconRight:i,hasIconTop:r,hasIconBottom:d,hasIconBefore:l,hasIconAfter:n}}(y,w),re=e.computed((()=>{switch(c.type){case A.COLOR:return{name:_};case A.DATE:case A.DATETIME_LOCAL:case A.WEEK:case A.MONTH:return{name:V};case A.TIME:return{name:O};default:return""}})),{formatted:ue}=function(t,o){const l=e.computed((()=>(e.unref(t)??"").length)),n=e.computed((()=>void 0!==(null==o?void 0:o.lowerLimit)&&l.value<(null==o?void 0:o.lowerLimit)?l.value-o.lowerLimit:void 0!==(null==o?void 0:o.upperLimit)&&l.value<(null==o?void 0:o.upperLimit)?o.upperLimit-l.value:0)),a=e.computed((()=>{if(!1===(null==o?void 0:o.mode))return"";if("limit"===(null==o?void 0:o.mode)&&(null==o?void 0:o.upperLimit))return`${l.value} / ${o.lowerLimit?`${o.lowerLimit}-`:""}${o.upperLimit}`;if("countdown"===(null==o?void 0:o.mode)){if(0===n.value)return;return n}return l.value}));return{length:l,gap:n,formatted:a}}(I,{mode:c.count,upperLimit:Number(c.maxlength),lowerLimit:Number(c.minlength)}),se=e.computed((()=>!c.disabled&&!c.readonly)),de=e.computed((()=>se.value?c.tabindex:-1)),ce=e.computed((()=>!a(B))),pe=e.computed((()=>!0===x.value||!0!==E.value&&void 0)),{modifiers:ve}=e.toRefs(c),me=v("vv-input-text",ve,e.computed((()=>({valid:E.value,invalid:x.value,loading:P.value,disabled:c.disabled,readonly:c.readonly,"icon-before":ae.value,"icon-after":ie.value||!a(re),floating:c.floating&&!a(c.label),dirty:ce.value,focus:D.value,"auto-width":c.autoWidth})))),fe=e.computed((()=>{const e=G.value&&J.value?A.TEXT:!Y.value||ce.value||R.value?c.type:A.TEXT,t={type:e,name:c.name,tabindex:de.value,disabled:c.disabled,readonly:c.readonly,required:c.required,autocomplete:c.autocomplete,"aria-invalid":pe.value,"aria-describedby":ge.value?C.value:void 0,"aria-errormessage":Se.value?C.value:void 0};return e!==A.DATE&&e!==A.MONTH&&e!==A.WEEK&&e!==A.TIME&&e!==A.DATETIME_LOCAL&&e!==A.NUMBER||(t.step=c.step,t.max=void 0!==c.max?String(c.max):void 0,t.min=void 0!==c.min?String(c.min):void 0),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD&&e!==A.NUMBER||(t.placeholder=$.value),e!==A.TEXT&&e!==A.SEARCH&&e!==A.URL&&e!==A.TEL&&e!==A.EMAIL&&e!==A.PASSWORD||(t.minlength=c.minlength,t.maxlength=c.maxlength,t.pattern=c.pattern),e===A.EMAIL&&(t.multiple=c.multiple),t})),he=e.computed((()=>({valid:c.valid,invalid:c.invalid,modelValue:c.modelValue,togglePassword:Q,stepUp:ee,stepDown:te,clear:le}))),{HintSlot:be,hasHintLabelOrSlot:ge,hasInvalidLabelOrSlot:Se,hintSlotScope:ye}=function(t,o){const l=e.computed((()=>e.isRef(t)?t.value:t)),n=e.computed((()=>i(l.value.invalidLabel))),a=e.computed((()=>i(l.value.validLabel))),r=e.computed((()=>l.value.loadingLabel)),u=e.computed((()=>l.value.hintLabel)),s=e.computed((()=>Boolean(l.value.loading&&(o.loading||r.value)))),d=e.computed((()=>!s.value&&Boolean(l.value.invalid&&(o.invalid||n.value)))),c=e.computed((()=>!s.value&&!d.value&&Boolean(l.value.valid&&(o.valid||a.value)))),p=e.computed((()=>!s.value&&!d.value&&!c.value&&Boolean(o.hint||u.value))),v=e.computed((()=>d.value||c.value||s.value||p.value)),m=e.computed((()=>({modelValue:l.value.modelValue,valid:l.value.valid,invalid:l.value.invalid,loading:l.value.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:n,validLabel:a,loadingLabel:r,hintLabel:u,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hasHintLabelOrSlot:p}),render(){var t,o,l,n,a,i,r,u;if(this.isVisible){let s;return this.hasInvalidLabelOrSlot&&(s="alert"),this.hasValidLabelOrSlot&&(s="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:s},(null==(o=(t=this.$slots).loading)?void 0:o.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:s},(null==(n=(l=this.$slots).invalid)?void 0:n.call(l))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:s},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:s},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:p,hasValidLabelOrSlot:c,hasLoadingLabelOrSlot:s,hintSlotScope:m,HintSlot:f}}(h,f),we=M(A.PASSWORD,c),ke=M(A.NUMBER,c),Be=M(A.SEARCH,c),Le=e.ref();e.watch([()=>c.mask,()=>c.type,()=>c.maskEager,()=>c.maskReversed,()=>c.maskTokens,()=>c.maskTokensReplace],(([e,o,l,n,a,i])=>{Le.value=e&&o===A.TEXT?new t.Mask({mask:e,eager:l,reversed:n,tokens:a,tokensReplace:i}):void 0}),{immediate:!0});const Ee=()=>{se.value&&(R.value=!0)},xe=e.computed((()=>{if(c.autoWidth)return{width:void 0!==I.value?`${String(I.value).length+1}ch`:void 0}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(me))},[e.unref(k)?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(T),class:"vv-input-text__label"},e.toDisplayString(e.unref(k)),9,U)):e.createCommentVNode("",!0),e.createElementVNode("div",j,[t.$slots.before?(e.openBlock(),e.createElementBlock("div",W,[e.renderSlot(t.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"innerEl",ref:g,class:"vv-input-text__inner",onClick:e.withModifiers(Ee,["stop"])},[e.unref(ae)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-input-text__icon"},e.unref(ne)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({id:e.unref(T),ref_key:"inputEl",ref:b,"onUpdate:modelValue":o[0]||(o[0]=t=>e.isRef(I)?I.value=t:null)},e.unref(fe),{style:e.unref(xe),onKeyup:o[1]||(o[1]=e=>d("keyup",e))}),null,16,z),[[e.vModelDynamic,e.unref(I)]]),(t.unit||t.$slots.unit)&&e.unref(ce)?(e.openBlock(),e.createElementBlock("div",F,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(t.unit),1)]))])):e.createCommentVNode("",!0)],8,q),e.unref(ie)||e.unref(re)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:1,class:"vv-input-text__icon vv-input-text__icon-after"},e.unref(ie)?e.unref(ne):e.unref(re)),null,16)):e.unref(G)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(we),{key:2,onTogglePassword:Q})):e.unref(Z)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(ke),{key:3,onStepUp:ee,onStepDown:te})):e.unref(oe)&&!t.hideActions&&e.unref(se)?(e.openBlock(),e.createBlock(e.unref(Be),{key:4,onClear:le})):e.createCommentVNode("",!0),t.$slots.after?(e.openBlock(),e.createElementBlock("div",X,[e.renderSlot(t.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(he))))])):e.createCommentVNode("",!0),e.unref(L)?(e.openBlock(),e.createElementBlock("span",K,[e.renderSlot(t.$slots,"count",e.normalizeProps(e.guardReactiveProps(e.unref(he))),(()=>[e.createTextVNode(e.toDisplayString(e.unref(ue)),1)]))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(be),{id:e.unref(C),class:"vv-input-text__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(ye))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|