lddatetimepicker 0.0.1 → 0.0.2
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/CHANGELOG.md +6 -0
- package/index.css +11 -0
- package/index.js +2 -2
- package/index.min.css +1 -1
- package/index.min.js +1 -1
- package/package.json +1 -1
- package/theme.css +43 -0
- package/theme.min.css +1 -0
package/CHANGELOG.md
CHANGED
package/index.css
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
.lddtp-h {
|
|
2
2
|
display: grid;
|
|
3
3
|
grid-template-columns: 1fr 2.5fr 2.5fr 1fr;
|
|
4
|
+
padding: 0.33em 0;
|
|
4
5
|
}
|
|
5
6
|
.lddtp-h div {
|
|
6
7
|
border-radius: 0.25em;
|
|
@@ -13,6 +14,16 @@
|
|
|
13
14
|
flex: 1 0 auto;
|
|
14
15
|
text-align: center;
|
|
15
16
|
}
|
|
17
|
+
.lddtp-a:before,
|
|
18
|
+
.lddtp-a:after {
|
|
19
|
+
display: block;
|
|
20
|
+
}
|
|
21
|
+
.lddtp-a:first-child:before {
|
|
22
|
+
content: "\25c0";
|
|
23
|
+
}
|
|
24
|
+
.lddtp-a:last-child:before {
|
|
25
|
+
content: "\25ba";
|
|
26
|
+
}
|
|
16
27
|
.lddtp {
|
|
17
28
|
position: absolute;
|
|
18
29
|
z-index: 100;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(function(){
|
|
2
2
|
var html, lddatetimepicker;
|
|
3
|
-
html = '<div class="lddtp">\n <div class="lddtp-h">\n <div data-action="-"
|
|
3
|
+
html = '<div class="lddtp">\n <div class="lddtp-h">\n <div class="lddtp-a" data-action="-"></div>\n <div class="lddtp-f"><select class="lddtp-month-sel"></select></div>\n <div class="lddtp-f"><input class="lddtp-year-sel" type="number"/></div>\n <div class="lddtp-a" data-action="+"></div>\n </div>\n <div class="lddtp-ds">\n </div>\n <div class="lddtp-t">\n <div class="lddtp-f"><select class="lddtp-hour-sel"></select></div>\n <div><b>:</b></div>\n <div class="lddtp-f"><select class="lddtp-minute-sel"></select></div>\n </div>\n</div>';
|
|
4
4
|
lddatetimepicker = function(opt){
|
|
5
5
|
var div, r, ref$, x$, _handler, this$ = this;
|
|
6
6
|
opt == null && (opt = {});
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
minute: r.querySelector('.lddtp-minute-sel')
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
this.n.t.style.display = this._enabled.time ? '
|
|
94
|
+
this.n.t.style.display = this._enabled.time ? '' : 'none';
|
|
95
95
|
this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
96
96
|
this.wdays = ['SUN', 'MON', 'TUE', 'WED', 'THR', 'FRI', 'SAT'];
|
|
97
97
|
this.n.ds.innerHTML = [0, 1, 2, 3, 4, 5, 6].map(function(w){
|
package/index.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.lddtp-h{display:grid;grid-template-columns:1fr 2.5fr 2.5fr 1fr}.lddtp-h div{border-radius:.25em;display:flex;align-items:center;justify-content:center;margin:1px}.lddtp-h .info{flex:1 0 auto;text-align:center}.lddtp{position:absolute;z-index:100;width:300px;border:1px solid #d6d7d8;border-radius:.25em;background:#fff;box-shadow:0 3px 5px rgba(0,0,0,0.1);cursor:pointer;display:none}.lddtp div{user-select:none}.lddtp.active{display:block}.lddtp-ds{height:250px;display:grid;grid-template:.8fr repeat(6,1fr) / repeat(7,1fr);border-bottom:1px solid #e7e8e9;border-top:1px solid #e7e8e9}.lddtp-ds div{margin:1px;overflow:hidden;display:flex;position:relative;align-items:center;justify-content:center}.lddtp-ds .dim{color:#ccc;background:#f7f8f9}.lddtp-ds .today:before{display:block;content:" ";border-radius:50%;width:6px;height:6px;position:absolute;top:4px;left:4px;background:#0f0}.lddtp-w{font-size:.8em;font-weight:700}.lddtp-d.selected{background:#00f;color:#fff;border-radius:.25em;font-weight:700}.lddtp-t{display:grid;grid-template-columns:1fr 5px 1fr}.lddtp-t div{height:2.5em;display:flex;align-items:center}.lddtp-t .lddtp-f input,.lddtp-h .lddtp-f input,.lddtp-t .lddtp-f select,.lddtp-h .lddtp-f select{height:100%;width:100%;border:0;outline:0;text-align:center}
|
|
1
|
+
.lddtp-h{display:grid;grid-template-columns:1fr 2.5fr 2.5fr 1fr;padding:.33em 0}.lddtp-h div{border-radius:.25em;display:flex;align-items:center;justify-content:center;margin:1px}.lddtp-h .info{flex:1 0 auto;text-align:center}.lddtp-a:before,.lddtp-a:after{display:block}.lddtp-a:first-child:before{content:"\25c0"}.lddtp-a:last-child:before{content:"\25ba"}.lddtp{position:absolute;z-index:100;width:300px;border:1px solid #d6d7d8;border-radius:.25em;background:#fff;box-shadow:0 3px 5px rgba(0,0,0,0.1);cursor:pointer;display:none}.lddtp div{user-select:none}.lddtp.active{display:block}.lddtp-ds{height:250px;display:grid;grid-template:.8fr repeat(6,1fr) / repeat(7,1fr);border-bottom:1px solid #e7e8e9;border-top:1px solid #e7e8e9}.lddtp-ds div{margin:1px;overflow:hidden;display:flex;position:relative;align-items:center;justify-content:center}.lddtp-ds .dim{color:#ccc;background:#f7f8f9}.lddtp-ds .today:before{display:block;content:" ";border-radius:50%;width:6px;height:6px;position:absolute;top:4px;left:4px;background:#0f0}.lddtp-w{font-size:.8em;font-weight:700}.lddtp-d.selected{background:#00f;color:#fff;border-radius:.25em;font-weight:700}.lddtp-t{display:grid;grid-template-columns:1fr 5px 1fr}.lddtp-t div{height:2.5em;display:flex;align-items:center}.lddtp-t .lddtp-f input,.lddtp-h .lddtp-f input,.lddtp-t .lddtp-f select,.lddtp-h .lddtp-f select{height:100%;width:100%;border:0;outline:0;text-align:center}
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var t;(t=function(t){var e,p=this;return this.opt=t=null==t?{}:t,this._enabled={time:!(null!=t.time)||t.time},this.evthdr={},this.hdr={mouseup:function(){return p.root.classList.toggle("active",!1),document.removeEventListener("mouseup",p.hdr.mouseup)}},e=document.createElement("div"),t.host?(this.host="string"==typeof t.host?document.querySelector(t.host):t.host,this.host.parentNode.insertBefore(e,t.host.nextSibling),this.host.addEventListener("mouseup",function(t){var e,n,s,i,o,r,
|
|
1
|
+
!function(){var t;(t=function(t){var e,p=this;return this.opt=t=null==t?{}:t,this._enabled={time:!(null!=t.time)||t.time},this.evthdr={},this.hdr={mouseup:function(){return p.root.classList.toggle("active",!1),document.removeEventListener("mouseup",p.hdr.mouseup)}},e=document.createElement("div"),t.host?(this.host="string"==typeof t.host?document.querySelector(t.host):t.host,this.host.parentNode.insertBefore(e,t.host.nextSibling),this.host.addEventListener("mouseup",function(t){var e,n,s,i,d,o,r,a,l,u,h;if(t.stopPropagation(),p.root.classList.contains("active"))return p.root.classList.remove("active"),void document.removeEventListener("mouseup",p.hdr.mouseup);for(document.addEventListener("mouseup",p.hdr.mouseup),p.root.classList.toggle("active",!0),t=p.root,e=(n=p.host).parentNode,n=n.getBoundingClientRect(),s=t.getBoundingClientRect(),d=(i=[0,0])[0],o=i[1],r=(i=[null,null])[0],a=i[1];e&&e.getAttribute&&(l=getComputedStyle(e),"BODY"!==e.nodeName&&!["overflow","overflow-y","overflow-x"].filter(c).length||(r=r||e),"BODY"!==e.nodeName&&"static"===l.position||(a=a||e),!r||!a);)e=e.parentNode;return u=a.getBoundingClientRect(),h=r.getBoundingClientRect(),o=n.y+n.height+s.height>h.y+h.height?n.y-u.y-s.height+r.scrollTop-2:n.y-u.y+n.height+r.scrollTop+2,d=n.x+s.width>h.x+h.width?n.x-u.x+n.width-s.width+r.scrollLeft:n.x-u.x+r.scrollLeft,t.style.transform="translate("+d+"px, "+o+"px)",(i=t.style).top=0,i.left=0,i;function c(t){return"visible"!==l[t]}})):document.body.appendChild(e),e.innerHTML='<div class="lddtp">\n <div class="lddtp-h">\n <div class="lddtp-a" data-action="-"></div>\n <div class="lddtp-f"><select class="lddtp-month-sel"></select></div>\n <div class="lddtp-f"><input class="lddtp-year-sel" type="number"/></div>\n <div class="lddtp-a" data-action="+"></div>\n </div>\n <div class="lddtp-ds">\n </div>\n <div class="lddtp-t">\n <div class="lddtp-f"><select class="lddtp-hour-sel"></select></div>\n <div><b>:</b></div>\n <div class="lddtp-f"><select class="lddtp-minute-sel"></select></div>\n </div>\n</div>',this.root=t=e.querySelector(".lddtp"),this.root.addEventListener("mouseup",function(t){return t.stopPropagation()}),this.n={ds:t.querySelector(".lddtp-ds"),t:t.querySelector(".lddtp-t"),sel:{year:t.querySelector(".lddtp-year-sel"),month:t.querySelector(".lddtp-month-sel"),hour:t.querySelector(".lddtp-hour-sel"),minute:t.querySelector(".lddtp-minute-sel")}},this.n.t.style.display=this._enabled.time?"":"none",this.months=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],this.wdays=["SUN","MON","TUE","WED","THR","FRI","SAT"],this.n.ds.innerHTML=[0,1,2,3,4,5,6].map(function(t){return'<div class="lddtp-w">'+p.wdays[t]+"</div>"}).join("")+[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41].map(function(t){return'<div class="lddtp-d"></div>'}).join(""),(e=this.n).dh=Array.from(t.querySelectorAll(".lddtp-w")),e.dc=Array.from(t.querySelectorAll(".lddtp-d")),e=[0,1,2].map(function(){return dayjs()}),this.cur=e[0],this.today=e[1],this.sel=e[2],this.time={hour:0,minute:0},this.n.sel.month.innerHTML=this.months.map(function(t){return'<option value="'+t+'">'+t+"</option>"}).join(""),(t=this.n.sel.year).setAttribute("min",1900),t.setAttribute("max",2300),t.setAttribute("value",this.today.year()),this.n.sel.hour.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),this.n.sel.minute.innerHTML=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59].map(function(t){return'<option value="'+t+'">'+(""+t).padStart(2,"0")+"</option>"}).join(""),document.body.addEventListener("keydown",function(t){t=t.keyCode;if((37===t||38===t||39===t||40===t)&&p.sel)return p.sel=37===t?p.sel.subtract(1,"day"):39===t?p.sel.add(1,"day"):38===t?p.sel.subtract(7,"day"):40===t?p.sel.add(7,"day"):void 0,p.cur=p.sel,p.update()}),this.root.addEventListener("click",function(t){t=t.target;return t.classList.contains("lddtp-d")?(p.sel=dayjs(new Date(t.date.year,t.date.month,t.date.date)),p.update(p.cur)):"-"===t.getAttribute("data-action")?(p.cur=p.cur.subtract(1,"month"),p.update(p.cur)):"+"===t.getAttribute("data-action")?(p.cur=p.cur.add(1,"month"),p.update(p.cur)):void 0}),this.n.sel.minute.addEventListener("change",function(t){return p.time.minute=t.target.value}),this.n.sel.hour.addEventListener("change",function(t){return p.time.hour=t.target.value}),this.n.sel.year.addEventListener("change",function(t){return p.cur=dayjs(new Date(p.n.sel.year.value,p.months.indexOf(p.n.sel.month.value),1)),p.update(p.cur)}),this.n.sel.month.addEventListener("change",function(t){return p.cur=dayjs(new Date(p.n.sel.year.value,p.months.indexOf(p.n.sel.month.value),1)),p.update(p.cur)}),this.host&&(e=debounce(function(){var t;try{return t=dayjs(p.host.value).toISOString(),p.host.value=t,p.value(p.host.value)}catch(t){return t}}),this.host.addEventListener("change",e),this.host.addEventListener("input",e)),this.host&&this.host.value?this.value(this.host.value):this.update(),this}).prototype=function(t,e){var n,s={}.hasOwnProperty;for(n in e)s.call(e,n)&&(t[n]=e[n]);return t}(Object.create(Object.prototype),{on:function(t,n){var s=this;return(Array.isArray(t)?t:[t]).map(function(t){var e;return((e=s.evthdr)[t]||(e[t]=[])).push(n)})},fire:function(t){for(var e,n,s,i,d=[],o=[],r=1,a=arguments.length;r<a;++r)o.push(arguments[r]);for(e=o,r=0,s=(n=this.evthdr[t]||[]).length;r<s;++r)i=n[r],d.push(i.apply(this,e));return d},update:function(t){e=[(t=t||this.cur).year(),t.month()];var e,d,n,o,r,a,l,u,h,c=e[1];if(t=dayjs(new Date(t.year(),t.month(),1)),d=t.subtract(t.day(),"day"),t=(e=[t.year(),t.month(),t.date()])[0],n=e[1],e=[this.today.year(),this.today.month(),this.today.date()],o=e[0],r=e[1],a=e[2],e=this.sel?[this.sel.year(),this.sel.month(),this.sel.date()]:[null,null,null],l=e[0],u=e[1],h=e[2],this.n.sel.month.value=this.months[n],this.n.sel.year.value=t,this.n.dc.map(function(t,e){var e=d.add(e,"day"),n=[e.year(),e.month(),e.date()],s=n[0],i=n[1],n=n[2];return t.date={year:s,month:i,date:n},t.innerText=e.date(),t.classList.toggle("dim",e.month()!==c),t.classList.toggle("today",o===s&&r===i&&a===n),t.classList.toggle("selected",l===s&&u===i&&h===n)}),this.host)return this.host.value=this.value()},value:function(t){return arguments.length?(this.sel=dayjs(t),this.cur=dayjs(t),this.update()):this._enabled.time?dayjs(new Date(this.sel.year(),this.sel.month(),this.sel.date(),this.time.hour,this.time.minute)).toISOString():dayjs(new Date(this.sel.year(),this.sel.month(),this.sel.date())).format("YYYY-MM-DD")}}),"undefined"!=typeof module&&null!==module?module.exports=t:"undefined"!=typeof window&&null!==window&&(window.lddatetimepicker=t)}.call(this);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lddatetimepicker","version":"0.0.
|
|
1
|
+
{"name":"lddatetimepicker","version":"0.0.2","description":"vanilla date/time picker","browser":"index.min.js","main":"index.js","scripts":{"start":"npx server -r web -o true"},"homepage":"https://github.com/loadingio/lddatetimepicker","repository":{"type":"git","url":"https://github.com/loadingio/lddatetimepicker"},"keywords":["date","time","datetime","datepicker","datetimepicker"],"author":"zbryikt","license":"MIT","devDependencies":{"@loadingio/bootstrap.ext":"^0.0.6","@loadingio/debounce.js":"^1.0.1","@zbryikt/template":"^2.3.34","bootstrap":"^4.6.1","dayjs":"^1.11.0","fedep":"^1.1.7","ldcover":"^3.0.1","ldview":"^1.1.1","livescript":"^1.6.0","proxise":"^1.0.1","stylus":"^0.57.0","uglify-js":"^3.15.3","uglifycss":"^0.0.29"},"frontendDependencies":{"root":"web/static/assets/lib","modules":["@loadingio/bootstrap.ext","@loadingio/debounce.js","@loadingio/ldquery","dayjs","bootstrap","ldcover","ldview","proxise"]},"dependencies":{"@loadingio/ldquery":"^3.0.3"}}
|
package/theme.css
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
.lddtp {
|
|
2
|
+
padding: 0.5em;
|
|
3
|
+
}
|
|
4
|
+
.lddtp-ds .dim {
|
|
5
|
+
opacity: 0.4;
|
|
6
|
+
background: none;
|
|
7
|
+
}
|
|
8
|
+
.lddtp-d {
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
}
|
|
11
|
+
.lddtp-w {
|
|
12
|
+
opacity: 0.3;
|
|
13
|
+
}
|
|
14
|
+
.lddtp-ds {
|
|
15
|
+
border-top: 1px solid transparent;
|
|
16
|
+
border-bottom: 1px solid transparent;
|
|
17
|
+
}
|
|
18
|
+
.lddtp-d.selected {
|
|
19
|
+
background: none;
|
|
20
|
+
color: inherit;
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
23
|
+
.lddtp-d.selected:after {
|
|
24
|
+
display: block;
|
|
25
|
+
content: " ";
|
|
26
|
+
width: 80%;
|
|
27
|
+
height: 3px;
|
|
28
|
+
border-radius: 3px;
|
|
29
|
+
background: #0cf;
|
|
30
|
+
position: absolute;
|
|
31
|
+
bottom: 0.15em;
|
|
32
|
+
left: 10%;
|
|
33
|
+
right: 10%;
|
|
34
|
+
}
|
|
35
|
+
.lddtp-a:first-child:before {
|
|
36
|
+
content: "\00ab";
|
|
37
|
+
}
|
|
38
|
+
.lddtp-a:last-child:before {
|
|
39
|
+
content: "\00bb";
|
|
40
|
+
}
|
|
41
|
+
.lddtp-t {
|
|
42
|
+
padding: 0 0.5em;
|
|
43
|
+
}
|
package/theme.min.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.lddtp{padding:.5em}.lddtp-ds .dim{opacity:.4;background:0}.lddtp-d{font-weight:400}.lddtp-w{opacity:.3}.lddtp-ds{border-top:1px solid transparent;border-bottom:1px solid transparent}.lddtp-d.selected{background:0;color:inherit;position:relative}.lddtp-d.selected:after{display:block;content:" ";width:80%;height:3px;border-radius:3px;background:#0cf;position:absolute;bottom:.15em;left:10%;right:10%}.lddtp-a:first-child:before{content:"\00ab"}.lddtp-a:last-child:before{content:"\00bb"}.lddtp-t{padding:0 .5em}
|