UNPKG

ll-package

Version:

2 lines (1 loc) 2.71 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),M=require("../../../hooks/useDesign.js"),$=require("../../../../node_modules/ant-design-vue/es/time-picker/dayjs.js"),k=e.defineComponent({name:"LlTimePicker"}),w=e.defineComponent({...k,props:{value:{},format:{default:"HH:mm:ss"},startTime:{default:null},endTime:{default:null}},emits:["update:value","change"],setup(T,{emit:h}){const s=T,p=h,b=e.useAttrs(),m=e.ref(""),{prefixCls:g}=M.useDesign("time-picker"),l=e.computed(()=>s.startTime?s.startTime.split(":"):[]),d=e.computed(()=>s.endTime?s.endTime.split(":"):[]),S=e.computed(()=>({...e.unref(b),format:s.format,valueFormat:s.format,showNow:!s.startTime&&!s.endTime,disabledTime:()=>({disabledHours:()=>{const{startTime:t,endTime:f}=s;if(!t&&!f)return[];const i=[];if(t){const o=Number(e.unref(l)[0]);for(let r=0;r<o;r++)i.push(r)}if(f){const o=Number(e.unref(d)[0]);for(let r=0;r<24;r++)r>o&&i.push(r)}return i},disabledMinutes:t=>{const{startTime:f,endTime:i}=s;if(!f&&!i)return[];const o=[];if(f){const r=Number(e.unref(l)[0]),a=Number(e.unref(l)[1]);if(t<r){for(let n=0;n<60;n++)o.push(n);return o}if(t===r)for(let n=0;n<a;n++)o.push(n)}if(i){const r=Number(e.unref(d)[0]),a=Number(e.unref(d)[1]);if(t===r){for(let n=0;n<60;n++)n>a&&o.push(n);return o}if(t>r){for(let n=0;n<60;n++)o.push(n);return o}}return o},disabledSeconds:(t,f)=>{const{startTime:i,endTime:o}=s;if(!i&&!o||s.format==="HH:mm")return[];const r=[],a=v(t)+v(f);if(i){const n=e.unref(l)[0]+e.unref(l)[1],c=e.unref(l)[2]?Number(e.unref(l)[2]):0;if(a<n){for(let u=0;u<60;u++)r.push(u);return r}if(a===n)for(let u=0;u<c;u++)r.push(u)}if(o){const n=e.unref(d)[0]+e.unref(d)[1],c=e.unref(d)[2]?Number(e.unref(d)[2]):0;if(a===n){for(let u=0;u<60;u++)u>c&&r.push(u);return r}if(a>n){for(let u=0;u<60;u++)r.push(u);return r}}return r}})}));e.watch(()=>s.value,t=>{H(t)},{immediate:!0});function H(t){m.value=t}function N(t){p("update:value",t),p("change",t)}function v(t){return new RegExp(/^\d$/g).test(t)?`0${t}`:t.toString()}return(t,f)=>(e.openBlock(),e.createBlock(e.unref($.default),e.mergeProps({class:e.unref(g)},S.value,{value:m.value,"onUpdate:value":f[0]||(f[0]=i=>m.value=i),onChange:N}),e.createSlots({_:2},[t.$slots.clearIcon?{name:"clearIcon",fn:e.withCtx(()=>[e.renderSlot(t.$slots,"clearIcon",{},void 0,!0)]),key:"0"}:void 0,t.$slots.renderExtraFooter?{name:"renderExtraFooter",fn:e.withCtx(()=>[e.renderSlot(t.$slots,"renderExtraFooter",{},void 0,!0)]),key:"1"}:void 0,t.$slots.suffixIcon?{name:"suffixIcon",fn:e.withCtx(()=>[e.renderSlot(t.$slots,"suffixIcon",{},void 0,!0)]),key:"2"}:void 0]),1040,["class","value"]))}});exports.default=w;