@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.
- package/dist/components/preact/SearchModal/components/AskNetlifyLink.d.ts +8 -0
- package/dist/components/preact/SearchModal/components/AskNetlifyLink.js +22 -0
- package/dist/components/preact/SearchModal/components/SearchModal/SearchModal.js +31 -42
- package/dist/components/preact/SearchModal/components/SearchWindow.js +27 -41
- package/package.json +1 -1
- package/packages/components/preact/SearchModal/components/AskNetlifyLink.tsx +29 -0
- package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.tsx +2 -10
- package/packages/components/preact/SearchModal/components/SearchWindow.tsx +1 -17
|
@@ -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
|
|
3
|
-
import { A as
|
|
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
|
|
8
|
-
import
|
|
9
|
-
import { useSearch as
|
|
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
|
|
13
|
-
import { useSearchParams as
|
|
14
|
-
import { useSearchToggles as
|
|
15
|
-
import { useAskAnalytics as
|
|
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
|
|
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) &&
|
|
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
|
-
}, [
|
|
26
|
+
}, [t]), n;
|
|
27
27
|
}
|
|
28
|
-
function re(
|
|
29
|
-
const { children: n, className: o, debug: m, ...
|
|
30
|
-
|
|
31
|
-
const { handleNewQuery:
|
|
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
|
-
|
|
33
|
+
a.current && (i ? a.current.showModal() : a.current.close());
|
|
34
34
|
}, [i]), h(() => {
|
|
35
|
-
var
|
|
36
|
-
const S = (
|
|
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
|
-
|
|
39
|
+
b,
|
|
40
40
|
{
|
|
41
|
-
integrationId:
|
|
41
|
+
integrationId: t.kapaIntegrationId || "",
|
|
42
42
|
callbacks: {
|
|
43
43
|
askAI: {
|
|
44
|
-
onQuerySubmit:
|
|
45
|
-
onAnswerGenerationCompleted:
|
|
44
|
+
onQuerySubmit: A,
|
|
45
|
+
onAnswerGenerationCompleted: I
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
children: /* @__PURE__ */ e(
|
|
49
49
|
K,
|
|
50
50
|
{
|
|
51
|
-
ref:
|
|
51
|
+
ref: a,
|
|
52
52
|
className: `n-search-modal ${o || ""}`,
|
|
53
53
|
"data-state": s.current,
|
|
54
|
-
...
|
|
54
|
+
...T,
|
|
55
55
|
children: /* @__PURE__ */ e("div", { ref: v, className: "n-search-container", children: [
|
|
56
|
-
s.current === "ask" && /* @__PURE__ */ e(
|
|
56
|
+
s.current === "ask" && /* @__PURE__ */ e(w, { setModalState: c, initialQuery: r.searchTerm }),
|
|
57
57
|
s.current === "search" && /* @__PURE__ */ e(N, { children: [
|
|
58
|
-
/* @__PURE__ */ e(
|
|
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:
|
|
64
|
-
searchTerm:
|
|
65
|
-
results:
|
|
63
|
+
searchLoading: r.isLoading,
|
|
64
|
+
searchTerm: r.searchTerm,
|
|
65
|
+
results: r.results,
|
|
66
66
|
children: /* @__PURE__ */ e(N, { children: [
|
|
67
|
-
|
|
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
|
|
3
|
-
import
|
|
2
|
+
import t from "./SearchHeading/SearchHeading.js";
|
|
3
|
+
import h from "./SearchLink/SearchLink.js";
|
|
4
4
|
import m from "./SearchLinkThemeToggle.js";
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
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:
|
|
24
|
-
] }) }),
|
|
25
|
-
setModalState:
|
|
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:
|
|
14
|
+
results: e
|
|
29
15
|
}) => {
|
|
30
|
-
const
|
|
31
|
-
return /* @__PURE__ */ n(
|
|
32
|
-
/* @__PURE__ */ n(o, { searchTerm: i, setModalState:
|
|
33
|
-
|
|
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
|
|
37
|
-
setModalState:
|
|
22
|
+
function w({
|
|
23
|
+
setModalState: l,
|
|
38
24
|
searchLoading: c,
|
|
39
25
|
searchTerm: i,
|
|
40
|
-
results:
|
|
41
|
-
children:
|
|
26
|
+
results: e,
|
|
27
|
+
children: s
|
|
42
28
|
}) {
|
|
43
|
-
const
|
|
44
|
-
return /* @__PURE__ */ n("div", { className: "n-search-window", children: /* @__PURE__ */ n("div", { className: "n-search-links", children:
|
|
45
|
-
/* @__PURE__ */ n(o, { searchTerm: i, setModalState:
|
|
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
|
-
|
|
34
|
+
p,
|
|
49
35
|
{
|
|
50
|
-
setModalState:
|
|
36
|
+
setModalState: l,
|
|
51
37
|
searchLoading: c,
|
|
52
38
|
searchTerm: i,
|
|
53
|
-
results:
|
|
39
|
+
results: e
|
|
54
40
|
}
|
|
55
|
-
) : /* @__PURE__ */ n(
|
|
56
|
-
|
|
57
|
-
/* @__PURE__ */ n(
|
|
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
|
-
|
|
48
|
+
w as default
|
|
63
49
|
};
|
package/package.json
CHANGED
|
@@ -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
|
|
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
|
-
<
|
|
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">
|