ninegrid2 6.982.0 → 6.984.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,13 +121896,17 @@ 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
+
121899
121904
  connectedCallback() {
121900
121905
  this.#render();
121901
121906
  }
121902
121907
 
121903
121908
  attributeChangedCallback(name, oldValue, newValue) {
121904
- // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121905
- if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121909
+ if (oldValue !== newValue) {
121906
121910
  this.#render();
121907
121911
  }
121908
121912
  }
@@ -121912,27 +121916,24 @@ class NxLayout extends HTMLElement {
121912
121916
  }
121913
121917
 
121914
121918
  #render() {
121919
+ // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
121915
121920
  const children = Array.from(this.children);
121916
121921
  if (children.length === 0) return;
121917
121922
 
121918
- while (this.firstChild) {
121919
- this.removeChild(this.firstChild);
121923
+ console.log("333");
121924
+ // Shadow Root의 모든 자식 노드 제거
121925
+ while (this.shadowRoot.firstChild) {
121926
+ this.shadowRoot.removeChild(this.shadowRoot.firstChild);
121920
121927
  }
121921
121928
 
121922
- console.log("11111");
121923
-
121924
121929
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121925
121930
  const numRows = columnsLayout.length;
121926
121931
 
121927
- let gridTemplate = '';
121928
- for (const numCols of columnsLayout) {
121929
- gridTemplate += `1fr `; // 행의 높이
121930
- }
121931
-
121932
- this.style.display = 'grid';
121933
- this.style.width = '100%';
121934
- this.style.height = '100%';
121935
- this.style.gridTemplateRows = gridTemplate.trim();
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)`;
121936
121937
 
121937
121938
  let childIndex = 0;
121938
121939
 
@@ -121940,40 +121941,28 @@ class NxLayout extends HTMLElement {
121940
121941
  const numColumns = columnsLayout[row];
121941
121942
  const rowWrapper = document.createElement('div');
121942
121943
  rowWrapper.style.display = 'grid';
121943
-
121944
- let columnTemplate = '';
121945
- for (let i = 0; i < numColumns; i++) {
121946
- columnTemplate += '1fr ';
121947
- if (i < numColumns - 1) {
121948
- columnTemplate += '8px ';
121949
- }
121950
- }
121951
- rowWrapper.style.gridTemplateColumns = columnTemplate.trim();
121944
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121945
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121952
121946
  rowWrapper.style.height = '100%';
121953
121947
 
121954
121948
  for (let col = 0; col < numColumns; col++) {
121955
121949
  if (children[childIndex]) {
121956
- // 불필요한 래퍼(wrapper)를 제거하고 원본 자식 요소를 직접 추가
121950
+ // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
121957
121951
  rowWrapper.appendChild(children[childIndex]);
121958
121952
  childIndex++;
121959
121953
  }
121960
-
121961
- if (col < numColumns - 1) {
121962
- const splitter = document.createElement('nx-splitter');
121963
- splitter.setAttribute('direction', 'horizontal');
121964
- rowWrapper.appendChild(splitter);
121965
- }
121966
121954
  }
121967
121955
 
121968
- this.appendChild(rowWrapper);
121956
+ mainGrid.appendChild(rowWrapper);
121969
121957
 
121970
121958
  if (row < numRows - 1) {
121971
121959
  const splitter = document.createElement('nx-splitter');
121972
121960
  splitter.setAttribute('direction', 'vertical');
121973
- splitter.style.gridColumn = `1 / -1`;
121974
- this.appendChild(splitter);
121961
+ mainGrid.appendChild(splitter);
121975
121962
  }
121976
121963
  }
121964
+
121965
+ this.shadowRoot.appendChild(mainGrid);
121977
121966
  }
121978
121967
  }
121979
121968
 
@@ -121892,13 +121892,17 @@ 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
+
121895
121900
  connectedCallback() {
121896
121901
  this.#render();
121897
121902
  }
121898
121903
 
121899
121904
  attributeChangedCallback(name, oldValue, newValue) {
121900
- // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121901
- if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121905
+ if (oldValue !== newValue) {
121902
121906
  this.#render();
121903
121907
  }
121904
121908
  }
@@ -121908,27 +121912,24 @@ class NxLayout extends HTMLElement {
121908
121912
  }
121909
121913
 
121910
121914
  #render() {
121915
+ // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
121911
121916
  const children = Array.from(this.children);
121912
121917
  if (children.length === 0) return;
121913
121918
 
121914
- while (this.firstChild) {
121915
- this.removeChild(this.firstChild);
121919
+ console.log("333");
121920
+ // Shadow Root의 모든 자식 노드 제거
121921
+ while (this.shadowRoot.firstChild) {
121922
+ this.shadowRoot.removeChild(this.shadowRoot.firstChild);
121916
121923
  }
121917
121924
 
121918
- console.log("11111");
121919
-
121920
121925
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121921
121926
  const numRows = columnsLayout.length;
121922
121927
 
121923
- let gridTemplate = '';
121924
- for (const numCols of columnsLayout) {
121925
- gridTemplate += `1fr `; // 행의 높이
121926
- }
121927
-
121928
- this.style.display = 'grid';
121929
- this.style.width = '100%';
121930
- this.style.height = '100%';
121931
- this.style.gridTemplateRows = gridTemplate.trim();
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)`;
121932
121933
 
