@nosto/search-js 3.1.2 → 3.2.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/{InfiniteScrollWithObserver-CQV1s264.js → InfiniteScrollWithObserver-BsydJKFj.js} +25 -25
- package/dist/InfiniteScrollWithObserver-wzwXCrZ7.cjs +1 -0
- package/dist/baseConfig-CTN0CcW-.js +48 -0
- package/dist/baseConfig-KREDcxnC.cjs +1 -0
- package/dist/eventBusSubscribe-B75y7otR.cjs +1 -0
- package/dist/eventBusSubscribe-Cxw0xUAm.js +25 -0
- package/dist/{unique-DnsrXjFL.js → isBot-C58Y7eiv.js} +12 -34
- package/dist/{unique-C8Ij1UVz.cjs → isBot-CheH1DcZ.cjs} +1 -1
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -0
- package/dist/preact/autocomplete/autocomplete.d.ts +5 -0
- package/dist/preact/autocomplete/autocomplete.es.js +49 -0
- package/dist/preact/{src/config/pages/autocomplete/config.d.ts → autocomplete/src/AutocompleteConfig.d.ts} +5 -5
- package/dist/preact/{src/config/pages/autocomplete/provider.d.ts → autocomplete/src/AutocompletePageProvider.d.ts} +2 -2
- package/dist/preact/{src → autocomplete/src}/components/AutocompleteElement.d.ts +2 -2
- package/dist/preact/category/category.cjs.js +1 -0
- package/dist/preact/category/category.d.ts +3 -0
- package/dist/preact/category/category.es.js +25 -0
- package/dist/preact/{src/config/pages/category/config.d.ts → category/src/CategoryConfig.d.ts} +5 -5
- package/dist/preact/{src/config/pages/category/provider.d.ts → category/src/CategoryPageProvider.d.ts} +2 -2
- package/dist/preact/common/common.cjs.js +1 -0
- package/dist/preact/{common.d.ts → common/common.d.ts} +3 -3
- package/dist/preact/{common.es.js → common/common.es.js} +6 -6
- package/dist/preact/{src → common/src}/actions/newSearch.d.ts +2 -2
- package/dist/preact/{src → common/src}/actions/replaceFilter.d.ts +1 -1
- package/dist/preact/{src → common/src}/actions/toggleProductFilter.d.ts +1 -1
- package/dist/preact/{src → common/src}/actions/updateSearch.d.ts +2 -2
- package/dist/preact/{src/search/defaults.d.ts → common/src/actions/withDefaultQuery.d.ts} +2 -4
- package/dist/preact/{src/config/base → common/src/config}/baseConfig.d.ts +1 -2
- package/dist/preact/common/src/config/config.d.ts +4 -0
- package/dist/preact/common/src/config/configContext.d.ts +6 -0
- package/dist/preact/common/src/store/components/StoreActionsListener.d.ts +1 -0
- package/dist/preact/{src/api → common/src}/types.d.ts +6 -0
- package/dist/preact/events/events.cjs.js +1 -0
- package/dist/preact/events/events.d.ts +3 -0
- package/dist/preact/events/events.es.js +23 -0
- package/dist/preact/events/src/eventBusDispatch.d.ts +10 -0
- package/dist/preact/events/src/eventBusSubscribe.d.ts +8 -0
- package/dist/preact/events/src/types.d.ts +26 -0
- package/dist/preact/hooks/hooks.cjs.js +1 -0
- package/dist/preact/hooks/hooks.d.ts +18 -0
- package/dist/preact/{hooks.es.js → hooks/hooks.es.js} +96 -95
- package/dist/preact/{src/hooks → hooks/src}/useNostoAppState.d.ts +1 -1
- package/dist/preact/legacy/legacy.cjs.js +1 -0
- package/dist/preact/legacy/legacy.d.ts +6 -0
- package/dist/preact/legacy/legacy.es.js +10 -0
- package/dist/preact/serp/serp.cjs.js +1 -0
- package/dist/preact/serp/serp.d.ts +4 -0
- package/dist/preact/serp/serp.es.js +39 -0
- package/dist/preact/{src/config/pages/serp/config.d.ts → serp/src/SerpConfig.d.ts} +5 -5
- package/dist/preact/{src/config/pages/serp/provider.d.ts → serp/src/SerpPageProvider.d.ts} +2 -2
- package/dist/preact/{src → serp/src}/components/SerpElement.d.ts +2 -2
- package/dist/unique-3gEanSFU.cjs +1 -0
- package/dist/unique-DxrT0M20.js +39 -0
- package/dist/useActions-B-wWOcHo.cjs +1 -0
- package/dist/useActions-BIIcXXS6.js +229 -0
- package/dist/useLoadMore-BWgWw24W.cjs +1 -0
- package/dist/useLoadMore-Dw7GDu8a.js +31 -0
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.es.js +6 -6
- package/package.json +39 -33
- package/dist/InfiniteScrollWithObserver-DwzgJMlG.cjs +0 -1
- package/dist/baseConfig-BFFqFSg5.cjs +0 -1
- package/dist/baseConfig-Bafl02NY.js +0 -21
- package/dist/configContext-BR7w4VlU.cjs +0 -1
- package/dist/configContext-GuZOIX3o.js +0 -63
- package/dist/deepMerge-CZwCJzEe.js +0 -17
- package/dist/deepMerge-lDscDfII.cjs +0 -1
- package/dist/preact/autocomplete.cjs.js +0 -1
- package/dist/preact/autocomplete.d.ts +0 -5
- package/dist/preact/autocomplete.es.js +0 -46
- package/dist/preact/category.cjs.js +0 -1
- package/dist/preact/category.d.ts +0 -3
- package/dist/preact/category.es.js +0 -22
- package/dist/preact/common.cjs.js +0 -1
- package/dist/preact/hooks.cjs.js +0 -1
- package/dist/preact/hooks.d.ts +0 -18
- package/dist/preact/legacy.cjs.js +0 -1
- package/dist/preact/legacy.d.ts +0 -6
- package/dist/preact/legacy.es.js +0 -9
- package/dist/preact/preact.d.ts +0 -30
- package/dist/preact/serp.cjs.js +0 -1
- package/dist/preact/serp.d.ts +0 -4
- package/dist/preact/serp.es.js +0 -36
- package/dist/preact/src/actions/types.d.ts +0 -6
- package/dist/preact/src/config/config.d.ts +0 -4
- package/dist/preact/src/config/configContext.d.ts +0 -6
- package/dist/useLoadMore-Cflxq0FH.cjs +0 -1
- package/dist/useLoadMore-D9uu2DBj.js +0 -198
- /package/dist/preact/{src → autocomplete/src}/components/SearchInput.d.ts +0 -0
- /package/dist/preact/{src/components → autocomplete/src}/types.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/BaseElement.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScroll.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScrollWithLink.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/InfiniteScroll/InfiniteScrollWithObserver.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/InfiniteScroll/LoadMoreLink.d.ts +0 -0
- /package/dist/preact/{src → common/src}/components/InfiniteScroll/utils.d.ts +0 -0
- /package/dist/preact/{src → common/src/store}/store.d.ts +0 -0
- /package/dist/preact/{src → common/src/store}/storeContext.d.ts +0 -0
- /package/dist/preact/{src → common/src/store}/storeExtensions.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/types.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useActions.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useCheckClientScript.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useDecoratedSearchResults.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useFacet.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useFacets.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useLoadMore/getNextPageQuery.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useLoadMore/useLoadMore.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/usePagination.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/usePersonalization.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useProductFilters/useProductFilters.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useProductFilters/useProductFiltersUtils.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useRange.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useRangeSelector.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useResponse.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSelectedFiltersCount.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSizeOptions.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSort/useSort.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSort/utils.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSpeechToText.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSwatches/aggregateSwatches.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSwatches/applySelectionStates.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSwatches/sortOptions.d.ts +0 -0
- /package/dist/preact/{src/hooks → hooks/src}/useSwatches/useSwatches.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=require("./logger-BcHMZObS.cjs");function f(...e){return i(...e)}function i(...e){return e.reduce((r,n)=>c(r,n))}function c(e,r){return u.isPlainObject(e)&&u.isPlainObject(r)?Object.entries(r).reduce((n,[t,o])=>(n[t]=c(n[t],o),n),{...e}):u.isPlainObject(e)?e:r}function s(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,n)=>r.concat(n),[])}const a="nosto.search.";function d(e){const r=`${a}${e}`;window.performance?.mark(`${r}.start`)}function l(e){const r=`${a}${e}`;window.performance?.mark(`${r}.end`),window.performance?.measure(r,`${r}.start`,`${r}.end`)}function m(e){return d(e),()=>l(e)}function $(e){return Array.from(new Set(e))}exports.deepMerge=f;exports.deepMergePlain=i;exports.measure=m;exports.mergeArrays=s;exports.unique=$;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { a as u } from "./logger-DVwg4Wor.js";
|
|
2
|
+
function d(...r) {
|
|
3
|
+
return c(...r);
|
|
4
|
+
}
|
|
5
|
+
function c(...r) {
|
|
6
|
+
return r.reduce((e, n) => a(e, n));
|
|
7
|
+
}
|
|
8
|
+
function a(r, e) {
|
|
9
|
+
return u(r) && u(e) ? Object.entries(e).reduce(
|
|
10
|
+
(n, [t, o]) => (n[t] = a(n[t], o), n),
|
|
11
|
+
{ ...r }
|
|
12
|
+
) : u(r) ? r : e;
|
|
13
|
+
}
|
|
14
|
+
function l(...r) {
|
|
15
|
+
if (!r.every((e) => e == null))
|
|
16
|
+
return r.filter((e) => Array.isArray(e)).reduce((e, n) => e.concat(n), []);
|
|
17
|
+
}
|
|
18
|
+
const i = "nosto.search.";
|
|
19
|
+
function f(r) {
|
|
20
|
+
const e = `${i}${r}`;
|
|
21
|
+
window.performance?.mark(`${e}.start`);
|
|
22
|
+
}
|
|
23
|
+
function s(r) {
|
|
24
|
+
const e = `${i}${r}`;
|
|
25
|
+
window.performance?.mark(`${e}.end`), window.performance?.measure(e, `${e}.start`, `${e}.end`);
|
|
26
|
+
}
|
|
27
|
+
function $(r) {
|
|
28
|
+
return f(r), () => s(r);
|
|
29
|
+
}
|
|
30
|
+
function w(r) {
|
|
31
|
+
return Array.from(new Set(r));
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
$ as a,
|
|
35
|
+
c as b,
|
|
36
|
+
d,
|
|
37
|
+
l as m,
|
|
38
|
+
w as u
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const k=require("preact"),g=require("preact/hooks"),c=require("./unique-3gEanSFU.cjs"),y=require("./logger-BcHMZObS.cjs"),T=require("./search-sG5OjNAe.cjs"),m=k.createContext(null),w=()=>{const e=g.useContext(m);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function b(e,r={}){const t=new Map;let n=c.deepMergePlain(e,r??{});const o=c.deepMergePlain(e,r);function u(d){n=d(n);for(const f of t.values())f(n)}function i(d){u(f=>({...f,...d}))}function s(){return n}function a(){return structuredClone(o)}function l(d,f){let S;t.set(f,M=>{const h=d(M);y.isEqual(h,S)||(S=h,f(h))})}function q(d){t.delete(d)}return{updateState:i,getState:s,getInitialState:a,onChange:l,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function F(e={}){return b(v,e)}const P=k.createContext(F());function I(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:E,...r.products},...r.keywords?{keywords:{...r.keywords,fields:c.unique([...U,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const E=["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"],U=["keyword","_redirect"];async function C(e,r,t){const n=c.measure("newSearch"),o=e.config.pageType,u=o==="search"?"serp":o,i=c.deepMerge(e.store.getInitialState().query,r),s=c.deepMerge(e.config.search,t,{track:u,redirect:o!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,s),e.store.updateState({query:i,loading:!0,initialized:!0});const a=e.config.queryModifications({...i,products:{...i.products,filter:c.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},o);try{const l=await T.search(I(e.config.pageType,a),s);e.store.updateState({response:l,loading:!1})}catch(l){y.logger.error("Search action failed",l),e.config.onSearchError?.(l,a,s,o)}n()}async function p(e,r,t){const n=c.measure("updateSearch"),o=c.deepMerge(e.store.getState().query,{products:{from:0}},r);await C(e,o,t),n()}async function A(e,r,t){const n=c.measure("replaceFilter"),o=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await p(e,{products:{filter:[...o?.filter(i=>i.field!==r)??[],...u]}}),n()}async function Q(e,r,t,n){const o=c.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,i=u?.find(a=>a.value instanceof Array&&a.field===r),s=i?.value?{...i,value:[...i.value.filter(a=>!y.isEqual(a,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await p(e,{products:{filter:[...u?.filter(a=>a!==i)??[],...s?.value?.length?[s]:[]]}}),o()}function K(){const e=w(),r=g.useContext(P),t=g.useMemo(()=>({config:e,store:r}),[e,r]),n=g.useCallback((s,a)=>C(t,s,a),[t]),o=g.useCallback((s,a)=>p(t,s,a),[t]),u=g.useCallback((s,a,l)=>Q(t,s,a,l),[t]),i=g.useCallback((s,a)=>A(t,s,a),[t]);return{newSearch:n,updateSearch:o,toggleProductFilter:u,replaceFilter:i}}exports.ConfigContext=m;exports.StoreContext=P;exports.createExtendableStore=b;exports.createStore=F;exports.defaultState=v;exports.newSearch=C;exports.updateSearch=p;exports.useActions=K;exports.useConfig=w;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { createContext as k } from "preact";
|
|
2
|
+
import { useContext as C, useMemo as P, useCallback as g } from "preact/hooks";
|
|
3
|
+
import { b as S, u as T, a as f, d as y, m as M } from "./unique-DxrT0M20.js";
|
|
4
|
+
import { i as w, l as I } from "./logger-DVwg4Wor.js";
|
|
5
|
+
import { s as U } from "./search-DweKaGAI.js";
|
|
6
|
+
const q = k(null), E = () => {
|
|
7
|
+
const e = C(q);
|
|
8
|
+
if (!e)
|
|
9
|
+
throw new Error("useConfig must be used within a ConfigProvider");
|
|
10
|
+
return e;
|
|
11
|
+
};
|
|
12
|
+
function Q(e, r = {}) {
|
|
13
|
+
const t = /* @__PURE__ */ new Map();
|
|
14
|
+
let i = S(e, r ?? {});
|
|
15
|
+
const o = S(e, r);
|
|
16
|
+
function c(l) {
|
|
17
|
+
i = l(i);
|
|
18
|
+
for (const d of t.values())
|
|
19
|
+
d(i);
|
|
20
|
+
}
|
|
21
|
+
function n(l) {
|
|
22
|
+
c((d) => ({ ...d, ...l }));
|
|
23
|
+
}
|
|
24
|
+
function s() {
|
|
25
|
+
return i;
|
|
26
|
+
}
|
|
27
|
+
function a() {
|
|
28
|
+
return structuredClone(o);
|
|
29
|
+
}
|
|
30
|
+
function u(l, d) {
|
|
31
|
+
let m;
|
|
32
|
+
t.set(d, (F) => {
|
|
33
|
+
const p = l(F);
|
|
34
|
+
w(p, m) || (m = p, d(p));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function v(l) {
|
|
38
|
+
t.delete(l);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
updateState: n,
|
|
42
|
+
getState: s,
|
|
43
|
+
getInitialState: a,
|
|
44
|
+
onChange: u,
|
|
45
|
+
clearOnChange: v
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const A = {
|
|
49
|
+
loading: !0,
|
|
50
|
+
query: {},
|
|
51
|
+
response: {},
|
|
52
|
+
initialized: !1
|
|
53
|
+
};
|
|
54
|
+
function K(e = {}) {
|
|
55
|
+
return Q(A, e);
|
|
56
|
+
}
|
|
57
|
+
const z = k(K());
|
|
58
|
+
function B(e, r) {
|
|
59
|
+
return {
|
|
60
|
+
...r,
|
|
61
|
+
products: {
|
|
62
|
+
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
63
|
+
fields: D,
|
|
64
|
+
...r.products
|
|
65
|
+
},
|
|
66
|
+
...r.keywords ? {
|
|
67
|
+
keywords: {
|
|
68
|
+
...r.keywords,
|
|
69
|
+
fields: T([...L, ...r.keywords.fields ?? []]),
|
|
70
|
+
highlight: r.keywords.highlight ?? {
|
|
71
|
+
preTag: "<strong>",
|
|
72
|
+
postTag: "</strong>"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} : {}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const D = [
|
|
79
|
+
"productId",
|
|
80
|
+
"url",
|
|
81
|
+
"name",
|
|
82
|
+
"imageUrl",
|
|
83
|
+
"imageHash",
|
|
84
|
+
"thumbUrl",
|
|
85
|
+
"description",
|
|
86
|
+
"brand",
|
|
87
|
+
"variantId",
|
|
88
|
+
"availability",
|
|
89
|
+
"price",
|
|
90
|
+
"priceText",
|
|
91
|
+
"categoryIds",
|
|
92
|
+
"categories",
|
|
93
|
+
"customFields.key",
|
|
94
|
+
"customFields.value",
|
|
95
|
+
"priceCurrencyCode",
|
|
96
|
+
"datePublished",
|
|
97
|
+
"listPrice",
|
|
98
|
+
"unitPricingBaseMeasure",
|
|
99
|
+
"unitPricingUnit",
|
|
100
|
+
"unitPricingMeasure",
|
|
101
|
+
"googleCategory",
|
|
102
|
+
"gtin",
|
|
103
|
+
"ageGroup",
|
|
104
|
+
"gender",
|
|
105
|
+
"condition",
|
|
106
|
+
"alternateImageUrls",
|
|
107
|
+
"ratingValue",
|
|
108
|
+
"reviewCount",
|
|
109
|
+
"inventoryLevel",
|
|
110
|
+
"skus.id",
|
|
111
|
+
"skus.name",
|
|
112
|
+
"skus.price",
|
|
113
|
+
"skus.listPrice",
|
|
114
|
+
"skus.priceText",
|
|
115
|
+
"skus.url",
|
|
116
|
+
"skus.imageUrl",
|
|
117
|
+
"skus.inventoryLevel",
|
|
118
|
+
"skus.customFields.key",
|
|
119
|
+
"skus.customFields.value",
|
|
120
|
+
"skus.availability",
|
|
121
|
+
"pid",
|
|
122
|
+
"onDiscount",
|
|
123
|
+
"extra.key",
|
|
124
|
+
"extra.value",
|
|
125
|
+
"saleable",
|
|
126
|
+
"available",
|
|
127
|
+
"tags1",
|
|
128
|
+
"tags2",
|
|
129
|
+
"tags3"
|
|
130
|
+
], L = ["keyword", "_redirect"];
|
|
131
|
+
async function b(e, r, t) {
|
|
132
|
+
const i = f("newSearch"), o = e.config.pageType, c = o === "search" ? "serp" : o, n = y(e.store.getInitialState().query, r), s = y(e.config.search, t, {
|
|
133
|
+
track: c,
|
|
134
|
+
redirect: o !== "autocomplete",
|
|
135
|
+
isKeyword: !!t?.isKeyword,
|
|
136
|
+
usePersistentCache: e.config.pageType !== "autocomplete" && e.config.persistentSearchCache,
|
|
137
|
+
useMemoryCache: e.config.pageType === "autocomplete" && e.config.memoryCache
|
|
138
|
+
});
|
|
139
|
+
e.config.onBeforeSearch?.(e, s), e.store.updateState({
|
|
140
|
+
query: n,
|
|
141
|
+
loading: !0,
|
|
142
|
+
initialized: !0
|
|
143
|
+
});
|
|
144
|
+
const a = e.config.queryModifications(
|
|
145
|
+
{
|
|
146
|
+
...n,
|
|
147
|
+
products: {
|
|
148
|
+
...n.products,
|
|
149
|
+
// Apply filter merging to avoid overwriting base filters
|
|
150
|
+
filter: M(e.store.getInitialState().query?.products?.filter, r.products?.filter)
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
o
|
|
154
|
+
);
|
|
155
|
+
try {
|
|
156
|
+
const u = await U(B(e.config.pageType, a), s);
|
|
157
|
+
e.store.updateState({
|
|
158
|
+
response: u,
|
|
159
|
+
loading: !1
|
|
160
|
+
});
|
|
161
|
+
} catch (u) {
|
|
162
|
+
I.error("Search action failed", u), e.config.onSearchError?.(u, a, s, o);
|
|
163
|
+
}
|
|
164
|
+
i();
|
|
165
|
+
}
|
|
166
|
+
async function h(e, r, t) {
|
|
167
|
+
const i = f("updateSearch"), o = y(e.store.getState().query, { products: { from: 0 } }, r);
|
|
168
|
+
await b(e, o, t), i();
|
|
169
|
+
}
|
|
170
|
+
async function O(e, r, t) {
|
|
171
|
+
const i = f("replaceFilter"), o = e.store.getState().query.products?.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
172
|
+
await h(e, {
|
|
173
|
+
products: {
|
|
174
|
+
filter: [...o?.filter((n) => n.field !== r) ?? [], ...c]
|
|
175
|
+
}
|
|
176
|
+
}), i();
|
|
177
|
+
}
|
|
178
|
+
async function V(e, r, t, i) {
|
|
179
|
+
const o = f("toggleProductFilter"), c = e.store.getState().query.products?.filter, n = c?.find((a) => a.value instanceof Array && a.field === r), s = n?.value ? {
|
|
180
|
+
...n,
|
|
181
|
+
value: [...n.value.filter((a) => !w(a, t)), ...i ? [t] : []]
|
|
182
|
+
} : i ? {
|
|
183
|
+
field: r,
|
|
184
|
+
value: [t]
|
|
185
|
+
} : void 0;
|
|
186
|
+
await h(e, {
|
|
187
|
+
products: {
|
|
188
|
+
filter: [...c?.filter((a) => a !== n) ?? [], ...s?.value?.length ? [s] : []]
|
|
189
|
+
}
|
|
190
|
+
}), o();
|
|
191
|
+
}
|
|
192
|
+
function N() {
|
|
193
|
+
const e = E(), r = C(z), t = P(
|
|
194
|
+
() => ({
|
|
195
|
+
config: e,
|
|
196
|
+
store: r
|
|
197
|
+
}),
|
|
198
|
+
[e, r]
|
|
199
|
+
), i = g(
|
|
200
|
+
(s, a) => b(t, s, a),
|
|
201
|
+
[t]
|
|
202
|
+
), o = g(
|
|
203
|
+
(s, a) => h(t, s, a),
|
|
204
|
+
[t]
|
|
205
|
+
), c = g(
|
|
206
|
+
(s, a, u) => V(t, s, a, u),
|
|
207
|
+
[t]
|
|
208
|
+
), n = g(
|
|
209
|
+
(s, a) => O(t, s, a),
|
|
210
|
+
[t]
|
|
211
|
+
);
|
|
212
|
+
return {
|
|
213
|
+
newSearch: i,
|
|
214
|
+
updateSearch: o,
|
|
215
|
+
toggleProductFilter: c,
|
|
216
|
+
replaceFilter: n
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
export {
|
|
220
|
+
q as C,
|
|
221
|
+
z as S,
|
|
222
|
+
Q as a,
|
|
223
|
+
N as b,
|
|
224
|
+
K as c,
|
|
225
|
+
A as d,
|
|
226
|
+
E as e,
|
|
227
|
+
b as n,
|
|
228
|
+
h as u
|
|
229
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n=require("./useActions-B-wWOcHo.cjs"),r=require("preact/hooks"),i=require("./isBot-CheH1DcZ.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;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { S as n, b as u } from "./useActions-BIIcXXS6.js";
|
|
2
|
+
import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
|
|
3
|
+
import { i as m } from "./isBot-C58Y7eiv.js";
|
|
4
|
+
function l(t = p) {
|
|
5
|
+
const e = a(n), [o, r] = c(t(e.getState()));
|
|
6
|
+
return e.onChange(t, r), i(() => () => e.clearOnChange(r), [e]), o;
|
|
7
|
+
}
|
|
8
|
+
const p = (t) => t;
|
|
9
|
+
function d({ from: t, size: e, pageSize: o }) {
|
|
10
|
+
return m() ? {
|
|
11
|
+
products: { from: t + o }
|
|
12
|
+
} : {
|
|
13
|
+
products: { size: e + o }
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function y(t = 24) {
|
|
17
|
+
const { from: e, size: o } = l((s) => ({
|
|
18
|
+
from: s.query.products?.from ?? 0,
|
|
19
|
+
size: s.query.products?.size ?? 0
|
|
20
|
+
})), { updateSearch: r } = u();
|
|
21
|
+
return {
|
|
22
|
+
loadMore: f(async () => {
|
|
23
|
+
await r(d({ from: e, size: o, pageSize: t }));
|
|
24
|
+
}, [e, o, t, r])
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
l as a,
|
|
29
|
+
d as g,
|
|
30
|
+
y as u
|
|
31
|
+
};
|
package/dist/utils/utils.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../unique-3gEanSFU.cjs"),v=require("../isBot-CheH1DcZ.cjs"),p=require("../logger-BcHMZObS.cjs"),y=require("../parseNumber-FsZ8w61u.cjs"),k=require("../pick-rYi1lc2m.cjs");function b(i){i.setAttribute("autocomplete","off")}function A(i,{onClick:a,onFocus:n,onInput:d,onKeyDown:c,onSubmit:r},{form:f=i.form??void 0,nativeSubmit:o}={}){const t=[];function u(e,s,q){e.addEventListener(s,q),t.push(()=>e.removeEventListener(s,q))}return(c||r)&&u(i,"keydown",e=>{c?.(i.value,e.key),c&&(e.key==="ArrowDown"||e.key==="ArrowUp")?e.preventDefault():r&&e.key==="Enter"&&(i.value!==""&&!e.repeat&&r(i.value),o||e.preventDefault())}),r&&f&&(u(f,"submit",e=>{o||e.preventDefault(),r(i.value)}),f.querySelectorAll("[type=submit]").forEach(e=>{u(e,"click",s=>{o||s.preventDefault(),r(i.value)})})),a&&u(i,"click",()=>a(i.value)),n&&u(i,"focus",()=>n(i.value)),d&&u(i,"input",()=>d(i.value)),{destroy(){t.forEach(e=>e())}}}exports.deepMerge=l.deepMerge;exports.measure=l.measure;exports.mergeArrays=l.mergeArrays;exports.unique=l.unique;exports.isBot=v.isBot;exports.isEqual=p.isEqual;exports.isPlainObject=p.isPlainObject;exports.logger=p.logger;exports.parseNumber=y.parseNumber;exports.pick=k.pick;exports.bindInput=A;exports.disableNativeAutocomplete=b;
|
package/dist/utils/utils.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as x } from "../
|
|
2
|
-
import { i as
|
|
1
|
+
import { d as x, a as A, m as n, u as q } from "../unique-DxrT0M20.js";
|
|
2
|
+
import { i as L } from "../isBot-C58Y7eiv.js";
|
|
3
3
|
import { i as t, a as w, l as N } from "../logger-DVwg4Wor.js";
|
|
4
4
|
import { p as j } from "../parseNumber-QA48nJLp.js";
|
|
5
5
|
import { p as M } from "../pick-DReBictn.js";
|
|
@@ -29,13 +29,13 @@ export {
|
|
|
29
29
|
y as bindInput,
|
|
30
30
|
x as deepMerge,
|
|
31
31
|
k as disableNativeAutocomplete,
|
|
32
|
-
|
|
32
|
+
L as isBot,
|
|
33
33
|
t as isEqual,
|
|
34
34
|
w as isPlainObject,
|
|
35
35
|
N as logger,
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
A as measure,
|
|
37
|
+
n as mergeArrays,
|
|
38
38
|
j as parseNumber,
|
|
39
39
|
M as pick,
|
|
40
|
-
|
|
40
|
+
q as unique
|
|
41
41
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nosto/search-js",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -32,40 +32,45 @@
|
|
|
32
32
|
"import": "./dist/thumbnails/thumbnails.es.js",
|
|
33
33
|
"require": "./dist/thumbnails/thumbnails.cjs.js"
|
|
34
34
|
},
|
|
35
|
-
"./preact/
|
|
36
|
-
"types": "./dist/preact/
|
|
37
|
-
"import": "./dist/preact/
|
|
38
|
-
"require": "./dist/preact/
|
|
39
|
-
},
|
|
40
|
-
"./utils": {
|
|
41
|
-
"types": "./dist/utils/utils.d.ts",
|
|
42
|
-
"import": "./dist/utils/utils.es.js",
|
|
43
|
-
"require": "./dist/utils/utils.cjs.js"
|
|
35
|
+
"./preact/autocomplete": {
|
|
36
|
+
"types": "./dist/preact/autocomplete/autocomplete.d.ts",
|
|
37
|
+
"import": "./dist/preact/autocomplete/autocomplete.es.js",
|
|
38
|
+
"require": "./dist/preact/autocomplete/autocomplete.cjs.js"
|
|
44
39
|
},
|
|
45
40
|
"./preact/common": {
|
|
46
|
-
"types": "./dist/preact/common.d.ts",
|
|
47
|
-
"import": "./dist/preact/common.es.js",
|
|
48
|
-
"require": "./dist/preact/common.cjs.js"
|
|
49
|
-
},
|
|
50
|
-
"./preact/serp": {
|
|
51
|
-
"types": "./dist/preact/serp.d.ts",
|
|
52
|
-
"import": "./dist/preact/serp.es.js",
|
|
53
|
-
"require": "./dist/preact/serp.cjs.js"
|
|
41
|
+
"types": "./dist/preact/common/common.d.ts",
|
|
42
|
+
"import": "./dist/preact/common/common.es.js",
|
|
43
|
+
"require": "./dist/preact/common/common.cjs.js"
|
|
54
44
|
},
|
|
55
45
|
"./preact/category": {
|
|
56
|
-
"types": "./dist/preact/category.d.ts",
|
|
57
|
-
"import": "./dist/preact/category.es.js",
|
|
58
|
-
"require": "./dist/preact/category.cjs.js"
|
|
46
|
+
"types": "./dist/preact/category/category.d.ts",
|
|
47
|
+
"import": "./dist/preact/category/category.es.js",
|
|
48
|
+
"require": "./dist/preact/category/category.cjs.js"
|
|
59
49
|
},
|
|
60
|
-
"./preact/
|
|
61
|
-
"types": "./dist/preact/
|
|
62
|
-
"import": "./dist/preact/
|
|
63
|
-
"require": "./dist/preact/
|
|
50
|
+
"./preact/events": {
|
|
51
|
+
"types": "./dist/preact/events/events.d.ts",
|
|
52
|
+
"import": "./dist/preact/events/events.es.js",
|
|
53
|
+
"require": "./dist/preact/events/events.cjs.js"
|
|
64
54
|
},
|
|
65
55
|
"./preact/hooks": {
|
|
66
|
-
"types": "./dist/preact/hooks.d.ts",
|
|
67
|
-
"import": "./dist/preact/hooks.es.js",
|
|
68
|
-
"require": "./dist/preact/hooks.cjs.js"
|
|
56
|
+
"types": "./dist/preact/hooks/hooks.d.ts",
|
|
57
|
+
"import": "./dist/preact/hooks/hooks.es.js",
|
|
58
|
+
"require": "./dist/preact/hooks/hooks.cjs.js"
|
|
59
|
+
},
|
|
60
|
+
"./preact/legacy": {
|
|
61
|
+
"types": "./dist/preact/legacy/legacy.d.ts",
|
|
62
|
+
"import": "./dist/preact/legacy/legacy.es.js",
|
|
63
|
+
"require": "./dist/preact/legacy/legacy.cjs.js"
|
|
64
|
+
},
|
|
65
|
+
"./preact/serp": {
|
|
66
|
+
"types": "./dist/preact/serp/serp.d.ts",
|
|
67
|
+
"import": "./dist/preact/serp/serp.es.js",
|
|
68
|
+
"require": "./dist/preact/serp/serp.cjs.js"
|
|
69
|
+
},
|
|
70
|
+
"./utils": {
|
|
71
|
+
"types": "./dist/utils/utils.d.ts",
|
|
72
|
+
"import": "./dist/utils/utils.es.js",
|
|
73
|
+
"require": "./dist/utils/utils.cjs.js"
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"keywords": [],
|
|
@@ -76,7 +81,8 @@
|
|
|
76
81
|
"dev:library": "vite build --watch",
|
|
77
82
|
"dev:preact": "cd dev/preact && npm run dev",
|
|
78
83
|
"typedoc": "typedoc --treatWarningsAsErrors",
|
|
79
|
-
"test": "
|
|
84
|
+
"test": "npm run test:core && (cd dev/preact && npm run test)",
|
|
85
|
+
"test:core": "vitest --run --coverage",
|
|
80
86
|
"test:watch": "vitest",
|
|
81
87
|
"lint": "eslint",
|
|
82
88
|
"lint-fix": "eslint --fix",
|
|
@@ -90,11 +96,11 @@
|
|
|
90
96
|
"@testing-library/dom": "^10.4.0",
|
|
91
97
|
"@types/dom-speech-recognition": "^0.0.6",
|
|
92
98
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
93
|
-
"@types/node": "^24.0.
|
|
99
|
+
"@types/node": "^24.0.13",
|
|
94
100
|
"@vitest/coverage-v8": "^3.2.4",
|
|
95
101
|
"concurrently": "^9.2.0",
|
|
96
102
|
"copyfiles": "^2.4.1",
|
|
97
|
-
"eslint": "^9.
|
|
103
|
+
"eslint": "^9.31.0",
|
|
98
104
|
"eslint-config-prettier": "^10.1.5",
|
|
99
105
|
"eslint-plugin-barrel-files": "^3.0.1",
|
|
100
106
|
"eslint-plugin-prettier": "^5.5.1",
|
|
@@ -108,8 +114,8 @@
|
|
|
108
114
|
"prettier": "^3.6.2",
|
|
109
115
|
"typedoc": "^0.28.7",
|
|
110
116
|
"typescript": "^5.8.3",
|
|
111
|
-
"typescript-eslint": "^8.
|
|
112
|
-
"vite": "^7.0.
|
|
117
|
+
"typescript-eslint": "^8.37.0",
|
|
118
|
+
"vite": "^7.0.4",
|
|
113
119
|
"vite-plugin-dts": "^4.5.4",
|
|
114
120
|
"vitest": "^3.1.3"
|
|
115
121
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-Cflxq0FH.cjs"),N=require("./logger-BcHMZObS.cjs"),x=require("./pick-rYi1lc2m.cjs"),u=require("preact"),h=require("preact/hooks");function A(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 M(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 U=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)}U(e,r,t,o)};var b=u.options.unmount;function E(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=A({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return E(o,r,t)})),e}function P(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return P(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 R(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=R(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]=P(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]=E(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=R(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 q=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,I=/^(?: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]/,W=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,V=/[A-Z0-9]/g,j=typeof document<"u",F=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 H(){}function L(){return this.cancelBubble}function z(){return this.defaultPrevented}u.options.event=function(e){return k&&(e=k(e)),e.persist=H,e.isPropagationStopped=L,e.isDefaultPrevented=z,e.nativeEvent=e};var B={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||j&&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"||F(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":W.test(i)&&(i=l):l=i="oninput":s&&I.test(i)?i=i.replace(V,"-$&").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",B)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=q,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 S(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 D(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}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 S(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 $=M(T,N.isEqual);exports.InfiniteScrollWithObserver=$;exports.hasMoreResults=S;exports.intersectionObserverSupported=D;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./index.es-DlUp67LT.cjs"),o=require("./logger-BcHMZObS.cjs"),i=require("preact/hooks");function s(){i.useEffect(()=>{const e=window.setTimeout(()=>{o.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);t.s(()=>{window.clearTimeout(e)})},[])}const r={defaultCurrency:"EUR",queryModifications:e=>e};exports.defaultBaseConfig=r;exports.useCheckClientScript=s;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { s as e } from "./index.es-B8mbAxS4.js";
|
|
2
|
-
import { l as t } from "./logger-DVwg4Wor.js";
|
|
3
|
-
import { useEffect as r } from "preact/hooks";
|
|
4
|
-
function c() {
|
|
5
|
-
r(() => {
|
|
6
|
-
const o = window.setTimeout(() => {
|
|
7
|
-
t.error("Nosto client script has not loaded after 3 seconds.");
|
|
8
|
-
}, 3e3);
|
|
9
|
-
e(() => {
|
|
10
|
-
window.clearTimeout(o);
|
|
11
|
-
});
|
|
12
|
-
}, []);
|
|
13
|
-
}
|
|
14
|
-
const a = {
|
|
15
|
-
defaultCurrency: "EUR",
|
|
16
|
-
queryModifications: (o) => o
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
a as d,
|
|
20
|
-
c as u
|
|
21
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("preact"),u=require("./deepMerge-lDscDfII.cjs"),E=require("./logger-BcHMZObS.cjs"),M=require("preact/hooks");function l(e,i={}){const r=new Map;let o=u.deepMergePlain(e,i??{});const d=u.deepMergePlain(e,i);function S(t){o=t(o);for(const n of r.values())n(o)}function x(t){S(n=>({...n,...t}))}function p(){return o}function h(){return structuredClone(d)}function q(t,n){let c;r.set(n,w=>{const a=t(w);E.isEqual(a,c)||(c=a,n(a))})}function b(t){r.delete(t)}return{updateState:x,getState:p,getInitialState:h,onChange:q,clearOnChange:b}}const f={loading:!0,query:{},response:{},initialized:!1};function g(e={}){return l(f,e)}const P=s.createContext(g()),C=s.createContext(null),k=()=>{const e=M.useContext(C);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};exports.ConfigContext=C;exports.StoreContext=P;exports.createExtendableStore=l;exports.createStore=g;exports.defaultState=f;exports.useConfig=k;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { createContext as c } from "preact";
|
|
2
|
-
import { a as u } from "./deepMerge-CZwCJzEe.js";
|
|
3
|
-
import { i as x } from "./logger-DVwg4Wor.js";
|
|
4
|
-
import { useContext as h } from "preact/hooks";
|
|
5
|
-
function w(t, i = {}) {
|
|
6
|
-
const a = /* @__PURE__ */ new Map();
|
|
7
|
-
let o = u(t, i ?? {});
|
|
8
|
-
const f = u(t, i);
|
|
9
|
-
function l(e) {
|
|
10
|
-
o = e(o);
|
|
11
|
-
for (const n of a.values())
|
|
12
|
-
n(o);
|
|
13
|
-
}
|
|
14
|
-
function C(e) {
|
|
15
|
-
l((n) => ({ ...n, ...e }));
|
|
16
|
-
}
|
|
17
|
-
function g() {
|
|
18
|
-
return o;
|
|
19
|
-
}
|
|
20
|
-
function p() {
|
|
21
|
-
return structuredClone(f);
|
|
22
|
-
}
|
|
23
|
-
function d(e, n) {
|
|
24
|
-
let s;
|
|
25
|
-
a.set(n, (S) => {
|
|
26
|
-
const r = e(S);
|
|
27
|
-
x(r, s) || (s = r, n(r));
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function m(e) {
|
|
31
|
-
a.delete(e);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
updateState: C,
|
|
35
|
-
getState: g,
|
|
36
|
-
getInitialState: p,
|
|
37
|
-
onChange: d,
|
|
38
|
-
clearOnChange: m
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const b = {
|
|
42
|
-
loading: !0,
|
|
43
|
-
query: {},
|
|
44
|
-
response: {},
|
|
45
|
-
initialized: !1
|
|
46
|
-
};
|
|
47
|
-
function E(t = {}) {
|
|
48
|
-
return w(b, t);
|
|
49
|
-
}
|
|
50
|
-
const y = c(E()), q = c(null), z = () => {
|
|
51
|
-
const t = h(q);
|
|
52
|
-
if (!t)
|
|
53
|
-
throw new Error("useConfig must be used within a ConfigProvider");
|
|
54
|
-
return t;
|
|
55
|
-
};
|
|
56
|
-
export {
|
|
57
|
-
q as C,
|
|
58
|
-
y as S,
|
|
59
|
-
w as a,
|
|
60
|
-
E as c,
|
|
61
|
-
b as d,
|
|
62
|
-
z as u
|
|
63
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { a as u } from "./logger-DVwg4Wor.js";
|
|
2
|
-
function o(...e) {
|
|
3
|
-
return f(...e);
|
|
4
|
-
}
|
|
5
|
-
function f(...e) {
|
|
6
|
-
return e.reduce((n, r) => c(n, r));
|
|
7
|
-
}
|
|
8
|
-
function c(e, n) {
|
|
9
|
-
return u(e) && u(n) ? Object.entries(n).reduce(
|
|
10
|
-
(r, [i, t]) => (r[i] = c(r[i], t), r),
|
|
11
|
-
{ ...e }
|
|
12
|
-
) : u(e) ? e : n;
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
f as a,
|
|
16
|
-
o as d
|
|
17
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./logger-BcHMZObS.cjs");function s(...e){return c(...e)}function c(...e){return e.reduce((n,r)=>t(n,r))}function t(e,n){return i.isPlainObject(e)&&i.isPlainObject(n)?Object.entries(n).reduce((r,[u,l])=>(r[u]=t(r[u],l),r),{...e}):i.isPlainObject(e)?e:n}exports.deepMerge=s;exports.deepMergePlain=c;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../jsxRuntime.module-B3sGoTIU.cjs"),s=require("../index.es-DlUp67LT.cjs"),p=require("preact/hooks"),m=require("../BaseElement-Ds4INJSy.cjs"),i=require("../configContext-BR7w4VlU.cjs"),a=require("../baseConfig-BFFqFSg5.cjs");function f({children:e,hit:t,as:o,componentProps:n}){const r=p.useCallback(()=>{t&&"productId"in t&&s.s(c=>c.recordSearchClick("autocomplete",t))},[t]);return u.u(m.BaseElement,{onClick:r,as:o,componentProps:n,children:e})}function C({as:e,componentProps:t,onSearchInput:o,children:n}){const r={...t,onInput:l=>{o(l.target)}},c=e??"input";return e||(r.type="search"),u.u(c,{...r,children:n})}const d={...a.defaultBaseConfig,memoryCache:!1};function g(e){return{pageType:"autocomplete",...d,...e}}function S({config:e,store:t,children:o}){const n=t??i.createStore();return a.useCheckClientScript(),u.u(i.ConfigContext,{value:g(e),children:u.u(i.StoreContext,{value:n,children:o})})}exports.AutocompleteElement=f;exports.AutocompletePageProvider=S;exports.SearchInput=C;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/** @module preact/autocomplete */
|
|
2
|
-
export { AutocompleteElement, type AutocompleteElementProps } from './src/components/AutocompleteElement';
|
|
3
|
-
export { SearchInput } from './src/components/SearchInput';
|
|
4
|
-
export type { PublicAutocompleteConfig as AutocompleteConfig } from './src/config/pages/autocomplete/config';
|
|
5
|
-
export { AutocompletePageProvider } from './src/config/pages/autocomplete/provider';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { u as c } from "../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
|
-
import { s as m } from "../index.es-B8mbAxS4.js";
|
|
3
|
-
import { useCallback as p } from "preact/hooks";
|
|
4
|
-
import { B as i } from "../BaseElement-fZSwbg09.js";
|
|
5
|
-
import { c as l, S as f, C as s } from "../configContext-GuZOIX3o.js";
|
|
6
|
-
import { d as C, u as d } from "../baseConfig-Bafl02NY.js";
|
|
7
|
-
function B({
|
|
8
|
-
children: e,
|
|
9
|
-
hit: o,
|
|
10
|
-
as: t,
|
|
11
|
-
componentProps: r
|
|
12
|
-
}) {
|
|
13
|
-
const n = p(() => {
|
|
14
|
-
o && "productId" in o && m((a) => a.recordSearchClick("autocomplete", o));
|
|
15
|
-
}, [o]);
|
|
16
|
-
return /* @__PURE__ */ c(i, { onClick: n, as: t, componentProps: r, children: e });
|
|
17
|
-
}
|
|
18
|
-
function I({ as: e, componentProps: o, onSearchInput: t, children: r }) {
|
|
19
|
-
const n = {
|
|
20
|
-
...o,
|
|
21
|
-
onInput: (u) => {
|
|
22
|
-
t(u.target);
|
|
23
|
-
}
|
|
24
|
-
}, a = e ?? "input";
|
|
25
|
-
return e || (n.type = "search"), /* @__PURE__ */ c(a, { ...n, children: r });
|
|
26
|
-
}
|
|
27
|
-
const g = {
|
|
28
|
-
...C,
|
|
29
|
-
memoryCache: !1
|
|
30
|
-
};
|
|
31
|
-
function S(e) {
|
|
32
|
-
return {
|
|
33
|
-
pageType: "autocomplete",
|
|
34
|
-
...g,
|
|
35
|
-
...e
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function P({ config: e, store: o, children: t }) {
|
|
39
|
-
const r = o ?? l();
|
|
40
|
-
return d(), /* @__PURE__ */ c(s, { value: S(e), children: /* @__PURE__ */ c(f, { value: r, children: t }) });
|
|
41
|
-
}
|
|
42
|
-
export {
|
|
43
|
-
B as AutocompleteElement,
|
|
44
|
-
P as AutocompletePageProvider,
|
|
45
|
-
I as SearchInput
|
|
46
|
-
};
|