@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
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as
|
|
3
|
-
import { n as
|
|
4
|
-
import { S as $, m as
|
|
1
|
+
import { A as L, m as j } from "../../AutocompletePageProvider-DI2PONk8.js";
|
|
2
|
+
import { C as O, m as R } from "../../CategoryPageProvider-DcQlylFg.js";
|
|
3
|
+
import { n as T, c as p } from "../../useActions-MsVW37eV.js";
|
|
4
|
+
import { S as $, m as F } from "../../SerpPageProvider-CsrFA6mA.js";
|
|
5
5
|
import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
6
|
-
import { E as
|
|
7
|
-
import { d as
|
|
8
|
-
import { a as
|
|
9
|
-
import {
|
|
10
|
-
import { l as
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
t && clearTimeout(t), t = setTimeout(n, e);
|
|
6
|
+
import { E as h } from "../../ErrorBoundary-DTRm_60r.js";
|
|
7
|
+
import { d as k, b as B } from "../../disableNativeAutocomplete-Bkta_WR2.js";
|
|
8
|
+
import { a as I } from "../../unique-Cv2g464w.js";
|
|
9
|
+
import { render as y } from "preact";
|
|
10
|
+
import { l as q } from "../../logger-_fg_Za9y.js";
|
|
11
|
+
import { g as w, a as Q } from "../../search-mArZ2PXy.js";
|
|
12
|
+
function U(e) {
|
|
13
|
+
let n;
|
|
14
|
+
return (t) => {
|
|
15
|
+
n && clearTimeout(n), n = setTimeout(t, e);
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
|
-
function
|
|
18
|
+
function b(e) {
|
|
20
19
|
return Array.from(document.querySelectorAll(e));
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
for (;
|
|
26
|
-
|
|
27
|
-
return
|
|
21
|
+
function K(e) {
|
|
22
|
+
const n = [];
|
|
23
|
+
let t = e.parentNode;
|
|
24
|
+
for (; t && t !== document && t instanceof Element; )
|
|
25
|
+
n.push(t), t = t.parentNode;
|
|
26
|
+
return n;
|
|
28
27
|
}
|
|
29
|
-
function
|
|
28
|
+
function S([e, n], t) {
|
|
30
29
|
const o = (r) => {
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
const s = r.target;
|
|
31
|
+
s instanceof HTMLElement && e && s !== e && s !== n && !K(s).includes(e) && t();
|
|
33
32
|
};
|
|
34
33
|
return document.addEventListener("click", o), {
|
|
35
34
|
destroy: () => {
|
|
@@ -37,8 +36,8 @@ function b([e, t], n) {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
function E(e,
|
|
41
|
-
e.tabIndex = 0, e.addEventListener("blur",
|
|
39
|
+
function E(e, n) {
|
|
40
|
+
e.tabIndex = 0, e.addEventListener("blur", n);
|
|
42
41
|
}
|
|
43
42
|
function C(e) {
|
|
44
43
|
return typeof e == "string" ? {
|
|
@@ -49,304 +48,274 @@ function C(e) {
|
|
|
49
48
|
...e
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
function
|
|
53
|
-
return new Promise((
|
|
54
|
-
const o =
|
|
51
|
+
function N({ selector: e, timeout: n = 500 }) {
|
|
52
|
+
return new Promise((t) => {
|
|
53
|
+
const o = b(e);
|
|
55
54
|
if (o.length > 0)
|
|
56
|
-
return
|
|
55
|
+
return t(o);
|
|
57
56
|
const r = new MutationObserver(() => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
}),
|
|
61
|
-
r.disconnect(),
|
|
62
|
-
},
|
|
57
|
+
const i = b(e);
|
|
58
|
+
i.length > 0 && (r.disconnect(), clearTimeout(s), t(i));
|
|
59
|
+
}), s = setTimeout(() => {
|
|
60
|
+
r.disconnect(), q.warn(`Timed out (${n}) while waiting for element ${e}`), t([]);
|
|
61
|
+
}, n);
|
|
63
62
|
r.observe(document.body, {
|
|
64
63
|
childList: !0,
|
|
65
64
|
subtree: !0
|
|
66
65
|
});
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
reportKeywordClick: () => {
|
|
73
|
-
},
|
|
74
|
-
handleSubmit: () => {
|
|
75
|
-
},
|
|
76
|
-
highlightedElementIndex: -1
|
|
77
|
-
});
|
|
78
|
-
function G(e, t) {
|
|
79
|
-
const { dropdown: n, history: o, store: r, input: i, onNavigateToSearch: s } = e, a = (c, h) => {
|
|
80
|
-
n.hide(), o.hide(), c && (o.add(c), r.updateState({
|
|
81
|
-
historyItems: o.get()
|
|
82
|
-
}), h && Q((l) => l.recordSearchSubmit(c)), i.value = c);
|
|
83
|
-
};
|
|
84
|
-
return {
|
|
85
|
-
reportProductClick: (c) => {
|
|
86
|
-
a(c.name, !1);
|
|
87
|
-
},
|
|
88
|
-
reportKeywordClick: (c) => {
|
|
89
|
-
a(c.keyword, !0);
|
|
90
|
-
},
|
|
91
|
-
handleSubmit: (c) => {
|
|
92
|
-
a(c.query, !1), s?.(c);
|
|
93
|
-
},
|
|
94
|
-
highlightedElementIndex: t.highlightedIndex()
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function N(e, t, n) {
|
|
98
|
-
t.style.display = "none";
|
|
68
|
+
function H(e, n, t) {
|
|
69
|
+
n.style.display = "none";
|
|
99
70
|
const o = (() => {
|
|
100
71
|
if (e.parentElement && e.parentElement.classList.contains("nosto-autocomplete-wrapper"))
|
|
101
72
|
return e.parentElement;
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
})(), r = C(
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
73
|
+
const a = document.createElement("div");
|
|
74
|
+
return a.className = "nosto-autocomplete-wrapper", e.parentNode?.insertBefore(a, e.nextSibling), a.appendChild(e), a;
|
|
75
|
+
})(), r = C(t), s = r && document.querySelector(r.selector);
|
|
76
|
+
if (s) {
|
|
77
|
+
const a = document.createElement("form");
|
|
78
|
+
a.className = "nosto-dropdown-form", a.appendChild(n), r.position === "first" ? s.prepend(a) : s.appendChild(a);
|
|
108
79
|
} else
|
|
109
|
-
o.appendChild(
|
|
110
|
-
const
|
|
80
|
+
o.appendChild(n);
|
|
81
|
+
const i = {
|
|
111
82
|
index: -1,
|
|
112
83
|
onChangeListeners: []
|
|
113
|
-
},
|
|
114
|
-
const f =
|
|
115
|
-
f === 0 && (m = -1),
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
},
|
|
84
|
+
}, c = (a, m) => {
|
|
85
|
+
const f = a.length;
|
|
86
|
+
f === 0 && (m = -1), i.index = m >= 0 ? m % f : f - 1, i.onChangeListeners.forEach((D) => D());
|
|
87
|
+
}, l = () => {
|
|
88
|
+
i.index = -1, i.onChangeListeners.forEach((a) => a());
|
|
89
|
+
}, u = () => i.index;
|
|
119
90
|
return {
|
|
120
|
-
element:
|
|
91
|
+
element: n,
|
|
121
92
|
hide: () => {
|
|
122
|
-
|
|
93
|
+
n.style.display = "none", l();
|
|
123
94
|
},
|
|
124
95
|
show: () => {
|
|
125
|
-
|
|
96
|
+
n.style.display = "inherit";
|
|
126
97
|
},
|
|
127
|
-
isOpen: () =>
|
|
98
|
+
isOpen: () => n.style.display !== "none",
|
|
128
99
|
goDown: () => {
|
|
129
|
-
const
|
|
130
|
-
a
|
|
100
|
+
const a = Array.from(n.getElementsByClassName("ns-autocomplete-element")), m = u();
|
|
101
|
+
c(a, m + 1);
|
|
131
102
|
},
|
|
132
103
|
goUp: () => {
|
|
133
|
-
const
|
|
134
|
-
a
|
|
104
|
+
const a = Array.from(n.getElementsByClassName("ns-autocomplete-element")), m = u();
|
|
105
|
+
c(a, m - 1);
|
|
135
106
|
},
|
|
136
|
-
highlight:
|
|
137
|
-
highlightedIndex:
|
|
138
|
-
submitHighlightedItem: (
|
|
139
|
-
Array.from(
|
|
107
|
+
highlight: c,
|
|
108
|
+
highlightedIndex: u,
|
|
109
|
+
submitHighlightedItem: (a) => {
|
|
110
|
+
Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click();
|
|
140
111
|
},
|
|
141
|
-
onHighlightChange: (
|
|
142
|
-
|
|
112
|
+
onHighlightChange: (a) => {
|
|
113
|
+
i.onChangeListeners.push(a);
|
|
143
114
|
}
|
|
144
115
|
};
|
|
145
116
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
...
|
|
150
|
-
element:
|
|
117
|
+
function M(e, n) {
|
|
118
|
+
const t = document.createElement("div");
|
|
119
|
+
return t.className = "nosto-autocomplete-dropdown", {
|
|
120
|
+
...H(e, t, n),
|
|
121
|
+
element: t
|
|
151
122
|
};
|
|
152
123
|
}
|
|
153
124
|
const g = "nosto:search-js:history";
|
|
154
|
-
function
|
|
125
|
+
function v(e, n, t) {
|
|
155
126
|
const o = document.createElement("div");
|
|
156
127
|
return o.className = "nosto-autocomplete-history", {
|
|
157
|
-
...
|
|
128
|
+
...H(e, o, n),
|
|
158
129
|
element: o,
|
|
159
|
-
add: (
|
|
160
|
-
const
|
|
161
|
-
|
|
130
|
+
add: (s) => {
|
|
131
|
+
const c = (w(g) ?? []).filter((l) => l !== s).slice(t ? -t : 0);
|
|
132
|
+
c.push(s), Q(g, c);
|
|
162
133
|
},
|
|
163
|
-
get: () => (w(g) ?? []).reverse().filter((
|
|
134
|
+
get: () => (w(g) ?? []).reverse().filter((i) => !!i)
|
|
164
135
|
};
|
|
165
136
|
}
|
|
166
|
-
async function
|
|
167
|
-
const { historyEnabled:
|
|
168
|
-
if (e.length <
|
|
137
|
+
async function z(e, { config: n, dropdown: t, history: o, renderHistory: r, store: s }) {
|
|
138
|
+
const { historyEnabled: i, minQueryLength: c } = n;
|
|
139
|
+
if (e.length < c && i && r && !o.isOpen()) {
|
|
169
140
|
o.show();
|
|
170
141
|
return;
|
|
171
142
|
}
|
|
172
|
-
if (e.length <
|
|
143
|
+
if (e.length < c)
|
|
173
144
|
return;
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
145
|
+
t.hide();
|
|
146
|
+
const l = s.getState()?.query?.query;
|
|
147
|
+
l && l !== e && await T({ config: n, store: s }, { query: e }), t.show();
|
|
177
148
|
}
|
|
178
|
-
async function
|
|
179
|
-
const { config:
|
|
180
|
-
if (!o || e.length >=
|
|
149
|
+
async function G(e, n) {
|
|
150
|
+
const { config: t, renderHistory: o, history: r } = n, { historyEnabled: s, minQueryLength: i } = t;
|
|
151
|
+
if (!o || e.length >= i || !s || r.isOpen())
|
|
181
152
|
return;
|
|
182
|
-
const
|
|
153
|
+
const c = x(n);
|
|
183
154
|
r.onHighlightChange(() => {
|
|
184
|
-
|
|
155
|
+
c(o, r.element);
|
|
185
156
|
}), r.show();
|
|
186
|
-
const
|
|
187
|
-
|
|
157
|
+
const l = I("renderHistory");
|
|
158
|
+
c(o, r.element), l();
|
|
188
159
|
}
|
|
189
|
-
async function
|
|
190
|
-
const { minQueryLength:
|
|
191
|
-
if (e.length <
|
|
192
|
-
|
|
160
|
+
async function J(e, { config: n, dropdown: t, history: o, store: r, debouncer: s }) {
|
|
161
|
+
const { minQueryLength: i, historyEnabled: c } = n;
|
|
162
|
+
if (e.length < i && !c) {
|
|
163
|
+
t.hide(), o.hide();
|
|
193
164
|
return;
|
|
194
165
|
}
|
|
195
|
-
if (e.length <
|
|
196
|
-
|
|
166
|
+
if (e.length < i && c) {
|
|
167
|
+
t.hide(), o.show();
|
|
197
168
|
return;
|
|
198
169
|
}
|
|
199
|
-
o.hide(),
|
|
200
|
-
|
|
170
|
+
o.hide(), s(async () => {
|
|
171
|
+
T({ config: n, store: r }, { query: e }), t.show();
|
|
201
172
|
});
|
|
202
173
|
}
|
|
203
|
-
function
|
|
204
|
-
const { config: o, debouncer: r } =
|
|
174
|
+
function V(e, n, t) {
|
|
175
|
+
const { config: o, debouncer: r } = t;
|
|
205
176
|
if (r(() => {
|
|
206
177
|
}), e.length >= o.minQueryLength)
|
|
207
|
-
return A(
|
|
178
|
+
return A(n, t.dropdown, t.history);
|
|
208
179
|
if (o.historyEnabled)
|
|
209
|
-
return A(
|
|
180
|
+
return A(n, t.history, t.dropdown);
|
|
210
181
|
}
|
|
211
|
-
function A(e,
|
|
212
|
-
if (!
|
|
213
|
-
|
|
182
|
+
function A(e, n, t) {
|
|
183
|
+
if (!n.isOpen() && e === "ArrowDown") {
|
|
184
|
+
n.show(), t.hide();
|
|
214
185
|
return;
|
|
215
186
|
}
|
|
216
|
-
if (e === "Escape" &&
|
|
187
|
+
if (e === "Escape" && n.hide(), !!n.isOpen()) {
|
|
217
188
|
if (e === "ArrowDown")
|
|
218
|
-
|
|
189
|
+
n.goDown();
|
|
219
190
|
else if (e === "ArrowUp")
|
|
220
|
-
|
|
191
|
+
n.goUp();
|
|
221
192
|
else if (e === "Enter") {
|
|
222
|
-
const o =
|
|
223
|
-
return o >= 0 &&
|
|
193
|
+
const o = n.highlightedIndex();
|
|
194
|
+
return o >= 0 && n.submitHighlightedItem(o), n.hide(), o >= 0;
|
|
224
195
|
}
|
|
225
196
|
}
|
|
226
197
|
}
|
|
227
|
-
function
|
|
228
|
-
|
|
198
|
+
function W(e, { config: n, dropdown: t, history: o, onNavigateToSearch: r, store: s }) {
|
|
199
|
+
t.hide(), o.hide(), !(e.length < n.minQueryLength) && (o.add(e), s.updateState({
|
|
229
200
|
historyItems: o.get()
|
|
230
201
|
}), r?.({
|
|
231
202
|
query: e
|
|
232
203
|
}));
|
|
233
204
|
}
|
|
234
|
-
async function
|
|
235
|
-
const { inputCssSelector:
|
|
205
|
+
async function X(e, n) {
|
|
206
|
+
const { inputCssSelector: t, timeout: o } = e, r = C(t).selector, s = await N({
|
|
236
207
|
selector: r,
|
|
237
208
|
timeout: o
|
|
238
209
|
});
|
|
239
|
-
if (
|
|
210
|
+
if (s.length === 0)
|
|
240
211
|
throw new Error(`No elements found for selector: ${r}`);
|
|
241
|
-
|
|
242
|
-
|
|
212
|
+
s.forEach((i) => {
|
|
213
|
+
Y(i, e, n);
|
|
243
214
|
});
|
|
244
215
|
}
|
|
245
|
-
async function
|
|
246
|
-
const { config: o, dropdownCssSelector: r } =
|
|
247
|
-
...
|
|
216
|
+
async function Y(e, n, t) {
|
|
217
|
+
const { config: o, dropdownCssSelector: r } = n, s = M(e, r), i = v(e, r, o.historySize), c = {
|
|
218
|
+
...n,
|
|
248
219
|
input: e,
|
|
249
|
-
dropdown:
|
|
250
|
-
history:
|
|
251
|
-
store:
|
|
252
|
-
debouncer:
|
|
220
|
+
dropdown: s,
|
|
221
|
+
history: i,
|
|
222
|
+
store: t,
|
|
223
|
+
debouncer: U(o.debounceDelay)
|
|
253
224
|
};
|
|
254
|
-
|
|
255
|
-
historyItems:
|
|
256
|
-
}),
|
|
257
|
-
|
|
225
|
+
_(c), e.setAttribute("data-nosto-element", "search-input"), t.updateState({
|
|
226
|
+
historyItems: i.get()
|
|
227
|
+
}), k(e), t.onInit(() => {
|
|
228
|
+
Z(c);
|
|
258
229
|
}), B(e, {
|
|
259
|
-
onInput: (
|
|
260
|
-
onFocus: (
|
|
261
|
-
onClick: (
|
|
262
|
-
onSubmit: (
|
|
263
|
-
onKeyDown: (
|
|
264
|
-
}), E(
|
|
230
|
+
onInput: (l) => J(l, c),
|
|
231
|
+
onFocus: (l) => G(l, c),
|
|
232
|
+
onClick: (l) => z(l, c),
|
|
233
|
+
onSubmit: (l) => W(l, c),
|
|
234
|
+
onKeyDown: (l, u) => V(l, u, c)
|
|
235
|
+
}), E(i.element, i.hide), E(s.element, s.hide), S([i.element, e], i.hide), S([s.element, e], s.hide);
|
|
265
236
|
}
|
|
266
|
-
function
|
|
267
|
-
const { dropdown:
|
|
268
|
-
if (!
|
|
237
|
+
function Z(e) {
|
|
238
|
+
const { dropdown: n, renderAutocomplete: t } = e;
|
|
239
|
+
if (!t)
|
|
269
240
|
return;
|
|
270
|
-
const o =
|
|
271
|
-
|
|
272
|
-
o(
|
|
241
|
+
const o = x(e);
|
|
242
|
+
n.onHighlightChange(() => {
|
|
243
|
+
o(t, n.element);
|
|
273
244
|
});
|
|
274
|
-
const r =
|
|
275
|
-
o(
|
|
245
|
+
const r = I("renderAutocomplete");
|
|
246
|
+
o(t, n.element), r();
|
|
276
247
|
}
|
|
277
|
-
async function
|
|
278
|
-
const { input:
|
|
279
|
-
if (!
|
|
280
|
-
const
|
|
281
|
-
if (!!
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
const
|
|
248
|
+
async function _(e) {
|
|
249
|
+
const { input: n, renderSpeechToText: t, config: o, store: r } = e;
|
|
250
|
+
if (!t) return;
|
|
251
|
+
const s = "ns-autocomplete-voice-position";
|
|
252
|
+
if (!!n.parentElement?.querySelector(`.${s}`)) return;
|
|
253
|
+
const c = document.createElement("div");
|
|
254
|
+
c.className = s, n.insertAdjacentElement("afterend", c);
|
|
255
|
+
const l = await t();
|
|
285
256
|
y(
|
|
286
|
-
/* @__PURE__ */ d(
|
|
287
|
-
|
|
257
|
+
/* @__PURE__ */ d(h, { children: /* @__PURE__ */ d(L, { config: o, store: r, children: l }) }),
|
|
258
|
+
c
|
|
288
259
|
);
|
|
289
260
|
}
|
|
290
|
-
function
|
|
291
|
-
const { config: n, store:
|
|
292
|
-
return
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/* @__PURE__ */ d(u, { children: /* @__PURE__ */ d(I, { config: n, store: o, children: /* @__PURE__ */ d(z, { value: r, children: i() }) }) }),
|
|
296
|
-
s
|
|
261
|
+
function x(e) {
|
|
262
|
+
const { config: n, store: t } = e;
|
|
263
|
+
return (o, r) => y(
|
|
264
|
+
/* @__PURE__ */ d(h, { children: /* @__PURE__ */ d(L, { config: n, store: t, children: o() }) }),
|
|
265
|
+
r
|
|
297
266
|
);
|
|
298
267
|
}
|
|
299
|
-
async function
|
|
300
|
-
const o = C(e).selector, r = await
|
|
268
|
+
async function P({ cssSelector: e, timeout: n, renderComponent: t }) {
|
|
269
|
+
const o = C(e).selector, r = await N({
|
|
301
270
|
selector: o,
|
|
302
|
-
timeout:
|
|
271
|
+
timeout: n ?? 100
|
|
303
272
|
});
|
|
304
273
|
if (r.length === 0)
|
|
305
274
|
throw new Error(`No elements found for selector: ${o}`);
|
|
306
|
-
r.length > 1 &&
|
|
275
|
+
r.length > 1 && q.warn(`Multiple (${r.length}) elements found for selector: ${o}`), y(t(), r[0]);
|
|
307
276
|
}
|
|
308
|
-
async function
|
|
309
|
-
const { render:
|
|
310
|
-
|
|
277
|
+
async function ee(e, n) {
|
|
278
|
+
const { render: t } = e, o = await t();
|
|
279
|
+
P({
|
|
311
280
|
...e,
|
|
312
|
-
renderComponent: () => /* @__PURE__ */ d(
|
|
281
|
+
renderComponent: () => /* @__PURE__ */ d(h, { children: /* @__PURE__ */ d(O, { store: n, config: e.config, children: o }) })
|
|
313
282
|
});
|
|
314
283
|
}
|
|
315
|
-
async function
|
|
316
|
-
const { render:
|
|
317
|
-
|
|
284
|
+
async function ne(e, n) {
|
|
285
|
+
const { render: t } = e, o = await t();
|
|
286
|
+
P({
|
|
318
287
|
...e,
|
|
319
|
-
renderComponent: () => /* @__PURE__ */ d(
|
|
288
|
+
renderComponent: () => /* @__PURE__ */ d(h, { children: /* @__PURE__ */ d($, { store: n, config: e.config, children: o }) })
|
|
320
289
|
});
|
|
321
290
|
}
|
|
322
|
-
async function
|
|
291
|
+
async function he({ autocomplete: e, category: n, serp: t }) {
|
|
323
292
|
const o = {};
|
|
324
293
|
if (e) {
|
|
325
294
|
const r = p({ query: e.query });
|
|
326
|
-
await
|
|
295
|
+
await X(
|
|
327
296
|
{
|
|
328
297
|
...e,
|
|
329
|
-
config:
|
|
298
|
+
config: j(e.config)
|
|
330
299
|
},
|
|
331
300
|
r
|
|
332
301
|
), o.autocomplete = { store: r };
|
|
333
302
|
}
|
|
334
|
-
if (
|
|
335
|
-
const r = p({ query:
|
|
336
|
-
await
|
|
303
|
+
if (n) {
|
|
304
|
+
const r = p({ query: n.query });
|
|
305
|
+
await ee(
|
|
337
306
|
{
|
|
338
|
-
...
|
|
339
|
-
config:
|
|
307
|
+
...n,
|
|
308
|
+
config: R(n.config)
|
|
340
309
|
},
|
|
341
310
|
r
|
|
342
311
|
), o.category = { store: r };
|
|
343
312
|
}
|
|
344
|
-
if (
|
|
345
|
-
const r = p({ query:
|
|
346
|
-
await
|
|
313
|
+
if (t) {
|
|
314
|
+
const r = p({ query: t.query });
|
|
315
|
+
await ne(
|
|
347
316
|
{
|
|
348
|
-
...
|
|
349
|
-
config:
|
|
317
|
+
...t,
|
|
318
|
+
config: F(t.config)
|
|
350
319
|
},
|
|
351
320
|
r
|
|
352
321
|
), o.serp = { store: r };
|
|
@@ -354,6 +323,5 @@ async function Ce({ autocomplete: e, category: t, serp: n }) {
|
|
|
354
323
|
return o;
|
|
355
324
|
}
|
|
356
325
|
export {
|
|
357
|
-
|
|
358
|
-
Ce as init
|
|
326
|
+
he as init
|
|
359
327
|
};
|
|
@@ -12,4 +12,4 @@ export type AutocompleteInjectContext = AutocompleteInjectConfig & {
|
|
|
12
12
|
store: Store;
|
|
13
13
|
debouncer: ReturnType<typeof debounce>;
|
|
14
14
|
};
|
|
15
|
-
export declare function createUserComponentRenderer(injectContext: AutocompleteInjectContext
|
|
15
|
+
export declare function createUserComponentRenderer(injectContext: AutocompleteInjectContext): (renderer: () => VNode | Promise<VNode>, target: HTMLDivElement) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-Drtoxcu4.cjs"),r=require("../../InfiniteScrollWithObserver-BN-pDinB.cjs"),t=require("../../useLoadMore-DPYhbXHC.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as t, u as a } from "../../useActions-
|
|
2
|
-
import { I as s, i } from "../../InfiniteScrollWithObserver-
|
|
3
|
-
import { g as p } from "../../useLoadMore-
|
|
1
|
+
import { n as t, u as a } from "../../useActions-MsVW37eV.js";
|
|
2
|
+
import { I as s, i } from "../../InfiniteScrollWithObserver-CEtMyahq.js";
|
|
3
|
+
import { g as p } from "../../useLoadMore-BR-vDmqW.js";
|
|
4
4
|
export {
|
|
5
5
|
s as InfiniteScrollWithObserver,
|
|
6
6
|
p as getNextPageQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-Drtoxcu4.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-s4dO49Fx.cjs"),P="nosto:search-js:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { u as i } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
2
|
import { s as l } from "../../index.es-XNBESE3P.js";
|
|
3
3
|
import { B as m } from "../../BaseElement-DD_4UwDm.js";
|
|
4
|
-
import {
|
|
4
|
+
import { b as p } from "../../useActions-MsVW37eV.js";
|
|
5
5
|
import { useCallback as f } from "preact/hooks";
|
|
6
|
-
import { S as
|
|
6
|
+
import { S as h } from "../../SerpPageProvider-CsrFA6mA.js";
|
|
7
7
|
const S = "nosto:search-js:scrollPos";
|
|
8
8
|
function g() {
|
|
9
9
|
window.sessionStorage.setItem(S, window.scrollY.toString());
|
|
@@ -15,6 +15,6 @@ function C({ children: s, hit: o, componentProps: t, as: c }) {
|
|
|
15
15
|
return /* @__PURE__ */ i(m, { as: c, onClick: a, componentProps: t, children: s });
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
h as SearchPageProvider,
|
|
19
19
|
C as SerpElement
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const w=require("./index.es-Dp6Iaxz3.cjs"),i=require("./logger-Boh_C6Bz.cjs");async function y(t,{hitDecorators:e,...r},o){const n=await o(t,r);if(!n.products?.hits?.length||!e?.length)return n;const c=s=>e.reduce((a,u)=>u(a),s);return{...n,products:{...n.products,hits:n.products.hits.map(c)}}}function h(t,e,r){const o=JSON.stringify(e);try{r.setItem(t,o)}catch(n){i.logger.warn(n)}}function g(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function
|
|
1
|
+
"use strict";const w=require("./index.es-Dp6Iaxz3.cjs"),i=require("./logger-Boh_C6Bz.cjs");async function y(t,{hitDecorators:e,...r},o){const n=await o(t,r);if(!n.products?.hits?.length||!e?.length)return n;const c=s=>e.reduce((a,u)=>u(a),s);return{...n,products:{...n.products,hits:n.products.hits.map(c)}}}function h(t,e,r){const o=JSON.stringify(e);try{r.setItem(t,o)}catch(n){i.logger.warn(n)}}function g(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function I(t,e){h(t,e,localStorage)}function C(t,e){h(t,e,sessionStorage)}function R(t){return g(t,localStorage)}function b(t){return g(t,sessionStorage)}const p="nosto:search-js:cache",N=60*1e3;function T(t,e){C(p,{query:t,result:e,created:Date.now()})}function z(t){const e=b(p);if(!e||!E(e))return null;const r=d(e.query);return!i.isEqual(d(t),r)||Date.now()-e.created>N?null:e.result}function d(t){const e={...t,time:void 0,products:{...t.products,size:void 0}};return JSON.parse(JSON.stringify(e))}function E(t){return typeof t=="object"&&t!==null&&"query"in t&&"result"in t&&"created"in t}async function L(t,{usePersistentCache:e,...r},o){if(!e)return o(t,r);const n=await O(t,r,o);return T(t,n),n}async function O(t,e,r){const{from:o=0,size:n=0}=t.products||{},c=z(t);if(!c)return await r(t,e);const s=c?.products?.size??0,a=c?.products?.hits??[];if(n===s)return c;if(n<s)return{...c,products:{...c.products,size:n,hits:a.slice(0,n),total:c.products?.total||0}};const u=n-a.length,S=o>0?o+1:n-u,m={...t,products:{...t.products,from:S,size:u}},f=await r(m,e);return{...c,products:{...c.products,size:n,hits:[...c.products?.hits||[],...f.products?.hits||[]],total:f.products?.total||0}}}const J=3e4,l=new Map;function k(t,e){const r=l.get(t);if(!r)return;const o=Date.now()-r.created>J,n=i.isEqual(e,r.query);if(o||!n){l.delete(t);return}return r.result}function D(t,e,r){l.set(t,{query:e,result:r,created:Date.now()})}async function M(t,e,r){if(!e.useMemoryCache)return r(t,e);const o=JSON.stringify(t),n=k(o,t);if(n)return n;const c=await r(t,e);return D(o,t,c),c}function V(t){return new Promise(e=>setTimeout(e,t))}async function W(t,{maxRetries:e=0,retryInterval:r=0,...o},n){let c=0;for(;;)try{return await n(t,o)}catch(s){if(c>=e)throw s;if(!j(s))throw i.logger.info("Skipping retry logic for",s),s;c++,await V(r)}}function j(t){return!t||typeof t!="object"?!1:!("status"in t)||_(t.status)}function _(t){return typeof t=="number"&&(t<400||t>=500)}async function x(t,e={}){const r=await new Promise(w.s);return A(r.search,W,M,L,y)(t,e)}function A(t,...e){return e.reduce((r,o)=>(n,c)=>o(n,c,r),t)}exports.getLocalStorageItem=R;exports.search=x;exports.setLocalStorageItem=I;
|