ninegrid2 6.1171.0 → 6.1172.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.
@@ -122051,16 +122051,28 @@ class nxDiv extends HTMLElement
122051
122051
  };
122052
122052
 
122053
122053
  setData = (jsonData) => {
122054
+ if (!jsonData || typeof jsonData !== 'object') {
122055
+ console.error("setData: Invalid data provided. Expected an object.");
122056
+ return;
122057
+ }
122054
122058
 
122055
- console.log(jsonData);
122056
-
122057
- this.shadowRoot.querySelectorAll("input, textarea, select, [id], [name]").forEach(el => {
122058
- const key = el.id || el.name; // id가 있으면 우선, 없으면 name 사용
122059
- if (!key || !jsonData[key]) return; // id도 name도 없으면 건너뛰기
122059
+ this.shadowRoot.querySelectorAll("input[name], textarea[name], select[name]").forEach(el => {
122060
+ const key = el.name;
122061
+ if (!key || !jsonData.hasOwnProperty(key)) return;
122060
122062
 
122061
- console.log(el, jsonData[key]);
122063
+ const value = jsonData[key];
122062
122064
 
122063
- el[el.hasOwnProperty("value") ? "value" : "text"] = jsonData[key];
122065
+ // 요소에만 데이터를 설정합니다.
122066
+ if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
122067
+ if (el.type === "checkbox" || el.type === "radio") {
122068
+ el.checked = (el.value === String(value));
122069
+ } else {
122070
+ el.value = value;
122071
+ }
122072
+ } else {
122073
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
122074
+ el.textContent = value;
122075
+ }
122064
122076
  });
122065
122077
  };
122066
122078
 
@@ -122047,16 +122047,28 @@ class nxDiv extends HTMLElement
122047
122047
  };
122048
122048
 
122049
122049
  setData = (jsonData) => {
122050
+ if (!jsonData || typeof jsonData !== 'object') {
122051
+ console.error("setData: Invalid data provided. Expected an object.");
122052
+ return;
122053
+ }
122050
122054
 
122051
- console.log(jsonData);
122052
-
122053
- this.shadowRoot.querySelectorAll("input, textarea, select, [id], [name]").forEach(el => {
122054
- const key = el.id || el.name; // id가 있으면 우선, 없으면 name 사용
122055
- if (!key || !jsonData[key]) return; // id도 name도 없으면 건너뛰기
122055
+ this.shadowRoot.querySelectorAll("input[name], textarea[name], select[name]").forEach(el => {
122056
+ const key = el.name;
122057
+ if (!key || !jsonData.hasOwnProperty(key)) return;
122056
122058
 
122057
- console.log(el, jsonData[key]);
122059
+ const value = jsonData[key];
122058
122060
 
122059
- el[el.hasOwnProperty("value") ? "value" : "text"] = jsonData[key];
122061
+ // 요소에만 데이터를 설정합니다.
122062
+ if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
122063
+ if (el.type === "checkbox" || el.type === "radio") {
122064
+ el.checked = (el.value === String(value));
122065
+ } else {
122066
+ el.value = value;
122067
+ }
122068
+ } else {
122069
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
122070
+ el.textContent = value;
122071
+ }
122060
122072
  });
122061
122073
  };
122062
122074
 
package/dist/nx/_nxDiv.js CHANGED
@@ -46,16 +46,28 @@ export class nxDiv extends HTMLElement
46
46
  };
47
47
 
48
48
  setData = (jsonData) => {
49
+ if (!jsonData || typeof jsonData !== 'object') {
50
+ console.error("setData: Invalid data provided. Expected an object.");
51
+ return;
52
+ }
49
53
 
50
- console.log(jsonData);
51
-
52
- this.shadowRoot.querySelectorAll("input, textarea, select, [id], [name]").forEach(el => {
53
- const key = el.id || el.name; // id가 있으면 우선, 없으면 name 사용
54
- if (!key || !jsonData[key]) return; // id도 name도 없으면 건너뛰기
54
+ this.shadowRoot.querySelectorAll("input[name], textarea[name], select[name]").forEach(el => {
55
+ const key = el.name;
56
+ if (!key || !jsonData.hasOwnProperty(key)) return;
55
57
 
56
- console.log(el, jsonData[key]);
58
+ const value = jsonData[key];
57
59
 
58
- el[el.hasOwnProperty("value") ? "value" : "text"] = jsonData[key];
60
+ // 요소에만 데이터를 설정합니다.
61
+ if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
62
+ if (el.type === "checkbox" || el.type === "radio") {
63
+ el.checked = (el.value === String(value));
64
+ } else {
65
+ el.value = value;
66
+ }
67
+ } else {
68
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
69
+ el.textContent = value;
70
+ }
59
71
  });
60
72
  };
61
73
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1171.0",
4
+ "version": "6.1172.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
package/src/nx/_nxDiv.js CHANGED
@@ -46,16 +46,28 @@ export class nxDiv extends HTMLElement
46
46
  };
47
47
 
48
48
  setData = (jsonData) => {
49
+ if (!jsonData || typeof jsonData !== 'object') {
50
+ console.error("setData: Invalid data provided. Expected an object.");
51
+ return;
52
+ }
49
53
 
50
- console.log(jsonData);
51
-
52
- this.shadowRoot.querySelectorAll("input, textarea, select, [id], [name]").forEach(el => {
53
- const key = el.id || el.name; // id가 있으면 우선, 없으면 name 사용
54
- if (!key || !jsonData[key]) return; // id도 name도 없으면 건너뛰기
54
+ this.shadowRoot.querySelectorAll("input[name], textarea[name], select[name]").forEach(el => {
55
+ const key = el.name;
56
+ if (!key || !jsonData.hasOwnProperty(key)) return;
55
57
 
56
- console.log(el, jsonData[key]);
58
+ const value = jsonData[key];
57
59
 
58
- el[el.hasOwnProperty("value") ? "value" : "text"] = jsonData[key];
60
+ // 요소에만 데이터를 설정합니다.
61
+ if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
62
+ if (el.type === "checkbox" || el.type === "radio") {
63
+ el.checked = (el.value === String(value));
64
+ } else {
65
+ el.value = value;
66
+ }
67
+ } else {
68
+ // 폼 요소가 아닌 경우, textContent를 사용합니다.
69
+ el.textContent = value;
70
+ }
59
71
  });
60
72
  };
61
73