ninegrid2 6.871.0 → 6.873.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,83 @@ 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
+ setTimeout(() => {
260
+ this.#renderProgress();
261
+ }, 300);
262
+
263
+ }
264
+
265
+ /**
266
+ * 특정 단계의 진행 상태를 업데이트합니다.
267
+ * @param {string} id - 업데이트할 단계의 고유 ID
268
+ * @param {string} status - 'completed' 또는 'pending'
269
+ */
270
+ updateProgress(id, status) {
271
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
272
+ if (itemIndex > -1) {
273
+ this.#progressData[itemIndex].status = status;
274
+ this.#updateProgressItem(this.#progressData[itemIndex]);
275
+ }
276
+ }
277
+
278
+ #renderProgress() {
279
+ const progressList = this.shadowRoot.querySelector(".progress-list");
280
+ progressList.innerHTML = ''; // 기존 목록 초기화
281
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
282
+
283
+ this.#progressData.forEach((item, index) => {
284
+ const li = document.createElement("li");
285
+ li.setAttribute("data-id", item.id);
286
+ li.classList.add("progress-item", item.status);
287
+ li.innerHTML = `
288
+ <span class="icon"></span>
289
+ <span class="text">${item.message}</span>
290
+ `;
291
+ progressList.appendChild(li);
292
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
293
+ });
294
+ }
295
+
296
+ #updateProgressItem(item) {
297
+ const li = this.#progressElements.get(item.id);
298
+ if (li) {
299
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
300
+ li.classList.add(item.status); // 새 상태 클래스 추가
301
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
302
+ }
303
+ }
304
+ }
305
+
306
+
307
+
231
308
  class aiChat extends HTMLElement
232
309
  {
233
310
  constructor() {
@@ -301,9 +378,45 @@ class aiChat extends HTMLElement
301
378
  el.scrollIntoView({ behavior: "smooth", block: "end" });
302
379
  }, 200);
303
380
  };
381
+
382
+ /**
383
+ * 챗 메시지를 추가합니다.
384
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
385
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
386
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
387
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
388
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
389
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
390
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
391
+ */
392
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
393
+
394
+ const target = this.shadowRoot.querySelector(".chat-body");
395
+
396
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
397
+ el.remove();
398
+ });
399
+
400
+ let el = document.createElement("nx-ai-progress-message");
401
+ if (progressData) {
402
+ el.initialize(progressData); // progressData로 초기화
403
+ }
404
+ target.appendChild(el);
405
+
406
+ setTimeout(() => {
407
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
408
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
409
+ }
410
+ }, 200);
411
+
412
+ return el; // 생성된 엘리먼트를 반환
413
+ };
304
414
  }
305
415
 
416
+
417
+
306
418
  customElements.define("nx-ai-message", aiMessage);
307
419
  customElements.define("nx-ai-ing-message", aiIngMessage);
308
420
  customElements.define("nx-ai-my-message", aiMyMessage);
421
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
309
422
  customElements.define("nx-ai-chat", aiChat);
@@ -121865,6 +121865,83 @@ 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
+ setTimeout(() => {
121897
+ this.#renderProgress();
121898
+ }, 300);
121899
+
121900
+ }
121901
+
121902
+ /**
121903
+ * 특정 단계의 진행 상태를 업데이트합니다.
121904
+ * @param {string} id - 업데이트할 단계의 고유 ID
121905
+ * @param {string} status - 'completed' 또는 'pending'
121906
+ */
121907
+ updateProgress(id, status) {
121908
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
121909
+ if (itemIndex > -1) {
121910
+ this.#progressData[itemIndex].status = status;
121911
+ this.#updateProgressItem(this.#progressData[itemIndex]);
121912
+ }
121913
+ }
121914
+
121915
+ #renderProgress() {
121916
+ const progressList = this.shadowRoot.querySelector(".progress-list");
121917
+ progressList.innerHTML = ''; // 기존 목록 초기화
121918
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
121919
+
121920
+ this.#progressData.forEach((item, index) => {
121921
+ const li = document.createElement("li");
121922
+ li.setAttribute("data-id", item.id);
121923
+ li.classList.add("progress-item", item.status);
121924
+ li.innerHTML = `
121925
+ <span class="icon"></span>
121926
+ <span class="text">${item.message}</span>
121927
+ `;
121928
+ progressList.appendChild(li);
121929
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
121930
+ });
121931
+ }
121932
+
121933
+ #updateProgressItem(item) {
121934
+ const li = this.#progressElements.get(item.id);
121935
+ if (li) {
121936
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
121937
+ li.classList.add(item.status); // 새 상태 클래스 추가
121938
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
121939
+ }
121940
+ }
121941
+ }
121942
+
121943
+
121944
+
121868
121945
  class aiChat extends HTMLElement
