@netlify/spark-ui 1.12.1 → 1.12.2

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.
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ setModalState: (state: {
3
+ current: string;
4
+ }) => void;
5
+ searchTerm: string;
6
+ }
7
+ declare const AskNetlifyLink: (props: Props) => import("preact").JSX.Element;
8
+ export default AskNetlifyLink;
@@ -0,0 +1,22 @@
1
+ import { u as t } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
+ import a from "./SearchLink/SearchLink.js";
3
+ import { Fragment as n } from "preact";
4
+ const l = (e) => {
5
+ const r = e.searchTerm ? /* @__PURE__ */ t(n, { children: [
6
+ "Ask Netlify AI: ",
7
+ /* @__PURE__ */ t("span", { className: "n-search-term", children: e.searchTerm })
8
+ ] }) : "Ask Netlify AI";
9
+ return /* @__PURE__ */ t(
10
+ a,
11
+ {
12
+ as: "button",
13
+ icon: "askNetlify",
14
+ excerpt: "Get instant answers, powered by AI",
15
+ onClick: () => e.setModalState({ current: "ask" }),
16
+ children: r
17
+ }
18
+ );
19
+ };
20
+ export {
21
+ l as default
22
+ };
@@ -1,81 +1,70 @@
1
1
  import { u as e } from "../../../../../chunks/jsxRuntime.module.Bzuv3cXw.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";
2
+ import { A as g, y as h, d as k } from "../../../../../chunks/hooks.module.DGkdD5n9.js";
3
+ import { A as w, K as b } from "../../../../../chunks/AskNetlify.lrswYyKn.js";
4
4
  import K from "../../../Modal/Modal.js";
5
5
  import d from "../../../KeyboardKey/KeyboardKey.js";
6
6
  import L from "../SearchWindow.js";
7
- import C from "../SearchInput.js";
8
- import M from "../SearchLink/SearchLink.js";
9
- import { useSearch as O } from "../../hooks/useSearch.js";
7
+ import M from "../SearchInput.js";
8
+ import O from "../AskNetlifyLink.js";
9
+ import { useSearch as C } from "../../hooks/useSearch.js";
10
10
  import { useSearchAnalytics as E } from "../../hooks/useSearchAnalytics.js";
11
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";
12
+ import { useSearchHotkeys as P } from "../../hooks/useSearchHotkeys.js";
13
+ import { useSearchParams as R } from "../../hooks/useSearchParams.js";
14
+ import { useSearchToggles as q } from "../../hooks/useSearchToggles.js";
15
+ import { useAskAnalytics as x } from "../../../AskNetlify/hooks/useAskAnalytics.js";
16
16
  import { Fragment as N } from "preact";
