@volverjs/ui-vue 0.0.6-beta.5 → 0.0.6-beta.7
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 +9 -0
- package/dist/Volver.d.ts +1 -1
- package/dist/components/VvAccordion/index.d.ts +1 -1
- package/dist/components/VvButton/VvButton.es.js +25 -19
- package/dist/components/VvButton/VvButton.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.es.js +151 -98
- package/dist/components/VvCheckbox/VvCheckbox.umd.js +1 -1
- package/dist/components/VvCheckbox/VvCheckbox.vue.d.ts +37 -1
- package/dist/components/VvCheckbox/index.d.ts +6 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.es.js +187 -101
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.umd.js +1 -1
- package/dist/components/VvCheckboxGroup/VvCheckboxGroup.vue.d.ts +36 -0
- package/dist/components/VvCheckboxGroup/index.d.ts +5 -0
- package/dist/components/VvCombobox/VvCombobox.es.js +236 -140
- package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
- package/dist/components/VvCombobox/VvCombobox.vue.d.ts +25 -1
- package/dist/components/VvDialog/VvDialog.es.js +25 -19
- package/dist/components/VvDialog/VvDialog.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.es.js +19 -4
- package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
- package/dist/components/VvDropdown/VvDropdown.vue.d.ts +8 -4
- package/dist/components/VvDropdown/index.d.ts +1 -1
- package/dist/components/VvIcon/VvIcon.es.js +25 -19
- package/dist/components/VvIcon/VvIcon.umd.js +1 -1
- package/dist/components/VvIcon/VvIcon.vue.d.ts +2 -2
- package/dist/components/VvIcon/index.d.ts +2 -2
- package/dist/components/VvInputText/VvInputText.es.js +160 -136
- package/dist/components/VvInputText/VvInputText.umd.js +1 -1
- package/dist/components/VvInputText/VvInputText.vue.d.ts +24 -0
- package/dist/components/VvRadio/VvRadio.es.js +151 -98
- package/dist/components/VvRadio/VvRadio.umd.js +1 -1
- package/dist/components/VvRadio/VvRadio.vue.d.ts +37 -1
- package/dist/components/VvRadio/index.d.ts +6 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.es.js +187 -101
- package/dist/components/VvRadioGroup/VvRadioGroup.umd.js +1 -1
- package/dist/components/VvRadioGroup/VvRadioGroup.vue.d.ts +36 -0
- package/dist/components/VvRadioGroup/index.d.ts +5 -0
- package/dist/components/VvSelect/VvSelect.es.js +163 -137
- package/dist/components/VvSelect/VvSelect.umd.js +1 -1
- package/dist/components/VvSelect/VvSelect.vue.d.ts +24 -0
- package/dist/components/VvTextarea/VvTextarea.es.js +160 -136
- package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
- package/dist/components/VvTextarea/VvTextarea.vue.d.ts +24 -0
- package/dist/components/common/HintSlot.d.ts +38 -12
- package/dist/components/index.es.js +466 -168
- package/dist/components/index.umd.js +1 -1
- package/dist/composables/group/useInjectedGroupState.d.ts +1 -1
- package/dist/composables/useOptions.d.ts +2 -2
- package/dist/directives/index.d.ts +2 -2
- package/dist/icons.es.js +3 -3
- package/dist/icons.umd.js +1 -1
- package/dist/props/index.d.ts +22 -0
- package/package.json +33 -33
- 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/VvCheckbox/VvCheckbox.vue +23 -2
- package/src/components/VvCheckboxGroup/VvCheckboxGroup.vue +15 -2
- package/src/components/VvCombobox/VvCombobox.vue +40 -16
- package/src/components/VvDropdown/VvDropdown.vue +20 -2
- package/src/components/VvIcon/VvIcon.vue +37 -34
- package/src/components/VvIcon/index.ts +2 -2
- package/src/components/VvInputText/VvInputText.vue +26 -9
- package/src/components/VvRadio/VvRadio.vue +23 -2
- package/src/components/VvRadioGroup/VvRadioGroup.vue +15 -2
- package/src/components/VvSelect/VvSelect.vue +26 -9
- package/src/components/VvTextarea/VvTextarea.vue +26 -9
- package/src/components/common/HintSlot.ts +129 -170
- package/src/composables/useOptions.ts +9 -7
- package/src/props/index.ts +2 -0
package/auto-imports.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ declare global {
|
|
|
20
20
|
const createGlobalState: typeof import('@vueuse/core')['createGlobalState']
|
|
21
21
|
const createInjectionState: typeof import('@vueuse/core')['createInjectionState']
|
|
22
22
|
const createReactiveFn: typeof import('@vueuse/core')['createReactiveFn']
|
|
23
|
+
const createReusableTemplate: typeof import('@vueuse/core')['createReusableTemplate']
|
|
23
24
|
const createSharedComposable: typeof import('@vueuse/core')['createSharedComposable']
|
|
25
|
+
const createTemplatePromise: typeof import('@vueuse/core')['createTemplatePromise']
|
|
24
26
|
const createUnrefFn: typeof import('@vueuse/core')['createUnrefFn']
|
|
25
27
|
const customRef: typeof import('vue')['customRef']
|
|
26
28
|
const debouncedRef: typeof import('@vueuse/core')['debouncedRef']
|
|
@@ -112,11 +114,14 @@ declare global {
|
|
|
112
114
|
const unrefElement: typeof import('@vueuse/core')['unrefElement']
|
|
113
115
|
const until: typeof import('@vueuse/core')['until']
|
|
114
116
|
const useActiveElement: typeof import('@vueuse/core')['useActiveElement']
|
|
117
|
+
const useAnimate: typeof import('@vueuse/core')['useAnimate']
|
|
118
|
+
const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference']
|
|
115
119
|
const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery']
|
|
116
120
|
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
|
|
117
121
|
const useArrayFind: typeof import('@vueuse/core')['useArrayFind']
|
|
118
122
|
const useArrayFindIndex: typeof import('@vueuse/core')['useArrayFindIndex']
|
|
119
123
|
const useArrayFindLast: typeof import('@vueuse/core')['useArrayFindLast']
|
|
124
|
+
const useArrayIncludes: typeof import('@vueuse/core')['useArrayIncludes']
|
|
120
125
|
const useArrayJoin: typeof import('@vueuse/core')['useArrayJoin']
|
|
121
126
|
const useArrayMap: typeof import('@vueuse/core')['useArrayMap']
|
|
122
127
|
const useArrayReduce: typeof import('@vueuse/core')['useArrayReduce']
|
|
@@ -212,6 +217,8 @@ declare global {
|
|
|
212
217
|
const useOptions: typeof import('./src/composables/useOptions')['useOptions']
|
|
213
218
|
const usePageLeave: typeof import('@vueuse/core')['usePageLeave']
|
|
214
219
|
const useParallax: typeof import('@vueuse/core')['useParallax']
|
|
220
|
+
const useParentElement: typeof import('@vueuse/core')['useParentElement']
|
|
221
|
+
const usePerformanceObserver: typeof import('@vueuse/core')['usePerformanceObserver']
|
|
215
222
|
const usePermission: typeof import('@vueuse/core')['usePermission']
|
|
216
223
|
const usePointer: typeof import('@vueuse/core')['usePointer']
|
|
217
224
|
const usePointerLock: typeof import('@vueuse/core')['usePointerLock']
|
|
@@ -284,8 +291,10 @@ declare global {
|
|
|
284
291
|
const watchArray: typeof import('@vueuse/core')['watchArray']
|
|
285
292
|
const watchAtMost: typeof import('@vueuse/core')['watchAtMost']
|
|
286
293
|
const watchDebounced: typeof import('@vueuse/core')['watchDebounced']
|
|
294
|
+
const watchDeep: typeof import('@vueuse/core')['watchDeep']
|
|
287
295
|
const watchEffect: typeof import('vue')['watchEffect']
|
|
288
296
|
const watchIgnorable: typeof import('@vueuse/core')['watchIgnorable']
|
|
297
|
+
const watchImmediate: typeof import('@vueuse/core')['watchImmediate']
|
|
289
298
|
const watchOnce: typeof import('@vueuse/core')['watchOnce']
|
|
290
299
|
const watchPausable: typeof import('@vueuse/core')['watchPausable']
|
|
291
300
|
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
package/dist/Volver.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IconifyIcon, type IconifyJSON, type PartialIconifyAPIConfig } from '@iconify/vue';
|
|
2
2
|
import type { Component, Directive, Plugin, Ref } from 'vue';
|
|
3
|
-
export declare function useDefaultProps(component: Component, defaults?: Record<string, unknown>, name?: string): Component
|
|
3
|
+
export declare function useDefaultProps(component: Component, defaults?: Record<string, unknown>, name?: string): Component;
|
|
4
4
|
export type DefaultOptions = Record<string, Record<string, unknown>>;
|
|
5
5
|
export type VolverOptions = {
|
|
6
6
|
/**
|
|
@@ -39,7 +39,7 @@ export type VvAccordionPropsTypes = ExtractPropTypes<typeof VvAccordionProps>;
|
|
|
39
39
|
* Merges local and group props
|
|
40
40
|
*/
|
|
41
41
|
export declare function useGroupProps(props: VvAccordionPropsTypes, emit: (event: string, value: unknown) => void): {
|
|
42
|
-
modelValue: import("vue").WritableComputedRef<
|
|
42
|
+
modelValue: import("vue").WritableComputedRef<any>;
|
|
43
43
|
not: Ref<boolean>;
|
|
44
44
|
isInGroup: globalThis.ComputedRef<boolean>;
|
|
45
45
|
group: Ref<AccordionGroupState> | undefined;
|
|
@@ -176,6 +176,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
176
176
|
props: VvIconProps,
|
|
177
177
|
setup(__props) {
|
|
178
178
|
const props = __props;
|
|
179
|
+
const hasRotate = computed(() => {
|
|
180
|
+
if (typeof props.rotate === "string") {
|
|
181
|
+
return parseFloat(props.rotate);
|
|
182
|
+
}
|
|
183
|
+
return props.rotate;
|
|
184
|
+
});
|
|
179
185
|
const show = ref(true);
|
|
180
186
|
const volver = useVolver();
|
|
181
187
|
const { modifiers } = toRefs(props);
|
|
@@ -184,25 +190,24 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
184
190
|
return props.provider || (volver == null ? void 0 : volver.iconsProvider);
|
|
185
191
|
});
|
|
186
192
|
const icon = computed(() => {
|
|
187
|
-
const
|
|
188
|
-
const iconName = `@${provider.value}:${props.prefix}:${
|
|
189
|
-
if (iconExists(
|
|
190
|
-
return _name;
|
|
191
|
-
} else if (iconExists(iconName)) {
|
|
193
|
+
const name = props.name ?? "";
|
|
194
|
+
const iconName = `@${provider.value}:${props.prefix}:${name}`;
|
|
195
|
+
if (iconExists(iconName)) {
|
|
192
196
|
return iconName;
|
|
193
|
-
} else {
|
|
194
|
-
return (volver == null ? void 0 : volver.iconsCollections.find(
|
|
195
|
-
(iconsCollection) => {
|
|
196
|
-
const icon2 = `@${provider.value}:${iconsCollection.prefix}:${_name}`;
|
|
197
|
-
if (iconExists(icon2)) {
|
|
198
|
-
return icon2;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
)) || _name;
|
|
202
197
|
}
|
|
198
|
+
const iconsCollection = volver == null ? void 0 : volver.iconsCollections.find(
|
|
199
|
+
(iconsCollection2) => {
|
|
200
|
+
const icon2 = `@${provider.value}:${iconsCollection2.prefix}:${name}`;
|
|
201
|
+
return iconExists(icon2);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
if (iconsCollection) {
|
|
205
|
+
return `@${provider.value}:${iconsCollection.prefix}:${name}`;
|
|
206
|
+
}
|
|
207
|
+
return name;
|
|
203
208
|
});
|
|
204
209
|
function getSvgContent(svg) {
|
|
205
|
-
let dom
|
|
210
|
+
let dom;
|
|
206
211
|
if (typeof window === "undefined") {
|
|
207
212
|
const { JSDOM } = require("jsdom");
|
|
208
213
|
dom = new JSDOM().window;
|
|
@@ -233,12 +238,13 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
233
238
|
show.value = true;
|
|
234
239
|
}
|
|
235
240
|
}).catch((e) => {
|
|
236
|
-
throw new Error(`
|
|
241
|
+
throw new Error(`Error during fetch icon: ${e == null ? void 0 : e.message}`);
|
|
237
242
|
});
|
|
238
|
-
} else if (props.svg) {
|
|
239
|
-
addIconFromSvg(props.svg);
|
|
240
243
|
}
|
|
241
244
|
}
|
|
245
|
+
if (props.svg) {
|
|
246
|
+
addIconFromSvg(props.svg);
|
|
247
|
+
}
|
|
242
248
|
return (_ctx, _cache) => {
|
|
243
249
|
return unref(show) ? (openBlock(), createBlock(unref(Icon), mergeProps({
|
|
244
250
|
key: 0,
|
|
@@ -250,7 +256,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
250
256
|
horizontalFlip: _ctx.horizontalFlip,
|
|
251
257
|
verticalFlip: _ctx.verticalFlip,
|
|
252
258
|
flip: _ctx.flip,
|
|
253
|
-
rotate:
|
|
259
|
+
rotate: unref(hasRotate),
|
|
254
260
|
color: _ctx.color,
|
|
255
261
|
onLoad: _ctx.onLoad,
|
|
256
262
|
icon: unref(icon)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@iconify/vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvButton=t(e.vue,e.vue$1,e.nanoid)}(this,(function(e,t,o){"use strict";const n={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 r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),l=(e=>(e.before="before",e.after="after",e))(l||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{}),a=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(a||{});const s=Symbol.for("volver"),c=Symbol.for("buttonGroup"),d=Symbol.for("dropdownTrigger"),f=Symbol.for("dropdownAction");function v(){return e.inject(s)}function p(t,o,n){return e.computed((()=>{const r={[t]:!0},l="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(r[`${t}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((o=>{r[`${t}--${o}`]=e.unref(n.value[o])})),r}))}const m=e.defineComponent({name:"VvIcon",props:n,setup(o){const n=o,r=e.ref(!0),l=v(),{modifiers:i}=e.toRefs(n),u=p("vv-icon",i),a=e.computed((()=>n.provider||(null==l?void 0:l.iconsProvider))),s=e.computed((()=>{const e=n.name??"",o=`@${a.value}:${n.prefix}:${n.name}`;return t.iconExists(e)?e:t.iconExists(o)?o:(null==l?void 0:l.iconsCollections.find((o=>{const n=`@${a.value}:${o.prefix}:${e}`;if(t.iconExists(n))return n})))||e}));function c(e){const o=function(e){let t=null;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),r=(null==o?void 0:o.innerHTML.trim())||"";o&&r&&t.addIcon(`@${a.value}:${n.prefix}:${n.name}`,{body:r,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return l&&(n.src&&!t.iconExists(`@${a.value}:${n.prefix}:${n.name}`)?(r.value=!1,l.fetchIcon(n.src).then((e=>{e&&(c(e),r.value=!0)})).catch((e=>{throw new Error(`During fetch icon: ${null==e?void 0:e.message}`)}))):n.svg&&c(n.svg)),(o,n)=>e.unref(r)?(e.openBlock(),e.createBlock(e.unref(t.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:o.rotate,color:o.color,onLoad:o.onLoad,icon:e.unref(s)}),null,16,["class"])):e.createCommentVNode("",!0)}}),g={to:{type:[String,Object]},href:String,target:{type:String,validator:e=>Object.values(a).includes(e)},rel:{type:String,default:"noopener noreferrer"}},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},y={disabled:Boolean},h={active:Boolean},S={pressed:Boolean},k={label:[String,Number]},B={modifiers:[String,Array]};l.before;const x={unselectable:{type:Boolean,default:!0}},$={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const w={...y,...k,...S,...h,...g,type:{type:String,default:i.button,validator:e=>Object.values(i).includes(e)}},A=w;const j=e.defineComponent({name:"VvAction",props:A,emits:["click","mouseover","mouseleave"],setup(t,{expose:o,emit:n}){const r=t,l=v(),i=e.ref(null);o({$el:i});const{reference:a,bus:s,aria:c,expanded:p}=e.inject(d,{});e.watch((()=>i.value),(e=>{a&&(a.value=e)}));const m=e.computed((()=>r.pressed||(null==p?void 0:p.value))),{role:g}=e.inject(f,{}),b=e.computed((()=>{switch(!0){case r.disabled:return u.button;case void 0!==r.to:return(null==l?void 0:l.nuxt)?u.nuxtLink:u.routerLink;case void 0!==r.href:return u.a;default:return u.button}})),y=e.computed((()=>{const e={...null==c?void 0:c.value,"aria-pressed":!!m.value||void 0,role:g};switch(b.value){case u.a:return{...e,href:r.href,target:r.target,rel:r.rel};case u.routerLink:case u.nuxtLink:return{...e,to:r.to,target:r.target};default:return{...e,type:r.type,disabled:r.disabled}}})),h=e=>{r.disabled?e.preventDefault():(null==s||s.emit("click",e),n("click",e))},S=e=>{null==s||s.emit("mouseover",e),n("mouseover",e)},k=e=>{null==s||s.emit("mouseleave",e),n("mouseleave",e)};return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(b)),e.mergeProps(e.unref(y),{ref_key:"element",ref:i,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled},onClickPassive:h,onMouseoverPassive:S,onMouseleavePassive:k}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});function V(e,t,o){return o?O(e,o)===O(t,o):_(e,t)}function _(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const o=Array.isArray(e),n=Array.isArray(t);let r,l,i;if(o&&n){if(l=e.length,l!=t.length)return!1;for(r=l;0!=r--;)if(!_(e[r],t[r]))return!1;return!0}if(o!=n)return!1;const u=e instanceof Date,a=t instanceof Date;if(u!=a)return!1;if(u&&a)return e.getTime()==t.getTime();const s=e instanceof RegExp,c=t instanceof RegExp;if(s!=c)return!1;if(s&&c)return e.toString()==t.toString();const d=Object.keys(e);if(l=d.length,l!==Object.keys(t).length)return!1;for(r=l;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,d[r]))return!1;for(r=l;0!=r--;)if(i=d[r],!_(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function O(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const o=t.split(".");let n=e;for(let t=0,r=o.length;t<r;++t){if(null==e)return null;n=n[o[t]]}return n}}return null}function L(e,t){if(null!=e&&t&&t.length)for(const o of t)if(V(e,o))return!0;return!1}function N(t){const o=e.inject(t,void 0),n=e.computed((()=>{return t=o,!(null==(n=e.unref(t))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length);var t,n}));return{group:o,isInGroup:n,getGroupOrLocalRef:function(t,n,r){if(null==o?void 0:o.value){const n=e.unref(o.value)[t];return e.computed({get:()=>null==n?void 0:n.value,set(e){n.value=e}})}const l=e.toRef(n,t);return e.computed({get:()=>l.value,set(e){r&&r(`update:${t}`,e)}})}}}const P={...w,...$,...B,...x,...b,icon:[String,Object],iconPosition:{type:String,default:r.left,validator:e=>Object.values(r).includes(e)},loadingIcon:{type:String,default:"eos-icons:bubble-loading"},toggle:{type:Boolean,default:!1},value:{type:[String,Number,Boolean],default:void 0},uncheckedValue:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0}};const C={key:1,class:"vv-button__label"},E={key:1,class:"vv-button__label"};return e.defineComponent({name:"VvButton",props:P,emits:["update:modelValue"],setup(t,{expose:n,emit:l}){const i=t,u=e.useAttrs(),a=e.useSlots(),{id:s,modifiers:d,iconPosition:f,icon:v,label:g,modelValue:b,disabled:y,toggle:h,unselectable:S}=function(t,o){const{group:n,isInGroup:r,getGroupOrLocalRef:l}=N(c),{id:i,iconPosition:u,icon:a,label:s,pressed:d}=e.toRefs(t),f=l("modelValue",t,o),v=l("toggle",t),p=l("unselectable",t),m=e.computed((()=>(null==n?void 0:n.value.multiple.value)??!1)),g=e.computed((()=>{let e=t.modifiers,o=null==n?void 0:n.value.modifiers.value;const r=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>r.add(e)))),o&&(Array.isArray(o)||(o=o.split(" ")),o.forEach((e=>r.add(e)))),Array.from(r)})),b=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==n?void 0:n.value)?void 0:e.disabled.value))}));return{group:n,isInGroup:r,modelValue:f,toggle:v,unselectable:p,multiple:m,modifiers:g,disabled:b,id:i,pressed:d,iconPosition:u,icon:a,label:s}}(i,l),k=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(s),B=e.computed((()=>(null==u?void 0:u.name)||k.value)),x=e.ref(null);n({$el:e.computed((()=>{var e;return null==(e=x.value)?void 0:e.$el}))});const $=e.computed((()=>h.value?Array.isArray(b.value)?L(B.value,b.value):V(B.value,b.value):i.pressed)),w=p("vv-button",d,e.computed((()=>({reverse:[r.right,r.bottom].includes(f.value),column:[r.top,r.bottom].includes(f.value),"icon-only":Boolean((null==v?void 0:v.value)&&!(null==g?void 0:g.value)&&!a.default)})))),A=e.computed((()=>"string"==typeof(null==v?void 0:v.value)?{name:null==v?void 0:v.value}:null==v?void 0:v.value)),_=e.computed((()=>void 0!==i.value?i.value:B.value)),O=()=>{if(h.value){if(Array.isArray(b.value))return L(_.value,b.value)?void(S.value&&(b.value=b.value.filter((e=>e!==_.value)))):void b.value.push(_.value);if(_.value===b.value&&S.value)return void(b.value=i.uncheckedValue);b.value=_.value}};return(t,o)=>(e.openBlock(),e.createBlock(j,e.mergeProps({disabled:e.unref(y),pressed:e.unref($),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel},{id:e.unref(k),ref_key:"element",ref:x,class:e.unref(w),onClick:O}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(m,{key:0,class:"vv-button__loading-icon",name:t.loadingIcon},null,8,["name"])):e.createCommentVNode("",!0),t.loadingLabel?(e.openBlock(),e.createElementBlock("span",C,e.toDisplayString(t.loadingLabel),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(t.$slots,"before"),e.unref(v)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-button__icon"},e.unref(A)),null,16)):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("span",E,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("vue"),require("@iconify/vue"),require("nanoid")):"function"==typeof define&&define.amd?define(["vue","@iconify/vue","nanoid"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).VvButton=t(e.vue,e.vue$1,e.nanoid)}(this,(function(e,t,o){"use strict";const n={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 r=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(r||{}),l=(e=>(e.before="before",e.after="after",e))(l||{}),i=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(i||{}),u=(e=>(e.nuxtLink="nuxt-link",e.routerLink="router-link",e.a="a",e.button="button",e))(u||{}),a=(e=>(e._blank="_blank",e._self="_self",e._parent="_parent",e._top="_top",e))(a||{});const s=Symbol.for("volver"),c=Symbol.for("buttonGroup"),d=Symbol.for("dropdownTrigger"),f=Symbol.for("dropdownAction");function v(){return e.inject(s)}function p(t,o,n){return e.computed((()=>{const r={[t]:!0},l="string"==typeof(null==o?void 0:o.value)?o.value.split(" "):null==o?void 0:o.value;return l&&Array.isArray(l)&&l.forEach((e=>{e&&(r[`${t}--${e}`]=!0)})),n&&Object.keys(n.value).forEach((o=>{r[`${t}--${o}`]=e.unref(n.value[o])})),r}))}const m=e.defineComponent({name:"VvIcon",props:n,setup(o){const n=o,r=e.computed((()=>"string"==typeof n.rotate?parseFloat(n.rotate):n.rotate)),l=e.ref(!0),i=v(),{modifiers:u}=e.toRefs(n),a=p("vv-icon",u),s=e.computed((()=>n.provider||(null==i?void 0:i.iconsProvider))),c=e.computed((()=>{const e=n.name??"",o=`@${s.value}:${n.prefix}:${e}`;if(t.iconExists(o))return o;const r=null==i?void 0:i.iconsCollections.find((o=>{const n=`@${s.value}:${o.prefix}:${e}`;return t.iconExists(n)}));return r?`@${s.value}:${r.prefix}:${e}`:e}));function d(e){const o=function(e){let t;if("undefined"==typeof window){const{JSDOM:e}=require("jsdom");t=(new e).window}return(t?new t.DOMParser:new window.DOMParser).parseFromString(e,"text/html").querySelector("svg")}(e),r=(null==o?void 0:o.innerHTML.trim())||"";o&&r&&t.addIcon(`@${s.value}:${n.prefix}:${n.name}`,{body:r,height:o.viewBox.baseVal.height,width:o.viewBox.baseVal.width})}return i&&n.src&&!t.iconExists(`@${s.value}:${n.prefix}:${n.name}`)&&(l.value=!1,i.fetchIcon(n.src).then((e=>{e&&(d(e),l.value=!0)})).catch((e=>{throw new Error(`Error during fetch icon: ${null==e?void 0:e.message}`)}))),n.svg&&d(n.svg),(o,n)=>e.unref(l)?(e.openBlock(),e.createBlock(e.unref(t.Icon),e.mergeProps({key:0,class:e.unref(a)},{inline:o.inline,width:o.width,height:o.height,horizontalFlip:o.horizontalFlip,verticalFlip:o.verticalFlip,flip:o.flip,rotate:e.unref(r),color:o.color,onLoad:o.onLoad,icon:e.unref(c)}),null,16,["class"])):e.createCommentVNode("",!0)}}),g={to:{type:[String,Object]},href:String,target:{type:String,validator:e=>Object.values(a).includes(e)},rel:{type:String,default:"noopener noreferrer"}},b={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},y={disabled:Boolean},h={active:Boolean},S={pressed:Boolean},k={label:[String,Number]},B={modifiers:[String,Array]};l.before;const $={unselectable:{type:Boolean,default:!0}},x={id:[String,Number]};r.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const w={...y,...k,...S,...h,...g,type:{type:String,default:i.button,validator:e=>Object.values(i).includes(e)}},A=w;const j=e.defineComponent({name:"VvAction",props:A,emits:["click","mouseover","mouseleave"],setup(t,{expose:o,emit:n}){const r=t,l=v(),i=e.ref(null);o({$el:i});const{reference:a,bus:s,aria:c,expanded:p}=e.inject(d,{});e.watch((()=>i.value),(e=>{a&&(a.value=e)}));const m=e.computed((()=>r.pressed||(null==p?void 0:p.value))),{role:g}=e.inject(f,{}),b=e.computed((()=>{switch(!0){case r.disabled:return u.button;case void 0!==r.to:return(null==l?void 0:l.nuxt)?u.nuxtLink:u.routerLink;case void 0!==r.href:return u.a;default:return u.button}})),y=e.computed((()=>{const e={...null==c?void 0:c.value,"aria-pressed":!!m.value||void 0,role:g};switch(b.value){case u.a:return{...e,href:r.href,target:r.target,rel:r.rel};case u.routerLink:case u.nuxtLink:return{...e,to:r.to,target:r.target};default:return{...e,type:r.type,disabled:r.disabled}}})),h=e=>{r.disabled?e.preventDefault():(null==s||s.emit("click",e),n("click",e))},S=e=>{null==s||s.emit("mouseover",e),n("mouseover",e)},k=e=>{null==s||s.emit("mouseleave",e),n("mouseleave",e)};return(t,o)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(b)),e.mergeProps(e.unref(y),{ref_key:"element",ref:i,class:{active:t.active,pressed:e.unref(m),disabled:t.disabled},onClickPassive:h,onMouseoverPassive:S,onMouseleavePassive:k}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[e.createTextVNode(e.toDisplayString(t.label),1)]))])),_:3},16,["class"]))}});function V(e,t,o){return o?O(e,o)===O(t,o):_(e,t)}function _(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){const o=Array.isArray(e),n=Array.isArray(t);let r,l,i;if(o&&n){if(l=e.length,l!=t.length)return!1;for(r=l;0!=r--;)if(!_(e[r],t[r]))return!1;return!0}if(o!=n)return!1;const u=e instanceof Date,a=t instanceof Date;if(u!=a)return!1;if(u&&a)return e.getTime()==t.getTime();const s=e instanceof RegExp,c=t instanceof RegExp;if(s!=c)return!1;if(s&&c)return e.toString()==t.toString();const d=Object.keys(e);if(l=d.length,l!==Object.keys(t).length)return!1;for(r=l;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,d[r]))return!1;for(r=l;0!=r--;)if(i=d[r],!_(e[i],t[i]))return!1;return!0}return e!=e&&t!=t}function O(e,t){if(e&&Object.keys(e).length&&t){if(-1===t.indexOf("."))return e[t];{const o=t.split(".");let n=e;for(let t=0,r=o.length;t<r;++t){if(null==e)return null;n=n[o[t]]}return n}}return null}function L(e,t){if(null!=e&&t&&t.length)for(const o of t)if(V(e,o))return!0;return!1}function N(t){const o=e.inject(t,void 0),n=e.computed((()=>{return t=o,!(null==(n=e.unref(t))||""===n||Array.isArray(n)&&0===n.length||!(n instanceof Date)&&"object"==typeof n&&0===Object.keys(n).length);var t,n}));return{group:o,isInGroup:n,getGroupOrLocalRef:function(t,n,r){if(null==o?void 0:o.value){const n=e.unref(o.value)[t];return e.computed({get:()=>null==n?void 0:n.value,set(e){n.value=e}})}const l=e.toRef(n,t);return e.computed({get:()=>l.value,set(e){r&&r(`update:${t}`,e)}})}}}const P={...w,...x,...B,...$,...b,icon:[String,Object],iconPosition:{type:String,default:r.left,validator:e=>Object.values(r).includes(e)},loadingIcon:{type:String,default:"eos-icons:bubble-loading"},toggle:{type:Boolean,default:!1},value:{type:[String,Number,Boolean],default:void 0},uncheckedValue:{type:[String,Number,Boolean],default:void 0},modelValue:{type:[String,Number,Boolean],default:void 0}};const C={key:1,class:"vv-button__label"},E={key:1,class:"vv-button__label"};return e.defineComponent({name:"VvButton",props:P,emits:["update:modelValue"],setup(t,{expose:n,emit:l}){const i=t,u=e.useAttrs(),a=e.useSlots(),{id:s,modifiers:d,iconPosition:f,icon:v,label:g,modelValue:b,disabled:y,toggle:h,unselectable:S}=function(t,o){const{group:n,isInGroup:r,getGroupOrLocalRef:l}=N(c),{id:i,iconPosition:u,icon:a,label:s,pressed:d}=e.toRefs(t),f=l("modelValue",t,o),v=l("toggle",t),p=l("unselectable",t),m=e.computed((()=>(null==n?void 0:n.value.multiple.value)??!1)),g=e.computed((()=>{let e=t.modifiers,o=null==n?void 0:n.value.modifiers.value;const r=new Set;return e&&(Array.isArray(e)||(e=e.split(" ")),e.forEach((e=>r.add(e)))),o&&(Array.isArray(o)||(o=o.split(" ")),o.forEach((e=>r.add(e)))),Array.from(r)})),b=e.computed((()=>{var e;return Boolean(t.disabled||(null==(e=null==n?void 0:n.value)?void 0:e.disabled.value))}));return{group:n,isInGroup:r,modelValue:f,toggle:v,unselectable:p,multiple:m,modifiers:g,disabled:b,id:i,pressed:d,iconPosition:u,icon:a,label:s}}(i,l),k=(t=>e.computed((()=>String((null==t?void 0:t.value)||o.nanoid()))))(s),B=e.computed((()=>(null==u?void 0:u.name)||k.value)),$=e.ref(null);n({$el:e.computed((()=>{var e;return null==(e=$.value)?void 0:e.$el}))});const x=e.computed((()=>h.value?Array.isArray(b.value)?L(B.value,b.value):V(B.value,b.value):i.pressed)),w=p("vv-button",d,e.computed((()=>({reverse:[r.right,r.bottom].includes(f.value),column:[r.top,r.bottom].includes(f.value),"icon-only":Boolean((null==v?void 0:v.value)&&!(null==g?void 0:g.value)&&!a.default)})))),A=e.computed((()=>"string"==typeof(null==v?void 0:v.value)?{name:null==v?void 0:v.value}:null==v?void 0:v.value)),_=e.computed((()=>void 0!==i.value?i.value:B.value)),O=()=>{if(h.value){if(Array.isArray(b.value))return L(_.value,b.value)?void(S.value&&(b.value=b.value.filter((e=>e!==_.value)))):void b.value.push(_.value);if(_.value===b.value&&S.value)return void(b.value=i.uncheckedValue);b.value=_.value}};return(t,o)=>(e.openBlock(),e.createBlock(j,e.mergeProps({disabled:e.unref(y),pressed:e.unref(x),active:t.active,type:t.type,to:t.to,href:t.href,target:t.target,rel:t.rel},{id:e.unref(k),ref_key:"element",ref:$,class:e.unref(w),onClick:O}),{default:e.withCtx((()=>[e.renderSlot(t.$slots,"default",{},(()=>[t.loading?e.renderSlot(t.$slots,"loading",{key:0},(()=>[t.loadingIcon?(e.openBlock(),e.createBlock(m,{key:0,class:"vv-button__loading-icon",name:t.loadingIcon},null,8,["name"])):e.createCommentVNode("",!0),t.loadingLabel?(e.openBlock(),e.createElementBlock("span",C,e.toDisplayString(t.loadingLabel),1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(t.$slots,"before"),e.unref(v)?(e.openBlock(),e.createBlock(m,e.mergeProps({key:0,class:"vv-button__icon"},e.unref(A)),null,16)):e.createCommentVNode("",!0),e.unref(g)?(e.openBlock(),e.createElementBlock("span",E,[e.renderSlot(t.$slots,"label",{},(()=>[e.createTextVNode(e.toDisplayString(e.unref(g)),1)]))])):e.createCommentVNode("",!0),e.renderSlot(t.$slots,"after")],64))]))])),_:3},16,["id","class"]))}})}));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { unref, inject, computed, toRef, toRefs,
|
|
2
|
-
import { toReactive } from "@vueuse/core";
|
|
1
|
+
import { unref, inject, computed, toRef, toRefs, defineComponent, h, useSlots, ref, watchEffect, watch, onMounted, openBlock, createElementBlock, normalizeClass, withDirectives, createElementVNode, isRef, vModelCheckbox, renderSlot, createTextVNode, toDisplayString, createVNode, createSlots, withCtx, normalizeProps, guardReactiveProps } from "vue";
|
|
3
2
|
import { nanoid } from "nanoid";
|
|
4
3
|
var Side = /* @__PURE__ */ ((Side2) => {
|
|
5
4
|
Side2["left"] = "left";
|
|
@@ -85,6 +84,19 @@ const InvalidProps = {
|
|
|
85
84
|
*/
|
|
86
85
|
invalidLabel: [String, Array]
|
|
87
86
|
};
|
|
87
|
+
const LoadingProps = {
|
|
88
|
+
/**
|
|
89
|
+
* Loading status
|
|
90
|
+
*/
|
|
91
|
+
loading: Boolean,
|
|
92
|
+
/**
|
|
93
|
+
* Loading label
|
|
94
|
+
*/
|
|
95
|
+
loadingLabel: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "Loading..."
|
|
98
|
+
}
|
|
99
|
+
};
|
|
88
100
|
const DisabledProps = {
|
|
89
101
|
/**
|
|
90
102
|
* Whether the form control is disabled
|
|
@@ -268,6 +280,7 @@ const CheckboxRadioProps = {
|
|
|
268
280
|
...ReadonlyProps,
|
|
269
281
|
...ModifiersProps,
|
|
270
282
|
...LabelProps,
|
|
283
|
+
...LoadingProps,
|
|
271
284
|
/**
|
|
272
285
|
* Input value
|
|
273
286
|
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#value
|
|
@@ -460,111 +473,114 @@ function useGroupProps(props, emit) {
|
|
|
460
473
|
disabled
|
|
461
474
|
};
|
|
462
475
|
}
|
|
463
|
-
function joinLines(
|
|
464
|
-
if (Array.isArray(
|
|
465
|
-
return
|
|
476
|
+
function joinLines(items) {
|
|
477
|
+
if (Array.isArray(items)) {
|
|
478
|
+
return items.filter((item) => isString(item)).join(" ");
|
|
466
479
|
}
|
|
467
|
-
return
|
|
480
|
+
return items;
|
|
468
481
|
}
|
|
469
|
-
function HintSlotFactory(
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const {
|
|
477
|
-
hintLabel,
|
|
478
|
-
modelValue,
|
|
479
|
-
valid,
|
|
480
|
-
validLabel,
|
|
481
|
-
invalid,
|
|
482
|
-
invalidLabel,
|
|
483
|
-
...otherProps
|
|
484
|
-
} = toRefs(parentProps);
|
|
485
|
-
const loading = resolveFieldData(otherProps, "loading");
|
|
486
|
-
const loadingLabel = resolveFieldData(otherProps, "loadingLabel");
|
|
487
|
-
const hasInvalid = computed(() => {
|
|
488
|
-
if (!invalid.value) {
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
if (invalid.value && invalidSlot) {
|
|
492
|
-
return true;
|
|
493
|
-
}
|
|
494
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && Array.isArray(invalidLabel.value) && invalidLabel.value.length > 0) {
|
|
495
|
-
return true;
|
|
496
|
-
}
|
|
497
|
-
if ((invalidLabel == null ? void 0 : invalidLabel.value) && !isEmpty(invalidLabel)) {
|
|
498
|
-
return true;
|
|
499
|
-
}
|
|
500
|
-
return false;
|
|
501
|
-
});
|
|
502
|
-
const hasHint = computed(
|
|
503
|
-
() => !!(hintLabel && hintLabel.value || hintSlot)
|
|
482
|
+
function HintSlotFactory(props, slots) {
|
|
483
|
+
const invalidLabel = computed(() => joinLines(props.invalidLabel));
|
|
484
|
+
const validLabel = computed(() => joinLines(props.validLabel));
|
|
485
|
+
const loadingLabel = computed(() => props.loadingLabel);
|
|
486
|
+
const hintLabel = computed(() => props.hintLabel);
|
|
487
|
+
const hasLoadingLabelOrSlot = computed(
|
|
488
|
+
() => Boolean(props.loading && (slots.loading || loadingLabel.value))
|
|
504
489
|
);
|
|
505
|
-
const
|
|
506
|
-
() =>
|
|
490
|
+
const hasInvalidLabelOrSlot = computed(
|
|
491
|
+
() => !hasLoadingLabelOrSlot.value && Boolean(props.invalid && (slots.invalid || invalidLabel.value))
|
|
507
492
|
);
|
|
508
|
-
const
|
|
509
|
-
() =>
|
|
493
|
+
const hasValidLabelOrSlot = computed(
|
|
494
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && Boolean(props.valid && (slots.valid || validLabel.value))
|
|
495
|
+
);
|
|
496
|
+
const hasHintLabelOrSlot = computed(
|
|
497
|
+
() => !hasLoadingLabelOrSlot.value && !hasInvalidLabelOrSlot.value && !hasValidLabelOrSlot.value && Boolean(slots.hint || hintLabel.value)
|
|
510
498
|
);
|
|
511
499
|
const isVisible = computed(
|
|
512
|
-
() =>
|
|
500
|
+
() => hasInvalidLabelOrSlot.value || hasValidLabelOrSlot.value || hasLoadingLabelOrSlot.value || hasHintLabelOrSlot.value
|
|
513
501
|
);
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
502
|
+
const hintSlotScope = computed(() => ({
|
|
503
|
+
modelValue: props.modelValue,
|
|
504
|
+
valid: props.valid,
|
|
505
|
+
invalid: props.invalid,
|
|
506
|
+
loading: props.loading
|
|
507
|
+
}));
|
|
508
|
+
const HintSlot = defineComponent({
|
|
509
|
+
name: "HintSlot",
|
|
510
|
+
props: {
|
|
511
|
+
tag: {
|
|
512
|
+
type: String,
|
|
513
|
+
default: "small"
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
setup() {
|
|
517
|
+
return {
|
|
518
|
+
isVisible,
|
|
519
|
+
invalidLabel,
|
|
520
|
+
validLabel,
|
|
521
|
+
loadingLabel,
|
|
522
|
+
hintLabel,
|
|
523
|
+
hasInvalidLabelOrSlot,
|
|
524
|
+
hasValidLabelOrSlot,
|
|
525
|
+
hasLoadingLabelOrSlot,
|
|
526
|
+
hasHintLabelOrSlot
|
|
527
|
+
};
|
|
528
|
+
},
|
|
529
|
+
render() {
|
|
530
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
531
|
+
if (this.isVisible) {
|
|
532
|
+
let role;
|
|
533
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
534
|
+
role = "alert";
|
|
525
535
|
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
});
|
|
549
|
-
return {
|
|
550
|
-
isVisible,
|
|
551
|
-
hasInvalid,
|
|
552
|
-
hasValid,
|
|
553
|
-
hintContent
|
|
554
|
-
};
|
|
555
|
-
},
|
|
556
|
-
render() {
|
|
557
|
-
if (this.isVisible) {
|
|
536
|
+
if (this.hasValidLabelOrSlot) {
|
|
537
|
+
role = "status";
|
|
538
|
+
}
|
|
539
|
+
if (this.hasLoadingLabelOrSlot) {
|
|
540
|
+
return h(
|
|
541
|
+
this.tag,
|
|
542
|
+
{
|
|
543
|
+
role
|
|
544
|
+
},
|
|
545
|
+
((_b = (_a = this.$slots).loading) == null ? void 0 : _b.call(_a)) ?? this.loadingLabel
|
|
546
|
+
);
|
|
547
|
+
}
|
|
548
|
+
if (this.hasInvalidLabelOrSlot) {
|
|
549
|
+
return h(
|
|
550
|
+
this.tag,
|
|
551
|
+
{
|
|
552
|
+
role
|
|
553
|
+
},
|
|
554
|
+
((_d = (_c = this.$slots).invalid) == null ? void 0 : _d.call(_c)) ?? this.$slots.invalid ?? this.invalidLabel
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
if (this.hasValidLabelOrSlot) {
|
|
558
558
|
return h(
|
|
559
|
-
|
|
559
|
+
this.tag,
|
|
560
560
|
{
|
|
561
|
-
role
|
|
561
|
+
role
|
|
562
562
|
},
|
|
563
|
-
this.
|
|
563
|
+
((_f = (_e = this.$slots).valid) == null ? void 0 : _f.call(_e)) ?? this.validLabel
|
|
564
564
|
);
|
|
565
565
|
}
|
|
566
|
+
return h(
|
|
567
|
+
this.tag,
|
|
568
|
+
{
|
|
569
|
+
role
|
|
570
|
+
},
|
|
571
|
+
((_h = (_g = this.$slots).hint) == null ? void 0 : _h.call(_g)) ?? this.$slots.hint ?? this.hintLabel
|
|
572
|
+
);
|
|
566
573
|
}
|
|
574
|
+
return null;
|
|
567
575
|
}
|
|
576
|
+
});
|
|
577
|
+
return {
|
|
578
|
+
hasInvalidLabelOrSlot,
|
|
579
|
+
hasHintLabelOrSlot,
|
|
580
|
+
hasValidLabelOrSlot,
|
|
581
|
+
hasLoadingLabelOrSlot,
|
|
582
|
+
hintSlotScope,
|
|
583
|
+
HintSlot
|
|
568
584
|
};
|
|
569
585
|
}
|
|
570
586
|
const useUniqueId = (id) => computed(() => String((id == null ? void 0 : id.value) || nanoid()));
|
|
@@ -592,7 +608,7 @@ function useModifiers(prefix, modifiers, others) {
|
|
|
592
608
|
});
|
|
593
609
|
}
|
|
594
610
|
const _hoisted_1 = ["for"];
|
|
595
|
-
const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid"];
|
|
611
|
+
const _hoisted_2 = ["id", "name", "disabled", "value", "tabindex", "aria-invalid", "aria-describedby", "aria-errormessage"];
|
|
596
612
|
const __default__ = {
|
|
597
613
|
name: "VvCheckbox"
|
|
598
614
|
};
|
|
@@ -615,6 +631,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
615
631
|
isInGroup
|
|
616
632
|
} = useGroupProps(props, emit);
|
|
617
633
|
const hasId = useUniqueId(id);
|
|
634
|
+
const hasHintId = computed(() => `${hasId.value}-hint`);
|
|
618
635
|
const tabindex = computed(() => isDisabled.value ? -1 : props.tabindex);
|
|
619
636
|
const input = ref();
|
|
620
637
|
const isBinary = computed(
|
|
@@ -709,7 +726,12 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
709
726
|
input.value.indeterminate = true;
|
|
710
727
|
}
|
|
711
728
|
});
|
|
712
|
-
const {
|
|
729
|
+
const {
|
|
730
|
+
HintSlot,
|
|
731
|
+
hasHintLabelOrSlot,
|
|
732
|
+
hasInvalidLabelOrSlot,
|
|
733
|
+
hintSlotScope
|
|
734
|
+
} = HintSlotFactory(props, slots);
|
|
713
735
|
return (_ctx, _cache) => {
|
|
714
736
|
return openBlock(), createElementBlock("label", {
|
|
715
737
|
class: normalizeClass(unref(bemCssClasses)),
|
|
@@ -726,7 +748,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
726
748
|
disabled: unref(isDisabled),
|
|
727
749
|
value: unref(hasValue),
|
|
728
750
|
tabindex: unref(tabindex),
|
|
729
|
-
"aria-invalid": unref(isInvalid)
|
|
751
|
+
"aria-invalid": unref(isInvalid),
|
|
752
|
+
"aria-describedby": unref(hasHintLabelOrSlot) ? unref(hasHintId) : void 0,
|
|
753
|
+
"aria-errormessage": unref(hasInvalidLabelOrSlot) ? unref(hasHintId) : void 0
|
|
730
754
|
}, null, 8, _hoisted_2), [
|
|
731
755
|
[vModelCheckbox, unref(localModelValue)]
|
|
732
756
|
]),
|
|
@@ -734,9 +758,38 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
734
758
|
createTextVNode(toDisplayString(_ctx.label), 1)
|
|
735
759
|
]),
|
|
736
760
|
createVNode(unref(HintSlot), {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
},
|
|
761
|
+
id: unref(hasHintId),
|
|
762
|
+
class: "vv-checkbox__hint"
|
|
763
|
+
}, createSlots({ _: 2 }, [
|
|
764
|
+
_ctx.$slots.hint ? {
|
|
765
|
+
name: "hint",
|
|
766
|
+
fn: withCtx(() => [
|
|
767
|
+
renderSlot(_ctx.$slots, "hint", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
768
|
+
]),
|
|
769
|
+
key: "0"
|
|
770
|
+
} : void 0,
|
|
771
|
+
_ctx.$slots.loading ? {
|
|
772
|
+
name: "loading",
|
|
773
|
+
fn: withCtx(() => [
|
|
774
|
+
renderSlot(_ctx.$slots, "loading", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
775
|
+
]),
|
|
776
|
+
key: "1"
|
|
777
|
+
} : void 0,
|
|
778
|
+
_ctx.$slots.valid ? {
|
|
779
|
+
name: "valid",
|
|
780
|
+
fn: withCtx(() => [
|
|
781
|
+
renderSlot(_ctx.$slots, "valid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
782
|
+
]),
|
|
783
|
+
key: "2"
|
|
784
|
+
} : void 0,
|
|
785
|
+
_ctx.$slots.invalid ? {
|
|
786
|
+
name: "invalid",
|
|
787
|
+
fn: withCtx(() => [
|
|
788
|
+
renderSlot(_ctx.$slots, "invalid", normalizeProps(guardReactiveProps(unref(hintSlotScope))))
|
|
789
|
+
]),
|
|
790
|
+
key: "3"
|
|
791
|
+
} : void 0
|
|
792
|
+
]), 1032, ["id"])
|
|
740
793
|
], 10, _hoisted_1);
|
|
741
794
|
};
|
|
742
795
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l(require("vue"),require("
|
|
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).VvCheckbox=l(e.vue,e.nanoid)}(this,(function(e,l){"use strict";var a=(e=>(e.left="left",e.right="right",e.top="top",e.bottom="bottom",e))(a||{}),t=(e=>(e.before="before",e.after="after",e))(t||{}),n=(e=>(e.button="button",e.submit="submit",e.reset="reset",e))(n||{});const o=Symbol.for("checkGroup"),i={valid:Boolean,validLabel:[String,Array]},r={invalid:Boolean,invalidLabel:[String,Array]},u={loading:Boolean,loadingLabel:{type:String,default:"Loading..."}},d={disabled:Boolean},s=(Boolean,Boolean,{label:[String,Number]}),v={readonly:Boolean},c={modifiers:[String,Array]},f={hintLabel:{type:String,default:""}};t.before;const h={tabindex:{type:[String,Number],default:0}},b={id:[String,Number]};a.bottom,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean;const p={...{...b,name:{type:String,required:!0}},...h,...i,...r,...f,...d,...v,...c,...s,...u,value:[String,Number,Boolean],modelValue:[Object,Number,Boolean,String]};function m(e,l,a){return a?y(e,a)===y(l,a):g(e,l)}function g(e,l){if(e===l)return!0;if(e&&l&&"object"==typeof e&&"object"==typeof l){const a=Array.isArray(e),t=Array.isArray(l);let n,o,i;if(a&&t){if(o=e.length,o!=l.length)return!1;for(n=o;0!=n--;)if(!g(e[n],l[n]))return!1;return!0}if(a!=t)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],!g(e[i],l[i]))return!1;return!0}return e!=e&&l!=l}function y(e,l){if(e&&Object.keys(e).length&&l){if(-1===l.indexOf("."))return e[l];{const a=l.split(".");let t=e;for(let l=0,n=a.length;l<n;++l){if(null==e)return null;t=t[a[l]]}return t}}return null}function S(l){const a=e.inject(l,void 0),t=e.computed((()=>{return l=a,!(null==(t=e.unref(l))||""===t||Array.isArray(t)&&0===t.length||!(t instanceof Date)&&"object"==typeof t&&0===Object.keys(t).length);var l,t}));return{group:a,isInGroup:t,getGroupOrLocalRef:function(l,t,n){if(null==a?void 0:a.value){const t=e.unref(a.value)[l];return e.computed({get:()=>null==t?void 0:t.value,set(e){t.value=e}})}const o=e.toRef(t,l);return e.computed({get:()=>o.value,set(e){n&&n(`update:${l}`,e)}})}}}n.button;const L={...p,...c,indeterminate:Boolean,uncheckedValue:[String,Number,Boolean],switch:Boolean};function B(e){return Array.isArray(e)?e.filter((e=>{return"string"==typeof(l=e)||l instanceof String;var l})).join(" "):e}const k=["for"],O=["id","name","disabled","value","tabindex","aria-invalid","aria-describedby","aria-errormessage"];return e.defineComponent({name:"VvCheckbox",props:L,emits:["click","update:modelValue","change","blur"],setup(a,{emit:t}){const n=a,i=e.useSlots(),{id:r,disabled:u,readonly:d,valid:s,invalid:v,propsSwitch:c,modelValue:f,indeterminate:h,isInGroup:b}=function(l,a){const{group:t,isInGroup:n,getGroupOrLocalRef:i}=S(o),{id:r,switch:u,indeterminate:d}=e.toRefs(l),s=i("modelValue",l,a),v=i("valid",l),c=i("invalid",l),f=e.computed((()=>{var e;return Boolean(l.readonly||(null==(e=null==t?void 0:t.value)?void 0:e.readonly.value))})),h=e.computed((()=>{var e;return Boolean(l.disabled||(null==(e=null==t?void 0:t.value)?void 0:e.disabled.value))}));return{id:r,propsSwitch:u,indeterminate:d,group:t,isInGroup:n,modelValue:s,valid:v,invalid:c,readonly:f,disabled:h}}(n,t),p=(a=>e.computed((()=>String((null==a?void 0:a.value)||l.nanoid()))))(r),g=e.computed((()=>`${p.value}-hint`)),y=e.computed((()=>x.value?-1:n.tabindex)),L=e.ref(),V=e.computed((()=>void 0!==n.uncheckedValue&&!b.value)),x=e.computed((()=>u.value||d.value)),A=e.computed((()=>!0===v.value||!0!==s.value&&void 0)),$=e.computed((()=>V.value?f.value===n.value:Array.isArray(f.value)?function(e,l){if(null!=e&&l&&l.length)for(const a of l)if(m(e,a))return!0;return!1}(n.value,f.value):m(n.value,f.value))),w=e.computed((()=>!!h.value||!($.value||!V.value||n.uncheckedValue===f.value))),j=e.computed((()=>{if(!V.value)return!["string","number","boolean"].includes(typeof n.value)||n.value})),R=e.computed({get:()=>$.value,set(e){if(V.value)f.value=e?n.value:n.uncheckedValue;else if(Array.isArray(f.value)||b.value){const l=new Set(Array.isArray(f.value)?f.value:void 0!==f.value?[f.value]:[]);e?l.add(n.value):l.delete(n.value),f.value=[...l]}else f.value=e?n.value:void 0;t("change",e)}}),{modifiers:C}=e.toRefs(n),I=function(l,a,t){return e.computed((()=>{const n={[l]:!0},o="string"==typeof(null==a?void 0:a.value)?a.value.split(" "):null==a?void 0:a.value;return o&&Array.isArray(o)&&o.forEach((e=>{e&&(n[`${l}--${e}`]=!0)})),t&&Object.keys(t.value).forEach((a=>{n[`${l}--${a}`]=e.unref(t.value[a])})),n}))}("vv-checkbox",C,e.computed((()=>({switch:c.value,valid:s.value,invalid:v.value,disabled:u.value,readonly:d.value,indeterminate:h.value}))));e.watchEffect((()=>{V.value&&Array.isArray(f.value)&&console.warn("[VvCheckbox] The model value is an array but the component is in binary mode.")})),e.watch((()=>w.value),(e=>{L.value.indeterminate=!!e})),e.onMounted((()=>{w.value&&(L.value.indeterminate=!0)}));const{HintSlot:N,hasHintLabelOrSlot:P,hasInvalidLabelOrSlot:E,hintSlotScope:G}=function(l,a){const t=e.computed((()=>B(l.invalidLabel))),n=e.computed((()=>B(l.validLabel))),o=e.computed((()=>l.loadingLabel)),i=e.computed((()=>l.hintLabel)),r=e.computed((()=>Boolean(l.loading&&(a.loading||o.value)))),u=e.computed((()=>!r.value&&Boolean(l.invalid&&(a.invalid||t.value)))),d=e.computed((()=>!r.value&&!u.value&&Boolean(l.valid&&(a.valid||n.value)))),s=e.computed((()=>!r.value&&!u.value&&!d.value&&Boolean(a.hint||i.value))),v=e.computed((()=>u.value||d.value||r.value||s.value)),c=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:v,invalidLabel:t,validLabel:n,loadingLabel:o,hintLabel:i,hasInvalidLabelOrSlot:u,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hasHintLabelOrSlot:s}),render(){var l,a,t,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==(a=(l=this.$slots).loading)?void 0:a.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=(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:u,hasHintLabelOrSlot:s,hasValidLabelOrSlot:d,hasLoadingLabelOrSlot:r,hintSlotScope:c,HintSlot:f}}(n,i);return(l,a)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(e.unref(I)),for:e.unref(p)},[e.withDirectives(e.createElementVNode("input",{id:e.unref(p),ref_key:"input",ref:L,"onUpdate:modelValue":a[0]||(a[0]=l=>e.isRef(R)?R.value=l:null),type:"checkbox",class:"vv-checkbox__input",name:l.name,disabled:e.unref(x),value:e.unref(j),tabindex:e.unref(y),"aria-invalid":e.unref(A),"aria-describedby":e.unref(P)?e.unref(g):void 0,"aria-errormessage":e.unref(E)?e.unref(g):void 0},null,8,O),[[e.vModelCheckbox,e.unref(R)]]),e.renderSlot(l.$slots,"default",{value:e.unref(f)},(()=>[e.createTextVNode(e.toDisplayString(l.label),1)])),e.createVNode(e.unref(N),{id:e.unref(g),class:"vv-checkbox__hint"},e.createSlots({_:2},[l.$slots.hint?{name:"hint",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"hint",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"0"}:void 0,l.$slots.loading?{name:"loading",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"loading",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"1"}:void 0,l.$slots.valid?{name:"valid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"valid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"2"}:void 0,l.$slots.invalid?{name:"invalid",fn:e.withCtx((()=>[e.renderSlot(l.$slots,"invalid",e.normalizeProps(e.guardReactiveProps(e.unref(G))))])),key:"3"}:void 0]),1032,["id"])],10,k))}})}));
|
|
@@ -5,6 +5,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
5
5
|
modifiers: globalThis.PropType<string | string[]>;
|
|
6
6
|
value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
|
|
7
7
|
modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
|
|
8
|
+
loading: BooleanConstructor;
|
|
9
|
+
loadingLabel: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
8
13
|
label: (StringConstructor | NumberConstructor)[];
|
|
9
14
|
readonly: BooleanConstructor;
|
|
10
15
|
disabled: BooleanConstructor;
|
|
@@ -32,6 +37,11 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
32
37
|
modifiers: globalThis.PropType<string | string[]>;
|
|
33
38
|
value: (StringConstructor | BooleanConstructor | NumberConstructor)[];
|
|
34
39
|
modelValue: (StringConstructor | BooleanConstructor | ObjectConstructor | NumberConstructor)[];
|
|
40
|
+
loading: BooleanConstructor;
|
|
41
|
+
loadingLabel: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: string;
|
|
44
|
+
};
|
|
35
45
|
label: (StringConstructor | NumberConstructor)[];
|
|
36
46
|
readonly: BooleanConstructor;
|
|
37
47
|
disabled: BooleanConstructor;
|
|
@@ -57,6 +67,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
57
67
|
}, {
|
|
58
68
|
disabled: boolean;
|
|
59
69
|
switch: boolean;
|
|
70
|
+
loading: boolean;
|
|
71
|
+
loadingLabel: string;
|
|
60
72
|
indeterminate: boolean;
|
|
61
73
|
readonly: boolean;
|
|
62
74
|
hintLabel: string;
|
|
@@ -65,7 +77,31 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
65
77
|
tabindex: string | number;
|
|
66
78
|
}>, {
|
|
67
79
|
default: (_: {
|
|
68
|
-
value:
|
|
80
|
+
value: any;
|
|
81
|
+
}) => any;
|
|
82
|
+
hint: (_: {
|
|
83
|
+
modelValue: any;
|
|
84
|
+
valid: boolean;
|
|
85
|
+
invalid: boolean;
|
|
86
|
+
loading: boolean;
|
|
87
|
+
}) => any;
|
|
88
|
+
loading: (_: {
|
|
89
|
+
modelValue: any;
|
|
90
|
+
valid: boolean;
|
|
91
|
+
invalid: boolean;
|
|
92
|
+
loading: boolean;
|
|
93
|
+
}) => any;
|
|
94
|
+
valid: (_: {
|
|
95
|
+
modelValue: any;
|
|
96
|
+
valid: boolean;
|
|
97
|
+
invalid: boolean;
|
|
98
|
+
loading: boolean;
|
|
99
|
+
}) => any;
|
|
100
|
+
invalid: (_: {
|
|
101
|
+
modelValue: any;
|
|
102
|
+
valid: boolean;
|
|
103
|
+
invalid: boolean;
|
|
104
|
+
loading: boolean;
|
|
69
105
|
}) => any;
|
|
70
106
|
}>;
|
|
71
107
|
export default _default;
|