ninegrid2 6.871.0 → 6.872.0

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.
@@ -228,6 +228,80 @@ class aiMyMessage extends HTMLElement
228
228
  };
229
229
  }
230
230
 
231
+ // aiProgressMessage 클래스 정의
232
+ class aiProgressMessage extends HTMLElement {
233
+ #progressData = []; // 진행 상태 데이터를 저장할 배열
234
+ #progressElements = new Map(); // 각 진행 단계의 DOM 요소를 저장할 Map
235
+
236
+ constructor() {
237
+ super();
238
+ this.attachShadow({ mode: 'open' });
239
+ }
240
+
241
+ connectedCallback() {
242
+ this.shadowRoot.innerHTML = `
243
+ <style>
244
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ai.css";
245
+ ${ninegrid.getCustomPath(this, "ai.css")}
246
+ </style>
247
+ <div class="chat-message progress-message">
248
+ <ul class="progress-list"></ul>
249
+ </div>
250
+ `;
251
+ }
252
+
253
+ /**
254
+ * 진행 상태 데이터를 초기화하고 화면에 표시합니다.
255
+ * @param {Array<Object>} data - [{id: 'step1', message: '분석중입니다...', completedMessage: '분석이 완료되었습니다.'}, ...]
256
+ */
257
+ initialize(data) {
258
+ this.#progressData = data.map(item => ({ ...item, status: 'pending' })); // 초기 상태는 'pending'
259
+ this.#renderProgress();
260
+ }
261
+
262
+ /**
263
+ * 특정 단계의 진행 상태를 업데이트합니다.
264
+ * @param {string} id - 업데이트할 단계의 고유 ID
265
+ * @param {string} status - 'completed' 또는 'pending'
266
+ */
267
+ updateProgress(id, status) {
268
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
269
+ if (itemIndex > -1) {
270
+ this.#progressData[itemIndex].status = status;
271
+ this.#updateProgressItem(this.#progressData[itemIndex]);
272
+ }
273
+ }
274
+
275
+ #renderProgress() {
276
+ const progressList = this.shadowRoot.querySelector(".progress-list");
277
+ progressList.innerHTML = ''; // 기존 목록 초기화
278
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
279
+
280
+ this.#progressData.forEach((item, index) => {
281
+ const li = document.createElement("li");
282
+ li.setAttribute("data-id", item.id);
283
+ li.classList.add("progress-item", item.status);
284
+ li.innerHTML = `
285
+ <span class="icon"></span>
286
+ <span class="text">${item.message}</span>
287
+ `;
288
+ progressList.appendChild(li);
289
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
290
+ });
291
+ }
292
+
293
+ #updateProgressItem(item) {
294
+ const li = this.#progressElements.get(item.id);
295
+ if (li) {
296
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
297
+ li.classList.add(item.status); // 새 상태 클래스 추가
298
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
299
+ }
300
+ }
301
+ }
302
+
303
+
304
+
231
305
  class aiChat extends HTMLElement
232
306
  {
233
307
  constructor() {
@@ -301,9 +375,45 @@ class aiChat extends HTMLElement
301
375
  el.scrollIntoView({ behavior: "smooth", block: "end" });
302
376
  }, 200);
303
377
  };
378
+
379
+ /**
380
+ * 챗 메시지를 추가합니다.
381
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
382
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
383
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
384
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
385
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
386
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
387
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
388
+ */
389
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
390
+
391
+ const target = this.shadowRoot.querySelector(".chat-body");
392
+
393
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
394
+ el.remove();
395
+ });
396
+
397
+ let el = document.createElement("nx-ai-progress-message");
398
+ if (progressData) {
399
+ el.initialize(progressData); // progressData로 초기화
400
+ }
401
+ target.appendChild(el);
402
+
403
+ setTimeout(() => {
404
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
405
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
406
+ }
407
+ }, 200);
408
+
409
+ return el; // 생성된 엘리먼트를 반환
410
+ };
304
411
  }
305
412
 
413
+
414
+
306
415
  customElements.define("nx-ai-message", aiMessage);
307
416
  customElements.define("nx-ai-ing-message", aiIngMessage);
308
417
  customElements.define("nx-ai-my-message", aiMyMessage);
418
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
309
419
  customElements.define("nx-ai-chat", aiChat);
@@ -121865,6 +121865,80 @@ class aiMyMessage extends HTMLElement
121865
121865
  };
121866
121866
  }
121867
121867
 
