@floegence/floe-webapp-core 0.56.6 → 0.56.8
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,85 +1,101 @@
|
|
|
1
|
-
import { insert as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { highlightCode as
|
|
5
|
-
import { deferNonBlocking as
|
|
6
|
-
var
|
|
7
|
-
const
|
|
8
|
-
const [
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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),
|
|
17
|
-
|
|
18
|
-
n ===
|
|
23
|
+
s(!0), N(() => {
|
|
24
|
+
M(c, d).then((i) => {
|
|
25
|
+
n === y && (f(i), s(!1));
|
|
19
26
|
}).catch(() => {
|
|
20
|
-
n ===
|
|
27
|
+
n === y && (f(null), s(!1));
|
|
21
28
|
});
|
|
22
29
|
});
|
|
23
30
|
});
|
|
24
|
-
const
|
|
31
|
+
const H = async () => {
|
|
32
|
+
const n = ++a;
|
|
33
|
+
clearTimeout(g);
|
|
25
34
|
try {
|
|
26
|
-
await navigator.clipboard.writeText(t.content),
|
|
27
|
-
|
|
28
|
-
|
|
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 =
|
|
33
|
-
return
|
|
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 =
|
|
39
|
-
return
|
|
50
|
+
var e = A();
|
|
51
|
+
return l(e, () => t.filename), e;
|
|
40
52
|
}
|
|
41
|
-
}), null),
|
|
53
|
+
}), null), l(d, o(v, {
|
|
42
54
|
get when() {
|
|
43
|
-
return
|
|
55
|
+
return $(() => !t.filename)() && t.language;
|
|
44
56
|
},
|
|
45
57
|
get children() {
|
|
46
|
-
var e =
|
|
47
|
-
return
|
|
58
|
+
var e = V();
|
|
59
|
+
return l(e, () => t.language), e;
|
|
48
60
|
}
|
|
49
|
-
}), null),
|
|
61
|
+
}), null), i.$$click = H, l(i, o(v, {
|
|
50
62
|
get when() {
|
|
51
|
-
return
|
|
63
|
+
return u() === "copied";
|
|
52
64
|
},
|
|
53
65
|
get fallback() {
|
|
54
|
-
return o(
|
|
66
|
+
return o(J, {});
|
|
55
67
|
},
|
|
56
68
|
get children() {
|
|
57
|
-
return o(
|
|
69
|
+
return o(K, {});
|
|
58
70
|
}
|
|
59
|
-
})),
|
|
71
|
+
})), l(k, (() => {
|
|
72
|
+
var e = $(() => u() === "idle");
|
|
73
|
+
return () => e() ? "" : w();
|
|
74
|
+
})()), l(B, o(v, {
|
|
60
75
|
get when() {
|
|
61
|
-
return
|
|
76
|
+
return $(() => !T())() && p();
|
|
62
77
|
},
|
|
63
78
|
get fallback() {
|
|
64
79
|
return (() => {
|
|
65
|
-
var e =
|
|
66
|
-
return
|
|
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 =
|
|
71
|
-
return
|
|
85
|
+
var e = q();
|
|
86
|
+
return x(() => e.innerHTML = p()), e;
|
|
72
87
|
}
|
|
73
|
-
})),
|
|
74
|
-
var
|
|
75
|
-
return
|
|
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
|
-
},
|
|
82
|
-
|
|
97
|
+
}, J = () => F(), K = () => G();
|
|
98
|
+
E(["click"]);
|
|
83
99
|
export {
|
|
84
|
-
|
|
100
|
+
X as CodeBlock
|
|
85
101
|
};
|