17
- import '../../../../../assets/SearchModal.css';function q(r) {
17
+ import '../../../../../assets/SearchModal.css';function D(t) {
18
18
  const n = g(null);
19
19
  return h(() => {
20
20
  function o(m) {
21
- n.current && !n.current.contains(m.target) && r();
21
+ n.current && !n.current.contains(m.target) && t();
22
22
  }
23
23
  return document.addEventListener("mousedown", o), () => {
24
24
  document.removeEventListener("mousedown", o);
25
25
  };
26
- }, [r]), n;
26
+ }, [t]), n;
27
27
  }
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();
28
+ function re(t = { className: "", children: void 0, debug: !1, kapaIntegrationId: void 0 }) {
29
+ const { children: n, className: o, debug: m, ...T } = t, [s, c] = k({ current: "search" }), [i, f] = k(!1), l = () => f(!0), u = () => f(!1), a = g(null), v = D(u), { state: r, actions: p } = C();
30
+ q(l, c), R(p.setSearchTerm, l), P(i, l, u), Q(a, i, u), E(r, m);
31
+ const { handleNewQuery: A, handleAnswer: I } = x();
32
32
  return h(() => {
33
- t.current && (i ? t.current.showModal() : t.current.close());
33
+ a.current && (i ? a.current.showModal() : a.current.close());
34
34
  }, [i]), h(() => {
35
- var k;
36
- const S = (k = t.current) == null ? void 0 : k.querySelector("input");
35
+ var y;
36
+ const S = (y = a.current) == null ? void 0 : y.querySelector("input");
37
37
  S && S.focus();
38
38
  }, [s.current]), /* @__PURE__ */ e(
39
- w,
39
+ b,
40
40
  {
41
- integrationId: r.kapaIntegrationId || "",
41
+ integrationId: t.kapaIntegrationId || "",
42
42
  callbacks: {
43
43
  askAI: {
44
- onQuerySubmit: I,
45
- onAnswerGenerationCompleted: T
44
+ onQuerySubmit: A,
45
+ onAnswerGenerationCompleted: I
46
46
  }
47
47
  },
48
48
  children: /* @__PURE__ */ e(
49
49
  K,
50
50
  {
51
- ref: t,
51
+ ref: a,
52
52
  className: `n-search-modal ${o || ""}`,
53
53
  "data-state": s.current,
54
- ...A,
54
+ ...T,
55
55
  children: /* @__PURE__ */ e("div", { ref: v, className: "n-search-container", children: [
56
- s.current === "ask" && /* @__PURE__ */ e(b, { setModalState: c, initialQuery: a.searchTerm }),
56
+ s.current === "ask" && /* @__PURE__ */ e(w, { setModalState: c, initialQuery: r.searchTerm }),
57
57
  s.current === "search" && /* @__PURE__ */ e(N, { children: [
58
- /* @__PURE__ */ e(C, { setSearchTerm: p.setSearchTerm, initialValue: a.searchTerm }),
58
+ /* @__PURE__ */ e(M, { setSearchTerm: p.setSearchTerm, initialValue: r.searchTerm }),
59
59
  /* @__PURE__ */ e(
60
60
  L,
61
61
  {
62
62
  setModalState: c,
63
- searchLoading: a.isLoading,
64
- searchTerm: a.searchTerm,
65
- results: a.results,
63
+ searchLoading: r.isLoading,
64
+ searchTerm: r.searchTerm,
65
+ results: r.results,
66
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
- ),
67
+ t.kapaIntegrationId && /* @__PURE__ */ e(O, { searchTerm: r.searchTerm, setModalState: c }),
79
68
  n
80
69
  ] })
81
70
  }
@@ -1,63 +1,49 @@
1
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";
2
+ import t from "./SearchHeading/SearchHeading.js";
3
+ import h from "./SearchLink/SearchLink.js";
4
4
  import m from "./SearchLinkThemeToggle.js";
5
- import { Fragment as r } from "preact";
6
- const o = ({
7
- searchTerm: e,
8
- setModalState: c
9
- }) => /* @__PURE__ */ n(
10
- t,
11
- {
12
- as: "button",
13
- icon: "askNetlify",
14
- excerpt: "Get an instant AI-generated answer",
15
- onClick: () => c({ current: "ask" }),
16
- children: [
17
- "Ask Netlify AI: ",
18
- /* @__PURE__ */ n("span", { className: "n-search-term", children: e })
19
- ]
20
- }
21
- ), f = ({ searchTerm: e }) => /* @__PURE__ */ n("div", { className: "n-search-feedback", children: /* @__PURE__ */ n("p", { className: "n-results-info", children: [
5
+ import o from "./AskNetlifyLink.js";
6
+ import { Fragment as a } from "preact";
7
+ const f = ({ searchTerm: l }) => /* @__PURE__ */ n("div", { className: "n-search-feedback", children: /* @__PURE__ */ n("p", { className: "n-results-info", children: [
22
8
  "0 results for ",
23
- /* @__PURE__ */ n("span", { className: "n-search-term", children: e })
24
- ] }) }), N = ({
25
- setModalState: e,
9
+ /* @__PURE__ */ n("span", { className: "n-search-term", children: l })
10
+ ] }) }), p = ({
11
+ setModalState: l,
26
12
  searchLoading: c,
27
13
  searchTerm: i,
28
- results: s
14
+ results: e
29
15
  }) => {
30
- const l = !c && (!s || s.length === 0);
31
- return /* @__PURE__ */ n(r, { children: [
32
- /* @__PURE__ */ n(o, { searchTerm: i, setModalState: e }),
33
- l ? /* @__PURE__ */ n(f, { searchTerm: i }) : /* @__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)) })
16
+ const s = !c && (!e || e.length === 0);
17
+ return /* @__PURE__ */ n(a, { children: [
18
+ /* @__PURE__ */ n(o, { searchTerm: i, setModalState: l }),
19
+ s ? /* @__PURE__ */ n(f, { searchTerm: i }) : /* @__PURE__ */ n("ul", { className: "n-results-list", role: "list", children: e == null ? void 0 : e.map((r, d) => /* @__PURE__ */ n("li", { className: "n-results-list-item", children: /* @__PURE__ */ n(h, { ...r }) }, d)) })
34
20
  ] });
35
21
  };
36
- function A({
37
- setModalState: e,
22
+ function w({
23
+ setModalState: l,
38
24
  searchLoading: c,
39
25
  searchTerm: i,
40
- results: s,
41
- children: l
26
+ results: e,
27
+ children: s
42
28
  }) {
43
- const a = (i == null ? void 0 : i.length) > 1;
44
- return /* @__PURE__ */ n("div", { className: "n-search-window", children: /* @__PURE__ */ n("div", { className: "n-search-links", children: a ? c ? /* @__PURE__ */ n(r, { children: [
45
- /* @__PURE__ */ n(o, { searchTerm: i, setModalState: e }),
29
+ const r = (i == null ? void 0 : i.length) > 1;
30
+ return /* @__PURE__ */ n("div", { className: "n-search-window", children: /* @__PURE__ */ n("div", { className: "n-search-links", children: r ? c ? /* @__PURE__ */ n(a, { children: [
31
+ /* @__PURE__ */ n(o, { searchTerm: i, setModalState: l }),
46
32
  /* @__PURE__ */ n("div", { className: "n-search-feedback", children: /* @__PURE__ */ n("div", { className: "n-loader-dots-spinner" }) })
47
33
  ] }) : /* @__PURE__ */ n(
48
- N,
34
+ p,
49
35
  {
50
- setModalState: e,
36
+ setModalState: l,
51
37
  searchLoading: c,
52
38
  searchTerm: i,
53
- results: s
39
+ results: e
54
40
  }
55
- ) : /* @__PURE__ */ n(r, { children: [
56
- l,
57
- /* @__PURE__ */ n(h, { children: "Actions" }),
41
+ ) : /* @__PURE__ */ n(a, { children: [
42
+ s,
43
+ /* @__PURE__ */ n(t, { children: "Actions" }),
58
44
  /* @__PURE__ */ n(m, {})
59
45
  ] }) }) });
60
46
  }
61
47
  export {
62
- A as default
48
+ w as default
63
49
  };
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": "1.12.1",
4
+ "version": "1.12.2",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -0,0 +1,29 @@
1
+ import SearchLink from './SearchLink/SearchLink';
2
+
3
+ interface Props {
4
+ setModalState: (state: { current: string }) => void;
5
+ searchTerm: string;
6
+ }
7
+
8
+ const AskNetlifyLink = (props: Props) => {
9
+ const label = props.searchTerm ? (
10
+ <>
11
+ Ask Netlify AI: <span className="n-search-term">{props.searchTerm}</span>
12
+ </>
13
+ ) : (
14
+ 'Ask Netlify AI'
15
+ );
16
+
17
+ return (
18
+ <SearchLink
19
+ as="button"
20
+ icon="askNetlify"
21
+ excerpt="Get instant answers, powered by AI"
22
+ onClick={() => props.setModalState({ current: 'ask' })}
23
+ >
24
+ {label}
25
+ </SearchLink>
26
+ );
27
+ };
28
+
29
+ export default AskNetlifyLink;
@@ -7,7 +7,7 @@ import Modal from '../../../../preact/Modal/Modal';
7
7
  import KeyboardKey from '../../../../preact/KeyboardKey/KeyboardKey';
8
8
  import SearchWindow from '../../components/SearchWindow';
9
9
  import SearchInput from '../../components/SearchInput';
10
- import SearchLink from '../../components/SearchLink/SearchLink';
10
+ import AskNetlifyLink from '../AskNetlifyLink';
11
11
  import { useClickOutside } from '../../../../../utils/useClickOutside';
12
12
  import {
13
13
  useSearch,
@@ -93,15 +93,7 @@ function SearchModal(
93
93
  >
94
94
  <>
95
95
  {props.kapaIntegrationId && (
96
- <SearchLink
97
- as="button"
98
- icon="askNetlify"
99
- label="Ask Netlify"
100
- excerpt="Get an instant AI-generated answer"
101
- onClick={() => {
102
- setModalState({ current: 'ask' });
103
- }}
104
- />
96
+ <AskNetlifyLink searchTerm={state.searchTerm} setModalState={setModalState} />
105
97
  )}
106
98
  {children}
107
99
  </>
@@ -3,23 +3,7 @@ import type { SearchResultsProps, SearchWindowProps } from '../types/search.type
3
3
  import SearchHeading from './SearchHeading/SearchHeading';
4
4
  import SearchLink from './SearchLink/SearchLink';
5
5
  import SearchLinkThemeToggle from './SearchLinkThemeToggle';
6
-
7
- const AskNetlifyLink = ({
8
- searchTerm,
9
- setModalState,
10
- }: {
11
- searchTerm: string;
12
- setModalState: (state: { current: string }) => void;
13
- }) => (
14
- <SearchLink
15
- as="button"
16
- icon="askNetlify"
17
- excerpt="Get an instant AI-generated answer"
18
- onClick={() => setModalState({ current: 'ask' })}
19
- >
20
- Ask Netlify AI: <span className="n-search-term">{searchTerm}</span>
21
- </SearchLink>
22
- );
6
+ import AskNetlifyLink from './AskNetlifyLink';
23
7
 
24
8
  const NoResults = ({ searchTerm }: { searchTerm: string }) => (
25
9
  <div className="n-search-feedback">