@sajari/react-hooks
Advanced tools
Comparing version 1.4.6 to 1.4.7
# Change Log | ||
## 1.4.7 | ||
### Patch Changes | ||
- [`0662ebcb`](https://github.com/sajari/sdk-react/commit/0662ebcb580635607db02eb5f766b182ad42a673) [#413](https://github.com/sajari/sdk-react/pull/413) Thanks [@zlatanpham](https://github.com/zlatanpham)! - Made clear method public in useSearchContext so that it can be used to reset the response. | ||
## 1.4.6 | ||
@@ -4,0 +10,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("@sajari/react-sdk-utils"),n=require("react"),i=e(n),r=require("@sajari/sdk-js"),s=e(require("js-cookie"));function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var a,c={qParam:"q",qOverrideParam:"q.override",qSuggestionsParam:"q.suggestions",resultsPerPageParam:"resultsPerPage",pageParam:"page",maxSuggestions:10},l=function(){function e(){this.listeners=[]}var t=e.prototype;return t.listen=function(e){var t=this;return this.listeners.push(e),function(){return t.unlisten(e)}},t.unlisten=function(e){var t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)},t.notify=function(e){this.listeners.forEach((function(t){try{e(t)}catch(e){console&&console.error&&console.error(e)}}))},e}(),f=["page-close-analytics","body-reset-analytics","result-clicked-analytics"],p=function(){function e(e,n){var i,r=this;this.beforeunload=function(){r.enabled&&r.body&&(r.listeners.get("page-close-analytics").notify((function(e){e(r.body)})),r.enabled=!1)},this.resetBody=function(){r.enabled&&(r.listeners.get("body-reset-analytics").notify((function(e){e(r.body)})),r.longestNonAutocompletedBody="",r.longestAutocompletedBody="",r.enabled=!1)},this.responseUpdated=function(e){if(!e.isEmpty()&&!e.isError()){r.enabled=!0;var t=e.getQueryValues().get(r.bodyLabel)||"",n=e.getValues().get(r.bodyAutocompletedLabel)||t;r.body=n,t.length>=r.longestNonAutocompletedBody.length&&(r.longestNonAutocompletedBody=t,r.longestAutocompletedBody=n)}},this.resultClicked=function(){r.enabled&&r.body&&(r.listeners.get("result-clicked-analytics").notify((function(e){e(r.body)})),r.longestNonAutocompletedBody="",r.longestAutocompletedBody="",r.enabled=!1)},this.enabled=!1,this.body="",this.pipeline=e,this.tracking=n,this.listeners=new Map(Object.entries(((i={})["page-close-analytics"]=new l,i["body-reset-analytics"]=new l,i["result-clicked-analytics"]=new l,i))),this.longestNonAutocompletedBody="",this.longestAutocompletedBody="",this.bodyLabel="q",this.bodyAutocompletedLabel="q",t.isSSR()||window.addEventListener("beforeunload",this.beforeunload),this.pipeline.listen("response-updated",this.responseUpdated),this.pipeline.listen("result-clicked",this.resultClicked),this.tracking.listen("tracking-reset",this.resetBody)}return e.prototype.listen=function(e,t){if(-1===f.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},e}();!function(e){e.UniversalAnalytics="_ua",e.AnalyticsJS="ga",e.GTag="gtag"}(a||(a={}));var g={decodeUriArgs:function(e){var t={},n=e.split("&");for(var i in n)if(n.hasOwnProperty(i)){var r=n[i].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t},encodeUriArgs:function(e){var t=[];return Object.keys(e).forEach((function(n){return t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))})),t.join("&")},mergeQueryStr:function(e){for(var t=this,n="string"==typeof e?this.decodeUriArgs(e):e,i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return r.forEach((function(e){var i="string"==typeof e?t.decodeUriArgs(e):e;Object.keys(i).forEach((function(e){n[e]=i[e]}))})),this.encodeUriArgs(n)},augmentUri:function(e,t){var n=/^([^?]+)\?(.+)+$/.exec(e);return n?n[1]+"?"+this.mergeQueryStr(n[2],t):e+"?"+this.encodeUriArgs(t)},getURLParameter:function(e){var t=new RegExp("[?|&]"+e+"=([^&;]+?)(&|#|;|$)").exec(window.location.search)||[void 0,""];return decodeURIComponent(t[1].replace(/\+/g,"%20"))||null}},d=function(){function e(e,n,i){var r=this;void 0===i&&(i="q"),this.unregisterFunctions=[],this.detatch=function(){return r.unregisterFunctions.forEach((function(e){return e()}))},this.onBodyReset=function(e){return r.sendGAPageView(e)},this.onResultClicked=function(e){return r.sendGAPageView(e)},this.onPageClose=function(e){return r.sendGAPageView(e)},this.unregisterFunctions.push(e.listen("page-close-analytics",this.onPageClose)),this.unregisterFunctions.push(e.listen("body-reset-analytics",this.onBodyReset)),this.unregisterFunctions.push(e.listen("result-clicked-analytics",this.onResultClicked)),this.id=t.isSSR()?null:void 0!==n?n:t.isFunction(window[a.AnalyticsJS])?a.AnalyticsJS:t.isFunction(window[a.UniversalAnalytics])?a.UniversalAnalytics:t.isFunction(window[a.GTag])?a.GTag:null,this.param=i}return e.prototype.sendGAPageView=function(e){if(this.id&&!t.isSSR()&&t.isFunction(window[this.id])){var n,i=g.augmentUri(window.location.href.substring(window.location.origin.length),((n={})[this.param]=e,n));this.id===a.GTag?window[this.id]("event","page_view",{page_location:i}):window[this.id]("send","pageview",i)}},e}(),h=["selection-updated","options-updated"],v=function(){function e(e){var n,i=e.initial,r=void 0===i?[]:i,s=e.joinOperator,o=void 0===s?"OR":s,u=e.multi,a=void 0===u||u,c=e.options,f=void 0===c?{}:c,p=e.array,g=void 0!==p&&p,d=e.name,h=e.field,v=e.group,m=e.count,y=void 0===m?t.isEmpty(f):m;t.isString(r)&&(r=[r]),this.current=r,this.initial=r,this.name=d,this.group=v,this.field=h,this.count=y,this.options=f,this.multi=a,this.array=g,this.joinOperator=o,this.listeners=((n={})["selection-updated"]=new l,n["options-updated"]=new l,n)}var n=e.prototype;return n.listen=function(e,t){if(!h.includes(e))throw new Error('Unknown event type "'+e+'"');return this.listeners[e].listen(t)},n.set=function(e,t){var n=this;if(void 0===t&&(t=!1),t){var i=e.filter((function(e){return!n.current.includes(e)}));this.current=[].concat(this.current,i)}else this.current=e;this.emitSelectionUpdated()},n.remove=function(e){this.current=this.current.filter((function(t){return!e.includes(t)})),this.emitSelectionUpdated()},n.isSet=function(e){return this.current.includes(e)},n.setOptions=function(e,t){void 0===t&&(t=!1),this.options=t?o({},this.options,e):e,this.emitOptionsUpdated()},n.getName=function(){return this.name},n.getGroup=function(){return this.group},n.getField=function(){return this.field},n.getCount=function(){return this.count},n.getOptions=function(){return this.options},n.get=function(){return this.current},n.isArray=function(){return this.array},n.isMulti=function(){return this.multi},n.filter=function(){var e=this;if(t.isEmpty(this.options)&&this.count)return this.current.map((function(t){return"("+(e.array?e.field+' ~ ["'+t+'"]':e.field+' = "'+t+'"')+")"})).join(" "+this.joinOperator+" ");var n=this.current.map((function(n){var i=e.options[n];return t.isFunction(i)&&(i=i()),t.isEmpty(i)||(i=function(e){void 0===e&&(e="");var n=e;return[","].forEach((function(i){n=t.replaceAll(e,i,"\\"+i)})),n}(i)),i})).filter(Boolean);return n.length<2?n.join(""):n.map((function(e){return"("+e+")"})).join(" "+this.joinOperator+" ")},n.getBuckets=function(){var e=this;return Object.entries(this.options).map((function(t){return e.name+"_"+t[0]+":"+t[1]})).join(",")},n.reset=function(){this.current=[].concat(this.initial),this.emitSelectionUpdated()},n.emitSelectionUpdated=function(){this.listeners["selection-updated"].notify((function(e){e()}))},n.emitOptionsUpdated=function(){this.listeners["options-updated"].notify((function(e){e()}))},e}(),m=["range-updated"],y=function(){function e(e){var n,i=e.field,r=e.name,s=e.group,o=e.aggregate,u=void 0===o||o,a=e.initial,c=e.min,f=void 0===c?0:c,p=e.max,g=void 0===p?u?0:100:p,d=e.step,h=void 0===d?1:d,v=e.formatter,m=void 0===v?function(e){return e.map((function(e){return t.roundToStep(e,h)}))}:v;this.initial=void 0===a?u?null:[f,g]:a,this.range=this.initial,this.name=r,this.group=s,this.field=i,this.formatter=m,this.min=f,this.max=g,this.step=h,this.aggregate=u,this.listeners=((n={})["range-updated"]=new l,n)}var n=e.prototype;return n.listen=function(e,t){if(!m.includes(e))throw new Error('Unknown event type "'+e+'"');return this.listeners[e].listen(t)},n.get=function(){return this.range},n.set=function(e,t){void 0===t&&(t=!0),this.range=e?this.formatter(e):e,t&&this.emitRangeUpdated()},n.getName=function(){return this.name},n.getGroup=function(){return this.group},n.getField=function(){return this.field},n.setMin=function(e){this.min=e},n.setMax=function(e){this.max=e},n.getMinMax=function(){return[this.min,this.max]},n.getStep=function(){return this.step},n.filter=function(){return this.range?this.field+" >= "+this.range[0]+" AND "+this.field+" <= "+this.range[1]:""},n.isAggregate=function(){return this.aggregate},n.hasChanged=function(){return this.range&&this.initial?this.range[0]!==this.initial[0]||this.range[1]!==this.initial[1]:this.range===this.initial},n.reset=function(e){void 0===e&&(e=!0),this.range=t.isArray(this.initial)?[].concat(this.initial):this.initial,e&&this.emitRangeUpdated()},n.format=function(e){return this.formatter(e)},n.emitRangeUpdated=function(){var e=this;this.listeners["range-updated"].notify((function(t){t(e)}))},e}(),b=function(e){return"ARRAY_MATCH("+e.filter(Boolean).join(" AND ")+")"};function w(e,n,i){var r=e.map((function(e){return{group:e.getGroup(),field:e.getField(),expression:e.filter(),count:e instanceof v&&e.getCount()}}));"filter"===n&&(r=r.filter((function(e){return Boolean(e.expression)})));var s=Object.entries(t.groupBy(r,"group")).filter((function(e){return Boolean(e[0])})).reduce((function(e,t){var n;return o({},e,((n={})[t[0]]=t[1].map((function(e){return e.expression})),n))}),{});if("filter"===n){var u,a=r.filter((function(e){return!e.group&&!e.count})).map((function(e){return"("+e.expression+")"}));return(u=Object.entries(s).reduce((function(e,n){var i=n[1];return"undefined"===n[0]||t.isEmpty(i)?e:[].concat(e,[b(i)])}),[])).concat.apply(u,a).join(i)}return r.filter((function(e){var n=e.count;return!t.isEmpty(e.field)&&n})).map((function(e){var n=e.group,i=e.expression,r=e.count;return n&&!t.isEmpty(s[n])?b(s[n]):r?i:null})).filter((function(e){return null!==e})).join(i)}var E=["selection-updated","options-updated","range-updated"];function S(e,t){var n;void 0===t&&(t="AND");var i=((n={})["selection-updated"]=new l,n["options-updated"]=new l,n["range-updated"]=new l,n),r=[];return e.forEach((function(e){e instanceof v&&r.push(e.listen("selection-updated",(function(){i["selection-updated"].notify((function(t){t(e)}))})),e.listen("options-updated",(function(){i["options-updated"].notify((function(t){t(e)}))}))),e instanceof y&&r.push(e.listen("range-updated",(function(){i["range-updated"].notify((function(t){t(e)}))})))})),{filter:function(){return w(e,"filter"," "+t+" ")},listen:function(e,t){if(-1===E.indexOf(e))throw new Error('Unknown event type "'+e+'"');return i[e].listen(t)},buckets:function(){return e.filter((function(e){return e instanceof v&&!e.getCount()})).map((function(e){return e instanceof v&&e.getBuckets()})).filter(Boolean).join(",")},countFilters:function(){return w(e,"countFilters",",")},count:function(){return e.filter((function(e){return e instanceof v&&e.getCount()})).map((function(e){return e instanceof v&&e.getField()})).filter(Boolean).join(",")},removeChildFilterListeners:function(){r.forEach((function(e){return e()}))},max:function(){return e.filter((function(e){return e instanceof y&&e.isAggregate()})).map((function(e){return e.getField()})).join(",")},min:function(){return e.filter((function(e){return e instanceof y&&e.isAggregate()})).map((function(e){return e.getField()})).join(",")}}}var k=function(){function e(e,t,n,i){this.error=e,this.queryValues=t,this.response=n,this.values=i}var t=e.prototype;return t.isEmpty=function(){return null===this.error&&void 0===this.response&&void 0===this.values&&void 0===this.queryValues},t.isError=function(){return null!==this.error},t.getError=function(){return this.error},t.getQueryValues=function(){return this.queryValues},t.getResponse=function(){return this.response},t.getValues=function(){return this.values},t.getResults=function(){return void 0!==this.response?this.response.get("results"):void 0},t.getTotalResults=function(){return void 0!==this.response?this.response.get("totalResults"):void 0},t.getTime=function(){return void 0!==this.response?this.response.get("time"):void 0},t.getAggregates=function(){if(void 0!==this.response){var e=this.response.get("aggregates");if(void 0!==e)return e}},t.getAggregateFilters=function(){if(void 0!==this.response){var e=this.response.get("aggregateFilters");if(void 0!==e)return e}},e}(),P=["tracking-reset"],R=function(){function e(){var e;this.clientTracking=null,this.listeners=new Map(Object.entries(((e={})["tracking-reset"]=new l,e)))}var t=e.prototype;return t.listen=function(e,t){if(-1===P.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},t.emitTrackingReset=function(e){this.listeners.get("tracking-reset").notify((function(t){t(e)}))},t.reset=function(e){this.clientTracking.reset(),void 0!==e&&this.emitTrackingReset(e)},t.next=function(e){if(null===this.clientTracking)throw new Error("clientTracking is null");return this.clientTracking.next(e)},e}(),x=function(){var e={},t=s.get("_ga");t&&(e.ga=t);var n=s.get("sjID");return n&&(e.sjID=n),e},A=function(e){function t(t,n){var i;return void 0===t&&(t="url"),void 0===n&&(n="q"),(i=e.call(this)||this).field=t,i.clientTracking=new r.InteractiveSession(n,new r.DefaultSession(r.TrackingType.Click,i.field,x())),i}return u(t,e),t}(R),C=function(e){function t(){var t;return(t=e.call(this)||this).field="_id",t.clientTracking=new r.DefaultSession(r.TrackingType.None,t.field,x()),t}return u(t,e),t}(R),T=function(e){function t(t){var n;return void 0===t&&(t="url"),(n=e.call(this)||this).field=t,n.clientTracking=new r.DefaultSession(r.TrackingType.PosNeg,n.field,x()),n}return u(t,e),t}(R),O=["search-sent","response-updated","result-clicked"],U=function(){function e(e,n,i,s){var o=this;void 0===i&&(i=new C),void 0===s&&(s=[d]),this.response=new k(null);var u=e.account,a=e.collection,c=e.endpoint,f=e.key,g=e.secret;this.config=e;var h={name:void 0,version:void 0};t.isString(n)?h.name=n:"name"in n&&(h.name=n.name,h.version=n.version),this.client=t.isSSR()?new r.Client(u,a,c,f,g):new r.Client(u,a,c),this.pipeline=this.client.pipeline(h.name,h.version),this.tracking=i,this.listeners=new Map([["search-sent",new l],["response-updated",new l],["result-clicked",new l]]),this.searchCount=0,this.response=new k(null),this.analytics=new p(this,this.tracking),s.forEach((function(e){new e(o.analytics)}))}var n=e.prototype;return n.listen=function(e,t){if(-1===O.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},n._emitSearchSent=function(e){this.listeners.get("search-sent").notify((function(t){t(e)}))},n._emitResponseUpdated=function(e){this.listeners.get("response-updated").notify((function(t){t(e)}))},n.emitResultClicked=function(e){this.listeners.get("result-clicked").notify((function(t){t(e)}))},n.search=function(e){var t=this;this.searchCount+=1;var n=this.searchCount;this.pipeline.search(e,this.tracking.next(e)).then((function(i){var r=i[0],s=i[1];n<t.searchCount||(t.response=new k(null,new Map(Object.entries(e)),new Map(Object.entries(r)),new Map(Object.entries(s))))})).catch((function(i){console.error(i),n<t.searchCount||(t.response=new k(i,new Map(Object.entries(e)),void 0,void 0))})).finally((function(){t._emitResponseUpdated(t.response)})),this._emitSearchSent(e)},n.clearResponse=function(e){this.tracking.next(e),this.searchCount+=1,this.response=new k(null),this._emitResponseUpdated(this.response)},n.getResponse=function(){return this.response},n.getAnalytics=function(){return this.analytics},n.getClient=function(){return this.client},n.getTracking=function(){return this.tracking},e}(),j=function(){function e(e){var t;void 0===e&&(e={}),this.listeners=new Map([["values-changed",new l]]),this.variables=new Map(Object.entries(o(((t={})[c.qParam]="",t[c.resultsPerPageParam]=15,t),e)))}var t=e.prototype;return t.listen=function(e,t){if("values-changed"!==e)throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},t.set=function(e){this._set(e),this._emitUpdated(e)},t.get=function(){var e={};return this.variables.forEach((function(t,n){e[n]="function"==typeof t?t():Array.isArray(t)?t.join(","):String(t)})),e},t._emitUpdated=function(e){var t=this;this.listeners.get("values-changed").notify((function(n){return n(e,(function(e){return t._set(e)}))}))},t._set=function(e){var t=this;Object.keys(e).forEach((function(n){void 0===e[n]?t.variables.delete(n):t.variables.set(n,e[n])}))},e}(),N=function(e,t,n){var i=e&&t&&t.get(n.qParam)||"",r=[];return t&&(r=(t.get(n.qSuggestionsParam)||"").split(",").filter((function(e){return e.length>0})).slice(0,n.maxSuggestions)),{completion:i,query:e,suggestions:r}},_=function(e,t,n){var i=e.get()[t.qParam]||"",r=n.getValues();return N(i,r,t)},q=function(e,t,n){var i=e.get()[n.qParam]||"",r=t.getResponse().getValues();return N(i,r,n)},F=t.createContext({strict:!0,name:"PipelineContext"}),M=F[0],V=F[1],B={response:null,query:"",completion:"",suggestions:[],config:c},D=/\d+\s-\s\d+/gm,I=D.test.bind(D),L=new Intl.Collator(t.isSSR()?"en-US":window.navigator.language,{numeric:!0}),G=function(e,t,n){if(void 0===t&&(t="alpha"),void 0===n&&(n=!0),"none"===t)return e;var i="count"!==t;return[].concat(e).sort((function(e,t){var r=t[0],s=t[1],o=String(i?e[0]:e[1]),u=String(i?r:s);switch(!0){case[o,u].every(I):var a=o.split(" - ").map(Number)[0],c=u.split(" - ").map(Number)[0];return n?L.compare(String(a),String(c)):L.compare(String(c),String(a));case o.startsWith(">"):case u.startsWith("<"):return n?1:-1;case o.startsWith("<"):case u.startsWith(">"):return n?-1:1}return n?L.compare(String(o),String(u)):L.compare(String(u),String(o))}))};function Q(e){void 0===e&&(e="search");var t=V(),i=t.paginate,r=t[e],s=r.response,o=r.config,u=null==s?void 0:s.getQueryValues(),a=(null==u?void 0:u.get(o.pageParam))?parseInt(u.get(o.pageParam),10):1,c=(null==u?void 0:u.get(o.resultsPerPageParam))?parseInt(null==u?void 0:u.get(o.resultsPerPageParam),10):15,l=(null==s?void 0:s.getTotalResults())||0,f=Math.ceil(l/c),p=n.useMemo((function(){return a<f}),[a,f]),g=n.useMemo((function(){return a>1}),[a]),d=n.useCallback((function(){return p&&i(a+1)}),[i,p]),h=n.useCallback((function(){return g&&i(a-1)}),[i,g]);return{page:a,pageCount:f,totalResults:l,setPage:i,resultsPerPage:c,hasNext:p,hasPrevious:g,nextPage:d,previousPage:h}}exports.ClickTracking=A,exports.EVENT_ANALYTICS_BODY_RESET="body-reset-analytics",exports.EVENT_ANALYTICS_PAGE_CLOSED="page-close-analytics",exports.EVENT_ANALYTICS_RESULT_CLICKED="result-clicked-analytics",exports.EVENT_OPTIONS_UPDATED="options-updated",exports.EVENT_RANGE_UPDATED="range-updated",exports.EVENT_RESPONSE_UPDATED="response-updated",exports.EVENT_RESULT_CLICKED="result-clicked",exports.EVENT_SEARCH_SENT="search-sent",exports.EVENT_SELECTION_UPDATED="selection-updated",exports.EVENT_TRACKING_RESET="tracking-reset",exports.EVENT_VALUES_UPDATED="values-changed",exports.FieldDictionary=function(e){var t=null!=e?e:{},n=t.id,i=t.url,r=void 0===i?"url":i,s=t.title,o=void 0===s?"title":s,u=t.subtitle,a=void 0===u?"url":u,c=t.description,l=void 0===c?"description":c,f=t.image,p=void 0===f?"image":f,g=t.price,d=void 0===g?"price":g,h=t.originalPrice,v=void 0===h?"originalPrice":h,m=t.rating,y=void 0===m?"rating":m;this.id=void 0===n?"_id":n,this.url=r,this.title=o,this.subtitle=a,this.description=l,this.image=p,this.price=d,this.originalPrice=v,this.rating=y},exports.FilterBuilder=v,exports.Pipeline=U,exports.PosNegTracking=T,exports.RangeFilterBuilder=y,exports.Response=k,exports.SearchProvider=function(e){var r,s,u=e.children,a=e.search,l=e.autocomplete,f=e.defaultFilter,p=e.searchOnLoad,g=function(e){if(!t.isString(e)||t.isEmpty(e))return null;var n=JSON.parse(e),i=n.queryValues,r=n.response,s=void 0===r?{}:r,o=n.values,u=void 0===o?{}:o;return new k(null,new Map(Object.entries(void 0===i?{}:i)),new Map(Object.entries(s)),new Map(Object.entries(u)))}(e.initialResponse),d=n.useState(!1),h=d[0],v=d[1],m=n.useState(!1),y=m[0],b=m[1],w=n.useState(o({},B,{response:g})),E=w[0],P=w[1],R=n.useState(B),x=R[0],A=R[1],C=n.useState(!1),T=C[0],O=C[1],N=n.useRef(),F=n.useRef(),V=n.useRef(l),D=n.useRef(null!=(r=a.variables)?r:new j),I=n.useRef(null!=(s=null==l?void 0:l.variables)?s:new j),L=a.pipeline.getResponse();if(L.isEmpty()&&null!==g&&(L=g),a.variables||T||Object.assign(a,{variables:D.current}),!l||l.variables||T||Object.assign(l,{variables:I.current}),!T){var G,Q,J,Y=S(null!=(G=a.filters)?G:[]),W=null!=(Q=D.current.get().filter)?Q:"",K=null!=(J=null==f?void 0:f.toString())?J:"";D.current.set({filter:function(){var e=Y.filter();return[K,W,t.isEmpty(e)?'_id != ""':e].filter(Boolean).join(" AND ")},countFilters:function(){return Y.countFilters()},buckets:function(){return Y.buckets()},count:function(){return Y.count()},min:function(){return Y.min()},max:function(){return Y.max()}})}var H=n.useCallback((function(e){return function(t,n){var i;void 0===n&&(n=!1);var r="autocomplete"===e?V.current:a,s="autocomplete"===e?x:E,u="autocomplete"===e?F:N;("autocomplete"===e?b:v)(!0),P((function(e){return o({},e,{query:null!=t?t:e.query})}));var c=r.pipeline,l=r.variables,f=s.config,p=((i={})[f.qParam]=null!=t?t:l.get()[f.qParam],i[f.qOverrideParam]=void 0,i[f.pageParam]=void 0,i);n&&(p[f.qOverrideParam]="true"),l.set(p),u.current&&clearTimeout(u.current),u.current=setTimeout((function(){c.search(l.get())}),50)}}),[]);n.useEffect((function(){var e=o({},c,a.config);P((function(t){return o({},t,{response:L,query:D.current.get()[e.qParam]||"",config:e})})),A((function(e){return o({},e,{config:o({},c,a.config)})}));var t,n=[];if(a.filters){var i=S(a.filters);n.push(i.listen("selection-updated",(function(){return H("search")()})),i.listen("range-updated",(function(){return H("search")()})),i.removeChildFilterListeners)}if(n.push(a.pipeline.listen("response-updated",(function(e){var n;clearTimeout(t),t=setTimeout((function(){v(!1),P((function(t){return o({},t,{response:e},_(D.current,t.config,e))}))}),0===(null==(n=e.getResults())?void 0:n.length)?500:20)}))),n.push(D.current.listen("values-changed",(function(){return P((function(e){return o({},e,q(D.current,a.pipeline,e.config))}))}))),!V.current){var r=a.pipeline.config;V.current={pipeline:new U({account:r.account,collection:r.collection,endpoint:r.endpoint},"autocomplete"),variables:I.current}}return n.push(V.current.pipeline.listen("response-updated",(function(e){b(!1),A((function(t){return o({},t,{response:e},_(I.current,t.config,e))}))}))),n.push(I.current.listen("values-changed",(function(){return A((function(e){return o({},e,q(I.current,V.current.pipeline,e.config))}))}))),p&&a.pipeline.search(D.current.get()),O(!0),function(){n.forEach((function(e){return e()}))}}),[]);var $,z,X,Z=n.useCallback((function(e){return function(t){var n="autocomplete"===e?V.current:a,i=n.pipeline,r=n.variables;void 0!==t&&r.set(t),i.clearResponse(r.get())}}),[]),ee=n.useCallback((function(e){var t,n=a.pipeline,i=a.variables;i.set(((t={})[E.config.pageParam]=String(e),t)),n.search(i.get())}),[a.pipeline,a.variables,E.config]),te=n.useCallback((function(e){return a.pipeline.emitResultClicked(e)}),[]);return i.createElement(M,{value:($={autocomplete:x,search:E},o({},$,{search:o({},$.search,{variables:D.current,filters:a.filters,pipeline:a.pipeline,search:H("search"),clear:Z("search"),fields:a.fields,searching:h}),autocomplete:o({},$.autocomplete,{variables:I.current,filters:a.filters,pipeline:null==(z=V.current)?void 0:z.pipeline,search:H("autocomplete"),clear:Z("autocomplete"),fields:null==(X=V.current)?void 0:X.fields,searching:y}),resultClicked:te,paginate:ee}))},u)},exports.Variables=j,exports.combineFilters=S,exports.useAutocomplete=function(){var e=V().autocomplete;return{suggestions:e.suggestions,search:e.search,completion:e.completion,searching:e.searching}},exports.useFilter=function(e,i){void 0===i&&(i={});var r=V().search,s=r.filters,u=void 0===s?[]:s,a=r.response,c=n.useMemo((function(){return u.filter((function(t){return t instanceof v&&t.getName()===e}))[0]}),[]);if(!c)throw new Error('Filter "'+e+"\" doesn't exist.");var l=n.useState(c.get()),f=l[0],p=l[1];n.useEffect((function(){var e=c.listen("selection-updated",(function(){p(c.get())}));return function(){e()}}),[]);var g=i.sort,d=void 0===g?"alpha":g,h=i.sortAscending,m=void 0===h?"count"!==d:h;return{options:n.useMemo((function(){if(!a||(null==a?void 0:a.isEmpty()))return[];var n=a.getAggregates(),i=a.getAggregateFilters(),r=c.getCount(),s=c.getField();if(r&&s){var u=c.isArray(),l={};if(!(l=((i||{})[s]||{}).count)){var f=((n||{})[s]||{}).count;l=void 0===f?{}:f}var p=G(Object.entries(l),d,m).map((function(e){var t=e[0];return{label:t,count:e[1],value:u?s+' ~ ["'+t+'"]':s+' = "'+t+'"'}}));return c.setOptions(p.reduce((function(e,t){var n;return o({},e,((n={})[t.label]=t.value,n))}),{})),p}return G(Object.entries(c.getOptions()),d,m).map((function(n){var i=n[0];return{label:i,value:n[1],count:function(e,n){var i,r,s,o,u;if(!e||(null==e?void 0:e.isEmpty()))return null;var a=0,c=e.getAggregates(),l=e.getAggregateFilters();return l&&Object.keys(null!=(i=null==(r=l.buckets)?void 0:r.count)?i:{}).includes(n)?a=l.buckets.count:c&&Object.keys(null!=(s=null==(o=c.buckets)?void 0:o.count)?s:{}).includes(n)&&(a=c.buckets.count),t.isNumber(a)?0:null!=(u=a[n])?u:0}(a,e+"_"+i)}}))}),[JSON.stringify(null==a?void 0:a.getResults())]),setSelected:function(e,t){void 0===t&&(t=!1),c.set(e,t)},selected:f,reset:function(){c.reset()},multi:c.isMulti()}},exports.usePagination=Q,exports.useQuery=function(){var e=V().search,t=e.search,i=e.variables;return{query:e.query,setQuery:n.useCallback((function(e){i.set({q:e}),t(e)}),[t,i])}},exports.useRangeFilter=function(e){var i=V().search,r=i.filters,s=void 0===r?[]:r,o=i.response,u=i.query,a=n.useRef(null),c=n.useRef(!1),l=n.useMemo((function(){return s.filter((function(t){return t instanceof y&&t.getName()===e}))[0]}),[]),f=l.isAggregate(),p=l.getMinMax();if(!l)throw new Error('Filter "'+e+"\" doesn't exist.");var g=n.useState(l.get()),d=g[0],h=g[1],m=n.useState(p[0]),b=m[0],w=m[1],E=n.useState(p[1]),S=E[0],k=E[1];n.useEffect((function(){f&&null!==a.current&&l.reset(!1)}),[u]),n.useEffect((function(){if(!f)return function(){};var e=s.filter((function(e){return e instanceof v})).map((function(e){return e.listen("selection-updated",(function(){l.reset(!1),c.current=!0}))}));return function(){e.forEach((function(e){return e()}))}}),[]),n.useEffect((function(){var e=l.listen("range-updated",(function(){h(l.get())}));return function(){e()}}),[]);var P=n.useCallback((function(e){l.set(e)}),[]),R=n.useMemo((function(){return!!d&&(f?d[0]!==b||d[1]!==S:l.hasChanged())}),[d,b,S]);return n.useEffect((function(){if(f){if(!o||(null==o?void 0:o.isEmpty()))return w(d?d[0]:p[0]),k(d?d[1]:p[1]),a.current=u,void(c.current=!1);var e=l.getField(),n=o.getAggregates(),i=o.getAggregateFilters(),r=0,s=0,g=(n||{})[e]||{},v=(i||{})[e]||{};if(t.isNullOrUndefined(v.min)?t.isNullOrUndefined(g.min)||(r=g.min):r=v.min,t.isNullOrUndefined(v.max)?t.isNullOrUndefined(g.max)||(s=g.max):s=v.max,u!==a.current||!d||c.current){var m=l.format([r,s]);s=m[1],w(r=m[0]),k(s),l.setMin(r),l.setMax(s);var y=[d&&d[0]>r&&d[0]<=s?d[0]:r,d&&d[1]<s&&d[1]>=r?d[1]:s];l.set(y,!1),h(y)}a.current=u,c.current=!1}}),[JSON.stringify(null==o?void 0:o.getResults())]),{min:b,max:S,step:l.getStep(),setRange:P,range:d,reset:function(){f?l.set([].concat(l.getMinMax())):l.reset()},showReset:R}},exports.useResultsPerPage=function(){var e=V().search,i=e.search,r=e.config.resultsPerPageParam,s=e.variables,o=n.useCallback((function(e){var t;s.set(((t={})[r]=e,t)),i()}),[s,i]),u=parseInt(s.get()[r],10);return{resultsPerPage:t.isNumber(u)?u:15,setResultsPerPage:o}},exports.useSearch=function(e){return"object"==typeof e&&"pipeline"in e&&"variables"in e?(i=(t=e).pipeline,r=t.variables,u=(s=n.useState(!1))[0],a=s[1],l=n.useCallback((function(e){var t;a(!0),""===e?i.clearResponse(r.get()):(e&&r.set(((t={})[c.qParam]=e,t)),i.search(r.get()))}),[i,r]),p=(f=n.useState({search:l,error:null}))[0],g=f[1],n.useEffect((function(){return l(),i.listen("response-updated",(function(e){a(!1),g((function(t){return o({},t,{results:null==e?void 0:e.getResults(),latency:null==e?void 0:e.getTime(),totalResults:null==e?void 0:e.getTotalResults(),error:null==e?void 0:e.getError()})}))}))}),[]),n.useEffect((function(){return r.listen("values-changed",(function(){l()}))}),[]),o({},p,{searching:u})):function(e){var t=e.queryOverride,i=e.allowEmptySearch,r=void 0===i||i,s=n.useState(null),o=s[0],u=s[1],a=V(),c=a.search,l=c.searching,f=c.response,p=c.search,g=a.autocomplete,d=g.search,h=g.suggestions,v=null==f?void 0:f.getResults(),m=n.useCallback((function(e){return d(e)}),[]);return n.useEffect((function(){void 0!==t?(r||""!==t)&&p(t):p()}),[t]),n.useEffect((function(){var e,t;if(f)switch(!0){case f.isError():u(null!=(e=null==(t=f.getError())?void 0:t.error)?e:new Error("Something went wrong. Please try again."));break;case!f.isError():u(null)}}),[f]),{latency:null==f?void 0:f.getTime(),totalResults:null==f?void 0:f.getTotalResults(),suggestions:null!=h?h:[],results:v,search:p,searchInstant:m,searching:l,error:o}}(null!=e?e:{});var t,i,r,s,u,a,l,f,p,g},exports.useSearchContext=function(){var e,n,i,r=V().search,s=r.config,o=r.response,u=r.search,a=r.searching,c=r.fields,l=void 0===c?{}:c,f=Q("search"),p=f.page,g=f.resultsPerPage,d=f.totalResults,h=f.pageCount,v=f.setPage,m=(n=null==o?void 0:o.getResponse(),i={},n&&n.forEach((function(e,t){"string"!=typeof e&&"number"!=typeof e||(i[t]=e)})),i),y=null==o?void 0:o.getResults();return{empty:null!=(e=null==o?void 0:o.isEmpty())&&e,error:null==o?void 0:o.getError(),queryValues:null==o?void 0:o.getQueryValues(),latency:null==o?void 0:o.getTime(),page:p,resultsPerPage:g,totalResults:d,pageCount:h,setPage:v,search:u,results:y,response:m,searching:a,searched:!t.isNullOrUndefined(y),fields:l,config:s}},exports.useSorting=function(){var e,t=V().search,i=t.search,r=t.variables,s=n.useCallback((function(e){r.set({sort:e}),i()}),[r,i]);return{sorting:null!=(e=r.get().sort)?e:"",setSorting:s}},exports.useTracking=function(){var e=V(),t=e.resultClicked;return{consumeInteractionToken:e.search.pipeline.getClient().interactionConsume,handleResultClicked:t}},exports.useVariables=function(){return{variables:V().search.variables}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("@sajari/react-sdk-utils"),n=require("react"),i=e(n),r=require("@sajari/sdk-js"),s=e(require("js-cookie"));function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}function u(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var a,c={qParam:"q",qOverrideParam:"q.override",qSuggestionsParam:"q.suggestions",resultsPerPageParam:"resultsPerPage",pageParam:"page",maxSuggestions:10},l=function(){function e(){this.listeners=[]}var t=e.prototype;return t.listen=function(e){var t=this;return this.listeners.push(e),function(){return t.unlisten(e)}},t.unlisten=function(e){var t=this.listeners.indexOf(e);t>=0&&this.listeners.splice(t,1)},t.notify=function(e){this.listeners.forEach((function(t){try{e(t)}catch(e){console&&console.error&&console.error(e)}}))},e}(),f=["page-close-analytics","body-reset-analytics","result-clicked-analytics"],p=function(){function e(e,n){var i,r=this;this.beforeunload=function(){r.enabled&&r.body&&(r.listeners.get("page-close-analytics").notify((function(e){e(r.body)})),r.enabled=!1)},this.resetBody=function(){r.enabled&&(r.listeners.get("body-reset-analytics").notify((function(e){e(r.body)})),r.longestNonAutocompletedBody="",r.longestAutocompletedBody="",r.enabled=!1)},this.responseUpdated=function(e){if(!e.isEmpty()&&!e.isError()){r.enabled=!0;var t=e.getQueryValues().get(r.bodyLabel)||"",n=e.getValues().get(r.bodyAutocompletedLabel)||t;r.body=n,t.length>=r.longestNonAutocompletedBody.length&&(r.longestNonAutocompletedBody=t,r.longestAutocompletedBody=n)}},this.resultClicked=function(){r.enabled&&r.body&&(r.listeners.get("result-clicked-analytics").notify((function(e){e(r.body)})),r.longestNonAutocompletedBody="",r.longestAutocompletedBody="",r.enabled=!1)},this.enabled=!1,this.body="",this.pipeline=e,this.tracking=n,this.listeners=new Map(Object.entries(((i={})["page-close-analytics"]=new l,i["body-reset-analytics"]=new l,i["result-clicked-analytics"]=new l,i))),this.longestNonAutocompletedBody="",this.longestAutocompletedBody="",this.bodyLabel="q",this.bodyAutocompletedLabel="q",t.isSSR()||window.addEventListener("beforeunload",this.beforeunload),this.pipeline.listen("response-updated",this.responseUpdated),this.pipeline.listen("result-clicked",this.resultClicked),this.tracking.listen("tracking-reset",this.resetBody)}return e.prototype.listen=function(e,t){if(-1===f.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},e}();!function(e){e.UniversalAnalytics="_ua",e.AnalyticsJS="ga",e.GTag="gtag"}(a||(a={}));var g={decodeUriArgs:function(e){var t={},n=e.split("&");for(var i in n)if(n.hasOwnProperty(i)){var r=n[i].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t},encodeUriArgs:function(e){var t=[];return Object.keys(e).forEach((function(n){return t.push(encodeURIComponent(n)+"="+encodeURIComponent(e[n]))})),t.join("&")},mergeQueryStr:function(e){for(var t=this,n="string"==typeof e?this.decodeUriArgs(e):e,i=arguments.length,r=new Array(i>1?i-1:0),s=1;s<i;s++)r[s-1]=arguments[s];return r.forEach((function(e){var i="string"==typeof e?t.decodeUriArgs(e):e;Object.keys(i).forEach((function(e){n[e]=i[e]}))})),this.encodeUriArgs(n)},augmentUri:function(e,t){var n=/^([^?]+)\?(.+)+$/.exec(e);return n?n[1]+"?"+this.mergeQueryStr(n[2],t):e+"?"+this.encodeUriArgs(t)},getURLParameter:function(e){var t=new RegExp("[?|&]"+e+"=([^&;]+?)(&|#|;|$)").exec(window.location.search)||[void 0,""];return decodeURIComponent(t[1].replace(/\+/g,"%20"))||null}},d=function(){function e(e,n,i){var r=this;void 0===i&&(i="q"),this.unregisterFunctions=[],this.detatch=function(){return r.unregisterFunctions.forEach((function(e){return e()}))},this.onBodyReset=function(e){return r.sendGAPageView(e)},this.onResultClicked=function(e){return r.sendGAPageView(e)},this.onPageClose=function(e){return r.sendGAPageView(e)},this.unregisterFunctions.push(e.listen("page-close-analytics",this.onPageClose)),this.unregisterFunctions.push(e.listen("body-reset-analytics",this.onBodyReset)),this.unregisterFunctions.push(e.listen("result-clicked-analytics",this.onResultClicked)),this.id=t.isSSR()?null:void 0!==n?n:t.isFunction(window[a.AnalyticsJS])?a.AnalyticsJS:t.isFunction(window[a.UniversalAnalytics])?a.UniversalAnalytics:t.isFunction(window[a.GTag])?a.GTag:null,this.param=i}return e.prototype.sendGAPageView=function(e){if(this.id&&!t.isSSR()&&t.isFunction(window[this.id])){var n,i=g.augmentUri(window.location.href.substring(window.location.origin.length),((n={})[this.param]=e,n));this.id===a.GTag?window[this.id]("event","page_view",{page_location:i}):window[this.id]("send","pageview",i)}},e}(),h=["selection-updated","options-updated"],v=function(){function e(e){var n,i=e.initial,r=void 0===i?[]:i,s=e.joinOperator,o=void 0===s?"OR":s,u=e.multi,a=void 0===u||u,c=e.options,f=void 0===c?{}:c,p=e.array,g=void 0!==p&&p,d=e.name,h=e.field,v=e.group,m=e.count,y=void 0===m?t.isEmpty(f):m;t.isString(r)&&(r=[r]),this.current=r,this.initial=r,this.name=d,this.group=v,this.field=h,this.count=y,this.options=f,this.multi=a,this.array=g,this.joinOperator=o,this.listeners=((n={})["selection-updated"]=new l,n["options-updated"]=new l,n)}var n=e.prototype;return n.listen=function(e,t){if(!h.includes(e))throw new Error('Unknown event type "'+e+'"');return this.listeners[e].listen(t)},n.set=function(e,t){var n=this;if(void 0===t&&(t=!1),t){var i=e.filter((function(e){return!n.current.includes(e)}));this.current=[].concat(this.current,i)}else this.current=e;this.emitSelectionUpdated()},n.remove=function(e){this.current=this.current.filter((function(t){return!e.includes(t)})),this.emitSelectionUpdated()},n.isSet=function(e){return this.current.includes(e)},n.setOptions=function(e,t){void 0===t&&(t=!1),this.options=t?o({},this.options,e):e,this.emitOptionsUpdated()},n.getName=function(){return this.name},n.getGroup=function(){return this.group},n.getField=function(){return this.field},n.getCount=function(){return this.count},n.getOptions=function(){return this.options},n.get=function(){return this.current},n.isArray=function(){return this.array},n.isMulti=function(){return this.multi},n.filter=function(){var e=this;if(t.isEmpty(this.options)&&this.count)return this.current.map((function(t){return"("+(e.array?e.field+' ~ ["'+t+'"]':e.field+' = "'+t+'"')+")"})).join(" "+this.joinOperator+" ");var n=this.current.map((function(n){var i=e.options[n];return t.isFunction(i)&&(i=i()),t.isEmpty(i)||(i=function(e){void 0===e&&(e="");var n=e;return[","].forEach((function(i){n=t.replaceAll(e,i,"\\"+i)})),n}(i)),i})).filter(Boolean);return n.length<2?n.join(""):n.map((function(e){return"("+e+")"})).join(" "+this.joinOperator+" ")},n.getBuckets=function(){var e=this;return Object.entries(this.options).map((function(t){return e.name+"_"+t[0]+":"+t[1]})).join(",")},n.reset=function(){this.current=[].concat(this.initial),this.emitSelectionUpdated()},n.emitSelectionUpdated=function(){this.listeners["selection-updated"].notify((function(e){e()}))},n.emitOptionsUpdated=function(){this.listeners["options-updated"].notify((function(e){e()}))},e}(),m=["range-updated"],y=function(){function e(e){var n,i=e.field,r=e.name,s=e.group,o=e.aggregate,u=void 0===o||o,a=e.initial,c=e.min,f=void 0===c?0:c,p=e.max,g=void 0===p?u?0:100:p,d=e.step,h=void 0===d?1:d,v=e.formatter,m=void 0===v?function(e){return e.map((function(e){return t.roundToStep(e,h)}))}:v;this.initial=void 0===a?u?null:[f,g]:a,this.range=this.initial,this.name=r,this.group=s,this.field=i,this.formatter=m,this.min=f,this.max=g,this.step=h,this.aggregate=u,this.listeners=((n={})["range-updated"]=new l,n)}var n=e.prototype;return n.listen=function(e,t){if(!m.includes(e))throw new Error('Unknown event type "'+e+'"');return this.listeners[e].listen(t)},n.get=function(){return this.range},n.set=function(e,t){void 0===t&&(t=!0),this.range=e?this.formatter(e):e,t&&this.emitRangeUpdated()},n.getName=function(){return this.name},n.getGroup=function(){return this.group},n.getField=function(){return this.field},n.setMin=function(e){this.min=e},n.setMax=function(e){this.max=e},n.getMinMax=function(){return[this.min,this.max]},n.getStep=function(){return this.step},n.filter=function(){return this.range?this.field+" >= "+this.range[0]+" AND "+this.field+" <= "+this.range[1]:""},n.isAggregate=function(){return this.aggregate},n.hasChanged=function(){return this.range&&this.initial?this.range[0]!==this.initial[0]||this.range[1]!==this.initial[1]:this.range===this.initial},n.reset=function(e){void 0===e&&(e=!0),this.range=t.isArray(this.initial)?[].concat(this.initial):this.initial,e&&this.emitRangeUpdated()},n.format=function(e){return this.formatter(e)},n.emitRangeUpdated=function(){var e=this;this.listeners["range-updated"].notify((function(t){t(e)}))},e}(),b=function(e){return"ARRAY_MATCH("+e.filter(Boolean).join(" AND ")+")"};function w(e,n,i){var r=e.map((function(e){return{group:e.getGroup(),field:e.getField(),expression:e.filter(),count:e instanceof v&&e.getCount()}}));"filter"===n&&(r=r.filter((function(e){return Boolean(e.expression)})));var s=Object.entries(t.groupBy(r,"group")).filter((function(e){return Boolean(e[0])})).reduce((function(e,t){var n;return o({},e,((n={})[t[0]]=t[1].map((function(e){return e.expression})),n))}),{});if("filter"===n){var u,a=r.filter((function(e){return!e.group&&!e.count})).map((function(e){return"("+e.expression+")"}));return(u=Object.entries(s).reduce((function(e,n){var i=n[1];return"undefined"===n[0]||t.isEmpty(i)?e:[].concat(e,[b(i)])}),[])).concat.apply(u,a).join(i)}return r.filter((function(e){var n=e.count;return!t.isEmpty(e.field)&&n})).map((function(e){var n=e.group,i=e.expression,r=e.count;return n&&!t.isEmpty(s[n])?b(s[n]):r?i:null})).filter((function(e){return null!==e})).join(i)}var E=["selection-updated","options-updated","range-updated"];function S(e,t){var n;void 0===t&&(t="AND");var i=((n={})["selection-updated"]=new l,n["options-updated"]=new l,n["range-updated"]=new l,n),r=[];return e.forEach((function(e){e instanceof v&&r.push(e.listen("selection-updated",(function(){i["selection-updated"].notify((function(t){t(e)}))})),e.listen("options-updated",(function(){i["options-updated"].notify((function(t){t(e)}))}))),e instanceof y&&r.push(e.listen("range-updated",(function(){i["range-updated"].notify((function(t){t(e)}))})))})),{filter:function(){return w(e,"filter"," "+t+" ")},listen:function(e,t){if(-1===E.indexOf(e))throw new Error('Unknown event type "'+e+'"');return i[e].listen(t)},buckets:function(){return e.filter((function(e){return e instanceof v&&!e.getCount()})).map((function(e){return e instanceof v&&e.getBuckets()})).filter(Boolean).join(",")},countFilters:function(){return w(e,"countFilters",",")},count:function(){return e.filter((function(e){return e instanceof v&&e.getCount()})).map((function(e){return e instanceof v&&e.getField()})).filter(Boolean).join(",")},removeChildFilterListeners:function(){r.forEach((function(e){return e()}))},max:function(){return e.filter((function(e){return e instanceof y&&e.isAggregate()})).map((function(e){return e.getField()})).join(",")},min:function(){return e.filter((function(e){return e instanceof y&&e.isAggregate()})).map((function(e){return e.getField()})).join(",")}}}var k=function(){function e(e,t,n,i){this.error=e,this.queryValues=t,this.response=n,this.values=i}var t=e.prototype;return t.isEmpty=function(){return null===this.error&&void 0===this.response&&void 0===this.values&&void 0===this.queryValues},t.isError=function(){return null!==this.error},t.getError=function(){return this.error},t.getQueryValues=function(){return this.queryValues},t.getResponse=function(){return this.response},t.getValues=function(){return this.values},t.getResults=function(){return void 0!==this.response?this.response.get("results"):void 0},t.getTotalResults=function(){return void 0!==this.response?this.response.get("totalResults"):void 0},t.getTime=function(){return void 0!==this.response?this.response.get("time"):void 0},t.getAggregates=function(){if(void 0!==this.response){var e=this.response.get("aggregates");if(void 0!==e)return e}},t.getAggregateFilters=function(){if(void 0!==this.response){var e=this.response.get("aggregateFilters");if(void 0!==e)return e}},e}(),P=["tracking-reset"],R=function(){function e(){var e;this.clientTracking=null,this.listeners=new Map(Object.entries(((e={})["tracking-reset"]=new l,e)))}var t=e.prototype;return t.listen=function(e,t){if(-1===P.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},t.emitTrackingReset=function(e){this.listeners.get("tracking-reset").notify((function(t){t(e)}))},t.reset=function(e){this.clientTracking.reset(),void 0!==e&&this.emitTrackingReset(e)},t.next=function(e){if(null===this.clientTracking)throw new Error("clientTracking is null");return this.clientTracking.next(e)},e}(),x=function(){var e={},t=s.get("_ga");t&&(e.ga=t);var n=s.get("sjID");return n&&(e.sjID=n),e},A=function(e){function t(t,n){var i;return void 0===t&&(t="url"),void 0===n&&(n="q"),(i=e.call(this)||this).field=t,i.clientTracking=new r.InteractiveSession(n,new r.DefaultSession(r.TrackingType.Click,i.field,x())),i}return u(t,e),t}(R),C=function(e){function t(){var t;return(t=e.call(this)||this).field="_id",t.clientTracking=new r.DefaultSession(r.TrackingType.None,t.field,x()),t}return u(t,e),t}(R),T=function(e){function t(t){var n;return void 0===t&&(t="url"),(n=e.call(this)||this).field=t,n.clientTracking=new r.DefaultSession(r.TrackingType.PosNeg,n.field,x()),n}return u(t,e),t}(R),O=["search-sent","response-updated","result-clicked"],U=function(){function e(e,n,i,s){var o=this;void 0===i&&(i=new C),void 0===s&&(s=[d]),this.response=new k(null);var u=e.account,a=e.collection,c=e.endpoint,f=e.key,g=e.secret;this.config=e;var h={name:void 0,version:void 0};t.isString(n)?h.name=n:"name"in n&&(h.name=n.name,h.version=n.version),this.client=t.isSSR()?new r.Client(u,a,c,f,g):new r.Client(u,a,c),this.pipeline=this.client.pipeline(h.name,h.version),this.tracking=i,this.listeners=new Map([["search-sent",new l],["response-updated",new l],["result-clicked",new l]]),this.searchCount=0,this.response=new k(null),this.analytics=new p(this,this.tracking),s.forEach((function(e){new e(o.analytics)}))}var n=e.prototype;return n.listen=function(e,t){if(-1===O.indexOf(e))throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},n._emitSearchSent=function(e){this.listeners.get("search-sent").notify((function(t){t(e)}))},n._emitResponseUpdated=function(e){this.listeners.get("response-updated").notify((function(t){t(e)}))},n.emitResultClicked=function(e){this.listeners.get("result-clicked").notify((function(t){t(e)}))},n.search=function(e){var t=this;this.searchCount+=1;var n=this.searchCount;this.pipeline.search(e,this.tracking.next(e)).then((function(i){var r=i[0],s=i[1];n<t.searchCount||(t.response=new k(null,new Map(Object.entries(e)),new Map(Object.entries(r)),new Map(Object.entries(s))))})).catch((function(i){console.error(i),n<t.searchCount||(t.response=new k(i,new Map(Object.entries(e)),void 0,void 0))})).finally((function(){t._emitResponseUpdated(t.response)})),this._emitSearchSent(e)},n.clearResponse=function(e){this.tracking.next(e),this.searchCount+=1,this.response=new k(null),this._emitResponseUpdated(this.response)},n.getResponse=function(){return this.response},n.getAnalytics=function(){return this.analytics},n.getClient=function(){return this.client},n.getTracking=function(){return this.tracking},e}(),j=function(){function e(e){var t;void 0===e&&(e={}),this.listeners=new Map([["values-changed",new l]]),this.variables=new Map(Object.entries(o(((t={})[c.qParam]="",t[c.resultsPerPageParam]=15,t),e)))}var t=e.prototype;return t.listen=function(e,t){if("values-changed"!==e)throw new Error('Unknown event type "'+e+'"');return this.listeners.get(e).listen(t)},t.set=function(e){this._set(e),this._emitUpdated(e)},t.get=function(){var e={};return this.variables.forEach((function(t,n){e[n]="function"==typeof t?t():Array.isArray(t)?t.join(","):String(t)})),e},t._emitUpdated=function(e){var t=this;this.listeners.get("values-changed").notify((function(n){return n(e,(function(e){return t._set(e)}))}))},t._set=function(e){var t=this;Object.keys(e).forEach((function(n){void 0===e[n]?t.variables.delete(n):t.variables.set(n,e[n])}))},e}(),N=function(e,t,n){var i=e&&t&&t.get(n.qParam)||"",r=[];return t&&(r=(t.get(n.qSuggestionsParam)||"").split(",").filter((function(e){return e.length>0})).slice(0,n.maxSuggestions)),{completion:i,query:e,suggestions:r}},_=function(e,t,n){var i=e.get()[t.qParam]||"",r=n.getValues();return N(i,r,t)},q=function(e,t,n){var i=e.get()[n.qParam]||"",r=t.getResponse().getValues();return N(i,r,n)},F=t.createContext({strict:!0,name:"PipelineContext"}),M=F[0],V=F[1],B={response:null,query:"",completion:"",suggestions:[],config:c},D=/\d+\s-\s\d+/gm,I=D.test.bind(D),L=new Intl.Collator(t.isSSR()?"en-US":window.navigator.language,{numeric:!0}),G=function(e,t,n){if(void 0===t&&(t="alpha"),void 0===n&&(n=!0),"none"===t)return e;var i="count"!==t;return[].concat(e).sort((function(e,t){var r=t[0],s=t[1],o=String(i?e[0]:e[1]),u=String(i?r:s);switch(!0){case[o,u].every(I):var a=o.split(" - ").map(Number)[0],c=u.split(" - ").map(Number)[0];return n?L.compare(String(a),String(c)):L.compare(String(c),String(a));case o.startsWith(">"):case u.startsWith("<"):return n?1:-1;case o.startsWith("<"):case u.startsWith(">"):return n?-1:1}return n?L.compare(String(o),String(u)):L.compare(String(u),String(o))}))};function Q(e){void 0===e&&(e="search");var t=V(),i=t.paginate,r=t[e],s=r.response,o=r.config,u=null==s?void 0:s.getQueryValues(),a=(null==u?void 0:u.get(o.pageParam))?parseInt(u.get(o.pageParam),10):1,c=(null==u?void 0:u.get(o.resultsPerPageParam))?parseInt(null==u?void 0:u.get(o.resultsPerPageParam),10):15,l=(null==s?void 0:s.getTotalResults())||0,f=Math.ceil(l/c),p=n.useMemo((function(){return a<f}),[a,f]),g=n.useMemo((function(){return a>1}),[a]),d=n.useCallback((function(){return p&&i(a+1)}),[i,p]),h=n.useCallback((function(){return g&&i(a-1)}),[i,g]);return{page:a,pageCount:f,totalResults:l,setPage:i,resultsPerPage:c,hasNext:p,hasPrevious:g,nextPage:d,previousPage:h}}exports.ClickTracking=A,exports.EVENT_ANALYTICS_BODY_RESET="body-reset-analytics",exports.EVENT_ANALYTICS_PAGE_CLOSED="page-close-analytics",exports.EVENT_ANALYTICS_RESULT_CLICKED="result-clicked-analytics",exports.EVENT_OPTIONS_UPDATED="options-updated",exports.EVENT_RANGE_UPDATED="range-updated",exports.EVENT_RESPONSE_UPDATED="response-updated",exports.EVENT_RESULT_CLICKED="result-clicked",exports.EVENT_SEARCH_SENT="search-sent",exports.EVENT_SELECTION_UPDATED="selection-updated",exports.EVENT_TRACKING_RESET="tracking-reset",exports.EVENT_VALUES_UPDATED="values-changed",exports.FieldDictionary=function(e){var t=null!=e?e:{},n=t.id,i=t.url,r=void 0===i?"url":i,s=t.title,o=void 0===s?"title":s,u=t.subtitle,a=void 0===u?"url":u,c=t.description,l=void 0===c?"description":c,f=t.image,p=void 0===f?"image":f,g=t.price,d=void 0===g?"price":g,h=t.originalPrice,v=void 0===h?"originalPrice":h,m=t.rating,y=void 0===m?"rating":m;this.id=void 0===n?"_id":n,this.url=r,this.title=o,this.subtitle=a,this.description=l,this.image=p,this.price=d,this.originalPrice=v,this.rating=y},exports.FilterBuilder=v,exports.Pipeline=U,exports.PosNegTracking=T,exports.RangeFilterBuilder=y,exports.Response=k,exports.SearchProvider=function(e){var r,s,u=e.children,a=e.search,l=e.autocomplete,f=e.defaultFilter,p=e.searchOnLoad,g=function(e){if(!t.isString(e)||t.isEmpty(e))return null;var n=JSON.parse(e),i=n.queryValues,r=n.response,s=void 0===r?{}:r,o=n.values,u=void 0===o?{}:o;return new k(null,new Map(Object.entries(void 0===i?{}:i)),new Map(Object.entries(s)),new Map(Object.entries(u)))}(e.initialResponse),d=n.useState(!1),h=d[0],v=d[1],m=n.useState(!1),y=m[0],b=m[1],w=n.useState(o({},B,{response:g})),E=w[0],P=w[1],R=n.useState(B),x=R[0],A=R[1],C=n.useState(!1),T=C[0],O=C[1],N=n.useRef(),F=n.useRef(),V=n.useRef(l),D=n.useRef(null!=(r=a.variables)?r:new j),I=n.useRef(null!=(s=null==l?void 0:l.variables)?s:new j),L=a.pipeline.getResponse();if(L.isEmpty()&&null!==g&&(L=g),a.variables||T||Object.assign(a,{variables:D.current}),!l||l.variables||T||Object.assign(l,{variables:I.current}),!T){var G,Q,J,Y=S(null!=(G=a.filters)?G:[]),W=null!=(Q=D.current.get().filter)?Q:"",K=null!=(J=null==f?void 0:f.toString())?J:"";D.current.set({filter:function(){var e=Y.filter();return[K,W,t.isEmpty(e)?'_id != ""':e].filter(Boolean).join(" AND ")},countFilters:function(){return Y.countFilters()},buckets:function(){return Y.buckets()},count:function(){return Y.count()},min:function(){return Y.min()},max:function(){return Y.max()}})}var H=n.useCallback((function(e){return function(t,n){var i;void 0===n&&(n=!1);var r="autocomplete"===e?V.current:a,s="autocomplete"===e?x:E,u="autocomplete"===e?F:N;("autocomplete"===e?b:v)(!0),P((function(e){return o({},e,{query:null!=t?t:e.query})}));var c=r.pipeline,l=r.variables,f=s.config,p=((i={})[f.qParam]=null!=t?t:l.get()[f.qParam],i[f.qOverrideParam]=void 0,i[f.pageParam]=void 0,i);n&&(p[f.qOverrideParam]="true"),l.set(p),u.current&&clearTimeout(u.current),u.current=setTimeout((function(){c.search(l.get())}),50)}}),[]);n.useEffect((function(){var e=o({},c,a.config);P((function(t){return o({},t,{response:L,query:D.current.get()[e.qParam]||"",config:e})})),A((function(e){return o({},e,{config:o({},c,a.config)})}));var t,n=[];if(a.filters){var i=S(a.filters);n.push(i.listen("selection-updated",(function(){return H("search")()})),i.listen("range-updated",(function(){return H("search")()})),i.removeChildFilterListeners)}if(n.push(a.pipeline.listen("response-updated",(function(e){var n;clearTimeout(t),t=setTimeout((function(){v(!1),P((function(t){return o({},t,{response:e},_(D.current,t.config,e))}))}),0===(null==(n=e.getResults())?void 0:n.length)?500:20)}))),n.push(D.current.listen("values-changed",(function(){return P((function(e){return o({},e,q(D.current,a.pipeline,e.config))}))}))),!V.current){var r=a.pipeline.config;V.current={pipeline:new U({account:r.account,collection:r.collection,endpoint:r.endpoint},"autocomplete"),variables:I.current}}return n.push(V.current.pipeline.listen("response-updated",(function(e){b(!1),A((function(t){return o({},t,{response:e},_(I.current,t.config,e))}))}))),n.push(I.current.listen("values-changed",(function(){return A((function(e){return o({},e,q(I.current,V.current.pipeline,e.config))}))}))),p&&a.pipeline.search(D.current.get()),O(!0),function(){n.forEach((function(e){return e()}))}}),[]);var $,z,X,Z=n.useCallback((function(e){return function(t){var n="autocomplete"===e?V.current:a,i=n.pipeline,r=n.variables;void 0!==t&&r.set(t),i.clearResponse(r.get())}}),[]),ee=n.useCallback((function(e){var t,n=a.pipeline,i=a.variables;i.set(((t={})[E.config.pageParam]=String(e),t)),n.search(i.get())}),[a.pipeline,a.variables,E.config]),te=n.useCallback((function(e){return a.pipeline.emitResultClicked(e)}),[]);return i.createElement(M,{value:($={autocomplete:x,search:E},o({},$,{search:o({},$.search,{variables:D.current,filters:a.filters,pipeline:a.pipeline,search:H("search"),clear:Z("search"),fields:a.fields,searching:h}),autocomplete:o({},$.autocomplete,{variables:I.current,filters:a.filters,pipeline:null==(z=V.current)?void 0:z.pipeline,search:H("autocomplete"),clear:Z("autocomplete"),fields:null==(X=V.current)?void 0:X.fields,searching:y}),resultClicked:te,paginate:ee}))},u)},exports.Variables=j,exports.combineFilters=S,exports.useAutocomplete=function(){var e=V().autocomplete;return{suggestions:e.suggestions,search:e.search,completion:e.completion,searching:e.searching}},exports.useFilter=function(e,i){void 0===i&&(i={});var r=V().search,s=r.filters,u=void 0===s?[]:s,a=r.response,c=n.useMemo((function(){return u.filter((function(t){return t instanceof v&&t.getName()===e}))[0]}),[]);if(!c)throw new Error('Filter "'+e+"\" doesn't exist.");var l=n.useState(c.get()),f=l[0],p=l[1];n.useEffect((function(){var e=c.listen("selection-updated",(function(){p(c.get())}));return function(){e()}}),[]);var g=i.sort,d=void 0===g?"alpha":g,h=i.sortAscending,m=void 0===h?"count"!==d:h;return{options:n.useMemo((function(){if(!a||(null==a?void 0:a.isEmpty()))return[];var n=a.getAggregates(),i=a.getAggregateFilters(),r=c.getCount(),s=c.getField();if(r&&s){var u=c.isArray(),l={};if(!(l=((i||{})[s]||{}).count)){var f=((n||{})[s]||{}).count;l=void 0===f?{}:f}var p=G(Object.entries(l),d,m).map((function(e){var t=e[0];return{label:t,count:e[1],value:u?s+' ~ ["'+t+'"]':s+' = "'+t+'"'}}));return c.setOptions(p.reduce((function(e,t){var n;return o({},e,((n={})[t.label]=t.value,n))}),{})),p}return G(Object.entries(c.getOptions()),d,m).map((function(n){var i=n[0];return{label:i,value:n[1],count:function(e,n){var i,r,s,o,u;if(!e||(null==e?void 0:e.isEmpty()))return null;var a=0,c=e.getAggregates(),l=e.getAggregateFilters();return l&&Object.keys(null!=(i=null==(r=l.buckets)?void 0:r.count)?i:{}).includes(n)?a=l.buckets.count:c&&Object.keys(null!=(s=null==(o=c.buckets)?void 0:o.count)?s:{}).includes(n)&&(a=c.buckets.count),t.isNumber(a)?0:null!=(u=a[n])?u:0}(a,e+"_"+i)}}))}),[JSON.stringify(null==a?void 0:a.getResults())]),setSelected:function(e,t){void 0===t&&(t=!1),c.set(e,t)},selected:f,reset:function(){c.reset()},multi:c.isMulti()}},exports.usePagination=Q,exports.useQuery=function(){var e=V().search,t=e.search,i=e.variables;return{query:e.query,setQuery:n.useCallback((function(e){i.set({q:e}),t(e)}),[t,i])}},exports.useRangeFilter=function(e){var i=V().search,r=i.filters,s=void 0===r?[]:r,o=i.response,u=i.query,a=n.useRef(null),c=n.useRef(!1),l=n.useMemo((function(){return s.filter((function(t){return t instanceof y&&t.getName()===e}))[0]}),[]),f=l.isAggregate(),p=l.getMinMax();if(!l)throw new Error('Filter "'+e+"\" doesn't exist.");var g=n.useState(l.get()),d=g[0],h=g[1],m=n.useState(p[0]),b=m[0],w=m[1],E=n.useState(p[1]),S=E[0],k=E[1];n.useEffect((function(){f&&null!==a.current&&l.reset(!1)}),[u]),n.useEffect((function(){if(!f)return function(){};var e=s.filter((function(e){return e instanceof v})).map((function(e){return e.listen("selection-updated",(function(){l.reset(!1),c.current=!0}))}));return function(){e.forEach((function(e){return e()}))}}),[]),n.useEffect((function(){var e=l.listen("range-updated",(function(){h(l.get())}));return function(){e()}}),[]);var P=n.useCallback((function(e){l.set(e)}),[]),R=n.useMemo((function(){return!!d&&(f?d[0]!==b||d[1]!==S:l.hasChanged())}),[d,b,S]);return n.useEffect((function(){if(f){if(!o||(null==o?void 0:o.isEmpty()))return w(d?d[0]:p[0]),k(d?d[1]:p[1]),a.current=u,void(c.current=!1);var e=l.getField(),n=o.getAggregates(),i=o.getAggregateFilters(),r=0,s=0,g=(n||{})[e]||{},v=(i||{})[e]||{};if(t.isNullOrUndefined(v.min)?t.isNullOrUndefined(g.min)||(r=g.min):r=v.min,t.isNullOrUndefined(v.max)?t.isNullOrUndefined(g.max)||(s=g.max):s=v.max,u!==a.current||!d||c.current){var m=l.format([r,s]);s=m[1],w(r=m[0]),k(s),l.setMin(r),l.setMax(s);var y=[d&&d[0]>r&&d[0]<=s?d[0]:r,d&&d[1]<s&&d[1]>=r?d[1]:s];l.set(y,!1),h(y)}a.current=u,c.current=!1}}),[JSON.stringify(null==o?void 0:o.getResults())]),{min:b,max:S,step:l.getStep(),setRange:P,range:d,reset:function(){f?l.set([].concat(l.getMinMax())):l.reset()},showReset:R}},exports.useResultsPerPage=function(){var e=V().search,i=e.search,r=e.config.resultsPerPageParam,s=e.variables,o=n.useCallback((function(e){var t;s.set(((t={})[r]=e,t)),i()}),[s,i]),u=parseInt(s.get()[r],10);return{resultsPerPage:t.isNumber(u)?u:15,setResultsPerPage:o}},exports.useSearch=function(e){return"object"==typeof e&&"pipeline"in e&&"variables"in e?(i=(t=e).pipeline,r=t.variables,u=(s=n.useState(!1))[0],a=s[1],l=n.useCallback((function(e){var t;a(!0),""===e?i.clearResponse(r.get()):(e&&r.set(((t={})[c.qParam]=e,t)),i.search(r.get()))}),[i,r]),p=(f=n.useState({search:l,error:null}))[0],g=f[1],n.useEffect((function(){return l(),i.listen("response-updated",(function(e){a(!1),g((function(t){return o({},t,{results:null==e?void 0:e.getResults(),latency:null==e?void 0:e.getTime(),totalResults:null==e?void 0:e.getTotalResults(),error:null==e?void 0:e.getError()})}))}))}),[]),n.useEffect((function(){return r.listen("values-changed",(function(){l()}))}),[]),o({},p,{searching:u})):function(e){var t=e.queryOverride,i=e.allowEmptySearch,r=void 0===i||i,s=n.useState(null),o=s[0],u=s[1],a=V(),c=a.search,l=c.searching,f=c.response,p=c.search,g=a.autocomplete,d=g.search,h=g.suggestions,v=null==f?void 0:f.getResults(),m=n.useCallback((function(e){return d(e)}),[]);return n.useEffect((function(){void 0!==t?(r||""!==t)&&p(t):p()}),[t]),n.useEffect((function(){var e,t;if(f)switch(!0){case f.isError():u(null!=(e=null==(t=f.getError())?void 0:t.error)?e:new Error("Something went wrong. Please try again."));break;case!f.isError():u(null)}}),[f]),{latency:null==f?void 0:f.getTime(),totalResults:null==f?void 0:f.getTotalResults(),suggestions:null!=h?h:[],results:v,search:p,searchInstant:m,searching:l,error:o}}(null!=e?e:{});var t,i,r,s,u,a,l,f,p,g},exports.useSearchContext=function(){var e,n,i,r=V().search,s=r.config,o=r.response,u=r.search,a=r.searching,c=r.fields,l=void 0===c?{}:c,f=r.clear,p=Q("search"),g=p.page,d=p.resultsPerPage,h=p.totalResults,v=p.pageCount,m=p.setPage,y=(n=null==o?void 0:o.getResponse(),i={},n&&n.forEach((function(e,t){"string"!=typeof e&&"number"!=typeof e||(i[t]=e)})),i),b=null==o?void 0:o.getResults();return{empty:null!=(e=null==o?void 0:o.isEmpty())&&e,error:null==o?void 0:o.getError(),queryValues:null==o?void 0:o.getQueryValues(),latency:null==o?void 0:o.getTime(),page:g,resultsPerPage:d,totalResults:h,pageCount:v,setPage:m,search:u,results:b,response:y,searching:a,searched:!t.isNullOrUndefined(b),fields:l,config:s,clear:f}},exports.useSorting=function(){var e,t=V().search,i=t.search,r=t.variables,s=n.useCallback((function(e){r.set({sort:e}),i()}),[r,i]);return{sorting:null!=(e=r.get().sort)?e:"",setSorting:s}},exports.useTracking=function(){var e=V(),t=e.resultClicked;return{consumeInteractionToken:e.search.pipeline.getClient().interactionConsume,handleResultClicked:t}},exports.useVariables=function(){return{variables:V().search.variables}}; | ||
//# sourceMappingURL=react-hooks.cjs.production.min.js.map |
@@ -18,3 +18,4 @@ declare function useSearchContext(): { | ||
config: import("../ContextProvider").Config; | ||
clear: import("../ContextProvider/types").ClearFn; | ||
}; | ||
export default useSearchContext; |
@@ -17,3 +17,4 @@ import { isNullOrUndefined } from '@sajari/react-sdk-utils'; | ||
_useContext$search$fi = _useContext$search.fields, | ||
fields = _useContext$search$fi === void 0 ? {} : _useContext$search$fi; | ||
fields = _useContext$search$fi === void 0 ? {} : _useContext$search$fi, | ||
clear = _useContext$search.clear; | ||
@@ -45,3 +46,4 @@ var _usePagination = usePagination('search'), | ||
fields: fields, | ||
config: config | ||
config: config, | ||
clear: clear | ||
}; | ||
@@ -48,0 +50,0 @@ } |
{ | ||
"name": "@sajari/react-hooks", | ||
"version": "1.4.6", | ||
"version": "1.4.7", | ||
"description": "Easy to use hooks that allow you to build a powerful search interface powered by Sajari using any component library.", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is too big to display
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
611435
4629