Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nrk/core-datepicker

Package Overview
Dependencies
Maintainers
142
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrk/core-datepicker - npm Package Compare versions

Comparing version 3.0.8 to 3.1.0

77

core-datepicker.cjs.js

@@ -0,1 +1,2 @@

/*! @nrk/core-datepicker v3.1.0 - Copyright (c) 2017-2021 NRK */
'use strict';

@@ -56,3 +57,3 @@

function isNativeReflectConstruct() {
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;

@@ -63,3 +64,3 @@ if (Reflect.construct.sham) return false;

try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;

@@ -72,3 +73,3 @@ } catch (e) {

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;

@@ -143,11 +144,29 @@ } else {

function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var IS_BROWSER = typeof window !== 'undefined';
var IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform));
// Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {
global.HTMLElement =
/*#__PURE__*/
function () {
global.HTMLElement = /*#__PURE__*/function () {
function _class() {

@@ -262,9 +281,7 @@ _classCallCheck(this, _class);

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var index_min = {exports: {}};
var index_min = createCommonjsModule(function (module, exports) {
(function (module, exports) {
!function (e, t) {
module.exports = t() ;
module.exports = t() ;
}(commonjsGlobal, function () {

@@ -330,4 +347,6 @@

});
});
})(index_min);
var _parse = index_min.exports;
var MASK = {

@@ -356,11 +375,11 @@ year: '*-m-d',

var CoreDatepicker =
/*#__PURE__*/
function (_HTMLElement) {
var CoreDatepicker = /*#__PURE__*/function (_HTMLElement) {
_inherits(CoreDatepicker, _HTMLElement);
var _super = _createSuper(CoreDatepicker);
function CoreDatepicker() {
_classCallCheck(this, CoreDatepicker);
return _possibleConstructorReturn(this, _getPrototypeOf(CoreDatepicker).apply(this, arguments));
return _super.apply(this, arguments);
}

@@ -396,3 +415,3 @@

value: function attributeChangedCallback() {
if (!this._date) return; // Only render after connectedCallback
if (!this._date) return; // Only render after connectedCallback and before disconnectedCallback

@@ -411,3 +430,3 @@ if (this.disabled(this.date) && !this.disabled(this._date)) return this.date = this._date; // Jump back

if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || event.type === 'keydown' && !KEYS[event.keyCode]) return;
if (!this.contains(event.target) && !closest(event.target, "[for=\"".concat(this.id, "\"]"))) return;
if (!this.contains(event.target) && !closest(event.target, "[for=\"".concat(this.id, "\"],[data-for=\"").concat(this.id, "\"]"))) return;
if (event.type === 'change') this.date = MASK[event.target.getAttribute('data-type')].replace('*', event.target.value);else if (event.type === 'click') {

@@ -434,3 +453,3 @@ var _button = closest(event.target, 'button[value]');

value: function parse(val, from) {
return index_min(val, from || this._date);
return _parse(val, from || this._date);
}

@@ -492,3 +511,3 @@ }, {

get: function get() {
return index_min(this.getAttribute('timestamp') || this._date || Date.now());
return _parse(this.getAttribute('timestamp') || this._date || Date.now());
},

@@ -500,15 +519,15 @@ set: function set(val) {

key: "months",
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('months', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
}
}, {
key: "days",
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('days', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
}

@@ -523,3 +542,3 @@ }], [{

return CoreDatepicker;
}(_wrapNativeSuper(HTMLElement));
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));

@@ -526,0 +545,0 @@ var pad = function pad(val) {

@@ -29,3 +29,3 @@ import { addStyle, closest, dispatchEvent, toggleAttribute, queryAll } from '../utils'

attributeChangedCallback () {
if (!this._date) return // Only render after connectedCallback
if (!this._date) return // Only render after connectedCallback and before disconnectedCallback
if (this.disabled(this.date) && !this.disabled(this._date)) return (this.date = this._date) // Jump back

@@ -42,3 +42,3 @@ if (this.diff(this.date)) dispatchEvent(this, 'datepicker.change', this._date = this.date)

if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || (event.type === 'keydown' && !KEYS[event.keyCode])) return
if (!this.contains(event.target) && !closest(event.target, `[for="${this.id}"]`)) return
if (!this.contains(event.target) && !closest(event.target, `[for="${this.id}"],[data-for="${this.id}"]`)) return
if (event.type === 'change') this.date = MASK[event.target.getAttribute('data-type')].replace('*', event.target.value)

@@ -45,0 +45,0 @@ else if (event.type === 'click') {

@@ -0,9 +1,12 @@

/*! @nrk/core-datepicker v3.1.0 - Copyright (c) 2017-2021 NRK */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) :
typeof define === 'function' && define.amd ? define(['react'], factory) :
(global = global || self, global.CoreDatepicker = factory(global.React));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.CoreDatepicker = factory(global.React));
}(this, (function (React) { 'use strict';
React = React && React.hasOwnProperty('default') ? React['default'] : React;
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function _classCallCheck(instance, Constructor) {

@@ -62,3 +65,3 @@ if (!(instance instanceof Constructor)) {

function isNativeReflectConstruct() {
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;

@@ -69,3 +72,3 @@ if (Reflect.construct.sham) return false;

try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;

@@ -78,3 +81,3 @@ } catch (e) {

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;

@@ -149,11 +152,29 @@ } else {

function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var IS_BROWSER = typeof window !== 'undefined';
var IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform));
// Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {
global.HTMLElement =
/*#__PURE__*/
function () {
global.HTMLElement = /*#__PURE__*/function () {
function _class() {

@@ -184,3 +205,3 @@ _classCallCheck(this, _class);

var closest = function () {
var closest$1 = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;

@@ -269,9 +290,7 @@ var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var index_min = {exports: {}};
var index_min = createCommonjsModule(function (module, exports) {
(function (module, exports) {
!function (e, t) {
module.exports = t() ;
module.exports = t() ;
}(commonjsGlobal, function () {

@@ -337,4 +356,6 @@

});
});
})(index_min);
var _parse = index_min.exports;
var MASK = {

@@ -363,11 +384,11 @@ year: '*-m-d',

var CoreDatepicker =
/*#__PURE__*/
function (_HTMLElement) {
var CoreDatepicker = /*#__PURE__*/function (_HTMLElement) {
_inherits(CoreDatepicker, _HTMLElement);
var _super = _createSuper(CoreDatepicker);
function CoreDatepicker() {
_classCallCheck(this, CoreDatepicker);
return _possibleConstructorReturn(this, _getPrototypeOf(CoreDatepicker).apply(this, arguments));
return _super.apply(this, arguments);
}

@@ -403,3 +424,3 @@

value: function attributeChangedCallback() {
if (!this._date) return; // Only render after connectedCallback
if (!this._date) return; // Only render after connectedCallback and before disconnectedCallback

@@ -418,11 +439,11 @@ if (this.disabled(this.date) && !this.disabled(this._date)) return this.date = this._date; // Jump back

if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || event.type === 'keydown' && !KEYS[event.keyCode]) return;
if (!this.contains(event.target) && !closest(event.target, "[for=\"".concat(this.id, "\"]"))) return;
if (!this.contains(event.target) && !closest$1(event.target, "[for=\"".concat(this.id, "\"],[data-for=\"").concat(this.id, "\"]"))) return;
if (event.type === 'change') this.date = MASK[event.target.getAttribute('data-type')].replace('*', event.target.value);else if (event.type === 'click') {
var _button = closest(event.target, 'button[value]');
var _button = closest$1(event.target, 'button[value]');
var _table = closest(event.target, 'table');
var _table = closest$1(event.target, 'table');
if (_button) this.date = _button.value;
if (_button && _table) dispatchEvent(this, 'datepicker.click.day');
} else if (event.type === 'keydown' && closest(event.target, 'table')) {
} else if (event.type === 'keydown' && closest$1(event.target, 'table')) {
this.date = KEYS[event.keyCode];

@@ -441,3 +462,3 @@ this.querySelector('[autofocus]').focus();

value: function parse(val, from) {
return index_min(val, from || this._date);
return _parse(val, from || this._date);
}

@@ -499,3 +520,3 @@ }, {

get: function get() {
return index_min(this.getAttribute('timestamp') || this._date || Date.now());
return _parse(this.getAttribute('timestamp') || this._date || Date.now());
},

@@ -507,15 +528,15 @@ set: function set(val) {

key: "months",
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('months', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
}
}, {
key: "days",
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('days', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
}

@@ -530,3 +551,3 @@ }], [{

return CoreDatepicker;
}(_wrapNativeSuper(HTMLElement));
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));

@@ -611,3 +632,3 @@ var pad = function pad(val) {

var version = "3.0.8";
var version = "3.1.0";

@@ -621,3 +642,3 @@ /**

var closest$1 = function () {
var closest = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;

@@ -668,99 +689,96 @@ var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;

var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();
return (
/*@__PURE__*/
function (superclass) {
function anonymous(props) {
var this$1 = this;
superclass.call(this, props); // Register ref prop for accessing custom element https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
return function (superclass) {
function anonymous(props) {
var this$1$1 = this;
superclass.call(this, props); // Register ref prop for accessing custom element https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
this.ref = function (el) {
if (typeof this$1.props.forwardRef === 'function') {
this$1.props.forwardRef(el);
} else if (this$1.props.forwardRef) {
this$1.props.forwardRef.current = el;
}
this.ref = function (el) {
if (typeof this$1$1.props.forwardRef === 'function') {
this$1$1.props.forwardRef(el);
} else if (this$1$1.props.forwardRef) {
this$1$1.props.forwardRef.current = el;
}
return this$1.el = el;
}; // Register event handler on component for each custom event
return this$1$1.el = el;
}; // Register event handler on component for each custom event
Object.keys(eventMap).forEach(function (eventName) {
var onEventName = eventMap[eventName];
Object.keys(eventMap).forEach(function (eventName) {
var onEventName = eventMap[eventName];
this$1[eventName] = function (event) {
if (this$1.props[onEventName] && closest$1(event.target, this$1.el.nodeName) === this$1.el) {
this$1.props[onEventName](event);
}
};
});
}
this$1$1[eventName] = function (event) {
if (this$1$1.props[onEventName] && closest(event.target, this$1$1.el.nodeName) === this$1$1.el) {
this$1$1.props[onEventName](event);
}
};
});
}
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1 = this; // Run connectedCallback() after React componentDidMount() to allow React hydration to run first
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1$1 = this; // Run connectedCallback() after React componentDidMount() to allow React hydration to run first
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
} // Populate properties on custom element
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
} // Populate properties on custom element
customProps.forEach(function (propName) {
if (propName in this$1.props) {
this$1.el[propName] = this$1.props[propName];
}
}); // Register events on custom element
customProps.forEach(function (propName) {
if (propName in this$1$1.props) {
this$1$1.el[propName] = this$1$1.props[propName];
}
}); // Register events on custom element
customEvents.forEach(function (eventName) {
this$1.el.addEventListener(eventName, this$1[eventName]);
});
};
customEvents.forEach(function (eventName) {
this$1$1.el.addEventListener(eventName, this$1$1[eventName]);
});
};
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1 = this; // Sync prop changes to custom element
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1$1 = this; // Sync prop changes to custom element
customProps.forEach(function (propName) {
if (prev[propName] !== this$1.props[propName]) {
this$1.el[propName] = this$1.props[propName];
}
});
};
customProps.forEach(function (propName) {
if (prev[propName] !== this$1$1.props[propName]) {
this$1$1.el[propName] = this$1$1.props[propName];
}
});
};
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1 = this; // Remove event handlers on custom element on unmount
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1$1 = this; // Remove event handlers on custom element on unmount
customEvents.forEach(function (eventName) {
this$1.el.removeEventListener(eventName, this$1[eventName]);
});
};
customEvents.forEach(function (eventName) {
this$1$1.el.removeEventListener(eventName, this$1$1[eventName]);
});
};
anonymous.prototype.render = function render() {
var this$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
anonymous.prototype.render = function render() {
var this$1$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tagName, Object.keys(this.props).reduce(function (thisProps, propName) {
if (skipProps.indexOf(propName) === -1) {
// Do not render customEvents and custom props as attributes
if (propName === 'className') {
thisProps["class"] = this$1.props[propName];
} // Fixes className for custom elements
else if (this$1.props[propName] === true) {
thisProps[propName] = '';
} // Fixes boolean attributes
else if (this$1.props[propName] !== false) {
thisProps[propName] = this$1.props[propName];
} // Pass only truthy, non-function props
return React__default['default'].createElement(tagName, Object.keys(this.props).reduce(function (thisProps, propName) {
if (skipProps.indexOf(propName) === -1) {
// Do not render customEvents and custom props as attributes
if (propName === 'className') {
thisProps["class"] = this$1$1.props[propName];
} // Fixes className for custom elements
else if (this$1$1.props[propName] === true) {
thisProps[propName] = '';
} // Fixes boolean attributes
else if (this$1$1.props[propName] !== false) {
thisProps[propName] = this$1$1.props[propName];
} // Pass only truthy, non-function props
}
}
return thisProps;
}, {
ref: this.ref
}));
};
return thisProps;
}, {
ref: this.ref
}));
};
return anonymous;
}(React.Component)
);
return anonymous;
}(React__default['default'].Component);
}

@@ -767,0 +785,0 @@

@@ -1,3 +0,3 @@

/*! @nrk/core-datepicker v3.0.8 - Copyright (c) 2017-2019 NRK */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).coreDatepicker=e()}(this,function(){"use strict";function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(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 r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e,n){return(a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&o(r,n.prototype),r}).apply(null,arguments)}function u(t){var n="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||!function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return a(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)})(t)}function n(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform));t||global.HTMLElement||(global.HTMLElement=function(){return function t(){e(this,t)}}());var c,s,d=(c="undefined"==typeof window?{}:window.Element.prototype,s=c.matches||c.msMatchesSelector||c.webkitMatchesSelector,c.closest?function(t,e){return t.closest(e)}:function(t,e){for(t.correspondingUseElement&&(t=t.correspondingUseElement);t;t=t.parentElement)if(s.call(t,e))return t;return null});function l(t,e,n){var i,r=2<arguments.length&&void 0!==n?n:{},o="prevent_recursive_dispatch_maximum_callstack".concat(e);if(t[o])return!0;t[o]=!0,"function"==typeof window.CustomEvent?i=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r}):(i=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,r);var a=t.dispatchEvent(i);return t[o]=null,a}function f(t,e){var n=1<arguments.length&&void 0!==e?e:document;if(t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(n.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var h,y=(function(t,e){var b,v,k,w;t.exports=(b={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},v=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,k=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,w=/([\dh]+):([\dm]+):?([\ds]+)?/,function(t,e){if(isFinite(t))return new Date(Number(t));var n=String(t).toLowerCase(),r=new Date(isFinite(e)&&-1===n.indexOf("now")?Number(e):Date.now()),i=n.match(k)||[],o=i[1];void 0===o&&(o="y");var a=i[2];void 0===a&&(a="m");var u=i[3];void 0===u&&(u="d");var c=n.match(w)||[],s=c[1];void 0===s&&(s="h");var d=c[2];void 0===d&&(d="m");var l=c[3];void 0===l&&(l="s");var f={year:o,month:a,day:u,hour:s,minute:d,second:l};Object.keys(f).forEach(function(t){var e="month"===t?1:0,i=String(r["get"+b[t]]()+e);f[t]=f[t].replace(/[^-\d]+/g,function(t,e,n){return e?i.substr(i.length-n.length+e,t.length):i.substr(0,Math.max(0,i.length-n.length+t.length))})-e});var h=new Date(f.year,Math.min(12,f.month+1),0).getDate();for(r.setFullYear(f.year,Math.min(11,f.month),Math.max(1,Math.min(h,f.day))),r.setHours(Math.min(24,f.hour),Math.min(59,f.minute),Math.min(59,f.second));null!==(f=v.exec(n));){var y=f[2],m=String(f[1]).replace(/\s/g,"")*("week"===y?7:1),p=f.slice(2).indexOf(f[0]),g=r.getDate();y?r["set"+b[y]](r["get"+b[y]]()+m):r.setDate(r.getDate()-(r.getDay()||7)+p),"month"!==y&&"year"!==y||g===r.getDate()||r.setDate(0)}return r})}(h={exports:{}},h.exports),h.exports),m={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*",null:"*"},p={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},g=function(){function t(){return e(this,t),n(this,r(t).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}(t,u(HTMLElement)),function(t,e,n){e&&i(t.prototype,e),n&&i(t,n)}(t,[{key:"connectedCallback",value:function(){var t=this;this._date=this.date,document.addEventListener("click",this),document.addEventListener("change",this),document.addEventListener("keydown",this),setTimeout(function(){return t.attributeChangedCallback()}),function(t,e){var n="style-".concat(t.toLowerCase()),i=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1");document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(i,"</style>"))}(this.nodeName,"".concat(this.nodeName,"{display:block}"))}},{key:"disconnectedCallback",value:function(){this._date=this._disabled=null,document.removeEventListener("click",this),document.removeEventListener("change",this),document.removeEventListener("keydown",this)}},{key:"attributeChangedCallback",value:function(){if(this._date){if(this.disabled(this.date)&&!this.disabled(this._date))return this.date=this._date;this.diff(this.date)&&l(this,"datepicker.change",this._date=this.date),v("button",this,k),v("select",this,_),v("input",this,w),v("table",this,E)}}},{key:"handleEvent",value:function(t){if(!(t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||"keydown"===t.type&&!p[t.keyCode])&&(this.contains(t.target)||d(t.target,'[for="'.concat(this.id,'"]'))))if("change"===t.type)this.date=m[t.target.getAttribute("data-type")].replace("*",t.target.value);else if("click"===t.type){var e=d(t.target,"button[value]"),n=d(t.target,"table");e&&(this.date=e.value),e&&n&&l(this,"datepicker.click.day")}else"keydown"===t.type&&d(t.target,"table")&&(this.date=p[t.keyCode],this.querySelector("[autofocus]").focus(),t.preventDefault())}},{key:"diff",value:function(t){return this.parse(t).getTime()-this.timestamp}},{key:"parse",value:function(t,e){return y(t,e||this._date)}},{key:"disabled",get:function(){return this._disabled||Function.prototype},set:function(e){var n=this;this._disabled="function"==typeof e?function(t){return e(n.parse(t),n)}:function(){return e},this.attributeChangedCallback()}},{key:"timestamp",get:function(){return String(this._date.getTime())}},{key:"year",get:function(){return String(this._date.getFullYear())}},{key:"month",get:function(){return b(this._date.getMonth()+1)}},{key:"day",get:function(){return b(this._date.getDate())}},{key:"hour",get:function(){return b(this._date.getHours())}},{key:"minute",get:function(){return b(this._date.getMinutes())}},{key:"second",get:function(){return b(this._date.getSeconds())}},{key:"date",get:function(){return y(this.getAttribute("timestamp")||this._date||Date.now())},set:function(t){return this.setAttribute("timestamp",this.parse(t).getTime())}},{key:"months",set:function(t){this.setAttribute("months",[].concat(t).join(","))},get:function(){return(this.getAttribute("months")||"januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember").split(/\s*,\s*/)}},{key:"days",set:function(t){this.setAttribute("days",[].concat(t).join(","))},get:function(){return(this.getAttribute("days")||"man,tirs,ons,tors,fre,lør,søn").split(/\s*,\s*/)}}],[{key:"observedAttributes",get:function(){return["timestamp","months","days"]}}]),t}(),b=function(t){return"0".concat(t).slice(-2)},v=function(t,e,n){return[].forEach.call(document.getElementsByTagName(t),function(t){!e.contains(t)&&e.id!==t.getAttribute(e.external)||n(e,t)})};function k(t,e){e.value&&(e.type="button",e.disabled=t.disabled(e.value))}function w(t,e){var n=e.getAttribute("data-type")||e.getAttribute("type");"radio"===n||"checkbox"===n?(e.disabled=t.disabled(e.value),e.checked=!t.diff(e.value)):m[n]&&(e.setAttribute("type","number"),e.setAttribute("data-type",n),e.value=t[n])}function E(r,t){t.firstElementChild||(t.innerHTML="\n <caption></caption><thead><tr>".concat(Array(8).join("</th><th>"),"</tr></thead>\n <tbody>").concat(Array(7).join("<tr>".concat(Array(8).join('<td><button type="button"></button></td>'),"</tr>")),"</tbody>"));var o=new Date,a=r.date.getMonth(),u=r.parse("y-m-1 mon");t.caption.textContent="".concat(r.months[a],", ").concat(r.year),f("th",t).forEach(function(t,e){return t.textContent=r.days[e]}),f("button",t).forEach(function(t){var e=!r.diff(u),n=u.getDate(),i=u.getMonth();t.textContent=n,t.value="".concat(u.getFullYear(),"-").concat(i+1,"-").concat(n),t.disabled=r.disabled(u),t.tabIndex=e-1,t.setAttribute("data-adjacent",a!==i),t.setAttribute("aria-label","".concat(n,". ").concat(r.months[i])),t.setAttribute("aria-current",u.getDate()===o.getDate()&&u.getMonth()===o.getMonth()&&u.getFullYear()===o.getFullYear()&&"date"),function(t,e,n){var i=2<arguments.length&&void 0!==n?n:!this.hasAttribute(e);!i===t.hasAttribute(e)&&t[i?"setAttribute":"removeAttribute"](e,"")}(t,"autofocus",e),u.setDate(n+1)})}function _(n,i){i.firstElementChild||(i._autofill=!0,i.innerHTML=n.months.map(function(t,e){return'<option value="y-'.concat(e+1,'-d"></option>')}).join("")),f(i.children).forEach(function(t,e){i._autofill&&(t.textContent=n.months[e]),t.disabled=n.disabled(t.value),t.selected=!n.diff(t.value)})}return g}),window.customElements.define("core-datepicker",coreDatepicker);
/*! @nrk/core-datepicker v3.1.0 - Copyright (c) 2017-2021 NRK */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).coreDatepicker=e()}(this,(function(){"use strict";function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(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(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function r(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function o(t,e,n){return(o=r()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,a)}function a(){return o(t,arguments,n(this).constructor)}return a.prototype=Object.create(t.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),i(a,t)})(t)}function u(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var c="undefined"!=typeof window;c&&/(android)/i.test(navigator.userAgent),c&&/iPad|iPhone|iPod/.test(String(navigator.platform)),c||global.HTMLElement||(global.HTMLElement=function(){return function e(){t(this,e)}}());var s,l,d=(s="undefined"==typeof window?{}:window.Element.prototype,l=s.matches||s.msMatchesSelector||s.webkitMatchesSelector,s.closest?function(t,e){return t.closest(e)}:function(t,e){for(t.correspondingUseElement&&(t=t.correspondingUseElement);t;t=t.parentElement)if(l.call(t,e))return t;return null});function f(t,e){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r="prevent_recursive_dispatch_maximum_callstack".concat(e);if(t[r])return!0;t[r]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:i}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i);var o=t.dispatchEvent(n);return t[r]=null,o}function h(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;if(t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var y={exports:{}};!function(t,e){var n,i,r,o;t.exports=(n={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},i=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,r=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,o=/([\dh]+):([\dm]+):?([\ds]+)?/,function(t,e){if(isFinite(t))return new Date(Number(t));var a=String(t).toLowerCase(),u=new Date(isFinite(e)&&-1===a.indexOf("now")?Number(e):Date.now()),c=a.match(r)||[],s=c[1];void 0===s&&(s="y");var l=c[2];void 0===l&&(l="m");var d=c[3];void 0===d&&(d="d");var f=a.match(o)||[],h=f[1];void 0===h&&(h="h");var y=f[2];void 0===y&&(y="m");var m=f[3];void 0===m&&(m="s");var p={year:s,month:l,day:d,hour:h,minute:y,second:m};Object.keys(p).forEach((function(t){var e="month"===t?1:0,i=String(u["get"+n[t]]()+e);p[t]=p[t].replace(/[^-\d]+/g,(function(t,e,n){return e?i.substr(i.length-n.length+e,t.length):i.substr(0,Math.max(0,i.length-n.length+t.length))}))-e}));var b=new Date(p.year,Math.min(12,p.month+1),0).getDate();for(u.setFullYear(p.year,Math.min(11,p.month),Math.max(1,Math.min(b,p.day))),u.setHours(Math.min(24,p.hour),Math.min(59,p.minute),Math.min(59,p.second));null!==(p=i.exec(a));){var g=p[2],v=String(p[1]).replace(/\s/g,"")*("week"===g?7:1),k=p.slice(2).indexOf(p[0]),w=u.getDate();g?u["set"+n[g]](u["get"+n[g]]()+v):u.setDate(u.getDate()-(u.getDay()||7)+k),"month"!==g&&"year"!==g||w===u.getDate()||u.setDate(0)}return u})}(y);var m=y.exports,p={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*",null:"*"},b={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},g=function(o){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&i(t,e)}(g,o);var a,c,s,l,h,y=(a=g,c=r(),function(){var t,e=n(a);if(c){var i=n(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return u(this,t)});function g(){return t(this,g),y.apply(this,arguments)}return s=g,h=[{key:"observedAttributes",get:function(){return["timestamp","months","days"]}}],(l=[{key:"connectedCallback",value:function(){var t,e,n,i,r=this;this._date=this.date,document.addEventListener("click",this),document.addEventListener("change",this),document.addEventListener("keydown",this),setTimeout((function(){return r.attributeChangedCallback()})),t=this.nodeName,e="".concat(this.nodeName,"{display:block}"),n="style-".concat(t.toLowerCase()),i=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1"),document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(i,"</style>"))}},{key:"disconnectedCallback",value:function(){this._date=this._disabled=null,document.removeEventListener("click",this),document.removeEventListener("change",this),document.removeEventListener("keydown",this)}},{key:"attributeChangedCallback",value:function(){if(this._date){if(this.disabled(this.date)&&!this.disabled(this._date))return this.date=this._date;this.diff(this.date)&&f(this,"datepicker.change",this._date=this.date),k("button",this,w),k("select",this,A),k("input",this,E),k("table",this,_)}}},{key:"handleEvent",value:function(t){if(!(t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||"keydown"===t.type&&!b[t.keyCode])&&(this.contains(t.target)||d(t.target,'[for="'.concat(this.id,'"],[data-for="').concat(this.id,'"]'))))if("change"===t.type)this.date=p[t.target.getAttribute("data-type")].replace("*",t.target.value);else if("click"===t.type){var e=d(t.target,"button[value]"),n=d(t.target,"table");e&&(this.date=e.value),e&&n&&f(this,"datepicker.click.day")}else"keydown"===t.type&&d(t.target,"table")&&(this.date=b[t.keyCode],this.querySelector("[autofocus]").focus(),t.preventDefault())}},{key:"diff",value:function(t){return this.parse(t).getTime()-this.timestamp}},{key:"parse",value:function(t,e){return m(t,e||this._date)}},{key:"disabled",get:function(){return this._disabled||Function.prototype},set:function(t){var e=this;this._disabled="function"==typeof t?function(n){return t(e.parse(n),e)}:function(){return t},this.attributeChangedCallback()}},{key:"timestamp",get:function(){return String(this._date.getTime())}},{key:"year",get:function(){return String(this._date.getFullYear())}},{key:"month",get:function(){return v(this._date.getMonth()+1)}},{key:"day",get:function(){return v(this._date.getDate())}},{key:"hour",get:function(){return v(this._date.getHours())}},{key:"minute",get:function(){return v(this._date.getMinutes())}},{key:"second",get:function(){return v(this._date.getSeconds())}},{key:"date",get:function(){return m(this.getAttribute("timestamp")||this._date||Date.now())},set:function(t){return this.setAttribute("timestamp",this.parse(t).getTime())}},{key:"months",get:function(){return(this.getAttribute("months")||"januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember").split(/\s*,\s*/)},set:function(t){this.setAttribute("months",[].concat(t).join(","))}},{key:"days",get:function(){return(this.getAttribute("days")||"man,tirs,ons,tors,fre,lør,søn").split(/\s*,\s*/)},set:function(t){this.setAttribute("days",[].concat(t).join(","))}}])&&e(s.prototype,l),h&&e(s,h),g}(a(HTMLElement)),v=function(t){return"0".concat(t).slice(-2)},k=function(t,e,n){return[].forEach.call(document.getElementsByTagName(t),(function(t){(e.contains(t)||e.id===t.getAttribute(e.external))&&n(e,t)}))};function w(t,e){e.value&&(e.type="button",e.disabled=t.disabled(e.value))}function E(t,e){var n=e.getAttribute("data-type")||e.getAttribute("type");"radio"===n||"checkbox"===n?(e.disabled=t.disabled(e.value),e.checked=!t.diff(e.value)):p[n]&&(e.setAttribute("type","number"),e.setAttribute("data-type",n),e.value=t[n])}function _(t,e){e.firstElementChild||(e.innerHTML="\n <caption></caption><thead><tr>".concat(Array(8).join("</th><th>"),"</tr></thead>\n <tbody>").concat(Array(7).join("<tr>".concat(Array(8).join('<td><button type="button"></button></td>'),"</tr>")),"</tbody>"));var n=new Date,i=t.date.getMonth(),r=t.parse("y-m-1 mon");e.caption.textContent="".concat(t.months[i],", ").concat(t.year),h("th",e).forEach((function(e,n){return e.textContent=t.days[n]})),h("button",e).forEach((function(e){var o=!t.diff(r),a=r.getDate(),u=r.getMonth();e.textContent=a,e.value="".concat(r.getFullYear(),"-").concat(u+1,"-").concat(a),e.disabled=t.disabled(r),e.tabIndex=o-1,e.setAttribute("data-adjacent",i!==u),e.setAttribute("aria-label","".concat(a,". ").concat(t.months[u])),e.setAttribute("aria-current",r.getDate()===n.getDate()&&r.getMonth()===n.getMonth()&&r.getFullYear()===n.getFullYear()&&"date"),function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:!this.hasAttribute(e);!n===t.hasAttribute(e)&&t[n?"setAttribute":"removeAttribute"](e,"")}(e,"autofocus",o),r.setDate(a+1)}))}function A(t,e){e.firstElementChild||(e._autofill=!0,e.innerHTML=t.months.map((function(t,e){return'<option value="y-'.concat(e+1,'-d"></option>')})).join("")),h(e.children).forEach((function(n,i){e._autofill&&(n.textContent=t.months[i]),n.disabled=t.disabled(n.value),n.selected=!t.diff(n.value)}))}return g})),window.customElements.define("core-datepicker",coreDatepicker);
//# sourceMappingURL=core-datepicker.min.js.map

@@ -0,8 +1,48 @@

/*! @nrk/core-datepicker v3.1.0 - Copyright (c) 2017-2021 NRK */
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var fs = require('fs');
var path = require('path');
var fs = _interopDefault(require('fs'));
var path = _interopDefault(require('path'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function prop(selector, name) {

@@ -19,4 +59,4 @@ return browser.executeScript(function (selector, name) {

var coreDatepicker = fs.readFileSync(path.resolve(__dirname, 'core-datepicker.min.js'), 'utf-8');
var customElements = fs.readFileSync(require.resolve('@webcomponents/custom-elements'), 'utf-8');
var coreDatepicker = fs__default['default'].readFileSync(path__default['default'].resolve(__dirname, 'core-datepicker.min.js'), 'utf-8');
var customElements = fs__default['default'].readFileSync(require.resolve('@webcomponents/custom-elements'), 'utf-8');

@@ -28,4 +68,4 @@ var pad = function pad(val) {

describe('core-datepicker', function () {
beforeEach(function _callee() {
return regeneratorRuntime.async(function _callee$(_context) {
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {

@@ -35,11 +75,11 @@ switch (_context.prev = _context.next) {

_context.next = 2;
return regeneratorRuntime.awrap(browser.refresh());
return browser.refresh();
case 2:
_context.next = 4;
return regeneratorRuntime.awrap(browser.executeScript(customElements));
return browser.executeScript(customElements);
case 4:
_context.next = 6;
return regeneratorRuntime.awrap(browser.executeScript(coreDatepicker));
return browser.executeScript(coreDatepicker);

@@ -51,7 +91,7 @@ case 6:

}
});
});
it('sets up properties', function _callee2() {
}, _callee);
})));
it('sets up properties', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var hour;
return regeneratorRuntime.async(function _callee2$(_context2) {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {

@@ -61,23 +101,23 @@ switch (_context2.prev = _context2.next) {

_context2.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-04-30T12:44:56Z').getTime(), "\">\n </core-datepicker>\n ");
}));
});
case 2:
_context2.next = 4;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'year')).toEqual('2019'));
return expect(prop('core-datepicker', 'year')).toEqual('2019');
case 4:
_context2.next = 6;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'month')).toEqual('04'));
return expect(prop('core-datepicker', 'month')).toEqual('04');
case 6:
_context2.next = 8;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'day')).toEqual('30'));
return expect(prop('core-datepicker', 'day')).toEqual('30');
case 8:
_context2.next = 10;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
return new Date('2019-04-30T12:44:56Z').getHours();
}));
});

