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

@nrk/core-input

Package Overview
Dependencies
Maintainers
79
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.0.0 to 1.0.1

core-input.md

10

core-input.js

@@ -67,7 +67,9 @@ import {name, version} from './package.json'

if (event.keyCode === KEYS.END || event.keyCode === KEYS.PAGEDOWN) item = focus.pop()
else if (event.keyCode === KEYS.HOME || event.keyCode === KEYS.PAGEUP) item = focus[0]
else if (event.keyCode === KEYS.DOWN) item = focus[index + 1] || focus[0]
if (event.keyCode === KEYS.DOWN) item = focus[index + 1] || focus[0]
else if (event.keyCode === KEYS.UP) item = focus[index - 1] || focus.pop()
else if (event.keyCode !== KEYS.ENTER) input.focus()
else if (list.contains(event.target)) { // Aditional shortcuts if focus is inside list
if (event.keyCode === KEYS.END || event.keyCode === KEYS.PAGEDOWN) item = focus.pop()
else if (event.keyCode === KEYS.HOME || event.keyCode === KEYS.PAGEUP) item = focus[0]
else if (event.keyCode !== KEYS.ENTER) input.focus()
}

@@ -74,0 +76,0 @@ setupExpand(input, event.keyCode !== KEYS.ESC)

2

core-input.jsx

@@ -5,3 +5,3 @@ import React from 'react'

const DEFAULTS = {open: null, items: null, onFilter () {}, onSelect () {}}
const DEFAULTS = {open: null, onFilter () {}, onSelect () {}}

