@nine-lab/nine-mu 0.1.151 → 0.1.153
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 +57 -64
- 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 +45 -57
- 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,17 +6,13 @@ 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.
|
|
16
|
-
|
|
17
|
-
@import "https://cdn.jsdelivr.net/npm/ninegrid2@${ninegrid.version}/dist/css/ai.css";
|
|
18
|
-
${ninegrid.getCustomPath(this,"ai.css")}
|
|
19
|
-
</style>
|
|
14
|
+
this.innerHTML = `
|
|
15
|
+
|
|
20
16
|
|
|
21
17
|
<div class="chat-message">
|
|
22
18
|
<div class="message"></div>
|
|
@@ -50,11 +46,11 @@ class aiMessage extends HTMLElement
|
|
|
50
46
|
</svg>
|
|
51
47
|
*/
|
|
52
48
|
requestAnimationFrame(() => {
|
|
53
|
-
const elMessage = this.
|
|
49
|
+
const elMessage = this.querySelector(".message");
|
|
54
50
|
elMessage.setAttribute("title", this.#message);
|
|
55
51
|
elMessage.innerHTML = this.#message.replaceAll("\n\n", "<br/>").replaceAll("\n", "<br/>");
|
|
56
52
|
|
|
57
|
-
this.
|
|
53
|
+
this.querySelector(".filter").addEventListener("click", e => {
|
|
58
54
|
|
|
59
55
|
//if (e.target.classList.contains("disabled")) return;
|
|
60
56
|
if (this.#unique) {
|
|
@@ -66,8 +62,8 @@ class aiMessage extends HTMLElement
|
|
|
66
62
|
}
|
|
67
63
|
});
|
|
68
64
|
|
|
69
|
-
this.
|
|
70
|
-
//this.
|
|
65
|
+
this.querySelector(".database").addEventListener("click", e => {
|
|
66
|
+
//this.querySelector("nine-grid").maximize();
|
|
71
67
|
const keys = this.#data.map(item =>
|
|
72
68
|
Object.fromEntries(this.#unique.map(key => [key, item[key]]))
|
|
73
69
|
);
|
|
@@ -77,22 +73,22 @@ class aiMessage extends HTMLElement
|
|
|
77
73
|
this.dispatchEvent(new CustomEvent("database", { bubbles: true, detail: { key : keys } }));
|
|
78
74
|
});
|
|
79
75
|
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
76
|
+
this.querySelector(".maximize").addEventListener("click", e => {
|
|
77
|
+
this.querySelector("nine-grid").maximize();
|
|
82
78
|
});
|
|
83
79
|
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
80
|
+
this.querySelector(".excel").addEventListener("click", e => {
|
|
81
|
+
this.querySelector("nine-grid").export();
|
|
86
82
|
});
|
|
87
83
|
|
|
88
|
-
this.
|
|
84
|
+
this.querySelector(".more a").addEventListener("click", () => {
|
|
89
85
|
alert(this.#message);
|
|
90
86
|
});
|
|
91
87
|
|
|
92
88
|
setTimeout(() => {
|
|
93
|
-
const elMore = this.
|
|
89
|
+
const elMore = this.querySelector(".more");
|
|
94
90
|
|
|
95
|
-
//if (ninegrid.isEllipsis(this.
|
|
91
|
+
//if (ninegrid.isEllipsis(this.querySelector(".message"))) {
|
|
96
92
|
if (this.#message.length > 50) {
|
|
97
93
|
elMore.style.display = "flex";
|
|
98
94
|
elMore.style.position = "absolute";
|
|
@@ -111,8 +107,8 @@ class aiMessage extends HTMLElement
|
|
|
111
107
|
|
|
112
108
|
setTimeout(() => {
|
|
113
109
|
if (!unique) {
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
110
|
+
this.querySelector(".filter").classList.add("disabled");
|
|
111
|
+
this.querySelector(".database").classList.add("disabled");
|
|
116
112
|
}
|
|
117
113
|
|
|
118
114
|
this.#init(info);
|
|
@@ -123,8 +119,8 @@ class aiMessage extends HTMLElement
|
|
|
123
119
|
|
|
124
120
|
const rowCount = Number(this.getAttribute("row-count"));
|
|
125
121
|
if (rowCount < 1) {
|
|
126
|
-
this.
|
|
127
|
-
this.
|
|
122
|
+
this.querySelector(".grid").style.display = "none";
|
|
123
|
+
this.querySelector(".chat-menu").style.display = "none";
|
|
128
124
|
return;
|
|
129
125
|
}
|
|
130
126
|
|
|
@@ -156,10 +152,10 @@ class aiMessage extends HTMLElement
|
|
|
156
152
|
</nine-grid>
|
|
157
153
|
`;
|
|
158
154
|
|
|
159
|
-
this.
|
|
155
|
+
this.querySelector(".grid").innerHTML = html;
|
|
160
156
|
|
|
161
157
|
setTimeout(() => {
|
|
162
|
-
const grd = this.
|
|
158
|
+
const grd = this.querySelector("nine-grid");
|
|
163
159
|
grd.data.source = this.#data;
|
|
164
160
|
|
|
165
161
|
//this.scrollIntoView({ behavior: "smooth", block: "end" });
|
|
@@ -173,7 +169,6 @@ class aiIngMessage extends HTMLElement
|
|
|
173
169
|
|
|
174
170
|
constructor() {
|
|
175
171
|
super();
|
|
176
|
-
this.attachShadow({ mode: 'open' });
|
|
177
172
|
}
|
|
178
173
|
|
|
179
174
|
connectedCallback() {
|
|
@@ -181,11 +176,7 @@ class aiIngMessage extends HTMLElement
|
|
|
181
176
|
|
|
182
177
|
this.#message = ".";
|
|
183
178
|
|
|
184
|
-
this.
|
|
185
|
-
<style>
|
|
186
|
-
@import "https://cdn.jsdelivr.net/npm/ninegrid2@${ninegrid.version}/dist/css/ai.css";
|
|
187
|
-
${ninegrid.getCustomPath(this,"ai.css")}
|
|
188
|
-
</style>
|
|
179
|
+
this.innerHTML = `
|
|
189
180
|
|
|
190
181
|
<div class="chat-message">
|
|
191
182
|
.
|
|
@@ -198,27 +189,21 @@ class aiIngMessage extends HTMLElement
|
|
|
198
189
|
#init = () => {
|
|
199
190
|
const interval = setInterval(() => {
|
|
200
191
|
this.#message = this.#message.length < 3 ? this.#message + "." : "";
|
|
201
|
-
this.
|
|
192
|
+
this.querySelector(".chat-message").innerHTML = this.#message || " ";
|
|
202
193
|
}, 500);
|
|
203
194
|
};
|
|
204
195
|
}
|
|
205
196
|
|
|
206
|
-
class
|
|
197
|
+
class MyMessage extends HTMLElement
|
|
207
198
|
{
|
|
208
199
|
constructor() {
|
|
209
200
|
super();
|
|
210
|
-
this.attachShadow({ mode: 'open' });
|
|
211
201
|
}
|
|
212
202
|
|
|
213
203
|
connectedCallback() {
|
|
214
204
|
const message = this.getAttribute("message");
|
|
215
205
|
|
|
216
|
-
this.
|
|
217
|
-
<style>
|
|
218
|
-
@import "https://cdn.jsdelivr.net/npm/ninegrid2@${ninegrid.version}/dist/css/ai.css";
|
|
219
|
-
${ninegrid.getCustomPath(this,"ai.css")}
|
|
220
|
-
</style>
|
|
221
|
-
|
|
206
|
+
this.innerHTML = `
|
|
222
207
|
<div class="chat-message">
|
|
223
208
|
${message}
|
|
224
209
|
</div>
|
|
@@ -235,15 +220,11 @@ class aiProgressMessage extends HTMLElement {
|
|
|
235
220
|
|
|
236
221
|
constructor() {
|
|
237
222
|
super();
|
|
238
|
-
this.attachShadow({ mode: 'open' });
|
|
239
223
|
}
|
|
240
224
|
|
|
241
225
|
connectedCallback() {
|
|
242
|
-
this.
|
|
243
|
-
|
|
244
|
-
@import "https://cdn.jsdelivr.net/npm/ninegrid2@${ninegrid.version}/dist/css/ai.css";
|
|
245
|
-
${ninegrid.getCustomPath(this, "ai.css")}
|
|
246
|
-
</style>
|
|
226
|
+
this.innerHTML = `
|
|
227
|
+
|
|
247
228
|
<div class="chat-message progress-message">
|
|
248
229
|
<ul class="progress-list"></ul>
|
|
249
230
|
</div>
|
|
@@ -308,7 +289,7 @@ class aiProgressMessage extends HTMLElement {
|
|
|
308
289
|
}
|
|
309
290
|
|
|
310
291
|
#renderProgress() {
|
|
311
|
-
const progressList = this.
|
|
292
|
+
const progressList = this.querySelector(".progress-list");
|
|
312
293
|
progressList.innerHTML = '';
|
|
313
294
|
this.#progressElements.clear();
|
|
314
295
|
this.#animationIntervals.forEach(intervalId => clearInterval(intervalId));
|
|
@@ -383,19 +364,25 @@ class ChatMessage extends HTMLElement
|
|
|
383
364
|
connectedCallback() {
|
|
384
365
|
const message = this.getAttribute("message");
|
|
385
366
|
|
|
386
|
-
this
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
${ninegrid.getCustomPath(this,"ai.css")}
|
|
390
|
-
</style>
|
|
367
|
+
this.#renderer();
|
|
368
|
+
this.#init();
|
|
369
|
+
};
|
|
391
370
|
|
|
371
|
+
#renderer = () => {
|
|
372
|
+
const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
|
|
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
|
+
|
|
392
380
|
<div class="chat-body">
|
|
393
381
|
</div>
|
|
394
382
|
`;
|
|
395
|
-
|
|
396
|
-
this.#init();
|
|
397
383
|
};
|
|
398
384
|
|
|
385
|
+
|
|
399
386
|
#init = () => {
|
|
400
387
|
|
|
401
388
|
};
|
|
@@ -414,7 +401,7 @@ class ChatMessage extends HTMLElement
|
|
|
414
401
|
let el;
|
|
415
402
|
switch (sender) {
|
|
416
403
|
case "me":
|
|
417
|
-
el = document.createElement("
|
|
404
|
+
el = document.createElement("nine-chat-me");
|
|
418
405
|
el.setAttribute("message", message);
|
|
419
406
|
target.appendChild(el);
|
|
420
407
|
break;
|
|
@@ -490,14 +477,15 @@ if (!customElements.get('nx-ai-ing-message')) {
|
|
|
490
477
|
customElements.define("nx-ai-ing-message", aiIngMessage);
|
|
491
478
|
}
|
|
492
479
|
|
|
493
|
-
if (!customElements.get('nx-ai-my-message')) {
|
|
494
|
-
customElements.define("nx-ai-my-message", aiMyMessage);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
480
|
if (!customElements.get('nx-ai-progress-message')) {
|
|
498
481
|
customElements.define("nx-ai-progress-message", aiProgressMessage);
|
|
499
482
|
}
|
|
500
483
|
|
|
484
|
+
|
|
485
|
+
|
|
501
486
|
if (!customElements.get('nine-chat-message')) {
|
|
502
487
|
customElements.define("nine-chat-message", ChatMessage);
|
|
503
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 => {
|