@netlify/spark-ui 0.0.40 → 0.0.41
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/components/preact/SearchModal/components/SearchWindow.js +1 -1
- package/dist/components/preact/SearchModal/hooks/useSearch.js +23 -23
- package/package.json +1 -1
- package/packages/components/preact/SearchModal/components/SearchWindow.tsx +1 -1
- package/packages/components/preact/SearchModal/hooks/useSearch.ts +0 -2
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
function L(
|
|
3
|
-
const
|
|
1
|
+
import { A as i, y as S, d as T } from "../../../../chunks/hooks.module.BFfOesdf.js";
|
|
2
|
+
function L(o, n) {
|
|
3
|
+
const e = i(null), s = i("");
|
|
4
4
|
return S(() => () => {
|
|
5
|
-
|
|
5
|
+
e.current && clearTimeout(e.current);
|
|
6
6
|
}, []), { reset: () => {
|
|
7
|
-
|
|
7
|
+
e.current && clearTimeout(e.current);
|
|
8
8
|
}, run: (h) => {
|
|
9
|
-
s.current = h,
|
|
10
|
-
() =>
|
|
9
|
+
s.current = h, e.current = setTimeout(
|
|
10
|
+
() => o(s.current),
|
|
11
11
|
n
|
|
12
12
|
);
|
|
13
13
|
} };
|
|
14
14
|
}
|
|
15
15
|
function x() {
|
|
16
|
-
const [
|
|
16
|
+
const [o, n] = T({
|
|
17
17
|
searchTerm: "",
|
|
18
18
|
results: [],
|
|
19
19
|
isLoading: !1
|
|
20
|
-
}),
|
|
21
|
-
(
|
|
22
|
-
}, 150),
|
|
23
|
-
var
|
|
20
|
+
}), e = i(/* @__PURE__ */ new Map()), { reset: s, run: l } = L((t) => {
|
|
21
|
+
u(t);
|
|
22
|
+
}, 150), u = async (t) => {
|
|
23
|
+
var m;
|
|
24
24
|
if (!(window != null && window.pagefind)) return;
|
|
25
|
-
if (n((r) => ({ ...r, isLoading: !0 })),
|
|
25
|
+
if (n((r) => ({ ...r, isLoading: !0 })), e.current.has(t)) {
|
|
26
26
|
n((r) => ({
|
|
27
27
|
...r,
|
|
28
|
-
results:
|
|
28
|
+
results: e.current.get(t),
|
|
29
29
|
isLoading: !1
|
|
30
30
|
}));
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const a = await window.pagefind.debouncedSearch(
|
|
34
|
-
(
|
|
35
|
-
var
|
|
33
|
+
const a = await window.pagefind.debouncedSearch(t), g = await Promise.all(
|
|
34
|
+
(m = a == null ? void 0 : a.results) == null ? void 0 : m.slice(0, 15).map(async (r) => {
|
|
35
|
+
var d, f;
|
|
36
36
|
const c = await r.data(), p = (w) => w.replace("#", "");
|
|
37
37
|
return {
|
|
38
38
|
icon: "pageWithLines",
|
|
39
|
-
resource: (
|
|
40
|
-
label: (
|
|
39
|
+
resource: (d = c.meta) == null ? void 0 : d.resource,
|
|
40
|
+
label: (f = c.meta) == null ? void 0 : f.title,
|
|
41
41
|
url: c.url,
|
|
42
42
|
excerpt: p(c.excerpt)
|
|
43
43
|
};
|
|
@@ -50,12 +50,12 @@ function x() {
|
|
|
50
50
|
}));
|
|
51
51
|
};
|
|
52
52
|
return {
|
|
53
|
-
state:
|
|
53
|
+
state: o,
|
|
54
54
|
actions: {
|
|
55
|
-
setSearchTerm: (
|
|
56
|
-
n((a) => ({ ...a, searchTerm:
|
|
55
|
+
setSearchTerm: (t) => {
|
|
56
|
+
n((a) => ({ ...a, searchTerm: t })), s(), l(t);
|
|
57
57
|
},
|
|
58
|
-
submitSearch:
|
|
58
|
+
submitSearch: u
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
}
|
package/package.json
CHANGED
|
@@ -58,7 +58,7 @@ export default function SearchWindow({
|
|
|
58
58
|
<div className="n-search-window">
|
|
59
59
|
<div className="search-links">
|
|
60
60
|
<SearchLink {...askNetlify} />
|
|
61
|
-
{searchTerm && searchTerm.length >
|
|
61
|
+
{searchTerm && searchTerm.length > 1 ? (
|
|
62
62
|
<SearchResults
|
|
63
63
|
searchLoading={searchLoading}
|
|
64
64
|
searchTerm={searchTerm}
|
|
@@ -21,9 +21,7 @@ export function useSearch() {
|
|
|
21
21
|
const cacheRef = useRef(new Map());
|
|
22
22
|
|
|
23
23
|
const { reset, run } = useTimeout((query: string) => {
|
|
24
|
-
if (query.length > 2 || query.length === 0) {
|
|
25
24
|
submitSearch(query);
|
|
26
|
-
}
|
|
27
25
|
}, 150);
|
|
28
26
|
|
|
29
27
|
const submitSearch = async (query: string) => {
|