@volverjs/ui-vue 0.0.9-beta.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/auto-imports.d.ts +2 -2
- package/dist/components/VvAccordion/VvAccordion.es.js +8 -7
- package/dist/components/VvAccordionGroup/VvAccordionGroup.es.js +8 -7
- package/dist/components/VvAction/VvAction.es.js +8 -7
- package/dist/components/VvAlert/VvAlert.es.js +8 -7
- package/dist/components/VvAlertGroup/VvAlertGroup.es.js +8 -7
- package/dist/components/VvAlertGroup/VvAlertGroup.vue.d.ts +7 -7
- package/dist/components/VvAlertGroup/index.d.ts +2 -2
- package/dist/components/VvAvatar/VvAvatar.es.js +8 -7
- package/dist/components/VvAvatarGroup/VvAvatarGroup.es.js +8 -7
- package/dist/components/VvBadge/VvBadge.es.js +8 -7
- package/dist/components/VvBreadcrumb/VvBreadcrumb.es.js +8 -7
- package/dist/components/VvButton/VvButton.es.js +8 -7
- package/dist/components/VvButtonGroup/VvButtonGroup.es.js +8 -7
- package/dist/components/VvCard/VvCard.es.js +8 -7
- package/dist/components/VvCheckbox/VvCheckbox.es.js +28 -20
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +28 -20
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.es.js +165 -129
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +306 -90
- package/dist/components/VvCombobox/index.d.ts +108 -31
- package/dist/components/VvDialog/VvDialog.es.js +37 -31
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -16
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +301 -93
- package/dist/components/VvDropdown/index.d.ts +99 -30
- package/dist/components/VvDropdownAction/VvDropdownAction.es.js +8 -7
- package/dist/components/VvDropdownOptgroup/VvDropdownOptgroup.es.js +8 -7
- package/dist/components/VvDropdownOption/VvDropdownOption.es.js +8 -7
- package/dist/components/VvInputText/VvInputText.es.js +212 -115
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +19 -37
- package/dist/components/VvInputText/index.d.ts +15 -33
- package/dist/components/VvNav/VvNav.es.js +8 -7
- package/dist/components/VvProgress/VvProgress.es.js +8 -7
- package/dist/components/VvRadio/VvRadio.es.js +28 -20
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +28 -20
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.es.js +28 -20
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +1 -1
- package/dist/components/VvTab/VvTab.es.js +8 -7
- package/dist/components/VvTextarea/VvTextarea.es.js +36 -25
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTooltip/VvTooltip.es.js +8 -7
- package/dist/components/index.es.js +390 -257
- package/dist/components/index.umd.js +1 -1
- package/dist/constants.d.ts +4 -0
- package/dist/directives/index.es.js +8 -7
- package/dist/directives/v-tooltip.es.js +8 -7
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +100 -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 +1 -1
- package/dist/stories/AccordionGroup/AccordionGroupSlots.stories.d.ts +11 -11
- package/dist/stories/Combobox/Combobox.settings.d.ts +8 -0
- 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/package.json +63 -62
- 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/VvAlertGroup/VvAlertGroup.vue +2 -0
- package/src/components/VvCombobox/VvCombobox.vue +40 -19
- package/src/components/VvCombobox/index.ts +13 -0
- package/src/components/VvDialog/VvDialog.vue +16 -13
- package/src/components/VvDropdown/VvDropdown.vue +18 -16
- package/src/components/VvInputText/VvInputText.vue +170 -55
- package/src/components/VvInputText/index.ts +32 -34
- package/src/components/VvTextarea/VvTextarea.vue +8 -5
- package/src/components/common/HintSlot.ts +20 -12
- package/src/constants.ts +5 -0
- package/src/props/index.ts +7 -11
- package/src/resolvers/unplugin.ts +3 -0
- package/src/stories/Combobox/Combobox.settings.ts +8 -0
- 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
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { unref, computed, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode,
|
|
1
|
+
import { unref, computed, isRef, defineComponent, h, inject, toRef, toRefs, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, vModelCheckbox, 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";
|
|
@@ -132,19 +137,26 @@ function joinLines(items) {
|
|
|
132
137
|
return items;
|
|
133
138
|
}
|
|
134
139
|
function HintSlotFactory(propsOrRef, slots) {
|
|
135
|
-
const props =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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);
|
|
140
150
|
const hasLoadingLabelOrSlot = computed(
|
|
141
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
151
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
142
152
|
);
|
|
143
153
|
const hasInvalidLabelOrSlot = computed(
|
|
144
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
154
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
155
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
156
|
+
)
|
|
145
157
|
);
|
|
146
158
|
const hasValidLabelOrSlot = computed(
|
|
147
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
159
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
148
160
|
);
|
|
149
161
|
const hasHintLabelOrSlot = computed(
|
|
150
162
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -153,10 +165,10 @@ function HintSlotFactory(propsOrRef, slots) {
|
|
|
153
165
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
154
166
|
);
|
|
155
167
|
const hintSlotScope = computed(() => ({
|
|
156
|
-
modelValue: props.modelValue,
|
|
157
|
-
valid: props.valid,
|
|
158
|
-
invalid: props.invalid,
|
|
159
|
-
loading: props.loading
|
|
168
|
+
modelValue: props.value.modelValue,
|
|
169
|
+
valid: props.value.valid,
|
|
170
|
+
invalid: props.value.invalid,
|
|
171
|
+
loading: props.value.loading
|
|
160
172
|
}));
|
|
161
173
|
const HintSlot = defineComponent({
|
|
162
174
|
name: "HintSlot",
|
|
@@ -392,19 +404,15 @@ const IdProps = {
|
|
|
392
404
|
placement: {
|
|
393
405
|
type: String,
|
|
394
406
|
default: Side.bottom,
|
|
395
|
-
validator: (value) =>
|
|
396
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
397
|
-
}
|
|
407
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
398
408
|
},
|
|
399
409
|
/**
|
|
400
410
|
* Dropdown strategy
|
|
401
411
|
*/
|
|
402
412
|
strategy: {
|
|
403
413
|
type: String,
|
|
404
|
-
default:
|
|
405
|
-
validator: (value) =>
|
|
406
|
-
return ["fixed", "absolute"].includes(value);
|
|
407
|
-
}
|
|
414
|
+
default: void 0,
|
|
415
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
408
416
|
},
|
|
409
417
|
/**
|
|
410
418
|
* Dropdown show / hide transition name
|
|
@@ -1 +1 @@
|
|
|
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).VvCheckboxGroup=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("checkGroup");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 c=Object.keys(e);if(n=c.length,n!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,c[a]))return!1;for(a=n;0!=a--;)if(i=c[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 c(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function f(t,l){const o=e.unref(t),a=e.computed((()=>c(o.invalidLabel))),n=e.computed((()=>c(o.validLabel))),i=e.computed((()=>o.loadingLabel)),r=e.computed((()=>o.hintLabel)),u=e.computed((()=>Boolean(o.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(o.invalid&&(l.invalid||a.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(o.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),f=e.computed((()=>d.value||s.value||u.value||v.value)),p=e.computed((()=>({modelValue:o.modelValue,valid:o.valid,invalid:o.invalid,loading:o.loading}))),b=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,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:b}}const p={valid:Boolean,validLabel:[String,Array]},b={invalid:Boolean,invalidLabel:[String,Array]},m={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},h={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},k={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 V={...{...O,name:{type:String,required:!0}},...B,...p,...b,...k,...h,...y,...S,...g,...m,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},x={...p,...b,...L,...k,...h,...y,...S,...g,...m,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function $(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 A={...V,...S,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function C(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 j(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 w=["for"],P=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],R=e.defineComponent({name:"VvCheckbox",props:A,emits:["click","update:modelValue","change","blur"],setup(l,{emit:o}){const a=l,n=e.useSlots(),i=C("VvCheckbox",A,a),{id:r,disabled:s,readonly:v,valid:c,invalid:p,propsSwitch:b,modelValue:m,indeterminate:h,isInGroup:g}=function(t,l){const{group:o,isInGroup:a,getGroupOrLocalRef:n}=$(u),{id:i,switch:r,indeterminate:d}=e.toRefs(t),s=n("modelValue",t,l),v=n("valid",t),c=n("invalid",t),f=e.computed((()=>{var e;return Boolean(t.readonly||(null==(e=null==o?void 0:o.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==o?void 0:o.value)?void 0:e.disabled.value))}));return{id:i,propsSwitch:r,indeterminate:d,group:o,isInGroup:a,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(a,o),y=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(r),S=e.computed((()=>`${y.value}-hint`)),k=e.computed((()=>O.value?-1:a.tabindex)),L=e.ref(),B=e.computed((()=>void 0!==a.uncheckedValue&&!g.value)),O=e.computed((()=>s.value||v.value)),V=e.computed((()=>!0===p.value||!0!==c.value&&void 0)),x=e.computed((()=>B.value?m.value===a.value:Array.isArray(m.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,m.value):d(a.value,m.value))),R=e.computed((()=>!!h.value||!(x.value||!B.value||a.uncheckedValue===m.value))),N=e.computed((()=>{if(!B.value)return!["string","number","boolean"].includes(typeof a.value)||a.value})),E=e.computed({get:()=>x.value,set(e){if(B.value)m.value=e?a.value:a.uncheckedValue;else if(Array.isArray(m.value)||g.value){const t=new Set(Array.isArray(m.value)?m.value:void 0!==m.value?[m.value]:[]);e?t.add(a.value):t.delete(a.value),m.value=[...t]}else m.value=e?a.value:void 0;o("change",e)}}),{modifiers:_}=e.toRefs(a),z=j("vv-checkbox",_,e.computed((()=>({switch:b.value,valid:c.value,invalid:p.value,disabled:s.value,readonly:v.value,indeterminate:h.value}))));e.watchEffect((()=>{B.value&&Array.isArray(m.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>R.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{R.value&&(L.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:D,hintSlotScope:H}=f(i,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(z)),for:e.unref(y)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(y),ref_key:"input",ref:L,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(E)?E.value=t:null),type:"checkbox",class:"vv-checkbox__input",name:t.name,disabled:e.unref(O),value:e.unref(N),tabindex:e.unref(k),"aria-invalid":e.unref(V),"aria-describedby":e.unref(I)?e.unref(S):void 0,"aria-errormessage":e.unref(D)?e.unref(S):void 0},null,8,P),[[e.vModelCheckbox,e.unref(E)]]),e.renderSlot(t.$slots,"default",{value:e.unref(m)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(G),{id:e.unref(S),class:"vv-checkbox__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"3"}:void 0]),1032,["id"])],10,w))}}),N=x;const E=["textContent"],_={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:N,emits:["update:modelValue","change"],setup(t,{emit:a}){const n=t,i=e.useSlots(),r=C("VvCheckboxGroup",N,n),d=l.useVModel(n,"modelValue",a),{disabled:s,readonly:v,vertical:c,valid:p,invalid:b,modifiers:m}=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:b});const{getOptionLabel:h,getOptionValue:g}=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),y=j("vv-checkbox-group",m,e.computed((()=>({disabled:s.value,readonly:v.value,horizontal:!c.value,valid:p.value,invalid:b.value})))),{HintSlot:S,hintSlotScope:k}=f(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,E)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(R,e.mergeProps({key:l},((e,t)=>({id:`${n.name}_opt${t}`,name:n.name,label:h(e),value:g(e)}))(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(S),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),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).VvCheckboxGroup=t(e.vue,e.nanoid,e.core,e.tsDotProp)}(this,(function(e,t,l,a){"use strict";var o=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(o||{}),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("checkGroup");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),a=Array.isArray(t);let o,n,i;if(l&&a){if(n=e.length,n!=t.length)return!1;for(o=n;0!=o--;)if(!s(e[o],t[o]))return!1;return!0}if(l!=a)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 c=Object.keys(e);if(n=c.length,n!==Object.keys(t).length)return!1;for(o=n;0!=o--;)if(!Object.prototype.hasOwnProperty.call(t,c[o]))return!1;for(o=n;0!=o--;)if(i=c[o],!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 a=e;for(let t=0,o=l.length;t<o;++t){if(null==e)return null;a=a[l[t]]}return a}}return null}function c(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(t=e)||t instanceof String;var t})).join(" "):e}function f(t,l){const a=e.computed((()=>e.isRef(t)?t.value:t)),o=e.computed((()=>c(a.value.invalidLabel))),n=e.computed((()=>c(a.value.validLabel))),i=e.computed((()=>a.value.loadingLabel)),r=e.computed((()=>a.value.hintLabel)),u=e.computed((()=>Boolean(a.value.loading&&(l.loading||i.value)))),d=e.computed((()=>!u.value&&Boolean(a.value.invalid&&(l.invalid||o.value)))),s=e.computed((()=>!u.value&&!d.value&&Boolean(a.value.valid&&(l.valid||n.value)))),v=e.computed((()=>!u.value&&!d.value&&!s.value&&Boolean(l.hint||r.value))),f=e.computed((()=>d.value||s.value||u.value||v.value)),p=e.computed((()=>({modelValue:a.value.modelValue,valid:a.value.valid,invalid:a.value.invalid,loading:a.value.loading}))),m=e.defineComponent({name:"HintSlot",props:{tag:{type:String,default:"small"}},setup:()=>({isVisible:f,invalidLabel:o,validLabel:n,loadingLabel:i,hintLabel:r,hasInvalidLabelOrSlot:d,hasValidLabelOrSlot:s,hasLoadingLabelOrSlot:u,hasHintLabelOrSlot:v}),render(){var t,l,a,o,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==(o=(a=this.$slots).invalid)?void 0:o.call(a))??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..."}},h={disabled:Boolean},g=(Boolean,Boolean,{label:[String,Number]}),y={readonly:Boolean},S={modifiers:[String,Array]},k={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]};o.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const V={...{...O,name:{type:String,required:!0}},...B,...p,...m,...k,...h,...y,...S,...g,...b,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]},x={...p,...m,...L,...k,...h,...y,...S,...g,...b,modelValue:[String,Array,Boolean,Number,Symbol],name:{type:String,required:!0},vertical:Boolean};function $(t){const l=e.inject(t,void 0),a=e.computed((()=>{return t=l,!(null==(a=e.unref(t))||""===a||Array.isArray(a)&&0===a.length||!(a instanceof Date)&&"object"==typeof a&&0===Object.keys(a).length);var t,a}));return{group:l,isInGroup:a,getGroupOrLocalRef:function(t,a,o){if(null==l?void 0:l.value){const a=e.unref(l.value)[t];return e.computed({get:()=>null==a?void 0:a.value,set(e){a.value=e}})}const n=e.toRef(a,t);return e.computed({get:()=>n.value,set(e){o&&o(`update:${t}`,e)}})}}}i.button;const A={...V,...S,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function C(t,l,a){const o=e.inject(r),n=e.computed((()=>{var e;if(o&&(null==(e=o.defaults.value)?void 0:e[t]))return o.defaults.value[t]}));return e.computed((()=>{if(void 0===n.value)return a;const e=n.value,t=l,o=a;return Object.keys(t).reduce(((l,a)=>{const n=o[a];if(l[a]=n,a in e){if(Array.isArray(t[a])){const o=t[a];if(o.length){o[0]===n&&(l[a]=e[a])}}if("function"==typeof t[a]){(0,t[a])()===n&&(l[a]=e[a])}if("object"==typeof t[a]){let o=t[a].default;"function"==typeof o&&(o=o()),"object"==typeof o?JSON.stringify(o)===JSON.stringify(n)&&(l[a]=e[a]):o===n&&(l[a]=e[a])}}return l}),{})}))}function j(t,l,a){return e.computed((()=>{const o={[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&&(o[`${t}--${e}`]=!0)})),a&&Object.keys(a.value).forEach((l=>{o[`${t}--${l}`]=e.unref(a.value[l])})),o}))}const w=["for"],R=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"],P=e.defineComponent({name:"VvCheckbox",props:A,emits:["click","update:modelValue","change","blur"],setup(l,{emit:a}){const o=l,n=e.useSlots(),i=C("VvCheckbox",A,o),{id:r,disabled:s,readonly:v,valid:c,invalid:p,propsSwitch:m,modelValue:b,indeterminate:h,isInGroup:g}=function(t,l){const{group:a,isInGroup:o,getGroupOrLocalRef:n}=$(u),{id:i,switch:r,indeterminate:d}=e.toRefs(t),s=n("modelValue",t,l),v=n("valid",t),c=n("invalid",t),f=e.computed((()=>{var e;return Boolean(t.readonly||(null==(e=null==a?void 0:a.value)?void 0:e.readonly.value))})),p=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==a?void 0:a.value)?void 0:e.disabled.value))}));return{id:i,propsSwitch:r,indeterminate:d,group:a,isInGroup:o,modelValue:s,valid:v,invalid:c,readonly:f,disabled:p}}(o,a),y=(l=>e.computed((()=>String((null==l?void 0:l.value)||t.nanoid()))))(r),S=e.computed((()=>`${y.value}-hint`)),k=e.computed((()=>O.value?-1:o.tabindex)),L=e.ref(),B=e.computed((()=>void 0!==o.uncheckedValue&&!g.value)),O=e.computed((()=>s.value||v.value)),V=e.computed((()=>!0===p.value||!0!==c.value&&void 0)),x=e.computed((()=>B.value?b.value===o.value:Array.isArray(b.value)?function(e,t){if(null!=e&&t&&t.length)for(const l of t)if(d(e,l))return!0;return!1}(o.value,b.value):d(o.value,b.value))),P=e.computed((()=>!!h.value||!(x.value||!B.value||o.uncheckedValue===b.value))),N=e.computed((()=>{if(!B.value)return!["string","number","boolean"].includes(typeof o.value)||o.value})),E=e.computed({get:()=>x.value,set(e){if(B.value)b.value=e?o.value:o.uncheckedValue;else if(Array.isArray(b.value)||g.value){const t=new Set(Array.isArray(b.value)?b.value:void 0!==b.value?[b.value]:[]);e?t.add(o.value):t.delete(o.value),b.value=[...t]}else b.value=e?o.value:void 0;a("change",e)}}),{modifiers:_}=e.toRefs(o),z=j("vv-checkbox",_,e.computed((()=>({switch:m.value,valid:c.value,invalid:p.value,disabled:s.value,readonly:v.value,indeterminate:h.value}))));e.watchEffect((()=>{B.value&&Array.isArray(b.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>P.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{P.value&&(L.value.indeterminate=!0)}));const{HintSlot:G,hasHintLabelOrSlot:I,hasInvalidLabelOrSlot:D,hintSlotScope:H}=f(i,n);return(t,l)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(z)),for:e.unref(y)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(y),ref_key:"input",ref:L,"onUpdate:modelValue":l[0]||(l[0]=t=>e.isRef(E)?E.value=t:null),type:"checkbox",class:"vv-checkbox__input",name:t.name,disabled:e.unref(O),value:e.unref(N),tabindex:e.unref(k),"aria-invalid":e.unref(V),"aria-describedby":e.unref(I)?e.unref(S):void 0,"aria-errormessage":e.unref(D)?e.unref(S):void 0},null,8,R),[[e.vModelCheckbox,e.unref(E)]]),e.renderSlot(t.$slots,"default",{value:e.unref(b)},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)])),e.createVNode(e.unref(G),{id:e.unref(S),class:"vv-checkbox__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(H))))])),key:"3"}:void 0]),1032,["id"])],10,w))}}),N=x;const E=["textContent"],_={class:"vv-checkbox-group__wrapper"};return e.defineComponent({name:"VvCheckboxGroup",props:N,emits:["update:modelValue","change"],setup(t,{emit:o}){const n=t,i=e.useSlots(),r=C("VvCheckboxGroup",N,n),d=l.useVModel(n,"modelValue",o),{disabled:s,readonly:v,vertical:c,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:h,getOptionValue:g}=function(t){const{options:l,labelKey:o,valueKey:n,disabledKey:i}=e.toRefs(t);return{options:l,getOptionLabel:e=>"object"!=typeof e&&null!==e?e:String("function"==typeof o.value?o.value(e):a.get(e,o.value)),getOptionValue:e=>"object"!=typeof e&&null!==e?e:"function"==typeof n.value?n.value(e):a.get(e,n.value),getOptionDisabled:e=>("object"==typeof e||null===e)&&("function"==typeof i.value?i.value(e):a.get(e,i.value)),getOptionGrouped:e=>"object"!=typeof e&&null!==e?[]:e.options||[]}}(n),y=j("vv-checkbox-group",b,e.computed((()=>({disabled:s.value,readonly:v.value,horizontal:!c.value,valid:p.value,invalid:m.value})))),{HintSlot:S,hintSlotScope:k}=f(r,i);return(t,l)=>(e.openBlock(),e.createElementBlock("fieldset",{class:e.normalizeClass(e.unref(y))},[t.label?(e.openBlock(),e.createElementBlock("legend",{key:0,textContent:e.toDisplayString(t.label)},null,8,E)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[t.options.length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.options,((t,l)=>(e.openBlock(),e.createBlock(P,e.mergeProps({key:l},((e,t)=>({id:`${n.name}_opt${t}`,name:n.name,label:h(e),value:g(e)}))(t,l)),null,16)))),128)):e.renderSlot(t.$slots,"default",{key:1})]),e.createVNode(e.unref(S),{class:"vv-checkbox-group__hint"},e.createSlots({_:2},[t.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"0"}:void 0,t.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"1"}:void 0,t.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"2"}:void 0,t.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(t.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(k))))])),key:"3"}:void 0]),1024)],2))}})}));
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, provide, h, Fragment, useAttrs, onMounted, watch, nextTick, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, toHandlers, withDirectives, createElementVNode, normalizeStyle, normalizeClass, vShow, createTextVNode, toDisplayString,
|
|
1
|
+
import { inject, computed, unref, defineComponent, ref, toRefs, openBlock, createBlock, mergeProps, createCommentVNode, provide, h, Fragment, useAttrs, onMounted, watch, nextTick, createElementBlock, createVNode, withCtx, renderSlot, normalizeProps, guardReactiveProps, Transition, toHandlers, withDirectives, createElementVNode, normalizeStyle, normalizeClass, vShow, createTextVNode, toDisplayString, isRef, useSlots, renderList, vModelSelect, createSlots, resolveDynamicComponent, toRef, withModifiers, vModelText } from "vue";
|
|
2
2
|
import { iconExists, Icon, addIcon } from "@iconify/vue";
|
|
3
3
|
import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
|
-
import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced } from "@vueuse/core";
|
|
5
|
+
import { useMutationObserver, useVModel, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced, computedAsync } from "@vueuse/core";
|
|
6
6
|
import mitt from "mitt";
|
|
7
7
|
import { get } from "ts-dot-prop";
|
|
8
|
+
var Strategy = /* @__PURE__ */ ((Strategy2) => {
|
|
9
|
+
Strategy2["absolute"] = "absolute";
|
|
10
|
+
Strategy2["fixed"] = "fixed";
|
|
11
|
+
return Strategy2;
|
|
12
|
+
})(Strategy || {});
|
|
8
13
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
9
14
|
Side2["left"] = "left";
|
|
10
15
|
Side2["right"] = "right";
|
|
@@ -249,19 +254,15 @@ const DropdownProps = {
|
|
|
249
254
|
placement: {
|
|
250
255
|
type: String,
|
|
251
256
|
default: Side.bottom,
|
|
252
|
-
validator: (value) =>
|
|
253
|
-
return Object.values(Side).includes(value) || Object.values(Placement).includes(value);
|
|
254
|
-
}
|
|
257
|
+
validator: (value) => Object.values(Side).includes(value) || Object.values(Placement).includes(value)
|
|
255
258
|
},
|
|
256
259
|
/**
|
|
257
260
|
* Dropdown strategy
|
|
258
261
|
*/
|
|
259
262
|
strategy: {
|
|
260
263
|
type: String,
|
|
261
|
-
default:
|
|
262
|
-
validator: (value) =>
|
|
263
|
-
return ["fixed", "absolute"].includes(value);
|
|
264
|
-
}
|
|
264
|
+
default: void 0,
|
|
265
|
+
validator: (value) => Object.values(Strategy).includes(value)
|
|
265
266
|
},
|
|
266
267
|
/**
|
|
267
268
|
* Dropdown show / hide transition name
|
|
@@ -455,6 +456,13 @@ const VvComboboxProps = {
|
|
|
455
456
|
* Use input text to search on options
|
|
456
457
|
*/
|
|
457
458
|
searchable: Boolean,
|
|
459
|
+
/**
|
|
460
|
+
* Search function to filter options
|
|
461
|
+
*/
|
|
462
|
+
searchFunction: {
|
|
463
|
+
type: Function,
|
|
464
|
+
default: void 0
|
|
465
|
+
},
|
|
458
466
|
/**
|
|
459
467
|
* On searchable select is the input search placeholder
|
|
460
468
|
*/
|
|
@@ -884,7 +892,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
884
892
|
}
|
|
885
893
|
} else if (props.flip) {
|
|
886
894
|
if (typeof props.flip === "boolean") {
|
|
887
|
-
toReturn.push(flip());
|
|
895
|
+
toReturn.push(flip({ fallbackStrategy: "initialPlacement" }));
|
|
888
896
|
} else {
|
|
889
897
|
toReturn.push(flip(props.flip));
|
|
890
898
|
}
|
|
@@ -936,13 +944,13 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
936
944
|
}
|
|
937
945
|
return toReturn;
|
|
938
946
|
});
|
|
939
|
-
const { x, y,
|
|
947
|
+
const { x, y, middlewareData, placement, strategy } = useFloating(
|
|
940
948
|
referenceEl,
|
|
941
949
|
floatingEl,
|
|
942
950
|
{
|
|
943
951
|
whileElementsMounted: (...args) => {
|
|
944
952
|
return autoUpdate(...args, {
|
|
945
|
-
animationFrame: props.strategy ===
|
|
953
|
+
animationFrame: props.strategy === Strategy.fixed
|
|
946
954
|
});
|
|
947
955
|
},
|
|
948
956
|
placement: computed(() => props.placement),
|
|
@@ -951,16 +959,18 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
951
959
|
}
|
|
952
960
|
);
|
|
953
961
|
const dropdownPlacement = computed(() => {
|
|
962
|
+
var _a;
|
|
954
963
|
if (hasCustomPosition.value) {
|
|
955
964
|
return void 0;
|
|
956
965
|
}
|
|
966
|
+
const width = props.triggerWidth && referenceEl.value ? `${(_a = referenceEl.value) == null ? void 0 : _a.offsetWidth}px` : void 0;
|
|
957
967
|
return {
|
|
958
968
|
position: strategy.value,
|
|
959
969
|
top: `${y.value ?? 0}px`,
|
|
960
970
|
left: `${x.value ?? 0}px`,
|
|
961
|
-
maxWidth: maxWidth.value,
|
|
971
|
+
maxWidth: width ? void 0 : maxWidth.value,
|
|
962
972
|
maxHeight: maxHeight.value,
|
|
963
|
-
width
|
|
973
|
+
width
|
|
964
974
|
};
|
|
965
975
|
});
|
|
966
976
|
const side = computed(
|
|
@@ -972,10 +982,10 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
|
|
|
972
982
|
return void 0;
|
|
973
983
|
}
|
|
974
984
|
const staticSide = {
|
|
975
|
-
top:
|
|
976
|
-
right:
|
|
977
|
-
bottom:
|
|
978
|
-
left:
|
|
985
|
+
[Side.top]: Side.bottom,
|
|
986
|
+
[Side.right]: Side.left,
|
|
987
|
+
[Side.bottom]: Side.top,
|
|
988
|
+
[Side.left]: Side.right
|
|
979
989
|
}[side.value];
|
|
980
990
|
return {
|
|
981
991
|
left: ((_a = middlewareData.value.arrow) == null ? void 0 : _a.x) !== void 0 ? `${(_b = middlewareData.value.arrow) == null ? void 0 : _b.x}px` : void 0,
|
|
@@ -1456,19 +1466,26 @@ function joinLines(items) {
|
|
|
1456
1466
|
return items;
|
|
1457
1467
|
}
|
|
1458
1468
|
function HintSlotFactory(propsOrRef, slots) {
|
|
1459
|
-
const props =
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1469
|
+
const props = computed(() => {
|
|
1470
|
+
if (isRef(propsOrRef)) {
|
|
1471
|
+
return propsOrRef.value;
|
|
1472
|
+
}
|
|
1473
|
+
return propsOrRef;
|
|
1474
|
+
});
|
|
1475
|
+
const invalidLabel = computed(() => joinLines(props.value.invalidLabel));
|
|
1476
|
+
const validLabel = computed(() => joinLines(props.value.validLabel));
|
|
1477
|
+
const loadingLabel = computed(() => props.value.loadingLabel);
|
|
1478
|
+
const hintLabel = computed(() => props.value.hintLabel);
|
|
1464
1479
|
const hasLoadingLabelOrSlot = computed(
|
|
1465
|
-
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
1480
|
+
() => Boolean(props.value.loading && (slots.loading || loadingLabel.value))
|
|
1466
1481
|
);
|
|
1467
1482
|
const hasInvalidLabelOrSlot = computed(
|
|
1468
|
-
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
1483
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(
|
|
1484
|
+
props.value.invalid && (slots.invalid || invalidLabel.value)
|
|
1485
|
+
)
|
|
1469
1486
|
);
|
|
1470
1487
|
const hasValidLabelOrSlot = computed(
|
|
1471
|
-
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
1488
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.value.valid && (slots.valid || validLabel.value))
|
|
1472
1489
|
);
|
|
1473
1490
|
const hasHintLabelOrSlot = computed(
|
|
1474
1491
|
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
@@ -1477,10 +1494,10 @@ function HintSlotFactory(propsOrRef, slots) {
|
|
|
1477
1494
|
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
1478
1495
|
);
|
|
1479
1496
|
const hintSlotScope = computed(() => ({
|
|
1480
|
-
modelValue: props.modelValue,
|
|
1481
|
-
valid: props.valid,
|
|
1482
|
-
invalid: props.invalid,
|
|
1483
|
-
loading: props.loading
|
|
1497
|
+
modelValue: props.value.modelValue,
|
|
1498
|
+
valid: props.value.valid,
|
|
1499
|
+
invalid: props.value.invalid,
|
|
1500
|
+
loading: props.value.loading
|
|
1484
1501
|
}));
|
|
1485
1502
|
const HintSlot = defineComponent({
|
|
1486
1503
|
name: "HintSlot",
|
|
@@ -2460,7 +2477,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2460
2477
|
const searchText = ref("");
|
|
2461
2478
|
const debouncedSearchText = refDebounced(
|
|
2462
2479
|
searchText,
|
|
2463
|
-
Number(props.debounceSearch)
|
|
2480
|
+
computed(() => Number(props.debounceSearch))
|
|
2464
2481
|
);
|
|
2465
2482
|
watch(
|
|
2466
2483
|
debouncedSearchText,
|
|
@@ -2483,7 +2500,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2483
2500
|
expanded.value = false;
|
|
2484
2501
|
};
|
|
2485
2502
|
const onAfterExpand = () => {
|
|
2486
|
-
if (
|
|
2503
|
+
if (propsDefaults.value.searchable) {
|
|
2487
2504
|
if (inputSearchEl.value) {
|
|
2488
2505
|
inputSearchEl.value.focus({
|
|
2489
2506
|
preventScroll: true
|
|
@@ -2492,7 +2509,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2492
2509
|
}
|
|
2493
2510
|
};
|
|
2494
2511
|
const onAfterCollapse = () => {
|
|
2495
|
-
if (
|
|
2512
|
+
if (propsDefaults.value.searchable) {
|
|
2496
2513
|
searchText.value = "";
|
|
2497
2514
|
}
|
|
2498
2515
|
};
|
|
@@ -2506,14 +2523,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2506
2523
|
loading,
|
|
2507
2524
|
valid,
|
|
2508
2525
|
invalid,
|
|
2509
|
-
floating
|
|
2510
|
-
searchable
|
|
2526
|
+
floating
|
|
2511
2527
|
} = toRefs(props);
|
|
2512
2528
|
const hasId = useUniqueId(id);
|
|
2513
2529
|
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
2514
2530
|
const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
|
|
2515
2531
|
const hasSearchId = computed(() => `${hasId.value}-search`);
|
|
2516
2532
|
const hasLabelId = computed(() => `${hasId.value}-label`);
|
|
2533
|
+
const localLoading = ref(false);
|
|
2534
|
+
const isLoading = computed(() => localLoading.value || loading.value);
|
|
2517
2535
|
const dropdownEl = ref();
|
|
2518
2536
|
const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
|
|
2519
2537
|
icon,
|
|
@@ -2528,7 +2546,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2528
2546
|
modifiers,
|
|
2529
2547
|
computed(() => ({
|
|
2530
2548
|
disabled: disabled.value,
|
|
2531
|
-
loading:
|
|
2549
|
+
loading: isLoading.value,
|
|
2532
2550
|
readonly: readonly.value,
|
|
2533
2551
|
"icon-before": Boolean(hasIconBefore.value),
|
|
2534
2552
|
"icon-after": Boolean(hasIconAfter.value),
|
|
@@ -2546,8 +2564,19 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2546
2564
|
getOptionDisabled,
|
|
2547
2565
|
getOptionGrouped
|
|
2548
2566
|
} = useOptions(props);
|
|
2549
|
-
const filteredOptions =
|
|
2567
|
+
const filteredOptions = computedAsync(async () => {
|
|
2550
2568
|
var _a;
|
|
2569
|
+
if (propsDefaults.value.searchFunction) {
|
|
2570
|
+
localLoading.value = true;
|
|
2571
|
+
const toReturn = await Promise.resolve(
|
|
2572
|
+
propsDefaults.value.searchFunction(
|
|
2573
|
+
debouncedSearchText.value,
|
|
2574
|
+
props.options
|
|
2575
|
+
)
|
|
2576
|
+
);
|
|
2577
|
+
localLoading.value = false;
|
|
2578
|
+
return toReturn;
|
|
2579
|
+
}
|
|
2551
2580
|
return (_a = props.options) == null ? void 0 : _a.filter((option) => {
|
|
2552
2581
|
return getOptionLabel(option).toLowerCase().includes(debouncedSearchText.value.toLowerCase().trim());
|
|
2553
2582
|
});
|
|
@@ -2565,12 +2594,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2565
2594
|
} else if (props.modelValue) {
|
|
2566
2595
|
selectedValues = [props.modelValue];
|
|
2567
2596
|
}
|
|
2568
|
-
const options = props.options.reduce(
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2597
|
+
const options = props.options.reduce(
|
|
2598
|
+
(acc, value) => {
|
|
2599
|
+
if (isGroup(value)) {
|
|
2600
|
+
return [...acc, ...getOptionGrouped(value)];
|
|
2601
|
+
}
|
|
2602
|
+
return [...acc, value];
|
|
2603
|
+
},
|
|
2604
|
+
[]
|
|
2605
|
+
);
|
|
2574
2606
|
return options.filter((option) => {
|
|
2575
2607
|
if (isGroup(option)) {
|
|
2576
2608
|
return getOptionGrouped(option).some(
|
|
@@ -2624,7 +2656,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2624
2656
|
invalid: invalid.value,
|
|
2625
2657
|
invalidLabel: propsDefaults.value.invalidLabel,
|
|
2626
2658
|
hintLabel: propsDefaults.value.hintLabel,
|
|
2627
|
-
loading:
|
|
2659
|
+
loading: isLoading.value,
|
|
2628
2660
|
loadingLabel: propsDefaults.value.loadingLabel,
|
|
2629
2661
|
disabled: disabled.value,
|
|
2630
2662
|
readonly: readonly.value,
|
|
@@ -2652,7 +2684,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2652
2684
|
flip: propsDefaults.value.flip,
|
|
2653
2685
|
autoPlacement: propsDefaults.value.autoPlacement,
|
|
2654
2686
|
arrow: propsDefaults.value.arrow,
|
|
2655
|
-
autofocusFirst:
|
|
2687
|
+
autofocusFirst: propsDefaults.value.searchable ? true : propsDefaults.value.autofocusFirst,
|
|
2656
2688
|
triggerWidth: propsDefaults.value.triggerWidth,
|
|
2657
2689
|
modifiers: propsDefaults.value.dropdownModifiers
|
|
2658
2690
|
}));
|
|
@@ -2684,7 +2716,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2684
2716
|
_ctx.label ? (openBlock(), createElementBlock("label", {
|
|
2685
2717
|
key: 0,
|
|
2686
2718
|
id: unref(hasLabelId),
|
|
2687
|
-
for: unref(searchable
|
|
2719
|
+
for: unref(propsDefaults).searchable ? unref(hasSearchId) : void 0
|
|
2688
2720
|
}, toDisplayString(_ctx.label), 9, _hoisted_2)) : createCommentVNode("", true),
|
|
2689
2721
|
createElementVNode("div", {
|
|
2690
2722
|
ref_key: "wrapperEl",
|
|
@@ -2736,6 +2768,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2736
2768
|
_ctx.unselectable && !unref(readonly) && !unref(disabled) ? (openBlock(), createElementBlock("button", {
|
|
2737
2769
|
key: 0,
|
|
2738
2770
|
"aria-label": unref(propsDefaults).deselectActionLabel,
|
|
2771
|
+
type: "button",
|
|
2739
2772
|
onClick: withModifiers(($event) => onInput(option), ["stop"])
|
|
2740
2773
|
}, [
|
|
2741
2774
|
createVNode(_sfc_main$9, { name: "close" })
|
|
@@ -2758,87 +2791,90 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2758
2791
|
renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps(unref(slotProps))))
|
|
2759
2792
|
])) : createCommentVNode("", true)
|
|
2760
2793
|
]),
|
|
2761
|
-
items: withCtx(() =>
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2794
|
+
items: withCtx(() => {
|
|
2795
|
+
var _a;
|
|
2796
|
+
return [
|
|
2797
|
+
!unref(disabled) && ((_a = unref(filteredOptions)) == null ? void 0 : _a.length) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(filteredOptions), (option, index) => {
|
|
2798
|
+
return openBlock(), createElementBlock(Fragment, { key: index }, [
|
|
2799
|
+
isGroup(option) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
2800
|
+
createVNode(_sfc_main$5, {
|
|
2801
|
+
label: unref(getOptionLabel)(option)
|
|
2802
|
+
}, null, 8, ["label"]),
|
|
2803
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(
|
|
2804
|
+
option
|
|
2805
|
+
), (item, i) => {
|
|
2806
|
+
return openBlock(), createBlock(_sfc_main$6, mergeProps({
|
|
2807
|
+
disabled: unref(getOptionDisabled)(item),
|
|
2808
|
+
selected: getOptionSelected(item),
|
|
2809
|
+
unselectable: _ctx.unselectable,
|
|
2810
|
+
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
2811
|
+
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
2812
|
+
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
2813
|
+
}, {
|
|
2814
|
+
key: i,
|
|
2815
|
+
class: "vv-dropdown-option",
|
|
2816
|
+
onClickPassive: ($event) => onInput(item)
|
|
2817
|
+
}), {
|
|
2818
|
+
default: withCtx(() => [
|
|
2819
|
+
renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
|
|
2820
|
+
option,
|
|
2821
|
+
selectedOptions: unref(selectedOptions),
|
|
2822
|
+
selected: getOptionSelected(item),
|
|
2823
|
+
disabled: unref(getOptionDisabled)(item)
|
|
2824
|
+
})), () => [
|
|
2825
|
+
createTextVNode(toDisplayString(unref(getOptionLabel)(item)), 1)
|
|
2826
|
+
])
|
|
2827
|
+
]),
|
|
2828
|
+
_: 2
|
|
2829
|
+
}, 1040, ["onClickPassive"]);
|
|
2830
|
+
}), 128))
|
|
2831
|
+
], 64)) : (openBlock(), createBlock(_sfc_main$6, mergeProps({ key: 1 }, {
|
|
2832
|
+
disabled: unref(getOptionDisabled)(option),
|
|
2833
|
+
selected: getOptionSelected(option),
|
|
2834
|
+
unselectable: _ctx.unselectable,
|
|
2835
|
+
deselectHintLabel: unref(propsDefaults).deselectHintLabel,
|
|
2836
|
+
selectHintLabel: unref(propsDefaults).selectHintLabel,
|
|
2837
|
+
selectedHintLabel: unref(propsDefaults).selectedHintLabel
|
|
2838
|
+
}, {
|
|
2839
|
+
class: "vv-dropdown-option",
|
|
2840
|
+
onClickPassive: ($event) => onInput(option)
|
|
2841
|
+
}), {
|
|
2842
|
+
default: withCtx(() => [
|
|
2843
|
+
renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
|
|
2844
|
+
option,
|
|
2845
|
+
selectedOptions: unref(selectedOptions),
|
|
2846
|
+
selected: getOptionSelected(option),
|
|
2847
|
+
disabled: unref(getOptionDisabled)(option)
|
|
2848
|
+
})), () => [
|
|
2849
|
+
createTextVNode(toDisplayString(unref(getOptionLabel)(option)), 1)
|
|
2850
|
+
])
|
|
2851
|
+
]),
|
|
2852
|
+
_: 2
|
|
2853
|
+
}, 1040, ["onClickPassive"]))
|
|
2854
|
+
], 64);
|
|
2855
|
+
}), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$6, {
|
|
2856
|
+
key: 1,
|
|
2857
|
+
modifiers: "inert"
|
|
2858
|
+
}, {
|
|
2859
|
+
default: withCtx(() => [
|
|
2860
|
+
renderSlot(_ctx.$slots, "no-options", {}, () => [
|
|
2861
|
+
createTextVNode(toDisplayString(unref(propsDefaults).noOptionsLabel), 1)
|
|
2862
|
+
])
|
|
2863
|
+
]),
|
|
2864
|
+
_: 3
|
|
2865
|
+
})) : !unref(disabled) ? (openBlock(), createBlock(_sfc_main$6, {
|
|
2866
|
+
key: 2,
|
|
2867
|
+
modifiers: "inert"
|
|
2868
|
+
}, {
|
|
2869
|
+
default: withCtx(() => [
|
|
2870
|
+
renderSlot(_ctx.$slots, "no-results", {}, () => [
|
|
2871
|
+
createTextVNode(toDisplayString(unref(propsDefaults).noResultsLabel), 1)
|
|
2872
|
+
])
|
|
2873
|
+
]),
|
|
2874
|
+
_: 3
|
|
2875
|
+
})) : createCommentVNode("", true)
|
|
2876
|
+
];
|
|
2877
|
+
}),
|
|
2842
2878
|
after: withCtx(() => [
|
|
2843
2879
|
renderSlot(_ctx.$slots, "dropdown::after", {}, () => {
|
|
2844
2880
|
var _a;
|
|
@@ -2854,11 +2890,11 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
2854
2890
|
]),
|
|
2855
2891
|
_: 2
|
|
2856
2892
|
}, [
|
|
2857
|
-
unref(searchable
|
|
2893
|
+
unref(propsDefaults).searchable || _ctx.$slots["dropdown::before"] ? {
|
|
2858
2894
|
name: "before",
|
|
2859
2895
|
fn: withCtx(() => [
|
|
2860
2896
|
renderSlot(_ctx.$slots, "dropdown::before"),
|
|
2861
|
-
unref(searchable) ? withDirectives((openBlock(), createElementBlock("input", {
|
|
2897
|
+
unref(propsDefaults).searchable && !unref(disabled) ? withDirectives((openBlock(), createElementBlock("input", {
|
|
2862
2898
|
key: 0,
|
|
2863
2899
|
id: unref(hasSearchId),
|
|
2864
2900
|
ref_key: "inputSearchEl",
|