@nonoun/native-chat 0.1.2 → 0.2.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.
- package/dist/avatar/chat-avatar-element.d.ts +18 -0
- package/dist/avatar/chat-avatar-element.d.ts.map +1 -0
- package/dist/avatar/index.d.ts +2 -0
- package/dist/avatar/index.d.ts.map +1 -0
- package/dist/avatar/n-chat-avatar.d.ts +2 -0
- package/dist/avatar/n-chat-avatar.d.ts.map +1 -0
- package/dist/chat-input-element.d.ts +10 -0
- package/dist/chat-input-element.d.ts.map +1 -1
- package/dist/chat-input-structured-element-CbDnI4zv.js +1069 -0
- package/dist/chat-panel-element.d.ts +28 -7
- package/dist/chat-panel-element.d.ts.map +1 -1
- package/dist/feed/chat-feed-element.d.ts +29 -0
- package/dist/feed/chat-feed-element.d.ts.map +1 -0
- package/dist/feed/index.d.ts +2 -0
- package/dist/feed/index.d.ts.map +1 -0
- package/dist/feed/n-chat-feed.d.ts +2 -0
- package/dist/feed/n-chat-feed.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/message/chat-input-structured-element.d.ts +43 -0
- package/dist/message/chat-input-structured-element.d.ts.map +1 -0
- package/dist/message/chat-message-activity-element.d.ts +32 -0
- package/dist/message/chat-message-activity-element.d.ts.map +1 -0
- package/dist/message/chat-message-element.d.ts +28 -0
- package/dist/message/chat-message-element.d.ts.map +1 -0
- package/dist/message/chat-message-genui-element.d.ts +45 -0
- package/dist/message/chat-message-genui-element.d.ts.map +1 -0
- package/dist/message/chat-message-seed-element.d.ts +33 -0
- package/dist/message/chat-message-seed-element.d.ts.map +1 -0
- package/dist/message/chat-message-text-element.d.ts +37 -0
- package/dist/message/chat-message-text-element.d.ts.map +1 -0
- package/dist/message/chat-messages-element.d.ts +28 -0
- package/dist/message/chat-messages-element.d.ts.map +1 -0
- package/dist/message/index.d.ts +8 -0
- package/dist/message/index.d.ts.map +1 -0
- package/dist/message/n-chat-message.d.ts +2 -0
- package/dist/message/n-chat-message.d.ts.map +1 -0
- package/dist/native-chat.css +470 -28
- package/dist/native-chat.js +2 -2
- package/dist/register.d.ts +10 -1
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +4 -4
- package/package.json +1 -1
- package/dist/chat-panel-element-CXPbtkyi.js +0 -113
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { NativeElement as e, createDisabledEffect as t, signal as n } from "@nonoun/native-ui";
|
|
2
|
-
/**
|
|
3
|
-
* Chat message input with textarea, submit button, and Enter-to-send behavior.
|
|
4
|
-
* @attr {boolean} disabled - Disables interaction
|
|
5
|
-
* @attr {boolean} no-enter-submit - Disables Enter key submission
|
|
6
|
-
* @attr {boolean} no-auto-clear - Prevents clearing the textarea after send
|
|
7
|
-
* @fires native:send - Fired on submit with `{ value }` detail
|
|
8
|
-
*/
|
|
9
|
-
var r = class extends e {
|
|
10
|
-
static observedAttributes = ["disabled"];
|
|
11
|
-
#e;
|
|
12
|
-
#t = n(!1);
|
|
13
|
-
#n = null;
|
|
14
|
-
#r = null;
|
|
15
|
-
constructor() {
|
|
16
|
-
super(), this.#e = this.attachInternals();
|
|
17
|
-
}
|
|
18
|
-
get value() {
|
|
19
|
-
return this.#n?.value ?? "";
|
|
20
|
-
}
|
|
21
|
-
set value(e) {
|
|
22
|
-
this.#n && (this.#n.value = e);
|
|
23
|
-
}
|
|
24
|
-
get disabled() {
|
|
25
|
-
return this.#t.value;
|
|
26
|
-
}
|
|
27
|
-
set disabled(e) {
|
|
28
|
-
this.#t.value = e, this.toggleAttribute("disabled", e);
|
|
29
|
-
}
|
|
30
|
-
attributeChangedCallback(e, t, n) {
|
|
31
|
-
if (t !== n) {
|
|
32
|
-
switch (e) {
|
|
33
|
-
case "disabled":
|
|
34
|
-
this.#t.value = n !== null;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
super.attributeChangedCallback(e, t, n);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
setup() {
|
|
41
|
-
super.setup(), this.addEffect(t(this, this.#t, this.#e)), this.deferChildren(() => {
|
|
42
|
-
this.#i(), this.addEffect(() => {
|
|
43
|
-
let e = this.#t.value;
|
|
44
|
-
this.#n && this.#n.toggleAttribute("disabled", e), this.#r && (e ? this.#r.setAttribute("disabled", "") : this.#o());
|
|
45
|
-
});
|
|
46
|
-
}), this.addEventListener("native:input", this.#s), this.addEventListener("native:press", this.#c), this.addEventListener("keydown", this.#l);
|
|
47
|
-
}
|
|
48
|
-
teardown() {
|
|
49
|
-
this.removeEventListener("native:input", this.#s), this.removeEventListener("native:press", this.#c), this.removeEventListener("keydown", this.#l), this.#n = null, this.#r = null, super.teardown();
|
|
50
|
-
}
|
|
51
|
-
#i() {
|
|
52
|
-
this.#n = this.querySelector(":scope > n-textarea"), this.#r = this.querySelector("[data-submit]") ?? this.#a();
|
|
53
|
-
}
|
|
54
|
-
#a() {
|
|
55
|
-
let e = this.querySelector(":scope > n-chat-input-actions");
|
|
56
|
-
if (!e) return null;
|
|
57
|
-
let t = e.querySelectorAll("n-button[variant=\"primary\"]");
|
|
58
|
-
return t.length ? t[t.length - 1] : null;
|
|
59
|
-
}
|
|
60
|
-
#o() {
|
|
61
|
-
!this.#r || this.#t.value || (this.value.trim() ? this.#r.removeAttribute("disabled") : this.#r.setAttribute("disabled", ""));
|
|
62
|
-
}
|
|
63
|
-
#s = (e) => {
|
|
64
|
-
this.#t.value || this.#o();
|
|
65
|
-
};
|
|
66
|
-
#c = (e) => {
|
|
67
|
-
this.#t.value || e.target === this.#r && this.#u();
|
|
68
|
-
};
|
|
69
|
-
#l = (e) => {
|
|
70
|
-
if (this.#t.value || this.hasAttribute("no-enter-submit")) return;
|
|
71
|
-
let t = e;
|
|
72
|
-
if (t.isComposing) return;
|
|
73
|
-
let n = t.target;
|
|
74
|
-
!this.#n?.contains(n) && n !== this.#n || t.key === "Enter" && !t.shiftKey && !t.ctrlKey && !t.metaKey && (t.preventDefault(), this.value.trim() && this.#u());
|
|
75
|
-
};
|
|
76
|
-
#u() {
|
|
77
|
-
let e = this.value.trim();
|
|
78
|
-
e && this.dispatchEvent(new CustomEvent("native:send", {
|
|
79
|
-
bubbles: !0,
|
|
80
|
-
composed: !0,
|
|
81
|
-
cancelable: !0,
|
|
82
|
-
detail: { value: e }
|
|
83
|
-
})) && !this.hasAttribute("no-auto-clear") && (this.value = "", this.#r?.setAttribute("disabled", ""));
|
|
84
|
-
}
|
|
85
|
-
}, i = class extends e {
|
|
86
|
-
setup() {
|
|
87
|
-
super.setup();
|
|
88
|
-
let e = document.createElement("n-header");
|
|
89
|
-
e.setAttribute("dividers", "");
|
|
90
|
-
let t = document.createElement("n-icon");
|
|
91
|
-
t.setAttribute("name", "chat-dots"), t.setAttribute("slot", "leading"), e.appendChild(t);
|
|
92
|
-
let n = document.createElement("span");
|
|
93
|
-
n.setAttribute("slot", "label"), n.textContent = "Assistant", e.appendChild(n);
|
|
94
|
-
let r = document.createElement("n-body"), i = document.createElement("n-chat-content");
|
|
95
|
-
r.appendChild(i);
|
|
96
|
-
let a = document.createElement("n-footer");
|
|
97
|
-
a.setAttribute("dividers", ""), a.setAttribute("padding", "none");
|
|
98
|
-
let o = document.createElement("n-chat-input");
|
|
99
|
-
o.setAttribute("variant", "plain");
|
|
100
|
-
let s = document.createElement("n-textarea");
|
|
101
|
-
s.setAttribute("placeholder", "Ask anything"), s.setAttribute("autogrow", ""), s.setAttribute("rows", "3"), o.appendChild(s);
|
|
102
|
-
let c = document.createElement("n-chat-input-actions"), l = document.createElement("n-button");
|
|
103
|
-
l.setAttribute("variant", "ghost"), l.setAttribute("inline", ""), l.innerHTML = "<n-icon name=\"plus\"></n-icon>", c.appendChild(l);
|
|
104
|
-
let u = document.createElement("n-button");
|
|
105
|
-
u.setAttribute("variant", "ghost"), u.setAttribute("inline", ""), u.innerHTML = "<n-icon name=\"microphone\"></n-icon>", c.appendChild(u);
|
|
106
|
-
let d = document.createElement("n-button");
|
|
107
|
-
d.setAttribute("variant", "primary"), d.setAttribute("intent", "accent"), d.setAttribute("radius", "round"), d.setAttribute("inline", ""), d.setAttribute("disabled", ""), d.classList.add("submit-btn"), d.innerHTML = "<n-icon name=\"arrow-up\"></n-icon>", c.appendChild(d), o.appendChild(c), a.appendChild(o), this.append(e, r, a);
|
|
108
|
-
}
|
|
109
|
-
teardown() {
|
|
110
|
-
this.innerHTML = "", super.teardown();
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
export { r as n, i as t };
|