@@ -87,19 +127,19 @@ case 10:

_context2.next = 13;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'hour')).toEqual(pad(String(hour))));
return expect(prop('core-datepicker', 'hour')).toEqual(pad(String(hour)));
case 13:
_context2.next = 15;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'minute')).toEqual('44'));
return expect(prop('core-datepicker', 'minute')).toEqual('44');
case 15:
_context2.next = 17;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'second')).toEqual('56'));
return expect(prop('core-datepicker', 'second')).toEqual('56');
case 17:
_context2.next = 19;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'days')).toEqual('man,tirs,ons,tors,fre,lør,søn'));
return expect(prop('core-datepicker', 'days')).toEqual('man,tirs,ons,tors,fre,lør,søn');
case 19:
_context2.next = 21;
return regeneratorRuntime.awrap(expect(prop('core-datepicker', 'months')).toEqual('januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember'));
return expect(prop('core-datepicker', 'months')).toEqual('januar,februar,mars,april,mai,juni,juli,august,september,oktober,november,desember');

@@ -111,7 +151,7 @@ case 21:

}
});
});
it('sets input values from timestamp', function _callee3() {
}, _callee2);
})));
it('sets input values from timestamp', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var hours, timestamp;
return regeneratorRuntime.async(function _callee3$(_context3) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {

@@ -121,35 +161,35 @@ switch (_context3.prev = _context3.next) {

_context3.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-04-30T10:44:56Z').getTime(), "\">\n <input type=\"year\">\n <input type=\"month\">\n <input type=\"day\">\n <input type=\"hour\">\n <input type=\"minute\">\n <input type=\"second\">\n <input type=\"timestamp\">\n </core-datepicker>\n ");
}));
});
case 2:
_context3.next = 4;
return regeneratorRuntime.awrap(expect(prop('input[data-type="year"]', 'value')).toEqual('2019'));
return expect(prop('input[data-type="year"]', 'value')).toEqual('2019');
case 4:
_context3.next = 6;
return regeneratorRuntime.awrap(expect(prop('input[data-type="year"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="year"]', 'type')).toEqual('number');
case 6:
_context3.next = 8;
return regeneratorRuntime.awrap(expect(prop('input[data-type="month"]', 'value')).toEqual('04'));
return expect(prop('input[data-type="month"]', 'value')).toEqual('04');
case 8:
_context3.next = 10;
return regeneratorRuntime.awrap(expect(prop('input[data-type="month"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="month"]', 'type')).toEqual('number');
case 10:
_context3.next = 12;
return regeneratorRuntime.awrap(expect(prop('input[data-type="day"]', 'value')).toEqual('30'));
return expect(prop('input[data-type="day"]', 'value')).toEqual('30');
case 12:
_context3.next = 14;
return regeneratorRuntime.awrap(expect(prop('input[data-type="day"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="day"]', 'type')).toEqual('number');
case 14:
_context3.next = 16;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
return new Date('2019-04-30T10:44:56Z').getHours();
}));
});