121933
121934
  let childIndex = 0;
121934
121935
 
@@ -121936,40 +121937,28 @@ class NxLayout extends HTMLElement {
121936
121937
  const numColumns = columnsLayout[row];
121937
121938
  const rowWrapper = document.createElement('div');
121938
121939
  rowWrapper.style.display = 'grid';
121939
-
121940
- let columnTemplate = '';
121941
- for (let i = 0; i < numColumns; i++) {
121942
- columnTemplate += '1fr ';
121943
- if (i < numColumns - 1) {
121944
- columnTemplate += '8px ';
121945
- }
121946
- }
121947
- rowWrapper.style.gridTemplateColumns = columnTemplate.trim();
121940
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121941
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
121948
121942
  rowWrapper.style.height = '100%';
121949
121943
 
121950
121944
  for (let col = 0; col < numColumns; col++) {
121951
121945
  if (children[childIndex]) {
121952
- // 불필요한 래퍼(wrapper)를 제거하고 원본 자식 요소를 직접 추가
121946
+ // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
121953
121947
  rowWrapper.appendChild(children[childIndex]);
121954
121948
  childIndex++;
121955
121949
  }
121956
-
121957
- if (col < numColumns - 1) {
121958
- const splitter = document.createElement('nx-splitter');
121959
- splitter.setAttribute('direction', 'horizontal');
121960
- rowWrapper.appendChild(splitter);
121961
- }
121962
121950
  }
121963
121951
 
121964
- this.appendChild(rowWrapper);
121952
+ mainGrid.appendChild(rowWrapper);
121965
121953
 
121966
121954
  if (row < numRows - 1) {
121967
121955
  const splitter = document.createElement('nx-splitter');
121968
121956
  splitter.setAttribute('direction', 'vertical');
121969
- splitter.style.gridColumn = `1 / -1`;
121970
- this.appendChild(splitter);
121957
+ mainGrid.appendChild(splitter);
121971
121958
  }
121972
121959
  }
121960
+
121961
+ this.shadowRoot.appendChild(mainGrid);
121973
121962
  }
121974
121963
  }
121975
121964
 
@@ -1,13 +1,17 @@
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
+
4
9
  connectedCallback() {
5
10
  this.#render();
6
11
  }
7
12
 
8
13
  attributeChangedCallback(name, oldValue, newValue) {
9
- // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
- if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
14
+ if (oldValue !== newValue) {
11
15
  this.#render();
12
16
  }
13
17
  }
@@ -17,27 +21,24 @@ class NxLayout extends HTMLElement {
17
21
  }
18
22
 
19
23
  #render() {
24
+ // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
20
25
  const children = Array.from(this.children);
21
26
  if (children.length === 0) return;
22
27
 