121869
121946
  {
121870
121947
  constructor() {
@@ -121935,11 +122012,47 @@ class aiChat extends HTMLElement
121935
122012
  el.scrollIntoView({ behavior: "smooth", block: "end" });
121936
122013
  }, 200);
121937
122014
  };
122015
+
122016
+ /**
122017
+ * 챗 메시지를 추가합니다.
122018
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
122019
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
122020
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
122021
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
122022
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
122023
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
122024
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
122025
+ */
122026
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
122027
+
122028
+ const target = this.shadowRoot.querySelector(".chat-body");
122029
+
122030
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
122031
+ el.remove();
122032
+ });
122033
+
122034
+ let el = document.createElement("nx-ai-progress-message");
122035
+ if (progressData) {
122036
+ el.initialize(progressData); // progressData로 초기화
122037
+ }
122038
+ target.appendChild(el);
122039
+
122040
+ setTimeout(() => {
122041
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
122042
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
122043
+ }
122044
+ }, 200);
122045
+
122046
+ return el; // 생성된 엘리먼트를 반환
122047
+ };
121938
122048
  }
121939
122049
 
122050
+
122051
+
121940
122052
  customElements.define("nx-ai-message", aiMessage);
121941
122053
  customElements.define("nx-ai-ing-message", aiIngMessage);
121942
122054
  customElements.define("nx-ai-my-message", aiMyMessage);
122055
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
121943
122056
  customElements.define("nx-ai-chat", aiChat);
121944
122057
 
121945
122058
  /**
@@ -121861,6 +121861,83 @@ 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
+ setTimeout(() => {
121893
+ this.#renderProgress();
121894
+ }, 300);
121895
+
121896
+ }
121897
+
121898
+ /**
121899
+ * 특정 단계의 진행 상태를 업데이트합니다.
121900
+ * @param {string} id - 업데이트할 단계의 고유 ID
121901
+ * @param {string} status - 'completed' 또는 'pending'
121902
+ */
121903
+ updateProgress(id, status) {
121904
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
121905
+ if (itemIndex > -1) {
121906
+ this.#progressData[itemIndex].status = status;
121907
+ this.#updateProgressItem(this.#progressData[itemIndex]);
121908
+ }
121909
+ }
121910
+
121911
+ #renderProgress() {
121912
+ const progressList = this.shadowRoot.querySelector(".progress-list");
121913
+ progressList.innerHTML = ''; // 기존 목록 초기화
121914
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
121915
+
121916
+ this.#progressData.forEach((item, index) => {
121917
+ const li = document.createElement("li");
121918
+ li.setAttribute("data-id", item.id);
121919
+ li.classList.add("progress-item", item.status);
121920
+ li.innerHTML = `
121921
+ <span class="icon"></span>
121922
+ <span class="text">${item.message}</span>
121923
+ `;
121924
+ progressList.appendChild(li);
121925
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
121926
+ });
121927
+ }
121928
+
121929
+ #updateProgressItem(item) {
121930
+ const li = this.#progressElements.get(item.id);
121931
+ if (li) {
121932
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
121933
+ li.classList.add(item.status); // 새 상태 클래스 추가
121934
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
121935
+ }
121936
+ }
121937
+ }
121938
+
121939
+
121940
+
121864
121941
  class aiChat extends HTMLElement
121865
121942
  {
121866
121943
  constructor() {
@@ -121931,11 +122008,47 @@ class aiChat extends HTMLElement
121931
122008
  el.scrollIntoView({ behavior: "smooth", block: "end" });
121932
122009
  }, 200);
121933
122010
  };
122011
+
122012
+ /**
122013
+ * 챗 메시지를 추가합니다.
122014
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
122015
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
122016
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
122017
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
122018
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
122019
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
122020
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
122021
+ */
122022
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
122023
+
122024
+ const target = this.shadowRoot.querySelector(".chat-body");
122025
+
122026
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
122027
+ el.remove();
122028
+ });
122029
+
122030
+ let el = document.createElement("nx-ai-progress-message");
122031
+ if (progressData) {
122032
+ el.initialize(progressData); // progressData로 초기화
122033
+ }
122034
+ target.appendChild(el);
122035
+
122036
+ setTimeout(() => {
122037
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
122038
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
122039
+ }
122040
+ }, 200);
122041
+
122042
+ return el; // 생성된 엘리먼트를 반환
122043
+ };
121934
122044
  }
121935
122045
 
122046
+
122047
+
121936
122048
  customElements.define("nx-ai-message", aiMessage);
121937
122049
  customElements.define("nx-ai-ing-message", aiIngMessage);
