1 |
- import{t as M,N,w as c,d as p,R as E,y as _,Z as P,a_ as S,c as w,E as A,am as D,D as I}from"./index.5f7ffb46.js";import{s as R,a as T,f as $,p as F}from"./utils.0f86fc1f.js";import{P as K}from"./index.de1f78a6.js";const[L]=M("time-picker"),V=a=>/^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(a),O=["hour","minute","second"],U=N({},R,{minHour:c(0),maxHour:c(23),minMinute:c(0),maxMinute:c(59),minSecond:c(0),maxSecond:c(59),minTime:{type:String,validator:V},maxTime:{type:String,validator:V},columnsType:{type:Array,default:()=>["hour","minute"]},filter:Function});var Z=p({name:L,props:U,emits:["confirm","cancel","change","update:modelValue"],setup(a,{emit:f,slots:k}){const n=E(a.modelValue),h=e=>{const i=e.split(":");return O.map((r,l)=>a.columnsType.includes(r)?i[l]:"00")},v=_(()=>{let{minHour:e,maxHour:i,minMinute:r,maxMinute:l,minSecond:x,maxSecond:g}=a;if(a.minTime||a.maxTime){const m={hour:0,minute:0,second:0};a.columnsType.forEach((s,d)=>{var u;m[s]=(u=n.value[d])!=null?u:0});const{hour:t,minute:o}=m;if(a.minTime){const[s,d,u]=h(a.minTime);e=s,r=+t<=+e?d:"00",x=+t<=+e&&+o<=+r?u:"00"}if(a.maxTime){const[s,d,u]=h(a.maxTime);i=s,l=+t>=+i?d:"59",g=+t>=+i&&+o>=+l?u:"59"}}return a.columnsType.map(m=>{const{filter:t,formatter:o}=a;switch(m){case"hour":return T(+e,+i,m,o,t,n.value);case"minute":return T(+r,+l,m,o,t,n.value);case"second":return T(+x,+g,m,o,t,n.value);default:throw new Error(`[Vant] DatePicker: unsupported columns type: ${m}`)}})});P(n,e=>{S(e,a.modelValue)||f("update:modelValue",e)}),P(()=>a.modelValue,e=>{e=$(e,v.value),S(e,n.value)||(n.value=e)},{immediate:!0});const C=(...e)=>f("change",...e),y=(...e)=>f("cancel",...e),H=(...e)=>f("confirm",...e);return()=>w(K,A({modelValue:n.value,"onUpdate:modelValue":e=>n.value=e,columns:v.value,onChange:C,onCancel:y,onConfirm:H},D(a,F)),k)}});const z=I(Z);export{z as T};
|