@floegence/floe-webapp-core 0.56.6 → 0.56.7

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.
@@ -4,5 +4,8 @@ export interface CodeBlockProps {
4
4
  content: string;
5
5
  filename?: string;
6
6
  class?: string;
7
+ copyLabel?: string;
8
+ copiedLabel?: string;
9
+ copyErrorLabel?: string;
7
10
  }
8
11
  export declare const CodeBlock: Component<CodeBlockProps>;
@@ -1,85 +1,101 @@
1
- import { insert as r, createComponent as o, memo as k, effect as _, className as x, setAttribute as y, template as l, delegateEvents as H } from "solid-js/web";
2
- import { createSignal as m, createEffect as B, Show as h } from "solid-js";
3
- import { cn as I } from "../../../utils/cn.js";
4
- import { highlightCode as S } from "../hooks/useCodeHighlight.js";
5
- import { deferNonBlocking as L } from "../../../utils/defer.js";
6
- var T = /* @__PURE__ */ l("<span class=chat-code-filename>"), j = /* @__PURE__ */ l("<span class=chat-code-language>"), E = /* @__PURE__ */ l("<div>"), M = /* @__PURE__ */ l("<div><div class=chat-code-header><div class=chat-code-info></div><button type=button class=chat-code-copy-btn></button></div><div class=chat-code-content>"), N = /* @__PURE__ */ l("<pre class=chat-code-pre><code>"), A = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect x=9 y=9 width=13 height=13 rx=2 ry=2></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1">'), F = /* @__PURE__ */ l('<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><polyline points="20 6 9 17 4 12">');
7
- const K = (t) => {
8
- const [f, g] = m(null), [p, s] = m(!0), [v, w] = m(!1);
9
- let u = 0;
10
- B(() => {
11
- const n = ++u, i = t.content, c = t.language || "text";
12
- if (!i) {
13
- g(""), s(!1);
1
+ import { insert as l, createComponent as o, memo as $, effect as x, className as I, setAttribute as L, template as r, delegateEvents as E } from "solid-js/web";
2
+ import { createSignal as b, createEffect as S, onCleanup as R, Show as v } from "solid-js";
3
+ import { cn as j } from "../../../utils/cn.js";
4
+ import { highlightCode as M } from "../hooks/useCodeHighlight.js";
5
+ import { deferNonBlocking as N } from "../../../utils/defer.js";
6
+ var A = /* @__PURE__ */ r("<span class=chat-code-filename>"), V = /* @__PURE__ */ r("<span class=chat-code-language>"), q = /* @__PURE__ */ r("<div>"), z = /* @__PURE__ */ r("<div><div class=chat-code-header><div class=chat-code-info></div><button type=button class=chat-code-copy-btn></button></div><span class=sr-only role=status aria-live=polite aria-atomic=true></span><div class=chat-code-content>"), D = /* @__PURE__ */ r("<pre class=chat-code-pre><code>"), F = /* @__PURE__ */ r('<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><rect x=9 y=9 width=13 height=13 rx=2 ry=2></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1">'), G = /* @__PURE__ */ r('<svg xmlns=http://www.w3.org/2000/svg width=14 height=14 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><polyline points="20 6 9 17 4 12">');
7
+ const X = (t) => {
8
+ const [p, f] = b(null), [T, s] = b(!0), [u, h] = b("idle");
9
+ let a = 0, g;
10
+ const w = () => u() === "copied" ? t.copiedLabel ?? "Copied!" : u() === "failed" ? t.copyErrorLabel ?? "Could not copy code" : t.copyLabel ?? "Copy code";
11
+ S(() => {
12
+ t.content, a++, clearTimeout(g), h("idle");
13
+ }), R(() => {
14
+ a++, clearTimeout(g);
15
+ });
16
+ let y = 0;
17
+ S(() => {
18
+ const n = ++y, c = t.content, d = t.language || "text";
19
+ if (!c) {
20
+ f(""), s(!1);
14
21
  return;
15
22
  }
16
- s(!0), L(() => {
17
- S(i, c).then((a) => {
18
- n === u && (g(a), s(!1));
23
+ s(!0), N(() => {
24
+ M(c, d).then((i) => {
25
+ n === y && (f(i), s(!1));
19
26
  }).catch(() => {
20
- n === u && (g(null), s(!1));
27
+ n === y && (f(null), s(!1));
21
28
  });
22
29
  });
23
30
  });
24
- const C = async () => {
31
+ const H = async () => {
32
+ const n = ++a;
33
+ clearTimeout(g);
25
34
  try {
26
- await navigator.clipboard.writeText(t.content), w(!0), setTimeout(() => w(!1), 2e3);
27
- } catch (n) {
28
- console.error("Failed to copy:", n);
35
+ if (await navigator.clipboard.writeText(t.content), n !== a) return;
36
+ h("copied");
37
+ } catch {
38
+ if (n !== a) return;
39
+ h("failed");
29
40
  }
41
+ g = setTimeout(() => h("idle"), 2e3);
30
42
  };
31
43
  return (() => {
32
- var n = M(), i = n.firstChild, c = i.firstChild, a = c.nextSibling, b = i.nextSibling;
33
- return r(c, o(h, {
44
+ var n = z(), c = n.firstChild, d = c.firstChild, i = d.nextSibling, k = c.nextSibling, B = k.nextSibling;
45
+ return l(d, o(v, {
34
46
  get when() {
35
47
  return t.filename;
36
48
  },
37
49
  get children() {
38
- var e = T();
39
- return r(e, () => t.filename), e;
50
+ var e = A();
51
+ return l(e, () => t.filename), e;
40
52
  }
41
- }), null), r(c, o(h, {
53
+ }), null), l(d, o(v, {
42
54
  get when() {
43
- return k(() => !t.filename)() && t.language;
55
+ return $(() => !t.filename)() && t.language;
44
56
  },
45
57
  get children() {
46
- var e = j();
47
- return r(e, () => t.language), e;
58
+ var e = V();
59
+ return l(e, () => t.language), e;
48
60
  }
49
- }), null), a.$$click = C, r(a, o(h, {
61
+ }), null), i.$$click = H, l(i, o(v, {
50
62
  get when() {
51
- return v();
63
+ return u() === "copied";
52
64
  },
53
65
  get fallback() {
54
- return o(R, {});
66
+ return o(J, {});
55
67
  },
56
68
  get children() {
57
- return o(V, {});
69
+ return o(K, {});
58
70
  }
59
- })), r(b, o(h, {
71
+ })), l(k, (() => {
72
+ var e = $(() => u() === "idle");
73
+ return () => e() ? "" : w();
74
+ })()), l(B, o(v, {
60
75
  get when() {
61
- return k(() => !p())() && f();
76
+ return $(() => !T())() && p();
62
77
  },
63
78
  get fallback() {
64
79
  return (() => {
65
- var e = N(), d = e.firstChild;
66
- return r(d, () => t.content), e;
80
+ var e = D(), m = e.firstChild;
81
+ return l(m, () => t.content), e;
67
82
  })();
68
83
  },
69
84
  get children() {
70
- var e = E();
71
- return _(() => e.innerHTML = f()), e;
85
+ var e = q();
86
+ return x(() => e.innerHTML = p()), e;
72
87
  }
73
- })), _((e) => {
74
- var d = I("chat-code-block", t.class), $ = v() ? "Copied!" : "Copy code";
75
- return d !== e.e && x(n, e.e = d), $ !== e.t && y(a, "title", e.t = $), e;
88
+ })), x((e) => {
89
+ var m = j("chat-code-block", t.class), C = w(), _ = w();
90
+ return m !== e.e && I(n, e.e = m), C !== e.t && L(i, "title", e.t = C), _ !== e.a && L(i, "aria-label", e.a = _), e;
76
91
  }, {
77
92
  e: void 0,
78
- t: void 0
93
+ t: void 0,
94
+ a: void 0
79
95
  }), n;
80
96
  })();
81
- }, R = () => A(), V = () => F();
82
- H(["click"]);
97
+ }, J = () => F(), K = () => G();
98
+ E(["click"]);
83
99
  export {
84
- K as CodeBlock
100
+ X as CodeBlock
85
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.56.6",
3
+ "version": "0.56.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",