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

@nrk/core-datepicker

Package Overview
Dependencies
Maintainers
124
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.4

9

core-datepicker.jsx
import CoreDatepicker from './core-datepicker.js'
import { elementToReact } from '../utils.js'
import { version } from './package.json'
import customElementToReact from '@nrk/custom-element-to-react'
export default elementToReact(CoreDatepicker, 'datepicker.change', 'datepicker.click.day', 'disabled', 'months', 'days')
export default customElementToReact(CoreDatepicker, {
props: ['disabled', 'months', 'days'],
customEvents: ['datepicker.change', 'datepicker.click.day'],
suffix: version
})

@@ -254,96 +254,3 @@ (function (global, factory) {

}
function elementToReact(elementClass) {
for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
attr[_key - 1] = arguments[_key];
}
var name = elementClass.name || String(elementClass).match(/function ([^(]+)/)[1]; // String match for IE11
var tag = "".concat(name.replace(/\W+/, '-'), "-").concat(getUUID()).toLowerCase();
if (IS_BROWSER && !window.customElements.get(tag)) window.customElements.define(tag, elementClass);
return (
/*#__PURE__*/
function (_React$Component) {
_inherits(_class2, _React$Component);
function _class2(props) {
var _this;
_classCallCheck(this, _class2);
_this = _possibleConstructorReturn(this, _getPrototypeOf(_class2).call(this, props));
_this.ref = function (el) {
return _this.el = el;
};
attr.forEach(function (k) {
var on = "on".concat(k.replace(/(^|\.)./g, function (m) {
return m.slice(-1).toUpperCase();
})); // input.filter => onInputFilter
_this[k] = function (event) {
return _this.props[on] && closest(event.target, _this.el.nodeName) === _this.el && _this.props[on](event);
};
});
return _this;
}
_createClass(_class2, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
attr.forEach(function (k) {
return _this2.props[k] ? _this2.el[k] = _this2.props[k] : _this2.el.addEventListener(k, _this2[k]);
});
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prev) {
var _this3 = this;
attr.forEach(function (k) {
return prev[k] !== _this3.props[k] && (_this3.el[k] = _this3.props[k]);
});
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var _this4 = this;
attr.forEach(function (k) {
return _this4.el.removeEventListener(k, _this4[k]);
});
}
}, {
key: "render",
value: function render() {
var _this5 = this;
// Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tag, Object.keys(this.props).reduce(function (props, k) {
if (k === 'className') props["class"] = _this5.props[k]; // Fixes className for custom elements
else if (_this5.props[k] === true) props[k] = ''; // Fixes boolean attributes
else if (_this5.props[k] !== false) props[k] = _this5.props[k];
return props;
}, {
ref: this.ref
}));
}
}]);
return _class2;
}(React.Component)
);
}
/**
* getUUID
* @return {String} A generated unique ID
*/
function getUUID() {
return Date.now().toString(36) + Math.random().toString(36).slice(2, 5);
}
/**
* queryAll

@@ -692,4 +599,141 @@ * @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element

var coreDatepicker = elementToReact(CoreDatepicker, 'datepicker.change', 'datepicker.click.day', 'disabled', 'months', 'days');
var version = "3.0.4";
/**
* closest
* @param {Element} element Element to traverse up from
* @param {String} selector A selector to search for matching parents or element itself
* @return {Element|null} Element which is the closest ancestor matching selector
*/
var closest$1 = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;
var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;
return proto.closest ? function (el, css) {
return el.closest(css);
} : function (el, css) {
for (; el; el = el.parentElement) {
if (match.call(el, css)) {
return el;
}
}
return null;
};
}();
/**
* customElementToReact
* @param {Class|Function} elem A custom element definition.
* @param {Array} attr Props and events
* @return {Object} A React component
*/
function customElementToReact(elementClass, options) {
if (options === void 0) options = {};
var name = elementClass.name || String(elementClass).match(/function ([^(]+)/)[1]; // String match for IE11
var dashCase = name.replace(/.[A-Z]/g, function (ref) {
var a = ref[0];
var b = ref[1];
return a + "-" + b;
}); // NameName -> name-name
var customProps = options.props || [];
var customEvents = options.customEvents || [];
var skipProps = customProps.slice(); // Keep a copy
var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();
return (
/*@__PURE__*/
function (superclass) {
function anonymous(props) {
var this$1 = this;
superclass.call(this, props);
this.ref = function (el) {
return this$1.el = el;
};
customEvents.forEach(function (eventName) {
var on = "on" + eventName.replace(/(^|\.)./g, function (m) {
return m.slice(-1).toUpperCase();
}); // input.filter => onInputFilter
this$1[eventName] = function (event) {
return this$1.props[on] && closest$1(event.target, this$1.el.nodeName) === this$1.el && this$1.props[on](event);
};
skipProps.push(on); // Skip props that are customEvents
});
}
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1 = this; // Do not run connectedCallback before after React componentDidMount, to allow React hydration to run first
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
}
customProps.forEach(function (key) {
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]);
});
customEvents.forEach(function (key) {
return this$1.el.addEventListener(key, this$1[key]);
});
};
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1 = this;
customProps.forEach(function (key) {
return prev[key] !== this$1.props[key] && (this$1.el[key] = this$1.props[key]);
});
};
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1 = this;
customEvents.forEach(function (eventName) {
return this$1.el.removeEventListener(eventName, this$1[eventName]);
});
};
anonymous.prototype.render = function render() {
var this$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tagName, Object.keys(this.props).reduce(function (thisProps, key) {
if (skipProps.indexOf(key) === -1) {
// Do not render customEvents and custom props as attributes
if (key === 'className') {
thisProps["class"] = this$1.props[key];
} // Fixes className for custom elements
else if (this$1.props[key] === true) {
thisProps[key] = '';
} // Fixes boolean attributes
else if (this$1.props[key] !== false) {
thisProps[key] = this$1.props[key];
} // Pass only truthy, non-function props
}
return thisProps;
}, {
ref: this.ref
}));
};
return anonymous;
}(React.Component)
);
}
var coreDatepicker = customElementToReact(CoreDatepicker, {
props: ['disabled', 'months', 'days'],
customEvents: ['datepicker.change', 'datepicker.click.day'],
suffix: version
});
return coreDatepicker;

