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

@nrk/core-input

Package Overview
Dependencies
Maintainers
84
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.1 to 1.0.2

3

core-input.js

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

return queryAll(elements).forEach((input) => {
return queryAll(elements).map((input) => {
const list = input.nextElementSibling

@@ -76,2 +76,3 @@

if (!list.hasAttribute('hidden') && event.keyCode === KEYS.ESC) event.preventDefault()
setupExpand(input, event.keyCode !== KEYS.ESC)

@@ -78,0 +79,0 @@ if (item !== false) event.preventDefault() // event.preventDefault even if empty list

import React from 'react'
import coreInput from '../core-input/core-input'
import coreInput from './core-input'
import {exclude} from '../utils'
const DEFAULTS = {open: null, onFilter () {}, onSelect () {}}
const DEFAULTS = {open: null, onFilter: null, onSelect: null}

@@ -20,6 +20,11 @@ export default class Input extends React.Component {

return React.createElement('div', exclude(this.props, DEFAULTS, {ref: el => (this.el = el)}),
React.Children.map(this.props.children, (child, adjacent) => adjacent
? React.cloneElement(child, {'hidden': !this.props.open})
: React.cloneElement(child, {'aria-expanded': String(Boolean(this.props.open))})
)
React.Children.map(this.props.children, (child, adjacent) => {
if (adjacent === 0) {
return React.cloneElement(child, {
'aria-expanded': String(Boolean(this.props.open))
})
}
if (adjacent === 1) return React.cloneElement(child, {'hidden': !this.props.open})
return child
})
)

@@ -26,0 +31,0 @@ }

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

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

"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)",
"version": "1.0.1",
"version": "1.0.2",
"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