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

react-datalist-input

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-datalist-input - npm Package Compare versions

Comparing version 1.1.7 to 1.1.8

2

lib/DataListInput.js

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

module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=a(n(1)),u=a(n(4));function a(e){return e&&e.__esModule?e:{default:e}}n(7);var c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onHandleInput=function(e){var t=e.target.value,o=n.props,i=o.items,u=o.match,a=i.filter(function(e){return(void 0===u?"undefined":r(u))===("undefined"==typeof Function?"undefined":r(Function))?u(t,e):n.match(t,e)});n.setState({currentInput:t,matchingItems:a,focusIndex:0,visible:!0})},n.match=function(e,t){return t.label.substr(0,e.length).toUpperCase()===e.toUpperCase()},n.indexOfMatch=function(e,t){return t.label.toUpperCase().indexOf(e.toUpperCase())},n.onHandleKeydown=function(e){var t=n.state,r=t.visible,o=t.focusIndex,i=t.matchingItems;if(r){var u=o;if(40===e.keyCode||9===e.keyCode)(u+=1)>=i.length&&(u=0),n.setState({focusIndex:u}),e.preventDefault();else if(38===e.keyCode)(u-=1)<=-1&&(u=i.length-1),n.setState({focusIndex:u});else if(13===e.keyCode&&o>-1){var a=i[u];n.onSelect(a)}}},n.onClickItem=function(e){for(var t=n.state.matchingItems,r=e.currentTarget.children,o=void 0,i=0;i<r.length;i+=1)if("INPUT"===r[i].tagName){o=Number(r[i].value);break}var u=t.find(function(e){return e.key===o});n.onSelect(u)},n.onSelect=function(e){var t=n.props,r=t.suppressReselect,o=t.clearInputOnSelect,i=n.state.lastValidItem;r&&i&&e.key===i.key?n.setState({currentInput:o?e.label:"",visible:!1,focusIndex:-1}):(n.setState({currentInput:o?e.label:"",lastValidItem:e,visible:!1,focusIndex:-1}),(0,n.props.onSelect)(e))},n.renderItemLabel=function(e,t){return i.default.createElement(i.default.Fragment,null,t.label.substr(0,n.indexOfMatch(e,t)),i.default.createElement("strong",null,t.label.substr(n.indexOfMatch(e,t),e.length)),t.label.substr(n.indexOfMatch(e,t)+e.length))},n.renderItems=function(e,t,r,o,u){return i.default.createElement("div",{className:"datalist-items"},t.map(function(t,a){var c=u+" "+(r===a?"datalist-active-item "+o:"")+";";return i.default.createElement("div",{onClick:n.onClickItem,className:c,key:t.key,tabIndex:0,role:"button",onKeyUp:function(e){return e.preventDefault()}},n.renderItemLabel(e,t),i.default.createElement("input",{type:"hidden",value:t.key,readOnly:!0}))}))},n.renderInputField=function(e,t,r){return i.default.createElement("input",{onChange:n.onHandleInput,onKeyDown:n.onHandleKeydown,type:"text",className:"autocomplete-input "+r,placeholder:e,value:t})},n.state={lastValidItem:void 0,currentInput:"",matchingItems:[],visible:!1,focusIndex:0},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this.state,t=e.currentInput,n=e.matchingItems,r=e.focusIndex,o=e.visible,u=this.props,a=u.placeholder,c=u.inputClassName,l=u.activeItemClassName,s=u.itemClassName,f=u.requiredInputLength,p=t.length>=f;return i.default.createElement("div",{className:"datalist-input"},this.renderInputField(a,t,c),p&&o&&this.renderItems(t,n,r,l,s))}}]),t}();c.propTypes={items:u.default.arrayOf(u.default.shape({label:u.default.string.isRequired,key:u.default.number.isRequired})).isRequired,placeholder:u.default.string,onSelect:u.default.func.isRequired,match:u.default.func,inputClassName:u.default.string,itemClassName:u.default.string,activeItemClassName:u.default.string,requiredInputLength:u.default.number,clearInputOnSelect:u.default.bool,suppressReselect:u.default.bool},c.defaultProps={placeholder:"",match:void 0,inputClassName:"",itemClassName:"",activeItemClassName:"",requiredInputLength:0,clearInputOnSelect:!1,suppressReselect:!0},t.default=c},function(e,t,n){"use strict";e.exports=n(2)},function(e,t,n){"use strict";
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=a(n(1)),u=a(n(4));function a(e){return e&&e.__esModule?e:{default:e}}n(7);var c=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.onHandleInput=function(e){var t=e.target.value,o=n.props,i=o.items,u=o.match,a=i.filter(function(e){return(void 0===u?"undefined":r(u))===("undefined"==typeof Function?"undefined":r(Function))?u(t,e):n.match(t,e)});n.setState({currentInput:t,matchingItems:a,focusIndex:0,visible:!0})},n.match=function(e,t){return t.label.substr(0,e.length).toUpperCase()===e.toUpperCase()},n.indexOfMatch=function(e,t){return t.label.toUpperCase().indexOf(e.toUpperCase())},n.onHandleKeydown=function(e){var t=n.state,r=t.visible,o=t.focusIndex,i=t.matchingItems;if(r){var u=o;if(40===e.keyCode||9===e.keyCode)(u+=1)>=i.length&&(u=0),n.setState({focusIndex:u}),e.preventDefault();else if(38===e.keyCode)(u-=1)<=-1&&(u=i.length-1),n.setState({focusIndex:u});else if(13===e.keyCode&&o>-1){var a=i[u];n.onSelect(a)}}},n.onClickItem=function(e){for(var t=n.state.matchingItems,r=e.currentTarget.children,o=void 0,i=0;i<r.length;i+=1)if("INPUT"===r[i].tagName){o=Number(r[i].value);break}var u=t.find(function(e){return e.key===o});n.onSelect(u)},n.onSelect=function(e){var t=n.props,r=t.suppressReselect,o=t.clearInputOnSelect,i=n.state.lastValidItem;r&&i&&e.key===i.key?n.setState({currentInput:o?"":e.label,visible:!1,focusIndex:-1}):(n.setState({currentInput:o?"":e.label,lastValidItem:e,visible:!1,focusIndex:-1}),(0,n.props.onSelect)(e))},n.renderItemLabel=function(e,t){return i.default.createElement(i.default.Fragment,null,t.label.substr(0,n.indexOfMatch(e,t)),i.default.createElement("strong",null,t.label.substr(n.indexOfMatch(e,t),e.length)),t.label.substr(n.indexOfMatch(e,t)+e.length))},n.renderItems=function(e,t,r,o,u){return i.default.createElement("div",{className:"datalist-items"},t.map(function(t,a){var c=u+" "+(r===a?"datalist-active-item "+o:"")+";";return i.default.createElement("div",{onClick:n.onClickItem,className:c,key:t.key,tabIndex:0,role:"button",onKeyUp:function(e){return e.preventDefault()}},n.renderItemLabel(e,t),i.default.createElement("input",{type:"hidden",value:t.key,readOnly:!0}))}))},n.renderInputField=function(e,t,r){return i.default.createElement("input",{onChange:n.onHandleInput,onKeyDown:n.onHandleKeydown,type:"text",className:"autocomplete-input "+r,placeholder:e,value:t})},n.state={lastValidItem:void 0,currentInput:"",matchingItems:[],visible:!1,focusIndex:0},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,i.default.Component),o(t,[{key:"render",value:function(){var e=this.state,t=e.currentInput,n=e.matchingItems,r=e.focusIndex,o=e.visible,u=this.props,a=u.placeholder,c=u.inputClassName,l=u.activeItemClassName,s=u.itemClassName,f=u.requiredInputLength,p=t.length>=f;return i.default.createElement("div",{className:"datalist-input"},this.renderInputField(a,t,c),p&&o&&this.renderItems(t,n,r,l,s))}}]),t}();c.propTypes={items:u.default.arrayOf(u.default.shape({label:u.default.string.isRequired,key:u.default.number.isRequired})).isRequired,placeholder:u.default.string,onSelect:u.default.func.isRequired,match:u.default.func,inputClassName:u.default.string,itemClassName:u.default.string,activeItemClassName:u.default.string,requiredInputLength:u.default.number,clearInputOnSelect:u.default.bool,suppressReselect:u.default.bool},c.defaultProps={placeholder:"",match:void 0,inputClassName:"",itemClassName:"",activeItemClassName:"",requiredInputLength:0,clearInputOnSelect:!1,suppressReselect:!0},t.default=c},function(e,t,n){"use strict";e.exports=n(2)},function(e,t,n){"use strict";
/** @license React v16.8.6

@@ -3,0 +3,0 @@ * react.production.min.js

{
"name": "react-datalist-input",
"version": "1.1.7",
"version": "1.1.8",
"description": "This package provides a react component as follows: an input field with a drop down menu to pick a possible option based on the current input.",

@@ -5,0 +5,0 @@ "main": "./lib/DataListInput.js",

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