ninegrid2 6.1250.0 → 6.1252.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.
@@ -121838,48 +121838,33 @@ class nxTitle extends HTMLElement {
121838
121838
 
121839
121839
  customElements.define("nx-title", nxTitle);
121840
121840
 
121841
- class nxDiv extends HTMLElement {
121841
+ class nxDiv extends HTMLElement
121842
+ {
121842
121843
  originContents;
121843
121844
  #isInitialized = false;
121844
- #root; // Shadow DOM 사용 여부에 따라 shadowRoot 또는 this를 가리킴
121845
121845
 
121846
- constructor() {
121846
+ constructor () {
121847
121847
  super();
121848
- // 1. 'use-shadow' 속성이 "false"가 아니면 기본적으로 Shadow DOM을 사용하도록 설정
121849
- const useShadow = this.getAttribute("use-shadow") !== "false";
121850
-
121851
- if (useShadow) {
121852
- this.attachShadow({ mode: 'open' });
121853
- this.#root = this.shadowRoot;
121854
- } else {
121855
- this.#root = this;
121856
- }
121848
+ this.attachShadow({ mode: 'open' });
121857
121849
  }
121858
121850
 
121859
121851
  connectedCallback() {
121860
121852
  if (!this.#isInitialized) {
121861
121853
  this.#init();
121862
- this.#isInitialized = true;
121854
+ this.#isInitialized = true; // 3. 초기화 후 플래그를 true로 변경합니다.
121863
121855
  return true;
121864
121856
  }
121865
- return false;
121866
- }
121867
-
121868
- // 공통 쿼리 함수: 현재 root(Shadow 또는 Light DOM)에서 요소를 찾음
121869
- #getElements() {
121870
- return ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.#root);
121871
- }
121872
121857
 
121873
- // 자식 클래스에서 접근할 수 있도록 getter 제공
121874
- get root() {
121875
- return this.#root;
121858
+ return false;
121876
121859
  }
121877
121860
 
121878
121861
  getData = () => {
121879
121862
  const jsonData = {};
121880
- this.#getElements().forEach(el => {
121863
+
121864
+ // Shadow DOM 내의 폼 요소만 선택
121865
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121881
121866
  const key = el.name;
121882
- if (!key) return;
121867
+ if (!key) return; // name이 없는 요소는 건너뜁니다.
121883
121868
 
121884
121869
  let value;
121885
121870
  if (el.tagName === "INPUT" && (el.type === "checkbox" || el.type === "radio")) {
@@ -121888,40 +121873,50 @@ class nxDiv extends HTMLElement {
121888
121873
  value = el.value;
121889
121874
  }
121890
121875
 
121876
+ // 중복 name을 대비한 배열 처리
121891
121877
  if (jsonData[key]) {
121892
- if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
121878
+ if (!Array.isArray(jsonData[key])) {
121879
+ jsonData[key] = [jsonData[key]];
121880
+ }
121893
121881
  jsonData[key].push(value);
121894
121882
  } else {
121895
121883
  jsonData[key] = value;
121896
121884
  }
121897
121885
  });
121886
+
121898
121887
  return jsonData;
121899
121888
  };
121900
121889
 
121901
121890
  setData = (jsonData) => {
121902
- this.#getElements().forEach(el => {
121891
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121892
+ console.log("------", el);
121903
121893
  el.removeEventListener("input", this.#changeHandler);
121904
121894
  el.addEventListener("input", this.#changeHandler);
121905
121895
  });
121906
121896
 
121907
- if (!jsonData || typeof jsonData !== 'object') return;
121897
+ if (!jsonData || typeof jsonData !== 'object') {
121898
+ console.error("setData: Invalid data provided. Expected an object.");
121899
+ return;
121900
+ }
121908
121901
 
121909
121902
  let bChanged = false;
121910
- this.#getElements().forEach(el => {
121903
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121911
121904
  const key = el.name;
121912
121905
  if (!key || !jsonData.hasOwnProperty(key)) return;
121913
121906
 
121914
121907
  const value = jsonData[key];
121908
+
121909
+ // 폼 요소에만 데이터를 설정합니다.
121915
121910
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
121916
121911
  if (el.type === "checkbox" || el.type === "radio") {
121917
- const isChecked = (String(el.value) === String(value));
121918
- if (el.checked !== isChecked) bChanged = true;
121919
- el.checked = isChecked;
121912
+ if (el.checked !== (el.value === String(value))) bChanged = true;
121913
+ el.checked = (el.value === String(value));
121920
121914
  } else {
121921
121915
  if (el.value !== value) bChanged = true;
121922
121916
  el.value = value;
121923
121917
  }
121924
121918
  } else {
121919
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
121925
121920
  if (el.textContent !== value) bChanged = true;
121926
121921
  el.textContent = value;
121927
121922
  }
@@ -121948,22 +121943,22 @@ class nxDiv extends HTMLElement {
121948
121943
  }
121949
121944
 
121950
121945
  #init = () => {
121951
- // CSS Style 적용
121946
+
121947
+ //console.log(this);
121948
+ //console.log(this.querySelectorAll("input[name], textarea[name], select[name]"));
121949
+
121950
+ /**
121951
+ * css style 적용
121952
+ */
121952
121953
  for (const attr of this.attributes) {
121953
121954
  if (attr.name.startsWith("css-")) {
121955
+ // "css-" 접두사를 제거하고 CSS 속성명으로 변환
121954
121956
  this.style.setProperty(attr.name.substring(4), attr.value);
121955
121957
  }
121956
121958
  }
121957
121959
 
121958
- // 2. HTML 내용 처리
121959
121960
  this.originContents = this.innerHTML.trim();
121960
-
121961
- // Shadow DOM을 사용할 경우 내용을 안으로 옮김
121962
- if (this.shadowRoot) {
121963
- this.shadowRoot.innerHTML = this.originContents;
121964
- this.innerHTML = ""; // 외부(Light DOM) 내용은 비움
121965
- }
121966
- // Shadow DOM을 안 쓰면 그대로 유지 (this.#root가 this이므로 별도 처리 불필요)
121961
+ this.innerHTML = ""; // 기존 내부 HTML 제거
121967
121962
  };
121968
121963
  }
