@searchstax-inc/searchstudio-ux-react 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/SearchstaxInputWidget.d.ts +11 -0
- package/dist/components/SearchstaxResultWidget.d.ts +7 -0
- package/dist/components/SearchstaxWrapper.d.ts +12 -0
- package/{src/main.tsx → dist/main.d.ts} +1 -2
- package/dist/searchstudio-ux-react-ts.cjs.js +95 -0
- package/dist/searchstudio-ux-react-ts.es.js +1726 -0
- package/dist/searchstudio-ux-react-ts.umd.js +95 -0
- package/package.json +4 -1
- package/index.html +0 -24
- package/src/App.scss +0 -1
- package/src/App.tsx +0 -234
- package/src/assets/react.svg +0 -1
- package/src/components/SearchstaxInputWidget.tsx +0 -83
- package/src/components/SearchstaxResultWidget.tsx +0 -202
- package/src/components/SearchstaxWrapper.tsx +0 -34
- package/src/index.css +0 -0
- package/src/main.js +0 -4
- package/src/stores/searchstaxStore.js +0 -5
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -24
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -30
- /package/{public → dist}/vite.svg +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
(function(V,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],j):(V=typeof globalThis<"u"?globalThis:V||self,j(V.searchstudioUxReactTs={},V.React))})(this,function(V,j){"use strict";var d={},ze={get exports(){return d},set exports(r){d=r}},z={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var xe;function Ge(){if(xe)return z;xe=1;var r=j,e=Symbol.for("react.element"),s=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(l,h,p){var C,A={},L=null,U=null;p!==void 0&&(L=""+p),h.key!==void 0&&(L=""+h.key),h.ref!==void 0&&(U=h.ref);for(C in h)n.call(h,C)&&!i.hasOwnProperty(C)&&(A[C]=h[C]);if(l&&l.defaultProps)for(C in h=l.defaultProps,h)A[C]===void 0&&(A[C]=h[C]);return{$$typeof:e,type:l,key:L,ref:U,props:A,_owner:a.current}}return z.Fragment=s,z.jsx=u,z.jsxs=u,z}var G={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Ce;function Je(){return Ce||(Ce=1,process.env.NODE_ENV!=="production"&&function(){var r=j,e=Symbol.for("react.element"),s=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),Z=Symbol.iterator,E="@@iterator";function P(t){if(t===null||typeof t!="object")return null;var o=Z&&t[Z]||t[E];return typeof o=="function"?o:null}var R=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(t){{for(var o=arguments.length,c=new Array(o>1?o-1:0),f=1;f<o;f++)c[f-1]=arguments[f];H("error",t,c)}}function H(t,o,c){{var f=R.ReactDebugCurrentFrame,b=f.getStackAddendum();b!==""&&(o+="%s",c=c.concat([b]));var x=c.map(function(m){return String(m)});x.unshift("Warning: "+o),Function.prototype.apply.call(console[t],console,x)}}var K=!1,F=!1,ee=!1,he=!1,O=!1,Ee;Ee=Symbol.for("react.module.reference");function kt(t){return!!(typeof t=="string"||typeof t=="function"||t===n||t===i||O||t===a||t===p||t===C||he||t===U||K||F||ee||typeof t=="object"&&t!==null&&(t.$$typeof===L||t.$$typeof===A||t.$$typeof===u||t.$$typeof===l||t.$$typeof===h||t.$$typeof===Ee||t.getModuleId!==void 0))}function Tt(t,o,c){var f=t.displayName;if(f)return f;var b=o.displayName||o.name||"";return b!==""?c+"("+b+")":c}function ke(t){return t.displayName||"Context"}function D(t){if(t==null)return null;if(typeof t.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case n:return"Fragment";case s:return"Portal";case i:return"Profiler";case a:return"StrictMode";case p:return"Suspense";case C:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case l:var o=t;return ke(o)+".Consumer";case u:var c=t;return ke(c._context)+".Provider";case h:return Tt(t,t.render,"ForwardRef");case A:var f=t.displayName||null;return f!==null?f:D(t.type)||"Memo";case L:{var b=t,x=b._payload,m=b._init;try{return D(m(x))}catch{return null}}}return null}var W=Object.assign,te=0,Te,Ie,Ae,we,Le,je,_e;function Oe(){}Oe.__reactDisabledLog=!0;function It(){{if(te===0){Te=console.log,Ie=console.info,Ae=console.warn,we=console.error,Le=console.group,je=console.groupCollapsed,_e=console.groupEnd;var t={configurable:!0,enumerable:!0,value:Oe,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}te++}}function At(){{if(te--,te===0){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},t,{value:Te}),info:W({},t,{value:Ie}),warn:W({},t,{value:Ae}),error:W({},t,{value:we}),group:W({},t,{value:Le}),groupCollapsed:W({},t,{value:je}),groupEnd:W({},t,{value:_e})})}te<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ge=R.ReactCurrentDispatcher,de;function re(t,o,c){{if(de===void 0)try{throw Error()}catch(b){var f=b.stack.trim().match(/\n( *(at )?)/);de=f&&f[1]||""}return`
|
|
18
|
+
`+de+t}}var fe=!1,ae;{var wt=typeof WeakMap=="function"?WeakMap:Map;ae=new wt}function Pe(t,o){if(!t||fe)return"";{var c=ae.get(t);if(c!==void 0)return c}var f;fe=!0;var b=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var x;x=ge.current,ge.current=null,It();try{if(o){var m=function(){throw Error()};if(Object.defineProperty(m.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(m,[])}catch(B){f=B}Reflect.construct(t,[],m)}else{try{m.call()}catch(B){f=B}t.call(m.prototype)}}else{try{throw Error()}catch(B){f=B}t()}}catch(B){if(B&&f&&typeof B.stack=="string"){for(var v=B.stack.split(`
|
|
19
|
+
`),w=f.stack.split(`
|
|
20
|
+
`),S=v.length-1,k=w.length-1;S>=1&&k>=0&&v[S]!==w[k];)k--;for(;S>=1&&k>=0;S--,k--)if(v[S]!==w[k]){if(S!==1||k!==1)do if(S--,k--,k<0||v[S]!==w[k]){var _=`
|
|
21
|
+
`+v[S].replace(" at new "," at ");return t.displayName&&_.includes("<anonymous>")&&(_=_.replace("<anonymous>",t.displayName)),typeof t=="function"&&ae.set(t,_),_}while(S>=1&&k>=0);break}}}finally{fe=!1,ge.current=x,At(),Error.prepareStackTrace=b}var $=t?t.displayName||t.name:"",$e=$?re($):"";return typeof t=="function"&&ae.set(t,$e),$e}function Lt(t,o,c){return Pe(t,!1)}function jt(t){var o=t.prototype;return!!(o&&o.isReactComponent)}function ne(t,o,c){if(t==null)return"";if(typeof t=="function")return Pe(t,jt(t));if(typeof t=="string")return re(t);switch(t){case p:return re("Suspense");case C:return re("SuspenseList")}if(typeof t=="object")switch(t.$$typeof){case h:return Lt(t.render);case A:return ne(t.type,o,c);case L:{var f=t,b=f._payload,x=f._init;try{return ne(x(b),o,c)}catch{}}}return""}var ie=Object.prototype.hasOwnProperty,Ve={},Me=R.ReactDebugCurrentFrame;function oe(t){if(t){var o=t._owner,c=ne(t.type,t._source,o?o.type:null);Me.setExtraStackFrame(c)}else Me.setExtraStackFrame(null)}function _t(t,o,c,f,b){{var x=Function.call.bind(ie);for(var m in t)if(x(t,m)){var v=void 0;try{if(typeof t[m]!="function"){var w=Error((f||"React class")+": "+c+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw w.name="Invariant Violation",w}v=t[m](o,m,f,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(S){v=S}v&&!(v instanceof Error)&&(oe(b),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",f||"React class",c,m,typeof v),oe(null)),v instanceof Error&&!(v.message in Ve)&&(Ve[v.message]=!0,oe(b),y("Failed %s type: %s",c,v.message),oe(null))}}}var Ot=Array.isArray;function pe(t){return Ot(t)}function Pt(t){{var o=typeof Symbol=="function"&&Symbol.toStringTag,c=o&&t[Symbol.toStringTag]||t.constructor.name||"Object";return c}}function Vt(t){try{return Fe(t),!1}catch{return!0}}function Fe(t){return""+t}function De(t){if(Vt(t))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Pt(t)),Fe(t)}var se=R.ReactCurrentOwner,Mt={key:!0,ref:!0,__self:!0,__source:!0},Be,Ue,ve;ve={};function Ft(t){if(ie.call(t,"ref")){var o=Object.getOwnPropertyDescriptor(t,"ref").get;if(o&&o.isReactWarning)return!1}return t.ref!==void 0}function Dt(t){if(ie.call(t,"key")){var o=Object.getOwnPropertyDescriptor(t,"key").get;if(o&&o.isReactWarning)return!1}return t.key!==void 0}function Bt(t,o){if(typeof t.ref=="string"&&se.current&&o&&se.current.stateNode!==o){var c=D(se.current.type);ve[c]||(y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',D(se.current.type),t.ref),ve[c]=!0)}}function Ut(t,o){{var c=function(){Be||(Be=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};c.isReactWarning=!0,Object.defineProperty(t,"key",{get:c,configurable:!0})}}function Ht(t,o){{var c=function(){Ue||(Ue=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",o))};c.isReactWarning=!0,Object.defineProperty(t,"ref",{get:c,configurable:!0})}}var Wt=function(t,o,c,f,b,x,m){var v={$$typeof:e,type:t,key:o,ref:c,props:m,_owner:x};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:f}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function Nt(t,o,c,f,b){{var x,m={},v=null,w=null;c!==void 0&&(De(c),v=""+c),Dt(o)&&(De(o.key),v=""+o.key),Ft(o)&&(w=o.ref,Bt(o,b));for(x in o)ie.call(o,x)&&!Mt.hasOwnProperty(x)&&(m[x]=o[x]);if(t&&t.defaultProps){var S=t.defaultProps;for(x in S)m[x]===void 0&&(m[x]=S[x])}if(v||w){var k=typeof t=="function"?t.displayName||t.name||"Unknown":t;v&&Ut(m,k),w&&Ht(m,k)}return Wt(t,v,w,b,f,se.current,m)}}var me=R.ReactCurrentOwner,He=R.ReactDebugCurrentFrame;function Y(t){if(t){var o=t._owner,c=ne(t.type,t._source,o?o.type:null);He.setExtraStackFrame(c)}else He.setExtraStackFrame(null)}var be;be=!1;function ye(t){return typeof t=="object"&&t!==null&&t.$$typeof===e}function We(){{if(me.current){var t=D(me.current.type);if(t)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+t+"`."}return""}}function qt(t){{if(t!==void 0){var o=t.fileName.replace(/^.*[\\\/]/,""),c=t.lineNumber;return`
|
|
24
|
+
|
|
25
|
+
Check your code at `+o+":"+c+"."}return""}}var Ne={};function Kt(t){{var o=We();if(!o){var c=typeof t=="string"?t:t.displayName||t.name;c&&(o=`
|
|
26
|
+
|
|
27
|
+
Check the top-level render call using <`+c+">.")}return o}}function qe(t,o){{if(!t._store||t._store.validated||t.key!=null)return;t._store.validated=!0;var c=Kt(o);if(Ne[c])return;Ne[c]=!0;var f="";t&&t._owner&&t._owner!==me.current&&(f=" It was passed a child from "+D(t._owner.type)+"."),Y(t),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,f),Y(null)}}function Ke(t,o){{if(typeof t!="object")return;if(pe(t))for(var c=0;c<t.length;c++){var f=t[c];ye(f)&&qe(f,o)}else if(ye(t))t._store&&(t._store.validated=!0);else if(t){var b=P(t);if(typeof b=="function"&&b!==t.entries)for(var x=b.call(t),m;!(m=x.next()).done;)ye(m.value)&&qe(m.value,o)}}}function Yt(t){{var o=t.type;if(o==null||typeof o=="string")return;var c;if(typeof o=="function")c=o.propTypes;else if(typeof o=="object"&&(o.$$typeof===h||o.$$typeof===A))c=o.propTypes;else return;if(c){var f=D(o);_t(c,t.props,"prop",f,t)}else if(o.PropTypes!==void 0&&!be){be=!0;var b=D(o);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",b||"Unknown")}typeof o.getDefaultProps=="function"&&!o.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function $t(t){{for(var o=Object.keys(t.props),c=0;c<o.length;c++){var f=o[c];if(f!=="children"&&f!=="key"){Y(t),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",f),Y(null);break}}t.ref!==null&&(Y(t),y("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}function Ye(t,o,c,f,b,x){{var m=kt(t);if(!m){var v="";(t===void 0||typeof t=="object"&&t!==null&&Object.keys(t).length===0)&&(v+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var w=qt(b);w?v+=w:v+=We();var S;t===null?S="null":pe(t)?S="array":t!==void 0&&t.$$typeof===e?(S="<"+(D(t.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):S=typeof t,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",S,v)}var k=Nt(t,o,c,b,x);if(k==null)return k;if(m){var _=o.children;if(_!==void 0)if(f)if(pe(_)){for(var $=0;$<_.length;$++)Ke(_[$],t);Object.freeze&&Object.freeze(_)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Ke(_,t)}return t===n?$t(k):Yt(k),k}}function zt(t,o,c){return Ye(t,o,c,!0)}function Gt(t,o,c){return Ye(t,o,c,!1)}var Jt=Gt,Xt=zt;G.Fragment=n,G.jsx=Jt,G.jsxs=Xt}()),G}(function(r){process.env.NODE_ENV==="production"?r.exports=Ge():r.exports=Je()})(ze);var Xe=Object.defineProperty,Qe=(r,e,s)=>e in r?Xe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s,g=(r,e,s)=>(Qe(r,typeof e!="symbol"?e+"":e,s),s);class J{constructor(e){g(this,"value"),g(this,"observers",[]),this.value=e,this.observers=[]}subscribe(e){this.observers.push(e),e(this.value)}unsubscribe(e){const s=this.observers.indexOf(e);s!==-1&&this.observers.splice(s,1)}setValue(e){this.value=e,this.notify()}getValue(){return this.value}notify(){this.observers.forEach(e=>e(this.value))}}class Ze{constructor(){g(this,"searchTermChangeObservable",new J("")),g(this,"loadingChangeObservable",new J(!1)),g(this,"searchResultsObservable",new J(null)),g(this,"searchResultsMetadataObservable",new J(null)),g(this,"searchAutosuggestObservable",new J(null)),g(this,"currentPage",1),g(this,"renderingEngine","mustache")}setSearchTerm(e){this.searchTermChangeObservable.setValue(e)}setRenderingEngine(e){this.renderingEngine=e}setCurrentPage(e){this.currentPage=e}setLoading(e){this.loadingChangeObservable.setValue(e)}setSearchResults(e){this.searchResultsObservable.setValue(e)}setSearchResultsMetadata(e){this.searchResultsMetadataObservable.setValue(e)}setSearchAutosuggest(e){this.searchAutosuggestObservable.setValue(e)}get searchResultsValue(){return this.searchResultsObservable.getValue()}get searchTermValue(){return this.searchTermChangeObservable.getValue()}get loadingValue(){return this.loadingChangeObservable.getValue()}get searchAutosuggestValue(){return this.searchAutosuggestObservable.getValue()}get searchResultsMetadataValue(){return this.searchResultsMetadataObservable.getValue()}get currentPageValue(){return this.currentPage}get renderingEngineValue(){return this.renderingEngine}}class ue{static combineResultsWithMetadata(e){const s=[],n=parseInt(e.response.start+"");return e.response.docs.forEach((a,i)=>{const u={custom:null,uniqueId:this.getValueByKey(e.responseHeader.params.uniqueId,a,e)??"",position:n+i+1,ribbon:this.doesMapExist("ribbon",e)?this.getValueByKey("ribbon",a,e):null,paths:this.doesMapExist("paths",e)?this.getValueByKey("paths",a,e):null,url:this.doesMapExist("url",e)?this.getValueByKey("url",a,e):null,title:this.doesMapExist("title",e)?this.getValueByKey("title",a,e):null,promoted:a["[elevated]"]?a["[elevated]"]:!1,thumbnail:this.doesMapExist("thumbnail",e)?this.getValueByKey("thumbnail",a,e):null,date:this.doesMapExist("date",e)?this.getValueByKey("date",a,e):null,snippet:this.doesMapExist("snippet",e)?this.getValueByKey("snippet",a,e):null,description:this.doesMapExist("description",e)?this.getValueByKey("description",a,e):null,unmappedFields:this.getUnmappedFields(a,e),allFields:this.getAllFields(a,e)};s.push(u)}),s}static extractSearchResultsMetadata(e){var s,n,a,i;let u="";return u=((i=(a=(n=(s=e==null?void 0:e.spellcheck)==null?void 0:s.suggestions)==null?void 0:n[0])==null?void 0:a.suggestion)==null?void 0:i[0])??"",typeof u!="string"&&(u=(u==null?void 0:u.word)??""),{recordsPerPageValue:parseInt(e.responseHeader.params.rows),startDocVal:parseInt(e.response.start+""),totalResultsValue:parseInt(e.response.numFound+""),latency:parseInt(e.responseHeader.QTime+""),endDocValue:parseInt(e.responseHeader.params.rows)+parseInt(e.response.start+""),spellingSuggestion:u}}static findResultByUniqueId(e,s){return s.find(n=>n.uniqueId===e)??null}static getUnmappedFields(e,s){const n=s.metadata.results.filter(i=>i.result_card==="").map(i=>i.name),a=[];for(const i of Object.keys(e))if(n.indexOf(i)!==-1){const u=Array.isArray(e[i])?e[i].join(", "):e[i];a.push({key:i,value:u,isImage:this.checkIfImage(e[i])})}return a}static checkIfImage(e){return e===void 0||typeof e!="string"?!1:/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(e)}static getAllFields(e,s){const n=s.metadata.results.map(i=>i.name),a=[];for(const i of Object.keys(e))n.indexOf(i)!==-1&&a.push({key:i,value:e[i],isImage:this.checkIfImage(e[i])});return a}static doesMapExist(e,s){return s.metadata.results.find(n=>n.result_card===e)!==void 0}static getValueByKey(e,s,n){const a=n.metadata.results.find(u=>u.result_card===e);if(a===void 0)return null;const i=s[a.name];return i===void 0?null:typeof i=="string"?i:Array.isArray(i)?i.join(", "):null}}class et{constructor(e,s){g(this,"url",""),g(this,"relatedSearches",""),g(this,"suggester",""),g(this,"authHeader"),g(this,"authHeaderRelated"),g(this,"language","en"),g(this,"trackApiKey",""),g(this,"session",""),g(this,"searchAuthType"),g(this,"controllerSearch"),g(this,"signalSearch"),g(this,"controllerSuggest"),g(this,"signalSuggest"),g(this,"dataLayer"),this.dataLayer=s,this.url=e.searchURL,this.language=e.language,this.suggester=e.suggesterURL,this.trackApiKey=e.trackApiKey,this.session=e.sessionId,this.searchAuthType=e.authType,this.authHeader=new Headers,this.authHeader.append("Accept","application/json");const n=this.searchAuthType==="token"?`Token ${e.searchAuth}`:`Basic ${e.searchAuth}`;this.authHeader.append("Authorization",n),this.authHeaderRelated=new Headers,this.authHeaderRelated.append("Accept","application/json"),this.authHeaderRelated.append("Authorization",e.searchAuth)}search(e,s,n){this.dataLayer.setSearchTerm(e),this.dataLayer.setLoading(!0),this.controllerSearch&&this.controllerSearch.abort(),this.controllerSearch=new AbortController,this.signalSearch=this.controllerSearch.signal;const a=new Proxy(new URLSearchParams(window.location.search),{get:(l,h)=>l.get(h)??""}),i=a.languageVariant?"&fq=_language:"+a.languageVariant:"",u=this.url+"?q="+encodeURIComponent(e.trim())+this.toQueryString(n)+"&language="+this.language+i;fetch(u,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSearch}).then(l=>l.json()).then(l=>{this.dataLayer.setLoading(!1),s(l)}).catch(l=>{this.dataLayer.setLoading(!1),console.log(l)})}suggest(e,s,n){this.controllerSuggest&&this.controllerSuggest.abort(),this.controllerSuggest=new AbortController,this.signalSuggest=this.controllerSuggest.signal;const a=this.suggester+"?q="+e.trim()+this.toQueryString(n)+"&language="+this.language;fetch(a,{method:"GET",headers:this.authHeader,credentials:"same-origin",signal:this.signalSuggest}).then(i=>i.json()).then(i=>{s(i)}).catch(i=>console.log(i))}fields(){return this.fields}toQueryString(e){return"&"+e.join("&")}}class tt{static getOrSetCookie(e){let s=this.getCookie(e);return s==null&&(s=this.makeid(25),this.setCookie(e,s,{secure:!0,"max-age":3600})),s}static makeid(e){let s="";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a=n.length;for(let i=0;i<e;i++)s+=n.charAt(Math.floor(Math.random()*a));return s}static getCookie(e){const s=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return s?decodeURIComponent(s[1]):void 0}static setCookie(e,s,n){const a={path:"/",...n};n.expires instanceof Date&&(a.expires=n.expires.toUTCString());let i=encodeURIComponent(e)+"="+encodeURIComponent(s);for(const u in a){i+="; "+u;const l=a[u];l!==!0&&(i+="="+l)}document.cookie=i}}class st{static trackClick(e){const s={key:e.trackApiKey,query:e.searchTermValue,shownHits:e.recordsPerPage,totalHits:e.totalResults,pageNo:e.currentPage,latency:e.latencyVal,session:e.session,cDocId:e.result.uniqueId,cDocTitle:e.result.title,position:e.result.position,language:e.language};_msq.push(["trackClick",s])}}/*!
|
|
28
|
+
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
29
|
+
* http://github.com/janl/mustache.js
|
|
30
|
+
*/var rt=Object.prototype.toString,N=Array.isArray||function(r){return rt.call(r)==="[object Array]"};function ce(r){return typeof r=="function"}function at(r){return N(r)?"array":typeof r}function le(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function Re(r,e){return r!=null&&typeof r=="object"&&e in r}function nt(r,e){return r!=null&&typeof r!="object"&&r.hasOwnProperty&&r.hasOwnProperty(e)}var it=RegExp.prototype.test;function ot(r,e){return it.call(r,e)}var ut=/\S/;function ct(r){return!ot(ut,r)}var lt={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function ht(r){return String(r).replace(/[&<>"'`=\/]/g,function(e){return lt[e]})}var gt=/\s*/,dt=/\s+/,Se=/\s*=/,ft=/\s*\}/,pt=/#|\^|\/|>|\{|&|=|!/;function vt(r,e){if(!r)return[];var s=!1,n=[],a=[],i=[],u=!1,l=!1,h="",p=0;function C(){if(u&&!l)for(;i.length;)delete a[i.pop()];else i=[];u=!1,l=!1}var A,L,U;function Z(O){if(typeof O=="string"&&(O=O.split(dt,2)),!N(O)||O.length!==2)throw new Error("Invalid tags: "+O);A=new RegExp(le(O[0])+"\\s*"),L=new RegExp("\\s*"+le(O[1])),U=new RegExp("\\s*"+le("}"+O[1]))}Z(e||T.tags);for(var E=new X(r),P,R,y,H,K,F;!E.eos();){if(P=E.pos,y=E.scanUntil(A),y)for(var ee=0,he=y.length;ee<he;++ee)H=y.charAt(ee),ct(H)?(i.push(a.length),h+=H):(l=!0,s=!0,h+=" "),a.push(["text",H,P,P+1]),P+=1,H===`
|
|
31
|
+
`&&(C(),h="",p=0,s=!1);if(!E.scan(A))break;if(u=!0,R=E.scan(pt)||"name",E.scan(gt),R==="="?(y=E.scanUntil(Se),E.scan(Se),E.scanUntil(L)):R==="{"?(y=E.scanUntil(U),E.scan(ft),E.scanUntil(L),R="&"):y=E.scanUntil(L),!E.scan(L))throw new Error("Unclosed tag at "+E.pos);if(R==">"?K=[R,y,P,E.pos,h,p,s]:K=[R,y,P,E.pos],p++,a.push(K),R==="#"||R==="^")n.push(K);else if(R==="/"){if(F=n.pop(),!F)throw new Error('Unopened section "'+y+'" at '+P);if(F[1]!==y)throw new Error('Unclosed section "'+F[1]+'" at '+P)}else R==="name"||R==="{"||R==="&"?l=!0:R==="="&&Z(y)}if(C(),F=n.pop(),F)throw new Error('Unclosed section "'+F[1]+'" at '+E.pos);return bt(mt(a))}function mt(r){for(var e=[],s,n,a=0,i=r.length;a<i;++a)s=r[a],s&&(s[0]==="text"&&n&&n[0]==="text"?(n[1]+=s[1],n[3]=s[3]):(e.push(s),n=s));return e}function bt(r){for(var e=[],s=e,n=[],a,i,u=0,l=r.length;u<l;++u)switch(a=r[u],a[0]){case"#":case"^":s.push(a),n.push(a),s=a[4]=[];break;case"/":i=n.pop(),i[5]=a[2],s=n.length>0?n[n.length-1][4]:e;break;default:s.push(a)}return e}function X(r){this.string=r,this.tail=r,this.pos=0}X.prototype.eos=function(){return this.tail===""},X.prototype.scan=function(r){var e=this.tail.match(r);if(!e||e.index!==0)return"";var s=e[0];return this.tail=this.tail.substring(s.length),this.pos+=s.length,s},X.prototype.scanUntil=function(r){var e=this.tail.search(r),s;switch(e){case-1:s=this.tail,this.tail="";break;case 0:s="";break;default:s=this.tail.substring(0,e),this.tail=this.tail.substring(e)}return this.pos+=s.length,s};function q(r,e){this.view=r,this.cache={".":this.view},this.parent=e}q.prototype.push=function(r){return new q(r,this)},q.prototype.lookup=function(r){var e=this.cache,s;if(e.hasOwnProperty(r))s=e[r];else{for(var n=this,a,i,u,l=!1;n;){if(r.indexOf(".")>0)for(a=n.view,i=r.split("."),u=0;a!=null&&u<i.length;)u===i.length-1&&(l=Re(a,i[u])||nt(a,i[u])),a=a[i[u++]];else a=n.view[r],l=Re(n.view,r);if(l){s=a;break}n=n.parent}e[r]=s}return ce(s)&&(s=s.call(this.view)),s};function I(){this.templateCache={_cache:{},set:function(r,e){this._cache[r]=e},get:function(r){return this._cache[r]},clear:function(){this._cache={}}}}I.prototype.clearCache=function(){typeof this.templateCache<"u"&&this.templateCache.clear()},I.prototype.parse=function(r,e){var s=this.templateCache,n=r+":"+(e||T.tags).join(":"),a=typeof s<"u",i=a?s.get(n):void 0;return i==null&&(i=vt(r,e),a&&s.set(n,i)),i},I.prototype.render=function(r,e,s,n){var a=this.getConfigTags(n),i=this.parse(r,a),u=e instanceof q?e:new q(e,void 0);return this.renderTokens(i,u,s,r,n)},I.prototype.renderTokens=function(r,e,s,n,a){for(var i="",u,l,h,p=0,C=r.length;p<C;++p)h=void 0,u=r[p],l=u[0],l==="#"?h=this.renderSection(u,e,s,n,a):l==="^"?h=this.renderInverted(u,e,s,n,a):l===">"?h=this.renderPartial(u,e,s,a):l==="&"?h=this.unescapedValue(u,e):l==="name"?h=this.escapedValue(u,e,a):l==="text"&&(h=this.rawValue(u)),h!==void 0&&(i+=h);return i},I.prototype.renderSection=function(r,e,s,n,a){var i=this,u="",l=e.lookup(r[1]);function h(A){return i.render(A,e,s,a)}if(l){if(N(l))for(var p=0,C=l.length;p<C;++p)u+=this.renderTokens(r[4],e.push(l[p]),s,n,a);else if(typeof l=="object"||typeof l=="string"||typeof l=="number")u+=this.renderTokens(r[4],e.push(l),s,n,a);else if(ce(l)){if(typeof n!="string")throw new Error("Cannot use higher-order sections without the original template");l=l.call(e.view,n.slice(r[3],r[5]),h),l!=null&&(u+=l)}else u+=this.renderTokens(r[4],e,s,n,a);return u}},I.prototype.renderInverted=function(r,e,s,n,a){var i=e.lookup(r[1]);if(!i||N(i)&&i.length===0)return this.renderTokens(r[4],e,s,n,a)},I.prototype.indentPartial=function(r,e,s){for(var n=e.replace(/[^ \t]/g,""),a=r.split(`
|
|
32
|
+
`),i=0;i<a.length;i++)a[i].length&&(i>0||!s)&&(a[i]=n+a[i]);return a.join(`
|
|
33
|
+
`)},I.prototype.renderPartial=function(r,e,s,n){if(s){var a=this.getConfigTags(n),i=ce(s)?s(r[1]):s[r[1]];if(i!=null){var u=r[6],l=r[5],h=r[4],p=i;l==0&&h&&(p=this.indentPartial(i,h,u));var C=this.parse(p,a);return this.renderTokens(C,e,s,p,n)}}},I.prototype.unescapedValue=function(r,e){var s=e.lookup(r[1]);if(s!=null)return s},I.prototype.escapedValue=function(r,e,s){var n=this.getConfigEscape(s)||T.escape,a=e.lookup(r[1]);if(a!=null)return typeof a=="number"&&n===T.escape?String(a):n(a)},I.prototype.rawValue=function(r){return r[1]},I.prototype.getConfigTags=function(r){return N(r)?r:r&&typeof r=="object"?r.tags:void 0},I.prototype.getConfigEscape=function(r){if(r&&typeof r=="object"&&!N(r))return r.escape};var T={name:"mustache.js",version:"4.2.0",tags:["{{","}}"],clearCache:void 0,escape:void 0,parse:void 0,render:void 0,Scanner:void 0,Context:void 0,Writer:void 0,set templateCache(r){Q.templateCache=r},get templateCache(){return Q.templateCache}},Q=new I;T.clearCache=function(){return Q.clearCache()},T.parse=function(r,e){return Q.parse(r,e)},T.render=function(r,e,s,n){if(typeof r!="string")throw new TypeError('Invalid template! Template should be a "string" but "'+at(r)+'" was given as the first argument for mustache#render(template, view, partials)');return Q.render(r,e,s,n)},T.escape=ht,T.Scanner=X,T.Context=q,T.Writer=I;class yt{constructor(e){g(this,"dataLayer"),g(this,"config"),g(this,"suggestAfterMinChars"),g(this,"containerId"),g(this,"currentInputValue",""),g(this,"autosuggestResults"),g(this,"searchInput"),g(this,"actionButton"),g(this,"autosuggestContainer"),g(this,"buttonState","search"),g(this,"selectedAutosuggestItem",-1),g(this,"suggestTrigger"),g(this,"searchTrigger"),this.dataLayer=e.dataLayer,this.config=e.config,this.searchTrigger=e.searchTrigger,this.suggestTrigger=e.suggestTrigger,this.containerId=e.containerId,this.suggestAfterMinChars=e.config.suggestAfterMinChars,this.renderMainTemplate(),this.actionButtonInit(),this.updateActionButtonState("search"),this.searchInput&&(this.createAutosuggestContainer(),this.attachSubscriptions())}renderMainTemplate(){var e,s;const n=document.getElementById(this.containerId);if(!n)throw new Error("Search input container not found");const a=((e=this.config.templates)==null?void 0:e.mainTemplate)||`
|
|
34
|
+
<div class="searchstax-search-input-container">
|
|
35
|
+
<div class="searchstax-search-input-wrapper">
|
|
36
|
+
<input type="text" id="searchstax-search-input" class="searchstax-search-input" placeholder="SEARCH FOR..." />
|
|
37
|
+
<button class="searchstax-spinner-icon" id="searchstax-search-input-action-button"></button>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
`;if(console.log("this.dataLayer.renderingEngineValue",this.dataLayer.renderingEngineValue),this.dataLayer.renderingEngineValue==="mustache"){const l=T.render(a,{});n.innerHTML=l}const i=((s=this.config.templates)==null?void 0:s.searchInputId)||"searchstax-search-input",u=document.querySelector(`#${i}`);if(u)this.searchInput=u,u.addEventListener("keyup",this.inputKeyupEvent.bind(this)),u.addEventListener("blur",this.hideAutosuggest.bind(this)),u.addEventListener("paste",this.inputPasteEvent.bind(this));else throw new Error("Input not found")}createAutosuggestContainer(){var e;this.autosuggestContainer=document.createElement("div"),this.autosuggestContainer.classList.add("searchstax-autosuggest-container"),this.autosuggestContainer.addEventListener("mouseleave",()=>{this.resetAutosuggestSelection(),this.markActiveAutosuggestItem()}),(e=this.searchInput)==null||e.after(this.autosuggestContainer)}actionButtonInit(){this.actionButton=document.getElementById("searchstax-search-input-action-button"),this.actionButton&&this.actionButton.addEventListener("click",()=>{var e;this.buttonState==="search"?this.executeSearch(((e=this.searchInput)==null?void 0:e.value)??""):this.buttonState==="close"&&this.searchInput&&(this.searchInput.value="",this.executeSearch(""))})}attachSubscriptions(){this.dataLayer.searchTermChangeObservable.subscribe(()=>{this.handleSearchTermChange()}),this.dataLayer.loadingChangeObservable.subscribe(()=>{this.handleLoadingChange()}),this.dataLayer.searchAutosuggestObservable.subscribe(e=>{e&&this.appendSuggestions(e)})}handleLoadingChange(){this.dataLayer.loadingValue?this.updateActionButtonState("loading"):this.handleSearchTermChange()}handleSearchTermChange(){var e;this.dataLayer.searchTermValue===((e=this.searchInput)==null?void 0:e.value)&&this.searchInput.value!==""?this.updateActionButtonState("close"):this.updateActionButtonState("search")}updateActionButtonState(e){if(this.buttonState=e,this.actionButton)switch(this.actionButton.classList.remove("searchstax-spinner-icon"),this.actionButton.classList.remove("searchstax-search-close"),this.actionButton.classList.remove("searchstax-search-icon"),e){case"loading":this.actionButton.classList.add("searchstax-spinner-icon");break;case"search":this.actionButton.classList.add("searchstax-search-icon");break;case"close":this.actionButton.classList.add("searchstax-search-close");break}}selectPreviousAutosuggestItem(){this.selectedAutosuggestItem>0?this.selectedAutosuggestItem--:this.selectedAutosuggestItem=this.autosuggestResults.suggestions.length-1,this.markActiveAutosuggestItem()}selectNextAutosuggestItem(){this.selectedAutosuggestItem<this.autosuggestResults.suggestions.length-1?this.selectedAutosuggestItem++:this.selectedAutosuggestItem=0,this.markActiveAutosuggestItem()}resetAutosuggestSelection(){this.selectedAutosuggestItem=-1,this.markActiveAutosuggestItem()}markActiveAutosuggestItem(){const e=document.getElementsByClassName("searchstax-autosuggest-item");for(let s=0;s<e.length;s++){const n=e[s];s===this.selectedAutosuggestItem?n.classList.add("active"):n.classList.remove("active")}}inputKeyupEvent(e){const s=e.key;this.currentInputValue=e.target.value,s==="Enter"?this.suggestionChosen():s==="Escape"?this.hideAutosuggest():s==="ArrowUp"?this.selectPreviousAutosuggestItem():s==="ArrowDown"?this.selectNextAutosuggestItem():this.autosuggestHandling(e),this.handleSearchTermChange()}autosuggestHandling(e){e.target&&e.target.value.length>=this.suggestAfterMinChars?this.executeSuggest(e.target.value):this.hideAutosuggest()}inputPasteEvent(e){setTimeout(()=>{this.autosuggestHandling(e),this.handleSearchTermChange()},0)}executeSuggest(e){this.suggestTrigger(e)}executeSearch(e){this.hideAutosuggest(),this.searchTrigger(e===""?"*":e)}suggestionChosen(){this.selectedAutosuggestItem>-1?this.autosuggestItemClicked(this.autosuggestResults.suggestions[this.selectedAutosuggestItem]):this.executeSearch(this.currentInputValue)}hideAutosuggest(){this.autosuggestContainer&&(this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.add("hidden")),this.resetAutosuggestSelection()}cleanSuggestionTerm(e){return e.replace(/(<([^>]+)>)/gi,"").trim()}autosuggestItemClicked(e){this.searchInput.value=this.cleanSuggestionTerm(e.term),this.executeSearch(this.cleanSuggestionTerm(e.term))}createAutosuggestItem(e){var s;const n=document.createElement("div");n.classList.add("searchstax-autosuggest-item"),n.addEventListener("click",()=>{this.autosuggestItemClicked(e)}),n.addEventListener("mouseenter",()=>{var i;this.selectedAutosuggestItem=((i=this.autosuggestResults)==null?void 0:i.suggestions.indexOf(e))||0,this.markActiveAutosuggestItem()});const a=((s=this.config.templates)==null?void 0:s.autosuggestItemTemplate)||'<div class="searchstax-autosuggest-item-term-container">{{{term}}}</div>';return n.innerHTML=T.render(a,e),n}appendSuggestions(e){if(this.autosuggestContainer){this.autosuggestContainer.innerHTML="",this.autosuggestContainer.classList.remove("hidden");for(const s in e.suggest)if(Object.prototype.hasOwnProperty.call(e.suggest,s)){const n=e.suggest[s];for(const a in n)if(Object.prototype.hasOwnProperty.call(n,a)){const i=n[a];this.autosuggestResults=i,i.numFound>0?i.suggestions.forEach(u=>{this.autosuggestContainer.appendChild(this.createAutosuggestItem(u))}):this.autosuggestContainer.classList.add("hidden")}}}}}class xt{constructor(e){g(this,"dataLayer"),g(this,"config"),g(this,"linkClickCallback"),g(this,"searchCallback"),g(this,"containerId"),g(this,"searchResultsMainContainer"),g(this,"searchResultsContainer"),g(this,"searchResultLinks",[]),this.linkClickCallback=e.linkClickCallback,this.searchCallback=e.searchTrigger,this.dataLayer=e.dataLayer,this.config=e.config,this.containerId=e.containerId;const s=document.getElementById(this.containerId);if(console.log("resultsContainer",s),s)this.searchResultsMainContainer=s;else throw new Error(`Search Results Main Container with id ${this.containerId} not found`);this.initializeSubscriptions(),this.renderMainTemplate()}initializeSubscriptions(){this.dataLayer.searchResultsObservable.subscribe(e=>{e&&this.searchResultsContainer&&this.renderResults(e)})}renderNoResultsTemplate(){var e,s,n;const a=((s=(e=this.config)==null?void 0:e.templates)==null?void 0:s.noSearchResultTemplate)||`
|
|
41
|
+
<div class="searchstax-no-results">
|
|
42
|
+
Showing <strong>no results</strong> for <strong>"{{ searchTerm }}"</strong>
|
|
43
|
+
<br>
|
|
44
|
+
{{#spellingSuggestion}}
|
|
45
|
+
<span> Did you mean <a href="#"
|
|
46
|
+
class="searchstax-suggestion-term">{{ spellingSuggestion }}</a>?</span>
|
|
47
|
+
{{/spellingSuggestion}}
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<p>Try searching for search related terms or topics. We offer a wide variety of content to help you get the information you need.</p>
|
|
51
|
+
<p>Lost? Click on the ‘X” in the Search Box to reset your search.</p>
|
|
52
|
+
</div>
|
|
53
|
+
`,i=((n=this.dataLayer.searchResultsMetadataValue)==null?void 0:n.spellingSuggestion)??"";if(this.dataLayer.renderingEngineValue==="mustache"&&this.searchResultsContainer&&(this.searchResultsContainer.innerHTML=T.render(a,{spellingSuggestion:i,searchTerm:this.dataLayer.searchTermValue})),i&&this.searchResultsContainer){const u=this.searchResultsContainer.querySelector("a");u&&u.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),this.searchCallback(i)})}}renderResults(e){var s,n;if(this.dataLayer.renderingEngineValue==="mustache"&&this.searchResultsContainer)if(this.removeLinkClickEvents(),e.length===0)this.renderNoResultsTemplate();else{const a=((n=(s=this.config)==null?void 0:s.templates)==null?void 0:n.searchResultTemplate)||`
|
|
54
|
+
<div class="searchstax-search-result">
|
|
55
|
+
{{#url}}
|
|
56
|
+
<a href="{{url}}" data-searchstax-unique-result-id="{{uniqueId}}" class="searchstax-result-item-link"></a>
|
|
57
|
+
{{/url}}
|
|
58
|
+
{{#ribbon}}
|
|
59
|
+
<div class="searchstax-search-result-ribbon">
|
|
60
|
+
{{ribbon}}
|
|
61
|
+
</div>
|
|
62
|
+
{{/ribbon}}
|
|
63
|
+
{{#thumbnail}}
|
|
64
|
+
<img :src="thumbnail" class="searchstax-thumbnail">
|
|
65
|
+
{{/thumbnail}}
|
|
66
|
+
<div class="searchstax-search-result-title-container">
|
|
67
|
+
<span class="searchstax-search-result-title">{{title}}</span>
|
|
68
|
+
</div>
|
|
69
|
+
{{#paths}}
|
|
70
|
+
<p class="searchstax-search-result-common">
|
|
71
|
+
{{paths}}
|
|
72
|
+
</p>
|
|
73
|
+
{{/paths}}
|
|
74
|
+
{{#description}}
|
|
75
|
+
<p class="searchstax-search-result-description searchstax-search-result-common">
|
|
76
|
+
{{description}}
|
|
77
|
+
</p>
|
|
78
|
+
{{/description}}
|
|
79
|
+
{{#unmappedFields}}
|
|
80
|
+
{{#isImage}}
|
|
81
|
+
<div class="searchstax-search-result-image-container">
|
|
82
|
+
<img :src="result[value]" class="searchstax-result-image">
|
|
83
|
+
</div>
|
|
84
|
+
{{/isImage}}
|
|
85
|
+
{{^isImage}}
|
|
86
|
+
<p class="searchstax-search-result-common">
|
|
87
|
+
{{value}}
|
|
88
|
+
</p>
|
|
89
|
+
{{/isImage}}
|
|
90
|
+
{{/unmappedFields}}
|
|
91
|
+
</div>`,i=e.map(u=>T.render(a,u));this.searchResultsContainer.innerHTML=i.join(""),this.searchResultLinks=Array.from(this.searchResultsContainer.querySelectorAll(`[${this.uniqueIdAttribute}]`)),this.attachLinkClickEvents()}}removeLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.removeEventListener("click",()=>{})})}get uniqueIdAttribute(){return this.config.searchResultUniqueIdAttribute||"data-searchstax-unique-result-id"}attachLinkClickEvents(){this.searchResultLinks.forEach(e=>{e.addEventListener("click",s=>{s.preventDefault(),s.stopPropagation();const n=e.getAttribute(this.uniqueIdAttribute)??"";n&&this.linkClickCallback(n)})})}renderMainTemplate(){var e,s;const n=((s=(e=this.config)==null?void 0:e.templates)==null?void 0:s.mainTemplate)||`
|
|
92
|
+
<div class="searchstax-search-results-container">
|
|
93
|
+
<div class="searchstax-search-results"></div>
|
|
94
|
+
</div>
|
|
95
|
+
`;this.dataLayer.renderingEngineValue==="mustache"&&(this.searchResultsMainContainer.innerHTML=T.render(n,{})),setTimeout(()=>{var a,i;const u=(a=this.config)!=null&&a.searchResultsContainerId?(i=this.config)==null?void 0:i.searchResultsContainerId:"searchstax-search-results",l=document.getElementById(u);if(l)this.searchResultsContainer=l;else throw new Error(`Search Results Container with id ${u} not found`)},0)}}class Ct{constructor(e="mustache"){g(this,"sessionId"),g(this,"searchstaxConfig"),g(this,"searchHelper"),g(this,"searchInputConfig"),g(this,"searchResultsConfig"),g(this,"searchInputWidget"),g(this,"searchResultsWidget"),g(this,"dataLayer",new Ze),e&&this.dataLayer.setRenderingEngine(e),this.sessionId=tt.getOrSetCookie("searchstax_session_id"),this.handleHooks()}setRenderingEngine(e="mustache"){this.dataLayer.setRenderingEngine(e)}handleHooks(){var e,s;(s=(e=this.searchInputConfig)==null?void 0:e.hooks)!=null&&s.afterSearch&&this.dataLayer.searchResultsObservable.subscribe(n=>{this.searchInputConfig.hooks.afterSearch(n)})}initialize(e){this.searchstaxConfig||(this.searchstaxConfig=e,this.searchHelper=new et({...e,sessionId:this.sessionId},this.dataLayer))}search(e,s){this.searchHelper&&this.searchHelper.search(e,this.parseSearchResultsResponse.bind(this),s)}parseSearchResultsResponse(e){var s,n;let a=ue.combineResultsWithMetadata(e);(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.afterSearch&&(a=this.searchInputConfig.hooks.afterSearch(a)),this.dataLayer.setSearchResults(a),this.dataLayer.setSearchResultsMetadata(ue.extractSearchResultsMetadata(e))}parseSuggestSuggestResponse(e){var s,n;let a=e;(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.afterAutosuggest&&(a=this.searchInputConfig.hooks.afterAutosuggest(e)),this.dataLayer.setSearchAutosuggest(a)}suggest(e,s){this.searchHelper&&this.searchHelper.suggest(e,this.parseSuggestSuggestResponse.bind(this),s)}changeLanguage(e){this.searchHelper&&(this.searchHelper.language=e)}addSearchInputWidget(e,s){this.searchInputConfig||(this.searchInputConfig=s,this.searchInputWidget=new yt({containerId:e,config:s,searchTrigger:this.executeSearch.bind(this),suggestTrigger:this.executeSuggest.bind(this),dataLayer:this.dataLayer}))}addSearchResultsWidget(e,s){this.searchResultsConfig||(this.searchResultsConfig=s,this.searchResultsWidget=new xt({containerId:e,linkClickCallback:this.executeLinkClick.bind(this),searchTrigger:this.executeSearch.bind(this),config:s,dataLayer:this.dataLayer}))}executeSearch(e){var s,n;let a={term:e,queryParams:[]};(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.beforeSearch&&(a=this.searchInputConfig.hooks.beforeSearch(a)),a&&a.term!==void 0&&a.queryParams!==void 0&&this.search(a.term,a.queryParams)}executeSuggest(e){var s,n;let a={term:e,queryParams:[]};(n=(s=this.searchInputConfig)==null?void 0:s.hooks)!=null&&n.beforeAutosuggest&&(a=this.searchInputConfig.hooks.beforeAutosuggest(a)),a&&a.term!==void 0&&a.queryParams!==void 0&&this.suggest(a.term,a.queryParams)}executeLinkClick(e){var s,n,a,i;let u=ue.findResultByUniqueId(e,this.dataLayer.searchResultsValue??[]);u&&((n=(s=this.searchResultsConfig)==null?void 0:s.hooks)!=null&&n.afterLinkClick&&(u=this.searchResultsConfig.hooks.afterLinkClick(u)),u&&(console.log("foundResult",u),this.dataLayer.searchResultsMetadataValue&&st.trackClick({result:u,searchTermValue:this.dataLayer.searchTermValue,trackApiKey:((a=this.searchstaxConfig)==null?void 0:a.trackApiKey)??"",session:this.sessionId,language:((i=this.searchHelper)==null?void 0:i.language)??"",recordsPerPage:this.dataLayer.searchResultsMetadataValue.recordsPerPageValue,totalResults:this.dataLayer.searchResultsMetadataValue.totalResultsValue,currentPage:this.dataLayer.currentPageValue,latencyVal:this.dataLayer.searchResultsMetadataValue.latency})))}}const M={searchstax:new Ct("react")};function Rt(r){return j.useEffect(()=>{if(M.searchstax){const e={};r.beforeSearch&&(e.beforeSearch=r.beforeSearch),r.afterSearch&&(e.afterSearch=r.afterSearch),r.afterAutosuggest&&(e.afterAutosuggest=r.afterAutosuggest),r.beforeAutosuggest&&(e.beforeAutosuggest=r.beforeAutosuggest),M.searchstax.addSearchInputWidget("searchstax-input-container",{suggestAfterMinChars:r.suggestAfterMinChars??3,hooks:e,templates:{searchInputId:r.searchInputId??"searchstax-search-input"}})}else throw Error("Searchstax instance needs to be passed via props")},[]),d.jsx(d.Fragment,{children:d.jsx("div",{id:"searchstax-input-container",children:d.jsxs("div",{className:"searchstax-search-input-container",children:[!r.inputTemplate&&d.jsxs("div",{className:"searchstax-search-input-wrapper",children:[d.jsx("input",{type:"text",id:"searchstax-search-input",className:"searchstax-search-input",placeholder:"SEARCH FOR..."}),d.jsx("button",{className:"searchstax-spinner-icon",id:"searchstax-search-input-action-button"})]}),r.inputTemplate&&d.jsx(d.Fragment,{children:r.inputTemplate()})]})})})}function St(r){return j.useEffect(()=>{M.searchstax.initialize({language:r.language??"en",searchURL:r.searchURL,suggesterURL:r.suggesterURL,trackApiKey:r.trackApiKey,searchAuth:r.searchAuth,authType:r.authType??"basic"}),r.initialized(M.searchstax)},[r.initialized]),d.jsx(d.Fragment,{children:r.children})}function Et(r){const[e,s]=j.useState(null),[n,a]=j.useState(""),[i,u]=j.useState(""),l=(h,p)=>{p.preventDefault(),p.stopPropagation(),M.searchstax.executeLinkClick(h.uniqueId)};return j.useEffect(()=>{const h={};r.afterLinkClick&&(h.afterLinkClick=r.afterLinkClick),M.searchstax.dataLayer.searchResultsObservable.subscribe(p=>{s(p)}),M.searchstax.dataLayer.searchResultsMetadataObservable.subscribe(p=>{u((p==null?void 0:p.spellingSuggestion)??"")}),M.searchstax.dataLayer.searchTermChangeObservable.subscribe(p=>{a(p)}),M.searchstax.addSearchResultsWidget("searchstax-results-container",{searchResultsContainerId:"searchstax-result-container",templates:{},hooks:h})},[]),d.jsx(d.Fragment,{children:d.jsx("div",{id:"searchstax-results-container",children:d.jsx("div",{className:"searchstax-search-results-container",children:d.jsxs("div",{id:"searchstax-result-container",children:[e&&e.length===0&&!r.noResultTemplate&&d.jsxs("div",{children:[d.jsxs("div",{className:"searchstax-no-results",children:["Showing ",d.jsx("strong",{children:"no results"})," for",d.jsxs("strong",{children:['"',n,'"']}),d.jsx("br",{}),i&&d.jsxs("span",{children:[" Did you mean",d.jsx("a",{href:"#",className:"searchstax-suggestion-term",children:i}),"?"]})]}),d.jsxs("div",{children:[d.jsx("p",{children:"Try searching for search related terms or topics. We offer a wide variety of content to help you get the information you need."}),d.jsx("p",{children:"Lost? Click on the ‘X” in the Search Box to reset your search."})]})]}),e&&e.length===0&&r.noResultTemplate&&d.jsx(d.Fragment,{children:r.noResultTemplate(n,i)}),e&&e.length&&!r.resultsTemplate&&d.jsxs("div",{className:"searchstax-search-results",children:[e!==null&&e.map(function(h){return d.jsxs("div",{className:"searchstax-search-result",children:[h.url&&d.jsx("a",{href:h.url,"data-searchstax-unique-result-id":h.uniqueId,onClick:p=>{l(h,p)},className:"searchstax-result-item-link"}),h.ribbon&&d.jsx("div",{className:"searchstax-search-result-ribbon",children:h.ribbon}),h.thumbnail&&d.jsx("img",{src:h.thumbnail,className:"searchstax-thumbnail"}),d.jsx("div",{className:"searchstax-search-result-title-container",children:d.jsx("span",{className:"searchstax-search-result-title",children:h.title})}),h.paths&&d.jsx("p",{className:"searchstax-search-result-common",children:h.paths}),h.description&&d.jsx("p",{className:"searchstax-search-result-description searchstax-search-result-common",children:h.description}),h.unmappedFields.map(function(p){return d.jsxs("div",{children:[p.isImage&&d.jsx("div",{className:"searchstax-search-result-image-container",children:d.jsx("img",{src:p.value,className:"searchstax-result-image"})}),!p.isImage&&d.jsx("div",{children:d.jsx("p",{className:"searchstax-search-result-common",children:p.value})})]},p.value)})]},h.uniqueId)}),e!==null&&e.length&&d.jsx("div",{"v-if":"searchResults && searchResults.length && hasResultSlot"})]}),e&&e.length&&r.resultsTemplate&&d.jsx(d.Fragment,{children:r.resultsTemplate(e,l)})]})})})})}V.SearchstaxInputWidget=Rt,V.SearchstaxResultWidget=Et,V.SearchstaxWrapper=St,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@searchstax-inc/searchstudio-ux-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/searchstudio-ux-react-ts.umd.js",
|
|
7
7
|
"module": "./dist/searchstudio-ux-react-ts.es.js",
|
|
8
8
|
"types": "./dist/main.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
9
12
|
"exports": {
|
|
10
13
|
".": {
|
|
11
14
|
"import": "./dist/searchstudio-ux-react-ts.es.js",
|
package/index.html
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Vite + React + TS</title>
|
|
8
|
-
<script type="text/javascript">
|
|
9
|
-
var _msq = _msq || []; //declare object
|
|
10
|
-
var analyticsBaseUrl = 'https://analytics-us-east.searchstax.co';
|
|
11
|
-
(function () {
|
|
12
|
-
var ms = document.createElement('script');
|
|
13
|
-
ms.type = 'text/javascript';
|
|
14
|
-
ms.src = 'https://static.searchstax.co/studio-js/v3/js/studio-analytics.js';
|
|
15
|
-
var s = document.getElementsByTagName('script')[0];
|
|
16
|
-
s.parentNode.insertBefore(ms, s);
|
|
17
|
-
})();
|
|
18
|
-
</script>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<div id="root"></div>
|
|
22
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
23
|
-
</body>
|
|
24
|
-
</html>
|
package/src/App.scss
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import './../node_modules/@searchstax-inc/searchstudio-ux-js/dist/styles/scss/mainTheme.scss';
|
package/src/App.tsx
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import "./App.scss";
|
|
3
|
-
import SearchstaxInputWidget from "./components/SearchstaxInputWidget";
|
|
4
|
-
import SearchstaxResultWidget from "./components/SearchstaxResultWidget";
|
|
5
|
-
import SearchstaxWrapper from "./components/SearchstaxWrapper";
|
|
6
|
-
import type {
|
|
7
|
-
ISearchstaxSuggestResponse,
|
|
8
|
-
ISearchstaxSearchProps,
|
|
9
|
-
ISearchstaxParsedResult,
|
|
10
|
-
ISearchstaxSuggestProps,
|
|
11
|
-
//@ts-expect-error
|
|
12
|
-
} from "@searchstax-inc/searchstudio-ux-js";
|
|
13
|
-
//@ts-expect-error
|
|
14
|
-
import { Searchstax } from "@searchstax-inc/searchstudio-ux-js";
|
|
15
|
-
|
|
16
|
-
function App() {
|
|
17
|
-
//@ts-expect-error
|
|
18
|
-
const [searchstaxInstance, setSearchstaxInstance] = useState(
|
|
19
|
-
null as null | Searchstax
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
function beforeSearch(props: ISearchstaxSearchProps) {
|
|
23
|
-
// gets searchProps, if passed along further search will execute, if null then event gets canceled
|
|
24
|
-
// props can be modified and passed along
|
|
25
|
-
const propsCopy = { ...props };
|
|
26
|
-
// propsCopy.term = propsCopy.term;
|
|
27
|
-
return propsCopy;
|
|
28
|
-
}
|
|
29
|
-
function afterSearch(results: ISearchstaxParsedResult[]) {
|
|
30
|
-
const copy = [...results];
|
|
31
|
-
// copy.splice(0, 1);
|
|
32
|
-
return copy;
|
|
33
|
-
}
|
|
34
|
-
function afterAutosuggest(result: ISearchstaxSuggestResponse) {
|
|
35
|
-
const copy = { ...result };
|
|
36
|
-
return copy;
|
|
37
|
-
}
|
|
38
|
-
function beforeAutosuggest(props: ISearchstaxSuggestProps) {
|
|
39
|
-
// gets suggestProps, if passed along further autosuggest will execute, if null then event gets canceled
|
|
40
|
-
// props can be modified and passed along
|
|
41
|
-
const propsCopy = { ...props };
|
|
42
|
-
// propsCopy.term = propsCopy.term + '222';
|
|
43
|
-
return propsCopy;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function afterLinkClick(result: ISearchstaxParsedResult) {
|
|
47
|
-
// gets result that was clicked, if passed along further functions will execute, if null then event gets canceled
|
|
48
|
-
const propsCopy = { ...result };
|
|
49
|
-
|
|
50
|
-
return propsCopy;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function initialized(searchstax: Searchstax) {
|
|
54
|
-
setSearchstaxInstance(searchstax);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function InputTemplate(): React.ReactElement {
|
|
58
|
-
return (
|
|
59
|
-
<div className="searchstax-search-input-wrapper">
|
|
60
|
-
<input
|
|
61
|
-
type="text"
|
|
62
|
-
id="searchstax-search-input"
|
|
63
|
-
className="searchstax-search-input"
|
|
64
|
-
placeholder="SEARCH FOR222..."
|
|
65
|
-
/>
|
|
66
|
-
<button
|
|
67
|
-
className="searchstax-spinner-icon"
|
|
68
|
-
id="searchstax-search-input-action-button"
|
|
69
|
-
></button>
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function noResultTemplate(
|
|
75
|
-
searchTerm: string,
|
|
76
|
-
searchSuggestion: string
|
|
77
|
-
): React.ReactElement {
|
|
78
|
-
return (
|
|
79
|
-
<div>
|
|
80
|
-
<div className="searchstax-no-results">
|
|
81
|
-
Showing <strong>no results</strong> forRRRRR
|
|
82
|
-
<strong>"{searchTerm}"</strong>
|
|
83
|
-
<br />
|
|
84
|
-
{searchSuggestion && (
|
|
85
|
-
<span>
|
|
86
|
-
Did you mean
|
|
87
|
-
<a href="#" className="searchstax-suggestion-term">
|
|
88
|
-
{searchSuggestion}
|
|
89
|
-
</a>
|
|
90
|
-
?
|
|
91
|
-
</span>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
<div>
|
|
95
|
-
<p>
|
|
96
|
-
Try searching for search related terms or topics. We offer a wide
|
|
97
|
-
variety of content to help you get the information you need.
|
|
98
|
-
</p>
|
|
99
|
-
<p>Lost? Click on the ‘X” in the Search Box to reset your search.</p>
|
|
100
|
-
</div>
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function resultsTemplate(
|
|
106
|
-
searchResults: ISearchstaxParsedResult[],
|
|
107
|
-
linkClick: (
|
|
108
|
-
results: ISearchstaxParsedResult[],
|
|
109
|
-
event: any
|
|
110
|
-
) => ISearchstaxParsedResult[]
|
|
111
|
-
): React.ReactElement {
|
|
112
|
-
return (
|
|
113
|
-
<div className="searchstax-search-results">
|
|
114
|
-
{searchResults !== null &&
|
|
115
|
-
searchResults.map(function (searchResult) {
|
|
116
|
-
return (
|
|
117
|
-
<div
|
|
118
|
-
className="searchstax-search-result"
|
|
119
|
-
key={searchResult.uniqueId}
|
|
120
|
-
>
|
|
121
|
-
{searchResult.url && (
|
|
122
|
-
<a
|
|
123
|
-
href={searchResult.url}
|
|
124
|
-
data-searchstax-unique-result-id={searchResult.uniqueId}
|
|
125
|
-
onClick={(event) => {
|
|
126
|
-
linkClick(searchResult, event);
|
|
127
|
-
}}
|
|
128
|
-
className="searchstax-result-item-link"
|
|
129
|
-
></a>
|
|
130
|
-
)}
|
|
131
|
-
|
|
132
|
-
{searchResult.ribbon && (
|
|
133
|
-
<div className="searchstax-search-result-ribbon">
|
|
134
|
-
{searchResult.ribbon}
|
|
135
|
-
</div>
|
|
136
|
-
)}
|
|
137
|
-
|
|
138
|
-
{searchResult.thumbnail && (
|
|
139
|
-
<img
|
|
140
|
-
src={searchResult.thumbnail}
|
|
141
|
-
className="searchstax-thumbnail"
|
|
142
|
-
/>
|
|
143
|
-
)}
|
|
144
|
-
|
|
145
|
-
<div className="searchstax-search-result-title-container">
|
|
146
|
-
<span className="searchstax-search-result-title">
|
|
147
|
-
{searchResult.title}
|
|
148
|
-
</span>
|
|
149
|
-
</div>
|
|
150
|
-
|
|
151
|
-
{searchResult.paths && (
|
|
152
|
-
<p className="searchstax-search-result-common">
|
|
153
|
-
{searchResult.paths}
|
|
154
|
-
</p>
|
|
155
|
-
)}
|
|
156
|
-
|
|
157
|
-
{searchResult.description && (
|
|
158
|
-
<p className="searchstax-search-result-description searchstax-search-result-common">
|
|
159
|
-
{searchResult.description}
|
|
160
|
-
</p>
|
|
161
|
-
)}
|
|
162
|
-
|
|
163
|
-
{searchResult.unmappedFields.map(function (unmappedField: any) {
|
|
164
|
-
return (
|
|
165
|
-
<div key={unmappedField.value}>
|
|
166
|
-
{unmappedField.isImage && (
|
|
167
|
-
<div className="searchstax-search-result-image-container">
|
|
168
|
-
<img
|
|
169
|
-
src={unmappedField.value}
|
|
170
|
-
className="searchstax-result-image"
|
|
171
|
-
/>
|
|
172
|
-
</div>
|
|
173
|
-
)}
|
|
174
|
-
|
|
175
|
-
{!unmappedField.isImage && (
|
|
176
|
-
<div>
|
|
177
|
-
<p className="searchstax-search-result-common">
|
|
178
|
-
{unmappedField.value}
|
|
179
|
-
</p>
|
|
180
|
-
</div>
|
|
181
|
-
)}
|
|
182
|
-
</div>
|
|
183
|
-
);
|
|
184
|
-
})}
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
})}
|
|
188
|
-
|
|
189
|
-
{searchResults !== null && searchResults.length && (
|
|
190
|
-
<div v-if="searchResults && searchResults.length && hasResultSlot">
|
|
191
|
-
{/* <slot name="results" ></slot> */}
|
|
192
|
-
</div>
|
|
193
|
-
)}
|
|
194
|
-
</div>
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const config = {
|
|
199
|
-
searchURL: 'https://ss325316-pz27ybgj-us-east-1-aws.searchstax.co/solr/corpsiteproductionclone-1512/emselect',
|
|
200
|
-
suggesterURL: 'https://ss325316-pz27ybgj-us-east-1-aws.searchstax.co/solr/corpsiteproductionclone-1512-suggester/emsuggest',
|
|
201
|
-
trackApiKey: 'K48zwO871m7aYwowBkweALTWVQRZTMBpVNq0Qg2Mamo',
|
|
202
|
-
searchAuth: 'YXBwMTUxMi1hcGk6U3R1ZGlvITIz',
|
|
203
|
-
authType: 'basic',
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<>
|
|
208
|
-
<SearchstaxWrapper
|
|
209
|
-
searchURL={config.searchURL}
|
|
210
|
-
suggesterURL={config.suggesterURL}
|
|
211
|
-
trackApiKey={config.trackApiKey}
|
|
212
|
-
searchAuth={config.searchAuth}
|
|
213
|
-
initialized={initialized}
|
|
214
|
-
authType="basic"
|
|
215
|
-
language="en"
|
|
216
|
-
>
|
|
217
|
-
<SearchstaxInputWidget
|
|
218
|
-
beforeSearch={beforeSearch}
|
|
219
|
-
afterSearch={afterSearch}
|
|
220
|
-
afterAutosuggest={afterAutosuggest}
|
|
221
|
-
beforeAutosuggest={beforeAutosuggest}
|
|
222
|
-
inputTemplate={InputTemplate}
|
|
223
|
-
></SearchstaxInputWidget>
|
|
224
|
-
<SearchstaxResultWidget
|
|
225
|
-
afterLinkClick={afterLinkClick}
|
|
226
|
-
noResultTemplate={noResultTemplate}
|
|
227
|
-
resultsTemplate={resultsTemplate}
|
|
228
|
-
></SearchstaxResultWidget>
|
|
229
|
-
</SearchstaxWrapper>
|
|
230
|
-
</>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export default App;
|
package/src/assets/react.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
//@ts-expect-error
|
|
3
|
-
import { store } from "./../stores/searchstaxStore.js";
|
|
4
|
-
import type {
|
|
5
|
-
ISearchstaxSearchProps,
|
|
6
|
-
ISearchstaxSuggestProps,
|
|
7
|
-
ISearchstaxParsedResult,
|
|
8
|
-
ISearchstaxSuggestResponse,
|
|
9
|
-
//@ts-expect-error
|
|
10
|
-
} from "@searchstax-inc/searchstudio-ux-js";
|
|
11
|
-
|
|
12
|
-
function SearchstaxInputWidget(props: {
|
|
13
|
-
beforeSearch: (
|
|
14
|
-
props: ISearchstaxSearchProps
|
|
15
|
-
) => ISearchstaxSearchProps | null;
|
|
16
|
-
afterSearch: (
|
|
17
|
-
results: ISearchstaxParsedResult[]
|
|
18
|
-
) => ISearchstaxParsedResult[];
|
|
19
|
-
afterAutosuggest: (
|
|
20
|
-
result: ISearchstaxSuggestResponse
|
|
21
|
-
) => ISearchstaxSuggestResponse;
|
|
22
|
-
beforeAutosuggest: (
|
|
23
|
-
props: ISearchstaxSuggestProps
|
|
24
|
-
) => ISearchstaxSuggestProps | null;
|
|
25
|
-
searchInputId?: string;
|
|
26
|
-
suggestAfterMinChars?: number;
|
|
27
|
-
inputTemplate?: ()=> React.ReactElement;
|
|
28
|
-
}) {
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (store.searchstax) {
|
|
32
|
-
const hooks: { [key: string]: (prop: any) => any } = {};
|
|
33
|
-
if (props.beforeSearch) {
|
|
34
|
-
hooks.beforeSearch = props.beforeSearch;
|
|
35
|
-
}
|
|
36
|
-
if (props.afterSearch) {
|
|
37
|
-
hooks.afterSearch = props.afterSearch;
|
|
38
|
-
}
|
|
39
|
-
if (props.afterAutosuggest) {
|
|
40
|
-
hooks.afterAutosuggest = props.afterAutosuggest;
|
|
41
|
-
}
|
|
42
|
-
if (props.beforeAutosuggest) {
|
|
43
|
-
hooks.beforeAutosuggest = props.beforeAutosuggest;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
store.searchstax.addSearchInputWidget("searchstax-input-container", {
|
|
47
|
-
suggestAfterMinChars: props.suggestAfterMinChars ?? 3,
|
|
48
|
-
hooks: hooks,
|
|
49
|
-
templates: {
|
|
50
|
-
searchInputId: props.searchInputId ?? "searchstax-search-input",
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
} else {
|
|
54
|
-
throw Error("Searchstax instance needs to be passed via props");
|
|
55
|
-
}
|
|
56
|
-
}, []);
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<>
|
|
60
|
-
<div id="searchstax-input-container">
|
|
61
|
-
<div className="searchstax-search-input-container">
|
|
62
|
-
{!props.inputTemplate && (
|
|
63
|
-
<div className="searchstax-search-input-wrapper">
|
|
64
|
-
<input
|
|
65
|
-
type="text"
|
|
66
|
-
id="searchstax-search-input"
|
|
67
|
-
className="searchstax-search-input"
|
|
68
|
-
placeholder="SEARCH FOR..."
|
|
69
|
-
/>
|
|
70
|
-
<button
|
|
71
|
-
className="searchstax-spinner-icon"
|
|
72
|
-
id="searchstax-search-input-action-button"
|
|
73
|
-
></button>
|
|
74
|
-
</div>
|
|
75
|
-
)}
|
|
76
|
-
{props.inputTemplate && <>{props.inputTemplate()}</>}
|
|
77
|
-
</div>
|
|
78
|
-
</div>
|
|
79
|
-
</>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default SearchstaxInputWidget;
|