121938
122050
  customElements.define("nx-ai-my-message", aiMyMessage);
122051
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
121939
122052
  customElements.define("nx-ai-chat", aiChat);
121940
122053
 
121941
122054
  /**
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.873.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -228,6 +228,83 @@ 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
+ setTimeout(() => {
260
+ this.#renderProgress();
261
+ }, 300);
262
+
263
+ }
264
+
265
+ /**
266
+ * 특정 단계의 진행 상태를 업데이트합니다.
267
+ * @param {string} id - 업데이트할 단계의 고유 ID
268
+ * @param {string} status - 'completed' 또는 'pending'
269
+ */
270
+ updateProgress(id, status) {
271
+ const itemIndex = this.#progressData.findIndex(item => item.id === id);
272
+ if (itemIndex > -1) {
273
+ this.#progressData[itemIndex].status = status;
274
+ this.#updateProgressItem(this.#progressData[itemIndex]);
275
+ }
276
+ }
277
+
278
+ #renderProgress() {
279
+ const progressList = this.shadowRoot.querySelector(".progress-list");
280
+ progressList.innerHTML = ''; // 기존 목록 초기화
281
+ this.#progressElements.clear(); // 기존 요소 Map 초기화
282
+
283
+ this.#progressData.forEach((item, index) => {
284
+ const li = document.createElement("li");
285
+ li.setAttribute("data-id", item.id);
286
+ li.classList.add("progress-item", item.status);
287
+ li.innerHTML = `
288
+ <span class="icon"></span>
289
+ <span class="text">${item.message}</span>
290
+ `;
291
+ progressList.appendChild(li);
292
+ this.#progressElements.set(item.id, li); // DOM 요소 참조 저장
293
+ });
294
+ }
295
+
296
+ #updateProgressItem(item) {
297
+ const li = this.#progressElements.get(item.id);
298
+ if (li) {
299
+ li.classList.remove('pending', 'completed'); // 기존 클래스 제거
300
+ li.classList.add(item.status); // 새 상태 클래스 추가
301
+ li.querySelector(".text").textContent = item.status === 'completed' ? item.completedMessage : item.message;
302
+ }
303
+ }
304
+ }
305
+
306
+
307
+
231
308
  class aiChat extends HTMLElement
232
309
  {
233
310
  constructor() {
@@ -301,9 +378,45 @@ class aiChat extends HTMLElement
301
378
  el.scrollIntoView({ behavior: "smooth", block: "end" });
302
379
  }, 200);
303
380
  };
381
+
382
+ /**
383
+ * 챗 메시지를 추가합니다.
384
+ * @param {string} sender - 메시지 발신자 ('me', 'ing', 'ai', 'progress')
385
+ * @param {string} message - 메시지 내용 (progress 타입의 경우 사용되지 않음)
386
+ * @param {Array<Object>} info - nine-grid 정보 (ai 타입에만 해당)
387
+ * @param {Array<Object>} data - nine-grid 데이터 (ai 타입에만 해당)
388
+ * @param {Array<string>|string} unique - nine-grid 고유 키 (ai 타입에만 해당)
389
+ * @param {Array<Object>} progressData - aiProgressMessage의 초기 진행 데이터 (progress 타입에만 해당)
390
+ * @returns {HTMLElement|null} 생성된 메시지 엘리먼트 (특히 aiProgressMessage의 경우 업데이트를 위해 반환)
391
+ */
392
+ addProgress = (progressData = null) => { // progressData 파라미터 추가
393
+
394
+ const target = this.shadowRoot.querySelector(".chat-body");
395
+
396
+ this.shadowRoot.querySelectorAll("nx-ai-ing-message").forEach(el => {
397
+ el.remove();
398
+ });
399
+
400
+ let el = document.createElement("nx-ai-progress-message");
401
+ if (progressData) {
402
+ el.initialize(progressData); // progressData로 초기화
403
+ }
404
+ target.appendChild(el);
405
+
406
+ setTimeout(() => {
407
+ if (el) { // el이 null이 아닐 때만 scrollIntoView 호출
408
+ el.scrollIntoView({ behavior: "smooth", block: "end" });
409
+ }
410
+ }, 200);
411
+
412
+ return el; // 생성된 엘리먼트를 반환
413
+ };
304
414
  }
305
415
 
416
+
417
+
306
418
  customElements.define("nx-ai-message", aiMessage);
307
419
  customElements.define("nx-ai-ing-message", aiIngMessage);
308
420
  customElements.define("nx-ai-my-message", aiMyMessage);
421
+ customElements.define("nx-ai-progress-message", aiProgressMessage);
309
422
  customElements.define("nx-ai-chat", aiChat);