@nosto/search-js 3.25.4 → 3.25.6
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-D48n1GB-.js +37 -0
- package/dist/AutocompletePageProvider-DzjwKsBp.cjs +1 -0
- package/dist/BaseElement-BnP6tQrH.cjs +1 -0
- package/dist/BaseElement-C25wjvSR.js +19 -0
- package/dist/CategoryPageProvider-B6w4FHhB.cjs +1 -0
- package/dist/CategoryPageProvider-BYw7KGoS.js +30 -0
- package/dist/ErrorBoundary-BtAe8lXu.cjs +1 -0
- package/dist/ErrorBoundary-Bxyssvki.js +11 -0
- package/dist/InfiniteScrollWithObserver-8imjYGGz.js +226 -0
- package/dist/InfiniteScrollWithObserver-k7oYk4f9.cjs +1 -0
- package/dist/SerpPageProvider-BgRZJNth.cjs +1 -0
- package/dist/SerpPageProvider-fg14kNV9.js +30 -0
- package/dist/baseConfig-Che6Adb6.js +50 -0
- package/dist/baseConfig-jLd7jchq.cjs +1 -0
- package/dist/cl-CYT5y6Dn.cjs +1 -0
- package/dist/cl-G5KK1qHD.js +6 -0
- package/dist/core/core.cjs.js +1 -1
- package/dist/core/core.es.js +8 -8
- package/dist/currencies/currencies.cjs.js +1 -1
- package/dist/currencies/currencies.es.js +61 -65
- package/dist/disableNativeAutocomplete-CcR_Ek_P.js +26 -0
- package/dist/disableNativeAutocomplete-CjBGhRWW.cjs +1 -0
- package/dist/eventBusDispatch-B6VswTu8.cjs +1 -0
- package/dist/eventBusDispatch-DnFmEqYe.js +15 -0
- package/dist/eventBusSubscribe-C6qT1aOO.js +22 -0
- package/dist/eventBusSubscribe-c9a_PP0j.cjs +1 -0
- package/dist/index.es-Ba4tuzxb.cjs +1 -0
- package/dist/index.es-jSYcbRvi.js +25 -0
- package/dist/{isBot-B05pQGIe.js → isBot-CPesLwHL.js} +18 -17
- package/dist/isBot-CkyQfegP.cjs +1 -0
- package/dist/jsxRuntime.module-BRdvPAre.js +30 -0
- package/dist/jsxRuntime.module-Ba9fccPy.cjs +1 -0
- package/dist/parseNumber-BH_92pM8.cjs +1 -0
- package/dist/parseNumber-DFsrGj64.js +9 -0
- package/dist/pick-0KNFTqKn.cjs +1 -0
- package/dist/pick-B8ymxJme.js +6 -0
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +49 -42
- package/dist/preact/category/category.cjs.js +1 -1
- package/dist/preact/category/category.es.js +9 -4
- package/dist/preact/common/common.cjs.js +1 -1
- package/dist/preact/common/common.es.js +27 -31
- package/dist/preact/events/events.cjs.js +1 -1
- package/dist/preact/events/events.es.js +3 -8
- package/dist/preact/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.es.js +495 -508
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +318 -301
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +8 -10
- package/dist/preact/serp/serp.cjs.js +1 -1
- package/dist/preact/serp/serp.es.js +28 -18
- package/dist/search-BeFE0Ezr.cjs +1 -0
- package/dist/search-C2WGFf4C.js +155 -0
- package/dist/storage-B3FIcJQv.cjs +1 -0
- package/dist/storage-DeAo7M3s.js +115 -0
- package/dist/thumbnails/thumbnails.cjs.js +1 -1
- package/dist/thumbnails/thumbnails.es.js +93 -97
- package/dist/unique-BXFI_-3F.cjs +1 -0
- package/dist/unique-DSDxyj90.js +37 -0
- package/dist/useActions-BmWNZAES.js +182 -0
- package/dist/useActions-boQy-Vp0.cjs +1 -0
- package/dist/useHistory-BMkSr69f.js +24 -0
- package/dist/useHistory-GRnuHgQ5.cjs +1 -0
- package/dist/useLoadMore-B9LiuhfV.cjs +1 -0
- package/dist/useLoadMore-BkJV7F21.js +38 -0
- package/dist/utils/utils.cjs.js +1 -1
- package/dist/utils/utils.es.js +9 -28
- package/package.json +5 -5
- package/dist/AutocompletePageProvider-CFEbt11-.cjs +0 -1
- package/dist/AutocompletePageProvider-CQePqAhB.js +0 -35
- package/dist/BaseElement-CIHACCWd.cjs +0 -1
- package/dist/BaseElement-DD_4UwDm.js +0 -24
- package/dist/CategoryPageProvider-037sXEh9.cjs +0 -1
- package/dist/CategoryPageProvider-DVL9lsCU.js +0 -26
- package/dist/ErrorBoundary-DFs5vnv-.js +0 -11
- package/dist/ErrorBoundary-DNPL7EwP.cjs +0 -1
- package/dist/InfiniteScrollWithObserver-BliG4dEl.cjs +0 -1
- package/dist/InfiniteScrollWithObserver-DvkEUZUE.js +0 -205
- package/dist/SerpPageProvider-BzrNPc7g.js +0 -26
- package/dist/SerpPageProvider-CxqiX9Zo.cjs +0 -1
- package/dist/baseConfig-BOOw0mWW.cjs +0 -1
- package/dist/baseConfig-Cf28X268.js +0 -48
- package/dist/cl-B00bZ7jc.cjs +0 -1
- package/dist/cl-CcykAxZN.js +0 -6
- package/dist/disableNativeAutocomplete-Bkta_WR2.js +0 -27
- package/dist/disableNativeAutocomplete-DI6zaZII.cjs +0 -1
- package/dist/eventBusDispatch-BKQcSHAB.cjs +0 -1
- package/dist/eventBusDispatch-DPR2Vwd4.js +0 -20
- package/dist/eventBusSubscribe-B5E7dTzk.js +0 -26
- package/dist/eventBusSubscribe-C4H9Nv1Z.cjs +0 -1
- package/dist/index.es-Dp6Iaxz3.cjs +0 -1
- package/dist/index.es-XNBESE3P.js +0 -26
- package/dist/isBot-C-qPIZyF.cjs +0 -1
- package/dist/jsxRuntime.module-B3sGoTIU.cjs +0 -1
- package/dist/jsxRuntime.module-Bzuv3cXw.js +0 -13
- package/dist/parseNumber-FsZ8w61u.cjs +0 -1
- package/dist/parseNumber-QA48nJLp.js +0 -11
- package/dist/pick-DReBictn.js +0 -9
- package/dist/pick-rYi1lc2m.cjs +0 -1
- package/dist/search-BchLEATK.cjs +0 -1
- package/dist/search-D1jQPG6P.js +0 -156
- package/dist/storage-9KuhFI9v.cjs +0 -1
- package/dist/storage-B97DRj5i.js +0 -121
- package/dist/unique-C1G3v2Y8.cjs +0 -1
- package/dist/unique-CCu7ChUL.js +0 -39
- package/dist/useActions-BD6dgsX8.js +0 -260
- package/dist/useActions-DIlSparF.cjs +0 -1
- package/dist/useHistory-DLCyHMo1.cjs +0 -1
- package/dist/useHistory-sjFYeR68.js +0 -27
- package/dist/useLoadMore-BMOT8Dfn.js +0 -33
- package/dist/useLoadMore-vCpwy6JC.cjs +0 -1
|
@@ -1,326 +1,343 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import "../../index.es-jSYcbRvi.js";
|
|
2
|
+
import "../../search-C2WGFf4C.js";
|
|
3
|
+
import { a as e, s as t, t as n } from "../../storage-DeAo7M3s.js";
|
|
4
|
+
import { n as r, t as i } from "../../disableNativeAutocomplete-CcR_Ek_P.js";
|
|
5
|
+
import { n as a } from "../../unique-DSDxyj90.js";
|
|
6
|
+
import { a as o, r as s } from "../../useActions-BmWNZAES.js";
|
|
7
|
+
import "../../eventBusSubscribe-C6qT1aOO.js";
|
|
8
|
+
import "../../baseConfig-Che6Adb6.js";
|
|
9
|
+
import "../../useHistory-BMkSr69f.js";
|
|
10
|
+
import { n as c, t as l } from "../../AutocompletePageProvider-D48n1GB-.js";
|
|
11
|
+
import { n as u } from "../../jsxRuntime.module-BRdvPAre.js";
|
|
12
|
+
import { n as d, t as f } from "../../CategoryPageProvider-BYw7KGoS.js";
|
|
13
|
+
import { t as p } from "../../ErrorBoundary-Bxyssvki.js";
|
|
14
|
+
import { n as m, t as h } from "../../SerpPageProvider-fg14kNV9.js";
|
|
15
|
+
import { render as g } from "preact";
|
|
16
|
+
//#region packages/utils/src/debounce.ts
|
|
17
|
+
function _(e) {
|
|
18
|
+
let t;
|
|
19
|
+
return (n) => {
|
|
20
|
+
t && clearTimeout(t), t = setTimeout(n, e);
|
|
21
|
+
};
|
|
16
22
|
}
|
|
17
|
-
|
|
18
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region packages/preact/inject/src/helpers/dom.ts
|
|
25
|
+
function v(e) {
|
|
26
|
+
return Array.from(document.querySelectorAll(e));
|
|
19
27
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
n.push(t), t = t.parentNode;
|
|
25
|
-
return n;
|
|
28
|
+
function y(e) {
|
|
29
|
+
let t = [], n = e.parentNode;
|
|
30
|
+
for (; n && n !== document && n instanceof Element;) t.push(n), n = n.parentNode;
|
|
31
|
+
return t;
|
|
26
32
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
};
|
|
33
|
+
function b([e, t], n) {
|
|
34
|
+
let r = (r) => {
|
|
35
|
+
let i = r.target;
|
|
36
|
+
i instanceof HTMLElement && e && i !== e && i !== t && !y(i).includes(e) && n();
|
|
37
|
+
};
|
|
38
|
+
return document.addEventListener("click", r), { destroy: () => {
|
|
39
|
+
document.removeEventListener("click", r);
|
|
40
|
+
} };
|
|
37
41
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
42
|
+
function x(e, t) {
|
|
43
|
+
e.tabIndex = 0, e.addEventListener("blur", t);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region packages/preact/inject/src/resolveCssSelector.ts
|
|
47
|
+
function S(e) {
|
|
48
|
+
return typeof e == "string" ? {
|
|
49
|
+
selector: e,
|
|
50
|
+
position: "last"
|
|
51
|
+
} : {
|
|
52
|
+
position: "last",
|
|
53
|
+
...e
|
|
54
|
+
};
|
|
49
55
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region packages/preact/inject/src/wait.ts
|
|
58
|
+
function C({ selector: e, timeout: n = 500 }) {
|
|
59
|
+
return new Promise((r) => {
|
|
60
|
+
let i = v(e);
|
|
61
|
+
if (i.length > 0) return r(i);
|
|
62
|
+
let a = new MutationObserver(() => {
|
|
63
|
+
let t = v(e);
|
|
64
|
+
t.length > 0 && (a.disconnect(), clearTimeout(o), r(t));
|
|
65
|
+
}), o = setTimeout(() => {
|
|
66
|
+
a.disconnect(), t.warn(`Timed out (${n}) while waiting for element ${e}`), r([]);
|
|
67
|
+
}, n);
|
|
68
|
+
a.observe(document.body, {
|
|
69
|
+
childList: !0,
|
|
70
|
+
subtree: !0
|
|
71
|
+
});
|
|
72
|
+
});
|
|
66
73
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
};
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region packages/preact/inject/src/init/autocomplete/components/createComponent.tsx
|
|
76
|
+
function w(e, t, n) {
|
|
77
|
+
t.style.display = "none";
|
|
78
|
+
let r = (() => {
|
|
79
|
+
if (e.parentElement && e.parentElement.classList.contains("nosto-autocomplete-wrapper")) return e.parentElement;
|
|
80
|
+
let t = document.createElement("div");
|
|
81
|
+
return t.className = "nosto-autocomplete-wrapper", e.parentNode?.insertBefore(t, e.nextSibling), t.appendChild(e), t;
|
|
82
|
+
})(), i = S(n), a = i && document.querySelector(i.selector);
|
|
83
|
+
if (a) {
|
|
84
|
+
let e = document.createElement("form");
|
|
85
|
+
e.className = "nosto-dropdown-form", e.appendChild(t), i.position === "first" ? a.prepend(e) : a.appendChild(e);
|
|
86
|
+
} else r.appendChild(t);
|
|
87
|
+
let o = {
|
|
88
|
+
index: -1,
|
|
89
|
+
onChangeListeners: []
|
|
90
|
+
}, s = (e, t) => {
|
|
91
|
+
let n = e.length;
|
|
92
|
+
n === 0 && (t = -1), o.index = t >= 0 ? t % n : n - 1, o.onChangeListeners.forEach((e) => e());
|
|
93
|
+
}, c = () => {
|
|
94
|
+
o.index = -1, o.onChangeListeners.forEach((e) => e());
|
|
95
|
+
}, l = () => o.index;
|
|
96
|
+
return {
|
|
97
|
+
element: t,
|
|
98
|
+
hide: () => {
|
|
99
|
+
t.style.display = "none", c();
|
|
100
|
+
},
|
|
101
|
+
show: () => {
|
|
102
|
+
t.style.display = "inherit";
|
|
103
|
+
},
|
|
104
|
+
isOpen: () => t.style.display !== "none",
|
|
105
|
+
goDown: () => {
|
|
106
|
+
s(Array.from(t.getElementsByClassName("ns-autocomplete-element")), l() + 1);
|
|
107
|
+
},
|
|
108
|
+
goUp: () => {
|
|
109
|
+
s(Array.from(t.getElementsByClassName("ns-autocomplete-element")), l() - 1);
|
|
110
|
+
},
|
|
111
|
+
highlight: s,
|
|
112
|
+
highlightedIndex: l,
|
|
113
|
+
submitHighlightedItem: (e) => {
|
|
114
|
+
Array.from(t.querySelectorAll(".ns-autocomplete-element"))[e]?.click();
|
|
115
|
+
},
|
|
116
|
+
onHighlightChange: (e) => {
|
|
117
|
+
o.onChangeListeners.push(e);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
115
120
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region packages/preact/inject/src/init/autocomplete/components/AutocompleteDropdown.tsx
|
|
123
|
+
function T(e, t) {
|
|
124
|
+
let n = document.createElement("div");
|
|
125
|
+
return n.className = "nosto-autocomplete-dropdown", {
|
|
126
|
+
...w(e, n, t),
|
|
127
|
+
element: n
|
|
128
|
+
};
|
|
122
129
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region packages/preact/inject/src/init/autocomplete/components/AutocompleteHistory.tsx
|
|
132
|
+
var E = "nosto:search-js:history";
|
|
133
|
+
function D(t, r, i) {
|
|
134
|
+
let a = document.createElement("div");
|
|
135
|
+
return a.className = "nosto-autocomplete-history", {
|
|
136
|
+
...w(t, a, r),
|
|
137
|
+
element: a,
|
|
138
|
+
add: (t) => {
|
|
139
|
+
let r = (n(E) ?? []).filter((e) => e !== t).slice(i ? -i : 0);
|
|
140
|
+
r.push(t), e(E, r);
|
|
141
|
+
},
|
|
142
|
+
get: () => (n(E) ?? []).reverse().filter((e) => !!e)
|
|
143
|
+
};
|
|
135
144
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region packages/preact/inject/src/init/autocomplete/events/onClick.tsx
|
|
147
|
+
async function O(e, { config: t, dropdown: n, history: r, renderHistory: i, store: a }) {
|
|
148
|
+
let { historyEnabled: o, minQueryLength: c } = t;
|
|
149
|
+
if (e.length < c && o && i && !r.isOpen()) {
|
|
150
|
+
r.show();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (e.length < c) return;
|
|
154
|
+
n.hide();
|
|
155
|
+
let l = a.getState()?.query?.query;
|
|
156
|
+
l && l !== e && await s({
|
|
157
|
+
config: t,
|
|
158
|
+
store: a
|
|
159
|
+
}, { query: e }), n.show();
|
|
147
160
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region packages/preact/inject/src/init/autocomplete/events/onFocus.tsx
|
|
163
|
+
async function k(e, t) {
|
|
164
|
+
let { config: n, renderHistory: r, history: i } = t, { historyEnabled: o, minQueryLength: s } = n;
|
|
165
|
+
if (!r || e.length >= s || !o || i.isOpen()) return;
|
|
166
|
+
let c = R(t);
|
|
167
|
+
i.onHighlightChange(() => {
|
|
168
|
+
c(r, i.element);
|
|
169
|
+
}), i.show();
|
|
170
|
+
let l = a("renderHistory");
|
|
171
|
+
c(r, i.element), l();
|
|
158
172
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region packages/preact/inject/src/init/autocomplete/events/onInput.tsx
|
|
175
|
+
async function A(e, { config: t, dropdown: n, history: r, store: i, debouncer: a }) {
|
|
176
|
+
let { minQueryLength: o, historyEnabled: c } = t;
|
|
177
|
+
if (e.length < o && !c) {
|
|
178
|
+
n.hide(), r.hide();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (e.length < o && c) {
|
|
182
|
+
n.hide(), r.show();
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
r.hide(), a(async () => {
|
|
186
|
+
s({
|
|
187
|
+
config: t,
|
|
188
|
+
store: i
|
|
189
|
+
}, { query: e }), n.show();
|
|
190
|
+
});
|
|
172
191
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return A(n, t.history, t.dropdown);
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region packages/preact/inject/src/init/autocomplete/events/onKeyDown.tsx
|
|
194
|
+
function j(e, t, n) {
|
|
195
|
+
let { config: r, debouncer: i } = n;
|
|
196
|
+
if (i(() => {}), e.length >= r.minQueryLength) return M(t, n.dropdown, n.history);
|
|
197
|
+
if (r.historyEnabled) return M(t, n.history, n.dropdown);
|
|
180
198
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
}
|
|
199
|
+
function M(e, t, n) {
|
|
200
|
+
if (!t.isOpen() && e === "ArrowDown") {
|
|
201
|
+
t.show(), n.hide();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (e === "Escape" && t.hide(), t.isOpen()) {
|
|
205
|
+
if (e === "ArrowDown") t.goDown();
|
|
206
|
+
else if (e === "ArrowUp") t.goUp();
|
|
207
|
+
else if (e === "Enter") {
|
|
208
|
+
let e = t.highlightedIndex();
|
|
209
|
+
return e >= 0 && t.submitHighlightedItem(e), t.hide(), e >= 0;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
196
212
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
query: e
|
|
202
|
-
}));
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region packages/preact/inject/src/init/autocomplete/events/onSubmit.tsx
|
|
215
|
+
function N(e, { config: t, dropdown: n, history: r, onNavigateToSearch: i, store: a }) {
|
|
216
|
+
n.hide(), r.hide(), !(e.length < t.minQueryLength) && (r.add(e), a.updateState({ historyItems: r.get() }), i?.({ query: e }));
|
|
203
217
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region packages/preact/inject/src/init/injectAutocomplete.tsx
|
|
220
|
+
async function P(e, t) {
|
|
221
|
+
let { inputCssSelector: n, timeout: r } = e, i = S(n).selector, a = await C({
|
|
222
|
+
selector: i,
|
|
223
|
+
timeout: r
|
|
224
|
+
});
|
|
225
|
+
if (a.length === 0) throw Error(`No elements found for selector: ${i}`);
|
|
226
|
+
a.forEach((n) => {
|
|
227
|
+
F(n, e, t);
|
|
228
|
+
});
|
|
214
229
|
}
|
|
215
|
-
async function
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
onKeyDown: (l, u) => V(l, u, c)
|
|
234
|
-
}), E(i.element, i.hide), E(s.element, s.hide), S([i.element, e], i.hide), S([s.element, e], s.hide);
|
|
230
|
+
async function F(e, t, n) {
|
|
231
|
+
let { config: a, dropdownCssSelector: o } = t, s = T(e, o), c = D(e, o, a.historySize), l = {
|
|
232
|
+
...t,
|
|
233
|
+
input: e,
|
|
234
|
+
dropdown: s,
|
|
235
|
+
history: c,
|
|
236
|
+
store: n,
|
|
237
|
+
debouncer: _(a.debounceDelay)
|
|
238
|
+
};
|
|
239
|
+
L(l), e.setAttribute("data-nosto-element", "search-input"), n.updateState({ historyItems: c.get() }), i(e), n.onInit(() => {
|
|
240
|
+
I(l);
|
|
241
|
+
}), r(e, {
|
|
242
|
+
onInput: (e) => A(e, l),
|
|
243
|
+
onFocus: (e) => k(e, l),
|
|
244
|
+
onClick: (e) => O(e, l),
|
|
245
|
+
onSubmit: (e) => N(e, l),
|
|
246
|
+
onKeyDown: (e, t) => j(e, t, l)
|
|
247
|
+
}), x(c.element, c.hide), x(s.element, s.hide), b([c.element, e], c.hide), b([s.element, e], s.hide);
|
|
235
248
|
}
|
|
236
|
-
function
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
o(t, n.element), r();
|
|
249
|
+
function I(e) {
|
|
250
|
+
let { dropdown: t, renderAutocomplete: n } = e;
|
|
251
|
+
if (!n) return;
|
|
252
|
+
let r = R(e);
|
|
253
|
+
t.onHighlightChange(() => {
|
|
254
|
+
r(n, t.element);
|
|
255
|
+
});
|
|
256
|
+
let i = a("renderAutocomplete");
|
|
257
|
+
r(n, t.element), i();
|
|
246
258
|
}
|
|
247
|
-
async function
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
);
|
|
259
|
+
async function L(e) {
|
|
260
|
+
let { input: t, renderSpeechToText: n, config: r, store: i } = e;
|
|
261
|
+
if (!n) return;
|
|
262
|
+
let a = "ns-autocomplete-voice-position";
|
|
263
|
+
if (t.parentElement?.querySelector(`.${a}`)) return;
|
|
264
|
+
let o = document.createElement("div");
|
|
265
|
+
o.className = a, t.insertAdjacentElement("afterend", o), g(/* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(l, {
|
|
266
|
+
config: r,
|
|
267
|
+
store: i,
|
|
268
|
+
children: await n()
|
|
269
|
+
}) }), o);
|
|
259
270
|
}
|
|
260
|
-
function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
271
|
+
function R(e) {
|
|
272
|
+
let { config: t, store: n } = e;
|
|
273
|
+
return (e, r) => g(/* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(l, {
|
|
274
|
+
config: t,
|
|
275
|
+
store: n,
|
|
276
|
+
children: e()
|
|
277
|
+
}) }), r);
|
|
266
278
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region packages/preact/inject/src/init/injectComponent.tsx
|
|
281
|
+
async function z({ cssSelector: e, timeout: n, renderComponent: r }) {
|
|
282
|
+
let i = S(e).selector, a = await C({
|
|
283
|
+
selector: i,
|
|
284
|
+
timeout: n ?? 100
|
|
285
|
+
});
|
|
286
|
+
if (a.length === 0) throw Error(`No elements found for selector: ${i}`);
|
|
287
|
+
a.length > 1 && t.warn(`Multiple (${a.length}) elements found for selector: ${i}`), g(r(), a[0]);
|
|
275
288
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region packages/preact/inject/src/init/injectCategory.tsx
|
|
291
|
+
async function B(e, t) {
|
|
292
|
+
let { render: n } = e, r = await n(), i = () => /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(f, {
|
|
293
|
+
store: t,
|
|
294
|
+
config: e.config,
|
|
295
|
+
children: r
|
|
296
|
+
}) });
|
|
297
|
+
z({
|
|
298
|
+
...e,
|
|
299
|
+
renderComponent: i
|
|
300
|
+
});
|
|
282
301
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region packages/preact/inject/src/init/injectSerp.tsx
|
|
304
|
+
async function V(e, t) {
|
|
305
|
+
let { render: n } = e, r = await n(), i = () => /* @__PURE__ */ u(p, { children: /* @__PURE__ */ u(h, {
|
|
306
|
+
store: t,
|
|
307
|
+
config: e.config,
|
|
308
|
+
children: r
|
|
309
|
+
}) });
|
|
310
|
+
z({
|
|
311
|
+
...e,
|
|
312
|
+
renderComponent: i
|
|
313
|
+
});
|
|
289
314
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
...t,
|
|
317
|
-
config: F(t.config)
|
|
318
|
-
},
|
|
319
|
-
r
|
|
320
|
-
), o.serp = { store: r };
|
|
321
|
-
}
|
|
322
|
-
return o;
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region packages/preact/inject/src/init.ts
|
|
317
|
+
async function H({ autocomplete: e, category: t, serp: n }) {
|
|
318
|
+
let r = {};
|
|
319
|
+
if (e) {
|
|
320
|
+
let t = o({ query: e.query });
|
|
321
|
+
await P({
|
|
322
|
+
...e,
|
|
323
|
+
config: c(e.config)
|
|
324
|
+
}, t), r.autocomplete = { store: t };
|
|
325
|
+
}
|
|
326
|
+
if (t) {
|
|
327
|
+
let e = o({ query: t.query });
|
|
328
|
+
await B({
|
|
329
|
+
...t,
|
|
330
|
+
config: d(t.config)
|
|
331
|
+
}, e), r.category = { store: e };
|
|
332
|
+
}
|
|
333
|
+
if (n) {
|
|
334
|
+
let e = o({ query: n.query });
|
|
335
|
+
await V({
|
|
336
|
+
...n,
|
|
337
|
+
config: m(n.config)
|
|
338
|
+
}, e), r.serp = { store: e };
|
|
339
|
+
}
|
|
340
|
+
return r;
|
|
323
341
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
};
|
|
342
|
+
//#endregion
|
|
343
|
+
export { H as init };
|