🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@nrk/core-datepicker

Package Overview
Dependencies
Maintainers
130
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

to
3.0.7

33

core-datepicker.cjs.js

@@ -143,13 +143,4 @@ 'use strict';

var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) {
window.Element.prototype.toggleAttribute = function (name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name);
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
};
} // Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {

@@ -231,4 +222,18 @@ global.HTMLElement =

/**
* toggleAttribute (Ponyfill for IE and Edge, fixes #299)
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute
* @param {Element} el Single DOM Element
* @param {String} name The name of the attribute to be toggled
* @param {Boolean} force Force attribute to be added or removed regardless of previous state
*/
function toggleAttribute(el, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !this.hasAttribute(name);
if (!force === el.hasAttribute(name)) el[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
}
/**
* queryAll
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element
* @param {Element} context Node to look for elements within
* @return {Element[]} Array of elements

@@ -440,3 +445,4 @@ */

return String(this._date.getTime());
}
} // Stringify for consistency and for truthy '0'
}, {

@@ -446,4 +452,3 @@ key: "year",

return String(this._date.getFullYear());
} // Stringify for consistency and for truthy '0'
}
}, {

@@ -566,3 +571,3 @@ key: "month",

button.setAttribute('aria-current', day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear() && 'date');
button.toggleAttribute('autofocus', isSelected);
toggleAttribute(button, 'autofocus', isSelected);
day.setDate(dayInMonth + 1);

@@ -569,0 +574,0 @@ });

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

import { addStyle, closest, dispatchEvent, queryAll } from '../utils'
import { addStyle, closest, dispatchEvent, toggleAttribute, queryAll } from '../utils'
import parse from '@nrk/simple-date-parse'

@@ -68,3 +68,4 @@

get year () { return String(this._date.getFullYear()) } // Stringify for consistency and for truthy '0'
// Stringify for consistency and for truthy '0'
get year () { return String(this._date.getFullYear()) }

@@ -143,3 +144,3 @@ get month () { return pad(this._date.getMonth() + 1) }

button.setAttribute('aria-current', day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear() && 'date')
button.toggleAttribute('autofocus', isSelected)
toggleAttribute(button, 'autofocus', isSelected)
day.setDate(dayInMonth + 1)

@@ -146,0 +147,0 @@ })

@@ -149,13 +149,4 @@ (function (global, factory) {

var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) {
window.Element.prototype.toggleAttribute = function (name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name);
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
};
} // Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {

@@ -237,4 +228,18 @@ global.HTMLElement =

/**
* toggleAttribute (Ponyfill for IE and Edge, fixes #299)
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute
* @param {Element} el Single DOM Element
* @param {String} name The name of the attribute to be toggled
* @param {Boolean} force Force attribute to be added or removed regardless of previous state
*/
function toggleAttribute(el, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !this.hasAttribute(name);
if (!force === el.hasAttribute(name)) el[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
}
/**
* queryAll
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element
* @param {Element} context Node to look for elements within
* @return {Element[]} Array of elements

@@ -446,3 +451,4 @@ */

return String(this._date.getTime());
}
} // Stringify for consistency and for truthy '0'
}, {

@@ -452,4 +458,3 @@ key: "year",

return String(this._date.getFullYear());
} // Stringify for consistency and for truthy '0'
}
}, {

@@ -572,3 +577,3 @@ key: "month",

button.setAttribute('aria-current', day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear() && 'date');
button.toggleAttribute('autofocus', isSelected);
toggleAttribute(button, 'autofocus', isSelected);
day.setDate(dayInMonth + 1);

@@ -593,3 +598,3 @@ });

var version = "3.0.6";
var version = "3.0.7";

