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

@nrk/core-input

Package Overview
Dependencies
Maintainers
121
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrk/core-input - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

6

core-input.cjs.js
'use strict';
var name = "@nrk/core-input";
var version = "1.2.1";
var version = "1.2.2";

@@ -108,2 +108,3 @@ var IS_BROWSER = typeof window !== 'undefined';

var ajax = typeof options.ajax === 'undefined' ? input.getAttribute(UUID) : options.ajax;
var open = typeof options.open === 'undefined' ? input === document.activeElement : options.open;

@@ -117,3 +118,4 @@ input.setAttribute(UUID, ajax || '');

queryAll('a,button', list).forEach(setupItem);
setupExpand(input, options.open);
setupExpand(input, open);
return input

@@ -120,0 +122,0 @@ })

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

const ajax = typeof options.ajax === 'undefined' ? input.getAttribute(UUID) : options.ajax
const open = typeof options.open === 'undefined' ? input === document.activeElement : options.open

@@ -25,3 +26,4 @@ input.setAttribute(UUID, ajax || '')

queryAll('a,button', list).forEach(setupItem)
setupExpand(input, options.open)
setupExpand(input, open)
return input

@@ -28,0 +30,0 @@ })

@@ -7,8 +7,9 @@ import React from 'react'

export default class Input extends React.Component {
static get defaultProps () { return { open: null, ajax: null, onAjax: null, onFilter: null, onSelect: null } }
static get defaultProps () { return { open: null, ajax: null, onAjax: null, onAjaxBeforeSend: null, onFilter: null, onSelect: null } }
constructor (props) {
super(props)
this.onFilter = this.onFilter.bind(this)
this.onSelect = this.onSelect.bind(this)
this.onAjax = this.onAjax.bind(this)
this.onFilter = (event) => this.props.onFilter && this.props.onFilter(event)
this.onSelect = (event) => this.props.onSelect && this.props.onSelect(event)
this.onAjaxBeforeSend = (event) => this.props.onAjaxBeforeSend && this.props.onAjaxBeforeSend(event)
this.onAjax = (event) => this.props.onAjax && this.props.onAjax(event)
}

@@ -18,2 +19,3 @@ componentDidMount () { // Mount client side only to avoid rerender

this.el.addEventListener('input.select', this.onSelect)
this.el.addEventListener('input.ajax.beforeSend', this.onAjaxBeforeSend)
this.el.addEventListener('input.ajax', this.onAjax)

@@ -26,7 +28,5 @@ coreInput(this.el.firstElementChild, this.props)

this.el.removeEventListener('input.select', this.onSelect)
this.el.removeEventListener('input.beforeSend', this.onAjaxBeforeSend)
this.el.removeEventListener('input.ajax', this.onAjax)
}
onFilter (event) { this.props.onFilter && this.props.onFilter(event) }
onSelect (event) { this.props.onSelect && this.props.onSelect(event) }
onAjax (event) { this.props.onAjax && this.props.onAjax(event) }
render () {

@@ -33,0 +33,0 @@ return React.createElement('div', exclude(this.props, Input.defaultProps, { ref: el => (this.el = el) }),

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

/*! @nrk/core-input v1.2.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(a,e){"use strict";a=a&&a.hasOwnProperty("default")?a.default:a,e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof window,i=(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function u(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return r[e]})}var l="prevent_recursive_dispatch_maximum_callstack";function s(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 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[]}var p="data-@nrk/core-input-1.2.1".replace(/\W+/g,"-"),d=13,f=27,h=33,v=34,m=35,b=36,y=38,g=40,x='[tabindex="-1"]',E=500;function w(e,t){var r="object"==typeof t?t:{content:t},o="string"==typeof r.content;return c(e).map(function(e){var t=e.nextElementSibling,n=void 0===r.ajax?e.getAttribute(p):r.ajax;return e.setAttribute(p,n||""),e.setAttribute(i?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),o&&(t.innerHTML=r.content),c("a,button",t).forEach(C),j(e,r.open),e})}function A(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||c("["+p+"]").forEach(function(e){var t,n,r=e.nextElementSibling,o=e===a.target||r.contains(a.target),i="click"===a.type&&o&&c(x,r).filter(function(e){return e.contains(a.target)})[0];i?(t=e,n={relatedTarget:r,currentTarget:i,value:i.value||i.textContent.trim()},s(t,"input.select",n)&&(t.value=n.value,t.focus(),j(t,!1))):j(e,o)})}function S(e,t){var n=e.nextElementSibling,r=[e].concat(c(x+":not([hidden])",n)),o=t.keyCode===f&&"true"===e.getAttribute("aria-expanded"),i=r.indexOf(document.activeElement),a=!1;t.keyCode===g?a=r[i+1]||r[0]:t.keyCode===y?a=r[i-1]||r.pop():n.contains(t.target)&&(t.keyCode===m||t.keyCode===v?a=r.pop():t.keyCode===b||t.keyCode===h?a=r[1]:t.keyCode!==d&&e.focus()),j(e,t.keyCode!==f),(!1!==a||o)&&t.preventDefault(),a&&a.focus()}function j(e,t){var n;void 0===t&&(t="true"===e.getAttribute("aria-expanded")),n=function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)},(window.requestAnimationFrame||window.setTimeout)(n)}function C(e,t,n){e.setAttribute("aria-label",e.textContent.trim()+", "+(t+1)+" av "+n.length),e.setAttribute("tabindex","-1"),e.setAttribute("type","button")}function k(e){var t=e.getAttribute(p),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}s(e,"input.ajax",n)},k.timer=setTimeout(function(){e.value&&s(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)}w.escapeHTML=u,w.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return u(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(p,"click",A),n(p,"focus",A,!0),n(p,"input",function(e){var i,t,n=e.target;n.hasAttribute(p)&&(t={relatedTarget:(i=n).nextElementSibling},s(i,"input.filter",t)&&!1===k(i)&&c(x,i.nextElementSibling).reduce(function(e,t){var n="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(i.value.toLowerCase()),o=r?"removeAttribute":"setAttribute";return n&&n[o]("hidden",""),t[o]("hidden",""),r?e.concat(t):e},[]).forEach(C))}),n(p,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(p))return S(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(p))return S(n,e)}},!0);var L=function(t){function i(e){t.call(this,e),this.onFilter=this.onFilter.bind(this),this.onSelect=this.onSelect.bind(this),this.onAjax=this.onAjax.bind(this)}t&&(i.__proto__=t),(i.prototype=Object.create(t&&t.prototype)).constructor=i;var e={defaultProps:{configurable:!0}};return e.defaultProps.get=function(){return{open:null,ajax:null,onAjax:null,onFilter:null,onSelect:null}},i.prototype.componentDidMount=function(){this.el.addEventListener("input.filter",this.onFilter),this.el.addEventListener("input.select",this.onSelect),this.el.addEventListener("input.ajax",this.onAjax),w(this.el.firstElementChild,this.props)},i.prototype.componentDidUpdate=function(){w(this.el.firstElementChild)},i.prototype.componentWillUnmount=function(){this.el.removeEventListener("input.filter",this.onFilter),this.el.removeEventListener("input.select",this.onSelect),this.el.removeEventListener("input.ajax",this.onAjax)},i.prototype.onFilter=function(e){this.props.onFilter&&this.props.onFilter(e)},i.prototype.onSelect=function(e){this.props.onSelect&&this.props.onSelect(e)},i.prototype.onAjax=function(e){this.props.onAjax&&this.props.onAjax(e)},i.prototype.render=function(){var n,r,e,o=this;return a.createElement("div",(n=this.props,r=i.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)),a.Children.map(this.props.children,function(e,t){return 0===t?a.cloneElement(e,{"aria-expanded":String(Boolean(o.props.open))}):1===t?a.cloneElement(e,{hidden:!o.props.open}):e}))},Object.defineProperties(i,e),i}(a.Component);return L.Highlight=function(e){var t=e.text,n=e.query;return void 0===n&&(n=""),a.createElement("span",{dangerouslySetInnerHTML:{__html:w.highlight(t,n)}})},L.propTypes={onFilter:e.func,onSelect:e.func,onAjax:e.func,open:e.bool,ajax:e.oneOfType([e.string,e.object])},L});
/*! @nrk/core-input v1.2.2 - 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,a=(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function u(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 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 p="data-@nrk/core-input-1.2.2".replace(/\W+/g,"-"),d=13,f=27,v=33,h=34,m=35,b=36,g=38,x=40,y='[tabindex="-1"]',E=500;function A(e,t){var o="object"==typeof t?t:{content:t},i="string"==typeof o.content;return s(e).map(function(e){var t=e.nextElementSibling,n=void 0===o.ajax?e.getAttribute(p):o.ajax,r=void 0===o.open?e===document.activeElement:o.open;return e.setAttribute(p,n||""),e.setAttribute(a?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),i&&(t.innerHTML=o.content),s("a,button",t).forEach(C),j(e,r),e})}function w(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||s("["+p+"]").forEach(function(e){var t,n,r=e.nextElementSibling,o=e===a.target||r.contains(a.target),i="click"===a.type&&o&&s(y,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(),j(t,!1))):j(e,o)})}function S(e,t){var n=e.nextElementSibling,r=[e].concat(s(y+":not([hidden])",n)),o=t.keyCode===f&&"true"===e.getAttribute("aria-expanded"),i=r.indexOf(document.activeElement),a=!1;t.keyCode===x?a=r[i+1]||r[0]:t.keyCode===g?a=r[i-1]||r.pop():n.contains(t.target)&&(t.keyCode===m||t.keyCode===h?a=r.pop():t.keyCode===b||t.keyCode===v?a=r[1]:t.keyCode!==d&&e.focus()),j(e,t.keyCode!==f),(!1!==a||o)&&t.preventDefault(),a&&a.focus()}function j(e,t){var n;void 0===t&&(t="true"===e.getAttribute("aria-expanded")),n=function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)},(window.requestAnimationFrame||window.setTimeout)(n)}function C(e,t,n){e.setAttribute("aria-label",e.textContent.trim()+", "+(t+1)+" av "+n.length),e.setAttribute("tabindex","-1"),e.setAttribute("type","button")}function L(e){var t=e.getAttribute(p),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=u,A.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return u(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(p,"click",w),n(p,"focus",w,!0),n(p,"input",function(e){var i,t,n=e.target;n.hasAttribute(p)&&(t={relatedTarget:(i=n).nextElementSibling},c(i,"input.filter",t)&&!1===L(i)&&s(y,i.nextElementSibling).reduce(function(e,t){var n="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(i.value.toLowerCase()),o=r?"removeAttribute":"setAttribute";return n&&n[o]("hidden",""),t[o]("hidden",""),r?e.concat(t):e},[]).forEach(C))}),n(p,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(p))return S(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(p))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,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,ajax:e.oneOfType([e.string,e.object])},k});
//# sourceMappingURL=core-input.jsx.js.map

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

/*! @nrk/core-input v1.2.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,o=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform))),i=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 r(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var a="prevent_recursive_dispatch_maximum_callstack";function u(e,t,n){void 0===n&&(n={});var r,i=""+a+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[]}var d="data-@nrk/core-input-1.2.1".replace(/\W+/g,"-"),l=13,s=27,f=33,p=34,v=35,m=36,b=38,g=40,y='[tabindex="-1"]',w=500;function x(e,t){var r="object"==typeof t?t:{content:t},i="string"==typeof r.content;return c(e).map(function(e){var t=e.nextElementSibling,n=void 0===r.ajax?e.getAttribute(d):r.ajax;return e.setAttribute(d,n||""),e.setAttribute(o?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),i&&(t.innerHTML=r.content),c("a,button",t).forEach(C),A(e,r.open),e})}function h(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||c("["+d+"]").forEach(function(e){var t,n,r=e.nextElementSibling,i=e===a.target||r.contains(a.target),o="click"===a.type&&i&&c(y,r).filter(function(e){return e.contains(a.target)})[0];o?(t=e,n={relatedTarget:r,currentTarget:o,value:o.value||o.textContent.trim()},u(t,"input.select",n)&&(t.value=n.value,t.focus(),A(t,!1))):A(e,i)})}function E(e,t){var n=e.nextElementSibling,r=[e].concat(c(y+":not([hidden])",n)),i=t.keyCode===s&&"true"===e.getAttribute("aria-expanded"),o=r.indexOf(document.activeElement),a=!1;t.keyCode===g?a=r[o+1]||r[0]:t.keyCode===b?a=r[o-1]||r.pop():n.contains(t.target)&&(t.keyCode===v||t.keyCode===p?a=r.pop():t.keyCode===m||t.keyCode===f?a=r[1]:t.keyCode!==l&&e.focus()),A(e,t.keyCode!==s),(!1!==a||i)&&t.preventDefault(),a&&a.focus()}function A(e,t){var n;void 0===t&&(t="true"===e.getAttribute("aria-expanded")),n=function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)},(window.requestAnimationFrame||window.setTimeout)(n)}function C(e,t,n){e.setAttribute("aria-label",e.textContent.trim()+", "+(t+1)+" av "+n.length),e.setAttribute("tabindex","-1"),e.setAttribute("type","button")}function k(e){var t=e.getAttribute(d),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}u(e,"input.ajax",n)},k.timer=setTimeout(function(){e.value&&u(e,"input.ajax.beforeSend",n)&&(n.open("GET",t.replace("{{value}}",window.encodeURIComponent(e.value)),!0),n.setRequestHeader("X-Requested-With","XMLHttpRequest"),n.send())},w)}return x.escapeHTML=r,x.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return r(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},t(d,"click",h),t(d,"focus",h,!0),t(d,"input",function(e){var o,t,n=e.target;n.hasAttribute(d)&&(t={relatedTarget:(o=n).nextElementSibling},u(o,"input.filter",t)&&!1===k(o)&&c(y,o.nextElementSibling).reduce(function(e,t){var n="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(o.value.toLowerCase()),i=r?"removeAttribute":"setAttribute";return n&&n[i]("hidden",""),t[i]("hidden",""),r?e.concat(t):e},[]).forEach(C))}),t(d,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(d))return E(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(d))return E(n,e)}},!0),x});
/*! @nrk/core-input v1.2.2 - 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,a=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform))),i=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 r(e){return String(e||"").replace(/[&<>"'/]/g,function(e){return n[e]})}var u="prevent_recursive_dispatch_maximum_callstack";function c(e,t,n){void 0===n&&(n={});var r,i=""+u+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 d(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 l="data-@nrk/core-input-1.2.2".replace(/\W+/g,"-"),s=13,f=27,p=33,v=34,m=35,b=36,g=38,y=40,w='[tabindex="-1"]',o=500;function x(e,t){var i="object"==typeof t?t:{content:t},o="string"==typeof i.content;return d(e).map(function(e){var t=e.nextElementSibling,n=void 0===i.ajax?e.getAttribute(l):i.ajax,r=void 0===i.open?e===document.activeElement:i.open;return e.setAttribute(l,n||""),e.setAttribute(a?"data-role":"role","combobox"),e.setAttribute("aria-autocomplete","list"),e.setAttribute("autocomplete","off"),o&&(t.innerHTML=i.content),d("a,button",t).forEach(C),A(e,r),e})}function h(a){a.ctrlKey||a.altKey||a.metaKey||a.defaultPrevented||d("["+l+"]").forEach(function(e){var t,n,r=e.nextElementSibling,i=e===a.target||r.contains(a.target),o="click"===a.type&&i&&d(w,r).filter(function(e){return e.contains(a.target)})[0];o?(t=e,n={relatedTarget:r,currentTarget:o,value:o.value||o.textContent.trim()},c(t,"input.select",n)&&(t.value=n.value,t.focus(),A(t,!1))):A(e,i)})}function E(e,t){var n=e.nextElementSibling,r=[e].concat(d(w+":not([hidden])",n)),i=t.keyCode===f&&"true"===e.getAttribute("aria-expanded"),o=r.indexOf(document.activeElement),a=!1;t.keyCode===y?a=r[o+1]||r[0]:t.keyCode===g?a=r[o-1]||r.pop():n.contains(t.target)&&(t.keyCode===m||t.keyCode===v?a=r.pop():t.keyCode===b||t.keyCode===p?a=r[1]:t.keyCode!==s&&e.focus()),A(e,t.keyCode!==f),(!1!==a||i)&&t.preventDefault(),a&&a.focus()}function A(e,t){var n;void 0===t&&(t="true"===e.getAttribute("aria-expanded")),n=function(){e.nextElementSibling[t?"removeAttribute":"setAttribute"]("hidden",""),e.setAttribute("aria-expanded",t)},(window.requestAnimationFrame||window.setTimeout)(n)}function C(e,t,n){e.setAttribute("aria-label",e.textContent.trim()+", "+(t+1)+" av "+n.length),e.setAttribute("tabindex","-1"),e.setAttribute("type","button")}function k(e){var t=e.getAttribute(l),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 x.escapeHTML=r,x.highlight=function(e,t){var n=t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return r(e).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},t(l,"click",h),t(l,"focus",h,!0),t(l,"input",function(e){var o,t,n=e.target;n.hasAttribute(l)&&(t={relatedTarget:(o=n).nextElementSibling},c(o,"input.filter",t)&&!1===k(o)&&d(w,o.nextElementSibling).reduce(function(e,t){var n="LI"===t.parentElement.nodeName&&t.parentElement,r=-1!==t.textContent.toLowerCase().indexOf(o.value.toLowerCase()),i=r?"removeAttribute":"setAttribute";return n&&n[i]("hidden",""),t[i]("hidden",""),r?e.concat(t):e},[]).forEach(C))}),t(l,"keydown",function(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){if(e.target.hasAttribute&&e.target.hasAttribute(l))return E(e.target,e);for(var t=e.target,n=void 0;t;t=t.parentElement)if((n=t.previousElementSibling)&&n.hasAttribute(l))return E(n,e)}},!0),x});
//# sourceMappingURL=core-input.min.js.map

@@ -9,3 +9,3 @@ 'use strict';

var name = "@nrk/core-input";
var version = "1.2.1";
var version = "1.2.2";

@@ -129,2 +129,3 @@ var IS_BROWSER = typeof window !== 'undefined';

var ajax = typeof options.ajax === 'undefined' ? input.getAttribute(UUID) : options.ajax;
var open = typeof options.open === 'undefined' ? input === document.activeElement : options.open;

@@ -138,3 +139,4 @@ input.setAttribute(UUID, ajax || '');

queryAll('a,button', list).forEach(setupItem);
setupExpand(input, options.open);
setupExpand(input, open);
return input

@@ -260,6 +262,9 @@ })

function Input (props) {
var this$1 = this;
superclass.call(this, props);
this.onFilter = this.onFilter.bind(this);
this.onSelect = this.onSelect.bind(this);
this.onAjax = this.onAjax.bind(this);
this.onFilter = function (event) { return this$1.props.onFilter && this$1.props.onFilter(event); };
this.onSelect = function (event) { return this$1.props.onSelect && this$1.props.onSelect(event); };
this.onAjaxBeforeSend = function (event) { return this$1.props.onAjaxBeforeSend && this$1.props.onAjaxBeforeSend(event); };
this.onAjax = function (event) { return this$1.props.onAjax && this$1.props.onAjax(event); };
}

@@ -272,3 +277,3 @@

var staticAccessors = { defaultProps: { configurable: true } };
staticAccessors.defaultProps.get = function () { return { open: null, ajax: null, onAjax: null, onFilter: null, onSelect: null } };
staticAccessors.defaultProps.get = function () { return { open: null, ajax: null, onAjax: null, onAjaxBeforeSend: null, onFilter: null, onSelect: null } };

@@ -278,2 +283,3 @@ Input.prototype.componentDidMount = function componentDidMount () { // Mount client side only to avoid rerender

this.el.addEventListener('input.select', this.onSelect);
this.el.addEventListener('input.ajax.beforeSend', this.onAjaxBeforeSend);
this.el.addEventListener('input.ajax', this.onAjax);

@@ -286,7 +292,5 @@ input(this.el.firstElementChild, this.props);

this.el.removeEventListener('input.select', this.onSelect);
this.el.removeEventListener('input.beforeSend', this.onAjaxBeforeSend);
this.el.removeEventListener('input.ajax', this.onAjax);
};
Input.prototype.onFilter = function onFilter (event) { this.props.onFilter && this.props.onFilter(event); };
Input.prototype.onSelect = function onSelect (event) { this.props.onSelect && this.props.onSelect(event); };
Input.prototype.onAjax = function onAjax (event) { this.props.onAjax && this.props.onAjax(event); };
Input.prototype.render = function render () {

@@ -293,0 +297,0 @@ var this$1 = this;

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

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

@@ -14,4 +14,4 @@ "main": "core-input.cjs.js",

"dependencies": {
"prop-types": "15.6.2"
"prop-types": "15.7.2"
}
}

@@ -103,3 +103,3 @@ # Core Input

<CoreInput open={false} onFilter={(event) => {}} onSelect={(event) => {}} onAjax={(event) => {}} ajax="https://search.com?q={{value}}">
<CoreInput open={false} onFilter={(event) => {}} onSelect={(event) => {}} onAjax={(event) => {}} onAjaxBeforeSend={(event) => {}} ajax="https://search.com?q={{value}}">
<input type="text" /> <!-- First element must result in a input-tag. Accepts both elements and components -->

@@ -106,0 +106,0 @@ <ul> // Next element will be used for items. Accepts both elements and components

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