react-search-autocomplete
Advanced tools
Comparing version 3.0.1 to 4.0.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=ReactSearchAutocomplete,exports.MAX_RESULTS=exports.DEFAULT_INPUT_DEBOUNCE=void 0;var _react=_interopRequireDefault(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_fuse=_interopRequireDefault(require("fuse.js")),_config=require("../config/config"),_Results=_interopRequireDefault(require("./Results")),_SearchInput=_interopRequireDefault(require("./SearchInput")),_styledComponents=_interopRequireWildcard(require("styled-components")),_utils=require("../utils/utils");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _templateObject(){var a=_taggedTemplateLiteral(["\n position: relative;\n\n height: ",";\n\n > .wrapper {\n position: absolute;\n display: flex;\n flex-direction: column;\n width: 100%;\n\n border: ",";\n border-radius: ",";\n\n background-color: ",";\n color: ",";\n\n font-size: ",";\n\n z-index: ",";\n\n &:hover {\n box-shadow: ",";\n }\n &:active {\n box-shadow: ",";\n }\n &:focus-within {\n box-shadow: ",";\n }\n }\n"]);return _templateObject=function(){return a},a}function _taggedTemplateLiteral(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var DEFAULT_INPUT_DEBOUNCE=200;exports.DEFAULT_INPUT_DEBOUNCE=200;var MAX_RESULTS=10;exports.MAX_RESULTS=10;function ReactSearchAutocomplete(a){var b=a.items,c=a.fuseOptions,d=a.useCaching,e=a.inputDebounce,f=a.onSearch,g=a.onSelect,h=a.onFocus,i=a.showIcon,j=a.maxResults,k=a.placeholder,l=a.autoFocus,m=a.styling,n=a.resultStringKeyName,o=_objectSpread(_objectSpread({},_config.defaultTheme),m),p=_objectSpread(_objectSpread({},_config.defaultFuseOptions),c),q=new _fuse.default(b,p),r=_react.default.useState(""),s=_slicedToArray(r,2),t=s[0],u=s[1],v=_react.default.useState(),w=_slicedToArray(v,2),x=w[0],y=w[1];_react.default.useEffect(function(){d&&sessionStorage.clear(),q.setCollection(b),y([])},[b]);var z=function(a,b){return d&&sessionStorage.setItem(a,JSON.stringify(b))},A=function(a){return d&&a in sessionStorage&&JSON.parse(sessionStorage.getItem(a))},B=function(a){return q.search(a,{limit:j}).map(function(a){return _objectSpread({},a.item)}).slice(0,j)},C=function(a){var b=A(null===a||void 0===a?void 0:a.toLowerCase())||B(a);z(null===a||void 0===a?void 0:a.toLowerCase(),b),f(a,b),y(b)},D=_react.default.useCallback(0<e?(0,_utils.debounce)(function(a){return C(a)},e):function(a){return C(a)},[b]);return _react.default.createElement(_styledComponents.ThemeProvider,{theme:o},_react.default.createElement(_config.GlobalStyle,null),_react.default.createElement(StyledReactSearchAutocomplete,null,_react.default.createElement("div",{className:"wrapper"},_react.default.createElement(_SearchInput.default,{searchString:t,setSearchString:function(a){var b=a.target.value;u(b),0<b.length?D(b):y([])},autoFocus:l,onBlur:function(){return y([])},onFocus:h,placeholder:k,showIcon:i}),_react.default.createElement(_Results.default,{results:x,onClick:g,setSearchString:u,showIcon:i,maxResults:j,resultStringKeyName:n}))))}ReactSearchAutocomplete.defaultProps={items:[],fuseOptions:_config.defaultFuseOptions,onSearch:function(){},useCaching:!1,inputDebounce:200,showIcon:!0,maxResults:10,placeholder:"",autoFocus:!1,styling:{},resultStringKeyName:"name"},ReactSearchAutocomplete.propTypes={items:_propTypes.default.array,fuseOptions:_propTypes.default.object,useCaching:_propTypes.default.bool,inputDebounce:_propTypes.default.number,onSearch:_propTypes.default.func,onSelect:_propTypes.default.func,onFocus:_propTypes.default.func,showIcon:_propTypes.default.bool,maxResults:_propTypes.default.number,placeholder:_propTypes.default.string,autoFocus:_propTypes.default.bool,styling:_propTypes.default.object,resultStringKeyName:_propTypes.default.string};var StyledReactSearchAutocomplete=_styledComponents.default.div(_templateObject(),function(a){return parseInt(a.theme.height)+2+"px"},function(a){return a.theme.border},function(a){return a.theme.borderRadius},function(a){return a.theme.backgroundColor},function(a){return a.theme.color},function(a){return a.theme.fontSize},function(a){return a.theme.zIndex},function(a){return a.theme.boxShadow},function(a){return a.theme.boxShadow},function(a){return a.theme.boxShadow}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=ReactSearchAutocomplete,exports.MAX_RESULTS=exports.DEFAULT_INPUT_DEBOUNCE=void 0;var _react=_interopRequireDefault(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_fuse=_interopRequireDefault(require("fuse.js")),_config=require("../config/config"),_Results=_interopRequireDefault(require("./Results")),_SearchInput=_interopRequireDefault(require("./SearchInput")),_styledComponents=_interopRequireWildcard(require("styled-components")),_utils=require("../utils/utils");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var a=new WeakMap;return _getRequireWildcardCache=function(){return a},a}function _interopRequireWildcard(a){if(a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var b=_getRequireWildcardCache();if(b&&b.has(a))return b.get(a);var c={},d=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var e in a)if(Object.prototype.hasOwnProperty.call(a,e)){var f=d?Object.getOwnPropertyDescriptor(a,e):null;f&&(f.get||f.set)?Object.defineProperty(c,e,f):c[e]=a[e]}return c.default=a,b&&b.set(a,c),c}function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _templateObject(){var a=_taggedTemplateLiteral(["\n position: relative;\n\n height: ",";\n\n > .wrapper {\n position: absolute;\n display: flex;\n flex-direction: column;\n width: 100%;\n\n border: ",";\n border-radius: ",";\n\n background-color: ",";\n color: ",";\n\n font-size: ",";\n font-family: ",";\n\n z-index: ",";\n\n &:hover {\n box-shadow: ",";\n }\n &:active {\n box-shadow: ",";\n }\n &:focus-within {\n box-shadow: ",";\n }\n }\n"]);return _templateObject=function(){return a},a}function _taggedTemplateLiteral(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(a,b){if(a){if("string"==typeof a)return _arrayLikeToArray(a,b);var c=Object.prototype.toString.call(a).slice(8,-1);return"Object"===c&&a.constructor&&(c=a.constructor.name),"Map"===c||"Set"===c?Array.from(a):"Arguments"===c||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)?_arrayLikeToArray(a,b):void 0}}function _arrayLikeToArray(a,b){(null==b||b>a.length)&&(b=a.length);for(var c=0,d=Array(b);c<b;c++)d[c]=a[c];return d}function _iterableToArrayLimit(a,b){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}var DEFAULT_INPUT_DEBOUNCE=200;exports.DEFAULT_INPUT_DEBOUNCE=200;var MAX_RESULTS=10;exports.MAX_RESULTS=10;function ReactSearchAutocomplete(a){var b=a.items,c=a.fuseOptions,d=a.useCaching,e=a.inputDebounce,f=a.onSearch,g=a.onSelect,h=a.onFocus,i=a.showIcon,j=a.maxResults,k=a.placeholder,l=a.autoFocus,m=a.styling,n=a.resultStringKeyName,o=_objectSpread(_objectSpread({},_config.defaultTheme),m),p=_objectSpread(_objectSpread({},_config.defaultFuseOptions),c),q=new _fuse.default(b,p),r=_react.default.useState(""),s=_slicedToArray(r,2),t=s[0],u=s[1],v=_react.default.useState(),w=_slicedToArray(v,2),x=w[0],y=w[1];_react.default.useEffect(function(){d&&sessionStorage.clear(),q.setCollection(b),y([])},[b]);var z=function(a,b){return d&&sessionStorage.setItem(a,JSON.stringify(b))},A=function(a){return d&&a in sessionStorage&&JSON.parse(sessionStorage.getItem(a))},B=function(a){return q.search(a,{limit:j}).map(function(a){return _objectSpread({},a.item)}).slice(0,j)},C=function(a){var b=A(null===a||void 0===a?void 0:a.toLowerCase())||B(a);z(null===a||void 0===a?void 0:a.toLowerCase(),b),f(a,b),y(b)},D=_react.default.useCallback(0<e?(0,_utils.debounce)(function(a){return C(a)},e):function(a){return C(a)},[b]);return _react.default.createElement(_styledComponents.ThemeProvider,{theme:o},_react.default.createElement(StyledReactSearchAutocomplete,null,_react.default.createElement("div",{className:"wrapper"},_react.default.createElement(_SearchInput.default,{searchString:t,setSearchString:function(a){var b=a.target.value;u(b),0<b.length?D(b):y([])},autoFocus:l,onBlur:function(){return y([])},onFocus:h,placeholder:k,showIcon:i}),_react.default.createElement(_Results.default,{results:x,onClick:g,setSearchString:u,showIcon:i,maxResults:j,resultStringKeyName:n}))))}ReactSearchAutocomplete.defaultProps={items:[],fuseOptions:_config.defaultFuseOptions,onSearch:function(){},useCaching:!1,inputDebounce:200,showIcon:!0,maxResults:10,placeholder:"",autoFocus:!1,styling:{},resultStringKeyName:"name"},ReactSearchAutocomplete.propTypes={items:_propTypes.default.array,fuseOptions:_propTypes.default.object,useCaching:_propTypes.default.bool,inputDebounce:_propTypes.default.number,onSearch:_propTypes.default.func,onSelect:_propTypes.default.func,onFocus:_propTypes.default.func,showIcon:_propTypes.default.bool,maxResults:_propTypes.default.number,placeholder:_propTypes.default.string,autoFocus:_propTypes.default.bool,styling:_propTypes.default.object,resultStringKeyName:_propTypes.default.string};var StyledReactSearchAutocomplete=_styledComponents.default.div(_templateObject(),function(a){return parseInt(a.theme.height)+2+"px"},function(a){return a.theme.border},function(a){return a.theme.borderRadius},function(a){return a.theme.backgroundColor},function(a){return a.theme.color},function(a){return a.theme.fontSize},function(a){return a.theme.fontFamily},function(a){return a.theme.zIndex},function(a){return a.theme.boxShadow},function(a){return a.theme.boxShadow},function(a){return a.theme.boxShadow}); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=SearchInput;var _react=_interopRequireDefault(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_SearchIcon=require("./SearchIcon"),_styledComponents=_interopRequireDefault(require("styled-components"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _templateObject(){var a=_taggedTemplateLiteral(["\n min-height: ",";\n width: 100%;\n\n display: flex;\n align-items: center;\n\n > input {\n width: 100%;\n\n padding: 0 0 0 13px;\n\n border: none;\n outline: none;\n\n background-color: rgba(0, 0, 0, 0);\n\n color: ",";\n }\n\n > svg {\n flex-shrink: 0;\n margin-left: 16px;\n fill: ",";\n }\n"]);return _templateObject=function(){return a},a}function _taggedTemplateLiteral(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function SearchInput(a){var b=a.searchString,c=a.setSearchString,d=a.autoFocus,e=a.onBlur,f=a.onFocus,g=a.placeholder,h=a.showIcon;return _react.default.createElement(StyledSearchInput,null,h&&_react.default.createElement(_SearchIcon.SearchIcon,null),_react.default.createElement("input",{spellCheck:!1,value:b,onChange:c,onBlur:e,onFocus:f,placeholder:g,autoFocus:d}))}SearchInput.defaultProps={showIcon:!0},SearchInput.propTypes={searchString:_propTypes.default.string.isRequired,setSearchString:_propTypes.default.func.isRequired,autoFocus:_propTypes.default.bool,onBlur:_propTypes.default.func.isRequired,onFocus:_propTypes.default.func,placeholder:_propTypes.default.string,showIcon:_propTypes.default.bool};var StyledSearchInput=_styledComponents.default.div(_templateObject(),function(a){return a.theme.height},function(a){return a.theme.color},function(a){return a.theme.iconColor}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=SearchInput;var _react=_interopRequireDefault(require("react")),_propTypes=_interopRequireDefault(require("prop-types")),_SearchIcon=require("./SearchIcon"),_styledComponents=_interopRequireDefault(require("styled-components"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _templateObject(){var a=_taggedTemplateLiteral(["\n min-height: ",";\n width: 100%;\n\n display: flex;\n align-items: center;\n\n > input {\n width: 100%;\n\n padding: 0 0 0 13px;\n\n border: none;\n outline: none;\n\n background-color: rgba(0, 0, 0, 0);\n font-size: inherit;\n font-family: inherit;\n\n color: ",";\n }\n\n > svg {\n flex-shrink: 0;\n margin-left: 16px;\n fill: ",";\n }\n"]);return _templateObject=function(){return a},a}function _taggedTemplateLiteral(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}function SearchInput(a){var b=a.searchString,c=a.setSearchString,d=a.autoFocus,e=a.onBlur,f=a.onFocus,g=a.placeholder,h=a.showIcon;return _react.default.createElement(StyledSearchInput,null,h&&_react.default.createElement(_SearchIcon.SearchIcon,null),_react.default.createElement("input",{spellCheck:!1,value:b,onChange:c,onBlur:e,onFocus:f,placeholder:g,autoFocus:d}))}SearchInput.defaultProps={showIcon:!0},SearchInput.propTypes={searchString:_propTypes.default.string.isRequired,setSearchString:_propTypes.default.func.isRequired,autoFocus:_propTypes.default.bool,onBlur:_propTypes.default.func.isRequired,onFocus:_propTypes.default.func,placeholder:_propTypes.default.string,showIcon:_propTypes.default.bool};var StyledSearchInput=_styledComponents.default.div(_templateObject(),function(a){return a.theme.height},function(a){return a.theme.color},function(a){return a.theme.iconColor}); |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultFuseOptions=exports.GlobalStyle=exports.defaultTheme=void 0;var _styledComponents=require("styled-components");function _templateObject(){var a=_taggedTemplateLiteral(["\n * {\n box-sizing: border-box;\n font-family: ",";\n font-size: ",";\n }\n"]);return _templateObject=function(){return a},a}function _taggedTemplateLiteral(a,b){return b||(b=a.slice(0)),Object.freeze(Object.defineProperties(a,{raw:{value:Object.freeze(b)}}))}var defaultTheme={height:"44px",border:"1px solid #dfe1e5",borderRadius:"24px",backgroundColor:"white",boxShadow:"rgba(32, 33, 36, 0.28) 0px 1px 6px 0px",hoverBackgroundColor:"#eee",color:"#212121",fontSize:"16px",fontFamily:"Arial",iconColor:"grey",lineColor:"rgb(232, 234, 237)",placeholderColor:"grey",zIndex:0};exports.defaultTheme=defaultTheme;var GlobalStyle=(0,_styledComponents.createGlobalStyle)(_templateObject(),function(a){return a.theme.fontFamily},function(a){return a.theme.fontSize});exports.GlobalStyle=GlobalStyle;var defaultFuseOptions={shouldSort:!0,threshold:.6,location:0,distance:100,maxPatternLength:32,minMatchCharLength:1,keys:["name"]};exports.defaultFuseOptions=defaultFuseOptions; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.defaultFuseOptions=exports.defaultTheme=void 0;var defaultTheme={height:"44px",border:"1px solid #dfe1e5",borderRadius:"24px",backgroundColor:"white",boxShadow:"rgba(32, 33, 36, 0.28) 0px 1px 6px 0px",hoverBackgroundColor:"#eee",color:"#212121",fontSize:"16px",fontFamily:"Arial",iconColor:"grey",lineColor:"rgb(232, 234, 237)",placeholderColor:"grey",zIndex:0};exports.defaultTheme=defaultTheme;var defaultFuseOptions={shouldSort:!0,threshold:.6,location:0,distance:100,maxPatternLength:32,minMatchCharLength:1,keys:["name"]};exports.defaultFuseOptions=defaultFuseOptions; |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "A search box for React", | ||
@@ -8,0 +8,0 @@ "main": "dist/index.js", |
@@ -9,2 +9,6 @@ ![travis](https://travis-ci.com/sickdyd/react-search-autocomplete.svg?branch=master) | ||
`4.0.0` | ||
- Removed global styles for font-size, font-family and border-box (now applied only to the component) | ||
`3.0.1` | ||
@@ -11,0 +15,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
5
234
1
22985