@nosto/search-js 3.6.0 → 3.8.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-BoV4iLil.js → AutocompletePageProvider-B5fknz_F.js} +1 -1
- package/dist/{AutocompletePageProvider-DPTHPXyz.cjs → AutocompletePageProvider-yFydWINa.cjs} +1 -1
- package/dist/BaseElement-CIHACCWd.cjs +1 -0
- package/dist/BaseElement-DD_4UwDm.js +24 -0
- package/dist/{CategoryPageProvider-CkeR1heA.cjs → CategoryPageProvider-Cv2clyeT.cjs} +1 -1
- package/dist/{CategoryPageProvider-Dzcbnz1W.js → CategoryPageProvider-aGaznOx0.js} +1 -1
- package/dist/{SerpPageProvider-CCPCHjKU.cjs → SerpPageProvider-1jG3MP2M.cjs} +1 -1
- package/dist/{SerpPageProvider-Ca6ZoAOq.js → SerpPageProvider-UgSIPtNb.js} +1 -1
- package/dist/{baseConfig-CvAG6x_p.js → baseConfig-CvJ08LBP.js} +1 -1
- package/dist/{baseConfig-0GdMC5Qa.cjs → baseConfig-dsYHpa9W.cjs} +1 -1
- package/dist/cl-B00bZ7jc.cjs +1 -0
- package/dist/cl-CcykAxZN.js +6 -0
- package/dist/eventBusSubscribe-CzlS132j.js +26 -0
- package/dist/eventBusSubscribe-oONOUGH8.cjs +1 -0
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +18 -17
- package/dist/preact/category/category.cjs.js +1 -1
- package/dist/preact/category/category.es.js +1 -1
- package/dist/preact/events/events.cjs.js +1 -1
- package/dist/preact/events/events.es.js +14 -14
- package/dist/preact/events/src/eventBusDispatch.d.ts +3 -3
- package/dist/preact/events/src/eventBusSubscribe.d.ts +2 -2
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +85 -85
- package/dist/preact/inject/src/init.d.ts +1 -1
- package/dist/preact/serp/serp.cjs.js +1 -1
- package/dist/preact/serp/serp.es.js +2 -2
- package/dist/utils/src/cl.d.ts +15 -0
- package/dist/utils/src/deepFreeze.d.ts +1 -1
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.es.js +17 -15
- package/package.json +1 -1
- package/dist/BaseElement-DgwqyaY8.cjs +0 -1
- package/dist/BaseElement-iXMoOyxY.js +0 -23
- package/dist/eventBusSubscribe-B75y7otR.cjs +0 -1
- package/dist/eventBusSubscribe-Cxw0xUAm.js +0 -25
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
2
|
import { c as n, S as i, C as u } from "./useActions-Cd7V2qfb.js";
|
|
3
|
-
import { d as c, u as s, S as l } from "./baseConfig-
|
|
3
|
+
import { d as c, u as s, S as l } from "./baseConfig-CvJ08LBP.js";
|
|
4
4
|
const m = {
|
|
5
5
|
...c,
|
|
6
6
|
memoryCache: !1,
|
package/dist/{AutocompletePageProvider-DPTHPXyz.cjs → AutocompletePageProvider-yFydWINa.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),o=require("./useActions-yB4RkNMW.cjs"),n=require("./baseConfig-
|
|
1
|
+
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),o=require("./useActions-yB4RkNMW.cjs"),n=require("./baseConfig-dsYHpa9W.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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),m=require("./cl-B00bZ7jc.cjs"),C=require("preact/hooks");function k({onClick:a,as:c,children:l,componentProps:s,className:n}){const e={...s,onClick:C.useCallback(i=>{a(),s?.onClick?.(i)},[a,s])},t=m.cl("className"in e&&e.className,n),u=c??(s&&"href"in s?"a":"span");return r.u(u,{...e,className:t,children:l})}exports.BaseElement=k;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { u as f } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
+
import { c as n } from "./cl-CcykAxZN.js";
|
|
3
|
+
import { useCallback as o } from "preact/hooks";
|
|
4
|
+
function k({
|
|
5
|
+
onClick: l,
|
|
6
|
+
as: c,
|
|
7
|
+
children: m,
|
|
8
|
+
componentProps: a,
|
|
9
|
+
className: e
|
|
10
|
+
}) {
|
|
11
|
+
const s = {
|
|
12
|
+
...a,
|
|
13
|
+
onClick: o(
|
|
14
|
+
(t) => {
|
|
15
|
+
l(), a?.onClick?.(t);
|
|
16
|
+
},
|
|
17
|
+
[l, a]
|
|
18
|
+
)
|
|
19
|
+
}, i = n("className" in s && s.className, e), r = c ?? (a && "href" in a ? "a" : "span");
|
|
20
|
+
return /* @__PURE__ */ f(r, { ...s, className: i, children: m });
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
k as B
|
|
24
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-yB4RkNMW.cjs"),o=require("./baseConfig-
|
|
1
|
+
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-yB4RkNMW.cjs"),o=require("./baseConfig-dsYHpa9W.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
2
|
import { c as n, S as s, C as i } from "./useActions-Cd7V2qfb.js";
|
|
3
|
-
import { d as c, u as C, S as f } from "./baseConfig-
|
|
3
|
+
import { d as c, u as C, S as f } from "./baseConfig-CvJ08LBP.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...c,
|
|
6
6
|
persistentSearchCache: !1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-yB4RkNMW.cjs"),n=require("./baseConfig-
|
|
1
|
+
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-yB4RkNMW.cjs"),n=require("./baseConfig-dsYHpa9W.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
2
|
import { c as n, S as s, C as c } from "./useActions-Cd7V2qfb.js";
|
|
3
|
-
import { d as i, u as f, S } from "./baseConfig-
|
|
3
|
+
import { d as i, u as f, S } from "./baseConfig-CvJ08LBP.js";
|
|
4
4
|
const l = {
|
|
5
5
|
...i,
|
|
6
6
|
persistentSearchCache: !1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as i, e as n } from "./useActions-Cd7V2qfb.js";
|
|
2
|
-
import { u as r } from "./eventBusSubscribe-
|
|
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";
|
|
5
5
|
import { useEffect as l } from "preact/hooks";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./useActions-yB4RkNMW.cjs"),r=require("./eventBusSubscribe-
|
|
1
|
+
"use strict";const i=require("./useActions-yB4RkNMW.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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function t(...n){return n.filter(Boolean).join(" ")}exports.cl=t;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useCallback as r, useEffect as i } from "preact/hooks";
|
|
2
|
+
function c({ event: s, callback: n }) {
|
|
3
|
+
const e = (o) => {
|
|
4
|
+
const t = o.detail;
|
|
5
|
+
n(t);
|
|
6
|
+
};
|
|
7
|
+
return window.addEventListener(`@nosto/search-js/${s}`, e), () => {
|
|
8
|
+
window.removeEventListener(`@nosto/search-js/${s}`, e);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function u({ event: s, callback: n }) {
|
|
12
|
+
const e = r(
|
|
13
|
+
(o) => {
|
|
14
|
+
const t = o.detail;
|
|
15
|
+
n(t);
|
|
16
|
+
},
|
|
17
|
+
[n]
|
|
18
|
+
);
|
|
19
|
+
i(() => (window.addEventListener(`@nosto/search-js/${s}`, e), () => {
|
|
20
|
+
window.removeEventListener(`@nosto/search-js/${s}`, e);
|
|
21
|
+
}), [s, e]);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
c as s,
|
|
25
|
+
u
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const r=require("preact/hooks");function i({event:s,callback:n}){const e=o=>{const t=o.detail;n(t)};return window.addEventListener(`@nosto/search-js/${s}`,e),()=>{window.removeEventListener(`@nosto/search-js/${s}`,e)}}function c({event:s,callback:n}){const e=r.useCallback(o=>{const t=o.detail;n(t)},[n]);r.useEffect(()=>(window.addEventListener(`@nosto/search-js/${s}`,e),()=>{window.removeEventListener(`@nosto/search-js/${s}`,e)}),[s,e])}exports.subscribeToNostoEvent=i;exports.useEventBusSubscribe=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-yFydWINa.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,44 +1,45 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as g } from "../../AutocompletePageProvider-B5fknz_F.js";
|
|
2
2
|
import { u as m } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
3
3
|
import { s } from "../../index.es-XNBESE3P.js";
|
|
4
|
-
import { B as a } from "../../BaseElement-
|
|
4
|
+
import { B as a } from "../../BaseElement-DD_4UwDm.js";
|
|
5
5
|
import { useCallback as l } from "preact/hooks";
|
|
6
|
-
|
|
6
|
+
import { c as u } from "../../cl-CcykAxZN.js";
|
|
7
|
+
function y({
|
|
7
8
|
children: o,
|
|
8
9
|
hit: e,
|
|
9
10
|
as: t,
|
|
10
|
-
componentProps:
|
|
11
|
+
componentProps: r
|
|
11
12
|
}) {
|
|
12
|
-
const
|
|
13
|
+
const n = l(() => {
|
|
13
14
|
e && "productId" in e && s((c) => c.recordSearchClick("autocomplete", e));
|
|
14
15
|
}, [e]);
|
|
15
|
-
return /* @__PURE__ */ m(a, { onClick:
|
|
16
|
+
return /* @__PURE__ */ m(a, { onClick: n, as: t, componentProps: r, className: "ns-autocomplete-element", children: o });
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function E({ children: o, class: e, onSubmit: t }) {
|
|
18
19
|
return /* @__PURE__ */ m(
|
|
19
20
|
"div",
|
|
20
21
|
{
|
|
21
|
-
className:
|
|
22
|
+
className: u("ns-autocomplete-element", e),
|
|
22
23
|
onClick: t,
|
|
23
|
-
onKeyDown: (
|
|
24
|
-
|
|
24
|
+
onKeyDown: (r) => {
|
|
25
|
+
r.key === "Enter" && t();
|
|
25
26
|
},
|
|
26
27
|
children: o
|
|
27
28
|
}
|
|
28
29
|
);
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
const
|
|
31
|
+
function A({ as: o, componentProps: e, onSearchInput: t, children: r }) {
|
|
32
|
+
const n = {
|
|
32
33
|
...e,
|
|
33
34
|
onInput: (p) => {
|
|
34
35
|
t(p.target);
|
|
35
36
|
}
|
|
36
37
|
}, c = o ?? "input";
|
|
37
|
-
return o || (
|
|
38
|
+
return o || (n.type = "search"), /* @__PURE__ */ m(c, { ...n, children: r });
|
|
38
39
|
}
|
|
39
40
|
export {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
y as AutocompleteElement,
|
|
42
|
+
g as AutocompletePageProvider,
|
|
43
|
+
E as HistoryElement,
|
|
44
|
+
A as SearchInput
|
|
44
45
|
};
|
|
@@ -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-Cv2clyeT.cjs");exports.CategoryPageProvider=e.CategoryPageProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("preact/hooks"),t=require("../../eventBusSubscribe-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("preact/hooks"),t=require("../../eventBusSubscribe-oONOUGH8.cjs");function o({event:e,params:s}){window.dispatchEvent(new CustomEvent(`@nosto/search-js/${e}`,{detail:s}))}function n({event:e}){return u.useCallback(s=>{o({event:e,params:s})},[e])}exports.subscribeToNostoEvent=t.subscribeToNostoEvent;exports.useEventBusSubscribe=t.useEventBusSubscribe;exports.dispatchNostoEvent=o;exports.useEventBusDispatch=n;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { useCallback as o } from "preact/hooks";
|
|
2
|
-
import { s as
|
|
3
|
-
|
|
4
|
-
event: s,
|
|
5
|
-
params: t
|
|
6
|
-
}) => {
|
|
2
|
+
import { s as a, u as c } from "../../eventBusSubscribe-CzlS132j.js";
|
|
3
|
+
function e({ event: s, params: t }) {
|
|
7
4
|
window.dispatchEvent(
|
|
8
5
|
new CustomEvent(`@nosto/search-js/${s}`, {
|
|
9
6
|
detail: t
|
|
10
7
|
})
|
|
11
8
|
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
}
|
|
10
|
+
function u({ event: s }) {
|
|
11
|
+
return o(
|
|
12
|
+
(t) => {
|
|
13
|
+
e({ event: s, params: t });
|
|
14
|
+
},
|
|
15
|
+
[s]
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
18
|
export {
|
|
19
19
|
e as dispatchNostoEvent,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
a as subscribeToNostoEvent,
|
|
21
|
+
u as useEventBusDispatch,
|
|
22
|
+
c as useEventBusSubscribe
|
|
23
23
|
};
|
|
@@ -2,9 +2,9 @@ import { AllowedEvents, EventParams } from './types';
|
|
|
2
2
|
type Props<T extends AllowedEvents> = {
|
|
3
3
|
event: T;
|
|
4
4
|
};
|
|
5
|
-
export declare
|
|
5
|
+
export declare function dispatchNostoEvent<T extends AllowedEvents>({ event, params }: {
|
|
6
6
|
event: T;
|
|
7
7
|
params: EventParams[T];
|
|
8
|
-
})
|
|
9
|
-
export declare
|
|
8
|
+
}): void;
|
|
9
|
+
export declare function useEventBusDispatch<T extends AllowedEvents>({ event }: Props<T>): (params: EventParams[T]) => void;
|
|
10
10
|
export {};
|
|
@@ -3,6 +3,6 @@ type Props<T extends AllowedEvents> = {
|
|
|
3
3
|
event: T;
|
|
4
4
|
callback: (params: EventParams[T]) => void;
|
|
5
5
|
};
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
6
|
+
export declare function subscribeToNostoEvent<T extends AllowedEvents>({ event, callback }: Props<T>): () => void;
|
|
7
|
+
export declare function useEventBusSubscribe<T extends AllowedEvents>({ event, callback }: Props<T>): void;
|
|
8
8
|
export {};
|
|
@@ -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-yFydWINa.cjs"),L=require("../../CategoryPageProvider-Cv2clyeT.cjs"),m=require("../../useActions-yB4RkNMW.cjs"),x=require("../../SerpPageProvider-1jG3MP2M.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),A=require("../../bindInput-BnKvCky1.cjs"),P=require("../../unique-BXXNictB.cjs"),g=require("preact"),b=require("../../logger-Boh_C6Bz.cjs"),O=require("preact/hooks"),B=require("../../index.es-Dp6Iaxz3.cjs"),y=require("../../search-DTqo1D6Y.cjs");function F(e){let t;return n=>{t&&clearTimeout(t),t=setTimeout(n,e)}}function f({children:e}){const[t]=O.useErrorBoundary();return t&&b.logger.error("Error caught in ErrorBoundary",t),u.u(g.Fragment,{children:e})}function w(e,t){return(typeof e=="string"?Array.from(document.querySelectorAll(e)):[e]).filter(o=>!0)}function H(e,t){let n=[];return w(e).forEach(o=>{const r=o.parentNode;r!==document&&r instanceof Element&&(n.push(r),n=n.concat(H(r)))}),n.filter(o=>t===void 0)}function I([e,t],n){const o=r=>{const i=r.target;i instanceof HTMLElement&&e&&i!==e&&i!==t&&!H(i).includes(e)&&n()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function T(e,t){e.tabIndex=0,e.addEventListener("blur",t)}function E(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function N({selector:e,timeout:t=500}){return new Promise(n=>{const o=w(e);if(o.length>0)return n(o);const r=new MutationObserver(()=>{const s=w(e);s.length>0&&(r.disconnect(),clearTimeout(i),n(s))}),i=setTimeout(()=>{r.disconnect(),b.logger.warn(`Timed out (${t}) while waiting for element ${e}`),n([])},t);r.observe(document.body,{childList:!0,subtree:!0})})}const k=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&&B.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 v(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=E(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(D=>D())},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",{...v(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",{...v(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 q(t,n.dropdown,n.history);if(o.historyEnabled)return q(t,n.history,n.dropdown)}function q(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=E(n).selector,i=await N({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:F(o.debounceDelay)};X(l),e.setAttribute("data-nosto-element","search-input"),n.updateState({historyItems:s.get()}),A.disableNativeAutocomplete(e),n.onInit(()=>{W(l)}),A.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)}),T(s.element,s.hide),T(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(S.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(S.AutocompletePageProvider,{config:n,store:o,children:u.u(k,{value:r,children:i()})})}),s)}async function j({cssSelector:e,timeout:t,renderComponent:n}){const o=E(e).selector,r=await N({selector:o,timeout:t??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&b.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(L.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:S.makeAutocompleteConfig(e.config)},m.createStore({query:e.query})),t&&await Y({...t,config:L.makeCategoryConfig(t.config)},m.createStore()),n&&await Z({...n,config:x.makeSerpConfig(n.config)},m.createStore())}exports.AutocompleteContext=k;exports.init=ee;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A as T, m as R } from "../../AutocompletePageProvider-
|
|
2
|
-
import { C as B, m as F } from "../../CategoryPageProvider-
|
|
3
|
-
import { n as L, c as
|
|
4
|
-
import { S as O, m as $ } from "../../SerpPageProvider-
|
|
1
|
+
import { A as T, m as R } from "../../AutocompletePageProvider-B5fknz_F.js";
|
|
2
|
+
import { C as B, m as F } from "../../CategoryPageProvider-aGaznOx0.js";
|
|
3
|
+
import { n as L, c as g } from "../../useActions-Cd7V2qfb.js";
|
|
4
|
+
import { S as O, m as $ } from "../../SerpPageProvider-UgSIPtNb.js";
|
|
5
5
|
import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
6
6
|
import { d as j, b as v } 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 C } from "preact";
|
|
9
|
+
import { l as w } from "../../logger-_fg_Za9y.js";
|
|
10
10
|
import { useErrorBoundary as U } from "preact/hooks";
|
|
11
11
|
import { s as M } from "../../index.es-XNBESE3P.js";
|
|
12
12
|
import { g as b, a as z } from "../../search-sC5QgJmw.js";
|
|
@@ -16,9 +16,9 @@ function G(e) {
|
|
|
16
16
|
t && clearTimeout(t), t = setTimeout(n, e);
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function u({ children: e }) {
|
|
20
20
|
const [t] = U();
|
|
21
|
-
return t &&
|
|
21
|
+
return t && w.error("Error caught in ErrorBoundary", t), /* @__PURE__ */ d(K, { children: e });
|
|
22
22
|
}
|
|
23
23
|
function y(e, t) {
|
|
24
24
|
return (typeof e == "string" ? Array.from(document.querySelectorAll(e)) : [e]).filter((o) => !0);
|
|
@@ -32,8 +32,8 @@ function H(e, t) {
|
|
|
32
32
|
}
|
|
33
33
|
function E([e, t], n) {
|
|
34
34
|
const o = (r) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const i = r.target;
|
|
36
|
+
i instanceof HTMLElement && e && i !== e && i !== t && !H(i).includes(e) && n();
|
|
37
37
|
};
|
|
38
38
|
return document.addEventListener("click", o), {
|
|
39
39
|
destroy: () => {
|
|
@@ -59,10 +59,10 @@ function N({ selector: e, timeout: t = 500 }) {
|
|
|
59
59
|
if (o.length > 0)
|
|
60
60
|
return n(o);
|
|
61
61
|
const r = new MutationObserver(() => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
r.disconnect(),
|
|
62
|
+
const s = y(e);
|
|
63
|
+
s.length > 0 && (r.disconnect(), clearTimeout(i), n(s));
|
|
64
|
+
}), i = setTimeout(() => {
|
|
65
|
+
r.disconnect(), w.warn(`Timed out (${t}) while waiting for element ${e}`), n([]);
|
|
66
66
|
}, t);
|
|
67
67
|
r.observe(document.body, {
|
|
68
68
|
childList: !0,
|
|
@@ -80,10 +80,10 @@ const J = Q({
|
|
|
80
80
|
highlightedElementIndex: -1
|
|
81
81
|
});
|
|
82
82
|
function V(e, t) {
|
|
83
|
-
const { dropdown: n, history: o, store: r, input:
|
|
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
|
-
}),
|
|
86
|
+
}), h && M((l) => l.recordSearchSubmit(c)), i.value = c);
|
|
87
87
|
};
|
|
88
88
|
return {
|
|
89
89
|
reportProductClick: (c) => {
|
|
@@ -93,7 +93,7 @@ function V(e, t) {
|
|
|
93
93
|
a(c.keyword, !0);
|
|
94
94
|
},
|
|
95
95
|
handleSubmit: (c) => {
|
|
96
|
-
a(c.query, !1),
|
|
96
|
+
a(c.query, !1), s?.(c);
|
|
97
97
|
},
|
|
98
98
|
highlightedElementIndex: t.highlightedIndex()
|
|
99
99
|
};
|
|
@@ -105,21 +105,21 @@ function k(e, t, n) {
|
|
|
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 = S(n),
|
|
109
|
-
if (
|
|
108
|
+
})(), r = S(n), i = r && document.querySelector(r.selector);
|
|
109
|
+
if (i) {
|
|
110
110
|
const l = document.createElement("form");
|
|
111
|
-
l.className = "nosto-dropdown-form", l.appendChild(t), r.position === "first" ?
|
|
111
|
+
l.className = "nosto-dropdown-form", l.appendChild(t), r.position === "first" ? i.prepend(l) : i.appendChild(l);
|
|
112
112
|
} else
|
|
113
113
|
o.appendChild(t);
|
|
114
|
-
const
|
|
114
|
+
const s = {
|
|
115
115
|
index: -1,
|
|
116
116
|
onChangeListeners: []
|
|
117
117
|
}, a = (l, m) => {
|
|
118
|
-
const
|
|
119
|
-
|
|
118
|
+
const f = l.length;
|
|
119
|
+
f === 0 && (m = -1), s.index = m >= 0 ? m % f : f - 1, s.onChangeListeners.forEach((D) => D());
|
|
120
120
|
}, c = () => {
|
|
121
|
-
|
|
122
|
-
},
|
|
121
|
+
s.index = -1, s.onChangeListeners.forEach((l) => l());
|
|
122
|
+
}, h = () => s.index;
|
|
123
123
|
return {
|
|
124
124
|
element: t,
|
|
125
125
|
hide: () => {
|
|
@@ -130,20 +130,20 @@ function k(e, t, n) {
|
|
|
130
130
|
},
|
|
131
131
|
isOpen: () => t.style.display !== "none",
|
|
132
132
|
goDown: () => {
|
|
133
|
-
const l = Array.from(t.getElementsByClassName("ns-autocomplete-element")), m =
|
|
133
|
+
const l = Array.from(t.getElementsByClassName("ns-autocomplete-element")), m = h();
|
|
134
134
|
a(l, m + 1);
|
|
135
135
|
},
|
|
136
136
|
goUp: () => {
|
|
137
|
-
const l = Array.from(t.getElementsByClassName("ns-autocomplete-element")), m =
|
|
137
|
+
const l = Array.from(t.getElementsByClassName("ns-autocomplete-element")), m = h();
|
|
138
138
|
a(l, m - 1);
|
|
139
139
|
},
|
|
140
140
|
highlight: a,
|
|
141
|
-
highlightedIndex:
|
|
141
|
+
highlightedIndex: h,
|
|
142
142
|
submitHighlightedItem: (l) => {
|
|
143
143
|
Array.from(t.querySelectorAll(".ns-autocomplete-element"))[l]?.click();
|
|
144
144
|
},
|
|
145
145
|
onHighlightChange: (l) => {
|
|
146
|
-
|
|
146
|
+
s.onChangeListeners.push(l);
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
}
|
|
@@ -154,34 +154,34 @@ function W(e, t) {
|
|
|
154
154
|
element: n
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
const
|
|
157
|
+
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
|
...k(e, o, t),
|
|
162
162
|
element: o,
|
|
163
|
-
add: (
|
|
164
|
-
const a = (b(
|
|
165
|
-
a.push(
|
|
163
|
+
add: (i) => {
|
|
164
|
+
const a = (b(p) ?? []).filter((c) => c !== i).slice(n ? -n : 0);
|
|
165
|
+
a.push(i), z(p, a);
|
|
166
166
|
},
|
|
167
|
-
get: () => (b(
|
|
167
|
+
get: () => (b(p) ?? []).reverse().filter((s) => !!s)
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
|
-
async function Y(e, { config: t, dropdown: n, history: o, renderHistory: r, store:
|
|
171
|
-
const { historyEnabled:
|
|
172
|
-
if (e.length < a &&
|
|
170
|
+
async function Y(e, { config: t, dropdown: n, history: o, renderHistory: r, store: i }) {
|
|
171
|
+
const { historyEnabled: s, minQueryLength: a } = t;
|
|
172
|
+
if (e.length < a && s && r && !o.isOpen()) {
|
|
173
173
|
o.show();
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
176
|
if (e.length < a)
|
|
177
177
|
return;
|
|
178
178
|
n.hide();
|
|
179
|
-
const c =
|
|
180
|
-
c && c !== e && await L({ config: t, store:
|
|
179
|
+
const c = i.getState()?.query?.query;
|
|
180
|
+
c && c !== e && await L({ config: t, store: i }, { query: e }), n.show();
|
|
181
181
|
}
|
|
182
182
|
async function Z(e, t) {
|
|
183
|
-
const { config: n, renderHistory: o, history: r } = t, { historyEnabled:
|
|
184
|
-
if (!o || e.length >=
|
|
183
|
+
const { config: n, renderHistory: o, history: r } = t, { historyEnabled: i, minQueryLength: s } = n;
|
|
184
|
+
if (!o || e.length >= s || !i || r.isOpen())
|
|
185
185
|
return;
|
|
186
186
|
const a = P(t, r);
|
|
187
187
|
r.onHighlightChange(() => {
|
|
@@ -190,17 +190,17 @@ async function Z(e, t) {
|
|
|
190
190
|
const c = x("renderHistory");
|
|
191
191
|
a(o, r.element), c();
|
|
192
192
|
}
|
|
193
|
-
async function _(e, { config: t, dropdown: n, history: o, store: r, debouncer:
|
|
194
|
-
const { minQueryLength:
|
|
195
|
-
if (e.length <
|
|
193
|
+
async function _(e, { config: t, dropdown: n, history: o, store: r, debouncer: i }) {
|
|
194
|
+
const { minQueryLength: s, historyEnabled: a } = t;
|
|
195
|
+
if (e.length < s && !a) {
|
|
196
196
|
n.hide(), o.hide();
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
|
-
if (e.length <
|
|
199
|
+
if (e.length < s && a) {
|
|
200
200
|
n.hide(), o.show();
|
|
201
201
|
return;
|
|
202
202
|
}
|
|
203
|
-
o.hide(),
|
|
203
|
+
o.hide(), i(async () => {
|
|
204
204
|
L({ config: t, store: r }, { query: e }), n.show();
|
|
205
205
|
});
|
|
206
206
|
}
|
|
@@ -228,35 +228,35 @@ function I(e, t, n) {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
function te(e, { config: t, dropdown: n, history: o, onNavigateToSearch: r, store:
|
|
232
|
-
n.hide(), o.hide(), !(e.length < t.minQueryLength) && (o.add(e),
|
|
231
|
+
function te(e, { config: t, dropdown: n, history: o, onNavigateToSearch: r, store: i }) {
|
|
232
|
+
n.hide(), o.hide(), !(e.length < t.minQueryLength) && (o.add(e), i.updateState({
|
|
233
233
|
historyItems: o.get()
|
|
234
234
|
}), r?.({
|
|
235
235
|
query: e
|
|
236
236
|
}));
|
|
237
237
|
}
|
|
238
238
|
async function ne(e, t) {
|
|
239
|
-
const { inputCssSelector: n, timeout: o } = e, r = S(n).selector,
|
|
239
|
+
const { inputCssSelector: n, timeout: o } = e, r = S(n).selector, i = await N({
|
|
240
240
|
selector: r,
|
|
241
241
|
timeout: o
|
|
242
242
|
});
|
|
243
|
-
if (
|
|
243
|
+
if (i.length === 0)
|
|
244
244
|
throw new Error(`No elements found for selector: ${r}`);
|
|
245
|
-
|
|
246
|
-
oe(
|
|
245
|
+
i.forEach((s) => {
|
|
246
|
+
oe(s, e, t);
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
249
|
async function oe(e, t, n) {
|
|
250
|
-
const { config: o, dropdownCssSelector: r } = t,
|
|
250
|
+
const { config: o, dropdownCssSelector: r } = t, i = W(e, r), s = X(e, r, o.historySize), a = {
|
|
251
251
|
...t,
|
|
252
252
|
input: e,
|
|
253
|
-
dropdown:
|
|
254
|
-
history:
|
|
253
|
+
dropdown: i,
|
|
254
|
+
history: s,
|
|
255
255
|
store: n,
|
|
256
256
|
debouncer: G(o.debounceDelay)
|
|
257
257
|
};
|
|
258
|
-
|
|
259
|
-
historyItems:
|
|
258
|
+
ie(a), e.setAttribute("data-nosto-element", "search-input"), n.updateState({
|
|
259
|
+
historyItems: s.get()
|
|
260
260
|
}), j(e), n.onInit(() => {
|
|
261
261
|
re(a);
|
|
262
262
|
}), v(e, {
|
|
@@ -264,8 +264,8 @@ async function oe(e, t, n) {
|
|
|
264
264
|
onFocus: (c) => Z(c, a),
|
|
265
265
|
onClick: (c) => Y(c, a),
|
|
266
266
|
onSubmit: (c) => te(c, a),
|
|
267
|
-
onKeyDown: (c,
|
|
268
|
-
}), A(
|
|
267
|
+
onKeyDown: (c, h) => ee(c, h, a)
|
|
268
|
+
}), A(s.element, s.hide), A(i.element, i.hide), E([s.element, e], s.hide), E([i.element, e], i.hide);
|
|
269
269
|
}
|
|
270
270
|
function re(e) {
|
|
271
271
|
const { dropdown: t, renderAutocomplete: n } = e;
|
|
@@ -278,16 +278,16 @@ function re(e) {
|
|
|
278
278
|
const r = x("renderAutocomplete");
|
|
279
279
|
o(n, t.element), r();
|
|
280
280
|
}
|
|
281
|
-
async function
|
|
281
|
+
async function ie(e) {
|
|
282
282
|
const { input: t, renderSpeechToText: n, config: o, store: r } = e;
|
|
283
283
|
if (!n) return;
|
|
284
|
-
const
|
|
285
|
-
if (!!t.parentElement?.querySelector(`.${
|
|
284
|
+
const i = "ns-autocomplete-voice-position";
|
|
285
|
+
if (!!t.parentElement?.querySelector(`.${i}`)) return;
|
|
286
286
|
const a = document.createElement("div");
|
|
287
|
-
a.className =
|
|
287
|
+
a.className = i, t.insertAdjacentElement("afterend", a);
|
|
288
288
|
const c = await n();
|
|
289
|
-
|
|
290
|
-
/* @__PURE__ */ d(
|
|
289
|
+
C(
|
|
290
|
+
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(T, { config: o, store: r, children: c }) }),
|
|
291
291
|
a
|
|
292
292
|
);
|
|
293
293
|
}
|
|
@@ -295,9 +295,9 @@ function P(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
|
-
}), (
|
|
299
|
-
/* @__PURE__ */ d(
|
|
300
|
-
|
|
298
|
+
}), (i, s) => C(
|
|
299
|
+
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(T, { config: n, store: o, children: /* @__PURE__ */ d(J, { value: r, children: i() }) }) }),
|
|
300
|
+
s
|
|
301
301
|
);
|
|
302
302
|
}
|
|
303
303
|
async function q({ cssSelector: e, timeout: t, renderComponent: n }) {
|
|
@@ -307,41 +307,41 @@ async function q({ cssSelector: e, timeout: t, renderComponent: n }) {
|
|
|
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 && w.warn(`Multiple (${r.length}) elements found for selector: ${o}`), C(n(), r[0]);
|
|
311
311
|
}
|
|
312
|
-
async function
|
|
312
|
+
async function se(e, t) {
|
|
313
313
|
const { render: n } = e, o = await n();
|
|
314
314
|
q({
|
|
315
315
|
...e,
|
|
316
|
-
renderComponent: () => /* @__PURE__ */ d(
|
|
316
|
+
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(B, { 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
|
q({
|
|
322
322
|
...e,
|
|
323
|
-
renderComponent: () => /* @__PURE__ */ d(
|
|
323
|
+
renderComponent: () => /* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(O, { store: t, config: e.config, children: o }) })
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
|
-
async function Se(e) {
|
|
327
|
-
e
|
|
326
|
+
async function Se({ autocomplete: e, category: t, serp: n }) {
|
|
327
|
+
e && await ne(
|
|
328
328
|
{
|
|
329
|
-
...e
|
|
330
|
-
config: R(e.
|
|
329
|
+
...e,
|
|
330
|
+
config: R(e.config)
|
|
331
331
|
},
|
|
332
|
-
|
|
333
|
-
),
|
|
332
|
+
g({ query: e.query })
|
|
333
|
+
), t && await se(
|
|
334
334
|
{
|
|
335
|
-
...
|
|
336
|
-
config: F(
|
|
335
|
+
...t,
|
|
336
|
+
config: F(t.config)
|
|
337
337
|
},
|
|
338
|
-
|
|
339
|
-
),
|
|
338
|
+
g()
|
|
339
|
+
), n && await ce(
|
|
340
340
|
{
|
|
341
|
-
...
|
|
342
|
-
config: $(
|
|
341
|
+
...n,
|
|
342
|
+
config: $(n.config)
|
|
343
343
|
},
|
|
344
|
-
|
|
344
|
+
g()
|
|
345
345
|
);
|
|
346
346
|
}
|
|
347
347
|
export {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { InitConfig } from './config';
|
|
2
|
-
export declare function init(
|
|
2
|
+
export declare function init({ autocomplete, category, serp }: InitConfig): Promise<void>;
|
|
@@ -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-
|
|
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-yB4RkNMW.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-1jG3MP2M.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
|
-
import { B as m } from "../../BaseElement-
|
|
3
|
+
import { B as m } from "../../BaseElement-DD_4UwDm.js";
|
|
4
4
|
import { a as p } from "../../useActions-Cd7V2qfb.js";
|
|
5
5
|
import { useCallback as f } from "preact/hooks";
|
|
6
|
-
import { S as x } from "../../SerpPageProvider-
|
|
6
|
+
import { S as x } from "../../SerpPageProvider-UgSIPtNb.js";
|
|
7
7
|
const S = "nosto:search:scrollPos";
|
|
8
8
|
function g() {
|
|
9
9
|
window.sessionStorage.setItem(S, window.scrollY.toString());
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to join class names by filtering out falsy values and joining with spaces.
|
|
3
|
+
*
|
|
4
|
+
* @param classes - Class names to join (can include strings, undefined, null, false, etc.)
|
|
5
|
+
* @returns Joined class names as a string
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* cl("base", "active") // "base active"
|
|
10
|
+
* cl("base", undefined, "active") // "base active"
|
|
11
|
+
* cl("base", false && "conditional") // "base"
|
|
12
|
+
* cl("base", condition && "active") // "base" or "base active"
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function cl(...classes: unknown[]): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Equals, Expect } from './types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function deepFreeze<T extends object>(obj: T): Readonly<Freeze<T>>;
|
|
3
3
|
type Freeze<T> = T extends object ? Readonly<{
|
|
4
4
|
[K in keyof T]: Freeze<T[K]>;
|
|
5
5
|
}> : T;
|
package/dist/utils/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../bindInput-BnKvCky1.cjs"),e=require("../unique-BXXNictB.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../bindInput-BnKvCky1.cjs"),u=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),t=require("../isBot-iyBlT_oq.cjs"),r=require("../logger-Boh_C6Bz.cjs"),s=require("../parseNumber-FsZ8w61u.cjs"),o=require("../pick-rYi1lc2m.cjs");exports.bindInput=i.bindInput;exports.disableNativeAutocomplete=i.disableNativeAutocomplete;exports.cl=u.cl;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=t.isBot;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.logger=r.logger;exports.parseNumber=s.parseNumber;exports.pick=o.pick;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @module utils */
|
|
2
2
|
export { type BindElementOptions, bindInput, disableNativeAutocomplete, type InputBindingCallbacks } from './src/bindInput';
|
|
3
|
+
export { cl } from './src/cl';
|
|
3
4
|
export { deepMerge, type Merge, type PlainMerge } from './src/deepMerge';
|
|
4
5
|
export { isBot } from './src/isBot';
|
|
5
6
|
export { isEqual } from './src/isEqual';
|
package/dist/utils/utils.es.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { b as r, d as s } from "../bindInput-CCx0Fhsg.js";
|
|
2
|
-
import {
|
|
3
|
-
import { i as f } from "../
|
|
4
|
-
import { i as x
|
|
5
|
-
import {
|
|
6
|
-
import { p as q } from "../
|
|
2
|
+
import { c as p } from "../cl-CcykAxZN.js";
|
|
3
|
+
import { d as m, a as i, m as u, u as f } from "../unique-Cv2g464w.js";
|
|
4
|
+
import { i as x } from "../isBot-Lnmft0Z0.js";
|
|
5
|
+
import { i as c, a as d, l as g } from "../logger-_fg_Za9y.js";
|
|
6
|
+
import { p as q } from "../parseNumber-QA48nJLp.js";
|
|
7
|
+
import { p as N } from "../pick-DReBictn.js";
|
|
7
8
|
export {
|
|
8
9
|
r as bindInput,
|
|
9
|
-
p as
|
|
10
|
+
p as cl,
|
|
11
|
+
m as deepMerge,
|
|
10
12
|
s as disableNativeAutocomplete,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
x as isBot,
|
|
14
|
+
c as isEqual,
|
|
15
|
+
d as isPlainObject,
|
|
16
|
+
g as logger,
|
|
17
|
+
i as measure,
|
|
18
|
+
u as mergeArrays,
|
|
19
|
+
q as parseNumber,
|
|
20
|
+
N as pick,
|
|
21
|
+
f as unique
|
|
20
22
|
};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),m=require("preact/hooks");function C({onClick:a,as:n,children:t,componentProps:s,className:l}){const e={...s,onClick:m.useCallback(i=>{a(),s?.onClick?.(i)},[a,s])},u="className"in e?e.className+" "+l:l,c=n??(s&&"href"in s?"a":"span");return r.u(c,{...e,className:u,children:t})}exports.BaseElement=C;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { u as r } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { useCallback as f } from "preact/hooks";
|
|
3
|
-
function k({
|
|
4
|
-
onClick: l,
|
|
5
|
-
as: i,
|
|
6
|
-
children: t,
|
|
7
|
-
componentProps: a,
|
|
8
|
-
className: e
|
|
9
|
-
}) {
|
|
10
|
-
const s = {
|
|
11
|
-
...a,
|
|
12
|
-
onClick: f(
|
|
13
|
-
(n) => {
|
|
14
|
-
l(), a?.onClick?.(n);
|
|
15
|
-
},
|
|
16
|
-
[l, a]
|
|
17
|
-
)
|
|
18
|
-
}, c = "className" in s ? s.className + " " + e : e, m = i ?? (a && "href" in a ? "a" : "span");
|
|
19
|
-
return /* @__PURE__ */ r(m, { ...s, className: c, children: t });
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
k as B
|
|
23
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("preact/hooks"),c=({event:s,callback:o})=>{const e=t=>{const n=t.detail;o(n)};return window.addEventListener(`@nosto/search-js/${s}`,e),()=>{window.removeEventListener(`@nosto/search-js/${s}`,e)}},i=({event:s,callback:o})=>{const e=r.useCallback(t=>{const n=t.detail;o(n)},[o]);r.useEffect(()=>(window.addEventListener(`@nosto/search-js/${s}`,e),()=>{window.removeEventListener(`@nosto/search-js/${s}`,e)}),[s,e])};exports.subscribeToNostoEvent=c;exports.useEventBusSubscribe=i;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useCallback as r, useEffect as a } from "preact/hooks";
|
|
2
|
-
const c = ({ event: s, callback: o }) => {
|
|
3
|
-
const e = (n) => {
|
|
4
|
-
const t = n.detail;
|
|
5
|
-
o(t);
|
|
6
|
-
};
|
|
7
|
-
return window.addEventListener(`@nosto/search-js/${s}`, e), () => {
|
|
8
|
-
window.removeEventListener(`@nosto/search-js/${s}`, e);
|
|
9
|
-
};
|
|
10
|
-
}, d = ({ event: s, callback: o }) => {
|
|
11
|
-
const e = r(
|
|
12
|
-
(n) => {
|
|
13
|
-
const t = n.detail;
|
|
14
|
-
o(t);
|
|
15
|
-
},
|
|
16
|
-
[o]
|
|
17
|
-
);
|
|
18
|
-
a(() => (window.addEventListener(`@nosto/search-js/${s}`, e), () => {
|
|
19
|
-
window.removeEventListener(`@nosto/search-js/${s}`, e);
|
|
20
|
-
}), [s, e]);
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
c as s,
|
|
24
|
-
d as u
|
|
25
|
-
};
|