@netlify/spark-ui 1.5.0-alpha.0 → 1.5.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.
@@ -1 +1 @@
1
- .chat-container{opacity:0;animation:appearContainer .12s ease-in-out forwards;animation-delay:.14s}@keyframes appearContainer{0%{opacity:0}to{opacity:1}}.conversation{height:calc(var(--n-search-container-height) + var(--n-search-footer-height));padding:var(--n-search-padding-inline);scroll-behavior:smooth;overflow-y:auto;display:grid;align-items:flex-end;gap:var(--space-s)}.message{display:grid;gap:var(--space-s)}.message-bubble{padding:var(--space-xs) var(--space-s);background:var(--search-answer-message-color);border-radius:var(--radius-l);width:fit-content;max-width:85%;font-size:var(--step-0)}.prose{font-size:var(--step--0)}.prose>*+*{margin-top:var(--flow-space, var(--space-xs))}.prose h1,.prose h2,.prose h3{font-size:var(--step-1)}.prose h4,.prose h5,.prose h6{font-size:var(--step-0)}.prose pre{background:var(--neutral-light-700);border-radius:var(--radius-m);max-width:100%;box-sizing:border-box}.prose code{overflow-x:auto}.prose code[class*=language-],.prose pre[class*=language-]{display:block;padding:var(--space-s)}.user-message{margin-inline-start:auto;background:var(--search-user-message-color)}.form-wrapper{display:flex;align-items:center;position:relative;height:var(--n-search-input-height)}.form-wrapper:after{content:"";display:block;width:100%;height:1px;background:var(--color-bg-3);position:absolute;top:0;left:0}.form-input{border:none;outline:none;padding-inline:var(--n-search-padding-inline)}.form-submit{padding:.7rem;border-radius:var(--radius-pill);margin-inline-end:var(--space-2xs);border:none;background:var(--color-link);color:var(--neutral-000);transition:background-color .15s ease-out}.form-submit>svg{width:1rem;height:auto;aspect-ratio:1 / 1;border-radius:1.5px;transition:opacity .15s ease-out}.form-submit[disabled]{background:var(--neutral-500)}.form-submit[disabled]>*{opacity:.5}.button-back{width:fit-content;background:transparent;position:absolute;z-index:1;padding:.5rem 1rem;background:var(--search-back-btn-bg-color);margin:1rem;border:2px solid var(--color-bg-3);border-radius:var(--radius-pill);font-size:var(--step--1);border:1px solid;cursor:pointer;border-color:var(--color-bg-3);color:var(--color-text-1);border-width:.5px}.pulsing{display:block;width:1rem;height:1rem;clip-path:circle(40%);background:var(--search-loading-color);animation:pulsing 2.5s infinite ease-in-out}@keyframes pulsing{0%,to{transform:scale(.9)}50%{transform:scale(1.05)}}
1
+ .chat-container{opacity:0;animation:appearContainer .12s ease-in-out forwards;animation-delay:.14s}@keyframes appearContainer{0%{opacity:0}to{opacity:1}}.conversation{height:calc(var(--n-search-container-height) + var(--n-search-footer-height));padding:var(--n-search-padding-inline);scroll-behavior:smooth;overflow-y:auto;display:grid;align-items:flex-end;gap:var(--space-s)}.question{border:none;color:var(--color-text-1);font-weight:var(--font-weight-regular);font-size:var(--step--1);border-radius:var(--radius-pill);transform:translate(-.75rem)}.question-list li{opacity:0;transform:translateY(10px);animation:fadeInUp .5s forwards}.question-list li:nth-child(1){animation-delay:.5s}.question-list li:nth-child(2){animation-delay:.3s}.question-list li:nth-child(3){animation-delay:.1s}@keyframes fadeInUp{to{opacity:1;transform:translateY(0)}}.message{display:grid;gap:var(--space-s)}.message-bubble{padding:var(--space-xs) var(--space-s);background:var(--search-answer-message-color);border-radius:var(--radius-l);width:fit-content;max-width:85%;font-size:var(--step-0)}.prose{font-size:var(--step--0)}.prose>*+*{margin-top:var(--flow-space, var(--space-xs))}.prose h1,.prose h2,.prose h3{font-size:var(--step-1)}.prose h4,.prose h5,.prose h6{font-size:var(--step-0)}.prose pre{background:var(--neutral-light-700);border-radius:var(--radius-m);max-width:100%;box-sizing:border-box}.prose code{overflow-x:auto}.prose code[class*=language-],.prose pre[class*=language-]{display:block;padding:var(--space-s)}.user-message{margin-inline-start:auto;background:var(--search-user-message-color)}.form-wrapper{display:flex;align-items:center;position:relative;height:var(--n-search-input-height)}.form-wrapper:after{content:"";display:block;width:100%;height:1px;background:var(--color-bg-3);position:absolute;top:0;left:0}.form-input{border:none;outline:none;padding-inline:var(--n-search-padding-inline)}.form-submit{padding:.7rem;border-radius:var(--radius-pill);margin-inline-end:var(--space-2xs);border:none;background:var(--color-link);color:var(--neutral-000);transition:background-color .15s ease-out}.form-submit>svg{width:1rem;height:auto;aspect-ratio:1 / 1;border-radius:1.5px;transition:opacity .15s ease-out}.form-submit[disabled]{background:var(--neutral-500)}.form-submit[disabled]>*{opacity:.5}.button-back{width:fit-content;background:transparent;position:absolute;z-index:1;padding:.5rem 1rem;background:var(--search-back-btn-bg-color);margin:1rem;border:2px solid var(--color-bg-3);border-radius:var(--radius-pill);font-size:var(--step--1);border:1px solid;cursor:pointer;border-color:var(--color-bg-3);color:var(--color-text-1);border-width:.5px}.pulsing{display:block;width:1rem;height:1rem;clip-path:circle(40%);background:var(--search-loading-color);animation:pulsing 2.5s infinite ease-in-out}@keyframes pulsing{0%,to{transform:scale(.9)}50%{transform:scale(1.05)}}
@@ -4,7 +4,7 @@ var Ta = (e) => {
4
4
  };
