@netlify/spark-ui 1.18.0-alpha.1 → 1.18.0

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.
@@ -4332,7 +4332,7 @@ function cs({ setModalState: e, searchQuery: a, urlParamQuery: t }) {
4332
4332
  isPreparingAnswer: f,
4333
4333
  conversation: l,
4334
4334
  lastMessageRef: u,
4335
- addFeedback: g
4335
+ feedback: g
4336
4336
  }
4337
4337
  )
4338
4338
  ] }),
@@ -1,6 +1,6 @@
1
1
  import "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
2
  import "../../../chunks/hooks.module.DGkdD5n9.js";
3
- import { A as d } from "../../../chunks/AskNetlify.BYFTesUF.js";
3
+ import { A as d } from "../../../chunks/AskNetlify.CpaPeYsd.js";
4
4
  import "./components/QuestionList/questions.js";
5
5
  import "./components/QuestionList/QuestionList.js";
6
6
  import "./components/BackButton.js";
@@ -1,7 +1,7 @@
1
1
  interface ActionBarProps {
2
2
  answer: string;
3
3
  questionAnswerId: string;
4
- addFeedback: (id: string, type: string, meta?: object) => void;
4
+ feedback: (id: string, type: string, meta?: object) => void;
5
5
  }
6
- export declare function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarProps): import("preact").JSX.Element;
6
+ export declare function ActionBar({ answer, questionAnswerId, feedback }: ActionBarProps): import("preact").JSX.Element;
7
7
  export {};
@@ -1,78 +1,78 @@
1
1
  import { u as t } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import i from "../../Icon/index.js";
