huiyi-time 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{huiyi-time/huiyi-time.es.js → huiyi-time.es.js} +4 -4
- package/{dist/huiyi-time.umd.js → huiyi-time.umd.js} +1 -1
- package/package.json +16 -26
- package/style.css +1 -0
- package/README.md +0 -10
- package/babel.config.js +0 -5
- package/dist/huiyi-time.es.js +0 -670
- package/dist/style.css +0 -1
- package/huiyi-time/favicon.ico +0 -0
- package/huiyi-time/huiyi-time.umd.js +0 -1
- package/huiyi-time/index.html +0 -17
- package/huiyi-time/package.json +0 -20
- package/huiyi-time/style.css +0 -1
- package/huiyi-time-0.1.12.tgz +0 -0
- package/jsconfig.json +0 -19
- package/vite.config.js +0 -43
- package/vue.config.js +0 -25
- /package/{dist/favicon.ico → favicon.ico} +0 -0
- /package/{dist/index.html → index.html} +0 -0
|
@@ -4,7 +4,7 @@ const O = (e, t) => {
|
|
|
4
4
|
for (const [r, l] of t)
|
|
5
5
|
n[r] = l;
|
|
6
6
|
return n;
|
|
7
|
-
},
|
|
7
|
+
}, b = {
|
|
8
8
|
name: "TimeComponentsUp",
|
|
9
9
|
props: {
|
|
10
10
|
initTime: {
|
|
@@ -418,7 +418,7 @@ const O = (e, t) => {
|
|
|
418
418
|
this.showPanel = !0, this.handleListener();
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
},
|
|
421
|
+
}, P = {
|
|
422
422
|
class: "container",
|
|
423
423
|
id: "content"
|
|
424
424
|
}, x = { class: "content" }, T = { class: "huiyi-time-input-section" }, R = { class: "huiyi-time-input-field" }, A = { class: "huiyi-time-panel-body" }, E = { class: "huiyi-time-quick-options" }, q = { class: "option-group" }, Q = { class: "option-group" }, L = ["onClick"], B = { class: "option-group" }, U = ["onClick"], W = { class: "option-group" }, N = ["onClick"], K = { class: "option-group" }, $ = ["onClick"], z = { class: "huiyi-time-panels-container" }, j = { class: "huiyi-time-date-panel" }, G = { class: "calendar-section" }, H = { class: "huiyi-time-calendar-header" }, J = { class: "huiyi-time-current-month" }, X = { class: "huiyi-time-calendar-days" }, Z = ["onClick"], tt = { class: "huiyi-time-date-panel" }, et = { class: "calendar-section" }, nt = { class: "huiyi-time-calendar-header" }, at = { class: "huiyi-time-current-month" }, it = { class: "huiyi-time-calendar-days" }, st = ["onClick"];
|
|
@@ -429,7 +429,7 @@ function lt(e, t, n, r, l, i) {
|
|
|
429
429
|
onMouseover: t[12] || (t[12] = (...a) => i.handleMouseOver && i.handleMouseOver(...a)),
|
|
430
430
|
onMouseleave: t[13] || (t[13] = (...a) => i.handleMouseOut && i.handleMouseOut(...a))
|
|
431
431
|
}, [
|
|
432
|
-
s("div",
|
|
432
|
+
s("div", P, [
|
|
433
433
|
s("div", x, [
|
|
434
434
|
s("div", T, [
|
|
435
435
|
s("div", R, [
|
|
@@ -647,7 +647,7 @@ function lt(e, t, n, r, l, i) {
|
|
|
647
647
|
], 4)
|
|
648
648
|
], 32);
|
|
649
649
|
}
|
|
650
|
-
const V = /* @__PURE__ */ O(
|
|
650
|
+
const V = /* @__PURE__ */ O(b, [["render", lt], ["__scopeId", "data-v-fa5b0329"]]);
|
|
651
651
|
V.install = (e) => {
|
|
652
652
|
e.component(V.name, V);
|
|
653
653
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(u=typeof globalThis<"u"?globalThis:u||self,t(u.HuiyiTime={},u.Vue))})(this,function(u,t){"use strict";const X="",Z="",f=(n,e)=>{const a=n.__vccOpts||n;for(const[r,l]of e)a[r]=l;return a},w={name:"TimeComponentsUp",props:{initTime:{type:String,default:""}},data(){return{showPanel:!1,startDate:new Date,endDate:new Date,activeControl:"startYear",selectedRange:null,inputValue:"",isInvalid:!1,inputSelection:{start:0,end:0},mouseOver:!1,startCalendarViewDate:new Date,endCalendarViewDate:new Date,quickOptions:{common:[{name:"近3月",type:"months",value:3,active:!1},{name:"近1年",type:"years",value:1,active:!1}],today:[],yesterday:[{name:"昨天",type:"yesterday",value:"full",active:!1}],thisWeek:[{name:"本周",type:"thisWeek",value:"full",active:!1}],thisMonth:[{name:"本月",type:"thisMonth",value:"full",active:!1}]},dateFormatter:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"2-digit"})}},computed:{startDateMonthYear(){const n=this.startCalendarViewDate.getFullYear(),e=this.startCalendarViewDate.getMonth()+1;return`${n}年${e}月`},endDateMonthYear(){const n=this.endCalendarViewDate.getFullYear(),e=this.endCalendarViewDate.getMonth()+1;return`${n}年${e}月`},startCalendarDays(){return this.generateCalendarDays(this.startCalendarViewDate,this.startDate,this.endDate,"start")},endCalendarDays(){return this.generateCalendarDays(this.endCalendarViewDate,this.startDate,this.endDate,"end")},fieldPositions(){return[{name:"startYear",start:0,end:4,length:4},{name:"startMonth",start:5,end:7,length:2},{name:"startDay",start:8,end:10,length:2},{name:"endYear",start:13,end:17,length:4},{name:"endMonth",start:18,end:20,length:2},{name:"endDay",start:21,end:23,length:2}]}},mounted(){this.inputValue=this.initTime,this.updateQuickOptionsActiveState()},methods:{setActiveControl(n){this.activeControl=n},updateInputValue(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};this.inputValue=`${n(this.startDate)} ~ ${n(this.endDate)}`,this.modelClick()},onInputFocus(n){setTimeout(()=>{this.inputSelection={start:n.target.selectionStart,end:n.target.selectionEnd},this.selectCurrentField(this.inputSelection.start)},0)},onInputBlur(){this.validateInput()},onInputChange(){this.validateInput()},onInputKeydown(n){const e=n.key;["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e)&&(n.preventDefault(),e==="ArrowLeft"?this.navigateLeft():e==="ArrowRight"?this.navigateRight():e==="ArrowUp"?this.incrementValue():e==="ArrowDown"&&this.decrementValue()),e==="Tab"&&(n.preventDefault(),n.shiftKey?this.navigateLeft():this.navigateRight()),e==="Enter"&&(n.preventDefault(),this.showPanel=!1)},navigateLeft(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a>0?e=this.fieldPositions[a-1]:e=this.fieldPositions[this.fieldPositions.length-1];break}e||(e=this.fieldPositions[0]),this.selectField(e)},navigateRight(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a<this.fieldPositions.length-1?e=this.fieldPositions[a+1]:e=this.fieldPositions[0];break}e||(e=this.fieldPositions[0]),this.selectField(e)},selectCurrentField(n){for(const e of this.fieldPositions)if(n>=e.start&&n<=e.end){this.selectField(e);return}this.selectField(this.fieldPositions[0])},selectField(n){document.getElementById("datetime-input").setSelectionRange(n.start,n.end),this.inputSelection={start:n.start,end:n.end},this.activeControl=n.name},incrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))+1;switch(n.name){case"startYear":case"endYear":break;case"startMonth":case"endMonth":a>12&&(a=1);break;case"startDay":case"endDay":a>31&&(a=1);break}this.updateFieldValue(n,a)},decrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))-1;switch(n.name){case"startYear":case"endYear":a<1&&(a=9999);break;case"startMonth":case"endMonth":a<1&&(a=12);break;case"startDay":case"endDay":a<1&&(a=31);break}this.updateFieldValue(n,a)},getCurrentField(){for(const n of this.fieldPositions)if(this.inputSelection.start>=n.start&&this.inputSelection.start<=n.end)return n;return null},updateFieldValue(n,e){const a=String(e).padStart(n.length,"0"),r=this.inputValue.substring(0,n.start)+a+this.inputValue.substring(n.end);this.inputValue=r,this.$nextTick(()=>{this.selectField(n)}),this.updateDateFromInput()},updateDateFromInput(){if(!this.validateInputFormat())return;const n=this.inputValue.split(/[''~-]/);if(n.length!==6)return;const e=parseInt(n[0]),a=parseInt(n[1])-1,r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4])-1,d=parseInt(n[5]),h=new Date(e,a,r),i=new Date(l,s,d);if(isNaN(h.getTime())||isNaN(i.getTime())){this.isInvalid=!0;return}this.startDate=h,this.endDate=i,this.isInvalid=!1,this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},validateInputFormat(){return/^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue)},validateInput(){if(!this.validateInputFormat()){this.isInvalid=!0;return}const n=this.inputValue.split(/[ ~-]/),e=parseInt(n[0]),a=parseInt(n[1]),r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4]),d=parseInt(n[5]);if(a<1||a>12||s<1||s>12){this.isInvalid=!0;return}if(r<1||r>31||d<1||d>31){this.isInvalid=!0;return}const h=new Date(e,a-1,r),i=new Date(l,s-1,d);if(h.getMonth()!==a-1||h.getDate()!==r||i.getMonth()!==s-1||i.getDate()!==d){this.isInvalid=!0;return}this.isInvalid=!1},prevYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.endCalendarViewDate=e}},nextYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.endCalendarViewDate=e}},prevMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()-1),this.endCalendarViewDate=e}},nextMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()+1),this.endCalendarViewDate=e}},selectDate(n,e){n==="start"?this.startDate=e:this.endDate=e,this.updateInputValue(),this.updateQuickOptionsActiveState()},generateCalendarDays(n,e,a,r){const l=n.getFullYear(),s=n.getMonth(),d=new Date(l,s,1),h=new Date(l,s+1,0),i=d.getDay(),m=new Date(l,s,0).getDate(),D=[],g=new Date;for(let o=i-1;o>=0;o--){const c=new Date(l,s-1,m-o);D.push({id:`prev-${o}-${r}`,day:m-o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}for(let o=1;o<=h.getDate();o++){const c=new Date(l,s,o);D.push({id:`current-${o}-${r}`,day:o,date:c,isCurrentMonth:!0,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}const J=42-D.length;for(let o=1;o<=J;o++){const c=new Date(l,s+1,o);D.push({id:`next-${o}-${r}`,day:o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}return D},isSameDay(n,e){return n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth()&&n.getDate()===e.getDate()},isDateInRange(n,e,a){return n>=e&&n<=a},applyQuickOption(n){const e=new Date;let a=new Date,r=new Date;switch(n.type){case"days":a=new Date(e.getTime()-n.value*24*60*60*1e3);break;case"months":a=new Date(e.getFullYear(),e.getMonth()-n.value,e.getDate());break;case"years":a=new Date(e.getFullYear()-n.value,e.getMonth(),e.getDate());break;case"today":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()));break;case"yesterday":if(n.value==="full"){const l=new Date(e.getTime()-864e5);a=new Date(l.getFullYear(),l.getMonth(),l.getDate()),r=new Date(l.getFullYear(),l.getMonth(),l.getDate())}break;case"thisWeek":{const l=e.getDay(),s=new Date(e.getTime()-l*24*60*60*1e3);if(n.value==="full"){a=new Date(s.getFullYear(),s.getMonth(),s.getDate());const d=new Date(s.getTime()+6*24*60*60*1e3);r=new Date(d.getFullYear(),d.getMonth(),d.getDate())}break}case"thisMonth":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+1,0));break}this.startDate=a,this.endDate=r,this.updateInputValue(),this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},updateQuickOptionsActiveState(){Object.keys(this.quickOptions).forEach(n=>{this.quickOptions[n].forEach(e=>{e.active=!1})})},formatRangeDisplay(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};return`${n(this.startDate)} ~ ${n(this.endDate)}`},clickStop(n){n.stopPropagation()},confirmSelection(){this.selectedRange=this.formatRangeDisplay(),this.inputValue=this.selectedRange,this.showPanel=!1},blurInput(){this.mouseOver==!1&&(this.showPanel=!1)},handleMouseOver(){this.mouseOver=!0},handleMouseOut(){this.mouseOver=!1},modelClick(){this.showPanel=!1;const e=this.inputValue.split("~").map(a=>a.trim());this.$emit("changeTime",e)},handleListener(){const n=document.getElementById("content"),e=document.getElementById("timePanel");document.addEventListener("click",a=>{const r=n.contains(a.target),l=e.contains(a.target);r||l||this.modelClick()})},openShowPanel(){this.showPanel=!0,this.handleListener()}}},V={class:"container",id:"content"},k={class:"content"},C={class:"huiyi-time-input-section"},M={class:"huiyi-time-input-field"},E={class:"huiyi-time-panel-body"},N={class:"huiyi-time-quick-options"},_={class:"option-group"},I={class:"option-group"},S=["onClick"],F={class:"option-group"},Y=["onClick"],v={class:"option-group"},O=["onClick"],b={class:"option-group"},B=["onClick"],P={class:"huiyi-time-panels-container"},T={class:"huiyi-time-date-panel"},x={class:"calendar-section"},R={class:"huiyi-time-calendar-header"},L={class:"huiyi-time-current-month"},q={class:"huiyi-time-calendar-days"},A=["onClick"],Q={class:"huiyi-time-date-panel"},U={class:"calendar-section"},z={class:"huiyi-time-calendar-header"},W={class:"huiyi-time-current-month"},K={class:"huiyi-time-calendar-days"},$=["onClick"];function j(n,e,a,r,l,s){const d=t.resolveComponent("el-input"),h=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",{id:"huiyi-time-app",onMouseover:e[12]||(e[12]=(...i)=>s.handleMouseOver&&s.handleMouseOver(...i)),onMouseleave:e[13]||(e[13]=(...i)=>s.handleMouseOut&&s.handleMouseOut(...i))},[t.createElementVNode("div",V,[t.createElementVNode("div",k,[t.createElementVNode("div",C,[t.createElementVNode("div",M,[t.createVNode(d,{type:"text",id:"datetime-input",class:t.normalizeClass(["huiyi-time-datetime-input",{invalid:l.isInvalid}]),modelValue:l.inputValue,"onUpdate:modelValue":e[0]||(e[0]=i=>l.inputValue=i),placeholder:"YYYY-MM-DD ~ YYYY-MM-DD",onMouseup:s.onInputFocus,onBlur:s.onInputBlur,onKeydown:s.onInputKeydown,onInput:s.onInputChange,onClick:e[1]||(e[1]=i=>s.openShowPanel())},null,8,["class","modelValue","onMouseup","onBlur","onKeydown","onInput"])])])])]),t.createElementVNode("div",{class:"huiyi-time-time-panel",style:t.normalizeStyle(l.showPanel?"display:visible":"display:none"),id:"timePanel"},[t.createElementVNode("div",{class:"huiyi-time-panel-container",onClick:e[11]||(e[11]=t.withModifiers((...i)=>s.clickStop&&s.clickStop(...i),["stop"]))},[t.createElementVNode("div",E,[t.createElementVNode("div",N,[t.createElementVNode("div",_,[t.createElementVNode("div",{class:"huiyi-time-quick-option",onClick:e[2]||(e[2]=t.withModifiers(i=>s.applyQuickOption({name:"今天",type:"today",value:"full",active:!1}),["stop"]))},[t.createVNode(h,{type:"primary",plain:"",text:"",bg:""},{default:t.withCtx(()=>[...e[14]||(e[14]=[t.createTextVNode(" 今天 ",-1)])]),_:1})])]),t.createElementVNode("div",I,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.yesterday,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,S))),128))]),t.createElementVNode("div",F,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisWeek,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,Y))),128))]),t.createElementVNode("div",v,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisMonth,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,O))),128))]),t.createElementVNode("div",b,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.common,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,B))),128))])]),t.createElementVNode("div",P,[t.createElementVNode("div",T,[t.createElementVNode("div",x,[t.createElementVNode("div",R,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[3]||(e[3]=i=>s.prevYear("start"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[4]||(e[4]=i=>s.prevMonth("start"))},"<"),t.createElementVNode("div",L,t.toDisplayString(s.startDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[5]||(e[5]=i=>s.nextMonth("start"))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[6]||(e[6]=i=>s.nextYear("start"))},">>")]),e[15]||(e[15]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",q,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.startCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("start",i.date),["stop"])},t.toDisplayString(i.day),11,A))),128))])])]),t.createElementVNode("div",Q,[t.createElementVNode("div",U,[t.createElementVNode("div",z,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[7]||(e[7]=i=>s.prevYear("end"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[8]||(e[8]=t.withModifiers(i=>s.prevMonth("end"),["stop"]))},"<"),t.createElementVNode("div",W,t.toDisplayString(s.endDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[9]||(e[9]=t.withModifiers(i=>s.nextMonth("end"),["stop"]))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[10]||(e[10]=i=>s.nextYear("end"))},">>")]),e[16]||(e[16]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",K,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.endCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("end",i.date),["stop"])},t.toDisplayString(i.day),11,$))),128))])])])])])])],4)],32)}const p=f(w,[["render",j],["__scopeId","data-v-f5587819"]]);p.install=n=>{n.component(p.name,p)};const H=[p],y=function(n){y.installed||H.forEach(e=>{n.component(e.name,e)})};typeof window<"u"&&window.Vue&&y(window.Vue);const G={install:y,TimeComponentsUp:p};u.TimeComponentsUp=p,u.default=G,u.install=y,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(u,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(u=typeof globalThis<"u"?globalThis:u||self,t(u.HuiyiTime={},u.Vue))})(this,function(u,t){"use strict";const X="",Z="",f=(n,e)=>{const a=n.__vccOpts||n;for(const[r,l]of e)a[r]=l;return a},w={name:"TimeComponentsUp",props:{initTime:{type:String,default:""}},data(){return{showPanel:!1,startDate:new Date,endDate:new Date,activeControl:"startYear",selectedRange:null,inputValue:"",isInvalid:!1,inputSelection:{start:0,end:0},mouseOver:!1,startCalendarViewDate:new Date,endCalendarViewDate:new Date,quickOptions:{common:[{name:"近3月",type:"months",value:3,active:!1},{name:"近1年",type:"years",value:1,active:!1}],today:[],yesterday:[{name:"昨天",type:"yesterday",value:"full",active:!1}],thisWeek:[{name:"本周",type:"thisWeek",value:"full",active:!1}],thisMonth:[{name:"本月",type:"thisMonth",value:"full",active:!1}]},dateFormatter:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"2-digit"})}},computed:{startDateMonthYear(){const n=this.startCalendarViewDate.getFullYear(),e=this.startCalendarViewDate.getMonth()+1;return`${n}年${e}月`},endDateMonthYear(){const n=this.endCalendarViewDate.getFullYear(),e=this.endCalendarViewDate.getMonth()+1;return`${n}年${e}月`},startCalendarDays(){return this.generateCalendarDays(this.startCalendarViewDate,this.startDate,this.endDate,"start")},endCalendarDays(){return this.generateCalendarDays(this.endCalendarViewDate,this.startDate,this.endDate,"end")},fieldPositions(){return[{name:"startYear",start:0,end:4,length:4},{name:"startMonth",start:5,end:7,length:2},{name:"startDay",start:8,end:10,length:2},{name:"endYear",start:13,end:17,length:4},{name:"endMonth",start:18,end:20,length:2},{name:"endDay",start:21,end:23,length:2}]}},mounted(){this.inputValue=this.initTime,this.updateQuickOptionsActiveState()},methods:{setActiveControl(n){this.activeControl=n},updateInputValue(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};this.inputValue=`${n(this.startDate)} ~ ${n(this.endDate)}`,this.modelClick()},onInputFocus(n){setTimeout(()=>{this.inputSelection={start:n.target.selectionStart,end:n.target.selectionEnd},this.selectCurrentField(this.inputSelection.start)},0)},onInputBlur(){this.validateInput()},onInputChange(){this.validateInput()},onInputKeydown(n){const e=n.key;["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e)&&(n.preventDefault(),e==="ArrowLeft"?this.navigateLeft():e==="ArrowRight"?this.navigateRight():e==="ArrowUp"?this.incrementValue():e==="ArrowDown"&&this.decrementValue()),e==="Tab"&&(n.preventDefault(),n.shiftKey?this.navigateLeft():this.navigateRight()),e==="Enter"&&(n.preventDefault(),this.showPanel=!1)},navigateLeft(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a>0?e=this.fieldPositions[a-1]:e=this.fieldPositions[this.fieldPositions.length-1];break}e||(e=this.fieldPositions[0]),this.selectField(e)},navigateRight(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a<this.fieldPositions.length-1?e=this.fieldPositions[a+1]:e=this.fieldPositions[0];break}e||(e=this.fieldPositions[0]),this.selectField(e)},selectCurrentField(n){for(const e of this.fieldPositions)if(n>=e.start&&n<=e.end){this.selectField(e);return}this.selectField(this.fieldPositions[0])},selectField(n){document.getElementById("datetime-input").setSelectionRange(n.start,n.end),this.inputSelection={start:n.start,end:n.end},this.activeControl=n.name},incrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))+1;switch(n.name){case"startYear":case"endYear":break;case"startMonth":case"endMonth":a>12&&(a=1);break;case"startDay":case"endDay":a>31&&(a=1);break}this.updateFieldValue(n,a)},decrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))-1;switch(n.name){case"startYear":case"endYear":a<1&&(a=9999);break;case"startMonth":case"endMonth":a<1&&(a=12);break;case"startDay":case"endDay":a<1&&(a=31);break}this.updateFieldValue(n,a)},getCurrentField(){for(const n of this.fieldPositions)if(this.inputSelection.start>=n.start&&this.inputSelection.start<=n.end)return n;return null},updateFieldValue(n,e){const a=String(e).padStart(n.length,"0"),r=this.inputValue.substring(0,n.start)+a+this.inputValue.substring(n.end);this.inputValue=r,this.$nextTick(()=>{this.selectField(n)}),this.updateDateFromInput()},updateDateFromInput(){if(!this.validateInputFormat())return;const n=this.inputValue.split(/[''~-]/);if(n.length!==6)return;const e=parseInt(n[0]),a=parseInt(n[1])-1,r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4])-1,d=parseInt(n[5]),h=new Date(e,a,r),i=new Date(l,s,d);if(isNaN(h.getTime())||isNaN(i.getTime())){this.isInvalid=!0;return}this.startDate=h,this.endDate=i,this.isInvalid=!1,this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},validateInputFormat(){return/^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue)},validateInput(){if(!this.validateInputFormat()){this.isInvalid=!0;return}const n=this.inputValue.split(/[ ~-]/),e=parseInt(n[0]),a=parseInt(n[1]),r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4]),d=parseInt(n[5]);if(a<1||a>12||s<1||s>12){this.isInvalid=!0;return}if(r<1||r>31||d<1||d>31){this.isInvalid=!0;return}const h=new Date(e,a-1,r),i=new Date(l,s-1,d);if(h.getMonth()!==a-1||h.getDate()!==r||i.getMonth()!==s-1||i.getDate()!==d){this.isInvalid=!0;return}this.isInvalid=!1},prevYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.endCalendarViewDate=e}},nextYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.endCalendarViewDate=e}},prevMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()-1),this.endCalendarViewDate=e}},nextMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()+1),this.endCalendarViewDate=e}},selectDate(n,e){n==="start"?this.startDate=e:this.endDate=e,this.updateInputValue(),this.updateQuickOptionsActiveState()},generateCalendarDays(n,e,a,r){const l=n.getFullYear(),s=n.getMonth(),d=new Date(l,s,1),h=new Date(l,s+1,0),i=d.getDay(),m=new Date(l,s,0).getDate(),D=[],g=new Date;for(let o=i-1;o>=0;o--){const c=new Date(l,s-1,m-o);D.push({id:`prev-${o}-${r}`,day:m-o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}for(let o=1;o<=h.getDate();o++){const c=new Date(l,s,o);D.push({id:`current-${o}-${r}`,day:o,date:c,isCurrentMonth:!0,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}const J=42-D.length;for(let o=1;o<=J;o++){const c=new Date(l,s+1,o);D.push({id:`next-${o}-${r}`,day:o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}return D},isSameDay(n,e){return n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth()&&n.getDate()===e.getDate()},isDateInRange(n,e,a){return n>=e&&n<=a},applyQuickOption(n){const e=new Date;let a=new Date,r=new Date;switch(n.type){case"days":a=new Date(e.getTime()-n.value*24*60*60*1e3);break;case"months":a=new Date(e.getFullYear(),e.getMonth()-n.value,e.getDate());break;case"years":a=new Date(e.getFullYear()-n.value,e.getMonth(),e.getDate());break;case"today":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()));break;case"yesterday":if(n.value==="full"){const l=new Date(e.getTime()-864e5);a=new Date(l.getFullYear(),l.getMonth(),l.getDate()),r=new Date(l.getFullYear(),l.getMonth(),l.getDate())}break;case"thisWeek":{const l=e.getDay(),s=new Date(e.getTime()-l*24*60*60*1e3);if(n.value==="full"){a=new Date(s.getFullYear(),s.getMonth(),s.getDate());const d=new Date(s.getTime()+6*24*60*60*1e3);r=new Date(d.getFullYear(),d.getMonth(),d.getDate())}break}case"thisMonth":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+1,0));break}this.startDate=a,this.endDate=r,this.updateInputValue(),this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},updateQuickOptionsActiveState(){Object.keys(this.quickOptions).forEach(n=>{this.quickOptions[n].forEach(e=>{e.active=!1})})},formatRangeDisplay(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};return`${n(this.startDate)} ~ ${n(this.endDate)}`},clickStop(n){n.stopPropagation()},confirmSelection(){this.selectedRange=this.formatRangeDisplay(),this.inputValue=this.selectedRange,this.showPanel=!1},blurInput(){this.mouseOver==!1&&(this.showPanel=!1)},handleMouseOver(){this.mouseOver=!0},handleMouseOut(){this.mouseOver=!1},modelClick(){this.showPanel=!1;const e=this.inputValue.split("~").map(a=>a.trim());this.$emit("changeTime",e)},handleListener(){const n=document.getElementById("content"),e=document.getElementById("timePanel");document.addEventListener("click",a=>{const r=n.contains(a.target),l=e.contains(a.target);r||l||this.modelClick()})},openShowPanel(){this.showPanel=!0,this.handleListener()}}},V={class:"container",id:"content"},k={class:"content"},C={class:"huiyi-time-input-section"},M={class:"huiyi-time-input-field"},E={class:"huiyi-time-panel-body"},N={class:"huiyi-time-quick-options"},_={class:"option-group"},I={class:"option-group"},S=["onClick"],F={class:"option-group"},Y=["onClick"],v={class:"option-group"},b=["onClick"],O={class:"option-group"},B=["onClick"],P={class:"huiyi-time-panels-container"},T={class:"huiyi-time-date-panel"},x={class:"calendar-section"},R={class:"huiyi-time-calendar-header"},L={class:"huiyi-time-current-month"},q={class:"huiyi-time-calendar-days"},A=["onClick"],Q={class:"huiyi-time-date-panel"},U={class:"calendar-section"},z={class:"huiyi-time-calendar-header"},W={class:"huiyi-time-current-month"},K={class:"huiyi-time-calendar-days"},$=["onClick"];function j(n,e,a,r,l,s){const d=t.resolveComponent("el-input"),h=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",{id:"huiyi-time-app",onMouseover:e[12]||(e[12]=(...i)=>s.handleMouseOver&&s.handleMouseOver(...i)),onMouseleave:e[13]||(e[13]=(...i)=>s.handleMouseOut&&s.handleMouseOut(...i))},[t.createElementVNode("div",V,[t.createElementVNode("div",k,[t.createElementVNode("div",C,[t.createElementVNode("div",M,[t.createVNode(d,{type:"text",id:"datetime-input",class:t.normalizeClass(["huiyi-time-datetime-input",{invalid:l.isInvalid}]),modelValue:l.inputValue,"onUpdate:modelValue":e[0]||(e[0]=i=>l.inputValue=i),placeholder:"YYYY-MM-DD ~ YYYY-MM-DD",onMouseup:s.onInputFocus,onBlur:s.onInputBlur,onKeydown:s.onInputKeydown,onInput:s.onInputChange,onClick:e[1]||(e[1]=i=>s.openShowPanel())},null,8,["class","modelValue","onMouseup","onBlur","onKeydown","onInput"])])])])]),t.createElementVNode("div",{class:"huiyi-time-time-panel",style:t.normalizeStyle(l.showPanel?"display:visible":"display:none"),id:"timePanel"},[t.createElementVNode("div",{class:"huiyi-time-panel-container",onClick:e[11]||(e[11]=t.withModifiers((...i)=>s.clickStop&&s.clickStop(...i),["stop"]))},[t.createElementVNode("div",E,[t.createElementVNode("div",N,[t.createElementVNode("div",_,[t.createElementVNode("div",{class:"huiyi-time-quick-option",onClick:e[2]||(e[2]=t.withModifiers(i=>s.applyQuickOption({name:"今天",type:"today",value:"full",active:!1}),["stop"]))},[t.createVNode(h,{type:"primary",plain:"",text:"",bg:""},{default:t.withCtx(()=>[...e[14]||(e[14]=[t.createTextVNode(" 今天 ",-1)])]),_:1})])]),t.createElementVNode("div",I,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.yesterday,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,S))),128))]),t.createElementVNode("div",F,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisWeek,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,Y))),128))]),t.createElementVNode("div",v,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisMonth,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,b))),128))]),t.createElementVNode("div",O,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.common,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,B))),128))])]),t.createElementVNode("div",P,[t.createElementVNode("div",T,[t.createElementVNode("div",x,[t.createElementVNode("div",R,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[3]||(e[3]=i=>s.prevYear("start"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[4]||(e[4]=i=>s.prevMonth("start"))},"<"),t.createElementVNode("div",L,t.toDisplayString(s.startDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[5]||(e[5]=i=>s.nextMonth("start"))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[6]||(e[6]=i=>s.nextYear("start"))},">>")]),e[15]||(e[15]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",q,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.startCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("start",i.date),["stop"])},t.toDisplayString(i.day),11,A))),128))])])]),t.createElementVNode("div",Q,[t.createElementVNode("div",U,[t.createElementVNode("div",z,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[7]||(e[7]=i=>s.prevYear("end"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[8]||(e[8]=t.withModifiers(i=>s.prevMonth("end"),["stop"]))},"<"),t.createElementVNode("div",W,t.toDisplayString(s.endDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[9]||(e[9]=t.withModifiers(i=>s.nextMonth("end"),["stop"]))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[10]||(e[10]=i=>s.nextYear("end"))},">>")]),e[16]||(e[16]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",K,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.endCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("end",i.date),["stop"])},t.toDisplayString(i.day),11,$))),128))])])])])])])],4)],32)}const p=f(w,[["render",j],["__scopeId","data-v-fa5b0329"]]);p.install=n=>{n.component(p.name,p)};const H=[p],y=function(n){y.installed||H.forEach(e=>{n.component(e.name,e)})};typeof window<"u"&&window.Vue&&y(window.Vue);const G={install:y,TimeComponentsUp:p};u.TimeComponentsUp=p,u.default=G,u.install=y,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "huiyi-time",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
|
+
"description": "A Vue.js time range picker component",
|
|
5
|
+
"main": "huiyi-time.umd.js",
|
|
6
|
+
"module": "huiyi-time.es.js",
|
|
7
|
+
"unpkg": "huiyi-time.umd.js",
|
|
8
|
+
"browser": "huiyi-time.umd.js",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vue",
|
|
11
|
+
"component",
|
|
12
|
+
"time-picker",
|
|
13
|
+
"date-range"
|
|
14
|
+
],
|
|
15
|
+
"author": "Time Components Up",
|
|
16
|
+
"license": "MIT",
|
|
4
17
|
"peerDependencies": {
|
|
5
18
|
"vue": "^3.0.0"
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
"serve": "vite",
|
|
9
|
-
"dev": "vite",
|
|
10
|
-
"build": "vite build",
|
|
11
|
-
"lib": "vite build && npm run lib-init",
|
|
12
|
-
"lib-init": "mkdir -p huiyi-time && node -e \"const pkg = require('./package.json'); const fs = require('fs'); const newPkg = { name: pkg.name, version: pkg.version, description: 'A Vue.js time range picker component', main: 'huiyi-time.umd.js', module: 'huiyi-time.es.js', unpkg: 'huiyi-time.umd.js', browser: 'huiyi-time.umd.js', keywords: ['vue', 'component', 'time-picker', 'date-range'], author: 'Time Components Up', license: 'MIT', peerDependencies: { vue: '^3.0.0' } }; fs.writeFileSync('./huiyi-time/package.json', JSON.stringify(newPkg, null, 2));\"",
|
|
13
|
-
"preview": "vite preview"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"element-plus": "^2.11.7",
|
|
17
|
-
"vue": "^3.2.13"
|
|
18
|
-
},
|
|
19
|
-
"devDependencies": {
|
|
20
|
-
"@vitejs/plugin-vue": "^4.0.0",
|
|
21
|
-
"sass": "^1.94.0",
|
|
22
|
-
"vite": "^4.0.0"
|
|
23
|
-
},
|
|
24
|
-
"browserslist": [
|
|
25
|
-
"> 1%",
|
|
26
|
-
"last 2 versions",
|
|
27
|
-
"not dead",
|
|
28
|
-
"not ie 11"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#huiyi-time-app[data-v-fa5b0329]{position:relative}.huiyi-time-input-section[data-v-fa5b0329]{display:flex;flex-direction:column;align-items:center}.huiyi-time-input-field[data-v-fa5b0329]{width:100%;max-width:190px}.huiyi-time-time-panel[data-v-fa5b0329]{width:600px;height:300px;justify-content:center;align-items:center;z-index:10000;position:fixed}.huiyi-time-panel-container[data-v-fa5b0329]{background:white;border-radius:15px;width:98%;max-width:600px;box-shadow:0 15px 30px #0000004d;overflow:hidden;display:flex;flex-direction:column;max-height:90vh}.huiyi-time-panel-body[data-v-fa5b0329]{display:flex;flex:1;overflow:hidden}.huiyi-time-quick-options[data-v-fa5b0329]{width:80px;background:#fff;padding:5px;border-right:1px solid #e9ecef;overflow-y:auto}.huiyi-time-quick-option[data-v-fa5b0329]{display:block;width:50px;padding:0 5px;background:white;border-radius:8px;text-align:left;margin-bottom:8px;cursor:pointer;transition:all .2s;font-size:.9rem}.huiyi-time-quick-option.active[data-v-fa5b0329]{background:#409eff;color:#fff;border-color:#409eff}.huiyi-time-panels-container[data-v-fa5b0329]{flex:1;display:flex;overflow:hidden}.huiyi-time-date-panel[data-v-fa5b0329]{flex:1;padding:10px;overflow-y:auto;width:360px;border-right:1px solid #e9ecef}.huiyi-time-date-panel[data-v-fa5b0329]:last-child{border-right:none}.huiyi-time-calendar-header[data-v-fa5b0329]{display:flex;justify-content:space-between;align-items:center;margin-bottom:11px}.huiyi-time-year-nav[data-v-fa5b0329]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-year-nav[data-v-fa5b0329]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-month-nav[data-v-fa5b0329]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-month-nav[data-v-fa5b0329]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-current-month[data-v-fa5b0329]{font-size:1.1rem;font-weight:600;color:#333}.huiyi-time-week-days[data-v-fa5b0329]{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;margin-bottom:6px;font-weight:600;color:#666;font-size:.85rem}.huiyi-time-calendar-days[data-v-fa5b0329]{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}.huiyi-time-calendar-day[data-v-fa5b0329]{height:30px;display:flex;align-items:center;justify-content:center;border-radius:6px;cursor:pointer;transition:all .2s;font-size:12px}.huiyi-time-calendar-day[data-v-fa5b0329]:hover{background:#e9ecef;color:var(--el-color-primary)}.huiyi-time-calendar-day.other-month[data-v-fa5b0329]{color:#ccc}.huiyi-time-calendar-day.selected[data-v-fa5b0329]{background:var(--el-color-primary)!important;color:#fff!important}.huiyi-time-calendar-day.today[data-v-fa5b0329]{background:#fff;color:var(--el-color-primary);font-weight:600}.huiyi-time-calendar-day.in-range[data-v-fa5b0329]{background:#e6eeff}@media (max-width: 900px){.huiyi-time-panel-body[data-v-fa5b0329]{flex-direction:column;max-height:none}.huiyi-time-quick-options[data-v-fa5b0329]{width:100%;border-right:none;border-bottom:1px solid #e9ecef;max-height:200px}.huiyi-time-panels-container[data-v-fa5b0329]{flex-direction:column}.huiyi-time-date-panel[data-v-fa5b0329]{border-right:none;border-bottom:1px solid #e9ecef}.huiyi-time-date-panel[data-v-fa5b0329]:last-child{border-bottom:none}}
|
package/README.md
DELETED
package/babel.config.js
DELETED
package/dist/huiyi-time.es.js
DELETED
|
@@ -1,670 +0,0 @@
|
|
|
1
|
-
import { resolveComponent as Y, openBlock as c, createElementBlock as p, createElementVNode as s, createVNode as g, normalizeClass as y, normalizeStyle as S, withModifiers as m, withCtx as C, createTextVNode as M, Fragment as f, renderList as w, toDisplayString as v } from "vue";
|
|
2
|
-
const O = (e, t) => {
|
|
3
|
-
const n = e.__vccOpts || e;
|
|
4
|
-
for (const [r, l] of t)
|
|
5
|
-
n[r] = l;
|
|
6
|
-
return n;
|
|
7
|
-
}, P = {
|
|
8
|
-
name: "TimeComponentsUp",
|
|
9
|
-
props: {
|
|
10
|
-
initTime: {
|
|
11
|
-
type: String,
|
|
12
|
-
default: ""
|
|
13
|
-
// 默认返回空对象
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
// 这里是你的数据
|
|
19
|
-
showPanel: !1,
|
|
20
|
-
startDate: /* @__PURE__ */ new Date(),
|
|
21
|
-
endDate: /* @__PURE__ */ new Date(),
|
|
22
|
-
activeControl: "startYear",
|
|
23
|
-
selectedRange: null,
|
|
24
|
-
inputValue: "",
|
|
25
|
-
isInvalid: !1,
|
|
26
|
-
inputSelection: {
|
|
27
|
-
start: 0,
|
|
28
|
-
end: 0
|
|
29
|
-
},
|
|
30
|
-
mouseOver: !1,
|
|
31
|
-
startCalendarViewDate: /* @__PURE__ */ new Date(),
|
|
32
|
-
endCalendarViewDate: /* @__PURE__ */ new Date(),
|
|
33
|
-
quickOptions: {
|
|
34
|
-
common: [
|
|
35
|
-
{ name: "近3月", type: "months", value: 3, active: !1 },
|
|
36
|
-
{ name: "近1年", type: "years", value: 1, active: !1 }
|
|
37
|
-
],
|
|
38
|
-
today: [],
|
|
39
|
-
yesterday: [
|
|
40
|
-
{ name: "昨天", type: "yesterday", value: "full", active: !1 }
|
|
41
|
-
],
|
|
42
|
-
thisWeek: [
|
|
43
|
-
{ name: "本周", type: "thisWeek", value: "full", active: !1 }
|
|
44
|
-
],
|
|
45
|
-
thisMonth: [
|
|
46
|
-
{ name: "本月", type: "thisMonth", value: "full", active: !1 }
|
|
47
|
-
]
|
|
48
|
-
},
|
|
49
|
-
dateFormatter: new Intl.DateTimeFormat("en-US", { year: "numeric", month: "long", day: "2-digit" })
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
computed: {
|
|
53
|
-
startDateMonthYear() {
|
|
54
|
-
const e = this.startCalendarViewDate.getFullYear(), t = this.startCalendarViewDate.getMonth() + 1;
|
|
55
|
-
return `${e}年${t}月`;
|
|
56
|
-
},
|
|
57
|
-
endDateMonthYear() {
|
|
58
|
-
const e = this.endCalendarViewDate.getFullYear(), t = this.endCalendarViewDate.getMonth() + 1;
|
|
59
|
-
return `${e}年${t}月`;
|
|
60
|
-
},
|
|
61
|
-
startCalendarDays() {
|
|
62
|
-
return this.generateCalendarDays(this.startCalendarViewDate, this.startDate, this.endDate, "start");
|
|
63
|
-
},
|
|
64
|
-
endCalendarDays() {
|
|
65
|
-
return this.generateCalendarDays(this.endCalendarViewDate, this.startDate, this.endDate, "end");
|
|
66
|
-
},
|
|
67
|
-
// 定义输入框中各个时间字段的位置范围
|
|
68
|
-
fieldPositions() {
|
|
69
|
-
return [
|
|
70
|
-
{ name: "startYear", start: 0, end: 4, length: 4 },
|
|
71
|
-
{ name: "startMonth", start: 5, end: 7, length: 2 },
|
|
72
|
-
{ name: "startDay", start: 8, end: 10, length: 2 },
|
|
73
|
-
{ name: "endYear", start: 13, end: 17, length: 4 },
|
|
74
|
-
{ name: "endMonth", start: 18, end: 20, length: 2 },
|
|
75
|
-
{ name: "endDay", start: 21, end: 23, length: 2 }
|
|
76
|
-
];
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
mounted() {
|
|
80
|
-
this.inputValue = this.initTime, this.updateQuickOptionsActiveState();
|
|
81
|
-
},
|
|
82
|
-
methods: {
|
|
83
|
-
setActiveControl(e) {
|
|
84
|
-
this.activeControl = e;
|
|
85
|
-
},
|
|
86
|
-
// 更新输入框的值
|
|
87
|
-
updateInputValue() {
|
|
88
|
-
const e = (t) => {
|
|
89
|
-
const n = t.getFullYear(), r = String(t.getMonth() + 1).padStart(2, "0"), l = String(t.getDate()).padStart(2, "0");
|
|
90
|
-
return `${n}-${r}-${l}`;
|
|
91
|
-
};
|
|
92
|
-
this.inputValue = `${e(this.startDate)} ~ ${e(this.endDate)}`, this.modelClick();
|
|
93
|
-
},
|
|
94
|
-
// 输入框获得焦点时
|
|
95
|
-
onInputFocus(e) {
|
|
96
|
-
setTimeout(() => {
|
|
97
|
-
this.inputSelection = {
|
|
98
|
-
start: e.target.selectionStart,
|
|
99
|
-
end: e.target.selectionEnd
|
|
100
|
-
}, this.selectCurrentField(this.inputSelection.start);
|
|
101
|
-
}, 0);
|
|
102
|
-
},
|
|
103
|
-
// 输入框失去焦点时
|
|
104
|
-
onInputBlur() {
|
|
105
|
-
this.validateInput();
|
|
106
|
-
},
|
|
107
|
-
// 输入框内容变化时
|
|
108
|
-
onInputChange() {
|
|
109
|
-
this.validateInput();
|
|
110
|
-
},
|
|
111
|
-
// 输入框键盘事件
|
|
112
|
-
onInputKeydown(e) {
|
|
113
|
-
const t = e.key;
|
|
114
|
-
["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(t) && (e.preventDefault(), t === "ArrowLeft" ? this.navigateLeft() : t === "ArrowRight" ? this.navigateRight() : t === "ArrowUp" ? this.incrementValue() : t === "ArrowDown" && this.decrementValue()), t === "Tab" && (e.preventDefault(), e.shiftKey ? this.navigateLeft() : this.navigateRight()), t === "Enter" && (e.preventDefault(), this.showPanel = !1);
|
|
115
|
-
},
|
|
116
|
-
// 向左导航
|
|
117
|
-
navigateLeft() {
|
|
118
|
-
const e = this.inputSelection.start;
|
|
119
|
-
let t = null;
|
|
120
|
-
for (let n = 0; n < this.fieldPositions.length; n++)
|
|
121
|
-
if (e >= this.fieldPositions[n].start && e <= this.fieldPositions[n].end) {
|
|
122
|
-
n > 0 ? t = this.fieldPositions[n - 1] : t = this.fieldPositions[this.fieldPositions.length - 1];
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
t || (t = this.fieldPositions[0]), this.selectField(t);
|
|
126
|
-
},
|
|
127
|
-
// 向右导航
|
|
128
|
-
navigateRight() {
|
|
129
|
-
const e = this.inputSelection.start;
|
|
130
|
-
let t = null;
|
|
131
|
-
for (let n = 0; n < this.fieldPositions.length; n++)
|
|
132
|
-
if (e >= this.fieldPositions[n].start && e <= this.fieldPositions[n].end) {
|
|
133
|
-
n < this.fieldPositions.length - 1 ? t = this.fieldPositions[n + 1] : t = this.fieldPositions[0];
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
t || (t = this.fieldPositions[0]), this.selectField(t);
|
|
137
|
-
},
|
|
138
|
-
// 选择当前字段
|
|
139
|
-
selectCurrentField(e) {
|
|
140
|
-
for (const t of this.fieldPositions)
|
|
141
|
-
if (e >= t.start && e <= t.end) {
|
|
142
|
-
this.selectField(t);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.selectField(this.fieldPositions[0]);
|
|
146
|
-
},
|
|
147
|
-
// 选择指定字段
|
|
148
|
-
selectField(e) {
|
|
149
|
-
document.getElementById("datetime-input").setSelectionRange(e.start, e.end), this.inputSelection = {
|
|
150
|
-
start: e.start,
|
|
151
|
-
end: e.end
|
|
152
|
-
}, this.activeControl = e.name;
|
|
153
|
-
},
|
|
154
|
-
// 增加当前字段的值
|
|
155
|
-
incrementValue() {
|
|
156
|
-
const e = this.getCurrentField();
|
|
157
|
-
if (!e)
|
|
158
|
-
return;
|
|
159
|
-
let n = parseInt(this.inputValue.substring(e.start, e.end)) + 1;
|
|
160
|
-
switch (e.name) {
|
|
161
|
-
case "startYear":
|
|
162
|
-
case "endYear":
|
|
163
|
-
break;
|
|
164
|
-
case "startMonth":
|
|
165
|
-
case "endMonth":
|
|
166
|
-
n > 12 && (n = 1);
|
|
167
|
-
break;
|
|
168
|
-
case "startDay":
|
|
169
|
-
case "endDay":
|
|
170
|
-
n > 31 && (n = 1);
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
this.updateFieldValue(e, n);
|
|
174
|
-
},
|
|
175
|
-
// 减少当前字段的值
|
|
176
|
-
decrementValue() {
|
|
177
|
-
const e = this.getCurrentField();
|
|
178
|
-
if (!e)
|
|
179
|
-
return;
|
|
180
|
-
let n = parseInt(this.inputValue.substring(e.start, e.end)) - 1;
|
|
181
|
-
switch (e.name) {
|
|
182
|
-
case "startYear":
|
|
183
|
-
case "endYear":
|
|
184
|
-
n < 1 && (n = 9999);
|
|
185
|
-
break;
|
|
186
|
-
case "startMonth":
|
|
187
|
-
case "endMonth":
|
|
188
|
-
n < 1 && (n = 12);
|
|
189
|
-
break;
|
|
190
|
-
case "startDay":
|
|
191
|
-
case "endDay":
|
|
192
|
-
n < 1 && (n = 31);
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
this.updateFieldValue(e, n);
|
|
196
|
-
},
|
|
197
|
-
// 获取当前字段
|
|
198
|
-
getCurrentField() {
|
|
199
|
-
for (const e of this.fieldPositions)
|
|
200
|
-
if (this.inputSelection.start >= e.start && this.inputSelection.start <= e.end)
|
|
201
|
-
return e;
|
|
202
|
-
return null;
|
|
203
|
-
},
|
|
204
|
-
// 更新字段值
|
|
205
|
-
updateFieldValue(e, t) {
|
|
206
|
-
const n = String(t).padStart(e.length, "0"), r = this.inputValue.substring(0, e.start) + n + this.inputValue.substring(e.end);
|
|
207
|
-
this.inputValue = r, this.$nextTick(() => {
|
|
208
|
-
this.selectField(e);
|
|
209
|
-
}), this.updateDateFromInput();
|
|
210
|
-
},
|
|
211
|
-
// 从输入框更新日期对象
|
|
212
|
-
updateDateFromInput() {
|
|
213
|
-
if (!this.validateInputFormat())
|
|
214
|
-
return;
|
|
215
|
-
const e = this.inputValue.split(/[''~-]/);
|
|
216
|
-
if (e.length !== 6)
|
|
217
|
-
return;
|
|
218
|
-
const t = parseInt(e[0]), n = parseInt(e[1]) - 1, r = parseInt(e[2]), l = parseInt(e[3]), i = parseInt(e[4]) - 1, d = parseInt(e[5]), h = new Date(t, n, r), a = new Date(l, i, d);
|
|
219
|
-
if (isNaN(h.getTime()) || isNaN(a.getTime())) {
|
|
220
|
-
this.isInvalid = !0;
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
this.startDate = h, this.endDate = a, this.isInvalid = !1, this.updateQuickOptionsActiveState(), this.startCalendarViewDate = new Date(this.startDate), this.endCalendarViewDate = new Date(this.endDate);
|
|
224
|
-
},
|
|
225
|
-
// 验证输入格式
|
|
226
|
-
validateInputFormat() {
|
|
227
|
-
return /^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue);
|
|
228
|
-
},
|
|
229
|
-
// 验证输入内容
|
|
230
|
-
validateInput() {
|
|
231
|
-
if (!this.validateInputFormat()) {
|
|
232
|
-
this.isInvalid = !0;
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
const e = this.inputValue.split(/[ ~-]/), t = parseInt(e[0]), n = parseInt(e[1]), r = parseInt(e[2]), l = parseInt(e[3]), i = parseInt(e[4]), d = parseInt(e[5]);
|
|
236
|
-
if (n < 1 || n > 12 || i < 1 || i > 12) {
|
|
237
|
-
this.isInvalid = !0;
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (r < 1 || r > 31 || d < 1 || d > 31) {
|
|
241
|
-
this.isInvalid = !0;
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
const h = new Date(t, n - 1, r), a = new Date(l, i - 1, d);
|
|
245
|
-
if (h.getMonth() !== n - 1 || h.getDate() !== r || a.getMonth() !== i - 1 || a.getDate() !== d) {
|
|
246
|
-
this.isInvalid = !0;
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
this.isInvalid = !1;
|
|
250
|
-
},
|
|
251
|
-
// 前一年
|
|
252
|
-
prevYear(e) {
|
|
253
|
-
if (e === "start") {
|
|
254
|
-
const t = new Date(this.startCalendarViewDate);
|
|
255
|
-
t.setFullYear(t.getFullYear() - 1), this.startCalendarViewDate = t;
|
|
256
|
-
} else {
|
|
257
|
-
const t = new Date(this.endCalendarViewDate);
|
|
258
|
-
t.setFullYear(t.getFullYear() - 1), this.endCalendarViewDate = t;
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
// 后一年
|
|
262
|
-
nextYear(e) {
|
|
263
|
-
if (e === "start") {
|
|
264
|
-
const t = new Date(this.startCalendarViewDate);
|
|
265
|
-
t.setFullYear(t.getFullYear() + 1), this.startCalendarViewDate = t;
|
|
266
|
-
} else {
|
|
267
|
-
const t = new Date(this.endCalendarViewDate);
|
|
268
|
-
t.setFullYear(t.getFullYear() + 1), this.endCalendarViewDate = t;
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
prevMonth(e) {
|
|
272
|
-
if (e === "start") {
|
|
273
|
-
const t = new Date(this.startCalendarViewDate);
|
|
274
|
-
t.setMonth(t.getMonth() - 1), this.startCalendarViewDate = t;
|
|
275
|
-
} else {
|
|
276
|
-
const t = new Date(this.endCalendarViewDate);
|
|
277
|
-
t.setMonth(t.getMonth() - 1), this.endCalendarViewDate = t;
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
nextMonth(e) {
|
|
281
|
-
if (e === "start") {
|
|
282
|
-
const t = new Date(this.startCalendarViewDate);
|
|
283
|
-
t.setMonth(t.getMonth() + 1), this.startCalendarViewDate = t;
|
|
284
|
-
} else {
|
|
285
|
-
const t = new Date(this.endCalendarViewDate);
|
|
286
|
-
t.setMonth(t.getMonth() + 1), this.endCalendarViewDate = t;
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
selectDate(e, t) {
|
|
290
|
-
e === "start" ? this.startDate = t : this.endDate = t, this.updateInputValue(), this.updateQuickOptionsActiveState();
|
|
291
|
-
},
|
|
292
|
-
generateCalendarDays(e, t, n, r) {
|
|
293
|
-
const l = e.getFullYear(), i = e.getMonth(), d = new Date(l, i, 1), h = new Date(l, i + 1, 0), a = d.getDay(), D = new Date(l, i, 0).getDate(), k = [], I = /* @__PURE__ */ new Date();
|
|
294
|
-
for (let o = a - 1; o >= 0; o--) {
|
|
295
|
-
const u = new Date(l, i - 1, D - o);
|
|
296
|
-
k.push({
|
|
297
|
-
id: `prev-${o}-${r}`,
|
|
298
|
-
day: D - o,
|
|
299
|
-
date: u,
|
|
300
|
-
isCurrentMonth: !1,
|
|
301
|
-
isSelected: this.isSameDay(u, r === "start" ? t : n),
|
|
302
|
-
isToday: this.isSameDay(u, I),
|
|
303
|
-
isInRange: this.isDateInRange(u, t, n)
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
for (let o = 1; o <= h.getDate(); o++) {
|
|
307
|
-
const u = new Date(l, i, o);
|
|
308
|
-
k.push({
|
|
309
|
-
id: `current-${o}-${r}`,
|
|
310
|
-
day: o,
|
|
311
|
-
date: u,
|
|
312
|
-
isCurrentMonth: !0,
|
|
313
|
-
isSelected: this.isSameDay(u, r === "start" ? t : n),
|
|
314
|
-
isToday: this.isSameDay(u, I),
|
|
315
|
-
isInRange: this.isDateInRange(u, t, n)
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
const F = 42 - k.length;
|
|
319
|
-
for (let o = 1; o <= F; o++) {
|
|
320
|
-
const u = new Date(l, i + 1, o);
|
|
321
|
-
k.push({
|
|
322
|
-
id: `next-${o}-${r}`,
|
|
323
|
-
day: o,
|
|
324
|
-
date: u,
|
|
325
|
-
isCurrentMonth: !1,
|
|
326
|
-
isSelected: this.isSameDay(u, r === "start" ? t : n),
|
|
327
|
-
isToday: this.isSameDay(u, I),
|
|
328
|
-
isInRange: this.isDateInRange(u, t, n)
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
return k;
|
|
332
|
-
},
|
|
333
|
-
isSameDay(e, t) {
|
|
334
|
-
return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
335
|
-
},
|
|
336
|
-
isDateInRange(e, t, n) {
|
|
337
|
-
return e >= t && e <= n;
|
|
338
|
-
},
|
|
339
|
-
applyQuickOption(e) {
|
|
340
|
-
const t = /* @__PURE__ */ new Date();
|
|
341
|
-
let n = /* @__PURE__ */ new Date(), r = /* @__PURE__ */ new Date();
|
|
342
|
-
switch (e.type) {
|
|
343
|
-
case "days":
|
|
344
|
-
n = new Date(t.getTime() - e.value * 24 * 60 * 60 * 1e3);
|
|
345
|
-
break;
|
|
346
|
-
case "months":
|
|
347
|
-
n = new Date(t.getFullYear(), t.getMonth() - e.value, t.getDate());
|
|
348
|
-
break;
|
|
349
|
-
case "years":
|
|
350
|
-
n = new Date(t.getFullYear() - e.value, t.getMonth(), t.getDate());
|
|
351
|
-
break;
|
|
352
|
-
case "today":
|
|
353
|
-
e.value === "full" && (n = new Date(t.getFullYear(), t.getMonth(), t.getDate()), r = new Date(t.getFullYear(), t.getMonth(), t.getDate()));
|
|
354
|
-
break;
|
|
355
|
-
case "yesterday":
|
|
356
|
-
if (e.value === "full") {
|
|
357
|
-
const l = new Date(t.getTime() - 864e5);
|
|
358
|
-
n = new Date(l.getFullYear(), l.getMonth(), l.getDate()), r = new Date(l.getFullYear(), l.getMonth(), l.getDate());
|
|
359
|
-
}
|
|
360
|
-
break;
|
|
361
|
-
case "thisWeek": {
|
|
362
|
-
const l = t.getDay(), i = new Date(t.getTime() - l * 24 * 60 * 60 * 1e3);
|
|
363
|
-
if (e.value === "full") {
|
|
364
|
-
n = new Date(i.getFullYear(), i.getMonth(), i.getDate());
|
|
365
|
-
const d = new Date(i.getTime() + 6 * 24 * 60 * 60 * 1e3);
|
|
366
|
-
r = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
367
|
-
}
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
case "thisMonth":
|
|
371
|
-
e.value === "full" && (n = new Date(t.getFullYear(), t.getMonth(), 1), r = new Date(t.getFullYear(), t.getMonth() + 1, 0));
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
this.startDate = n, this.endDate = r, this.updateInputValue(), this.updateQuickOptionsActiveState(), this.startCalendarViewDate = new Date(this.startDate), this.endCalendarViewDate = new Date(this.endDate);
|
|
375
|
-
},
|
|
376
|
-
updateQuickOptionsActiveState() {
|
|
377
|
-
Object.keys(this.quickOptions).forEach((e) => {
|
|
378
|
-
this.quickOptions[e].forEach((t) => {
|
|
379
|
-
t.active = !1;
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
},
|
|
383
|
-
formatRangeDisplay() {
|
|
384
|
-
const e = (t) => {
|
|
385
|
-
const n = t.getFullYear(), r = String(t.getMonth() + 1).padStart(2, "0"), l = String(t.getDate()).padStart(2, "0");
|
|
386
|
-
return `${n}-${r}-${l}`;
|
|
387
|
-
};
|
|
388
|
-
return `${e(this.startDate)} ~ ${e(this.endDate)}`;
|
|
389
|
-
},
|
|
390
|
-
clickStop(e) {
|
|
391
|
-
e.stopPropagation();
|
|
392
|
-
},
|
|
393
|
-
confirmSelection() {
|
|
394
|
-
this.selectedRange = this.formatRangeDisplay(), this.inputValue = this.selectedRange, this.showPanel = !1;
|
|
395
|
-
},
|
|
396
|
-
blurInput() {
|
|
397
|
-
this.mouseOver == !1 && (this.showPanel = !1);
|
|
398
|
-
},
|
|
399
|
-
handleMouseOver() {
|
|
400
|
-
this.mouseOver = !0;
|
|
401
|
-
},
|
|
402
|
-
handleMouseOut() {
|
|
403
|
-
this.mouseOver = !1;
|
|
404
|
-
},
|
|
405
|
-
modelClick() {
|
|
406
|
-
this.showPanel = !1;
|
|
407
|
-
const t = this.inputValue.split("~").map((n) => n.trim());
|
|
408
|
-
this.$emit("changeTime", t);
|
|
409
|
-
},
|
|
410
|
-
handleListener() {
|
|
411
|
-
const e = document.getElementById("content"), t = document.getElementById("timePanel");
|
|
412
|
-
document.addEventListener("click", (n) => {
|
|
413
|
-
const r = e.contains(n.target), l = t.contains(n.target);
|
|
414
|
-
r || l || this.modelClick();
|
|
415
|
-
});
|
|
416
|
-
},
|
|
417
|
-
openShowPanel() {
|
|
418
|
-
this.showPanel = !0, this.handleListener();
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}, b = {
|
|
422
|
-
class: "container",
|
|
423
|
-
id: "content"
|
|
424
|
-
}, x = { class: "content" }, T = { class: "huiyi-time-input-section" }, R = { class: "huiyi-time-input-field" }, A = { class: "huiyi-time-panel-body" }, E = { class: "huiyi-time-quick-options" }, q = { class: "option-group" }, Q = { class: "option-group" }, L = ["onClick"], B = { class: "option-group" }, U = ["onClick"], W = { class: "option-group" }, N = ["onClick"], K = { class: "option-group" }, $ = ["onClick"], z = { class: "huiyi-time-panels-container" }, j = { class: "huiyi-time-date-panel" }, G = { class: "calendar-section" }, H = { class: "huiyi-time-calendar-header" }, J = { class: "huiyi-time-current-month" }, X = { class: "huiyi-time-calendar-days" }, Z = ["onClick"], tt = { class: "huiyi-time-date-panel" }, et = { class: "calendar-section" }, nt = { class: "huiyi-time-calendar-header" }, at = { class: "huiyi-time-current-month" }, it = { class: "huiyi-time-calendar-days" }, st = ["onClick"];
|
|
425
|
-
function lt(e, t, n, r, l, i) {
|
|
426
|
-
const d = Y("el-input"), h = Y("el-button");
|
|
427
|
-
return c(), p("div", {
|
|
428
|
-
id: "huiyi-time-app",
|
|
429
|
-
onMouseover: t[12] || (t[12] = (...a) => i.handleMouseOver && i.handleMouseOver(...a)),
|
|
430
|
-
onMouseleave: t[13] || (t[13] = (...a) => i.handleMouseOut && i.handleMouseOut(...a))
|
|
431
|
-
}, [
|
|
432
|
-
s("div", b, [
|
|
433
|
-
s("div", x, [
|
|
434
|
-
s("div", T, [
|
|
435
|
-
s("div", R, [
|
|
436
|
-
g(d, {
|
|
437
|
-
type: "text",
|
|
438
|
-
id: "datetime-input",
|
|
439
|
-
class: y(["huiyi-time-datetime-input", { invalid: l.isInvalid }]),
|
|
440
|
-
modelValue: l.inputValue,
|
|
441
|
-
"onUpdate:modelValue": t[0] || (t[0] = (a) => l.inputValue = a),
|
|
442
|
-
placeholder: "YYYY-MM-DD ~ YYYY-MM-DD",
|
|
443
|
-
onMouseup: i.onInputFocus,
|
|
444
|
-
onBlur: i.onInputBlur,
|
|
445
|
-
onKeydown: i.onInputKeydown,
|
|
446
|
-
onInput: i.onInputChange,
|
|
447
|
-
onClick: t[1] || (t[1] = (a) => i.openShowPanel())
|
|
448
|
-
}, null, 8, ["class", "modelValue", "onMouseup", "onBlur", "onKeydown", "onInput"])
|
|
449
|
-
])
|
|
450
|
-
])
|
|
451
|
-
])
|
|
452
|
-
]),
|
|
453
|
-
s("div", {
|
|
454
|
-
class: "huiyi-time-time-panel",
|
|
455
|
-
style: S(l.showPanel ? "display:visible" : "display:none"),
|
|
456
|
-
id: "timePanel"
|
|
457
|
-
}, [
|
|
458
|
-
s("div", {
|
|
459
|
-
class: "huiyi-time-panel-container",
|
|
460
|
-
onClick: t[11] || (t[11] = m((...a) => i.clickStop && i.clickStop(...a), ["stop"]))
|
|
461
|
-
}, [
|
|
462
|
-
s("div", A, [
|
|
463
|
-
s("div", E, [
|
|
464
|
-
s("div", q, [
|
|
465
|
-
s("div", {
|
|
466
|
-
class: "huiyi-time-quick-option",
|
|
467
|
-
onClick: t[2] || (t[2] = m((a) => i.applyQuickOption({ name: "今天", type: "today", value: "full", active: !1 }), ["stop"]))
|
|
468
|
-
}, [
|
|
469
|
-
g(h, {
|
|
470
|
-
type: "primary",
|
|
471
|
-
plain: "",
|
|
472
|
-
text: "",
|
|
473
|
-
bg: ""
|
|
474
|
-
}, {
|
|
475
|
-
default: C(() => [...t[14] || (t[14] = [
|
|
476
|
-
M(" 今天 ", -1)
|
|
477
|
-
])]),
|
|
478
|
-
_: 1
|
|
479
|
-
})
|
|
480
|
-
])
|
|
481
|
-
]),
|
|
482
|
-
s("div", Q, [
|
|
483
|
-
(c(!0), p(f, null, w(l.quickOptions.yesterday, (a) => (c(), p("div", {
|
|
484
|
-
key: a.name,
|
|
485
|
-
class: y(["huiyi-time-quick-option", { active: a.active }]),
|
|
486
|
-
onClick: m((D) => i.applyQuickOption(a), ["stop"])
|
|
487
|
-
}, [
|
|
488
|
-
g(h, {
|
|
489
|
-
type: "primary",
|
|
490
|
-
text: "",
|
|
491
|
-
bg: ""
|
|
492
|
-
}, {
|
|
493
|
-
default: C(() => [
|
|
494
|
-
M(v(a.name), 1)
|
|
495
|
-
]),
|
|
496
|
-
_: 2
|
|
497
|
-
}, 1024)
|
|
498
|
-
], 10, L))), 128))
|
|
499
|
-
]),
|
|
500
|
-
s("div", B, [
|
|
501
|
-
(c(!0), p(f, null, w(l.quickOptions.thisWeek, (a) => (c(), p("div", {
|
|
502
|
-
key: a.name,
|
|
503
|
-
class: y(["huiyi-time-quick-option", { active: a.active }]),
|
|
504
|
-
onClick: m((D) => i.applyQuickOption(a), ["stop"])
|
|
505
|
-
}, [
|
|
506
|
-
g(h, {
|
|
507
|
-
type: "primary",
|
|
508
|
-
text: "",
|
|
509
|
-
bg: ""
|
|
510
|
-
}, {
|
|
511
|
-
default: C(() => [
|
|
512
|
-
M(v(a.name), 1)
|
|
513
|
-
]),
|
|
514
|
-
_: 2
|
|
515
|
-
}, 1024)
|
|
516
|
-
], 10, U))), 128))
|
|
517
|
-
]),
|
|
518
|
-
s("div", W, [
|
|
519
|
-
(c(!0), p(f, null, w(l.quickOptions.thisMonth, (a) => (c(), p("div", {
|
|
520
|
-
key: a.name,
|
|
521
|
-
class: y(["huiyi-time-quick-option", { active: a.active }]),
|
|
522
|
-
onClick: m((D) => i.applyQuickOption(a), ["stop"])
|
|
523
|
-
}, [
|
|
524
|
-
g(h, {
|
|
525
|
-
type: "primary",
|
|
526
|
-
text: "",
|
|
527
|
-
bg: ""
|
|
528
|
-
}, {
|
|
529
|
-
default: C(() => [
|
|
530
|
-
M(v(a.name), 1)
|
|
531
|
-
]),
|
|
532
|
-
_: 2
|
|
533
|
-
}, 1024)
|
|
534
|
-
], 10, N))), 128))
|
|
535
|
-
]),
|
|
536
|
-
s("div", K, [
|
|
537
|
-
(c(!0), p(f, null, w(l.quickOptions.common, (a) => (c(), p("div", {
|
|
538
|
-
key: a.name,
|
|
539
|
-
class: y(["huiyi-time-quick-option", { active: a.active }]),
|
|
540
|
-
onClick: m((D) => i.applyQuickOption(a), ["stop"])
|
|
541
|
-
}, [
|
|
542
|
-
g(h, {
|
|
543
|
-
type: "primary",
|
|
544
|
-
text: "",
|
|
545
|
-
bg: ""
|
|
546
|
-
}, {
|
|
547
|
-
default: C(() => [
|
|
548
|
-
M(v(a.name), 1)
|
|
549
|
-
]),
|
|
550
|
-
_: 2
|
|
551
|
-
}, 1024)
|
|
552
|
-
], 10, $))), 128))
|
|
553
|
-
])
|
|
554
|
-
]),
|
|
555
|
-
s("div", z, [
|
|
556
|
-
s("div", j, [
|
|
557
|
-
s("div", G, [
|
|
558
|
-
s("div", H, [
|
|
559
|
-
s("div", {
|
|
560
|
-
class: "huiyi-time-year-nav",
|
|
561
|
-
onClick: t[3] || (t[3] = (a) => i.prevYear("start"))
|
|
562
|
-
}, "<<"),
|
|
563
|
-
s("div", {
|
|
564
|
-
class: "huiyi-time-month-nav",
|
|
565
|
-
onClick: t[4] || (t[4] = (a) => i.prevMonth("start"))
|
|
566
|
-
}, "<"),
|
|
567
|
-
s("div", J, v(i.startDateMonthYear), 1),
|
|
568
|
-
s("div", {
|
|
569
|
-
class: "huiyi-time-month-nav",
|
|
570
|
-
onClick: t[5] || (t[5] = (a) => i.nextMonth("start"))
|
|
571
|
-
}, ">"),
|
|
572
|
-
s("div", {
|
|
573
|
-
class: "huiyi-time-year-nav",
|
|
574
|
-
onClick: t[6] || (t[6] = (a) => i.nextYear("start"))
|
|
575
|
-
}, ">>")
|
|
576
|
-
]),
|
|
577
|
-
t[15] || (t[15] = s("div", { class: "huiyi-time-week-days" }, [
|
|
578
|
-
s("div", null, "日"),
|
|
579
|
-
s("div", null, "一"),
|
|
580
|
-
s("div", null, "二"),
|
|
581
|
-
s("div", null, "三"),
|
|
582
|
-
s("div", null, "四"),
|
|
583
|
-
s("div", null, "五"),
|
|
584
|
-
s("div", null, "六")
|
|
585
|
-
], -1)),
|
|
586
|
-
s("div", X, [
|
|
587
|
-
(c(!0), p(f, null, w(i.startCalendarDays, (a) => (c(), p("div", {
|
|
588
|
-
key: a.id,
|
|
589
|
-
class: y(["huiyi-time-calendar-day", {
|
|
590
|
-
"other-month": !a.isCurrentMonth,
|
|
591
|
-
selected: a.isSelected,
|
|
592
|
-
today: a.isToday,
|
|
593
|
-
"in-range": a.isInRange
|
|
594
|
-
}]),
|
|
595
|
-
onClick: m((D) => i.selectDate("start", a.date), ["stop"])
|
|
596
|
-
}, v(a.day), 11, Z))), 128))
|
|
597
|
-
])
|
|
598
|
-
])
|
|
599
|
-
]),
|
|
600
|
-
s("div", tt, [
|
|
601
|
-
s("div", et, [
|
|
602
|
-
s("div", nt, [
|
|
603
|
-
s("div", {
|
|
604
|
-
class: "huiyi-time-year-nav",
|
|
605
|
-
onClick: t[7] || (t[7] = (a) => i.prevYear("end"))
|
|
606
|
-
}, "<<"),
|
|
607
|
-
s("div", {
|
|
608
|
-
class: "huiyi-time-month-nav",
|
|
609
|
-
onClick: t[8] || (t[8] = m((a) => i.prevMonth("end"), ["stop"]))
|
|
610
|
-
}, "<"),
|
|
611
|
-
s("div", at, v(i.endDateMonthYear), 1),
|
|
612
|
-
s("div", {
|
|
613
|
-
class: "huiyi-time-month-nav",
|
|
614
|
-
onClick: t[9] || (t[9] = m((a) => i.nextMonth("end"), ["stop"]))
|
|
615
|
-
}, ">"),
|
|
616
|
-
s("div", {
|
|
617
|
-
class: "huiyi-time-year-nav",
|
|
618
|
-
onClick: t[10] || (t[10] = (a) => i.nextYear("end"))
|
|
619
|
-
}, ">>")
|
|
620
|
-
]),
|
|
621
|
-
t[16] || (t[16] = s("div", { class: "huiyi-time-week-days" }, [
|
|
622
|
-
s("div", null, "日"),
|
|
623
|
-
s("div", null, "一"),
|
|
624
|
-
s("div", null, "二"),
|
|
625
|
-
s("div", null, "三"),
|
|
626
|
-
s("div", null, "四"),
|
|
627
|
-
s("div", null, "五"),
|
|
628
|
-
s("div", null, "六")
|
|
629
|
-
], -1)),
|
|
630
|
-
s("div", it, [
|
|
631
|
-
(c(!0), p(f, null, w(i.endCalendarDays, (a) => (c(), p("div", {
|
|
632
|
-
key: a.id,
|
|
633
|
-
class: y(["huiyi-time-calendar-day", {
|
|
634
|
-
"other-month": !a.isCurrentMonth,
|
|
635
|
-
selected: a.isSelected,
|
|
636
|
-
today: a.isToday,
|
|
637
|
-
"in-range": a.isInRange
|
|
638
|
-
}]),
|
|
639
|
-
onClick: m((D) => i.selectDate("end", a.date), ["stop"])
|
|
640
|
-
}, v(a.day), 11, st))), 128))
|
|
641
|
-
])
|
|
642
|
-
])
|
|
643
|
-
])
|
|
644
|
-
])
|
|
645
|
-
])
|
|
646
|
-
])
|
|
647
|
-
], 4)
|
|
648
|
-
], 32);
|
|
649
|
-
}
|
|
650
|
-
const V = /* @__PURE__ */ O(P, [["render", lt], ["__scopeId", "data-v-f5587819"]]);
|
|
651
|
-
V.install = (e) => {
|
|
652
|
-
e.component(V.name, V);
|
|
653
|
-
};
|
|
654
|
-
const rt = [
|
|
655
|
-
V
|
|
656
|
-
], _ = function(e) {
|
|
657
|
-
_.installed || rt.forEach((t) => {
|
|
658
|
-
e.component(t.name, t);
|
|
659
|
-
});
|
|
660
|
-
};
|
|
661
|
-
typeof window < "u" && window.Vue && _(window.Vue);
|
|
662
|
-
const ut = {
|
|
663
|
-
install: _,
|
|
664
|
-
TimeComponentsUp: V
|
|
665
|
-
};
|
|
666
|
-
export {
|
|
667
|
-
V as TimeComponentsUp,
|
|
668
|
-
ut as default,
|
|
669
|
-
_ as install
|
|
670
|
-
};
|
package/dist/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#huiyi-time-app[data-v-f5587819]{position:relative}.huiyi-time-input-section[data-v-f5587819]{display:flex;flex-direction:column;align-items:center}.huiyi-time-input-field[data-v-f5587819]{width:100%;max-width:190px}.huiyi-time-time-panel[data-v-f5587819]{width:600px;height:300px;justify-content:center;align-items:center;z-index:10000;position:fixed}.huiyi-time-panel-container[data-v-f5587819]{background:white;border-radius:15px;width:98%;max-width:600px;box-shadow:0 15px 30px #0000004d;overflow:hidden;display:flex;flex-direction:column;max-height:90vh}.huiyi-time-panel-body[data-v-f5587819]{display:flex;flex:1;overflow:hidden}.huiyi-time-quick-options[data-v-f5587819]{width:80px;background:#fff;padding:5px;border-right:1px solid #e9ecef;overflow-y:auto}.huiyi-time-quick-option[data-v-f5587819]{display:block;width:50px;padding:0 5px;background:white;border-radius:8px;text-align:left;margin-bottom:8px;cursor:pointer;transition:all .2s;font-size:.9rem}.huiyi-time-quick-option.active[data-v-f5587819]{background:#409eff;color:#fff;border-color:#409eff}.huiyi-time-panels-container[data-v-f5587819]{flex:1;display:flex;overflow:hidden}.huiyi-time-date-panel[data-v-f5587819]{flex:1;padding:10px;overflow-y:auto;width:360px;border-right:1px solid #e9ecef}.huiyi-time-date-panel[data-v-f5587819]:last-child{border-right:none}.huiyi-time-calendar-header[data-v-f5587819]{display:flex;justify-content:space-between;align-items:center;margin-bottom:11px}.huiyi-time-year-nav[data-v-f5587819]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-year-nav[data-v-f5587819]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-month-nav[data-v-f5587819]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-month-nav[data-v-f5587819]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-current-month[data-v-f5587819]{font-size:1.1rem;font-weight:600;color:#333}.huiyi-time-week-days[data-v-f5587819]{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;margin-bottom:6px;font-weight:600;color:#666;font-size:.85rem}.huiyi-time-calendar-days[data-v-f5587819]{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}.huiyi-time-calendar-day[data-v-f5587819]{height:30px;display:flex;align-items:center;justify-content:center;border-radius:6px;cursor:pointer;transition:all .2s;font-size:12px}.huiyi-time-calendar-day[data-v-f5587819]:hover{background:#e9ecef;color:var(--el-color-primary)}.huiyi-time-calendar-day.other-month[data-v-f5587819]{color:#ccc}.huiyi-time-calendar-day.selected[data-v-f5587819]{background:var(--el-color-primary)!important;color:#fff}.huiyi-time-calendar-day.today[data-v-f5587819]{background:#fff;color:var(--el-color-primary);font-weight:600}.huiyi-time-calendar-day.in-range[data-v-f5587819]{background:#e6eeff}@media (max-width: 900px){.huiyi-time-panel-body[data-v-f5587819]{flex-direction:column;max-height:none}.huiyi-time-quick-options[data-v-f5587819]{width:100%;border-right:none;border-bottom:1px solid #e9ecef;max-height:200px}.huiyi-time-panels-container[data-v-f5587819]{flex-direction:column}.huiyi-time-date-panel[data-v-f5587819]{border-right:none;border-bottom:1px solid #e9ecef}.huiyi-time-date-panel[data-v-f5587819]:last-child{border-bottom:none}}
|
package/huiyi-time/favicon.ico
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(u,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(u=typeof globalThis<"u"?globalThis:u||self,t(u.HuiyiTime={},u.Vue))})(this,function(u,t){"use strict";const X="",Z="",f=(n,e)=>{const a=n.__vccOpts||n;for(const[r,l]of e)a[r]=l;return a},w={name:"TimeComponentsUp",props:{initTime:{type:String,default:""}},data(){return{showPanel:!1,startDate:new Date,endDate:new Date,activeControl:"startYear",selectedRange:null,inputValue:"",isInvalid:!1,inputSelection:{start:0,end:0},mouseOver:!1,startCalendarViewDate:new Date,endCalendarViewDate:new Date,quickOptions:{common:[{name:"近3月",type:"months",value:3,active:!1},{name:"近1年",type:"years",value:1,active:!1}],today:[],yesterday:[{name:"昨天",type:"yesterday",value:"full",active:!1}],thisWeek:[{name:"本周",type:"thisWeek",value:"full",active:!1}],thisMonth:[{name:"本月",type:"thisMonth",value:"full",active:!1}]},dateFormatter:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"2-digit"})}},computed:{startDateMonthYear(){const n=this.startCalendarViewDate.getFullYear(),e=this.startCalendarViewDate.getMonth()+1;return`${n}年${e}月`},endDateMonthYear(){const n=this.endCalendarViewDate.getFullYear(),e=this.endCalendarViewDate.getMonth()+1;return`${n}年${e}月`},startCalendarDays(){return this.generateCalendarDays(this.startCalendarViewDate,this.startDate,this.endDate,"start")},endCalendarDays(){return this.generateCalendarDays(this.endCalendarViewDate,this.startDate,this.endDate,"end")},fieldPositions(){return[{name:"startYear",start:0,end:4,length:4},{name:"startMonth",start:5,end:7,length:2},{name:"startDay",start:8,end:10,length:2},{name:"endYear",start:13,end:17,length:4},{name:"endMonth",start:18,end:20,length:2},{name:"endDay",start:21,end:23,length:2}]}},mounted(){this.inputValue=this.initTime,this.updateQuickOptionsActiveState()},methods:{setActiveControl(n){this.activeControl=n},updateInputValue(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};this.inputValue=`${n(this.startDate)} ~ ${n(this.endDate)}`,this.modelClick()},onInputFocus(n){setTimeout(()=>{this.inputSelection={start:n.target.selectionStart,end:n.target.selectionEnd},this.selectCurrentField(this.inputSelection.start)},0)},onInputBlur(){this.validateInput()},onInputChange(){this.validateInput()},onInputKeydown(n){const e=n.key;["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e)&&(n.preventDefault(),e==="ArrowLeft"?this.navigateLeft():e==="ArrowRight"?this.navigateRight():e==="ArrowUp"?this.incrementValue():e==="ArrowDown"&&this.decrementValue()),e==="Tab"&&(n.preventDefault(),n.shiftKey?this.navigateLeft():this.navigateRight()),e==="Enter"&&(n.preventDefault(),this.showPanel=!1)},navigateLeft(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a>0?e=this.fieldPositions[a-1]:e=this.fieldPositions[this.fieldPositions.length-1];break}e||(e=this.fieldPositions[0]),this.selectField(e)},navigateRight(){const n=this.inputSelection.start;let e=null;for(let a=0;a<this.fieldPositions.length;a++)if(n>=this.fieldPositions[a].start&&n<=this.fieldPositions[a].end){a<this.fieldPositions.length-1?e=this.fieldPositions[a+1]:e=this.fieldPositions[0];break}e||(e=this.fieldPositions[0]),this.selectField(e)},selectCurrentField(n){for(const e of this.fieldPositions)if(n>=e.start&&n<=e.end){this.selectField(e);return}this.selectField(this.fieldPositions[0])},selectField(n){document.getElementById("datetime-input").setSelectionRange(n.start,n.end),this.inputSelection={start:n.start,end:n.end},this.activeControl=n.name},incrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))+1;switch(n.name){case"startYear":case"endYear":break;case"startMonth":case"endMonth":a>12&&(a=1);break;case"startDay":case"endDay":a>31&&(a=1);break}this.updateFieldValue(n,a)},decrementValue(){const n=this.getCurrentField();if(!n)return;let a=parseInt(this.inputValue.substring(n.start,n.end))-1;switch(n.name){case"startYear":case"endYear":a<1&&(a=9999);break;case"startMonth":case"endMonth":a<1&&(a=12);break;case"startDay":case"endDay":a<1&&(a=31);break}this.updateFieldValue(n,a)},getCurrentField(){for(const n of this.fieldPositions)if(this.inputSelection.start>=n.start&&this.inputSelection.start<=n.end)return n;return null},updateFieldValue(n,e){const a=String(e).padStart(n.length,"0"),r=this.inputValue.substring(0,n.start)+a+this.inputValue.substring(n.end);this.inputValue=r,this.$nextTick(()=>{this.selectField(n)}),this.updateDateFromInput()},updateDateFromInput(){if(!this.validateInputFormat())return;const n=this.inputValue.split(/[''~-]/);if(n.length!==6)return;const e=parseInt(n[0]),a=parseInt(n[1])-1,r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4])-1,d=parseInt(n[5]),h=new Date(e,a,r),i=new Date(l,s,d);if(isNaN(h.getTime())||isNaN(i.getTime())){this.isInvalid=!0;return}this.startDate=h,this.endDate=i,this.isInvalid=!1,this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},validateInputFormat(){return/^\d{4}-\d{2}-\d{2} ~ \d{4}-\d{2}-\d{2}$/.test(this.inputValue)},validateInput(){if(!this.validateInputFormat()){this.isInvalid=!0;return}const n=this.inputValue.split(/[ ~-]/),e=parseInt(n[0]),a=parseInt(n[1]),r=parseInt(n[2]),l=parseInt(n[3]),s=parseInt(n[4]),d=parseInt(n[5]);if(a<1||a>12||s<1||s>12){this.isInvalid=!0;return}if(r<1||r>31||d<1||d>31){this.isInvalid=!0;return}const h=new Date(e,a-1,r),i=new Date(l,s-1,d);if(h.getMonth()!==a-1||h.getDate()!==r||i.getMonth()!==s-1||i.getDate()!==d){this.isInvalid=!0;return}this.isInvalid=!1},prevYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()-1),this.endCalendarViewDate=e}},nextYear(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setFullYear(e.getFullYear()+1),this.endCalendarViewDate=e}},prevMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()-1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()-1),this.endCalendarViewDate=e}},nextMonth(n){if(n==="start"){const e=new Date(this.startCalendarViewDate);e.setMonth(e.getMonth()+1),this.startCalendarViewDate=e}else{const e=new Date(this.endCalendarViewDate);e.setMonth(e.getMonth()+1),this.endCalendarViewDate=e}},selectDate(n,e){n==="start"?this.startDate=e:this.endDate=e,this.updateInputValue(),this.updateQuickOptionsActiveState()},generateCalendarDays(n,e,a,r){const l=n.getFullYear(),s=n.getMonth(),d=new Date(l,s,1),h=new Date(l,s+1,0),i=d.getDay(),m=new Date(l,s,0).getDate(),D=[],g=new Date;for(let o=i-1;o>=0;o--){const c=new Date(l,s-1,m-o);D.push({id:`prev-${o}-${r}`,day:m-o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}for(let o=1;o<=h.getDate();o++){const c=new Date(l,s,o);D.push({id:`current-${o}-${r}`,day:o,date:c,isCurrentMonth:!0,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}const J=42-D.length;for(let o=1;o<=J;o++){const c=new Date(l,s+1,o);D.push({id:`next-${o}-${r}`,day:o,date:c,isCurrentMonth:!1,isSelected:this.isSameDay(c,r==="start"?e:a),isToday:this.isSameDay(c,g),isInRange:this.isDateInRange(c,e,a)})}return D},isSameDay(n,e){return n.getFullYear()===e.getFullYear()&&n.getMonth()===e.getMonth()&&n.getDate()===e.getDate()},isDateInRange(n,e,a){return n>=e&&n<=a},applyQuickOption(n){const e=new Date;let a=new Date,r=new Date;switch(n.type){case"days":a=new Date(e.getTime()-n.value*24*60*60*1e3);break;case"months":a=new Date(e.getFullYear(),e.getMonth()-n.value,e.getDate());break;case"years":a=new Date(e.getFullYear()-n.value,e.getMonth(),e.getDate());break;case"today":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()));break;case"yesterday":if(n.value==="full"){const l=new Date(e.getTime()-864e5);a=new Date(l.getFullYear(),l.getMonth(),l.getDate()),r=new Date(l.getFullYear(),l.getMonth(),l.getDate())}break;case"thisWeek":{const l=e.getDay(),s=new Date(e.getTime()-l*24*60*60*1e3);if(n.value==="full"){a=new Date(s.getFullYear(),s.getMonth(),s.getDate());const d=new Date(s.getTime()+6*24*60*60*1e3);r=new Date(d.getFullYear(),d.getMonth(),d.getDate())}break}case"thisMonth":n.value==="full"&&(a=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+1,0));break}this.startDate=a,this.endDate=r,this.updateInputValue(),this.updateQuickOptionsActiveState(),this.startCalendarViewDate=new Date(this.startDate),this.endCalendarViewDate=new Date(this.endDate)},updateQuickOptionsActiveState(){Object.keys(this.quickOptions).forEach(n=>{this.quickOptions[n].forEach(e=>{e.active=!1})})},formatRangeDisplay(){const n=e=>{const a=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),l=String(e.getDate()).padStart(2,"0");return`${a}-${r}-${l}`};return`${n(this.startDate)} ~ ${n(this.endDate)}`},clickStop(n){n.stopPropagation()},confirmSelection(){this.selectedRange=this.formatRangeDisplay(),this.inputValue=this.selectedRange,this.showPanel=!1},blurInput(){this.mouseOver==!1&&(this.showPanel=!1)},handleMouseOver(){this.mouseOver=!0},handleMouseOut(){this.mouseOver=!1},modelClick(){this.showPanel=!1;const e=this.inputValue.split("~").map(a=>a.trim());this.$emit("changeTime",e)},handleListener(){const n=document.getElementById("content"),e=document.getElementById("timePanel");document.addEventListener("click",a=>{const r=n.contains(a.target),l=e.contains(a.target);r||l||this.modelClick()})},openShowPanel(){this.showPanel=!0,this.handleListener()}}},V={class:"container",id:"content"},k={class:"content"},C={class:"huiyi-time-input-section"},M={class:"huiyi-time-input-field"},E={class:"huiyi-time-panel-body"},N={class:"huiyi-time-quick-options"},_={class:"option-group"},I={class:"option-group"},S=["onClick"],F={class:"option-group"},Y=["onClick"],v={class:"option-group"},O=["onClick"],b={class:"option-group"},B=["onClick"],P={class:"huiyi-time-panels-container"},T={class:"huiyi-time-date-panel"},x={class:"calendar-section"},R={class:"huiyi-time-calendar-header"},L={class:"huiyi-time-current-month"},q={class:"huiyi-time-calendar-days"},A=["onClick"],Q={class:"huiyi-time-date-panel"},U={class:"calendar-section"},z={class:"huiyi-time-calendar-header"},W={class:"huiyi-time-current-month"},K={class:"huiyi-time-calendar-days"},$=["onClick"];function j(n,e,a,r,l,s){const d=t.resolveComponent("el-input"),h=t.resolveComponent("el-button");return t.openBlock(),t.createElementBlock("div",{id:"huiyi-time-app",onMouseover:e[12]||(e[12]=(...i)=>s.handleMouseOver&&s.handleMouseOver(...i)),onMouseleave:e[13]||(e[13]=(...i)=>s.handleMouseOut&&s.handleMouseOut(...i))},[t.createElementVNode("div",V,[t.createElementVNode("div",k,[t.createElementVNode("div",C,[t.createElementVNode("div",M,[t.createVNode(d,{type:"text",id:"datetime-input",class:t.normalizeClass(["huiyi-time-datetime-input",{invalid:l.isInvalid}]),modelValue:l.inputValue,"onUpdate:modelValue":e[0]||(e[0]=i=>l.inputValue=i),placeholder:"YYYY-MM-DD ~ YYYY-MM-DD",onMouseup:s.onInputFocus,onBlur:s.onInputBlur,onKeydown:s.onInputKeydown,onInput:s.onInputChange,onClick:e[1]||(e[1]=i=>s.openShowPanel())},null,8,["class","modelValue","onMouseup","onBlur","onKeydown","onInput"])])])])]),t.createElementVNode("div",{class:"huiyi-time-time-panel",style:t.normalizeStyle(l.showPanel?"display:visible":"display:none"),id:"timePanel"},[t.createElementVNode("div",{class:"huiyi-time-panel-container",onClick:e[11]||(e[11]=t.withModifiers((...i)=>s.clickStop&&s.clickStop(...i),["stop"]))},[t.createElementVNode("div",E,[t.createElementVNode("div",N,[t.createElementVNode("div",_,[t.createElementVNode("div",{class:"huiyi-time-quick-option",onClick:e[2]||(e[2]=t.withModifiers(i=>s.applyQuickOption({name:"今天",type:"today",value:"full",active:!1}),["stop"]))},[t.createVNode(h,{type:"primary",plain:"",text:"",bg:""},{default:t.withCtx(()=>[...e[14]||(e[14]=[t.createTextVNode(" 今天 ",-1)])]),_:1})])]),t.createElementVNode("div",I,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.yesterday,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,S))),128))]),t.createElementVNode("div",F,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisWeek,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,Y))),128))]),t.createElementVNode("div",v,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.thisMonth,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,O))),128))]),t.createElementVNode("div",b,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(l.quickOptions.common,i=>(t.openBlock(),t.createElementBlock("div",{key:i.name,class:t.normalizeClass(["huiyi-time-quick-option",{active:i.active}]),onClick:t.withModifiers(m=>s.applyQuickOption(i),["stop"])},[t.createVNode(h,{type:"primary",text:"",bg:""},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(i.name),1)]),_:2},1024)],10,B))),128))])]),t.createElementVNode("div",P,[t.createElementVNode("div",T,[t.createElementVNode("div",x,[t.createElementVNode("div",R,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[3]||(e[3]=i=>s.prevYear("start"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[4]||(e[4]=i=>s.prevMonth("start"))},"<"),t.createElementVNode("div",L,t.toDisplayString(s.startDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[5]||(e[5]=i=>s.nextMonth("start"))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[6]||(e[6]=i=>s.nextYear("start"))},">>")]),e[15]||(e[15]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",q,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.startCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("start",i.date),["stop"])},t.toDisplayString(i.day),11,A))),128))])])]),t.createElementVNode("div",Q,[t.createElementVNode("div",U,[t.createElementVNode("div",z,[t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[7]||(e[7]=i=>s.prevYear("end"))},"<<"),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[8]||(e[8]=t.withModifiers(i=>s.prevMonth("end"),["stop"]))},"<"),t.createElementVNode("div",W,t.toDisplayString(s.endDateMonthYear),1),t.createElementVNode("div",{class:"huiyi-time-month-nav",onClick:e[9]||(e[9]=t.withModifiers(i=>s.nextMonth("end"),["stop"]))},">"),t.createElementVNode("div",{class:"huiyi-time-year-nav",onClick:e[10]||(e[10]=i=>s.nextYear("end"))},">>")]),e[16]||(e[16]=t.createElementVNode("div",{class:"huiyi-time-week-days"},[t.createElementVNode("div",null,"日"),t.createElementVNode("div",null,"一"),t.createElementVNode("div",null,"二"),t.createElementVNode("div",null,"三"),t.createElementVNode("div",null,"四"),t.createElementVNode("div",null,"五"),t.createElementVNode("div",null,"六")],-1)),t.createElementVNode("div",K,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.endCalendarDays,i=>(t.openBlock(),t.createElementBlock("div",{key:i.id,class:t.normalizeClass(["huiyi-time-calendar-day",{"other-month":!i.isCurrentMonth,selected:i.isSelected,today:i.isToday,"in-range":i.isInRange}]),onClick:t.withModifiers(m=>s.selectDate("end",i.date),["stop"])},t.toDisplayString(i.day),11,$))),128))])])])])])])],4)],32)}const p=f(w,[["render",j],["__scopeId","data-v-f5587819"]]);p.install=n=>{n.component(p.name,p)};const H=[p],y=function(n){y.installed||H.forEach(e=>{n.component(e.name,e)})};typeof window<"u"&&window.Vue&&y(window.Vue);const G={install:y,TimeComponentsUp:p};u.TimeComponentsUp=p,u.default=G,u.install=y,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/huiyi-time/index.html
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
8
|
-
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<noscript>
|
|
12
|
-
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
13
|
-
</noscript>
|
|
14
|
-
<div id="app"></div>
|
|
15
|
-
<!-- built files will be auto injected -->
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
package/huiyi-time/package.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "huiyi-time",
|
|
3
|
-
"version": "0.1.12",
|
|
4
|
-
"description": "A Vue.js time range picker component",
|
|
5
|
-
"main": "huiyi-time.umd.js",
|
|
6
|
-
"module": "huiyi-time.es.js",
|
|
7
|
-
"unpkg": "huiyi-time.umd.js",
|
|
8
|
-
"browser": "huiyi-time.umd.js",
|
|
9
|
-
"keywords": [
|
|
10
|
-
"vue",
|
|
11
|
-
"component",
|
|
12
|
-
"time-picker",
|
|
13
|
-
"date-range"
|
|
14
|
-
],
|
|
15
|
-
"author": "Time Components Up",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"peerDependencies": {
|
|
18
|
-
"vue": "^3.0.0"
|
|
19
|
-
}
|
|
20
|
-
}
|
package/huiyi-time/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#huiyi-time-app[data-v-f5587819]{position:relative}.huiyi-time-input-section[data-v-f5587819]{display:flex;flex-direction:column;align-items:center}.huiyi-time-input-field[data-v-f5587819]{width:100%;max-width:190px}.huiyi-time-time-panel[data-v-f5587819]{width:600px;height:300px;justify-content:center;align-items:center;z-index:10000;position:fixed}.huiyi-time-panel-container[data-v-f5587819]{background:white;border-radius:15px;width:98%;max-width:600px;box-shadow:0 15px 30px #0000004d;overflow:hidden;display:flex;flex-direction:column;max-height:90vh}.huiyi-time-panel-body[data-v-f5587819]{display:flex;flex:1;overflow:hidden}.huiyi-time-quick-options[data-v-f5587819]{width:80px;background:#fff;padding:5px;border-right:1px solid #e9ecef;overflow-y:auto}.huiyi-time-quick-option[data-v-f5587819]{display:block;width:50px;padding:0 5px;background:white;border-radius:8px;text-align:left;margin-bottom:8px;cursor:pointer;transition:all .2s;font-size:.9rem}.huiyi-time-quick-option.active[data-v-f5587819]{background:#409eff;color:#fff;border-color:#409eff}.huiyi-time-panels-container[data-v-f5587819]{flex:1;display:flex;overflow:hidden}.huiyi-time-date-panel[data-v-f5587819]{flex:1;padding:10px;overflow-y:auto;width:360px;border-right:1px solid #e9ecef}.huiyi-time-date-panel[data-v-f5587819]:last-child{border-right:none}.huiyi-time-calendar-header[data-v-f5587819]{display:flex;justify-content:space-between;align-items:center;margin-bottom:11px}.huiyi-time-year-nav[data-v-f5587819]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-year-nav[data-v-f5587819]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-month-nav[data-v-f5587819]{border:none;width:25px;height:25px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:.8rem;transition:all .2s}.huiyi-time-month-nav[data-v-f5587819]:hover{background:#e9ecef;cursor:pointer}.huiyi-time-current-month[data-v-f5587819]{font-size:1.1rem;font-weight:600;color:#333}.huiyi-time-week-days[data-v-f5587819]{display:grid;grid-template-columns:repeat(7,1fr);text-align:center;margin-bottom:6px;font-weight:600;color:#666;font-size:.85rem}.huiyi-time-calendar-days[data-v-f5587819]{display:grid;grid-template-columns:repeat(7,1fr);gap:5px}.huiyi-time-calendar-day[data-v-f5587819]{height:30px;display:flex;align-items:center;justify-content:center;border-radius:6px;cursor:pointer;transition:all .2s;font-size:12px}.huiyi-time-calendar-day[data-v-f5587819]:hover{background:#e9ecef;color:var(--el-color-primary)}.huiyi-time-calendar-day.other-month[data-v-f5587819]{color:#ccc}.huiyi-time-calendar-day.selected[data-v-f5587819]{background:var(--el-color-primary)!important;color:#fff}.huiyi-time-calendar-day.today[data-v-f5587819]{background:#fff;color:var(--el-color-primary);font-weight:600}.huiyi-time-calendar-day.in-range[data-v-f5587819]{background:#e6eeff}@media (max-width: 900px){.huiyi-time-panel-body[data-v-f5587819]{flex-direction:column;max-height:none}.huiyi-time-quick-options[data-v-f5587819]{width:100%;border-right:none;border-bottom:1px solid #e9ecef;max-height:200px}.huiyi-time-panels-container[data-v-f5587819]{flex-direction:column}.huiyi-time-date-panel[data-v-f5587819]{border-right:none;border-bottom:1px solid #e9ecef}.huiyi-time-date-panel[data-v-f5587819]:last-child{border-bottom:none}}
|
package/huiyi-time-0.1.12.tgz
DELETED
|
Binary file
|
package/jsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"baseUrl": "./",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
"paths": {
|
|
8
|
-
"@/*": [
|
|
9
|
-
"src/*"
|
|
10
|
-
]
|
|
11
|
-
},
|
|
12
|
-
"lib": [
|
|
13
|
-
"esnext",
|
|
14
|
-
"dom",
|
|
15
|
-
"dom.iterable",
|
|
16
|
-
"scripthost"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
}
|
package/vite.config.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import { resolve } from 'path'
|
|
3
|
-
import vue from '@vitejs/plugin-vue'
|
|
4
|
-
|
|
5
|
-
// https://vitejs.dev/config/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [vue()],
|
|
8
|
-
resolve: {
|
|
9
|
-
alias: {
|
|
10
|
-
'@': resolve(__dirname, 'examples'),
|
|
11
|
-
'~': resolve(__dirname, 'packages')
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
build: {
|
|
15
|
-
lib: {
|
|
16
|
-
entry: resolve(__dirname, 'packages/index.js'),
|
|
17
|
-
name: 'HuiyiTime',
|
|
18
|
-
fileName: (format) => `huiyi-time.${format}.js`,
|
|
19
|
-
formats: ['es', 'umd']
|
|
20
|
-
},
|
|
21
|
-
rollupOptions: {
|
|
22
|
-
external: ['vue'],
|
|
23
|
-
output: {
|
|
24
|
-
// 为UMD格式提供全局变量名
|
|
25
|
-
globals: {
|
|
26
|
-
vue: 'Vue'
|
|
27
|
-
},
|
|
28
|
-
// 为ES格式明确导出模式
|
|
29
|
-
exports: 'named',
|
|
30
|
-
// 将CSS提取到单独的文件中
|
|
31
|
-
assetFileNames: (assetInfo) => {
|
|
32
|
-
if (assetInfo.name === 'style.css') {
|
|
33
|
-
return 'style.css';
|
|
34
|
-
}
|
|
35
|
-
return assetInfo.name;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
server: {
|
|
41
|
-
port: 8080
|
|
42
|
-
}
|
|
43
|
-
})
|
package/vue.config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
function resolve(dir) {
|
|
3
|
-
return path.join(__dirname, dir)
|
|
4
|
-
}
|
|
5
|
-
module.exports = {
|
|
6
|
-
// 修改 src 为 examples
|
|
7
|
-
pages: {
|
|
8
|
-
// lintOnSave: false,
|
|
9
|
-
index: {
|
|
10
|
-
entry: "examples/main.js",
|
|
11
|
-
template: "public/index.html",
|
|
12
|
-
filename: "index.html"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
// 组件样式内联
|
|
16
|
-
css: {
|
|
17
|
-
extract: false
|
|
18
|
-
},
|
|
19
|
-
// 扩展 webpack 配置,使 packages 加入编译
|
|
20
|
-
chainWebpack: config => {
|
|
21
|
-
config.resolve.alias
|
|
22
|
-
.set('@', resolve('examples'))
|
|
23
|
-
.set('~', resolve('packages'))
|
|
24
|
-
}
|
|
25
|
-
};
|
|
File without changes
|
|
File without changes
|