@@ -159,27 +199,27 @@ case 16:

_context3.next = 19;
return regeneratorRuntime.awrap(expect(prop('input[data-type="hour"]', 'value')).toEqual(pad(String(hours))));
return expect(prop('input[data-type="hour"]', 'value')).toEqual(pad(String(hours)));
case 19:
_context3.next = 21;
return regeneratorRuntime.awrap(expect(prop('input[data-type="hour"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="hour"]', 'type')).toEqual('number');
case 21:
_context3.next = 23;
return regeneratorRuntime.awrap(expect(prop('input[data-type="minute"]', 'value')).toEqual('44'));
return expect(prop('input[data-type="minute"]', 'value')).toEqual('44');
case 23:
_context3.next = 25;
return regeneratorRuntime.awrap(expect(prop('input[data-type="minute"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="minute"]', 'type')).toEqual('number');
case 25:
_context3.next = 27;
return regeneratorRuntime.awrap(expect(prop('input[data-type="second"]', 'value')).toEqual('56'));
return expect(prop('input[data-type="second"]', 'value')).toEqual('56');
case 27:
_context3.next = 29;
return regeneratorRuntime.awrap(expect(prop('input[data-type="second"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="second"]', 'type')).toEqual('number');
case 29:
_context3.next = 31;
return regeneratorRuntime.awrap(prop('core-datepicker', 'timestamp'));
return prop('core-datepicker', 'timestamp');

@@ -189,7 +229,7 @@ case 31:

_context3.next = 34;
return regeneratorRuntime.awrap(expect(prop('input[data-type="timestamp"]', 'value')).toEqual(timestamp));
return expect(prop('input[data-type="timestamp"]', 'value')).toEqual(timestamp);
case 34:
_context3.next = 36;
return regeneratorRuntime.awrap(expect(prop('input[data-type="timestamp"]', 'type')).toEqual('number'));
return expect(prop('input[data-type="timestamp"]', 'type')).toEqual('number');

@@ -201,7 +241,7 @@ case 36:

}
});
});
it('populates empty select with months', function _callee4() {
}, _callee3);
})));
it('populates empty select with months', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var i;
return regeneratorRuntime.async(function _callee4$(_context4) {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {

@@ -211,13 +251,13 @@ switch (_context4.prev = _context4.next) {

_context4.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker>\n <select></select>\n </core-datepicker>\n ";
}));
});
case 2:
_context4.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker select option'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker select option')));
case 4:
_context4.next = 6;
return regeneratorRuntime.awrap(expect(prop('core-datepicker select', 'childElementCount')).toEqual('12'));
return expect(prop('core-datepicker select', 'childElementCount')).toEqual('12');

