@volverjs/ui-vue 0.0.9-beta.2 → 0.0.9-beta.21
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 +3 -3
- package/auto-imports.d.ts +2 -0
- package/dist/components/VvAccordion/VvAccordion.es.js +15 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +15 -7
- package/dist/components/VvAction/VvAction.es.js +17 -8
- 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 +22 -13
- 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 +22 -13
- package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +6 -6
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +15 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +15 -7
- package/dist/components/VvBadge/VvBadge.es.js +15 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +15 -7
- package/dist/components/VvButton/VvButton.es.js +19 -9
- 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 +15 -7
- package/dist/components/VvCard/VvCard.es.js +15 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +99 -21
- 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 +105 -22
- 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 +256 -191
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +329 -101
- package/dist/components/VvCombobox/index.d.ts +123 -37
- package/dist/components/VvDialog/VvDialog.es.js +50 -37
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +32 -18
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +300 -92
- package/dist/components/VvDropdown/VvDropdownAction.vue.d.ts +9 -0
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +17 -8
- package/dist/components/VvDropdownAction/VvDropdownAction.umd.js +1 -1
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +15 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +15 -7
- package/dist/components/VvInputText/VvInputText.es.js +279 -116
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +23 -41
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +18 -9
- 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 +15 -7
- package/dist/components/VvRadio/VvRadio.es.js +99 -21
- 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 +105 -22
- 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 +95 -21
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +5 -5
- package/dist/components/VvTab/VvTab.es.js +18 -9
- package/dist/components/VvTab/VvTab.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.es.js +103 -26
- 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 +15 -7
- package/dist/components/common/HintSlot.d.ts +4 -3
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.es.js +1212 -626
- 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 +14 -0
- package/dist/directives/index.es.js +15 -7
- package/dist/directives/v-tooltip.es.js +15 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +107 -31
- package/dist/resolvers/unplugin.es.js +3 -0
- package/dist/resolvers/unplugin.umd.js +1 -1
- package/dist/stories/AccordionGroup/AccordionGroup.stories.d.ts +2 -2
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +54 -269
- 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/InputText/InputText.settings.d.ts +31 -9
- package/dist/stories/InputText/InputText.stories.d.ts +0 -1
- package/dist/stories/InputText/InputTextMask.stories.d.ts +12 -0
- package/dist/stories/Nav/Nav.settings.d.ts +3 -21
- package/package.json +75 -66
- 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 +2 -0
- 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 +43 -23
- package/src/components/VvCombobox/index.ts +24 -0
- package/src/components/VvDialog/VvDialog.vue +22 -19
- package/src/components/VvDropdown/VvDropdown.vue +24 -18
- package/src/components/VvInputText/VvInputText.vue +177 -55
- package/src/components/VvInputText/index.ts +32 -34
- 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 +16 -6
- 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 +26 -0
- package/src/props/index.ts +14 -11
- 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/Combobox/Combobox.test.ts +1 -1
- package/src/stories/InputText/InputText.settings.ts +36 -15
- package/src/stories/InputText/InputText.stories.ts +4 -12
- package/src/stories/InputText/InputText.test.ts +31 -15
- package/src/stories/InputText/InputTextMask.stories.ts +122 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadio=l(e.vue,e.nanoid)}(this,(function(e,l){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const o=Symbol.for("
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","nanoid"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadio=l(e.vue,e.nanoid)}(this,(function(e,l){"use strict";var t=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(t||{}),a=(e=>(e.before="before",e.after="after",e))(a||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const o=Symbol.for("volver"),i=Symbol.for("radioGroup"),r={valid:Boolean,validLabel:[String,Array]},u={invalid:Boolean,invalidLabel:[String,Array]},d={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},s={disabled:Boolean},v=(Boolean,Boolean,{label:[String,Number]}),f={readonly:Boolean},c={modifiers:[String,Array]},p={hintLabel:{type:String,default:""}};a.before;const b={tabindex:{type:[String,Number],default:0}},m={id:[String,Number]};t.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const g={...{...m,name:{type:String,required:!0}},...b,...r,...u,...p,...s,...f,...c,...v,...d,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function h(e,l,t){return t?S(e,t)===S(l,t):y(e,l)}function y(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),a=Array.isArray(l);let n,o,i;if(t&&a){if(o=e.length,o!=l.length)return!1;for(n=o;0!=n--;)if(!y(e[n],l[n]))return!1;return!0}if(t!=a)return!1;const r=e instanceof Date,u=l instanceof Date;if(r!=u)return!1;if(r&&u)return e.getTime()==l.getTime();const d=e instanceof RegExp,s=l instanceof RegExp;if(d!=s)return!1;if(d&&s)return e.toString()==l.toString();const v=Object.keys(e);if(o=v.length,o!==Object.keys(l).length)return!1;for(n=o;0!=n--;)if(!Object.prototype.hasOwnProperty.call(l,v[n]))return!1;for(n=o;0!=n--;)if(i=v[n],!y(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function S(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let a=e;for(let l=0,n=t.length;l<n;++l){if(null==e)return null;a=a[t[l]]}return a}}return null}function L(l){const t=e.inject(l,void 0),a=e.computed((()=>{return l=t,!(null==(a=e.unref(l))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var l,a}));return{group:t,isInGroup:a,getGroupOrLocalRef:function(l,a,n){if(null==t?void 0:t.value){const a=e.unref(t.value)[l];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const o=e.toRef(a,l);return e.computed({get:()=>o.value,set(e){n&&n(`update:${l}`,e)}})}}}n.button;const O=g;function B(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function $(l,t,a){const n=e.inject(o),i=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[l]))return n.defaults.value[l]}));return e.computed((()=>{if(void 0===i.value)return a;const e=i.value,l=t,n=a;return Object.keys(l).reduce(((t,a)=>{const o=n[a];if(t[a]=o,a in e){if(Array.isArray(l[a])){const n=l[a];if(n.length){n[0]===o&&(t[a]=e[a])}}if("function"==typeof l[a]){(0,l[a])()===o&&(t[a]=e[a])}if("object"==typeof l[a]){let n=l[a].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(o)&&(t[a]=e[a]):n===o&&(t[a]=e[a])}}return t}),{})}))}const V=["for"],A=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvRadio",props:O,emits:["click","update:modelValue","change","blur"],setup(t,{emit:a}){const n=t,o=e.useSlots(),r=$("VvRadio",O,n),{id:u,disabled:d,readonly:s,modelValue:v,valid:f,invalid:c}=function(l,t){const{id:a}=e.toRefs(l),{group:n,isInGroup:o,getGroupOrLocalRef:r}=L(i),u=r("modelValue",l,t),d=r("valid",l),s=r("invalid",l),v=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==n?void 0:n.value)?void 0:e.readonly.value))})),f=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==n?void 0:n.value)?void 0:e.disabled.value))}));return{id:a,group:n,isInGroup:o,modelValue:u,valid:d,invalid:s,readonly:v,disabled:f}}(n,a),p=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(u),b=e.computed((()=>`${p.value}-hint`)),m=e.computed((()=>y.value?-1:n.tabindex)),g=e.ref(),y=e.computed((()=>d.value||s.value)),S=e.computed((()=>!0===c.value||!0!==f.value&&void 0)),j=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(h(e,t))return!0;return!1}(n.value,v.value):h(n.value,v.value))),R=e.computed((()=>!["string","number","boolean"].includes(typeof n.value)||n.value)),k=e.computed({get:()=>j.value?R.value:null,set(e){Array.isArray(v.value)?v.value=[n.value]:v.value=n.value,a("change",e)}}),{modifiers:x}=e.toRefs(n),N=function(l,t,a){return e.computed((()=>{const n={[l]:!0},o="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return o&&Array.isArray(o)&&o.forEach((e=>{e&&(n[`${l}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((t=>{n[`${l}--${t}`]=e.unref(a.value[t])})),n}))}("vv-radio",x,e.computed((()=>({valid:f.value,invalid:c.value,disabled:d.value,readonly:s.value})))),{HintSlot:P,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:C,hintSlotScope:w}=function(l,t){const a=e.computed((()=>e.isRef(l)?l.value:l)),n=e.computed((()=>B(a.value.invalidLabel))),o=e.computed((()=>B(a.value.validLabel))),i=e.computed((()=>a.value.loadingLabel)),r=e.computed((()=>a.value.hintLabel)),u=e.computed((()=>Boolean(a.value.loading&&(t.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(a.value.invalid&&(t.invalid||n.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(a.value.valid&&(t.valid||o.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(t.hint||r.value))),f=e.computed((()=>d.value||s.value||u.value||v.value)),c=e.computed((()=>({modelValue:a.value.modelValue,valid:a.value.valid,invalid:a.value.invalid,loading:a.value.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,invalidLabel:n,validLabel:o,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var l,t,a,n,o,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(t=(l=this.$slots).loading)?void 0:t.call(l))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(n=(a=this.$slots).invalid)?void 0:n.call(a))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(o=this.$slots).valid)?void 0:i.call(o))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:c,HintSlot:p}}(r,o);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(N)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:g,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(k)?k.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(y),value:e.unref(R),tabindex:e.unref(m),"aria-invalid":e.unref(S),"aria-describedby":e.unref(I)?e.unref(b):void 0,"aria-errormessage":e.unref(C)?e.unref(b):void 0},null,8,A),[[e.vModelRadio,e.unref(k)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(P),{id:e.unref(b),class:"vv-radio__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"3"}:void 0]),1032,["id"])],10,V))}})}));
|
|
@@ -72,25 +72,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
72
72
|
value: any;
|
|
73
73
|
}): any;
|
|
74
74
|
hint?(_: {
|
|
75
|
-
modelValue:
|
|
75
|
+
modelValue: unknown;
|
|
76
76
|
valid: boolean;
|
|
77
77
|
invalid: boolean;
|
|
78
78
|
loading: boolean;
|
|
79
79
|
}): any;
|
|
80
80
|
loading?(_: {
|
|
81
|
-
modelValue:
|
|
81
|
+
modelValue: unknown;
|
|
82
82
|
valid: boolean;
|
|
83
83
|
invalid: boolean;
|
|
84
84
|
loading: boolean;
|
|
85
85
|
}): any;
|
|
86
86
|
valid?(_: {
|
|
87
|
-
modelValue:
|
|
87
|
+
modelValue: unknown;
|
|
88
88
|
valid: boolean;
|
|
89
89
|
invalid: boolean;
|
|
90
90
|
loading: boolean;
|
|
91
91
|
}): any;
|
|
92
92
|
invalid?(_: {
|
|
93
|
-
modelValue:
|
|
93
|
+
modelValue: unknown;
|
|
94
94
|
valid: boolean;
|
|
95
95
|
invalid: boolean;
|
|
96
96
|
loading: boolean;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode,
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, toRef, toRefs, useSlots, ref, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelRadio, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps, provide, createCommentVNode, Fragment, renderList, createBlock, mergeProps } from "vue";
|
|
2
2
|
import { nanoid } from "nanoid";
|
|
3
3
|
import { useVModel } from "@vueuse/core";
|
|
4
4
|
import { get } from "ts-dot-prop";
|
|
5
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
6
|
+
Strategy2["absolute"] = "absolute";
|
|
7
|
+
Strategy2["fixed"] = "fixed";
|
|
8
|
+
return Strategy2;
|
|
9
|
+
})(Strategy || {});
|
|
5
10
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
6
11
|
Side2["left"] = "left";
|
|
7
12
|
Side2["right"] = "right";
|
|
@@ -38,6 +43,7 @@ var AnchorTarget = /* @__PURE__ */ ((AnchorTarget2) => {
|
|
|
38
43
|
AnchorTarget2["_top"] = "_top";
|
|
39
44
|
return AnchorTarget2;
|
|
40
45
|
})(AnchorTarget || {});
|
|
46
|
+
const INJECTION_KEY_VOLVER = Symbol.for("volver");
|
|
41
47
|
const INJECTION_KEY_RADIO_GROUP = Symbol.for("radioGroup");
|
|
42
48
|
function equals(obj1, obj2, field) {
|
|
43
49
|
if (field)
|
|
@@ -130,19 +136,27 @@ function joinLines(items) {
|
|
|
130
136
|
}
|
|
131
137
|
return items;
|
|
132
138
|
}
|
|
133
|
-
function HintSlotFactory(
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
140
|
+
const props = computed(() => {
|
|
141
|
+
if (isRef(propsOrRef)) {
|
|
142
|
+
return propsOrRef.value;
|
|
143
|
+
}
|
|
144
|
+
return propsOrRef;
|
|
145
|
+
});
|
|
146
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
147
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
148
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
149
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
138
150
|
const hasLoadingLabelOrSlot = computed(
|
|
139
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
151
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
140
152
|
);
|
|
141
153
|
const hasInvalidLabelOrSlot = computed(
|
|
142
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
154
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
155
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
156
|
+
)
|
|
143
157
|
);
|
|
144
158
|
const hasValidLabelOrSlot = computed(
|
|
145
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
159
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
146
160
|
);
|
|
147
161
|
const hasHintLabelOrSlot = computed(
|
|
148
162
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -151,10 +165,10 @@ function HintSlotFactory(props, slots) {
|
|
|
151
165
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
152
166
|
);
|
|
153
167
|
const hintSlotScope = computed(() => ({
|
|
154
|
-
modelValue: props.modelValue,
|
|
155
|
-
valid: props.valid,
|
|
156
|
-
invalid: props.invalid,
|
|
157
|
-
loading: props.loading
|
|
168
|
+
modelValue: props.value.modelValue,
|
|
169
|
+
valid: props.value.valid,
|
|
170
|
+
invalid: props.value.invalid,
|
|
171
|
+
loading: props.value.loading
|
|
158
172
|
}));
|
|
159
173
|
const HintSlot = defineComponent({
|
|
160
174
|
name: "HintSlot",
|
|
@@ -390,19 +404,15 @@ const IdProps = {
|
|
|
390
404
|
placement: {
|
|
391
405
|
type: String,
|
|
392
406
|
default: Side.bottom,
|
|
393
|
-
validator: (value) =>
|
|
394
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
395
|
-
}
|
|
407
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
396
408
|
},
|
|
397
409
|
/**
|
|
398
410
|
* Dropdown strategy
|
|
399
411
|
*/
|
|
400
412
|
strategy: {
|
|
401
413
|
type: String,
|
|
402
|
-
default:
|
|
403
|
-
validator: (value) =>
|
|
404
|
-
return ["fixed", "absolute"].includes(value);
|
|
405
|
-
}
|
|
414
|
+
default: void 0,
|
|
415
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
406
416
|
},
|
|
407
417
|
/**
|
|
408
418
|
* Dropdown show / hide transition name
|
|
@@ -545,6 +555,13 @@ const CheckboxRadioGroupProps = {
|
|
|
545
555
|
type: String,
|
|
546
556
|
default: ButtonType.button,
|
|
547
557
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
558
|
+
},
|
|
559
|
+
/**
|
|
560
|
+
* Button aria-label
|
|
561
|
+
*/
|
|
562
|
+
ariaLabel: {
|
|
563
|
+
type: String,
|
|
564
|
+
default: void 0
|
|
548
565
|
}
|
|
549
566
|
});
|
|
550
567
|
function useInjectedGroupState(groupKey) {
|
|
@@ -612,6 +629,62 @@ function useGroupProps(props, emit) {
|
|
|
612
629
|
disabled
|
|
613
630
|
};
|
|
614
631
|
}
|
|
632
|
+
function useVolver() {
|
|
633
|
+
return inject(INJECTION_KEY_VOLVER);
|
|
634
|
+
}
|
|
635
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
636
|
+
const volver = useVolver();
|
|
637
|
+
const volverComponentDefaults = computed(() => {
|
|
638
|
+
var _a;
|
|
639
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
640
|
+
return void 0;
|
|
641
|
+
}
|
|
642
|
+
return volver.defaults.value[componentName];
|
|
643
|
+
});
|
|
644
|
+
return computed(() => {
|
|
645
|
+
if (volverComponentDefaults.value === void 0) {
|
|
646
|
+
return props;
|
|
647
|
+
}
|
|
648
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
649
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
650
|
+
const simplifiedProps = props;
|
|
651
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
652
|
+
const propValue = simplifiedProps[key];
|
|
653
|
+
acc[key] = propValue;
|
|
654
|
+
if (key in componentDefaults) {
|
|
655
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
656
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
657
|
+
if (typeArray.length) {
|
|
658
|
+
const typeFunction = typeArray[0];
|
|
659
|
+
if (typeFunction === propValue) {
|
|
660
|
+
acc[key] = componentDefaults[key];
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
665
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
666
|
+
if (typeFunction() === propValue) {
|
|
667
|
+
acc[key] = componentDefaults[key];
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
671
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
672
|
+
if (typeof defaultValue === "function") {
|
|
673
|
+
defaultValue = defaultValue();
|
|
674
|
+
}
|
|
675
|
+
if (typeof defaultValue === "object") {
|
|
676
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
677
|
+
acc[key] = componentDefaults[key];
|
|
678
|
+
}
|
|
679
|
+
} else if (defaultValue === propValue) {
|
|
680
|
+
acc[key] = componentDefaults[key];
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
return acc;
|
|
685
|
+
}, {});
|
|
686
|
+
});
|
|
687
|
+
}
|
|
615
688
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
616
689
|
function useModifiers(prefix, modifiers, others) {
|
|
617
690
|
return computed(() => {
|
|
@@ -648,6 +721,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
648
721
|
setup(__props, { emit }) {
|
|
649
722
|
const props = __props;
|
|
650
723
|
const slots = useSlots();
|
|
724
|
+
const propsDefaults = useDefaults(
|
|
725
|
+
"VvRadio",
|
|
726
|
+
VvRadioProps,
|
|
727
|
+
props
|
|
728
|
+
);
|
|
651
729
|
const { id, disabled, readonly, modelValue, valid, invalid } = useGroupProps(props, emit);
|
|
652
730
|
const hasId = useUniqueId(id);
|
|
653
731
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
@@ -698,7 +776,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
698
776
|
hasHintLabelOrSlot,
|
|
699
777
|
hasInvalidLabelOrSlot,
|
|
700
778
|
hintSlotScope
|
|
701
|
-
} = HintSlotFactory(
|
|
779
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
702
780
|
return (_ctx, _cache) => {
|
|
703
781
|
return openBlock(), createElementBlock("label", {
|
|
704
782
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -817,6 +895,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
817
895
|
setup(__props, { emit }) {
|
|
818
896
|
const props = __props;
|
|
819
897
|
const slots = useSlots();
|
|
898
|
+
const propsDefaults = useDefaults(
|
|
899
|
+
"VvRadioGroup",
|
|
900
|
+
VvRadioGroupProps,
|
|
901
|
+
props
|
|
902
|
+
);
|
|
820
903
|
const modelValue = useVModel(props, "modelValue", emit);
|
|
821
904
|
const { disabled, readonly, vertical, valid, invalid, modifiers } = toRefs(props);
|
|
822
905
|
useProvideGroupState({
|
|
@@ -847,7 +930,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
847
930
|
value: getOptionValue(option)
|
|
848
931
|
};
|
|
849
932
|
};
|
|
850
|
-
const { HintSlot, hintSlotScope } = HintSlotFactory(
|
|
933
|
+
const { HintSlot, hintSlotScope } = HintSlotFactory(propsDefaults, slots);
|
|
851
934
|
return (_ctx, _cache) => {
|
|
852
935
|
return openBlock(), createElementBlock("fieldset", {
|
|
853
936
|
class: normalizeClass(unref(bemCssClasses))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core","ts-dot-prop"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadioGroup=l(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,l,t,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const r=Symbol.for("radioGroup");function u(e,l,t){return t?s(e,t)===s(l,t):d(e,l)}function d(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const t=Array.isArray(e),o=Array.isArray(l);let a,n,i;if(t&&o){if(n=e.length,n!=l.length)return!1;for(a=n;0!=a--;)if(!d(e[a],l[a]))return!1;return!0}if(t!=o)return!1;const r=e instanceof Date,u=l instanceof Date;if(r!=u)return!1;if(r&&u)return e.getTime()==l.getTime();const s=e instanceof RegExp,v=l instanceof RegExp;if(s!=v)return!1;if(s&&v)return e.toString()==l.toString();const c=Object.keys(e);if(n=c.length,n!==Object.keys(l).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(l,c[a]))return!1;for(a=n;0!=a--;)if(i=c[a],!d(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function s(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const t=l.split(".");let o=e;for(let l=0,a=t.length;l<a;++l){if(null==e)return null;o=o[t[l]]}return o}}return null}function v(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}function c(l,t){const o=e.computed((()=>v(l.invalidLabel))),a=e.computed((()=>v(l.validLabel))),n=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(t.loading||n.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(t.invalid||o.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(t.valid||a.value)))),s=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(t.hint||i.value))),c=e.computed((()=>u.value||d.value||r.value||s.value)),f=e.computed((()=>({modelValue:l.modelValue,valid:l.valid,invalid:l.invalid,loading:l.loading}))),p=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:o,validLabel:a,loadingLabel:n,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),render(){var l,t,o,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(t=(l=this.$slots).loading)?void 0:t.call(l))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:u,hasHintLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:f,HintSlot:p}}const f={valid:Boolean,validLabel:[String,Array]},p={invalid:Boolean,invalidLabel:[String,Array]},m={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},b={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},h={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},L={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};n.before;const B={tabindex:{type:[String,Number],default:0}},O={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const k={...{...O,name:{type:String,required:!0}},...B,...f,...p,...S,...b,...y,...h,...g,...m,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},$={...f,...p,...L,...S,...b,...y,...h,...g,...m,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function V(l){const t=e.inject(l,void 0),o=e.computed((()=>{return l=t,!(null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var l,o}));return{group:t,isInGroup:o,getGroupOrLocalRef:function(l,o,a){if(null==t?void 0:t.value){const o=e.unref(t.value)[l];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,l);return e.computed({get:()=>n.value,set(e){a&&a(`update:${l}`,e)}})}}}i.button;const R=k;function x(l,t,o){return e.computed((()=>{const a={[l]:!0},n="string"==typeof(null==t?void 0:t.value)?t.value.split(" "):null==t?void 0:t.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${l}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((t=>{a[`${l}--${t}`]=e.unref(o.value[t])})),a}))}const A=["for"],P=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],j=e.defineComponent({name:"VvRadio",props:R,emits:["click","update:modelValue","change","blur"],setup(t,{emit:o}){const a=t,n=e.useSlots(),{id:i,disabled:d,readonly:s,modelValue:v,valid:f,invalid:p}=function(l,t){const{id:o}=e.toRefs(l),{group:a,isInGroup:n,getGroupOrLocalRef:i}=V(r),u=i("modelValue",l,t),d=i("valid",l),s=i("invalid",l),v=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),c=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:o,group:a,isInGroup:n,modelValue:u,valid:d,invalid:s,readonly:v,disabled:c}}(a,o),m=(t=>e.computed((()=>String((null==t?void 0:t.value)||l.nanoid()))))(i),b=e.computed((()=>`${m.value}-hint`)),g=e.computed((()=>h.value?-1:a.tabindex)),y=e.ref(),h=e.computed((()=>d.value||s.value)),S=e.computed((()=>!0===p.value||!0!==f.value&&void 0)),L=e.computed((()=>Array.isArray(v.value)?function(e,l){if(null!=e&&l&&l.length)for(const t of l)if(u(e,t))return!0;return!1}(a.value,v.value):u(a.value,v.value))),B=e.computed((()=>!["string","number","boolean"].includes(typeof a.value)||a.value)),O=e.computed({get:()=>L.value?B.value:null,set(e){Array.isArray(v.value)?v.value=[a.value]:v.value=a.value,o("change",e)}}),{modifiers:k}=e.toRefs(a),$=x("vv-radio",k,e.computed((()=>({valid:f.value,invalid:p.value,disabled:d.value,readonly:s.value})))),{HintSlot:R,hasHintLabelOrSlot:j,hasInvalidLabelOrSlot:C,hintSlotScope:w}=c(a,n);return(l,t)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref($)),for:e.unref(m)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(m),ref_key:"input",ref:y,"onUpdate:modelValue":t[0]||(t[0]=l=>e.isRef(O)?O.value=l:null),type:"radio",class:"vv-radio__input",name:l.name,disabled:e.unref(h),value:e.unref(B),tabindex:e.unref(g),"aria-invalid":e.unref(S),"aria-describedby":e.unref(j)?e.unref(b):void 0,"aria-errormessage":e.unref(C)?e.unref(b):void 0},null,8,P),[[e.vModelRadio,e.unref(O)]]),e.renderSlot(l.$slots,"default",{value:e.unref(v)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(R),{id:e.unref(b),class:"vv-radio__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(w))))])),key:"3"}:void 0]),1032,["id"])],10,A))}}),C=$;const w=["textContent"],N={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:C,emits:["update:modelValue","change"],setup(l,{emit:a}){const n=l,i=e.useSlots(),u=t.useVModel(n,"modelValue",a),{disabled:d,readonly:s,vertical:v,valid:f,invalid:p,modifiers:m}=e.toRefs(n);!function(l){if(Object.keys(l).some((t=>"key"!==t&&!e.isRef(l[t]))))throw Error("One or more groupState props aren't ref.");e.provide(l.key,e.computed((()=>l)))}({key:r,modelValue:u,disabled:d,readonly:s,valid:f,invalid:p});const{getOptionLabel:b,getOptionValue:g}=function(l){const{options:t,labelKey:a,valueKey:n,disabledKey:i}=e.toRefs(l);return{options:t,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):o.get(e,a.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):o.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):o.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),y=x("vv-radio-group",m,e.computed((()=>({disabled:d.value,readonly:s.value,horizontal:!v.value,valid:f.value,invalid:p.value})))),{HintSlot:h,hintSlotScope:S}=c(n,i);return(l,t)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[l.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(l.label)},null,8,w)):e.createCommentVNode("",!0),e.createElementVNode("div",N,[l.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(l.options,((l,t)=>(e.openBlock(),e.createBlock(j,e.mergeProps({key:t},((e,l)=>({id:`${n.name}_opt${l}`,name:n.name,label:b(e),value:g(e)}))(l,t)),null,16)))),128)):e.renderSlot(l.$slots,"default",{key:1})]),e.createVNode(e.unref(h),{class:"vv-radio-group__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(S))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","nanoid","@vueuse/core","ts-dot-prop"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvRadioGroup=t(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,t,l,o){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),n=(e=>(e.before="before",e.after="after",e))(n||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{});const r=Symbol.for("volver"),u=Symbol.for("radioGroup");function d(e,t,l){return l?v(e,l)===v(t,l):s(e,t)}function s(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const l=Array.isArray(e),o=Array.isArray(t);let a,n,i;if(l&&o){if(n=e.length,n!=t.length)return!1;for(a=n;0!=a--;)if(!s(e[a],t[a]))return!1;return!0}if(l!=o)return!1;const r=e instanceof Date,u=t instanceof Date;if(r!=u)return!1;if(r&&u)return e.getTime()==t.getTime();const d=e instanceof RegExp,v=t instanceof RegExp;if(d!=v)return!1;if(d&&v)return e.toString()==t.toString();const f=Object.keys(e);if(n=f.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,f[a]))return!1;for(a=n;0!=a--;)if(i=f[a],!s(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function v(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const l=t.split(".");let o=e;for(let t=0,a=l.length;t<a;++t){if(null==e)return null;o=o[l[t]]}return o}}return null}function f(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function c(t,l){const o=e.computed((()=>e.isRef(t)?t.value:t)),a=e.computed((()=>f(o.value.invalidLabel))),n=e.computed((()=>f(o.value.validLabel))),i=e.computed((()=>o.value.loadingLabel)),r=e.computed((()=>o.value.hintLabel)),u=e.computed((()=>Boolean(o.value.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(o.value.invalid&&(l.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),c=e.computed((()=>d.value||s.value||u.value||v.value)),p=e.computed((()=>({modelValue:o.value.modelValue,valid:o.value.valid,invalid:o.value.invalid,loading:o.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:a,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,o,a,n,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(l=(t=this.$slots).loading)?void 0:l.call(t))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(a=(o=this.$slots).invalid)?void 0:a.call(o))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(n=this.$slots).valid)?void 0:i.call(n))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:v,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:p,HintSlot:m}}const p={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},y=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},S={modifiers:[String,Array]},L={hintLabel:{type:String,default:""}},O={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}};n.before;const B={tabindex:{type:[String,Number],default:0}},k={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...k,name:{type:String,required:!0}},...B,...p,...m,...L,...g,...h,...S,...y,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},$={...p,...m,...O,...L,...g,...h,...S,...y,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function R(t){const l=e.inject(t,void 0),o=e.computed((()=>{return t=l,!(null==(o=e.unref(t))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var t,o}));return{group:l,isInGroup:o,getGroupOrLocalRef:function(t,o,a){if(null==l?void 0:l.value){const o=e.unref(l.value)[t];return e.computed({get:()=>null==o?void 0:o.value,set(e){o.value=e}})}const n=e.toRef(o,t);return e.computed({get:()=>n.value,set(e){a&&a(`update:${t}`,e)}})}}}i.button;const j=V;function A(t,l,o){const a=e.inject(r),n=e.computed((()=>{var e;if(a&&(null==(e=a.defaults.value)?void 0:e[t]))return a.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return o;const e=n.value,t=l,a=o;return Object.keys(t).reduce(((l,o)=>{const n=a[o];if(l[o]=n,o in e){if(Array.isArray(t[o])){const a=t[o];if(a.length){a[0]===n&&(l[o]=e[o])}}if("function"==typeof t[o]){(0,t[o])()===n&&(l[o]=e[o])}if("object"==typeof t[o]){let a=t[o].default;"function"==typeof a&&(a=a()),"object"==typeof a?JSON.stringify(a)===JSON.stringify(n)&&(l[o]=e[o]):a===n&&(l[o]=e[o])}}return l}),{})}))}function x(t,l,o){return e.computed((()=>{const a={[t]:!0},n="string"==typeof(null==l?void 0:l.value)?l.value.split(" "):null==l?void 0:l.value;return n&&Array.isArray(n)&&n.forEach((e=>{e&&(a[`${t}--${e}`]=!0)})),o&&Object.keys(o.value).forEach((l=>{a[`${t}--${l}`]=e.unref(o.value[l])})),a}))}const P=["for"],C=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],N=e.defineComponent({name:"VvRadio",props:j,emits:["click","update:modelValue","change","blur"],setup(l,{emit:o}){const a=l,n=e.useSlots(),i=A("VvRadio",j,a),{id:r,disabled:s,readonly:v,modelValue:f,valid:p,invalid:m}=function(t,l){const{id:o}=e.toRefs(t),{group:a,isInGroup:n,getGroupOrLocalRef:i}=R(u),r=i("modelValue",t,l),d=i("valid",t),s=i("invalid",t),v=e.computed((()=>{var e;return Boolean(t.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),f=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:o,group:a,isInGroup:n,modelValue:r,valid:d,invalid:s,readonly:v,disabled:f}}(a,o),b=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(r),g=e.computed((()=>`${b.value}-hint`)),y=e.computed((()=>S.value?-1:a.tabindex)),h=e.ref(),S=e.computed((()=>s.value||v.value)),L=e.computed((()=>!0===m.value||!0!==p.value&&void 0)),O=e.computed((()=>Array.isArray(f.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(d(e,l))return!0;return!1}(a.value,f.value):d(a.value,f.value))),B=e.computed((()=>!["string","number","boolean"].includes(typeof a.value)||a.value)),k=e.computed({get:()=>O.value?B.value:null,set(e){Array.isArray(f.value)?f.value=[a.value]:f.value=a.value,o("change",e)}}),{modifiers:V}=e.toRefs(a),$=x("vv-radio",V,e.computed((()=>({valid:p.value,invalid:m.value,disabled:s.value,readonly:v.value})))),{HintSlot:N,hasHintLabelOrSlot:w,hasInvalidLabelOrSlot:_,hintSlotScope:z}=c(i,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref($)),for:e.unref(b)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(b),ref_key:"input",ref:h,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(k)?k.value=t:null),type:"radio",class:"vv-radio__input",name:t.name,disabled:e.unref(S),value:e.unref(B),tabindex:e.unref(y),"aria-invalid":e.unref(L),"aria-describedby":e.unref(w)?e.unref(g):void 0,"aria-errormessage":e.unref(_)?e.unref(g):void 0},null,8,C),[[e.vModelRadio,e.unref(k)]]),e.renderSlot(t.$slots,"default",{value:e.unref(f)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(N),{id:e.unref(g),class:"vv-radio__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(z))))])),key:"3"}:void 0]),1032,["id"])],10,P))}}),w=$;const _=["textContent"],z={class:"vv-radio-group__wrapper"};return e.defineComponent({name:"VvRadioGroup",props:w,emits:["update:modelValue","change"],setup(t,{emit:a}){const n=t,i=e.useSlots(),r=A("VvRadioGroup",w,n),d=l.useVModel(n,"modelValue",a),{disabled:s,readonly:v,vertical:f,valid:p,invalid:m,modifiers:b}=e.toRefs(n);!function(t){if(Object.keys(t).some((l=>"key"!==l&&!e.isRef(t[l]))))throw Error("One or more groupState props aren't ref.");e.provide(t.key,e.computed((()=>t)))}({key:u,modelValue:d,disabled:s,readonly:v,valid:p,invalid:m});const{getOptionLabel:g,getOptionValue:y}=function(t){const{options:l,labelKey:a,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof a.value?a.value(e):o.get(e,a.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):o.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):o.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),h=x("vv-radio-group",b,e.computed((()=>({disabled:s.value,readonly:v.value,horizontal:!f.value,valid:p.value,invalid:m.value})))),{HintSlot:S,hintSlotScope:L}=c(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(h))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,_)):e.createCommentVNode("",!0),e.createElementVNode("div",z,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(N,e.mergeProps({key:l},((e,t)=>({id:`${n.name}_opt${t}`,name:n.name,label:g(e),value:y(e)}))(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(S),{class:"vv-radio-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(L))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
@@ -97,25 +97,25 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
97
97
|
}, {}>, {
|
|
98
98
|
default?(_: {}): any;
|
|
99
99
|
hint?(_: {
|
|
100
|
-
modelValue:
|
|
100
|
+
modelValue: unknown;
|
|
101
101
|
valid: boolean;
|
|
102
102
|
invalid: boolean;
|
|
103
103
|
loading: boolean;
|
|
104
104
|
}): any;
|
|
105
105
|
loading?(_: {
|
|
106
|
-
modelValue:
|
|
106
|
+
modelValue: unknown;
|
|
107
107
|
valid: boolean;
|
|
108
108
|
invalid: boolean;
|
|
109
109
|
loading: boolean;
|
|
110
110
|
}): any;
|
|
111
111
|
valid?(_: {
|
|
112
|
-
modelValue:
|
|
112
|
+
modelValue: unknown;
|
|
113
113
|
valid: boolean;
|
|
114
114
|
invalid: boolean;
|
|
115
115
|
loading: boolean;
|
|
116
116
|
}): any;
|
|
117
117
|
invalid?(_: {
|
|
118
|
-
modelValue:
|
|
118
|
+
modelValue: unknown;
|
|
119
119
|
valid: boolean;
|
|
120
120
|
invalid: boolean;
|
|
121
121
|
loading: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, h, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withDirectives,
|
|
1
|
+
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, isRef, h, watch, useSlots, createElementBlock, normalizeClass, toDisplayString, createElementVNode, renderSlot, normalizeProps, guardReactiveProps, withDirectives, Fragment, renderList, vModelSelect, createVNode, createSlots, withCtx } from "vue";
|
|
2
2
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
3
3
|
import { nanoid } from "nanoid";
|
|
4
4
|
import { useFocus, useElementVisibility } from "@vueuse/core";
|
|
@@ -97,6 +97,11 @@ const VvIconProps = {
|
|
|
97
97
|
type: [String, Array]
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
101
|
+
Strategy2["absolute"] = "absolute";
|
|
102
|
+
Strategy2["fixed"] = "fixed";
|
|
103
|
+
return Strategy2;
|
|
104
|
+
})(Strategy || {});
|
|
100
105
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
101
106
|
Side2["left"] = "left";
|
|
102
107
|
Side2["right"] = "right";
|
|
@@ -268,19 +273,27 @@ function joinLines(items) {
|
|
|
268
273
|
}
|
|
269
274
|
return items;
|
|
270
275
|
}
|
|
271
|
-
function HintSlotFactory(
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
function HintSlotFactory(propsOrRef, slots) {
|
|
277
|
+
const props = computed(() => {
|
|
278
|
+
if (isRef(propsOrRef)) {
|
|
279
|
+
return propsOrRef.value;
|
|
280
|
+
}
|
|
281
|
+
return propsOrRef;
|
|
282
|
+
});
|
|
283
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
284
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
285
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
286
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
276
287
|
const hasLoadingLabelOrSlot = computed(
|
|
277
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
288
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
278
289
|
);
|
|
279
290
|
const hasInvalidLabelOrSlot = computed(
|
|
280
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
291
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
292
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
293
|
+
)
|
|
281
294
|
);
|
|
282
295
|
const hasValidLabelOrSlot = computed(
|
|
283
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
296
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
284
297
|
);
|
|
285
298
|
const hasHintLabelOrSlot = computed(
|
|
286
299
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -289,10 +302,10 @@ function HintSlotFactory(props, slots) {
|
|
|
289
302
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
290
303
|
);
|
|
291
304
|
const hintSlotScope = computed(() => ({
|
|
292
|
-
modelValue: props.modelValue,
|
|
293
|
-
valid: props.valid,
|
|
294
|
-
invalid: props.invalid,
|
|
295
|
-
loading: props.loading
|
|
305
|
+
modelValue: props.value.modelValue,
|
|
306
|
+
valid: props.value.valid,
|
|
307
|
+
invalid: props.value.invalid,
|
|
308
|
+
loading: props.value.loading
|
|
296
309
|
}));
|
|
297
310
|
const HintSlot = defineComponent({
|
|
298
311
|
name: "HintSlot",
|
|
@@ -540,19 +553,15 @@ const IdProps = {
|
|
|
540
553
|
placement: {
|
|
541
554
|
type: String,
|
|
542
555
|
default: Side.bottom,
|
|
543
|
-
validator: (value) =>
|
|
544
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
545
|
-
}
|
|
556
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
546
557
|
},
|
|
547
558
|
/**
|
|
548
559
|
* Dropdown strategy
|
|
549
560
|
*/
|
|
550
561
|
strategy: {
|
|
551
562
|
type: String,
|
|
552
|
-
default:
|
|
553
|
-
validator: (value) =>
|
|
554
|
-
return ["fixed", "absolute"].includes(value);
|
|
555
|
-
}
|
|
563
|
+
default: void 0,
|
|
564
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
556
565
|
},
|
|
557
566
|
/**
|
|
558
567
|
* Dropdown show / hide transition name
|
|
@@ -665,6 +674,13 @@ const AutocompleteProps = {
|
|
|
665
674
|
type: String,
|
|
666
675
|
default: ButtonType.button,
|
|
667
676
|
validator: (value) => Object.values(ButtonType).includes(value)
|
|
677
|
+
},
|
|
678
|
+
/**
|
|
679
|
+
* Button aria-label
|
|
680
|
+
*/
|
|
681
|
+
ariaLabel: {
|
|
682
|
+
type: String,
|
|
683
|
+
default: void 0
|
|
668
684
|
}
|
|
669
685
|
});
|
|
670
686
|
const VvSelectProps = {
|
|
@@ -716,6 +732,59 @@ const VvSelectProps = {
|
|
|
716
732
|
placeholder: String
|
|
717
733
|
};
|
|
718
734
|
const VvSelectEmits = ["update:modelValue", "focus", "blur"];
|
|
735
|
+
function useDefaults(componentName, propsDefinition, props) {
|
|
736
|
+
const volver = useVolver();
|
|
737
|
+
const volverComponentDefaults = computed(() => {
|
|
738
|
+
var _a;
|
|
739
|
+
if (!volver || !((_a = volver.defaults.value) == null ? void 0 : _a[componentName])) {
|
|
740
|
+
return void 0;
|
|
741
|
+
}
|
|
742
|
+
return volver.defaults.value[componentName];
|
|
743
|
+
});
|
|
744
|
+
return computed(() => {
|
|
745
|
+
if (volverComponentDefaults.value === void 0) {
|
|
746
|
+
return props;
|
|
747
|
+
}
|
|
748
|
+
const componentDefaults = volverComponentDefaults.value;
|
|
749
|
+
const simplifiedPropsDefinition = propsDefinition;
|
|
750
|
+
const simplifiedProps = props;
|
|
751
|
+
return Object.keys(simplifiedPropsDefinition).reduce((acc, key) => {
|
|
752
|
+
const propValue = simplifiedProps[key];
|
|
753
|
+
acc[key] = propValue;
|
|
754
|
+
if (key in componentDefaults) {
|
|
755
|
+
if (Array.isArray(simplifiedPropsDefinition[key])) {
|
|
756
|
+
const typeArray = simplifiedPropsDefinition[key];
|
|
757
|
+
if (typeArray.length) {
|
|
758
|
+
const typeFunction = typeArray[0];
|
|
759
|
+
if (typeFunction === propValue) {
|
|
760
|
+
acc[key] = componentDefaults[key];
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
if (typeof simplifiedPropsDefinition[key] === "function") {
|
|
765
|
+
const typeFunction = simplifiedPropsDefinition[key];
|
|
766
|
+
if (typeFunction() === propValue) {
|
|
767
|
+
acc[key] = componentDefaults[key];
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
if (typeof simplifiedPropsDefinition[key] === "object") {
|
|
771
|
+
let defaultValue = simplifiedPropsDefinition[key].default;
|
|
772
|
+
if (typeof defaultValue === "function") {
|
|
773
|
+
defaultValue = defaultValue();
|
|
774
|
+
}
|
|
775
|
+
if (typeof defaultValue === "object") {
|
|
776
|
+
if (JSON.stringify(defaultValue) === JSON.stringify(propValue)) {
|
|
777
|
+
acc[key] = componentDefaults[key];
|
|
778
|
+
}
|
|
779
|
+
} else if (defaultValue === propValue) {
|
|
780
|
+
acc[key] = componentDefaults[key];
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return acc;
|
|
785
|
+
}, {});
|
|
786
|
+
});
|
|
787
|
+
}
|
|
719
788
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
720
789
|
function useComponentFocus(inputTemplateRef, emit) {
|
|
721
790
|
const { focused } = useFocus(inputTemplateRef);
|
|
@@ -819,13 +888,18 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
819
888
|
setup(__props, { emit }) {
|
|
820
889
|
const props = __props;
|
|
821
890
|
const slots = useSlots();
|
|
891
|
+
const propsDefaults = useDefaults(
|
|
892
|
+
"VvSelect",
|
|
893
|
+
VvSelectProps,
|
|
894
|
+
props
|
|
895
|
+
);
|
|
822
896
|
const select = ref();
|
|
823
897
|
const {
|
|
824
898
|
HintSlot,
|
|
825
899
|
hasHintLabelOrSlot,
|
|
826
900
|
hasInvalidLabelOrSlot,
|
|
827
901
|
hintSlotScope
|
|
828
|
-
} = HintSlotFactory(
|
|
902
|
+
} = HintSlotFactory(propsDefaults, slots);
|
|
829
903
|
const {
|
|
830
904
|
id,
|
|
831
905
|
modifiers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid","@vueuse/core","ts-dot-prop"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvSelect=l(e.vue,e.vue$1,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,l,o,t,n){"use strict";const a={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 i=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(i||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{});const d=Symbol.for("volver");function s(l,o,t){return e.computed((()=>{const n={[l]:!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[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((o=>{n[`${l}--${o}`]=e.unref(t.value[o])})),n}))}const c=e.defineComponent({name:"VvIcon",props:a,setup(o){const t=o,n=e.computed((()=>"string"==typeof t.rotate?parseFloat(t.rotate):t.rotate)),a=e.ref(!0),i=e.inject(d),{modifiers:r}=e.toRefs(t),u=s("vv-icon",r),c=e.computed((()=>t.provider||(null==i?void 0:i.iconsProvider))),v=e.computed((()=>{const e=t.name??"",o=`@${c.value}:${t.prefix}:${e}`;if(l.iconExists(o))return o;const n=null==i?void 0:i.iconsCollections.find((o=>{const t=`@${c.value}:${o.prefix}:${e}`;return l.iconExists(t)}));return n?`@${c.value}:${n.prefix}:${e}`:e}));function p(e){const o=function(e){let l;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==o?void 0:o.innerHTML.trim())||"";o&&n&&l.addIcon(`@${c.value}:${t.prefix}:${t.name}`,{body:n,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return i&&t.src&&!l.iconExists(`@${c.value}:${t.prefix}:${t.name}`)&&(a.value=!1,i.fetchIcon(t.src).then((e=>{e&&(p(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),t.svg&&p(t.svg),(o,t)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:e.unref(n),color:o.color,onLoad:o.onLoad,icon:e.unref(v)}),null,16,["class"])):e.createCommentVNode("",!0)}});function v(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const p={valid:Boolean,validLabel:[String,Array]},f={invalid:Boolean,invalidLabel:[String,Array]},m={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},g={disabled:Boolean},b=(Boolean,Boolean,{label:[String,Number]}),h={readonly:Boolean},y={modifiers:[String,Array]},S={hintLabel:{type:String,default:""}},B={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}},k={icon:{type:[String,Object]},iconPosition:{type:String,default:r.before,validation:e=>Object.values(r).includes(e)}},L={tabindex:{type:[String,Number],default:0}},$={floating:Boolean},V={unselectable:{type:Boolean,default:!0}},O={id:[String,Number]};i.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const w={...O,name:{type:String,required:!0}},E={autofocus:Boolean},P={autocomplete:{type:String,default:"off"}};u.button;const x={...w,...E,...P,...L,...p,...f,...S,...m,...g,...h,...y,...B,...k,...$,...V,...b,multiple:Boolean,required:Boolean,size:[String,Number],modelValue:{type:[String,Number,Boolean,Object,Array],default:void 0},placeholder:String};const I=["for"],N={class:"vv-select__wrapper"},_={key:0,class:"vv-select__input-before"},A={class:"vv-select__inner"},C=["id"],F=["disabled","hidden"],j=["disabled","value"],z=["disabled","label"],q=["disabled","value"],D={key:1,class:"vv-select__input-after"};return e.defineComponent({name:"VvSelect",props:x,emits:["update:modelValue","focus","blur"],setup(l,{emit:a}){const u=l,d=e.useSlots(),p=e.ref(),{HintSlot:f,hasHintLabelOrSlot:m,hasInvalidLabelOrSlot:g,hintSlotScope:b}=function(l,o){const t=e.computed((()=>v(l.invalidLabel))),n=e.computed((()=>v(l.validLabel))),a=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(o.loading||a.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(o.invalid||t.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(o.valid||n.value)))),s=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(o.hint||i.value))),c=e.computed((()=>u.value||d.value||r.value||s.value)),p=e.computed((()=>({modelValue:l.modelValue,valid:l.valid,invalid:l.invalid,loading:l.loading}))),f=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:c,invalidLabel:t,validLabel:n,loadingLabel:a,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),render(){var l,o,t,n,a,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(l=this.$slots).loading)?void 0:o.call(l))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(n=(t=this.$slots).invalid)?void 0:n.call(t))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:u,hasHintLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:p,HintSlot:f}}(u,d),{id:h,modifiers:y,disabled:S,readonly:B,loading:k,icon:L,iconPosition:$,invalid:V,valid:O,floating:w,multiple:E}=e.toRefs(u),P=(l=>e.computed((()=>String((null==l?void 0:l.value)||o.nanoid()))))(h),x=e.computed((()=>`${P.value}-hint`)),{focused:R}=function(l,o){const{focused:n}=t.useFocus(l);return e.watch(n,(t=>{o(t?"focus":"blur",e.unref(l))})),{focused:n}}(p,a),H=t.useElementVisibility(p);e.watch(H,(e=>{e&&u.autofocus&&(R.value=!0)}));const{hasIcon:K,hasIconBefore:M,hasIconAfter:T}=function(l,o){const t=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===r.before))),n=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===r.after))),a=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.left))),u=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.right))),d=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.top))),s=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),hasIconLeft:a,hasIconRight:u,hasIconTop:d,hasIconBottom:s,hasIconBefore:t,hasIconAfter:n}}(L,$),G=e.computed((()=>{return l=u.modelValue,!(null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var l,o})),J=e.computed((()=>u.disabled||u.readonly)),U=e.computed((()=>J.value?-1:u.tabindex)),Q=e.computed((()=>!0===u.invalid||!0!==u.valid&&void 0)),W=s("vv-select",y,e.computed((()=>({valid:O.value,invalid:V.value,loading:k.value,disabled:S.value,readonly:B.value,"icon-before":M.value,"icon-after":T.value,dirty:G.value,focus:R.value,floating:w.value,multiple:E.value})))),X=e.computed((()=>({name:u.name,tabindex:U.value,disabled:J.value,required:u.required,size:u.size,autocomplete:u.autocomplete,multiple:u.multiple,"aria-invalid":Q.value,"aria-describedby":m.value?x.value:void 0,"aria-errormessage":g.value?x.value:void 0}))),Y=e.computed((()=>({valid:u.valid,invalid:u.invalid,modelValue:u.modelValue}))),{getOptionLabel:Z,getOptionValue:ee,getOptionDisabled:le,getOptionGrouped:oe}=function(l){const{options:o,labelKey:t,valueKey:a,disabledKey:i}=e.toRefs(l);return{options:o,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof t.value?t.value(e):n.get(e,t.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof a.value?a.value(e):n.get(e,a.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):n.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(u),te=e.computed({get:()=>u.modelValue,set:e=>{Array.isArray(e)&&(e=e.filter((e=>void 0!==e))),a("update:modelValue",e)}}),ne=e=>"string"!=typeof e&&(e&&e.options&&e.options.length>0);return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(W))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(P)},e.toDisplayString(l.label),9,I)):e.createCommentVNode("",!0),e.createElementVNode("div",N,[l.$slots.before?(e.openBlock(),e.createElementBlock("div",_,[e.renderSlot(l.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(Y))))])):e.createCommentVNode("",!0),e.createElementVNode("div",A,[e.unref(M)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:0,class:"vv-select__icon"},e.unref(K)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({id:e.unref(P),ref_key:"select",ref:p,"onUpdate:modelValue":o[0]||(o[0]=l=>e.isRef(te)?te.value=l:null)},e.unref(X)),[l.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,value:void 0,disabled:!l.unselectable,hidden:!l.unselectable},e.toDisplayString(l.placeholder),9,F)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,((l,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[ne(l)?(e.openBlock(),e.createElementBlock("optgroup",{key:`group-${o}`,disabled:e.unref(le)(l),label:e.unref(Z)(l)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(oe)(l),((l,t)=>(e.openBlock(),e.createElementBlock("option",{key:`group-${o}-item-${t}`,disabled:e.unref(le)(l),value:e.unref(ee)(l)},e.toDisplayString(e.unref(Z)(l)),9,q)))),128))],8,z)):(e.openBlock(),e.createElementBlock("option",{key:o,disabled:e.unref(le)(l),value:e.unref(ee)(l)},e.toDisplayString(e.unref(Z)(l)),9,j))],64)))),256))],16,C),[[e.vModelSelect,e.unref(te)]]),e.unref(T)?(e.openBlock(),e.createBlock(c,e.mergeProps({key:1,class:"vv-select__icon vv-select__icon-after"},e.unref(K)),null,16)):e.createCommentVNode("",!0)]),l.$slots.after?(e.openBlock(),e.createElementBlock("div",D,[e.renderSlot(l.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(Y))))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(f),{id:e.unref(x),class:"vv-select__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(b))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(b))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(b))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(b))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|
|
1
|
+
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("@iconify/vue"),require("nanoid"),require("@vueuse/core"),require("ts-dot-prop")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid","@vueuse/core","ts-dot-prop"],l):(e="undefined"!=typeof globalThis?globalThis:e||self).VvSelect=l(e.vue,e.vue$1,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,l,o,t,n){"use strict";const a={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 i=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(i||{}),r=(e=>(e.before="before",e.after="after",e))(r||{}),u=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(u||{});const d=Symbol.for("volver");function s(){return e.inject(d)}function c(l,o,t){return e.computed((()=>{const n={[l]:!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[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((o=>{n[`${l}--${o}`]=e.unref(t.value[o])})),n}))}const v=e.defineComponent({name:"VvIcon",props:a,setup(o){const t=o,n=e.computed((()=>"string"==typeof t.rotate?parseFloat(t.rotate):t.rotate)),a=e.ref(!0),i=s(),{modifiers:r}=e.toRefs(t),u=c("vv-icon",r),d=e.computed((()=>t.provider||(null==i?void 0:i.iconsProvider))),v=e.computed((()=>{const e=t.name??"",o=`@${d.value}:${t.prefix}:${e}`;if(l.iconExists(o))return o;const n=null==i?void 0:i.iconsCollections.find((o=>{const t=`@${d.value}:${o.prefix}:${e}`;return l.iconExists(t)}));return n?`@${d.value}:${n.prefix}:${e}`:e}));function p(e){const o=function(e){let l;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");l=(new e).window}return(l?new l.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),n=(null==o?void 0:o.innerHTML.trim())||"";o&&n&&l.addIcon(`@${d.value}:${t.prefix}:${t.name}`,{body:n,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return i&&t.src&&!l.iconExists(`@${d.value}:${t.prefix}:${t.name}`)&&(a.value=!1,i.fetchIcon(t.src).then((e=>{e&&(p(e),a.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),t.svg&&p(t.svg),(o,t)=>e.unref(a)?(e.openBlock(),e.createBlock(e.unref(l.Icon),e.mergeProps({key:0,class:e.unref(u)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:e.unref(n),color:o.color,onLoad:o.onLoad,icon:e.unref(v)}),null,16,["class"])):e.createCommentVNode("",!0)}});function p(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const f={valid:Boolean,validLabel:[String,Array]},m={invalid:Boolean,invalidLabel:[String,Array]},g={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},b={disabled:Boolean},h=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},B={hintLabel:{type:String,default:""}},k={options:{type:Array,default:()=>[]},labelKey:{type:[String,Function],default:"label"},valueKey:{type:[String,Function],default:"value"},disabledKey:{type:[String,Function],default:"disabled"}},L={icon:{type:[String,Object]},iconPosition:{type:String,default:r.before,validation:e=>Object.values(r).includes(e)}},$={tabindex:{type:[String,Number],default:0}},V={floating:Boolean},O={unselectable:{type:Boolean,default:!0}},w={id:[String,Number]};i.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const E={...w,name:{type:String,required:!0}},P={autofocus:Boolean},x={autocomplete:{type:String,default:"off"}};u.button;const N={...E,...P,...x,...$,...f,...m,...B,...g,...b,...y,...S,...k,...L,...V,...O,...h,multiple:Boolean,required:Boolean,size:[String,Number],modelValue:{type:[String,Number,Boolean,Object,Array],default:void 0},placeholder:String};const I=["for"],A={class:"vv-select__wrapper"},_={key:0,class:"vv-select__input-before"},j={class:"vv-select__inner"},C=["id"],F=["disabled","hidden"],z=["disabled","value"],q=["disabled","label"],D=["disabled","value"],R={key:1,class:"vv-select__input-after"};return e.defineComponent({name:"VvSelect",props:N,emits:["update:modelValue","focus","blur"],setup(l,{emit:a}){const u=l,d=e.useSlots(),f=function(l,o,t){const n=s(),a=e.computed((()=>{var e;if(n&&(null==(e=n.defaults.value)?void 0:e[l]))return n.defaults.value[l]}));return e.computed((()=>{if(void 0===a.value)return t;const e=a.value,l=o,n=t;return Object.keys(l).reduce(((o,t)=>{const a=n[t];if(o[t]=a,t in e){if(Array.isArray(l[t])){const n=l[t];n.length&&n[0]===a&&(o[t]=e[t])}if("function"==typeof l[t]&&(0,l[t])()===a&&(o[t]=e[t]),"object"==typeof l[t]){let n=l[t].default;"function"==typeof n&&(n=n()),"object"==typeof n?JSON.stringify(n)===JSON.stringify(a)&&(o[t]=e[t]):n===a&&(o[t]=e[t])}}return o}),{})}))}("VvSelect",N,u),m=e.ref(),{HintSlot:g,hasHintLabelOrSlot:b,hasInvalidLabelOrSlot:h,hintSlotScope:y}=function(l,o){const t=e.computed((()=>e.isRef(l)?l.value:l)),n=e.computed((()=>p(t.value.invalidLabel))),a=e.computed((()=>p(t.value.validLabel))),i=e.computed((()=>t.value.loadingLabel)),r=e.computed((()=>t.value.hintLabel)),u=e.computed((()=>Boolean(t.value.loading&&(o.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(t.value.invalid&&(o.invalid||n.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(t.value.valid&&(o.valid||a.value)))),c=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(o.hint||r.value))),v=e.computed((()=>d.value||s.value||u.value||c.value)),f=e.computed((()=>({modelValue:t.value.modelValue,valid:t.value.valid,invalid:t.value.invalid,loading:t.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:v,invalidLabel:n,validLabel:a,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:c}),render(){var l,o,t,n,a,i,r,u;if(this.isVisible){let d;return this.hasInvalidLabelOrSlot&&(d="alert"),this.hasValidLabelOrSlot&&(d="status"),this.hasLoadingLabelOrSlot?e.h(this.tag,{role:d},(null==(o=(l=this.$slots).loading)?void 0:o.call(l))??this.loadingLabel):this.hasInvalidLabelOrSlot?e.h(this.tag,{role:d},(null==(n=(t=this.$slots).invalid)?void 0:n.call(t))??this.$slots.invalid??this.invalidLabel):this.hasValidLabelOrSlot?e.h(this.tag,{role:d},(null==(i=(a=this.$slots).valid)?void 0:i.call(a))??this.validLabel):e.h(this.tag,{role:d},(null==(u=(r=this.$slots).hint)?void 0:u.call(r))??this.$slots.hint??this.hintLabel)}return null}});return{hasInvalidLabelOrSlot:d,hasHintLabelOrSlot:c,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hintSlotScope:f,HintSlot:m}}(f,d),{id:S,modifiers:B,disabled:k,readonly:L,loading:$,icon:V,iconPosition:O,invalid:w,valid:E,floating:P,multiple:x}=e.toRefs(u),H=(l=>e.computed((()=>String((null==l?void 0:l.value)||o.nanoid()))))(S),K=e.computed((()=>`${H.value}-hint`)),{focused:M}=function(l,o){const{focused:n}=t.useFocus(l);return e.watch(n,(t=>{o(t?"focus":"blur",e.unref(l))})),{focused:n}}(m,a),T=t.useElementVisibility(m);e.watch(T,(e=>{e&&u.autofocus&&(M.value=!0)}));const{hasIcon:J,hasIconBefore:G,hasIconAfter:U}=function(l,o){const t=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===r.before))),n=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===r.after))),a=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.left))),u=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.right))),d=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.top))),s=e.computed((()=>Boolean((null==l?void 0:l.value)&&o.value===i.bottom)));return{hasIcon:e.computed((()=>"string"==typeof(null==l?void 0:l.value)?{name:null==l?void 0:l.value}:null==l?void 0:l.value)),hasIconLeft:a,hasIconRight:u,hasIconTop:d,hasIconBottom:s,hasIconBefore:t,hasIconAfter:n}}(V,O),Q=e.computed((()=>{return l=u.modelValue,!(null==(o=e.unref(l))||""===o||Array.isArray(o)&&0===o.length||!(o instanceof Date)&&"object"==typeof o&&0===Object.keys(o).length);var l,o})),W=e.computed((()=>u.disabled||u.readonly)),X=e.computed((()=>W.value?-1:u.tabindex)),Y=e.computed((()=>!0===u.invalid||!0!==u.valid&&void 0)),Z=c("vv-select",B,e.computed((()=>({valid:E.value,invalid:w.value,loading:$.value,disabled:k.value,readonly:L.value,"icon-before":G.value,"icon-after":U.value,dirty:Q.value,focus:M.value,floating:P.value,multiple:x.value})))),ee=e.computed((()=>({name:u.name,tabindex:X.value,disabled:W.value,required:u.required,size:u.size,autocomplete:u.autocomplete,multiple:u.multiple,"aria-invalid":Y.value,"aria-describedby":b.value?K.value:void 0,"aria-errormessage":h.value?K.value:void 0}))),le=e.computed((()=>({valid:u.valid,invalid:u.invalid,modelValue:u.modelValue}))),{getOptionLabel:oe,getOptionValue:te,getOptionDisabled:ne,getOptionGrouped:ae}=function(l){const{options:o,labelKey:t,valueKey:a,disabledKey:i}=e.toRefs(l);return{options:o,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof t.value?t.value(e):n.get(e,t.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof a.value?a.value(e):n.get(e,a.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):n.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(u),ie=e.computed({get:()=>u.modelValue,set:e=>{Array.isArray(e)&&(e=e.filter((e=>void 0!==e))),a("update:modelValue",e)}}),re=e=>"string"!=typeof e&&(e&&e.options&&e.options.length>0);return(l,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(Z))},[l.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:e.unref(H)},e.toDisplayString(l.label),9,I)):e.createCommentVNode("",!0),e.createElementVNode("div",A,[l.$slots.before?(e.openBlock(),e.createElementBlock("div",_,[e.renderSlot(l.$slots,"before",e.normalizeProps(e.guardReactiveProps(e.unref(le))))])):e.createCommentVNode("",!0),e.createElementVNode("div",j,[e.unref(G)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:0,class:"vv-select__icon"},e.unref(J)),null,16)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("select",e.mergeProps({id:e.unref(H),ref_key:"select",ref:m,"onUpdate:modelValue":o[0]||(o[0]=l=>e.isRef(ie)?ie.value=l:null)},e.unref(ee)),[l.placeholder?(e.openBlock(),e.createElementBlock("option",{key:0,value:void 0,disabled:!l.unselectable,hidden:!l.unselectable},e.toDisplayString(l.placeholder),9,F)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.options,((l,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[re(l)?(e.openBlock(),e.createElementBlock("optgroup",{key:`group-${o}`,disabled:e.unref(ne)(l),label:e.unref(oe)(l)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ae)(l),((l,t)=>(e.openBlock(),e.createElementBlock("option",{key:`group-${o}-item-${t}`,disabled:e.unref(ne)(l),value:e.unref(te)(l)},e.toDisplayString(e.unref(oe)(l)),9,D)))),128))],8,q)):(e.openBlock(),e.createElementBlock("option",{key:o,disabled:e.unref(ne)(l),value:e.unref(te)(l)},e.toDisplayString(e.unref(oe)(l)),9,z))],64)))),256))],16,C),[[e.vModelSelect,e.unref(ie)]]),e.unref(U)?(e.openBlock(),e.createBlock(v,e.mergeProps({key:1,class:"vv-select__icon vv-select__icon-after"},e.unref(J)),null,16)):e.createCommentVNode("",!0)]),l.$slots.after?(e.openBlock(),e.createElementBlock("div",R,[e.renderSlot(l.$slots,"after",e.normalizeProps(e.guardReactiveProps(e.unref(le))))])):e.createCommentVNode("",!0)]),e.createVNode(e.unref(g),{id:e.unref(K),class:"vv-select__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(y))))])),key:"3"}:void 0]),1032,["id"])],2))}})}));
|