ninegrid2 6.1258.0 → 6.1260.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.
@@ -121961,18 +121961,10 @@ class nxDiv extends HTMLElement {
121961
121961
  this.originContents = this.innerHTML.trim();
121962
121962
  this.innerHTML = ""; // 기존 내부 HTML 제거
121963
121963
 
121964
- /**
121965
- // 2. Shadow DOM을 사용할 때만 내용을 안으로 옮기고 밖을 비웁니다.
121966
- if (this.shadowRoot) {
121967
- // 상속받은 자식 클래스(nxButtons 등)가 직접 렌더링하는 경우를 위해
121968
- // nx-div 태그일 때만 자동으로 내용을 옮겨줍니다.
121969
- if (this.tagName.toLowerCase() === 'nx-div') {
121970
- this.shadowRoot.innerHTML = this.originContents;
121971
- }
121972
- this.innerHTML = "";
121964
+ // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
121965
+ if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
121966
+ this.shadowRoot.innerHTML = this.originContents;
121973
121967
  }
121974
- // Shadow DOM을 안 쓰면 Light DOM 상태이므로 innerHTML을 유지합니다.
121975
- */
121976
121968
  };
121977
121969
  }
121978
121970
 
@@ -122269,6 +122261,8 @@ class nxButtons extends nxDiv {
122269
122261
  };
122270
122262
 
122271
122263
  #init = () => {
122264
+ const target = this.shadowRoot || this;
122265
+
122272
122266
  const htmlTmpl = document.createElement("template");
122273
122267
  htmlTmpl.innerHTML = `
122274
122268
  <style>
@@ -122279,7 +122273,24 @@ class nxButtons extends nxDiv {
122279
122273
  ${this.originContents}
122280
122274
  `;
122281
122275
 
122282
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
122276
+ target.appendChild(htmlTmpl.content.cloneNode(true));
122277
+
122278
+ target.addEventListener('click', (e) => {
122279
+ const btn = e.target.closest('button');
122280
+ if (!btn) return;
122281
+
122282
+ const actionName = btn.getAttribute('on-click') || btn.getAttribute('onClick') || btn.getAttribute('onclick');
122283
+ if (actionName) {
122284
+ // 1. 먼저 엘리먼트 자체(this)에 해당 이름의 함수가 있는지 확인
122285
+ if (typeof this[actionName] === 'function') {
122286
+ this[actionName](e);
122287
+ }
122288
+ // 2. 없으면 전역 window에서 확인
122289
+ else if (typeof window[actionName] === 'function') {
122290
+ window[actionName](e);
122291
+ }
122292
+ }
122293
+ });
122283
122294
  }
122284
122295
  }
122285
122296
 
@@ -121957,18 +121957,10 @@ class nxDiv extends HTMLElement {
121957
121957
  this.originContents = this.innerHTML.trim();
121958
121958
  this.innerHTML = ""; // 기존 내부 HTML 제거
121959
121959
 
121960
- /**
121961
- // 2. Shadow DOM을 사용할 때만 내용을 안으로 옮기고 밖을 비웁니다.
121962
- if (this.shadowRoot) {
121963
- // 상속받은 자식 클래스(nxButtons 등)가 직접 렌더링하는 경우를 위해
121964
- // nx-div 태그일 때만 자동으로 내용을 옮겨줍니다.
121965
- if (this.tagName.toLowerCase() === 'nx-div') {
121966
- this.shadowRoot.innerHTML = this.originContents;
121967
- }
121968
- this.innerHTML = "";
121960
+ // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
121961
+ if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
121962
+ this.shadowRoot.innerHTML = this.originContents;
121969
121963
  }
121970
- // Shadow DOM을 안 쓰면 Light DOM 상태이므로 innerHTML을 유지합니다.
121971
- */
121972
121964
  };
121973
121965
  }
121974
121966
 
@@ -122265,6 +122257,8 @@ class nxButtons extends nxDiv {
122265
122257
  };
122266
122258
 
122267
122259
  #init = () => {
122260
+ const target = this.shadowRoot || this;
122261
+
122268
122262
  const htmlTmpl = document.createElement("template");
122269
122263
  htmlTmpl.innerHTML = `
122270
122264
  <style>
@@ -122275,7 +122269,24 @@ class nxButtons extends nxDiv {
122275
122269
  ${this.originContents}
122276
122270
  `;
122277
122271
 
122278
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
122272
+ target.appendChild(htmlTmpl.content.cloneNode(true));
122273
+
122274
+ target.addEventListener('click', (e) => {
122275
+ const btn = e.target.closest('button');
122276
+ if (!btn) return;
122277
+
122278
+ const actionName = btn.getAttribute('on-click') || btn.getAttribute('onClick') || btn.getAttribute('onclick');
122279
+ if (actionName) {
122280
+ // 1. 먼저 엘리먼트 자체(this)에 해당 이름의 함수가 있는지 확인
122281
+ if (typeof this[actionName] === 'function') {
122282
+ this[actionName](e);
122283
+ }
122284
+ // 2. 없으면 전역 window에서 확인
122285
+ else if (typeof window[actionName] === 'function') {
122286
+ window[actionName](e);
122287
+ }
122288
+ }
122289
+ });
122279
122290
  }
122280
122291
  }
122281
122292
 
package/dist/nx/_nxDiv.js CHANGED
@@ -123,17 +123,9 @@ export class nxDiv extends HTMLElement {
123
123
  this.originContents = this.innerHTML.trim();
124
124
  this.innerHTML = ""; // 기존 내부 HTML 제거
125
125
 
126
- /**
127
- // 2. Shadow DOM을 사용할 때만 내용을 안으로 옮기고 밖을 비웁니다.
128
- if (this.shadowRoot) {
129
- // 상속받은 자식 클래스(nxButtons 등)가 직접 렌더링하는 경우를 위해
130
- // nx-div 태그일 때만 자동으로 내용을 옮겨줍니다.
131
- if (this.tagName.toLowerCase() === 'nx-div') {
132
- this.shadowRoot.innerHTML = this.originContents;
133
- }
134
- this.innerHTML = "";
126
+ // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
127
+ if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
128
+ this.shadowRoot.innerHTML = this.originContents;
135
129
  }
136
- // Shadow DOM을 안 쓰면 Light DOM 상태이므로 innerHTML을 유지합니다.
137
- */
138
130
  };
139
131
  }
@@ -12,6 +12,8 @@ class nxButtons extends nxDiv {
12
12
  };
13
13
 
14
14
  #init = () => {
15
+ const target = this.shadowRoot || this;
16
+
15
17
  const htmlTmpl = document.createElement("template");
16
18
  htmlTmpl.innerHTML = `
17
19
  <style>
@@ -22,7 +24,24 @@ class nxButtons extends nxDiv {
22
24
  ${this.originContents}
23
25
  `;
24
26
 
25
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
27
+ target.appendChild(htmlTmpl.content.cloneNode(true));
28
+
29
+ target.addEventListener('click', (e) => {
30
+ const btn = e.target.closest('button');
31
+ if (!btn) return;
32
+
33
+ const actionName = btn.getAttribute('on-click') || btn.getAttribute('onClick') || btn.getAttribute('onclick');
34
+ if (actionName) {
35
+ // 1. 먼저 엘리먼트 자체(this)에 해당 이름의 함수가 있는지 확인
36
+ if (typeof this[actionName] === 'function') {
37
+ this[actionName](e);
38
+ }
39
+ // 2. 없으면 전역 window에서 확인
40
+ else if (typeof window[actionName] === 'function') {
41
+ window[actionName](e);
42
+ }
43
+ }
44
+ });
26
45
  }
27
46
  }
28
47
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.1258.0",
4
+ "version": "6.1260.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
package/src/nx/_nxDiv.js CHANGED
@@ -123,17 +123,9 @@ export class nxDiv extends HTMLElement {
123
123
  this.originContents = this.innerHTML.trim();
124
124
  this.innerHTML = ""; // 기존 내부 HTML 제거
125
125
 
126
- /**
127
- // 2. Shadow DOM을 사용할 때만 내용을 안으로 옮기고 밖을 비웁니다.
128
- if (this.shadowRoot) {
129
- // 상속받은 자식 클래스(nxButtons 등)가 직접 렌더링하는 경우를 위해
130
- // nx-div 태그일 때만 자동으로 내용을 옮겨줍니다.
131
- if (this.tagName.toLowerCase() === 'nx-div') {
132
- this.shadowRoot.innerHTML = this.originContents;
133
- }
134
- this.innerHTML = "";
126
+ // 만약 순수 nx-div로만 쓰일 경우(상속 x), 내용을 shadow에 채워줌
127
+ if (this.shadowRoot && this.tagName.toLowerCase() === 'nx-div') {
128
+ this.shadowRoot.innerHTML = this.originContents;
135
129
  }
136
- // Shadow DOM을 안 쓰면 Light DOM 상태이므로 innerHTML을 유지합니다.
137
- */
138
130
  };
139
131
  }
@@ -12,6 +12,8 @@ class nxButtons extends nxDiv {
12
12
  };
13
13
 
14
14
  #init = () => {
15
+ const target = this.shadowRoot || this;
16
+
15
17
  const htmlTmpl = document.createElement("template");
16
18
  htmlTmpl.innerHTML = `
17
19
  <style>
@@ -22,7 +24,24 @@ class nxButtons extends nxDiv {
22
24
  ${this.originContents}
23
25
  `;
24
26
 
25
- this.shadowRoot.appendChild(htmlTmpl.content.cloneNode(true));
27
+ target.appendChild(htmlTmpl.content.cloneNode(true));
28
+
29
+ target.addEventListener('click', (e) => {
30
+ const btn = e.target.closest('button');
31
+ if (!btn) return;
32
+
33
+ const actionName = btn.getAttribute('on-click') || btn.getAttribute('onClick') || btn.getAttribute('onclick');
34
+ if (actionName) {
35
+ // 1. 먼저 엘리먼트 자체(this)에 해당 이름의 함수가 있는지 확인
36
+ if (typeof this[actionName] === 'function') {
37
+ this[actionName](e);
38
+ }
39
+ // 2. 없으면 전역 window에서 확인
40
+ else if (typeof window[actionName] === 'function') {
41
+ window[actionName](e);
42
+ }
43
+ }
44
+ });
26
45
  }
27
46
  }
28
47