@nosto/search-js 3.14.0 → 3.15.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-BJxsORbo.cjs +1 -0
- package/dist/AutocompletePageProvider-DI2PONk8.js +37 -0
- package/dist/{CategoryPageProvider-Clj40F3F.cjs → CategoryPageProvider-CYRnaUx1.cjs} +1 -1
- package/dist/{CategoryPageProvider-Bou8i9Tx.js → CategoryPageProvider-DcQlylFg.js} +2 -2
- package/dist/{InfiniteScrollWithObserver-CoPOQr8Q.cjs → InfiniteScrollWithObserver-BN-pDinB.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-6A57AOKr.js → InfiniteScrollWithObserver-CEtMyahq.js} +1 -1
- package/dist/{SerpPageProvider-B-W6nCqu.js → SerpPageProvider-CsrFA6mA.js} +2 -2
- package/dist/{SerpPageProvider-pR-E8S6m.cjs → SerpPageProvider-s4dO49Fx.cjs} +1 -1
- package/dist/baseConfig-BMc1698x.js +48 -0
- package/dist/baseConfig-gkfFlBOL.cjs +1 -0
- package/dist/core/core.cjs.js +1 -1
- package/dist/core/core.es.js +1 -1
- package/dist/{bindInput-CCx0Fhsg.js → disableNativeAutocomplete-Bkta_WR2.js} +6 -6
- package/dist/disableNativeAutocomplete-DI6zaZII.cjs +1 -0
- 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.d.ts +1 -0
- package/dist/preact/hooks/hooks.es.js +14 -12
- package/dist/preact/hooks/src/useHistory.d.ts +5 -0
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.d.ts +0 -1
- package/dist/preact/inject/inject.es.js +183 -215
- package/dist/preact/inject/src/init/injectAutocomplete.d.ts +1 -1
- 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 +3 -3
- package/dist/{search-DTqo1D6Y.cjs → search-RNs4Cunh.cjs} +1 -1
- package/dist/{search-sC5QgJmw.js → search-mArZ2PXy.js} +14 -14
- package/dist/{useActions-CJ71kc2N.cjs → useActions-Drtoxcu4.cjs} +1 -1
- package/dist/{useActions-SEyBHGra.js → useActions-MsVW37eV.js} +3 -3
- package/dist/useHistory-2uGnArVO.cjs +1 -0
- package/dist/useHistory-W6FQSk99.js +20 -0
- package/dist/{useLoadMore-hrNp8P0M.js → useLoadMore-BR-vDmqW.js} +1 -1
- package/dist/{useLoadMore-B0JgcUfM.cjs → useLoadMore-DPYhbXHC.cjs} +1 -1
- package/dist/utils/src/bindInput.d.ts +0 -1
- package/dist/utils/src/disableNativeAutocomplete.d.ts +1 -0
- package/dist/utils/src/storage.d.ts +3 -0
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.d.ts +2 -1
- package/dist/utils/utils.es.js +1 -1
- package/package.json +5 -5
- package/dist/AutocompletePageProvider-99syi-nl.cjs +0 -1
- package/dist/AutocompletePageProvider-HeGU8tjH.js +0 -29
- package/dist/baseConfig-CoxOyC7r.cjs +0 -1
- package/dist/baseConfig-DzkbWglo.js +0 -48
- package/dist/bindInput-BnKvCky1.cjs +0 -1
- package/dist/preact/inject/src/init/autocomplete/AutocompleteContext.d.ts +0 -12
|
@@ -33,25 +33,25 @@ function g(t, e) {
|
|
|
33
33
|
function P(t, e) {
|
|
34
34
|
p(t, e, localStorage);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function I(t, e) {
|
|
37
37
|
p(t, e, sessionStorage);
|
|
38
38
|
}
|
|
39
39
|
function _(t) {
|
|
40
40
|
return g(t, localStorage);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function R(t) {
|
|
43
43
|
return g(t, sessionStorage);
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
47
|
-
|
|
45
|
+
const m = "nosto:search-js:cache", b = 60 * 1e3;
|
|
46
|
+
function N(t, e) {
|
|
47
|
+
I(m, { query: t, result: e, created: Date.now() });
|
|
48
48
|
}
|
|
49
|
-
function
|
|
50
|
-
const e =
|
|
51
|
-
if (!e || !
|
|
49
|
+
function T(t) {
|
|
50
|
+
const e = R(m);
|
|
51
|
+
if (!e || !z(e))
|
|
52
52
|
return null;
|
|
53
53
|
const r = d(e.query);
|
|
54
|
-
return !h(d(t), r) || Date.now() - e.created >
|
|
54
|
+
return !h(d(t), r) || Date.now() - e.created > b ? null : e.result;
|
|
55
55
|
}
|
|
56
56
|
function d(t) {
|
|
57
57
|
const e = {
|
|
@@ -64,17 +64,17 @@ function d(t) {
|
|
|
64
64
|
};
|
|
65
65
|
return JSON.parse(JSON.stringify(e));
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function z(t) {
|
|
68
68
|
return typeof t == "object" && t !== null && "query" in t && "result" in t && "created" in t;
|
|
69
69
|
}
|
|
70
70
|
async function O(t, { usePersistentCache: e, ...r }, o) {
|
|
71
71
|
if (!e)
|
|
72
72
|
return o(t, r);
|
|
73
73
|
const n = await E(t, r, o);
|
|
74
|
-
return
|
|
74
|
+
return N(t, n), n;
|
|
75
75
|
}
|
|
76
76
|
async function E(t, e, r) {
|
|
77
|
-
const { from: o = 0, size: n = 0 } = t.products || {}, c =
|
|
77
|
+
const { from: o = 0, size: n = 0 } = t.products || {}, c = T(t);
|
|
78
78
|
if (!c)
|
|
79
79
|
return await r(t, e);
|
|
80
80
|
const s = c?.products?.size ?? 0, i = c?.products?.hits ?? [];
|
|
@@ -90,11 +90,11 @@ async function E(t, e, r) {
|
|
|
90
90
|
total: c.products?.total || 0
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
const a = n - i.length,
|
|
93
|
+
const a = n - i.length, S = o > 0 ? o + 1 : n - a, w = {
|
|
94
94
|
...t,
|
|
95
95
|
products: {
|
|
96
96
|
...t.products,
|
|
97
|
-
from:
|
|
97
|
+
from: S,
|
|
98
98
|
size: a
|
|
99
99
|
}
|
|
100
100
|
}, l = await r(w, e);
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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;
|
|
@@ -2,7 +2,7 @@ import { createContext as S } from "preact";
|
|
|
2
2
|
import { useContext as k, useMemo as I, useCallback as d } from "preact/hooks";
|
|
3
3
|
import { b as w, u as M, a as f, d as h, m as E } from "./unique-Cv2g464w.js";
|
|
4
4
|
import { i as b, l as A } from "./logger-_fg_Za9y.js";
|
|
5
|
-
import { s as U } from "./search-
|
|
5
|
+
import { s as U } from "./search-mArZ2PXy.js";
|
|
6
6
|
const q = S(null);
|
|
7
7
|
function p() {
|
|
8
8
|
const e = k(q);
|
|
@@ -247,8 +247,8 @@ function Y() {
|
|
|
247
247
|
export {
|
|
248
248
|
q as C,
|
|
249
249
|
N as S,
|
|
250
|
-
|
|
251
|
-
|
|
250
|
+
X as a,
|
|
251
|
+
p as b,
|
|
252
252
|
K as c,
|
|
253
253
|
W as d,
|
|
254
254
|
R as e,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("./useActions-Drtoxcu4.cjs"),o=require("./search-RNs4Cunh.cjs"),s=require("preact/hooks"),r="nosto:search-js:history";function S(){const{updateState:c}=s.useContext(i.StoreContext),{historySize:e}=i.useAutocompleteConfig(),l=s.useCallback(t=>{const m=(o.getLocalStorageItem(r)??[]).filter(y=>y!==t).concat(t),a=e?m.slice(-e):[];o.setLocalStorageItem(r,a),c({historyItems:a.reverse()})},[e,c]),u=s.useCallback(()=>(o.getLocalStorageItem(r)??[]).slice().reverse().filter(n=>!!n),[]);return{addQuery:l,getSaved:u}}exports.useHistory=S;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { S, a as y } from "./useActions-MsVW37eV.js";
|
|
2
|
+
import { g as c, a as g } from "./search-mArZ2PXy.js";
|
|
3
|
+
import { useContext as f, useCallback as n } from "preact/hooks";
|
|
4
|
+
const o = "nosto:search-js:history";
|
|
5
|
+
function d() {
|
|
6
|
+
const { updateState: s } = f(S), { historySize: t } = y(), i = n(
|
|
7
|
+
(e) => {
|
|
8
|
+
const m = (c(o) ?? []).filter((u) => u !== e).concat(e), a = t ? m.slice(-t) : [];
|
|
9
|
+
g(o, a), s({ historyItems: a.reverse() });
|
|
10
|
+
},
|
|
11
|
+
[t, s]
|
|
12
|
+
), l = n(() => (c(o) ?? []).slice().reverse().filter((r) => !!r), []);
|
|
13
|
+
return {
|
|
14
|
+
addQuery: i,
|
|
15
|
+
getSaved: l
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
d as u
|
|
20
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as n, h as u } from "./useActions-
|
|
1
|
+
import { S as n, h as u } from "./useActions-MsVW37eV.js";
|
|
2
2
|
import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
|
|
3
3
|
import { i as m } from "./isBot-Lnmft0Z0.js";
|
|
4
4
|
function l(t = p) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./useActions-
|
|
1
|
+
"use strict";const n=require("./useActions-Drtoxcu4.cjs"),r=require("preact/hooks"),i=require("./isBot-iyBlT_oq.cjs");function c(e=f){const t=r.useContext(n.StoreContext),[o,s]=r.useState(e(t.getState()));return t.onChange(e,s),r.useEffect(()=>()=>t.clearOnChange(s),[t]),o}const f=e=>e;function a({from:e,size:t,pageSize:o}){return i.isBot()?{products:{from:e+o}}:{products:{size:t+o}}}function d(e=24){const{from:t,size:o}=c(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:s}=n.useActions();return{loadMore:r.useCallback(async()=>{await s(a({from:t,size:o,pageSize:e}))},[t,o,e,s])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
|
|
@@ -9,7 +9,6 @@ export interface BindElementOptions {
|
|
|
9
9
|
form?: HTMLFormElement;
|
|
10
10
|
nativeSubmit?: boolean;
|
|
11
11
|
}
|
|
12
|
-
export declare function disableNativeAutocomplete(target: HTMLInputElement): void;
|
|
13
12
|
export declare function bindInput(target: HTMLInputElement, { onClick, onFocus, onInput, onKeyDown, onSubmit }: InputBindingCallbacks, { form, nativeSubmit }?: BindElementOptions): {
|
|
14
13
|
destroy: () => void;
|
|
15
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function disableNativeAutocomplete(target: HTMLInputElement): void;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
type Key = `nosto:search-js:${string}`;
|
|
2
|
+
export declare function setStorageItem(name: Key, value: unknown, storage: Storage): void;
|
|
3
|
+
export declare function getStorageItem<T>(name: Key, storage: Storage): T | undefined;
|
|
4
|
+
export declare function removeStorageItem(name: Key, storage: Storage): void;
|
|
2
5
|
export declare function setLocalStorageItem(name: Key, value: unknown): void;
|
|
3
6
|
export declare function setSessionStorageItem(name: Key, value: unknown): void;
|
|
4
7
|
export declare function getLocalStorageItem<T>(name: Key): T | undefined;
|
package/dist/utils/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../disableNativeAutocomplete-DI6zaZII.cjs"),t=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),u=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=t.cl;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=u.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,7 +1,8 @@
|
|
|
1
1
|
/** @module utils */
|
|
2
|
-
export { type BindElementOptions, bindInput,
|
|
2
|
+
export { type BindElementOptions, bindInput, type InputBindingCallbacks } from './src/bindInput';
|
|
3
3
|
export { cl } from './src/cl';
|
|
4
4
|
export { deepMerge, type Merge, type PlainMerge } from './src/deepMerge';
|
|
5
|
+
export { disableNativeAutocomplete } from './src/disableNativeAutocomplete';
|
|
5
6
|
export { isBot } from './src/isBot';
|
|
6
7
|
export { isEqual } from './src/isEqual';
|
|
7
8
|
export { isPlainObject } from './src/isPlainObject';
|
package/dist/utils/utils.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as r, d as s } from "../
|
|
1
|
+
import { b as r, d as s } from "../disableNativeAutocomplete-Bkta_WR2.js";
|
|
2
2
|
import { c as p } from "../cl-CcykAxZN.js";
|
|
3
3
|
import { d as m, a as i, m as u, u as f } from "../unique-Cv2g464w.js";
|
|
4
4
|
import { i as x } from "../isBot-Lnmft0Z0.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -103,11 +103,11 @@
|
|
|
103
103
|
"@testing-library/dom": "^10.4.1",
|
|
104
104
|
"@types/dom-speech-recognition": "^0.0.6",
|
|
105
105
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
106
|
-
"@types/node": "^24.
|
|
106
|
+
"@types/node": "^24.5.2",
|
|
107
107
|
"@vitest/coverage-v8": "^3.2.4",
|
|
108
108
|
"concurrently": "^9.2.1",
|
|
109
109
|
"copyfiles": "^2.4.1",
|
|
110
|
-
"eslint": "^9.
|
|
110
|
+
"eslint": "^9.36.0",
|
|
111
111
|
"eslint-config-prettier": "^10.1.8",
|
|
112
112
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
113
113
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
"prettier": "^3.6.2",
|
|
122
122
|
"typedoc": "^0.28.13",
|
|
123
123
|
"typescript": "^5.9.2",
|
|
124
|
-
"typescript-eslint": "^8.
|
|
125
|
-
"vite": "^7.1.
|
|
124
|
+
"typescript-eslint": "^8.44.1",
|
|
125
|
+
"vite": "^7.1.7",
|
|
126
126
|
"vite-plugin-dts": "^4.5.4",
|
|
127
127
|
"vitest": "^3.1.3"
|
|
128
128
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),o=require("./useActions-CJ71kc2N.cjs"),n=require("./baseConfig-CoxOyC7r.cjs"),a={...n.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function r(e={}){return{pageType:"autocomplete",...a,...e}}function l({config:e,store:u,children:i}){const c=u??o.createStore();return n.useCheckClientScript(),t.u(o.ConfigContext,{value:r(e),children:t.u(o.StoreContext,{value:c,children:[t.u(n.StoreActionsListener,{}),i]})})}exports.AutocompletePageProvider=l;exports.makeAutocompleteConfig=r;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { c as n, S as i, C as u } from "./useActions-SEyBHGra.js";
|
|
3
|
-
import { d as c, u as s, S as l } from "./baseConfig-DzkbWglo.js";
|
|
4
|
-
const m = {
|
|
5
|
-
...c,
|
|
6
|
-
memoryCache: !1,
|
|
7
|
-
historyEnabled: !0,
|
|
8
|
-
historySize: 5,
|
|
9
|
-
debounceDelay: 500,
|
|
10
|
-
minQueryLength: 2
|
|
11
|
-
};
|
|
12
|
-
function f(e = {}) {
|
|
13
|
-
return {
|
|
14
|
-
pageType: "autocomplete",
|
|
15
|
-
...m,
|
|
16
|
-
...e
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
function S({ config: e, store: o, children: r }) {
|
|
20
|
-
const a = o ?? n();
|
|
21
|
-
return s(), /* @__PURE__ */ t(u, { value: f(e), children: /* @__PURE__ */ t(i, { value: a, children: [
|
|
22
|
-
/* @__PURE__ */ t(l, {}),
|
|
23
|
-
r
|
|
24
|
-
] }) });
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
S as A,
|
|
28
|
-
f as m
|
|
29
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./useActions-CJ71kc2N.cjs"),r=require("./eventBusSubscribe-oONOUGH8.cjs"),c=require("./index.es-Dp6Iaxz3.cjs"),o=require("./logger-Boh_C6Bz.cjs"),u=require("preact/hooks");function s(){const{pageType:t}=i.useConfig(),n=i.useActions();return r.useEventBusSubscribe({event:"actions/newSearch",callback:e=>{t===e.targetStore&&n.newSearch(e.query,e.options)}}),r.useEventBusSubscribe({event:"actions/updateSearch",callback:e=>{t===e.targetStore&&n.updateSearch(e.query,e.options)}}),r.useEventBusSubscribe({event:"actions/replaceFilter",callback:e=>{t===e.targetStore&&n.replaceFilter(e.field,e.value)}}),r.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:e=>{t===e.targetStore&&n.toggleProductFilter(e.field,e.value,e.active)}}),null}function l(){u.useEffect(()=>{const t=window.setTimeout(()=>{o.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);c.s(()=>{window.clearTimeout(t)})},[])}const a={defaultCurrency:"EUR",queryModifications:t=>t};exports.StoreActionsListener=s;exports.defaultBaseConfig=a;exports.useCheckClientScript=l;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { a as i, h as n } from "./useActions-SEyBHGra.js";
|
|
2
|
-
import { u as r } from "./eventBusSubscribe-CzlS132j.js";
|
|
3
|
-
import { s as c } from "./index.es-XNBESE3P.js";
|
|
4
|
-
import { l as u } from "./logger-_fg_Za9y.js";
|
|
5
|
-
import { useEffect as l } from "preact/hooks";
|
|
6
|
-
function S() {
|
|
7
|
-
const { pageType: t } = i(), o = n();
|
|
8
|
-
return r({
|
|
9
|
-
event: "actions/newSearch",
|
|
10
|
-
callback: (e) => {
|
|
11
|
-
t === e.targetStore && o.newSearch(e.query, e.options);
|
|
12
|
-
}
|
|
13
|
-
}), r({
|
|
14
|
-
event: "actions/updateSearch",
|
|
15
|
-
callback: (e) => {
|
|
16
|
-
t === e.targetStore && o.updateSearch(e.query, e.options);
|
|
17
|
-
}
|
|
18
|
-
}), r({
|
|
19
|
-
event: "actions/replaceFilter",
|
|
20
|
-
callback: (e) => {
|
|
21
|
-
t === e.targetStore && o.replaceFilter(e.field, e.value);
|
|
22
|
-
}
|
|
23
|
-
}), r({
|
|
24
|
-
event: "actions/toggleProductFilter",
|
|
25
|
-
callback: (e) => {
|
|
26
|
-
t === e.targetStore && o.toggleProductFilter(e.field, e.value, e.active);
|
|
27
|
-
}
|
|
28
|
-
}), null;
|
|
29
|
-
}
|
|
30
|
-
function v() {
|
|
31
|
-
l(() => {
|
|
32
|
-
const t = window.setTimeout(() => {
|
|
33
|
-
u.error("Nosto client script has not loaded after 3 seconds.");
|
|
34
|
-
}, 3e3);
|
|
35
|
-
c(() => {
|
|
36
|
-
window.clearTimeout(t);
|
|
37
|
-
});
|
|
38
|
-
}, []);
|
|
39
|
-
}
|
|
40
|
-
const h = {
|
|
41
|
-
defaultCurrency: "EUR",
|
|
42
|
-
queryModifications: (t) => t
|
|
43
|
-
};
|
|
44
|
-
export {
|
|
45
|
-
S,
|
|
46
|
-
h as d,
|
|
47
|
-
v as u
|
|
48
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function y(f){f.setAttribute("autocomplete","off")}function k(f,{onClick:d,onFocus:v,onInput:o,onKeyDown:s,onSubmit:i},{form:c=f.form??void 0,nativeSubmit:p}={}){const r=[];function l(e,u,a){e.addEventListener(u,a),r.push(()=>e.removeEventListener(u,a))}return(s||i)&&l(f,"keydown",e=>{const u=s?.(f.value,e.key);s&&(e.key==="ArrowDown"||e.key==="ArrowUp")?e.preventDefault():i&&e.key==="Enter"&&(f.value!==""&&!e.repeat&&!u&&i(f.value),p||e.preventDefault())}),i&&c&&(l(c,"submit",e=>{p||e.preventDefault(),i(f.value)}),c.querySelectorAll("[type=submit]").forEach(e=>{l(e,"click",u=>{p||u.preventDefault(),i(f.value)})})),d&&l(f,"click",()=>d(f.value)),v&&l(f,"focus",()=>v(f.value)),o&&l(f,"input",()=>o(f.value)),{destroy(){r.forEach(e=>e())}}}exports.bindInput=k;exports.disableNativeAutocomplete=y;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { SearchKeyword, SearchProduct, SearchQuery } from '@nosto/nosto-js/client';
|
|
2
|
-
import { AutocompleteInjectContext } from '../injectAutocomplete';
|
|
3
|
-
import { AutocompleteDropdown } from './components/AutocompleteDropdown';
|
|
4
|
-
import { AutocompleteHistory } from './components/AutocompleteHistory';
|
|
5
|
-
export type AutocompleteUserContext = {
|
|
6
|
-
reportProductClick: (product: SearchProduct) => void;
|
|
7
|
-
reportKeywordClick: (keyword: SearchKeyword) => void;
|
|
8
|
-
handleSubmit: (query: SearchQuery) => void;
|
|
9
|
-
highlightedElementIndex: number;
|
|
10
|
-
};
|
|
11
|
-
export declare const AutocompleteContext: import('preact').Context<AutocompleteUserContext>;
|
|
12
|
-
export declare function createContextHandle(context: AutocompleteInjectContext, element: AutocompleteDropdown | AutocompleteHistory): AutocompleteUserContext;
|