@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.
@@ -33,7 +33,7 @@ function p({
33
33
  label: "Ask Netlify AI",
34
34
  url: "https://docs.netlify.com/ask-netlify/"
35
35
  } }),
36
- r && r.length > 3 ? /* @__PURE__ */ e(
36
+ r && r.length > 1 ? /* @__PURE__ */ e(
37
37
  h,
38
38
  {
39
39
  searchLoading: s,
@@ -1,43 +1,43 @@
1
- import { A as u, y as S, d as T } from "../../../../chunks/hooks.module.BFfOesdf.js";
2
- function L(i, n) {
3
- const t = u(null), s = u("");
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
- t.current && clearTimeout(t.current);
5
+ e.current && clearTimeout(e.current);
6
6
  }, []), { reset: () => {
7
- t.current && clearTimeout(t.current);
7
+ e.current && clearTimeout(e.current);
8
8
  }, run: (h) => {
9
- s.current = h, t.current = setTimeout(
10
- () => i(s.current),
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 [i, n] = T({
16
+ const [o, n] = T({
17
17
  searchTerm: "",
18
18
  results: [],
19
19
  isLoading: !1
20
- }), t = u(/* @__PURE__ */ new Map()), { reset: s, run: l } = L((e) => {
21
- (e.length > 2 || e.length === 0) && o(e);
22
- }, 150), o = async (e) => {
23
- var f;
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 })), t.current.has(e)) {
25
+ if (n((r) => ({ ...r, isLoading: !0 })), e.current.has(t)) {
26
26
  n((r) => ({
27
27
  ...r,
28
- results: t.current.get(e),
28
+ results: e.current.get(t),
29
29
  isLoading: !1
30
30
  }));
31
31
  return;
32
32
  }
33
- const a = await window.pagefind.debouncedSearch(e), g = await Promise.all(
34
- (f = a == null ? void 0 : a.results) == null ? void 0 : f.slice(0, 15).map(async (r) => {
35
- var m, d;
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: (m = c.meta) == null ? void 0 : m.resource,
40
- label: (d = c.meta) == null ? void 0 : d.title,
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: i,
53
+ state: o,
54
54
  actions: {
55
- setSearchTerm: (e) => {
56
- n((a) => ({ ...a, searchTerm: e })), s(), l(e);
55
+ setSearchTerm: (t) => {
56
+ n((a) => ({ ...a, searchTerm: t })), s(), l(t);
57
57
  },
58
- submitSearch: o
58
+ submitSearch: u
59
59
  }
60
60
  };
61
61
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "0.0.40",
4
+ "version": "0.0.41",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -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 > 3 ? (
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) => {