23
- while (this.firstChild) {
24
- this.removeChild(this.firstChild);
28
+ console.log("333")
29
+ // Shadow Root의 모든 자식 노드 제거
30
+ while (this.shadowRoot.firstChild) {
31
+ this.shadowRoot.removeChild(this.shadowRoot.firstChild);
25
32
  }
26
33
 
27
- console.log("11111")
28
-
29
34
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
30
35
  const numRows = columnsLayout.length;
31
36
 
32
- let gridTemplate = '';
33
- for (const numCols of columnsLayout) {
34
- gridTemplate += `1fr `; // 행의 높이
35
- }
36
-
37
- this.style.display = 'grid';
38
- this.style.width = '100%';
39
- this.style.height = '100%';
40
- this.style.gridTemplateRows = gridTemplate.trim();
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)`;
41
42
 
42
43
  let childIndex = 0;
43
44
 
@@ -45,41 +46,29 @@ class NxLayout extends HTMLElement {
45
46
  const numColumns = columnsLayout[row];
46
47
  const rowWrapper = document.createElement('div');
47
48
  rowWrapper.style.display = 'grid';
48
-
49
- let columnTemplate = '';
50
- for (let i = 0; i < numColumns; i++) {
51
- columnTemplate += '1fr ';
52
- if (i < numColumns - 1) {
53
- columnTemplate += '8px ';
54
- }
55
- }
56
- rowWrapper.style.gridTemplateColumns = columnTemplate.trim();
49
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
50
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
57
51
  rowWrapper.style.height = '100%';
58
52
 
59
53
  for (let col = 0; col < numColumns; col++) {
60
54
  if (children[childIndex]) {
61
- // 불필요한 래퍼(wrapper)를 제거하고 원본 자식 요소를 직접 추가
55
+ // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
62
56
  rowWrapper.appendChild(children[childIndex]);
63
57
  childIndex++;
64
58
  }
65
-
66
- if (col < numColumns - 1) {
67
- const splitter = document.createElement('nx-splitter');
68
- splitter.setAttribute('direction', 'horizontal');
69
- rowWrapper.appendChild(splitter);
70
- }
71
59
  }
72
60
 
73
- this.appendChild(rowWrapper);
61
+ mainGrid.appendChild(rowWrapper);
74
62
 
75
63
  if (row < numRows - 1) {
76
64
  const splitter = document.createElement('nx-splitter');
77
65
  splitter.setAttribute('direction', 'vertical');
78
- splitter.style.gridColumn = `1 / -1`;
79
- this.appendChild(splitter);
66
+ mainGrid.appendChild(splitter);
80
67
  }
81
68
  }
69
+
70
+ this.shadowRoot.appendChild(mainGrid);
82
71
  }
83
72
  }
84
73
 
85
- customElements.define('nx-layout', NxLayout);
74
+ 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.982.0",
4
+ "version": "6.984.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -1,13 +1,17 @@
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
+
4
9
  connectedCallback() {
5
10
  this.#render();
6
11
  }
7
12
 
8
13
  attributeChangedCallback(name, oldValue, newValue) {
9
- // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
- if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
14
+ if (oldValue !== newValue) {
11
15
  this.#render();
12
16
  }
13
17
  }
@@ -17,27 +21,24 @@ class NxLayout extends HTMLElement {
17
21
  }
18
22
 
19
23
  #render() {
24
+ // 컴포넌트의 자식 요소는 Shadow DOM의 렌더링 대상이 아님
20
25
  const children = Array.from(this.children);
21
26
  if (children.length === 0) return;
22
27
 
23
- while (this.firstChild) {
24
- this.removeChild(this.firstChild);
28
+ console.log("333")
29
+ // Shadow Root의 모든 자식 노드 제거
30
+ while (this.shadowRoot.firstChild) {
31
+ this.shadowRoot.removeChild(this.shadowRoot.firstChild);
25
32
  }
26
33
 
27
- console.log("11111")
28
-
29
34
  const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
30
35
  const numRows = columnsLayout.length;
31
36
 
32
- let gridTemplate = '';
33
- for (const numCols of columnsLayout) {
34
- gridTemplate += `1fr `; // 행의 높이
35
- }
36
-
37
- this.style.display = 'grid';
38
- this.style.width = '100%';
39
- this.style.height = '100%';
40
- this.style.gridTemplateRows = gridTemplate.trim();
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)`;
41
42
 
42
43
  let childIndex = 0;
43
44
 
@@ -45,41 +46,29 @@ class NxLayout extends HTMLElement {
45
46
  const numColumns = columnsLayout[row];
46
47
  const rowWrapper = document.createElement('div');
47
48
  rowWrapper.style.display = 'grid';
48
-
49
- let columnTemplate = '';
50
- for (let i = 0; i < numColumns; i++) {
51
- columnTemplate += '1fr ';
52
- if (i < numColumns - 1) {
53
- columnTemplate += '8px ';
54
- }
55
- }
56
- rowWrapper.style.gridTemplateColumns = columnTemplate.trim();
49
+ rowWrapper.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
50
+ rowWrapper.style.gap = `8px`; // 가로 스플리터 간격
57
51
  rowWrapper.style.height = '100%';
58
52
 
59
53
  for (let col = 0; col < numColumns; col++) {
60
54
  if (children[childIndex]) {
61
- // 불필요한 래퍼(wrapper)를 제거하고 원본 자식 요소를 직접 추가
55
+ // 원본 자식 요소를 Shadow DOM 내부의 div에 직접 추가
62
56
  rowWrapper.appendChild(children[childIndex]);
63
57
  childIndex++;
64
58
  }
65
-
66
- if (col < numColumns - 1) {
67
- const splitter = document.createElement('nx-splitter');
68
- splitter.setAttribute('direction', 'horizontal');
69
- rowWrapper.appendChild(splitter);
70
- }
71
59
  }
72
60
 
73
- this.appendChild(rowWrapper);
61
+ mainGrid.appendChild(rowWrapper);
74
62
 
75
63
  if (row < numRows - 1) {
76
64
  const splitter = document.createElement('nx-splitter');
77
65
  splitter.setAttribute('direction', 'vertical');
78
- splitter.style.gridColumn = `1 / -1`;
79
- this.appendChild(splitter);
66
+ mainGrid.appendChild(splitter);
80
67
  }
81
68
  }
69
+
70
+ this.shadowRoot.appendChild(mainGrid);
82
71
  }
83
72
  }
84
73
 
85
- customElements.define('nx-layout', NxLayout);
74
+ customElements.define('nx-layout', NxLayout);