import{_ as t}from"./u-icon.CWuTHPBs.js";import{v as e,o as i,d as o,w as n,L as l,e as s,I as a,K as r,J as u,x as d,_ as c,X as h,i as p,a3 as m,H as _,f,t as y,h as g}from"./index-Du27JD75.js";import{r as v}from"./uni-app.es.BZ3Oj9NS.js";import{_ as C,a as k}from"./u-cell-group.BqcJACNe.js";import{_ as b}from"./_plugin-vue_export-helper.BCo6x5W8.js";const $=b({name:"u-dropdown-item",emits:["update:modelValue","input","change"],props:{value:{type:[Number,String,Array],default:""},modelValue:{type:[Number,String,Array],default:""},title:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},disabled:{type:Boolean,default:!1},height:{type:[Number,String],default:"auto"}},data:()=>({active:!1,activeColor:"#2979ff",inactiveColor:"#606266"}),computed:{valueCom(){return this.modelValue},propsChange(){return`${this.title}-${this.disabled}`}},watch:{propsChange(t){this.parent&&this.parent.init()}},created(){this.parent=!1},methods:{init(){let t=this.$u.$parent.call(this,"u-dropdown");if(t){this.parent=t,this.activeColor=t.activeColor,this.inactiveColor=t.inactiveColor,t.children.find((t=>this===t))||t.children.push(this),1==t.children.length&&(this.active=!0),t.menuList.push({title:this.title,disabled:this.disabled})}},cellClick(t){this.$emit("input",t),this.$emit("update:modelValue",t),this.parent.close(),this.$emit("change",t)}},mounted(){this.init()}},[["render",function(_,f,y,g,b,$){const w=v(e("u-icon"),t),S=v(e("u-cell-item"),C),x=v(e("u-cell-group"),k),I=p,z=m;return b.active?(i(),o(I,{key:0,class:"u-dropdown-item",onTouchmove:h((()=>{}),["stop","prevent"]),onClick:h((()=>{}),["stop","prevent"])},{default:n((()=>[_.$slots.default||_.$slots.$default?c(_.$slots,"default",{key:1},void 0,!0):(i(),o(z,{key:0,"scroll-y":"true",style:l({height:_.$u.addUnit(y.height)})},{default:n((()=>[s(I,{class:"u-dropdown-item__options"},{default:n((()=>[s(x,null,{default:n((()=>[(i(!0),a(r,null,u(y.options,((t,e)=>(i(),o(S,{onClick:e=>$.cellClick(t.value),arrow:!1,title:t.label,key:e,"title-style":{color:y.value===t.value?b.activeColor:b.inactiveColor}},{default:n((()=>[$.valueCom===t.value?(i(),o(w,{key:0,name:"checkbox-mark",color:b.activeColor,size:"32"},null,8,["color"])):d("",!0)])),_:2},1032,["onClick","title","title-style"])))),128))])),_:1})])),_:1})])),_:1},8,["style"]))])),_:3})):d("",!0)}],["__scopeId","data-v-a2b38bc1"]]);const w=b({name:"u-dropdown",emits:["open","close"],props:{activeColor:{type:String,default:"#2979ff"},inactiveColor:{type:String,default:"#606266"},closeOnClickMask:{type:Boolean,default:!0},closeOnClickSelf:{type:Boolean,default:!0},duration:{type:[Number,String],default:300},height:{type:[Number,String],default:80},borderBottom:{type:Boolean,default:!1},titleSize:{type:[Number,String],default:28},borderRadius:{type:[Number,String],default:0},menuIcon:{type:String,default:"arrow-down"},menuIconSize:{type:[Number,String],default:26}},data:()=>({showDropdown:!0,menuList:[],active:!1,current:99999,contentStyle:{zIndex:-1,opacity:0},highlightIndex:99999,contentHeight:0}),computed:{popupStyle(){let t={};return t.transform=`translateY(${this.active?0:"-100%"})`,t["transition-duration"]=this.duration/1e3+"s",t.borderRadius=`0 0 ${this.$u.addUnit(this.borderRadius)} ${this.$u.addUnit(this.borderRadius)}`,t}},created(){this.children=[]},mounted(){this.getContentHeight()},methods:{init(){this.menuList=[],this.children.map((t=>{t.init()}))},menuClick(t){if(!this.menuList[t].disabled)return t===this.current&&this.closeOnClickSelf?(this.close(),void setTimeout((()=>{this.children[t].active=!1}),this.duration)):void this.open(t)},open(t){this.contentStyle={zIndex:11},this.active=!0,this.current=t,this.children.map(((e,i)=>{e.active=t==i})),this.$emit("open",this.current)},close(){this.$emit("close",this.current),this.active=!1,this.current=99999,this.contentStyle={zIndex:-1,opacity:0}},maskClick(){this.closeOnClickMask&&this.close()},highlight(t){this.highlightIndex=void 0!==t?t:99999},getContentHeight(){let t=this.$u.sys().windowHeight;this.$uGetRect(".u-dropdown__menu").then((e=>{this.contentHeight=t-e.bottom}))}}},[["render",function(d,m,C,k,b,$){const w=g,S=v(e("u-icon"),t),x=p;return i(),o(x,{class:"u-dropdown"},{default:n((()=>[s(x,{class:_(["u-dropdown__menu",{"u-border-bottom":C.borderBottom}]),style:l({height:d.$u.addUnit(C.height)})},{default:n((()=>[(i(!0),a(r,null,u(b.menuList,((t,e)=>(i(),o(x,{class:"u-dropdown__menu__item",key:e,onClick:h((t=>$.menuClick(e)),["stop"])},{default:n((()=>[s(x,{class:"u-flex"},{default:n((()=>[s(w,{class:"u-dropdown__menu__item__text",style:l({color:t.disabled?"#c0c4cc":e===b.current||b.highlightIndex==e?C.activeColor:C.inactiveColor,fontSize:d.$u.addUnit(C.titleSize)})},{default:n((()=>[f(y(t.title),1)])),_:2},1032,["style"]),s(x,{class:_(["u-dropdown__menu__item__arrow",{"u-dropdown__menu__item__arrow--rotate":e===b.current}])},{default:n((()=>[s(S,{"custom-style":{display:"flex"},name:C.menuIcon,size:d.$u.addUnit(C.menuIconSize),color:e===b.current||b.highlightIndex==e?C.activeColor:"#c0c4cc"},null,8,["name","size","color"])])),_:2},1032,["class"])])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1},8,["style","class"]),s(x,{class:"u-dropdown__content",style:l([b.contentStyle,{transition:`opacity ${C.duration/1e3}s linear`,top:d.$u.addUnit(C.height),height:b.contentHeight+"px"}]),onClick:$.maskClick,onTouchmove:m[1]||(m[1]=h((()=>{}),["stop","prevent"]))},{default:n((()=>[s(x,{onClick:m[0]||(m[0]=h((()=>{}),["stop","prevent"])),class:"u-dropdown__content__popup",style:l([$.popupStyle])},{default:n((()=>[c(d.$slots,"default",{},void 0,!0)])),_:3},8,["style"]),s(x,{class:"u-dropdown__content__mask"})])),_:3},8,["style","onClick"])])),_:3})}],["__scopeId","data-v-8e6b359a"]]);export{$ as _,w as a};