@meleon/uni-ui
Version:
A uniapp components library written in vue3 and typescript
1 lines • 570 B
JavaScript
import{toRefs,computed,watch}from"vue";import{convertDate2Dayjs,isUndefined}from"@meleon/uni-ui/utils";import{useState}from"../useState";export default function useTimeState(e){const{modelValue:a,defaultModelValue:t,format:u}=toRefs(e),l=computed((()=>convertDate2Dayjs(a.value,u.value))),o=computed((()=>convertDate2Dayjs(t.value,u.value))),[n,s]=useState(isUndefined(l.value)?isUndefined(o.value)?void 0:o.value:l.value),v=computed((()=>l.value||n.value)),[d,i]=useState(v.value);return watch(v,(e=>{i(e)})),{localValue:v,setLocalValue:s,panelValue:d,setPanelValue:i}}