@netlify/spark-ui 1.11.0 → 1.12.0-alpha.1

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.
Files changed (61) hide show
  1. package/dist/assets/AskNetlify.css +1 -1
  2. package/dist/assets/SearchLink.css +1 -1
  3. package/dist/assets/SearchModal.css +1 -1
  4. package/dist/chunks/{ChatInterface.EQAPs01R.js → AskNetlify.lrswYyKn.js} +119 -110
  5. package/dist/components/preact/AskNetlify/AskNetlify.d.ts +3 -3
  6. package/dist/components/preact/AskNetlify/AskNetlify.js +8 -34
  7. package/dist/components/preact/AskNetlify/components/ChatMessages.d.ts +2 -1
  8. package/dist/components/preact/AskNetlify/components/ChatMessages.js +78 -70
  9. package/dist/components/preact/AskNetlify/components/SourcesList.d.ts +3 -0
  10. package/dist/components/preact/AskNetlify/components/SourcesList.js +23 -0
  11. package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.d.ts +23 -0
  12. package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.js +22 -0
  13. package/dist/components/preact/Icon/index.js +6 -6
  14. package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.d.ts +1 -1
  15. package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.js +23 -22
  16. package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.d.ts +1 -0
  17. package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.js +26 -0
  18. package/dist/components/preact/SearchModal/components/SearchModal/SearchModal.js +89 -84
  19. package/dist/components/preact/SearchModal/components/SearchWindow.d.ts +1 -1
  20. package/dist/components/preact/SearchModal/components/SearchWindow.js +55 -48
  21. package/dist/components/preact/SearchModal/hooks/index.d.ts +1 -1
  22. package/dist/components/preact/SearchModal/hooks/index.js +8 -8
  23. package/dist/components/preact/SearchModal/hooks/useKeyboardNav.d.ts +1 -1
  24. package/dist/components/preact/SearchModal/hooks/useKeyboardNav.js +11 -12
  25. package/dist/components/preact/SearchModal/hooks/useSearch.js +19 -19
  26. package/dist/components/preact/SearchModal/hooks/{useSearchLogger.d.ts → useSearchAnalytics.d.ts} +2 -2
  27. package/dist/components/preact/SearchModal/hooks/{useSearchLogger.js → useSearchAnalytics.js} +5 -5
  28. package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.d.ts +1 -1
  29. package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.js +8 -9
  30. package/dist/components/preact/SearchModal/hooks/useSearchParams.d.ts +1 -1
  31. package/dist/components/preact/SearchModal/hooks/useSearchParams.js +14 -7
  32. package/dist/components/preact/SearchModal/hooks/useSearchToggles.d.ts +1 -1
  33. package/dist/components/preact/SearchModal/hooks/useSearchToggles.js +7 -8
  34. package/dist/components/preact/SearchModal/types/search.types.d.ts +11 -4
  35. package/dist/components/preact/index.js +3 -3
  36. package/package.json +2 -2
  37. package/packages/components/preact/AskNetlify/AskNetlify.css +54 -1
  38. package/packages/components/preact/AskNetlify/AskNetlify.tsx +98 -34
  39. package/packages/components/preact/AskNetlify/components/ChatMessages.tsx +10 -5
  40. package/packages/components/preact/AskNetlify/components/SourcesList.tsx +33 -0
  41. package/packages/components/preact/AskNetlify/hooks/useAskAnalytics.tsx +50 -0
  42. package/packages/components/preact/Icon/index.tsx +2 -2
  43. package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.css +5 -0
  44. package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.tsx +6 -4
  45. package/packages/components/preact/SearchModal/components/SearchLinkThemeToggle.tsx +19 -0
  46. package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.css +22 -3
  47. package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.tsx +73 -89
  48. package/packages/components/preact/SearchModal/components/SearchWindow.tsx +64 -46
  49. package/packages/components/preact/SearchModal/hooks/index.ts +1 -1
  50. package/packages/components/preact/SearchModal/hooks/useKeyboardNav.ts +1 -3
  51. package/packages/components/preact/SearchModal/hooks/useSearch.ts +20 -16
  52. package/packages/components/preact/SearchModal/hooks/{useSearchLogger.ts → useSearchAnalytics.ts} +9 -10
  53. package/packages/components/preact/SearchModal/hooks/useSearchHotkeys.ts +2 -4
  54. package/packages/components/preact/SearchModal/hooks/useSearchParams.ts +24 -2
  55. package/packages/components/preact/SearchModal/hooks/useSearchToggles.ts +1 -3
  56. package/packages/components/preact/SearchModal/types/search.types.tsx +7 -4
  57. package/packages/styles/loaders.css +18 -0
  58. package/packages/styles/tokens.css +4 -0
  59. package/dist/components/preact/AskNetlify/components/ChatInterface.d.ts +0 -7
  60. package/dist/components/preact/AskNetlify/components/ChatInterface.js +0 -10
  61. package/packages/components/preact/AskNetlify/components/ChatInterface.tsx +0 -94
