import{az as t,b8 as s,o as e,c as i,w as o,t as n,R as a,a0 as h,a2 as l,C as d,F as c,D as u,v as r,x as m,A as p,i as b,b9 as v,ba as f}from"./index-DL8B2Mxu.js";import{_ as w}from"./_plugin-vue_export-helper.BCo6x5W8.js";const x=w({name:"u-swipe-action",emits:["click","content-click","open","close"],props:{index:{type:[Number,String],default:""},btnWidth:{type:[String,Number],default:180},disabled:{type:Boolean,default:!1},show:{type:Boolean,default:!1},bgColor:{type:String,default:"#ffffff"},vibrateShort:{type:Boolean,default:!1},options:{type:Array,default:()=>[]}},watch:{show:{immediate:!0,handler(t,s){t?this.open():this.close()}}},data(){return{moveX:0,scrollX:0,status:!1,movableAreaWidth:0,elId:this.$u.guid(),showBtn:!1}},computed:{movableViewWidth(){return this.movableAreaWidth+this.allBtnWidth+"px"},innerBtnWidth(){return t(this.btnWidth)},allBtnWidth(){return t(this.btnWidth)*this.options.length},btnStyle(){return t=>(t.width=this.btnWidth+"rpx",t)}},mounted(){this.getActionRect()},methods:{btnClick(t){this.status=!1,this.$emit("click",this.index,t)},change(t){this.scrollX=t.detail.x},close(){this.moveX=0,this.status=!1},open(){this.disabled||(this.moveX=-this.allBtnWidth,this.status=!0)},touchend(){this.moveX=this.scrollX,this.$nextTick((function(){0==this.status?this.scrollX<=-this.allBtnWidth/4?(this.moveX=-this.allBtnWidth,this.status=!0,this.emitOpenEvent(),this.vibrateShort&&s()):(this.moveX=0,this.status=!1,this.emitCloseEvent()):this.scrollX>3*-this.allBtnWidth/4?(this.moveX=0,this.$nextTick((()=>{this.moveX=101})),this.status=!1,this.emitCloseEvent()):(this.moveX=-this.allBtnWidth,this.status=!0,this.emitOpenEvent())}))},emitOpenEvent(){this.$emit("open",this.index)},emitCloseEvent(){this.$emit("close",this.index)},touchstart(){},getActionRect(){this.$uGetRect(".u-swipe-action").then((t=>{this.movableAreaWidth=t.width,this.$nextTick((()=>{this.showBtn=!0}))}))},contentClick(){1==this.status&&(this.status="close",this.moveX=0),this.$emit("content-click",this.index)}}},[["render",function(t,s,w,x,y,k){const W=b,C=v,X=f;return e(),i(W,{class:""},{default:o((()=>[n(X,{class:"u-swipe-action",style:a({backgroundColor:w.bgColor})},{default:o((()=>[n(C,{class:"u-swipe-view",onChange:k.change,onTouchend:k.touchend,onTouchstart:k.touchstart,direction:"horizontal",disabled:w.disabled,x:y.moveX,style:a({width:k.movableViewWidth?k.movableViewWidth:"100%"})},{default:o((()=>[n(W,{class:"u-swipe-content",onClick:h(k.contentClick,["stop"])},{default:o((()=>[l(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick"]),y.showBtn?(e(!0),d(c,{key:0},u(w.options,((t,s)=>(e(),i(W,{class:"u-swipe-del",onClick:h((t=>k.btnClick(s)),["stop"]),style:a([k.btnStyle(t.style)]),key:s},{default:o((()=>[n(W,{class:"u-btn-text"},{default:o((()=>[r(m(t.text),1)])),_:2},1024)])),_:2},1032,["onClick","style"])))),128)):p("",!0)])),_:3},8,["onChange","onTouchend","onTouchstart","disabled","x","style"])])),_:3},8,["style"])])),_:3})}],["__scopeId","data-v-46aea3a3"]]);export{x as _};