@@ -696,0 +740,0 @@

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

/*! @nrk/core-datepicker v3.0.3 - Copyright (c) 2017-2019 NRK */
/*! @nrk/core-datepicker v3.0.4 - 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 r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}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 i(t,e,n){return(i=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 r=[null];r.push.apply(r,e);var i=new(Function.bind.apply(t,r));return n&&c(i,n.prototype),i}).apply(null,arguments)}function s(t){var r="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!==r){if(r.has(t))return r.get(t);r.set(t,n)}function n(){return i(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function n(t){return String(t||"").replace(/[&<>"'/]/g,function(t){return e[t]})}var r,l,f=(r="undefined"==typeof window?{}:window.Element.prototype,l=r.matches||r.msMatchesSelector||r.webkitMatchesSelector,r.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(l.call(t,e))return t;return null});function h(t,e){var n,r=2<arguments.length&&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=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 m,p=(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(),i=new Date(isFinite(e)&&-1===n.indexOf("now")?Number(e):Date.now()),r=n.match(w)||[],o=r[1];void 0===o&&(o="y");var a=r[2];void 0===a&&(a="m");var u=r[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,r=String(i["get"+b[t]]()+e);f[t]=f[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 h=new Date(f.year,Math.min(12,f.month+1),0).getDate();for(i.setFullYear(f.year,Math.min(11,f.month),Math.max(1,Math.min(h,f.day))),i.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=i.getDate();y?i["set"+b[y]](i["get"+b[y]]()+m):i.setDate(i.getDate()-(i.getDay()||7)+p),"month"!==y&&"year"!==y||g===i.getDate()||i.setDate(0)}return i})}(m={exports:{}},m.exports),m.exports),g={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"},v=function(t){function e(){return o(this,e),d(this,u(e).apply(this,arguments))}var n,r,i;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,i=[{key:"observedAttributes",get:function(){return["timestamp","months","days"]}}],(r=[{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(){if(this._date){if(this.disabled(this.date)&&!this.disabled(this._date))return this.date=this._date;this.diff(this.date)&&h(this,"datepicker.change",this._date=this.date),k("button",this,E),k("select",this,M),k("input",this,_),k("table",this,A)}}},{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)||f(t.target,'[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=f(t.target,"button[value]"),n=f(t.target,"table");e&&(this.date=e.value),e&&n&&h(this,"datepicker.click.day")}else"keydown"===t.type&&f(t.target,"table")&&(this.date=b[t.keyCode],this.querySelector("[autofocus]").focus(),t.preventDefault())}},{key:"diff",value:function(t){return this.parse(t).getTime()-this.timestamp}},{key:"parse",value:function(t,e){return p(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 w(this._date.getMonth()+1)}},{key:"day",get:function(){return w(this._date.getDate())}},{key:"hour",get:function(){return w(this._date.getHours())}},{key:"minute",get:function(){return w(this._date.getMinutes())}},{key:"second",get:function(){return w(this._date.getSeconds())}},{key:"date",get:function(){return p(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,r),i&&a(n,i),e}(),w=function(t){return"0".concat(t).slice(-2)},k=function(t,e,n){return[].forEach.call(document.getElementsByTagName(t),function(t){(e.contains(t)||e.id===t.getAttribute(e.external))&&n(e,t,e._date)})};function E(t,e){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)):g[n]&&(e.setAttribute("type","number"),e.setAttribute("data-type",n),e.value=t[n])}function A(i,t){t.firstElementChild||(t.innerHTML="\n <caption></caption><thead><tr><th>".concat(i.days.map(n).join("</th><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=i.date.getMonth(),u=i.parse("y-m-1 mon");t.caption.textContent="".concat(i.months[a],", ").concat(i.year),y("button",t).forEach(function(t){var e=!i.diff(u),n=u.getDate(),r=u.getMonth();t.textContent=n,t.value="".concat(u.getFullYear(),"-").concat(r+1,"-").concat(n),t.disabled=i.disabled(u),t.tabIndex=e-1,t.setAttribute("data-adjacent",a!==r),t.setAttribute("aria-label","".concat(n,". ").concat(i.months[r])),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 M(e,t){t.firstElementChild||(t.innerHTML=e.months.map(function(t,e){return'<option value="y-'.concat(e+1,'-d">').concat(n(t),"</option>")}).join("")),y(t.children).forEach(function(t){t.disabled=e.disabled(t.value),t.selected=!e.diff(t.value)})}return v}),window.customElements.define("core-datepicker",coreDatepicker);
//# sourceMappingURL=core-datepicker.min.js.map

@@ -252,96 +252,3 @@ 'use strict';

}
function elementToReact(elementClass) {
for (var _len = arguments.length, attr = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
attr[_key - 1] = arguments[_key];
}
var name = elementClass.name || String(elementClass).match(/function ([^(]+)/)[1]; // String match for IE11
var tag = "".concat(name.replace(/\W+/, '-'), "-").concat(getUUID()).toLowerCase();
if (IS_BROWSER && !window.customElements.get(tag)) window.customElements.define(tag, elementClass);
return (
/*#__PURE__*/
function (_React$Component) {
_inherits(_class2, _React$Component);
function _class2(props) {
var _this;
_classCallCheck(this, _class2);
_this = _possibleConstructorReturn(this, _getPrototypeOf(_class2).call(this, props));
_this.ref = function (el) {
return _this.el = el;
};
attr.forEach(function (k) {
var on = "on".concat(k.replace(/(^|\.)./g, function (m) {
return m.slice(-1).toUpperCase();
})); // input.filter => onInputFilter
_this[k] = function (event) {
return _this.props[on] && closest(event.target, _this.el.nodeName) === _this.el && _this.props[on](event);
};
});
return _this;
}
_createClass(_class2, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
attr.forEach(function (k) {
return _this2.props[k] ? _this2.el[k] = _this2.props[k] : _this2.el.addEventListener(k, _this2[k]);
});
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prev) {
var _this3 = this;
attr.forEach(function (k) {
return prev[k] !== _this3.props[k] && (_this3.el[k] = _this3.props[k]);
});
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
var _this4 = this;
attr.forEach(function (k) {
return _this4.el.removeEventListener(k, _this4[k]);
});
}
}, {
key: "render",
value: function render() {
var _this5 = this;
// Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tag, Object.keys(this.props).reduce(function (props, k) {
if (k === 'className') props["class"] = _this5.props[k]; // Fixes className for custom elements
else if (_this5.props[k] === true) props[k] = ''; // Fixes boolean attributes
else if (_this5.props[k] !== false) props[k] = _this5.props[k];
return props;
}, {
ref: this.ref
}));
}
}]);
return _class2;
}(React.Component)
);
}
/**
* getUUID
* @return {String} A generated unique ID
*/
function getUUID() {
return Date.now().toString(36) + Math.random().toString(36).slice(2, 5);
}
/**
* queryAll

@@ -690,4 +597,141 @@ * @param {String|NodeList|Array|Element} elements A CSS selector string, nodeList, element array, or single element

var coreDatepicker = elementToReact(CoreDatepicker, 'datepicker.change', 'datepicker.click.day', 'disabled', 'months', 'days');
var version = "3.0.4";
/**
* closest
* @param {Element} element Element to traverse up from
* @param {String} selector A selector to search for matching parents or element itself
* @return {Element|null} Element which is the closest ancestor matching selector
*/
var closest$1 = function () {
var proto = typeof window === 'undefined' ? {} : window.Element.prototype;
var match = proto.matches || proto.msMatchesSelector || proto.webkitMatchesSelector;
return proto.closest ? function (el, css) {
return el.closest(css);
} : function (el, css) {
for (; el; el = el.parentElement) {
if (match.call(el, css)) {
return el;
}
}
return null;
};
}();
/**
* customElementToReact
* @param {Class|Function} elem A custom element definition.
* @param {Array} attr Props and events
* @return {Object} A React component
*/
function customElementToReact(elementClass, options) {
if (options === void 0) options = {};
var name = elementClass.name || String(elementClass).match(/function ([^(]+)/)[1]; // String match for IE11
var dashCase = name.replace(/.[A-Z]/g, function (ref) {
var a = ref[0];
var b = ref[1];
return a + "-" + b;
}); // NameName -> name-name
var customProps = options.props || [];
var customEvents = options.customEvents || [];
var skipProps = customProps.slice(); // Keep a copy
var tagName = (dashCase + "-" + (options.suffix || 'react')).replace(/\W+/g, '-').toLowerCase();
return (
/*@__PURE__*/
function (superclass) {
function anonymous(props) {
var this$1 = this;
superclass.call(this, props);
this.ref = function (el) {
return this$1.el = el;
};
customEvents.forEach(function (eventName) {
var on = "on" + eventName.replace(/(^|\.)./g, function (m) {
return m.slice(-1).toUpperCase();
}); // input.filter => onInputFilter
this$1[eventName] = function (event) {
return this$1.props[on] && closest$1(event.target, this$1.el.nodeName) === this$1.el && this$1.props[on](event);
};
skipProps.push(on); // Skip props that are customEvents
});
}
if (superclass) anonymous.__proto__ = superclass;
anonymous.prototype = Object.create(superclass && superclass.prototype);
anonymous.prototype.constructor = anonymous;
anonymous.prototype.componentDidMount = function componentDidMount() {
var this$1 = this; // Do not run connectedCallback before after React componentDidMount, to allow React hydration to run first
if (!window.customElements.get(tagName)) {
window.customElements.define(tagName, elementClass);
}
customProps.forEach(function (key) {
return this$1.props.hasOwnProperty(key) && (this$1.el[key] = this$1.props[key]);
});
customEvents.forEach(function (key) {
return this$1.el.addEventListener(key, this$1[key]);
});
};
anonymous.prototype.componentDidUpdate = function componentDidUpdate(prev) {
var this$1 = this;
customProps.forEach(function (key) {
return prev[key] !== this$1.props[key] && (this$1.el[key] = this$1.props[key]);
});
};
anonymous.prototype.componentWillUnmount = function componentWillUnmount() {
var this$1 = this;
customEvents.forEach(function (eventName) {
return this$1.el.removeEventListener(eventName, this$1[eventName]);
});
};
anonymous.prototype.render = function render() {
var this$1 = this; // Convert React props to CustomElement props https://github.com/facebook/react/issues/12810
return React.createElement(tagName, Object.keys(this.props).reduce(function (thisProps, key) {
if (skipProps.indexOf(key) === -1) {
// Do not render customEvents and custom props as attributes
if (key === 'className') {
thisProps["class"] = this$1.props[key];
} // Fixes className for custom elements
else if (this$1.props[key] === true) {
thisProps[key] = '';
} // Fixes boolean attributes
else if (this$1.props[key] !== false) {
thisProps[key] = this$1.props[key];
} // Pass only truthy, non-function props
}
return thisProps;
}, {
ref: this.ref
}));
};
return anonymous;
}(React.Component)
);
}
var coreDatepicker = customElementToReact(CoreDatepicker, {
props: ['disabled', 'months', 'days'],
customEvents: ['datepicker.change', 'datepicker.click.day'],
suffix: version
});
module.exports = coreDatepicker;

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet