ninegrid2 6.984.0 → 6.985.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.
@@ -121916,53 +121916,47 @@ class NxLayout extends HTMLElement {
121916
121916
  }
121917
121917
 
121918
121918
  #render() {
121919
- // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
121920
- const children = Array.from(this.children);
121921
- if (children.length === 0) return;
121922
-
121923
- console.log("333");
121924
- // Shadow Root의 모든 자식 노드 제거
121925
- while (this.shadowRoot.firstChild) {
121926
- this.shadowRoot.removeChild(this.shadowRoot.firstChild);
121927
- }
121928
-
121929
121919
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121930
121920
  const numRows = columnsLayout.length;
121931
121921
 
121932
- const mainGrid = document.createElement('div');
121933
- mainGrid.style.display = 'grid';
121934
- mainGrid.style.width = '100%';
121935
- mainGrid.style.height = '100%';
121936
- mainGrid.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
121922
+ console.log("111");
121937
121923
 
121938
- let childIndex = 0;
121924
+ // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
121925
+ let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
121926
+ let slotIndex = 0;
121939
121927
 
121940
121928
  for (let row = 0; row < numRows; row++) {
121941
121929
  const numColumns = columnsLayout[row];
121942
- const rowWrapper = document.createElement('div');
121943
- rowWrapper.style.display = 'grid';
121944
- rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121945
- rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121946
- rowWrapper.style.height = '100%';
121930
+ let rowTemplate = '';
121947
121931
 
121948
121932
  for (let col = 0; col < numColumns; col++) {
121949
- if (children[childIndex]) {
121950
- // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
121951
- rowWrapper.appendChild(children[childIndex]);
121952
- childIndex++;
121933
+ // <slot>에 이름을 부여하여 특정 요소를 투영
121934
+ rowTemplate += `<div><slot name="slot-${slotIndex}"></slot></div>`;
121935
+ slotIndex++;
121936
+ if (col < numColumns - 1) {
121937
+ rowTemplate += `<nx-splitter direction="horizontal"></nx-splitter>`;
121953
121938
  }
121954
121939
  }
121955
121940
 
121956
- mainGrid.appendChild(rowWrapper);
121941
+ template += `
121942
+ <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
121943
+ ${rowTemplate}
121944
+ </div>
121945
+ `;
121957
121946
 
121958
121947
  if (row < numRows - 1) {
121959
- const splitter = document.createElement('nx-splitter');
121960
- splitter.setAttribute('direction', 'vertical');
121961
- mainGrid.appendChild(splitter);
121948
+ template += `<nx-splitter direction="vertical"></nx-splitter>`;
121962
121949
  }
121963
121950
  }
121964
121951
 
121965
- this.shadowRoot.appendChild(mainGrid);
121952
+ // 섀도우 돔에 동적으로 생성된 HTML을 삽입
121953
+ this.shadowRoot.innerHTML = template;
121954
+
121955
+ // 사용자가 제공한 원본 자식 요소를 <slot>에 할당
121956
+ const children = Array.from(this.children);
121957
+ for (let i = 0; i < children.length; i++) {
121958
+ children[i].slot = `slot-${i}`;
121959
+ }
121966
121960
  }
121967
121961
  }
121968
121962
 
@@ -121912,53 +121912,47 @@ class NxLayout extends HTMLElement {
121912
121912
  }
121913
121913
 
121914
121914
  #render() {
121915
- // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
121916
- const children = Array.from(this.children);
121917
- if (children.length === 0) return;
121918
-
121919
- console.log("333");
121920
- // Shadow Root의 모든 자식 노드 제거
121921
- while (this.shadowRoot.firstChild) {
121922
- this.shadowRoot.removeChild(this.shadowRoot.firstChild);
121923
- }
121924
-
121925
121915
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121926
121916
  const numRows = columnsLayout.length;
121927
121917
 
121928
- const mainGrid = document.createElement('div');
121929
- mainGrid.style.display = 'grid';
121930
- mainGrid.style.width = '100%';
121931
- mainGrid.style.height = '100%';
121932
- mainGrid.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
121918
+ console.log("111");
121933
121919
 
