ninegrid2 6.233.0 → 6.235.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.
@@ -12,12 +12,14 @@ export class ngFiltering
12
12
  #owner;
13
13
  #isFiltering;
14
14
 
15
- constructor (owner) {
16
- this.#owner = owner;
17
- this.#isFiltering = false;
18
-
19
- $(this.#owner.shadowRoot).append($('<ng-filter-panel></ng-filter-panel>').hide());
20
- }
15
+ constructor(owner) {
16
+ this.#owner = owner;
17
+ this.#isFiltering = false;
18
+
19
+ const filterPanel = document.createElement("ng-filter-panel"); // ✅ 필터 패널 생성
20
+ filterPanel.style.display = "none"; // ✅ 숨김 처리
21
+ this.#owner.shadowRoot.appendChild(filterPanel); // ✅ Shadow DOM 내부에 추가
22
+ }
21
23
 
22
24
  initialize = () => {
23
25
  /**
@@ -25,8 +27,6 @@ export class ngFiltering
25
27
  */
26
28
  this.#isFiltering = false;
27
29
  this.#owner.data.clearFilter();
28
-
29
- //this.#on();
30
30
  };
31
31
 
32
32
  isFiltering = () => {
@@ -74,78 +74,47 @@ export class ngFiltering
74
74
 
75
75
  this.on();
76
76
 
77
- let jsonFilter = {};
78
- if (Array.isArray(oFilter)) {
79
- for (let key in oFilter[0]) {
80
- jsonFilter[key] = Array.from(new Set(oFilter.map(item => item[key])));//oFilter.map(item => item[key]);
81
- }
82
- }
83
- else {
84
- jsonFilter = oFilter;
85
- }
86
-
87
- //jsonFilter.doc_id = [2, 18, 20, 28, 36, 45, 46, 48, 56, 64, 73, 81, 83, 90];
88
-
89
- //let filterData = [];
90
-
91
- console.log("==================", jsonFilter);
77
+ // JSON 변환 (배열 → 객체)
78
+ let jsonFilter = Array.isArray(oFilter)
79
+ ? Object.fromEntries(Object.keys(oFilter[0]).map(key => [key, [...new Set(oFilter.map(item => item[key]))]]))
80
+ : oFilter;
81
+
82
+ //console.log(oFilter, jsonFilter);
92
83
 
93
84
  this.#owner.data.clearFilter();
94
85
 
95
- for (let key in jsonFilter) {
96
- const arr = jsonFilter[key];
86
+ Object.entries(jsonFilter).forEach(([key, arr]) => {
97
87
  const idx = this.#owner.fields.indexOf(key);
98
-
99
- let isNum = false;
100
- for (let o of this.#owner.data.getValidData()) {
101
- if (o.v[idx] == null) continue;
102
-
103
- //console.log(o.v[idx], typeof o.v[idx])
104
-
105
- isNum = (typeof o.v[idx] === "number") ? true : false;
106
-
107
- break;
108
- }
109
-
110
- if (isNum) {
111
- for (var i = 0; i < arr.length; i++) {
112
- arr[i] = Number(arr[i]);
113
- }
88
+
89
+ // 숫자 판별 및 변환
90
+ if (this.#owner.data.getValidData().some(o => typeof o.v[idx] === "number")) {
91
+ arr = arr.map(Number);
114
92
  }
115
-
116
- this.#owner.data.getValidData().filter(m => { return arr.nineBinarySearch(m.v[idx] || '') < 0; }).map(m => { m.__ng.filtered = true; });
117
- }
93
+
94
+ // 필터 적용
95
+ this.#owner.data.getValidData()
96
+ .filter(m => arr.nineBinarySearch(m.v[idx] || '') < 0)
97
+ .forEach(m => { m.__ng.filtered = true; });
98
+ });
118
99
 
119
100
 
120
101
  this.#owner.data.refreshFilter();
121
102
 
103
+ // ✅ 필터 버튼 초기화
122
104
  this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(el => {
123
- let options = el.filterOptions;
124
-
125
- options.forEach(opt => {
126
- opt.data = [];
127
- });
128
-
129
- el.filterOptions = options;
105
+ el.filterOptions.forEach(opt => { opt.data = []; });
130
106
  });
131
107
 
132
- for (let key in jsonFilter) {
108
+ // 필터 데이터 적용
109
+ Object.entries(jsonFilter).forEach(([key, arr]) => {
133
110
  this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(el => {
134
- let options = el.filterOptions;
135
-
136
- options.forEach(opt => {
137
- if (opt.colnm === key) {
138
- opt.data = jsonFilter[key];
139
- }
111
+ el.filterOptions.forEach(opt => {
112
+ if (opt.colnm === key) opt.data = arr;
140
113
  });
141
-
142
- el.filterOptions = options;
143
114
  });
144
- }
145
-
115
+ });
146
116
 
147
117
  this.#owner.scrollTo_V1(0);
148
-
149
118
  this.#owner.paging.reset();
150
119
  };
151
120
 
@@ -158,82 +127,12 @@ export class ngFiltering
158
127
 
159
128
  return index;
160
129
  };
161
-
162
-
163
-
164
-
165
-
166
- #init = (option) => {
167
-
168
- let jsonOption = {};
169
- if (Array.isArray(option)) {
170
- for (let key in option[0]) {
171
- jsonOption[key] = Array.from(new Set(oFilter.map(item => item[key])));//oFilter.map(item => item[key]);
172
- }
173
- }
174
- else {
175
- jsonOption = option;
176
- }
177
-
178
- this.#owner.data.clearFilter();
179
-
180
- for (let key in jsonOption) {
181
- const arr = jsonOption[key];
182
- const idx = this.#owner.fields.indexOf(key);
183
-
184
- for (let o of this.#owner.data.getValidData()) {
185
- if (o.v[idx] != null) {
186
- if (typeof o.v[idx] === "number") {
187
- for (var i = 0; i < arr.length; i++) {
188
- arr[i] = Number(arr[i]);
189
- }
190
- }
191
- break;
192
- }
193
- }
194
-
195
- this.#owner.data.getValidData().filter(m => { return arr.nineBinarySearch(m.v[idx] || '') < 0; }).map(m => { m.__ng.filtered = true; });
196
- }
197
-
198
-
199
- this.#owner.data.refreshFilter();
200
-
201
- var colnms = [];
202
- for (let key in jsonOption) {
203
- colnms.push(key);
204
- }
205
- //var colnms = filterData.map(item => item.colnm);
206
-
207
- this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(v => {
208
- v.filterData = null;
209
- });
210
-
211
- for (let key in jsonOption) {
212
- const arr = jsonOption[key];
213
-
214
- this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(v => {
215
- //console.log(v.colnms);
216
-
217
- v.colnms.forEach(colnm => {
218
- if (colnms.includes(colnm)) {
219
- v.filterData = arr;
220
- }
221
- });
222
- });
223
- }
224
-
225
-
226
- this.#owner.scrollTo_V1(0);
227
-
228
- this.#owner.paging.reset();
229
- };
230
130
  }
231
131
 
232
132
  class ngFilterButton extends HTMLElement
233
133
  {
234
134
  #owner;
235
135
  #filterOptions;
236
- #colnms;
237
136
 
238
137
  constructor () {
239
138
  super();
@@ -242,15 +141,8 @@ class ngFilterButton extends HTMLElement
242
141
  connectedCallback() {
243
142
  this.#owner = this.getRootNode().host;//this.closest("nine-grid");
244
143
 
245
- $(this).off("click", this.#onClick);
246
- $(this).on("click", this.#onClick);
247
- };
248
-
249
- get colnms() {
250
- return this.#colnms || [];
251
- };
252
- set colnms(v) {
253
- this.#colnms = v;
144
+ this.removeEventListener("click", this.#onClick);
145
+ this.addEventListener("click", this.#onClick);
254
146
  };
255
147
 
256
148
  get filterOptions() {
@@ -267,32 +159,8 @@ class ngFilterButton extends HTMLElement
267
159
  e.stopPropagation();
268
160
 
269
161
  const panel = this.#owner.shadowRoot.querySelector('ng-filter-panel');
270
-
271
- //console.log(panel.isHidden);
272
-
273
- //panel.style.display = 'flex' : 'none';
274
- //console.log(panel.isHidden, panel.col, this.closest('th,td').dataset.col);
275
-
276
- if (panel.col === this.closest('th,td').dataset.col) {
277
- panel.close();
278
- }
279
- else {
280
- /**
281
- var cell = e.target.closest("th,td");
282
-
283
- var l = $(e.target).offset().left - $(this.#owner).offset().left;// - $(panel).width() + $(e.target).width() + 1;
284
- if (l < 0) l = 0;
285
- if (l + $(panel).width() > $(this.#owner).width()) l = $(this.#owner).width() - $(panel).width() - 5;
286
-
287
-
288
-
289
- var t = $(cell).offset().top + $(cell).height()- $(this.#owner).offset().top;//$(e.target).offset().top + $(e.target).height() + 2;
290
-
291
- //$(panel).offset({left: l, top: t});
292
- $(panel).css({left: l, top: t});
293
- */
294
- panel.open(this);
295
- }
162
+
163
+ (panel.col === this.closest('th,td').dataset.col) ? panel.close() : panel.open(this);
296
164
  };
297
165
  }
298
166
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.233.0",
4
+ "version": "6.235.0",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
7
7
  "import": "./dist/index.js",
package/src/etc/ngData.js CHANGED
@@ -219,115 +219,6 @@ export class ngData
219
219
  }
220
220
 
221
221
 
222
- /**
223
- * { "key1": [1,2,...], "key2": [1,2,...], ... }
224
- */
225
- setFilter = (oFilter) => {
226
-
227
- this.#owner.filtering.on();
228
-
229
-
230
- let jsonFilter = {};
231
- if (Array.isArray(oFilter)) {
232
-
233
- for (let key in oFilter[0]) {
234
- //console.log(`::::::${key}::::::`)
235
- //key = key.trim();
236
- //console.log(key);
237
- jsonFilter[key] = Array.from(new Set(oFilter.map(item => item[key])));//oFilter.map(item => item[key]);
238
- }
239
- }
240
- else {
241
- jsonFilter = oFilter;
242
- }
243
-
244
- //jsonFilter.doc_id = [2, 18, 20, 28, 36, 45, 46, 48, 56, 64, 73, 81, 83, 90];
245
-
246
- //let filterData = [];
247
-
248
- console.log("==================", jsonFilter);
249
-
250
- this.clearFilter();
251
-
252
- for (let key in jsonFilter) {
253
- const arr = jsonFilter[key];
254
- const idx = this.#parent.owner.fields.indexOf(key);
255
-
256
- let isNum = false;
257
- for (let o of this.getValidData()) {
258
- if (o.v[idx] == null) continue;
259
-
260
- //console.log(o.v[idx], typeof o.v[idx])
261
-
262
- isNum = (typeof o.v[idx] === "number") ? true : false;
263
-
264
- break;
265
- }
266
-
267
- if (isNum) {
268
- for (var i = 0; i < arr.length; i++) {
269
- arr[i] = Number(arr[i]);
270
- }
271
- }
272
-
273
- /** filtering button 용 데이타 */
274
- /**
275
- filterData.push({
276
- "colnm" : key,
277
- "data" : arr,
278
- }); */
279
- //console.log(arr);
280
-
281
-
282
- //console.log(arr, idx, arr.nineBinarySearch(m.v[idx]));
283
-
284
- this.getValidData().filter(m => { return arr.nineBinarySearch(m.v[idx] || '') < 0; }).map(m => { m.__ng.filtered = true; });
285
-
286
-
287
- //break;
288
-
289
-
290
- }
291
-
292
-
293
- this.refreshFilter();
294
-
295
- var colnms = [];
296
- for (let key in jsonFilter) {
297
- colnms.push(key);
298
- }
299
- //var colnms = filterData.map(item => item.colnm);
300
-
301
- ninegrid.querySelectorAll("ng-filter-button").forEach(v => {
302
- v.filterData = null;
303
- });
304
-
305
- for (let key in jsonFilter) {
306
- const arr = jsonFilter[key];
307
- const idx = this.#parent.owner.fields.indexOf(key);
308
-
309
- //console.log(filterData);
310
- ninegrid.querySelectorAll("ng-filter-button").forEach(v => {
311
- //v.filterData = null;
312
- //console.log(v);
313
- //var b = v.colnms;
314
- v.colnms.forEach(colnm => {
315
-
316
- console.log(colnms, colnm);
317
- if (colnms.includes(colnm)) {
318
- console.log("==================");
319
-
320
- v.filterData = arr;
321
- }
322
- });
323
- });
324
- }
325
-
326
-
327
- this.#parent.owner.scrollTo_V1(0);
328
-
329
- this.#parent.owner.paging.reset();
330
- };
331
222
 
332
223
  /**
333
224
  *
@@ -12,12 +12,14 @@ export class ngFiltering
12
12
  #owner;
13
13
  #isFiltering;
14
14
 
15
- constructor (owner) {
16
- this.#owner = owner;
17
- this.#isFiltering = false;
18
-
19
- $(this.#owner.shadowRoot).append($('<ng-filter-panel></ng-filter-panel>').hide());
20
- }
15
+ constructor(owner) {
16
+ this.#owner = owner;
17
+ this.#isFiltering = false;
18
+
19
+ const filterPanel = document.createElement("ng-filter-panel"); // ✅ 필터 패널 생성
20
+ filterPanel.style.display = "none"; // ✅ 숨김 처리
21
+ this.#owner.shadowRoot.appendChild(filterPanel); // ✅ Shadow DOM 내부에 추가
22
+ }
21
23
 
22
24
  initialize = () => {
23
25
  /**
@@ -25,8 +27,6 @@ export class ngFiltering
25
27
  */
26
28
  this.#isFiltering = false;
27
29
  this.#owner.data.clearFilter();
28
-
29
- //this.#on();
30
30
  };
31
31
 
32
32
  isFiltering = () => {
@@ -74,78 +74,47 @@ export class ngFiltering
74
74
 
75
75
  this.on();
76
76
 
77
- let jsonFilter = {};
78
- if (Array.isArray(oFilter)) {
79
- for (let key in oFilter[0]) {
80
- jsonFilter[key] = Array.from(new Set(oFilter.map(item => item[key])));//oFilter.map(item => item[key]);
81
- }
82
- }
83
- else {
84
- jsonFilter = oFilter;
85
- }
86
-
87
- //jsonFilter.doc_id = [2, 18, 20, 28, 36, 45, 46, 48, 56, 64, 73, 81, 83, 90];
88
-
89
- //let filterData = [];
90
-
91
- console.log("==================", jsonFilter);
77
+ // JSON 변환 (배열 → 객체)
78
+ let jsonFilter = Array.isArray(oFilter)
79
+ ? Object.fromEntries(Object.keys(oFilter[0]).map(key => [key, [...new Set(oFilter.map(item => item[key]))]]))
80
+ : oFilter;
81
+
82
+ //console.log(oFilter, jsonFilter);
92
83
 
93
84
  this.#owner.data.clearFilter();
94
85
 
95
- for (let key in jsonFilter) {
96
- const arr = jsonFilter[key];
86
+ Object.entries(jsonFilter).forEach(([key, arr]) => {
97
87
  const idx = this.#owner.fields.indexOf(key);
98
-
99
- let isNum = false;
100
- for (let o of this.#owner.data.getValidData()) {
101
- if (o.v[idx] == null) continue;
102
-
103
- //console.log(o.v[idx], typeof o.v[idx])
104
-
105
- isNum = (typeof o.v[idx] === "number") ? true : false;
106
-
107
- break;
108
- }
109
-
110
- if (isNum) {
111
- for (var i = 0; i < arr.length; i++) {
112
- arr[i] = Number(arr[i]);
113
- }
88
+
89
+ // 숫자 판별 및 변환
90
+ if (this.#owner.data.getValidData().some(o => typeof o.v[idx] === "number")) {
91
+ arr = arr.map(Number);
114
92
  }
115
-
116
- this.#owner.data.getValidData().filter(m => { return arr.nineBinarySearch(m.v[idx] || '') < 0; }).map(m => { m.__ng.filtered = true; });
117
- }
93
+
94
+ // 필터 적용
95
+ this.#owner.data.getValidData()
96
+ .filter(m => arr.nineBinarySearch(m.v[idx] || '') < 0)
97
+ .forEach(m => { m.__ng.filtered = true; });
98
+ });
118
99
 
119
100
 
120
101
  this.#owner.data.refreshFilter();
121
102
 
103
+ // ✅ 필터 버튼 초기화
122
104
  this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(el => {
123
- let options = el.filterOptions;
124
-
125
- options.forEach(opt => {
126
- opt.data = [];
127
- });
128
-
129
- el.filterOptions = options;
105
+ el.filterOptions.forEach(opt => { opt.data = []; });
130
106
  });
131
107
 
132
- for (let key in jsonFilter) {
108
+ // 필터 데이터 적용
109
+ Object.entries(jsonFilter).forEach(([key, arr]) => {
133
110
  this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(el => {
134
- let options = el.filterOptions;
135
-
136
- options.forEach(opt => {
137
- if (opt.colnm === key) {
138
- opt.data = jsonFilter[key];
139
- }
111
+ el.filterOptions.forEach(opt => {
112
+ if (opt.colnm === key) opt.data = arr;
140
113
  });
141
-
142
- el.filterOptions = options;
143
114
  });
144
- }
145
-
115
+ });
146
116
 
147
117
  this.#owner.scrollTo_V1(0);
148
-
149
118
  this.#owner.paging.reset();
150
119
  };
151
120
 
@@ -158,82 +127,12 @@ export class ngFiltering
158
127
 
159
128
  return index;
160
129
  };
161
-
162
-
163
-
164
-
165
-
166
- #init = (option) => {
167
-
168
- let jsonOption = {};
169
- if (Array.isArray(option)) {
170
- for (let key in option[0]) {
171
- jsonOption[key] = Array.from(new Set(oFilter.map(item => item[key])));//oFilter.map(item => item[key]);
172
- }
173
- }
174
- else {
175
- jsonOption = option;
176
- }
177
-
178
- this.#owner.data.clearFilter();
179
-
180
- for (let key in jsonOption) {
181
- const arr = jsonOption[key];
182
- const idx = this.#owner.fields.indexOf(key);
183
-
184
- for (let o of this.#owner.data.getValidData()) {
185
- if (o.v[idx] != null) {
186
- if (typeof o.v[idx] === "number") {
187
- for (var i = 0; i < arr.length; i++) {
188
- arr[i] = Number(arr[i]);
189
- }
190
- }
191
- break;
192
- }
193
- }
194
-
195
- this.#owner.data.getValidData().filter(m => { return arr.nineBinarySearch(m.v[idx] || '') < 0; }).map(m => { m.__ng.filtered = true; });
196
- }
197
-
198
-
199
- this.#owner.data.refreshFilter();
200
-
201
- var colnms = [];
202
- for (let key in jsonOption) {
203
- colnms.push(key);
204
- }
205
- //var colnms = filterData.map(item => item.colnm);
206
-
207
- this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(v => {
208
- v.filterData = null;
209
- });
210
-
211
- for (let key in jsonOption) {
212
- const arr = jsonOption[key];
213
-
214
- this.#owner.shadowRoot.querySelectorAll("ng-filter-button").forEach(v => {
215
- //console.log(v.colnms);
216
-
217
- v.colnms.forEach(colnm => {
218
- if (colnms.includes(colnm)) {
219
- v.filterData = arr;
220
- }
221
- });
222
- });
223
- }
224
-
225
-
226
- this.#owner.scrollTo_V1(0);
227
-
228
- this.#owner.paging.reset();
229
- };
230
130
  }
231
131
 
232
132
  class ngFilterButton extends HTMLElement
233
133
  {
234
134
  #owner;
235
135
  #filterOptions;
236
- #colnms;
237
136
 
238
137
  constructor () {
239
138
  super();
@@ -242,15 +141,8 @@ class ngFilterButton extends HTMLElement
242
141
  connectedCallback() {
243
142
  this.#owner = this.getRootNode().host;//this.closest("nine-grid");
244
143
 
245
- $(this).off("click", this.#onClick);
246
- $(this).on("click", this.#onClick);
247
- };
248
-
249
- get colnms() {
250
- return this.#colnms || [];
251
- };
252
- set colnms(v) {
253
- this.#colnms = v;
144
+ this.removeEventListener("click", this.#onClick);
145
+ this.addEventListener("click", this.#onClick);
254
146
  };
255
147
 
256
148
  get filterOptions() {
@@ -267,32 +159,8 @@ class ngFilterButton extends HTMLElement
267
159
  e.stopPropagation();
268
160
 
269
161
  const panel = this.#owner.shadowRoot.querySelector('ng-filter-panel');
270
-
271
- //console.log(panel.isHidden);
272
-
273
- //panel.style.display = 'flex' : 'none';
274
- //console.log(panel.isHidden, panel.col, this.closest('th,td').dataset.col);
275
-
276
- if (panel.col === this.closest('th,td').dataset.col) {
277
- panel.close();
278
- }
279
- else {
280
- /**
281
- var cell = e.target.closest("th,td");
282
-
283
- var l = $(e.target).offset().left - $(this.#owner).offset().left;// - $(panel).width() + $(e.target).width() + 1;
284
- if (l < 0) l = 0;
285
- if (l + $(panel).width() > $(this.#owner).width()) l = $(this.#owner).width() - $(panel).width() - 5;
286
-
287
-
288
-
289
- var t = $(cell).offset().top + $(cell).height()- $(this.#owner).offset().top;//$(e.target).offset().top + $(e.target).height() + 2;
290
-
291
- //$(panel).offset({left: l, top: t});
292
- $(panel).css({left: l, top: t});
293
- */
294
- panel.open(this);
295
- }
162
+
163
+ (panel.col === this.closest('th,td').dataset.col) ? panel.close() : panel.open(this);
296
164
  };
297
165
  }
298
166