121969
121964
 
@@ -122266,7 +122261,7 @@ class nxButtons extends nxDiv {
122266
122261
  ${ninegrid.getCustomPath(this, "nxButtons.css")}
122267
122262
  </style>
122268
122263
  `;
122269
- console.log("11111");
122264
+
122270
122265
  const htmlTmpl = document.createElement("template");
122271
122266
 
122272
122267
  // Shadow DOM일 때는 originContents를 옮겨야 하고,
@@ -121834,48 +121834,33 @@ class nxTitle extends HTMLElement {
121834
121834
 
121835
121835
  customElements.define("nx-title", nxTitle);
121836
121836
 
121837
- class nxDiv extends HTMLElement {
121837
+ class nxDiv extends HTMLElement
121838
+ {
121838
121839
  originContents;
121839
121840
  #isInitialized = false;
121840
- #root; // Shadow DOM 사용 여부에 따라 shadowRoot 또는 this를 가리킴
121841
121841
 
121842
- constructor() {
121842
+ constructor () {
121843
121843
  super();
121844
- // 1. 'use-shadow' 속성이 "false"가 아니면 기본적으로 Shadow DOM을 사용하도록 설정
121845
- const useShadow = this.getAttribute("use-shadow") !== "false";
121846
-
121847
- if (useShadow) {
121848
- this.attachShadow({ mode: 'open' });
121849
- this.#root = this.shadowRoot;
121850
- } else {
121851
- this.#root = this;
121852
- }
121844
+ this.attachShadow({ mode: 'open' });
121853
121845
  }
121854
121846
 
121855
121847
  connectedCallback() {
121856
121848
  if (!this.#isInitialized) {
121857
121849
  this.#init();
121858
- this.#isInitialized = true;
121850
+ this.#isInitialized = true; // 3. 초기화 후 플래그를 true로 변경합니다.
121859
121851
  return true;
121860
121852
  }
121861
- return false;
121862
- }
121863
-
121864
- // 공통 쿼리 함수: 현재 root(Shadow 또는 Light DOM)에서 요소를 찾음
121865
- #getElements() {
121866
- return ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.#root);
121867
- }
121868
121853
 
121869
- // 자식 클래스에서 접근할 수 있도록 getter 제공
121870
- get root() {
121871
- return this.#root;
121854
+ return false;
121872
121855
  }
121873
121856
 
121874
121857
  getData = () => {
121875
121858
  const jsonData = {};
121876
- this.#getElements().forEach(el => {
121859
+
121860
+ // Shadow DOM 내의 폼 요소만 선택
121861
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121877
121862
  const key = el.name;
121878
- if (!key) return;
121863
+ if (!key) return; // name이 없는 요소는 건너뜁니다.
121879
121864
 
121880
121865
  let value;
121881
121866
  if (el.tagName === "INPUT" && (el.type === "checkbox" || el.type === "radio")) {
@@ -121884,40 +121869,50 @@ class nxDiv extends HTMLElement {
121884
121869
  value = el.value;
121885
121870
  }
121886
121871
 
121872
+ // 중복 name을 대비한 배열 처리
121887
121873
  if (jsonData[key]) {
121888
- if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
121874
+ if (!Array.isArray(jsonData[key])) {
121875
+ jsonData[key] = [jsonData[key]];
121876
+ }
121889
121877
  jsonData[key].push(value);
121890
121878
  } else {
121891
121879
  jsonData[key] = value;
121892
121880
  }
121893
121881
  });
121882
+
121894
121883
  return jsonData;
121895
121884
  };
121896
121885
 
121897
121886
  setData = (jsonData) => {
121898
- this.#getElements().forEach(el => {
121887
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121888
+ console.log("------", el);
121899
121889
  el.removeEventListener("input", this.#changeHandler);
121900
121890
  el.addEventListener("input", this.#changeHandler);
121901
121891
  });
121902
121892
 
121903
- if (!jsonData || typeof jsonData !== 'object') return;
121893
+ if (!jsonData || typeof jsonData !== 'object') {
121894
+ console.error("setData: Invalid data provided. Expected an object.");
121895
+ return;
121896
+ }
121904
121897
 
121905
121898
  let bChanged = false;
121906
- this.#getElements().forEach(el => {
121899
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
121907
121900
  const key = el.name;
121908
121901
  if (!key || !jsonData.hasOwnProperty(key)) return;
121909
121902
 
121910
121903
  const value = jsonData[key];
121904
+
121905
+ // 폼 요소에만 데이터를 설정합니다.
121911
121906
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
121912
121907
  if (el.type === "checkbox" || el.type === "radio") {
121913
- const isChecked = (String(el.value) === String(value));
121914
- if (el.checked !== isChecked) bChanged = true;
121915
- el.checked = isChecked;
121908
+ if (el.checked !== (el.value === String(value))) bChanged = true;
121909
+ el.checked = (el.value === String(value));
121916
121910
  } else {
121917
121911
  if (el.value !== value) bChanged = true;
121918
121912
  el.value = value;
121919
121913
  }
121920
121914
  } else {
121915
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
121921
121916
  if (el.textContent !== value) bChanged = true;
121922
121917
  el.textContent = value;
121923
121918
  }
@@ -121944,22 +121939,22 @@ class nxDiv extends HTMLElement {
121944
121939
  }
121945
121940
 
121946
121941
  #init = () => {
121947
- // CSS Style 적용
121942
+
121943
+ //console.log(this);
121944
+ //console.log(this.querySelectorAll("input[name], textarea[name], select[name]"));
121945
+
121946
+ /**
121947
+ * css style 적용
121948
+ */
121948
121949
  for (const attr of this.attributes) {
121949
121950
  if (attr.name.startsWith("css-")) {
121951
+ // "css-" 접두사를 제거하고 CSS 속성명으로 변환
121950
121952
  this.style.setProperty(attr.name.substring(4), attr.value);
121951
121953
  }
121952
121954
  }
121953
121955
 
121954
- // 2. HTML 내용 처리
121955
121956
  this.originContents = this.innerHTML.trim();
121956
-
121957
- // Shadow DOM을 사용할 경우 내용을 안으로 옮김
121958
- if (this.shadowRoot) {
121959
- this.shadowRoot.innerHTML = this.originContents;
121960
- this.innerHTML = ""; // 외부(Light DOM) 내용은 비움
121961
- }
121962
- // Shadow DOM을 안 쓰면 그대로 유지 (this.#root가 this이므로 별도 처리 불필요)
121957
+ this.innerHTML = ""; // 기존 내부 HTML 제거
121963
121958
  };
121964
121959
  }
121965
121960
 
@@ -122262,7 +122257,7 @@ class nxButtons extends nxDiv {
122262
122257
  ${ninegrid.getCustomPath(this, "nxButtons.css")}
122263
122258
  </style>
122264
122259
  `;
122265
- console.log("11111");
122260
+
122266
122261
  const htmlTmpl = document.createElement("template");
122267
122262
 
122268
122263
  // Shadow DOM일 때는 originContents를 옮겨야 하고,
package/dist/nx/_nxDiv.js CHANGED
@@ -1,47 +1,32 @@
1
1
  import ninegrid from "../index.js";
2
2
 
3
- export class nxDiv extends HTMLElement {
3
+ export class nxDiv extends HTMLElement
4
+ {
4
5
  originContents;
5
6
  #isInitialized = false;
6
- #root; // Shadow DOM 사용 여부에 따라 shadowRoot 또는 this를 가리킴
7
7
 
8
- constructor() {
8
+ constructor () {
9
9
  super();
10
- // 1. 'use-shadow' 속성이 "false"가 아니면 기본적으로 Shadow DOM을 사용하도록 설정
11
- const useShadow = this.getAttribute("use-shadow") !== "false";
12
-
13
- if (useShadow) {
14
- this.attachShadow({ mode: 'open' });
15
- this.#root = this.shadowRoot;
16
- } else {
17
- this.#root = this;
18
- }
10
+ this.attachShadow({ mode: 'open' });
19
11
  }
20
12
 
21
13
  connectedCallback() {
22
14
  if (!this.#isInitialized) {
23
15
  this.#init();
24
- this.#isInitialized = true;
16
+ this.#isInitialized = true; // 3. 초기화 후 플래그를 true로 변경합니다.
25
17
  return true;
26
18
  }
27
- return false;
28
- }
29
-
30
- // 공통 쿼리 함수: 현재 root(Shadow 또는 Light DOM)에서 요소를 찾음
31
- #getElements() {
32
- return ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.#root);
33
- }
34
19
 
35
- // 자식 클래스에서 접근할 수 있도록 getter 제공
36
- get root() {
37
- return this.#root;
20
+ return false;
38
21
  }
39
22
 
40
23
  getData = () => {
41
24
  const jsonData = {};
42
- this.#getElements().forEach(el => {
25
+
26
+ // Shadow DOM 내의 폼 요소만 선택
27
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
43
28
  const key = el.name;
44
- if (!key) return;
29
+ if (!key) return; // name이 없는 요소는 건너뜁니다.
45
30
 
46
31
  let value;
47
32
  if (el.tagName === "INPUT" && (el.type === "checkbox" || el.type === "radio")) {
@@ -50,40 +35,50 @@ export class nxDiv extends HTMLElement {
50
35
  value = el.value;
51
36
  }
52
37
 
38
+ // 중복 name을 대비한 배열 처리
53
39
  if (jsonData[key]) {
54
- if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
40
+ if (!Array.isArray(jsonData[key])) {
41
+ jsonData[key] = [jsonData[key]];
42
+ }
55
43
  jsonData[key].push(value);
56
44
  } else {
57
45
  jsonData[key] = value;
58
46
  }
59
47
  });
48
+
60
49
  return jsonData;
61
50
  };
62
51
 
63
52
  setData = (jsonData) => {
64
- this.#getElements().forEach(el => {
53
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
54
+ console.log("------", el);
65
55
  el.removeEventListener("input", this.#changeHandler);
66
56
  el.addEventListener("input", this.#changeHandler);
67
57
  });
68
58
 
69
- if (!jsonData || typeof jsonData !== 'object') return;
59
+ if (!jsonData || typeof jsonData !== 'object') {
60
+ console.error("setData: Invalid data provided. Expected an object.");
61
+ return;
62
+ }
70
63
 
71
64
  let bChanged = false;
72
- this.#getElements().forEach(el => {
65
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
73
66
  const key = el.name;
74
67
  if (!key || !jsonData.hasOwnProperty(key)) return;
75
68
 
76
69
  const value = jsonData[key];
70
+
71
+ // 폼 요소에만 데이터를 설정합니다.
77
72
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
78
73
  if (el.type === "checkbox" || el.type === "radio") {
79
- const isChecked = (String(el.value) === String(value));
80
- if (el.checked !== isChecked) bChanged = true;
81
- el.checked = isChecked;
74
+ if (el.checked !== (el.value === String(value))) bChanged = true;
75
+ el.checked = (el.value === String(value));
82
76
  } else {
83
77
  if (el.value !== value) bChanged = true;
84
78
  el.value = value;
85
79
  }
86
80
  } else {
81
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
87
82
  if (el.textContent !== value) bChanged = true;
88
83
  el.textContent = value;
89
84
  }
@@ -110,21 +105,21 @@ export class nxDiv extends HTMLElement {
110
105
  }
111
106
 
112
107
  #init = () => {
113
- // CSS Style 적용
108
+
109
+ //console.log(this);
110
+ //console.log(this.querySelectorAll("input[name], textarea[name], select[name]"));
111
+
112
+ /**
113
+ * css style 적용
114
+ */
114
115
  for (const attr of this.attributes) {
115
116
  if (attr.name.startsWith("css-")) {
117
+ // "css-" 접두사를 제거하고 CSS 속성명으로 변환
116
118
  this.style.setProperty(attr.name.substring(4), attr.value);
117
119
  }
118
120
  }
119
121
 
120
- // 2. HTML 내용 처리
121
122
  this.originContents = this.innerHTML.trim();
122
-
123
- // Shadow DOM을 사용할 경우 내용을 안으로 옮김
124
- if (this.shadowRoot) {
125
- this.shadowRoot.innerHTML = this.originContents;
126
- this.innerHTML = ""; // 외부(Light DOM) 내용은 비움
127
- }
128
- // Shadow DOM을 안 쓰면 그대로 유지 (this.#root가 this이므로 별도 처리 불필요)
123
+ this.innerHTML = ""; // 기존 내부 HTML 제거
129
124
  };
130
125
  }
