niucloud-admin/niucloud/public/wap/assets/u-steps.e3cbd6f9.js
2023-11-15 15:57:04 +08:00

2 lines
5.7 KiB
JavaScript

import{A as t,B as e,C as a,q as s,t as i,i as r,j as n,w as o,D as p,p as c,m as l,k as u,F as d,G as h,H as m,x as _,I as D}from"./index-faf5e276.js";import{_ as f}from"./u-icon.71776381.js";import{_ as v}from"./u--text.c8005a3e.js";import{_ as C}from"./_plugin-vue_export-helper.1b428a4d.js";const x=C({name:"u-steps-item",mixins:[e,a,{props:{title:{type:[String,Number],default:t.stepsItem.title},desc:{type:[String,Number],default:t.stepsItem.desc},iconSize:{type:[String,Number],default:t.stepsItem.iconSize},error:{type:Boolean,default:t.stepsItem.error}}}],data:()=>({index:0,childLength:0,showLine:!1,size:{height:0,width:0},parentData:{direction:"row",current:0,activeColor:"",inactiveColor:"",activeIcon:"",inactiveIcon:"",dot:!1}}),watch:{parentData(t,e){}},created(){this.init()},computed:{lineStyle(){var t,e;const a={};return"row"===this.parentData.direction?(a.width=this.size.width+"px",a.left=this.size.width/2+"px"):a.height=this.size.height+"px",a.backgroundColor=(null==(e=null==(t=this.parent.children)?void 0:t[this.index+1])?void 0:e.error)?uni.$u.color.error:this.index<this.parentData.current?this.parentData.activeColor:this.parentData.inactiveColor,a},statusClass(){const{index:t,error:e}=this,{current:a}=this.parentData;return a==t?!0===e?"error":"process":e?"error":a>t?"finish":"wait"},statusColor(){let t="";switch(this.statusClass){case"finish":t=this.parentData.activeColor;break;case"error":t=uni.$u.color.error;break;case"process":t=this.parentData.dot?this.parentData.activeColor:"transparent";break;default:t=this.parentData.inactiveColor}return t},contentStyle(){const t={};return"column"===this.parentData.direction?(t.marginLeft=this.parentData.dot?"2px":"6px",t.marginTop=this.parentData.dot?"0px":"6px"):(t.marginTop=this.parentData.dot?"2px":"6px",t.marginLeft=this.parentData.dot?"2px":"6px"),t}},mounted(){this.parent&&this.parent.updateFromChild(),uni.$u.sleep().then((()=>{this.getStepsItemRect()}))},methods:{init(){if(this.updateParentData(),!this.parent)return uni.$u.error("u-steps-item必须要搭配u-steps组件使用");this.index=this.parent.children.indexOf(this),this.childLength=this.parent.children.length},updateParentData(){this.getParentData("u-steps")},updateFromParent(){this.init()},getStepsItemRect(){this.$uGetRect(".u-steps-item").then((t=>{this.size=t}))}}},[["render",function(t,e,a,C,x,y){const g=_,w=s(i("u-icon"),f),I=D,S=s(i("u--text"),v);return r(),n(g,{class:p(["u-steps-item",[`u-steps-item--${x.parentData.direction}`]]),ref:"u-steps-item"},{default:o((()=>[x.index+1<x.childLength?(r(),n(g,{key:0,class:p(["u-steps-item__line",[`u-steps-item__line--${x.parentData.direction}`]]),style:c([y.lineStyle])},null,8,["class","style"])):l("v-if",!0),u(g,{class:p(["u-steps-item__wrapper",[`u-steps-item__wrapper--${x.parentData.direction}`,x.parentData.dot&&`u-steps-item__wrapper--${x.parentData.direction}--dot`]])},{default:o((()=>[d(t.$slots,"icon",{},(()=>[x.parentData.dot?(r(),n(g,{key:0,class:"u-steps-item__wrapper__dot",style:c({backgroundColor:y.statusColor})},null,8,["style"])):x.parentData.activeIcon||x.parentData.inactiveIcon?(r(),n(g,{key:1,class:"u-steps-item__wrapper__icon"},{default:o((()=>[u(w,{name:x.index<=x.parentData.current?x.parentData.activeIcon:x.parentData.inactiveIcon,size:t.iconSize,color:x.index<=x.parentData.current?x.parentData.activeColor:x.parentData.inactiveColor},null,8,["name","size","color"])])),_:1})):(r(),n(g,{key:2,style:c({backgroundColor:"process"===y.statusClass?x.parentData.activeColor:"transparent",borderColor:y.statusColor}),class:"u-steps-item__wrapper__circle"},{default:o((()=>["process"===y.statusClass||"wait"===y.statusClass?(r(),n(I,{key:0,class:"u-steps-item__wrapper__circle__text",style:c({color:x.index==x.parentData.current?"#ffffff":x.parentData.inactiveColor})},{default:o((()=>[h(m(x.index+1),1)])),_:1},8,["style"])):(r(),n(w,{key:1,color:"error"===y.statusClass?"error":x.parentData.activeColor,size:"12",name:"error"===y.statusClass?"close":"checkmark"},null,8,["color","name"]))])),_:1},8,["style"]))]),!0)])),_:3},8,["class"]),u(g,{class:p(["u-steps-item__content",[`u-steps-item__content--${x.parentData.direction}`]]),style:c([y.contentStyle])},{default:o((()=>[u(S,{text:t.title,type:x.parentData.current==x.index?"main":"content",lineHeight:"20px",size:x.parentData.current==x.index?14:13},null,8,["text","type","size"]),d(t.$slots,"desc",{},(()=>[u(S,{text:t.desc,type:"tips",size:"12"},null,8,["text"])]),!0)])),_:3},8,["class","style"]),l(' <view\n\t\t class="u-steps-item__line"\n\t\t v-if="showLine && parentData.direction === \'column\'"\n\t\t\t:class="[`u-steps-item__line--${parentData.direction}`]"\n\t\t :style="[lineStyle]"\n\t\t></view> ')])),_:3},8,["class"])}],["__scopeId","data-v-45a927e1"]]);const y=C({name:"u-steps",mixins:[e,a,{props:{direction:{type:String,default:t.steps.direction},current:{type:[String,Number],default:t.steps.current},activeColor:{type:String,default:t.steps.activeColor},inactiveColor:{type:String,default:t.steps.inactiveColor},activeIcon:{type:String,default:t.steps.activeIcon},inactiveIcon:{type:String,default:t.steps.inactiveIcon},dot:{type:Boolean,default:t.steps.dot}}}],data:()=>({}),watch:{children(){this.updateChildData()},parentData(){this.updateChildData()}},computed:{parentData(){return[this.current,this.direction,this.activeColor,this.inactiveColor,this.activeIcon,this.inactiveIcon,this.dot]}},methods:{updateChildData(){this.children.map((t=>{uni.$u.test.func((t||{}).updateFromParent())&&t.updateFromParent()}))},updateFromChild(){this.updateChildData()}},created(){this.children=[]}},[["render",function(t,e,a,s,i,c){const l=_;return r(),n(l,{class:p(["u-steps",[`u-steps--${t.direction}`]])},{default:o((()=>[d(t.$slots,"default",{},void 0,!0)])),_:3},8,["class"])}],["__scopeId","data-v-9d7fe081"]]);export{x as _,y as a};