121868
+ // aiProgressMessage 클래스 정의
121869
+ class aiProgressMessage extends HTMLElement {
121870
+ #progressData = []; // 진행 상태 데이터를 저장할 배열
121871
+ #progressElements = new Map(); // 각 진행 단계의 DOM 요소를 저장할 Map
121872
+
121873
+ constructor() {
121874
+ super();
121875
+ this.attachShadow({ mode: 'open' });
121876
+ }
121877
+
121878
+ connectedCallback() {
121879
+ this.shadowRoot.innerHTML = `
121880
+ <style>
121881
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ai.css";
121882
+ ${ninegrid.getCustomPath(this, "ai.css")}
121883
+ </style>
121884
+ <div class="chat-message progress-message">
121885
+ <ul class="progress-list"></ul>
121886
+ </div>
121887
+ `;
121888
+ }
121889
+
121890
+ /**
121891
+ * 진행 상태 데이터를 초기화하고 화면에 표시합니다.
121892
+ * @param {Array<Object>} data - [{id: 'step1', message: '분석중입니다...', completedMessage: '분석이 완료되었습니다.'}, ...]
121893
+ */
121894
+ initialize(data) {
121895
+ this.#progressData = data.map(item => ({ ...item, status: 'pending' })); // 초기 상태는 'pending'
121896
+ this.#renderProgress();
121897
+ }
121898
+
121899
+ /**
121900
+ * 특정 단계의 진행 상태를 업데이트합니다.
121901
+ * @param {string} id - 업데이트할 단계의 고유 ID
121902
+ * @param {string} status - 'completed' 또는 'pending'
121903
+ */
121904
+ updateProgress(id, status) {
121905
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
121906
+ if (itemIndex > -1) {
121907
+ this.#progressData[itemIndex].status = status;
121908
+ this.#updateProgressItem(this.#progressData[itemIndex]);
121909
+ }
121910
+ }
121911
+
121912
+ #renderProgress() {
121913
+ const progressList = this.shadowRoot.querySelector(".progress-list");
121914
+ progressList.innerHTML = ''; // 기존 목록 초기화
121915
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
121916
+
121917
+ this.#progressData.forEach((item, index) => {
121918
+ const li = document.createElement("li");
121919
+ li.setAttribute("data-id", item.id);
121920
+ li.classList.add("progress-item", item.status);
121921
+ li.innerHTML = `
121922
+ <span class="icon"></span>
121923
+ <span class="text">${item.message}</span>
121924
+ `;
121925
+ progressList.appendChild(li);
121926
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
121927
+ });
121928
+ }
121929
+
121930
+ #updateProgressItem(item) {
121931
+ const li = this.#progressElements.get(item.id);
121932
+ if (li) {
121933
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
121934
+ li.classList.add(item.status); // 새 상태 클래스 추가
121935
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
121936
+ }
121937
+ }
121938
+ }
121939
+
121940
+
121941
+
121868
121942
  class aiChat extends HTMLElement
121869
121943
  {
121870
121944
  constructor() {
@@ -121935,11 +122009,47 @@ class aiChat extends HTMLElement
121935
122009
  el.scrollIntoView({ behavior: "smooth", block: "end" });
121936
122010
  }, 200);
121937
122011
  };
122012
+
122013
+ /**
122014
+ * 챗 메시지를 추가합니다.
122015
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
122016
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
122017
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
122018
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
122019
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
122020
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
122021
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
122022
+ */
122023
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
122024
+
122025
+ const target = this.shadowRoot.querySelector(".chat-body");
122026
+
122027
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
122028
+ el.remove();
122029
+ });
122030
+
122031
+ let el = document.createElement("nx-ai-progress-message");
122032
+ if (progressData) {
122033
+ el.initialize(progressData); // progressData로 초기화
122034
+ }
122035
+ target.appendChild(el);
122036
+
122037
+ setTimeout(() => {
122038
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
122039
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
122040
+ }
122041
+ }, 200);
122042
+
122043
+ return el; // 생성된 엘리먼트를 반환
122044
+ };
121938
122045
  }
121939
122046
 
122047
+
122048
+
121940
122049
  customElements.define("nx-ai-message", aiMessage);
121941
122050
  customElements.define("nx-ai-ing-message", aiIngMessage);
121942
122051
  customElements.define("nx-ai-my-message", aiMyMessage);
122052
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
121943
122053
  customElements.define("nx-ai-chat", aiChat);
121944
122054
 