@@ -18,7 +18,7 @@ class nxButtons extends nxDiv {
18
18
  ${ninegrid.getCustomPath(this, "nxButtons.css")}
19
19
  </style>
20
20
  `;
21
- console.log("11111")
21
+
22
22
  const htmlTmpl = document.createElement("template");
23
23
 
24
24
  // Shadow DOM일 때는 originContents를 옮겨야 하고,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1250.0",
4
+ "version": "6.1252.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
package/src/nx/_nxDiv.js CHANGED
@@ -1,47 +1,32 @@
1
1
  import ninegrid from "../index.js";
2
2
 
3
- export class nxDiv extends HTMLElement {
3
+ export class nxDiv extends HTMLElement
4
+ {
4
5
  originContents;
5
6
  #isInitialized = false;
6
- #root; // Shadow DOM 사용 여부에 따라 shadowRoot 또는 this를 가리킴
7
7
 
8
- constructor() {
8
+ constructor () {
9
9
  super();
10
- // 1. 'use-shadow' 속성이 "false"가 아니면 기본적으로 Shadow DOM을 사용하도록 설정
11
- const useShadow = this.getAttribute("use-shadow") !== "false";
12
-
13
- if (useShadow) {
14
- this.attachShadow({ mode: 'open' });
15
- this.#root = this.shadowRoot;
16
- } else {
17
- this.#root = this;
18
- }
10
+ this.attachShadow({ mode: 'open' });
19
11
  }
20
12
 
21
13
  connectedCallback() {
22
14
  if (!this.#isInitialized) {
23
15
  this.#init();
24
- this.#isInitialized = true;
16
+ this.#isInitialized = true; // 3. 초기화 후 플래그를 true로 변경합니다.
25
17
  return true;
26
18
  }
27
- return false;
28
- }
29
-
30
- // 공통 쿼리 함수: 현재 root(Shadow 또는 Light DOM)에서 요소를 찾음
31
- #getElements() {
32
- return ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.#root);
33
- }
34
19
 
35
- // 자식 클래스에서 접근할 수 있도록 getter 제공
36
- get root() {
37
- return this.#root;
20
+ return false;
38
21
  }
39
22
 
40
23
  getData = () => {
41
24
  const jsonData = {};
42
- this.#getElements().forEach(el => {
25
+
26
+ // Shadow DOM 내의 폼 요소만 선택
27
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
43
28
  const key = el.name;
44
- if (!key) return;
29
+ if (!key) return; // name이 없는 요소는 건너뜁니다.
45
30
 
46
31
  let value;
47
32
  if (el.tagName === "INPUT" && (el.type === "checkbox" || el.type === "radio")) {
@@ -50,40 +35,50 @@ export class nxDiv extends HTMLElement {
50
35
  value = el.value;
51
36
  }
52
37
 
38
+ // 중복 name을 대비한 배열 처리
53
39
  if (jsonData[key]) {
54
- if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
40
+ if (!Array.isArray(jsonData[key])) {
41
+ jsonData[key] = [jsonData[key]];
42
+ }
55
43
  jsonData[key].push(value);
56
44
  } else {
57
45
  jsonData[key] = value;
58
46
  }
59
47
  });
48
+
60
49
  return jsonData;
61
50
  };
62
51
 
63
52
  setData = (jsonData) => {
64
- this.#getElements().forEach(el => {
53
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
54
+ console.log("------", el);
65
55
  el.removeEventListener("input", this.#changeHandler);
66
56
  el.addEventListener("input", this.#changeHandler);
67
57
  });
68
58
 
69
- if (!jsonData || typeof jsonData !== 'object') return;
59
+ if (!jsonData || typeof jsonData !== 'object') {
60
+ console.error("setData: Invalid data provided. Expected an object.");
61
+ return;
62
+ }
70
63
 
71
64
  let bChanged = false;
72
- this.#getElements().forEach(el => {
65
+ ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this.shadowRoot).forEach(el => {
73
66
  const key = el.name;
74
67
  if (!key || !jsonData.hasOwnProperty(key)) return;
75
68
 
76
69
  const value = jsonData[key];
70
+
71
+ // 폼 요소에만 데이터를 설정합니다.
77
72
  if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
78
73
  if (el.type === "checkbox" || el.type === "radio") {
79
- const isChecked = (String(el.value) === String(value));
80
- if (el.checked !== isChecked) bChanged = true;
81
- el.checked = isChecked;
74
+ if (el.checked !== (el.value === String(value))) bChanged = true;
75
+ el.checked = (el.value === String(value));
82
76
  } else {
83
77
  if (el.value !== value) bChanged = true;
84
78
  el.value = value;
85
79
  }
86
80
  } else {
81
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
87
82
  if (el.textContent !== value) bChanged = true;
88
83
  el.textContent = value;
89
84
  }
@@ -110,21 +105,21 @@ export class nxDiv extends HTMLElement {
110
105
  }
111
106
 
112
107
  #init = () => {
113
- // CSS Style 적용
108
+
109
+ //console.log(this);
110
+ //console.log(this.querySelectorAll("input[name], textarea[name], select[name]"));
111
+
112
+ /**
113
+ * css style 적용
114
+ */
114
115
  for (const attr of this.attributes) {
115
116
  if (attr.name.startsWith("css-")) {
117
+ // "css-" 접두사를 제거하고 CSS 속성명으로 변환
116
118
  this.style.setProperty(attr.name.substring(4), attr.value);
117
119
  }
118
120
  }
119
121
 
120
- // 2. HTML 내용 처리
121
122
  this.originContents = this.innerHTML.trim();
122
-
123
- // Shadow DOM을 사용할 경우 내용을 안으로 옮김
124
- if (this.shadowRoot) {
125
- this.shadowRoot.innerHTML = this.originContents;
126
- this.innerHTML = ""; // 외부(Light DOM) 내용은 비움
127
- }
128
- // Shadow DOM을 안 쓰면 그대로 유지 (this.#root가 this이므로 별도 처리 불필요)
123
+ this.innerHTML = ""; // 기존 내부 HTML 제거
129
124
  };
130
125
  }
@@ -18,7 +18,7 @@ class nxButtons extends nxDiv {
18
18
  ${ninegrid.getCustomPath(this, "nxButtons.css")}
19
19
  </style>
20
20
  `;
21
- console.log("11111")
21
+
22
22
  const htmlTmpl = document.createElement("template");
23
23
 
24
24
  // Shadow DOM일 때는 originContents를 옮겨야 하고,