ninegrid2 6.1154.0 → 6.1155.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.
@@ -121946,41 +121946,31 @@ class NxLayout2 extends HTMLElement {
121946
121946
  };
121947
121947
 
121948
121948
  #position = () => {
121949
- // 임시로 숨겨진 요소의 너비를 측정하는 헬퍼 함수
121950
- const getRenderedWidth = (element) => {
121951
- // 요소의 현재 부모 노드를 저장
121952
- const parent = element.parentNode;
121949
+ // 요소를 복제하여 너비를 측정하는 헬퍼 함수
121950
+ const getRenderedWidthWithClone = (element) => {
121951
+ // 1. 요소를 깊은 복제(deep clone)합니다.
121952
+ const clone = element.cloneNode(true);
121953
121953
 
121954
- // 1. 요소를 원래 위치에서 임시로 제거
121955
- parent.removeChild(element);
121954
+ // 2. 복제본을 시각적으로 숨기고 레이아웃에 포함시킬 스타일을 적용합니다.
121955
+ clone.style.position = 'absolute';
121956
+ clone.style.left = '-9999px';
121957
+ clone.style.visibility = 'hidden';
121956
121958
 
121957
- // 2. 요소를 화면 밖으로 이동시킬 스타일을 적용
121958
- element.style.position = 'absolute';
121959
- element.style.left = '-9999px';
121960
- element.style.visibility = 'hidden';
121961
- element.style.display = 'block'; // display:none이 아님을 보장
121962
-
121963
- // 3. body에 임시로 추가하여 렌더링되도록 함
121964
- document.body.appendChild(element);
121959
+ // 3. 복제본을 body에 임시로 추가하여 렌더링되도록 합니다.
121960
+ document.body.appendChild(clone);
121965
121961
 
121966
121962
  // 4. 너비 측정
121967
- const width = element.getBoundingClientRect().width;
121968
-
121969
- // 5. 원래 스타일을 복구
121970
- element.style.position = '';
121971
- element.style.left = '';
121972
- element.style.visibility = '';
121973
- element.style.display = '';
121963
+ const width = clone.getBoundingClientRect().width;
121974
121964
 
121975
- // 6. 요소를 다시 원래 부모의 위치로 복원
121976
- document.body.removeChild(element);
121977
- parent.appendChild(element);
121965
+ // 5. 측정이 끝나면 복제본을 제거합니다.
121966
+ document.body.removeChild(clone);
121978
121967
 
121979
121968
  return width;
121980
121969
  };
121981
121970
 
121982
121971
  const allLabels = [];
121983
121972
 
121973
+ // 모든 .row에서 .label 요소를 찾아서 위치별로 그룹화
121984
121974
  this.querySelectorAll(".row").forEach((el) => {
121985
121975
  const labelsInRow = el.querySelectorAll(".label");
121986
121976
  labelsInRow.forEach((label, index) => {
@@ -121991,10 +121981,11 @@ class NxLayout2 extends HTMLElement {
121991
121981
  });
121992
121982
  });
121993
121983
 
121984
+ // 각 그룹별로 최대 너비를 계산하고 적용
121994
121985
  allLabels.forEach((labelGroup) => {
121995
121986
  if (labelGroup && labelGroup.length > 0) {
121996
121987
  // ⭐⭐ 헬퍼 함수를 사용하여 너비 계산 ⭐⭐
121997
- const renderedWidths = labelGroup.map(label => getRenderedWidth(label));
121988
+ const renderedWidths = labelGroup.map(label => getRenderedWidthWithClone(label));
121998
121989
  const maxWidth = Math.max(...renderedWidths);
121999
121990
 
122000
121991
  labelGroup.forEach(label => {
@@ -121942,41 +121942,31 @@ class NxLayout2 extends HTMLElement {
121942
121942
  };
121943
121943
 
121944
121944
  #position = () => {
121945
- // 임시로 숨겨진 요소의 너비를 측정하는 헬퍼 함수
121946
- const getRenderedWidth = (element) => {
121947
- // 요소의 현재 부모 노드를 저장
121948
- const parent = element.parentNode;
121945
+ // 요소를 복제하여 너비를 측정하는 헬퍼 함수
121946
+ const getRenderedWidthWithClone = (element) => {
121947
+ // 1. 요소를 깊은 복제(deep clone)합니다.
121948
+ const clone = element.cloneNode(true);
121949
121949
 
121950
- // 1. 요소를 원래 위치에서 임시로 제거
121951
- parent.removeChild(element);
121950
+ // 2. 복제본을 시각적으로 숨기고 레이아웃에 포함시킬 스타일을 적용합니다.
121951
+ clone.style.position = 'absolute';
121952
+ clone.style.left = '-9999px';
121953
+ clone.style.visibility = 'hidden';
121952
121954
 
121953
- // 2. 요소를 화면 밖으로 이동시킬 스타일을 적용
121954
- element.style.position = 'absolute';
121955
- element.style.left = '-9999px';
121956
- element.style.visibility = 'hidden';
121957
- element.style.display = 'block'; // display:none이 아님을 보장
121958
-
121959
- // 3. body에 임시로 추가하여 렌더링되도록 함
121960
- document.body.appendChild(element);
121955
+ // 3. 복제본을 body에 임시로 추가하여 렌더링되도록 합니다.
121956
+ document.body.appendChild(clone);
121961
121957
 
121962
121958
  // 4. 너비 측정
121963
- const width = element.getBoundingClientRect().width;
121964
-
121965
- // 5. 원래 스타일을 복구
121966
- element.style.position = '';
121967
- element.style.left = '';
121968
- element.style.visibility = '';
121969
- element.style.display = '';
121959
+ const width = clone.getBoundingClientRect().width;
121970
121960
 
121971
- // 6. 요소를 다시 원래 부모의 위치로 복원
121972
- document.body.removeChild(element);
121973
- parent.appendChild(element);
121961
+ // 5. 측정이 끝나면 복제본을 제거합니다.
121962
+ document.body.removeChild(clone);
121974
121963
 
121975
121964
  return width;
121976
121965
  };
121977
121966
 
121978
121967
  const allLabels = [];
121979
121968
 
121969
+ // 모든 .row에서 .label 요소를 찾아서 위치별로 그룹화
121980
121970
  this.querySelectorAll(".row").forEach((el) => {
121981
121971
  const labelsInRow = el.querySelectorAll(".label");
121982
121972
  labelsInRow.forEach((label, index) => {
@@ -121987,10 +121977,11 @@ class NxLayout2 extends HTMLElement {
121987
121977
  });
121988
121978
  });
121989
121979
 
121980
+ // 각 그룹별로 최대 너비를 계산하고 적용
121990
121981
  allLabels.forEach((labelGroup) => {
121991
121982
  if (labelGroup && labelGroup.length > 0) {
121992
121983
  // ⭐⭐ 헬퍼 함수를 사용하여 너비 계산 ⭐⭐
121993
- const renderedWidths = labelGroup.map(label => getRenderedWidth(label));
121984
+ const renderedWidths = labelGroup.map(label => getRenderedWidthWithClone(label));
121994
121985
  const maxWidth = Math.max(...renderedWidths);
121995
121986
 
121996
121987
  labelGroup.forEach(label => {
@@ -59,41 +59,31 @@ class NxLayout2 extends HTMLElement {
59
59
  };
60
60
 
61
61
  #position = () => {
62
- // 임시로 숨겨진 요소의 너비를 측정하는 헬퍼 함수
63
- const getRenderedWidth = (element) => {
64
- // 요소의 현재 부모 노드를 저장
65
- const parent = element.parentNode;
62
+ // 요소를 복제하여 너비를 측정하는 헬퍼 함수
63
+ const getRenderedWidthWithClone = (element) => {
64
+ // 1. 요소를 깊은 복제(deep clone)합니다.
65
+ const clone = element.cloneNode(true);
66
66
 
67
- // 1. 요소를 원래 위치에서 임시로 제거
68
- parent.removeChild(element);
67
+ // 2. 복제본을 시각적으로 숨기고 레이아웃에 포함시킬 스타일을 적용합니다.
68
+ clone.style.position = 'absolute';
69
+ clone.style.left = '-9999px';
70
+ clone.style.visibility = 'hidden';
69
71
 
70
- // 2. 요소를 화면 밖으로 이동시킬 스타일을 적용
71
- element.style.position = 'absolute';
72
- element.style.left = '-9999px';
73
- element.style.visibility = 'hidden';
74
- element.style.display = 'block'; // display:none이 아님을 보장
75
-
76
- // 3. body에 임시로 추가하여 렌더링되도록 함
77
- document.body.appendChild(element);
72
+ // 3. 복제본을 body에 임시로 추가하여 렌더링되도록 합니다.
73
+ document.body.appendChild(clone);
78
74
 
79
75
  // 4. 너비 측정
80
- const width = element.getBoundingClientRect().width;
81
-
82
- // 5. 원래 스타일을 복구
83
- element.style.position = '';
84
- element.style.left = '';
85
- element.style.visibility = '';
86
- element.style.display = '';
76
+ const width = clone.getBoundingClientRect().width;
87
77
 
88
- // 6. 요소를 다시 원래 부모의 위치로 복원
89
- document.body.removeChild(element);
90
- parent.appendChild(element);
78
+ // 5. 측정이 끝나면 복제본을 제거합니다.
79
+ document.body.removeChild(clone);
91
80
 
92
81
  return width;
93
82
  };
94
83
 
95
84
  const allLabels = [];
96
85
 
86
+ // 모든 .row에서 .label 요소를 찾아서 위치별로 그룹화
97
87
  this.querySelectorAll(".row").forEach((el) => {
98
88
  const labelsInRow = el.querySelectorAll(".label");
99
89
  labelsInRow.forEach((label, index) => {
@@ -104,10 +94,11 @@ class NxLayout2 extends HTMLElement {
104
94
  });
105
95
  });
106
96
 
97
+ // 각 그룹별로 최대 너비를 계산하고 적용
107
98
  allLabels.forEach((labelGroup) => {
108
99
  if (labelGroup && labelGroup.length > 0) {
109
100
  // ⭐⭐ 헬퍼 함수를 사용하여 너비 계산 ⭐⭐
110
- const renderedWidths = labelGroup.map(label => getRenderedWidth(label));
101
+ const renderedWidths = labelGroup.map(label => getRenderedWidthWithClone(label));
111
102
  const maxWidth = Math.max(...renderedWidths);
112
103
 
113
104
  labelGroup.forEach(label => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1154.0",
4
+ "version": "6.1155.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -59,41 +59,31 @@ class NxLayout2 extends HTMLElement {
59
59
  };
60
60
 
61
61
  #position = () => {
62
- // 임시로 숨겨진 요소의 너비를 측정하는 헬퍼 함수
63
- const getRenderedWidth = (element) => {
64
- // 요소의 현재 부모 노드를 저장
65
- const parent = element.parentNode;
62
+ // 요소를 복제하여 너비를 측정하는 헬퍼 함수
63
+ const getRenderedWidthWithClone = (element) => {
64
+ // 1. 요소를 깊은 복제(deep clone)합니다.
65
+ const clone = element.cloneNode(true);
66
66
 
67
- // 1. 요소를 원래 위치에서 임시로 제거
68
- parent.removeChild(element);
67
+ // 2. 복제본을 시각적으로 숨기고 레이아웃에 포함시킬 스타일을 적용합니다.
68
+ clone.style.position = 'absolute';
69
+ clone.style.left = '-9999px';
70
+ clone.style.visibility = 'hidden';
69
71
 
70
- // 2. 요소를 화면 밖으로 이동시킬 스타일을 적용
71
- element.style.position = 'absolute';
72
- element.style.left = '-9999px';
73
- element.style.visibility = 'hidden';
74
- element.style.display = 'block'; // display:none이 아님을 보장
75
-
76
- // 3. body에 임시로 추가하여 렌더링되도록 함
77
- document.body.appendChild(element);
72
+ // 3. 복제본을 body에 임시로 추가하여 렌더링되도록 합니다.
73
+ document.body.appendChild(clone);
78
74
 
79
75
  // 4. 너비 측정
80
- const width = element.getBoundingClientRect().width;
81
-
82
- // 5. 원래 스타일을 복구
83
- element.style.position = '';
84
- element.style.left = '';
85
- element.style.visibility = '';
86
- element.style.display = '';
76
+ const width = clone.getBoundingClientRect().width;
87
77
 
88
- // 6. 요소를 다시 원래 부모의 위치로 복원
89
- document.body.removeChild(element);
90
- parent.appendChild(element);
78
+ // 5. 측정이 끝나면 복제본을 제거합니다.
79
+ document.body.removeChild(clone);
91
80
 
92
81
  return width;
93
82
  };
94
83
 
95
84
  const allLabels = [];
96
85
 
86
+ // 모든 .row에서 .label 요소를 찾아서 위치별로 그룹화
97
87
  this.querySelectorAll(".row").forEach((el) => {
98
88
  const labelsInRow = el.querySelectorAll(".label");
99
89
  labelsInRow.forEach((label, index) => {
@@ -104,10 +94,11 @@ class NxLayout2 extends HTMLElement {
104
94
  });
105
95
  });
106
96
 
97
+ // 각 그룹별로 최대 너비를 계산하고 적용
107
98
  allLabels.forEach((labelGroup) => {
108
99
  if (labelGroup && labelGroup.length > 0) {
109
100
  // ⭐⭐ 헬퍼 함수를 사용하여 너비 계산 ⭐⭐
110
- const renderedWidths = labelGroup.map(label => getRenderedWidth(label));
101
+ const renderedWidths = labelGroup.map(label => getRenderedWidthWithClone(label));
111
102
  const maxWidth = Math.max(...renderedWidths);
112
103
 
113
104
  labelGroup.forEach(label => {