121934
- let childIndex = 0;
121920
+ // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
121921
+ let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
121922
+ let slotIndex = 0;
121935
121923
 
121936
121924
  for (let row = 0; row < numRows; row++) {
121937
121925
  const numColumns = columnsLayout[row];
121938
- const rowWrapper = document.createElement('div');
121939
- rowWrapper.style.display = 'grid';
121940
- rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121941
- rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121942
- rowWrapper.style.height = '100%';
121926
+ let rowTemplate = '';
121943
121927
 
121944
121928
  for (let col = 0; col < numColumns; col++) {
121945
- if (children[childIndex]) {
121946
- // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
121947
- rowWrapper.appendChild(children[childIndex]);
121948
- childIndex++;
121929
+ // <slot>에 이름을 부여하여 특정 요소를 투영
121930
+ rowTemplate += `<div><slot name="slot-${slotIndex}"></slot></div>`;
121931
+ slotIndex++;
121932
+ if (col < numColumns - 1) {
121933
+ rowTemplate += `<nx-splitter direction="horizontal"></nx-splitter>`;
121949
121934
  }
121950
121935
  }
121951
121936
 
121952
- mainGrid.appendChild(rowWrapper);
121937
+ template += `
121938
+ <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
121939
+ ${rowTemplate}
121940
+ </div>
121941
+ `;
121953
121942
 
121954
121943
  if (row < numRows - 1) {
121955
- const splitter = document.createElement('nx-splitter');
121956
- splitter.setAttribute('direction', 'vertical');
121957
- mainGrid.appendChild(splitter);
121944
+ template += `<nx-splitter direction="vertical"></nx-splitter>`;
121958
121945
  }
121959
121946
  }
121960
121947
 
121961
- this.shadowRoot.appendChild(mainGrid);
121948
+ // 섀도우 돔에 동적으로 생성된 HTML을 삽입
121949
+ this.shadowRoot.innerHTML = template;
121950
+
121951
+ // 사용자가 제공한 원본 자식 요소를 <slot>에 할당
121952
+ const children = Array.from(this.children);
121953
+ for (let i = 0; i < children.length; i++) {
121954
+ children[i].slot = `slot-${i}`;
121955
+ }
121962
121956
  }
121963
121957
  }
121964
121958
 
@@ -21,53 +21,47 @@ class NxLayout extends HTMLElement {
21
21
  }
22
22
 
23
23
  #render() {
24
- // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
25
- const children = Array.from(this.children);
26
- if (children.length === 0) return;
27
-
28
- console.log("333")
29
- // Shadow Root의 모든 자식 노드 제거
30
- while (this.shadowRoot.firstChild) {
31
- this.shadowRoot.removeChild(this.shadowRoot.firstChild);
32
- }
33
-
34
24
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
35
25
  const numRows = columnsLayout.length;
36
26
 
37
- const mainGrid = document.createElement('div');
38
- mainGrid.style.display = 'grid';
39
- mainGrid.style.width = '100%';
40
- mainGrid.style.height = '100%';
41
- mainGrid.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
27
+ console.log("111")
42
28
 
43
- let childIndex = 0;
29
+ // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
30
+ let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
31
+ let slotIndex = 0;
44
32
 
