ninegrid2 6.976.0 → 6.978.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.
@@ -121902,7 +121902,9 @@ class NxLayout extends HTMLElement {
121902
121902
 
121903
121903
  attributeChangedCallback(name, oldValue, newValue) {
121904
121904
  // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121905
- //this.#render();
121905
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121906
+ this.#render();
121907
+ }
121906
121908
  }
121907
121909
 
121908
121910
  static get observedAttributes() {
@@ -121910,89 +121912,58 @@ class NxLayout extends HTMLElement {
121910
121912
  }
121911
121913
 
121912
121914
  #render() {
121913
- // 이전 콘텐츠를 모두 제거합니다.
121914
- console.log("====================");
121915
-
121916
121915
  const children = Array.from(this.children);
121916
+ if (children.length === 0) return;
121917
121917
 
121918
- if (children.length <= 0) return;
121919
-
121920
- //this.innerHTML = '';
121921
121918
  // 기존 자식 노드를 안전하게 제거합니다.
121922
121919
  while (this.firstChild) {
121923
121920
  this.removeChild(this.firstChild);
121924
121921
  }
121925
121922
 
121926
- const numColumns = Number(this.getAttribute('columns') || "1");
121927
- const numRows = Number(this.getAttribute('rows') || "1");
121928
-
121929
-
121930
-
121923
+ const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121924
+ const numRows = columnsLayout.length;
121931
121925
 
121926
+ console.log(columnsLayout);
121932
121927
 
121933
-
121934
- // CSS Grid 컨테이너 스타일 설정
121935
- let gridColumns = '';
121928
+ // CSS Grid 템플릿 설정
121936
121929
  let gridRows = '';
121937
-
121938
- for (let i = 0; i < numColumns; i++) {
121939
- gridColumns += '1fr ';
121940
- if (i < numColumns - 1) {
121941
- gridColumns += '8px '; // 스플리터 너비
121942
- }
121943
- }
121944
-
121945
121930
  for (let i = 0; i < numRows; i++) {
121946
121931
  gridRows += '1fr ';
121947
121932
  if (i < numRows - 1) {
121948
- gridRows += '8px '; // 스플리터 높이
121933
+ gridRows += '8px '; // 세로 스플리터 높이
121949
121934
  }
121950
121935
  }
121951
121936
 
121952
121937
  this.style.display = 'grid';
121953
121938
  this.style.width = '100%';
121954
121939
  this.style.height = '100%';
121955
- this.style.gridTemplateColumns = gridColumns.trim();
121956
121940
  this.style.gridTemplateRows = gridRows.trim();
121957
121941
 
121958
-
121959
-
121960
- // 자식 요소를 다시 추가하고 스플리터 삽입
121961
- const renderedLayout = [];
121962
- let childIndex = 0;
121942
+ // 자식 요소와 스플리터 배치
121943
+ let renderedIndex = 0;
121963
121944
 
121964
121945
  for (let row = 0; row < numRows; row++) {
121965
- for (let col = 0; col < numColumns; col++) {
121966
-
121967
- console.log(row, col, childIndex);
121946
+ const numColumns = columnsLayout[row];
121947
+ let rowContent = document.createElement('div');
121948
+ rowContent.style.display = 'grid';
121949
+ rowContent.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121950
+ rowContent.style.gap = '8px';
121968
121951
 
121969
- if (children[childIndex]) {
121970
-
121971
- console.log(children[childIndex]);
121972
-
121973
- const childWrapper = document.createElement('div');
121974
- childWrapper.style.width = '100%';
121975
- childWrapper.style.height = '100%';
121976
- childWrapper.appendChild(children[childIndex]);
121977
- renderedLayout.push(childWrapper);
121978
- childIndex++;
121979
- }
121980
-
121981
- if (col < numColumns - 1) {
121982
- const splitter = document.createElement('nx-splitter');
121983
- splitter.setAttribute('direction', 'horizontal');
121984
- renderedLayout.push(splitter);
121952
+ for (let col = 0; col < numColumns; col++) {
121953
+ if (children[renderedIndex]) {
121954
+ rowContent.appendChild(children[renderedIndex]);
121955
+ renderedIndex++;
121985
121956
  }
121986
121957
  }
121958
+
121959
+ this.appendChild(rowContent);
121960
+
121987
121961
  if (row < numRows - 1) {
121988
121962
  const splitter = document.createElement('nx-splitter');
121989
121963
  splitter.setAttribute('direction', 'vertical');
121990
- splitter.style.gridColumn = `span ${numColumns * 2 - 1}`;
121991
- renderedLayout.push(splitter);
121964
+ this.appendChild(splitter);
121992
121965
  }
121993
121966
  }
121994
-
121995
- renderedLayout.forEach(el => this.appendChild(el));
121996
121967
  }
121997
121968
  }
121998
121969
 
@@ -121898,7 +121898,9 @@ class NxLayout extends HTMLElement {
121898
121898
 
121899
121899
  attributeChangedCallback(name, oldValue, newValue) {
121900
121900
  // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
121901
- //this.#render();
121901
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
121902
+ this.#render();
121903
+ }
121902
121904
  }
121903
121905
 
121904
121906
  static get observedAttributes() {
@@ -121906,89 +121908,58 @@ class NxLayout extends HTMLElement {
121906
121908
  }
121907
121909
 
121908
121910
  #render() {
121909
- // 이전 콘텐츠를 모두 제거합니다.
121910
- console.log("====================");
121911
-
121912
121911
  const children = Array.from(this.children);
121912
+ if (children.length === 0) return;
121913
121913
 
121914
- if (children.length <= 0) return;
121915
-
121916
- //this.innerHTML = '';
121917
121914
  // 기존 자식 노드를 안전하게 제거합니다.
121918
121915
  while (this.firstChild) {
121919
121916
  this.removeChild(this.firstChild);
121920
121917
  }
121921
121918
 
121922
- const numColumns = Number(this.getAttribute('columns') || "1");
121923
- const numRows = Number(this.getAttribute('rows') || "1");
121924
-
121925
-
121926
-
121919
+ const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
121920
+ const numRows = columnsLayout.length;
121927
121921
 
121922
+ console.log(columnsLayout);
121928
121923
 
121929
-
121930
- // CSS Grid 컨테이너 스타일 설정
121931
- let gridColumns = '';
121924
+ // CSS Grid 템플릿 설정
121932
121925
  let gridRows = '';
121933
-
121934
- for (let i = 0; i < numColumns; i++) {
121935
- gridColumns += '1fr ';
121936
- if (i < numColumns - 1) {
121937
- gridColumns += '8px '; // 스플리터 너비
121938
- }
121939
- }
121940
-
121941
121926
  for (let i = 0; i < numRows; i++) {
121942
121927
  gridRows += '1fr ';
121943
121928
  if (i < numRows - 1) {
121944
- gridRows += '8px '; // 스플리터 높이
121929
+ gridRows += '8px '; // 세로 스플리터 높이
121945
121930
  }
121946
121931
  }
121947
121932
 
121948
121933
  this.style.display = 'grid';
121949
121934
  this.style.width = '100%';
121950
121935
  this.style.height = '100%';
121951
- this.style.gridTemplateColumns = gridColumns.trim();
121952
121936
  this.style.gridTemplateRows = gridRows.trim();
121953
121937
 
121954
-
121955
-
121956
- // 자식 요소를 다시 추가하고 스플리터 삽입
121957
- const renderedLayout = [];
121958
- let childIndex = 0;
121938
+ // 자식 요소와 스플리터 배치
121939
+ let renderedIndex = 0;
121959
121940
 
121960
121941
  for (let row = 0; row < numRows; row++) {
121961
- for (let col = 0; col < numColumns; col++) {
121962
-
121963
- console.log(row, col, childIndex);
121942
+ const numColumns = columnsLayout[row];
121943
+ let rowContent = document.createElement('div');
121944
+ rowContent.style.display = 'grid';
121945
+ rowContent.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
121946
+ rowContent.style.gap = '8px';
121964
121947
 
121965
- if (children[childIndex]) {
121966
-
121967
- console.log(children[childIndex]);
121968
-
121969
- const childWrapper = document.createElement('div');
121970
- childWrapper.style.width = '100%';
121971
- childWrapper.style.height = '100%';
121972
- childWrapper.appendChild(children[childIndex]);
121973
- renderedLayout.push(childWrapper);
121974
- childIndex++;
121975
- }
121976
-
121977
- if (col < numColumns - 1) {
121978
- const splitter = document.createElement('nx-splitter');
121979
- splitter.setAttribute('direction', 'horizontal');
121980
- renderedLayout.push(splitter);
121948
+ for (let col = 0; col < numColumns; col++) {
121949
+ if (children[renderedIndex]) {
121950
+ rowContent.appendChild(children[renderedIndex]);
121951
+ renderedIndex++;
121981
121952
  }
121982
121953
  }
121954
+
121955
+ this.appendChild(rowContent);
121956
+
121983
121957
  if (row < numRows - 1) {
121984
121958
  const splitter = document.createElement('nx-splitter');
121985
121959
  splitter.setAttribute('direction', 'vertical');
121986
- splitter.style.gridColumn = `span ${numColumns * 2 - 1}`;
121987
- renderedLayout.push(splitter);
121960
+ this.appendChild(splitter);
121988
121961
  }
121989
121962
  }
121990
-
121991
- renderedLayout.forEach(el => this.appendChild(el));
121992
121963
  }
121993
121964
  }
121994
121965
 
@@ -7,7 +7,9 @@ class NxLayout extends HTMLElement {
7
7
 
8
8
  attributeChangedCallback(name, oldValue, newValue) {
9
9
  // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
- //this.#render();
10
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
11
+ this.#render();
12
+ }
11
13
  }
12
14
 
13
15
  static get observedAttributes() {
@@ -15,89 +17,58 @@ class NxLayout extends HTMLElement {
15
17
  }
16
18
 
17
19
  #render() {
18
- // 이전 콘텐츠를 모두 제거합니다.
19
- console.log("====================");
20
-
21
20
  const children = Array.from(this.children);
21
+ if (children.length === 0) return;
22
22
 
23
- if (children.length <= 0) return;
24
-
25
- //this.innerHTML = '';
26
23
  // 기존 자식 노드를 안전하게 제거합니다.
27
24
  while (this.firstChild) {
28
25
  this.removeChild(this.firstChild);
29
26
  }
30
27
 
31
- const numColumns = Number(this.getAttribute('columns') || "1");
32
- const numRows = Number(this.getAttribute('rows') || "1");
33
-
34
-
35
-
28
+ const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
29
+ const numRows = columnsLayout.length;
36
30
 
31
+ console.log(columnsLayout);
37
32
 
38
-
39
- // CSS Grid 컨테이너 스타일 설정
40
- let gridColumns = '';
33
+ // CSS Grid 템플릿 설정
41
34
  let gridRows = '';
42
-
43
- for (let i = 0; i < numColumns; i++) {
44
- gridColumns += '1fr ';
45
- if (i < numColumns - 1) {
46
- gridColumns += '8px '; // 스플리터 너비
47
- }
48
- }
49
-
50
35
  for (let i = 0; i < numRows; i++) {
51
36
  gridRows += '1fr ';
52
37
  if (i < numRows - 1) {
53
- gridRows += '8px '; // 스플리터 높이
38
+ gridRows += '8px '; // 세로 스플리터 높이
54
39
  }
55
40
  }
56
41
 
57
42
  this.style.display = 'grid';
58
43
  this.style.width = '100%';
59
44
  this.style.height = '100%';
60
- this.style.gridTemplateColumns = gridColumns.trim();
61
45
  this.style.gridTemplateRows = gridRows.trim();
62
46
 
63
-
64
-
65
- // 자식 요소를 다시 추가하고 스플리터 삽입
66
- const renderedLayout = [];
67
- let childIndex = 0;
47
+ // 자식 요소와 스플리터 배치
48
+ let renderedIndex = 0;
68
49
 
69
50
  for (let row = 0; row < numRows; row++) {
70
- for (let col = 0; col < numColumns; col++) {
71
-
72
- console.log(row, col, childIndex);
51
+ const numColumns = columnsLayout[row];
52
+ let rowContent = document.createElement('div');
53
+ rowContent.style.display = 'grid';
54
+ rowContent.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
55
+ rowContent.style.gap = '8px';
73
56
 
74
- if (children[childIndex]) {
75
-
76
- console.log(children[childIndex]);
77
-
78
- const childWrapper = document.createElement('div');
79
- childWrapper.style.width = '100%';
80
- childWrapper.style.height = '100%';
81
- childWrapper.appendChild(children[childIndex]);
82
- renderedLayout.push(childWrapper);
83
- childIndex++;
84
- }
85
-
86
- if (col < numColumns - 1) {
87
- const splitter = document.createElement('nx-splitter');
88
- splitter.setAttribute('direction', 'horizontal');
89
- renderedLayout.push(splitter);
57
+ for (let col = 0; col < numColumns; col++) {
58
+ if (children[renderedIndex]) {
59
+ rowContent.appendChild(children[renderedIndex]);
60
+ renderedIndex++;
90
61
  }
91
62
  }
63
+
64
+ this.appendChild(rowContent);
65
+
92
66
  if (row < numRows - 1) {
93
67
  const splitter = document.createElement('nx-splitter');
94
68
  splitter.setAttribute('direction', 'vertical');
95
- splitter.style.gridColumn = `span ${numColumns * 2 - 1}`;
96
- renderedLayout.push(splitter);
69
+ this.appendChild(splitter);
97
70
  }
98
71
  }
99
-
100
- renderedLayout.forEach(el => this.appendChild(el));
101
72
  }
102
73
  }
103
74
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.976.0",
4
+ "version": "6.978.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -7,7 +7,9 @@ class NxLayout extends HTMLElement {
7
7
 
8
8
  attributeChangedCallback(name, oldValue, newValue) {
9
9
  // 속성이 변경되면 레이아웃을 다시 렌더링합니다.
10
- //this.#render();
10
+ if (oldValue !== newValue) { // 값 변경이 있을 때만 실행하는 것이 효율적
11
+ this.#render();
12
+ }
11
13
  }
12
14
 
13
15
  static get observedAttributes() {
@@ -15,89 +17,58 @@ class NxLayout extends HTMLElement {
15
17
  }
16
18
 
17
19
  #render() {
18
- // 이전 콘텐츠를 모두 제거합니다.
19
- console.log("====================");
20
-
21
20
  const children = Array.from(this.children);
21
+ if (children.length === 0) return;
22
22
 
23
- if (children.length <= 0) return;
24
-
25
- //this.innerHTML = '';
26
23
  // 기존 자식 노드를 안전하게 제거합니다.
27
24
  while (this.firstChild) {
28
25
  this.removeChild(this.firstChild);
29
26
  }
30
27
 
31
- const numColumns = Number(this.getAttribute('columns') || "1");
32
- const numRows = Number(this.getAttribute('rows') || "1");
33
-
34
-
35
-
28
+ const columnsLayout = (this.getAttribute('columns') || '1').split(',').map(Number);
29
+ const numRows = columnsLayout.length;
36
30
 
31
+ console.log(columnsLayout);
37
32
 
38
-
39
- // CSS Grid 컨테이너 스타일 설정
40
- let gridColumns = '';
33
+ // CSS Grid 템플릿 설정
41
34
  let gridRows = '';
42
-
43
- for (let i = 0; i < numColumns; i++) {
44
- gridColumns += '1fr ';
45
- if (i < numColumns - 1) {
46
- gridColumns += '8px '; // 스플리터 너비
47
- }
48
- }
49
-
50
35
  for (let i = 0; i < numRows; i++) {
51
36
  gridRows += '1fr ';
52
37
  if (i < numRows - 1) {
53
- gridRows += '8px '; // 스플리터 높이
38
+ gridRows += '8px '; // 세로 스플리터 높이
54
39
  }
55
40
  }
56
41
 
57
42
  this.style.display = 'grid';
58
43
  this.style.width = '100%';
59
44
  this.style.height = '100%';
60
- this.style.gridTemplateColumns = gridColumns.trim();
61
45
  this.style.gridTemplateRows = gridRows.trim();
62
46
 
63
-
64
-
65
- // 자식 요소를 다시 추가하고 스플리터 삽입
66
- const renderedLayout = [];
67
- let childIndex = 0;
47
+ // 자식 요소와 스플리터 배치
48
+ let renderedIndex = 0;
68
49
 
69
50
  for (let row = 0; row < numRows; row++) {
70
- for (let col = 0; col < numColumns; col++) {
71
-
72
- console.log(row, col, childIndex);
51
+ const numColumns = columnsLayout[row];
52
+ let rowContent = document.createElement('div');
53
+ rowContent.style.display = 'grid';
54
+ rowContent.style.gridTemplateColumns = `repeat(${numColumns}, 1fr)`;
55
+ rowContent.style.gap = '8px';
73
56
 
74
- if (children[childIndex]) {
75
-
76
- console.log(children[childIndex]);
77
-
78
- const childWrapper = document.createElement('div');
79
- childWrapper.style.width = '100%';
80
- childWrapper.style.height = '100%';
81
- childWrapper.appendChild(children[childIndex]);
82
- renderedLayout.push(childWrapper);
83
- childIndex++;
84
- }
85
-
86
- if (col < numColumns - 1) {
87
- const splitter = document.createElement('nx-splitter');
88
- splitter.setAttribute('direction', 'horizontal');
89
- renderedLayout.push(splitter);
57
+ for (let col = 0; col < numColumns; col++) {
58
+ if (children[renderedIndex]) {
59
+ rowContent.appendChild(children[renderedIndex]);
60
+ renderedIndex++;
90
61
  }
91
62
  }
63
+
64
+ this.appendChild(rowContent);
65
+
92
66
  if (row < numRows - 1) {
93
67
  const splitter = document.createElement('nx-splitter');
94
68
  splitter.setAttribute('direction', 'vertical');
95
- splitter.style.gridColumn = `span ${numColumns * 2 - 1}`;
96
- renderedLayout.push(splitter);
69
+ this.appendChild(splitter);
97
70
  }
98
71
  }
99
-
100
- renderedLayout.forEach(el => this.appendChild(el));
101
72
  }
102
73
  }
103
74