121945
122055
  /**
@@ -121861,6 +121861,80 @@ class aiMyMessage extends HTMLElement
121861
121861
  };
121862
121862
  }
121863
121863
 
121864
+ // aiProgressMessage 클래스 정의
121865
+ class aiProgressMessage extends HTMLElement {
121866
+ #progressData = []; // 진행 상태 데이터를 저장할 배열
121867
+ #progressElements = new Map(); // 각 진행 단계의 DOM 요소를 저장할 Map
121868
+
121869
+ constructor() {
121870
+ super();
121871
+ this.attachShadow({ mode: 'open' });
121872
+ }
121873
+
121874
+ connectedCallback() {
121875
+ this.shadowRoot.innerHTML = `
121876
+ <style>
121877
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ai.css";
121878
+ ${ninegrid.getCustomPath(this, "ai.css")}
121879
+ </style>
121880
+ <div class="chat-message progress-message">
121881
+ <ul class="progress-list"></ul>
121882
+ </div>
121883
+ `;
121884
+ }
121885
+
121886
+ /**
121887
+ * 진행 상태 데이터를 초기화하고 화면에 표시합니다.
121888
+ * @param {Array<Object>} data - [{id: 'step1', message: '분석중입니다...', completedMessage: '분석이 완료되었습니다.'}, ...]
121889
+ */
121890
+ initialize(data) {
121891
+ this.#progressData = data.map(item => ({ ...item, status: 'pending' })); // 초기 상태는 'pending'
121892
+ this.#renderProgress();
121893
+ }
121894
+
121895
+ /**
121896
+ * 특정 단계의 진행 상태를 업데이트합니다.
121897
+ * @param {string} id - 업데이트할 단계의 고유 ID
121898
+ * @param {string} status - 'completed' 또는 'pending'
121899
+ */
121900
+ updateProgress(id, status) {
121901
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
121902
+ if (itemIndex > -1) {
121903
+ this.#progressData[itemIndex].status = status;
121904
+ this.#updateProgressItem(this.#progressData[itemIndex]);
121905
+ }
121906
+ }
121907
+
121908
+ #renderProgress() {
121909
+ const progressList = this.shadowRoot.querySelector(".progress-list");
121910
+ progressList.innerHTML = ''; // 기존 목록 초기화
121911
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
121912
+
121913
+ this.#progressData.forEach((item, index) => {
121914
+ const li = document.createElement("li");
121915
+ li.setAttribute("data-id", item.id);
121916
+ li.classList.add("progress-item", item.status);
121917
+ li.innerHTML = `
121918
+ <span class="icon"></span>
121919
+ <span class="text">${item.message}</span>
121920
+ `;
121921
+ progressList.appendChild(li);
121922
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
121923
+ });
121924
+ }
121925
+
121926
+ #updateProgressItem(item) {
121927
+ const li = this.#progressElements.get(item.id);
121928
+ if (li) {
121929
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
121930
+ li.classList.add(item.status); // 새 상태 클래스 추가
121931
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
121932
+ }
121933
+ }
121934
+ }
121935
+
121936
+
121937
+
121864
121938
  class aiChat extends HTMLElement
121865
121939
  {
121866
121940
  constructor() {
@@ -121931,11 +122005,47 @@ class aiChat extends HTMLElement
121931
122005
  el.scrollIntoView({ behavior: "smooth", block: "end" });
121932
122006
  }, 200);
121933
122007
  };
122008
+
122009
+ /**
122010
+ * 챗 메시지를 추가합니다.
122011
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
122012
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
122013
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
122014
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
122015
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
122016
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
122017
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
122018
+ */
122019
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
122020
+
122021
+ const target = this.shadowRoot.querySelector(".chat-body");
122022
+
122023
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
122024
+ el.remove();
122025
+ });
122026
+
122027
+ let el = document.createElement("nx-ai-progress-message");
122028
+ if (progressData) {
122029
+ el.initialize(progressData); // progressData로 초기화
122030
+ }
122031
+ target.appendChild(el);
122032
+
122033
+ setTimeout(() => {
122034
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
122035
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
122036
+ }
122037
+ }, 200);
122038
+
122039
+ return el; // 생성된 엘리먼트를 반환
122040
+ };
121934
122041
  }
121935
122042
 
122043
+
122044
+
121936
122045
  customElements.define("nx-ai-message", aiMessage);
121937
122046
  customElements.define("nx-ai-ing-message", aiIngMessage);