45
33
  for (let row = 0; row < numRows; row++) {
46
34
  const numColumns = columnsLayout[row];
47
- const rowWrapper = document.createElement('div');
48
- rowWrapper.style.display = 'grid';
49
- rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
50
- rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
51
- rowWrapper.style.height = '100%';
35
+ let rowTemplate = '';
52
36
 
53
37
  for (let col = 0; col < numColumns; col++) {
54
- if (children[childIndex]) {
55
- // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
56
- rowWrapper.appendChild(children[childIndex]);
57
- childIndex++;
38
+ // <slot>에 이름을 부여하여 특정 요소를 투영
39
+ rowTemplate += `<div><slot name="slot-${slotIndex}"></slot></div>`;
40
+ slotIndex++;
41
+ if (col < numColumns - 1) {
42
+ rowTemplate += `<nx-splitter direction="horizontal"></nx-splitter>`;
58
43
  }
59
44
  }
60
45
 
61
- mainGrid.appendChild(rowWrapper);
46
+ template += `
47
+ <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
48
+ ${rowTemplate}
49
+ </div>
50
+ `;
62
51
 
63
52
  if (row < numRows - 1) {
64
- const splitter = document.createElement('nx-splitter');
65
- splitter.setAttribute('direction', 'vertical');
66
- mainGrid.appendChild(splitter);
53
+ template += `<nx-splitter direction="vertical"></nx-splitter>`;
67
54
  }
68
55
  }
69
56
 
70
- this.shadowRoot.appendChild(mainGrid);
57
+ // 섀도우 돔에 동적으로 생성된 HTML을 삽입
58
+ this.shadowRoot.innerHTML = template;
59
+
60
+ // 사용자가 제공한 원본 자식 요소를 <slot>에 할당
61
+ const children = Array.from(this.children);
62
+ for (let i = 0; i < children.length; i++) {
63
+ children[i].slot = `slot-${i}`;
64
+ }
71
65
  }
72
66
  }
73
67
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.984.0",
4
+ "version": "6.985.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -21,53 +21,47 @@ class NxLayout extends HTMLElement {
21
21
  }
22
22
 
23
23
  #render() {
24
- // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
25
- const children = Array.from(this.children);
26
- if (children.length === 0) return;
27
-
28
- console.log("333")
29
- // Shadow Root의 모든 자식 노드 제거
30
- while (this.shadowRoot.firstChild) {
31
- this.shadowRoot.removeChild(this.shadowRoot.firstChild);
32
- }
33
-
34
24
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
35
25
  const numRows = columnsLayout.length;
36
26
 
37
- const mainGrid = document.createElement('div');
38
- mainGrid.style.display = 'grid';
39
- mainGrid.style.width = '100%';
40
- mainGrid.style.height = '100%';
41
- mainGrid.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
27
+ console.log("111")
42
28
 
43
- let childIndex = 0;
29
+ // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
30
+ let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
31
+ let slotIndex = 0;
44
32
 
45
33
  for (let row = 0; row < numRows; row++) {
46
34
  const numColumns = columnsLayout[row];
47
- const rowWrapper = document.createElement('div');
48
- rowWrapper.style.display = 'grid';
49
- rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
50
- rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
51
- rowWrapper.style.height = '100%';
35
+ let rowTemplate = '';
52
36
 
53
37
  for (let col = 0; col < numColumns; col++) {
54
- if (children[childIndex]) {
55
- // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
56
- rowWrapper.appendChild(children[childIndex]);
57
- childIndex++;
38
+ // <slot>에 이름을 부여하여 특정 요소를 투영
39
+ rowTemplate += `<div><slot name="slot-${slotIndex}"></slot></div>`;
40
+ slotIndex++;
41
+ if (col < numColumns - 1) {
42
+ rowTemplate += `<nx-splitter direction="horizontal"></nx-splitter>`;
58
43
  }
59
44
  }
60
45
 
61
- mainGrid.appendChild(rowWrapper);
46
+ template += `
47
+ <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
48
+ ${rowTemplate}
49
+ </div>
50
+ `;
62
51
 
63
52
  if (row < numRows - 1) {
64
- const splitter = document.createElement('nx-splitter');
65
- splitter.setAttribute('direction', 'vertical');
66
- mainGrid.appendChild(splitter);
53
+ template += `<nx-splitter direction="vertical"></nx-splitter>`;
67
54
  }
68
55
  }
69
56
 
70
- this.shadowRoot.appendChild(mainGrid);
57
+ // 섀도우 돔에 동적으로 생성된 HTML을 삽입
58
+ this.shadowRoot.innerHTML = template;
59
+
60
+ // 사용자가 제공한 원본 자식 요소를 <slot>에 할당
61
+ const children = Array.from(this.children);
62
+ for (let i = 0; i < children.length; i++) {
63
+ children[i].slot = `slot-${i}`;
64
+ }
71
65
  }
72
66
  }
73
67