@nosto/search-js 3.8.0 → 3.9.0
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/dist/{AutocompletePageProvider-B5fknz_F.js → AutocompletePageProvider-BoVX16FG.js} +2 -2
- package/dist/{AutocompletePageProvider-yFydWINa.cjs → AutocompletePageProvider-kQ8RqtRT.cjs} +1 -1
- package/dist/{CategoryPageProvider-aGaznOx0.js → CategoryPageProvider-DrDTw4gs.js} +2 -2
- package/dist/{CategoryPageProvider-Cv2clyeT.cjs → CategoryPageProvider-DwqxtD8L.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-MCgxQ06X.cjs → InfiniteScrollWithObserver-BlsPDXH_.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-Dh_gZaQ6.js → InfiniteScrollWithObserver-Da3akCS0.js} +1 -1
- package/dist/{SerpPageProvider-1jG3MP2M.cjs → SerpPageProvider-NSsaKQ7f.cjs} +1 -1
- package/dist/{SerpPageProvider-UgSIPtNb.js → SerpPageProvider-qRhpKBXS.js} +2 -2
- package/dist/{baseConfig-dsYHpa9W.cjs → baseConfig-DKaOLPtn.cjs} +1 -1
- package/dist/{baseConfig-CvJ08LBP.js → baseConfig-DV2JVKBc.js} +1 -1
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +1 -1
- package/dist/preact/category/category.cjs.js +1 -1
- package/dist/preact/category/category.es.js +1 -1
- package/dist/preact/common/common.cjs.js +1 -1
- package/dist/preact/common/common.es.js +3 -3
- package/dist/preact/common/src/config/configContext.d.ts +4 -4
- package/dist/preact/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.es.js +3 -3
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +57 -57
- package/dist/preact/inject/src/helpers/dom.d.ts +1 -8
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +3 -3
- package/dist/preact/serp/serp.cjs.js +1 -1
- package/dist/preact/serp/serp.es.js +2 -2
- package/dist/{useActions-Cd7V2qfb.js → useActions-BFZx84-K.js} +29 -28
- package/dist/useActions-DSWNCNrI.cjs +1 -0
- package/dist/{useLoadMore-vgH5ApBL.js → useLoadMore-BZ5wWCPk.js} +1 -1
- package/dist/{useLoadMore-DMhtg639.cjs → useLoadMore-PtSHiAZq.cjs} +1 -1
- package/package.json +3 -3
- package/dist/useActions-yB4RkNMW.cjs +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as i, C as u } from "./useActions-
|
|
3
|
-
import { d as c, u as s, S as l } from "./baseConfig-
|
|
2
|
+
import { c as n, S as i, C as u } from "./useActions-BFZx84-K.js";
|
|
3
|
+
import { d as c, u as s, S as l } from "./baseConfig-DV2JVKBc.js";
|
|
4
4
|
const m = {
|
|
5
5
|
...c,
|
|
6
6
|
memoryCache: !1,
|
package/dist/{AutocompletePageProvider-yFydWINa.cjs → AutocompletePageProvider-kQ8RqtRT.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),o=require("./useActions-
|
|
1
|
+
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),o=require("./useActions-DSWNCNrI.cjs"),n=require("./baseConfig-DKaOLPtn.cjs"),a={...n.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function r(e={}){return{pageType:"autocomplete",...a,...e}}function l({config:e,store:u,children:i}){const c=u??o.createStore();return n.useCheckClientScript(),t.u(o.ConfigContext,{value:r(e),children:t.u(o.StoreContext,{value:c,children:[t.u(n.StoreActionsListener,{}),i]})})}exports.AutocompletePageProvider=l;exports.makeAutocompleteConfig=r;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as s, C as i } from "./useActions-
|
|
3
|
-
import { d as c, u as C, S as f } from "./baseConfig-
|
|
2
|
+
import { c as n, S as s, C as i } from "./useActions-BFZx84-K.js";
|
|
3
|
+
import { d as c, u as C, S as f } from "./baseConfig-DV2JVKBc.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...c,
|
|
6
6
|
persistentSearchCache: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-
|
|
1
|
+
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-DSWNCNrI.cjs"),o=require("./baseConfig-DKaOLPtn.cjs"),s={...o.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function n(e){return{pageType:"category",...s,...e}}function u({config:e,store:a,children:i}){const c=a??r.createStore();return o.useCheckClientScript(),t.u(r.ConfigContext,{value:n(e),children:t.u(r.StoreContext,{value:c,children:[t.u(o.StoreActionsListener,{}),i]})})}exports.CategoryPageProvider=u;exports.makeCategoryConfig=n;
|
package/dist/{InfiniteScrollWithObserver-MCgxQ06X.cjs → InfiniteScrollWithObserver-BlsPDXH_.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-
|
|
1
|
+
"use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-PtSHiAZq.cjs"),N=require("./logger-Boh_C6Bz.cjs"),x=require("./pick-rYi1lc2m.cjs"),u=require("preact"),h=require("preact/hooks");function E(e,r){const t=r.products?.total??0,o=e.products?.from??0,n=e.products?.size??0;return t>0&&t>o+n}function A(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function M(e,r){for(var t in r)e[t]=r[t];return e}function f(e,r){for(var t in e)if(t!=="__source"&&!(t in r))return!0;for(var o in r)if(o!=="__source"&&e[o]!==r[o])return!0;return!1}function m(e,r){this.props=e,this.context=r}function U(e,r){function t(n){var s=this.props.ref,i=s==n.ref;return!i&&s&&(s.call?s(null):s.current=null),r?!r(this.props,n)||!i:f(this.props,n)}function o(n){return this.shouldComponentUpdate=t,u.createElement(e,n)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o}(m.prototype=new u.Component).isPureReactComponent=!0,m.prototype.shouldComponentUpdate=function(e,r){return f(this.props,e)||f(this.state,r)};var y=u.options.__b;u.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),y&&y(e)};var q=u.options.__e;u.options.__e=function(e,r,t,o){if(e.then){for(var n,s=r;s=s.__;)if((n=s.__c)&&n.__c)return r.__e==null&&(r.__e=t.__e,r.__k=t.__k),n.__c(e,r)}q(e,r,t,o)};var b=u.options.unmount;function P(e,r,t){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=M({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return P(o,r,t)})),e}function R(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return R(o,r,t)}),e.__c&&e.__c.__P===r&&(e.__e&&t.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=t)),e}function p(){this.__u=0,this.o=null,this.__b=null}function S(e){var r=e.__.__c;return r&&r.__a&&r.__a(e)}function c(){this.i=null,this.l=null}u.options.unmount=function(e){var r=e.__c;r&&r.__R&&r.__R(),r&&32&e.__u&&(e.type=null),b&&b(e)},(p.prototype=new u.Component).__c=function(e,r){var t=r.__c,o=this;o.o==null&&(o.o=[]),o.o.push(t);var n=S(o.__v),s=!1,i=function(){s||(s=!0,t.__R=null,n?n(_):_())};t.__R=i;var _=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=R(l,l.__c.__P,l.__c.__O)}var a;for(o.setState({__a:o.__b=null});a=o.o.pop();)a.forceUpdate()}};o.__u++||32&r.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},p.prototype.componentWillUnmount=function(){this.o=[]},p.prototype.render=function(e,r){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=P(this.__b,t,o.__O=o.__P)}this.__b=null}var n=r.__a&&u.createElement(u.Fragment,null,e.fallback);return n&&(n.__u&=-33),[u.createElement(u.Fragment,null,r.__a?null:e.children),n]};var g=function(e,r,t){if(++t[1]===t[0]&&e.l.delete(r),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(c.prototype=new u.Component).__a=function(e){var r=this,t=S(r.__v),o=r.l.get(e);return o[0]++,function(n){var s=function(){r.props.revealOrder?(o.push(n),g(r,e,o)):n()};t?t(s):s()}},c.prototype.render=function(e){this.i=null,this.l=new Map;var r=u.toChildArray(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&r.reverse();for(var t=r.length;t--;)this.l.set(r[t],this.i=[1,0,this.i]);return e.children},c.prototype.componentDidUpdate=c.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(r,t){g(e,t,r)})};var I=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,j=/[A-Z0-9]/g,F=typeof document<"u",H=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};u.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(u.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})});var k=u.options.event;function L(){}function z(){return this.cancelBubble}function B(){return this.defaultPrevented}u.options.event=function(e){return k&&(e=k(e)),e.persist=L,e.isPropagationStopped=z,e.isDefaultPrevented=B,e.nativeEvent=e};var D={enumerable:!1,configurable:!0,get:function(){return this.class}},O=u.options.vnode;u.options.vnode=function(e){typeof e.type=="string"&&function(r){var t=r.props,o=r.type,n={},s=o.indexOf("-")===-1;for(var i in t){var _=t[i];if(!(i==="value"&&"defaultValue"in t&&_==null||F&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var l=i.toLowerCase();i==="defaultValue"&&"value"in t&&t.value==null?i="value":i==="download"&&_===!0?_="":l==="translate"&&_==="no"?_=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?i="ondblclick":l!=="onchange"||o!=="input"&&o!=="textarea"||H(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":V.test(i)&&(i=l):l=i="oninput":s&&W.test(i)?i=i.replace(j,"-$&").toLowerCase():_===null&&(_=void 0),l==="oninput"&&n[i=l]&&(i="oninputCapture"),n[i]=_}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.value.indexOf(a.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.multiple?n.defaultValue.indexOf(a.props.value)!=-1:n.defaultValue==a.props.value})),t.class&&!t.className?(n.class=t.class,Object.defineProperty(n,"className",D)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=I,O&&O(e)};var C=u.options.__r;u.options.__r=function(e){C&&C(e),e.__c};var w=u.options.diffed;u.options.diffed=function(e){w&&w(e);var r=e.props,t=e.__e;t!=null&&e.type==="textarea"&&"value"in r&&r.value!==t.value&&(t.value=r.value==null?"":r.value)};function T({children:e,pageSize:r,observerOptions:t}){const o=h.useRef(null),{query:n,response:s}=d.useNostoAppState(_=>x.pick(_,"query","response")),{loadMore:i}=d.useLoadMore(r);return h.useEffect(()=>{let _,l;return E(n,s)&&(_=o.current,l=new IntersectionObserver(a=>{a[0]?.isIntersecting&&i()},t),_&&l.observe(_)),()=>{_&&l.unobserve(_)}},[s]),v.u(u.Fragment,{children:[e,v.u("div",{ref:o,style:{height:"1px"}})]})}const $=U(T,N.isEqual);exports.InfiniteScrollWithObserver=$;exports.hasMoreResults=E;exports.intersectionObserverSupported=A;
|
package/dist/{InfiniteScrollWithObserver-Dh_gZaQ6.js → InfiniteScrollWithObserver-Da3akCS0.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as y } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { a as x, u as U } from "./useLoadMore-
|
|
2
|
+
import { a as x, u as U } from "./useLoadMore-BZ5wWCPk.js";
|
|
3
3
|
import { i as I } from "./logger-_fg_Za9y.js";
|
|
4
4
|
import { p as A } from "./pick-DReBictn.js";
|
|
5
5
|
import { Component as c, options as l, createElement as v, Fragment as d, toChildArray as h } from "preact";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-
|
|
1
|
+
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-DSWNCNrI.cjs"),n=require("./baseConfig-DKaOLPtn.cjs"),s={...n.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function o(e={}){return{pageType:"search",...s,...e}}function u({config:e,store:i,children:a}){const c=i??t.createStore();return n.useCheckClientScript(),r.u(t.ConfigContext,{value:o(e),children:r.u(t.StoreContext,{value:c,children:[r.u(n.StoreActionsListener,{}),a]})})}exports.SearchPageProvider=u;exports.makeSerpConfig=o;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as r } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as s, C as c } from "./useActions-
|
|
3
|
-
import { d as i, u as f, S } from "./baseConfig-
|
|
2
|
+
import { c as n, S as s, C as c } from "./useActions-BFZx84-K.js";
|
|
3
|
+
import { d as i, u as f, S } from "./baseConfig-DV2JVKBc.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...i,
|
|
6
6
|
persistentSearchCache: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./useActions-
|
|
1
|
+
"use strict";const i=require("./useActions-DSWNCNrI.cjs"),r=require("./eventBusSubscribe-oONOUGH8.cjs"),c=require("./index.es-Dp6Iaxz3.cjs"),o=require("./logger-Boh_C6Bz.cjs"),u=require("preact/hooks");function s(){const{pageType:t}=i.useConfig(),n=i.useActions();return r.useEventBusSubscribe({event:"actions/newSearch",callback:e=>{t===e.targetStore&&n.newSearch(e.query,e.options)}}),r.useEventBusSubscribe({event:"actions/updateSearch",callback:e=>{t===e.targetStore&&n.updateSearch(e.query,e.options)}}),r.useEventBusSubscribe({event:"actions/replaceFilter",callback:e=>{t===e.targetStore&&n.replaceFilter(e.field,e.value)}}),r.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:e=>{t===e.targetStore&&n.toggleProductFilter(e.field,e.value,e.active)}}),null}function l(){u.useEffect(()=>{const t=window.setTimeout(()=>{o.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);c.s(()=>{window.clearTimeout(t)})},[])}const a={defaultCurrency:"EUR",queryModifications:t=>t};exports.StoreActionsListener=s;exports.defaultBaseConfig=a;exports.useCheckClientScript=l;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as i, e as n } from "./useActions-
|
|
1
|
+
import { a as i, e as n } from "./useActions-BFZx84-K.js";
|
|
2
2
|
import { u as r } from "./eventBusSubscribe-CzlS132j.js";
|
|
3
3
|
import { s as c } from "./index.es-XNBESE3P.js";
|
|
4
4
|
import { l as u } from "./logger-_fg_Za9y.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-kQ8RqtRT.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),i=require("../../index.es-Dp6Iaxz3.cjs"),a=require("../../BaseElement-CIHACCWd.cjs"),m=require("preact/hooks"),p=require("../../cl-B00bZ7jc.cjs");function d({children:t,hit:e,as:o,componentProps:n}){const r=m.useCallback(()=>{e&&"productId"in e&&i.s(c=>c.recordSearchClick("autocomplete",e))},[e]);return u.u(a.BaseElement,{onClick:r,as:o,componentProps:n,className:"ns-autocomplete-element",children:t})}function P({children:t,class:e,onSubmit:o}){return u.u("div",{className:p.cl("ns-autocomplete-element",e),onClick:o,onKeyDown:n=>{n.key==="Enter"&&o()},children:t})}function f({as:t,componentProps:e,onSearchInput:o,children:n}){const r={...e,onInput:l=>{o(l.target)}},c=t??"input";return t||(r.type="search"),u.u(c,{...r,children:n})}exports.AutocompletePageProvider=s.AutocompletePageProvider;exports.AutocompleteElement=d;exports.HistoryElement=P;exports.SearchInput=f;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as g } from "../../AutocompletePageProvider-
|
|
1
|
+
import { A as g } from "../../AutocompletePageProvider-BoVX16FG.js";
|
|
2
2
|
import { u as m } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
3
3
|
import { s } from "../../index.es-XNBESE3P.js";
|
|
4
4
|
import { B as a } from "../../BaseElement-DD_4UwDm.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../CategoryPageProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../CategoryPageProvider-DwqxtD8L.cjs");exports.CategoryPageProvider=e.CategoryPageProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../isBot-iyBlT_oq.cjs"),t=require("../../jsxRuntime.module-B3sGoTIU.cjs"),s=require("../../useLoadMore-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../isBot-iyBlT_oq.cjs"),t=require("../../jsxRuntime.module-B3sGoTIU.cjs"),s=require("../../useLoadMore-PtSHiAZq.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-BlsPDXH_.cjs"),q=require("preact"),r=require("../../useActions-DSWNCNrI.cjs");function b({pageSize:o}){const{loadMore:e}=s.useLoadMore(o);return t.u("button",{onClick:e,children:"More results"})}function c({children:o,loadMoreComponent:e,pageSize:i}){const{loading:u,query:l,response:a}=s.useNostoAppState(S=>p.pick(S,"loading","query","response")),d=!u&&n.hasMoreResults(l,a);return t.u(q.Fragment,{children:[o,d&&(e?t.u(e,{pageSize:i}):t.u(b,{pageSize:i}))]})}const M=!f.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:c;exports.StoreContext=r.StoreContext;exports.createExtendableStore=r.createExtendableStore;exports.createStore=r.createStore;exports.defaultState=r.defaultState;exports.InfiniteScroll=M;exports.InfiniteScrollWithLink=c;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { i as l } from "../../isBot-Lnmft0Z0.js";
|
|
2
2
|
import { u as r } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
3
|
-
import { u as p, a as m } from "../../useLoadMore-
|
|
3
|
+
import { u as p, a as m } from "../../useLoadMore-BZ5wWCPk.js";
|
|
4
4
|
import { p as u } from "../../pick-DReBictn.js";
|
|
5
|
-
import { h as d, i as f, I as S } from "../../InfiniteScrollWithObserver-
|
|
5
|
+
import { h as d, i as f, I as S } from "../../InfiniteScrollWithObserver-Da3akCS0.js";
|
|
6
6
|
import { Fragment as h } from "preact";
|
|
7
|
-
import { S as O, b as W, c as A, d as B } from "../../useActions-
|
|
7
|
+
import { S as O, b as W, c as A, d as B } from "../../useActions-BFZx84-K.js";
|
|
8
8
|
function M({ pageSize: e }) {
|
|
9
9
|
const { loadMore: o } = p(e);
|
|
10
10
|
return /* @__PURE__ */ r("button", { onClick: o, children: "More results" });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config } from './config';
|
|
2
2
|
export declare const ConfigContext: import('preact').Context<Config | null>;
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
3
|
+
export declare function useConfig(): Config;
|
|
4
|
+
export declare function useSerpConfig(): import('../../../serp/src/SerpConfig').SerpConfig;
|
|
5
|
+
export declare function useCategoryConfig(): import('../../../category/src/CategoryConfig').CategoryConfig;
|
|
6
|
+
export declare function useAutocompleteConfig(): import('../../../autocomplete/src/AutocompleteConfig').AutocompleteConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../useActions-DSWNCNrI.cjs"),x=require("../../logger-Boh_C6Bz.cjs"),h=require("../../useLoadMore-PtSHiAZq.cjs"),d=require("preact/hooks"),L=require("../../index.es-Dp6Iaxz3.cjs"),y=require("../../parseNumber-FsZ8w61u.cjs");function P(t){const n=h.useNostoAppState(e=>e.response);return t&&Array.isArray(t)||t&&x.isPlainObject(t)?t:n}function T(t,n){const e=t.data?.filter(f=>f.selected).length??0,{active:o}={active:e>0,...n},[r,c]=d.useState(o),{toggleProductFilter:u}=b.useActions(),l=d.useCallback(()=>{c(!r)},[r]);return{active:r,selectedFiltersCount:e,toggleActive:l,toggleProductFilter:u}}function q(){const{loading:t,facets:n}=h.useNostoAppState(e=>({loading:e.loading,facets:e.response?.products?.facets??[]}));return{loading:t,facets:n}}function z(t,n){const e=n-t;return!isNaN(e)&&e>0?new Array(n-t).fill(void 0).map((o,r)=>r+t):[]}function X(t){const{query:n,products:e}=h.useNostoAppState(o=>({query:o.query,products:o.response.products}));return d.useMemo(()=>{if(!e)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const o=n.products?.from??0,r=t?.width??1/0,c=Math.max(Math.floor(r-1)/2,1),u=e.size>0?Math.floor(o/e.size)+1:1,l=e.size>0?Math.ceil(e.total/e.size):0,f=A=>A>=u-c&&A<=u+c,s=o+1,i=Math.min(o+e.total,e.total),a={from:o,page:u,current:!0},p=A=>({from:(A-1)*e.size,page:A,current:A===u}),S=u>1?p(u-1):void 0,m=u<l?p(u+1):void 0,g=u-c-1>1?p(1):void 0,v=u+c+1<l?p(l):void 0,F=z(1,l+1).filter(f).map(p);return!g&&F[0]?.page===2&&F.unshift(p(1)),!v&&F[F.length-1]?.page===l-1&&F.push(p(l)),{totalPages:l,resultsFrom:s,resultsTo:i,current:a,prev:S,next:m,first:g,last:v,pages:F}},[n,e,t?.width])}function O(){const[t,n]=d.useState([]),[e,o]=d.useState([]);return d.useEffect(()=>{L.s(async r=>{const{products:c,segments:u}=await r.getSearchSessionParams();n(u??[]),o(c?.personalizationBoost??[])})},[]),{segments:t,boost:e}}function j(){const{facets:t}=h.useNostoAppState(s=>({facets:s.response.products?.facets??[]})),{replaceFilter:n,toggleProductFilter:e}=b.useActions(),o=d.useCallback(s=>{const i=t?.find(a=>a.type==="stats"&&a.field===s);if(i&&"min"in i&&"max"in i)return i},[t]),r=d.useCallback(s=>t?.find(i=>i.field===s)?.name??s,[t]),c=d.useCallback(s=>"field"in s&&(s.value instanceof Array||s.range instanceof Array),[]),u=d.useCallback(s=>({...s,range:s.range?.map(i=>({gt:i.gt?Number(i.gt):i.gt,gte:i.gte?Number(i.gte):i.gte,lt:i.lt?Number(i.lt):i.lt,lte:i.lte?Number(i.lte):i.lte}))}),[]),l=d.useCallback(s=>(s.value??[]).map(a=>({value:a,field:s.field,name:r(s.field),filter:u(s),remove:()=>{e(s.field,a,!1)}})),[u,r,e]),f=d.useCallback(s=>(s.range??[]).map(a=>{const p=a.gte??a.gt??o(s.field)?.min,S=a.lte??a.lt??o(s.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:s.field,name:r(s.field),filter:u(s),remove:()=>{n(s.field,void 0)}}}).filter(Boolean),[u,o,r,n]);return{selectFilters:c,toValueFilter:l,toRangeFilter:f}}function R(){const{filter:t}=h.useNostoAppState(l=>({filter:l.query.products?.filter??[]})),{updateSearch:n}=b.useActions(),{selectFilters:e,toValueFilter:o,toRangeFilter:r}=j(),c=d.useMemo(()=>t?t.filter(e).flatMap(l=>"value"in l?o(l):"range"in l?r(l):[]).filter(Boolean):[],[t,e,r,o]),u=d.useCallback(()=>{n({products:{filter:[]}})},[n]);return{filters:c,removeAll:u}}function k(t){const{replaceFilter:n}=b.useActions(),{query:e,products:o}=h.useNostoAppState(a=>({query:a.query,products:a.response.products})),r=o?.facets?.find(a=>a.id===t);if(!r)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const c=e.products?.filter?.find(a=>a.field===r.field),u=c?.range?c.range[0]:void 0,l=typeof u=="object"&&("gte"in u||"lte"in u)?[y.parseNumber(u.gte),y.parseNumber(u.lte)]:[void 0,void 0],f="min"in r?Math.floor(r.min):0,s="max"in r?Math.ceil(r.max):0,i=([a,p])=>{const S=a!==void 0?Math.floor(a):void 0,m=p!==void 0?Math.ceil(p):void 0,g=S!==void 0,v=m!==void 0;(f===S||!g)&&(s===m||!v)?n(r.field,void 0):(f===S||!g)&&v?n(r.field,{lte:m.toString()}):(s===m||!v)&&g?n(r.field,{gte:S.toString()}):g&&v&&n(r.field,{gte:S.toString(),lte:m.toString()})};return{min:f,max:s,range:[l[0]??f,l[1]??s],updateRange:i}}function V(t,n){const{min:e,max:o,range:r,updateRange:c}=k(t),{filters:u}=R(),l=d.useMemo(()=>{const a=u.find(g=>g?.filter?.range);let p=null;if(a){const g=a.filter.range?.[0];p=[y.parseNumber(g?.gte),y.parseNumber(g?.lte)]}const S=[];let m=Math.floor(e/n)*n;for(;m<o;){const g=m+n,v=p&&p[0]===m&&p[1]===g;S.push({min:m,max:g,selected:v}),m=g}return S},[u,e,o,n]),f=a=>{c([a,r[1]])},s=a=>{c([r[0],a])},i=e!==r[0]||o!==r[1];return{min:e,max:o,range:r,updateRange:c,ranges:l,handleMinChange:f,handleMaxChange:s,isSelected:i}}function D(){const{products:t,keywords:n}=h.useNostoAppState(e=>e.response);return{products:t??{hits:[],total:0},keywords:n??{hits:[],total:0}}}function B(){const t=h.useNostoAppState(e=>e.query.products?.filter);return d.useMemo(()=>t?t.reduce((e,o)=>e+(Array.isArray(o.value)?o.value.length:1),0):0,[t])}function N(t){return t&&!Number.isNaN(t)?t:0}function _(t,n){const{from:e,size:o,total:r}=h.useNostoAppState(s=>({from:N(s.query.products?.from??0),size:N(s.response?.products?.size??n),total:N(s.response?.products?.total??0)})),{updateSearch:c}=b.useActions(),u=e+o,l=d.useMemo(()=>[...t].reverse().filter(s=>s<r),[t,r]),f=d.useCallback(s=>{c({products:{size:y.parseNumber(s)}})},[c]);return{from:e,to:u,total:r,size:o,sizeOptions:l,handleSizeChange:f}}function E(t,n){return t.length!==n.length?!1:t.every(e=>n.find(o=>e.field===o.field&&e.order===o.order))}function U(t){const n=h.useNostoAppState(c=>c.query),{updateSearch:e}=b.useActions();return{activeSort:t.find(c=>E(c.value.sort,n.products?.sort||[]))?.id??t[0]?.id,setSort:c=>{const u=t.find(l=>l.id===c);u&&e({products:{sort:u.value.sort}})}}}const M=window.SpeechRecognition||window.webkitSpeechRecognition,C=!!(M&&typeof M=="function");function $(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function I({language:t="en-US",interimResults:n=!1,onResult:e,onError:o}={}){const[r,c]=d.useState(!1),u=d.useRef(null),l=d.useCallback(()=>{const s=new M;s.lang=t,s.interimResults=n,s.onstart=()=>c(!0),e&&(s.onresult=i=>{const{transcript:a}=i.results?.[0]?.[0];e(a)}),o&&(s.onerror=i=>o(i.error)),s.onend=()=>c(!1),u.current=s,s.start()},[t,n,o,e]),f=d.useCallback(()=>{u.current?.stop()},[u]);return{listening:r,startListening:l,stopListening:f}}const Z=C?I:$;function G(t,n){if(!t.length||!n.length)return[];const e=n.reduce((o,r)=>(o[r]={},o),{});return t.forEach(o=>{o.customFields?.forEach(({key:r,value:c})=>{const u=r.toLowerCase();n.includes(u)&&(e[u][c]=e[u][c]||[],e[u][c].push(o))})}),Object.entries(e).filter(o=>Object.keys(o[1]).length).map(([o,r])=>({field:o,options:Object.entries(r).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function H(t,n){return t.length?t.map(({field:e,options:o})=>({field:e,options:o.map(r=>{const c=!r.skus?.some(l=>Object.entries(n).every(([f,s])=>f===e?!0:l.customFields?.find(a=>a.key.toLowerCase()===f)?.value===s)),u=n[e]===r.value;return{...r,unavailable:c,selected:u}})})):[]}const w=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function J(t){if(w.includes(t))return 1e3+w.indexOf(t);const n=parseFloat(t);return isNaN(n)?t:n}function K(t,n){return[...n].sort((e,o)=>{const[r,c]=[e.value,o.value].map(J);return r<c?-1:1})}function Q(t=[],n=[]){const[e,o]=d.useState({}),r=d.useMemo(()=>G(t,n).map(({field:s,options:i})=>({field:s,options:K(s,i)})),[t,n]),c=d.useMemo(()=>H(r,e),[r,e]),u=d.useCallback((f,s)=>{o(i=>{const a={...i};return a[f]===s?delete a[f]:a[f]=s,a})},[]),l=d.useMemo(()=>Object.keys(e).filter(i=>e[i]).length===0?[]:c.filter(({field:i})=>e[i]).map(({field:i,options:a})=>{const p=e[i];return a.find(m=>m.value===p)?.skus??[]}).reduce((i,a)=>i.filter(p=>a.includes(p))),[c,e]);return{swatches:c,toggleOption:u,matchedSkus:l}}exports.useActions=b.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.speechToTextSupported=C;exports.useDecoratedSearchResults=P;exports.useFacet=T;exports.useFacets=q;exports.usePagination=X;exports.usePersonalization=O;exports.useProductFilters=R;exports.useRange=k;exports.useRangeSelector=V;exports.useResponse=D;exports.useSelectedFiltersCount=B;exports.useSizeOptions=_;exports.useSort=U;exports.useSpeechToText=Z;exports.useSwatches=Q;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { e as b } from "../../useActions-
|
|
1
|
+
import { e as b } from "../../useActions-BFZx84-K.js";
|
|
2
2
|
import { a as z } from "../../logger-_fg_Za9y.js";
|
|
3
|
-
import { a as v } from "../../useLoadMore-
|
|
4
|
-
import { u as le } from "../../useLoadMore-
|
|
3
|
+
import { a as v } from "../../useLoadMore-BZ5wWCPk.js";
|
|
4
|
+
import { u as le } from "../../useLoadMore-BZ5wWCPk.js";
|
|
5
5
|
import { useState as R, useCallback as h, useMemo as y, useEffect as A, useRef as N } from "preact/hooks";
|
|
6
6
|
import { s as P } from "../../index.es-XNBESE3P.js";
|
|
7
7
|
import { p as x } from "../../parseNumber-QA48nJLp.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-kQ8RqtRT.cjs"),T=require("../../CategoryPageProvider-DwqxtD8L.cjs"),m=require("../../useActions-DSWNCNrI.cjs"),x=require("../../SerpPageProvider-NSsaKQ7f.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),E=require("../../bindInput-BnKvCky1.cjs"),P=require("../../unique-BXXNictB.cjs"),g=require("preact"),S=require("../../logger-Boh_C6Bz.cjs"),D=require("preact/hooks"),O=require("../../index.es-Dp6Iaxz3.cjs"),y=require("../../search-DTqo1D6Y.cjs");function B(e){let t;return n=>{t&&clearTimeout(t),t=setTimeout(n,e)}}function f({children:e}){const[t]=D.useErrorBoundary();return t&&S.logger.error("Error caught in ErrorBoundary",t),u.u(g.Fragment,{children:e})}function A(e){return Array.from(document.querySelectorAll(e))}function F(e){const t=[];let n=e.parentNode;for(;n&&n!==document&&n instanceof Element;)t.push(n),n=n.parentNode;return t}function I([e,t],n){const o=r=>{const i=r.target;i instanceof HTMLElement&&e&&i!==e&&i!==t&&!F(i).includes(e)&&n()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function q(e,t){e.tabIndex=0,e.addEventListener("blur",t)}function b(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function H({selector:e,timeout:t=500}){return new Promise(n=>{const o=A(e);if(o.length>0)return n(o);const r=new MutationObserver(()=>{const s=A(e);s.length>0&&(r.disconnect(),clearTimeout(i),n(s))}),i=setTimeout(()=>{r.disconnect(),S.logger.warn(`Timed out (${t}) while waiting for element ${e}`),n([])},t);r.observe(document.body,{childList:!0,subtree:!0})})}const N=g.createContext({reportProductClick:()=>{},reportKeywordClick:()=>{},handleSubmit:()=>{},highlightedElementIndex:-1});function $(e,t){const{dropdown:n,history:o,store:r,input:i,onNavigateToSearch:s}=e,l=(c,h)=>{n.hide(),o.hide(),c&&(o.add(c),r.updateState({historyItems:o.get()}),h&&O.s(a=>a.recordSearchSubmit(c)),i.value=c)};return{reportProductClick:c=>{l(c.name,!1)},reportKeywordClick:c=>{l(c.keyword,!0)},handleSubmit:c=>{l(c.query,!1),s?.(c)},highlightedElementIndex:t.highlightedIndex()}}function k(e,t,n){t.style.display="none";const o=(()=>{if(e.parentElement&&e.parentElement.classList.contains("nosto-autocomplete-wrapper"))return e.parentElement;const a=document.createElement("div");return a.className="nosto-autocomplete-wrapper",e.parentNode?.insertBefore(a,e.nextSibling),a.appendChild(e),a})(),r=b(n),i=r&&document.querySelector(r.selector);if(i){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(t),r.position==="first"?i.prepend(a):i.appendChild(a)}else o.appendChild(t);const s={index:-1,onChangeListeners:[]},l=(a,d)=>{const p=a.length;p===0&&(d=-1),s.index=d>=0?d%p:p-1,s.onChangeListeners.forEach(v=>v())},c=()=>{s.index=-1,s.onChangeListeners.forEach(a=>a())},h=()=>s.index;return{element:t,hide:()=>{t.style.display="none",c()},show:()=>{t.style.display="inherit"},isOpen:()=>t.style.display!=="none",goDown:()=>{const a=Array.from(t.getElementsByClassName("ns-autocomplete-element")),d=h();l(a,d+1)},goUp:()=>{const a=Array.from(t.getElementsByClassName("ns-autocomplete-element")),d=h();l(a,d-1)},highlight:l,highlightedIndex:h,submitHighlightedItem:a=>{Array.from(t.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{s.onChangeListeners.push(a)}}}function K(e,t){const n=document.createElement("div");return n.className="nosto-autocomplete-dropdown",{...k(e,n,t),element:n}}const C="nosto:search-js:history";function Q(e,t,n){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...k(e,o,t),element:o,add:i=>{const l=(y.getLocalStorageItem(C)??[]).filter(c=>c!==i).slice(n?-n:0);l.push(i),y.setLocalStorageItem(C,l)},get:()=>(y.getLocalStorageItem(C)??[]).reverse().filter(s=>!!s)}}async function M(e,{config:t,dropdown:n,history:o,renderHistory:r,store:i}){const{historyEnabled:s,minQueryLength:l}=t;if(e.length<l&&s&&r&&!o.isOpen()){o.show();return}if(e.length<l)return;n.hide();const c=i.getState()?.query?.query;c&&c!==e&&await m.newSearch({config:t,store:i},{query:e}),n.show()}async function U(e,t){const{config:n,renderHistory:o,history:r}=t,{historyEnabled:i,minQueryLength:s}=n;if(!o||e.length>=s||!i||r.isOpen())return;const l=R(t,r);r.onHighlightChange(()=>{l(o,r.element)}),r.show();const c=P.measure("renderHistory");l(o,r.element),c()}async function _(e,{config:t,dropdown:n,history:o,store:r,debouncer:i}){const{minQueryLength:s,historyEnabled:l}=t;if(e.length<s&&!l){n.hide(),o.hide();return}if(e.length<s&&l){n.hide(),o.show();return}o.hide(),i(async()=>{m.newSearch({config:t,store:r},{query:e}),n.show()})}function z(e,t,n){const{config:o,debouncer:r}=n;if(r(()=>{}),e.length>=o.minQueryLength)return L(t,n.dropdown,n.history);if(o.historyEnabled)return L(t,n.history,n.dropdown)}function L(e,t,n){if(!t.isOpen()&&e==="ArrowDown"){t.show(),n.hide();return}if(e==="Escape"&&t.hide(),!!t.isOpen()){if(e==="ArrowDown")t.goDown();else if(e==="ArrowUp")t.goUp();else if(e==="Enter"){const o=t.highlightedIndex();return o>=0&&t.submitHighlightedItem(o),t.hide(),o>=0}}}function G(e,{config:t,dropdown:n,history:o,onNavigateToSearch:r,store:i}){n.hide(),o.hide(),!(e.length<t.minQueryLength)&&(o.add(e),i.updateState({historyItems:o.get()}),r?.({query:e}))}async function J(e,t){const{inputCssSelector:n,timeout:o}=e,r=b(n).selector,i=await H({selector:r,timeout:o});if(i.length===0)throw new Error(`No elements found for selector: ${r}`);i.forEach(s=>{V(s,e,t)})}async function V(e,t,n){const{config:o,dropdownCssSelector:r}=t,i=K(e,r),s=Q(e,r,o.historySize),l={...t,input:e,dropdown:i,history:s,store:n,debouncer:B(o.debounceDelay)};X(l),e.setAttribute("data-nosto-element","search-input"),n.updateState({historyItems:s.get()}),E.disableNativeAutocomplete(e),n.onInit(()=>{W(l)}),E.bindInput(e,{onInput:c=>_(c,l),onFocus:c=>U(c,l),onClick:c=>M(c,l),onSubmit:c=>G(c,l),onKeyDown:(c,h)=>z(c,h,l)}),q(s.element,s.hide),q(i.element,i.hide),I([s.element,e],s.hide),I([i.element,e],i.hide)}function W(e){const{dropdown:t,renderAutocomplete:n}=e;if(!n)return;const o=R(e,t);t.onHighlightChange(()=>{o(n,t.element)});const r=P.measure("renderAutocomplete");o(n,t.element),r()}async function X(e){const{input:t,renderSpeechToText:n,config:o,store:r}=e;if(!n)return;const i="ns-autocomplete-voice-position";if(!!t.parentElement?.querySelector(`.${i}`))return;const l=document.createElement("div");l.className=i,t.insertAdjacentElement("afterend",l);const c=await n();g.render(u.u(f,{children:u.u(w.AutocompletePageProvider,{config:o,store:r,children:c})}),l)}function R(e,t){const{config:n,store:o}=e,r=$(e,t);return t.onHighlightChange(()=>{r.highlightedElementIndex=t.highlightedIndex()}),(i,s)=>g.render(u.u(f,{children:u.u(w.AutocompletePageProvider,{config:n,store:o,children:u.u(N,{value:r,children:i()})})}),s)}async function j({cssSelector:e,timeout:t,renderComponent:n}){const o=b(e).selector,r=await H({selector:o,timeout:t??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&S.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),g.render(n(),r[0])}async function Y(e,t){const{render:n}=e,o=await n();j({...e,renderComponent:()=>u.u(f,{children:u.u(T.CategoryPageProvider,{store:t,config:e.config,children:o})})})}async function Z(e,t){const{render:n}=e,o=await n();j({...e,renderComponent:()=>u.u(f,{children:u.u(x.SearchPageProvider,{store:t,config:e.config,children:o})})})}async function ee({autocomplete:e,category:t,serp:n}){e&&await J({...e,config:w.makeAutocompleteConfig(e.config)},m.createStore({query:e.query})),t&&await Y({...t,config:T.makeCategoryConfig(t.config)},m.createStore()),n&&await Z({...n,config:x.makeSerpConfig(n.config)},m.createStore())}exports.AutocompleteContext=N;exports.init=ee;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as
|
|
3
|
-
import { n as
|
|
4
|
-
import { S as
|
|
1
|
+
import { A as L, m as D } from "../../AutocompletePageProvider-BoVX16FG.js";
|
|
2
|
+
import { C as R, m as B } from "../../CategoryPageProvider-DrDTw4gs.js";
|
|
3
|
+
import { n as T, c as g } from "../../useActions-BFZx84-K.js";
|
|
4
|
+
import { S as F, m as O } from "../../SerpPageProvider-qRhpKBXS.js";
|
|
5
5
|
import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
6
|
-
import { d as
|
|
6
|
+
import { d as $, b as j } from "../../bindInput-CCx0Fhsg.js";
|
|
7
7
|
import { a as x } from "../../unique-Cv2g464w.js";
|
|
8
|
-
import { Fragment as K, createContext as Q, render as
|
|
9
|
-
import { l as
|
|
8
|
+
import { Fragment as K, createContext as Q, render as y } from "preact";
|
|
9
|
+
import { l as C } from "../../logger-_fg_Za9y.js";
|
|
10
10
|
import { useErrorBoundary as U } from "preact/hooks";
|
|
11
|
-
import { s as
|
|
12
|
-
import { g as
|
|
13
|
-
function
|
|
11
|
+
import { s as v } from "../../index.es-XNBESE3P.js";
|
|
12
|
+
import { g as S, a as M } from "../../search-sC5QgJmw.js";
|
|
13
|
+
function z(e) {
|
|
14
14
|
let t;
|
|
15
15
|
return (n) => {
|
|
16
16
|
t && clearTimeout(t), t = setTimeout(n, e);
|
|
@@ -18,22 +18,22 @@ function G(e) {
|
|
|
18
18
|
}
|
|
19
19
|
function u({ children: e }) {
|
|
20
20
|
const [t] = U();
|
|
21
|
-
return t &&
|
|
21
|
+
return t && C.error("Error caught in ErrorBoundary", t), /* @__PURE__ */ d(K, { children: e });
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
23
|
+
function b(e) {
|
|
24
|
+
return Array.from(document.querySelectorAll(e));
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
function G(e) {
|
|
27
|
+
const t = [];
|
|
28
|
+
let n = e.parentNode;
|
|
29
|
+
for (; n && n !== document && n instanceof Element; )
|
|
30
|
+
t.push(n), n = n.parentNode;
|
|
31
|
+
return t;
|
|
32
32
|
}
|
|
33
33
|
function E([e, t], n) {
|
|
34
34
|
const o = (r) => {
|
|
35
35
|
const i = r.target;
|
|
36
|
-
i instanceof HTMLElement && e && i !== e && i !== t && !
|
|
36
|
+
i instanceof HTMLElement && e && i !== e && i !== t && !G(i).includes(e) && n();
|
|
37
37
|
};
|
|
38
38
|
return document.addEventListener("click", o), {
|
|
39
39
|
destroy: () => {
|
|
@@ -44,7 +44,7 @@ function E([e, t], n) {
|
|
|
44
44
|
function A(e, t) {
|
|
45
45
|
e.tabIndex = 0, e.addEventListener("blur", t);
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function w(e) {
|
|
48
48
|
return typeof e == "string" ? {
|
|
49
49
|
selector: e,
|
|
50
50
|
position: "last"
|
|
@@ -53,16 +53,16 @@ function S(e) {
|
|
|
53
53
|
...e
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function H({ selector: e, timeout: t = 500 }) {
|
|
57
57
|
return new Promise((n) => {
|
|
58
|
-
const o =
|
|
58
|
+
const o = b(e);
|
|
59
59
|
if (o.length > 0)
|
|
60
60
|
return n(o);
|
|
61
61
|
const r = new MutationObserver(() => {
|
|
62
|
-
const s =
|
|
62
|
+
const s = b(e);
|
|
63
63
|
s.length > 0 && (r.disconnect(), clearTimeout(i), n(s));
|
|
64
64
|
}), i = setTimeout(() => {
|
|
65
|
-
r.disconnect(),
|
|
65
|
+
r.disconnect(), C.warn(`Timed out (${t}) while waiting for element ${e}`), n([]);
|
|
66
66
|
}, t);
|
|
67
67
|
r.observe(document.body, {
|
|
68
68
|
childList: !0,
|
|
@@ -83,7 +83,7 @@ function V(e, t) {
|
|
|
83
83
|
const { dropdown: n, history: o, store: r, input: i, onNavigateToSearch: s } = e, a = (c, h) => {
|
|
84
84
|
n.hide(), o.hide(), c && (o.add(c), r.updateState({
|
|
85
85
|
historyItems: o.get()
|
|
86
|
-
}), h &&
|
|
86
|
+
}), h && v((l) => l.recordSearchSubmit(c)), i.value = c);
|
|
87
87
|
};
|
|
88
88
|
return {
|
|
89
89
|
reportProductClick: (c) => {
|
|
@@ -98,14 +98,14 @@ function V(e, t) {
|
|
|
98
98
|
highlightedElementIndex: t.highlightedIndex()
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function N(e, t, n) {
|
|
102
102
|
t.style.display = "none";
|
|
103
103
|
const o = (() => {
|
|
104
104
|
if (e.parentElement && e.parentElement.classList.contains("nosto-autocomplete-wrapper"))
|
|
105
105
|
return e.parentElement;
|
|
106
106
|
const l = document.createElement("div");
|
|
107
107
|
return l.className = "nosto-autocomplete-wrapper", e.parentNode?.insertBefore(l, e.nextSibling), l.appendChild(e), l;
|
|
108
|
-
})(), r =
|
|
108
|
+
})(), r = w(n), i = r && document.querySelector(r.selector);
|
|
109
109
|
if (i) {
|
|
110
110
|
const l = document.createElement("form");
|
|
111
111
|
l.className = "nosto-dropdown-form", l.appendChild(t), r.position === "first" ? i.prepend(l) : i.appendChild(l);
|
|
@@ -116,7 +116,7 @@ function k(e, t, n) {
|
|
|
116
116
|
onChangeListeners: []
|
|
117
117
|
}, a = (l, m) => {
|
|
118
118
|
const f = l.length;
|
|
119
|
-
f === 0 && (m = -1), s.index = m >= 0 ? m % f : f - 1, s.onChangeListeners.forEach((
|
|
119
|
+
f === 0 && (m = -1), s.index = m >= 0 ? m % f : f - 1, s.onChangeListeners.forEach((q) => q());
|
|
120
120
|
}, c = () => {
|
|
121
121
|
s.index = -1, s.onChangeListeners.forEach((l) => l());
|
|
122
122
|
}, h = () => s.index;
|
|
@@ -150,7 +150,7 @@ function k(e, t, n) {
|
|
|
150
150
|
function W(e, t) {
|
|
151
151
|
const n = document.createElement("div");
|
|
152
152
|
return n.className = "nosto-autocomplete-dropdown", {
|
|
153
|
-
...
|
|
153
|
+
...N(e, n, t),
|
|
154
154
|
element: n
|
|
155
155
|
};
|
|
156
156
|
}
|
|
@@ -158,13 +158,13 @@ const p = "nosto:search-js:history";
|
|
|
158
158
|
function X(e, t, n) {
|
|
159
159
|
const o = document.createElement("div");
|
|
160
160
|
return o.className = "nosto-autocomplete-history", {
|
|
161
|
-
...
|
|
161
|
+
...N(e, o, t),
|
|
162
162
|
element: o,
|
|
163
163
|
add: (i) => {
|
|
164
|
-
const a = (
|
|
165
|
-
a.push(i),
|
|
164
|
+
const a = (S(p) ?? []).filter((c) => c !== i).slice(n ? -n : 0);
|
|
165
|
+
a.push(i), M(p, a);
|
|
166
166
|
},
|
|
167
|
-
get: () => (
|
|
167
|
+
get: () => (S(p) ?? []).reverse().filter((s) => !!s)
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
async function Y(e, { config: t, dropdown: n, history: o, renderHistory: r, store: i }) {
|
|
@@ -177,13 +177,13 @@ async function Y(e, { config: t, dropdown: n, history: o, renderHistory: r, stor
|
|
|
177
177
|
return;
|
|
178
178
|
n.hide();
|
|
179
179
|
const c = i.getState()?.query?.query;
|
|
180
|
-
c && c !== e && await
|
|
180
|
+
c && c !== e && await T({ config: t, store: i }, { query: e }), n.show();
|
|
181
181
|
}
|
|
182
182
|
async function Z(e, t) {
|
|
183
183
|
const { config: n, renderHistory: o, history: r } = t, { historyEnabled: i, minQueryLength: s } = n;
|
|
184
184
|
if (!o || e.length >= s || !i || r.isOpen())
|
|
185
185
|
return;
|
|
186
|
-
const a =
|
|
186
|
+
const a = k(t, r);
|
|
187
187
|
r.onHighlightChange(() => {
|
|
188
188
|
a(o, r.element);
|
|
189
189
|
}), r.show();
|
|
@@ -201,7 +201,7 @@ async function _(e, { config: t, dropdown: n, history: o, store: r, debouncer: i
|
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
203
|
o.hide(), i(async () => {
|
|
204
|
-
|
|
204
|
+
T({ config: t, store: r }, { query: e }), n.show();
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
function ee(e, t, n) {
|
|
@@ -236,7 +236,7 @@ function te(e, { config: t, dropdown: n, history: o, onNavigateToSearch: r, stor
|
|
|
236
236
|
}));
|
|
237
237
|
}
|
|
238
238
|
async function ne(e, t) {
|
|
239
|
-
const { inputCssSelector: n, timeout: o } = e, r =
|
|
239
|
+
const { inputCssSelector: n, timeout: o } = e, r = w(n).selector, i = await H({
|
|
240
240
|
selector: r,
|
|
241
241
|
timeout: o
|
|
242
242
|
});
|
|
@@ -253,13 +253,13 @@ async function oe(e, t, n) {
|
|
|
253
253
|
dropdown: i,
|
|
254
254
|
history: s,
|
|
255
255
|
store: n,
|
|
256
|
-
debouncer:
|
|
256
|
+
debouncer: z(o.debounceDelay)
|
|
257
257
|
};
|
|
258
258
|
ie(a), e.setAttribute("data-nosto-element", "search-input"), n.updateState({
|
|
259
259
|
historyItems: s.get()
|
|
260
|
-
}),
|
|
260
|
+
}), $(e), n.onInit(() => {
|
|
261
261
|
re(a);
|
|
262
|
-
}),
|
|
262
|
+
}), j(e, {
|
|
263
263
|
onInput: (c) => _(c, a),
|
|
264
264
|
onFocus: (c) => Z(c, a),
|
|
265
265
|
onClick: (c) => Y(c, a),
|
|
@@ -271,7 +271,7 @@ function re(e) {
|
|
|
271
271
|
const { dropdown: t, renderAutocomplete: n } = e;
|
|
272
272
|
if (!n)
|
|
273
273
|
return;
|
|
274
|
-
const o =
|
|
274
|
+
const o = k(e, t);
|
|
275
275
|
t.onHighlightChange(() => {
|
|
276
276
|
o(n, t.element);
|
|
277
277
|
});
|
|
@@ -286,60 +286,60 @@ async function ie(e) {
|
|
|
286
286
|
const a = document.createElement("div");
|
|
287
287
|
a.className = i, t.insertAdjacentElement("afterend", a);
|
|
288
288
|
const c = await n();
|
|
289
|
-
|
|
290
|
-
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(
|
|
289
|
+
y(
|
|
290
|
+
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(L, { config: o, store: r, children: c }) }),
|
|
291
291
|
a
|
|
292
292
|
);
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function k(e, t) {
|
|
295
295
|
const { config: n, store: o } = e, r = V(e, t);
|
|
296
296
|
return t.onHighlightChange(() => {
|
|
297
297
|
r.highlightedElementIndex = t.highlightedIndex();
|
|
298
|
-
}), (i, s) =>
|
|
299
|
-
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(
|
|
298
|
+
}), (i, s) => y(
|
|
299
|
+
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(L, { config: n, store: o, children: /* @__PURE__ */ d(J, { value: r, children: i() }) }) }),
|
|
300
300
|
s
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
|
-
async function
|
|
304
|
-
const o =
|
|
303
|
+
async function P({ cssSelector: e, timeout: t, renderComponent: n }) {
|
|
304
|
+
const o = w(e).selector, r = await H({
|
|
305
305
|
selector: o,
|
|
306
306
|
timeout: t ?? 100
|
|
307
307
|
});
|
|
308
308
|
if (r.length === 0)
|
|
309
309
|
throw new Error(`No elements found for selector: ${o}`);
|
|
310
|
-
r.length > 1 &&
|
|
310
|
+
r.length > 1 && C.warn(`Multiple (${r.length}) elements found for selector: ${o}`), y(n(), r[0]);
|
|
311
311
|
}
|
|
312
312
|
async function se(e, t) {
|
|
313
313
|
const { render: n } = e, o = await n();
|
|
314
|
-
|
|
314
|
+
P({
|
|
315
315
|
...e,
|
|
316
|
-
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(
|
|
316
|
+
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(R, { store: t, config: e.config, children: o }) })
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
319
|
async function ce(e, t) {
|
|
320
320
|
const { render: n } = e, o = await n();
|
|
321
|
-
|
|
321
|
+
P({
|
|
322
322
|
...e,
|
|
323
|
-
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(
|
|
323
|
+
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(F, { store: t, config: e.config, children: o }) })
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
326
|
async function Se({ autocomplete: e, category: t, serp: n }) {
|
|
327
327
|
e && await ne(
|
|
328
328
|
{
|
|
329
329
|
...e,
|
|
330
|
-
config:
|
|
330
|
+
config: D(e.config)
|
|
331
331
|
},
|
|
332
332
|
g({ query: e.query })
|
|
333
333
|
), t && await se(
|
|
334
334
|
{
|
|
335
335
|
...t,
|
|
336
|
-
config:
|
|
336
|
+
config: B(t.config)
|
|
337
337
|
},
|
|
338
338
|
g()
|
|
339
339
|
), n && await ce(
|
|
340
340
|
{
|
|
341
341
|
...n,
|
|
342
|
-
config:
|
|
342
|
+
config: O(n.config)
|
|
343
343
|
},
|
|
344
344
|
g()
|
|
345
345
|
);
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare function findAll<T extends Element>(selector: DOMTarget, filterType?: {
|
|
3
|
-
new (): T;
|
|
4
|
-
}): T[];
|
|
5
|
-
export declare function DOMReady(): Promise<void>;
|
|
6
|
-
export declare function cloneNode<T extends Node>(node: T, deep: boolean): T;
|
|
7
|
-
export declare function parents(target: DOMTarget, selector?: string): Element[];
|
|
8
|
-
export declare function matches(target: DOMTarget, selector: string): boolean;
|
|
1
|
+
export declare function findAll<T extends Element>(selector: string): T[];
|
|
9
2
|
export declare function bindClickOutside([element, input]: HTMLElement[], callback: () => void): {
|
|
10
3
|
destroy: () => void;
|
|
11
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-DSWNCNrI.cjs"),r=require("../../InfiniteScrollWithObserver-BlsPDXH_.cjs"),t=require("../../useLoadMore-PtSHiAZq.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as t, u as a } from "../../useActions-
|
|
2
|
-
import { I as s, i } from "../../InfiniteScrollWithObserver-
|
|
3
|
-
import { g as p } from "../../useLoadMore-
|
|
1
|
+
import { n as t, u as a } from "../../useActions-BFZx84-K.js";
|
|
2
|
+
import { I as s, i } from "../../InfiniteScrollWithObserver-Da3akCS0.js";
|
|
3
|
+
import { g as p } from "../../useLoadMore-BZ5wWCPk.js";
|
|
4
4
|
export {
|
|
5
5
|
s as InfiniteScrollWithObserver,
|
|
6
6
|
p as getNextPageQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-DSWNCNrI.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-NSsaKQ7f.cjs"),P="nosto:search:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { u as i } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
2
|
import { s as l } from "../../index.es-XNBESE3P.js";
|
|
3
3
|
import { B as m } from "../../BaseElement-DD_4UwDm.js";
|
|
4
|
-
import { a as p } from "../../useActions-
|
|
4
|
+
import { a as p } from "../../useActions-BFZx84-K.js";
|
|
5
5
|
import { useCallback as f } from "preact/hooks";
|
|
6
|
-
import { S as x } from "../../SerpPageProvider-
|
|
6
|
+
import { S as x } from "../../SerpPageProvider-qRhpKBXS.js";
|
|
7
7
|
const S = "nosto:search:scrollPos";
|
|
8
8
|
function g() {
|
|
9
9
|
window.sessionStorage.setItem(S, window.scrollY.toString());
|
|
@@ -3,26 +3,27 @@ import { useContext as C, useMemo as T, useCallback as g } from "preact/hooks";
|
|
|
3
3
|
import { b as S, u as I, a as f, d as y, m as M } from "./unique-Cv2g464w.js";
|
|
4
4
|
import { i as w, l as U } from "./logger-_fg_Za9y.js";
|
|
5
5
|
import { s as q } from "./search-sC5QgJmw.js";
|
|
6
|
-
const E = k(null)
|
|
6
|
+
const E = k(null);
|
|
7
|
+
function Q() {
|
|
7
8
|
const e = C(E);
|
|
8
9
|
if (!e)
|
|
9
10
|
throw new Error("useConfig must be used within a ConfigProvider");
|
|
10
11
|
return e;
|
|
11
|
-
}
|
|
12
|
+
}
|
|
12
13
|
function z(e, r = {}) {
|
|
13
14
|
const t = /* @__PURE__ */ new Map();
|
|
14
|
-
let
|
|
15
|
+
let s = S(e, r ?? {});
|
|
15
16
|
const o = S(e, r);
|
|
16
17
|
function c(d) {
|
|
17
|
-
|
|
18
|
+
s = d(s);
|
|
18
19
|
for (const u of t.values())
|
|
19
|
-
u(
|
|
20
|
+
u(s);
|
|
20
21
|
}
|
|
21
22
|
function n(d) {
|
|
22
23
|
c((u) => ({ ...u, ...d }));
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
25
|
+
function i() {
|
|
26
|
+
return s;
|
|
26
27
|
}
|
|
27
28
|
function a() {
|
|
28
29
|
return structuredClone(o);
|
|
@@ -47,7 +48,7 @@ function z(e, r = {}) {
|
|
|
47
48
|
}
|
|
48
49
|
return {
|
|
49
50
|
updateState: n,
|
|
50
|
-
getState:
|
|
51
|
+
getState: i,
|
|
51
52
|
getInitialState: a,
|
|
52
53
|
onChange: l,
|
|
53
54
|
onInit: v,
|
|
@@ -138,14 +139,14 @@ const L = [
|
|
|
138
139
|
"tags3"
|
|
139
140
|
], O = ["keyword", "_redirect"];
|
|
140
141
|
async function b(e, r, t) {
|
|
141
|
-
const
|
|
142
|
+
const s = f("newSearch"), o = e.config.pageType, c = o === "search" ? "serp" : o, n = y(e.store.getInitialState().query, r), i = y(e.config.search, t, {
|
|
142
143
|
track: c,
|
|
143
144
|
redirect: o !== "autocomplete",
|
|
144
145
|
isKeyword: !!t?.isKeyword,
|
|
145
146
|
usePersistentCache: e.config.pageType !== "autocomplete" && e.config.persistentSearchCache,
|
|
146
147
|
useMemoryCache: e.config.pageType === "autocomplete" && e.config.memoryCache
|
|
147
148
|
});
|
|
148
|
-
e.config.onBeforeSearch?.(e,
|
|
149
|
+
e.config.onBeforeSearch?.(e, i), e.store.updateState({
|
|
149
150
|
query: n,
|
|
150
151
|
loading: !0,
|
|
151
152
|
initialized: !0
|
|
@@ -162,39 +163,39 @@ async function b(e, r, t) {
|
|
|
162
163
|
o
|
|
163
164
|
);
|
|
164
165
|
try {
|
|
165
|
-
const l = await q(D(e.config.pageType, a),
|
|
166
|
+
const l = await q(D(e.config.pageType, a), i);
|
|
166
167
|
e.store.updateState({
|
|
167
168
|
response: l,
|
|
168
169
|
loading: !1
|
|
169
170
|
});
|
|
170
171
|
} catch (l) {
|
|
171
|
-
U.error("Search action failed", l), e.config.onSearchError?.(l, a,
|
|
172
|
+
U.error("Search action failed", l), e.config.onSearchError?.(l, a, i, o);
|
|
172
173
|
}
|
|
173
|
-
|
|
174
|
+
s();
|
|
174
175
|
}
|
|
175
176
|
async function h(e, r, t) {
|
|
176
|
-
const
|
|
177
|
-
await b(e, o, t),
|
|
177
|
+
const s = f("updateSearch"), o = y(e.store.getState().query, { products: { from: 0 } }, r);
|
|
178
|
+
await b(e, o, t), s();
|
|
178
179
|
}
|
|
179
180
|
async function V(e, r, t) {
|
|
180
|
-
const
|
|
181
|
+
const s = f("replaceFilter"), o = e.store.getState().query.products?.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
181
182
|
await h(e, {
|
|
182
183
|
products: {
|
|
183
184
|
filter: [...o?.filter((n) => n.field !== r) ?? [], ...c]
|
|
184
185
|
}
|
|
185
|
-
}),
|
|
186
|
+
}), s();
|
|
186
187
|
}
|
|
187
|
-
async function j(e, r, t,
|
|
188
|
-
const o = f("toggleProductFilter"), c = e.store.getState().query.products?.filter, n = c?.find((a) => a.value instanceof Array && a.field === r),
|
|
188
|
+
async function j(e, r, t, s) {
|
|
189
|
+
const o = f("toggleProductFilter"), c = e.store.getState().query.products?.filter, n = c?.find((a) => a.value instanceof Array && a.field === r), i = n?.value ? {
|
|
189
190
|
...n,
|
|
190
|
-
value: [...n.value.filter((a) => !w(a, t)), ...
|
|
191
|
-
} :
|
|
191
|
+
value: [...n.value.filter((a) => !w(a, t)), ...s ? [t] : []]
|
|
192
|
+
} : s ? {
|
|
192
193
|
field: r,
|
|
193
194
|
value: [t]
|
|
194
195
|
} : void 0;
|
|
195
196
|
await h(e, {
|
|
196
197
|
products: {
|
|
197
|
-
filter: [...c?.filter((a) => a !== n) ?? [], ...
|
|
198
|
+
filter: [...c?.filter((a) => a !== n) ?? [], ...i?.value?.length ? [i] : []]
|
|
198
199
|
}
|
|
199
200
|
}), o();
|
|
200
201
|
}
|
|
@@ -205,21 +206,21 @@ function R() {
|
|
|
205
206
|
store: r
|
|
206
207
|
}),
|
|
207
208
|
[e, r]
|
|
208
|
-
),
|
|
209
|
-
(
|
|
209
|
+
), s = g(
|
|
210
|
+
(i, a) => b(t, i, a),
|
|
210
211
|
[t]
|
|
211
212
|
), o = g(
|
|
212
|
-
(
|
|
213
|
+
(i, a) => h(t, i, a),
|
|
213
214
|
[t]
|
|
214
215
|
), c = g(
|
|
215
|
-
(
|
|
216
|
+
(i, a, l) => j(t, i, a, l),
|
|
216
217
|
[t]
|
|
217
218
|
), n = g(
|
|
218
|
-
(
|
|
219
|
+
(i, a) => V(t, i, a),
|
|
219
220
|
[t]
|
|
220
221
|
);
|
|
221
222
|
return {
|
|
222
|
-
newSearch:
|
|
223
|
+
newSearch: s,
|
|
223
224
|
updateSearch: o,
|
|
224
225
|
toggleProductFilter: c,
|
|
225
226
|
replaceFilter: n
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const k=require("preact"),f=require("preact/hooks"),c=require("./unique-BXXNictB.cjs"),y=require("./logger-Boh_C6Bz.cjs"),I=require("./search-DTqo1D6Y.cjs"),m=k.createContext(null);function w(){const e=f.useContext(m);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function b(e,r={}){const t=new Map;let n=c.deepMergePlain(e,r??{});const s=c.deepMergePlain(e,r);function u(g){n=g(n);for(const l of t.values())l(n)}function o(g){u(l=>({...l,...g}))}function i(){return n}function a(){return structuredClone(s)}function d(g,l){let S;t.set(l,T=>{const h=g(T);y.isEqual(h,S)||(S=h,l(h))})}function q(g){d(l=>l.initialized,l=>{l&&g()})}function M(g){t.delete(g)}return{updateState:o,getState:i,getInitialState:a,onChange:d,onInit:q,clearOnChange:M}}const v={loading:!0,query:{},response:{},initialized:!1};function F(e={}){return b(v,e)}const P=k.createContext(F());function E(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:U,...r.products},...r.keywords?{keywords:{...r.keywords,fields:c.unique([...A,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const U=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],A=["keyword","_redirect"];async function C(e,r,t){const n=c.measure("newSearch"),s=e.config.pageType,u=s==="search"?"serp":s,o=c.deepMerge(e.store.getInitialState().query,r),i=c.deepMerge(e.config.search,t,{track:u,redirect:s!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,i),e.store.updateState({query:o,loading:!0,initialized:!0});const a=e.config.queryModifications({...o,products:{...o.products,filter:c.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},s);try{const d=await I.search(E(e.config.pageType,a),i);e.store.updateState({response:d,loading:!1})}catch(d){y.logger.error("Search action failed",d),e.config.onSearchError?.(d,a,i,s)}n()}async function p(e,r,t){const n=c.measure("updateSearch"),s=c.deepMerge(e.store.getState().query,{products:{from:0}},r);await C(e,s,t),n()}async function Q(e,r,t){const n=c.measure("replaceFilter"),s=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await p(e,{products:{filter:[...s?.filter(o=>o.field!==r)??[],...u]}}),n()}async function z(e,r,t,n){const s=c.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,o=u?.find(a=>a.value instanceof Array&&a.field===r),i=o?.value?{...o,value:[...o.value.filter(a=>!y.isEqual(a,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await p(e,{products:{filter:[...u?.filter(a=>a!==o)??[],...i?.value?.length?[i]:[]]}}),s()}function K(){const e=w(),r=f.useContext(P),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((i,a)=>C(t,i,a),[t]),s=f.useCallback((i,a)=>p(t,i,a),[t]),u=f.useCallback((i,a,d)=>z(t,i,a,d),[t]),o=f.useCallback((i,a)=>Q(t,i,a),[t]);return{newSearch:n,updateSearch:s,toggleProductFilter:u,replaceFilter:o}}exports.ConfigContext=m;exports.StoreContext=P;exports.createExtendableStore=b;exports.createStore=F;exports.defaultState=v;exports.newSearch=C;exports.updateSearch=p;exports.useActions=K;exports.useConfig=w;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as n, e as u } from "./useActions-
|
|
1
|
+
import { S as n, e as u } from "./useActions-BFZx84-K.js";
|
|
2
2
|
import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
|
|
3
3
|
import { i as m } from "./isBot-Lnmft0Z0.js";
|
|
4
4
|
function l(t = p) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-
|
|
1
|
+
"use strict";const n=require("./useActions-DSWNCNrI.cjs"),r=require("preact/hooks"),i=require("./isBot-iyBlT_oq.cjs");function c(e=f){const t=r.useContext(n.StoreContext),[o,s]=r.useState(e(t.getState()));return t.onChange(e,s),r.useEffect(()=>()=>t.clearOnChange(s),[t]),o}const f=e=>e;function a({from:e,size:t,pageSize:o}){return i.isBot()?{products:{from:e+o}}:{products:{size:t+o}}}function d(e=24){const{from:t,size:o}=c(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:s}=n.useActions();return{loadMore:r.useCallback(async()=>{await s(a({from:t,size:o,pageSize:e}))},[t,o,e,s])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -118,10 +118,10 @@
|
|
|
118
118
|
"isbot": "^5.1.30",
|
|
119
119
|
"jsdom": "^26.1.0",
|
|
120
120
|
"prettier": "^3.6.2",
|
|
121
|
-
"typedoc": "^0.28.
|
|
121
|
+
"typedoc": "^0.28.12",
|
|
122
122
|
"typescript": "^5.9.2",
|
|
123
123
|
"typescript-eslint": "^8.41.0",
|
|
124
|
-
"vite": "^7.1.
|
|
124
|
+
"vite": "^7.1.4",
|
|
125
125
|
"vite-plugin-dts": "^4.5.4",
|
|
126
126
|
"vitest": "^3.1.3"
|
|
127
127
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const k=require("preact"),f=require("preact/hooks"),c=require("./unique-BXXNictB.cjs"),y=require("./logger-Boh_C6Bz.cjs"),I=require("./search-DTqo1D6Y.cjs"),m=k.createContext(null),w=()=>{const e=f.useContext(m);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function b(e,r={}){const t=new Map;let n=c.deepMergePlain(e,r??{});const s=c.deepMergePlain(e,r);function u(g){n=g(n);for(const l of t.values())l(n)}function o(g){u(l=>({...l,...g}))}function i(){return n}function a(){return structuredClone(s)}function d(g,l){let S;t.set(l,T=>{const h=g(T);y.isEqual(h,S)||(S=h,l(h))})}function q(g){d(l=>l.initialized,l=>{l&&g()})}function M(g){t.delete(g)}return{updateState:o,getState:i,getInitialState:a,onChange:d,onInit:q,clearOnChange:M}}const v={loading:!0,query:{},response:{},initialized:!1};function F(e={}){return b(v,e)}const P=k.createContext(F());function E(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:U,...r.products},...r.keywords?{keywords:{...r.keywords,fields:c.unique([...A,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const U=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],A=["keyword","_redirect"];async function C(e,r,t){const n=c.measure("newSearch"),s=e.config.pageType,u=s==="search"?"serp":s,o=c.deepMerge(e.store.getInitialState().query,r),i=c.deepMerge(e.config.search,t,{track:u,redirect:s!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,i),e.store.updateState({query:o,loading:!0,initialized:!0});const a=e.config.queryModifications({...o,products:{...o.products,filter:c.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},s);try{const d=await I.search(E(e.config.pageType,a),i);e.store.updateState({response:d,loading:!1})}catch(d){y.logger.error("Search action failed",d),e.config.onSearchError?.(d,a,i,s)}n()}async function p(e,r,t){const n=c.measure("updateSearch"),s=c.deepMerge(e.store.getState().query,{products:{from:0}},r);await C(e,s,t),n()}async function Q(e,r,t){const n=c.measure("replaceFilter"),s=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await p(e,{products:{filter:[...s?.filter(o=>o.field!==r)??[],...u]}}),n()}async function z(e,r,t,n){const s=c.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,o=u?.find(a=>a.value instanceof Array&&a.field===r),i=o?.value?{...o,value:[...o.value.filter(a=>!y.isEqual(a,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await p(e,{products:{filter:[...u?.filter(a=>a!==o)??[],...i?.value?.length?[i]:[]]}}),s()}function K(){const e=w(),r=f.useContext(P),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((i,a)=>C(t,i,a),[t]),s=f.useCallback((i,a)=>p(t,i,a),[t]),u=f.useCallback((i,a,d)=>z(t,i,a,d),[t]),o=f.useCallback((i,a)=>Q(t,i,a),[t]);return{newSearch:n,updateSearch:s,toggleProductFilter:u,replaceFilter:o}}exports.ConfigContext=m;exports.StoreContext=P;exports.createExtendableStore=b;exports.createStore=F;exports.defaultState=v;exports.newSearch=C;exports.updateSearch=p;exports.useActions=K;exports.useConfig=w;
|