ninegrid2 6.1380.0 → 6.1382.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.
@@ -28501,42 +28501,42 @@ class nxDiv extends HTMLElement {
28501
28501
  return jsonData;
28502
28502
  };
28503
28503
 
28504
- clearData = (jsonData) => {
28505
- this.#getElements().forEach(el => {
28506
- el.removeEventListener("input", this.#changeHandler);
28507
- el.addEventListener("input", this.#changeHandler);
28508
- });
28509
-
28510
- //if (!jsonData || typeof jsonData !== 'object') return;
28504
+ // [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
28505
+ #updateElement(el, value) {
28506
+ const tagName = el.tagName.toUpperCase();
28507
+ const type = el.type;
28508
+ let isChanged = false;
28509
+
28510
+ if (["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"].includes(tagName)) {
28511
+ if (type === "checkbox") {
28512
+ const t = el.getAttribute("true-value") || "Y";
28513
+ const isChecked = (String(t) === String(value));
28514
+ if (el.checked !== isChecked) isChanged = true;
28515
+ el.checked = isChecked;
28516
+ } else if (type === "radio") {
28517
+ const isChecked = (String(el.value) === String(value));
28518
+ if (el.checked !== isChecked) isChanged = true;
28519
+ el.checked = isChecked;
28520
+ } else {
28521
+ if (el.value !== value) isChanged = true;
28522
+ el.value = value;
28523
+ }
28524
+ } else {
28525
+ if (el.textContent !== value) isChanged = true;
28526
+ el.textContent = value;
28527
+ }
28528
+ return isChanged;
28529
+ }
28511
28530
 
28512
- //let bChanged = false;
28531
+ // 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
28532
+ clearData = (jsonData = {}) => {
28533
+ this.#refreshListeners();
28513
28534
  this.#getElements().forEach(el => {
28514
28535
  const key = el.name;
28515
- if (!key) return; // name이 없는 요소는 스킵
28516
- //console.log(el.tagName, key, el.name);
28517
-
28518
- // 2. jsonData에 해당 key가 없으면 공백("") 할당
28519
- const value = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
28520
-
28521
- const tagName = el.tagName.toUpperCase();
28522
- const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
28523
-
28524
- if (inputTags.includes(tagName)) {
28525
- if (el.type === "checkbox") {
28526
- // 3. true-value 속성을 읽어와서 체크 여부 결정
28527
- let t = el.getAttribute("true-value") || "Y";
28528
- el.checked = (String(t) === String(value));
28529
- } else if (el.type === "radio") {
28530
- // 라디오 버튼 그룹 내에서 값 일치 여부 확인
28531
- el.checked = (String(el.value) === String(value));
28532
- } else {
28533
- el.value = value;
28534
- }
28535
- } else {
28536
- el.textContent = value;
28537
- }
28536
+ if (!key) return;
28537
+ const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
28538
+ this.#updateElement(el, val);
28538
28539
  });
28539
-
28540
28540
  this.#changed(false);
28541
28541
  };
28542
28542
 
@@ -28497,42 +28497,42 @@ class nxDiv extends HTMLElement {
28497
28497
  return jsonData;
28498
28498
  };
28499
28499
 
28500
- clearData = (jsonData) => {
28501
- this.#getElements().forEach(el => {
28502
- el.removeEventListener("input", this.#changeHandler);
28503
- el.addEventListener("input", this.#changeHandler);
28504
- });
28505
-
28506
- //if (!jsonData || typeof jsonData !== 'object') return;
28500
+ // [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
28501
+ #updateElement(el, value) {
28502
+ const tagName = el.tagName.toUpperCase();
28503
+ const type = el.type;
28504
+ let isChanged = false;
28505
+
28506
+ if (["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"].includes(tagName)) {
28507
+ if (type === "checkbox") {
28508
+ const t = el.getAttribute("true-value") || "Y";
28509
+ const isChecked = (String(t) === String(value));
28510
+ if (el.checked !== isChecked) isChanged = true;
28511
+ el.checked = isChecked;
28512
+ } else if (type === "radio") {
28513
+ const isChecked = (String(el.value) === String(value));
28514
+ if (el.checked !== isChecked) isChanged = true;
28515
+ el.checked = isChecked;
28516
+ } else {
28517
+ if (el.value !== value) isChanged = true;
28518
+ el.value = value;
28519
+ }
28520
+ } else {
28521
+ if (el.textContent !== value) isChanged = true;
28522
+ el.textContent = value;
28523
+ }
28524
+ return isChanged;
28525
+ }
28507
28526
 
28508
- //let bChanged = false;
28527
+ // 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
28528
+ clearData = (jsonData = {}) => {
28529
+ this.#refreshListeners();
28509
28530
  this.#getElements().forEach(el => {
28510
28531
  const key = el.name;
28511
- if (!key) return; // name이 없는 요소는 스킵
28512
- //console.log(el.tagName, key, el.name);
28513
-
28514
- // 2. jsonData에 해당 key가 없으면 공백("") 할당
28515
- const value = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
28516
-
28517
- const tagName = el.tagName.toUpperCase();
28518
- const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
28519
-
28520
- if (inputTags.includes(tagName)) {
28521
- if (el.type === "checkbox") {
28522
- // 3. true-value 속성을 읽어와서 체크 여부 결정
28523
- let t = el.getAttribute("true-value") || "Y";
28524
- el.checked = (String(t) === String(value));
28525
- } else if (el.type === "radio") {
28526
- // 라디오 버튼 그룹 내에서 값 일치 여부 확인
28527
- el.checked = (String(el.value) === String(value));
28528
- } else {
28529
- el.value = value;
28530
- }
28531
- } else {
28532
- el.textContent = value;
28533
- }
28532
+ if (!key) return;
28533
+ const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
28534
+ this.#updateElement(el, val);
28534
28535
  });