@@ -234,3 +274,3 @@ case 6:

_context4.next = 10;
return regeneratorRuntime.awrap(expect(prop("option:nth-child(".concat(i, ")"), 'value')).toEqual("y-".concat(i, "-d")));
return expect(prop("option:nth-child(".concat(i, ")"), 'value')).toEqual("y-".concat(i, "-d"));

@@ -244,47 +284,47 @@ case 10:

_context4.next = 15;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(1)', 'textContent')).toEqual('januar'));
return expect(prop('option:nth-child(1)', 'textContent')).toEqual('januar');
case 15:
_context4.next = 17;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(2)', 'textContent')).toEqual('februar'));
return expect(prop('option:nth-child(2)', 'textContent')).toEqual('februar');
case 17:
_context4.next = 19;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(3)', 'textContent')).toEqual('mars'));
return expect(prop('option:nth-child(3)', 'textContent')).toEqual('mars');
case 19:
_context4.next = 21;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(4)', 'textContent')).toEqual('april'));
return expect(prop('option:nth-child(4)', 'textContent')).toEqual('april');
case 21:
_context4.next = 23;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(5)', 'textContent')).toEqual('mai'));
return expect(prop('option:nth-child(5)', 'textContent')).toEqual('mai');
case 23:
_context4.next = 25;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(6)', 'textContent')).toEqual('juni'));
return expect(prop('option:nth-child(6)', 'textContent')).toEqual('juni');
case 25:
_context4.next = 27;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(7)', 'textContent')).toEqual('juli'));
return expect(prop('option:nth-child(7)', 'textContent')).toEqual('juli');
case 27:
_context4.next = 29;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(8)', 'textContent')).toEqual('august'));
return expect(prop('option:nth-child(8)', 'textContent')).toEqual('august');
case 29:
_context4.next = 31;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(9)', 'textContent')).toEqual('september'));
return expect(prop('option:nth-child(9)', 'textContent')).toEqual('september');
case 31:
_context4.next = 33;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(10)', 'textContent')).toEqual('oktober'));
return expect(prop('option:nth-child(10)', 'textContent')).toEqual('oktober');
case 33:
_context4.next = 35;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(11)', 'textContent')).toEqual('november'));
return expect(prop('option:nth-child(11)', 'textContent')).toEqual('november');
case 35:
_context4.next = 37;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(12)', 'textContent')).toEqual('desember'));
return expect(prop('option:nth-child(12)', 'textContent')).toEqual('desember');