@@ -8,0 +8,0 @@ export default class Input extends React.Component {

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.coreInput=e()}(this,function(){"use strict";var t="undefined"!=typeof window,e=(t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform)));function n(t,e,n){var r="blur"===e||"focus"===e,i=t+"-"+e;"undefined"==typeof window||window[i]||document.addEventListener(window[i]=e,n,r)}var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function i(t){return String(t||"").replace(/[&<>"'/]/g,function(t){return r[t]})}function o(t,e,n){var r;return void 0===n&&(n={}),"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,n),t.dispatchEvent(r)}function u(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var a="data-@nrk/core-input-1.0.0".replace(/\W+/g,"-"),c={ENTER:13,ESC:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,UP:38,DOWN:40},l='[tabindex="-1"]';function d(t,n){var r="object"==typeof n?n:{content:n},i="string"==typeof r.content;return u(t).forEach(function(t){var n=t.nextElementSibling;return t.setAttribute(a,""),t.setAttribute(e?"data-role":"role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("autocomplete","off"),i&&(n.innerHTML=r.content),u("a,button",n).forEach(v),p(t,r.open),t})}function f(t){t.ctrlKey||t.altKey||t.metaKey||t.defaultPrevented||u("["+a+"]").forEach(function(e){var n=e.nextElementSibling,r=e===t.target||n.contains(t.target),i="click"===t.type&&r&&u(l,n).filter(function(e){return e.contains(t.target)})[0];i?function(t,e){o(t,"input.select",e)&&(t.value=e.value,t.focus(),p(t,!1))}(e,{relatedTarget:n,currentTarget:i,value:i.value||i.textContent.trim()}):p(e,r)})}function s(t,e){var n=t.nextElementSibling,r=u(l+":not([hidden])",n),i=r.indexOf(document.activeElement),o=!1;e.keyCode===c.END||e.keyCode===c.PAGEDOWN?o=r.pop():e.keyCode===c.HOME||e.keyCode===c.PAGEUP?o=r[0]:e.keyCode===c.DOWN?o=r[i+1]||r[0]:e.keyCode===c.UP?o=r[i-1]||r.pop():e.keyCode!==c.ENTER&&t.focus(),p(t,e.keyCode!==c.ESC),!1!==o&&e.preventDefault(),o&&o.focus()}function p(t,e){void 0===e&&(e="true"===t.getAttribute("aria-expanded")),t.nextElementSibling[e?"removeAttribute":"setAttribute"]("hidden",""),t.setAttribute("aria-expanded",e)}function v(t,e,n){t.setAttribute("aria-label",t.textContent.trim()+", "+(e+1)+" av "+n.length),t.setAttribute("tabindex","-1")}return d.escapeHTML=i,d.highlight=function(t,e){var n=e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return i(t).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(a,"click",f),n(a,"focus",f),n(a,"input",function(t){var e=t.target;e.hasAttribute(a)&&function(t,e){o(t,"input.filter",e)&&u(l,t.nextElementSibling).reduce(function(e,n){var r=-1!==n.textContent.toLowerCase().indexOf(t.value.toLowerCase());return n[r?"removeAttribute":"setAttribute"]("hidden",""),r?e.concat(n):e},[]).forEach(v)}(e,{relatedTarget:e.nextElementSibling})}),n(a,"keydown",function(t){if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.target.hasAttribute(a))return s(t.target,t);for(var e=t.target,n=void 0;e;e=e.parentElement)if((n=e.previousElementSibling)&&n.hasAttribute(a))return s(n,t)}}),d});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.coreInput=e()}(this,function(){"use strict";var t="undefined"!=typeof window,e=(t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform)));function n(t,e,n){var r="blur"===e||"focus"===e,i=t+"-"+e;"undefined"==typeof window||window[i]||document.addEventListener(window[i]=e,n,r)}var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function i(t){return String(t||"").replace(/[&<>"'/]/g,function(t){return r[t]})}function o(t,e,n){var r;return void 0===n&&(n={}),"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,n),t.dispatchEvent(r)}function a(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var u="data-@nrk/core-input-1.0.0".replace(/\W+/g,"-"),c={ENTER:13,ESC:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,UP:38,DOWN:40},l='[tabindex="-1"]';function d(t,n){var r="object"==typeof n?n:{content:n},i="string"==typeof r.content;return a(t).forEach(function(t){var n=t.nextElementSibling;return t.setAttribute(u,""),t.setAttribute(e?"data-role":"role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("autocomplete","off"),i&&(n.innerHTML=r.content),a("a,button",n).forEach(v),p(t,r.open),t})}function f(t){t.ctrlKey||t.altKey||t.metaKey||t.defaultPrevented||a("["+u+"]").forEach(function(e){var n=e.nextElementSibling,r=e===t.target||n.contains(t.target),i="click"===t.type&&r&&a(l,n).filter(function(e){return e.contains(t.target)})[0];i?function(t,e){o(t,"input.select",e)&&(t.value=e.value,t.focus(),p(t,!1))}(e,{relatedTarget:n,currentTarget:i,value:i.value||i.textContent.trim()}):p(e,r)})}function s(t,e){var n=t.nextElementSibling,r=a(l+":not([hidden])",n),i=r.indexOf(document.activeElement),o=!1;e.keyCode===c.DOWN?o=r[i+1]||r[0]:e.keyCode===c.UP?o=r[i-1]||r.pop():n.contains(e.target)&&(e.keyCode===c.END||e.keyCode===c.PAGEDOWN?o=r.pop():e.keyCode===c.HOME||e.keyCode===c.PAGEUP?o=r[0]:e.keyCode!==c.ENTER&&t.focus()),p(t,e.keyCode!==c.ESC),!1!==o&&e.preventDefault(),o&&o.focus()}function p(t,e){void 0===e&&(e="true"===t.getAttribute("aria-expanded")),t.nextElementSibling[e?"removeAttribute":"setAttribute"]("hidden",""),t.setAttribute("aria-expanded",e)}function v(t,e,n){t.setAttribute("aria-label",t.textContent.trim()+", "+(e+1)+" av "+n.length),t.setAttribute("tabindex","-1")}return d.escapeHTML=i,d.highlight=function(t,e){var n=e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return i(t).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},n(u,"click",f),n(u,"focus",f),n(u,"input",function(t){var e=t.target;e.hasAttribute(u)&&function(t,e){o(t,"input.filter",e)&&a(l,t.nextElementSibling).reduce(function(e,n){var r=-1!==n.textContent.toLowerCase().indexOf(t.value.toLowerCase());return n[r?"removeAttribute":"setAttribute"]("hidden",""),r?e.concat(n):e},[]).forEach(v)}(e,{relatedTarget:e.nextElementSibling})}),n(u,"keydown",function(t){if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.target.hasAttribute(u))return s(t.target,t);for(var e=t.target,n=void 0;e;e=e.parentElement)if((n=e.previousElementSibling)&&n.hasAttribute(u))return s(n,t)}}),d});
//# sourceMappingURL=core-input.min.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):t.CoreInput=e(t.React)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,n=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)));function r(t,e,n){var r="blur"===e||"focus"===e,i=t+"-"+e;"undefined"==typeof window||window[i]||document.addEventListener(window[i]=e,n,r)}var i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function o(t){return String(t||"").replace(/[&<>"'/]/g,function(t){return i[t]})}function u(t,e,n){var r;return void 0===n&&(n={}),"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,n),t.dispatchEvent(r)}function a(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var c="data-@nrk/core-input-1.0.0".replace(/\W+/g,"-"),l={ENTER:13,ESC:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,UP:38,DOWN:40},p='[tabindex="-1"]';function d(t,e){var r="object"==typeof e?e:{content:e},i="string"==typeof r.content;return a(t).forEach(function(t){var e=t.nextElementSibling;return t.setAttribute(c,""),t.setAttribute(n?"data-role":"role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("autocomplete","off"),i&&(e.innerHTML=r.content),a("a,button",e).forEach(m),v(t,r.open),t})}function f(t){t.ctrlKey||t.altKey||t.metaKey||t.defaultPrevented||a("["+c+"]").forEach(function(e){var n=e.nextElementSibling,r=e===t.target||n.contains(t.target),i="click"===t.type&&r&&a(p,n).filter(function(e){return e.contains(t.target)})[0];i?function(t,e){u(t,"input.select",e)&&(t.value=e.value,t.focus(),v(t,!1))}(e,{relatedTarget:n,currentTarget:i,value:i.value||i.textContent.trim()}):v(e,r)})}function s(t,e){var n=t.nextElementSibling,r=a(p+":not([hidden])",n),i=r.indexOf(document.activeElement),o=!1;e.keyCode===l.END||e.keyCode===l.PAGEDOWN?o=r.pop():e.keyCode===l.HOME||e.keyCode===l.PAGEUP?o=r[0]:e.keyCode===l.DOWN?o=r[i+1]||r[0]:e.keyCode===l.UP?o=r[i-1]||r.pop():e.keyCode!==l.ENTER&&t.focus(),v(t,e.keyCode!==l.ESC),!1!==o&&e.preventDefault(),o&&o.focus()}function v(t,e){void 0===e&&(e="true"===t.getAttribute("aria-expanded")),t.nextElementSibling[e?"removeAttribute":"setAttribute"]("hidden",""),t.setAttribute("aria-expanded",e)}function m(t,e,n){t.setAttribute("aria-label",t.textContent.trim()+", "+(e+1)+" av "+n.length),t.setAttribute("tabindex","-1")}d.escapeHTML=o,d.highlight=function(t,e){var n=e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return o(t).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},r(c,"click",f),r(c,"focus",f),r(c,"input",function(t){var e=t.target;e.hasAttribute(c)&&function(t,e){u(t,"input.filter",e)&&a(p,t.nextElementSibling).reduce(function(e,n){var r=-1!==n.textContent.toLowerCase().indexOf(t.value.toLowerCase());return n[r?"removeAttribute":"setAttribute"]("hidden",""),r?e.concat(n):e},[]).forEach(m)}(e,{relatedTarget:e.nextElementSibling})}),r(c,"keydown",function(t){if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.target.hasAttribute(c))return s(t.target,t);for(var e=t.target,n=void 0;e;e=e.parentElement)if((n=e.previousElementSibling)&&n.hasAttribute(c))return s(n,t)}});var h={open:null,items:null,onFilter:function(){},onSelect:function(){}},E=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.componentDidMount=function(){this.el.addEventListener("input.filter",this.props.onFilter),this.el.addEventListener("input.select",this.props.onSelect),d(this.el.firstElementChild)},n.prototype.componentDidUpdate=function(){d(this.el.firstElementChild)},n.prototype.componentWillUnmount=function(){this.el.removeEventListener("input.filter",this.props.onFilter),this.el.removeEventListener("input.select",this.props.onSelect)},n.prototype.render=function(){var e=this;return t.createElement("div",function(t,e,n){return void 0===n&&(n={}),Object.keys(t).reduce(function(n,r){return e.hasOwnProperty(r)||(n[r]=t[r]),n},n)}(this.props,h,{ref:function(t){return e.el=t}}),t.Children.map(this.props.children,function(n,r){return r?t.cloneElement(n,{hidden:!e.props.open}):t.cloneElement(n,{"aria-expanded":String(Boolean(e.props.open))})}))},n}(t.Component);return E.Highlight=function(e){var n=e.text,r=e.query;return void 0===r&&(r=""),t.createElement("span",{dangerouslySetInnerHTML:{__html:d.highlight(n,r)}})},E});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):t.CoreInput=e(t.React)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,n=(e&&/(android)/i.test(navigator.userAgent),e&&/iPad|iPhone|iPod/.test(String(navigator.platform)));function r(t,e,n){var r="blur"===e||"focus"===e,o=t+"-"+e;"undefined"==typeof window||window[o]||document.addEventListener(window[o]=e,n,r)}var o={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","/":"&#x2F;","'":"&#x27;"};function i(t){return String(t||"").replace(/[&<>"'/]/g,function(t){return o[t]})}function u(t,e,n){var r;return void 0===n&&(n={}),"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,n),t.dispatchEvent(r)}function a(t,e){if(void 0===e&&(e=document),t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var c="data-@nrk/core-input-1.0.0".replace(/\W+/g,"-"),l={ENTER:13,ESC:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,UP:38,DOWN:40},p='[tabindex="-1"]';function d(t,e){var r="object"==typeof e?e:{content:e},o="string"==typeof r.content;return a(t).forEach(function(t){var e=t.nextElementSibling;return t.setAttribute(c,""),t.setAttribute(n?"data-role":"role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("autocomplete","off"),o&&(e.innerHTML=r.content),a("a,button",e).forEach(m),v(t,r.open),t})}function f(t){t.ctrlKey||t.altKey||t.metaKey||t.defaultPrevented||a("["+c+"]").forEach(function(e){var n=e.nextElementSibling,r=e===t.target||n.contains(t.target),o="click"===t.type&&r&&a(p,n).filter(function(e){return e.contains(t.target)})[0];o?function(t,e){u(t,"input.select",e)&&(t.value=e.value,t.focus(),v(t,!1))}(e,{relatedTarget:n,currentTarget:o,value:o.value||o.textContent.trim()}):v(e,r)})}function s(t,e){var n=t.nextElementSibling,r=a(p+":not([hidden])",n),o=r.indexOf(document.activeElement),i=!1;e.keyCode===l.DOWN?i=r[o+1]||r[0]:e.keyCode===l.UP?i=r[o-1]||r.pop():n.contains(e.target)&&(e.keyCode===l.END||e.keyCode===l.PAGEDOWN?i=r.pop():e.keyCode===l.HOME||e.keyCode===l.PAGEUP?i=r[0]:e.keyCode!==l.ENTER&&t.focus()),v(t,e.keyCode!==l.ESC),!1!==i&&e.preventDefault(),i&&i.focus()}function v(t,e){void 0===e&&(e="true"===t.getAttribute("aria-expanded")),t.nextElementSibling[e?"removeAttribute":"setAttribute"]("hidden",""),t.setAttribute("aria-expanded",e)}function m(t,e,n){t.setAttribute("aria-label",t.textContent.trim()+", "+(e+1)+" av "+n.length),t.setAttribute("tabindex","-1")}d.escapeHTML=i,d.highlight=function(t,e){var n=e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&");return i(t).replace(new RegExp(n||".^","gi"),"<mark>$&</mark>")},r(c,"click",f),r(c,"focus",f),r(c,"input",function(t){var e=t.target;e.hasAttribute(c)&&function(t,e){u(t,"input.filter",e)&&a(p,t.nextElementSibling).reduce(function(e,n){var r=-1!==n.textContent.toLowerCase().indexOf(t.value.toLowerCase());return n[r?"removeAttribute":"setAttribute"]("hidden",""),r?e.concat(n):e},[]).forEach(m)}(e,{relatedTarget:e.nextElementSibling})}),r(c,"keydown",function(t){if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.target.hasAttribute(c))return s(t.target,t);for(var e=t.target,n=void 0;e;e=e.parentElement)if((n=e.previousElementSibling)&&n.hasAttribute(c))return s(n,t)}});var h={open:null,onFilter:function(){},onSelect:function(){}},E=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.componentDidMount=function(){this.el.addEventListener("input.filter",this.props.onFilter),this.el.addEventListener("input.select",this.props.onSelect),d(this.el.firstElementChild)},n.prototype.componentDidUpdate=function(){d(this.el.firstElementChild)},n.prototype.componentWillUnmount=function(){this.el.removeEventListener("input.filter",this.props.onFilter),this.el.removeEventListener("input.select",this.props.onSelect)},n.prototype.render=function(){var e=this;return t.createElement("div",function(t,e,n){return void 0===n&&(n={}),Object.keys(t).reduce(function(n,r){return e.hasOwnProperty(r)||(n[r]=t[r]),n},n)}(this.props,h,{ref:function(t){return e.el=t}}),t.Children.map(this.props.children,function(n,r){return r?t.cloneElement(n,{hidden:!e.props.open}):t.cloneElement(n,{"aria-expanded":String(Boolean(e.props.open))})}))},n}(t.Component);return E.Highlight=function(e){var n=e.text,r=e.query;return void 0===r&&(r=""),t.createElement("span",{dangerouslySetInnerHTML:{__html:d.highlight(n,r)}})},E});
//# sourceMappingURL=index.js.map

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

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

@@ -8,0 +8,0 @@ "main": "core-input.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