@tryghost/sodo-search 1.8.29 → 1.8.30
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/package.json
CHANGED
package/umd/sodo-search.min.js
CHANGED
|
@@ -26,4 +26,3 @@ Add a <Suspense fallback=...> component higher in the tree to provide a loading
|
|
|
26
26
|
`)+" "+W[1]:W[0]+T+" "+S.join(", ")+" "+W[1]}function z(S){return Array.isArray(S)}r.isArray=z;function _(S){return typeof S=="boolean"}r.isBoolean=_;function R(S){return S===null}r.isNull=R;function q(S){return S==null}r.isNullOrUndefined=q;function Q(S){return typeof S=="number"}r.isNumber=Q;function ue(S){return typeof S=="string"}r.isString=ue;function pe(S){return typeof S=="symbol"}r.isSymbol=pe;function ce(S){return S===void 0}r.isUndefined=ce;function ae(S){return ne(S)&&K(S)==="[object RegExp]"}r.isRegExp=ae;function ne(S){return typeof S=="object"&&S!==null}r.isObject=ne;function re(S){return ne(S)&&K(S)==="[object Date]"}r.isDate=re;function fe(S){return ne(S)&&(K(S)==="[object Error]"||S instanceof Error)}r.isError=fe;function F(S){return typeof S=="function"}r.isFunction=F;function M(S){return S===null||typeof S=="boolean"||typeof S=="number"||typeof S=="string"||typeof S=="symbol"||typeof S>"u"}r.isPrimitive=M,r.isBuffer=bg();function K(S){return Object.prototype.toString.call(S)}function se(S){return S<10?"0"+S.toString(10):S.toString(10)}var he=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Se(){var S=new Date,T=[se(S.getHours()),se(S.getMinutes()),se(S.getSeconds())].join(":");return[S.getDate(),he[S.getMonth()],T].join(" ")}r.log=function(){console.log("%s - %s",Se(),r.format.apply(r,arguments))},r.inherits=Ig(),r._extend=function(S,T){if(!T||!ne(T))return S;for(var W=Object.keys(T),ge=W.length;ge--;)S[W[ge]]=T[W[ge]];return S};function Oe(S,T){return Object.prototype.hasOwnProperty.call(S,T)}})(Yi)),Yi}var mc;function zg(){if(mc)return ai.exports;mc=1;var r=Fg()();function s(F,M){if(F===M)return 0;for(var K=F.length,se=M.length,he=0,Se=Math.min(K,se);he<Se;++he)if(F[he]!==M[he]){K=F[he],se=M[he];break}return K<se?-1:se<K?1:0}function i(F){return Er.Buffer&&typeof Er.Buffer.isBuffer=="function"?Er.Buffer.isBuffer(F):!!(F!=null&&F._isBuffer)}var l=Mg(),a=Object.prototype.hasOwnProperty,h=Array.prototype.slice,p=(function(){return(function(){}).name==="foo"})();function v(F){return Object.prototype.toString.call(F)}function g(F){return i(F)||typeof Er.ArrayBuffer!="function"?!1:typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(F):F?!!(F instanceof DataView||F.buffer&&F.buffer instanceof ArrayBuffer):!1}var w=ai.exports=R,k=/\s*function\s+([^\(\s]*)\s*/;function $(F){if(l.isFunction(F)){if(p)return F.name;var M=F.toString(),K=M.match(k);return K&&K[1]}}w.AssertionError=function(M){this.name="AssertionError",this.actual=M.actual,this.expected=M.expected,this.operator=M.operator,M.message?(this.message=M.message,this.generatedMessage=!1):(this.message=z(this),this.generatedMessage=!0);var K=M.stackStartFunction||_;if(Error.captureStackTrace)Error.captureStackTrace(this,K);else{var se=new Error;if(se.stack){var he=se.stack,Se=$(K),Oe=he.indexOf(`
|
|
27
27
|
`+Se);if(Oe>=0){var S=he.indexOf(`
|
|
28
28
|
`,Oe+1);he=he.substring(S+1)}this.stack=he}}},l.inherits(w.AssertionError,Error);function j(F,M){return typeof F=="string"?F.length<M?F:F.slice(0,M):F}function A(F){if(p||!l.isFunction(F))return l.inspect(F);var M=$(F),K=M?": "+M:"";return"[Function"+K+"]"}function z(F){return j(A(F.actual),128)+" "+F.operator+" "+j(A(F.expected),128)}function _(F,M,K,se,he){throw new w.AssertionError({message:K,actual:F,expected:M,operator:se,stackStartFunction:he})}w.fail=_;function R(F,M){F||_(F,!0,M,"==",w.ok)}w.ok=R,w.equal=function(M,K,se){M!=K&&_(M,K,se,"==",w.equal)},w.notEqual=function(M,K,se){M==K&&_(M,K,se,"!=",w.notEqual)},w.deepEqual=function(M,K,se){q(M,K,!1)||_(M,K,se,"deepEqual",w.deepEqual)},w.deepStrictEqual=function(M,K,se){q(M,K,!0)||_(M,K,se,"deepStrictEqual",w.deepStrictEqual)};function q(F,M,K,se){if(F===M)return!0;if(i(F)&&i(M))return s(F,M)===0;if(l.isDate(F)&&l.isDate(M))return F.getTime()===M.getTime();if(l.isRegExp(F)&&l.isRegExp(M))return F.source===M.source&&F.global===M.global&&F.multiline===M.multiline&&F.lastIndex===M.lastIndex&&F.ignoreCase===M.ignoreCase;if((F===null||typeof F!="object")&&(M===null||typeof M!="object"))return K?F===M:F==M;if(g(F)&&g(M)&&v(F)===v(M)&&!(F instanceof Float32Array||F instanceof Float64Array))return s(new Uint8Array(F.buffer),new Uint8Array(M.buffer))===0;if(i(F)!==i(M))return!1;se=se||{actual:[],expected:[]};var he=se.actual.indexOf(F);return he!==-1&&he===se.expected.indexOf(M)?!0:(se.actual.push(F),se.expected.push(M),ue(F,M,K,se))}function Q(F){return Object.prototype.toString.call(F)=="[object Arguments]"}function ue(F,M,K,se){if(F==null||M===null||M===void 0)return!1;if(l.isPrimitive(F)||l.isPrimitive(M))return F===M;if(K&&Object.getPrototypeOf(F)!==Object.getPrototypeOf(M))return!1;var he=Q(F),Se=Q(M);if(he&&!Se||!he&&Se)return!1;if(he)return F=h.call(F),M=h.call(M),q(F,M,K);var Oe=fe(F),S=fe(M),T,W;if(Oe.length!==S.length)return!1;for(Oe.sort(),S.sort(),W=Oe.length-1;W>=0;W--)if(Oe[W]!==S[W])return!1;for(W=Oe.length-1;W>=0;W--)if(T=Oe[W],!q(F[T],M[T],K,se))return!1;return!0}w.notDeepEqual=function(M,K,se){q(M,K,!1)&&_(M,K,se,"notDeepEqual",w.notDeepEqual)},w.notDeepStrictEqual=pe;function pe(F,M,K){q(F,M,!0)&&_(F,M,K,"notDeepStrictEqual",pe)}w.strictEqual=function(M,K,se){M!==K&&_(M,K,se,"===",w.strictEqual)},w.notStrictEqual=function(M,K,se){M===K&&_(M,K,se,"!==",w.notStrictEqual)};function ce(F,M){if(!F||!M)return!1;if(Object.prototype.toString.call(M)=="[object RegExp]")return M.test(F);try{if(F instanceof M)return!0}catch{}return Error.isPrototypeOf(M)?!1:M.call({},F)===!0}function ae(F){var M;try{F()}catch(K){M=K}return M}function ne(F,M,K,se){var he;if(typeof M!="function")throw new TypeError('"block" argument must be a function');typeof K=="string"&&(se=K,K=null),he=ae(M),se=(K&&K.name?" ("+K.name+").":".")+(se?" "+se:"."),F&&!he&&_(he,K,"Missing expected exception"+se);var Se=typeof se=="string",Oe=!F&&l.isError(he),S=!F&&he&&!K;if((Oe&&Se&&ce(he,K)||S)&&_(he,K,"Got unwanted exception"+se),F&&he&&K&&!ce(he,K)||!F&&he)throw he}w.throws=function(F,M,K){ne(!0,F,M,K)},w.doesNotThrow=function(F,M,K){ne(!1,F,M,K)},w.ifError=function(F){if(F)throw F};function re(F,M){F||_(F,!0,M,"==",re)}w.strict=r(re,w,{equal:w.strictEqual,deepEqual:w.deepStrictEqual,notEqual:w.notStrictEqual,notDeepEqual:w.notDeepStrictEqual}),w.strict.strict=w.strict;var fe=Object.keys||function(F){var M=[];for(var K in F)a.call(F,K)&&M.push(K);return M};return ai.exports}var Zi,yc;function Dg(){if(yc)return Zi;yc=1;var r=zg();return Zi=function(s){var i,l,a,h,p;for(i=Error.prepareStackTrace,Error.prepareStackTrace=function(v,g){return Error.prepareStackTrace=i,g},l=new Error().stack,p=0;p<l.length&&l[p].getFileName()!==__filename;)p++;r(p<l.length,"Unexpected: unable to find caller/index.js in the stack"),s=!s||isNaN(s)?1:s>l.length-2?l.length-2:s,l=l.slice(p+s+1);do h=l.shift(),a=h&&h.getFileName();while(l.length&&a==="module.js");return a},Zi}var vc;function Ug(){if(vc)return _s;vc=1;const r=er,s=er,i=og(),l=Dg();return _s.getCallerRoot=function(){try{return i(l(2))}catch{return}},_s.getProcessRoot=function(){let h=process.cwd();const p=s.join(h,"current");try{r.statSync(p).isDirectory()&&(h=p)}catch{}try{return i(h)}catch{return}},_s}var el,wc;function Bg(){return wc||(wc=1,el=Ug()),el}var bs={exports:{}},tl,Sc;function Vg(){if(Sc)return tl;Sc=1;var r=1e3,s=r*60,i=s*60,l=i*24,a=l*7,h=l*365.25;tl=function(k,$){$=$||{};var j=typeof k;if(j==="string"&&k.length>0)return p(k);if(j==="number"&&isFinite(k))return $.long?g(k):v(k);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(k))};function p(k){if(k=String(k),!(k.length>100)){var $=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(k);if($){var j=parseFloat($[1]),A=($[2]||"ms").toLowerCase();switch(A){case"years":case"year":case"yrs":case"yr":case"y":return j*h;case"weeks":case"week":case"w":return j*a;case"days":case"day":case"d":return j*l;case"hours":case"hour":case"hrs":case"hr":case"h":return j*i;case"minutes":case"minute":case"mins":case"min":case"m":return j*s;case"seconds":case"second":case"secs":case"sec":case"s":return j*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return j;default:return}}}}function v(k){var $=Math.abs(k);return $>=l?Math.round(k/l)+"d":$>=i?Math.round(k/i)+"h":$>=s?Math.round(k/s)+"m":$>=r?Math.round(k/r)+"s":k+"ms"}function g(k){var $=Math.abs(k);return $>=l?w(k,$,l,"day"):$>=i?w(k,$,i,"hour"):$>=s?w(k,$,s,"minute"):$>=r?w(k,$,r,"second"):k+" ms"}function w(k,$,j,A){var z=$>=j*1.5;return Math.round(k/j)+" "+A+(z?"s":"")}return tl}var nl,xc;function Hg(){if(xc)return nl;xc=1;function r(s){l.debug=l,l.default=l,l.coerce=w,l.disable=v,l.enable=h,l.enabled=g,l.humanize=Vg(),l.destroy=k,Object.keys(s).forEach($=>{l[$]=s[$]}),l.names=[],l.skips=[],l.formatters={};function i($){let j=0;for(let A=0;A<$.length;A++)j=(j<<5)-j+$.charCodeAt(A),j|=0;return l.colors[Math.abs(j)%l.colors.length]}l.selectColor=i;function l($){let j,A=null,z,_;function R(...q){if(!R.enabled)return;const Q=R,ue=Number(new Date),pe=ue-(j||ue);Q.diff=pe,Q.prev=j,Q.curr=ue,j=ue,q[0]=l.coerce(q[0]),typeof q[0]!="string"&&q.unshift("%O");let ce=0;q[0]=q[0].replace(/%([a-zA-Z%])/g,(ne,re)=>{if(ne==="%%")return"%";ce++;const fe=l.formatters[re];if(typeof fe=="function"){const F=q[ce];ne=fe.call(Q,F),q.splice(ce,1),ce--}return ne}),l.formatArgs.call(Q,q),(Q.log||l.log).apply(Q,q)}return R.namespace=$,R.useColors=l.useColors(),R.color=l.selectColor($),R.extend=a,R.destroy=l.destroy,Object.defineProperty(R,"enabled",{enumerable:!0,configurable:!1,get:()=>A!==null?A:(z!==l.namespaces&&(z=l.namespaces,_=l.enabled($)),_),set:q=>{A=q}}),typeof l.init=="function"&&l.init(R),R}function a($,j){const A=l(this.namespace+(typeof j>"u"?":":j)+$);return A.log=this.log,A}function h($){l.save($),l.namespaces=$,l.names=[],l.skips=[];const j=(typeof $=="string"?$:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const A of j)A[0]==="-"?l.skips.push(A.slice(1)):l.names.push(A)}function p($,j){let A=0,z=0,_=-1,R=0;for(;A<$.length;)if(z<j.length&&(j[z]===$[A]||j[z]==="*"))j[z]==="*"?(_=z,R=A,z++):(A++,z++);else if(_!==-1)z=_+1,R++,A=R;else return!1;for(;z<j.length&&j[z]==="*";)z++;return z===j.length}function v(){const $=[...l.names,...l.skips.map(j=>"-"+j)].join(",");return l.enable(""),$}function g($){for(const j of l.skips)if(p($,j))return!1;for(const j of l.names)if(p($,j))return!0;return!1}function w($){return $ instanceof Error?$.stack||$.message:$}function k(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return l.enable(l.load()),l}return nl=r,nl}var Cc;function qg(){return Cc||(Cc=1,(function(r,s){s.formatArgs=l,s.save=a,s.load=h,s.useColors=i,s.storage=p(),s.destroy=(()=>{let g=!1;return()=>{g||(g=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),s.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function i(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let g;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(g=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(g[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function l(g){if(g[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+g[0]+(this.useColors?"%c ":" ")+"+"+r.exports.humanize(this.diff),!this.useColors)return;const w="color: "+this.color;g.splice(1,0,w,"color: inherit");let k=0,$=0;g[0].replace(/%[a-zA-Z%]/g,j=>{j!=="%%"&&(k++,j==="%c"&&($=k))}),g.splice($,0,w)}s.log=console.debug||console.log||(()=>{});function a(g){try{g?s.storage.setItem("debug",g):s.storage.removeItem("debug")}catch{}}function h(){let g;try{g=s.storage.getItem("debug")||s.storage.getItem("DEBUG")}catch{}return!g&&typeof process<"u"&&"env"in process&&(g=process.env.DEBUG),g}function p(){try{return localStorage}catch{}}r.exports=Hg()(s);const{formatters:v}=r.exports;v.j=function(g){try{return JSON.stringify(g)}catch(w){return"[UnexpectedJSONParseError]: "+w.message}}})(bs,bs.exports)),bs.exports}var kc;function Wg(){if(kc)return Rs.exports;kc=1;const r=Bg(),s=qg();return Rs.exports=function(l){const a=r.getCallerRoot();let h;try{const p=Nn("/node_modules/.pnpm/@tryghost+debug@2.2.3/node_modules/@tryghost/debug/lib")(a+"/package.json");p.alias?h=p.alias:h=p.name}catch{h="undefined"}return s(h+":"+l)},Rs.exports._base=s,Rs.exports}var rl,Pc;function Kg(){return Pc||(Pc=1,rl=Wg()),rl}const Gg=[{code:"af",label:"Afrikaans"},{code:"ar",label:"Arabic"},{code:"bg",label:"Bulgarian"},{code:"bn",label:"Bengali"},{code:"bs",label:"Bosnian"},{code:"ca",label:"Catalan"},{code:"cs",label:"Czech"},{code:"da",label:"Danish"},{code:"de",label:"German"},{code:"de-CH",label:"Swiss German"},{code:"el",label:"Greek"},{code:"en",label:"English"},{code:"eo",label:"Esperanto"},{code:"es",label:"Spanish"},{code:"et",label:"Estonian"},{code:"eu",label:"Basque"},{code:"fa",label:"Persian/Farsi"},{code:"fi",label:"Finnish"},{code:"fr",label:"French"},{code:"gd",label:"Gaelic (Scottish)"},{code:"he",label:"Hebrew"},{code:"hi",label:"Hindi"},{code:"hr",label:"Croatian"},{code:"hu",label:"Hungarian"},{code:"id",label:"Indonesian"},{code:"is",label:"Icelandic"},{code:"it",label:"Italian"},{code:"ja",label:"Japanese"},{code:"ko",label:"Korean"},{code:"kz",label:"Kazakh"},{code:"lt",label:"Lithuanian"},{code:"lv",label:"Latvian"},{code:"mk",label:"Macedonian"},{code:"mn",label:"Mongolian"},{code:"ms",label:"Malay"},{code:"nb",label:"Norwegian Bokmål"},{code:"ne",label:"Nepali"},{code:"nl",label:"Dutch"},{code:"nn",label:"Norwegian Nynorsk"},{code:"pa",label:"Punjabi"},{code:"pl",label:"Polish"},{code:"pt",label:"Portuguese"},{code:"pt-BR",label:"Portuguese (Brazil)"},{code:"ro",label:"Romanian"},{code:"ru",label:"Russian"},{code:"si",label:"Sinhala"},{code:"sk",label:"Slovak"},{code:"sl",label:"Slovenian"},{code:"sq",label:"Albanian"},{code:"sr",label:"Serbian"},{code:"sr-Cyrl",label:"Serbian (Cyrillic)"},{code:"sv",label:"Swedish"},{code:"sw",label:"Swahili"},{code:"ta",label:"Tamil"},{code:"th",label:"Thai"},{code:"tr",label:"Turkish"},{code:"uk",label:"Ukrainian"},{code:"ur",label:"Urdu"},{code:"uz",label:"Uzbek"},{code:"vi",label:"Vietnamese"},{code:"zh",label:"Chinese"},{code:"zh-Hant",label:"Traditional Chinese"}];var $c;function Qg(){if($c)return Zn.exports;$c=1;const r=sg(),s=er,i=er,l=Kg()("i18n"),a=Gg,h=a.map(g=>g.code);function p(g,w){return g.reduce((k,$)=>{let j;try{j=Nn("/ghost/i18n/lib")(`../locales/${$}/${w}.json`)}catch{j=Nn("/ghost/i18n/lib")(`../locales/en/${w}.json`)}return k[$]={[w]:{...j,...j.default&&typeof j.default=="object"?j.default:{}}},k},{})}function v(g,w){if(!w)return{[g]:{theme:{}}};let k=[];try{k=i.readdirSync(w).filter(A=>A.endsWith(".json")).map(A=>A.replace(".json",""))}catch{k=[g,"en"]}return[...new Set([g,...k,"en"])].reduce((j,A)=>{let z,_=!1;const R=s.join(w,`${A}.json`);if(i.existsSync(R))try{delete require.cache[Nn("/ghost/i18n/lib").resolve(R)],z=Nn("/ghost/i18n/lib")(R)}catch{l(`Error loading theme locale file: ${A}`),_=!0}else _=!0;if(_)if(A!=="en")try{const q=s.join(w,"en.json");i.existsSync(q)?(delete require.cache[Nn("/ghost/i18n/lib").resolve(q)],z=Nn("/ghost/i18n/lib")(q)):z={}}catch{z={}}else l("Theme en.json file not found"),z={};return j[A]={theme:{...z,...z.default&&typeof z.default=="object"?z.default:{}}},j},{})}return Zn.exports=(g="en",w="portal",k={})=>{const $=r.createInstance(),j={prefix:"{",suffix:"}"};(w==="theme"||w==="portal")&&(j.escapeValue=!1);let A;return w!=="theme"?A=p(h,w):(l(`generateThemeResources: ${g}, ${k.themePath}`),A=v(g,k.themePath)),$.init({lng:g,nsSeparator:!1,keySeparator:!1,returnEmptyString:!1,fallbackLng:{no:["nb","en"],default:["en"]},ns:w,defaultNS:w,interpolation:j,resources:A}),$},Zn.exports.SUPPORTED_LOCALES=h,Zn.exports.LOCALE_DATA=a,Zn.exports.generateResources=p,Zn.exports}var Ec;function Jg(){if(Ec)return Tn.exports;Ec=1;const r=Qg();return Tn.exports=r,Tn.exports.default=r,Tn.exports.LOCALE_DATA=r.LOCALE_DATA,Tn.exports.SUPPORTED_LOCALES=r.SUPPORTED_LOCALES,Tn.exports.generateResources=r.generateResources,Tn.exports}var Yg=Jg();const Xg=Fo(Yg);class Zg extends en.Component{constructor(s){super(s);const i=this.props.locale||"en",l=Xg(i,"search"),a=l.dir()||"ltr",h=new Gd({adminUrl:s.adminUrl,apiKey:s.apiKey,dir:a});this.state={searchIndex:h,showPopup:!1,indexStarted:!1,indexComplete:!1,t:l.t,dir:a,scrollbarWidth:0},this.inputRef=en.createRef()}componentDidMount(){const s=this.getScrollbarWidth();this.setState({scrollbarWidth:s}),this.initSetup()}componentDidUpdate(s,i){if(i.showPopup!==this.state.showPopup)try{this.state.showPopup?(this.bodyScroll=window.document?.body?.style?.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&document.body.scrollHeight>window.innerHeight&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin)}catch{}this.state.showPopup!==i?.showPopup&&!this.state.showPopup&&this.setState({searchValue:""}),this.state.showPopup&&!this.state.indexStarted&&this.setupSearchIndex()}async setupSearchIndex(){this.setState({indexStarted:!0}),await this.state.searchIndex.init(),this.setState({indexComplete:!0})}componentWillUnmount(){window.removeEventListener("hashchange",this.hashHandler,!1),window.removeEventListener("keydown",this.handleKeyDown,!1)}initSetup(){this.handleSearchUrl(),this.addKeyboardShortcuts(),this.setupCustomTriggerButton(),this.hashHandler=()=>{this.handleSearchUrl()},window.addEventListener("hashchange",this.hashHandler,!1)}getScrollbarWidth(){const s=document.createElement("div");s.style.visibility="hidden",s.style.overflow="scroll",document.body.appendChild(s);const i=s.offsetWidth-s.clientWidth;return document.body.removeChild(s),i}setupCustomTriggerButton(){this.clickHandler=s=>{s.preventDefault(),this.setState({showPopup:!0});const i=document.createElement("input");i.style.opacity="0",i.style.position="fixed",i.style.top="0",document.body.appendChild(i),i.focus(),setTimeout(()=>{this.inputRef.current.focus(),document.body.removeChild(i)},150)},this.customTriggerButtons=this.getCustomTriggerButtons(),this.customTriggerButtons.forEach(s=>{s.removeEventListener("click",this.clickHandler),s.addEventListener("click",this.clickHandler)})}getCustomTriggerButtons(){return document.querySelectorAll("[data-ghost-search]")||[]}handleSearchUrl(){const[s]=window.location.hash.substr(1).split("?");(s==="/search"||s==="/search/")&&(this.setState({showPopup:!0}),window.history.replaceState("",document.title,window.location.pathname))}addKeyboardShortcuts(){this.getCustomTriggerButtons()?.length&&(this.handleKeyDown=i=>{if(i.key==="k"&&i.metaKey)return this.setState({showPopup:!0}),i.preventDefault(),i.stopPropagation(),!1},document.addEventListener("keydown",this.handleKeyDown))}render(){return le.jsx(ut.Provider,{value:{page:"search",showPopup:this.state.showPopup,adminUrl:this.props.adminUrl,stylesUrl:this.props.stylesUrl,searchIndex:this.state.searchIndex,indexComplete:this.state.indexComplete,searchValue:this.state.searchValue,inputRef:this.inputRef,onAction:()=>{},dispatch:(s,i)=>{s==="update"&&this.setState({...this.state,...i})},t:this.state.t,dir:this.state.dir},children:le.jsx(Ed,{})})}}const jc="sodo-search-root";function em(){const r=document.createElement("div");r.id=jc,document.body.appendChild(r)}function tm(){const r=document.querySelector("script[data-sodo-search]");if(r){const s=r.dataset.sodoSearch,i=r.dataset.key,l=r.dataset.styles,a=r.dataset.locale||"en";return{adminUrl:s,apiKey:i,stylesUrl:l,locale:a}}return{}}function nm(){em()}function rm(){const{adminUrl:r,apiKey:s,stylesUrl:i,locale:l}=tm(),a=(r||window.location.origin)?.replace(/\/+$/,"");nm(),ed.render(le.jsx(en.StrictMode,{children:le.jsx(Zg,{adminUrl:a,apiKey:s,stylesUrl:i,locale:l})}),document.getElementById(jc))}rm()}));
|
|
29
|
-
//# sourceMappingURL=sodo-search.min.js.map
|