uni-segmented-control.e937152d.js 1.95 KB
import{o as t,c as e,w as n,j as r,F as s,k as o,v as l,J as c,b as a,d as u,t as d,q as i,i as y}from"./index-faed4152.js";import{_ as m}from"./_plugin-vue_export-helper.1b428a4d.js";const p=m({name:"UniSegmentedControl",emits:["clickItem"],props:{current:{type:Number,default:0},values:{type:Array,default:()=>[]},activeColor:{type:String,default:"#2979FF"},styleType:{type:String,default:"button"}},data:()=>({currentIndex:0}),watch:{current(t){t!==this.currentIndex&&(this.currentIndex=t)}},created(){this.currentIndex=this.current},methods:{_onClick(t){this.currentIndex!==t&&(this.currentIndex=t,this.$emit("clickItem",{currentIndex:t}))}}},[["render",function(m,p,_,x,b,g){const f=i,I=y;return t(),e(I,{class:l([["text"===_.styleType?"segmented-control--text":"segmented-control--button"],"segmented-control"]),style:c({borderColor:"text"===_.styleType?"":_.activeColor})},{default:n((()=>[(t(!0),r(s,null,o(_.values,((r,s)=>(t(),e(I,{class:l([["text"===_.styleType?"":"segmented-control__item--button",s===b.currentIndex&&"button"===_.styleType?"segmented-control__item--button--active":"",0===s&&"button"===_.styleType?"segmented-control__item--button--first":"",s===_.values.length-1&&"button"===_.styleType?"segmented-control__item--button--last":""],"segmented-control__item"]),key:s,style:c({backgroundColor:s===b.currentIndex&&"button"===_.styleType?_.activeColor:"",borderColor:s===b.currentIndex&&"text"===_.styleType||"button"===_.styleType?_.activeColor:"transparent"}),onClick:t=>g._onClick(s)},{default:n((()=>[a(I,null,{default:n((()=>[a(f,{style:c({color:s===b.currentIndex?"text"===_.styleType?_.activeColor:"#fff":"text"===_.styleType?"#000":_.activeColor}),class:l(["segmented-control__text","text"===_.styleType&&s===b.currentIndex?"segmented-control__item--text":""])},{default:n((()=>[u(d(r),1)])),_:2},1032,["style","class"])])),_:2},1024)])),_:2},1032,["class","style","onClick"])))),128))])),_:1},8,["class","style"])}],["__scopeId","data-v-bda4a78b"]]);export{p as _};