react-search-highlight
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -12,3 +12,4 @@ import React from 'react'; | ||
initialValue?: string; | ||
PrefixIcon: React.FC; | ||
} | ||
export declare const SearchBar: React.FC<Props>; |
@@ -1,13 +0,11 @@ | ||
import React from 'react'; | ||
/// <reference types="react" /> | ||
import { useCharacterMatching, useStringMatching } from '../../hooks'; | ||
declare const Input: React.FC<{ | ||
import { Props } from './index'; | ||
interface InputProps extends Omit<Props, 'matchingAlgorithm'> { | ||
matchingAlgorithm: typeof useCharacterMatching | typeof useStringMatching; | ||
inputAlgorithm: any; | ||
keysToSearch: any[]; | ||
duration: number; | ||
inputAlgorithm: any; | ||
matchingAlgorithm: typeof useCharacterMatching | typeof useStringMatching; | ||
data: any[]; | ||
value?: string; | ||
initialValue?: string; | ||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
}>; | ||
} | ||
declare const Input: ({ keysToSearch, inputAlgorithm, matchingAlgorithm, data, value: controlledValue, onChange, initialValue, PrefixIcon, ...any }: InputProps) => JSX.Element; | ||
export default Input; |
@@ -586,3 +586,3 @@ 'use strict'; | ||
var _excluded$3 = ["keysToSearch", "inputAlgorithm", "matchingAlgorithm", "data", "value", "onChange", "initialValue"]; | ||
var _excluded$3 = ["keysToSearch", "inputAlgorithm", "matchingAlgorithm", "data", "value", "onChange", "initialValue", "PrefixIcon"]; | ||
@@ -597,2 +597,3 @@ var Input = function Input(_ref) { | ||
initialValue = _ref.initialValue, | ||
PrefixIcon = _ref.PrefixIcon, | ||
any = _objectWithoutPropertiesLoose(_ref, _excluded$3); | ||
@@ -640,3 +641,3 @@ | ||
var handleOnChange = function handleOnChange(e) { | ||
return setInput(e.target.value); | ||
return setInput(e.target.value.toLowerCase()); | ||
}; | ||
@@ -654,3 +655,3 @@ | ||
className: "rsh-input-box-logo" | ||
}, React__default.createElement("img", { | ||
}, PrefixIcon ? React__default.createElement(PrefixIcon, null) : React__default.createElement("img", { | ||
src: searchIcon, | ||
@@ -668,3 +669,3 @@ width: "18px" | ||
var _excluded$4 = ["data", "keysToSearch", "inputAlgorithmTimeout", "inputAlgorithm", "matchingAlgorithm", "onChange", "initialValue"]; | ||
var _excluded$4 = ["data", "keysToSearch", "inputAlgorithmTimeout", "inputAlgorithm", "matchingAlgorithm"]; | ||
var inputAlgorithms = { | ||
@@ -690,4 +691,2 @@ DEBOUNCE: useDebounce, | ||
matchingAlgorithm = props.matchingAlgorithm, | ||
onChange = props.onChange, | ||
initialValue = props.initialValue, | ||
any = _objectWithoutPropertiesLoose(props, _excluded$4); | ||
@@ -704,5 +703,3 @@ | ||
matchingAlgorithm: matchingAlgorithms[matchingAlgorithm], | ||
data: data, | ||
onChange: onChange, | ||
initialValue: initialValue | ||
data: data | ||
}, any)); | ||
@@ -709,0 +706,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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 i(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}require("process"),function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.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}");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({},o);default:return e}},o={isLoading:!1,searchData:void 0,input:""},u=t.createContext(null),l=function(){return t.useContext(u)},c=function(e){var r=e.children,i=t.useReducer(a,o),l=i[0],c=i[1],s=function(){c({type:"START_LOADING"})},d=function(){c({type:"END_LOADING"})},p=function(){c({type:"RESET_STATE"})},f=t.useMemo((function(){return{state:l,dispatch:c,startLoading:s,endLoading:d,resetState:p}}),[l]);return n.createElement(u.Provider,{value:f},r)},s=function(e,t,n){return n.some((function(n){return e[n].toLowerCase().includes(t)}))},d=function(e,t,n){var i=r({},e);return n.forEach((function(n){return i[n]=e[n].replaceAll(t,(function(e){return"(<mark>"+e+"</mark>)"}))})),i},p=function(e,n,r,i){void 0===r&&(r="k"),void 0===i&&(i=[]),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)}}),i)},f=["as","children","classNames"],h=function(e){var n=e.as,a=e.children,o=e.classNames,u=i(e,f);return t.createElement(n,r({className:o},u),a)},m=["children"],g=["children","optionIndex"],x=["className","value","as"],v={isPopoverExpanded:!1,listItemActiveIndex:0,updateInternalContext:function(e,t){},dataLength:0},E=t.createContext(v),y=function(e){var i,a,o,u=e.children,c=e.isFunction,s=t.useState(v),d=s[0],p=s[1],f=l(),h=function(e,t){p((function(n){var i;return r({},n,((i={})[e]=t,i))}))},m=t.useRef(null),g=function(e){var n=t.useState(!1),r=n[0],i=n[1];return t.useEffect((function(){function t(t){e.current&&!e.current.contains(t.target)&&i(!1)}return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[e]),[r,i]}(m),x=g[0],y=g[1];return i=function(){h("isPopoverExpanded",x)},a=[x],o=t.useRef(!1),t.useEffect((function(){o.current?i():o.current=!0}),a),n.createElement(E.Provider,{value:r({},d,{updateInternalContext:h})},n.createElement("section",{ref:m,className:"rsh-search-wrapper",onFocusCapture:function(){return y(!0)}},c?u(f):u))},A=["as","children","className","onClick","onMouseDown","onFocusCapture"],C=function(e){var t=e.as,a=e.children,o=e.className,u=e.onClick,l=e.onFocusCapture,c=i(e,A);return n.createElement("div",{style:r({display:"flex",flexDirection:"HStack"===t?"row":"column",alignItems:"center"},c),className:o,onClick:u,onFocusCapture:l},a)},T=["keysToSearch","inputAlgorithm","matchingAlgorithm","data","value","onChange","initialValue"],b=function(e){var r=e.keysToSearch,a=e.inputAlgorithm,o=e.matchingAlgorithm,u=e.data,c=e.value,s=e.onChange,d=e.initialValue,f=i(e,T),h=t.useState(null!=d?d:""),m=h[0],g=h[1],x=l().dispatch,v=n.useContext(E),y=t.useRef(null),A=null!=c?c:m,b=a(A,500),w=o(r);t.useEffect((function(){u&&w(A,u),null==x||x({type:"SET_INPUT",payload:A})}),[b,u]),t.useEffect((function(){v&&v.updateInternalContext("dataLength",u.length)}),[u]);var S=function(){var e;return null==y||null==(e=y.current)?void 0:e.focus()};return p(S,!0),n.createElement(C,{as:"HStack",onClick:S,justifyContent:"center",className:"rsh-input-box",padding:0,height:40,cursor:"text"},n.createElement("figure",{className:"rsh-input-box-logo"},n.createElement("img",{src:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --\x3e\n<svg version="1.1" id="icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">\n<style type="text/css">\n\t.st0{fill:none;}\n</style>\n<title>search</title>\n<path d="M15,14.3L10.7,10c1.9-2.3,1.6-5.8-0.7-7.7S4.2,0.7,2.3,3S0.7,8.8,3,10.7c2,1.7,5,1.7,7,0l4.3,4.3L15,14.3z M2,6.5\n\tC2,4,4,2,6.5,2S11,4,11,6.5S9,11,6.5,11S2,9,2,6.5z"/>\n<rect id="_Transparent_Rectangle_" class="st0" width="16" height="16"/>\n</svg>',width:"18px"})),n.createElement("input",Object.assign({value:null!=c?c:m,onChange:null!=s?s:function(e){return g(e.target.value)},placeholder:"search here",className:"rsh-input",autoFocus:!0,ref:y},f)))},w=["data","keysToSearch","inputAlgorithmTimeout","inputAlgorithm","matchingAlgorithm","onChange","initialValue"],S={DEBOUNCE:function(e,n){var r=t.useState(e),i=r[0],a=r[1];return t.useEffect((function(){var t=setTimeout((function(){a(e)}),n);return function(){clearTimeout(t)}}),[e,n]),i},THROTTLE:function(e,n){void 0===n&&(n=200);var r=t.useState(e),i=r[0],a=r[1],o=t.useRef(),u=t.useRef(null),l=t.useRef(0),c=t.useRef(null);return t.useEffect((function(){o.current?(u.current=e,l.current=!0):(a(e),o.current=setTimeout((function e(){l.current?(l.current=!1,a(u.current),o.current=setTimeout(e,n)):o.current=void 0}),n))}),[e]),c.current=function(){o.current&&clearTimeout(o.current)},t.useEffect((function(){return function(){return c.current()}}),[]),i},DEFAULT:function(e){return e}},I={CHARACTER_MATCHING:function(e){var t=l().dispatch;return function(n,i){var a=n.toLowerCase().split("");if(0!==a.length){var o=new RegExp(a.join("|"),"gi");if(Array.isArray(i)&&Array.isArray(e)&&(!(i.length>0)||Object.keys(i[0]).some((function(t){return e.includes(t)})))){var u=null==i?void 0:i.filter((function(t){return a.every((function(n){return s(t,n,e)}))})).map((function(t){return r({},t,d(t,o,e))}));null==t||t({type:"SEARCH_DATA",payload:u})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}},STRING_MATCHING:function(e){var t=l().dispatch;return function(n,i){if(0!==n.length){var a=new RegExp(n,"gi");if(Array.isArray(i)&&Array.isArray(e)&&(!(i.length>0)||Object.keys(i[0]).some((function(t){return e.includes(t)})))){var o=null==i?void 0:i.filter((function(t){return s(t,n,e)})).map((function(t){return r({},t,d(t,a,e))}));null==t||t({type:"SEARCH_DATA",payload:o})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}}};exports.InternalContext=E,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.PopOverList=function(e){var r=e.children,a=i(e,m),o=t.useRef(null),u=n.useContext(E),l=u.isPopoverExpanded,c=u.listItemActiveIndex,s=u.updateInternalContext,d=u.dataLength;return p((function(){c<d-1&&s("listItemActiveIndex",c+1)}),!1,"arrowdown",[c,d]),p((function(){c>0&&s("listItemActiveIndex",c-1)}),!1,"arrowup",[c]),n.createElement(n.Fragment,null,l&&n.createElement("ul",Object.assign({ref:o,className:"rsh-search-list"},a),r))},exports.PopOverOption=function(e){var t=e.children,r=e.optionIndex,a=i(e,g),o=n.useContext(E),u=o.updateInternalContext;return n.createElement("li",Object.assign({onMouseEnter:function(){u("listItemActiveIndex",r)},className:"rsh-search-list-item "+(o.listItemActiveIndex===r&&"rsh-search-list-item__active")},a),t)},exports.PopOverOptionText=function(e){var t,r=e.className,a=e.value,o=e.as,u=i(e,x),l=null==a?void 0:a.split(/\(([^)]+)\)/);return o=null!=(t=o)?t:"h3",n.createElement(h,Object.assign({as:o,classNames:r+" rsh-search-list-item-text"},u),null==l?void 0:l.map((function(e,t){return"<"===e[0]?n.createElement("span",{key:t,dangerouslySetInnerHTML:{__html:e}}):n.createElement("span",{key:t},e)})))},exports.ReactSearchHighlightProvider=c,exports.SearchBar=function(e){var t,r,a,o,u=e.data,l=e.keysToSearch,c=e.inputAlgorithmTimeout,s=e.inputAlgorithm,d=void 0===s?"DEBOUNCE":s,p=e.matchingAlgorithm,f=e.onChange,h=e.initialValue,m=i(e,w);return l=null!=(t=l)?t:Object.keys(null==u?void 0:u[0]),d=null!=(r=d)?r:"DEBOUNCE",c=null!=(a=c)?a:500,p=null!=(o=p)?o:"CHARACTER_MATCHING",n.createElement(b,Object.assign({keysToSearch:l,duration:c,inputAlgorithm:S[d],matchingAlgorithm:I[p],data:u,onChange:f,initialValue:h},m))},exports.Wrapper=function(e){var t=e.children,r="function"==typeof t;return n.createElement(n.Fragment,null,r?n.createElement(c,null,n.createElement(y,{isFunction:r,children:t})):n.createElement(y,{isFunction:r,children:t}))},exports.context=u,exports.initialState=o,exports.useReactSearchHighlight=l; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});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 i(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}require("process"),function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.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}");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({},o);default:return e}},o={isLoading:!1,searchData:void 0,input:""},u=t.createContext(null),c=function(){return t.useContext(u)},s=function(e){var r=e.children,i=t.useReducer(a,o),c=i[0],s=i[1],l=function(){s({type:"START_LOADING"})},d=function(){s({type:"END_LOADING"})},p=function(){s({type:"RESET_STATE"})},f=t.useMemo((function(){return{state:c,dispatch:s,startLoading:l,endLoading:d,resetState:p}}),[c]);return n.createElement(u.Provider,{value:f},r)},l=function(e,t,n){return n.some((function(n){return e[n].toLowerCase().includes(t)}))},d=function(e,t,n){var i=r({},e);return n.forEach((function(n){return i[n]=e[n].replaceAll(t,(function(e){return"(<mark>"+e+"</mark>)"}))})),i},p=function(e,n,r,i){void 0===r&&(r="k"),void 0===i&&(i=[]),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)}}),i)},f=["as","children","classNames"],h=function(e){var n=e.as,a=e.children,o=e.classNames,u=i(e,f);return t.createElement(n,r({className:o},u),a)},m=["children"],x=["children","optionIndex"],g=["className","value","as"],v={isPopoverExpanded:!1,listItemActiveIndex:0,updateInternalContext:function(e,t){},dataLength:0},E=t.createContext(v),y=function(e){var i,a,o,u=e.children,s=e.isFunction,l=t.useState(v),d=l[0],p=l[1],f=c(),h=function(e,t){p((function(n){var i;return r({},n,((i={})[e]=t,i))}))},m=t.useRef(null),x=function(e){var n=t.useState(!1),r=n[0],i=n[1];return t.useEffect((function(){function t(t){e.current&&!e.current.contains(t.target)&&i(!1)}return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}}),[e]),[r,i]}(m),g=x[0],y=x[1];return i=function(){h("isPopoverExpanded",g)},a=[g],o=t.useRef(!1),t.useEffect((function(){o.current?i():o.current=!0}),a),n.createElement(E.Provider,{value:r({},d,{updateInternalContext:h})},n.createElement("section",{ref:m,className:"rsh-search-wrapper",onFocusCapture:function(){return y(!0)}},s?u(f):u))},A=["as","children","className","onClick","onMouseDown","onFocusCapture"],C=function(e){var t=e.as,a=e.children,o=e.className,u=e.onClick,c=e.onFocusCapture,s=i(e,A);return n.createElement("div",{style:r({display:"flex",flexDirection:"HStack"===t?"row":"column",alignItems:"center"},s),className:o,onClick:u,onFocusCapture:c},a)},T=["keysToSearch","inputAlgorithm","matchingAlgorithm","data","value","onChange","initialValue","PrefixIcon"],b=function(e){var r=e.keysToSearch,a=e.inputAlgorithm,o=e.matchingAlgorithm,u=e.data,s=e.value,l=e.onChange,d=e.initialValue,f=e.PrefixIcon,h=i(e,T),m=t.useState(null!=d?d:""),x=m[0],g=m[1],v=c().dispatch,y=n.useContext(E),A=t.useRef(null),b=null!=s?s:x,w=a(b,500),S=o(r);t.useEffect((function(){u&&S(b,u),null==v||v({type:"SET_INPUT",payload:b})}),[w,u]),t.useEffect((function(){y&&y.updateInternalContext("dataLength",u.length)}),[u]);var I=function(){var e;return null==A||null==(e=A.current)?void 0:e.focus()};return p(I,!0),n.createElement(C,{as:"HStack",onClick:I,justifyContent:"center",className:"rsh-input-box",padding:0,height:40,cursor:"text"},n.createElement("figure",{className:"rsh-input-box-logo"},f?n.createElement(f,null):n.createElement("img",{src:'<?xml version="1.0" encoding="utf-8"?>\n\x3c!-- Generator: Adobe Illustrator 23.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --\x3e\n<svg version="1.1" id="icon" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\n\t width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">\n<style type="text/css">\n\t.st0{fill:none;}\n</style>\n<title>search</title>\n<path d="M15,14.3L10.7,10c1.9-2.3,1.6-5.8-0.7-7.7S4.2,0.7,2.3,3S0.7,8.8,3,10.7c2,1.7,5,1.7,7,0l4.3,4.3L15,14.3z M2,6.5\n\tC2,4,4,2,6.5,2S11,4,11,6.5S9,11,6.5,11S2,9,2,6.5z"/>\n<rect id="_Transparent_Rectangle_" class="st0" width="16" height="16"/>\n</svg>',width:"18px"})),n.createElement("input",Object.assign({value:null!=s?s:x,onChange:null!=l?l:function(e){return g(e.target.value.toLowerCase())},placeholder:"search here",className:"rsh-input",autoFocus:!0,ref:A},h)))},w=["data","keysToSearch","inputAlgorithmTimeout","inputAlgorithm","matchingAlgorithm"],S={DEBOUNCE:function(e,n){var r=t.useState(e),i=r[0],a=r[1];return t.useEffect((function(){var t=setTimeout((function(){a(e)}),n);return function(){clearTimeout(t)}}),[e,n]),i},THROTTLE:function(e,n){void 0===n&&(n=200);var r=t.useState(e),i=r[0],a=r[1],o=t.useRef(),u=t.useRef(null),c=t.useRef(0),s=t.useRef(null);return t.useEffect((function(){o.current?(u.current=e,c.current=!0):(a(e),o.current=setTimeout((function e(){c.current?(c.current=!1,a(u.current),o.current=setTimeout(e,n)):o.current=void 0}),n))}),[e]),s.current=function(){o.current&&clearTimeout(o.current)},t.useEffect((function(){return function(){return s.current()}}),[]),i},DEFAULT:function(e){return e}},I={CHARACTER_MATCHING:function(e){var t=c().dispatch;return function(n,i){var a=n.toLowerCase().split("");if(0!==a.length){var o=new RegExp(a.join("|"),"gi");if(Array.isArray(i)&&Array.isArray(e)&&(!(i.length>0)||Object.keys(i[0]).some((function(t){return e.includes(t)})))){var u=null==i?void 0:i.filter((function(t){return a.every((function(n){return l(t,n,e)}))})).map((function(t){return r({},t,d(t,o,e))}));null==t||t({type:"SEARCH_DATA",payload:u})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}},STRING_MATCHING:function(e){var t=c().dispatch;return function(n,i){if(0!==n.length){var a=new RegExp(n,"gi");if(Array.isArray(i)&&Array.isArray(e)&&(!(i.length>0)||Object.keys(i[0]).some((function(t){return e.includes(t)})))){var o=null==i?void 0:i.filter((function(t){return l(t,n,e)})).map((function(t){return r({},t,d(t,a,e))}));null==t||t({type:"SEARCH_DATA",payload:o})}}else null==t||t({type:"SEARCH_DATA",payload:[]})}}};exports.InternalContext=E,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.PopOverList=function(e){var r=e.children,a=i(e,m),o=t.useRef(null),u=n.useContext(E),c=u.isPopoverExpanded,s=u.listItemActiveIndex,l=u.updateInternalContext,d=u.dataLength;return p((function(){s<d-1&&l("listItemActiveIndex",s+1)}),!1,"arrowdown",[s,d]),p((function(){s>0&&l("listItemActiveIndex",s-1)}),!1,"arrowup",[s]),n.createElement(n.Fragment,null,c&&n.createElement("ul",Object.assign({ref:o,className:"rsh-search-list"},a),r))},exports.PopOverOption=function(e){var t=e.children,r=e.optionIndex,a=i(e,x),o=n.useContext(E),u=o.updateInternalContext;return n.createElement("li",Object.assign({onMouseEnter:function(){u("listItemActiveIndex",r)},className:"rsh-search-list-item "+(o.listItemActiveIndex===r&&"rsh-search-list-item__active")},a),t)},exports.PopOverOptionText=function(e){var t,r=e.className,a=e.value,o=e.as,u=i(e,g),c=null==a?void 0:a.split(/\(([^)]+)\)/);return o=null!=(t=o)?t:"h3",n.createElement(h,Object.assign({as:o,classNames:r+" rsh-search-list-item-text"},u),null==c?void 0:c.map((function(e,t){return"<"===e[0]?n.createElement("span",{key:t,dangerouslySetInnerHTML:{__html:e}}):n.createElement("span",{key:t},e)})))},exports.ReactSearchHighlightProvider=s,exports.SearchBar=function(e){var t,r,a,o,u=e.data,c=e.keysToSearch,s=e.inputAlgorithmTimeout,l=e.inputAlgorithm,d=void 0===l?"DEBOUNCE":l,p=e.matchingAlgorithm,f=i(e,w);return c=null!=(t=c)?t:Object.keys(null==u?void 0:u[0]),d=null!=(r=d)?r:"DEBOUNCE",s=null!=(a=s)?a:500,p=null!=(o=p)?o:"CHARACTER_MATCHING",n.createElement(b,Object.assign({keysToSearch:c,duration:s,inputAlgorithm:S[d],matchingAlgorithm:I[p],data:u},f))},exports.Wrapper=function(e){var t=e.children,r="function"==typeof t;return n.createElement(n.Fragment,null,r?n.createElement(s,null,n.createElement(y,{isFunction:r,children:t})):n.createElement(y,{isFunction:r,children:t}))},exports.context=u,exports.initialState=o,exports.useReactSearchHighlight=c; | ||
//# sourceMappingURL=react-search-highlight.cjs.production.min.js.map |
@@ -610,3 +610,3 @@ import React, { createContext, useContext, useReducer, useMemo, useState, useEffect, useRef, createElement } from 'react'; | ||
var _excluded$3 = ["keysToSearch", "inputAlgorithm", "matchingAlgorithm", "data", "value", "onChange", "initialValue"]; | ||
var _excluded$3 = ["keysToSearch", "inputAlgorithm", "matchingAlgorithm", "data", "value", "onChange", "initialValue", "PrefixIcon"]; | ||
@@ -621,2 +621,3 @@ var Input = function Input(_ref) { | ||
initialValue = _ref.initialValue, | ||
PrefixIcon = _ref.PrefixIcon, | ||
any = _objectWithoutPropertiesLoose(_ref, _excluded$3); | ||
@@ -664,3 +665,3 @@ | ||
var handleOnChange = function handleOnChange(e) { | ||
return setInput(e.target.value); | ||
return setInput(e.target.value.toLowerCase()); | ||
}; | ||
@@ -678,3 +679,3 @@ | ||
className: "rsh-input-box-logo" | ||
}, React.createElement("img", { | ||
}, PrefixIcon ? React.createElement(PrefixIcon, null) : React.createElement("img", { | ||
src: searchIcon, | ||
@@ -692,3 +693,3 @@ width: "18px" | ||
var _excluded$4 = ["data", "keysToSearch", "inputAlgorithmTimeout", "inputAlgorithm", "matchingAlgorithm", "onChange", "initialValue"]; | ||
var _excluded$4 = ["data", "keysToSearch", "inputAlgorithmTimeout", "inputAlgorithm", "matchingAlgorithm"]; | ||
var inputAlgorithms = { | ||
@@ -714,4 +715,2 @@ DEBOUNCE: useDebounce, | ||
matchingAlgorithm = props.matchingAlgorithm, | ||
onChange = props.onChange, | ||
initialValue = props.initialValue, | ||
any = _objectWithoutPropertiesLoose(props, _excluded$4); | ||
@@ -728,5 +727,3 @@ | ||
matchingAlgorithm: matchingAlgorithms[matchingAlgorithm], | ||
data: data, | ||
onChange: onChange, | ||
initialValue: initialValue | ||
data: data | ||
}, any)); | ||
@@ -733,0 +730,0 @@ }; |
{ | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
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
Sorry, the diff of this file is not supported yet
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
212815
2242