28535
-
28536
28536
  this.#changed(false);
28537
28537
  };
28538
28538
 
package/dist/nx/_nxDiv.js CHANGED
@@ -68,42 +68,42 @@ export class nxDiv extends HTMLElement {
68
68
  return jsonData;
69
69
  };
70
70
 
71
- clearData = (jsonData) => {
72
- this.#getElements().forEach(el => {
73
- el.removeEventListener("input", this.#changeHandler);
74
- el.addEventListener("input", this.#changeHandler);
75
- });
76
-
77
- //if (!jsonData || typeof jsonData !== 'object') return;
71
+ // [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
72
+ #updateElement(el, value) {
73
+ const tagName = el.tagName.toUpperCase();
74
+ const type = el.type;
75
+ let isChanged = false;
76
+
77
+ if (["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"].includes(tagName)) {
78
+ if (type === "checkbox") {
79
+ const t = el.getAttribute("true-value") || "Y";
80
+ const isChecked = (String(t) === String(value));
81
+ if (el.checked !== isChecked) isChanged = true;
82
+ el.checked = isChecked;
83
+ } else if (type === "radio") {
84
+ const isChecked = (String(el.value) === String(value));
85
+ if (el.checked !== isChecked) isChanged = true;
86
+ el.checked = isChecked;
87
+ } else {
88
+ if (el.value !== value) isChanged = true;
89
+ el.value = value;
90
+ }
91
+ } else {
92
+ if (el.textContent !== value) isChanged = true;
93
+ el.textContent = value;
94
+ }
95
+ return isChanged;
96
+ }
78
97
 
79
- //let bChanged = false;
98
+ // 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
99
+ clearData = (jsonData = {}) => {
100
+ this.#refreshListeners();
80
101
  this.#getElements().forEach(el => {
81
102
  const key = el.name;
82
- if (!key) return; // name이 없는 요소는 스킵
83
- //console.log(el.tagName, key, el.name);
84
-
85
- // 2. jsonData에 해당 key가 없으면 공백("") 할당
86
- const value = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
87
-
88
- const tagName = el.tagName.toUpperCase();
89
- const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
90
-
91
- if (inputTags.includes(tagName)) {
92
- if (el.type === "checkbox") {
93
- // 3. true-value 속성을 읽어와서 체크 여부 결정
94
- let t = el.getAttribute("true-value") || "Y";
95
- el.checked = (String(t) === String(value));
96
- } else if (el.type === "radio") {
97
- // 라디오 버튼 그룹 내에서 값 일치 여부 확인
98
- el.checked = (String(el.value) === String(value));
99
- } else {
100
- el.value = value;
101
- }
102
- } else {
103
- el.textContent = value;
104
- }
103
+ if (!key) return;
104
+ const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
105
+ this.#updateElement(el, val);
105
106
  });
106
-
107
107
  this.#changed(false);
108
108
  };
109
109
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1380.0",
4
+ "version": "6.1382.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
package/src/nx/_nxDiv.js CHANGED
@@ -68,42 +68,42 @@ export class nxDiv extends HTMLElement {
68
68
  return jsonData;
69
69
  };
70
70
 
71
- clearData = (jsonData) => {
72
- this.#getElements().forEach(el => {
73
- el.removeEventListener("input", this.#changeHandler);
74
- el.addEventListener("input", this.#changeHandler);
75
- });
76
-
77
- //if (!jsonData || typeof jsonData !== 'object') return;
71
+ // [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
72
+ #updateElement(el, value) {
73
+ const tagName = el.tagName.toUpperCase();
74
+ const type = el.type;
75
+ let isChanged = false;
76
+
77
+ if (["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"].includes(tagName)) {
78
+ if (type === "checkbox") {
79
+ const t = el.getAttribute("true-value") || "Y";
80
+ const isChecked = (String(t) === String(value));
81
+ if (el.checked !== isChecked) isChanged = true;
82
+ el.checked = isChecked;
83
+ } else if (type === "radio") {
84
+ const isChecked = (String(el.value) === String(value));
85
+ if (el.checked !== isChecked) isChanged = true;
86
+ el.checked = isChecked;
87
+ } else {
88
+ if (el.value !== value) isChanged = true;
89
+ el.value = value;
90
+ }
91
+ } else {
92
+ if (el.textContent !== value) isChanged = true;
93
+ el.textContent = value;
94
+ }
95
+ return isChanged;
96
+ }
78
97
 
79
- //let bChanged = false;
98
+ // 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
99
+ clearData = (jsonData = {}) => {
100
+ this.#refreshListeners();
80
101
  this.#getElements().forEach(el => {
81
102
  const key = el.name;
82
- if (!key) return; // name이 없는 요소는 스킵
83
- //console.log(el.tagName, key, el.name);
84
-
85
- // 2. jsonData에 해당 key가 없으면 공백("") 할당
86
- const value = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
87
-
88
- const tagName = el.tagName.toUpperCase();
89
- const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
90
-
91
- if (inputTags.includes(tagName)) {
92
- if (el.type === "checkbox") {
93
- // 3. true-value 속성을 읽어와서 체크 여부 결정
94
- let t = el.getAttribute("true-value") || "Y";
95
- el.checked = (String(t) === String(value));
96
- } else if (el.type === "radio") {
97
- // 라디오 버튼 그룹 내에서 값 일치 여부 확인
98
- el.checked = (String(el.value) === String(value));
99
- } else {
100
- el.value = value;
101
- }
102
- } else {
103
- el.textContent = value;
104
- }
103
+ if (!key) return;
104
+ const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
105
+ this.#updateElement(el, val);
105
106
  });
106
-
107
107
  this.#changed(false);
108
108
  };
109
109