@@ -296,6 +336,6 @@ case 37:

}
});
});
it('re-uses custom select', function _callee5() {
return regeneratorRuntime.async(function _callee5$(_context5) {
}, _callee4);
})));
it('re-uses custom select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {

@@ -305,21 +345,21 @@ switch (_context5.prev = _context5.next) {

_context5.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker>\n <select>\n <option>---</option>\n <option value=\"2016-m-d\">Set year to 2016</option>\n <option value=\"19yy-1-1\">Back 100 years and set to January 1st.</option>\n <option value=\"1985-12-19\">December 19, 1985</option>\n </select>\n </core-datepicker>\n ";
}));
});
case 2:
_context5.next = 4;
return regeneratorRuntime.awrap(expect(prop('select', 'childElementCount')).toEqual('4'));
return expect(prop('select', 'childElementCount')).toEqual('4');
case 4:
_context5.next = 6;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(1)', 'value')).toEqual('---'));
return expect(prop('option:nth-child(1)', 'value')).toEqual('---');
case 6:
_context5.next = 8;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(2)', 'value')).toEqual('2016-m-d'));
return expect(prop('option:nth-child(2)', 'value')).toEqual('2016-m-d');
case 8:
_context5.next = 10;
return regeneratorRuntime.awrap(expect(prop('option:nth-child(3)', 'value')).toEqual('19yy-1-1'));
return expect(prop('option:nth-child(3)', 'value')).toEqual('19yy-1-1');

@@ -331,7 +371,7 @@ case 10:

}
});
});
it('populates empty table', function _callee6() {
}, _callee5);
})));
it('populates empty table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
var days, i;
return regeneratorRuntime.async(function _callee6$(_context6) {
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {

@@ -341,13 +381,13 @@ switch (_context6.prev = _context6.next) {

_context6.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-01-01T12:00:00Z').getTime(), "\">\n <table></table>\n </core-datepicker>\n ");
}));
});
case 2:
_context6.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button')));
case 4:
_context6.next = 6;
return regeneratorRuntime.awrap(prop('core-datepicker', 'days'));
return prop('core-datepicker', 'days');

@@ -357,3 +397,3 @@ case 6:

_context6.next = 9;
return regeneratorRuntime.awrap(expect(days.length).toEqual(7));
return expect(days.length).toEqual(7);

@@ -370,3 +410,3 @@ case 9:

_context6.next = 13;
return regeneratorRuntime.awrap(expect(prop("thead tr th:nth-child(".concat(i, ")"), 'textContent')).toEqual(days[i - 1]));
return expect(prop("thead tr th:nth-child(".concat(i, ")"), 'textContent')).toEqual(days[i - 1]);

@@ -380,7 +420,7 @@ case 13:

_context6.next = 18;
return regeneratorRuntime.awrap(expect($$('table td button[data-adjacent="false"]').count()).toEqual(31));
return expect($$('table td button[data-adjacent="false"]').count()).toEqual(31);
case 18:
_context6.next = 20;
return regeneratorRuntime.awrap(expect(prop('button[autofocus]', 'textContent')).toEqual('1'));
return expect(prop('button[autofocus]', 'textContent')).toEqual('1');

@@ -392,7 +432,7 @@ case 20:

}
});
});
it('marks today\'s date in table', function _callee7() {
}, _callee6);
})));
it('marks today\'s date in table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
var browserDate;
return regeneratorRuntime.async(function _callee7$(_context7) {
return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) {

@@ -402,19 +442,19 @@ switch (_context7.prev = _context7.next) {

_context7.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date().getTime(), "\">\n <table></table>\n </core-datepicker>\n ");
}));
});
case 2:
_context7.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button')));
case 4:
_context7.next = 6;
return regeneratorRuntime.awrap(expect($('button[aria-current="date"]').isPresent()).toEqual(true));
return expect($('button[aria-current="date"]').isPresent()).toEqual(true);
case 6:
_context7.next = 8;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
return new Date().getDate();
}));
});

@@ -424,3 +464,3 @@ case 8:

_context7.next = 11;
return regeneratorRuntime.awrap(expect(prop('button[aria-current="date"]', 'textContent')).toEqual(String(browserDate)));
return expect(prop('button[aria-current="date"]', 'textContent')).toEqual(String(browserDate));

@@ -432,6 +472,6 @@ case 11:

}
});
});
it('changes date on day clicked', function _callee8() {
return regeneratorRuntime.async(function _callee8$(_context8) {
}, _callee7);
})));
it('changes date on day clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {

@@ -441,21 +481,21 @@ switch (_context8.prev = _context8.next) {

_context8.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-01-01T12:00:00Z').getTime(), "\">\n <table></table>\n </core-datepicker>\n ");
}));
});
case 2:
_context8.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button')));
case 4:
_context8.next = 6;
return regeneratorRuntime.awrap(expect(prop('button[autofocus]', 'textContent')).toEqual('1'));
return expect(prop('button[autofocus]', 'textContent')).toEqual('1');
case 6:
_context8.next = 8;
return regeneratorRuntime.awrap($('tbody tr:nth-child(2) td:nth-child(5) button').click());
return $('tbody tr:nth-child(2) td:nth-child(5) button').click();
case 8:
_context8.next = 10;
return regeneratorRuntime.awrap(expect(prop('button[autofocus]', 'textContent')).toEqual('11'));
return expect(prop('button[autofocus]', 'textContent')).toEqual('11');

