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

react-search-highlight

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-search-highlight - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

6

dist/react-search-highlight.cjs.development.js

@@ -184,4 +184,6 @@ 'use strict';

return function (input, data) {
var inputArr = input.toLowerCase().split('');
var _input$toLowerCase;
var inputArr = input == null ? void 0 : (_input$toLowerCase = input.toLowerCase()) == null ? void 0 : _input$toLowerCase.split('');
if (inputArr.length === 0) {

@@ -708,3 +710,3 @@ dispatch == null ? void 0 : dispatch({

var handleOnChange = function handleOnChange(e) {
return setInput(e.target.value.toLowerCase());
return setInput(e.target.value);
};

@@ -711,0 +713,0 @@

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("process");var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".rsh-input:focus{outline:none}.rsh-search-wrapper{position:relative}.rsh-input-box{background-color:#fff;border:1px solid transparent;border-radius:5px;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06);min-width:200px}.rsh-input-box-logo{align-items:center;display:flex;height:100%;justify-content:center;margin:0;width:40px}.rsh-input{border:none;border-radius:inherit;font-size:15px;height:100%;margin:0;padding:0;width:100%}.rsh-search-list{background-color:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06);box-sizing:border-box;max-height:500px;min-width:200px;overflow-x:scroll;overflow:scroll;padding:0 8px;position:absolute;top:40px;width:100%;z-index:12}.rsh-search-list-item{border-radius:13px;list-style:none;margin:10px 0;padding:3px 8px}.rsh-search-list-item__active{background-color:hsla(0,0%,47%,.05)}.rsh-search-list-item-text{margin:0}[data-heightlighted-value=true]{background-color:#ff0}");var a=function(e,t){switch(t.type){case"SET_INPUT":return r({},e,{input:t.payload});case"SEARCH_DATA":return r({},e,{searchData:t.payload});case"START_LOADING":return r({},e,{isLoading:!0});case"END_LOADING":return r({},e,{isLoading:!1});case"RESET_STATE":return r({},s);default:return e}},i=function(e,t,n){return n.some((function(n){return e[n].toLowerCase().includes(t)}))},u=function(e,t,n){var o=r({},e);return n.forEach((function(n){return o[n]=e[n].replaceAll(t,(function(e){return"<mark>"+e+"<mark>"}))})),o},s={isLoading:!1,searchData:[],input:""},c=t.createContext(null),l=function(){return t.useContext(c)},d=function(e){var r=e.children,o=t.useReducer(a,s),i=o[0],u=o[1],l=function(){u({type:"START_LOADING"})},d=function(){u({type:"END_LOADING"})},p=function(){u({type:"RESET_STATE"})},f=0===i.searchData.length&&i.input.length>0,h=t.useMemo((function(){return{suggestions:i.searchData,isLoading:i.isLoading,input:i.input,dispatch:u,startLoading:l,endLoading:d,resetState:p,isResultsEmpty:f}}),[i]);return n.createElement(c.Provider,{value:h},r)},p=["as","children","classNames"],f=function(e){var n=e.as,a=e.children,i=e.classNames,u=o(e,p);return t.createElement(n,r({className:i},u),a)},h=function(e,n,r,o){void 0===r&&(r="k"),void 0===o&&(o=[]),t.useEffect((function(){var t=function(t){(!n||t.metaKey)&&t.key.toLowerCase()===r&&(null==e||e())};return document.addEventListener("keydown",t),function(){document.removeEventListener("keydown",t)}}),o)},m=function(e){return function(t){e.forEach((function(e){null!==e&&("function"==typeof e?e(t):e.current=t)}))}},x=["children"],g=["children","optionIndex"],E=["className","value","as"],v={isPopoverExpanded:!1,listItemActiveIndex:0,updateInternalContext:function(e,t){},dataLength:0},A=t.createContext(v),T=n.forwardRef((function(e,o){var a,i,u,s=e.children,c=e.isFunction,d=t.useState(v),p=d[0],f=d[1],h=l(),x=function(e,t){f((function(n){var o;return r({},n,((o={})[e]=t,o))}))},g=t.useRef(null),E=m([g,o]),T=function(e){var n=t.useState(!1),r=n[0],o=n[1];return t.useEffect((function(){function t(t){e.current&&!e.current.contains(t.target)&&o(!1)}return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[e]),[r,o]}(g),C=T[0],y=T[1];return a=function(){x("isPopoverExpanded",C)},i=[C],u=t.useRef(!1),t.useEffect((function(){u.current?a():u.current=!0}),i),n.createElement(A.Provider,{value:r({},p,{updateInternalContext:x})},n.createElement("section",{ref:E,className:"rsh-search-wrapper",onFocusCapture:function(){return y(!0)}},c?s(h):s))})),C=n.forwardRef((function(e,t){var r=e.children,o="function"==typeof r;return n.createElement(n.Fragment,null,o?n.createElement(d,null,n.createElement(T,{ref:t,isFunction:o,children:r})):n.createElement(T,{ref:t,isFunction:o,children:r}))})),y=n.forwardRef((function(e,t){var r=e.children,a=o(e,x),i=l().suggestions,u=n.useContext(A),s=u.isPopoverExpanded,c=u.listItemActiveIndex,d=u.updateInternalContext;return h((function(){c<i.length-1&&d("listItemActiveIndex",c+1)}),!1,"arrowdown",[c,i.length]),h((function(){c>0&&d("listItemActiveIndex",c-1)}),!1,"arrowup",[c]),n.createElement(n.Fragment,null,s&&n.createElement("ul",Object.assign({"data-popover-expanded":s,ref:t,className:"rsh-search-list"},a),r))})),N=["as","children","className","onClick","onMouseDown","onFocusCapture"],R=function(e){var t=e.as,a=e.children,i=e.className,u=e.onClick,s=e.onFocusCapture,c=o(e,N);return n.createElement("div",{style:r({display:"flex",flexDirection:"HStack"===t?"row":"column",alignItems:"center"},c),className:i,onClick:u,onFocusCapture:s},a)},I=function(){return n.createElement("svg",{width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{d:"M14 13.3L9.70001 9.00001C11.6 6.70001 11.3 3.20001 9.00001 1.30001C6.70001 -0.599986 3.20001 -0.299986 1.30001 2.00001C-0.599986 4.30001 -0.299986 7.80001 2.00001 9.70001C4.00001 11.4 7.00001 11.4 9.00001 9.70001L13.3 14L14 13.3ZM1.00001 5.50001C1.00001 3.00001 3.00001 1.00001 5.50001 1.00001C8.00001 1.00001 10 3.00001 10 5.50001C10 8.00001 8.00001 10 5.50001 10C3.00001 10 1.00001 8.00001 1.00001 5.50001Z",fill:"black"}))},S=["keysToSearch","inputAlgorithm","matchingAlgorithm","data","value","inputAlgorithmTimeout","onChange","initialValue","PrefixIcon"],_={DEBOUNCE:function(e,n){var r=t.useState(e),o=r[0],a=r[1];return t.useEffect((function(){var t=setTimeout((function(){a(e)}),n);return function(){clearTimeout(t)}}),[e,n]),o},THROTTLE:function(e,n){void 0===n&&(n=200);var r=t.useState(e),o=r[0],a=r[1],i=t.useRef(),u=t.useRef(null),s=t.useRef(0),c=t.useRef(null);return t.useEffect((function(){i.current?(u.current=e,s.current=!0):(a(e),i.current=setTimeout((function e(){s.current?(s.current=!1,a(u.current),i.current=setTimeout(e,n)):i.current=void 0}),n))}),[e]),c.current=function(){i.current&&clearTimeout(i.current)},t.useEffect((function(){return function(){return c.current()}}),[]),o},DEFAULT:function(e){return e}},b={CHARACTER_MATCHING:function(e){var t=l().dispatch;return function(n,o){var a=n.toLowerCase().split("");if(0!==a.length){var s=new RegExp(a.join("|"),"gi");if(Array.isArray(o)&&Array.isArray(e)&&(!(o.length>0)||Object.keys(o[0]).some((function(t){return e.includes(t)})))){var c=null==o?void 0:o.filter((function(t){return a.every((function(n){return i(t,n,e)}))})).map((function(t){return r({},t,u(t,s,e))}));null==t||t({type:"SEARCH_DATA",payload:c})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}},STRING_MATCHING:function(e){var t=l().dispatch;return function(n,o){if(0!==n.length){var a=new RegExp(n,"gi");if(Array.isArray(o)&&Array.isArray(e)&&(!(o.length>0)||Object.keys(o[0]).some((function(t){return e.includes(t)})))){var s=null==o?void 0:o.filter((function(t){return i(t,n,e)})).map((function(t){return r({},t,u(t,a,e))}));null==t||t({type:"SEARCH_DATA",payload:s})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}}},w=n.forwardRef((function(e,r){var a,i=e.keysToSearch,u=e.inputAlgorithm,s=void 0===u?"DEBOUNCE":u,c=e.matchingAlgorithm,d=void 0===c?"CHARACTER_MATCHING":c,p=e.data,f=e.value,x=e.inputAlgorithmTimeout,g=void 0===x?500:x,E=e.onChange,v=e.initialValue,T=e.PrefixIcon,C=o(e,S),y=t.useState(null!=v?v:""),N=y[0],w=y[1],O=l().dispatch,L=n.useContext(A);i=null!=(a=i)?a:Object.keys(null==p?void 0:p[0]);var D=t.useRef(null),k=m([D,r]),H=null!=f?f:N,P=_[s](H,g),G=b[d](i);t.useEffect((function(){p&&G(H,p),null==O||O({type:"SET_INPUT",payload:H})}),[P]),t.useEffect((function(){L&&L.updateInternalContext("matchingAlgorithm",d)}),[]);var j=function(){var e;return null==D||null==(e=D.current)?void 0:e.focus()};return h(j,!0),n.createElement(R,{as:"HStack",onClick:j,justifyContent:"center",className:"rsh-input-box",padding:0,height:40,cursor:"text"},n.createElement("figure",{className:"rsh-input-box-logo"},n.createElement(T||I,null)),n.createElement("input",Object.assign({value:null!=f?f:N,onChange:null!=E?E:function(e){return w(e.target.value.toLowerCase())},placeholder:"search here",className:"rsh-input",autoFocus:!0,ref:k},C)))}));exports.CHARACTER_MATCHING="CHARACTER_MATCHING",exports.DEBOUNCE="DEBOUNCE",exports.DEFAULT="DEFAULT",exports.END_LOADING="END_LOADING",exports.InternalContext=A,exports.Modal=function(e){var t=e.isOpen,r=e.onClose;return n.createElement(n.Fragment,null,(null==t||t)&&n.createElement("div",{onClick:null!=r?r:void 0,className:"rsh-modal-dialog",style:{backgroundColor:"rgba(220,220,220,0.5)",position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:1e3}},n.createElement("div",{className:"rsh-modal-dialog-box-wrapper",style:{maxWidth:400,margin:"auto",padding:5}},e.children)))},exports.POPOVER_EXPANDED="POPOVER_EXPANDED",exports.PopOverList=y,exports.PopOverOption=function(e){var t=e.children,r=e.optionIndex,a=o(e,g),i=n.useContext(A),u=i.updateInternalContext;return n.createElement("li",Object.assign({onMouseEnter:function(){u("listItemActiveIndex",r)},className:"rsh-search-list-item "+(i.listItemActiveIndex===r&&"rsh-search-list-item__active")},a),t)},exports.PopOverOptionText=function(e){var t=e.className,r=e.value,a=e.as,i=void 0===a?"h3":a,u=o(e,E),s=l().input,c=n.useContext(A).matchingAlgorithm,d=null==r?void 0:r.split(/<mark>/);return n.createElement(f,Object.assign({as:i,classNames:t+" rsh-search-list-item-text"},u),null==d?void 0:d.map((function(e,t){return function(e){return"STRING_MATCHING"===c?e.toLocaleLowerCase()===s:s.includes(e.toLocaleLowerCase())}(e)?n.createElement("span",{key:e+"-"+t,"data-user-value":!0,"data-suggested-value":!0,"data-heightlighted-value":!0},e):n.createElement("span",{key:e+"-"+t},e)})))},exports.RESET_STATE="RESET_STATE",exports.ReactSearchHighlightProvider=d,exports.SEARCH_DATA="SEARCH_DATA",exports.SET_INPUT="SET_INPUT",exports.START_LOADING="START_LOADING",exports.STRING_MATCHING="STRING_MATCHING",exports.SearchBar=w,exports.THROTTLE="THROTTLE",exports.Wrapper=C,exports.__DEV__=!1,exports.context=c,exports.initialState=s,exports.inputAlgorithms=_,exports.matchingAlgorithms=b,exports.useReactSearchHighlight=l;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("process");var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===n&&r.firstChild?r.insertBefore(o,r.firstChild):r.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}(".rsh-input:focus{outline:none}.rsh-search-wrapper{position:relative}.rsh-input-box{background-color:#fff;border:1px solid transparent;border-radius:5px;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06);min-width:200px}.rsh-input-box-logo{align-items:center;display:flex;height:100%;justify-content:center;margin:0;width:40px}.rsh-input{border:none;border-radius:inherit;font-size:15px;height:100%;margin:0;padding:0;width:100%}.rsh-search-list{background-color:#fff;box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06);box-sizing:border-box;max-height:500px;min-width:200px;overflow-x:scroll;overflow:scroll;padding:0 8px;position:absolute;top:40px;width:100%;z-index:12}.rsh-search-list-item{border-radius:13px;list-style:none;margin:10px 0;padding:3px 8px}.rsh-search-list-item__active{background-color:hsla(0,0%,47%,.05)}.rsh-search-list-item-text{margin:0}[data-heightlighted-value=true]{background-color:#ff0}");var i=function(e,t){switch(t.type){case"SET_INPUT":return r({},e,{input:t.payload});case"SEARCH_DATA":return r({},e,{searchData:t.payload});case"START_LOADING":return r({},e,{isLoading:!0});case"END_LOADING":return r({},e,{isLoading:!1});case"RESET_STATE":return r({},s);default:return e}},a=function(e,t,n){return n.some((function(n){return e[n].toLowerCase().includes(t)}))},u=function(e,t,n){var o=r({},e);return n.forEach((function(n){return o[n]=e[n].replaceAll(t,(function(e){return"<mark>"+e+"<mark>"}))})),o},s={isLoading:!1,searchData:[],input:""},c=t.createContext(null),l=function(){return t.useContext(c)},d=function(e){var r=e.children,o=t.useReducer(i,s),a=o[0],u=o[1],l=function(){u({type:"START_LOADING"})},d=function(){u({type:"END_LOADING"})},p=function(){u({type:"RESET_STATE"})},f=0===a.searchData.length&&a.input.length>0,h=t.useMemo((function(){return{suggestions:a.searchData,isLoading:a.isLoading,input:a.input,dispatch:u,startLoading:l,endLoading:d,resetState:p,isResultsEmpty:f}}),[a]);return n.createElement(c.Provider,{value:h},r)},p=["as","children","classNames"],f=function(e){var n=e.as,i=e.children,a=e.classNames,u=o(e,p);return t.createElement(n,r({className:a},u),i)},h=function(e,n,r,o){void 0===r&&(r="k"),void 0===o&&(o=[]),t.useEffect((function(){var t=function(t){(!n||t.metaKey)&&t.key.toLowerCase()===r&&(null==e||e())};return document.addEventListener("keydown",t),function(){document.removeEventListener("keydown",t)}}),o)},m=function(e){return function(t){e.forEach((function(e){null!==e&&("function"==typeof e?e(t):e.current=t)}))}},x=["children"],g=["children","optionIndex"],v=["className","value","as"],E={isPopoverExpanded:!1,listItemActiveIndex:0,updateInternalContext:function(e,t){},dataLength:0},A=t.createContext(E),T=n.forwardRef((function(e,o){var i,a,u,s=e.children,c=e.isFunction,d=t.useState(E),p=d[0],f=d[1],h=l(),x=function(e,t){f((function(n){var o;return r({},n,((o={})[e]=t,o))}))},g=t.useRef(null),v=m([g,o]),T=function(e){var n=t.useState(!1),r=n[0],o=n[1];return t.useEffect((function(){function t(t){e.current&&!e.current.contains(t.target)&&o(!1)}return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[e]),[r,o]}(g),C=T[0],y=T[1];return i=function(){x("isPopoverExpanded",C)},a=[C],u=t.useRef(!1),t.useEffect((function(){u.current?i():u.current=!0}),a),n.createElement(A.Provider,{value:r({},p,{updateInternalContext:x})},n.createElement("section",{ref:v,className:"rsh-search-wrapper",onFocusCapture:function(){return y(!0)}},c?s(h):s))})),C=n.forwardRef((function(e,t){var r=e.children,o="function"==typeof r;return n.createElement(n.Fragment,null,o?n.createElement(d,null,n.createElement(T,{ref:t,isFunction:o,children:r})):n.createElement(T,{ref:t,isFunction:o,children:r}))})),y=n.forwardRef((function(e,t){var r=e.children,i=o(e,x),a=l().suggestions,u=n.useContext(A),s=u.isPopoverExpanded,c=u.listItemActiveIndex,d=u.updateInternalContext;return h((function(){c<a.length-1&&d("listItemActiveIndex",c+1)}),!1,"arrowdown",[c,a.length]),h((function(){c>0&&d("listItemActiveIndex",c-1)}),!1,"arrowup",[c]),n.createElement(n.Fragment,null,s&&n.createElement("ul",Object.assign({"data-popover-expanded":s,ref:t,className:"rsh-search-list"},i),r))})),N=["as","children","className","onClick","onMouseDown","onFocusCapture"],R=function(e){var t=e.as,i=e.children,a=e.className,u=e.onClick,s=e.onFocusCapture,c=o(e,N);return n.createElement("div",{style:r({display:"flex",flexDirection:"HStack"===t?"row":"column",alignItems:"center"},c),className:a,onClick:u,onFocusCapture:s},i)},I=function(){return n.createElement("svg",{width:"18",height:"18",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n.createElement("path",{d:"M14 13.3L9.70001 9.00001C11.6 6.70001 11.3 3.20001 9.00001 1.30001C6.70001 -0.599986 3.20001 -0.299986 1.30001 2.00001C-0.599986 4.30001 -0.299986 7.80001 2.00001 9.70001C4.00001 11.4 7.00001 11.4 9.00001 9.70001L13.3 14L14 13.3ZM1.00001 5.50001C1.00001 3.00001 3.00001 1.00001 5.50001 1.00001C8.00001 1.00001 10 3.00001 10 5.50001C10 8.00001 8.00001 10 5.50001 10C3.00001 10 1.00001 8.00001 1.00001 5.50001Z",fill:"black"}))},S=["keysToSearch","inputAlgorithm","matchingAlgorithm","data","value","inputAlgorithmTimeout","onChange","initialValue","PrefixIcon"],_={DEBOUNCE:function(e,n){var r=t.useState(e),o=r[0],i=r[1];return t.useEffect((function(){var t=setTimeout((function(){i(e)}),n);return function(){clearTimeout(t)}}),[e,n]),o},THROTTLE:function(e,n){void 0===n&&(n=200);var r=t.useState(e),o=r[0],i=r[1],a=t.useRef(),u=t.useRef(null),s=t.useRef(0),c=t.useRef(null);return t.useEffect((function(){a.current?(u.current=e,s.current=!0):(i(e),a.current=setTimeout((function e(){s.current?(s.current=!1,i(u.current),a.current=setTimeout(e,n)):a.current=void 0}),n))}),[e]),c.current=function(){a.current&&clearTimeout(a.current)},t.useEffect((function(){return function(){return c.current()}}),[]),o},DEFAULT:function(e){return e}},b={CHARACTER_MATCHING:function(e){var t=l().dispatch;return function(n,o){var i,s=null==n||null==(i=n.toLowerCase())?void 0:i.split("");if(0!==s.length){var c=new RegExp(s.join("|"),"gi");if(Array.isArray(o)&&Array.isArray(e)&&(!(o.length>0)||Object.keys(o[0]).some((function(t){return e.includes(t)})))){var l=null==o?void 0:o.filter((function(t){return s.every((function(n){return a(t,n,e)}))})).map((function(t){return r({},t,u(t,c,e))}));null==t||t({type:"SEARCH_DATA",payload:l})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}},STRING_MATCHING:function(e){var t=l().dispatch;return function(n,o){if(0!==n.length){var i=new RegExp(n,"gi");if(Array.isArray(o)&&Array.isArray(e)&&(!(o.length>0)||Object.keys(o[0]).some((function(t){return e.includes(t)})))){var s=null==o?void 0:o.filter((function(t){return a(t,n,e)})).map((function(t){return r({},t,u(t,i,e))}));null==t||t({type:"SEARCH_DATA",payload:s})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}}},w=n.forwardRef((function(e,r){var i,a=e.keysToSearch,u=e.inputAlgorithm,s=void 0===u?"DEBOUNCE":u,c=e.matchingAlgorithm,d=void 0===c?"CHARACTER_MATCHING":c,p=e.data,f=e.value,x=e.inputAlgorithmTimeout,g=void 0===x?500:x,v=e.onChange,E=e.initialValue,T=e.PrefixIcon,C=o(e,S),y=t.useState(null!=E?E:""),N=y[0],w=y[1],O=l().dispatch,D=n.useContext(A);a=null!=(i=a)?i:Object.keys(null==p?void 0:p[0]);var L=t.useRef(null),k=m([L,r]),H=null!=f?f:N,P=_[s](H,g),G=b[d](a);t.useEffect((function(){p&&G(H,p),null==O||O({type:"SET_INPUT",payload:H})}),[P]),t.useEffect((function(){D&&D.updateInternalContext("matchingAlgorithm",d)}),[]);var j=function(){var e;return null==L||null==(e=L.current)?void 0:e.focus()};return h(j,!0),n.createElement(R,{as:"HStack",onClick:j,justifyContent:"center",className:"rsh-input-box",padding:0,height:40,cursor:"text"},n.createElement("figure",{className:"rsh-input-box-logo"},n.createElement(T||I,null)),n.createElement("input",Object.assign({value:null!=f?f:N,onChange:null!=v?v:function(e){return w(e.target.value)},placeholder:"search here",className:"rsh-input",autoFocus:!0,ref:k},C)))}));exports.CHARACTER_MATCHING="CHARACTER_MATCHING",exports.DEBOUNCE="DEBOUNCE",exports.DEFAULT="DEFAULT",exports.END_LOADING="END_LOADING",exports.InternalContext=A,exports.Modal=function(e){var t=e.isOpen,r=e.onClose;return n.createElement(n.Fragment,null,(null==t||t)&&n.createElement("div",{onClick:null!=r?r:void 0,className:"rsh-modal-dialog",style:{backgroundColor:"rgba(220,220,220,0.5)",position:"fixed",top:0,right:0,bottom:0,left:0,zIndex:1e3}},n.createElement("div",{className:"rsh-modal-dialog-box-wrapper",style:{maxWidth:400,margin:"auto",padding:5}},e.children)))},exports.POPOVER_EXPANDED="POPOVER_EXPANDED",exports.PopOverList=y,exports.PopOverOption=function(e){var t=e.children,r=e.optionIndex,i=o(e,g),a=n.useContext(A),u=a.updateInternalContext;return n.createElement("li",Object.assign({onMouseEnter:function(){u("listItemActiveIndex",r)},className:"rsh-search-list-item "+(a.listItemActiveIndex===r&&"rsh-search-list-item__active")},i),t)},exports.PopOverOptionText=function(e){var t=e.className,r=e.value,i=e.as,a=void 0===i?"h3":i,u=o(e,v),s=l().input,c=n.useContext(A).matchingAlgorithm,d=null==r?void 0:r.split(/<mark>/);return n.createElement(f,Object.assign({as:a,classNames:t+" rsh-search-list-item-text"},u),null==d?void 0:d.map((function(e,t){return function(e){return"STRING_MATCHING"===c?e.toLocaleLowerCase()===s:s.includes(e.toLocaleLowerCase())}(e)?n.createElement("span",{key:e+"-"+t,"data-user-value":!0,"data-suggested-value":!0,"data-heightlighted-value":!0},e):n.createElement("span",{key:e+"-"+t},e)})))},exports.RESET_STATE="RESET_STATE",exports.ReactSearchHighlightProvider=d,exports.SEARCH_DATA="SEARCH_DATA",exports.SET_INPUT="SET_INPUT",exports.START_LOADING="START_LOADING",exports.STRING_MATCHING="STRING_MATCHING",exports.SearchBar=w,exports.THROTTLE="THROTTLE",exports.Wrapper=C,exports.__DEV__=!1,exports.context=c,exports.initialState=s,exports.inputAlgorithms=_,exports.matchingAlgorithms=b,exports.useReactSearchHighlight=l;
//# sourceMappingURL=react-search-highlight.cjs.production.min.js.map

@@ -207,4 +207,6 @@ import process from 'process';

return function (input, data) {
var inputArr = input.toLowerCase().split('');
var _input$toLowerCase;
var inputArr = input == null ? void 0 : (_input$toLowerCase = input.toLowerCase()) == null ? void 0 : _input$toLowerCase.split('');
if (inputArr.length === 0) {

@@ -731,3 +733,3 @@ dispatch == null ? void 0 : dispatch({

var handleOnChange = function handleOnChange(e) {
return setInput(e.target.value.toLowerCase());
return setInput(e.target.value);
};

@@ -734,0 +736,0 @@

{
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -10,3 +10,2 @@ # react-search-highlight

<img src="https://img.shields.io/npm/l/react-search-highlight">
<img src="https://img.shields.io/node/v-lts/react-search-highlight">
<img src="https://img.shields.io/github/languages/top/abusayid693/react-search-highlight">

@@ -266,2 +265,2 @@ </div>

This software is open source, licensed under the [MIT License](./LICENSE).
This software is open source, licensed under the [MIT License](./LICENSE).

@@ -12,3 +12,3 @@ import { SEARCH_DATA, __DEV__ } from '../const';

return (input: string, data: any[]) => {
const inputArr = input.toLowerCase().split('');
const inputArr = input?.toLowerCase()?.split('');

@@ -15,0 +15,0 @@ if (inputArr.length === 0) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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