5
5
  var Pi = (e, t, a) => t in e ? Ti(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
6
6
  var P = (e, t, a) => Pi(e, typeof t != "symbol" ? t + "" : t, a), Ht = (e, t, a) => t.has(e) || Ta("Cannot " + a);
7
- var d = (e, t, a) => (Ht(e, t, "read from private field"), a ? a.call(e) : t.get(e)), E = (e, t, a) => t.has(e) ? Ta("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), z = (e, t, a, i) => (Ht(e, t, "write to private field"), i ? i.call(e, a) : t.set(e, a), a), $ = (e, t, a) => (Ht(e, t, "access private method"), a);
7
+ var d = (e, t, a) => (Ht(e, t, "read from private field"), a ? a.call(e) : t.get(e)), _ = (e, t, a) => t.has(e) ? Ta("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, a), z = (e, t, a, i) => (Ht(e, t, "write to private field"), i ? i.call(e, a) : t.set(e, a), a), $ = (e, t, a) => (Ht(e, t, "access private method"), a);
8
8
  var kt = (e, t, a, i) => ({
9
9
  set _(n) {
10
10
  z(e, t, n, a);
@@ -13,7 +13,7 @@ var kt = (e, t, a, i) => ({
13
13
  return d(e, t, i);
14
14
  }
15
15
  });
16
- import { u as _ } from "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
16
+ import { u as E } from "../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
17
17
  import { A as Se, T as Pa, q as ge, y as Oe, x as sa, d as lt, h as qi } from "../../../chunks/hooks.module.DGkdD5n9.js";
18
18
  import { _ as Di, C as Li, R as Ni } from "../../../chunks/compat.module.BNbXPLVY.js";
19
19
  import { createElement as $i, createRef as Fi, Component as Rn, createContext as At } from "preact";
@@ -2924,7 +2924,7 @@ var Ms = (
2924
2924
  ), Us = Os.split("/")[1];
2925
2925
  function Bs(e) {
2926
2926
  var t = e;
2927
- return _(Ms, { children: _(Ks, M({}, t)) });
2927
+ return E(Ms, { children: E(Ks, M({}, t)) });
2928
2928
  }
2929
2929
  function Ks(e) {
2930
2930
  var t = this, a = e.children, i = e.forceRebuild, n = e.cache, r = e.cacheTimeInSeconds, s = e.cachePrefix, l = e.cacheLocation, u = e.customAgent, o = e.loadOptions, c = e.env, h = Se(), m = Se(), g = Pa(function() {
@@ -3012,7 +3012,7 @@ function Ks(e) {
3012
3012
  }, [b, k]);
3013
3013
  return Oe(function() {
3014
3014
  (!h.current || i) && (h.current = f());
3015
- }, [i, g, f]), _(bi.Provider, { value: S, children: a });
3015
+ }, [i, g, f]), E(bi.Provider, { value: S, children: a });
3016
3016
  }
3017
3017
  function Gs(e) {
3018
3018
  var t = Se();
@@ -3241,9 +3241,9 @@ function io(e, t) {
3241
3241
  var Ie, we, Me, mn, ro = (mn = class extends ht {
3242
3242
  constructor() {
3243
3243
  super();
3244
- E(this, Ie);
3245
- E(this, we);
3246
- E(this, Me);
3244
+ _(this, Ie);
3245
+ _(this, we);
3246
+ _(this, Me);
3247
3247
  z(this, Me, (t) => {
3248
3248
  if (!Nt && window.addEventListener) {
3249
3249
  const a = () => t();
@@ -3282,9 +3282,9 @@ var Ie, we, Me, mn, ro = (mn = class extends ht {
3282
3282
  }, Ie = new WeakMap(), we = new WeakMap(), Me = new WeakMap(), mn), vi = new ro(), Ue, xe, Be, gn, so = (gn = class extends ht {
3283
3283
  constructor() {
3284
3284
  super();
3285
- E(this, Ue, !0);
3286
- E(this, xe);
3287
- E(this, Be);
3285
+ _(this, Ue, !0);
3286
+ _(this, xe);
3287
+ _(this, Be);
3288
3288
  z(this, Be, (t) => {
3289
3289
  if (!Nt && window.addEventListener) {
3290
3290
  const a = () => t(!0), i = () => t(!1);
@@ -3469,7 +3469,7 @@ function uo() {
3469
3469
  }
3470
3470
  var U = uo(), Ae, fn, ji = (fn = class {
3471
3471
  constructor() {
3472
- E(this, Ae);
3472
+ _(this, Ae);
3473
3473
  }
3474
3474
  destroy() {
3475
3475
  this.clearGcTimeout();
@@ -3491,14 +3491,14 @@ var U = uo(), Ae, fn, ji = (fn = class {
3491
3491
  }, Ae = new WeakMap(), fn), Ke, Ge, Y, Te, K, st, Pe, ne, de, kn, ho = (kn = class extends ji {
3492
3492
  constructor(t) {
3493
3493
  super();
3494
- E(this, ne);
3495
- E(this, Ke);
3496
- E(this, Ge);
3497
- E(this, Y);
3498
- E(this, Te);
3499
- E(this, K);
3500
- E(this, st);
3501
- E(this, Pe);
3494
+ _(this, ne);
3495
+ _(this, Ke);
3496
+ _(this, Ge);
3497
+ _(this, Y);
3498
+ _(this, Te);
3499
+ _(this, K);
3500
+ _(this, st);
3501
+ _(this, Pe);
3502
3502
  z(this, Pe, !1), z(this, st, t.defaultOptions), this.setOptions(t.options), this.observers = [], z(this, Te, t.client), z(this, Y, d(this, Te).getQueryCache()), this.queryKey = t.queryKey, this.queryHash = t.queryHash, z(this, Ke, mo(this.options)), this.state = t.state ?? d(this, Ke), this.scheduleGc();
3503
3503
  }
3504
3504
  get meta() {
@@ -3776,7 +3776,7 @@ function mo(e) {
3776
3776
  var le, bn, go = (bn = class extends ht {
3777
3777
  constructor(t = {}) {
3778
3778
  super();
3779
- E(this, le);
3779
+ _(this, le);
3780
3780
  this.config = t, z(this, le, /* @__PURE__ */ new Map());
3781
3781
  }
3782
3782
  build(t, a, i) {
@@ -3848,10 +3848,10 @@ var le, bn, go = (bn = class extends ht {
3848
3848
  }, le = new WeakMap(), bn), ce, Q, qe, ue, ye, yn, fo = (yn = class extends ji {
3849
3849
  constructor(t) {
3850
3850
  super();
3851
- E(this, ue);
3852
- E(this, ce);
3853
- E(this, Q);
3854
- E(this, qe);
3851
+ _(this, ue);
3852
+ _(this, ce);
3853
+ _(this, Q);
3854
+ _(this, qe);
3855
3855
  this.mutationId = t.mutationId, z(this, Q, t.mutationCache), z(this, ce, []), this.state = t.state || zi(), this.setOptions(t.options), this.scheduleGc();
3856
3856
  }
3857
3857
  setOptions(t) {
@@ -4048,9 +4048,9 @@ function zi() {
4048
4048
  var pe, ie, ot, vn, ko = (vn = class extends ht {
4049
4049
  constructor(t = {}) {
4050
4050
  super();
4051
- E(this, pe);
4052
- E(this, ie);
4053
- E(this, ot);
4051
+ _(this, pe);
4052
+ _(this, ie);
4053
+ _(this, ot);
4054
4054
  this.config = t, z(this, pe, /* @__PURE__ */ new Set()), z(this, ie, /* @__PURE__ */ new Map()), z(this, ot, 0);
4055
4055
  }
4056
4056
  build(t, a, i) {
@@ -4228,14 +4228,14 @@ function bo(e, { pages: t, pageParams: a }) {
4228
4228
  }
4229
4229
  var L, Re, je, Qe, He, ze, Ve, We, wn, yo = (wn = class {
4230
4230
  constructor(e = {}) {
4231
- E(this, L);
4232
- E(this, Re);
4233
- E(this, je);
4234
- E(this, Qe);
4235
- E(this, He);
4236
- E(this, ze);
4237
- E(this, Ve);
4238
- E(this, We);
4231
+ _(this, L);
4232
+ _(this, Re);
4233
+ _(this, je);
4234
+ _(this, Qe);
4235
+ _(this, He);
4236
+ _(this, ze);
4237
+ _(this, Ve);
4238
+ _(this, We);
4239
4239
  z(this, L, e.queryCache || new go()), z(this, Re, e.mutationCache || new ko()), z(this, je, e.defaultOptions || {}), z(this, Qe, /* @__PURE__ */ new Map()), z(this, He, /* @__PURE__ */ new Map()), z(this, ze, 0);
4240
4240
  }
4241
4241
  mount() {
@@ -4435,11 +4435,11 @@ var L, Re, je, Qe, He, ze, Ve, We, wn, yo = (wn = class {
4435
4435
  }, L = new WeakMap(), Re = new WeakMap(), je = new WeakMap(), Qe = new WeakMap(), He = new WeakMap(), ze = new WeakMap(), Ve = new WeakMap(), We = new WeakMap(), wn), Ee, _e, W, me, fe, jt, ia, xn, vo = (xn = class extends ht {
4436
4436
  constructor(t, a) {
4437
4437
  super();
4438
- E(this, fe);
4439
- E(this, Ee);
4440
- E(this, _e);
4441
- E(this, W);
4442
- E(this, me);
4438
+ _(this, fe);
4439
+ _(this, Ee);
4440
+ _(this, _e);
4441
+ _(this, W);
4442
+ _(this, me);
4443
4443
  z(this, Ee, t), this.setOptions(a), this.bindMethods(), $(this, fe, jt).call(this);
4444
4444
  }
4445
4445
  bindMethods() {
@@ -4513,7 +4513,7 @@ var L, Re, je, Qe, He, ze, Ve, We, wn, yo = (wn = class {
4513
4513
  children: t
4514
4514
  }) => (Oe(() => (e.mount(), () => {
4515
4515
  e.unmount();
4516
- }), [e]), /* @__PURE__ */ _(Ei.Provider, { value: e, children: t }));
4516
+ }), [e]), /* @__PURE__ */ E(Ei.Provider, { value: e, children: t }));
4517
4517
  function Ro(e, t) {
4518
4518
  const a = wo(), [i] = lt(
4519
4519
  () => new vo(
@@ -4948,7 +4948,7 @@ var un = "kapa-recaptcha-script", Bo = ({ siteKey: e, config: t, onLoad: a }) =>
4948
4948
  },
4949
4949
  [r]
4950
4950
  );
4951
- return /* @__PURE__ */ _(
4951
+ return /* @__PURE__ */ E(
4952
4952
  Oi.Provider,
4953
4953
  {
4954
4954
  value: {
@@ -4956,8 +4956,8 @@ var un = "kapa-recaptcha-script", Bo = ({ siteKey: e, config: t, onLoad: a }) =>
4956
4956
  },
4957
4957
  children: [
4958
4958
  e,
4959
- /* @__PURE__ */ _("div", { ref: n, style: { display: "none" }, children: [
4960
- t === "hcaptcha" && a ? /* @__PURE__ */ _(
4959
+ /* @__PURE__ */ E("div", { ref: n, style: { display: "none" }, children: [
4960
+ t === "hcaptcha" && a ? /* @__PURE__ */ E(
4961
4961
  ts,
4962
4962
  {
4963
4963
  sitekey: Go,
@@ -4969,7 +4969,7 @@ var un = "kapa-recaptcha-script", Bo = ({ siteKey: e, config: t, onLoad: a }) =>
4969
4969
  scriptLocation: n.current
4970
4970
  }
4971
4971
  ) : null,
4972
- t === "recaptcha" ? /* @__PURE__ */ _(
4972
+ t === "recaptcha" ? /* @__PURE__ */ E(
4973
4973
  Ko,
4974
4974
  {
4975
4975
  onLoad: () => {
@@ -5472,7 +5472,7 @@ var el = "MHIUVE6Y4VV6H5lpgMyI", dn = "kapa_web_id", Ai = At(void 0), pn = ({
5472
5472
  }
5473
5473
  );
5474
5474
  };
5475
- return /* @__PURE__ */ _(
5475
+ return /* @__PURE__ */ E(
5476
5476
  Ai.Provider,
5477
5477
  {
5478
5478
  value: {
@@ -5505,12 +5505,12 @@ var el = "MHIUVE6Y4VV6H5lpgMyI", dn = "kapa_web_id", Ai = At(void 0), pn = ({
5505
5505
  botProtectionMechanism: r,
5506
5506
  hasConsentForCaptcha: s = !0,
5507
5507
  apiService: l
5508
- }) => /* @__PURE__ */ _(xo, { client: tl, children: /* @__PURE__ */ _(
5508
+ }) => /* @__PURE__ */ E(xo, { client: tl, children: /* @__PURE__ */ E(
5509
5509
  Qo,
5510
5510
  {
5511
5511
  provider: r || "recaptcha",
5512
5512
  hasConsent: s,
5513
- children: a ? /* @__PURE__ */ _(
5513
+ children: a ? /* @__PURE__ */ E(
5514
5514
  Bs,
5515
5515
  {
5516
5516
  loadOptions: {
@@ -5519,7 +5519,7 @@ var el = "MHIUVE6Y4VV6H5lpgMyI", dn = "kapa_web_id", Ai = At(void 0), pn = ({
5519
5519
  scriptUrlPattern: "https://metrics.kapa.ai/web/v<version>/<apiKey>/loader_v<loaderVersion>.js"
5520
5520
  },
5521
5521
  cacheLocation: re.LocalStorage,
5522
- children: /* @__PURE__ */ _(
5522
+ children: /* @__PURE__ */ E(
5523
5523
  pn,
5524
5524
  {
5525
5525
  integrationId: t,
@@ -5531,7 +5531,7 @@ var el = "MHIUVE6Y4VV6H5lpgMyI", dn = "kapa_web_id", Ai = At(void 0), pn = ({
5531
5531
  }
5532
5532
  )
5533
5533
  }
5534
- ) : /* @__PURE__ */ _(
5534
+ ) : /* @__PURE__ */ E(
5535
5535
  pn,
5536
5536
  {
5537
5537
  integrationId: t,
@@ -5562,7 +5562,7 @@ function nl() {
5562
5562
  };
5563
5563
  }
5564
5564
  function hl(e) {
5565
- return /* @__PURE__ */ _(
5565
+ return /* @__PURE__ */ E(
5566
5566
  al,
5567
5567
  {
5568
5568
  integrationId: "3c0789a6-c6a8-4fbc-b0cc-235f9e4a6351",
@@ -5571,19 +5571,29 @@ function hl(e) {
5571
5571
  onQuerySubmit: (t) => console.log("Question asked:", t.question)
5572
5572
  }
5573
5573
  },
5574
- children: /* @__PURE__ */ _(il, { ...e })
5574
+ children: /* @__PURE__ */ E(il, { ...e })
5575
5575
  }
5576
5576
  );
5577
5577
  }
5578
5578
  function il({ setModalState: e }) {
5579
- const [t, a] = lt(""), { conversation: i, submitQuery: n, isGeneratingAnswer: r, isPreparingAnswer: s, stopGeneration: l } = nl(), u = Se(null), o = (c) => {
5580
- c.preventDefault(), t.trim() && (n(t), a(""));
5579
+ const [t, a] = lt(""), { conversation: i, submitQuery: n, isGeneratingAnswer: r, isPreparingAnswer: s, stopGeneration: l } = nl(), u = Se(null), o = {
5580
+ "487cda5f-e852-4223-85dd-d18ab58dc7a9": "Why can't I add my domain to Netlify DNS?",
5581
+ "d133a822-dbe1-4870-8a94-212c5841f194": "Why is my website not loading?",
5582
+ "e477f4dd-7159-4c31-8a18-4dfc7e84d927": "How do I set up environment variables?"
5583
+ }, c = (h) => {
5584
+ h.preventDefault();
5585
+ const m = h.target.getAttribute("data-id");
5586
+ if (m) {
5587
+ const g = o[m];
5588
+ g.trim() && n(g.trim()), a("");
5589
+ }
5590
+ t.trim() && (n(t.trim()), a(""));
5581
5591
  };
5582
5592
  return Oe(() => {
5583
- const c = u.current;
5584
- c && (c.scrollTop = c.scrollHeight);
5585
- }, [i]), /* @__PURE__ */ _("div", { className: "chat-container", children: [
5586
- /* @__PURE__ */ _(
5593
+ const h = u.current;
5594
+ h && (h.scrollTop = h.scrollHeight);
5595
+ }, [i]), /* @__PURE__ */ E("div", { className: "chat-container", children: [
5596
+ /* @__PURE__ */ E(
5587
5597
  "button",
5588
5598
  {
5589
5599
  class: "button button-back",
@@ -5591,7 +5601,7 @@ function il({ setModalState: e }) {
5591
5601
  onClick: () => e({ current: "search" }),
5592
5602
  "aria-label": "Return to search",
5593
5603
  children: [
5594
- /* @__PURE__ */ _("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 320 512", children: /* @__PURE__ */ _(
5604
+ /* @__PURE__ */ E("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 320 512", children: /* @__PURE__ */ E(
5595
5605
  "path",
5596
5606
  {
5597
5607
  d: "M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z",
@@ -5602,47 +5612,50 @@ function il({ setModalState: e }) {
5602
5612
  ]
5603
5613
  }
5604
5614
  ),
5605
- /* @__PURE__ */ _("div", { ref: u, className: "conversation n-search-window", children: i.map((c, h) => /* @__PURE__ */ _("div", { className: "message", children: [
5606
- /* @__PURE__ */ _("div", { className: "message-right", children: /* @__PURE__ */ _("div", { className: "message-bubble user-message", children: /* @__PURE__ */ _("p", { children: c.question }) }) }),
5607
- /* @__PURE__ */ _("div", { className: "message-left", children: c.answer ? /* @__PURE__ */ _("div", { className: "message-bubble bot-message", children: /* @__PURE__ */ _(
5608
- "div",
5609
- {
5610
- className: "message-answer prose flow",
5611
- dangerouslySetInnerHTML: {
5612
- __html: T.parse(c.answer)
5615
+ /* @__PURE__ */ E("div", { ref: u, className: "conversation n-search-window", children: [
5616
+ !i.length && /* @__PURE__ */ E("ul", { class: "question-list", role: "list", children: Object.entries(o).map(([h, m]) => /* @__PURE__ */ E("li", { children: /* @__PURE__ */ E("button", { class: "question", onClick: c, "data-id": h, children: m }) })) }),
5617
+ i.map((h, m) => /* @__PURE__ */ E("div", { className: "message", children: [
5618
+ /* @__PURE__ */ E("div", { className: "message-right", children: /* @__PURE__ */ E("div", { className: "message-bubble user-message", children: /* @__PURE__ */ E("p", { children: h.question }) }) }),
5619
+ /* @__PURE__ */ E("div", { className: "message-left", children: h.answer ? /* @__PURE__ */ E("div", { className: "message-bubble bot-message", children: /* @__PURE__ */ E(
5620
+ "div",
5621
+ {
5622
+ className: "message-answer prose flow",
5623
+ dangerouslySetInnerHTML: {
5624
+ __html: T.parse(h.answer)
5625
+ }
5613
5626
  }
5614
- }
5615
- ) }) : /* @__PURE__ */ _("span", { class: "pulsing" }) })
5616
- ] }, c.id || `qa-${h}`)) }),
5617
- /* @__PURE__ */ _("form", { onSubmit: o, className: "form-wrapper n-search-input-wrapper", children: [
5618
- /* @__PURE__ */ _(
5627
+ ) }) : /* @__PURE__ */ E("span", { class: "pulsing" }) })
5628
+ ] }, h.id || `qa-${m}`))
5629
+ ] }),
5630
+ /* @__PURE__ */ E("form", { onSubmit: c, className: "form-wrapper n-search-input-wrapper", children: [
5631
+ /* @__PURE__ */ E(
5619
5632
  "input",
5620
5633
  {
5621
5634
  type: "text",
5622
5635
  className: "form-input n-search-input",
5623
5636
  value: t,
5624
- onChange: (c) => a(c.target.value),
5637
+ onChange: (h) => a(h.target.value),
5625
5638
  placeholder: "Ask a question...",
5626
5639
  disabled: r
5627
5640
  }
5628
5641
  ),
5629
- r ? /* @__PURE__ */ _(
5642
+ r ? /* @__PURE__ */ E(
5630
5643
  "button",
5631
5644
  {
5632
5645
  type: "button",
5633
5646
  className: "form-submit",
5634
5647
  onClick: l,
5635
5648
  "aria-label": "Stop generation",
5636
- children: /* @__PURE__ */ _("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ _("rect", { x: "0", y: "0", width: "16", height: "16" }) })
5649
+ children: /* @__PURE__ */ E("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ E("rect", { x: "0", y: "0", width: "16", height: "16" }) })
5637
5650
  }
5638
- ) : /* @__PURE__ */ _(
5651
+ ) : /* @__PURE__ */ E(
5639
5652
  "button",
5640
5653
  {
5641
5654
  type: "submit",
5642
5655
  className: "form-submit",
5643
5656
  disabled: !t.trim() || s,
5644
5657
  "aria-label": "Send message",
5645
- children: /* @__PURE__ */ _("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", fill: "currentColor", children: /* @__PURE__ */ _("path", { d: "M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z" }) })
5658
+ children: /* @__PURE__ */ E("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 448 512", fill: "currentColor", children: /* @__PURE__ */ E("path", { d: "M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z" }) })
5646
5659
  }
5647
5660
  )
5648
5661
  ] })
@@ -1,38 +1,40 @@
1
1
  import { u as e } from "../../../../chunks/jsxRuntime.module.Bzuv3cXw.js";
2
- import { T as m } from "../../../../chunks/hooks.module.DGkdD5n9.js";
3
- import o from "./SearchHeading/SearchHeading.js";
2
+ import { T as o } from "../../../../chunks/hooks.module.DGkdD5n9.js";
3
+ import s from "./SearchHeading/SearchHeading.js";
4
4
  import c from "./SearchLink/SearchLink.js";
5
- import { Fragment as s } from "preact";
6
- const h = (n) => {
7
- const r = document.documentElement;
8
- n === "" ? (r.removeAttribute("data-theme"), localStorage.removeItem("theme")) : (r.setAttribute("data-theme", n), localStorage.setItem("theme", n));
9
- }, d = ({
5
+ import { Fragment as m } from "preact";
6
+ const h = {
7
+ light: "dark",
8
+ dark: "light"
9
+ }, d = (n) => {
10
+ document.documentElement.setAttribute("data-theme", n), localStorage.setItem("theme", n);
11
+ }, u = ({
10
12
  searchLoading: n,
11
13
  searchTerm: r,
12
14
  results: t
13
15
  }) => {
14
16
  if (n)
15
- return /* @__PURE__ */ e(o, { children: [
17
+ return /* @__PURE__ */ e(s, { children: [
16
18
  "Searching for ",
17
19
  /* @__PURE__ */ e("span", { className: "n-search-term", children: r }),
18
20
  " ..."
19
21
  ] });
20
22
  if (!t || t.length === 0)
21
- return /* @__PURE__ */ e(o, { children: [
23
+ return /* @__PURE__ */ e(s, { children: [
22
24
  "0 results for ",
23
25
  /* @__PURE__ */ e("span", { className: "n-search-term", children: r })
24
26
  ] });
25
- const i = m(() => t.map((l, a) => /* @__PURE__ */ e("li", { className: "n-results-list-item", children: /* @__PURE__ */ e(c, { ...l }) }, a)), [t]);
26
- return /* @__PURE__ */ e("ul", { className: "n-results-list", role: "list", children: i });
27
+ const a = o(() => t.map((l, i) => /* @__PURE__ */ e("li", { className: "n-results-list-item", children: /* @__PURE__ */ e(c, { ...l }) }, i)), [t]);
28
+ return /* @__PURE__ */ e("ul", { className: "n-results-list", role: "list", children: a });
27
29
  };
28
30
  function b({
29
31
  setModalState: n,
30
32
  searchLoading: r,
31
33
  searchTerm: t,
32
- results: i,
34
+ results: a,
33
35
  children: l
34
36
  }) {
35
- return /* @__PURE__ */ e("div", { className: "n-search-window", children: /* @__PURE__ */ e("div", { className: "search-links", children: t && t.length > 1 ? /* @__PURE__ */ e(d, { searchLoading: r, searchTerm: t, results: i }) : l ? /* @__PURE__ */ e(s, { children: [
37
+ return /* @__PURE__ */ e("div", { className: "n-search-window", children: /* @__PURE__ */ e("div", { className: "search-links", children: t && t.length > 1 ? /* @__PURE__ */ e(u, { searchLoading: r, searchTerm: t, results: a }) : l ? /* @__PURE__ */ e(m, { children: [
36
38
  /* @__PURE__ */ e(
37
39
  c,
38
40
  {
@@ -52,8 +54,8 @@ function b({
52
54
  icon: "netlify",
53
55
  label: "Toggle theme",
54
56
  onClick: () => {
55
- const a = document.documentElement.getAttribute("data-theme");
56
- h(a === "dark" ? "light" : "dark");
57
+ const i = document.documentElement.getAttribute("data-theme");
58
+ i && d(h[i]);
57
59
  }
58
60
  }
59
61
  )
@@ -0,0 +1,3 @@
1
+ export type Theme = 'light' | 'dark';
2
+ export declare const ThemeMap: Record<Theme, Theme>;
3
+ export declare const handleThemeChange: (value: Theme) => void;
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.5.0-alpha.0",
4
+ "version": "1.5.0-alpha.1",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -23,6 +23,40 @@
23
23
  gap: var(--space-s);
24
24
  }
25
25
 
26
+ .question {
27
+ border: none;
28
+ color: var(--color-text-1);
29
+ font-weight: var(--font-weight-regular);
30
+ font-size: var(--step--1);
31
+ border-radius: var(--radius-pill);
32
+ transform: translateX(-0.75rem);
33
+ }
34
+
35
+ .question-list li {
36
+ opacity: 0;
37
+ transform: translateY(10px);
38
+ animation: fadeInUp 0.5s forwards;
39
+ }
40
+
41
+ .question-list li:nth-child(1) {
42
+ animation-delay: 0.5s;
43
+ }
44
+
45
+ .question-list li:nth-child(2) {
46
+ animation-delay: 0.3s;
47
+ }
48
+
49
+ .question-list li:nth-child(3) {
50
+ animation-delay: 0.1s;
51
+ }
52
+
53
+ @keyframes fadeInUp {
54
+ to {
55
+ opacity: 1;
56
+ transform: translateY(0);
57
+ }
58
+ }
59
+
26
60
  .message {
27
61
  display: grid;
28
62
  gap: var(--space-s);
@@ -26,10 +26,27 @@ function ChatInterface({ setModalState }) {
26
26
 
27
27
  const chatRef = useRef(null);
28
28
 
29
+ const QandAMap = {
30
+ '487cda5f-e852-4223-85dd-d18ab58dc7a9': "Why can't I add my domain to Netlify DNS?",
31
+ 'd133a822-dbe1-4870-8a94-212c5841f194': 'Why is my website not loading?',
32
+ 'e477f4dd-7159-4c31-8a18-4dfc7e84d927': 'How do I set up environment variables?',
33
+ };
34
+
29
35
  const handleSubmit = e => {
30
36
  e.preventDefault();
37
+
38
+ const id = e.target.getAttribute('data-id');
39
+
40
+ if (id) {
41
+ const question = QandAMap[id];
42
+ if (question.trim()) {
43
+ submitQuery(question.trim());
44
+ }
45
+ setMessage('');
46
+ }
47
+
31
48
  if (message.trim()) {
32
- submitQuery(message);
49
+ submitQuery(message.trim());
33
50
  setMessage('');
34
51
  }
35
52
  };
@@ -56,6 +73,18 @@ function ChatInterface({ setModalState }) {
56
73
  Search
57
74
  </button>
58
75
  <div ref={chatRef} className="conversation n-search-window">
76
+ {!conversation.length && (
77
+ <ul class="question-list" role="list">
78
+ {Object.entries(QandAMap).map(([id, question]) => (
79
+ <li>
80
+ <button class="question" onClick={handleSubmit} data-id={id}>
81
+ {question}
82
+ </button>
83
+ </li>
84
+ ))}
85
+ </ul>
86
+ )}
87
+
59
88
  {conversation.map((qa, index) => (
60
89
  <div key={qa.id || `qa-${index}`} className="message">
61
90
  <div className="message-right">
@@ -1,12 +1,10 @@
1
1
  import type { FunctionComponent } from 'preact';
2
- import type { SearchLinkProps, SearchResultsProps, SearchWindowProps } from '../types/search.types';
2
+ import type { SearchResultsProps, SearchWindowProps } from '../types/search.types';
3
3
  import { useMemo } from 'preact/hooks';
4
4
  import SearchHeading from './SearchHeading/SearchHeading';
5
5
  import SearchLink from './SearchLink/SearchLink';
6
6
 
7
- import { handleThemeChange } from '@utils/handleThemeChange';
8
-
9
- import Icon from '../../../preact/Icon';
7
+ import { handleThemeChange, ThemeMap, Theme } from '@utils/theme';
10
8
 
11
9
  /* --- Search Results Window (for active searches) --- */
12
10
  const SearchResults: FunctionComponent<SearchResultsProps> = ({
@@ -76,8 +74,8 @@ export default function SearchWindow({
76
74
  icon="netlify"
77
75
  label="Toggle theme"
78
76
  onClick={() => {
79
- const theme = document.documentElement.getAttribute('data-theme');
80
- handleThemeChange(theme === 'dark' ? 'light' : 'dark');
77
+ const theme = document.documentElement.getAttribute('data-theme') as Theme;
78
+ theme && handleThemeChange(ThemeMap[theme]);
81
79
  }}
82
80
  />
83
81
  </>
@@ -0,0 +1,12 @@
1
+ export type Theme = 'light' | 'dark';
2
+
3
+ export const ThemeMap: Record<Theme, Theme> = {
4
+ light: 'dark',
5
+ dark: 'light',
6
+ };
7
+
8
+ export const handleThemeChange = (value: Theme) => {
9
+ const element = document.documentElement;
10
+ element.setAttribute('data-theme', value);
11
+ localStorage.setItem('theme', value);
12
+ };
@@ -1 +0,0 @@
1
- export declare const handleThemeChange: (value: "dark" | "light" | "") => void;
@@ -1,11 +0,0 @@
1
- export const handleThemeChange = (value: 'dark' | 'light' | '') => {
2
- const element = document.documentElement;
3
-
4
- if (value === '') {
5
- element.removeAttribute('data-theme');
6
- localStorage.removeItem('theme');
7
- } else {
8
- element.setAttribute('data-theme', value);
9
- localStorage.setItem('theme', value);
10
- }
11
- };