Socket
Socket
Sign inDemoInstall

pickerjs

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

4

CHANGELOG.md
# Changelog
## 1.1.0 (Dec 15, 2018)
- Add `headers` option for customizing the column headers (#20).
## 1.0.0 (Oct 25, 2018)

@@ -4,0 +8,0 @@

/*!
* Picker.js v1.0.0
* Picker.js v1.1.0
* https://fengyuanchen.github.io/pickerjs

@@ -8,3 +8,3 @@ *

*
* Date: 2018-10-25T11:27:11.156Z
* Date: 2018-12-15T09:03:15.534Z
*/

@@ -77,2 +77,4 @@

format: 'YYYY-MM-DD HH:mm',
// Indicate whether show the column headers or customize column headers
headers: false,
// Define the increment for each date / time part.

@@ -92,3 +94,3 @@ increment: 1,

text: {
title: 'Pick a date / time',
title: 'Pick a date',
cancel: 'Cancel',

@@ -1225,3 +1227,4 @@ confirm: 'OK'

var index = date.indexOf(digit);
var isBC = index > 1 && /\D/.test(date.substr(index - 2, 1)) || index === 1 && date.substr(index - 1, 1) === '-';
var isHyphen = date.substr(index - 1, 1) === '-';
var isBC = index > 1 && isHyphen && /\S/.test(date.substr(index - 2, 1)) || index === 1 && isHyphen;
parsedDate.setFullYear(isBC ? -n : n);

@@ -1477,2 +1480,7 @@ break;

addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
if (options.headers) {
addClass(grid, "".concat(NAMESPACE, "-headers"));
}
var increment = options.increment;

@@ -1561,2 +1569,8 @@

setData(cell, 'token', token);
if (options.headers) {
var header = options.headers[type] || type[0].toUpperCase() + type.substr(1);
setData(cell, 'header', header);
}
addClass(list, "".concat(NAMESPACE, "-list"));

@@ -1563,0 +1577,0 @@ addClass(cell, "".concat(NAMESPACE, "-cell"));

/*!
* Picker.js v1.0.0
* Picker.js v1.1.0
* https://fengyuanchen.github.io/pickerjs

@@ -8,3 +8,3 @@ *

*
* Date: 2018-10-25T11:27:11.156Z
* Date: 2018-12-15T09:03:15.534Z
*/

@@ -75,2 +75,4 @@

format: 'YYYY-MM-DD HH:mm',
// Indicate whether show the column headers or customize column headers
headers: false,
// Define the increment for each date / time part.

@@ -90,3 +92,3 @@ increment: 1,

text: {
title: 'Pick a date / time',
title: 'Pick a date',
cancel: 'Cancel',

@@ -1223,3 +1225,4 @@ confirm: 'OK'

var index = date.indexOf(digit);
var isBC = index > 1 && /\D/.test(date.substr(index - 2, 1)) || index === 1 && date.substr(index - 1, 1) === '-';
var isHyphen = date.substr(index - 1, 1) === '-';
var isBC = index > 1 && isHyphen && /\S/.test(date.substr(index - 2, 1)) || index === 1 && isHyphen;
parsedDate.setFullYear(isBC ? -n : n);

@@ -1475,2 +1478,7 @@ break;

addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
if (options.headers) {
addClass(grid, "".concat(NAMESPACE, "-headers"));
}
var increment = options.increment;

@@ -1559,2 +1567,8 @@

setData(cell, 'token', token);
if (options.headers) {
var header = options.headers[type] || type[0].toUpperCase() + type.substr(1);
setData(cell, 'header', header);
}
addClass(list, "".concat(NAMESPACE, "-list"));

@@ -1561,0 +1575,0 @@ addClass(cell, "".concat(NAMESPACE, "-cell"));

/*!
* Picker.js v1.0.0
* Picker.js v1.1.0
* https://fengyuanchen.github.io/pickerjs

@@ -8,3 +8,3 @@ *

*
* Date: 2018-10-25T11:27:11.156Z
* Date: 2018-12-15T09:03:15.534Z
*/

@@ -81,2 +81,4 @@

format: 'YYYY-MM-DD HH:mm',
// Indicate whether show the column headers or customize column headers
headers: false,
// Define the increment for each date / time part.

@@ -96,3 +98,3 @@ increment: 1,

text: {
title: 'Pick a date / time',
title: 'Pick a date',
cancel: 'Cancel',

@@ -1229,3 +1231,4 @@ confirm: 'OK'

var index = date.indexOf(digit);
var isBC = index > 1 && /\D/.test(date.substr(index - 2, 1)) || index === 1 && date.substr(index - 1, 1) === '-';
var isHyphen = date.substr(index - 1, 1) === '-';
var isBC = index > 1 && isHyphen && /\S/.test(date.substr(index - 2, 1)) || index === 1 && isHyphen;
parsedDate.setFullYear(isBC ? -n : n);

@@ -1481,2 +1484,7 @@ break;

addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
if (options.headers) {
addClass(grid, "".concat(NAMESPACE, "-headers"));
}
var increment = options.increment;

@@ -1565,2 +1573,8 @@

setData(cell, 'token', token);
if (options.headers) {
var header = options.headers[type] || type[0].toUpperCase() + type.substr(1);
setData(cell, 'header', header);
}
addClass(list, "".concat(NAMESPACE, "-list"));

@@ -1567,0 +1581,0 @@ addClass(cell, "".concat(NAMESPACE, "-cell"));

6

dist/picker.min.js
/*!
* Picker.js v1.0.0
* Picker.js v1.1.0
* https://fengyuanchen.github.io/pickerjs

@@ -8,4 +8,4 @@ *

*
* Date: 2018-10-25T11:27:11.156Z
* Date: 2018-12-15T09:03:15.534Z
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Picker=e()}(this,function(){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function n(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={container:null,date:null,format:"YYYY-MM-DD HH:mm",increment:1,inline:!1,language:"",months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rows:5,text:{title:"Pick a date / time",cancel:"Cancel",confirm:"OK"},translate:function(t,e){return e},show:null,shown:null,hide:null,hidden:null,pick:null},p='<div class="picker" data-action="hide" touch-action="none" tabindex="-1" role="dialog"><div class="picker-dialog" role="document"><div class="picker-header"><h4 class="picker-title">{{ title }}</h4><button type="button" class="picker-close" data-action="hide" aria-label="Close">&times;</button></div><div class="picker-body"><div class="picker-grid"></div></div><div class="picker-footer"><button type="button" class="picker-cancel" data-action="hide">{{ cancel }}</button><button type="button" class="picker-confirm" data-action="pick">{{ confirm }}</button></div></div></div>',a="undefined"!=typeof window,v=a?window:{},g="picker",o={},b="".concat(g,"-open"),y="".concat(g,"-opened"),d="".concat(g,"-picked"),i="click",c="focus",h="hidden",l="hide",u="keydown",m="pick",f=v.PointerEvent?"pointerdown":"touchstart mousedown",k=v.PointerEvent?"pointermove":"touchmove mousemove",w=v.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",M="show",Y="shown",D="wheel mousewheel DOMMouseScroll",t=Object.prototype,E=t.hasOwnProperty,x=t.toString;function S(t){return"string"==typeof t}var C=Number.isFinite||v.isFinite,N=Number.isNaN||v.isNaN;function A(t){return"number"==typeof t&&!N(t)}function O(t){return"object"===e(t)&&null!==t}function H(t){if(!O(t))return!1;try{var e=t.constructor,n=e.prototype;return e&&n&&E.call(n,"isPrototypeOf")}catch(t){return!1}}function P(t){return"function"==typeof t}function L(t){return"date"===(e=t,x.call(e).slice(8,-1).toLowerCase());var e}function F(e,n){if(e&&P(n))if(Array.isArray(e)||A(e.length)){var t,i=e.length;for(t=0;t<i&&!1!==n.call(e,e[t],t,e);t+=1);}else O(e)&&Object.keys(e).forEach(function(t){n.call(e,e[t],t,e)});return e}function j(n){for(var t=arguments.length,e=new Array(1<t?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return O(n)&&0<e.length&&e.forEach(function(e){O(e)&&Object.keys(e).forEach(function(t){H(n[t])&&H(e[t])?n[t]=j({},n[t],e[t]):n[t]=e[t]})}),n}function T(t,e){if(e)if(A(t.length))F(t,function(t){T(t,e)});else if(t.classList)t.classList.add(e);else{var n=t.className.trim();n?n.indexOf(e)<0&&(t.className="".concat(n," ").concat(e)):t.className=e}}function B(t,e){e&&(A(t.length)?F(t,function(t){B(t,e)}):t.classList?t.classList.remove(e):0<=t.className.indexOf(e)&&(t.className=t.className.replace(e,"")))}var V=/([a-z\d])([A-Z])/g;function I(t){return t.replace(V,"$1-$2").toLowerCase()}function R(t,e){return O(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(I(e)))}function W(t,e,n){O(n)?t[e]=n:t.dataset?t.dataset[e]=n:t.setAttribute("data-".concat(I(e)),n)}var J=/\s\s*/,K=function(){var t=!1;if(a){var e=!1,n=function(){},i=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});v.addEventListener("test",n,i),v.removeEventListener("test",n,i)}return t}();function q(n,t,i){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},s=i;t.trim().split(J).forEach(function(t){if(!K){var e=n.listeners;e&&e[t]&&e[t][i]&&(s=e[t][i],delete e[t][i],0===Object.keys(e[t]).length&&delete e[t],0===Object.keys(e).length&&delete n.listeners)}n.removeEventListener(t,s,r)})}function U(s,t,a){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},c=a;t.trim().split(J).forEach(function(i){if(o.once&&!K){var t=s.listeners,r=void 0===t?{}:t;c=function(){delete r[i][a],s.removeEventListener(i,c,o);for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];a.apply(s,e)},r[i]||(r[i]={}),r[i][a]&&s.removeEventListener(i,r[i][a],o),r[i][a]=c,s.listeners=r}s.addEventListener(i,c,o)})}function $(t,e,n){var i;return P(Event)&&P(CustomEvent)?i=new CustomEvent(e,{detail:n,bubbles:!0,cancelable:!0}):(i=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,n),t.dispatchEvent(i)}function z(t,e){return[31,(n=t,n%4==0&&n%100!=0||n%400==0?29:28),31,30,31,30,31,31,30,31,30,31][e];var n}function Z(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=String(Math.abs(t)),i=n.length,r="";for(t<0&&(r+="-");i<e;)i+=1,r+="0";return r+n}function G(t){return{Y:"year",M:"month",D:"day",H:"hour",m:"minute",s:"second",S:"millisecond"}[t.charAt(0)]}var Q=/(Y|M|D|H|m|s|S)\1*/g;var X={bind:function(){var t=this.element,e=this.options,n=this.grid;P(e.show)&&U(t,M,e.show),P(e.shown)&&U(t,Y,e.shown),P(e.hide)&&U(t,l,e.hide),P(e.hidden)&&U(t,h,e.hidden),P(e.pick)&&U(t,m,e.pick),U(t,c,this.onFocus=this.focus.bind(this)),U(t,i,this.onFocus),U(this.picker,i,this.onClick=this.click.bind(this)),U(n,D,this.onWheel=this.wheel.bind(this)),U(n,f,this.onPointerDown=this.pointerdown.bind(this)),U(document,k,this.onPointerMove=this.pointermove.bind(this)),U(document,w,this.onPointerUp=this.pointerup.bind(this)),U(document,u,this.onKeyDown=this.keydown.bind(this))},unbind:function(){var t=this.element,e=this.options,n=this.grid;P(e.show)&&q(t,M,e.show),P(e.shown)&&q(t,Y,e.shown),P(e.hide)&&q(t,l,e.hide),P(e.hidden)&&q(t,h,e.hidden),P(e.pick)&&q(t,m,e.pick),q(t,c,this.onFocus),q(t,i,this.onFocus),q(this.picker,i,this.onClick),q(n,D,this.onWheel),q(n,f,this.onPointerDown),q(document,k,this.onPointerMove),q(document,w,this.onPointerUp),q(document,u,this.onKeyDown)}},_={focus:function(t){t.target.blur(),this.show()},click:function(t){var e=R(t.target,"action");"hide"===e?this.hide():"pick"===e&&this.pick()},wheel:function(t){var e=t.target;if(e!==this.grid){t.preventDefault(),"li"===e.tagName.toLowerCase()&&(e=e.parentNode),"ul"===e.tagName.toLowerCase()&&(e=e.parentNode);var n=R(e,"type");t.deltaY<0?this.prev(n):this.next(n)}},pointerdown:function(t){var e=t.target;if(e!==this.grid){t.preventDefault(),"li"===e.tagName.toLowerCase()&&(e=e.parentNode),"ul"===e.tagName.toLowerCase()&&(e=e.parentNode);var n=e.firstElementChild,i=n.firstElementChild.offsetHeight;this.cell={elem:e,list:n,moveY:0,maxMoveY:i,minMoveY:i/2,startY:t.changedTouches?t.changedTouches[0].pageY:t.pageY,type:R(e,"type")}}},pointermove:function(t){var e=this.cell;if(e){t.preventDefault();var n=t.changedTouches?t.changedTouches[0].pageY:t.pageY,i=e.moveY+(n-e.startY);e.startY=n,e.moveY=i,Math.abs(i)<e.maxMoveY?e.list.style.top="".concat(i,"px"):(e.list.style.top=0,e.moveY=0,i>=e.maxMoveY?this.prev(e.type):i<=-e.maxMoveY&&this.next(e.type))}},pointerup:function(t){var e=this.cell;e&&(t.preventDefault(),e.list.style.top=0,e.moveY>=e.minMoveY?this.prev(e.type):e.moveY<=-e.minMoveY&&this.next(e.type),this.cell=null)},keydown:function(t){!this.shown||"Escape"!==t.key&&27!==t.keyCode||this.hide()}},tt={render:function(t){var e=this;if(t){var n=this.options,i=this.data[t],r=this.current(t),s=P(i.max)?i.max():i.max,a=P(i.min)?i.min():i.min,o=0;C(s)&&(o=0<a?s:s+1),i.list.innerHTML="",i.current=r;for(var c=0;c<n.rows+2;c+=1){var h=document.createElement("li"),l=c-i.index,u=r+l*i.increment;o&&(u%=o)<a&&(u+=o),h.textContent=n.translate(t,i.aliases?i.aliases[u]:Z(u+i.offset,i.digit)),W(h,"name",t),W(h,"value",u),T(h,"".concat(g,"-item")),0===l&&(T(h,d),i.item=h),i.list.appendChild(h)}}else this.format.tokens.forEach(function(t){return e.render(G(t))})},current:function(t,e){var n=this.date,i=this.format,r=i[t];switch(r.charAt(0)){case"Y":return A(e)&&(n.setFullYear(2===r.length?2e3+e:e),i.month&&this.render(G(i.month)),i.day&&this.render(G(i.day))),n.getFullYear();case"M":return A(e)&&(n.setMonth(e,Math.min(n.getDate(),z(n.getFullYear(),e))),i.day&&this.render(G(i.day))),n.getMonth();case"D":return A(e)&&n.setDate(e),n.getDate();case"H":return A(e)&&n.setHours(e),n.getHours();case"m":return A(e)&&n.setMinutes(e),n.getMinutes();case"s":return A(e)&&n.setSeconds(e),n.getSeconds();case"S":return A(e)&&n.setMilliseconds(e),n.getMilliseconds()}return n},getValue:function(){var t=this.element;return this.isInput?t.value:t.textContent},setValue:function(t){var e=this.element;this.isInput?e.value=t:this.options.container&&(e.textContent=t)},open:function(){var t=this.body;t.style.overflow="hidden",t.style.paddingRight="".concat(this.scrollBarWidth+(parseFloat(this.initialBodyPaddingRight)||0),"px")},close:function(){var t=this.body;t.style.overflow="",t.style.paddingRight=this.initialBodyPaddingRight}},et={show:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.element,n=this.picker;if(this.inline||this.shown)return this;if(!1===$(e,M))return this;this.shown=!0,this.open(),T(n,b);var i=function(){$(e,Y)};return t||n.offsetWidth,T(n,y),t?i():setTimeout(i,300),this},hide:function(){var t=this,e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=this.element,i=this.picker;if(this.inline||!this.shown)return this;if(!1===$(n,l))return this;this.shown=!1,B(i,y);var r=function(){t.close(),B(i,b),$(n,h)};return e?r():setTimeout(r,300),this},prev:function(t){var e=this.options,n=this.format[t],i=this.data[t],r=i.list,s=r.lastElementChild,a=P(i.max)?i.max():i.max,o=P(i.min)?i.min():i.min,c=i.item.previousElementSibling,h=Number(R(r.firstElementChild,"value"))-i.increment;return h<o&&(h+=a-o+1),s.textContent=e.translate(t,i.aliases?i.aliases[h]:Z(h+i.offset,n.length)),W(s,"value",h),c&&(B(i.item,d),T(c,d),i.item=c),r.insertBefore(s,r.firstElementChild),i.current=Number(R(i.item,"value")),this.current(t,i.current),this.inline&&e.container&&this.pick(),this},next:function(t){var e=this.options,n=this.format[t],i=this.data[t],r=i.list,s=r.firstElementChild,a=P(i.max)?i.max():i.max,o=P(i.min)?i.min():i.min,c=i.item.nextElementSibling,h=Number(R(r.lastElementChild,"value"))+i.increment;return a<h&&(h-=a-o+1),s.textContent=e.translate(t,i.aliases?i.aliases[h]:Z(h+i.offset,n.length)),W(s,"value",h),r.appendChild(s),c&&(B(i.item,d),T(c,d),i.item=c),i.current=Number(R(i.item,"value")),this.current(t,i.current),this.inline&&e.container&&this.pick(),this},pick:function(){var t=this.element;if(!1===$(t,m))return this;var e=this.formatDate(this.date);return this.setValue(e),this.isInput&&!1===$(t,"change")&&this.reset(),this.hide(),this},getDate:function(){var t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],e=this.date;return t?this.formatDate(e):new Date(e)},setDate:function(t){return t&&(this.date=this.parseDate(t),this.render()),this},update:function(){return this.date=this.parseDate(this.getValue()),this.render(),this},reset:function(){return this.setValue(this.initialValue),this.date=new Date(this.initialDate),this.render(),this},parseDate:function(a){var o=this.options,c=this.format,t=[];if(L(a))return new Date(a);if(S(a)){var e=n(o.months).concat(n(o.monthsShort),["\\d+"]);if((t=a.match(new RegExp("(".concat(e.join("|"),")"),"g")))&&a.length===o.format.length&&t.length!==c.tokens.length&&(t=c.tokens.map(function(t){return a.substr(o.format.indexOf(t),t.length)})),!t||t.length!==c.tokens.length)return new Date}var h=new Date;return t.forEach(function(t,e){var n=c.tokens[e],i=Number(t);switch(n){case"YYYY":case"YYY":case"Y":var r=a.indexOf(t),s=1<r&&/\D/.test(a.substr(r-2,1))||1===r&&"-"===a.substr(r-1,1);h.setFullYear(s?-i:i);break;case"YY":h.setFullYear(2e3+i);break;case"MMMM":h.setMonth(o.months.indexOf(t));break;case"MMM":h.setMonth(o.monthsShort.indexOf(t));break;case"MM":case"M":h.setMonth(i-1);break;case"DD":case"D":h.setDate(i);break;case"HH":case"H":h.setHours(i);break;case"mm":case"m":h.setMinutes(i);break;case"ss":case"s":h.setSeconds(i);break;case"SSS":case"SS":case"S":h.setMilliseconds(i)}}),h},formatDate:function(t){var e,n=this.options,i=this.format,r="";if(L(e=t)&&"Invalid Date"!==e.toString()){var s=t.getFullYear(),a=t.getMonth(),o=t.getDate(),c=t.getHours(),h=t.getMinutes(),l=t.getSeconds(),u=t.getMilliseconds();r=n.format,i.tokens.forEach(function(t){var e="";switch(t){case"YYYY":case"YYY":case"Y":e=Z(s,t.length);break;case"YY":e=Z(s%100,2);break;case"MMMM":e=n.months[a];break;case"MMM":e=n.monthsShort[a];break;case"MM":case"M":e=Z(a+1,t.length);break;case"DD":case"D":e=Z(o,t.length);break;case"HH":case"H":e=Z(c,t.length);break;case"mm":case"m":e=Z(h,t.length);break;case"ss":case"s":e=Z(l,t.length);break;case"SSS":case"SS":case"S":e=Z(u,t.length)}r=r.replace(t,e)})}return r},destroy:function(){var t=this.element,e=this.picker;return R(t,g)&&(this.hide(!0),this.unbind(),function(e,n){if(O(e[n]))try{delete e[n]}catch(t){e[n]=void 0}else if(e.dataset)try{delete e.dataset[n]}catch(t){e.dataset[n]=void 0}else e.removeAttribute("data-".concat(I(n)))}(t,g),e.parentNode.removeChild(e)),this}},nt=/\{\{\s*(\w+)\s*\}\}/g,it=/input|textarea/i,rt=v.Picker,st=function(){function n(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),!t||1!==t.nodeType)throw new Error("The first argument is required and must be an element.");this.element=t,this.options=j({},s,o[e.language],H(e)&&e),this.shown=!1,this.init()}var t,e,i;return t=n,i=[{key:"noConflict",value:function(){return v.Picker=rt,n}},{key:"setDefaults",value:function(t){j(s,o[t.language],H(t)&&t)}}],(e=[{key:"init",value:function(){var s=this,t=this.element;if(!R(t,g)){W(t,g,this);var a=this.options,e=it.test(t.tagName),n=a.inline&&(a.container||!e),i=document.createElement("div");i.insertAdjacentHTML("afterbegin",p.replace(nt,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return a.text[e[1]]}));var r=i.getElementsByClassName(g)[0],o=r.getElementsByClassName("".concat(g,"-grid"))[0],c=a.container;if(S(c)&&(c=document.querySelector(c)),n)T(r,b),T(r,y),c||(c=t);else{var h=t.ownerDocument,l=h.body||h.documentElement;this.body=l,this.scrollBarWidth=v.innerWidth-h.documentElement.clientWidth,this.initialBodyPaddingRight=v.getComputedStyle(l).paddingRight,T(r,"".concat(g,"-fixed")),c||(c=document.body)}this.isInput=e,this.inline=n,this.container=c,this.picker=r,this.grid=o,this.cell=null,this.format=function(t){var e=t.match(Q);if(!e)throw new Error("Invalid format");var n={tokens:e};return e.forEach(function(t){n[G(t)]=t}),n}(a.format);var u=this.getValue(),d=this.parseDate(a.date||u);this.date=d,this.initialDate=new Date(d),this.initialValue=u,this.data={};var m=Number(a.rows);m%2||(m+=1),a.rows=m||5,T(o,"".concat(g,1<m?"-multiple":"-single"));var f=a.increment;H(f)||(f={year:f,month:f,day:f,hour:f,minute:f,second:f,millisecond:f}),this.format.tokens.forEach(function(t){var e=G(t),n=document.createElement("div"),i=document.createElement("ul"),r={digit:t.length,increment:Math.abs(Number(f[e]))||1,list:i,max:1/0,min:-1/0,index:Math.floor((a.rows+2)/2),offset:0};switch(t.charAt(0)){case"Y":2===r.digit&&(r.max=99,r.min=0);break;case"M":r.max=11,r.min=0,r.offset=1,3===r.digit?r.aliases=a.monthsShort:4===r.digit&&(r.aliases=a.months);break;case"D":r.max=function(){return z(d.getFullYear(),d.getMonth())},r.min=1;break;case"H":r.max=23,r.min=0;break;case"m":case"s":r.max=59,r.min=0;break;case"S":r.max=999,r.min=0}W(n,"type",e),W(n,"token",t),T(i,"".concat(g,"-list")),T(n,"".concat(g,"-cell")),T(n,"".concat(g,"-").concat(e,"s")),n.appendChild(i),o.appendChild(n),s.data[e]=r,s.render(e)}),n&&(c.innerHTML=""),c.appendChild(r),this.bind()}}}])&&r(t.prototype,e),i&&r(t,i),n}();return j(st.prototype,X,_,tt,et),st.languages=o,st});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Picker=t()}(this,function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function n(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var s={container:null,date:null,format:"YYYY-MM-DD HH:mm",headers:!1,increment:1,inline:!1,language:"",months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rows:5,text:{title:"Pick a date",cancel:"Cancel",confirm:"OK"},translate:function(e,t){return t},show:null,shown:null,hide:null,hidden:null,pick:null},p='<div class="picker" data-action="hide" touch-action="none" tabindex="-1" role="dialog"><div class="picker-dialog" role="document"><div class="picker-header"><h4 class="picker-title">{{ title }}</h4><button type="button" class="picker-close" data-action="hide" aria-label="Close">&times;</button></div><div class="picker-body"><div class="picker-grid"></div></div><div class="picker-footer"><button type="button" class="picker-cancel" data-action="hide">{{ cancel }}</button><button type="button" class="picker-confirm" data-action="pick">{{ confirm }}</button></div></div></div>',a="undefined"!=typeof window,v=a?window:{},g="picker",o={},b="".concat(g,"-open"),y="".concat(g,"-opened"),d="".concat(g,"-picked"),i="click",c="focus",h="hidden",l="hide",u="keydown",m="pick",f=v.PointerEvent?"pointerdown":"touchstart mousedown",k=v.PointerEvent?"pointermove":"touchmove mousemove",w=v.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",M="show",Y="shown",E="wheel mousewheel DOMMouseScroll",e=Object.prototype,x=e.hasOwnProperty,D=e.toString;function S(e){return"string"==typeof e}var C=Number.isFinite||v.isFinite,N=Number.isNaN||v.isNaN;function A(e){return"number"==typeof e&&!N(e)}function O(e){return"object"===t(e)&&null!==e}function H(e){if(!O(e))return!1;try{var t=e.constructor,n=t.prototype;return t&&n&&x.call(n,"isPrototypeOf")}catch(e){return!1}}function P(e){return"function"==typeof e}function L(e){return"date"===(t=e,D.call(t).slice(8,-1).toLowerCase());var t}function F(t,n){if(t&&P(n))if(Array.isArray(t)||A(t.length)){var e,i=t.length;for(e=0;e<i&&!1!==n.call(t,t[e],e,t);e+=1);}else O(t)&&Object.keys(t).forEach(function(e){n.call(t,t[e],e,t)});return t}function j(n){for(var e=arguments.length,t=new Array(1<e?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return O(n)&&0<t.length&&t.forEach(function(t){O(t)&&Object.keys(t).forEach(function(e){H(n[e])&&H(t[e])?n[e]=j({},n[e],t[e]):n[e]=t[e]})}),n}function T(e,t){if(t)if(A(e.length))F(e,function(e){T(e,t)});else if(e.classList)e.classList.add(t);else{var n=e.className.trim();n?n.indexOf(t)<0&&(e.className="".concat(n," ").concat(t)):e.className=t}}function B(e,t){t&&(A(e.length)?F(e,function(e){B(e,t)}):e.classList?e.classList.remove(t):0<=e.className.indexOf(t)&&(e.className=e.className.replace(t,"")))}var V=/([a-z\d])([A-Z])/g;function I(e){return e.replace(V,"$1-$2").toLowerCase()}function R(e,t){return O(e[t])?e[t]:e.dataset?e.dataset[t]:e.getAttribute("data-".concat(I(t)))}function W(e,t,n){O(n)?e[t]=n:e.dataset?e.dataset[t]=n:e.setAttribute("data-".concat(I(t)),n)}var J=/\s\s*/,K=function(){var e=!1;if(a){var t=!1,n=function(){},i=Object.defineProperty({},"once",{get:function(){return e=!0,t},set:function(e){t=e}});v.addEventListener("test",n,i),v.removeEventListener("test",n,i)}return e}();function U(n,e,i){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},s=i;e.trim().split(J).forEach(function(e){if(!K){var t=n.listeners;t&&t[e]&&t[e][i]&&(s=t[e][i],delete t[e][i],0===Object.keys(t[e]).length&&delete t[e],0===Object.keys(t).length&&delete n.listeners)}n.removeEventListener(e,s,r)})}function q(s,e,a){var o=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},c=a;e.trim().split(J).forEach(function(i){if(o.once&&!K){var e=s.listeners,r=void 0===e?{}:e;c=function(){delete r[i][a],s.removeEventListener(i,c,o);for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];a.apply(s,t)},r[i]||(r[i]={}),r[i][a]&&s.removeEventListener(i,r[i][a],o),r[i][a]=c,s.listeners=r}s.addEventListener(i,c,o)})}function $(e,t,n){var i;return P(Event)&&P(CustomEvent)?i=new CustomEvent(t,{detail:n,bubbles:!0,cancelable:!0}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n),e.dispatchEvent(i)}function z(e,t){return[31,(n=e,n%4==0&&n%100!=0||n%400==0?29:28),31,30,31,30,31,31,30,31,30,31][t];var n}function Z(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=String(Math.abs(e)),i=n.length,r="";for(e<0&&(r+="-");i<t;)i+=1,r+="0";return r+n}function G(e){return{Y:"year",M:"month",D:"day",H:"hour",m:"minute",s:"second",S:"millisecond"}[e.charAt(0)]}var Q=/(Y|M|D|H|m|s|S)\1*/g;var X={bind:function(){var e=this.element,t=this.options,n=this.grid;P(t.show)&&q(e,M,t.show),P(t.shown)&&q(e,Y,t.shown),P(t.hide)&&q(e,l,t.hide),P(t.hidden)&&q(e,h,t.hidden),P(t.pick)&&q(e,m,t.pick),q(e,c,this.onFocus=this.focus.bind(this)),q(e,i,this.onFocus),q(this.picker,i,this.onClick=this.click.bind(this)),q(n,E,this.onWheel=this.wheel.bind(this)),q(n,f,this.onPointerDown=this.pointerdown.bind(this)),q(document,k,this.onPointerMove=this.pointermove.bind(this)),q(document,w,this.onPointerUp=this.pointerup.bind(this)),q(document,u,this.onKeyDown=this.keydown.bind(this))},unbind:function(){var e=this.element,t=this.options,n=this.grid;P(t.show)&&U(e,M,t.show),P(t.shown)&&U(e,Y,t.shown),P(t.hide)&&U(e,l,t.hide),P(t.hidden)&&U(e,h,t.hidden),P(t.pick)&&U(e,m,t.pick),U(e,c,this.onFocus),U(e,i,this.onFocus),U(this.picker,i,this.onClick),U(n,E,this.onWheel),U(n,f,this.onPointerDown),U(document,k,this.onPointerMove),U(document,w,this.onPointerUp),U(document,u,this.onKeyDown)}},_={focus:function(e){e.target.blur(),this.show()},click:function(e){var t=R(e.target,"action");"hide"===t?this.hide():"pick"===t&&this.pick()},wheel:function(e){var t=e.target;if(t!==this.grid){e.preventDefault(),"li"===t.tagName.toLowerCase()&&(t=t.parentNode),"ul"===t.tagName.toLowerCase()&&(t=t.parentNode);var n=R(t,"type");e.deltaY<0?this.prev(n):this.next(n)}},pointerdown:function(e){var t=e.target;if(t!==this.grid){e.preventDefault(),"li"===t.tagName.toLowerCase()&&(t=t.parentNode),"ul"===t.tagName.toLowerCase()&&(t=t.parentNode);var n=t.firstElementChild,i=n.firstElementChild.offsetHeight;this.cell={elem:t,list:n,moveY:0,maxMoveY:i,minMoveY:i/2,startY:e.changedTouches?e.changedTouches[0].pageY:e.pageY,type:R(t,"type")}}},pointermove:function(e){var t=this.cell;if(t){e.preventDefault();var n=e.changedTouches?e.changedTouches[0].pageY:e.pageY,i=t.moveY+(n-t.startY);t.startY=n,t.moveY=i,Math.abs(i)<t.maxMoveY?t.list.style.top="".concat(i,"px"):(t.list.style.top=0,t.moveY=0,i>=t.maxMoveY?this.prev(t.type):i<=-t.maxMoveY&&this.next(t.type))}},pointerup:function(e){var t=this.cell;t&&(e.preventDefault(),t.list.style.top=0,t.moveY>=t.minMoveY?this.prev(t.type):t.moveY<=-t.minMoveY&&this.next(t.type),this.cell=null)},keydown:function(e){!this.shown||"Escape"!==e.key&&27!==e.keyCode||this.hide()}},ee={render:function(e){var t=this;if(e){var n=this.options,i=this.data[e],r=this.current(e),s=P(i.max)?i.max():i.max,a=P(i.min)?i.min():i.min,o=0;C(s)&&(o=0<a?s:s+1),i.list.innerHTML="",i.current=r;for(var c=0;c<n.rows+2;c+=1){var h=document.createElement("li"),l=c-i.index,u=r+l*i.increment;o&&(u%=o)<a&&(u+=o),h.textContent=n.translate(e,i.aliases?i.aliases[u]:Z(u+i.offset,i.digit)),W(h,"name",e),W(h,"value",u),T(h,"".concat(g,"-item")),0===l&&(T(h,d),i.item=h),i.list.appendChild(h)}}else this.format.tokens.forEach(function(e){return t.render(G(e))})},current:function(e,t){var n=this.date,i=this.format,r=i[e];switch(r.charAt(0)){case"Y":return A(t)&&(n.setFullYear(2===r.length?2e3+t:t),i.month&&this.render(G(i.month)),i.day&&this.render(G(i.day))),n.getFullYear();case"M":return A(t)&&(n.setMonth(t,Math.min(n.getDate(),z(n.getFullYear(),t))),i.day&&this.render(G(i.day))),n.getMonth();case"D":return A(t)&&n.setDate(t),n.getDate();case"H":return A(t)&&n.setHours(t),n.getHours();case"m":return A(t)&&n.setMinutes(t),n.getMinutes();case"s":return A(t)&&n.setSeconds(t),n.getSeconds();case"S":return A(t)&&n.setMilliseconds(t),n.getMilliseconds()}return n},getValue:function(){var e=this.element;return this.isInput?e.value:e.textContent},setValue:function(e){var t=this.element;this.isInput?t.value=e:this.options.container&&(t.textContent=e)},open:function(){var e=this.body;e.style.overflow="hidden",e.style.paddingRight="".concat(this.scrollBarWidth+(parseFloat(this.initialBodyPaddingRight)||0),"px")},close:function(){var e=this.body;e.style.overflow="",e.style.paddingRight=this.initialBodyPaddingRight}},te={show:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.element,n=this.picker;if(this.inline||this.shown)return this;if(!1===$(t,M))return this;this.shown=!0,this.open(),T(n,b);var i=function(){$(t,Y)};return e||n.offsetWidth,T(n,y),e?i():setTimeout(i,300),this},hide:function(){var e=this,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0],n=this.element,i=this.picker;if(this.inline||!this.shown)return this;if(!1===$(n,l))return this;this.shown=!1,B(i,y);var r=function(){e.close(),B(i,b),$(n,h)};return t?r():setTimeout(r,300),this},prev:function(e){var t=this.options,n=this.format[e],i=this.data[e],r=i.list,s=r.lastElementChild,a=P(i.max)?i.max():i.max,o=P(i.min)?i.min():i.min,c=i.item.previousElementSibling,h=Number(R(r.firstElementChild,"value"))-i.increment;return h<o&&(h+=a-o+1),s.textContent=t.translate(e,i.aliases?i.aliases[h]:Z(h+i.offset,n.length)),W(s,"value",h),c&&(B(i.item,d),T(c,d),i.item=c),r.insertBefore(s,r.firstElementChild),i.current=Number(R(i.item,"value")),this.current(e,i.current),this.inline&&t.container&&this.pick(),this},next:function(e){var t=this.options,n=this.format[e],i=this.data[e],r=i.list,s=r.firstElementChild,a=P(i.max)?i.max():i.max,o=P(i.min)?i.min():i.min,c=i.item.nextElementSibling,h=Number(R(r.lastElementChild,"value"))+i.increment;return a<h&&(h-=a-o+1),s.textContent=t.translate(e,i.aliases?i.aliases[h]:Z(h+i.offset,n.length)),W(s,"value",h),r.appendChild(s),c&&(B(i.item,d),T(c,d),i.item=c),i.current=Number(R(i.item,"value")),this.current(e,i.current),this.inline&&t.container&&this.pick(),this},pick:function(){var e=this.element;if(!1===$(e,m))return this;var t=this.formatDate(this.date);return this.setValue(t),this.isInput&&!1===$(e,"change")&&this.reset(),this.hide(),this},getDate:function(){var e=0<arguments.length&&void 0!==arguments[0]&&arguments[0],t=this.date;return e?this.formatDate(t):new Date(t)},setDate:function(e){return e&&(this.date=this.parseDate(e),this.render()),this},update:function(){return this.date=this.parseDate(this.getValue()),this.render(),this},reset:function(){return this.setValue(this.initialValue),this.date=new Date(this.initialDate),this.render(),this},parseDate:function(o){var c=this.options,h=this.format,e=[];if(L(o))return new Date(o);if(S(o)){var t=n(c.months).concat(n(c.monthsShort),["\\d+"]);if((e=o.match(new RegExp("(".concat(t.join("|"),")"),"g")))&&o.length===c.format.length&&e.length!==h.tokens.length&&(e=h.tokens.map(function(e){return o.substr(c.format.indexOf(e),e.length)})),!e||e.length!==h.tokens.length)return new Date}var l=new Date;return e.forEach(function(e,t){var n=h.tokens[t],i=Number(e);switch(n){case"YYYY":case"YYY":case"Y":var r=o.indexOf(e),s="-"===o.substr(r-1,1),a=1<r&&s&&/\S/.test(o.substr(r-2,1))||1===r&&s;l.setFullYear(a?-i:i);break;case"YY":l.setFullYear(2e3+i);break;case"MMMM":l.setMonth(c.months.indexOf(e));break;case"MMM":l.setMonth(c.monthsShort.indexOf(e));break;case"MM":case"M":l.setMonth(i-1);break;case"DD":case"D":l.setDate(i);break;case"HH":case"H":l.setHours(i);break;case"mm":case"m":l.setMinutes(i);break;case"ss":case"s":l.setSeconds(i);break;case"SSS":case"SS":case"S":l.setMilliseconds(i)}}),l},formatDate:function(e){var t,n=this.options,i=this.format,r="";if(L(t=e)&&"Invalid Date"!==t.toString()){var s=e.getFullYear(),a=e.getMonth(),o=e.getDate(),c=e.getHours(),h=e.getMinutes(),l=e.getSeconds(),u=e.getMilliseconds();r=n.format,i.tokens.forEach(function(e){var t="";switch(e){case"YYYY":case"YYY":case"Y":t=Z(s,e.length);break;case"YY":t=Z(s%100,2);break;case"MMMM":t=n.months[a];break;case"MMM":t=n.monthsShort[a];break;case"MM":case"M":t=Z(a+1,e.length);break;case"DD":case"D":t=Z(o,e.length);break;case"HH":case"H":t=Z(c,e.length);break;case"mm":case"m":t=Z(h,e.length);break;case"ss":case"s":t=Z(l,e.length);break;case"SSS":case"SS":case"S":t=Z(u,e.length)}r=r.replace(e,t)})}return r},destroy:function(){var e=this.element,t=this.picker;return R(e,g)&&(this.hide(!0),this.unbind(),function(t,n){if(O(t[n]))try{delete t[n]}catch(e){t[n]=void 0}else if(t.dataset)try{delete t.dataset[n]}catch(e){t.dataset[n]=void 0}else t.removeAttribute("data-".concat(I(n)))}(e,g),t.parentNode.removeChild(t)),this}},ne=/\{\{\s*(\w+)\s*\}\}/g,ie=/input|textarea/i,re=v.Picker,se=function(){function n(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),!e||1!==e.nodeType)throw new Error("The first argument is required and must be an element.");this.element=e,this.options=j({},s,o[t.language],H(t)&&t),this.shown=!1,this.init()}var e,t,i;return e=n,i=[{key:"noConflict",value:function(){return v.Picker=re,n}},{key:"setDefaults",value:function(e){j(s,o[e.language],H(e)&&e)}}],(t=[{key:"init",value:function(){var s=this,e=this.element;if(!R(e,g)){W(e,g,this);var a=this.options,t=ie.test(e.tagName),n=a.inline&&(a.container||!t),i=document.createElement("div");i.insertAdjacentHTML("afterbegin",p.replace(ne,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.text[t[1]]}));var r=i.getElementsByClassName(g)[0],o=r.getElementsByClassName("".concat(g,"-grid"))[0],c=a.container;if(S(c)&&(c=document.querySelector(c)),n)T(r,b),T(r,y),c||(c=e);else{var h=e.ownerDocument,l=h.body||h.documentElement;this.body=l,this.scrollBarWidth=v.innerWidth-h.documentElement.clientWidth,this.initialBodyPaddingRight=v.getComputedStyle(l).paddingRight,T(r,"".concat(g,"-fixed")),c||(c=document.body)}this.isInput=t,this.inline=n,this.container=c,this.picker=r,this.grid=o,this.cell=null,this.format=function(e){var t=e.match(Q);if(!t)throw new Error("Invalid format");var n={tokens:t};return t.forEach(function(e){n[G(e)]=e}),n}(a.format);var u=this.getValue(),d=this.parseDate(a.date||u);this.date=d,this.initialDate=new Date(d),this.initialValue=u,this.data={};var m=Number(a.rows);m%2||(m+=1),a.rows=m||5,T(o,"".concat(g,1<m?"-multiple":"-single")),a.headers&&T(o,"".concat(g,"-headers"));var f=a.increment;H(f)||(f={year:f,month:f,day:f,hour:f,minute:f,second:f,millisecond:f}),this.format.tokens.forEach(function(e){var t=G(e),n=document.createElement("div"),i=document.createElement("ul"),r={digit:e.length,increment:Math.abs(Number(f[t]))||1,list:i,max:1/0,min:-1/0,index:Math.floor((a.rows+2)/2),offset:0};switch(e.charAt(0)){case"Y":2===r.digit&&(r.max=99,r.min=0);break;case"M":r.max=11,r.min=0,r.offset=1,3===r.digit?r.aliases=a.monthsShort:4===r.digit&&(r.aliases=a.months);break;case"D":r.max=function(){return z(d.getFullYear(),d.getMonth())},r.min=1;break;case"H":r.max=23,r.min=0;break;case"m":case"s":r.max=59,r.min=0;break;case"S":r.max=999,r.min=0}(W(n,"type",t),W(n,"token",e),a.headers)&&W(n,"header",a.headers[t]||t[0].toUpperCase()+t.substr(1));T(i,"".concat(g,"-list")),T(n,"".concat(g,"-cell")),T(n,"".concat(g,"-").concat(t,"s")),n.appendChild(i),o.appendChild(n),s.data[t]=r,s.render(t)}),n&&(c.innerHTML=""),c.appendChild(r),this.bind()}}}])&&r(e.prototype,t),i&&r(e,i),n}();return j(se.prototype,X,_,ee,te),se.languages=o,se});
{
"name": "pickerjs",
"description": "JavaScript date time picker.",
"version": "1.0.0",
"version": "1.1.0",
"main": "dist/picker.common.js",

@@ -47,3 +47,5 @@ "module": "dist/picker.esm.js",

"copy:i18n": "cpy i18n/* docs/js",
"lint": "eslint src test *.js --fix",
"lint": "npm run lint:js && npm run lint:css",
"lint:css": "stylelint {src,docs,examples}/**/*.{css,scss,html} --fix",
"lint:js": "eslint src test *.js --fix",
"release": "npm run clear && npm run lint && npm run build && npm run compress && npm run copy && npm test",

@@ -56,4 +58,4 @@ "start": "npm-run-all --parallel watch:*",

"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@babel/core": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@commitlint/cli": "^7.2.1",

@@ -70,7 +72,7 @@ "@commitlint/config-conventional": "^7.1.2",

"del-cli": "^1.1.0",
"eslint": "^5.7.0",
"eslint": "^5.10.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"husky": "^1.1.2",
"karma": "^3.1.1",
"husky": "^1.2.1",
"karma": "^3.1.3",
"karma-chai": "^0.1.0",

@@ -81,17 +83,20 @@ "karma-chrome-launcher": "^2.2.0",

"karma-mocha-reporter": "^2.2.5",
"karma-rollup-preprocessor": "^6.1.0",
"karma-rollup-preprocessor": "^6.1.1",
"lint-staged": "^8.1.0",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"npm-run-all": "^4.1.5",
"postcss-cli": "^6.0.1",
"postcss-header": "^1.0.0",
"postcss-import": "^12.0.0",
"postcss-preset-env": "^6.1.2",
"postcss-preset-env": "^6.5.0",
"postcss-url": "^8.0.0",
"puppeteer": "^1.9.0",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.3",
"puppeteer": "^1.11.0",
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.1.0",
"rollup-watch": "^4.3.1",
"stylefmt": "^6.0.3",
"stylelint": "^9.9.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-order": "^2.0.0",
"uglify-js": "^3.4.9"
}
}
# Picker.js
[![Build Status](https://travis-ci.org/fengyuanchen/pickerjs.svg)](https://travis-ci.org/fengyuanchen/pickerjs) [![Downloads](https://img.shields.io/npm/dm/pickerjs.svg)](https://www.npmjs.com/package/pickerjs) [![Version](https://img.shields.io/npm/v/pickerjs.svg)](https://www.npmjs.com/package/pickerjs)
[![Build Status](https://img.shields.io/travis/fengyuanchen/pickerjs.svg)](https://travis-ci.org/fengyuanchen/pickerjs) [![Downloads](https://img.shields.io/npm/dm/pickerjs.svg)](https://www.npmjs.com/package/pickerjs) [![Version](https://img.shields.io/npm/v/pickerjs.svg)](https://www.npmjs.com/package/pickerjs)

@@ -164,3 +164,3 @@ > JavaScript date time picker.

new Picker(element, {
date: 'Jul 15, 2016',
date: 'Oct 24, 2048',
format: 'MMM D, YYYY',

@@ -170,2 +170,31 @@ });

### headers
- Type: `Boolean` or `Object`
- Default: `false`
Indicate whether show the column headers or customize column headers.
```js
new Picker(element, {
headers: true,
});
```
Or
```js
new Picker(element, {
headers: {
year: '年',
month: '月',
day: '日',
hour: '时',
minute: '分',
second: '秒',
millisecond: '毫秒',
},
});
```
### increment

@@ -244,3 +273,3 @@

{
title: 'Pick a date / time',
title: 'Pick a date',
cancel: 'Cancel',

@@ -360,3 +389,3 @@ confirm: 'OK',

picker.getDate();
// > Sat Oct 24 2048 05:12:00 GMT+0800 (中国标准时间)
// > Sat Oct 24 2048 05:12:00 GMT+0800 (China Standard Time)

@@ -396,3 +425,3 @@ picker.getDate(true);

picker.parseDate('2048-10-24 05:12');
// > Sat Oct 24 2048 05:12:00 GMT+0800 (中国标准时间)
// > Sat Oct 24 2048 05:12:00 GMT+0800 (China Standard Time)
```

@@ -481,3 +510,3 @@

Maintained under the [Semantic Versioning guidelines](http://semver.org/).
Maintained under the [Semantic Versioning guidelines](https://semver.org).

@@ -484,0 +513,0 @@ ## License

@@ -11,2 +11,5 @@ export default {

// Indicate whether show the column headers or customize column headers
headers: false,
// Define the increment for each date / time part.

@@ -58,3 +61,3 @@ increment: 1,

text: {
title: 'Pick a date / time',
title: 'Pick a date',
cancel: 'Cancel',

@@ -61,0 +64,0 @@ confirm: 'OK',

@@ -296,4 +296,5 @@ import {

const index = date.indexOf(digit);
const isBC = (index > 1 && /\D/.test(date.substr(index - 2, 1)))
|| (index === 1 && date.substr(index - 1, 1) === '-');
const isHyphen = date.substr(index - 1, 1) === '-';
const isBC = (index > 1 && isHyphen && /\S/.test(date.substr(index - 2, 1)))
|| (index === 1 && isHyphen);

@@ -300,0 +301,0 @@ parsedDate.setFullYear(isBC ? -n : n);

@@ -125,2 +125,6 @@ import DEFAULTS from './defaults';

if (options.headers) {
addClass(grid, `${NAMESPACE}-headers`);
}
let { increment } = options;

@@ -160,2 +164,3 @@

}
break;

@@ -173,2 +178,3 @@

}
break;

@@ -206,2 +212,9 @@

setData(cell, 'token', token);
if (options.headers) {
const header = options.headers[type] || (type[0].toUpperCase() + type.substr(1));
setData(cell, 'header', header);
}
addClass(list, `${NAMESPACE}-list`);

@@ -208,0 +221,0 @@ addClass(cell, `${NAMESPACE}-cell`);

declare namespace Picker {
export interface HeadersOptions {
year?: string;
month?: string;
day?: string;
hour?: string;
minute?: string;
second?: string;
millisecond?: string;
}
export interface IncrementOptions {

@@ -22,2 +32,3 @@ year?: number;

format?: string;
headers?: boolean | HeadersOptions;
hidden?(event: CustomEvent): void;

@@ -24,0 +35,0 @@ hide?(event: CustomEvent): void;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc