@nine-lab/nine-mu 0.1.152 → 0.1.154
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/css/nine-mu.css +25 -0
- package/dist/nine-mu.js +55 -46
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +3 -3
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/public/css/nine-mu.css +25 -0
- package/src/components/ChatMessage.js +42 -38
- package/src/components/NineChat.js +16 -2
package/package.json
CHANGED
package/public/css/nine-mu.css
CHANGED
|
@@ -948,4 +948,29 @@
|
|
|
948
948
|
background-color: #d7d4f9 !important;
|
|
949
949
|
color: inherit !important;
|
|
950
950
|
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
:host(nine-chat-message) {
|
|
954
|
+
width: 100%;
|
|
955
|
+
height: 100%;
|
|
956
|
+
overflow: scroll;
|
|
957
|
+
|
|
958
|
+
nine-chat-my {
|
|
959
|
+
display: flex;
|
|
960
|
+
justify-content: flex-end;
|
|
961
|
+
padding: 5px;
|
|
962
|
+
|
|
963
|
+
.chat-message {
|
|
964
|
+
max-width: 70%;
|
|
965
|
+
padding: 8px 16px;
|
|
966
|
+
border-radius: 8px;
|
|
967
|
+
font-size: 14px;
|
|
968
|
+
background-color: #fef01b;
|
|
969
|
+
text-align: left;
|
|
970
|
+
color: #333;
|
|
971
|
+
align-self: flex-end;
|
|
972
|
+
position: relative;
|
|
973
|
+
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
951
976
|
}
|
|
@@ -6,13 +6,12 @@ class aiMessage extends HTMLElement
|
|
|
6
6
|
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.attachShadow({ mode: 'open' });
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
connectedCallback() {
|
|
13
12
|
this.#message = this.getAttribute("message");
|
|
14
13
|
|
|
15
|
-
this.
|
|
14
|
+
this.innerHTML = `
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
<div class="chat-message">
|
|
@@ -47,11 +46,11 @@ class aiMessage extends HTMLElement
|
|
|
47
46
|
</svg>
|
|
48
47
|
*/
|
|
49
48
|
requestAnimationFrame(() => {
|
|
50
|
-
const elMessage = this.
|
|
49
|
+
const elMessage = this.querySelector(".message");
|
|
51
50
|
elMessage.setAttribute("title", this.#message);
|
|
52
51
|
elMessage.innerHTML = this.#message.replaceAll("\n\n", "<br/>").replaceAll("\n", "<br/>");
|
|
53
52
|
|
|
54
|
-
this.
|
|
53
|
+
this.querySelector(".filter").addEventListener("click", e => {
|
|
55
54
|
|
|
56
55
|
//if (e.target.classList.contains("disabled")) return;
|
|
57
56
|
if (this.#unique) {
|
|
@@ -63,8 +62,8 @@ class aiMessage extends HTMLElement
|
|
|
63
62
|
}
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
this.
|
|
67
|
-
//this.
|
|
65
|
+
this.querySelector(".database").addEventListener("click", e => {
|
|
66
|
+
//this.querySelector("nine-grid").maximize();
|
|
68
67
|
const keys = this.#data.map(item =>
|
|
69
68
|
Object.fromEntries(this.#unique.map(key => [key, item[key]]))
|
|
70
69
|
);
|
|
@@ -74,22 +73,22 @@ class aiMessage extends HTMLElement
|
|
|
74
73
|
this.dispatchEvent(new CustomEvent("database", { bubbles: true, detail: { key : keys } }));
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
76
|
+
this.querySelector(".maximize").addEventListener("click", e => {
|
|
77
|
+
this.querySelector("nine-grid").maximize();
|
|
79
78
|
});
|
|
80
79
|
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
80
|
+
this.querySelector(".excel").addEventListener("click", e => {
|
|
81
|
+
this.querySelector("nine-grid").export();
|
|
83
82
|
});
|
|
84
83
|
|
|
85
|
-
this.
|
|
84
|
+
this.querySelector(".more a").addEventListener("click", () => {
|
|
86
85
|
alert(this.#message);
|
|
87
86
|
});
|
|
88
87
|
|
|
89
88
|
setTimeout(() => {
|
|
90
|
-
const elMore = this.
|
|
89
|
+
const elMore = this.querySelector(".more");
|
|
91
90
|
|
|
92
|
-
//if (ninegrid.isEllipsis(this.
|
|
91
|
+
//if (ninegrid.isEllipsis(this.querySelector(".message"))) {
|
|
93
92
|
if (this.#message.length > 50) {
|
|
94
93
|
elMore.style.display = "flex";
|
|
95
94
|
elMore.style.position = "absolute";
|
|
@@ -108,8 +107,8 @@ class aiMessage extends HTMLElement
|
|
|
108
107
|
|
|
109
108
|
setTimeout(() => {
|
|
110
109
|
if (!unique) {
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
110
|
+
this.querySelector(".filter").classList.add("disabled");
|
|
111
|
+
this.querySelector(".database").classList.add("disabled");
|
|
113
112
|
}
|
|
114
113
|
|
|
115
114
|
this.#init(info);
|
|
@@ -120,8 +119,8 @@ class aiMessage extends HTMLElement
|
|
|
120
119
|
|
|
121
120
|
const rowCount = Number(this.getAttribute("row-count"));
|
|
122
121
|
if (rowCount < 1) {
|
|
123
|
-
this.
|
|
124
|
-
this.
|
|
122
|
+
this.querySelector(".grid").style.display = "none";
|
|
123
|
+
this.querySelector(".chat-menu").style.display = "none";
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
|
|
@@ -153,10 +152,10 @@ class aiMessage extends HTMLElement
|
|
|
153
152
|
</nine-grid>
|
|
154
153
|
`;
|
|
155
154
|
|
|
156
|
-
this.
|
|
155
|
+
this.querySelector(".grid").innerHTML = html;
|
|
157
156
|
|
|
158
157
|
setTimeout(() => {
|
|
159
|
-
const grd = this.
|
|
158
|
+
const grd = this.querySelector("nine-grid");
|
|
160
159
|
grd.data.source = this.#data;
|
|
161
160
|
|
|
162
161
|
//this.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
@@ -170,7 +169,6 @@ class aiIngMessage extends HTMLElement
|
|
|
170
169
|
|
|
171
170
|
constructor() {
|
|
172
171
|
super();
|
|
173
|
-
this.attachShadow({ mode: 'open' });
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
connectedCallback() {
|
|
@@ -178,7 +176,7 @@ class aiIngMessage extends HTMLElement
|
|
|
178
176
|
|
|
179
177
|
this.#message = ".";
|
|
180
178
|
|
|
181
|
-
this.
|
|
179
|
+
this.innerHTML = `
|
|
182
180
|
|
|
183
181
|
<div class="chat-message">
|
|
184
182
|
.
|
|
@@ -191,24 +189,21 @@ class aiIngMessage extends HTMLElement
|
|
|
191
189
|
#init = () => {
|
|
192
190
|
const interval = setInterval(() => {
|
|
193
191
|
this.#message = this.#message.length < 3 ? this.#message + "." : "";
|
|
194
|
-
this.
|
|
192
|
+
this.querySelector(".chat-message").innerHTML = this.#message || " ";
|
|
195
193
|
}, 500);
|
|
196
194
|
};
|
|
197
195
|
}
|
|
198
196
|
|
|
199
|
-
class
|
|
197
|
+
class MyMessage extends HTMLElement
|
|
200
198
|
{
|
|
201
199
|
constructor() {
|
|
202
200
|
super();
|
|
203
|
-
this.attachShadow({ mode: 'open' });
|
|
204
201
|
}
|
|
205
202
|
|
|
206
203
|
connectedCallback() {
|
|
207
204
|
const message = this.getAttribute("message");
|
|
208
205
|
|
|
209
|
-
this.
|
|
210
|
-
|
|
211
|
-
|
|
206
|
+
this.innerHTML = `
|
|
212
207
|
<div class="chat-message">
|
|
213
208
|
${message}
|
|
214
209
|
</div>
|
|
@@ -225,11 +220,10 @@ class aiProgressMessage extends HTMLElement {
|
|
|
225
220
|
|
|
226
221
|
constructor() {
|
|
227
222
|
super();
|
|
228
|
-
this.attachShadow({ mode: 'open' });
|
|
229
223
|
}
|
|
230
224
|
|
|
231
225
|
connectedCallback() {
|
|
232
|
-
this.
|
|
226
|
+
this.innerHTML = `
|
|
233
227
|
|
|
234
228
|
<div class="chat-message progress-message">
|
|
235
229
|
<ul class="progress-list"></ul>
|
|
@@ -295,7 +289,7 @@ class aiProgressMessage extends HTMLElement {
|
|
|
295
289
|
}
|
|
296
290
|
|
|
297
291
|
#renderProgress() {
|
|
298
|
-
const progressList = this.
|
|
292
|
+
const progressList = this.querySelector(".progress-list");
|
|
299
293
|
progressList.innerHTML = '';
|
|
300
294
|
this.#progressElements.clear();
|
|
301
295
|
this.#animationIntervals.forEach(intervalId => clearInterval(intervalId));
|
|
@@ -370,16 +364,25 @@ class ChatMessage extends HTMLElement
|
|
|
370
364
|
connectedCallback() {
|
|
371
365
|
const message = this.getAttribute("message");
|
|
372
366
|
|
|
373
|
-
this
|
|
367
|
+
this.#renderer();
|
|
368
|
+
this.#init();
|
|
369
|
+
};
|
|
374
370
|
|
|
371
|
+
#renderer = () => {
|
|
372
|
+
const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
|
|
375
373
|
|
|
374
|
+
this.shadowRoot.innerHTML = `
|
|
375
|
+
<style>
|
|
376
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${__APP_VERSION__}/dist/css/nine-mu.css";
|
|
377
|
+
${customImport}
|
|
378
|
+
</style>
|
|
379
|
+
|
|
376
380
|
<div class="chat-body">
|
|
377
381
|
</div>
|
|
378
382
|
`;
|
|
379
|
-
|
|
380
|
-
this.#init();
|
|
381
383
|
};
|
|
382
384
|
|
|
385
|
+
|
|
383
386
|
#init = () => {
|
|
384
387
|
|
|
385
388
|
};
|
|
@@ -398,7 +401,7 @@ class ChatMessage extends HTMLElement
|
|
|
398
401
|
let el;
|
|
399
402
|
switch (sender) {
|
|
400
403
|
case "me":
|
|
401
|
-
el = document.createElement("
|
|
404
|
+
el = document.createElement("nine-chat-me");
|
|
402
405
|
el.setAttribute("message", message);
|
|
403
406
|
target.appendChild(el);
|
|
404
407
|
break;
|
|
@@ -474,14 +477,15 @@ if (!customElements.get('nx-ai-ing-message')) {
|
|
|
474
477
|
customElements.define("nx-ai-ing-message", aiIngMessage);
|
|
475
478
|
}
|
|
476
479
|
|
|
477
|
-
if (!customElements.get('nx-ai-my-message')) {
|
|
478
|
-
customElements.define("nx-ai-my-message", aiMyMessage);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
480
|
if (!customElements.get('nx-ai-progress-message')) {
|
|
482
481
|
customElements.define("nx-ai-progress-message", aiProgressMessage);
|
|
483
482
|
}
|
|
484
483
|
|
|
484
|
+
|
|
485
|
+
|
|
485
486
|
if (!customElements.get('nine-chat-message')) {
|
|
486
487
|
customElements.define("nine-chat-message", ChatMessage);
|
|
487
488
|
}
|
|
489
|
+
if (!customElements.get('nine-chat-me')) {
|
|
490
|
+
customElements.define("nine-chat-me", MyMessage);
|
|
491
|
+
}
|
|
@@ -12,9 +12,10 @@ export class NineChat extends HTMLElement {
|
|
|
12
12
|
#packageName;
|
|
13
13
|
#routesPath;
|
|
14
14
|
#connectorUrl;
|
|
15
|
-
#mcpClient;
|
|
16
15
|
#manager;
|
|
17
16
|
|
|
17
|
+
#$nineChatMessage;
|
|
18
|
+
|
|
18
19
|
constructor() {
|
|
19
20
|
super();
|
|
20
21
|
this.attachShadow({ mode: 'open' });
|
|
@@ -72,7 +73,18 @@ export class NineChat extends HTMLElement {
|
|
|
72
73
|
$textarea.addEventListener('keypress', async (e) => {
|
|
73
74
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
74
75
|
e.preventDefault();
|
|
75
|
-
|
|
76
|
+
|
|
77
|
+
const textarea = e.target.value.trim();
|
|
78
|
+
|
|
79
|
+
if (!textarea) return;
|
|
80
|
+
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
$textarea.value = "";
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.#$nineChatMessage.add("me", textarea);
|
|
86
|
+
this.#$nineChatMessage.add("ing", textarea);
|
|
87
|
+
|
|
76
88
|
await this.#manager.handleChatSubmit($textarea);
|
|
77
89
|
}
|
|
78
90
|
});
|
|
@@ -123,6 +135,8 @@ export class NineChat extends HTMLElement {
|
|
|
123
135
|
`;
|
|
124
136
|
|
|
125
137
|
this.#diffPopup = this.shadowRoot.querySelector('nine-diff-popup');
|
|
138
|
+
|
|
139
|
+
this.#$nineChatMessage = this.shadowRoot.querySelector("nine-chat-message");
|
|
126
140
|
}
|
|
127
141
|
|
|
128
142
|
#makeMenuHandler = async e => {
|