ninegrid2 6.985.0 → 6.986.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.
@@ -121896,17 +121896,13 @@ class nxTitle extends HTMLElement {
121896
121896
  customElements.define("nx-title", nxTitle);
121897
121897
 
121898
121898
  class NxLayout extends HTMLElement {
121899
- constructor() {
121900
- super();
121901
- this.attachShadow({ mode: 'open' });
121902
- }
121903
-
121904
121899
  connectedCallback() {
121905
121900
  this.#render();
121906
121901
  }
121907
121902
 
121908
121903
  attributeChangedCallback(name, oldValue, newValue) {
121909
- if (oldValue !== newValue) {
121904
+ // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121905
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121910
121906
  this.#render();
121911
121907
  }
121912
121908
  }
@@ -121916,47 +121912,50 @@ class NxLayout extends HTMLElement {
121916
121912
  }
121917
121913
 
121918
121914
  #render() {
121915
+ const children = Array.from(this.children);
121916
+ if (children.length === 0) return;
121917
+
121918
+ // 기존 자식 노드를 안전하게 제거
121919
+ while (this.firstChild) {
121920
+ this.removeChild(this.firstChild);
121921
+ }
121922
+
121923
+ console.log("22222");
121924
+
121919
121925
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121920
121926
  const numRows = columnsLayout.length;
121921
121927
 
121922
- console.log("111");
121928
+ this.style.display = 'grid';
121929
+ this.style.width = '100%';
121930
+ this.style.height = '100%';
121931
+ this.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
121923
121932
 
121924
- // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
121925
- let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
121926
- let slotIndex = 0;
121933
+ let childIndex = 0;
121927
121934
 
121928
121935
  for (let row = 0; row < numRows; row++) {
121929
121936
  const numColumns = columnsLayout[row];
121930
- let rowTemplate = '';
121937
+ const rowWrapper = document.createElement('div');
121938
+ rowWrapper.style.display = 'grid';
121939
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121940
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121941
+ rowWrapper.style.height = '100%';
121931
121942
 
121932
121943
  for (let col = 0; col < numColumns; col++) {
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>`;
121944
+ if (children[childIndex]) {
121945
+ // 불필요한 래퍼 없이 원본 자식 요소를 직접 추가
121946
+ rowWrapper.appendChild(children[childIndex]);
121947
+ childIndex++;
121938
121948
  }
121939
121949
  }
121940
121950
 
121941
- template += `
121942
- <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
121943
- ${rowTemplate}
121944
- </div>
121945
- `;
121951
+ this.appendChild(rowWrapper);
121946
121952
 
121947
121953
  if (row < numRows - 1) {
121948
- template += `<nx-splitter direction="vertical"></nx-splitter>`;
121954
+ const splitter = document.createElement('nx-splitter');
121955
+ splitter.setAttribute('direction', 'vertical');
121956
+ this.appendChild(splitter);
121949
121957
  }
121950
121958
  }
121951
-
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
- }
121960
121959
  }
121961
121960
  }
121962
121961
 
@@ -121892,17 +121892,13 @@ class nxTitle extends HTMLElement {
121892
121892
  customElements.define("nx-title", nxTitle);
121893
121893
 
121894
121894
  class NxLayout extends HTMLElement {
121895
- constructor() {
121896
- super();
121897
- this.attachShadow({ mode: 'open' });
121898
- }
121899
-
121900
121895
  connectedCallback() {
121901
121896
  this.#render();
121902
121897
  }
121903
121898
 
121904
121899
  attributeChangedCallback(name, oldValue, newValue) {
121905
- if (oldValue !== newValue) {
121900
+ // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121901
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121906
121902
  this.#render();
121907
121903
  }
121908
121904
  }
@@ -121912,47 +121908,50 @@ class NxLayout extends HTMLElement {
121912
121908
  }
121913
121909
 
121914
121910
  #render() {
121911
+ const children = Array.from(this.children);
121912
+ if (children.length === 0) return;
121913
+
121914
+ // 기존 자식 노드를 안전하게 제거
121915
+ while (this.firstChild) {
121916
+ this.removeChild(this.firstChild);
121917
+ }
121918
+
121919
+ console.log("22222");
121920
+
121915
121921
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121916
121922
  const numRows = columnsLayout.length;
121917
121923
 
121918
- console.log("111");
121924
+ this.style.display = 'grid';
121925
+ this.style.width = '100%';
121926
+ this.style.height = '100%';
121927
+ this.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
121919
121928
 
121920
- // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
121921
- let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
121922
- let slotIndex = 0;
121929
+ let childIndex = 0;
121923
121930
 
121924
121931
  for (let row = 0; row < numRows; row++) {
121925
121932
  const numColumns = columnsLayout[row];
121926
- let rowTemplate = '';
121933
+ const rowWrapper = document.createElement('div');
121934
+ rowWrapper.style.display = 'grid';
121935
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121936
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121937
+ rowWrapper.style.height = '100%';
121927
121938
 
121928
121939
  for (let col = 0; col < numColumns; col++) {
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>`;
121940
+ if (children[childIndex]) {
121941
+ // 불필요한 래퍼 없이 원본 자식 요소를 직접 추가
121942
+ rowWrapper.appendChild(children[childIndex]);
121943
+ childIndex++;
121934
121944
  }
121935
121945
  }
121936
121946
 
121937
- template += `
121938
- <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
121939
- ${rowTemplate}
121940
- </div>
121941
- `;
121947
+ this.appendChild(rowWrapper);
121942
121948
 
121943
121949
  if (row < numRows - 1) {
121944
- template += `<nx-splitter direction="vertical"></nx-splitter>`;
121950
+ const splitter = document.createElement('nx-splitter');
121951
+ splitter.setAttribute('direction', 'vertical');
121952
+ this.appendChild(splitter);
121945
121953
  }
121946
121954
  }
121947
-
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
- }
121956
121955
  }