@@ -1,99 +1,104 @@
1
1
  import { u as e } from "../../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import { A as v, y as m, d as h } from "../../../../../chunks/hooks.module.DGkdD5n9.js";
3
- import b from "../../../Modal/Modal.js";
4
- import p from "../../../KeyboardKey/KeyboardKey.js";
5
- import w from "../SearchWindow.js";
6
- import A from "../SearchInput.js";
2
+ import { A as g, y as h, d as y } from "../../../../../chunks/hooks.module.DGkdD5n9.js";
3
+ import { A as b, K as w } from "../../../../../chunks/AskNetlify.lrswYyKn.js";
4
+ import K from "../../../Modal/Modal.js";
5
+ import d from "../../../KeyboardKey/KeyboardKey.js";
6
+ import L from "../SearchWindow.js";
7
+ import C from "../SearchInput.js";
7
8
  import M from "../SearchLink/SearchLink.js";
8
9
  import { useSearch as O } from "../../hooks/useSearch.js";
9
- import { useSearchLogger as P } from "../../hooks/useSearchLogger.js";
10
- import { useKeyboardNav as C } from "../../hooks/useKeyboardNav.js";
11
- import { useSearchHotkeys as E } from "../../hooks/useSearchHotkeys.js";
12
- import { useSearchParams as K } from "../../hooks/useSearchParams.js";
13
- import { useSearchToggles as F } from "../../hooks/useSearchToggles.js";
14
- import R from "../../../AskNetlify/AskNetlify.js";
15
- import { Fragment as I } from "preact";
16
- import '../../../../../assets/SearchModal.css';function q(s) {
17
- const r = v(null);
18
- return m(() => {
19
- function i(t) {
20
- r.current && !r.current.contains(t.target) && s();
10
+ import { useSearchAnalytics as E } from "../../hooks/useSearchAnalytics.js";
11
+ import { useKeyboardNav as Q } from "../../hooks/useKeyboardNav.js";
12
+ import { useSearchHotkeys as x } from "../../hooks/useSearchHotkeys.js";
13
+ import { useSearchParams as G } from "../../hooks/useSearchParams.js";
14
+ import { useSearchToggles as P } from "../../hooks/useSearchToggles.js";
15
+ import { useAskAnalytics as R } from "../../../AskNetlify/hooks/useAskAnalytics.js";
16
+ import { Fragment as N } from "preact";
17
+ import '../../../../../assets/SearchModal.css';function q(r) {
18
+ const n = g(null);
19
+ return h(() => {
20
+ function o(m) {
21
+ n.current && !n.current.contains(m.target) && r();
21
22
  }
22
- return document.addEventListener("mousedown", i), () => {
23
- document.removeEventListener("mousedown", i);
23
+ return document.addEventListener("mousedown", o), () => {
24
+ document.removeEventListener("mousedown", o);
24
25
  };
25
- }, [s]), r;
26
+ }, [r]), n;
26
27
  }
27
- function Z(s = { className: "", children: void 0, debug: !1, kapaIntegrationId: void 0 }) {
28
- const [r, i] = h(!1), [t, d] = h({ current: "search" });
29
- m(() => {
30
- let n;
31
- const c = () => {
32
- window.pagefind && (i(!0), n && clearInterval(n));
33
- };
34
- return c(), n = setInterval(c, 100), () => clearInterval(n);
35
- }, []);
36
- const { children: N, className: k, debug: y, ...L } = s, { state: o, actions: g } = O(), [l, S] = h(!1), u = () => S(!0), f = () => S(!1), a = v(null), T = q(f);
37
- return P(o, y), F(r, u, d), K(r, g.setSearchTerm, u), E(r, l, u, f), C(r, a, l, f), m(() => {
38
- a.current && (l ? a.current.showModal() : a.current.close());
39
- }, [l]), m(() => {
40
- var c;
41
- const n = (c = a.current) == null ? void 0 : c.querySelector("input");
42
- n && n.focus(), t.current === "ask" ? setTimeout(() => {
43
- a.current.classList.add("n-search-modal-ask");
44
- }, 150) : t.current === "search" && setTimeout(() => {
45
- a.current.classList.remove("n-search-modal-ask");
46
- }, 150);
47
- }, [t.current]), /* @__PURE__ */ e(
48
- b,
28
+ function re(r = { className: "", children: void 0, debug: !1, kapaIntegrationId: void 0 }) {
29
+ const { children: n, className: o, debug: m, ...A } = r, [s, c] = y({ current: "search" }), [i, f] = y(!1), l = () => f(!0), u = () => f(!1), t = g(null), v = q(u), { state: a, actions: p } = O();
30
+ P(l, c), G(p.setSearchTerm, l), x(i, l, u), Q(t, i, u), E(a, m);
31
+ const { handleNewQuery: I, handleAnswer: T } = R();
32
+ return h(() => {
33
+ t.current && (i ? t.current.showModal() : t.current.close());
34
+ }, [i]), h(() => {
35
+ var k;
36
+ const S = (k = t.current) == null ? void 0 : k.querySelector("input");
37
+ S && S.focus();
38
+ }, [s.current]), /* @__PURE__ */ e(
39
+ w,
49
40
  {
50
- ref: a,
51
- className: `n-search-modal ${k || ""}`,
52
- "data-state": t.current,
53
- ...L,
54
- children: /* @__PURE__ */ e("div", { ref: T, className: "n-search-container", children: [
55
- t.current === "ask" && /* @__PURE__ */ e(R, { setModalState: d, kapaIntegrationId: s.kapaIntegrationId }),
56
- t.current === "search" && /* @__PURE__ */ e(I, { children: [
57
- /* @__PURE__ */ e(A, { setSearchTerm: g.setSearchTerm, initialValue: o.searchTerm }),
58
- /* @__PURE__ */ e(
59
- w,
60
- {
61
- searchLoading: o.isLoading,
62
- searchTerm: o.searchTerm,
63
- results: o.results,
64
- children: /* @__PURE__ */ e(I, { children: [
65
- s.kapaIntegrationId && /* @__PURE__ */ e(
66
- M,
67
- {
68
- as: "button",
69
- icon: "askNetlify",
70
- label: "Ask Netlify AI",
71
- onClick: () => {
72
- d({ current: "ask" });
73
- }
74
- }
75
- ),
76
- N
41
+ integrationId: r.kapaIntegrationId || "",
42
+ callbacks: {
43
+ askAI: {
44
+ onQuerySubmit: I,
45
+ onAnswerGenerationCompleted: T
46
+ }
47
+ },
48
+ children: /* @__PURE__ */ e(
49
+ K,
50
+ {
51
+ ref: t,
52
+ className: `n-search-modal ${o || ""}`,
53
+ "data-state": s.current,
54
+ ...A,
55
+ children: /* @__PURE__ */ e("div", { ref: v, className: "n-search-container", children: [
56
+ s.current === "ask" && /* @__PURE__ */ e(b, { setModalState: c, initialQuery: a.searchTerm }),
57
+ s.current === "search" && /* @__PURE__ */ e(N, { children: [
58
+ /* @__PURE__ */ e(C, { setSearchTerm: p.setSearchTerm, initialValue: a.searchTerm }),
59
+ /* @__PURE__ */ e(
60
+ L,
61
+ {
62
+ setModalState: c,
63
+ searchLoading: a.isLoading,
64
+ searchTerm: a.searchTerm,
65
+ results: a.results,
66
+ children: /* @__PURE__ */ e(N, { children: [
67
+ r.kapaIntegrationId && /* @__PURE__ */ e(
68
+ M,
69
+ {
70
+ as: "button",
71
+ icon: "askNetlify",
72
+ label: "Ask Netlify",
73
+ excerpt: "Get an instant AI-generated answer",
74
+ onClick: () => {
75
+ c({ current: "ask" });
76
+ }
77
+ }
78
+ ),
79
+ n
80
+ ] })
81
+ }
82
+ ),
83
+ /* @__PURE__ */ e("div", { className: "n-search-footer", children: [
84
+ /* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
85
+ /* @__PURE__ */ e(d, { keyNames: ["Esc"] }),
86
+ "to close"
87
+ ] }),
88
+ /* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
89
+ /* @__PURE__ */ e(d, { keyNames: ["Tab"] }),
90
+ /* @__PURE__ */ e("span", { children: "or" }),
91
+ /* @__PURE__ */ e(d, { keyNames: ["↑", "↓"] }),
92
+ "to navigate"
93
+ ] })
77
94
  ] })
78
- }
79
- ),
80
- /* @__PURE__ */ e("div", { className: "n-search-footer", children: [
81
- /* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
82
- /* @__PURE__ */ e(p, { keyNames: ["Esc"] }),
83
- "to close"
84
- ] }),
85
- /* @__PURE__ */ e("p", { className: "n-search-footer-tip", children: [
86
- /* @__PURE__ */ e(p, { keyNames: ["Tab"] }),
87
- /* @__PURE__ */ e("span", { children: "or" }),
88
- /* @__PURE__ */ e(p, { keyNames: ["↑", "↓"] }),
89
- "to navigate"
90
95
  ] })
91
96
  ] })
92
- ] })
93
- ] })
97
+ }
98
+ )
94
99
  }
95
100
  );
96
101
  }
97
102
  export {
98
- Z as default
103
+ re as default
99
104
  };
@@ -1,2 +1,2 @@
1
1
  import { SearchWindowProps } from '../types/search.types';
2
- export default function SearchWindow({ searchLoading, searchTerm, results, children: DefaultWindow, }: SearchWindowProps): import("preact").JSX.Element;
2
+ export default function SearchWindow({ setModalState, searchLoading, searchTerm, results, children: DefaultWindow, }: SearchWindowProps): import("preact").JSX.Element;
@@ -1,56 +1,63 @@
1
- import { u as e } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import { T as o } from "../../../../chunks/hooks.module.DGkdD5n9.js";
3
- import m from "./SearchHeading/SearchHeading.js";
4
- import a from "./SearchLink/SearchLink.js";
5
- import { Fragment as h } from "preact";
6
- const d = {
7
- light: "dark",
8
- dark: "light"
9
- }, u = (n) => {
10
- const t = document.getElementById("site-theme-select");
11
- t && (t.value = n), document.documentElement.setAttribute("data-theme", n), localStorage.setItem("theme", n);
12
- }, g = ({
13
- searchLoading: n,
14
- searchTerm: t,
15
- results: r
1
+ import { u as n } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
+ import h from "./SearchHeading/SearchHeading.js";
3
+ import t from "./SearchLink/SearchLink.js";
4
+ import m from "./SearchLinkThemeToggle.js";
5
+ import { Fragment as r } from "preact";
6
+ const o = ({
7
+ searchTerm: i,
8
+ setModalState: l
9
+ }) => /* @__PURE__ */ n(
10
+ t,
11
+ {
12
+ as: "button",
13
+ icon: "askNetlify",
14
+ excerpt: "Get an instant AI-generated answer",
15
+ onClick: () => l({ current: "ask" }),
16
+ children: [
17
+ "Ask Netlify: ",
18
+ /* @__PURE__ */ n("span", { className: "n-search-term", children: i })
19
+ ]
20
+ }
21
+ ), f = ({ searchTerm: i }) => /* @__PURE__ */ n("div", { className: "n-search-feedback", children: /* @__PURE__ */ n("p", { className: "n-results-info", children: [
22
+ "0 results for ",
23
+ /* @__PURE__ */ n("span", { className: "n-search-term", children: i })
24
+ ] }) }), N = ({
25
+ setModalState: i,
26
+ searchLoading: l,
27
+ searchTerm: e,
28
+ results: s
16
29
  }) => {
17
- if (n)
18
- return /* @__PURE__ */ e(m, { children: [
19
- "Searching for ",
20
- /* @__PURE__ */ e("span", { className: "n-search-term", children: t }),
21
- " ..."
22
- ] });
23
- if (!r || r.length === 0)
24
- return /* @__PURE__ */ e(m, { children: [
25
- "0 results for ",
26
- /* @__PURE__ */ e("span", { className: "n-search-term", children: t })
27
- ] });
28
- const c = o(() => r.map((i, l) => /* @__PURE__ */ e("li", { className: "n-results-list-item", children: /* @__PURE__ */ e(a, { ...i }) }, l)), [r]);
29
- return /* @__PURE__ */ e("ul", { className: "n-results-list", role: "list", children: c });
30
+ const c = e === "no results" || !l && (!s || s.length === 0);
31
+ return /* @__PURE__ */ n(r, { children: [
32
+ /* @__PURE__ */ n(o, { searchTerm: e, setModalState: i }),
33
+ c ? /* @__PURE__ */ n(f, { searchTerm: e }) : /* @__PURE__ */ n("ul", { className: "n-results-list", role: "list", children: s == null ? void 0 : s.map((a, d) => /* @__PURE__ */ n("li", { className: "n-results-list-item", children: /* @__PURE__ */ n(t, { ...a }) }, d)) })
34
+ ] });
30
35
  };
31
- function N({
32
- searchLoading: n,
33
- searchTerm: t,
34
- results: r,
36
+ function w({
37
+ setModalState: i,
38
+ searchLoading: l,
39
+ searchTerm: e,
40
+ results: s,
35
41
  children: c
36
42
  }) {
37
- return /* @__PURE__ */ e("div", { className: "n-search-window", children: /* @__PURE__ */ e("div", { className: "n-search-links", children: t && t.length > 1 ? /* @__PURE__ */ e(g, { searchLoading: n, searchTerm: t, results: r }) : c ? /* @__PURE__ */ e(h, { children: [
43
+ const a = (e == null ? void 0 : e.length) > 1;
44
+ return /* @__PURE__ */ n("div", { className: "n-search-window", children: /* @__PURE__ */ n("div", { className: "n-search-links", children: a ? l ? /* @__PURE__ */ n(r, { children: [
45
+ /* @__PURE__ */ n(o, { searchTerm: e, setModalState: i }),
46
+ /* @__PURE__ */ n("div", { className: "n-search-feedback", children: /* @__PURE__ */ n("div", { className: "n-loader-dots-spinner" }) })
47
+ ] }) : /* @__PURE__ */ n(
48
+ N,
49
+ {
50
+ setModalState: i,
51
+ searchLoading: l,
52
+ searchTerm: e,
53
+ results: s
54
+ }
55
+ ) : /* @__PURE__ */ n(r, { children: [
38
56
  c,
39
- /* @__PURE__ */ e(m, { children: "Actions" }),
40
- /* @__PURE__ */ e(
41
- a,
42
- {
43
- as: "button",
44
- icon: "lightbulb",
45
- label: "Toggle theme",
46
- onClick: () => {
47
- const i = window.matchMedia("(prefers-color-scheme: dark)").matches, l = document.documentElement.getAttribute("data-theme"), s = i ? "dark" : l || "light";
48
- s && u(d[s]);
49
- }
50
- }
51
- )
52
- ] }) : null }) });
57
+ /* @__PURE__ */ n(h, { children: "Actions" }),
58
+ /* @__PURE__ */ n(m, {})
59
+ ] }) }) });
53
60
  }
54
61
  export {
55
- N as default
62
+ w as default
56
63
  };
@@ -1,5 +1,5 @@
1
1
  export { useSearch } from '../hooks/useSearch';
2
- export { useSearchLogger } from './useSearchLogger';
2
+ export { useSearchAnalytics } from './useSearchAnalytics';
3
3
  export { useKeyboardNav } from '../hooks/useKeyboardNav';
4
4
  export { useSearchHotkeys } from '../hooks/useSearchHotkeys';
5
5
  export { useSearchParams } from '../hooks/useSearchParams';
@@ -1,14 +1,14 @@
1
1
  import { useSearch as o } from "./useSearch.js";
2
- import { useSearchLogger as s } from "./useSearchLogger.js";
3
- import { useKeyboardNav as t } from "./useKeyboardNav.js";
4
- import { useSearchHotkeys as p } from "./useSearchHotkeys.js";
5
- import { useSearchParams as x } from "./useSearchParams.js";
2
+ import { useSearchAnalytics as s } from "./useSearchAnalytics.js";
3
+ import { useKeyboardNav as m } from "./useKeyboardNav.js";
4
+ import { useSearchHotkeys as f } from "./useSearchHotkeys.js";
5
+ import { useSearchParams as u } from "./useSearchParams.js";
6
6
  import { useSearchToggles as h } from "./useSearchToggles.js";
7
7
  export {
8
- t as useKeyboardNav,
8
+ m as useKeyboardNav,
9
9
  o as useSearch,
10
- p as useSearchHotkeys,
11
- s as useSearchLogger,
12
- x as useSearchParams,
10
+ s as useSearchAnalytics,
11
+ f as useSearchHotkeys,
12
+ u as useSearchParams,
13
13
  h as useSearchToggles
14
14
  };
@@ -11,4 +11,4 @@ import { RefObject } from 'preact';
11
11
  * @param isOpen - Boolean indicating whether the navigation context is active
12
12
  * @param onClose - Callback to close the navigation UI when `Escape` is pressed
13
13
  */
14
- export declare function useKeyboardNav(isPagefindLoaded: boolean, containerRef: RefObject<HTMLElement>, isOpen: boolean, onClose: () => void): void;
14
+ export declare function useKeyboardNav(containerRef: RefObject<HTMLElement>, isOpen: boolean, onClose: () => void): void;
@@ -1,25 +1,24 @@
1
- import { y as f } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- function k(r, t, o, c) {
3
- f(() => {
4
- if (!r) return;
5
- const u = (e) => {
6
- if (o) {
1
+ import { y as l } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
+ function a(r, t, o) {
3
+ l(() => {
4
+ const c = (e) => {
5
+ if (t) {
7
6
  if (e.key === "Escape") {
8
- c();
7
+ o();
9
8
  return;
10
9
  }
11
10
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
12
11
  e.preventDefault();
13
- const d = t.current;
12
+ const d = r.current;
14
13
  if (!d) return;
15
- const n = Array.from(d.querySelectorAll(".n-search-link")), y = n.findIndex((l) => l === document.activeElement), i = e.key === "ArrowDown" ? (y + 1) % n.length : (y - 1 + n.length) % n.length;
14
+ const n = Array.from(d.querySelectorAll(".n-search-link")), u = n.findIndex((y) => y === document.activeElement), i = e.key === "ArrowDown" ? (u + 1) % n.length : (u - 1 + n.length) % n.length;
16
15
  n[i].focus();
17
16
  }
18
17
  }
19
18
  };
20
- return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
21
- }, [r, t, o, c]);
19
+ return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
20
+ }, [r, t, o]);
22
21
  }
23
22
  export {
24
- k as useKeyboardNav
23
+ a as useKeyboardNav
25
24
  };
@@ -1,47 +1,47 @@
1
- import { d as g, A as w } from "../../../../chunks/hooks.module.DGkdD5n9.js";
1
+ import { d as p, A as w } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
2
  import { u as S } from "../../../../chunks/useTimeout.Cq4aqnDe.js";
3
3
  function x() {
4
- const [l, r] = g({
4
+ const [d, s] = p({
5
5
  searchTerm: "",
6
6
  results: [],
7
7
  isLoading: !1
8
- }), n = w(/* @__PURE__ */ new Map()), { reset: d, run: h } = S((e) => {
9
- c(e);
8
+ }), n = w(/* @__PURE__ */ new Map()), { reset: h, run: m } = S((e) => {
9
+ e && e.length >= 2 && c(e);
10
10
  }, 150), c = async (e) => {
11
- var i;
11
+ var o;
12
12
  if (!(window != null && window.pagefind)) return;
13
- if (r((a) => ({ ...a, isLoading: !0 })), n.current.has(e)) {
14
- r((a) => ({
13
+ if (s((a) => ({ ...a, isLoading: !0 })), n.current.has(e)) {
14
+ s((a) => ({
15
15
  ...a,
16
16
  results: n.current.get(e),
17
17
  isLoading: !1
18
18
  }));
19
19
  return;
20
20
  }
21
- const t = await window.pagefind.debouncedSearch(e), m = (t == null ? void 0 : t.results) && await Promise.all(
22
- (i = t == null ? void 0 : t.results) == null ? void 0 : i.slice(0, 15).map(async (a) => {
23
- var o, u;
24
- const s = await a.data(), f = (p) => p.replace("#", "");
21
+ const t = await window.pagefind.debouncedSearch(e), i = (t == null ? void 0 : t.results) && await Promise.all(
22
+ (o = t == null ? void 0 : t.results) == null ? void 0 : o.slice(0, 15).map(async (a) => {
23
+ var l, u;
24
+ const r = await a.data(), f = (g) => g.replace("#", "");
25
25
  return {
26
26
  icon: "pageWithLines",
27
- resource: (o = s.meta) == null ? void 0 : o.resource,
28
- label: (u = s.meta) == null ? void 0 : u.title,
29
- url: s.url,
30
- excerpt: f(s.excerpt)
27
+ resource: (l = r.meta) == null ? void 0 : l.resource,
28
+ label: (u = r.meta) == null ? void 0 : u.title,
29
+ url: r.url,
30
+ excerpt: f(r.excerpt)
31
31
  };
32
32
  })
33
33
  );
34
- r((a) => ({
34
+ n.current.set(e, i), s((a) => ({
35
35
  ...a,
36
- results: m,
36
+ results: i,
37
37
  isLoading: !1
38
38
  }));
39
39
  };
40
40
  return {
41
- state: l,
41
+ state: d,
42
42
  actions: {
43
43
  setSearchTerm: (e) => {
44
- r((t) => ({ ...t, searchTerm: e })), d(), h(e);
44
+ s((t) => ({ ...t, results: [], searchTerm: e })), h(), m(e);
45
45
  },
46
46
  submitSearch: c
47
47
  }
@@ -18,11 +18,11 @@ import { SearchState } from '../types/search.types';
18
18
  * - `handleClick`: A callback function that should be attached to search result click events. It tracks `search:result_selected` events with the clicked result's title and URL.
19
19
  *
20
20
  * @example
21
- * const { handleClick } = useSearchLogger(searchState);
21
+ * const { handleClick } = useSearchAnalytics(searchState);
22
22
  *
23
23
  * // In your component, attach handleClick to the search result links
24
24
  * <a href="result-url" onClick={handleClick}>Search Result</a>
25
25
  */
26
- export declare function useSearchLogger(state?: SearchState, debug?: boolean): {
26
+ export declare function useSearchAnalytics(state?: SearchState, debug?: boolean): {
27
27
  handleClick: (e: Event) => void;
28
28
  };
@@ -1,9 +1,9 @@
1
1
  import { A as y, y as h, q as d } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- import { A as k } from "../../../../chunks/analytics.Ch1vuuOl.js";
3
- function b(r, l) {
4
- const n = y(new k()).current, e = (c) => c.debug_mode = !0;
2
+ import { A as T } from "../../../../chunks/analytics.Ch1vuuOl.js";
3
+ function A(r, l) {
4
+ const n = y(new T()).current, e = (c) => c.debug_mode = !0;
5
5
  return h(() => {
6
- if (!(r != null && r.searchTerm)) return;
6
+ if (!(r != null && r.searchTerm) || (r == null ? void 0 : r.searchTerm.length) < 3) return;
7
7
  const c = { query: r == null ? void 0 : r.searchTerm };
8
8
  l && e(c), n.track("search:new_query", c);
9
9
  }, [r == null ? void 0 : r.searchTerm]), h(() => {
@@ -24,5 +24,5 @@ function b(r, l) {
24
24
  };
25
25
  }
26
26
  export {
27
- b as useSearchLogger
27
+ A as useSearchAnalytics
28
28
  };
@@ -10,4 +10,4 @@
10
10
  * @param onOpen - Callback to open the search interface.
11
11
  * @param onClose - Callback to close the search interface.
12
12
  */
13
- export declare function useSearchHotkeys(isPagefindLoaded: boolean, isOpen: boolean, onOpen: () => void, onClose: () => void): void;
13
+ export declare function useSearchHotkeys(isOpen: boolean, onOpen: () => void, onClose: () => void): void;
@@ -1,13 +1,12 @@
1
- import { y as u } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- function a(t, r, n, o) {
3
- u(() => {
4
- if (!t) return;
5
- const m = (e) => {
6
- e.metaKey && e.key === "k" && (e.preventDefault(), e.stopImmediatePropagation(), r ? o() : n());
1
+ import { y as d } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
+ function m(t, n, o) {
3
+ d(() => {
4
+ const r = (e) => {
5
+ e.metaKey && e.key === "k" && (e.preventDefault(), e.stopImmediatePropagation(), t ? o() : n());
7
6
  };
8
- return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
9
- }, [t, r, n, o]);
7
+ return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
8
+ }, [t, n, o]);
10
9
  }
11
10
  export {
12
- a as useSearchHotkeys
11
+ m as useSearchHotkeys
13
12
  };
@@ -8,4 +8,4 @@
8
8
  * @param setSearchTerm - Function to update the search input state.
9
9
  * @param onOpen - Function to trigger opening of the search interface (e.g., modal or drawer).
10
10
  */
11
- export declare function useSearchParams(isPagefindLoaded: boolean, setSearchTerm: (term: string) => void, onOpen: () => void): void;
11
+ export declare function useSearchParams(setSearchTerm: (term: string) => void, onOpen: () => void): void;
@@ -1,11 +1,18 @@
1
- import { y as c } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- function n(r, o, a) {
3
- c(() => {
4
- if (typeof location > "u" || r) return;
1
+ import { d as c, y as n } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
+ function d(t, o) {
3
+ const [a, i] = c(!1);
4
+ n(() => {
5
+ let e;
6
+ const r = () => {
7
+ window.pagefind && (i(!0), e && clearInterval(e));
8
+ };
9
+ return r(), e = setInterval(r, 100), () => clearInterval(e);
10
+ }, []), n(() => {
11
+ if (typeof location > "u" || a) return;
5
12
  const e = (location == null ? void 0 : location.search) && new URLSearchParams(location.search).get("search");
6
- e && (o(e), a());
7
- }, [r]);
13
+ e && (t(e), o());
14
+ }, [a]);
8
15
  }
9
16
  export {
10
- n as useSearchParams
17
+ d as useSearchParams
11
18
  };
@@ -9,6 +9,6 @@
9
9
  *
10
10
  * @param onOpen - A function to be called when a toggle element is clicked.
11
11
  */
12
- export declare function useSearchToggles(isPagefindLoaded: boolean, onOpen: () => void, setState: (state: {
12
+ export declare function useSearchToggles(onOpen: () => void, setState: (state: {
13
13
  current: string;
14
14
  }) => void): void;
@@ -1,19 +1,18 @@
1
- import { y as a } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
- function s(c, t, l) {
3
- a(() => {
4
- if (!c) return;
1
+ import { y as l } from "../../../../chunks/hooks.module.DGkdD5n9.js";
2
+ function n(t, c) {
3
+ l(() => {
5
4
  const r = document.querySelectorAll("[data-ntl-search-toggle]");
6
5
  if (r.length)
7
6
  return r.forEach((e) => {
8
- const o = e.dataset.ntlSearchToggle ? e.dataset.ntlSearchToggle : "search";
7
+ const a = e.dataset.ntlSearchToggle ? e.dataset.ntlSearchToggle : "search";
9
8
  e.removeAttribute("disabled"), e.addEventListener("click", () => {
10
- t(), l({ current: o });
9
+ t(), c({ current: a });
11
10
  });
12
11
  }), () => {
13
12
  r.forEach((e) => e.removeEventListener("click", t));
14
13
  };
15
- }, [c, t]);
14
+ }, [t]);
16
15
  }
17
16
  export {
18
- s as useSearchToggles
17
+ n as useSearchToggles
19
18
  };
@@ -2,22 +2,29 @@ import { ComponentChildren } from 'preact';
2
2
  import { IconName } from '../../Icon';
3
3
  export interface SearchLinkProps {
4
4
  as?: any;
5
- icon: IconName;
6
- label: string;
5
+ icon?: IconName;
6
+ label?: string;
7
7
  resource?: 'blog' | 'changelog' | 'docs' | 'guide';
8
8
  url?: string;
9
9
  excerpt?: string;
10
+ children?: ComponentChildren;
10
11
  onClick?: () => void;
11
12
  }
12
13
  export interface SearchWindowProps {
14
+ setModalState: (e: {
15
+ current: string;
16
+ }) => void;
13
17
  searchLoading: boolean;
14
- searchTerm?: string;
18
+ searchTerm: string;
15
19
  results?: SearchLinkProps[];
16
20
  children: ComponentChildren;
17
21
  }
18
22
  export interface SearchResultsProps {
23
+ setModalState: (e: {
24
+ current: string;
25
+ }) => void;
19
26
  searchLoading: boolean;
20
- searchTerm?: string;
27
+ searchTerm: string;
21
28
  results?: SearchLinkProps[];
22
29
  }
23
30
  export interface SearchState {