@@ -638,3 +643,3 @@ /**

var customEvents = options.customEvents || [];
var skipProps = customProps.slice(); // Keep a copy
var skipProps = customProps.concat('forwardRef'); // Keep a copy with forwardRef added

@@ -650,2 +655,9 @@ var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();

this.ref = function (el) {
// Support callback ref https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
if (typeof this$1.props.forwardRef === 'function') {
this$1.props.forwardRef(el);
} else if (this$1.props.forwardRef) {
this$1.props.forwardRef.current = el;
}
return this$1.el = el;

@@ -679,3 +691,3 @@ };

customProps.forEach(function (key) {
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]);
return key in this$1.props && (this$1.el[key] = this$1.props[key]);
});

@@ -682,0 +694,0 @@ customEvents.forEach(function (key) {

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

/*! @nrk/core-datepicker v3.0.6 - 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 o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(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 u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function r(t,e,n){return(r=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&&c(r,n.prototype),r}).apply(null,arguments)}function s(t){var i="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return r(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function d(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&&!window.Element.prototype.toggleAttribute&&(window.Element.prototype.toggleAttribute=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!this.hasAttribute(t);return!e===this.hasAttribute(t)&&this[e?"setAttribute":"removeAttribute"](t,""),e}),t||global.HTMLElement||(global.HTMLElement=function(){return function t(){o(this,t)}}());var e,n,l=(e="undefined"==typeof window?{}:window.Element.prototype,n=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,e.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(n.call(t,e))return t;return null});function f(t,e){var n,i=2<arguments.length&&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=1<arguments.length&&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 i,y=(function(t,e){var b,v,w,k;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,w=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,k=/([\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(w)||[],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(k)||[],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})}(i={exports:{}},i.exports),i.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(t){function e(){return o(this,e),d(this,u(e).apply(this,arguments))}var n,i,r;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&&c(t,e)}(e,s(HTMLElement)),n=e,r=[{key:"observedAttributes",get:function(){return["timestamp","months","days"]}}],(i=[{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),v("button",this,w),v("select",this,_),v("input",this,k),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)||l(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=l(t.target,"button[value]"),n=l(t.target,"table");e&&(this.date=e.value),e&&n&&f(this,"datepicker.click.day")}else"keydown"===t.type&&l(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*/)}}])&&a(n.prototype,i),r&&a(n,r),e}(),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 w(t,e){e.value&&(e.type="button",e.disabled=t.disabled(e.value))}function k(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),h("th",t).forEach(function(t,e){return t.textContent=r.days[e]}),h("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"),t.toggleAttribute("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("")),h(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.0.7 - 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 o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(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 u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function r(t,e,n){return(r=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&&c(r,n.prototype),r}).apply(null,arguments)}function s(t){var i="function"==typeof Map?new Map:void 0;return(s=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return r(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)})(t)}function d(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(){o(this,t)}}());var e,n,l=(e="undefined"==typeof window?{}:window.Element.prototype,n=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,e.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(n.call(t,e))return t;return null});function f(t,e){var n,i=2<arguments.length&&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=1<arguments.length&&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 i,y=(function(t,e){var g,v,k,w;t.exports=(g={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"+g[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]),b=r.getDate();y?r["set"+g[y]](r["get"+g[y]]()+m):r.setDate(r.getDate()-(r.getDay()||7)+p),"month"!==y&&"year"!==y||b===r.getDate()||r.setDate(0)}return r})}(i={exports:{}},i.exports),i.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"},b=function(t){function e(){return o(this,e),d(this,u(e).apply(this,arguments))}var n,i,r;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&&c(t,e)}(e,s(HTMLElement)),n=e,r=[{key:"observedAttributes",get:function(){return["timestamp","months","days"]}}],(i=[{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),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)||l(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=l(t.target,"button[value]"),n=l(t.target,"table");e&&(this.date=e.value),e&&n&&f(this,"datepicker.click.day")}else"keydown"===t.type&&l(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 g(this._date.getMonth()+1)}},{key:"day",get:function(){return g(this._date.getDate())}},{key:"hour",get:function(){return g(this._date.getHours())}},{key:"minute",get:function(){return g(this._date.getMinutes())}},{key:"second",get:function(){return g(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*/)}}])&&a(n.prototype,i),r&&a(n,r),e}(),g=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),h("th",t).forEach(function(t,e){return t.textContent=r.days[e]}),h("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){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:!this.hasAttribute(e);!n===t.hasAttribute(e)&&t[n?"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("")),h(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 b}),window.customElements.define("core-datepicker",coreDatepicker);
//# sourceMappingURL=core-datepicker.min.js.map

@@ -147,13 +147,4 @@ 'use strict';

var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Polyfill toggleAttribute for IE
var IS_IOS = IS_BROWSER && /iPad|iPhone|iPod/.test(String(navigator.platform)); // Mock HTMLElement for Node
if (IS_BROWSER && !window.Element.prototype.toggleAttribute) {
window.Element.prototype.toggleAttribute = function (name) {
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !this.hasAttribute(name);
if (!force === this.hasAttribute(name)) this[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
};
} // Mock HTMLElement for Node
if (!IS_BROWSER && !global.HTMLElement) {

@@ -235,4 +226,18 @@ global.HTMLElement =

/**
* toggleAttribute (Ponyfill for IE and Edge, fixes #299)
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute
* @param {Element} el Single DOM Element
* @param {String} name The name of the attribute to be toggled
* @param {Boolean} force Force attribute to be added or removed regardless of previous state
*/
function toggleAttribute(el, name) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !this.hasAttribute(name);
if (!force === el.hasAttribute(name)) el[force ? 'setAttribute' : 'removeAttribute'](name, '');
return force;
}
/**
* queryAll
* @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element
* @param {Element} context Node to look for elements within
* @return {Element[]} Array of elements

@@ -444,3 +449,4 @@ */

return String(this._date.getTime());
}
} // Stringify for consistency and for truthy '0'
}, {

@@ -450,4 +456,3 @@ key: "year",

return String(this._date.getFullYear());
} // Stringify for consistency and for truthy '0'
}
}, {

@@ -570,3 +575,3 @@ key: "month",

button.setAttribute('aria-current', day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear() && 'date');
button.toggleAttribute('autofocus', isSelected);
toggleAttribute(button, 'autofocus', isSelected);
day.setDate(dayInMonth + 1);

@@ -591,3 +596,3 @@ });

var version = "3.0.6";
var version = "3.0.7";

@@ -636,3 +641,3 @@ /**

var customEvents = options.customEvents || [];
var skipProps = customProps.slice(); // Keep a copy
var skipProps = customProps.concat('forwardRef'); // Keep a copy with forwardRef added

@@ -648,2 +653,9 @@ var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();

this.ref = function (el) {
// Support callback ref https://reactjs.org/docs/refs-and-the-dom.html#callback-refs
if (typeof this$1.props.forwardRef === 'function') {
this$1.props.forwardRef(el);
} else if (this$1.props.forwardRef) {
this$1.props.forwardRef.current = el;
}
return this$1.el = el;

@@ -677,3 +689,3 @@ };

customProps.forEach(function (key) {
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]);
return key in this$1.props && (this$1.el[key] = this$1.props[key]);
});

@@ -680,0 +692,0 @@ customEvents.forEach(function (key) {

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

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

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

@@ -163,3 +163,3 @@ # Core Datepicker

```html
<script src="https://static.nrk.no/core-components/major/6/core-datepicker/core-datepicker.min.js"></script> <!-- Using static -->
<script src="https://static.nrk.no/core-components/major/7/core-datepicker/core-datepicker.min.js"></script> <!-- Using static -->
```

@@ -166,0 +166,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet