@ntohq/buefy-next
Version:
Lightweight UI components for Vue.js (v3) based on Bulma
3 lines (2 loc) • 8.97 kB
JavaScript
/*! Buefy v0.2.0 | MIT License | github.com/buefy/buefy */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Rate={},e.Vue)}(this,(function(e,t){"use strict";let l={defaultContainerElement:null,defaultIconPack:"mdi",defaultIconComponent:null,defaultIconPrev:"chevron-left",defaultIconNext:"chevron-right",defaultLocale:void 0,defaultDialogConfirmText:null,defaultDialogCancelText:null,defaultSnackbarDuration:3500,defaultSnackbarPosition:null,defaultToastDuration:2e3,defaultToastPosition:null,defaultNotificationDuration:2e3,defaultNotificationPosition:null,defaultTooltipType:"is-primary",defaultTooltipDelay:null,defaultTooltipCloseDelay:null,defaultSidebarDelay:null,defaultInputAutocomplete:"on",defaultDateFormatter:null,defaultDateParser:null,defaultDateCreator:null,defaultTimeCreator:null,defaultDayNames:null,defaultMonthNames:null,defaultFirstDayOfWeek:null,defaultUnselectableDaysOfWeek:null,defaultTimeFormatter:null,defaultTimeParser:null,defaultDatetimeFormatter:null,defaultDatetimeParser:null,defaultDatetimeCreator:null,defaultClockpickerHoursLabel:null,defaultClockpickerMinutesLabel:null,defaultColorFormatter:null,defaultColorParser:null,defaultModalCanCancel:["escape","x","outside","button"],defaultModalScroll:null,defaultDatepickerMobileNative:!0,defaultTimepickerMobileNative:!0,defaultTimepickerMobileModal:!0,defaultNoticeQueue:!0,defaultInputHasCounter:!0,defaultCompatFallthrough:!0,defaultTaginputHasCounter:!0,defaultUseHtml5Validation:!0,defaultDropdownMobileModal:!0,defaultFieldLabelPosition:null,defaultDatepickerYearsRange:[-100,10],defaultDatepickerNearbyMonthDays:!0,defaultDatepickerNearbySelectableMonthDays:!1,defaultDatepickerShowWeekNumber:!1,defaultDatepickerWeekNumberClickable:!1,defaultDatepickerMobileModal:!0,defaultTrapFocus:!0,defaultAutoFocus:!0,defaultButtonRounded:!1,defaultSwitchRounded:!0,defaultCarouselInterval:3500,defaultTabsExpanded:!1,defaultTabsAnimated:!0,defaultTabsType:null,defaultStatusIcon:!0,defaultProgrammaticPromise:!1,defaultLinkTags:["a","button","input","router-link","nuxt-link","n-link","RouterLink","NuxtLink","NLink"],defaultImageWebpFallback:null,defaultImageLazy:!0,defaultImageResponsive:!0,defaultImageRatio:null,defaultImageSrcsetFormatter:null,defaultBreadcrumbTag:"a",defaultBreadcrumbAlign:"is-left",defaultBreadcrumbSeparator:"",defaultBreadcrumbSize:"is-medium",customIconPacks:null};var a=Object.defineProperty,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,r=(e,t,l)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,s=(e,t)=>{for(var l in t||(t={}))o.call(t,l)&&r(e,l,t[l]);if(n)for(var l of n(t))i.call(t,l)&&r(e,l,t[l]);return e};const u=e=>"object"==typeof e&&!Array.isArray(e),c=(e,t,l=!1)=>{if(l||!Object.assign){const a=l=>u(t[l])&&null!==e&&Object.prototype.hasOwnProperty.call(e,l)&&u(e[l]),n=Object.getOwnPropertyNames(t).map((n=>({[n]:a(n)?c(e[n],t[n]||{},l):t[n]}))).reduce(((e,t)=>s(s({},e),t)),{});return s(s({},e),n)}return Object.assign(e,t)},d=c,f={sizes:{default:"mdi-24px","is-small":null,"is-medium":"mdi-36px","is-large":"mdi-48px"},iconPrefix:"mdi-"},m=()=>{const e=l&&l.defaultIconComponent?"":"fa-";return{sizes:{default:null,"is-small":null,"is-medium":e+"lg","is-large":e+"2x"},iconPrefix:e,internalIcons:{information:"info-circle",alert:"exclamation-triangle","alert-circle":"exclamation-circle","chevron-right":"angle-right","chevron-left":"angle-left","chevron-down":"angle-down","eye-off":"eye-slash","menu-down":"caret-down","menu-up":"caret-up","close-circle":"times-circle"}}};var p=()=>{let e={mdi:f,fa:m(),fas:m(),far:m(),fad:m(),fab:m(),fal:m(),"fa-solid":m(),"fa-regular":m(),"fa-light":m(),"fa-thin":m(),"fa-duotone":m(),"fa-brands":m()};return l&&l.customIconPacks&&(e=d(e,l.customIconPacks,!0)),e},h=(e,t)=>{const l=e.__vccOpts||e;for(const[e,a]of t)l[e]=a;return l};var k=h(t.defineComponent({name:"BIcon",props:{type:[String,Object],component:String,pack:String,icon:{type:String,required:!0},size:String,customSize:String,customClass:String,both:Boolean},computed:{iconConfig(){return p()[this.newPack]},iconPrefix(){return this.iconConfig&&this.iconConfig.iconPrefix?this.iconConfig.iconPrefix:""},newIcon(){return`${this.iconPrefix}${this.getEquivalentIconOf(this.icon)}`},newPack(){return this.pack||l.defaultIconPack},newType(){if(!this.type)return;let e=[];if("string"==typeof this.type)e=this.type.split("-");else for(const t in this.type)if(this.type[t]){e=t.split("-");break}if(e.length<=1)return;const[,...t]=e;return`has-text-${t.join("-")}`},newCustomSize(){return this.customSize||this.customSizeByPack},customSizeByPack(){if(this.iconConfig&&this.iconConfig.sizes){if(this.size&&void 0!==this.iconConfig.sizes[this.size])return this.iconConfig.sizes[this.size];if(this.iconConfig.sizes.default)return this.iconConfig.sizes.default}return null},useIconComponent(){return this.component||l.defaultIconComponent}},methods:{getEquivalentIconOf(e){if(!this.both)return e;if(null==this.iconConfig)return e;const t=this.iconConfig;return t&&t.internalIcons&&t.internalIcons[e]?t.internalIcons[e]:e}}}),[["render",function(e,l,a,n,o,i){return t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["icon",[e.newType,e.size]])},[e.useIconComponent?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.useIconComponent),{key:1,icon:[e.newPack,e.newIcon],size:e.newCustomSize,class:t.normalizeClass([e.customClass])},null,8,["icon","size","class"])):(t.openBlock(),t.createElementBlock("i",{key:0,class:t.normalizeClass([e.newPack,e.newIcon,e.newCustomSize,e.customClass])},null,2))],2)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/icon/Icon.vue"]]);const b=t.defineComponent({name:"BRate",components:{BIcon:k},props:{modelValue:{type:Number,default:0},max:{type:Number,default:5},icon:{type:String,default:"star"},iconPack:String,size:String,spaced:Boolean,rtl:Boolean,disabled:Boolean,showScore:Boolean,showText:Boolean,customText:String,texts:Array,locale:{type:[String,Array],default:()=>l.defaultLocale}},emits:{change:e=>!0,"update:modelValue":e=>!0},data(){return{newValue:this.modelValue,hoverValue:0}},computed:{halfStyle(){return`width:${this.valueDecimal}%`},showMe(){let e="";return this.showScore?(e=this.disabled?this.modelValue.toString():this.newValue.toString(),e=0===Number(e)?"":new Intl.NumberFormat(this.locale).format(this.modelValue)):this.showText&&this.texts&&(e=this.texts[Math.ceil(this.newValue)-1]),e},valueDecimal(){return 100*this.modelValue-100*Math.floor(this.modelValue)}},watch:{modelValue(e){this.newValue=e}},methods:{resetNewValue(){this.disabled||(this.hoverValue=0)},previewRate(e,t){this.disabled||(this.hoverValue=e,t.stopPropagation())},confirmValue(e){this.disabled||(this.newValue=e,this.$emit("change",this.newValue),this.$emit("update:modelValue",this.newValue))},checkHalf(e){return this.disabled&&this.valueDecimal>0&&e-1<this.modelValue&&e>this.modelValue},rateClass(e){let t="";return e<=(0!==this.hoverValue?this.hoverValue:this.newValue)?t="set-on":this.disabled&&Math.ceil(this.modelValue)===e&&(t="set-half"),t}}});const g=["onMousemove","onClick"],y={key:0};var C=h(b,[["render",function(e,l,a,n,o,i){const r=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["rate",{"is-disabled":e.disabled,"is-spaced":e.spaced,"is-rtl":e.rtl}])},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(e.max,((a,n)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["rate-item",e.rateClass(a)]),key:n,onMousemove:t=>e.previewRate(a,t),onMouseleave:l[0]||(l[0]=(...t)=>e.resetNewValue&&e.resetNewValue(...t)),onClick:t.withModifiers((t=>e.confirmValue(a)),["prevent"])},[t.createVNode(r,{pack:e.iconPack,icon:e.icon,size:e.size},null,8,["pack","icon","size"]),e.checkHalf(a)?(t.openBlock(),t.createBlock(r,{key:0,class:"is-half",pack:e.iconPack,icon:e.icon,size:e.size,style:t.normalizeStyle(e.halfStyle)},null,8,["pack","icon","size","style"])):t.createCommentVNode("v-if",!0)],42,g)))),128)),e.showText||e.showScore||e.customText?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["rate-text",e.size])},[t.createElementVNode("span",null,t.toDisplayString(e.showMe),1),e.customText&&!e.showText?(t.openBlock(),t.createElementBlock("span",y,t.toDisplayString(e.customText),1)):t.createCommentVNode("v-if",!0)],2)):t.createCommentVNode("v-if",!0)],2)}],["__file","/home/runner/work/buefy-next/buefy-next/packages/buefy-next/src/components/rate/Rate.vue"]]);const w={install(e){((e,t,l)=>{const a=l||t.name;if(null==a)throw new Error("Buefy.registerComponent: missing component name");e.component(a,t)})(e,C)}};e.BRate=C,e.default=w,Object.defineProperty(e,"__esModule",{value:!0})}));