UNPKG

@nextcloud/vue

Version:
2 lines (1 loc) 2.86 kB
var x=require("../assets/index10.css");const f=require("../chunks/_plugin-vue2_normalizer-764a4c12.cjs");const y={name:"NcButton",props:{alignment:{type:String,default:"center",validator:t=>["start","start-reverse","center","center-reverse","end","end-reverse"].includes(t)},disabled:{type:Boolean,default:!1},type:{type:String,validator(t){return["primary","secondary","tertiary","tertiary-no-background","tertiary-on-primary","error","warning","success"].indexOf(t)!==-1},default:"secondary"},nativeType:{type:String,validator(t){return["submit","reset","button"].indexOf(t)!==-1},default:"button"},wide:{type:Boolean,default:!1},ariaLabel:{type:String,default:null},href:{type:String,default:null},download:{type:String,default:null},to:{type:[String,Object],default:null},exact:{type:Boolean,default:!1},ariaHidden:{type:Boolean,default:null},pressed:{type:Boolean,default:null}},emits:["update:pressed","click"],computed:{realType(){return this.pressed?"primary":this.pressed===!1&&this.type==="primary"?"secondary":this.type},flexAlignment(){return this.alignment.split("-")[0]},isReverseAligned(){return this.alignment.includes("-")}},render(t){var a,o,s,u,d;const e=(u=(s=(o=(a=this.$slots.default)==null?void 0:a[0])==null?void 0:o.text)==null?void 0:s.trim)==null?void 0:u.call(s),n=!!e,i=(d=this.$slots)==null?void 0:d.icon;!e&&!this.ariaLabel&&console.warn("You need to fill either the text or the ariaLabel props in the button component.",{text:e,ariaLabel:this.ariaLabel},this);const l=({navigate:r,isActive:p,isExactActive:c}={})=>t(this.to||!this.href?"button":"a",{class:["button-vue",{"button-vue--icon-only":i&&!n,"button-vue--text-only":n&&!i,"button-vue--icon-and-text":i&&n,[`button-vue--vue-${this.realType}`]:this.realType,"button-vue--wide":this.wide,[`button-vue--${this.flexAlignment}`]:this.flexAlignment!=="center","button-vue--reverse":this.isReverseAligned,active:p,"router-link-exact-active":c}],attrs:{"aria-label":this.ariaLabel,"aria-pressed":this.pressed,disabled:this.disabled,type:this.href?null:this.nativeType,role:this.href?"button":null,href:!this.to&&this.href?this.href:null,target:!this.to&&this.href?"_self":null,rel:!this.to&&this.href?"nofollow noreferrer noopener":null,download:!this.to&&this.href&&this.download?this.download:null,...this.$attrs},on:{...this.$listeners,click:h=>{typeof this.pressed=="boolean"&&this.$emit("update:pressed",!this.pressed),this.$emit("click",h),r==null||r(h)}}},[t("span",{class:"button-vue__wrapper"},[i?t("span",{class:"button-vue__icon",attrs:{"aria-hidden":this.ariaHidden}},[this.$slots.icon]):null,n?t("span",{class:"button-vue__text"},[e]):null])]);return this.to?t("router-link",{props:{custom:!0,to:this.to,exact:this.exact},scopedSlots:{default:l}}):l()}},b=null,v=null;var m=f.normalizeComponent(y,b,v,!1,null,"bb88e612",null,null);const g=m.exports;module.exports=g;