3
- import s from "../../Popover/Popover.js";
4
- import { A as b } from "../../../../chunks/analytics.D_dJH08O.js";
5
- const d = (n) => {
6
- const e = n.target.closest("button");
7
- if (!e) return;
8
- const o = e.classList.contains("btn-feedback-helpful"), r = e.classList.contains("btn-feedback-incorrect");
9
- if (!o && !r) return;
10
- const c = e.closest(".n-ask-action-bar"), f = c == null ? void 0 : c.querySelector(".btn-feedback-helpful"), p = c == null ? void 0 : c.querySelector(".btn-feedback-incorrect");
11
- [f, p].forEach((l) => {
2
+ import s from "../../Icon/index.js";
3
+ import r from "../../Popover/Popover.js";
4
+ import { A as m } from "../../../../chunks/analytics.D_dJH08O.js";
5
+ const u = (a) => {
6
+ const e = "btn-feedback-helpful", n = "btn-feedback-inaccurate", c = a.target.closest("button");
7
+ if (!c) return;
8
+ const i = c.classList.contains(e), f = c.classList.contains(n);
9
+ if (!i && !f) return;
10
+ const o = c.closest(".n-ask-action-bar"), p = o == null ? void 0 : o.querySelector(`.${e}`), b = o == null ? void 0 : o.querySelector(`.${n}`);
11
+ [p, b].forEach((l) => {
12
12
  if (!l) return;
13
- l.querySelectorAll('[id*="icon"]').forEach((a, u) => {
14
- u === 0 ? a.classList.remove("hidden") : a.classList.add("hidden");
13
+ l.querySelectorAll('[id*="icon"]').forEach((d, h) => {
14
+ h === 0 ? d.classList.remove("hidden") : d.classList.add("hidden");
15
15
  });
16
- }), e.querySelectorAll('[id*="icon"]').forEach((l) => {
16
+ }), c.querySelectorAll('[id*="icon"]').forEach((l) => {
17
17
  l.classList.toggle("hidden");
18
18
  });
19
- }, h = async (n) => {
20
- const e = document.getElementById("copy-popover");
19
+ }, k = async (a) => {
20
+ const e = document.getElementById("copy-popover"), n = 2e3;
21
21
  try {
22
- await navigator.clipboard.writeText(n), e && (e.textContent = "Copied", setTimeout(() => {
22
+ await navigator.clipboard.writeText(a), e && (e.textContent = "Copied", setTimeout(() => {
23
23
  e.textContent = "Copy", e.blur();
24
- }, 2e3));
25
- } catch (o) {
26
- console.error("Failed to copy code: ", o), e && (e.textContent = "Failed to copy", setTimeout(() => {
24
+ }, n));
25
+ } catch (c) {
26
+ console.error("Failed to copy code: ", c), e && (e.textContent = "Failed to copy", setTimeout(() => {
27
27
  e.textContent = "Copy", e.blur();
28
- }, 2e3));
28
+ }, n));
29
29
  }
30
30
  };
31
- function x({ answer: n, questionAnswerId: e, addFeedback: o }) {
32
- const r = new b();
31
+ function T({ answer: a, questionAnswerId: e, feedback: n }) {
32
+ const c = new m();
33
33
  return /* @__PURE__ */ t("div", { className: "n-ask-action-bar", children: [
34
- /* @__PURE__ */ t(s, { id: "copy", content: "Copy", children: /* @__PURE__ */ t(
34
+ /* @__PURE__ */ t(r, { id: "copy", content: "Copy", children: /* @__PURE__ */ t(
35
35
  "button",
36
36
  {
37
37
  onClick: () => {
38
- h(n), r.track("ask:copy_answer", { id: e });
38
+ k(a), c.track("ask:copy_answer", { id: e });
39
39
  },
40
- children: /* @__PURE__ */ t(i, { name: "copy" })
40
+ children: /* @__PURE__ */ t(s, { name: "copy" })
41
41
  }
42
42
  ) }),
43
- /* @__PURE__ */ t(s, { id: "feedback-helpful", content: "Helpful", children: /* @__PURE__ */ t(
43
+ /* @__PURE__ */ t(r, { id: "feedback-helpful", content: "Helpful", children: /* @__PURE__ */ t(
44
44
  "button",
45
45
  {
46
46
  class: "btn-feedback-helpful n-stack",
47
- onClick: (c) => {
48
- d(c), o(e, "upvote"), r.track("ask:feedback_helpful", { id: e });
47
+ onClick: (i) => {
48
+ u(i), n(e, "upvote"), c.track("ask:feedback_helpful", { id: e });
49
49
  },
50
50
  children: [
51
- /* @__PURE__ */ t(i, { name: "thumbsUp" }),
52
- /* @__PURE__ */ t(i, { name: "thumbsUpSolid", className: "hidden" })
51
+ /* @__PURE__ */ t(s, { name: "thumbsUp" }),
52
+ /* @__PURE__ */ t(s, { name: "thumbsUpSolid", className: "hidden" })
53
53
  ]
54
54
  }
55
55
  ) }),
56
- /* @__PURE__ */ t(s, { id: "feedback-incorrect", content: "Not helpful", children: /* @__PURE__ */ t(
56
+ /* @__PURE__ */ t(r, { id: "feedback-inaccurate", content: "Not helpful", children: /* @__PURE__ */ t(
57
57
  "button",
58
58
  {
59
- class: "btn-feedback-incorrect n-stack",
60
- onClick: (c) => {
61
- d(c), o(e, "downvote", {
59
+ class: "btn-feedback-inaccurate n-stack",
60
+ onClick: (i) => {
61
+ u(i), n(e, "downvote", {
62
62
  incorrect: !0,
63
63
  irrelevant: !1,
64
64
  unaddressed: !1,
65
- issue: "This information isn't accurate"
66
- }), r.track("ask:feedback_not_helpful", { id: e });
65
+ issue: "This information is inaccurate"
66
+ }), c.track("ask:feedback_inaccurate", { id: e });
67
67
  },
68
68
  children: [
69
- /* @__PURE__ */ t(i, { name: "thumbsDown" }),
70
- /* @__PURE__ */ t(i, { name: "thumbsDownSolid", className: "hidden" })
69
+ /* @__PURE__ */ t(s, { name: "thumbsDown" }),
70
+ /* @__PURE__ */ t(s, { name: "thumbsDownSolid", className: "hidden" })
71
71
  ]
72
72
  }
73
73
  ) })
74
74
  ] });
75
75
  }
76
76
  export {
77
- x as ActionBar
77
+ T as ActionBar
78
78
  };
@@ -1,7 +1,7 @@
1
1
  import { Ref } from 'preact';
2
- export declare function ChatMessages({ conversation, lastMessageRef, isPreparingAnswer, addFeedback, }: {
2
+ export declare function ChatMessages({ conversation, lastMessageRef, isPreparingAnswer, feedback, }: {
3
3
  conversation: any[];
4
4
  lastMessageRef: Ref<HTMLDivElement>;
5
5
  isPreparingAnswer: boolean;
6
- addFeedback: any;
6
+ feedback: any;
7
7
  }): import("preact").JSX.Element;
@@ -1570,7 +1570,7 @@ function ft({
1570
1570
  conversation: n,
1571
1571
  lastMessageRef: e,
1572
1572
  isPreparingAnswer: t,
1573
- addFeedback: r
1573
+ feedback: r
1574
1574
  }) {
1575
1575
  return /* @__PURE__ */ w(ve, { children: [
1576
1576
  n.map((s, i) => {
@@ -1592,14 +1592,7 @@ function ft({
1592
1592
  dangerouslySetInnerHTML: { __html: f.parse(s.answer) }
1593
1593
  }
1594
1594
  ),
1595
- s.id && /* @__PURE__ */ w(
1596
- Re,
1597
- {
1598
- answer: s.answer,
1599
- addFeedback: r,
1600
- questionAnswerId: s.id
1601
- }
1602
- ),
1595
+ s.id && /* @__PURE__ */ w(Re, { answer: s.answer, feedback: r, questionAnswerId: s.id }),
1603
1596
  s.id && /* @__PURE__ */ w($e, { sources: s.sources })
1604
1597
  ] }) })
1605
1598
  ] }, s.id || `qa-${i}`);
@@ -1,6 +1,6 @@
1
1
  import { u as e } from "../../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
2
  import { A as g, y as f, d } from "../../../../../chunks/hooks.module.DGkdD5n9.js";
3
- import { A as K, K as L } from "../../../../../chunks/AskNetlify.BYFTesUF.js";
3
+ import { A as K, K as L } from "../../../../../chunks/AskNetlify.CpaPeYsd.js";
4
4
  import P from "../../../Modal/Modal.js";
5
5
  import h from "../../../KeyboardKey/KeyboardKey.js";
6
6
  import M from "../SearchWindow.js";
@@ -4,7 +4,7 @@ import { default as m } from "./Icon/index.js";
4
4
  import { default as s } from "./SearchModal/components/SearchLink/SearchLink.js";
5
5
  import { default as u } from "./SearchModal/components/SearchHeading/SearchHeading.js";
6
6
  import { default as i } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
- import { A as S } from "../../chunks/AskNetlify.BYFTesUF.js";
7
+ import { A as S } from "../../chunks/AskNetlify.CpaPeYsd.js";
8
8
  import "preact";
9
9
  import "../../chunks/hooks.module.DGkdD5n9.js";
10
10
  import { default as n } from "./SearchModal/components/SearchModal/SearchModal.js";
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.18.0-alpha.1",
4
+ "version": "1.18.0",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -68,4 +68,4 @@
68
68
  "prettier": "^3.5.3",
69
69
  "prettier-plugin-astro": "^0.14.1"
70
70
  }
71
- }
71
+ }
@@ -84,7 +84,7 @@ export default function AskNetlify({ setModalState, searchQuery, urlParamQuery }
84
84
  isPreparingAnswer={isPreparingAnswer}
85
85
  conversation={conversation}
86
86
  lastMessageRef={lastMessageRef}
87
- addFeedback={addFeedback}
87
+ feedback={addFeedback}
88
88
  />
89
89
  )}
90
90
  </div>
@@ -1,29 +1,32 @@
1
1
  import Icon from '@components/preact/Icon';
2
2
  import Popover from '@components/preact/Popover/Popover';
3
3
  import Analytics from '@analtyics/analytics';
4
+
4
5
  interface ActionBarProps {
5
6
  answer: string;
6
7
  questionAnswerId: string;
7
- addFeedback: (id: string, type: string, meta?: object) => void;
8
+ feedback: (id: string, type: string, meta?: object) => void;
8
9
  }
9
10
 
10
11
  const toggleFeedbackButton = (e: MouseEvent): void => {
12
+ const feedbackHelpfulId = 'btn-feedback-helpful';
13
+ const feedbackInaccurateId = 'btn-feedback-inaccurate';
11
14
  const btn = (e.target as HTMLElement).closest('button');
12
15
  if (!btn) return;
13
16
 
14
- const isHelpfulBtn = btn.classList.contains('btn-feedback-helpful');
15
- const isIncorrectBtn = btn.classList.contains('btn-feedback-incorrect');
17
+ const isHelpfulBtn = btn.classList.contains(feedbackHelpfulId);
18
+ const isInaccurateBtn = btn.classList.contains(feedbackInaccurateId);
16
19
 
17
20
  // Only proceed if it's one of the feedback buttons
18
- if (!isHelpfulBtn && !isIncorrectBtn) return;
21
+ if (!isHelpfulBtn && !isInaccurateBtn) return;
19
22
 
20
23
  // Get both feedback buttons
21
24
  const actionBar = btn.closest('.n-ask-action-bar');
22
- const helpfulBtn = actionBar?.querySelector('.btn-feedback-helpful');
23
- const incorrectBtn = actionBar?.querySelector('.btn-feedback-incorrect');
25
+ const helpfulBtn = actionBar?.querySelector(`.${feedbackHelpfulId}`);
26
+ const inaccurateBtn = actionBar?.querySelector(`.${feedbackInaccurateId}`);
24
27
 
25
28
  // Reset both buttons first (hide all solid icons, show all outline icons)
26
- [helpfulBtn, incorrectBtn].forEach(button => {
29
+ [helpfulBtn, inaccurateBtn].forEach(button => {
27
30
  if (!button) return;
28
31
  const icons = button.querySelectorAll('[id*="icon"]');
29
32
  icons.forEach((icon, index) => {
@@ -44,6 +47,7 @@ const toggleFeedbackButton = (e: MouseEvent): void => {
44
47
 
45
48
  const copyToClipboard = async (text: string): Promise<void> => {
46
49
  const copyPopover = document.getElementById('copy-popover');
50
+ const MAX_TIME = 2000;
47
51
  try {
48
52
  await navigator.clipboard.writeText(text);
49
53
  if (copyPopover) {
@@ -51,7 +55,7 @@ const copyToClipboard = async (text: string): Promise<void> => {
51
55
  setTimeout(() => {
52
56
  copyPopover.textContent = 'Copy';
53
57
  copyPopover.blur();
54
- }, 2000);
58
+ }, MAX_TIME);
55
59
  }
56
60
  } catch (error) {
57
61
  console.error('Failed to copy code: ', error);
@@ -60,12 +64,12 @@ const copyToClipboard = async (text: string): Promise<void> => {
60
64
  setTimeout(() => {
61
65
  copyPopover.textContent = 'Copy';
62
66
  copyPopover.blur();
63
- }, 2000);
67
+ }, MAX_TIME);
64
68
  }
65
69
  }
66
70
  };
67
71
 
68
- export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarProps) {
72
+ export function ActionBar({ answer, questionAnswerId, feedback }: ActionBarProps) {
69
73
  const analytics = new Analytics();
70
74
 
71
75
  return (
@@ -86,7 +90,7 @@ export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarPr
86
90
  class="btn-feedback-helpful n-stack"
87
91
  onClick={e => {
88
92
  toggleFeedbackButton(e as unknown as MouseEvent);
89
- addFeedback(questionAnswerId, 'upvote');
93
+ feedback(questionAnswerId, 'upvote');
90
94
  analytics.track('ask:feedback_helpful', { id: questionAnswerId });
91
95
  }}
92
96
  >
@@ -95,18 +99,18 @@ export function ActionBar({ answer, questionAnswerId, addFeedback }: ActionBarPr
95
99
  </button>
96
100
  </Popover>
97
101
 
98
- <Popover id="feedback-incorrect" content={`Not helpful`}>
102
+ <Popover id="feedback-inaccurate" content={`Not helpful`}>
99
103
  <button
100
- class="btn-feedback-incorrect n-stack"
104
+ class="btn-feedback-inaccurate n-stack"
101
105
  onClick={e => {
102
106
  toggleFeedbackButton(e as unknown as MouseEvent);
103
- addFeedback(questionAnswerId, 'downvote', {
107
+ feedback(questionAnswerId, 'downvote', {
104
108
  incorrect: true,
105
109
  irrelevant: false,
106
110
  unaddressed: false,
107
- issue: "This information isn't accurate",
111
+ issue: 'This information is inaccurate',
108
112
  });
109
- analytics.track('ask:feedback_not_helpful', { id: questionAnswerId });
113
+ analytics.track('ask:feedback_inaccurate', { id: questionAnswerId });
110
114
  }}
111
115
  >
112
116
  <Icon name="thumbsDown" />
@@ -8,12 +8,12 @@ export function ChatMessages({
8
8
  conversation,
9
9
  lastMessageRef,
10
10
  isPreparingAnswer,
11
- addFeedback,
11
+ feedback,
12
12
  }: {
13
13
  conversation: any[];
14
14
  lastMessageRef: Ref<HTMLDivElement>;
15
15
  isPreparingAnswer: boolean;
16
- addFeedback: any;
16
+ feedback: any;
17
17
  }) {
18
18
  return (
19
19
  <>
@@ -38,11 +38,7 @@ export function ChatMessages({
38
38
  dangerouslySetInnerHTML={{ __html: marked.parse(qa.answer) }}
39
39
  />
40
40
  {qa.id && (
41
- <ActionBar
42
- answer={qa.answer}
43
- addFeedback={addFeedback}
44
- questionAnswerId={qa.id}
45
- />
41
+ <ActionBar answer={qa.answer} feedback={feedback} questionAnswerId={qa.id} />
46
42
  )}
47
43
  {qa.id && <SourcesList sources={qa.sources} />}
48
44
  </div>