@nrk/core-input
Advanced tools
Comparing version 1.4.0 to 1.4.1
'use strict'; | ||
var name = "@nrk/core-input"; | ||
var version = "1.4.0"; | ||
var version = "1.4.1"; | ||
@@ -226,3 +226,3 @@ var IS_BROWSER = typeof window !== 'undefined'; | ||
item.setAttribute('type', 'button'); | ||
if (index >= limit) { item.parentElement.setAttribute('hidden', ''); } | ||
if (limit && (index >= limit)) { item.parentElement.setAttribute('hidden', ''); } | ||
} | ||
@@ -229,0 +229,0 @@ |
@@ -120,3 +120,3 @@ import { name, version } from './package.json' | ||
item.setAttribute('type', 'button') | ||
if (index >= limit) item.parentElement.setAttribute('hidden', '') | ||
if (limit && (index >= limit)) item.parentElement.setAttribute('hidden', '') | ||
} | ||
@@ -123,0 +123,0 @@ |
@@ -1,3 +0,3 @@ | ||
/*! @nrk/core-input v1.3.1 - Copyright (c) 2017-2019 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).CoreInput=t(e.React,e.PropTypes)}(this,function(i,e){"use strict";i=i&&i.hasOwnProperty("default")?i.default:i,e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof window,u=(t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform))),o=function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}();function n(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(o||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var r={"&":"&","<":"<",">":">",'"':""","/":"/","'":"'"};function a(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return r[e]})}var l="prevent_recursive_dispatch_maximum_callstack";function c(e,t,n){void 0===n&&(n={});var r,o=""+l+t;if(e[o])return!0;e[o]=!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[o]=null,i}function p(e){(window.requestAnimationFrame||window.setTimeout)(e)}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[]}var d="data-@nrk/core-input-1.4.0".replace(/\W+/g,"-"),f=13,m=27,v=33,h=34,b=35,g=36,x=38,y=40,E=500;function A(e,t){var o="object"==typeof t?t:{content:t},i="string"==typeof o.content,a=Math.max(o.limit,0)||0;return s(e).map(function(e){var t=e.nextElementSibling,n=void 0===o.ajax?e.getAttribute(d):o.ajax,r=void 0===o.open?e===document.activeElement:o.open;return e.setAttribute(d,n||""),e.setAttribute(d+"-limit",a),e.setAttribute(u?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),i&&(t.innerHTML=o.content),s("a,button",t).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[a].concat(e))}),j(e,r),e})}function w(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||s("["+d+"]").forEach(function(e){var t,n,r=e.nextElementSibling,o=e===a.target||r.contains(a.target),i="click"===a.type&&o&&s('[tabindex="-1"]',r).filter(function(e){return e.contains(a.target)})[0];i?(t=e,n={relatedTarget:r,currentTarget:i,value:i.value||i.textContent.trim()},c(t,"input.select",n)&&(t.value=n.value,t.focus(),p(function(){return j(t,!1)}))):j(e,o)})}function S(e,t){var n=e.nextElementSibling,r=[e].concat(s('[tabindex="-1"]:not([hidden])',n)),o=t.keyCode===m&&"true"===e.getAttribute("aria-expanded"),i=r.indexOf(document.activeElement),a=!1;t.keyCode===y?a=r[i+1]||r[0]:t.keyCode===x?a=r[i-1]||r.pop():n.contains(t.target)&&(t.keyCode===b||t.keyCode===h?a=r.pop():t.keyCode===g||t.keyCode===v?a=r[1]:t.keyCode!==f&&e.focus()),j(e,t.keyCode!==m),(!1!==a||o)&&t.preventDefault(),a&&a.focus()}function j(e,t){void 0===t&&(t="true"===e.getAttribute("aria-expanded")),p(function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)})}function C(e,t,n,r){t.setAttribute("aria-label",t.textContent.trim()+", "+(n+1)+" av "+r.length),t.setAttribute("tabindex","-1"),t.setAttribute("type","button"),e<=n&&t.parentElement.setAttribute("hidden","")}function L(e){var t=e.getAttribute(d),n=L.xhr=L.xhr||new window.XMLHttpRequest;if(!t)return!1;clearTimeout(L.timer),n.abort(),n.onload=function(){try{n.responseJSON=JSON.parse(n.responseText)}catch(e){n.responseJSON=!1}c(e,"input.ajax",n)},L.timer=setTimeout(function(){e.value&&c(e,"input.ajax.beforeSend",n)&&(n.open("GET",t.replace("{{value}}",window.encodeURIComponent(e.value)),!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.send())},E)}A.escapeHTML=a,A.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return a(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(d,"click",w),n(d,"focus",w,!0),n(d,"input",function(e){var a,t,n,r=e.target;r.hasAttribute(d)&&(t={relatedTarget:(a=r).nextElementSibling},n=Number(a.getAttribute(d+"-limit"))||1/0,c(a,"input.filter",t)&&!1===L(a)&&s('[tabindex="-1"]',a.nextElementSibling).reduce(function(e,t,n){var r="LI"===t.parentElement.nodeName&&t.parentElement,o=-1!==t.textContent.toLowerCase().indexOf(a.value.toLowerCase()),i=o?"removeAttribute":"setAttribute";return r&&r[i]("hidden",""),t[i]("hidden",""),o?e.concat(t):e},[]).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[n].concat(e))}))}),n(d,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(d))return S(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(d))return S(n,e)}},!0);var k=function(n){function t(e){var t=this;n.call(this,e),this.onFilter=function(e){return t.props.onFilter&&t.props.onFilter(e)},this.onSelect=function(e){return t.props.onSelect&&t.props.onSelect(e)},this.onAjaxBeforeSend=function(e){return t.props.onAjaxBeforeSend&&t.props.onAjaxBeforeSend(e)},this.onAjax=function(e){return t.props.onAjax&&t.props.onAjax(e)}}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{open:null,limit:null,ajax:null,onAjax:null,onAjaxBeforeSend:null,onFilter:null,onSelect:null}},t.prototype.componentDidMount=function(){this.el.addEventListener("input.filter",this.onFilter),this.el.addEventListener("input.select",this.onSelect),this.el.addEventListener("input.ajax.beforeSend",this.onAjaxBeforeSend),this.el.addEventListener("input.ajax",this.onAjax),A(this.el.firstElementChild,this.props)},t.prototype.componentDidUpdate=function(){A(this.el.firstElementChild)},t.prototype.componentWillUnmount=function(){this.el.removeEventListener("input.filter",this.onFilter),this.el.removeEventListener("input.select",this.onSelect),this.el.removeEventListener("input.beforeSend",this.onAjaxBeforeSend),this.el.removeEventListener("input.ajax",this.onAjax)},t.prototype.render=function(){var n,r,e,o=this;return i.createElement("div",(n=this.props,r=t.defaultProps,void 0===(e={ref:function(e){return o.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e)),i.Children.map(this.props.children,function(e,t){return 0===t?i.cloneElement(e,{"aria-expanded":String(Boolean(o.props.open))}):1===t?i.cloneElement(e,{hidden:!o.props.open}):e}))},Object.defineProperties(t,e),t}(i.Component);return k.Highlight=function(e){var t=e.text,n=e.query;return void 0===n&&(n=""),i.createElement("span",{dangerouslySetInnerHTML:{__html:A.highlight(t,n)}})},k.propTypes={onFilter:e.func,onSelect:e.func,onAjax:e.func,open:e.bool,limit:e.number,ajax:e.oneOfType([e.string,e.object])},k}); | ||
/*! @nrk/core-input v1.4.0 - Copyright (c) 2017-2019 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react"),require("prop-types")):"function"==typeof define&&define.amd?define(["react","prop-types"],t):(e=e||self).CoreInput=t(e.React,e.PropTypes)}(this,function(i,e){"use strict";i=i&&i.hasOwnProperty("default")?i.default:i,e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof window,u=(t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform))),o=function(e){void 0===e&&(e=!1);try{window.addEventListener("test",null,{get passive(){e=!0}})}catch(e){}return e}();function n(e,t,n,r){(void 0===r&&(r=!1),"undefined"==typeof window||window[e=e+"-"+t])||(o||"object"!=typeof r||(r=Boolean(r.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,r))}var r={"&":"&","<":"<",">":">",'"':""","/":"/","'":"'"};function a(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return r[e]})}var l="prevent_recursive_dispatch_maximum_callstack";function c(e,t,n){void 0===n&&(n={});var r,o=""+l+t;if(e[o])return!0;e[o]=!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[o]=null,i}function p(e){(window.requestAnimationFrame||window.setTimeout)(e)}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[]}var d="data-@nrk/core-input-1.4.1".replace(/\W+/g,"-"),f=13,m=27,v=33,h=34,b=35,g=36,x=38,y=40,E=500;function A(e,t){var o="object"==typeof t?t:{content:t},i="string"==typeof o.content,a=Math.max(o.limit,0)||0;return s(e).map(function(e){var t=e.nextElementSibling,n=void 0===o.ajax?e.getAttribute(d):o.ajax,r=void 0===o.open?e===document.activeElement:o.open;return e.setAttribute(d,n||""),e.setAttribute(d+"-limit",a),e.setAttribute(u?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),i&&(t.innerHTML=o.content),s("a,button",t).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[a].concat(e))}),j(e,r),e})}function w(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||s("["+d+"]").forEach(function(e){var t,n,r=e.nextElementSibling,o=e===a.target||r.contains(a.target),i="click"===a.type&&o&&s('[tabindex="-1"]',r).filter(function(e){return e.contains(a.target)})[0];i?(t=e,n={relatedTarget:r,currentTarget:i,value:i.value||i.textContent.trim()},c(t,"input.select",n)&&(t.value=n.value,t.focus(),p(function(){return j(t,!1)}))):j(e,o)})}function S(e,t){var n=e.nextElementSibling,r=[e].concat(s('[tabindex="-1"]:not([hidden])',n)),o=t.keyCode===m&&"true"===e.getAttribute("aria-expanded"),i=r.indexOf(document.activeElement),a=!1;t.keyCode===y?a=r[i+1]||r[0]:t.keyCode===x?a=r[i-1]||r.pop():n.contains(t.target)&&(t.keyCode===b||t.keyCode===h?a=r.pop():t.keyCode===g||t.keyCode===v?a=r[1]:t.keyCode!==f&&e.focus()),j(e,t.keyCode!==m),(!1!==a||o)&&t.preventDefault(),a&&a.focus()}function j(e,t){void 0===t&&(t="true"===e.getAttribute("aria-expanded")),p(function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)})}function C(e,t,n,r){t.setAttribute("aria-label",t.textContent.trim()+", "+(n+1)+" av "+r.length),t.setAttribute("tabindex","-1"),t.setAttribute("type","button"),e&&e<=n&&t.parentElement.setAttribute("hidden","")}function L(e){var t=e.getAttribute(d),n=L.xhr=L.xhr||new window.XMLHttpRequest;if(!t)return!1;clearTimeout(L.timer),n.abort(),n.onload=function(){try{n.responseJSON=JSON.parse(n.responseText)}catch(e){n.responseJSON=!1}c(e,"input.ajax",n)},L.timer=setTimeout(function(){e.value&&c(e,"input.ajax.beforeSend",n)&&(n.open("GET",t.replace("{{value}}",window.encodeURIComponent(e.value)),!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.send())},E)}A.escapeHTML=a,A.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return a(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(d,"click",w),n(d,"focus",w,!0),n(d,"input",function(e){var a,t,n,r=e.target;r.hasAttribute(d)&&(t={relatedTarget:(a=r).nextElementSibling},n=Number(a.getAttribute(d+"-limit"))||1/0,c(a,"input.filter",t)&&!1===L(a)&&s('[tabindex="-1"]',a.nextElementSibling).reduce(function(e,t,n){var r="LI"===t.parentElement.nodeName&&t.parentElement,o=-1!==t.textContent.toLowerCase().indexOf(a.value.toLowerCase()),i=o?"removeAttribute":"setAttribute";return r&&r[i]("hidden",""),t[i]("hidden",""),o?e.concat(t):e},[]).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[n].concat(e))}))}),n(d,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(d))return S(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(d))return S(n,e)}},!0);var k=function(n){function t(e){var t=this;n.call(this,e),this.onFilter=function(e){return t.props.onFilter&&t.props.onFilter(e)},this.onSelect=function(e){return t.props.onSelect&&t.props.onSelect(e)},this.onAjaxBeforeSend=function(e){return t.props.onAjaxBeforeSend&&t.props.onAjaxBeforeSend(e)},this.onAjax=function(e){return t.props.onAjax&&t.props.onAjax(e)}}n&&(t.__proto__=n),(t.prototype=Object.create(n&&n.prototype)).constructor=t;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{open:null,limit:null,ajax:null,onAjax:null,onAjaxBeforeSend:null,onFilter:null,onSelect:null}},t.prototype.componentDidMount=function(){this.el.addEventListener("input.filter",this.onFilter),this.el.addEventListener("input.select",this.onSelect),this.el.addEventListener("input.ajax.beforeSend",this.onAjaxBeforeSend),this.el.addEventListener("input.ajax",this.onAjax),A(this.el.firstElementChild,this.props)},t.prototype.componentDidUpdate=function(){A(this.el.firstElementChild)},t.prototype.componentWillUnmount=function(){this.el.removeEventListener("input.filter",this.onFilter),this.el.removeEventListener("input.select",this.onSelect),this.el.removeEventListener("input.beforeSend",this.onAjaxBeforeSend),this.el.removeEventListener("input.ajax",this.onAjax)},t.prototype.render=function(){var n,r,e,o=this;return i.createElement("div",(n=this.props,r=t.defaultProps,void 0===(e={ref:function(e){return o.el=e}})&&(e={}),Object.keys(n).reduce(function(e,t){return r.hasOwnProperty(t)||(e[t]=n[t]),e},e)),i.Children.map(this.props.children,function(e,t){return 0===t?i.cloneElement(e,{"aria-expanded":String(Boolean(o.props.open))}):1===t?i.cloneElement(e,{hidden:!o.props.open}):e}))},Object.defineProperties(t,e),t}(i.Component);return k.Highlight=function(e){var t=e.text,n=e.query;return void 0===n&&(n=""),i.createElement("span",{dangerouslySetInnerHTML:{__html:A.highlight(t,n)}})},k.propTypes={onFilter:e.func,onSelect:e.func,onAjax:e.func,open:e.bool,limit:e.number,ajax:e.oneOfType([e.string,e.object])},k}); | ||
//# sourceMappingURL=core-input.jsx.js.map |
@@ -1,3 +0,3 @@ | ||
/*! @nrk/core-input v1.3.1 - Copyright (c) 2017-2019 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).coreInput=t()}(this,function(){"use strict";var e="undefined"!=typeof window,u=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform))),r=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,i){(void 0===i&&(i=!1),"undefined"==typeof window||window[e=e+"-"+t])||(r||"object"!=typeof i||(i=Boolean(i.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,i))}var n={"&":"&","<":"<",">":">",'"':""","/":"/","'":"'"};function i(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var a="prevent_recursive_dispatch_maximum_callstack";function c(e,t,n){void 0===n&&(n={});var i,r=""+a+t;if(e[r])return!0;e[r]=!0,"function"==typeof window.CustomEvent?i=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var o=e.dispatchEvent(i);return e[r]=null,o}function d(e){(window.requestAnimationFrame||window.setTimeout)(e)}function l(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[]}var f="data-@nrk/core-input-1.4.0".replace(/\W+/g,"-"),s=13,p=27,m=33,v=34,b=35,g=36,y=38,x=40,o=500;function w(e,t){var r="object"==typeof t?t:{content:t},o="string"==typeof r.content,a=Math.max(r.limit,0)||0;return l(e).map(function(e){var t=e.nextElementSibling,n=void 0===r.ajax?e.getAttribute(f):r.ajax,i=void 0===r.open?e===document.activeElement:r.open;return e.setAttribute(f,n||""),e.setAttribute(f+"-limit",a),e.setAttribute(u?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),o&&(t.innerHTML=r.content),l("a,button",t).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[a].concat(e))}),E(e,i),e})}function h(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||l("["+f+"]").forEach(function(e){var t,n,i=e.nextElementSibling,r=e===a.target||i.contains(a.target),o="click"===a.type&&r&&l('[tabindex="-1"]',i).filter(function(e){return e.contains(a.target)})[0];o?(t=e,n={relatedTarget:i,currentTarget:o,value:o.value||o.textContent.trim()},c(t,"input.select",n)&&(t.value=n.value,t.focus(),d(function(){return E(t,!1)}))):E(e,r)})}function A(e,t){var n=e.nextElementSibling,i=[e].concat(l('[tabindex="-1"]:not([hidden])',n)),r=t.keyCode===p&&"true"===e.getAttribute("aria-expanded"),o=i.indexOf(document.activeElement),a=!1;t.keyCode===x?a=i[o+1]||i[0]:t.keyCode===y?a=i[o-1]||i.pop():n.contains(t.target)&&(t.keyCode===b||t.keyCode===v?a=i.pop():t.keyCode===g||t.keyCode===m?a=i[1]:t.keyCode!==s&&e.focus()),E(e,t.keyCode!==p),(!1!==a||r)&&t.preventDefault(),a&&a.focus()}function E(e,t){void 0===t&&(t="true"===e.getAttribute("aria-expanded")),d(function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)})}function C(e,t,n,i){t.setAttribute("aria-label",t.textContent.trim()+", "+(n+1)+" av "+i.length),t.setAttribute("tabindex","-1"),t.setAttribute("type","button"),e<=n&&t.parentElement.setAttribute("hidden","")}function k(e){var t=e.getAttribute(f),n=k.xhr=k.xhr||new window.XMLHttpRequest;if(!t)return!1;clearTimeout(k.timer),n.abort(),n.onload=function(){try{n.responseJSON=JSON.parse(n.responseText)}catch(e){n.responseJSON=!1}c(e,"input.ajax",n)},k.timer=setTimeout(function(){e.value&&c(e,"input.ajax.beforeSend",n)&&(n.open("GET",t.replace("{{value}}",window.encodeURIComponent(e.value)),!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.send())},o)}return w.escapeHTML=i,w.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return i(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},t(f,"click",h),t(f,"focus",h,!0),t(f,"input",function(e){var a,t,n,i=e.target;i.hasAttribute(f)&&(t={relatedTarget:(a=i).nextElementSibling},n=Number(a.getAttribute(f+"-limit"))||1/0,c(a,"input.filter",t)&&!1===k(a)&&l('[tabindex="-1"]',a.nextElementSibling).reduce(function(e,t,n){var i="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(a.value.toLowerCase()),o=r?"removeAttribute":"setAttribute";return i&&i[o]("hidden",""),t[o]("hidden",""),r?e.concat(t):e},[]).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[n].concat(e))}))}),t(f,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(f))return A(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(f))return A(n,e)}},!0),w}); | ||
/*! @nrk/core-input v1.4.0 - Copyright (c) 2017-2019 NRK */ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).coreInput=t()}(this,function(){"use strict";var e="undefined"!=typeof window,u=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform))),r=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,i){(void 0===i&&(i=!1),"undefined"==typeof window||window[e=e+"-"+t])||(r||"object"!=typeof i||(i=Boolean(i.capture)),("resize"===t||"load"===t?window:document).addEventListener(window[e]=t,n,i))}var n={"&":"&","<":"<",">":">",'"':""","/":"/","'":"'"};function i(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var a="prevent_recursive_dispatch_maximum_callstack";function c(e,t,n){void 0===n&&(n={});var i,r=""+a+t;if(e[r])return!0;e[r]=!0,"function"==typeof window.CustomEvent?i=new window.CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,n);var o=e.dispatchEvent(i);return e[r]=null,o}function d(e){(window.requestAnimationFrame||window.setTimeout)(e)}function l(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[]}var f="data-@nrk/core-input-1.4.1".replace(/\W+/g,"-"),s=13,p=27,m=33,v=34,b=35,g=36,y=38,x=40,o=500;function w(e,t){var r="object"==typeof t?t:{content:t},o="string"==typeof r.content,a=Math.max(r.limit,0)||0;return l(e).map(function(e){var t=e.nextElementSibling,n=void 0===r.ajax?e.getAttribute(f):r.ajax,i=void 0===r.open?e===document.activeElement:r.open;return e.setAttribute(f,n||""),e.setAttribute(f+"-limit",a),e.setAttribute(u?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),o&&(t.innerHTML=r.content),l("a,button",t).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[a].concat(e))}),E(e,i),e})}function h(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||l("["+f+"]").forEach(function(e){var t,n,i=e.nextElementSibling,r=e===a.target||i.contains(a.target),o="click"===a.type&&r&&l('[tabindex="-1"]',i).filter(function(e){return e.contains(a.target)})[0];o?(t=e,n={relatedTarget:i,currentTarget:o,value:o.value||o.textContent.trim()},c(t,"input.select",n)&&(t.value=n.value,t.focus(),d(function(){return E(t,!1)}))):E(e,r)})}function A(e,t){var n=e.nextElementSibling,i=[e].concat(l('[tabindex="-1"]:not([hidden])',n)),r=t.keyCode===p&&"true"===e.getAttribute("aria-expanded"),o=i.indexOf(document.activeElement),a=!1;t.keyCode===x?a=i[o+1]||i[0]:t.keyCode===y?a=i[o-1]||i.pop():n.contains(t.target)&&(t.keyCode===b||t.keyCode===v?a=i.pop():t.keyCode===g||t.keyCode===m?a=i[1]:t.keyCode!==s&&e.focus()),E(e,t.keyCode!==p),(!1!==a||r)&&t.preventDefault(),a&&a.focus()}function E(e,t){void 0===t&&(t="true"===e.getAttribute("aria-expanded")),d(function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)})}function C(e,t,n,i){t.setAttribute("aria-label",t.textContent.trim()+", "+(n+1)+" av "+i.length),t.setAttribute("tabindex","-1"),t.setAttribute("type","button"),e&&e<=n&&t.parentElement.setAttribute("hidden","")}function k(e){var t=e.getAttribute(f),n=k.xhr=k.xhr||new window.XMLHttpRequest;if(!t)return!1;clearTimeout(k.timer),n.abort(),n.onload=function(){try{n.responseJSON=JSON.parse(n.responseText)}catch(e){n.responseJSON=!1}c(e,"input.ajax",n)},k.timer=setTimeout(function(){e.value&&c(e,"input.ajax.beforeSend",n)&&(n.open("GET",t.replace("{{value}}",window.encodeURIComponent(e.value)),!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.send())},o)}return w.escapeHTML=i,w.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return i(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},t(f,"click",h),t(f,"focus",h,!0),t(f,"input",function(e){var a,t,n,i=e.target;i.hasAttribute(f)&&(t={relatedTarget:(a=i).nextElementSibling},n=Number(a.getAttribute(f+"-limit"))||1/0,c(a,"input.filter",t)&&!1===k(a)&&l('[tabindex="-1"]',a.nextElementSibling).reduce(function(e,t,n){var i="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(a.value.toLowerCase()),o=r?"removeAttribute":"setAttribute";return i&&i[o]("hidden",""),t[o]("hidden",""),r?e.concat(t):e},[]).forEach(function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return C.apply(void 0,[n].concat(e))}))}),t(f,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(f))return A(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(f))return A(n,e)}},!0),w}); | ||
//# sourceMappingURL=core-input.min.js.map |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var name = "@nrk/core-input"; | ||
var version = "1.4.0"; | ||
var version = "1.4.1"; | ||
@@ -247,3 +247,3 @@ var IS_BROWSER = typeof window !== 'undefined'; | ||
item.setAttribute('type', 'button'); | ||
if (index >= limit) { item.parentElement.setAttribute('hidden', ''); } | ||
if (limit && (index >= limit)) { item.parentElement.setAttribute('hidden', ''); } | ||
} | ||
@@ -250,0 +250,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "core-input.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
140350
1