ninegrid2 6.1243.0 → 6.1245.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.
- package/package.json +1 -1
- package/src/nx/_nxDiv2.js +0 -125
- package/src/nx/nxPanel2.js +0 -39
package/package.json
CHANGED
package/src/nx/_nxDiv2.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import ninegrid from "../index.js";
|
|
2
|
-
|
|
3
|
-
export class nxDiv2 extends HTMLElement
|
|
4
|
-
{
|
|
5
|
-
originContents;
|
|
6
|
-
#isInitialized = false;
|
|
7
|
-
|
|
8
|
-
constructor () {
|
|
9
|
-
super();
|
|
10
|
-
//this.attachShadow({ mode: 'open' });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
connectedCallback() {
|
|
14
|
-
if (!this.#isInitialized) {
|
|
15
|
-
this.#init();
|
|
16
|
-
this.#isInitialized = true; // 3. 초기화 후 플래그를 true로 변경합니다.
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getData = () => {
|
|
24
|
-
const jsonData = {};
|
|
25
|
-
|
|
26
|
-
// Shadow DOM 내의 폼 요소만 선택
|
|
27
|
-
ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this).forEach(el => {
|
|
28
|
-
const key = el.name;
|
|
29
|
-
if (!key) return; // name이 없는 요소는 건너뜁니다.
|
|
30
|
-
|
|
31
|
-
let value;
|
|
32
|
-
if (el.tagName === "INPUT" && (el.type === "checkbox" || el.type === "radio")) {
|
|
33
|
-
value = el.checked;
|
|
34
|
-
} else {
|
|
35
|
-
value = el.value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 중복 name을 대비한 배열 처리
|
|
39
|
-
if (jsonData[key]) {
|
|
40
|
-
if (!Array.isArray(jsonData[key])) {
|
|
41
|
-
jsonData[key] = [jsonData[key]];
|
|
42
|
-
}
|
|
43
|
-
jsonData[key].push(value);
|
|
44
|
-
} else {
|
|
45
|
-
jsonData[key] = value;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
return jsonData;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
setData = (jsonData) => {
|
|
53
|
-
ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this).forEach(el => {
|
|
54
|
-
console.log("------", el);
|
|
55
|
-
el.removeEventListener("input", this.#changeHandler);
|
|
56
|
-
el.addEventListener("input", this.#changeHandler);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
if (!jsonData || typeof jsonData !== 'object') {
|
|
60
|
-
console.error("setData: Invalid data provided. Expected an object.");
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let bChanged = false;
|
|
65
|
-
ninegrid.querySelectorAll("input[name], textarea[name], select[name]", this).forEach(el => {
|
|
66
|
-
const key = el.name;
|
|
67
|
-
if (!key || !jsonData.hasOwnProperty(key)) return;
|
|
68
|
-
|
|
69
|
-
const value = jsonData[key];
|
|
70
|
-
|
|
71
|
-
// 폼 요소에만 데이터를 설정합니다.
|
|
72
|
-
if (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || el.tagName === "SELECT") {
|
|
73
|
-
if (el.type === "checkbox" || el.type === "radio") {
|
|
74
|
-
if (el.checked !== (el.value === String(value))) bChanged = true;
|
|
75
|
-
el.checked = (el.value === String(value));
|
|
76
|
-
} else {
|
|
77
|
-
if (el.value !== value) bChanged = true;
|
|
78
|
-
el.value = value;
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
// 폼 요소가 아닌 경우, textContent를 사용합니다.
|
|
82
|
-
if (el.textContent !== value) bChanged = true;
|
|
83
|
-
el.textContent = value;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
if (bChanged) this.#changed(bChanged);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
initData = (jsonData) => {
|
|
91
|
-
this.setData(jsonData);
|
|
92
|
-
this.#changed(false);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
#changed = (v) => {
|
|
96
|
-
const parent = this.closest(".detail-wrapper");
|
|
97
|
-
if (parent) {
|
|
98
|
-
const el = parent.querySelector("nx-title2");
|
|
99
|
-
if (el) el.changed = v;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
#changeHandler = (e) => {
|
|
104
|
-
this.#changed(true);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#init = () => {
|
|
108
|
-
|
|
109
|
-
//console.log(this);
|
|
110
|
-
//console.log(this.querySelectorAll("input[name], textarea[name], select[name]"));
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* css style 적용
|
|
114
|
-
*/
|
|
115
|
-
for (const attr of this.attributes) {
|
|
116
|
-
if (attr.name.startsWith("css-")) {
|
|
117
|
-
// "css-" 접두사를 제거하고 CSS 속성명으로 변환
|
|
118
|
-
this.style.setProperty(attr.name.substring(4), attr.value);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
this.originContents = this.innerHTML.trim();
|
|
123
|
-
this.innerHTML = ""; // 기존 내부 HTML 제거
|
|
124
|
-
};
|
|
125
|
-
}
|
package/src/nx/nxPanel2.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import ninegrid from "../index.js";
|
|
2
|
-
import {nxDiv} from "./_nxDiv.js";
|
|
3
|
-
|
|
4
|
-
class nxPanel2 extends nxDiv2 {
|
|
5
|
-
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
connectedCallback() {
|
|
11
|
-
if (super.connectedCallback()) this.#init();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#init = () => {
|
|
15
|
-
const caption = this.getAttribute("caption");
|
|
16
|
-
const columns = this.getAttribute("columns") || "";
|
|
17
|
-
|
|
18
|
-
const htmlTmpl = document.createElement("template");
|
|
19
|
-
htmlTmpl.innerHTML = `
|
|
20
|
-
<style>
|
|
21
|
-
@import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/nxPanel.css";
|
|
22
|
-
${ninegrid.getCustomPath(this,"nxPanel.css")}
|
|
23
|
-
</style>
|
|
24
|
-
|
|
25
|
-
<div class="head ${caption ? '' : 'hide'}">
|
|
26
|
-
<div class="caption"><span>${caption}</span></div>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="body">
|
|
29
|
-
<nx-layout2 columns="${columns}">
|
|
30
|
-
${this.originContents}
|
|
31
|
-
</nx-layout2>
|
|
32
|
-
</div>
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
this.appendChild(htmlTmpl.content.cloneNode(true));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
customElements.define("nx-panel2", nxPanel2);
|