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

@nrk/core-datepicker

Package Overview
Dependencies
Maintainers
90
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 1.2.0 to 1.2.1

4

core-datepicker.js

@@ -100,3 +100,3 @@ import {name, version} from './package.json'

const month = date.getMonth()
const today = new Date().toJSON().slice(0, 10) // Get ymd part of date
const today = new Date()
let day = parse('y-m-1 mon', date) // Monday in first week of month

@@ -106,3 +106,3 @@ table.caption.textContent = `${escapeHTML(datepicker.months[month])}, ${date.getFullYear()}`

queryAll('button', table).forEach((button) => {
const isToday = day.toJSON().slice(0, 10) === today
const isToday = day.getDate() === today.getDate() && day.getMonth() === today.getMonth() && day.getFullYear() === today.getFullYear()
const isSelected = day.getTime() === date.getTime()

@@ -109,0 +109,0 @@ const dayInMonth = day.getDate()

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreDatepicker=t()}(this,function(){"use strict";var e="undefined"!=typeof window,a=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function t(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(a||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function c(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var o="prevent_recursive_dispatch_maximum_callstack";function d(e,t,n){void 0===n&&(n={});var r,a=""+o+t;if(e[a])return!0;e[a]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var i=e.dispatchEvent(r);return e[a]=null,i}function s(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,m=(function(e,t){var p,y,b,w;e.exports=(p={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},y=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,b=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,w=/([\dh]+):([\dm]+):?([\ds]+)?/,function(e,t){if(isFinite(e))return new Date(Number(e));var n=String(e).toLowerCase(),a=new Date(isFinite(t)&&-1===n.indexOf("now")?Number(t):Date.now()),r=n.match(b)||[],i=r[1];void 0===i&&(i="y");var o=r[2];void 0===o&&(o="m");var u=r[3];void 0===u&&(u="d");var d=n.match(w)||[],c=d[1];void 0===c&&(c="h");var s=d[2];void 0===s&&(s="m");var m=d[3];void 0===m&&(m="s");var l={year:i,month:o,day:u,hour:c,minute:s,second:m};Object.keys(l).forEach(function(e){var t="month"===e?1:0,r=""+(a["get"+p[e]]()+t);l[e]=l[e].replace(/[^-\d]+/g,function(e,t,n){return t?r.substr(r.length-n.length+t,e.length):r.substr(0,Math.max(0,r.length-n.length+e.length))})-t});var f=new Date(l.year,Math.min(12,l.month+1),0).getDate();for(a.setFullYear(l.year,Math.min(11,l.month),Math.max(1,Math.min(f,l.day))),a.setHours(Math.min(24,l.hour),Math.min(59,l.minute),Math.min(59,l.second));null!==(l=y.exec(n));){var h=l[2],v=String(l[1]).replace(/\s/g,"")*("week"===h?7:1),g=l.slice(2).indexOf(l[0]);h?a["set"+p[h]](a["get"+p[h]]()+v):a.setDate(a.getDate()-(a.getDay()||7)+g)}return a})}(r={exports:{}},r.exports),r.exports),l="data-core-datepicker",f="data-@nrk/core-datepicker-1.1.0".replace(/\W+/g,"-"),i={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},u={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*"},h=6e4;function v(e,a){return s(e).map(function(i){var e=m(i.getAttribute(f)||a),t=m(void 0===a?e:a,e),o=function(){return!1};d(i,"datepicker.render",{nextDate:t,prevDate:e,disable:function(e){return o=e}}),o(t)&&(t=e);var u=e.getTime()===t.getTime()||d(i,"datepicker.change",{prevDate:e,nextDate:t})?t:m(i.getAttribute(f)||Date.now()),n=new Date(u.getTime()-u.getTimezoneOffset()*h).toJSON().match(/\d+/g),r={year:u.getFullYear(),month:n[1],day:n[2],hour:n[3],minute:n[4],second:n[5],timestamp:u.getTime()};return i.setAttribute(f,r.timestamp),s("button").forEach(function(e){return n=u,r=o,a=i,void(((t=e).getAttribute(l)===a.id||a.contains(t))&&(t.disabled=r(m(t.value,n))));var t,n,r,a}),s("select",i).forEach(function(e){return function(e,n,r){e.firstElementChild||(e.innerHTML=v.months.map(function(e,t){return'<option value="y-'+(t+1)+'-d">'+c(e)+"</option>"}).join(""));s(e.children).forEach(function(e){var t=m(e.value,n);e.disabled=r(t),e.selected=t.getTime()===n.getTime()})}(e,u,o)}),s("input",i).forEach(function(e){return function(e,t,n,r){var a=e.getAttribute(f+"-type")||e.getAttribute("type");if("radio"===a||"checkbox"===a){var i=m(e.value,t);e.disabled=n(i),e.checked=i.getTime()===t.getTime()}else r[a]&&(e.setAttribute("type","number"),e.setAttribute(f+"-type",a),e.value=r[a])}(e,u,o,r)}),s("table",i).forEach(function(e){return function(e,a,i){e.firstElementChild||(e.innerHTML="\n <caption></caption><thead><tr><th>"+v.days.map(c).join("</th><th>")+"</th></tr></thead>\n <tbody>"+Array(7).join("<tr>"+Array(8).join('<td><button type="button"></button></td>')+"</tr>")+"</tbody>");var o=a.getMonth(),u=(new Date).toJSON().slice(0,10),d=m("y-m-1 mon",a);e.caption.textContent=c(v.months[o])+", "+a.getFullYear(),s("button",e).forEach(function(e){var t=d.toJSON().slice(0,10)===u,n=d.getTime()===a.getTime(),r=d.getDate();e.textContent=r,e.value=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+r,e.disabled=i(d),e.setAttribute("tabindex",n-1),e.setAttribute("aria-pressed",n),e.setAttribute("aria-current",t&&"date"),e.setAttribute("aria-disabled",o!==d.getMonth()),d.setDate(r+1)})}(e,u,o)}),i})}function g(e){for(var t=e.target,n=t,r=void 0;n;n=n.parentElement){var a=document.getElementById(n.getAttribute(l))||n,i=a.hasAttribute(f)&&(u[t.getAttribute(f+"-type")]||"*");if(r||"TABLE"!==n.nodeName||(r=n),i){var o=i.replace("*",t.value);return(!a.contains(r)||d(a,"datepicker.click.day",{currentTarget:t,relatedTarget:r,prevDate:m(a.getAttribute(f)),nextDate:m(o)}))&&v(a,o)}}}return v.parse=m,v.months=["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],v.days=["man","tirs","ons","tors","fre","lør","søn"],t(f,"change",g),t(f,"click",function(e){for(var t=e.target;t;t=t.parentElement)if("BUTTON"===t.nodeName)return g({target:t})}),t(f,"keydown",function(e){if(!(e.ctrlKey||e.metaKey||e.shitKey||e.altKey)&&i[e.keyCode])for(var t=e.target,n=void 0;t;t=t.parentElement)if(n||"TABLE"!==t.nodeName||(n=t),n&&t.hasAttribute(f)){v(t,i[e.keyCode]),n.querySelector('[aria-pressed="true"]').focus(),e.preventDefault();break}}),v});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.coreDatepicker=t()}(this,function(){"use strict";var e="undefined"!=typeof window,a=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function t(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(a||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function c(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var o="prevent_recursive_dispatch_maximum_callstack";function d(e,t,n){void 0===n&&(n={});var r,a=""+o+t;if(e[a])return!0;e[a]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var i=e.dispatchEvent(r);return e[a]=null,i}function s(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,m=(function(e,t){var p,y,b,w;e.exports=(p={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},y=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,b=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,w=/([\dh]+):([\dm]+):?([\ds]+)?/,function(e,t){if(isFinite(e))return new Date(Number(e));var n=String(e).toLowerCase(),a=new Date(isFinite(t)&&-1===n.indexOf("now")?Number(t):Date.now()),r=n.match(b)||[],i=r[1];void 0===i&&(i="y");var o=r[2];void 0===o&&(o="m");var u=r[3];void 0===u&&(u="d");var d=n.match(w)||[],c=d[1];void 0===c&&(c="h");var s=d[2];void 0===s&&(s="m");var m=d[3];void 0===m&&(m="s");var l={year:i,month:o,day:u,hour:c,minute:s,second:m};Object.keys(l).forEach(function(e){var t="month"===e?1:0,r=""+(a["get"+p[e]]()+t);l[e]=l[e].replace(/[^-\d]+/g,function(e,t,n){return t?r.substr(r.length-n.length+t,e.length):r.substr(0,Math.max(0,r.length-n.length+e.length))})-t});var f=new Date(l.year,Math.min(12,l.month+1),0).getDate();for(a.setFullYear(l.year,Math.min(11,l.month),Math.max(1,Math.min(f,l.day))),a.setHours(Math.min(24,l.hour),Math.min(59,l.minute),Math.min(59,l.second));null!==(l=y.exec(n));){var h=l[2],g=String(l[1]).replace(/\s/g,"")*("week"===h?7:1),v=l.slice(2).indexOf(l[0]);h?a["set"+p[h]](a["get"+p[h]]()+g):a.setDate(a.getDate()-(a.getDay()||7)+v)}return a})}(r={exports:{}},r.exports),r.exports),l="data-core-datepicker",f="data-@nrk/core-datepicker-1.2.0".replace(/\W+/g,"-"),i={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},u={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*"},h=6e4;function g(e,a){return s(e).map(function(i){var e=m(i.getAttribute(f)||a),t=m(void 0===a?e:a,e),o=function(){return!1};d(i,"datepicker.render",{nextDate:t,prevDate:e,disable:function(e){return o=e}}),o(t)&&(t=e);var u=e.getTime()===t.getTime()||d(i,"datepicker.change",{prevDate:e,nextDate:t})?t:m(i.getAttribute(f)||Date.now()),n=new Date(u.getTime()-u.getTimezoneOffset()*h).toJSON().match(/\d+/g),r={year:u.getFullYear(),month:n[1],day:n[2],hour:n[3],minute:n[4],second:n[5],timestamp:u.getTime()};return i.setAttribute(f,r.timestamp),s("button").forEach(function(e){return n=u,r=o,a=i,void(((t=e).getAttribute(l)===a.id||a.contains(t))&&(t.disabled=r(m(t.value,n))));var t,n,r,a}),s("select",i).forEach(function(e){return function(e,n,r){e.firstElementChild||(e.innerHTML=g.months.map(function(e,t){return'<option value="y-'+(t+1)+'-d">'+c(e)+"</option>"}).join(""));s(e.children).forEach(function(e){var t=m(e.value,n);e.disabled=r(t),e.selected=t.getTime()===n.getTime()})}(e,u,o)}),s("input",i).forEach(function(e){return function(e,t,n,r){var a=e.getAttribute(f+"-type")||e.getAttribute("type");if("radio"===a||"checkbox"===a){var i=m(e.value,t);e.disabled=n(i),e.checked=i.getTime()===t.getTime()}else r[a]&&(e.setAttribute("type","number"),e.setAttribute(f+"-type",a),e.value=r[a])}(e,u,o,r)}),s("table",i).forEach(function(e){return function(e,a,i){e.firstElementChild||(e.innerHTML="\n <caption></caption><thead><tr><th>"+g.days.map(c).join("</th><th>")+"</th></tr></thead>\n <tbody>"+Array(7).join("<tr>"+Array(8).join('<td><button type="button"></button></td>')+"</tr>")+"</tbody>");var o=a.getMonth(),u=new Date,d=m("y-m-1 mon",a);e.caption.textContent=c(g.months[o])+", "+a.getFullYear(),s("button",e).forEach(function(e){var t=d.getDate()===u.getDate()&&d.getMonth()===u.getMonth()&&d.getFullYear()===u.getFullYear(),n=d.getTime()===a.getTime(),r=d.getDate();e.textContent=r,e.value=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+r,e.disabled=i(d),e.setAttribute("tabindex",n-1),e.setAttribute("aria-pressed",n),e.setAttribute("aria-current",t&&"date"),e.setAttribute("aria-disabled",o!==d.getMonth()),d.setDate(r+1)})}(e,u,o)}),i})}function v(e){for(var t=e.target,n=t,r=void 0;n;n=n.parentElement){var a=document.getElementById(n.getAttribute(l))||n,i=a.hasAttribute(f)&&(u[t.getAttribute(f+"-type")]||"*");if(r||"TABLE"!==n.nodeName||(r=n),i){var o=i.replace("*",t.value);return(!a.contains(r)||d(a,"datepicker.click.day",{currentTarget:t,relatedTarget:r,prevDate:m(a.getAttribute(f)),nextDate:m(o)}))&&g(a,o)}}}return g.parse=m,g.months=["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],g.days=["man","tirs","ons","tors","fre","lør","søn"],t(f,"change",v),t(f,"click",function(e){for(var t=e.target;t;t=t.parentElement)if("BUTTON"===t.nodeName)return v({target:t})}),t(f,"keydown",function(e){if(!(e.ctrlKey||e.metaKey||e.shitKey||e.altKey)&&i[e.keyCode])for(var t=e.target,n=void 0;t;t=t.parentElement)if(n||"TABLE"!==t.nodeName||(n=t),n&&t.hasAttribute(f)){g(t,i[e.keyCode]),n.querySelector('[aria-pressed="true"]').focus(),e.preventDefault();break}}),g});
//# sourceMappingURL=core-datepicker.min.js.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):e.CoreDatepicker=t(e.React)}(this,function(a){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a;var e="undefined"!=typeof window,i=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function t(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(i||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function s(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var d="prevent_recursive_dispatch_maximum_callstack";function u(e,t,n){void 0===n&&(n={});var r,i=""+d+t;if(e[i])return!0;e[i]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var o=e.dispatchEvent(r);return e[i]=null,o}function c(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,l=(function(e,t){var v,g,b,k;e.exports=(v={year:"FullYear",month:"Month",week:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds"},g=/([+-]\s*\d+)\s*(second|minute|hour|day|week|month|year)|(mon)|(tue)|(wed)|(thu)|(fri)|(sat)|(sun)/g,b=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,k=/([\dh]+):([\dm]+):?([\ds]+)?/,function(e,t){if(isFinite(e))return new Date(Number(e));var n=String(e).toLowerCase(),i=new Date(isFinite(t)&&-1===n.indexOf("now")?Number(t):Date.now()),r=n.match(b)||[],o=r[1];void 0===o&&(o="y");var a=r[2];void 0===a&&(a="m");var d=r[3];void 0===d&&(d="d");var u=n.match(k)||[],s=u[1];void 0===s&&(s="h");var c=u[2];void 0===c&&(c="m");var l=u[3];void 0===l&&(l="s");var h={year:o,month:a,day:d,hour:s,minute:c,second:l};Object.keys(h).forEach(function(e){var t="month"===e?1:0,r=""+(i["get"+v[e]]()+t);h[e]=h[e].replace(/[^-\d]+/g,function(e,t,n){return t?r.substr(r.length-n.length+t,e.length):r.substr(0,Math.max(0,r.length-n.length+e.length))})-t});var p=new Date(h.year,Math.min(12,h.month+1),0).getDate();for(i.setFullYear(h.year,Math.min(11,h.month),Math.max(1,Math.min(p,h.day))),i.setHours(Math.min(24,h.hour),Math.min(59,h.minute),Math.min(59,h.second));null!==(h=g.exec(n));){var m=h[2],f=String(h[1]).replace(/\s/g,"")*("week"===m?7:1),y=h.slice(2).indexOf(h[0]);m?i["set"+v[m]](i["get"+v[m]]()+f):i.setDate(i.getDate()-(i.getDay()||7)+y)}return i})}(r={exports:{}},r.exports),r.exports),h="data-core-datepicker",p="data-@nrk/core-datepicker-1.1.0".replace(/\W+/g,"-"),o={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},m={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*"},f=6e4;function y(e,i){return c(e).map(function(o){var e=l(o.getAttribute(p)||i),t=l(void 0===i?e:i,e),a=function(){return!1};u(o,"datepicker.render",{nextDate:t,prevDate:e,disable:function(e){return a=e}}),a(t)&&(t=e);var d=e.getTime()===t.getTime()||u(o,"datepicker.change",{prevDate:e,nextDate:t})?t:l(o.getAttribute(p)||Date.now()),n=new Date(d.getTime()-d.getTimezoneOffset()*f).toJSON().match(/\d+/g),r={year:d.getFullYear(),month:n[1],day:n[2],hour:n[3],minute:n[4],second:n[5],timestamp:d.getTime()};return o.setAttribute(p,r.timestamp),c("button").forEach(function(e){return n=d,r=a,i=o,void(((t=e).getAttribute(h)===i.id||i.contains(t))&&(t.disabled=r(l(t.value,n))));var t,n,r,i}),c("select",o).forEach(function(e){return function(e,n,r){e.firstElementChild||(e.innerHTML=y.months.map(function(e,t){return'<option value="y-'+(t+1)+'-d">'+s(e)+"</option>"}).join(""));c(e.children).forEach(function(e){var t=l(e.value,n);e.disabled=r(t),e.selected=t.getTime()===n.getTime()})}(e,d,a)}),c("input",o).forEach(function(e){return function(e,t,n,r){var i=e.getAttribute(p+"-type")||e.getAttribute("type");if("radio"===i||"checkbox"===i){var o=l(e.value,t);e.disabled=n(o),e.checked=o.getTime()===t.getTime()}else r[i]&&(e.setAttribute("type","number"),e.setAttribute(p+"-type",i),e.value=r[i])}(e,d,a,r)}),c("table",o).forEach(function(e){return function(e,i,o){e.firstElementChild||(e.innerHTML="\n <caption></caption><thead><tr><th>"+y.days.map(s).join("</th><th>")+"</th></tr></thead>\n <tbody>"+Array(7).join("<tr>"+Array(8).join('<td><button type="button"></button></td>')+"</tr>")+"</tbody>");var a=i.getMonth(),d=(new Date).toJSON().slice(0,10),u=l("y-m-1 mon",i);e.caption.textContent=s(y.months[a])+", "+i.getFullYear(),c("button",e).forEach(function(e){var t=u.toJSON().slice(0,10)===d,n=u.getTime()===i.getTime(),r=u.getDate();e.textContent=r,e.value=u.getFullYear()+"-"+(u.getMonth()+1)+"-"+r,e.disabled=o(u),e.setAttribute("tabindex",n-1),e.setAttribute("aria-pressed",n),e.setAttribute("aria-current",t&&"date"),e.setAttribute("aria-disabled",a!==u.getMonth()),u.setDate(r+1)})}(e,d,a)}),o})}function v(e){for(var t=e.target,n=t,r=void 0;n;n=n.parentElement){var i=document.getElementById(n.getAttribute(h))||n,o=i.hasAttribute(p)&&(m[t.getAttribute(p+"-type")]||"*");if(r||"TABLE"!==n.nodeName||(r=n),o){var a=o.replace("*",t.value);return(!i.contains(r)||u(i,"datepicker.click.day",{currentTarget:t,relatedTarget:r,prevDate:l(i.getAttribute(p)),nextDate:l(a)}))&&y(i,a)}}}y.parse=l,y.months=["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],y.days=["man","tirs","ons","tors","fre","lør","søn"],t(p,"change",v),t(p,"click",function(e){for(var t=e.target;t;t=t.parentElement)if("BUTTON"===t.nodeName)return v({target:t})}),t(p,"keydown",function(e){if(!(e.ctrlKey||e.metaKey||e.shitKey||e.altKey)&&o[e.keyCode])for(var t=e.target,n=void 0;t;t=t.parentElement)if(n||"TABLE"!==t.nodeName||(n=t),n&&t.hasAttribute(p)){y(t,o[e.keyCode]),n.querySelector('[aria-pressed="true"]').focus(),e.preventDefault();break}});var g=function(t){function o(e){t.call(this,e),this.onClickDay=this.onClickDay.bind(this),this.onChange=this.onChange.bind(this),this.onRender=this.onRender.bind(this)}t&&(o.__proto__=t),(o.prototype=Object.create(t&&t.prototype)).constructor=o;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{date:null,disable:null,onChange:null,onClickDay:null}},o.prototype.componentDidMount=function(){this.el.addEventListener("datepicker.click.day",this.onClickDay),this.el.addEventListener("datepicker.change",this.onChange),this.el.addEventListener("datepicker.render",this.onRender),y(this.el,this.props.date)},o.prototype.componentDidUpdate=function(){y(this.el,this.props.date)},o.prototype.componentWillUnmount=function(){this.el.removeEventListener("datepicker.click.day",this.onClickDay),this.el.removeEventListener("datepicker.change",this.onChange),this.el.removeEventListener("datepicker.render",this.onRender)},o.prototype.onClickDay=function(e){this.props.onClickDay&&this.props.onClickDay(e)},o.prototype.onChange=function(e){this.props.onChange&&this.props.onChange(e)},o.prototype.onRender=function(e){this.props.disable&&e.detail.disable(this.props.disable)},o.prototype.render=function(){var n,r,e,t=this,i=(n=this.props,r=o.defaultProps,void 0===(e={ref:function(e){return t.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e));return a.createElement("div",i,this.props.children)},Object.defineProperties(o,e),o}(a.Component);return g.parse=y.parse,g.months=y.months,g.days=y.days,g});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):e.CoreDatepicker=t(e.React)}(this,function(a){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a;var e="undefined"!=typeof window,i=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)),function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}());function t(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(i||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var n={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function s(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var d="prevent_recursive_dispatch_maximum_callstack";function u(e,t,n){void 0===n&&(n={});var r,i=""+d+t;if(e[i])return!0;e[i]=!0,"function"==typeof window.CustomEvent?r=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var o=e.dispatchEvent(r);return e[i]=null,o}function c(e,t){if(void 0===t&&(t=document),e){if(e.nodeType)return[e];if("string"==typeof e)return[].slice.call(t.querySelectorAll(e));if(e.length)return[].slice.call(e)}return[]}"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var r,l=(function(e,t){var g,v,b,k;e.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,b=/([-\dy]+)[-/.]([\dm]+)[-/.]([\dd]+)/,k=/([\dh]+):([\dm]+):?([\ds]+)?/,function(e,t){if(isFinite(e))return new Date(Number(e));var n=String(e).toLowerCase(),i=new Date(isFinite(t)&&-1===n.indexOf("now")?Number(t):Date.now()),r=n.match(b)||[],o=r[1];void 0===o&&(o="y");var a=r[2];void 0===a&&(a="m");var d=r[3];void 0===d&&(d="d");var u=n.match(k)||[],s=u[1];void 0===s&&(s="h");var c=u[2];void 0===c&&(c="m");var l=u[3];void 0===l&&(l="s");var h={year:o,month:a,day:d,hour:s,minute:c,second:l};Object.keys(h).forEach(function(e){var t="month"===e?1:0,r=""+(i["get"+g[e]]()+t);h[e]=h[e].replace(/[^-\d]+/g,function(e,t,n){return t?r.substr(r.length-n.length+t,e.length):r.substr(0,Math.max(0,r.length-n.length+e.length))})-t});var p=new Date(h.year,Math.min(12,h.month+1),0).getDate();for(i.setFullYear(h.year,Math.min(11,h.month),Math.max(1,Math.min(p,h.day))),i.setHours(Math.min(24,h.hour),Math.min(59,h.minute),Math.min(59,h.second));null!==(h=v.exec(n));){var m=h[2],f=String(h[1]).replace(/\s/g,"")*("week"===m?7:1),y=h.slice(2).indexOf(h[0]);m?i["set"+g[m]](i["get"+g[m]]()+f):i.setDate(i.getDate()-(i.getDay()||7)+y)}return i})}(r={exports:{}},r.exports),r.exports),h="data-core-datepicker",p="data-@nrk/core-datepicker-1.2.0".replace(/\W+/g,"-"),o={33:"-1month",34:"+1month",35:"y-m-99",36:"y-m-1",37:"-1day",38:"-1week",39:"+1day",40:"+1week"},m={year:"*-m-d",month:"y-*-d",day:"y-m-*",hour:"*:m",minute:"h:*",second:"h:m:*",timestamp:"*"},f=6e4;function y(e,i){return c(e).map(function(o){var e=l(o.getAttribute(p)||i),t=l(void 0===i?e:i,e),a=function(){return!1};u(o,"datepicker.render",{nextDate:t,prevDate:e,disable:function(e){return a=e}}),a(t)&&(t=e);var d=e.getTime()===t.getTime()||u(o,"datepicker.change",{prevDate:e,nextDate:t})?t:l(o.getAttribute(p)||Date.now()),n=new Date(d.getTime()-d.getTimezoneOffset()*f).toJSON().match(/\d+/g),r={year:d.getFullYear(),month:n[1],day:n[2],hour:n[3],minute:n[4],second:n[5],timestamp:d.getTime()};return o.setAttribute(p,r.timestamp),c("button").forEach(function(e){return n=d,r=a,i=o,void(((t=e).getAttribute(h)===i.id||i.contains(t))&&(t.disabled=r(l(t.value,n))));var t,n,r,i}),c("select",o).forEach(function(e){return function(e,n,r){e.firstElementChild||(e.innerHTML=y.months.map(function(e,t){return'<option value="y-'+(t+1)+'-d">'+s(e)+"</option>"}).join(""));c(e.children).forEach(function(e){var t=l(e.value,n);e.disabled=r(t),e.selected=t.getTime()===n.getTime()})}(e,d,a)}),c("input",o).forEach(function(e){return function(e,t,n,r){var i=e.getAttribute(p+"-type")||e.getAttribute("type");if("radio"===i||"checkbox"===i){var o=l(e.value,t);e.disabled=n(o),e.checked=o.getTime()===t.getTime()}else r[i]&&(e.setAttribute("type","number"),e.setAttribute(p+"-type",i),e.value=r[i])}(e,d,a,r)}),c("table",o).forEach(function(e){return function(e,i,o){e.firstElementChild||(e.innerHTML="\n <caption></caption><thead><tr><th>"+y.days.map(s).join("</th><th>")+"</th></tr></thead>\n <tbody>"+Array(7).join("<tr>"+Array(8).join('<td><button type="button"></button></td>')+"</tr>")+"</tbody>");var a=i.getMonth(),d=new Date,u=l("y-m-1 mon",i);e.caption.textContent=s(y.months[a])+", "+i.getFullYear(),c("button",e).forEach(function(e){var t=u.getDate()===d.getDate()&&u.getMonth()===d.getMonth()&&u.getFullYear()===d.getFullYear(),n=u.getTime()===i.getTime(),r=u.getDate();e.textContent=r,e.value=u.getFullYear()+"-"+(u.getMonth()+1)+"-"+r,e.disabled=o(u),e.setAttribute("tabindex",n-1),e.setAttribute("aria-pressed",n),e.setAttribute("aria-current",t&&"date"),e.setAttribute("aria-disabled",a!==u.getMonth()),u.setDate(r+1)})}(e,d,a)}),o})}function g(e){for(var t=e.target,n=t,r=void 0;n;n=n.parentElement){var i=document.getElementById(n.getAttribute(h))||n,o=i.hasAttribute(p)&&(m[t.getAttribute(p+"-type")]||"*");if(r||"TABLE"!==n.nodeName||(r=n),o){var a=o.replace("*",t.value);return(!i.contains(r)||u(i,"datepicker.click.day",{currentTarget:t,relatedTarget:r,prevDate:l(i.getAttribute(p)),nextDate:l(a)}))&&y(i,a)}}}y.parse=l,y.months=["januar","februar","mars","april","mai","juni","juli","august","september","oktober","november","desember"],y.days=["man","tirs","ons","tors","fre","lør","søn"],t(p,"change",g),t(p,"click",function(e){for(var t=e.target;t;t=t.parentElement)if("BUTTON"===t.nodeName)return g({target:t})}),t(p,"keydown",function(e){if(!(e.ctrlKey||e.metaKey||e.shitKey||e.altKey)&&o[e.keyCode])for(var t=e.target,n=void 0;t;t=t.parentElement)if(n||"TABLE"!==t.nodeName||(n=t),n&&t.hasAttribute(p)){y(t,o[e.keyCode]),n.querySelector('[aria-pressed="true"]').focus(),e.preventDefault();break}});var v=function(t){function o(e){t.call(this,e),this.onClickDay=this.onClickDay.bind(this),this.onChange=this.onChange.bind(this),this.onRender=this.onRender.bind(this)}t&&(o.__proto__=t),(o.prototype=Object.create(t&&t.prototype)).constructor=o;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{date:null,disable:null,onChange:null,onClickDay:null}},o.prototype.componentDidMount=function(){this.el.addEventListener("datepicker.click.day",this.onClickDay),this.el.addEventListener("datepicker.change",this.onChange),this.el.addEventListener("datepicker.render",this.onRender),y(this.el,this.props.date)},o.prototype.componentDidUpdate=function(){y(this.el,this.props.date)},o.prototype.componentWillUnmount=function(){this.el.removeEventListener("datepicker.click.day",this.onClickDay),this.el.removeEventListener("datepicker.change",this.onChange),this.el.removeEventListener("datepicker.render",this.onRender)},o.prototype.onClickDay=function(e){this.props.onClickDay&&this.props.onClickDay(e)},o.prototype.onChange=function(e){this.props.onChange&&this.props.onChange(e)},o.prototype.onRender=function(e){this.props.disable&&e.detail.disable(this.props.disable)},o.prototype.render=function(){var n,r,e,t=this,i=(n=this.props,r=o.defaultProps,void 0===(e={ref:function(e){return t.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e));return a.createElement("div",i,this.props.children)},Object.defineProperties(o,e),o}(a.Component);return v.parse=y.parse,v.months=y.months,v.days=y.days,v});
//# sourceMappingURL=index.js.map

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

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

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

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