@@ -467,7 +507,7 @@ case 10:

}
});
});
it('changes month names', function _callee9() {
}, _callee8);
})));
it('changes month names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() {
var months, i;
return regeneratorRuntime.async(function _callee9$(_context9) {
return regeneratorRuntime.wrap(function _callee9$(_context9) {
while (1) {

@@ -478,13 +518,13 @@ switch (_context9.prev = _context9.next) {

_context9.next = 3;
return regeneratorRuntime.awrap(browser.executeScript(function (months) {
return browser.executeScript(function (months) {
document.body.innerHTML = "\n <core-datepicker months=\"".concat(months.join(), "\">\n <select></select>\n </core-datepicker>\n ");
}, months));
}, months);
case 3:
_context9.next = 5;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker select option'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker select option')));
case 5:
_context9.next = 7;
return regeneratorRuntime.awrap(expect(prop('select', 'childElementCount')).toEqual('12'));
return expect(prop('select', 'childElementCount')).toEqual('12');

@@ -501,3 +541,3 @@ case 7:

_context9.next = 11;
return regeneratorRuntime.awrap(expect(prop("option:nth-child(".concat(i, ")"), 'textContent')).toEqual(months[i - 1]));
return expect(prop("option:nth-child(".concat(i, ")"), 'textContent')).toEqual(months[i - 1]);

@@ -514,7 +554,7 @@ case 11:

}
});
});
it('changes day names', function _callee10() {
}, _callee9);
})));
it('changes day names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() {
var days, i;
return regeneratorRuntime.async(function _callee10$(_context10) {
return regeneratorRuntime.wrap(function _callee10$(_context10) {
while (1) {

@@ -525,13 +565,13 @@ switch (_context10.prev = _context10.next) {

_context10.next = 3;
return regeneratorRuntime.awrap(browser.executeScript(function (days) {
return browser.executeScript(function (days) {
document.body.innerHTML = "\n <core-datepicker days=\"".concat(days.join(), "\">\n <table></table>\n </core-datepicker>\n ");
}, days));
}, days);
case 3:
_context10.next = 5;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table thead'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table thead')));
case 5:
_context10.next = 7;
return regeneratorRuntime.awrap(expect(prop('table thead tr', 'childElementCount')).toEqual('7'));
return expect(prop('table thead tr', 'childElementCount')).toEqual('7');

@@ -548,3 +588,3 @@ case 7:

_context10.next = 11;
return regeneratorRuntime.awrap(expect(prop("thead tr th:nth-child(".concat(i, ")"), 'textContent')).toEqual(days[i - 1]));
return expect(prop("thead tr th:nth-child(".concat(i, ")"), 'textContent')).toEqual(days[i - 1]);

@@ -561,6 +601,6 @@ case 11:

}
});
});
it('disables elements from function', function _callee11() {
return regeneratorRuntime.async(function _callee11$(_context11) {
}, _callee10);
})));
it('disables elements from function', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() {
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {

@@ -570,3 +610,3 @@ switch (_context11.prev = _context11.next) {

_context11.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-01-01T12:00:00Z').getTime(), "\">\n <table></table>\n </core-datepicker>\n ");

@@ -577,23 +617,23 @@

};
}));
});
case 2:
_context11.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button')));
case 4:
_context11.next = 6;
return regeneratorRuntime.awrap(expect(attr('tbody tr:nth-child(1) td:nth-child(1) button', 'disabled')).toMatch(/(null|false)/i));
return expect(attr('tbody tr:nth-child(1) td:nth-child(1) button', 'disabled')).toMatch(/(null|false)/i);
case 6:
_context11.next = 8;
return regeneratorRuntime.awrap(expect($('button:not(disabled)[value="2018-12-31"]').isPresent()).toBeTruthy());
return expect($('button:not(disabled)[value="2018-12-31"]').isPresent()).toBeTruthy();
case 8:
_context11.next = 10;
return regeneratorRuntime.awrap(expect($('button:not(disabled)[value="2019-1-1"]').isPresent()).toBeTruthy());
return expect($('button:not(disabled)[value="2019-1-1"]').isPresent()).toBeTruthy();
case 10:
_context11.next = 12;
return regeneratorRuntime.awrap(expect($('button:disabled[value="2019-1-2"]').isPresent()).toBeTruthy());
return expect($('button:disabled[value="2019-1-2"]').isPresent()).toBeTruthy();

@@ -605,7 +645,7 @@ case 12:

}
});
});
it('triggers change event', function _callee12() {
}, _callee11);
})));
it('triggers change event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() {
var time;
return regeneratorRuntime.async(function _callee12$(_context12) {
return regeneratorRuntime.wrap(function _callee12$(_context12) {
while (1) {

@@ -615,3 +655,3 @@ switch (_context12.prev = _context12.next) {

_context12.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date('2019-01-01T12:00:00Z').getTime(), "\">\n </core-datepicker>\n ");

@@ -622,9 +662,9 @@ document.addEventListener('datepicker.change', function (event) {

document.querySelector('core-datepicker').date = new Date('2019-01-02T12:00:00Z');
}));
});
case 2:
_context12.next = 4;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
return new Date('2019-01-02T12:00:00Z').getTime();
}));
});

@@ -634,5 +674,5 @@ case 4:

_context12.next = 7;
return regeneratorRuntime.awrap(expect(browser.executeScript(function () {
return expect(browser.executeScript(function () {
return window.time;
})).toEqual(time));
})).toEqual(time);

@@ -644,6 +684,6 @@ case 7:

}
});
});
it('triggers click day event', function _callee13() {
return regeneratorRuntime.async(function _callee13$(_context13) {
}, _callee12);
})));
it('triggers click day event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() {
return regeneratorRuntime.wrap(function _callee13$(_context13) {
while (1) {

@@ -653,13 +693,13 @@ switch (_context13.prev = _context13.next) {

_context13.next = 2;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.body.innerHTML = "\n <core-datepicker timestamp=\"".concat(new Date().getTime(), "\">\n <table></table>\n </core-datepicker>\n ");
}));
});
case 2:
_context13.next = 4;
return regeneratorRuntime.awrap(browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button'))));
return browser.wait(ExpectedConditions.presenceOf($('core-datepicker table button')));
case 4:
_context13.next = 6;
return regeneratorRuntime.awrap(browser.executeScript(function () {
return browser.executeScript(function () {
document.addEventListener('datepicker.click.day', function () {

@@ -669,9 +709,9 @@ return window.triggered = true;

document.querySelector('core-datepicker button').click();
}));
});
case 6:
_context13.next = 8;
return regeneratorRuntime.awrap(expect(browser.executeScript(function () {
return expect(browser.executeScript(function () {
return window.triggered;
})).toEqual(true));
})).toEqual(true);

@@ -683,4 +723,4 @@ case 8:

}
});
});
}, _callee13);
})));
});

@@ -0,7 +1,10 @@

