@nosto/search-js 3.17.0 → 3.17.2
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-DtgDwaV9.cjs → AutocompletePageProvider-CjNvOYZz.cjs} +1 -1
- package/dist/{AutocompletePageProvider-FCFyqG35.js → AutocompletePageProvider-DMtA79nZ.js} +3 -3
- package/dist/{CategoryPageProvider-CJL0GSV1.cjs → CategoryPageProvider-2ZmajAxh.cjs} +1 -1
- package/dist/{CategoryPageProvider-OYvvNZSr.js → CategoryPageProvider-DU3DjmnJ.js} +2 -2
- package/dist/{InfiniteScrollWithObserver-kW5lM7Jh.js → InfiniteScrollWithObserver-B0iiezKy.js} +1 -1
- package/dist/{InfiniteScrollWithObserver-CwWRBU3q.cjs → InfiniteScrollWithObserver-LxLj-_bT.cjs} +1 -1
- package/dist/{SerpPageProvider-CsLAvEUE.cjs → SerpPageProvider-Dn6PSZoF.cjs} +1 -1
- package/dist/{SerpPageProvider-d781RZHT.js → SerpPageProvider-DshgTNpM.js} +2 -2
- package/dist/baseConfig-CaRa_-zN.cjs +1 -0
- package/dist/{baseConfig-CFx9WXL8.js → baseConfig-DeHr2N1l.js} +8 -17
- 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/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.es.js +25 -21
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +4 -4
- 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-MsVW37eV.js → useActions-CSNwQtT1.js} +53 -53
- package/dist/useActions-CY9uts_o.cjs +1 -0
- package/dist/{useHistory-D7detcsc.cjs → useHistory-CJSGam5n.cjs} +1 -1
- package/dist/{useHistory-DtcY_Wkt.js → useHistory-DeIqqw-P.js} +1 -1
- package/dist/{useLoadMore-CYYoAHua.js → useLoadMore-2OmOqicJ.js} +1 -1
- package/dist/{useLoadMore-QOHOP_fr.cjs → useLoadMore-CBshMpps.cjs} +1 -1
- package/package.json +1 -1
- package/dist/baseConfig-Bm8iHF7S.cjs +0 -1
- package/dist/useActions-Drtoxcu4.cjs +0 -1
package/dist/{AutocompletePageProvider-DtgDwaV9.cjs → AutocompletePageProvider-CjNvOYZz.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-
|
|
1
|
+
"use strict";const o=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-CY9uts_o.cjs"),u=require("./baseConfig-CaRa_-zN.cjs"),s=require("./useHistory-CJSGam5n.cjs"),a=require("preact/hooks"),l={...u.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function n(e={}){return{pageType:"autocomplete",...l,...e}}function m({config:e,store:i,children:c}){const t=i??r.createStore();return u.useCheckClientScript(),a.useEffect(()=>{t.updateState({historyItems:s.getSaved()})},[t]),o.u(r.ConfigContext,{value:n(e),children:o.u(r.StoreContext,{value:t,children:[o.u(u.StoreActionsListener,{}),c]})})}exports.AutocompletePageProvider=m;exports.makeAutocompleteConfig=n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u as o } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as i, S as n, C as s } from "./useActions-
|
|
3
|
-
import { d as u, u as m, S as c } from "./baseConfig-
|
|
4
|
-
import { g as f } from "./useHistory-
|
|
2
|
+
import { c as i, S as n, C as s } from "./useActions-CSNwQtT1.js";
|
|
3
|
+
import { d as u, u as m, S as c } from "./baseConfig-DeHr2N1l.js";
|
|
4
|
+
import { g as f } from "./useHistory-DeIqqw-P.js";
|
|
5
5
|
import { useEffect as l } from "preact/hooks";
|
|
6
6
|
const p = {
|
|
7
7
|
...u,
|
|
@@ -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-CY9uts_o.cjs"),o=require("./baseConfig-CaRa_-zN.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;
|
|
@@ -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-CSNwQtT1.js";
|
|
3
|
+
import { d as c, u as C, S as f } from "./baseConfig-DeHr2N1l.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...c,
|
|
6
6
|
persistentSearchCache: !1,
|
package/dist/{InfiniteScrollWithObserver-kW5lM7Jh.js → InfiniteScrollWithObserver-B0iiezKy.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-2OmOqicJ.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";
|
package/dist/{InfiniteScrollWithObserver-CwWRBU3q.cjs → InfiniteScrollWithObserver-LxLj-_bT.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-CBshMpps.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;
|
|
@@ -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-CY9uts_o.cjs"),n=require("./baseConfig-CaRa_-zN.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-CSNwQtT1.js";
|
|
3
|
+
import { d as i, u as f, S } from "./baseConfig-DeHr2N1l.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...i,
|
|
6
6
|
persistentSearchCache: !1,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const c=require("./useActions-CY9uts_o.cjs"),s=require("./eventBusSubscribe-oONOUGH8.cjs"),f=require("./index.es-Dp6Iaxz3.cjs"),b=require("./logger-Boh_C6Bz.cjs"),d=require("preact/hooks");function S(){const{pageType:e}=c.useConfig(),{newSearch:i,updateSearch:u,replaceFilter:o,toggleProductFilter:a}=c.useActions();return s.useEventBusSubscribe({event:"actions/newSearch",callback:({query:t,options:r,targetStore:n})=>{e===n&&i(t,r)}}),s.useEventBusSubscribe({event:"actions/updateSearch",callback:({query:t,options:r,targetStore:n})=>{e===n&&u(t,r)}}),s.useEventBusSubscribe({event:"actions/replaceFilter",callback:({field:t,value:r,targetStore:n})=>{e===n&&o(t,r)}}),s.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:({field:t,value:r,active:n,targetStore:l})=>{e===l&&a(t,r,n)}}),null}function g(){d.useEffect(()=>{const e=window.setTimeout(()=>{b.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);f.s(()=>{window.clearTimeout(e)})},[])}const p={defaultCurrency:"EUR",queryModifications:e=>e};exports.StoreActionsListener=S;exports.defaultBaseConfig=p;exports.useCheckClientScript=g;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { b as
|
|
1
|
+
import { b as l, h as f } from "./useActions-CSNwQtT1.js";
|
|
2
2
|
import { u as c } from "./eventBusSubscribe-CzlS132j.js";
|
|
3
3
|
import { s as p } from "./index.es-XNBESE3P.js";
|
|
4
4
|
import { l as d } from "./logger-_fg_Za9y.js";
|
|
5
5
|
import { useEffect as m } from "preact/hooks";
|
|
6
6
|
function k() {
|
|
7
|
-
const { pageType: e } =
|
|
7
|
+
const { pageType: e } = l(), { newSearch: n, updateSearch: i, replaceFilter: a, toggleProductFilter: s } = f();
|
|
8
8
|
return c({
|
|
9
9
|
event: "actions/newSearch",
|
|
10
10
|
callback: ({ query: t, options: r, targetStore: o }) => {
|
|
11
|
-
e === o &&
|
|
11
|
+
e === o && n(t, r);
|
|
12
12
|
}
|
|
13
13
|
}), c({
|
|
14
14
|
event: "actions/updateSearch",
|
|
15
15
|
callback: ({ query: t, options: r, targetStore: o }) => {
|
|
16
|
-
e === o &&
|
|
16
|
+
e === o && i(t, r);
|
|
17
17
|
}
|
|
18
18
|
}), c({
|
|
19
19
|
event: "actions/replaceFilter",
|
|
@@ -22,21 +22,12 @@ function k() {
|
|
|
22
22
|
}
|
|
23
23
|
}), c({
|
|
24
24
|
event: "actions/toggleProductFilter",
|
|
25
|
-
callback: ({ field: t, value: r, active: o, targetStore:
|
|
26
|
-
e ===
|
|
27
|
-
}
|
|
28
|
-
}), c({
|
|
29
|
-
event: "events/removeAllFilters",
|
|
30
|
-
callback: () => {
|
|
31
|
-
n({
|
|
32
|
-
products: {
|
|
33
|
-
filter: []
|
|
34
|
-
}
|
|
35
|
-
});
|
|
25
|
+
callback: ({ field: t, value: r, active: o, targetStore: u }) => {
|
|
26
|
+
e === u && s(t, r, o);
|
|
36
27
|
}
|
|
37
28
|
}), null;
|
|
38
29
|
}
|
|
39
|
-
function
|
|
30
|
+
function v() {
|
|
40
31
|
m(() => {
|
|
41
32
|
const e = window.setTimeout(() => {
|
|
42
33
|
d.error("Nosto client script has not loaded after 3 seconds.");
|
|
@@ -53,5 +44,5 @@ const C = {
|
|
|
53
44
|
export {
|
|
54
45
|
k as S,
|
|
55
46
|
C as d,
|
|
56
|
-
|
|
47
|
+
v as u
|
|
57
48
|
};
|
|
@@ -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-CjNvOYZz.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-DMtA79nZ.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-2ZmajAxh.cjs");exports.CategoryPageProvider=e.CategoryPageProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-CKn3Ecpu.cjs"),g=require("../../isBot-Bs99-Wlv.cjs"),o=require("../../jsxRuntime.module-B3sGoTIU.cjs"),u=require("../../useLoadMore-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-CKn3Ecpu.cjs"),g=require("../../isBot-Bs99-Wlv.cjs"),o=require("../../jsxRuntime.module-B3sGoTIU.cjs"),u=require("../../useLoadMore-CBshMpps.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-LxLj-_bT.cjs"),C=require("preact"),e=require("../../useActions-CY9uts_o.cjs");function q({pageSize:t}){const{loadMore:r}=u.useLoadMore(t);return o.u("button",{onClick:r,children:"More results"})}function s({children:t,loadMoreComponent:r,pageSize:i}){const{loading:c,query:l,response:a}=u.useNostoAppState(f=>p.pick(f,"loading","query","response")),d=!c&&n.hasMoreResults(l,a);return o.u(C.Fragment,{children:[t,d&&(r?o.u(r,{pageSize:i}):o.u(q,{pageSize:i}))]})}const y=!g.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:s;exports.ErrorBoundary=S.ErrorBoundary;exports.StoreContext=e.StoreContext;exports.createExtendableStore=e.createExtendableStore;exports.createStore=e.createStore;exports.defaultState=e.defaultState;exports.useAutocompleteConfig=e.useAutocompleteConfig;exports.useCategoryConfig=e.useCategoryConfig;exports.useConfig=e.useConfig;exports.useSerpConfig=e.useSerpConfig;exports.InfiniteScroll=y;exports.InfiniteScrollWithLink=s;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { E as v } from "../../ErrorBoundary-DTRm_60r.js";
|
|
2
2
|
import { i as f } from "../../isBot-Dt3hQTa6.js";
|
|
3
3
|
import { u as e } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
4
|
-
import { u as p, a as c } from "../../useLoadMore-
|
|
4
|
+
import { u as p, a as c } from "../../useLoadMore-2OmOqicJ.js";
|
|
5
5
|
import { p as l } from "../../pick-DReBictn.js";
|
|
6
|
-
import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-
|
|
6
|
+
import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-B0iiezKy.js";
|
|
7
7
|
import { Fragment as g } from "preact";
|
|
8
|
-
import { S as B, g as O, c as W, f as F, a as N, d as R, b as j, e as w } from "../../useActions-
|
|
8
|
+
import { S as B, g as O, c as W, f as F, a as N, d as R, b as j, e as w } from "../../useActions-CSNwQtT1.js";
|
|
9
9
|
function C({ pageSize: r }) {
|
|
10
10
|
const { loadMore: o } = p(r);
|
|
11
11
|
return /* @__PURE__ */ e("button", { onClick: o, children: "More results" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("../../useActions-CY9uts_o.cjs"),P=require("../../logger-Boh_C6Bz.cjs"),h=require("../../useLoadMore-CBshMpps.cjs"),q=require("../../eventBusSubscribe-oONOUGH8.cjs"),d=require("preact/hooks"),L=require("../../useHistory-CJSGam5n.cjs"),T=require("../../index.es-Dp6Iaxz3.cjs"),z=require("../../eventBusDispatch-BKQcSHAB.cjs"),A=require("../../parseNumber-FsZ8w61u.cjs");function X(e){const s=h.useNostoAppState(t=>t.response);return e&&Array.isArray(e)||e&&P.isPlainObject(e)?e:s}function O(e,s){const t=e.data?.filter(f=>f.selected).length??0,{active:r}={active:t>0,...s},[n,c]=d.useState(r),{toggleProductFilter:u}=b.useActions(),l=d.useCallback(()=>{c(!n)},[n]);return q.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{c(!1)}}),{active:n,selectedFiltersCount:t,toggleActive:l,toggleProductFilter:u}}function j(){const{loading:e,facets:s}=h.useNostoAppState(t=>({loading:t.loading,facets:t.response?.products?.facets??[]}));return{loading:e,facets:s}}function E(e,s){const t=s-e;return!isNaN(t)&&t>0?new Array(s-e).fill(void 0).map((r,n)=>n+e):[]}function D(e){const{query:s,products:t}=h.useNostoAppState(r=>({query:r.query,products:r.response.products}));return d.useMemo(()=>{if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const r=s.products?.from??0,n=e?.width??1/0,c=Math.max(Math.floor(n-1)/2,1),u=t.size>0?Math.floor(r/t.size)+1:1,l=t.size>0?Math.ceil(t.total/t.size):0,f=F=>F>=u-c&&F<=u+c,o=r+1,i=Math.min(r+t.total,t.total),a={from:r,page:u,current:!0},p=F=>({from:(F-1)*t.size,page:F,current:F===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,y=E(1,l+1).filter(f).map(p);return!g&&y[0]?.page===2&&y.unshift(p(1)),!v&&y[y.length-1]?.page===l-1&&y.push(p(l)),{totalPages:l,resultsFrom:o,resultsTo:i,current:a,prev:S,next:m,first:g,last:v,pages:y}},[s,t,e?.width])}function B(){const[e,s]=d.useState([]),[t,r]=d.useState([]);return d.useEffect(()=>{T.s(async n=>{const{products:c,segments:u}=await n.getSearchSessionParams();s(u??[]),r(c?.personalizationBoost??[])})},[]),{segments:e,boost:t}}function V(){const{facets:e}=h.useNostoAppState(o=>({facets:o.response.products?.facets??[]})),{replaceFilter:s,toggleProductFilter:t}=b.useActions(),r=d.useCallback(o=>{const i=e?.find(a=>a.type==="stats"&&a.field===o);if(i&&"min"in i&&"max"in i)return i},[e]),n=d.useCallback(o=>e?.find(i=>i.field===o)?.name??o,[e]),c=d.useCallback(o=>"field"in o&&(o.value instanceof Array||o.range instanceof Array),[]),u=d.useCallback(o=>({...o,range:o.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(o=>(o.value??[]).map(a=>({value:a,field:o.field,name:n(o.field),filter:u(o),remove:()=>{t(o.field,a,!1)}})),[u,n,t]),f=d.useCallback(o=>(o.range??[]).map(a=>{const p=a.gte??a.gt??r(o.field)?.min,S=a.lte??a.lt??r(o.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:o.field,name:n(o.field),filter:u(o),remove:()=>{s(o.field,void 0)}}}).filter(Boolean),[u,r,n,s]);return{selectFilters:c,toValueFilter:l,toRangeFilter:f}}function C(){const{filter:e}=h.useNostoAppState(l=>({filter:l.query.products?.filter??[]})),{updateSearch:s}=b.useActions(),{selectFilters:t,toValueFilter:r,toRangeFilter:n}=V(),c=d.useMemo(()=>e?e.filter(t).flatMap(l=>"value"in l?r(l):"range"in l?n(l):[]).filter(Boolean):[],[e,t,n,r]),u=d.useCallback(()=>{s({products:{filter:[]}}),z.dispatchNostoEvent({event:"events/removeAllFilters",params:null})},[s]);return{filters:c,removeAll:u}}function R(e){const{replaceFilter:s}=b.useActions(),{query:t,products:r}=h.useNostoAppState(a=>({query:a.query,products:a.response.products})),n=r?.facets?.find(a=>a.id===e);if(!n)return{min:0,max:0,range:[0,0],updateRange:()=>{}};const c=t.products?.filter?.find(a=>a.field===n.field),u=c?.range?c.range[0]:void 0,l=typeof u=="object"&&("gte"in u||"lte"in u)?[A.parseNumber(u.gte),A.parseNumber(u.lte)]:[void 0,void 0],f="min"in n?Math.floor(n.min):0,o="max"in n?Math.ceil(n.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)&&(o===m||!v)?s(n.field,void 0):(f===S||!g)&&v?s(n.field,{lte:m.toString()}):(o===m||!v)&&g?s(n.field,{gte:S.toString()}):g&&v&&s(n.field,{gte:S.toString(),lte:m.toString()})};return{min:f,max:o,range:[l[0]??f,l[1]??o],updateRange:i}}function $(e,s){const{min:t,max:r,range:n,updateRange:c}=R(e),{filters:u}=C(),l=d.useMemo(()=>{const a=u.find(g=>g?.filter?.range);let p=null;if(a){const g=a.filter.range?.[0];p=[A.parseNumber(g?.gte),A.parseNumber(g?.lte)]}const S=[];let m=Math.floor(t/s)*s;for(;m<r;){const g=m+s,v=p&&p[0]===m&&p[1]===g;S.push({min:m,max:g,selected:v}),m=g}return S},[u,t,r,s]),f=a=>{c([a,n[1]])},o=a=>{c([n[0],a])},i=t!==n[0]||r!==n[1];return{min:t,max:r,range:n,updateRange:c,ranges:l,handleMinChange:f,handleMaxChange:o,isSelected:i}}function _(){const{products:e,keywords:s}=h.useNostoAppState(t=>t.response);return{products:e??{hits:[],total:0},keywords:s??{hits:[],total:0}}}function H(){const e=h.useNostoAppState(t=>t.query.products?.filter);return d.useMemo(()=>e?e.reduce((t,r)=>t+(Array.isArray(r.value)?r.value.length:1),0):0,[e])}const U=5*60*1e3,w=new Map;function I(e){const[s,t]=d.useState({product:null,loading:!0,error:null});return d.useEffect(()=>{if(!e){t({product:null,loading:!1,error:"Product handle is required"});return}t(n=>({...n,loading:!0,error:null}));const r=G(e);if(r){t({product:r,loading:!1,error:null});return}Z(e).then(n=>{J(e,n),t({product:n,loading:!1,error:null})}).catch(n=>{t({product:null,loading:!1,error:n.message||"Failed to fetch product"})})},[e]),s}async function Z(e){const s=await fetch(`/products/${e}.js`);if(!s.ok)throw new Error(`Failed to fetch product: ${s.status} ${s.statusText}`);return s.json()}function G(e){const s=w.get(e);return s?Date.now()-s.created>U?(w.delete(e),null):s.product:null}function J(e,s){w.set(e,{product:s,created:Date.now()})}function N(e){return e&&!Number.isNaN(e)?e:0}function K(e,s){const{from:t,size:r,total:n}=h.useNostoAppState(o=>({from:N(o.query.products?.from??0),size:N(o.response?.products?.size??s),total:N(o.response?.products?.total??0)})),{updateSearch:c}=b.useActions(),u=t+r,l=d.useMemo(()=>[...e].reverse().filter(o=>o<n),[e,n]),f=d.useCallback(o=>{c({products:{size:A.parseNumber(o)}})},[c]);return{from:t,to:u,total:n,size:r,sizeOptions:l,handleSizeChange:f}}function Q(e,s){return e.length!==s.length?!1:e.every(t=>s.find(r=>t.field===r.field&&t.order===r.order))}function W(e){const s=h.useNostoAppState(c=>c.query),{updateSearch:t}=b.useActions();return{activeSort:e.find(c=>Q(c.value.sort,s.products?.sort||[]))?.id??e[0]?.id,setSort:c=>{const u=e.find(l=>l.id===c);u&&t({products:{sort:u.value.sort}})}}}const M=window.SpeechRecognition||window.webkitSpeechRecognition,x=!!(M&&typeof M=="function");function Y(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function ee({language:e="en-US",interimResults:s=!1,onResult:t,onError:r}={}){const[n,c]=d.useState(!1),u=d.useRef(null),l=d.useCallback(()=>{const o=new M;o.lang=e,o.interimResults=s,o.onstart=()=>c(!0),t&&(o.onresult=i=>{const{transcript:a}=i.results?.[0]?.[0];t(a)}),r&&(o.onerror=i=>r(i.error)),o.onend=()=>c(!1),u.current=o,o.start()},[e,s,r,t]),f=d.useCallback(()=>{u.current?.stop()},[u]);return{listening:n,startListening:l,stopListening:f}}const te=x?ee:Y;function se(e,s){if(!e.length||!s.length)return[];const t=s.reduce((r,n)=>(r[n]={},r),{});return e.forEach(r=>{r.customFields?.forEach(({key:n,value:c})=>{const u=n.toLowerCase();s.includes(u)&&(t[u][c]=t[u][c]||[],t[u][c].push(r))})}),Object.entries(t).filter(r=>Object.keys(r[1]).length).map(([r,n])=>({field:r,options:Object.entries(n).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function ne(e,s){return e.length?e.map(({field:t,options:r})=>({field:t,options:r.map(n=>{const c=!n.skus?.some(l=>Object.entries(s).every(([f,o])=>f===t?!0:l.customFields?.find(a=>a.key.toLowerCase()===f)?.value===o)),u=s[t]===n.value;return{...n,unavailable:c,selected:u}})})):[]}const k=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function oe(e){if(k.includes(e))return 1e3+k.indexOf(e);const s=parseFloat(e);return isNaN(s)?e:s}function re(e,s){return[...s].sort((t,r)=>{const[n,c]=[t.value,r.value].map(oe);return n<c?-1:1})}function ue(e=[],s=[]){const[t,r]=d.useState({}),n=d.useMemo(()=>se(e,s).map(({field:o,options:i})=>({field:o,options:re(o,i)})),[e,s]),c=d.useMemo(()=>ne(n,t),[n,t]),u=d.useCallback((f,o)=>{r(i=>{const a={...i};return a[f]===o?delete a[f]:a[f]=o,a})},[]),l=d.useMemo(()=>Object.keys(t).filter(i=>t[i]).length===0?[]:c.filter(({field:i})=>t[i]).map(({field:i,options:a})=>{const p=t[i];return a.find(m=>m.value===p)?.skus??[]}).reduce((i,a)=>i.filter(p=>a.includes(p))),[c,t]);return{swatches:c,toggleOption:u,matchedSkus:l}}exports.useActions=b.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.useHistory=L.useHistory;exports.speechToTextSupported=x;exports.useDecoratedSearchResults=X;exports.useFacet=O;exports.useFacets=j;exports.usePagination=D;exports.usePersonalization=B;exports.useProductFilters=C;exports.useRange=R;exports.useRangeSelector=$;exports.useResponse=_;exports.useSelectedFiltersCount=H;exports.useShopifyProduct=I;exports.useSizeOptions=K;exports.useSort=W;exports.useSpeechToText=te;exports.useSwatches=ue;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { h as
|
|
1
|
+
import { h as x } from "../../useActions-CSNwQtT1.js";
|
|
2
2
|
import { a as T } from "../../logger-_fg_Za9y.js";
|
|
3
|
-
import { a as v } from "../../useLoadMore-
|
|
4
|
-
import { u as Fe } from "../../useLoadMore-
|
|
3
|
+
import { a as v } from "../../useLoadMore-2OmOqicJ.js";
|
|
4
|
+
import { u as Fe } from "../../useLoadMore-2OmOqicJ.js";
|
|
5
5
|
import { u as X } from "../../eventBusSubscribe-CzlS132j.js";
|
|
6
6
|
import { useState as b, useCallback as h, useMemo as y, useEffect as N, useRef as z } from "preact/hooks";
|
|
7
|
-
import { u as be } from "../../useHistory-
|
|
7
|
+
import { u as be } from "../../useHistory-DeIqqw-P.js";
|
|
8
8
|
import { s as k } from "../../index.es-XNBESE3P.js";
|
|
9
9
|
import { d as C } from "../../eventBusDispatch-DPR2Vwd4.js";
|
|
10
|
-
import { p as
|
|
10
|
+
import { p as R } from "../../parseNumber-QA48nJLp.js";
|
|
11
11
|
function se(e) {
|
|
12
12
|
const n = v((t) => t.response);
|
|
13
13
|
return e && Array.isArray(e) || e && T(e) ? e : n;
|
|
@@ -16,7 +16,7 @@ function ie(e, n) {
|
|
|
16
16
|
const t = e.data?.filter((d) => d.selected).length ?? 0, { active: s } = {
|
|
17
17
|
active: t > 0,
|
|
18
18
|
...n
|
|
19
|
-
}, [r, c] = b(s), { toggleProductFilter: i } =
|
|
19
|
+
}, [r, c] = b(s), { toggleProductFilter: i } = x(), l = h(() => {
|
|
20
20
|
c(!r);
|
|
21
21
|
}, [r]);
|
|
22
22
|
return X({
|
|
@@ -101,7 +101,7 @@ function ae() {
|
|
|
101
101
|
function q() {
|
|
102
102
|
const { facets: e } = v((o) => ({
|
|
103
103
|
facets: o.response.products?.facets ?? []
|
|
104
|
-
})), { replaceFilter: n, toggleProductFilter: t } =
|
|
104
|
+
})), { replaceFilter: n, toggleProductFilter: t } = x(), s = h(
|
|
105
105
|
(o) => {
|
|
106
106
|
const u = e?.find((a) => a.type === "stats" && a.field === o);
|
|
107
107
|
if (u && "min" in u && "max" in u)
|
|
@@ -153,23 +153,27 @@ function q() {
|
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
function j() {
|
|
156
|
-
const { filter: e } = v((
|
|
157
|
-
filter:
|
|
158
|
-
})), {
|
|
159
|
-
|
|
156
|
+
const { filter: e } = v((l) => ({
|
|
157
|
+
filter: l.query.products?.filter ?? []
|
|
158
|
+
})), { updateSearch: n } = x(), { selectFilters: t, toValueFilter: s, toRangeFilter: r } = q(), c = y(() => e ? e.filter(t).flatMap((l) => "value" in l ? s(l) : "range" in l ? r(l) : []).filter(Boolean) : [], [e, t, r, s]), i = h(() => {
|
|
159
|
+
n({
|
|
160
|
+
products: {
|
|
161
|
+
filter: []
|
|
162
|
+
}
|
|
163
|
+
}), C({
|
|
160
164
|
event: "events/removeAllFilters",
|
|
161
165
|
params: null
|
|
162
166
|
});
|
|
163
|
-
}, []);
|
|
167
|
+
}, [n]);
|
|
164
168
|
return {
|
|
165
169
|
/** Selected filters array. */
|
|
166
|
-
filters:
|
|
170
|
+
filters: c,
|
|
167
171
|
/** Should remove all selected filters. */
|
|
168
|
-
removeAll:
|
|
172
|
+
removeAll: i
|
|
169
173
|
};
|
|
170
174
|
}
|
|
171
175
|
function E(e) {
|
|
172
|
-
const { replaceFilter: n } =
|
|
176
|
+
const { replaceFilter: n } = x(), { query: t, products: s } = v((a) => ({
|
|
173
177
|
query: a.query,
|
|
174
178
|
products: a.response.products
|
|
175
179
|
})), r = s?.facets?.find((a) => a.id === e);
|
|
@@ -181,7 +185,7 @@ function E(e) {
|
|
|
181
185
|
updateRange: () => {
|
|
182
186
|
}
|
|
183
187
|
};
|
|
184
|
-
const c = t.products?.filter?.find((a) => a.field === r.field), i = c?.range ? c.range[0] : void 0, l = typeof i == "object" && ("gte" in i || "lte" in i) ? [
|
|
188
|
+
const c = t.products?.filter?.find((a) => a.field === r.field), i = c?.range ? c.range[0] : void 0, l = typeof i == "object" && ("gte" in i || "lte" in i) ? [R(i.gte), R(i.lte)] : [void 0, void 0], d = "min" in r ? Math.floor(r.min) : 0, o = "max" in r ? Math.ceil(r.max) : 0, u = ([a, f]) => {
|
|
185
189
|
const m = a !== void 0 ? Math.floor(a) : void 0, p = f !== void 0 ? Math.ceil(f) : void 0, g = m !== void 0, S = p !== void 0;
|
|
186
190
|
(d === m || !g) && (o === p || !S) ? n(r.field, void 0) : (d === m || !g) && S ? n(r.field, {
|
|
187
191
|
lte: p.toString()
|
|
@@ -209,7 +213,7 @@ function le(e, n) {
|
|
|
209
213
|
let f = null;
|
|
210
214
|
if (a) {
|
|
211
215
|
const g = a.filter.range?.[0];
|
|
212
|
-
f = [
|
|
216
|
+
f = [R(g?.gte), R(g?.lte)];
|
|
213
217
|
}
|
|
214
218
|
const m = [];
|
|
215
219
|
let p = Math.floor(t / n) * n;
|
|
@@ -328,11 +332,11 @@ function pe(e, n) {
|
|
|
328
332
|
from: L(o.query.products?.from ?? 0),
|
|
329
333
|
size: L(o.response?.products?.size ?? n),
|
|
330
334
|
total: L(o.response?.products?.total ?? 0)
|
|
331
|
-
})), { updateSearch: c } =
|
|
335
|
+
})), { updateSearch: c } = x(), i = t + s, l = y(() => [...e].reverse().filter((o) => o < r), [e, r]), d = h(
|
|
332
336
|
(o) => {
|
|
333
337
|
c({
|
|
334
338
|
products: {
|
|
335
|
-
size:
|
|
339
|
+
size: R(o)
|
|
336
340
|
}
|
|
337
341
|
});
|
|
338
342
|
},
|
|
@@ -357,7 +361,7 @@ function U(e, n) {
|
|
|
357
361
|
return e.length !== n.length ? !1 : e.every((t) => n.find((s) => t.field === s.field && t.order === s.order));
|
|
358
362
|
}
|
|
359
363
|
function me(e) {
|
|
360
|
-
const n = v((c) => c.query), { updateSearch: t } =
|
|
364
|
+
const n = v((c) => c.query), { updateSearch: t } = x();
|
|
361
365
|
return {
|
|
362
366
|
/** Active sort */
|
|
363
367
|
activeSort: e.find((c) => U(c.value.sort, n.products?.sort || []))?.id ?? e[0]?.id,
|
|
@@ -465,7 +469,7 @@ function ve(e = [], n = []) {
|
|
|
465
469
|
}
|
|
466
470
|
export {
|
|
467
471
|
_ as speechToTextSupported,
|
|
468
|
-
|
|
472
|
+
x as useActions,
|
|
469
473
|
se as useDecoratedSearchResults,
|
|
470
474
|
ie as useFacet,
|
|
471
475
|
ce as useFacets,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-CjNvOYZz.cjs"),T=require("../../CategoryPageProvider-2ZmajAxh.cjs"),h=require("../../useActions-CY9uts_o.cjs"),I=require("../../SerpPageProvider-Dn6PSZoF.cjs"),d=require("../../jsxRuntime.module-B3sGoTIU.cjs"),g=require("../../ErrorBoundary-CKn3Ecpu.cjs"),b=require("../../disableNativeAutocomplete-DI6zaZII.cjs"),P=require("../../unique-BXXNictB.cjs"),C=require("preact"),N=require("../../logger-Boh_C6Bz.cjs"),p=require("../../search-RNs4Cunh.cjs");function O(e){let n;return t=>{n&&clearTimeout(n),n=setTimeout(t,e)}}function q(e){return Array.from(document.querySelectorAll(e))}function R(e){const n=[];let t=e.parentNode;for(;t&&t!==document&&t instanceof Element;)n.push(t),t=t.parentNode;return n}function E([e,n],t){const o=r=>{const s=r.target;s instanceof HTMLElement&&e&&s!==e&&s!==n&&!R(s).includes(e)&&t()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function A(e,n){e.tabIndex=0,e.addEventListener("blur",n)}function S(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function H({selector:e,timeout:n=500}){return new Promise(t=>{const o=q(e);if(o.length>0)return t(o);const r=new MutationObserver(()=>{const i=q(e);i.length>0&&(r.disconnect(),clearTimeout(s),t(i))}),s=setTimeout(()=>{r.disconnect(),N.logger.warn(`Timed out (${n}) while waiting for element ${e}`),t([])},n);r.observe(document.body,{childList:!0,subtree:!0})})}function x(e,n,t){n.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=S(t),s=r&&document.querySelector(r.selector);if(s){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(n),r.position==="first"?s.prepend(a):s.appendChild(a)}else o.appendChild(n);const i={index:-1,onChangeListeners:[]},c=(a,u)=>{const f=a.length;f===0&&(u=-1),i.index=u>=0?u%f:f-1,i.onChangeListeners.forEach(D=>D())},l=()=>{i.index=-1,i.onChangeListeners.forEach(a=>a())},m=()=>i.index;return{element:n,hide:()=>{n.style.display="none",l()},show:()=>{n.style.display="inherit"},isOpen:()=>n.style.display!=="none",goDown:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u+1)},goUp:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u-1)},highlight:c,highlightedIndex:m,submitHighlightedItem:a=>{Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{i.onChangeListeners.push(a)}}}function $(e,n){const t=document.createElement("div");return t.className="nosto-autocomplete-dropdown",{...x(e,t,n),element:t}}const y="nosto:search-js:history";function v(e,n,t){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...x(e,o,n),element:o,add:s=>{const c=(p.getLocalStorageItem(y)??[]).filter(l=>l!==s).slice(t?-t:0);c.push(s),p.setLocalStorageItem(y,c)},get:()=>(p.getLocalStorageItem(y)??[]).reverse().filter(i=>!!i)}}async function F(e,{config:n,dropdown:t,history:o,renderHistory:r,store:s}){const{historyEnabled:i,minQueryLength:c}=n;if(e.length<c&&i&&r&&!o.isOpen()){o.show();return}if(e.length<c)return;t.hide();const l=s.getState()?.query?.query;l&&l!==e&&await h.newSearch({config:n,store:s},{query:e}),t.show()}async function k(e,n){const{config:t,renderHistory:o,history:r}=n,{historyEnabled:s,minQueryLength:i}=t;if(!o||e.length>=i||!s||r.isOpen())return;const c=j(n);r.onHighlightChange(()=>{c(o,r.element)}),r.show();const l=P.measure("renderHistory");c(o,r.element),l()}async function Q(e,{config:n,dropdown:t,history:o,store:r,debouncer:s}){const{minQueryLength:i,historyEnabled:c}=n;if(e.length<i&&!c){t.hide(),o.hide();return}if(e.length<i&&c){t.hide(),o.show();return}o.hide(),s(async()=>{h.newSearch({config:n,store:r},{query:e}),t.show()})}function M(e,n,t){const{config:o,debouncer:r}=t;if(r(()=>{}),e.length>=o.minQueryLength)return L(n,t.dropdown,t.history);if(o.historyEnabled)return L(n,t.history,t.dropdown)}function L(e,n,t){if(!n.isOpen()&&e==="ArrowDown"){n.show(),t.hide();return}if(e==="Escape"&&n.hide(),!!n.isOpen()){if(e==="ArrowDown")n.goDown();else if(e==="ArrowUp")n.goUp();else if(e==="Enter"){const o=n.highlightedIndex();return o>=0&&n.submitHighlightedItem(o),n.hide(),o>=0}}}function U(e,{config:n,dropdown:t,history:o,onNavigateToSearch:r,store:s}){t.hide(),o.hide(),!(e.length<n.minQueryLength)&&(o.add(e),s.updateState({historyItems:o.get()}),r?.({query:e}))}async function K(e,n){const{inputCssSelector:t,timeout:o}=e,r=S(t).selector,s=await H({selector:r,timeout:o});if(s.length===0)throw new Error(`No elements found for selector: ${r}`);s.forEach(i=>{_(i,e,n)})}async function _(e,n,t){const{config:o,dropdownCssSelector:r}=n,s=$(e,r),i=v(e,r,o.historySize),c={...n,input:e,dropdown:s,history:i,store:t,debouncer:O(o.debounceDelay)};G(c),e.setAttribute("data-nosto-element","search-input"),t.updateState({historyItems:i.get()}),b.disableNativeAutocomplete(e),t.onInit(()=>{z(c)}),b.bindInput(e,{onInput:l=>Q(l,c),onFocus:l=>k(l,c),onClick:l=>F(l,c),onSubmit:l=>U(l,c),onKeyDown:(l,m)=>M(l,m,c)}),A(i.element,i.hide),A(s.element,s.hide),E([i.element,e],i.hide),E([s.element,e],s.hide)}function z(e){const{dropdown:n,renderAutocomplete:t}=e;if(!t)return;const o=j(e);n.onHighlightChange(()=>{o(t,n.element)});const r=P.measure("renderAutocomplete");o(t,n.element),r()}async function G(e){const{input:n,renderSpeechToText:t,config:o,store:r}=e;if(!t)return;const s="ns-autocomplete-voice-position";if(!!n.parentElement?.querySelector(`.${s}`))return;const c=document.createElement("div");c.className=s,n.insertAdjacentElement("afterend",c);const l=await t();C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:o,store:r,children:l})}),c)}function j(e){const{config:n,store:t}=e;return(o,r)=>C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:n,store:t,children:o()})}),r)}async function B({cssSelector:e,timeout:n,renderComponent:t}){const o=S(e).selector,r=await H({selector:o,timeout:n??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&N.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),C.render(t(),r[0])}async function J(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(T.CategoryPageProvider,{store:n,config:e.config,children:o})})})}async function V(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(I.SearchPageProvider,{store:n,config:e.config,children:o})})})}async function W({autocomplete:e,category:n,serp:t}){const o={};if(e){const r=h.createStore({query:e.query});await K({...e,config:w.makeAutocompleteConfig(e.config)},r),o.autocomplete={store:r}}if(n){const r=h.createStore({query:n.query});await J({...n,config:T.makeCategoryConfig(n.config)},r),o.category={store:r}}if(t){const r=h.createStore({query:t.query});await V({...t,config:I.makeSerpConfig(t.config)},r),o.serp={store:r}}return o}exports.init=W;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as L, m as j } from "../../AutocompletePageProvider-
|
|
2
|
-
import { C as O, m as R } from "../../CategoryPageProvider-
|
|
3
|
-
import { n as T, c as p } from "../../useActions-
|
|
4
|
-
import { S as $, m as F } from "../../SerpPageProvider-
|
|
1
|
+
import { A as L, m as j } from "../../AutocompletePageProvider-DMtA79nZ.js";
|
|
2
|
+
import { C as O, m as R } from "../../CategoryPageProvider-DU3DjmnJ.js";
|
|
3
|
+
import { n as T, c as p } from "../../useActions-CSNwQtT1.js";
|
|
4
|
+
import { S as $, m as F } from "../../SerpPageProvider-DshgTNpM.js";
|
|
5
5
|
import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
6
6
|
import { E as h } from "../../ErrorBoundary-DTRm_60r.js";
|
|
7
7
|
import { d as k, b as B } from "../../disableNativeAutocomplete-Bkta_WR2.js";
|
|
@@ -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-CY9uts_o.cjs"),r=require("../../InfiniteScrollWithObserver-LxLj-_bT.cjs"),t=require("../../useLoadMore-CBshMpps.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-CSNwQtT1.js";
|
|
2
|
+
import { I as s, i } from "../../InfiniteScrollWithObserver-B0iiezKy.js";
|
|
3
|
+
import { g as p } from "../../useLoadMore-2OmOqicJ.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-CY9uts_o.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-Dn6PSZoF.cjs"),P="nosto:search-js: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 { b as p } from "../../useActions-
|
|
4
|
+
import { b as p } from "../../useActions-CSNwQtT1.js";
|
|
5
5
|
import { useCallback as f } from "preact/hooks";
|
|
6
|
-
import { S as h } from "../../SerpPageProvider-
|
|
6
|
+
import { S as h } from "../../SerpPageProvider-DshgTNpM.js";
|
|
7
7
|
const S = "nosto:search-js:scrollPos";
|
|
8
8
|
function g() {
|
|
9
9
|
window.sessionStorage.setItem(S, window.scrollY.toString());
|
|
@@ -30,45 +30,45 @@ function X() {
|
|
|
30
30
|
}
|
|
31
31
|
function Q(e, r = {}) {
|
|
32
32
|
const t = /* @__PURE__ */ new Map();
|
|
33
|
-
let
|
|
34
|
-
const
|
|
35
|
-
function c(
|
|
36
|
-
|
|
37
|
-
for (const
|
|
38
|
-
|
|
33
|
+
let a = w(e, r ?? {});
|
|
34
|
+
const s = w(e, r);
|
|
35
|
+
function c(u) {
|
|
36
|
+
a = u(a);
|
|
37
|
+
for (const l of t.values())
|
|
38
|
+
l(a);
|
|
39
39
|
}
|
|
40
|
-
function n(
|
|
41
|
-
c((
|
|
40
|
+
function n(u) {
|
|
41
|
+
c((l) => ({ ...l, ...u }));
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
return
|
|
43
|
+
function i() {
|
|
44
|
+
return a;
|
|
45
45
|
}
|
|
46
46
|
function o() {
|
|
47
|
-
return structuredClone(
|
|
47
|
+
return structuredClone(s);
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
let C;
|
|
51
|
-
t.set(
|
|
52
|
-
const y =
|
|
53
|
-
b(y, C) || (C = y,
|
|
49
|
+
function g(u, l) {
|
|
50
|
+
let C = u(a);
|
|
51
|
+
t.set(l, (T) => {
|
|
52
|
+
const y = u(T);
|
|
53
|
+
b(y, C) || (C = y, l(y));
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
|
-
function P(
|
|
57
|
-
|
|
58
|
-
(
|
|
59
|
-
(
|
|
60
|
-
|
|
56
|
+
function P(u) {
|
|
57
|
+
g(
|
|
58
|
+
(l) => l.initialized,
|
|
59
|
+
(l) => {
|
|
60
|
+
l && u();
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
|
-
function F(
|
|
65
|
-
t.delete(
|
|
64
|
+
function F(u) {
|
|
65
|
+
t.delete(u);
|
|
66
66
|
}
|
|
67
67
|
return {
|
|
68
68
|
updateState: n,
|
|
69
|
-
getState:
|
|
69
|
+
getState: i,
|
|
70
70
|
getInitialState: o,
|
|
71
|
-
onChange:
|
|
71
|
+
onChange: g,
|
|
72
72
|
onInit: P,
|
|
73
73
|
clearOnChange: F
|
|
74
74
|
};
|
|
@@ -157,14 +157,14 @@ const D = [
|
|
|
157
157
|
"tags3"
|
|
158
158
|
], L = ["keyword", "_redirect"];
|
|
159
159
|
async function v(e, r, t) {
|
|
160
|
-
const
|
|
160
|
+
const a = f("newSearch"), s = e.config.pageType, c = s === "search" ? "serp" : s, n = h(e.store.getInitialState().query, r), i = h(e.config.search, t, {
|
|
161
161
|
track: c,
|
|
162
|
-
redirect:
|
|
162
|
+
redirect: s !== "autocomplete",
|
|
163
163
|
isKeyword: !!t?.isKeyword,
|
|
164
164
|
usePersistentCache: e.config.pageType !== "autocomplete" && e.config.persistentSearchCache,
|
|
165
165
|
useMemoryCache: e.config.pageType === "autocomplete" && e.config.memoryCache
|
|
166
166
|
});
|
|
167
|
-
e.config.onBeforeSearch?.(e,
|
|
167
|
+
e.config.onBeforeSearch?.(e, i), e.store.updateState({
|
|
168
168
|
query: n,
|
|
169
169
|
loading: !0,
|
|
170
170
|
initialized: !0
|
|
@@ -178,44 +178,44 @@ async function v(e, r, t) {
|
|
|
178
178
|
filter: E(e.store.getInitialState().query?.products?.filter, r.products?.filter)
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
|
-
|
|
181
|
+
s
|
|
182
182
|
);
|
|
183
183
|
try {
|
|
184
|
-
const
|
|
184
|
+
const g = await U(B(e.config.pageType, o), i);
|
|
185
185
|
e.store.updateState({
|
|
186
|
-
response:
|
|
186
|
+
response: g,
|
|
187
187
|
loading: !1
|
|
188
188
|
});
|
|
189
|
-
} catch (
|
|
190
|
-
A.error("Search action failed",
|
|
189
|
+
} catch (g) {
|
|
190
|
+
A.error("Search action failed", g), e.config.onSearchError?.(g, o, i, s);
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
a();
|
|
193
193
|
}
|
|
194
194
|
async function m(e, r, t) {
|
|
195
|
-
const
|
|
196
|
-
await v(e,
|
|
195
|
+
const a = f("updateSearch"), s = h(e.store.getState().query, { products: { from: 0 } }, r);
|
|
196
|
+
await v(e, s, t), a();
|
|
197
197
|
}
|
|
198
198
|
async function O(e, r, t) {
|
|
199
|
-
const
|
|
199
|
+
const a = f("replaceFilter"), s = e.store.getState().query.products?.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
200
200
|
await m(e, {
|
|
201
201
|
products: {
|
|
202
|
-
filter: [...
|
|
202
|
+
filter: [...s?.filter((n) => n.field !== r) ?? [], ...c]
|
|
203
203
|
}
|
|
204
|
-
}),
|
|
204
|
+
}), a();
|
|
205
205
|
}
|
|
206
|
-
async function V(e, r, t,
|
|
207
|
-
const
|
|
206
|
+
async function V(e, r, t, a) {
|
|
207
|
+
const s = f("toggleProductFilter"), c = e.store.getState().query.products?.filter, n = c?.find((o) => o.value instanceof Array && o.field === r), i = n?.value ? {
|
|
208
208
|
...n,
|
|
209
|
-
value: [...n.value.filter((o) => !b(o, t)), ...
|
|
210
|
-
} :
|
|
209
|
+
value: [...n.value.filter((o) => !b(o, t)), ...a ? [t] : []]
|
|
210
|
+
} : a ? {
|
|
211
211
|
field: r,
|
|
212
212
|
value: [t]
|
|
213
213
|
} : void 0;
|
|
214
214
|
await m(e, {
|
|
215
215
|
products: {
|
|
216
|
-
filter: [...c?.filter((o) => o !== n) ?? [], ...
|
|
216
|
+
filter: [...c?.filter((o) => o !== n) ?? [], ...i?.value?.length ? [i] : []]
|
|
217
217
|
}
|
|
218
|
-
}),
|
|
218
|
+
}), s();
|
|
219
219
|
}
|
|
220
220
|
function Y() {
|
|
221
221
|
const e = p(), r = k(N), t = I(
|
|
@@ -224,22 +224,22 @@ function Y() {
|
|
|
224
224
|
store: r
|
|
225
225
|
}),
|
|
226
226
|
[e, r]
|
|
227
|
-
),
|
|
228
|
-
(
|
|
227
|
+
), a = d(
|
|
228
|
+
(i, o) => v(t, i, o),
|
|
229
229
|
[t]
|
|
230
|
-
),
|
|
231
|
-
(
|
|
230
|
+
), s = d(
|
|
231
|
+
(i, o) => m(t, i, o),
|
|
232
232
|
[t]
|
|
233
233
|
), c = d(
|
|
234
|
-
(
|
|
234
|
+
(i, o, g) => V(t, i, o, g),
|
|
235
235
|
[t]
|
|
236
236
|
), n = d(
|
|
237
|
-
(
|
|
237
|
+
(i, o) => O(t, i, o),
|
|
238
238
|
[t]
|
|
239
239
|
);
|
|
240
240
|
return {
|
|
241
|
-
newSearch:
|
|
242
|
-
updateSearch:
|
|
241
|
+
newSearch: a,
|
|
242
|
+
updateSearch: s,
|
|
243
243
|
toggleProductFilter: c,
|
|
244
244
|
replaceFilter: n
|
|
245
245
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const w=require("preact"),f=require("preact/hooks"),u=require("./unique-BXXNictB.cjs"),C=require("./logger-Boh_C6Bz.cjs"),E=require("./search-RNs4Cunh.cjs"),k=w.createContext(null);function p(){const e=f.useContext(k);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function A(){const e=p();if(e.pageType!=="search")throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");return e}function I(){const e=p();if(e.pageType!=="category")throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");return e}function U(){const e=p();if(e.pageType!=="autocomplete")throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");return e}function b(e,r={}){const t=new Map;let n=u.deepMergePlain(e,r??{});const a=u.deepMergePlain(e,r);function c(l){n=l(n);for(const g of t.values())g(n)}function s(l){c(g=>({...g,...l}))}function i(){return n}function o(){return structuredClone(a)}function d(l,g){let m=l(n);t.set(g,M=>{const y=l(M);C.isEqual(y,m)||(m=y,g(y))})}function T(l){d(g=>g.initialized,g=>{g&&l()})}function q(l){t.delete(l)}return{updateState:s,getState:i,getInitialState:o,onChange:d,onInit:T,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function P(e={}){return b(v,e)}const F=w.createContext(P());function Q(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:z,...r.products},...r.keywords?{keywords:{...r.keywords,fields:u.unique([...K,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const z=["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"],K=["keyword","_redirect"];async function S(e,r,t){const n=u.measure("newSearch"),a=e.config.pageType,c=a==="search"?"serp":a,s=u.deepMerge(e.store.getInitialState().query,r),i=u.deepMerge(e.config.search,t,{track:c,redirect:a!=="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:s,loading:!0,initialized:!0});const o=e.config.queryModifications({...s,products:{...s.products,filter:u.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},a);try{const d=await E.search(Q(e.config.pageType,o),i);e.store.updateState({response:d,loading:!1})}catch(d){C.logger.error("Search action failed",d),e.config.onSearchError?.(d,o,i,a)}n()}async function h(e,r,t){const n=u.measure("updateSearch"),a=u.deepMerge(e.store.getState().query,{products:{from:0}},r);await S(e,a,t),n()}async function N(e,r,t){const n=u.measure("replaceFilter"),a=e.store.getState().query.products?.filter,c=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await h(e,{products:{filter:[...a?.filter(s=>s.field!==r)??[],...c]}}),n()}async function x(e,r,t,n){const a=u.measure("toggleProductFilter"),c=e.store.getState().query.products?.filter,s=c?.find(o=>o.value instanceof Array&&o.field===r),i=s?.value?{...s,value:[...s.value.filter(o=>!C.isEqual(o,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await h(e,{products:{filter:[...c?.filter(o=>o!==s)??[],...i?.value?.length?[i]:[]]}}),a()}function B(){const e=p(),r=f.useContext(F),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((i,o)=>S(t,i,o),[t]),a=f.useCallback((i,o)=>h(t,i,o),[t]),c=f.useCallback((i,o,d)=>x(t,i,o,d),[t]),s=f.useCallback((i,o)=>N(t,i,o),[t]);return{newSearch:n,updateSearch:a,toggleProductFilter:c,replaceFilter:s}}exports.ConfigContext=k;exports.StoreContext=F;exports.createExtendableStore=b;exports.createStore=P;exports.defaultState=v;exports.newSearch=S;exports.updateSearch=h;exports.useActions=B;exports.useAutocompleteConfig=U;exports.useCategoryConfig=I;exports.useConfig=p;exports.useSerpConfig=A;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-
|
|
1
|
+
"use strict";const n=require("./useActions-CY9uts_o.cjs"),o=require("./search-RNs4Cunh.cjs"),a=require("preact/hooks"),s="nosto:search-js:history";function l(){return(o.getLocalStorageItem(s)??[]).slice().reverse().filter(e=>!!e)}function y(){const{updateState:t}=a.useContext(n.StoreContext),{historySize:e}=n.useAutocompleteConfig();return{addQuery:a.useCallback(r=>{const i=(o.getLocalStorageItem(s)??[]).filter(u=>u!==r).concat(r),c=e?i.slice(-e):[];o.setLocalStorageItem(s,c),t({historyItems:c.reverse()})},[e,t])}}exports.getSaved=l;exports.useHistory=y;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as i, a as l } from "./useActions-
|
|
1
|
+
import { S as i, a as l } from "./useActions-CSNwQtT1.js";
|
|
2
2
|
import { g as a, a as m } from "./search-mArZ2PXy.js";
|
|
3
3
|
import { useContext as u, useCallback as y } from "preact/hooks";
|
|
4
4
|
const o = "nosto:search-js:history";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as n, h as u } from "./useActions-
|
|
1
|
+
import { S as n, h as u } from "./useActions-CSNwQtT1.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-Dt3hQTa6.js";
|
|
4
4
|
function l(t = p) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-
|
|
1
|
+
"use strict";const n=require("./useActions-CY9uts_o.cjs"),r=require("preact/hooks"),i=require("./isBot-Bs99-Wlv.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 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./useActions-Drtoxcu4.cjs"),c=require("./eventBusSubscribe-oONOUGH8.cjs"),b=require("./index.es-Dp6Iaxz3.cjs"),f=require("./logger-Boh_C6Bz.cjs"),d=require("preact/hooks");function S(){const{pageType:e}=i.useConfig(),{newSearch:u,updateSearch:n,replaceFilter:o,toggleProductFilter:l}=i.useActions();return c.useEventBusSubscribe({event:"actions/newSearch",callback:({query:t,options:r,targetStore:s})=>{e===s&&u(t,r)}}),c.useEventBusSubscribe({event:"actions/updateSearch",callback:({query:t,options:r,targetStore:s})=>{e===s&&n(t,r)}}),c.useEventBusSubscribe({event:"actions/replaceFilter",callback:({field:t,value:r,targetStore:s})=>{e===s&&o(t,r)}}),c.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:({field:t,value:r,active:s,targetStore:a})=>{e===a&&l(t,r,s)}}),c.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{n({products:{filter:[]}})}}),null}function v(){d.useEffect(()=>{const e=window.setTimeout(()=>{f.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);b.s(()=>{window.clearTimeout(e)})},[])}const g={defaultCurrency:"EUR",queryModifications:e=>e};exports.StoreActionsListener=S;exports.defaultBaseConfig=g;exports.useCheckClientScript=v;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const w=require("preact"),f=require("preact/hooks"),c=require("./unique-BXXNictB.cjs"),C=require("./logger-Boh_C6Bz.cjs"),E=require("./search-RNs4Cunh.cjs"),k=w.createContext(null);function p(){const e=f.useContext(k);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function A(){const e=p();if(e.pageType!=="search")throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");return e}function I(){const e=p();if(e.pageType!=="category")throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");return e}function U(){const e=p();if(e.pageType!=="autocomplete")throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");return e}function b(e,r={}){const t=new Map;let i=c.deepMergePlain(e,r??{});const a=c.deepMergePlain(e,r);function u(d){i=d(i);for(const l of t.values())l(i)}function s(d){u(l=>({...l,...d}))}function n(){return i}function o(){return structuredClone(a)}function g(d,l){let m;t.set(l,M=>{const y=d(M);C.isEqual(y,m)||(m=y,l(y))})}function T(d){g(l=>l.initialized,l=>{l&&d()})}function q(d){t.delete(d)}return{updateState:s,getState:n,getInitialState:o,onChange:g,onInit:T,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function P(e={}){return b(v,e)}const F=w.createContext(P());function Q(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:z,...r.products},...r.keywords?{keywords:{...r.keywords,fields:c.unique([...K,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const z=["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"],K=["keyword","_redirect"];async function S(e,r,t){const i=c.measure("newSearch"),a=e.config.pageType,u=a==="search"?"serp":a,s=c.deepMerge(e.store.getInitialState().query,r),n=c.deepMerge(e.config.search,t,{track:u,redirect:a!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,n),e.store.updateState({query:s,loading:!0,initialized:!0});const o=e.config.queryModifications({...s,products:{...s.products,filter:c.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},a);try{const g=await E.search(Q(e.config.pageType,o),n);e.store.updateState({response:g,loading:!1})}catch(g){C.logger.error("Search action failed",g),e.config.onSearchError?.(g,o,n,a)}i()}async function h(e,r,t){const i=c.measure("updateSearch"),a=c.deepMerge(e.store.getState().query,{products:{from:0}},r);await S(e,a,t),i()}async function N(e,r,t){const i=c.measure("replaceFilter"),a=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await h(e,{products:{filter:[...a?.filter(s=>s.field!==r)??[],...u]}}),i()}async function x(e,r,t,i){const a=c.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,s=u?.find(o=>o.value instanceof Array&&o.field===r),n=s?.value?{...s,value:[...s.value.filter(o=>!C.isEqual(o,t)),...i?[t]:[]]}:i?{field:r,value:[t]}:void 0;await h(e,{products:{filter:[...u?.filter(o=>o!==s)??[],...n?.value?.length?[n]:[]]}}),a()}function B(){const e=p(),r=f.useContext(F),t=f.useMemo(()=>({config:e,store:r}),[e,r]),i=f.useCallback((n,o)=>S(t,n,o),[t]),a=f.useCallback((n,o)=>h(t,n,o),[t]),u=f.useCallback((n,o,g)=>x(t,n,o,g),[t]),s=f.useCallback((n,o)=>N(t,n,o),[t]);return{newSearch:i,updateSearch:a,toggleProductFilter:u,replaceFilter:s}}exports.ConfigContext=k;exports.StoreContext=F;exports.createExtendableStore=b;exports.createStore=P;exports.defaultState=v;exports.newSearch=S;exports.updateSearch=h;exports.useActions=B;exports.useAutocompleteConfig=U;exports.useCategoryConfig=I;exports.useConfig=p;exports.useSerpConfig=A;
|