121957
121956
  }
121958
121957
 
@@ -1,17 +1,13 @@
1
1
  import ninegrid from "../index.js";
2
2
 
3
3
  class NxLayout extends HTMLElement {
4
- constructor() {
5
- super();
6
- this.attachShadow({ mode: 'open' });
7
- }
8
-
9
4
  connectedCallback() {
10
5
  this.#render();
11
6
  }
12
7
 
13
8
  attributeChangedCallback(name, oldValue, newValue) {
14
- if (oldValue !== newValue) {
9
+ // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
15
11
  this.#render();
16
12
  }
17
13
  }
@@ -21,48 +17,51 @@ class NxLayout extends HTMLElement {
21
17
  }
22
18
 
23
19
  #render() {
20
+ const children = Array.from(this.children);
21
+ if (children.length === 0) return;
22
+
23
+ // 기존 자식 노드를 안전하게 제거
24
+ while (this.firstChild) {
25
+ this.removeChild(this.firstChild);
26
+ }
27
+
28
+ console.log("22222")
29
+
24
30
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
25
31
  const numRows = columnsLayout.length;
26
32
 
27
- console.log("111")
33
+ this.style.display = 'grid';
34
+ this.style.width = '100%';
35
+ this.style.height = '100%';
36
+ this.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
28
37
 
29
- // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
30
- let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
31
- let slotIndex = 0;
38
+ let childIndex = 0;
32
39
 
33
40
  for (let row = 0; row < numRows; row++) {
34
41
  const numColumns = columnsLayout[row];
35
- let rowTemplate = '';
42
+ const rowWrapper = document.createElement('div');
43
+ rowWrapper.style.display = 'grid';
44
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
45
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
46
+ rowWrapper.style.height = '100%';
36
47
 
37
48
  for (let col = 0; col < numColumns; col++) {
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>`;
49
+ if (children[childIndex]) {
50
+ // 불필요한 래퍼 없이 원본 자식 요소를 직접 추가
51
+ rowWrapper.appendChild(children[childIndex]);
52
+ childIndex++;
43
53
  }
44
54
  }
45
55
 
46
- template += `
47
- <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
48
- ${rowTemplate}
49
- </div>
50
- `;
56
+ this.appendChild(rowWrapper);
51
57
 
52
58
  if (row < numRows - 1) {
53
- template += `<nx-splitter direction="vertical"></nx-splitter>`;
59
+ const splitter = document.createElement('nx-splitter');
60
+ splitter.setAttribute('direction', 'vertical');
61
+ this.appendChild(splitter);
54
62
  }
55
63
  }
56
-
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
- }
65
64
  }
66
65
  }
67
66
 
68
- customElements.define('nx-layout', NxLayout);
67
+ customElements.define('nx-layout', NxLayout);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.985.0",
4
+ "version": "6.986.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -1,17 +1,13 @@
1
1
  import ninegrid from "../index.js";
2
2
 
3
3
  class NxLayout extends HTMLElement {
4
- constructor() {
5
- super();
6
- this.attachShadow({ mode: 'open' });
7
- }
8
-
9
4
  connectedCallback() {
10
5
  this.#render();
11
6
  }
12
7
 
13
8
  attributeChangedCallback(name, oldValue, newValue) {
14
- if (oldValue !== newValue) {
9
+ // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
15
11
  this.#render();
16
12
  }
17
13
  }
@@ -21,48 +17,51 @@ class NxLayout extends HTMLElement {
21
17
  }
22
18
 
23
19
  #render() {
20
+ const children = Array.from(this.children);
21
+ if (children.length === 0) return;
22
+
23
+ // 기존 자식 노드를 안전하게 제거
24
+ while (this.firstChild) {
25
+ this.removeChild(this.firstChild);
26
+ }
27
+
28
+ console.log("22222")
29
+
24
30
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
25
31
  const numRows = columnsLayout.length;
26
32
 
27
- console.log("111")
33
+ this.style.display = 'grid';
34
+ this.style.width = '100%';
35
+ this.style.height = '100%';
36
+ this.style.gridTemplateRows = `repeat(${numRows}, 1fr)`;
28
37
 
29
- // 템플릿 스트링을 사용하여 섀도우 돔 내부 구조를 동적으로 생성
30
- let template = `<style>:host { display: grid; width: 100%; height: 100%; }</style>`;
31
- let slotIndex = 0;
38
+ let childIndex = 0;
32
39
 
33
40
  for (let row = 0; row < numRows; row++) {
34
41
  const numColumns = columnsLayout[row];
35
- let rowTemplate = '';
42
+ const rowWrapper = document.createElement('div');
43
+ rowWrapper.style.display = 'grid';
44
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
45
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
46
+ rowWrapper.style.height = '100%';
36
47
 
37
48
  for (let col = 0; col < numColumns; col++) {
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>`;
49
+ if (children[childIndex]) {
50
+ // 불필요한 래퍼 없이 원본 자식 요소를 직접 추가
51
+ rowWrapper.appendChild(children[childIndex]);
52
+ childIndex++;
43
53
  }
44
54
  }
45
55
 
46
- template += `
47
- <div style="display: grid; grid-template-columns: repeat(${numColumns}, 1fr) repeat(${numColumns-1}, 8px); height: 100%;">
48
- ${rowTemplate}
49
- </div>
50
- `;
56
+ this.appendChild(rowWrapper);
51
57
 
52
58
  if (row < numRows - 1) {
53
- template += `<nx-splitter direction="vertical"></nx-splitter>`;
59
+ const splitter = document.createElement('nx-splitter');
60
+ splitter.setAttribute('direction', 'vertical');
61
+ this.appendChild(splitter);
54
62
  }
55
63
  }
56
-
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
- }
65
64
  }
66
65
  }
67
66
 
68
- customElements.define('nx-layout', NxLayout);
67
+ customElements.define('nx-layout', NxLayout);