@nrk/core-datepicker
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
/*! @nrk/core-datepicker v4.0.0 - Copyright (c) 2017-2021 NRK */ | ||
/*! @nrk/core-datepicker v4.0.1 - Copyright (c) 2017-2022 NRK */ | ||
'use strict'; | ||
@@ -23,2 +23,5 @@ | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -39,2 +42,5 @@ } | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
@@ -44,3 +50,3 @@ } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
@@ -52,7 +58,6 @@ }; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
@@ -76,3 +81,3 @@ } | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
_construct = Reflect.construct.bind(); | ||
} else { | ||
@@ -168,5 +173,6 @@ _construct = function _construct(Parent, args, Class) { | ||
var IS_BROWSER = typeof window !== 'undefined'; | ||
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
var HAS_NAVIGATOR = IS_BROWSER && typeof window.navigator !== 'undefined'; | ||
HAS_NAVIGATOR && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
HAS_NAVIGATOR && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
// Mock HTMLElement for Node | ||
@@ -180,3 +186,3 @@ | ||
return _class; | ||
return _createClass(_class); | ||
}(); | ||
@@ -221,6 +227,6 @@ } | ||
* dispatchEvent - with infinite loop prevention | ||
* @param {Element} elem The target object | ||
* @param {String} name The source object(s) | ||
* @param {Element} element The target object | ||
* @param {String} name The event name | ||
* @param {Object} detail Detail object (bubbles and cancelable is set to true) | ||
* @return {Boolean} Whether the event was canceled | ||
* @return {Boolean} Whether the event was canceled. Returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. | ||
*/ | ||
@@ -227,0 +233,0 @@ |
@@ -1,2 +0,2 @@ | ||
/*! @nrk/core-datepicker v4.0.0 - Copyright (c) 2017-2021 NRK */ | ||
/*! @nrk/core-datepicker v4.0.1 - Copyright (c) 2017-2022 NRK */ | ||
(function (global, factory) { | ||
@@ -31,2 +31,5 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react')) : | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -47,2 +50,5 @@ } | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
@@ -52,3 +58,3 @@ } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
@@ -60,7 +66,6 @@ }; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
@@ -84,3 +89,3 @@ } | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
_construct = Reflect.construct.bind(); | ||
} else { | ||
@@ -176,5 +181,6 @@ _construct = function _construct(Parent, args, Class) { | ||
var IS_BROWSER = typeof window !== 'undefined'; | ||
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
var HAS_NAVIGATOR = IS_BROWSER && typeof window.navigator !== 'undefined'; | ||
HAS_NAVIGATOR && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
HAS_NAVIGATOR && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
// Mock HTMLElement for Node | ||
@@ -188,3 +194,3 @@ | ||
return _class; | ||
return _createClass(_class); | ||
}(); | ||
@@ -229,6 +235,6 @@ } | ||
* dispatchEvent - with infinite loop prevention | ||
* @param {Element} elem The target object | ||
* @param {String} name The source object(s) | ||
* @param {Element} element The target object | ||
* @param {String} name The event name | ||
* @param {Object} detail Detail object (bubbles and cancelable is set to true) | ||
* @return {Boolean} Whether the event was canceled | ||
* @return {Boolean} Whether the event was canceled. Returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. | ||
*/ | ||
@@ -648,3 +654,3 @@ | ||
var version = "4.0.0"; | ||
var version = "4.0.1"; | ||
@@ -651,0 +657,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
/*! @nrk/core-datepicker v4.0.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 r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t){return(n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(){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=i()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(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||(i=t,-1===Function.toString.call(i).indexOf("[native code]")))return t;var i;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}}),r(a,t)})(t)}function u(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}var s="undefined"!=typeof window;s&&/(android)/i.test(navigator.userAgent),s&&/iPad|iPhone|iPod/.test(String(navigator.platform)),s||global.HTMLElement||(global.HTMLElement=function(){return function e(){t(this,e)}}());var c,l,d=(c="undefined"==typeof window?{}:window.Element.prototype,l=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(l.call(t,e))return t;return null});function f(t,e){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="prevent_recursive_dispatch_maximum_callstack".concat(e);if(t[i])return!0;t[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,r);var o=t.dispatchEvent(n);return t[i]=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 m={exports:{}};!function(t,e){var n,r,i,o;t.exports=(n={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},r=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,i=/([-\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()),s=a.match(i)||[],c=s[1];void 0===c&&(c="y");var l=s[2];void 0===l&&(l="m");var d=s[3];void 0===d&&(d="d");var f=a.match(o)||[],h=f[1];void 0===h&&(h="h");var m=f[2];void 0===m&&(m="m");var y=f[3];void 0===y&&(y="s");var p={year:c,month:l,day:d,hour:h,minute:m,second:y};Object.keys(p).forEach((function(t){var e="month"===t?1:0,r=String(u["get"+n[t]]()+e);p[t]=p[t].replace(/[^-\d]+/g,(function(t,e,n){return e?r.substr(r.length-n.length+e,t.length):r.substr(0,Math.max(0,r.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=r.exec(a));){var g=p[2],v=String(p[1]).replace(/\s/g,"")*("week"===g?7:1),w=p.slice(2).indexOf(p[0]),k=u.getDate();g?u["set"+n[g]](u["get"+n[g]]()+v):u.setDate(u.getDate()-(u.getDay()||7)+w),"month"!==g&&"year"!==g||k===u.getDate()||u.setDate(0)}return u})}(m);var y=m.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&&r(t,e)}(g,o);var a,s,c,l,h,m=(a=g,s=i(),function(){var t,e=n(a);if(s){var r=n(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return u(this,t)});function g(){return t(this,g),m.apply(this,arguments)}return c=g,h=[{key:"observedAttributes",get:function(){return["date","months","days"]}}],(l=[{key:"connectedCallback",value:function(){var t,e,n,r,i=this;this._date=this.date,document.addEventListener("click",this),document.addEventListener("change",this),document.addEventListener("keydown",this),setTimeout((function(){return i.attributeChangedCallback()})),t=this.nodeName,e="".concat(this.nodeName,"{display:block}"),n="style-".concat(t.toLowerCase()),r=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1"),document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(r,"</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(t,e,n){if(this.parentNode){if(this.disabled(this.date)&&!this.disabled(this._date))return this.date=this._date;(this.diff(this.date)||null===e&&"0"===n||"0"===e&&null===n)&&f(this,"datepicker.change",this._date=this.date),w("button",this,k),w("select",this,A),w("input",this,_),w("table",this,E)}}},{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 if("keydown"===t.type){var r=d(t.target,"table");r&&(this.date=b[t.keyCode],r.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||Date.now())}},{key:"disabled",get:function(){return this._disabled||Function.prototype},set:function(t){var e=this;this._disabled="function"!=typeof t?function(){return Boolean(t)}:function(n){return null!==n&&t(e.parse(n),e)},this.attributeChangedCallback()}},{key:"timestamp",get:function(){return this._date?this._date.getTime():null}},{key:"year",get:function(){return this._date?String(this._date.getFullYear()):null}},{key:"month",get:function(){return this._date?v(this._date.getMonth()+1):null}},{key:"day",get:function(){return this._date?v(this._date.getDate()):null}},{key:"hour",get:function(){return this._date?v(this._date.getHours()):null}},{key:"minute",get:function(){return this._date?v(this._date.getMinutes()):null}},{key:"second",get:function(){return this._date?v(this._date.getSeconds()):null}},{key:"date",get:function(){var t=this.getAttribute("date");if(!t){if(!(t=this.getAttribute("timestamp")))return null;this.removeAttribute("timestamp"),console.warn(this,"uses deprecated `timestamp` attribute. Please use `date` as specified in the docs (https://static.nrk.no/core-components/latest/index.html?core-datepicker/readme.md). Note that the attribute has been removed to avoid confusion with the `date` attribute")}return this.parse(t)},set:function(t){return null===t?this.removeAttribute("date"):this.setAttribute("date",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(c.prototype,l),h&&e(c,h),g}(a(HTMLElement)),v=function(t){return"0".concat(t).slice(-2)},w=function(t,e,n){return[].forEach.call(document.getElementsByTagName(t),(function(t){(e.contains(t)||e.id===(t.getAttribute("data-for")||t.getAttribute("for")))&&n(e,t)}))};function k(t,e){e.value&&(e.type="button",e.disabled=t.disabled(e.value))}function _(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 E(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,r=t._date||n,i=r.getMonth(),o=t.parse("y-m-1 mon",r);e.caption.textContent="".concat(t.months[i],", ").concat(r.getFullYear()),h("th",e).forEach((function(e,n){return e.textContent=t.days[n]})),h("button",e).forEach((function(e){var r=o.getDate()===n.getDate()&&o.getMonth()===n.getMonth()&&o.getFullYear()===n.getFullYear(),a=null===t._date?r:!t.diff(o),u=o.getDate(),s=o.getMonth();e.textContent=u,e.value="".concat(o.getFullYear(),"-").concat(s+1,"-").concat(u),e.disabled=t.disabled(o),e.setAttribute("tabindex",Number(a)-1),e.setAttribute("data-adjacent",i!==s),e.setAttribute("aria-label","".concat(u,". ").concat(t.months[s])),e.setAttribute("aria-current",r&&"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",a),o.setDate(u+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,r){e._autofill&&(n.textContent=t.months[r]),n.disabled=t.disabled(n.value),n.selected=!t.diff(n.value)}))}return g})),window.customElements.define("core-datepicker",coreDatepicker); | ||
/*! @nrk/core-datepicker v4.0.1 - Copyright (c) 2017-2022 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 r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(){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 a(t,e,n){return a=o()?Reflect.construct.bind():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},a.apply(null,arguments)}function u(t){var e="function"==typeof Map?new Map:void 0;return u=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;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,o)}function o(){return a(t,arguments,r(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),i(o,t)},u(t)}function s(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}var c="undefined"!=typeof window,l=c&&void 0!==window.navigator;l&&/(android)/i.test(navigator.userAgent),l&&/iPad|iPhone|iPod/.test(String(navigator.platform)),c||global.HTMLElement||(global.HTMLElement=function(){return n((function e(){t(this,e)}))}());var d,f,h=(d="undefined"==typeof window?{}:window.Element.prototype,f=d.matches||d.msMatchesSelector||d.webkitMatchesSelector,d.closest?function(t,e){return t.closest(e)}:function(t,e){for(t.correspondingUseElement&&(t=t.correspondingUseElement);t;t=t.parentElement)if(f.call(t,e))return t;return null});function p(t,e){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i="prevent_recursive_dispatch_maximum_callstack".concat(e);if(t[i])return!0;t[i]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,r);var o=t.dispatchEvent(n);return t[i]=null,o}function y(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 m={exports:{}};!function(t,e){var n,r,i,o;t.exports=(n={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},r=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,i=/([-\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()),s=a.match(i)||[],c=s[1];void 0===c&&(c="y");var l=s[2];void 0===l&&(l="m");var d=s[3];void 0===d&&(d="d");var f=a.match(o)||[],h=f[1];void 0===h&&(h="h");var p=f[2];void 0===p&&(p="m");var y=f[3];void 0===y&&(y="s");var m={year:c,month:l,day:d,hour:h,minute:p,second:y};Object.keys(m).forEach((function(t){var e="month"===t?1:0,r=String(u["get"+n[t]]()+e);m[t]=m[t].replace(/[^-\d]+/g,(function(t,e,n){return e?r.substr(r.length-n.length+e,t.length):r.substr(0,Math.max(0,r.length-n.length+t.length))}))-e}));var b=new Date(m.year,Math.min(12,m.month+1),0).getDate();for(u.setFullYear(m.year,Math.min(11,m.month),Math.max(1,Math.min(b,m.day))),u.setHours(Math.min(24,m.hour),Math.min(59,m.minute),Math.min(59,m.second));null!==(m=r.exec(a));){var g=m[2],v=String(m[1]).replace(/\s/g,"")*("week"===g?7:1),w=m.slice(2).indexOf(m[0]),k=u.getDate();g?u["set"+n[g]](u["get"+n[g]]()+v):u.setDate(u.getDate()-(u.getDay()||7)+w),"month"!==g&&"year"!==g||k===u.getDate()||u.setDate(0)}return u})}(m);var b=m.exports,g={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*",null:"*"},v={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},w=function(e){!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}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&i(t,e)}(l,e);var a,u,c=(a=l,u=o(),function(){var t,e=r(a);if(u){var n=r(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return s(this,t)});function l(){return t(this,l),c.apply(this,arguments)}return n(l,[{key:"connectedCallback",value:function(){var t,e,n,r,i=this;this._date=this.date,document.addEventListener("click",this),document.addEventListener("change",this),document.addEventListener("keydown",this),setTimeout((function(){return i.attributeChangedCallback()})),t=this.nodeName,e="".concat(this.nodeName,"{display:block}"),n="style-".concat(t.toLowerCase()),r=e.replace(/\/\*[^!][^*]*\*\//g,"").replace(/\s*(^|[:;,{}]|$)\s*/g,"$1"),document.getElementById(n)||document.head.insertAdjacentHTML("afterbegin",'<style id="'.concat(n,'">').concat(r,"</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(t,e,n){if(this.parentNode){if(this.disabled(this.date)&&!this.disabled(this._date))return this.date=this._date;(this.diff(this.date)||null===e&&"0"===n||"0"===e&&null===n)&&p(this,"datepicker.change",this._date=this.date),_("button",this,E),_("select",this,j),_("input",this,A),_("table",this,M)}}},{key:"handleEvent",value:function(t){if(!(t.defaultPrevented||t.ctrlKey||t.metaKey||t.shiftKey||t.altKey||"keydown"===t.type&&!v[t.keyCode])&&(this.contains(t.target)||h(t.target,'[for="'.concat(this.id,'"],[data-for="').concat(this.id,'"]'))))if("change"===t.type)this.date=g[t.target.getAttribute("data-type")].replace("*",t.target.value);else if("click"===t.type){var e=h(t.target,"button[value]"),n=h(t.target,"table");e&&(this.date=e.value),e&&n&&p(this,"datepicker.click.day")}else if("keydown"===t.type){var r=h(t.target,"table");r&&(this.date=v[t.keyCode],r.querySelector("[autofocus]").focus(),t.preventDefault())}}},{key:"diff",value:function(t){return this.parse(t).getTime()-this.timestamp}},{key:"parse",value:function(t,e){return b(t,e||this._date||Date.now())}},{key:"disabled",get:function(){return this._disabled||Function.prototype},set:function(t){var e=this;this._disabled="function"!=typeof t?function(){return Boolean(t)}:function(n){return null!==n&&t(e.parse(n),e)},this.attributeChangedCallback()}},{key:"timestamp",get:function(){return this._date?this._date.getTime():null}},{key:"year",get:function(){return this._date?String(this._date.getFullYear()):null}},{key:"month",get:function(){return this._date?k(this._date.getMonth()+1):null}},{key:"day",get:function(){return this._date?k(this._date.getDate()):null}},{key:"hour",get:function(){return this._date?k(this._date.getHours()):null}},{key:"minute",get:function(){return this._date?k(this._date.getMinutes()):null}},{key:"second",get:function(){return this._date?k(this._date.getSeconds()):null}},{key:"date",get:function(){var t=this.getAttribute("date");if(!t){if(!(t=this.getAttribute("timestamp")))return null;this.removeAttribute("timestamp"),console.warn(this,"uses deprecated `timestamp` attribute. Please use `date` as specified in the docs (https://static.nrk.no/core-components/latest/index.html?core-datepicker/readme.md). Note that the attribute has been removed to avoid confusion with the `date` attribute")}return this.parse(t)},set:function(t){return null===t?this.removeAttribute("date"):this.setAttribute("date",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(","))}}],[{key:"observedAttributes",get:function(){return["date","months","days"]}}]),l}(u(HTMLElement)),k=function(t){return"0".concat(t).slice(-2)},_=function(t,e,n){return[].forEach.call(document.getElementsByTagName(t),(function(t){(e.contains(t)||e.id===(t.getAttribute("data-for")||t.getAttribute("for")))&&n(e,t)}))};function E(t,e){e.value&&(e.type="button",e.disabled=t.disabled(e.value))}function A(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)):g[n]&&(e.setAttribute("type","number"),e.setAttribute("data-type",n),e.value=t[n])}function M(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,r=t._date||n,i=r.getMonth(),o=t.parse("y-m-1 mon",r);e.caption.textContent="".concat(t.months[i],", ").concat(r.getFullYear()),y("th",e).forEach((function(e,n){return e.textContent=t.days[n]})),y("button",e).forEach((function(e){var r=o.getDate()===n.getDate()&&o.getMonth()===n.getMonth()&&o.getFullYear()===n.getFullYear(),a=null===t._date?r:!t.diff(o),u=o.getDate(),s=o.getMonth();e.textContent=u,e.value="".concat(o.getFullYear(),"-").concat(s+1,"-").concat(u),e.disabled=t.disabled(o),e.setAttribute("tabindex",Number(a)-1),e.setAttribute("data-adjacent",i!==s),e.setAttribute("aria-label","".concat(u,". ").concat(t.months[s])),e.setAttribute("aria-current",r&&"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",a),o.setDate(u+1)}))}function j(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("")),y(e.children).forEach((function(n,r){e._autofill&&(n.textContent=t.months[r]),n.disabled=t.disabled(n.value),n.selected=!t.diff(n.value)}))}return w})),window.customElements.define("core-datepicker",coreDatepicker); | ||
//# sourceMappingURL=core-datepicker.min.js.map |
@@ -1,2 +0,2 @@ | ||
/*! @nrk/core-datepicker v4.0.0 - Copyright (c) 2017-2021 NRK */ | ||
/*! @nrk/core-datepicker v4.0.1 - Copyright (c) 2017-2022 NRK */ | ||
'use strict'; | ||
@@ -12,2 +12,347 @@ | ||
function _regeneratorRuntime() { | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
_regeneratorRuntime = function () { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
return Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: !0, | ||
configurable: !0, | ||
writable: !0 | ||
}), obj[key]; | ||
} | ||
try { | ||
define({}, ""); | ||
} catch (err) { | ||
define = function (obj, key, value) { | ||
return obj[key] = value; | ||
}; | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return generator._invoke = function (innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
}(innerFn, self, context), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
try { | ||
return { | ||
type: "normal", | ||
arg: fn.call(obj, arg) | ||
}; | ||
} catch (err) { | ||
return { | ||
type: "throw", | ||
arg: err | ||
}; | ||
} | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
define(IteratorPrototype, iteratorSymbol, function () { | ||
return this; | ||
}); | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
["next", "throw", "return"].forEach(function (method) { | ||
define(prototype, method, function (arg) { | ||
return this._invoke(method, arg); | ||
}); | ||
}); | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
invoke("next", value, resolve, reject); | ||
}, function (err) { | ||
invoke("throw", err, resolve, reject); | ||
}) : PromiseImpl.resolve(value).then(function (unwrapped) { | ||
result.value = unwrapped, resolve(result); | ||
}, function (error) { | ||
return invoke("throw", error, resolve, reject); | ||
}); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
this._invoke = function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var method = delegate.iterator[context.method]; | ||
if (undefined === method) { | ||
if (context.delegate = null, "throw" === context.method) { | ||
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; | ||
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); | ||
} | ||
return ContinueSentinel; | ||
} | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
var info = record.arg; | ||
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); | ||
} | ||
function pushTryEntry(locs) { | ||
var entry = { | ||
tryLoc: locs[0] | ||
}; | ||
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); | ||
} | ||
function resetTryEntry(entry) { | ||
var record = entry.completion || {}; | ||
record.type = "normal", delete record.arg, entry.completion = record; | ||
} | ||
function Context(tryLocsList) { | ||
this.tryEntries = [{ | ||
tryLoc: "root" | ||
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); | ||
} | ||
function values(iterable) { | ||
if (iterable) { | ||
var iteratorMethod = iterable[iteratorSymbol]; | ||
if (iteratorMethod) return iteratorMethod.call(iterable); | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
next: doneResult | ||
}; | ||
} | ||
function doneResult() { | ||
return { | ||
value: undefined, | ||
done: !0 | ||
}; | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
}, exports.mark = function (genFun) { | ||
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; | ||
}, exports.awrap = function (arg) { | ||
return { | ||
__await: arg | ||
}; | ||
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { | ||
return this; | ||
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { | ||
void 0 === PromiseImpl && (PromiseImpl = Promise); | ||
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); | ||
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { | ||
return result.done ? result.value : iter.next(); | ||
}); | ||
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { | ||
return this; | ||
}), define(Gp, "toString", function () { | ||
return "[object Generator]"; | ||
}), exports.keys = function (object) { | ||
var keys = []; | ||
for (var key in object) keys.push(key); | ||
return keys.reverse(), function next() { | ||
for (; keys.length;) { | ||
var key = keys.pop(); | ||
if (key in object) return next.value = key, next.done = !1, next; | ||
} | ||
return next.done = !0, next; | ||
}; | ||
}, exports.values = values, Context.prototype = { | ||
constructor: Context, | ||
reset: function (skipTempReset) { | ||
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); | ||
}, | ||
stop: function () { | ||
this.done = !0; | ||
var rootRecord = this.tryEntries[0].completion; | ||
if ("throw" === rootRecord.type) throw rootRecord.arg; | ||
return this.rval; | ||
}, | ||
dispatchException: function (exception) { | ||
if (this.done) throw exception; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} else if (hasCatch) { | ||
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
} else { | ||
if (!hasFinally) throw new Error("try statement without catch or finally"); | ||
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); | ||
} | ||
} | ||
} | ||
}, | ||
abrupt: function (type, arg) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
var finallyEntry = entry; | ||
break; | ||
} | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
var record = finallyEntry ? finallyEntry.completion : {}; | ||
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); | ||
}, | ||
complete: function (record, afterLoc) { | ||
if ("throw" === record.type) throw record.arg; | ||
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; | ||
}, | ||
finish: function (finallyLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; | ||
} | ||
}, | ||
catch: function (tryLoc) { | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
var thrown = record.arg; | ||
resetTryEntry(entry); | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
}, | ||
delegateYield: function (iterable, resultName, nextLoc) { | ||
return this.delegate = { | ||
iterator: values(iterable), | ||
resultName: resultName, | ||
nextLoc: nextLoc | ||
}, "next" === this.method && (this.arg = undefined), ContinueSentinel; | ||
} | ||
}, exports; | ||
} | ||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
@@ -146,4 +491,4 @@ try { | ||
describe('core-datepicker', function () { | ||
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
beforeEach( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
return _regeneratorRuntime().wrap(function _callee$(_context) { | ||
while (1) { | ||
@@ -170,5 +515,5 @@ switch (_context.prev = _context.next) { | ||
}))); | ||
it('sets up properties from date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() { | ||
it('sets up properties from date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { | ||
var hour; | ||
return regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
return _regeneratorRuntime().wrap(function _callee2$(_context2) { | ||
while (1) { | ||
@@ -228,4 +573,4 @@ switch (_context2.prev = _context2.next) { | ||
}))); | ||
it('does not have a value when set up without date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { | ||
return regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
it('does not have a value when set up without date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { | ||
return _regeneratorRuntime().wrap(function _callee3$(_context3) { | ||
while (1) { | ||
@@ -278,5 +623,5 @@ switch (_context3.prev = _context3.next) { | ||
}))); | ||
it('supports simple-date-parse literals in date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { | ||
it('supports simple-date-parse literals in date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { | ||
var inputVal, parsedNow; | ||
return regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
return _regeneratorRuntime().wrap(function _callee4$(_context4) { | ||
while (1) { | ||
@@ -324,4 +669,4 @@ switch (_context4.prev = _context4.next) { | ||
it('resets value when date-attribute is removed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() { | ||
return regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
it('resets value when date-attribute is removed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() { | ||
return _regeneratorRuntime().wrap(function _callee5$(_context5) { | ||
while (1) { | ||
@@ -388,5 +733,5 @@ switch (_context5.prev = _context5.next) { | ||
}))); | ||
it('sets input values from date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() { | ||
it('sets input values from date-attribute', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() { | ||
var hour, timestamp; | ||
return regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
return _regeneratorRuntime().wrap(function _callee6$(_context6) { | ||
while (1) { | ||
@@ -475,5 +820,5 @@ switch (_context6.prev = _context6.next) { | ||
}))); | ||
it('populates empty select with months', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() { | ||
it('populates empty select with months', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() { | ||
var i; | ||
return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
return _regeneratorRuntime().wrap(function _callee7$(_context7) { | ||
while (1) { | ||
@@ -567,4 +912,4 @@ switch (_context7.prev = _context7.next) { | ||
}))); | ||
it('re-uses custom select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() { | ||
return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
it('re-uses custom select', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() { | ||
return _regeneratorRuntime().wrap(function _callee8$(_context8) { | ||
while (1) { | ||
@@ -601,5 +946,5 @@ switch (_context8.prev = _context8.next) { | ||
}))); | ||
it('populates empty table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9() { | ||
it('populates empty table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() { | ||
var days, i; | ||
return regeneratorRuntime.wrap(function _callee9$(_context9) { | ||
return _regeneratorRuntime().wrap(function _callee9$(_context9) { | ||
while (1) { | ||
@@ -658,5 +1003,5 @@ switch (_context9.prev = _context9.next) { | ||
}))); | ||
it('marks today\'s date in table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10() { | ||
it('marks today\'s date in table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() { | ||
var browserDate; | ||
return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
return _regeneratorRuntime().wrap(function _callee10$(_context10) { | ||
while (1) { | ||
@@ -696,4 +1041,4 @@ switch (_context10.prev = _context10.next) { | ||
}))); | ||
it('changes date on day clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11() { | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
it('changes date on day clicked', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() { | ||
return _regeneratorRuntime().wrap(function _callee11$(_context11) { | ||
while (1) { | ||
@@ -730,5 +1075,5 @@ switch (_context11.prev = _context11.next) { | ||
}))); | ||
it('changes date and focus on keyboard navigation as expected in adjacent table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12() { | ||
it('changes date and focus on keyboard navigation as expected in adjacent table', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() { | ||
var activeElementVal; | ||
return regeneratorRuntime.wrap(function _callee12$(_context12) { | ||
return _regeneratorRuntime().wrap(function _callee12$(_context12) { | ||
while (1) { | ||
@@ -787,5 +1132,5 @@ switch (_context12.prev = _context12.next) { | ||
}))); | ||
it('changes month names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13() { | ||
it('changes month names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() { | ||
var months, i; | ||
return regeneratorRuntime.wrap(function _callee13$(_context13) { | ||
return _regeneratorRuntime().wrap(function _callee13$(_context13) { | ||
while (1) { | ||
@@ -832,5 +1177,5 @@ switch (_context13.prev = _context13.next) { | ||
}))); | ||
it('changes day names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee14() { | ||
it('changes day names', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() { | ||
var days, i; | ||
return regeneratorRuntime.wrap(function _callee14$(_context14) { | ||
return _regeneratorRuntime().wrap(function _callee14$(_context14) { | ||
while (1) { | ||
@@ -877,4 +1222,4 @@ switch (_context14.prev = _context14.next) { | ||
}))); | ||
it('disables elements from function', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee15() { | ||
return regeneratorRuntime.wrap(function _callee15$(_context15) { | ||
it('disables elements from function', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() { | ||
return _regeneratorRuntime().wrap(function _callee15$(_context15) { | ||
while (1) { | ||
@@ -919,5 +1264,5 @@ switch (_context15.prev = _context15.next) { | ||
}))); | ||
it('triggers change event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee16() { | ||
it('triggers change event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() { | ||
var time; | ||
return regeneratorRuntime.wrap(function _callee16$(_context16) { | ||
return _regeneratorRuntime().wrap(function _callee16$(_context16) { | ||
while (1) { | ||
@@ -955,4 +1300,4 @@ switch (_context16.prev = _context16.next) { | ||
}))); | ||
it('triggers click day event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee17() { | ||
return regeneratorRuntime.wrap(function _callee17$(_context17) { | ||
it('triggers click day event', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() { | ||
return _regeneratorRuntime().wrap(function _callee17$(_context17) { | ||
while (1) { | ||
@@ -992,4 +1337,4 @@ switch (_context17.prev = _context17.next) { | ||
}))); | ||
it('does not trigger change event when clicking selected date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee18() { | ||
return regeneratorRuntime.wrap(function _callee18$(_context18) { | ||
it('does not trigger change event when clicking selected date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() { | ||
return _regeneratorRuntime().wrap(function _callee18$(_context18) { | ||
while (1) { | ||
@@ -1023,4 +1368,4 @@ switch (_context18.prev = _context18.next) { | ||
}))); | ||
it('does trigger change event when clicking selected date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee19() { | ||
return regeneratorRuntime.wrap(function _callee19$(_context19) { | ||
it('does trigger change event when clicking selected date', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() { | ||
return _regeneratorRuntime().wrap(function _callee19$(_context19) { | ||
while (1) { | ||
@@ -1027,0 +1372,0 @@ switch (_context19.prev = _context19.next) { |
30
jsx.js
@@ -1,2 +0,2 @@ | ||
/*! @nrk/core-datepicker v4.0.0 - Copyright (c) 2017-2021 NRK */ | ||
/*! @nrk/core-datepicker v4.0.1 - Copyright (c) 2017-2022 NRK */ | ||
'use strict'; | ||
@@ -29,2 +29,5 @@ | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
Object.defineProperty(Constructor, "prototype", { | ||
writable: false | ||
}); | ||
return Constructor; | ||
@@ -45,2 +48,5 @@ } | ||
}); | ||
Object.defineProperty(subClass, "prototype", { | ||
writable: false | ||
}); | ||
if (superClass) _setPrototypeOf(subClass, superClass); | ||
@@ -50,3 +56,3 @@ } | ||
function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { | ||
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
return o.__proto__ || Object.getPrototypeOf(o); | ||
@@ -58,7 +64,6 @@ }; | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
@@ -82,3 +87,3 @@ } | ||
if (_isNativeReflectConstruct()) { | ||
_construct = Reflect.construct; | ||
_construct = Reflect.construct.bind(); | ||
} else { | ||
@@ -174,5 +179,6 @@ _construct = function _construct(Parent, args, Class) { | ||
var IS_BROWSER = typeof window !== 'undefined'; | ||
IS_BROWSER && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
var HAS_NAVIGATOR = IS_BROWSER && typeof window.navigator !== 'undefined'; | ||
HAS_NAVIGATOR && /(android)/i.test(navigator.userAgent); // Bad, but needed | ||
IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
HAS_NAVIGATOR && /iPad|iPhone|iPod/.test(String(navigator.platform)); | ||
// Mock HTMLElement for Node | ||
@@ -186,3 +192,3 @@ | ||
return _class; | ||
return _createClass(_class); | ||
}(); | ||
@@ -227,6 +233,6 @@ } | ||
* dispatchEvent - with infinite loop prevention | ||
* @param {Element} elem The target object | ||
* @param {String} name The source object(s) | ||
* @param {Element} element The target object | ||
* @param {String} name The event name | ||
* @param {Object} detail Detail object (bubbles and cancelable is set to true) | ||
* @return {Boolean} Whether the event was canceled | ||
* @return {Boolean} Whether the event was canceled. Returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. | ||
*/ | ||
@@ -646,3 +652,3 @@ | ||
var version = "4.0.0"; | ||
var version = "4.0.1"; | ||
@@ -649,0 +655,0 @@ /** |
@@ -5,3 +5,3 @@ { | ||
"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "core-datepicker.cjs.js", |
@@ -38,3 +38,3 @@ # Core Datepicker | ||
<button type="button">Show calendar</button> | ||
<core-toggle id="calendar-toggle" popup hidden class="my-popup"> | ||
<core-toggle id="calendar-toggle" data-popup hidden class="my-popup"> | ||
<core-datepicker | ||
@@ -94,3 +94,3 @@ id="toggled-datepicker" | ||
<button type="button" class="my-toggle">Choose date</button> | ||
<core-toggle popup hidden class="my-popup"> | ||
<core-toggle data-popup hidden class="my-popup"> | ||
<core-datepicker | ||
@@ -210,3 +210,3 @@ id="my-datepicker" | ||
onToggle={handleToggle} | ||
popup | ||
data-popup | ||
> | ||
@@ -235,3 +235,3 @@ <CoreDatepicker | ||
<div id="jsx-datepicker"></div> | ||
<script type="text/jsx"> | ||
<script type="text/javascript"> | ||
class MyDate extends React.Component { | ||
@@ -256,3 +256,3 @@ constructor (props) { | ||
<button type="button">Choose date</button> | ||
<CoreToggle hidden popup className="my-popup"> | ||
<CoreToggle hidden data-popup className="my-popup"> | ||
<CoreDatepicker | ||
@@ -292,3 +292,3 @@ date={this.state.date} | ||
```html | ||
<script src="https://static.nrk.no/core-components/major/8/core-datepicker/core-datepicker.min.js"></script> <!-- Using static --> | ||
<script src="https://static.nrk.no/core-components/major/10/core-datepicker/core-datepicker.min.js"></script> <!-- Using static --> | ||
``` | ||
@@ -295,0 +295,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
256408
8.6%3602
9.62%