121938
122047
  customElements.define("nx-ai-my-message", aiMyMessage);
122048
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
121939
122049
  customElements.define("nx-ai-chat", aiChat);
121940
122050
 
121941
122051
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.871.0",
4
+ "version": "6.872.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -228,6 +228,80 @@ class aiMyMessage extends HTMLElement
228
228
  };
229
229
  }
230
230
 
231
+ // aiProgressMessage 클래스 정의
232
+ class aiProgressMessage extends HTMLElement {
233
+ #progressData = []; // 진행 상태 데이터를 저장할 배열
234
+ #progressElements = new Map(); // 각 진행 단계의 DOM 요소를 저장할 Map
235
+
236
+ constructor() {
237
+ super();
238
+ this.attachShadow({ mode: 'open' });
239
+ }
240
+
241
+ connectedCallback() {
242
+ this.shadowRoot.innerHTML = `
243
+ <style>
244
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ai.css";
245
+ ${ninegrid.getCustomPath(this, "ai.css")}
246
+ </style>
247
+ <div class="chat-message progress-message">
248
+ <ul class="progress-list"></ul>
249
+ </div>
250
+ `;
251
+ }
252
+
253
+ /**
254
+ * 진행 상태 데이터를 초기화하고 화면에 표시합니다.
255
+ * @param {Array<Object>} data - [{id: 'step1', message: '분석중입니다...', completedMessage: '분석이 완료되었습니다.'}, ...]
256
+ */
257
+ initialize(data) {
258
+ this.#progressData = data.map(item => ({ ...item, status: 'pending' })); // 초기 상태는 'pending'
259
+ this.#renderProgress();
260
+ }
261
+
262
+ /**
263
+ * 특정 단계의 진행 상태를 업데이트합니다.
264
+ * @param {string} id - 업데이트할 단계의 고유 ID
265
+ * @param {string} status - 'completed' 또는 'pending'
266
+ */
267
+ updateProgress(id, status) {
268
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
269
+ if (itemIndex > -1) {
270
+ this.#progressData[itemIndex].status = status;
271
+ this.#updateProgressItem(this.#progressData[itemIndex]);
272
+ }
273
+ }
274
+
275
+ #renderProgress() {
276
+ const progressList = this.shadowRoot.querySelector(".progress-list");
277
+ progressList.innerHTML = ''; // 기존 목록 초기화
278
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
279
+
280
+ this.#progressData.forEach((item, index) => {
281
+ const li = document.createElement("li");
282
+ li.setAttribute("data-id", item.id);
283
+ li.classList.add("progress-item", item.status);
284
+ li.innerHTML = `
285
+ <span class="icon"></span>
286
+ <span class="text">${item.message}</span>
287
+ `;
288
+ progressList.appendChild(li);
289
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
290
+ });
291
+ }
292
+
293
+ #updateProgressItem(item) {
294
+ const li = this.#progressElements.get(item.id);
295
+ if (li) {
296
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
297
+ li.classList.add(item.status); // 새 상태 클래스 추가
298
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
299
+ }
300
+ }
301
+ }
302
+
303
+
304
+
231
305
  class aiChat extends HTMLElement
232
306
  {
233
307
  constructor() {
@@ -301,9 +375,45 @@ class aiChat extends HTMLElement
301
375
  el.scrollIntoView({ behavior: "smooth", block: "end" });
302
376
  }, 200);
303
377
  };
378
+
379
+ /**
380
+ * 챗 메시지를 추가합니다.
381
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
382
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
383
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
384
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
385
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
386
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
387
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
388
+ */
389
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
390
+
391
+ const target = this.shadowRoot.querySelector(".chat-body");
392
+
393
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
394
+ el.remove();
395
+ });
396
+
397
+ let el = document.createElement("nx-ai-progress-message");
398
+ if (progressData) {
399
+ el.initialize(progressData); // progressData로 초기화
400
+ }
401
+ target.appendChild(el);
402
+
403
+ setTimeout(() => {
404
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
405
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
406
+ }
407
+ }, 200);
408
+
409
+ return el; // 생성된 엘리먼트를 반환
410
+ };
304
411
  }
305
412
 
413
+
414
+
306
415
  customElements.define("nx-ai-message", aiMessage);
307
416
  customElements.define("nx-ai-ing-message", aiIngMessage);
308
417
  customElements.define("nx-ai-my-message", aiMyMessage);
418
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
309
419
  customElements.define("nx-ai-chat", aiChat);