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-beta to 1.0.0-rc

5

CHANGELOG.md
# Changelog
## 1.0.0-rc (Oct 23, 2018)
- Add polish localization (#13).
- Fix wrong maximum day when month change (#15, #16).
## 1.0.0-beta (Jun 18, 2018)

@@ -4,0 +9,0 @@

356

dist/picker.common.js
/*!
* Picker.js v1.0.0-beta
* Picker.js v1.0.0-rc
* https://fengyuanchen.github.io/pickerjs

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

*
* Date: 2018-06-18T03:14:41.357Z
* Date: 2018-10-23T13:45:42.568Z
*/

@@ -14,30 +14,77 @@

function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var DEFAULTS = {
// Define the container for putting the picker.
container: null,
// The initial date. If not present, use the current date.
date: null,
// The date string format, also as the sorting order for columns.
format: 'YYYY-MM-DD HH:mm',
// Define the increment for each date / time part.
increment: 1,
// Enable inline mode.
inline: false,
// Define the language. (An ISO language code).
language: '',
// Months' name.
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
// Shorter months' name.
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
// Define the number of rows for showing.
rows: 5,
// Define the text of the picker.

@@ -49,3 +96,2 @@ text: {

},
// Translate date / time text.

@@ -55,4 +101,2 @@ translate: function translate(type, text) {

},
// Shortcuts of custom events.

@@ -71,10 +115,8 @@ show: null,

var NAMESPACE = 'picker';
var LANGUAGES = {};
var LANGUAGES = {}; // Classes
// Classes
var CLASS_OPEN = NAMESPACE + '-open';
var CLASS_OPENED = NAMESPACE + '-opened';
var CLASS_PICKED = NAMESPACE + '-picked';
var CLASS_OPEN = "".concat(NAMESPACE, "-open");
var CLASS_OPENED = "".concat(NAMESPACE, "-opened");
var CLASS_PICKED = "".concat(NAMESPACE, "-picked"); // Events
// Events
var EVENT_CLICK = 'click';

@@ -93,46 +135,5 @@ var EVENT_FOCUS = 'focus';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var _Object$prototype = Object.prototype,
hasOwnProperty = _Object$prototype.hasOwnProperty,
toString = _Object$prototype.toString;
/**

@@ -147,3 +148,2 @@ * Detect the type of the given value.

}
/**

@@ -154,16 +154,16 @@ * Check if the given value is a string.

*/
function isString(value) {
return typeof value === 'string';
}
/**
* Check if the given value is finite.
*/
var isFinite = Number.isFinite || WINDOW.isFinite;
/**
* Check if the given value is not a number.
*/
var isNaN = Number.isNaN || WINDOW.isNaN;
/**

@@ -174,6 +174,6 @@ * Check if the given value is a number.

*/
function isNumber(value) {
return typeof value === 'number' && !isNaN(value);
}
/**

@@ -184,6 +184,6 @@ * Check if the given value is an object.

*/
function isObject(value) {
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
return _typeof(value) === 'object' && value !== null;
}
/**

@@ -194,2 +194,3 @@ * Check if the given value is a plain object.

*/
function isPlainObject(value) {

@@ -203,4 +204,2 @@ if (!isObject(value)) {

var prototype = _constructor.prototype;
return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');

@@ -211,3 +210,2 @@ } catch (e) {

}
/**

@@ -218,6 +216,6 @@ * Check if the given value is a function.

*/
function isFunction(value) {
return typeof value === 'function';
}
/**

@@ -228,6 +226,6 @@ * Check if the given value is a date.

*/
function isDate(value) {
return typeOf(value) === 'date';
}
/**

@@ -238,6 +236,6 @@ * Check if the given value is a valid date.

*/
function isValidDate(value) {
return isDate(value) && value.toString() !== 'Invalid Date';
}
/**

@@ -249,9 +247,11 @@ * Iterate the given data.

*/
function forEach(data, callback) {
if (data && isFunction(callback)) {
if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
if (Array.isArray(data) || isNumber(data.length)
/* array-like */
) {
var length = data.length;
var i;
var i = void 0;
for (i = 0; i < length; i += 1) {

@@ -271,3 +271,2 @@ if (callback.call(data, data[i], i, data) === false) {

}
/**

@@ -279,4 +278,5 @@ * Recursively assigns own enumerable properties of source objects to the target object.

*/
function deepAssign(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];

@@ -301,3 +301,2 @@ }

}
/**

@@ -308,2 +307,3 @@ * Add classes to the given element.

*/
function addClass(element, value) {

@@ -331,6 +331,5 @@ if (!value) {

} else if (className.indexOf(value) < 0) {
element.className = className + ' ' + value;
element.className = "".concat(className, " ").concat(value);
}
}
/**

@@ -341,2 +340,3 @@ * Remove classes from the given element.

*/
function removeClass(element, value) {

@@ -363,5 +363,3 @@ if (!value) {

}
var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g;
/**

@@ -372,6 +370,6 @@ * Transform the given string from camelCase to kebab-case

*/
function hyphenate(value) {
return value.replace(REGEXP_HYPHENATE, '$1-$2').toLowerCase();
}
/**

@@ -383,12 +381,14 @@ * Get data from the given element.

*/
function getData(element, name) {
if (isObject(element[name])) {
return element[name];
} else if (element.dataset) {
}
if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute('data-' + hyphenate(name));
return element.getAttribute("data-".concat(hyphenate(name)));
}
/**

@@ -400,2 +400,3 @@ * Set data to the given element.

*/
function setData(element, name, data) {

@@ -407,6 +408,5 @@ if (isObject(data)) {

} else {
element.setAttribute('data-' + hyphenate(name), data);
element.setAttribute("data-".concat(hyphenate(name)), data);
}
}
/**

@@ -417,2 +417,3 @@ * Remove data from the given element.

*/
function removeData(element, name) {

@@ -433,7 +434,7 @@ if (isObject(element[name])) {

} else {
element.removeAttribute('data-' + hyphenate(name));
element.removeAttribute("data-".concat(hyphenate(name)));
}
}
var REGEXP_SPACES = /\s\s*/;
var REGEXP_SPACES = /\s\s*/;
var onceSupported = function () {

@@ -444,5 +445,7 @@ var supported = false;

var once = false;
var listener = function listener() {};
var options = Object.defineProperty({}, 'once', {
get: function get$$1() {
get: function get() {
supported = true;

@@ -452,3 +455,2 @@ return once;

/**

@@ -459,7 +461,6 @@ * This setter can fix a `TypeError` in strict mode

*/
set: function set$$1(value) {
set: function set(value) {
once = value;
}
});
WINDOW.addEventListener('test', listener, options);

@@ -471,3 +472,2 @@ WINDOW.removeEventListener('test', listener, options);

}();
/**

@@ -480,7 +480,7 @@ * Remove event listener from the target element.

*/
function removeListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {

@@ -490,3 +490,2 @@ if (!onceSupported) {

if (listeners && listeners[event] && listeners[event][listener]) {

@@ -509,3 +508,2 @@ handler = listeners[event][listener];

}
/**

@@ -518,20 +516,19 @@ * Add event listener to the target element.

*/
function addListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var _handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {
if (options.once && !onceSupported) {
var _element$listeners = element.listeners,
listeners = _element$listeners === undefined ? {} : _element$listeners;
listeners = _element$listeners === void 0 ? {} : _element$listeners;
_handler = function handler() {
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
_handler = function handler() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
listener.apply(element, args);

@@ -555,3 +552,2 @@ };

}
/**

@@ -564,6 +560,6 @@ * Dispatch event on the target element.

*/
function dispatchEvent(element, type, data) {
var event = void 0;
var event; // Event and CustomEvent on IE9-11 are global objects, not constructors
// Event and CustomEvent on IE9-11 are global objects, not constructors
if (isFunction(Event) && isFunction(CustomEvent)) {

@@ -582,3 +578,2 @@ event = new CustomEvent(type, {

}
/**

@@ -589,6 +584,6 @@ * Check if the given year is a leap year.

*/
function isLeapYear(year) {
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
}
/**

@@ -600,6 +595,6 @@ * Get days number of the given month.

*/
function getDaysInMonth(year, month) {
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
/**

@@ -611,5 +606,5 @@ * Add leading zeroes to the given value

*/
function addLeadingZero(value) {
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var str = String(Math.abs(value));

@@ -630,3 +625,2 @@ var i = str.length;

}
/**

@@ -637,2 +631,3 @@ * Map token to type name

*/
function tokenToType(token) {

@@ -649,5 +644,3 @@ return {

}
var REGEXP_TOKENS = /(Y|M|D|H|m|s|S)\1*/g;
/**

@@ -658,2 +651,3 @@ * Parse date format.

*/
function parseFormat(format) {

@@ -669,7 +663,5 @@ var tokens = format.match(REGEXP_TOKENS);

};
tokens.forEach(function (token) {
result[tokenToType(token)] = token;
});
return result;

@@ -684,3 +676,2 @@ }

if (isFunction(options.show)) {

@@ -720,3 +711,2 @@ addListener(element, EVENT_SHOW, options.show);

if (isFunction(options.show)) {

@@ -770,3 +760,2 @@ removeListener(element, EVENT_SHOW, options.show);

if (target === this.grid) {

@@ -797,8 +786,7 @@ return;

if (target === this.grid) {
return;
}
} // This line is required for preventing page scrolling in iOS browsers
// This line is required for preventing page scrolling in iOS browsers
e.preventDefault();

@@ -816,3 +804,2 @@

var itemHeight = list.firstElementChild.offsetHeight;
this.cell = {

@@ -831,3 +818,2 @@ elem: target,

if (!cell) {

@@ -838,6 +824,4 @@ return;

e.preventDefault();
var endY = e.changedTouches ? e.changedTouches[0].pageY : e.pageY;
var moveY = cell.moveY + (endY - cell.startY);
cell.startY = endY;

@@ -847,3 +831,3 @@ cell.moveY = moveY;

if (Math.abs(moveY) < cell.maxMoveY) {
cell.list.style.top = moveY + 'px';
cell.list.style.top = "".concat(moveY, "px");
return;

@@ -864,3 +848,2 @@ }

if (!cell) {

@@ -900,3 +883,2 @@ return;

var options = this.options;
var data = this.data[type];

@@ -929,6 +911,5 @@ var current = this.current(type);

item.textContent = options.translate(type, data.aliases ? data.aliases[newValue] : addLeadingZero(newValue + data.offset, data.digit));
setData(item, 'name', type);
setData(item, 'value', newValue);
addClass(item, NAMESPACE + '-item');
addClass(item, "".concat(NAMESPACE, "-item"));

@@ -946,3 +927,2 @@ if (position === 0) {

var format = this.format;
var token = format[type];

@@ -968,3 +948,4 @@

if (isNumber(value)) {
date.setMonth(value);
date.setMonth(value, // The current day should not exceed its maximum day in current month
Math.min(date.getDate(), getDaysInMonth(date.getFullYear(), value)));

@@ -1020,4 +1001,2 @@ if (format.day) {

var element = this.element;
return this.isInput ? element.value : element.textContent;

@@ -1028,3 +1007,2 @@ },

if (this.isInput) {

@@ -1038,11 +1016,7 @@ element.value = value;

var body = this.body;
body.style.overflow = 'hidden';
body.style.paddingRight = this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0) + 'px';
body.style.paddingRight = "".concat(this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0), "px");
},
close: function close() {
var body = this.body;
body.style.overflow = '';

@@ -1064,3 +1038,2 @@ body.style.paddingRight = this.initialBodyPaddingRight;

if (this.inline || this.shown) {

@@ -1099,3 +1072,2 @@ return this;

/**

@@ -1113,3 +1085,2 @@ * Hide the picker.

if (this.inline || !this.shown) {

@@ -1128,2 +1099,3 @@ return this;

_this.close();
removeClass(picker, CLASS_OPEN);

@@ -1142,3 +1114,2 @@ dispatchEvent(element, EVENT_HIDDEN);

/**

@@ -1151,7 +1122,5 @@ * Pick to the previous item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.lastElementChild;

@@ -1168,3 +1137,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1189,3 +1157,2 @@

/**

@@ -1198,7 +1165,5 @@ * Pick to the next item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.firstElementChild;

@@ -1215,3 +1180,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1235,4 +1199,2 @@ list.appendChild(item);

},
// Pick the current date to the target element.

@@ -1242,3 +1204,2 @@ pick: function pick() {

if (dispatchEvent(element, EVENT_PICK) === false) {

@@ -1249,3 +1210,2 @@ return this;

var value = this.formatDate(this.date);
this.setValue(value);

@@ -1258,7 +1218,5 @@

this.hide();
return this;
},
/**

@@ -1272,8 +1230,5 @@ * Get the current date.

var date = this.date;
return formatted ? this.formatDate(date) : new Date(date);
},
/**

@@ -1292,4 +1247,2 @@ * Override the current date with a new date.

},
// Update the picker with the current element value / text.

@@ -1299,7 +1252,4 @@ update: function update() {

this.render();
return this;
},
// Reset the picker and element value / text.

@@ -1310,7 +1260,5 @@ reset: function reset() {

this.render();
return this;
},
/**

@@ -1324,3 +1272,2 @@ * Parse a date with the set date format.

format = this.format;
var digits = [];

@@ -1333,7 +1280,6 @@

if (isString(date)) {
var groups = [].concat(toConsumableArray(options.months), toConsumableArray(options.monthsShort), ['\\d+']);
var groups = _toConsumableArray(options.months).concat(_toConsumableArray(options.monthsShort), ['\\d+']);
digits = date.match(new RegExp('(' + groups.join('|') + ')', 'g'));
digits = date.match(new RegExp("(".concat(groups.join('|'), ")"), 'g')); // Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
// Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
if (digits && date.length === options.format.length && digits.length !== format.tokens.length) {

@@ -1351,3 +1297,2 @@ digits = format.tokens.map(function (token) {

var parsedDate = new Date();
digits.forEach(function (digit, i) {

@@ -1410,7 +1355,5 @@ var token = format.tokens[i];

});
return parsedDate;
},
/**

@@ -1424,3 +1367,2 @@ * Format a date object to a string with the set date format.

format = this.format;
var formatted = '';

@@ -1436,5 +1378,3 @@

var milliseconds = date.getMilliseconds();
formatted = options.format;
format.tokens.forEach(function (token) {

@@ -1502,4 +1442,2 @@ var replacement = '';

},
// Destroy the picker and remove the instance from the target element.

@@ -1510,3 +1448,2 @@ destroy: function destroy() {

if (!getData(element, NAMESPACE)) {

@@ -1528,3 +1465,5 @@ return this;

var Picker = function () {
var Picker =
/*#__PURE__*/
function () {
/**

@@ -1537,4 +1476,5 @@ * Create a new Picker.

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Picker);
_classCallCheck(this, Picker);
if (!element || element.nodeType !== 1) {

@@ -1550,4 +1490,4 @@ throw new Error('The first argument is required and must be an element.');

createClass(Picker, [{
key: 'init',
_createClass(Picker, [{
key: "init",
value: function init() {

@@ -1558,3 +1498,2 @@ var _this = this;

if (getData(element, NAMESPACE)) {

@@ -1565,11 +1504,8 @@ return;

setData(element, NAMESPACE, this);
var options = this.options;
var isInput = REGEXP_INPUTS.test(element.tagName);
var inline = options.inline && (options.container || !isInput);
var template = document.createElement('div');
template.insertAdjacentHTML('afterbegin', TEMPLATE.replace(REGEXP_DELIMITER, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -1580,8 +1516,6 @@ }

}));
var picker = template.getElementsByClassName(NAMESPACE)[0];
var grid = picker.getElementsByClassName(NAMESPACE + '-grid')[0];
var grid = picker.getElementsByClassName("".concat(NAMESPACE, "-grid"))[0];
var container = options.container;
if (isString(container)) {

@@ -1600,9 +1534,7 @@ container = document.querySelector(container);

var ownerDocument = element.ownerDocument;
var body = ownerDocument.body || ownerDocument.documentElement;
this.body = body;
this.scrollBarWidth = WINDOW.innerWidth - ownerDocument.documentElement.clientWidth;
this.initialBodyPaddingRight = WINDOW.getComputedStyle(body).paddingRight;
addClass(picker, NAMESPACE + '-fixed');
addClass(picker, "".concat(NAMESPACE, "-fixed"));

@@ -1621,6 +1553,4 @@ if (!container) {

this.format = parseFormat(options.format);
var initialValue = this.getValue();
var date = this.parseDate(options.date || initialValue);
this.date = date;

@@ -1630,3 +1560,2 @@ this.initialDate = new Date(date);

this.data = {};
var rows = Number(options.rows);

@@ -1639,7 +1568,5 @@

options.rows = rows || 5;
addClass(grid, rows > 1 ? NAMESPACE + '-multiple' : NAMESPACE + '-single');
addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
var increment = options.increment;
if (!isPlainObject(increment)) {

@@ -1677,2 +1604,3 @@ increment = {

}
break;

@@ -1690,2 +1618,3 @@

}
break;

@@ -1697,2 +1626,3 @@

};
data.min = 1;

@@ -1726,8 +1656,9 @@ break;

setData(cell, 'token', token);
addClass(list, NAMESPACE + '-list');
addClass(cell, NAMESPACE + '-cell');
addClass(cell, NAMESPACE + '-' + type + 's');
addClass(list, "".concat(NAMESPACE, "-list"));
addClass(cell, "".concat(NAMESPACE, "-cell"));
addClass(cell, "".concat(NAMESPACE, "-").concat(type, "s"));
cell.appendChild(list);
grid.appendChild(cell);
_this.data[type] = data;
_this.render(type);

@@ -1743,3 +1674,2 @@ });

}
/**

@@ -1751,3 +1681,3 @@ * Get the no conflict picker class.

}], [{
key: 'noConflict',
key: "noConflict",
value: function noConflict() {

@@ -1757,3 +1687,2 @@ WINDOW.Picker = AnotherPicker;

}
/**

@@ -1765,3 +1694,3 @@ * Change the default options.

}, {
key: 'setDefaults',
key: "setDefaults",
value: function setDefaults(options) {

@@ -1771,2 +1700,3 @@ deepAssign(DEFAULTS, LANGUAGES[options.language], isPlainObject(options) && options);

}]);
return Picker;

@@ -1773,0 +1703,0 @@ }();

/*!
* Picker.js v1.0.0-beta
* Picker.js v1.0.0-rc
* https://fengyuanchen.github.io/pickerjs

@@ -8,33 +8,80 @@ *

*
* Date: 2018-06-18T03:14:41.357Z
* Date: 2018-10-23T13:45:42.568Z
*/
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var DEFAULTS = {
// Define the container for putting the picker.
container: null,
// The initial date. If not present, use the current date.
date: null,
// The date string format, also as the sorting order for columns.
format: 'YYYY-MM-DD HH:mm',
// Define the increment for each date / time part.
increment: 1,
// Enable inline mode.
inline: false,
// Define the language. (An ISO language code).
language: '',
// Months' name.
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
// Shorter months' name.
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
// Define the number of rows for showing.
rows: 5,
// Define the text of the picker.

@@ -46,3 +93,2 @@ text: {

},
// Translate date / time text.

@@ -52,4 +98,2 @@ translate: function translate(type, text) {

},
// Shortcuts of custom events.

@@ -68,10 +112,8 @@ show: null,

var NAMESPACE = 'picker';
var LANGUAGES = {};
var LANGUAGES = {}; // Classes
// Classes
var CLASS_OPEN = NAMESPACE + '-open';
var CLASS_OPENED = NAMESPACE + '-opened';
var CLASS_PICKED = NAMESPACE + '-picked';
var CLASS_OPEN = "".concat(NAMESPACE, "-open");
var CLASS_OPENED = "".concat(NAMESPACE, "-opened");
var CLASS_PICKED = "".concat(NAMESPACE, "-picked"); // Events
// Events
var EVENT_CLICK = 'click';

@@ -90,46 +132,5 @@ var EVENT_FOCUS = 'focus';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var _Object$prototype = Object.prototype,
hasOwnProperty = _Object$prototype.hasOwnProperty,
toString = _Object$prototype.toString;
/**

@@ -144,3 +145,2 @@ * Detect the type of the given value.

}
/**

@@ -151,16 +151,16 @@ * Check if the given value is a string.

*/
function isString(value) {
return typeof value === 'string';
}
/**
* Check if the given value is finite.
*/
var isFinite = Number.isFinite || WINDOW.isFinite;
/**
* Check if the given value is not a number.
*/
var isNaN = Number.isNaN || WINDOW.isNaN;
/**

@@ -171,6 +171,6 @@ * Check if the given value is a number.

*/
function isNumber(value) {
return typeof value === 'number' && !isNaN(value);
}
/**

@@ -181,6 +181,6 @@ * Check if the given value is an object.

*/
function isObject(value) {
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
return _typeof(value) === 'object' && value !== null;
}
/**

@@ -191,2 +191,3 @@ * Check if the given value is a plain object.

*/
function isPlainObject(value) {

@@ -200,4 +201,2 @@ if (!isObject(value)) {

var prototype = _constructor.prototype;
return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');

@@ -208,3 +207,2 @@ } catch (e) {

}
/**

@@ -215,6 +213,6 @@ * Check if the given value is a function.

*/
function isFunction(value) {
return typeof value === 'function';
}
/**

@@ -225,6 +223,6 @@ * Check if the given value is a date.

*/
function isDate(value) {
return typeOf(value) === 'date';
}
/**

@@ -235,6 +233,6 @@ * Check if the given value is a valid date.

*/
function isValidDate(value) {
return isDate(value) && value.toString() !== 'Invalid Date';
}
/**

@@ -246,9 +244,11 @@ * Iterate the given data.

*/
function forEach(data, callback) {
if (data && isFunction(callback)) {
if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
if (Array.isArray(data) || isNumber(data.length)
/* array-like */
) {
var length = data.length;
var i;
var i = void 0;
for (i = 0; i < length; i += 1) {

@@ -268,3 +268,2 @@ if (callback.call(data, data[i], i, data) === false) {

}
/**

@@ -276,4 +275,5 @@ * Recursively assigns own enumerable properties of source objects to the target object.

*/
function deepAssign(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];

@@ -298,3 +298,2 @@ }

}
/**

@@ -305,2 +304,3 @@ * Add classes to the given element.

*/
function addClass(element, value) {

@@ -328,6 +328,5 @@ if (!value) {

} else if (className.indexOf(value) < 0) {
element.className = className + ' ' + value;
element.className = "".concat(className, " ").concat(value);
}
}
/**

@@ -338,2 +337,3 @@ * Remove classes from the given element.

*/
function removeClass(element, value) {

@@ -360,5 +360,3 @@ if (!value) {

}
var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g;
/**

@@ -369,6 +367,6 @@ * Transform the given string from camelCase to kebab-case

*/
function hyphenate(value) {
return value.replace(REGEXP_HYPHENATE, '$1-$2').toLowerCase();
}
/**

@@ -380,12 +378,14 @@ * Get data from the given element.

*/
function getData(element, name) {
if (isObject(element[name])) {
return element[name];
} else if (element.dataset) {
}
if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute('data-' + hyphenate(name));
return element.getAttribute("data-".concat(hyphenate(name)));
}
/**

@@ -397,2 +397,3 @@ * Set data to the given element.

*/
function setData(element, name, data) {

@@ -404,6 +405,5 @@ if (isObject(data)) {

} else {
element.setAttribute('data-' + hyphenate(name), data);
element.setAttribute("data-".concat(hyphenate(name)), data);
}
}
/**

@@ -414,2 +414,3 @@ * Remove data from the given element.

*/
function removeData(element, name) {

@@ -430,7 +431,7 @@ if (isObject(element[name])) {

} else {
element.removeAttribute('data-' + hyphenate(name));
element.removeAttribute("data-".concat(hyphenate(name)));
}
}
var REGEXP_SPACES = /\s\s*/;
var REGEXP_SPACES = /\s\s*/;
var onceSupported = function () {

@@ -441,5 +442,7 @@ var supported = false;

var once = false;
var listener = function listener() {};
var options = Object.defineProperty({}, 'once', {
get: function get$$1() {
get: function get() {
supported = true;

@@ -449,3 +452,2 @@ return once;

/**

@@ -456,7 +458,6 @@ * This setter can fix a `TypeError` in strict mode

*/
set: function set$$1(value) {
set: function set(value) {
once = value;
}
});
WINDOW.addEventListener('test', listener, options);

@@ -468,3 +469,2 @@ WINDOW.removeEventListener('test', listener, options);

}();
/**

@@ -477,7 +477,7 @@ * Remove event listener from the target element.

*/
function removeListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {

@@ -487,3 +487,2 @@ if (!onceSupported) {

if (listeners && listeners[event] && listeners[event][listener]) {

@@ -506,3 +505,2 @@ handler = listeners[event][listener];

}
/**

@@ -515,20 +513,19 @@ * Add event listener to the target element.

*/
function addListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var _handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {
if (options.once && !onceSupported) {
var _element$listeners = element.listeners,
listeners = _element$listeners === undefined ? {} : _element$listeners;
listeners = _element$listeners === void 0 ? {} : _element$listeners;
_handler = function handler() {
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
_handler = function handler() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
listener.apply(element, args);

@@ -552,3 +549,2 @@ };

}
/**

@@ -561,6 +557,6 @@ * Dispatch event on the target element.

*/
function dispatchEvent(element, type, data) {
var event = void 0;
var event; // Event and CustomEvent on IE9-11 are global objects, not constructors
// Event and CustomEvent on IE9-11 are global objects, not constructors
if (isFunction(Event) && isFunction(CustomEvent)) {

@@ -579,3 +575,2 @@ event = new CustomEvent(type, {

}
/**

@@ -586,6 +581,6 @@ * Check if the given year is a leap year.

*/
function isLeapYear(year) {
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
}
/**

@@ -597,6 +592,6 @@ * Get days number of the given month.

*/
function getDaysInMonth(year, month) {
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
/**

@@ -608,5 +603,5 @@ * Add leading zeroes to the given value

*/
function addLeadingZero(value) {
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var str = String(Math.abs(value));

@@ -627,3 +622,2 @@ var i = str.length;

}
/**

@@ -634,2 +628,3 @@ * Map token to type name

*/
function tokenToType(token) {

@@ -646,5 +641,3 @@ return {

}
var REGEXP_TOKENS = /(Y|M|D|H|m|s|S)\1*/g;
/**

@@ -655,2 +648,3 @@ * Parse date format.

*/
function parseFormat(format) {

@@ -666,7 +660,5 @@ var tokens = format.match(REGEXP_TOKENS);

};
tokens.forEach(function (token) {
result[tokenToType(token)] = token;
});
return result;

@@ -681,3 +673,2 @@ }

if (isFunction(options.show)) {

@@ -717,3 +708,2 @@ addListener(element, EVENT_SHOW, options.show);

if (isFunction(options.show)) {

@@ -767,3 +757,2 @@ removeListener(element, EVENT_SHOW, options.show);

if (target === this.grid) {

@@ -794,8 +783,7 @@ return;

if (target === this.grid) {
return;
}
} // This line is required for preventing page scrolling in iOS browsers
// This line is required for preventing page scrolling in iOS browsers
e.preventDefault();

@@ -813,3 +801,2 @@

var itemHeight = list.firstElementChild.offsetHeight;
this.cell = {

@@ -828,3 +815,2 @@ elem: target,

if (!cell) {

@@ -835,6 +821,4 @@ return;

e.preventDefault();
var endY = e.changedTouches ? e.changedTouches[0].pageY : e.pageY;
var moveY = cell.moveY + (endY - cell.startY);
cell.startY = endY;

@@ -844,3 +828,3 @@ cell.moveY = moveY;

if (Math.abs(moveY) < cell.maxMoveY) {
cell.list.style.top = moveY + 'px';
cell.list.style.top = "".concat(moveY, "px");
return;

@@ -861,3 +845,2 @@ }

if (!cell) {

@@ -897,3 +880,2 @@ return;

var options = this.options;
var data = this.data[type];

@@ -926,6 +908,5 @@ var current = this.current(type);

item.textContent = options.translate(type, data.aliases ? data.aliases[newValue] : addLeadingZero(newValue + data.offset, data.digit));
setData(item, 'name', type);
setData(item, 'value', newValue);
addClass(item, NAMESPACE + '-item');
addClass(item, "".concat(NAMESPACE, "-item"));

@@ -943,3 +924,2 @@ if (position === 0) {

var format = this.format;
var token = format[type];

@@ -965,3 +945,4 @@

if (isNumber(value)) {
date.setMonth(value);
date.setMonth(value, // The current day should not exceed its maximum day in current month
Math.min(date.getDate(), getDaysInMonth(date.getFullYear(), value)));

@@ -1017,4 +998,2 @@ if (format.day) {

var element = this.element;
return this.isInput ? element.value : element.textContent;

@@ -1025,3 +1004,2 @@ },

if (this.isInput) {

@@ -1035,11 +1013,7 @@ element.value = value;

var body = this.body;
body.style.overflow = 'hidden';
body.style.paddingRight = this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0) + 'px';
body.style.paddingRight = "".concat(this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0), "px");
},
close: function close() {
var body = this.body;
body.style.overflow = '';

@@ -1061,3 +1035,2 @@ body.style.paddingRight = this.initialBodyPaddingRight;

if (this.inline || this.shown) {

@@ -1096,3 +1069,2 @@ return this;

/**

@@ -1110,3 +1082,2 @@ * Hide the picker.

if (this.inline || !this.shown) {

@@ -1125,2 +1096,3 @@ return this;

_this.close();
removeClass(picker, CLASS_OPEN);

@@ -1139,3 +1111,2 @@ dispatchEvent(element, EVENT_HIDDEN);

/**

@@ -1148,7 +1119,5 @@ * Pick to the previous item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.lastElementChild;

@@ -1165,3 +1134,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1186,3 +1154,2 @@

/**

@@ -1195,7 +1162,5 @@ * Pick to the next item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.firstElementChild;

@@ -1212,3 +1177,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1232,4 +1196,2 @@ list.appendChild(item);

},
// Pick the current date to the target element.

@@ -1239,3 +1201,2 @@ pick: function pick() {

if (dispatchEvent(element, EVENT_PICK) === false) {

@@ -1246,3 +1207,2 @@ return this;

var value = this.formatDate(this.date);
this.setValue(value);

@@ -1255,7 +1215,5 @@

this.hide();
return this;
},
/**

@@ -1269,8 +1227,5 @@ * Get the current date.

var date = this.date;
return formatted ? this.formatDate(date) : new Date(date);
},
/**

@@ -1289,4 +1244,2 @@ * Override the current date with a new date.

},
// Update the picker with the current element value / text.

@@ -1296,7 +1249,4 @@ update: function update() {

this.render();
return this;
},
// Reset the picker and element value / text.

@@ -1307,7 +1257,5 @@ reset: function reset() {

this.render();
return this;
},
/**

@@ -1321,3 +1269,2 @@ * Parse a date with the set date format.

format = this.format;
var digits = [];

@@ -1330,7 +1277,6 @@

if (isString(date)) {
var groups = [].concat(toConsumableArray(options.months), toConsumableArray(options.monthsShort), ['\\d+']);
var groups = _toConsumableArray(options.months).concat(_toConsumableArray(options.monthsShort), ['\\d+']);
digits = date.match(new RegExp('(' + groups.join('|') + ')', 'g'));
digits = date.match(new RegExp("(".concat(groups.join('|'), ")"), 'g')); // Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
// Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
if (digits && date.length === options.format.length && digits.length !== format.tokens.length) {

@@ -1348,3 +1294,2 @@ digits = format.tokens.map(function (token) {

var parsedDate = new Date();
digits.forEach(function (digit, i) {

@@ -1407,7 +1352,5 @@ var token = format.tokens[i];

});
return parsedDate;
},
/**

@@ -1421,3 +1364,2 @@ * Format a date object to a string with the set date format.

format = this.format;
var formatted = '';

@@ -1433,5 +1375,3 @@

var milliseconds = date.getMilliseconds();
formatted = options.format;
format.tokens.forEach(function (token) {

@@ -1499,4 +1439,2 @@ var replacement = '';

},
// Destroy the picker and remove the instance from the target element.

@@ -1507,3 +1445,2 @@ destroy: function destroy() {

if (!getData(element, NAMESPACE)) {

@@ -1525,3 +1462,5 @@ return this;

var Picker = function () {
var Picker =
/*#__PURE__*/
function () {
/**

@@ -1534,4 +1473,5 @@ * Create a new Picker.

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Picker);
_classCallCheck(this, Picker);
if (!element || element.nodeType !== 1) {

@@ -1547,4 +1487,4 @@ throw new Error('The first argument is required and must be an element.');

createClass(Picker, [{
key: 'init',
_createClass(Picker, [{
key: "init",
value: function init() {

@@ -1555,3 +1495,2 @@ var _this = this;

if (getData(element, NAMESPACE)) {

@@ -1562,11 +1501,8 @@ return;

setData(element, NAMESPACE, this);
var options = this.options;
var isInput = REGEXP_INPUTS.test(element.tagName);
var inline = options.inline && (options.container || !isInput);
var template = document.createElement('div');
template.insertAdjacentHTML('afterbegin', TEMPLATE.replace(REGEXP_DELIMITER, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -1577,8 +1513,6 @@ }

}));
var picker = template.getElementsByClassName(NAMESPACE)[0];
var grid = picker.getElementsByClassName(NAMESPACE + '-grid')[0];
var grid = picker.getElementsByClassName("".concat(NAMESPACE, "-grid"))[0];
var container = options.container;
if (isString(container)) {

@@ -1597,9 +1531,7 @@ container = document.querySelector(container);

var ownerDocument = element.ownerDocument;
var body = ownerDocument.body || ownerDocument.documentElement;
this.body = body;
this.scrollBarWidth = WINDOW.innerWidth - ownerDocument.documentElement.clientWidth;
this.initialBodyPaddingRight = WINDOW.getComputedStyle(body).paddingRight;
addClass(picker, NAMESPACE + '-fixed');
addClass(picker, "".concat(NAMESPACE, "-fixed"));

@@ -1618,6 +1550,4 @@ if (!container) {

this.format = parseFormat(options.format);
var initialValue = this.getValue();
var date = this.parseDate(options.date || initialValue);
this.date = date;

@@ -1627,3 +1557,2 @@ this.initialDate = new Date(date);

this.data = {};
var rows = Number(options.rows);

@@ -1636,7 +1565,5 @@

options.rows = rows || 5;
addClass(grid, rows > 1 ? NAMESPACE + '-multiple' : NAMESPACE + '-single');
addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
var increment = options.increment;
if (!isPlainObject(increment)) {

@@ -1674,2 +1601,3 @@ increment = {

}
break;

@@ -1687,2 +1615,3 @@

}
break;

@@ -1694,2 +1623,3 @@

};
data.min = 1;

@@ -1723,8 +1653,9 @@ break;

setData(cell, 'token', token);
addClass(list, NAMESPACE + '-list');
addClass(cell, NAMESPACE + '-cell');
addClass(cell, NAMESPACE + '-' + type + 's');
addClass(list, "".concat(NAMESPACE, "-list"));
addClass(cell, "".concat(NAMESPACE, "-cell"));
addClass(cell, "".concat(NAMESPACE, "-").concat(type, "s"));
cell.appendChild(list);
grid.appendChild(cell);
_this.data[type] = data;
_this.render(type);

@@ -1740,3 +1671,2 @@ });

}
/**

@@ -1748,3 +1678,3 @@ * Get the no conflict picker class.

}], [{
key: 'noConflict',
key: "noConflict",
value: function noConflict() {

@@ -1754,3 +1684,2 @@ WINDOW.Picker = AnotherPicker;

}
/**

@@ -1762,3 +1691,3 @@ * Change the default options.

}, {
key: 'setDefaults',
key: "setDefaults",
value: function setDefaults(options) {

@@ -1768,2 +1697,3 @@ deepAssign(DEFAULTS, LANGUAGES[options.language], isPlainObject(options) && options);

}]);
return Picker;

@@ -1770,0 +1700,0 @@ }();

/*!
* Picker.js v1.0.0-beta
* Picker.js v1.0.0-rc
* https://fengyuanchen.github.io/pickerjs

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

*
* Date: 2018-06-18T03:14:41.357Z
* Date: 2018-10-23T13:45:42.568Z
*/

@@ -18,30 +18,77 @@

function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
var DEFAULTS = {
// Define the container for putting the picker.
container: null,
// The initial date. If not present, use the current date.
date: null,
// The date string format, also as the sorting order for columns.
format: 'YYYY-MM-DD HH:mm',
// Define the increment for each date / time part.
increment: 1,
// Enable inline mode.
inline: false,
// Define the language. (An ISO language code).
language: '',
// Months' name.
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
// Shorter months' name.
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
// Define the number of rows for showing.
rows: 5,
// Define the text of the picker.

@@ -53,3 +100,2 @@ text: {

},
// Translate date / time text.

@@ -59,4 +105,2 @@ translate: function translate(type, text) {

},
// Shortcuts of custom events.

@@ -75,10 +119,8 @@ show: null,

var NAMESPACE = 'picker';
var LANGUAGES = {};
var LANGUAGES = {}; // Classes
// Classes
var CLASS_OPEN = NAMESPACE + '-open';
var CLASS_OPENED = NAMESPACE + '-opened';
var CLASS_PICKED = NAMESPACE + '-picked';
var CLASS_OPEN = "".concat(NAMESPACE, "-open");
var CLASS_OPENED = "".concat(NAMESPACE, "-opened");
var CLASS_PICKED = "".concat(NAMESPACE, "-picked"); // Events
// Events
var EVENT_CLICK = 'click';

@@ -97,46 +139,5 @@ var EVENT_FOCUS = 'focus';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
var _Object$prototype = Object.prototype,
hasOwnProperty = _Object$prototype.hasOwnProperty,
toString = _Object$prototype.toString;
/**

@@ -151,3 +152,2 @@ * Detect the type of the given value.

}
/**

@@ -158,16 +158,16 @@ * Check if the given value is a string.

*/
function isString(value) {
return typeof value === 'string';
}
/**
* Check if the given value is finite.
*/
var isFinite = Number.isFinite || WINDOW.isFinite;
/**
* Check if the given value is not a number.
*/
var isNaN = Number.isNaN || WINDOW.isNaN;
/**

@@ -178,6 +178,6 @@ * Check if the given value is a number.

*/
function isNumber(value) {
return typeof value === 'number' && !isNaN(value);
}
/**

@@ -188,6 +188,6 @@ * Check if the given value is an object.

*/
function isObject(value) {
return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
return _typeof(value) === 'object' && value !== null;
}
/**

@@ -198,2 +198,3 @@ * Check if the given value is a plain object.

*/
function isPlainObject(value) {

@@ -207,4 +208,2 @@ if (!isObject(value)) {

var prototype = _constructor.prototype;
return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');

@@ -215,3 +214,2 @@ } catch (e) {

}
/**

@@ -222,6 +220,6 @@ * Check if the given value is a function.

*/
function isFunction(value) {
return typeof value === 'function';
}
/**

@@ -232,6 +230,6 @@ * Check if the given value is a date.

*/
function isDate(value) {
return typeOf(value) === 'date';
}
/**

@@ -242,6 +240,6 @@ * Check if the given value is a valid date.

*/
function isValidDate(value) {
return isDate(value) && value.toString() !== 'Invalid Date';
}
/**

@@ -253,9 +251,11 @@ * Iterate the given data.

*/
function forEach(data, callback) {
if (data && isFunction(callback)) {
if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
if (Array.isArray(data) || isNumber(data.length)
/* array-like */
) {
var length = data.length;
var i;
var i = void 0;
for (i = 0; i < length; i += 1) {

@@ -275,3 +275,2 @@ if (callback.call(data, data[i], i, data) === false) {

}
/**

@@ -283,4 +282,5 @@ * Recursively assigns own enumerable properties of source objects to the target object.

*/
function deepAssign(target) {
for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];

@@ -305,3 +305,2 @@ }

}
/**

@@ -312,2 +311,3 @@ * Add classes to the given element.

*/
function addClass(element, value) {

@@ -335,6 +335,5 @@ if (!value) {

} else if (className.indexOf(value) < 0) {
element.className = className + ' ' + value;
element.className = "".concat(className, " ").concat(value);
}
}
/**

@@ -345,2 +344,3 @@ * Remove classes from the given element.

*/
function removeClass(element, value) {

@@ -367,5 +367,3 @@ if (!value) {

}
var REGEXP_HYPHENATE = /([a-z\d])([A-Z])/g;
/**

@@ -376,6 +374,6 @@ * Transform the given string from camelCase to kebab-case

*/
function hyphenate(value) {
return value.replace(REGEXP_HYPHENATE, '$1-$2').toLowerCase();
}
/**

@@ -387,12 +385,14 @@ * Get data from the given element.

*/
function getData(element, name) {
if (isObject(element[name])) {
return element[name];
} else if (element.dataset) {
}
if (element.dataset) {
return element.dataset[name];
}
return element.getAttribute('data-' + hyphenate(name));
return element.getAttribute("data-".concat(hyphenate(name)));
}
/**

@@ -404,2 +404,3 @@ * Set data to the given element.

*/
function setData(element, name, data) {

@@ -411,6 +412,5 @@ if (isObject(data)) {

} else {
element.setAttribute('data-' + hyphenate(name), data);
element.setAttribute("data-".concat(hyphenate(name)), data);
}
}
/**

@@ -421,2 +421,3 @@ * Remove data from the given element.

*/
function removeData(element, name) {

@@ -437,7 +438,7 @@ if (isObject(element[name])) {

} else {
element.removeAttribute('data-' + hyphenate(name));
element.removeAttribute("data-".concat(hyphenate(name)));
}
}
var REGEXP_SPACES = /\s\s*/;
var REGEXP_SPACES = /\s\s*/;
var onceSupported = function () {

@@ -448,5 +449,7 @@ var supported = false;

var once = false;
var listener = function listener() {};
var options = Object.defineProperty({}, 'once', {
get: function get$$1() {
get: function get() {
supported = true;

@@ -456,3 +459,2 @@ return once;

/**

@@ -463,7 +465,6 @@ * This setter can fix a `TypeError` in strict mode

*/
set: function set$$1(value) {
set: function set(value) {
once = value;
}
});
WINDOW.addEventListener('test', listener, options);

@@ -475,3 +476,2 @@ WINDOW.removeEventListener('test', listener, options);

}();
/**

@@ -484,7 +484,7 @@ * Remove event listener from the target element.

*/
function removeListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {

@@ -494,3 +494,2 @@ if (!onceSupported) {

if (listeners && listeners[event] && listeners[event][listener]) {

@@ -513,3 +512,2 @@ handler = listeners[event][listener];

}
/**

@@ -522,20 +520,19 @@ * Add event listener to the target element.

*/
function addListener(element, type, listener) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var _handler = listener;
type.trim().split(REGEXP_SPACES).forEach(function (event) {
if (options.once && !onceSupported) {
var _element$listeners = element.listeners,
listeners = _element$listeners === undefined ? {} : _element$listeners;
listeners = _element$listeners === void 0 ? {} : _element$listeners;
_handler = function handler() {
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
_handler = function handler() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
delete listeners[event][listener];
element.removeEventListener(event, _handler, options);
listener.apply(element, args);

@@ -559,3 +556,2 @@ };

}
/**

@@ -568,6 +564,6 @@ * Dispatch event on the target element.

*/
function dispatchEvent(element, type, data) {
var event = void 0;
var event; // Event and CustomEvent on IE9-11 are global objects, not constructors
// Event and CustomEvent on IE9-11 are global objects, not constructors
if (isFunction(Event) && isFunction(CustomEvent)) {

@@ -586,3 +582,2 @@ event = new CustomEvent(type, {

}
/**

@@ -593,6 +588,6 @@ * Check if the given year is a leap year.

*/
function isLeapYear(year) {
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
}
/**

@@ -604,6 +599,6 @@ * Get days number of the given month.

*/
function getDaysInMonth(year, month) {
return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
}
/**

@@ -615,5 +610,5 @@ * Add leading zeroes to the given value

*/
function addLeadingZero(value) {
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
var str = String(Math.abs(value));

@@ -634,3 +629,2 @@ var i = str.length;

}
/**

@@ -641,2 +635,3 @@ * Map token to type name

*/
function tokenToType(token) {

@@ -653,5 +648,3 @@ return {

}
var REGEXP_TOKENS = /(Y|M|D|H|m|s|S)\1*/g;
/**

@@ -662,2 +655,3 @@ * Parse date format.

*/
function parseFormat(format) {

@@ -673,7 +667,5 @@ var tokens = format.match(REGEXP_TOKENS);

};
tokens.forEach(function (token) {
result[tokenToType(token)] = token;
});
return result;

@@ -688,3 +680,2 @@ }

if (isFunction(options.show)) {

@@ -724,3 +715,2 @@ addListener(element, EVENT_SHOW, options.show);

if (isFunction(options.show)) {

@@ -774,3 +764,2 @@ removeListener(element, EVENT_SHOW, options.show);

if (target === this.grid) {

@@ -801,8 +790,7 @@ return;

if (target === this.grid) {
return;
}
} // This line is required for preventing page scrolling in iOS browsers
// This line is required for preventing page scrolling in iOS browsers
e.preventDefault();

@@ -820,3 +808,2 @@

var itemHeight = list.firstElementChild.offsetHeight;
this.cell = {

@@ -835,3 +822,2 @@ elem: target,

if (!cell) {

@@ -842,6 +828,4 @@ return;

e.preventDefault();
var endY = e.changedTouches ? e.changedTouches[0].pageY : e.pageY;
var moveY = cell.moveY + (endY - cell.startY);
cell.startY = endY;

@@ -851,3 +835,3 @@ cell.moveY = moveY;

if (Math.abs(moveY) < cell.maxMoveY) {
cell.list.style.top = moveY + 'px';
cell.list.style.top = "".concat(moveY, "px");
return;

@@ -868,3 +852,2 @@ }

if (!cell) {

@@ -904,3 +887,2 @@ return;

var options = this.options;
var data = this.data[type];

@@ -933,6 +915,5 @@ var current = this.current(type);

item.textContent = options.translate(type, data.aliases ? data.aliases[newValue] : addLeadingZero(newValue + data.offset, data.digit));
setData(item, 'name', type);
setData(item, 'value', newValue);
addClass(item, NAMESPACE + '-item');
addClass(item, "".concat(NAMESPACE, "-item"));

@@ -950,3 +931,2 @@ if (position === 0) {

var format = this.format;
var token = format[type];

@@ -972,3 +952,4 @@

if (isNumber(value)) {
date.setMonth(value);
date.setMonth(value, // The current day should not exceed its maximum day in current month
Math.min(date.getDate(), getDaysInMonth(date.getFullYear(), value)));

@@ -1024,4 +1005,2 @@ if (format.day) {

var element = this.element;
return this.isInput ? element.value : element.textContent;

@@ -1032,3 +1011,2 @@ },

if (this.isInput) {

@@ -1042,11 +1020,7 @@ element.value = value;

var body = this.body;
body.style.overflow = 'hidden';
body.style.paddingRight = this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0) + 'px';
body.style.paddingRight = "".concat(this.scrollBarWidth + (parseFloat(this.initialBodyPaddingRight) || 0), "px");
},
close: function close() {
var body = this.body;
body.style.overflow = '';

@@ -1068,3 +1042,2 @@ body.style.paddingRight = this.initialBodyPaddingRight;

if (this.inline || this.shown) {

@@ -1103,3 +1076,2 @@ return this;

/**

@@ -1117,3 +1089,2 @@ * Hide the picker.

if (this.inline || !this.shown) {

@@ -1132,2 +1103,3 @@ return this;

_this.close();
removeClass(picker, CLASS_OPEN);

@@ -1146,3 +1118,2 @@ dispatchEvent(element, EVENT_HIDDEN);

/**

@@ -1155,7 +1126,5 @@ * Pick to the previous item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.lastElementChild;

@@ -1172,3 +1141,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1193,3 +1161,2 @@

/**

@@ -1202,7 +1169,5 @@ * Pick to the next item.

var options = this.options;
var token = this.format[type];
var data = this.data[type];
var list = data.list;
var item = list.firstElementChild;

@@ -1219,3 +1184,2 @@ var max = isFunction(data.max) ? data.max() : data.max;

item.textContent = options.translate(type, data.aliases ? data.aliases[value] : addLeadingZero(value + data.offset, token.length));
setData(item, 'value', value);

@@ -1239,4 +1203,2 @@ list.appendChild(item);

},
// Pick the current date to the target element.

@@ -1246,3 +1208,2 @@ pick: function pick() {

if (dispatchEvent(element, EVENT_PICK) === false) {

@@ -1253,3 +1214,2 @@ return this;

var value = this.formatDate(this.date);
this.setValue(value);

@@ -1262,7 +1222,5 @@

this.hide();
return this;
},
/**

@@ -1276,8 +1234,5 @@ * Get the current date.

var date = this.date;
return formatted ? this.formatDate(date) : new Date(date);
},
/**

@@ -1296,4 +1251,2 @@ * Override the current date with a new date.

},
// Update the picker with the current element value / text.

@@ -1303,7 +1256,4 @@ update: function update() {

this.render();
return this;
},
// Reset the picker and element value / text.

@@ -1314,7 +1264,5 @@ reset: function reset() {

this.render();
return this;
},
/**

@@ -1328,3 +1276,2 @@ * Parse a date with the set date format.

format = this.format;
var digits = [];

@@ -1337,7 +1284,6 @@

if (isString(date)) {
var groups = [].concat(toConsumableArray(options.months), toConsumableArray(options.monthsShort), ['\\d+']);
var groups = _toConsumableArray(options.months).concat(_toConsumableArray(options.monthsShort), ['\\d+']);
digits = date.match(new RegExp('(' + groups.join('|') + ')', 'g'));
digits = date.match(new RegExp("(".concat(groups.join('|'), ")"), 'g')); // Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
// Parse `11111111` (YYYYMMDD) to ['1111', '11', '11']
if (digits && date.length === options.format.length && digits.length !== format.tokens.length) {

@@ -1355,3 +1301,2 @@ digits = format.tokens.map(function (token) {

var parsedDate = new Date();
digits.forEach(function (digit, i) {

@@ -1414,7 +1359,5 @@ var token = format.tokens[i];

});
return parsedDate;
},
/**

@@ -1428,3 +1371,2 @@ * Format a date object to a string with the set date format.

format = this.format;
var formatted = '';

@@ -1440,5 +1382,3 @@

var milliseconds = date.getMilliseconds();
formatted = options.format;
format.tokens.forEach(function (token) {

@@ -1506,4 +1446,2 @@ var replacement = '';

},
// Destroy the picker and remove the instance from the target element.

@@ -1514,3 +1452,2 @@ destroy: function destroy() {

if (!getData(element, NAMESPACE)) {

@@ -1532,3 +1469,5 @@ return this;

var Picker = function () {
var Picker =
/*#__PURE__*/
function () {
/**

@@ -1541,4 +1480,5 @@ * Create a new Picker.

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Picker);
_classCallCheck(this, Picker);
if (!element || element.nodeType !== 1) {

@@ -1554,4 +1494,4 @@ throw new Error('The first argument is required and must be an element.');

createClass(Picker, [{
key: 'init',
_createClass(Picker, [{
key: "init",
value: function init() {

@@ -1562,3 +1502,2 @@ var _this = this;

if (getData(element, NAMESPACE)) {

@@ -1569,11 +1508,8 @@ return;

setData(element, NAMESPACE, this);
var options = this.options;
var isInput = REGEXP_INPUTS.test(element.tagName);
var inline = options.inline && (options.container || !isInput);
var template = document.createElement('div');
template.insertAdjacentHTML('afterbegin', TEMPLATE.replace(REGEXP_DELIMITER, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];

@@ -1584,8 +1520,6 @@ }

}));
var picker = template.getElementsByClassName(NAMESPACE)[0];
var grid = picker.getElementsByClassName(NAMESPACE + '-grid')[0];
var grid = picker.getElementsByClassName("".concat(NAMESPACE, "-grid"))[0];
var container = options.container;
if (isString(container)) {

@@ -1604,9 +1538,7 @@ container = document.querySelector(container);

var ownerDocument = element.ownerDocument;
var body = ownerDocument.body || ownerDocument.documentElement;
this.body = body;
this.scrollBarWidth = WINDOW.innerWidth - ownerDocument.documentElement.clientWidth;
this.initialBodyPaddingRight = WINDOW.getComputedStyle(body).paddingRight;
addClass(picker, NAMESPACE + '-fixed');
addClass(picker, "".concat(NAMESPACE, "-fixed"));

@@ -1625,6 +1557,4 @@ if (!container) {

this.format = parseFormat(options.format);
var initialValue = this.getValue();
var date = this.parseDate(options.date || initialValue);
this.date = date;

@@ -1634,3 +1564,2 @@ this.initialDate = new Date(date);

this.data = {};
var rows = Number(options.rows);

@@ -1643,7 +1572,5 @@

options.rows = rows || 5;
addClass(grid, rows > 1 ? NAMESPACE + '-multiple' : NAMESPACE + '-single');
addClass(grid, rows > 1 ? "".concat(NAMESPACE, "-multiple") : "".concat(NAMESPACE, "-single"));
var increment = options.increment;
if (!isPlainObject(increment)) {

@@ -1681,2 +1608,3 @@ increment = {

}
break;

@@ -1694,2 +1622,3 @@

}
break;

@@ -1701,2 +1630,3 @@

};
data.min = 1;

@@ -1730,8 +1660,9 @@ break;

setData(cell, 'token', token);
addClass(list, NAMESPACE + '-list');
addClass(cell, NAMESPACE + '-cell');
addClass(cell, NAMESPACE + '-' + type + 's');
addClass(list, "".concat(NAMESPACE, "-list"));
addClass(cell, "".concat(NAMESPACE, "-cell"));
addClass(cell, "".concat(NAMESPACE, "-").concat(type, "s"));
cell.appendChild(list);
grid.appendChild(cell);
_this.data[type] = data;
_this.render(type);

@@ -1747,3 +1678,2 @@ });

}
/**

@@ -1755,3 +1685,3 @@ * Get the no conflict picker class.

}], [{
key: 'noConflict',
key: "noConflict",
value: function noConflict() {

@@ -1761,3 +1691,2 @@ WINDOW.Picker = AnotherPicker;

}
/**

@@ -1769,3 +1698,3 @@ * Change the default options.

}, {
key: 'setDefaults',
key: "setDefaults",
value: function setDefaults(options) {

@@ -1775,2 +1704,3 @@ deepAssign(DEFAULTS, LANGUAGES[options.language], isPlainObject(options) && options);

}]);
return Picker;

@@ -1777,0 +1707,0 @@ }();

/*!
* Picker.js v1.0.0-beta
* Picker.js v1.0.0-rc
* https://fengyuanchen.github.io/pickerjs

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

*
* Date: 2018-06-18T03:14:41.357Z
* Date: 2018-10-23T13:45:42.568Z
*/
!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";var i={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(e,t){return t},show:null,shown:null,hide:null,hidden:null,pick:null},v='<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>',s="undefined"!=typeof window,p=s?window:{},g="picker",r={},b=g+"-open",y=g+"-opened",d=g+"-picked",a="click",o="focus",c="hidden",h="hide",l="keydown",u="pick",m=p.PointerEvent?"pointerdown":"touchstart mousedown",f=p.PointerEvent?"pointermove":"touchmove mousemove",k=p.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",w="show",M="shown",Y="wheel mousewheel DOMMouseScroll",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(){function i(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)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}(),n=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)},x=Object.prototype,E=x.hasOwnProperty,D=x.toString;function S(e){return"string"==typeof e}var C=Number.isFinite||p.isFinite,N=Number.isNaN||p.isNaN;function A(e){return"number"==typeof e&&!N(e)}function H(e){return"object"===(void 0===e?"undefined":t(e))&&null!==e}function P(e){if(!H(e))return!1;try{var t=e.constructor,n=t.prototype;return t&&n&&E.call(n,"isPrototypeOf")}catch(e){return!1}}function L(e){return"function"==typeof e}function O(e){return"date"===(t=e,D.call(t).slice(8,-1).toLowerCase());var t}function F(t,n){if(t&&L(n))if(Array.isArray(t)||A(t.length)){var e=t.length,i=void 0;for(i=0;i<e&&!1!==n.call(t,t[i],i,t);i+=1);}else H(t)&&Object.keys(t).forEach(function(e){n.call(t,t[e],e,t)});return t}function T(n){for(var e=arguments.length,t=Array(1<e?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return H(n)&&0<t.length&&t.forEach(function(t){H(t)&&Object.keys(t).forEach(function(e){P(n[e])&&P(t[e])?n[e]=T({},n[e],t[e]):n[e]=t[e]})}),n}function j(e,t){if(t)if(A(e.length))F(e,function(e){j(e,t)});else if(e.classList)e.classList.add(t);else{var n=e.className.trim();n?n.indexOf(t)<0&&(e.className=n+" "+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 R(e){return e.replace(V,"$1-$2").toLowerCase()}function W(e,t){return H(e[t])?e[t]:e.dataset?e.dataset[t]:e.getAttribute("data-"+R(t))}function I(e,t,n){H(n)?e[t]=n:e.dataset?e.dataset[t]=n:e.setAttribute("data-"+R(t),n)}var J=/\s\s*/,K=function(){var e=!1;if(s){var t=!1,n=function(){},i=Object.defineProperty({},"once",{get:function(){return e=!0,t},set:function(e){t=e}});p.addEventListener("test",n,i),p.removeEventListener("test",n,i)}return e}();function q(n,e,i){var s=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},r=i;e.trim().split(J).forEach(function(e){if(!K){var t=n.listeners;t&&t[e]&&t[e][i]&&(r=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,r,s)})}function U(r,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=r.listeners,s=void 0===e?{}:e;c=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];delete s[i][a],r.removeEventListener(i,c,o),a.apply(r,t)},s[i]||(s[i]={}),s[i][a]&&r.removeEventListener(i,s[i][a],o),s[i][a]=c,r.listeners=s}r.addEventListener(i,c,o)})}function $(e,t,n){var i=void 0;return L(Event)&&L(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){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:1,n=String(Math.abs(e)),i=n.length,s="";for(e<0&&(s+="-");i<t;)i+=1,s+="0";return s+n}function Z(e){return{Y:"year",M:"month",D:"day",H:"hour",m:"minute",s:"second",S:"millisecond"}[e.charAt(0)]}var G=/(Y|M|D|H|m|s|S)\1*/g;var Q={bind:function(){var e=this.element,t=this.options,n=this.grid;L(t.show)&&U(e,w,t.show),L(t.shown)&&U(e,M,t.shown),L(t.hide)&&U(e,h,t.hide),L(t.hidden)&&U(e,c,t.hidden),L(t.pick)&&U(e,u,t.pick),U(e,o,this.onFocus=this.focus.bind(this)),U(e,a,this.onFocus),U(this.picker,a,this.onClick=this.click.bind(this)),U(n,Y,this.onWheel=this.wheel.bind(this)),U(n,m,this.onPointerDown=this.pointerdown.bind(this)),U(document,f,this.onPointerMove=this.pointermove.bind(this)),U(document,k,this.onPointerUp=this.pointerup.bind(this)),U(document,l,this.onKeyDown=this.keydown.bind(this))},unbind:function(){var e=this.element,t=this.options,n=this.grid;L(t.show)&&q(e,w,t.show),L(t.shown)&&q(e,M,t.shown),L(t.hide)&&q(e,h,t.hide),L(t.hidden)&&q(e,c,t.hidden),L(t.pick)&&q(e,u,t.pick),q(e,o,this.onFocus),q(e,a,this.onFocus),q(this.picker,a,this.onClick),q(n,Y,this.onWheel),q(n,m,this.onPointerDown),q(document,f,this.onPointerMove),q(document,k,this.onPointerUp),q(document,l,this.onKeyDown)}},X={focus:function(e){e.target.blur(),this.show()},click:function(e){var t=W(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=W(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:W(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=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()}},_={render:function(e){var t=this;if(e){var n=this.options,i=this.data[e],s=this.current(e),r=L(i.max)?i.max():i.max,a=L(i.min)?i.min():i.min,o=0;C(r)&&(o=0<a?r:r+1),i.list.innerHTML="",i.current=s;for(var c=0;c<n.rows+2;c+=1){var h=document.createElement("li"),l=c-i.index,u=s+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)),I(h,"name",e),I(h,"value",u),j(h,g+"-item"),0===l&&(j(h,d),i.item=h),i.list.appendChild(h)}}else this.format.tokens.forEach(function(e){return t.render(Z(e))})},current:function(e,t){var n=this.date,i=this.format,s=i[e];switch(s.charAt(0)){case"Y":return A(t)&&(n.setFullYear(2===s.length?2e3+t:t),i.month&&this.render(Z(i.month)),i.day&&this.render(Z(i.day))),n.getFullYear();case"M":return A(t)&&(n.setMonth(t),i.day&&this.render(Z(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=this.scrollBarWidth+(parseFloat(this.initialBodyPaddingRight)||0)+"px"},close:function(){var e=this.body;e.style.overflow="",e.style.paddingRight=this.initialBodyPaddingRight}},ee={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,w))return this;this.shown=!0,this.open(),j(n,b);var i=function(){$(t,M)};return e||n.offsetWidth,j(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,h))return this;this.shown=!1,B(i,y);var s=function(){e.close(),B(i,b),$(n,c)};return t?s():setTimeout(s,300),this},prev:function(e){var t=this.options,n=this.format[e],i=this.data[e],s=i.list,r=s.lastElementChild,a=L(i.max)?i.max():i.max,o=L(i.min)?i.min():i.min,c=i.item.previousElementSibling,h=Number(W(s.firstElementChild,"value"))-i.increment;return h<o&&(h+=a-o+1),r.textContent=t.translate(e,i.aliases?i.aliases[h]:z(h+i.offset,n.length)),I(r,"value",h),c&&(B(i.item,d),j(c,d),i.item=c),s.insertBefore(r,s.firstElementChild),i.current=Number(W(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],s=i.list,r=s.firstElementChild,a=L(i.max)?i.max():i.max,o=L(i.min)?i.min():i.min,c=i.item.nextElementSibling,h=Number(W(s.lastElementChild,"value"))+i.increment;return a<h&&(h-=a-o+1),r.textContent=t.translate(e,i.aliases?i.aliases[h]:z(h+i.offset,n.length)),I(r,"value",h),s.appendChild(r),c&&(B(i.item,d),j(c,d),i.item=c),i.current=Number(W(i.item,"value")),this.current(e,i.current),this.inline&&t.container&&this.pick(),this},pick:function(){var e=this.element;if(!1===$(e,u))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(s){var r=this.options,a=this.format,e=[];if(O(s))return new Date(s);if(S(s)){var t=[].concat(n(r.months),n(r.monthsShort),["\\d+"]);if((e=s.match(new RegExp("("+t.join("|")+")","g")))&&s.length===r.format.length&&e.length!==a.tokens.length&&(e=a.tokens.map(function(e){return s.substr(r.format.indexOf(e),e.length)})),!e||e.length!==a.tokens.length)return new Date}var o=new Date;return e.forEach(function(e,t){var n=a.tokens[t],i=Number(e);switch(n){case"YYYY":case"YYY":case"Y":o.setFullYear("-"===s.substr(s.indexOf(e)-1,1)?-i:i);break;case"YY":o.setFullYear(2e3+i);break;case"MMMM":o.setMonth(r.months.indexOf(e));break;case"MMM":o.setMonth(r.monthsShort.indexOf(e));break;case"MM":case"M":o.setMonth(i-1);break;case"DD":case"D":o.setDate(i);break;case"HH":case"H":o.setHours(i);break;case"mm":case"m":o.setMinutes(i);break;case"ss":case"s":o.setSeconds(i);break;case"SSS":case"SS":case"S":o.setMilliseconds(i)}}),o},formatDate:function(e){var t,n=this.options,i=this.format,s="";if(O(t=e)&&"Invalid Date"!==t.toString()){var r=e.getFullYear(),a=e.getMonth(),o=e.getDate(),c=e.getHours(),h=e.getMinutes(),l=e.getSeconds(),u=e.getMilliseconds();s=n.format,i.tokens.forEach(function(e){var t="";switch(e){case"YYYY":case"YYY":case"Y":t=z(r,e.length);break;case"YY":t=z(r%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)}s=s.replace(e,t)})}return s},destroy:function(){var e=this.element,t=this.picker;return W(e,g)&&(this.hide(!0),this.unbind(),function(t,n){if(H(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-"+R(n))}(e,g),t.parentNode.removeChild(t)),this}},te=/\{\{\s*(\w+)\s*\}\}/g,ne=/input|textarea/i,ie=p.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=T({},i,r[t.language],P(t)&&t),this.shown=!1,this.init()}return e(n,[{key:"init",value:function(){var r=this,e=this.element;if(!W(e,g)){I(e,g,this);var a=this.options,t=ne.test(e.tagName),n=a.inline&&(a.container||!t),i=document.createElement("div");i.insertAdjacentHTML("afterbegin",v.replace(te,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return a.text[t[1]]}));var s=i.getElementsByClassName(g)[0],o=s.getElementsByClassName(g+"-grid")[0],c=a.container;if(S(c)&&(c=document.querySelector(c)),n)j(s,b),j(s,y),c||(c=e);else{var h=e.ownerDocument,l=h.body||h.documentElement;this.body=l,this.scrollBarWidth=p.innerWidth-h.documentElement.clientWidth,this.initialBodyPaddingRight=p.getComputedStyle(l).paddingRight,j(s,g+"-fixed"),c||(c=document.body)}this.isInput=t,this.inline=n,this.container=c,this.picker=s,this.grid=o,this.cell=null,this.format=function(e){var t=e.match(G);if(!t)throw new Error("Invalid format");var n={tokens:t};return t.forEach(function(e){n[Z(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,j(o,1<m?g+"-multiple":g+"-single");var f=a.increment;P(f)||(f={year:f,month:f,day:f,hour:f,minute:f,second:f,millisecond:f}),this.format.tokens.forEach(function(e){var t=Z(e),n=document.createElement("div"),i=document.createElement("ul"),s={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===s.digit&&(s.max=99,s.min=0);break;case"M":s.max=11,s.min=0,s.offset=1,3===s.digit?s.aliases=a.monthsShort:4===s.digit&&(s.aliases=a.months);break;case"D":s.max=function(){return e=d.getFullYear(),t=d.getMonth(),[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 e,t,n},s.min=1;break;case"H":s.max=23,s.min=0;break;case"m":case"s":s.max=59,s.min=0;break;case"S":s.max=999,s.min=0}I(n,"type",t),I(n,"token",e),j(i,g+"-list"),j(n,g+"-cell"),j(n,g+"-"+t+"s"),n.appendChild(i),o.appendChild(n),r.data[t]=s,r.render(t)}),n&&(c.innerHTML=""),c.appendChild(s),this.bind()}}}],[{key:"noConflict",value:function(){return p.Picker=ie,n}},{key:"setDefaults",value:function(e){T(i,r[e.language],P(e)&&e)}}]),n}();return T(se.prototype,Q,X,_,ee),se.languages=r,se});
!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",E="wheel mousewheel DOMMouseScroll",t=Object.prototype,x=t.hasOwnProperty,D=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&&x.call(n,"isPrototypeOf")}catch(t){return!1}}function P(t){return"function"==typeof t}function L(t){return"date"===(e=t,D.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,E,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,E,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(r){var s=this.options,a=this.format,t=[];if(L(r))return new Date(r);if(S(r)){var e=n(s.months).concat(n(s.monthsShort),["\\d+"]);if((t=r.match(new RegExp("(".concat(e.join("|"),")"),"g")))&&r.length===s.format.length&&t.length!==a.tokens.length&&(t=a.tokens.map(function(t){return r.substr(s.format.indexOf(t),t.length)})),!t||t.length!==a.tokens.length)return new Date}var o=new Date;return t.forEach(function(t,e){var n=a.tokens[e],i=Number(t);switch(n){case"YYYY":case"YYY":case"Y":o.setFullYear("-"===r.substr(r.indexOf(t)-1,1)?-i:i);break;case"YY":o.setFullYear(2e3+i);break;case"MMMM":o.setMonth(s.months.indexOf(t));break;case"MMM":o.setMonth(s.monthsShort.indexOf(t));break;case"MM":case"M":o.setMonth(i-1);break;case"DD":case"D":o.setDate(i);break;case"HH":case"H":o.setHours(i);break;case"mm":case"m":o.setMinutes(i);break;case"ss":case"s":o.setSeconds(i);break;case"SSS":case"SS":case"S":o.setMilliseconds(i)}}),o},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});
{
"name": "pickerjs",
"description": "JavaScript date time picker.",
"version": "1.0.0-beta",
"version": "1.0.0-rc",
"main": "dist/picker.common.js",

@@ -39,2 +39,3 @@ "module": "dist/picker.esm.js",

"clear": "del-cli dist",
"codecov": "cat coverage/lcov.info | codecov",
"commitmsg": "npm run lint && commitlint -e",

@@ -50,3 +51,3 @@ "compress": "npm run compress:css && npm run compress:js",

"start": "npm-run-all --parallel watch:*",
"test": "karma start test/karma.conf.js",
"test": "cross-env NODE_ENV=test karma start test/karma.conf.js",
"watch:css": "postcss src/index.css -o docs/css/picker.css -m -w",

@@ -56,37 +57,40 @@ "watch:js": "rollup -c -m -w"

"devDependencies": {
"@commitlint/cli": "^7.0.0",
"@commitlint/config-angular": "^7.0.1",
"babel-core": "^6.26.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"chai": "^4.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"babel-plugin-istanbul": "^5.1.0",
"chai": "^4.2.0",
"change-case": "^3.0.2",
"codecov": "^3.1.0",
"cpy-cli": "^2.0.0",
"create-banner": "^1.0.0",
"cssnano": "^3.10.0",
"cross-env": "^5.2.0",
"cssnano": "^4.1.5",
"del-cli": "^1.1.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.12.0",
"husky": "^0.14.3",
"karma": "^2.0.3",
"eslint": "^5.7.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"husky": "^1.1.2",
"karma": "^3.0.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-rollup-preprocessor": "^6.0.0",
"karma-rollup-preprocessor": "^6.1.0",
"mocha": "^5.2.0",
"npm-run-all": "^4.1.3",
"postcss-cli": "^5.0.0",
"postcss-cli": "^6.0.1",
"postcss-header": "^1.0.0",
"postcss-import": "^11.1.0",
"postcss-preset-env": "^5.1.0",
"puppeteer": "^1.5.0",
"rollup": "^0.60.7",
"rollup-plugin-babel": "^3.0.4",
"postcss-import": "^12.0.0",
"postcss-preset-env": "^6.1.2",
"postcss-url": "^8.0.0",
"puppeteer": "^1.9.0",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.3",
"rollup-watch": "^4.3.1",
"stylefmt": "^6.0.0",
"uglify-js": "^3.4.0"
"stylefmt": "^6.0.3",
"uglify-js": "^3.4.9"
}
}

@@ -8,2 +8,3 @@ import {

addLeadingZero,
getDaysInMonth,
isFinite,

@@ -50,4 +51,4 @@ isFunction,

item.textContent = options.translate(type, data.aliases ? data.aliases[newValue] :
addLeadingZero(newValue + data.offset, data.digit));
item.textContent = options.translate(type, data.aliases ? data.aliases[newValue]
: addLeadingZero(newValue + data.offset, data.digit));

@@ -90,4 +91,9 @@ setData(item, 'name', type);

if (isNumber(value)) {
date.setMonth(value);
date.setMonth(
value,
// The current day should not exceed its maximum day in current month
Math.min(date.getDate(), getDaysInMonth(date.getFullYear(), value)),
);
if (format.day) {

@@ -94,0 +100,0 @@ this.render(tokenToType(format.day));

@@ -122,4 +122,4 @@ import {

item.textContent = options.translate(type, data.aliases ? data.aliases[value] :
addLeadingZero(value + data.offset, token.length));
item.textContent = options.translate(type, data.aliases ? data.aliases[value]
: addLeadingZero(value + data.offset, token.length));

@@ -165,4 +165,4 @@ setData(item, 'value', value);

item.textContent = options.translate(type, data.aliases ? data.aliases[value] :
addLeadingZero(value + data.offset, token.length));
item.textContent = options.translate(type, data.aliases ? data.aliases[value]
: addLeadingZero(value + data.offset, token.length));

@@ -169,0 +169,0 @@ setData(item, 'value', value);

export default (
'<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>'
'<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>'
);

@@ -159,5 +159,5 @@ import {

export function hasClass(element, value) {
return element.classList ?
element.classList.contains(value) :
element.className.indexOf(value) > -1;
return element.classList
? element.classList.contains(value)
: element.className.indexOf(value) > -1;
}

@@ -269,3 +269,5 @@

return element[name];
} else if (element.dataset) {
}
if (element.dataset) {
return element.dataset[name];

@@ -272,0 +274,0 @@ }

@@ -52,2 +52,4 @@ declare namespace Picker {

update(): Picker;
static noConflict(): Picker;
static setDefaults(options: Picker.Options): void;
}

@@ -54,0 +56,0 @@

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