/*! @nrk/core-datepicker v3.1.0 - Copyright (c) 2017-2021 NRK */
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React = _interopDefault(require('react'));
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function _classCallCheck(instance, Constructor) {

@@ -60,3 +63,3 @@ if (!(instance instanceof Constructor)) {

function isNativeReflectConstruct() {
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;

@@ -67,3 +70,3 @@ if (Reflect.construct.sham) return false;

try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
return true;

@@ -76,3 +79,3 @@ } catch (e) {

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;

@@ -147,11 +150,29 @@ } else {

function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
var IS_BROWSER = typeof window !== 'undefined';
var IS_ANDROID = IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform));
// Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {
global.HTMLElement =
/*#__PURE__*/
function () {
global.HTMLElement = /*#__PURE__*/function () {
function _class() {

@@ -182,3 +203,3 @@ _classCallCheck(this, _class);

var closest = function () {
var closest$1 = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;

@@ -267,9 +288,7 @@ var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;

function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
var index_min = {exports: {}};
var index_min = createCommonjsModule(function (module, exports) {
(function (module, exports) {
!function (e, t) {
module.exports = t() ;
module.exports = t() ;
}(commonjsGlobal, function () {

@@ -335,4 +354,6 @@

});
});
})(index_min);
var _parse = index_min.exports;
var MASK = {

@@ -361,11 +382,11 @@ year: '*-m-d',

var CoreDatepicker =
/*#__PURE__*/
function (_HTMLElement) {
var CoreDatepicker = /*#__PURE__*/function (_HTMLElement) {
_inherits(CoreDatepicker, _HTMLElement);
var _super = _createSuper(CoreDatepicker);
function CoreDatepicker() {
_classCallCheck(this, CoreDatepicker);
return _possibleConstructorReturn(this, _getPrototypeOf(CoreDatepicker).apply(this, arguments));
return _super.apply(this, arguments);
}

@@ -401,3 +422,3 @@

value: function attributeChangedCallback() {
if (!this._date) return; // Only render after connectedCallback
if (!this._date) return; // Only render after connectedCallback and before disconnectedCallback

@@ -416,11 +437,11 @@ if (this.disabled(this.date) && !this.disabled(this._date)) return this.date = this._date; // Jump back

if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || event.type === 'keydown' && !KEYS[event.keyCode]) return;
if (!this.contains(event.target) && !closest(event.target, "[for=\"".concat(this.id, "\"]"))) return;
if (!this.contains(event.target) && !closest$1(event.target, "[for=\"".concat(this.id, "\"],[data-for=\"").concat(this.id, "\"]"))) return;
if (event.type === 'change') this.date = MASK[event.target.getAttribute('data-type')].replace('*', event.target.value);else if (event.type === 'click') {
var _button = closest(event.target, 'button[value]');
var _button = closest$1(event.target, 'button[value]');
var _table = closest(event.target, 'table');
var _table = closest$1(event.target, 'table');
if (_button) this.date = _button.value;
if (_button && _table) dispatchEvent(this, 'datepicker.click.day');
} else if (event.type === 'keydown' && closest(event.target, 'table')) {
} else if (event.type === 'keydown' && closest$1(event.target, 'table')) {
this.date = KEYS[event.keyCode];

@@ -439,3 +460,3 @@ this.querySelector('[autofocus]').focus();

value: function parse(val, from) {
return index_min(val, from || this._date);
return _parse(val, from || this._date);
}

@@ -497,3 +518,3 @@ }, {

get: function get() {
return index_min(this.getAttribute('timestamp') || this._date || Date.now());
return _parse(this.getAttribute('timestamp') || this._date || Date.now());
},

@@ -505,15 +526,15 @@ set: function set(val) {

key: "months",
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('months', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('months') || MONTHS).split(/\s*,\s*/);
}
}, {
key: "days",
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
},
set: function set(val) {
this.setAttribute('days', [].concat(val).join(','));
},
get: function get() {
return (this.getAttribute('days') || DAYS).split(/\s*,\s*/);
}

@@ -528,3 +549,3 @@ }], [{

return CoreDatepicker;
}(_wrapNativeSuper(HTMLElement));
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));

@@ -609,3 +630,3 @@ var pad = function pad(val) {

var version = "3.0.8";
var version = "3.1.0";

@@ -619,3 +640,3 @@ /**

var closest$1 = function () {
var closest = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;

@@ -666,99 +687,96 @@ var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;

var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();
return (
/*@__PURE__*/
function (superclass) {
function anonymous(props) {
var this$1 = this;
superclass.call(this, props); // Register ref prop for accessing custom element https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
return function (superclass) {
function anonymous(props) {
var this$1$1 = this;
superclass.call(this, props); // Register ref prop for accessing custom element https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
this.ref = function (el) {
if (typeof this$1.props.forwardRef === 'function') {
this$1.props.forwardRef(el);
} else if (this$1.props.forwardRef) {
this$1.props.forwardRef.current = el;
}
this.ref = function (el) {
if (typeof this$1$1.props.forwardRef === 'function') {
this$1$1.props.forwardRef(el);
} else if (this$1$1.props.forwardRef) {
this$1$1.props.forwardRef.current = el;
}
return this$1.el = el;
}; // Register event handler on component for each custom event
return this$1$1.el = el;
}; // Register event handler on component for each custom event
Object.keys(eventMap).forEach(function (eventName) {
var onEventName = eventMap[eventName];
Object.keys(eventMap).forEach(function (eventName) {
var onEventName = eventMap[eventName];
this$1[eventName] = function (event) {
if (this$1.props[onEventName] && closest$1(event.target, this$1.el.nodeName) === this$1.el) {
this$1.props[onEventName](event);
}
};
});
}
this$1$1[eventName] = function (event) {
if (this$1$1.props[onEventName] && closest(event.target, this$1$1.el.nodeName) === this$1$1.el) {
this$1$1.props[onEventName](event);
}
};
});
}
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1 = this; // Run connectedCallback() after React componentDidMount() to allow React hydration to run first
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1$1 = this; // Run connectedCallback() after React componentDidMount() to allow React hydration to run first
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
} // Populate properties on custom element
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
} // Populate properties on custom element
customProps.forEach(function (propName) {
if (propName in this$1.props) {
this$1.el[propName] = this$1.props[propName];
}
}); // Register events on custom element
customProps.forEach(function (propName) {
if (propName in this$1$1.props) {
this$1$1.el[propName] = this$1$1.props[propName];
}
}); // Register events on custom element
customEvents.forEach(function (eventName) {
this$1.el.addEventListener(eventName, this$1[eventName]);
});
};
customEvents.forEach(function (eventName) {
this$1$1.el.addEventListener(eventName, this$1$1[eventName]);
});
};
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1 = this; // Sync prop changes to custom element
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1$1 = this; // Sync prop changes to custom element
customProps.forEach(function (propName) {
if (prev[propName] !== this$1.props[propName]) {
this$1.el[propName] = this$1.props[propName];
}
});
};
customProps.forEach(function (propName) {
if (prev[propName] !== this$1$1.props[propName]) {
this$1$1.el[propName] = this$1$1.props[propName];
}
});
};
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1 = this; // Remove event handlers on custom element on unmount
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1$1 = this; // Remove event handlers on custom element on unmount
customEvents.forEach(function (eventName) {
this$1.el.removeEventListener(eventName, this$1[eventName]);
});
};
customEvents.forEach(function (eventName) {
this$1$1.el.removeEventListener(eventName, this$1$1[eventName]);
});
};
anonymous.prototype.render = function render() {
var this$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
anonymous.prototype.render = function render() {
var this$1$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tagName, Object.keys(this.props).reduce(function (thisProps, propName) {
if (skipProps.indexOf(propName) === -1) {
// Do not render customEvents and custom props as attributes
if (propName === 'className') {
thisProps["class"] = this$1.props[propName];
} // Fixes className for custom elements
else if (this$1.props[propName] === true) {
thisProps[propName] = '';
} // Fixes boolean attributes
else if (this$1.props[propName] !== false) {
thisProps[propName] = this$1.props[propName];
} // Pass only truthy, non-function props
return React__default['default'].createElement(tagName, Object.keys(this.props).reduce(function (thisProps, propName) {
if (skipProps.indexOf(propName) === -1) {
// Do not render customEvents and custom props as attributes
if (propName === 'className') {
thisProps["class"] = this$1$1.props[propName];
} // Fixes className for custom elements
else if (this$1$1.props[propName] === true) {
thisProps[propName] = '';
} // Fixes boolean attributes
else if (this$1$1.props[propName] !== false) {
thisProps[propName] = this$1$1.props[propName];
} // Pass only truthy, non-function props
}
}
return thisProps;
}, {
ref: this.ref
}));
};
return thisProps;
}, {
ref: this.ref
}));
};
return anonymous;
}(React.Component)
);
return anonymous;
}(React__default['default'].Component);
}

@@ -765,0 +783,0 @@

@@ -5,3 +5,3 @@ {

"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)",
"version": "3.0.8",
"version": "3.1.0",
"license": "MIT",

@@ -8,0 +8,0 @@ "main": "core-datepicker.cjs.js",

@@ -92,5 +92,5 @@ # Core Datepicker

</core-toggle>
<button for="my-datepicker" value="now">Nå</button>
<button for="my-datepicker" value="+1 week">Neste uke</button>
<select for="my-datepicker">
<button data-for="my-datepicker" value="now">Nå</button>
<button data-for="my-datepicker" value="+1 week">Neste uke</button>
<select data-for="my-datepicker">
<option>Tid</option>

@@ -101,7 +101,10 @@ <option value="11:m">11</option>

</select>
<table for="my-datepicker"></table>
<table data-for="my-datepicker"></table>
<input type="text" id="my-datepicker-output">
<script>
// Update GUI
document.getElementById('my-datepicker').disabled = (date) => date > Date.now()
document.getElementById('my-datepicker').disabled = (date) => {
var oneWeekFromNow = (new Date()).setDate(new Date().getDate() + 7)
return date > oneWeekFromNow
}

@@ -168,3 +171,3 @@ // Update output

Remember to [polyfill](https://github.com/webcomponents/polyfills#custom-elements) custom elements if needed.
Remember to [polyfill](https://github.com/webcomponents/polyfills/tree/master/packages/custom-elements) custom elements if needed.

@@ -171,0 +174,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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc