@nonoun/native-chat 0.5.2 → 0.5.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.
- package/dist/{chat-input-structured-element-uXGIe-HI.js → chat-input-structured-element-Bt9nkgXp.js} +147 -82
- package/dist/message/chat-message-element.d.ts +2 -2
- package/dist/message/chat-message-element.d.ts.map +1 -1
- package/dist/message/chat-messages-element.d.ts +16 -6
- package/dist/message/chat-messages-element.d.ts.map +1 -1
- package/dist/native-chat.css +92 -41
- package/dist/native-chat.js +1 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +2 -2
- package/package.json +1 -1
package/dist/{chat-input-structured-element-uXGIe-HI.js → chat-input-structured-element-Bt9nkgXp.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NativeElement as e, VirtualScrollController as t, createDisabledEffect as n, signal as r } from "@nonoun/native-ui";
|
|
1
|
+
import { NativeElement as e, VirtualScrollController as t, createDisabledEffect as n, signal as r, uid as i } from "@nonoun/native-ui";
|
|
2
2
|
/**
|
|
3
3
|
* Chat message input with textarea, submit button, and Enter-to-send behavior.
|
|
4
4
|
* @attr {boolean} disabled - Disables interaction
|
|
@@ -10,7 +10,7 @@ import { NativeElement as e, VirtualScrollController as t, createDisabledEffect
|
|
|
10
10
|
* @fires native:composer-focus - Fired when the composer textarea gains focus
|
|
11
11
|
* @fires native:composer-blur - Fired when the composer textarea loses focus
|
|
12
12
|
*/
|
|
13
|
-
var
|
|
13
|
+
var a = class extends e {
|
|
14
14
|
static observedAttributes = ["disabled", "busy"];
|
|
15
15
|
#e;
|
|
16
16
|
#t = r(!1);
|
|
@@ -131,7 +131,7 @@ var i = class extends e {
|
|
|
131
131
|
})) && !this.hasAttribute("no-auto-clear") && (this.value = "", this.#i?.setAttribute("disabled", ""));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, o = class extends e {
|
|
135
135
|
static observedAttributes = [
|
|
136
136
|
"show-stop",
|
|
137
137
|
"show-restart",
|
|
@@ -224,7 +224,7 @@ var i = class extends e {
|
|
|
224
224
|
let d = document.createElement("n-button");
|
|
225
225
|
d.setAttribute("variant", "ghost"), d.setAttribute("inline", ""), d.innerHTML = "<n-icon name=\"microphone\"></n-icon>", l.appendChild(d);
|
|
226
226
|
let f = document.createElement("n-button");
|
|
227
|
-
f.setAttribute("variant", "primary"), f.setAttribute("intent", "accent"), f.setAttribute("radius", "round"), f.setAttribute("inline", ""), f.setAttribute("disabled", ""), f.
|
|
227
|
+
f.setAttribute("variant", "primary"), f.setAttribute("intent", "accent"), f.setAttribute("radius", "round"), f.setAttribute("inline", ""), f.setAttribute("disabled", ""), f.dataset.role = "submit", f.innerHTML = "<n-icon name=\"arrow-up\"></n-icon>", l.appendChild(f), s.appendChild(l), o.appendChild(s), this.append(e, i, o), this.addEffect(() => {
|
|
228
228
|
let e = this.#e.value;
|
|
229
229
|
if (e && !this.#a) {
|
|
230
230
|
let e = document.createElement("n-button");
|
|
@@ -342,7 +342,7 @@ var i = class extends e {
|
|
|
342
342
|
composed: !0
|
|
343
343
|
}));
|
|
344
344
|
};
|
|
345
|
-
},
|
|
345
|
+
}, s = 40, c = class extends e {
|
|
346
346
|
static observedAttributes = [
|
|
347
347
|
"auto-scroll",
|
|
348
348
|
"scrollable",
|
|
@@ -451,7 +451,7 @@ var i = class extends e {
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
#f = () => {
|
|
454
|
-
let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight -
|
|
454
|
+
let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight - s;
|
|
455
455
|
this.#n.value = t, t !== e && this.dispatchEvent(new CustomEvent("native:feed-scroll", {
|
|
456
456
|
bubbles: !0,
|
|
457
457
|
composed: !0,
|
|
@@ -470,7 +470,7 @@ var i = class extends e {
|
|
|
470
470
|
});
|
|
471
471
|
};
|
|
472
472
|
#m = (e) => {};
|
|
473
|
-
},
|
|
473
|
+
}, l = class extends e {
|
|
474
474
|
static observedAttributes = [
|
|
475
475
|
"src",
|
|
476
476
|
"name",
|
|
@@ -510,7 +510,7 @@ var i = class extends e {
|
|
|
510
510
|
}
|
|
511
511
|
if (n) {
|
|
512
512
|
let e = document.createElement("span");
|
|
513
|
-
e.className = "n-chat-avatar-initials", e.textContent =
|
|
513
|
+
e.className = "n-chat-avatar-initials", e.textContent = u(n), e.setAttribute("aria-hidden", "true"), this.appendChild(e);
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
516
516
|
let r = document.createElement("n-icon");
|
|
@@ -521,11 +521,11 @@ var i = class extends e {
|
|
|
521
521
|
this.textContent = "", super.teardown();
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
|
-
function
|
|
524
|
+
function u(e) {
|
|
525
525
|
let t = e.trim().split(/\s+/);
|
|
526
526
|
return t.length === 0 ? "" : t.length === 1 ? t[0][0].toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
|
|
527
527
|
}
|
|
528
|
-
const
|
|
528
|
+
const d = {
|
|
529
529
|
copy: {
|
|
530
530
|
label: "Copy",
|
|
531
531
|
icon: "copy"
|
|
@@ -550,7 +550,7 @@ const u = {
|
|
|
550
550
|
label: "Continue",
|
|
551
551
|
icon: "arrow-right"
|
|
552
552
|
}
|
|
553
|
-
},
|
|
553
|
+
}, f = {
|
|
554
554
|
assistant: [
|
|
555
555
|
"copy",
|
|
556
556
|
"retry",
|
|
@@ -570,12 +570,12 @@ const u = {
|
|
|
570
570
|
* @attr {string} timestamp - Epoch milliseconds
|
|
571
571
|
* @attr {string} status - `sending` | `sent` | `error` | `streaming` | `partial`
|
|
572
572
|
* @attr {string} actions - Comma-separated action list, or `"none"` to suppress
|
|
573
|
-
* @attr {string} actions-style - `"
|
|
574
|
-
* @attr {string} actions-position - `"
|
|
573
|
+
* @attr {string} actions-style - `"icon"` (default) | `"label"` | `"icon-label"`
|
|
574
|
+
* @attr {string} actions-position - `"below"` (default) | `"inside"` — toolbar placement
|
|
575
575
|
* @fires native:message-action - Fired when an action button is clicked
|
|
576
576
|
* @fires native:continue-request - Fired when continue is requested for a partial message
|
|
577
577
|
*/
|
|
578
|
-
var
|
|
578
|
+
var p = class extends e {
|
|
579
579
|
static observedAttributes = [
|
|
580
580
|
"role",
|
|
581
581
|
"message-id",
|
|
@@ -589,9 +589,11 @@ var f = class extends e {
|
|
|
589
589
|
#t = r("assistant");
|
|
590
590
|
#n = r("sent");
|
|
591
591
|
#r = r(null);
|
|
592
|
-
#i = r("
|
|
593
|
-
#a = r("
|
|
592
|
+
#i = r("icon");
|
|
593
|
+
#a = r("below");
|
|
594
594
|
#o = null;
|
|
595
|
+
#s = !1;
|
|
596
|
+
#c = 0;
|
|
595
597
|
constructor() {
|
|
596
598
|
super(), this.#e = this.attachInternals();
|
|
597
599
|
}
|
|
@@ -644,40 +646,71 @@ var f = class extends e {
|
|
|
644
646
|
this.#r.value = n;
|
|
645
647
|
break;
|
|
646
648
|
case "actions-style":
|
|
647
|
-
this.#i.value = n ?? "
|
|
649
|
+
this.#i.value = n ?? "icon";
|
|
648
650
|
break;
|
|
649
651
|
case "actions-position":
|
|
650
|
-
this.#a.value = n ?? "
|
|
652
|
+
this.#a.value = n ?? "below";
|
|
651
653
|
break;
|
|
652
654
|
}
|
|
653
655
|
super.attributeChangedCallback(e, t, n);
|
|
654
656
|
}
|
|
655
657
|
}
|
|
656
658
|
setup() {
|
|
657
|
-
super.setup(), this.addEffect(() => {
|
|
659
|
+
super.setup(), this.addEventListener("pointerenter", this.#l), this.addEventListener("pointerleave", this.#u), this.addEffect(() => {
|
|
658
660
|
let e = this.#t.value, t = this.#r.value, n = this.#i.value, r = this.#a.value, i = this.#n.value;
|
|
659
|
-
this.#
|
|
660
|
-
}), this.#e.role = "article"
|
|
661
|
+
this.#f(e, t, n, r, i);
|
|
662
|
+
}), this.#e.role = "article";
|
|
661
663
|
}
|
|
662
664
|
teardown() {
|
|
663
|
-
this.removeEventListener("
|
|
664
|
-
}
|
|
665
|
-
#
|
|
666
|
-
if (this.#
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
665
|
+
this.removeEventListener("pointerenter", this.#l), this.removeEventListener("pointerleave", this.#u), clearTimeout(this.#c), this.#o &&= (this.#d(), null), super.teardown();
|
|
666
|
+
}
|
|
667
|
+
#l = () => {
|
|
668
|
+
if (clearTimeout(this.#c), this.#o && this.#s && this.#n.value !== "partial") try {
|
|
669
|
+
this.#o.showPopover();
|
|
670
|
+
} catch {}
|
|
671
|
+
};
|
|
672
|
+
#u = () => {
|
|
673
|
+
!this.#s || this.#n.value === "partial" || (clearTimeout(this.#c), this.#c = window.setTimeout(() => {
|
|
674
|
+
try {
|
|
675
|
+
this.#o?.hidePopover();
|
|
676
|
+
} catch {}
|
|
677
|
+
}, 150));
|
|
678
|
+
};
|
|
679
|
+
#d() {
|
|
680
|
+
if (this.#o) {
|
|
681
|
+
if (this.#s) {
|
|
682
|
+
this.#o.removeEventListener("pointerenter", this.#l), this.#o.removeEventListener("pointerleave", this.#u), this.#o.removeEventListener("focusin", this.#l), this.#o.removeEventListener("focusout", this.#u);
|
|
683
|
+
try {
|
|
684
|
+
this.#o.hidePopover();
|
|
685
|
+
} catch {}
|
|
686
|
+
this.style.removeProperty("anchor-name"), this.#s = !1;
|
|
687
|
+
}
|
|
688
|
+
this.#o.removeEventListener("native:press", this.#p), this.#o.remove();
|
|
674
689
|
}
|
|
675
|
-
o.children.length !== 0 && (r === "below" ? this.after(o) : this.appendChild(o), this.#o = o);
|
|
676
690
|
}
|
|
677
|
-
#
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
691
|
+
#f(e, t, n, r, a) {
|
|
692
|
+
if (this.#o &&= (this.#d(), null), clearTimeout(this.#c), t === "none" || this.querySelector("[slot=\"actions\"]")) return;
|
|
693
|
+
let o;
|
|
694
|
+
if (o = t ? t.split(",").map((e) => e.trim()).filter(Boolean) : f[e] ?? [], a === "partial" && !o.includes("continue") && (o = [...o, "continue"]), o.length === 0) return;
|
|
695
|
+
let s = document.createElement("n-toolbar");
|
|
696
|
+
s.dataset.role = "actions", s.setAttribute("padding", "tight"), s.setAttribute("aria-label", "Message actions"), n !== "label" && s.setAttribute("data-style", n);
|
|
697
|
+
for (let e of o) {
|
|
698
|
+
let t = d[e];
|
|
699
|
+
t && s.appendChild(m(e, t, n));
|
|
700
|
+
}
|
|
701
|
+
if (s.children.length !== 0) {
|
|
702
|
+
if (s.addEventListener("native:press", this.#p), r === "below") {
|
|
703
|
+
s.setAttribute("popover", "manual");
|
|
704
|
+
let e = i("msg");
|
|
705
|
+
this.style.setProperty("anchor-name", `--${e}`), s.style.setProperty("position-anchor", `--${e}`), this.appendChild(s), this.#s = !0, s.addEventListener("pointerenter", this.#l), s.addEventListener("pointerleave", this.#u), s.addEventListener("focusin", this.#l), s.addEventListener("focusout", this.#u), a === "partial" && s.showPopover();
|
|
706
|
+
} else this.appendChild(s);
|
|
707
|
+
this.#o = s;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
#p = (e) => {
|
|
711
|
+
let t = e.target?.getAttribute("data-action");
|
|
712
|
+
if (t) {
|
|
713
|
+
if (e.stopPropagation(), t === "continue") {
|
|
681
714
|
this.dispatchEvent(new CustomEvent("native:continue-request", {
|
|
682
715
|
bubbles: !0,
|
|
683
716
|
composed: !0,
|
|
@@ -689,14 +722,14 @@ var f = class extends e {
|
|
|
689
722
|
bubbles: !0,
|
|
690
723
|
composed: !0,
|
|
691
724
|
detail: {
|
|
692
|
-
action:
|
|
725
|
+
action: t,
|
|
693
726
|
messageId: this.messageId
|
|
694
727
|
}
|
|
695
728
|
}));
|
|
696
729
|
}
|
|
697
730
|
};
|
|
698
731
|
};
|
|
699
|
-
function
|
|
732
|
+
function m(e, t, n) {
|
|
700
733
|
let r = document.createElement("n-button");
|
|
701
734
|
if (r.setAttribute("variant", "ghost"), r.setAttribute("size", "sm"), r.setAttribute("inline", ""), r.setAttribute("data-action", e), r.setAttribute("aria-label", t.label), n === "icon" || n === "icon-label") {
|
|
702
735
|
let e = document.createElement("n-icon");
|
|
@@ -707,13 +740,23 @@ function p(e, t, n) {
|
|
|
707
740
|
/**
|
|
708
741
|
* Message group — cluster of messages from the same sender.
|
|
709
742
|
*
|
|
710
|
-
* Provides
|
|
711
|
-
*
|
|
743
|
+
* Provides a 2×2 grid layout:
|
|
744
|
+
* - Col 1, row 1–2: avatar (bottom-aligned)
|
|
745
|
+
* - Col 2, row 1: context area (metadata, reasoning, timestamps)
|
|
746
|
+
* - Col 2, row 2: messages area (chat bubbles, flex column)
|
|
747
|
+
*
|
|
748
|
+
* On setup, non-avatar children are sorted into two wrapper divs:
|
|
749
|
+
* - `.n-chat-context` — non-message children (row 1)
|
|
750
|
+
* - `.n-chat-bubbles` — `n-chat-message` children (row 2)
|
|
751
|
+
*
|
|
752
|
+
* A MutationObserver routes dynamically added children into the
|
|
753
|
+
* correct wrapper automatically.
|
|
712
754
|
*
|
|
713
755
|
* ```html
|
|
714
|
-
* <n-chat-messages role="
|
|
715
|
-
* <n-chat-avatar
|
|
716
|
-
* <
|
|
756
|
+
* <n-chat-messages role="assistant" sender="AI">
|
|
757
|
+
* <n-chat-avatar>AI</n-chat-avatar>
|
|
758
|
+
* <span class="reasoning">Thinking...</span>
|
|
759
|
+
* <n-chat-message role="assistant">
|
|
717
760
|
* <n-chat-message-text>Hello!</n-chat-message-text>
|
|
718
761
|
* </n-chat-message>
|
|
719
762
|
* </n-chat-messages>
|
|
@@ -721,15 +764,18 @@ function p(e, t, n) {
|
|
|
721
764
|
*
|
|
722
765
|
* @attr {string} role - `user` | `assistant` | `system`
|
|
723
766
|
* @attr {string} sender - Display name of the sender
|
|
724
|
-
* @attr {string} avatar-align - `"top"`
|
|
767
|
+
* @attr {string} avatar-align - `"top"` | `"center"` | `"bottom"` (default) — avatar vertical alignment
|
|
725
768
|
*/
|
|
726
|
-
var
|
|
769
|
+
var h = class extends e {
|
|
727
770
|
static observedAttributes = [
|
|
728
771
|
"role",
|
|
729
772
|
"sender",
|
|
730
773
|
"avatar-align"
|
|
731
774
|
];
|
|
732
775
|
#e;
|
|
776
|
+
#t = null;
|
|
777
|
+
#n = null;
|
|
778
|
+
#r = null;
|
|
733
779
|
constructor() {
|
|
734
780
|
super(), this.#e = this.attachInternals();
|
|
735
781
|
}
|
|
@@ -739,12 +785,31 @@ var m = class extends e {
|
|
|
739
785
|
setup() {
|
|
740
786
|
super.setup(), this.#e.role = "group";
|
|
741
787
|
let e = this.getAttribute("sender");
|
|
742
|
-
e && (this.#e.ariaLabel = `Messages from ${e}`)
|
|
788
|
+
e && (this.#e.ariaLabel = `Messages from ${e}`), this.#i(), this.#r = new MutationObserver((e) => {
|
|
789
|
+
for (let t of e) for (let e of t.addedNodes) e instanceof Element && e.localName !== "n-chat-avatar" && (e === this.#t || e === this.#n || (e.localName === "n-chat-message" ? this.#n?.appendChild(e) : this.#t?.appendChild(e)));
|
|
790
|
+
}), this.#r.observe(this, { childList: !0 });
|
|
743
791
|
}
|
|
744
792
|
teardown() {
|
|
793
|
+
if (this.#r?.disconnect(), this.#r = null, this.#n) {
|
|
794
|
+
for (; this.#n.firstChild;) this.appendChild(this.#n.firstChild);
|
|
795
|
+
this.#n.remove(), this.#n = null;
|
|
796
|
+
}
|
|
797
|
+
if (this.#t) {
|
|
798
|
+
for (; this.#t.firstChild;) this.appendChild(this.#t.firstChild);
|
|
799
|
+
this.#t.remove(), this.#t = null;
|
|
800
|
+
}
|
|
745
801
|
super.teardown();
|
|
746
802
|
}
|
|
747
|
-
|
|
803
|
+
#i() {
|
|
804
|
+
let e = document.createElement("div");
|
|
805
|
+
e.className = "n-chat-context";
|
|
806
|
+
let t = document.createElement("div");
|
|
807
|
+
t.className = "n-chat-bubbles";
|
|
808
|
+
let n = Array.from(this.childNodes);
|
|
809
|
+
for (let r of n) r instanceof Element && r.localName === "n-chat-avatar" || (r instanceof Element && r.localName === "n-chat-message" ? t.appendChild(r) : e.appendChild(r));
|
|
810
|
+
this.appendChild(e), this.appendChild(t), this.#t = e, this.#n = t;
|
|
811
|
+
}
|
|
812
|
+
}, g = class extends e {
|
|
748
813
|
static observedAttributes = ["format"];
|
|
749
814
|
#e = r("markdown");
|
|
750
815
|
#t = r("");
|
|
@@ -768,14 +833,14 @@ var m = class extends e {
|
|
|
768
833
|
super.setup(), this.deferChildren(() => {
|
|
769
834
|
!this.#t.value && this.textContent?.trim() && (this.#t.value = this.textContent.trim()), this.#n = document.createElement("div"), this.#n.className = "n-chat-prose", this.textContent = "", this.appendChild(this.#n), this.addEffect(() => {
|
|
770
835
|
let e = this.#t.value, t = this.#e.value;
|
|
771
|
-
this.#n && (t === "plain" ? this.#n.textContent = e : this.#n.innerHTML =
|
|
836
|
+
this.#n && (t === "plain" ? this.#n.textContent = e : this.#n.innerHTML = b(e));
|
|
772
837
|
});
|
|
773
838
|
});
|
|
774
839
|
}
|
|
775
840
|
teardown() {
|
|
776
841
|
this.#n = null, super.teardown();
|
|
777
842
|
}
|
|
778
|
-
},
|
|
843
|
+
}, _ = new Set([
|
|
779
844
|
"p",
|
|
780
845
|
"br",
|
|
781
846
|
"strong",
|
|
@@ -795,14 +860,14 @@ var m = class extends e {
|
|
|
795
860
|
"blockquote",
|
|
796
861
|
"hr"
|
|
797
862
|
]);
|
|
798
|
-
function
|
|
863
|
+
function v(e) {
|
|
799
864
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
800
865
|
}
|
|
801
|
-
function
|
|
802
|
-
let t =
|
|
866
|
+
function y(e) {
|
|
867
|
+
let t = v(e);
|
|
803
868
|
return t = t.replace(/`([^`]+)`/g, "<code>$1</code>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__(.+?)__/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/(?<!\w)_(.+?)_(?!\w)/g, "<em>$1</em>"), t = t.replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g, "<a href=\"$2\" rel=\"noopener noreferrer\" target=\"_blank\">$1</a>"), t;
|
|
804
869
|
}
|
|
805
|
-
function
|
|
870
|
+
function b(e) {
|
|
806
871
|
if (!e) return "";
|
|
807
872
|
let t = e.split("\n"), n = [], r = 0;
|
|
808
873
|
for (; r < t.length;) {
|
|
@@ -811,14 +876,14 @@ function y(e) {
|
|
|
811
876
|
let i = e.slice(3).trim(), a = [];
|
|
812
877
|
for (r += 1; r < t.length && !t[r].startsWith("```");) a.push(t[r]), r += 1;
|
|
813
878
|
r += 1;
|
|
814
|
-
let o = i ? ` data-lang="${
|
|
815
|
-
n.push(`<pre${o}><code>${
|
|
879
|
+
let o = i ? ` data-lang="${v(i)}"` : "";
|
|
880
|
+
n.push(`<pre${o}><code>${v(a.join("\n"))}</code></pre>`);
|
|
816
881
|
continue;
|
|
817
882
|
}
|
|
818
883
|
let i = e.match(/^(#{1,6})\s+(.+)/);
|
|
819
884
|
if (i) {
|
|
820
885
|
let e = i[1].length;
|
|
821
|
-
n.push(`<h${e}>${
|
|
886
|
+
n.push(`<h${e}>${y(i[2])}</h${e}>`), r += 1;
|
|
822
887
|
continue;
|
|
823
888
|
}
|
|
824
889
|
if (/^---+$/.test(e.trim()) || /^\*\*\*+$/.test(e.trim())) {
|
|
@@ -828,19 +893,19 @@ function y(e) {
|
|
|
828
893
|
if (e.startsWith("> ")) {
|
|
829
894
|
let e = [];
|
|
830
895
|
for (; r < t.length && t[r].startsWith("> ");) e.push(t[r].slice(2)), r += 1;
|
|
831
|
-
n.push(`<blockquote>${
|
|
896
|
+
n.push(`<blockquote>${b(e.join("\n"))}</blockquote>`);
|
|
832
897
|
continue;
|
|
833
898
|
}
|
|
834
899
|
if (/^[-*+]\s/.test(e)) {
|
|
835
900
|
let e = [];
|
|
836
901
|
for (; r < t.length && /^[-*+]\s/.test(t[r]);) e.push(t[r].replace(/^[-*+]\s/, "")), r += 1;
|
|
837
|
-
n.push("<ul>" + e.map((e) => `<li>${
|
|
902
|
+
n.push("<ul>" + e.map((e) => `<li>${y(e)}</li>`).join("") + "</ul>");
|
|
838
903
|
continue;
|
|
839
904
|
}
|
|
840
905
|
if (/^\d+\.\s/.test(e)) {
|
|
841
906
|
let e = [];
|
|
842
907
|
for (; r < t.length && /^\d+\.\s/.test(t[r]);) e.push(t[r].replace(/^\d+\.\s/, "")), r += 1;
|
|
843
|
-
n.push("<ol>" + e.map((e) => `<li>${
|
|
908
|
+
n.push("<ol>" + e.map((e) => `<li>${y(e)}</li>`).join("") + "</ol>");
|
|
844
909
|
continue;
|
|
845
910
|
}
|
|
846
911
|
if (!e.trim()) {
|
|
@@ -849,15 +914,15 @@ function y(e) {
|
|
|
849
914
|
}
|
|
850
915
|
let a = [];
|
|
851
916
|
for (; r < t.length && t[r].trim() && !t[r].startsWith("#") && !t[r].startsWith("```") && !t[r].startsWith("> ") && !/^[-*+]\s/.test(t[r]) && !/^\d+\.\s/.test(t[r]) && !/^---+$/.test(t[r].trim());) a.push(t[r]), r += 1;
|
|
852
|
-
a.length > 0 && n.push(`<p>${
|
|
917
|
+
a.length > 0 && n.push(`<p>${y(a.join("\n"))}</p>`);
|
|
853
918
|
}
|
|
854
919
|
return n.join("");
|
|
855
920
|
}
|
|
856
921
|
/** Sanitize rendered HTML — strip any tags not in allowlist. */
|
|
857
|
-
function
|
|
922
|
+
function x(e) {
|
|
858
923
|
return e.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (e, t) => {
|
|
859
924
|
let n = t.toLowerCase();
|
|
860
|
-
return
|
|
925
|
+
return _.has(n) ? e : "";
|
|
861
926
|
});
|
|
862
927
|
}
|
|
863
928
|
/**
|
|
@@ -878,7 +943,7 @@ function b(e) {
|
|
|
878
943
|
* @attr {boolean} expandable - Allow click to expand trace content
|
|
879
944
|
* @fires native:activity-toggle - Fired when trace is expanded/collapsed
|
|
880
945
|
*/
|
|
881
|
-
var
|
|
946
|
+
var S = class extends e {
|
|
882
947
|
static observedAttributes = [
|
|
883
948
|
"type",
|
|
884
949
|
"label",
|
|
@@ -936,7 +1001,7 @@ var x = class extends e {
|
|
|
936
1001
|
this.#r.value ? (this.#p(), this.#e.states.add("active")) : (this.#m(), this.#e.states.delete("active"));
|
|
937
1002
|
}), this.addEffect(() => {
|
|
938
1003
|
if (!this.#c) return;
|
|
939
|
-
let e = this.#n.value ||
|
|
1004
|
+
let e = this.#n.value || C(this.#t.value);
|
|
940
1005
|
this.#c.textContent = e;
|
|
941
1006
|
}), this.addEffect(() => {
|
|
942
1007
|
this.#u && (this.#u.hidden = !this.#r.value);
|
|
@@ -966,7 +1031,7 @@ var x = class extends e {
|
|
|
966
1031
|
#h = () => {
|
|
967
1032
|
if (!this.#r.value || !this.#l) return;
|
|
968
1033
|
let e = performance.now() - this.#o;
|
|
969
|
-
this.#l.textContent =
|
|
1034
|
+
this.#l.textContent = w(e), this.#s = requestAnimationFrame(this.#h);
|
|
970
1035
|
};
|
|
971
1036
|
#g = () => {
|
|
972
1037
|
this.#i.value && (this.#a.value = !this.#a.value, this.toggleAttribute("expanded", this.#a.value), this.dispatchEvent(new CustomEvent("native:activity-toggle", {
|
|
@@ -976,14 +1041,14 @@ var x = class extends e {
|
|
|
976
1041
|
})));
|
|
977
1042
|
};
|
|
978
1043
|
};
|
|
979
|
-
function
|
|
1044
|
+
function C(e) {
|
|
980
1045
|
switch (e) {
|
|
981
1046
|
case "thinking": return "Thinking…";
|
|
982
1047
|
case "tool-use": return "Using tools…";
|
|
983
1048
|
default: return "Host is typing…";
|
|
984
1049
|
}
|
|
985
1050
|
}
|
|
986
|
-
function
|
|
1051
|
+
function w(e) {
|
|
987
1052
|
let t = Math.floor(e / 1e3);
|
|
988
1053
|
if (t < 60) return `${t}s`;
|
|
989
1054
|
let n = Math.floor(t / 60), r = t % 60;
|
|
@@ -1003,7 +1068,7 @@ function C(e) {
|
|
|
1003
1068
|
* @attr {boolean} disabled - Disables all chips
|
|
1004
1069
|
* @fires native:seed-select - Fired when a chip is clicked
|
|
1005
1070
|
*/
|
|
1006
|
-
var
|
|
1071
|
+
var T = class extends e {
|
|
1007
1072
|
static observedAttributes = ["options", "disabled"];
|
|
1008
1073
|
#e;
|
|
1009
1074
|
#t = r([]);
|
|
@@ -1072,7 +1137,7 @@ var w = class extends e {
|
|
|
1072
1137
|
}
|
|
1073
1138
|
}));
|
|
1074
1139
|
};
|
|
1075
|
-
},
|
|
1140
|
+
}, E = new Set([
|
|
1076
1141
|
"script",
|
|
1077
1142
|
"style",
|
|
1078
1143
|
"link",
|
|
@@ -1089,7 +1154,7 @@ var w = class extends e {
|
|
|
1089
1154
|
"frame",
|
|
1090
1155
|
"frameset",
|
|
1091
1156
|
"noscript"
|
|
1092
|
-
]),
|
|
1157
|
+
]), D = class extends e {
|
|
1093
1158
|
static observedAttributes = ["schema-type", "mode"];
|
|
1094
1159
|
#e;
|
|
1095
1160
|
#t = r("a2ui");
|
|
@@ -1134,7 +1199,7 @@ var w = class extends e {
|
|
|
1134
1199
|
super.setup(), this.#i = document.createElement("div"), this.#i.className = "n-chat-genui-container", this.appendChild(this.#i), this.addEffect(() => {
|
|
1135
1200
|
let e = this.#r.value, t = this.#n.value;
|
|
1136
1201
|
if (!this.#i || (this.#i.textContent = "", !e)) return;
|
|
1137
|
-
let n =
|
|
1202
|
+
let n = O(e);
|
|
1138
1203
|
if (n.length > 0) {
|
|
1139
1204
|
this.#a(n), this.dispatchEvent(new CustomEvent("native:genui-error", {
|
|
1140
1205
|
bubbles: !0,
|
|
@@ -1145,7 +1210,7 @@ var w = class extends e {
|
|
|
1145
1210
|
}
|
|
1146
1211
|
if (t === "lightbox") this.#o(e);
|
|
1147
1212
|
else {
|
|
1148
|
-
let t =
|
|
1213
|
+
let t = k(e);
|
|
1149
1214
|
t && this.#i.appendChild(t);
|
|
1150
1215
|
}
|
|
1151
1216
|
this.#e.states.add("rendered");
|
|
@@ -1162,14 +1227,14 @@ var w = class extends e {
|
|
|
1162
1227
|
#o(e) {
|
|
1163
1228
|
if (!this.#i) return;
|
|
1164
1229
|
let t = document.createElement("n-card");
|
|
1165
|
-
t.
|
|
1230
|
+
t.dataset.role = "preview";
|
|
1166
1231
|
let n = document.createElement("span");
|
|
1167
1232
|
n.textContent = `Interactive UI (${e.tag})`, t.appendChild(n);
|
|
1168
1233
|
let r = document.createElement("n-button");
|
|
1169
1234
|
r.setAttribute("variant", "outline"), r.setAttribute("size", "sm"), r.setAttribute("inline", ""), r.textContent = "Open", r.addEventListener("click", () => this.#s(e)), t.appendChild(r), this.#i.appendChild(t);
|
|
1170
1235
|
}
|
|
1171
1236
|
#s(e) {
|
|
1172
|
-
let t = document.createElement("n-dialog"), n =
|
|
1237
|
+
let t = document.createElement("n-dialog"), n = k(e);
|
|
1173
1238
|
n && t.appendChild(n), this.appendChild(t), requestAnimationFrame(() => {
|
|
1174
1239
|
let e = t.querySelector("dialog");
|
|
1175
1240
|
e && e.showModal();
|
|
@@ -1189,20 +1254,20 @@ var w = class extends e {
|
|
|
1189
1254
|
}));
|
|
1190
1255
|
};
|
|
1191
1256
|
};
|
|
1192
|
-
function
|
|
1257
|
+
function O(e, t = 0) {
|
|
1193
1258
|
let n = [];
|
|
1194
1259
|
if (t > 20) return n.push("Maximum nesting depth (20) exceeded"), n;
|
|
1195
1260
|
if (!e.tag || typeof e.tag != "string") return n.push("Node missing required \"tag\" property"), n;
|
|
1196
|
-
if (
|
|
1261
|
+
if (E.has(e.tag.toLowerCase()) && n.push(`Forbidden tag: <${e.tag}>`), e.children) for (let r of e.children) n.push(...O(r, t + 1));
|
|
1197
1262
|
return n;
|
|
1198
1263
|
}
|
|
1199
|
-
function
|
|
1200
|
-
if (
|
|
1264
|
+
function k(e) {
|
|
1265
|
+
if (E.has(e.tag.toLowerCase())) return null;
|
|
1201
1266
|
let t = document.createElement(e.tag);
|
|
1202
1267
|
if (e.id && (t.id = e.id), e.slot && (t.slot = e.slot), e.attributes) for (let [n, r] of Object.entries(e.attributes)) t.setAttribute(n, r);
|
|
1203
1268
|
if (e.properties) for (let [n, r] of Object.entries(e.properties)) t[n] = r;
|
|
1204
1269
|
if (e.text && (t.textContent = e.text), e.children) for (let n of e.children) {
|
|
1205
|
-
let e =
|
|
1270
|
+
let e = k(n);
|
|
1206
1271
|
e && t.appendChild(e);
|
|
1207
1272
|
}
|
|
1208
1273
|
return t;
|
|
@@ -1227,7 +1292,7 @@ function O(e) {
|
|
|
1227
1292
|
* @fires native:structured-submit - Fired on submit with selections
|
|
1228
1293
|
* @fires native:structured-cancel - Fired when dismissed without selecting
|
|
1229
1294
|
*/
|
|
1230
|
-
var
|
|
1295
|
+
var A = class extends e {
|
|
1231
1296
|
static observedAttributes = [
|
|
1232
1297
|
"question",
|
|
1233
1298
|
"type",
|
|
@@ -1353,4 +1418,4 @@ var k = class extends e {
|
|
|
1353
1418
|
}));
|
|
1354
1419
|
};
|
|
1355
1420
|
};
|
|
1356
|
-
export {
|
|
1421
|
+
export { g as a, x as c, p as d, f, a as g, o as h, S as i, h as l, c as m, D as n, y as o, l as p, T as r, b as s, A as t, d as u };
|
|
@@ -16,8 +16,8 @@ export declare const ROLE_DEFAULTS: Record<string, string[]>;
|
|
|
16
16
|
* @attr {string} timestamp - Epoch milliseconds
|
|
17
17
|
* @attr {string} status - `sending` | `sent` | `error` | `streaming` | `partial`
|
|
18
18
|
* @attr {string} actions - Comma-separated action list, or `"none"` to suppress
|
|
19
|
-
* @attr {string} actions-style - `"
|
|
20
|
-
* @attr {string} actions-position - `"
|
|
19
|
+
* @attr {string} actions-style - `"icon"` (default) | `"label"` | `"icon-label"`
|
|
20
|
+
* @attr {string} actions-position - `"below"` (default) | `"inside"` — toolbar placement
|
|
21
21
|
* @fires native:message-action - Fired when an action button is clicked
|
|
22
22
|
* @fires native:continue-request - Fired when continue is requested for a partial message
|
|
23
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-message-element.d.ts","sourceRoot":"","sources":["../../src/message/chat-message-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"chat-message-element.d.ts","sourceRoot":"","sources":["../../src/message/chat-message-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAe,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAOhE,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAGlD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAa,SAAQ,aAAa;;IAC7C,MAAM,CAAC,kBAAkB,WAAiG;;IAmB1H,IAAI,IAAI,IAAI,MAAM,CAA6B;IAC/C,IAAI,IAAI,CAAC,GAAG,EAAE,MAAM,EAGnB;IAED,IAAI,SAAS,IAAI,MAAM,CAAkD;IAEzE,IAAI,SAAS,IAAI,MAAM,CAAwD;IAE/E,IAAI,MAAM,IAAI,MAAM,CAA+B;IACnD,IAAI,MAAM,CAAC,GAAG,EAAE,MAAM,EAGrB;IAED,IAAI,OAAO,IAAI,MAAM,GAAG,IAAI,CAAgC;IAC5D,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAO7B;IAED,IAAI,YAAY,IAAI,MAAM,CAAqC;IAC/D,IAAI,YAAY,CAAC,GAAG,EAAE,MAAM,EAG3B;IAED,IAAI,eAAe,IAAI,MAAM,CAAwC;IACrE,IAAI,eAAe,CAAC,GAAG,EAAE,MAAM,EAG9B;IAID,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAcpF,KAAK,IAAI,IAAI;IAqBb,QAAQ,IAAI,IAAI;CAgJjB"}
|
|
@@ -2,13 +2,23 @@ import { NativeElement } from '@nonoun/native-ui';
|
|
|
2
2
|
/**
|
|
3
3
|
* Message group — cluster of messages from the same sender.
|
|
4
4
|
*
|
|
5
|
-
* Provides
|
|
6
|
-
*
|
|
5
|
+
* Provides a 2×2 grid layout:
|
|
6
|
+
* - Col 1, row 1–2: avatar (bottom-aligned)
|
|
7
|
+
* - Col 2, row 1: context area (metadata, reasoning, timestamps)
|
|
8
|
+
* - Col 2, row 2: messages area (chat bubbles, flex column)
|
|
9
|
+
*
|
|
10
|
+
* On setup, non-avatar children are sorted into two wrapper divs:
|
|
11
|
+
* - `.n-chat-context` — non-message children (row 1)
|
|
12
|
+
* - `.n-chat-bubbles` — `n-chat-message` children (row 2)
|
|
13
|
+
*
|
|
14
|
+
* A MutationObserver routes dynamically added children into the
|
|
15
|
+
* correct wrapper automatically.
|
|
7
16
|
*
|
|
8
17
|
* ```html
|
|
9
|
-
* <n-chat-messages role="
|
|
10
|
-
* <n-chat-avatar
|
|
11
|
-
* <
|
|
18
|
+
* <n-chat-messages role="assistant" sender="AI">
|
|
19
|
+
* <n-chat-avatar>AI</n-chat-avatar>
|
|
20
|
+
* <span class="reasoning">Thinking...</span>
|
|
21
|
+
* <n-chat-message role="assistant">
|
|
12
22
|
* <n-chat-message-text>Hello!</n-chat-message-text>
|
|
13
23
|
* </n-chat-message>
|
|
14
24
|
* </n-chat-messages>
|
|
@@ -16,7 +26,7 @@ import { NativeElement } from '@nonoun/native-ui';
|
|
|
16
26
|
*
|
|
17
27
|
* @attr {string} role - `user` | `assistant` | `system`
|
|
18
28
|
* @attr {string} sender - Display name of the sender
|
|
19
|
-
* @attr {string} avatar-align - `"top"`
|
|
29
|
+
* @attr {string} avatar-align - `"top"` | `"center"` | `"bottom"` (default) — avatar vertical alignment
|
|
20
30
|
*/
|
|
21
31
|
export declare class NChatMessages extends NativeElement {
|
|
22
32
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-messages-element.d.ts","sourceRoot":"","sources":["../../src/message/chat-messages-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"chat-messages-element.d.ts","sourceRoot":"","sources":["../../src/message/chat-messages-element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,aAAc,SAAQ,aAAa;;IAC9C,MAAM,CAAC,kBAAkB,WAAsC;;IAY/D,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKpF,KAAK,IAAI,IAAI;IA8Bb,QAAQ,IAAI,IAAI;CA4CjB"}
|
package/dist/native-chat.css
CHANGED
|
@@ -191,37 +191,85 @@
|
|
|
191
191
|
n-chat-messages — message group (bubble cluster)
|
|
192
192
|
══════════════════════════════════════════════════ */
|
|
193
193
|
|
|
194
|
+
/* 2×2 grid: avatar | context + bubbles.
|
|
195
|
+
Col 1: avatar (spans both rows, bottom-aligned)
|
|
196
|
+
Col 2 row 1: .n-chat-context — metadata, reasoning, timestamps
|
|
197
|
+
Col 2 row 2: .n-chat-bubbles — message bubbles (flex column) */
|
|
194
198
|
:where(n-chat-messages) {
|
|
195
|
-
display:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
gap: var(--n-chat-message-gap);
|
|
199
|
+
display: grid;
|
|
200
|
+
grid-template-columns: auto 1fr;
|
|
201
|
+
grid-template-rows: auto 1fr;
|
|
202
|
+
column-gap: var(--n-chat-message-gap);
|
|
199
203
|
align-self: flex-start;
|
|
204
|
+
max-width: var(--n-chat-bubble-max-width);
|
|
200
205
|
min-width: 0;
|
|
201
206
|
}
|
|
202
207
|
|
|
203
|
-
/*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
208
|
+
/* Avatar: col 1, spans both rows, bottom-align */
|
|
209
|
+
:where(n-chat-messages) > :where(n-chat-avatar) {
|
|
210
|
+
grid-column: 1;
|
|
211
|
+
grid-row: 1 / -1;
|
|
212
|
+
align-self: end;
|
|
207
213
|
}
|
|
208
214
|
|
|
209
|
-
/*
|
|
210
|
-
:where(n-chat-messages) > :where(
|
|
215
|
+
/* Context area: col 2, row 1 — metadata above messages */
|
|
216
|
+
:where(n-chat-messages) > :where(.n-chat-context) {
|
|
217
|
+
grid-column: 2;
|
|
218
|
+
grid-row: 1;
|
|
211
219
|
display: flex;
|
|
212
220
|
flex-direction: column;
|
|
213
|
-
gap:
|
|
214
|
-
max-width: var(--n-chat-bubble-max-width);
|
|
221
|
+
gap: var(--n-space);
|
|
215
222
|
min-width: 0;
|
|
216
223
|
}
|
|
217
224
|
|
|
218
|
-
/*
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
/* Empty context collapses */
|
|
226
|
+
:where(n-chat-messages) > :where(.n-chat-context:empty) {
|
|
227
|
+
display: none;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/* Bubbles area: col 2, row 2 — flex column of messages */
|
|
231
|
+
:where(n-chat-messages) > :where(.n-chat-bubbles) {
|
|
232
|
+
grid-column: 2;
|
|
233
|
+
grid-row: 2;
|
|
234
|
+
display: flex;
|
|
235
|
+
flex-direction: column;
|
|
236
|
+
gap: var(--n-space);
|
|
237
|
+
min-width: 0;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* Messages shrink-wrap to content width */
|
|
241
|
+
:where(.n-chat-bubbles) > :where(n-chat-message) {
|
|
242
|
+
width: fit-content;
|
|
243
|
+
max-width: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/* Avatar alignment overrides */
|
|
247
|
+
[avatar-align="top"]:where(n-chat-messages) > :where(n-chat-avatar) {
|
|
248
|
+
align-self: start;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
[avatar-align="center"]:where(n-chat-messages) > :where(n-chat-avatar) {
|
|
252
|
+
align-self: center;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* User messages: right-aligned, avatar on right */
|
|
256
|
+
[role="user"]:where(n-chat-messages) {
|
|
257
|
+
grid-template-columns: 1fr auto;
|
|
258
|
+
align-self: flex-end;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
[role="user"]:where(n-chat-messages) > :where(n-chat-avatar) {
|
|
262
|
+
grid-column: 2;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
[role="user"]:where(n-chat-messages) > :where(.n-chat-context),
|
|
266
|
+
[role="user"]:where(n-chat-messages) > :where(.n-chat-bubbles) {
|
|
267
|
+
grid-column: 1;
|
|
221
268
|
}
|
|
222
269
|
|
|
223
|
-
|
|
224
|
-
|
|
270
|
+
/* User bubbles align to the right edge */
|
|
271
|
+
[role="user"]:where(n-chat-messages) :where(.n-chat-bubbles) > :where(n-chat-message) {
|
|
272
|
+
align-self: flex-end;
|
|
225
273
|
}
|
|
226
274
|
|
|
227
275
|
:where(n-chat-messages[hidden]) { display: none; }
|
|
@@ -270,9 +318,7 @@
|
|
|
270
318
|
display: flex;
|
|
271
319
|
flex-direction: column;
|
|
272
320
|
gap: var(--n-space);
|
|
273
|
-
|
|
274
|
-
padding-block: var(--n-chat-bubble-padding-block);
|
|
275
|
-
padding-inline: var(--n-chat-bubble-padding-inline);
|
|
321
|
+
overflow: hidden;
|
|
276
322
|
|
|
277
323
|
/* Asymmetric radius: assistant = avatar on left */
|
|
278
324
|
border-radius:
|
|
@@ -317,40 +363,41 @@
|
|
|
317
363
|
|
|
318
364
|
/* ── Message actions toolbar ── */
|
|
319
365
|
|
|
320
|
-
:where(n-chat-message) > :where(
|
|
366
|
+
:where(n-chat-message) > :where(n-toolbar[data-role="actions"]) {
|
|
321
367
|
opacity: 0;
|
|
322
368
|
transition: opacity var(--n-duration) var(--n-easing);
|
|
369
|
+
padding-inline: var(--n-chat-bubble-padding-inline);
|
|
323
370
|
}
|
|
324
371
|
|
|
325
|
-
:where(n-chat-message):hover > :where(
|
|
326
|
-
:where(n-chat-message):focus-within > :where(
|
|
327
|
-
:where(n-chat-message[force-hover]) > :where(
|
|
372
|
+
:where(n-chat-message):hover > :where(n-toolbar[data-role="actions"]),
|
|
373
|
+
:where(n-chat-message):focus-within > :where(n-toolbar[data-role="actions"]),
|
|
374
|
+
:where(n-chat-message[force-hover]) > :where(n-toolbar[data-role="actions"]) {
|
|
328
375
|
opacity: 1;
|
|
329
376
|
}
|
|
330
377
|
|
|
331
378
|
/* Partial status — always show actions (contains continue button) */
|
|
332
|
-
[status="partial"]:where(n-chat-message) > :where(
|
|
379
|
+
[status="partial"]:where(n-chat-message) > :where(n-toolbar[data-role="actions"]) {
|
|
333
380
|
opacity: 1;
|
|
334
381
|
}
|
|
335
382
|
|
|
336
|
-
/* ── Below-bubble
|
|
383
|
+
/* ── Below-bubble popover toolbar ── */
|
|
337
384
|
|
|
338
|
-
/*
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
385
|
+
/* Popover toolbar: anchored below the message via CSS anchor positioning.
|
|
386
|
+
Toolbar is a child of n-chat-message with popover="manual", rendered in the
|
|
387
|
+
top layer. JS shows/hides via pointerenter/pointerleave + showPopover(). */
|
|
388
|
+
:where(n-chat-message) > :where(n-toolbar[data-role="actions"][popover]) {
|
|
389
|
+
position: fixed;
|
|
390
|
+
inset: auto;
|
|
391
|
+
top: anchor(bottom);
|
|
392
|
+
left: anchor(center);
|
|
393
|
+
translate: -50% 0;
|
|
394
|
+
margin: 2px 0 0;
|
|
395
|
+
width: max-content;
|
|
343
396
|
}
|
|
344
397
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
opacity: 1;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/* Partial status — always show below-bubble actions */
|
|
352
|
-
[status="partial"][actions-position="below"]:where(n-chat-message) + :where(.n-chat-message-actions) {
|
|
353
|
-
opacity: 1;
|
|
398
|
+
/* Override n-toolbar display to respect popover hidden state */
|
|
399
|
+
:where(n-toolbar[data-role="actions"][popover]):not(:popover-open) {
|
|
400
|
+
display: none;
|
|
354
401
|
}
|
|
355
402
|
|
|
356
403
|
:where(n-chat-message[hidden]) { display: none; }
|
|
@@ -361,6 +408,8 @@
|
|
|
361
408
|
|
|
362
409
|
:where(n-chat-message-text) {
|
|
363
410
|
display: block;
|
|
411
|
+
padding-block: var(--n-chat-bubble-padding-block);
|
|
412
|
+
padding-inline: var(--n-chat-bubble-padding-inline);
|
|
364
413
|
}
|
|
365
414
|
|
|
366
415
|
/* ── Prose reset — typography inside rendered markdown ── */
|
|
@@ -453,6 +502,7 @@
|
|
|
453
502
|
color: var(--n-chat-activity-color);
|
|
454
503
|
font-size: var(--n-font-size-sm);
|
|
455
504
|
padding-block: var(--n-space);
|
|
505
|
+
padding-inline: var(--n-chat-bubble-padding-inline);
|
|
456
506
|
align-self: flex-start;
|
|
457
507
|
}
|
|
458
508
|
|
|
@@ -545,6 +595,7 @@
|
|
|
545
595
|
flex-wrap: wrap;
|
|
546
596
|
gap: var(--n-space);
|
|
547
597
|
padding-block: var(--n-space);
|
|
598
|
+
padding-inline: var(--n-chat-bubble-padding-inline);
|
|
548
599
|
align-self: flex-start;
|
|
549
600
|
}
|
|
550
601
|
|
|
@@ -575,7 +626,7 @@
|
|
|
575
626
|
font-size: var(--n-font-size-sm);
|
|
576
627
|
}
|
|
577
628
|
|
|
578
|
-
:where(n-chat-message-genui) :where(
|
|
629
|
+
:where(n-chat-message-genui) :where(n-card[data-role="preview"]) {
|
|
579
630
|
display: flex;
|
|
580
631
|
align-items: center;
|
|
581
632
|
justify-content: space-between;
|
package/dist/native-chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "./chat-input-structured-element-
|
|
1
|
+
import { a as e, c as t, d as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "./chat-input-structured-element-Bt9nkgXp.js";
|
|
2
2
|
/**
|
|
3
3
|
* Parse a Server-Sent Events (SSE) response stream into ChatStreamChunk values.
|
|
4
4
|
*
|
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAqClF,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,CAAC"}
|
package/dist/register.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, d as t, g as n, h as r, i, l as a, m as o, n as s, p as c, r as l, t as u } from "./chat-input-structured-element-
|
|
1
|
+
import { a as e, d as t, g as n, h as r, i, l as a, m as o, n as s, p as c, r as l, t as u } from "./chat-input-structured-element-Bt9nkgXp.js";
|
|
2
2
|
import { NButton as d, NCard as f, NDialog as p, NIcon as m, NTextarea as h, NToolbar as g, define as _, registerIcon as v } from "@nonoun/native-ui";
|
|
3
|
-
_("n-chat-input", n), _("native-chat-panel", r), _("n-chat-feed", o), _("n-chat-avatar", c), _("n-chat-message", t), _("n-chat-messages", a), _("n-chat-message-text", e), _("n-chat-message-activity", i), _("n-chat-message-seed", l), _("n-chat-message-genui", s), _("n-chat-input-structured", u), _("n-textarea", h), _("n-button", d), _("n-icon", m), _("n-toolbar", g), _("n-dialog", p), _("n-card", f), v("chat-dots", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M116,128a12,12,0,1,1,12,12A12,12,0,0,1,116,128ZM84,140a12,12,0,1,0-12-12A12,12,0,0,0,84,140Zm88,0a12,12,0,1,0-12-12A12,12,0,0,0,172,140Zm60-76V192a16,16,0,0,1-16,16H83l-32.6,28.16-.09.07A15.89,15.89,0,0,1,40,240a16.13,16.13,0,0,1-6.8-1.52A15.85,15.85,0,0,1,24,224V64A16,16,0,0,1,40,48H216A16,16,0,0,1,232,64ZM40,224h0ZM216,64H40V224l34.77-30A8,8,0,0,1,80,192H216Z\"/></svg>"), v("user", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8C55.71,194.74,89.05,176,128,176s72.29,18.74,89.07,44a8,8,0,0,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z\"/></svg>"), v("stop", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z\"/></svg>"), v("arrow-counter-clockwise", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z\"/></svg>");
|
|
3
|
+
_("n-chat-input", n), _("native-chat-panel", r), _("n-chat-feed", o), _("n-chat-avatar", c), _("n-chat-message", t), _("n-chat-messages", a), _("n-chat-message-text", e), _("n-chat-message-activity", i), _("n-chat-message-seed", l), _("n-chat-message-genui", s), _("n-chat-input-structured", u), _("n-textarea", h), _("n-button", d), _("n-icon", m), _("n-toolbar", g), _("n-dialog", p), _("n-card", f), v("chat-dots", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M116,128a12,12,0,1,1,12,12A12,12,0,0,1,116,128ZM84,140a12,12,0,1,0-12-12A12,12,0,0,0,84,140Zm88,0a12,12,0,1,0-12-12A12,12,0,0,0,172,140Zm60-76V192a16,16,0,0,1-16,16H83l-32.6,28.16-.09.07A15.89,15.89,0,0,1,40,240a16.13,16.13,0,0,1-6.8-1.52A15.85,15.85,0,0,1,24,224V64A16,16,0,0,1,40,48H216A16,16,0,0,1,232,64ZM40,224h0ZM216,64H40V224l34.77-30A8,8,0,0,1,80,192H216Z\"/></svg>"), v("user", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M230.92,212c-15.23-26.33-38.7-45.21-66.09-54.16a72,72,0,1,0-73.66,0C63.78,166.78,40.31,185.66,25.08,212a8,8,0,1,0,13.85,8C55.71,194.74,89.05,176,128,176s72.29,18.74,89.07,44a8,8,0,0,0,13.85-8ZM72,96a56,56,0,1,1,56,56A56.06,56.06,0,0,1,72,96Z\"/></svg>"), v("stop", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z\"/></svg>"), v("arrow-counter-clockwise", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M224,128a96,96,0,0,1-94.71,96H128A95.38,95.38,0,0,1,62.1,197.8a8,8,0,0,1,11-11.63A80,80,0,1,0,71.43,71.39a3.07,3.07,0,0,1-.26.25L44.59,96H72a8,8,0,0,1,0,16H24a8,8,0,0,1-8-8V56a8,8,0,0,1,16,0V85.8L60.25,60A96,96,0,0,1,224,128Z\"/></svg>"), v("copy", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z\"/></svg>"), v("arrow-clockwise", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M240,56v48a8,8,0,0,1-8,8H184a8,8,0,0,1,0-16H211.4L184.81,71.64l-.25-.24a80,80,0,1,0-1.67,114.78,8,8,0,0,1,11,11.63A95.44,95.44,0,0,1,128,224h-1.32A96,96,0,1,1,195.75,60L224,85.8V56a8,8,0,1,1,16,0Z\"/></svg>"), v("pencil-simple", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z\"/></svg>"), v("thumbs-up", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M234,80.12A24,24,0,0,0,216,72H160V56a40,40,0,0,0-40-40,8,8,0,0,0-7.16,4.42L75.06,96H32a16,16,0,0,0-16,16v88a16,16,0,0,0,16,16H204a24,24,0,0,0,23.82-21l12-96A24,24,0,0,0,234,80.12ZM32,112H72v88H32ZM223.94,97l-12,96a8,8,0,0,1-7.94,7H88V105.89l36.71-73.43A24,24,0,0,1,144,56V80a8,8,0,0,0,8,8h64a8,8,0,0,1,7.94,9Z\"/></svg>"), v("thumbs-down", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M239.82,157l-12-96A24,24,0,0,0,204,40H32A16,16,0,0,0,16,56v88a16,16,0,0,0,16,16H75.06l37.78,75.58A8,8,0,0,0,120,240a40,40,0,0,0,40-40V184h56a24,24,0,0,0,23.82-27ZM72,144H32V56H72Zm150,21.29a7.88,7.88,0,0,1-6,2.71H152a8,8,0,0,0-8,8v24a24,24,0,0,1-19.29,23.54L88,150.11V56H204a8,8,0,0,1,7.94,7l12,96A7.87,7.87,0,0,1,222,165.29Z\"/></svg>"), v("arrow-right", "<svg viewBox=\"0 0 256 256\" fill=\"currentColor\"><path d=\"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z\"/></svg>");
|
|
4
4
|
export { c as NChatAvatar, o as NChatFeed, n as NChatInput, u as NChatInputStructured, t as NChatMessage, i as NChatMessageActivity, s as NChatMessageGenUI, l as NChatMessageSeed, e as NChatMessageText, a as NChatMessages, r as NChatPanel };
|