ninegrid2 6.246.0 → 6.247.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.
@@ -18114,12 +18114,7 @@ class ngFilterPanel extends HTMLElement
18114
18114
 
18115
18115
  grd.data.resetRecords();
18116
18116
 
18117
- if (this.#timer) {
18118
- console.log("-------------", this.#timer);
18119
- clearTimeout(this.#timer);
18120
- console.log("===============", this.#timer);
18121
- this.#timer = null;
18122
- }
18117
+ clearTimeout(this.#timer);
18123
18118
  this.#timer = setTimeout(() => {
18124
18119
  grd.dataManager.viewRecords.reset();
18125
18120
  grd.dataManager.viewRecords.touch();
@@ -18133,108 +18128,68 @@ class ngFilterPanel extends HTMLElement
18133
18128
 
18134
18129
  open = (filterButton) => {
18135
18130
 
18136
- //const owner = this.shadow.closest("nine-grid");
18137
-
18138
18131
  /** 위치 */
18139
18132
  const cell = filterButton.closest("th,td");
18140
18133
 
18141
- const filterButtonRect = filterButton.getBoundingClientRect();
18142
- const ownerRect = this.#owner.getBoundingClientRect();
18143
- const cellRect = cell.getBoundingClientRect();
18144
- const targetRect = this.getBoundingClientRect();
18145
-
18146
- let l = filterButtonRect.left - ownerRect.left;
18147
- if (l < 0) l = 0;
18148
- if (l + targetRect.width > ownerRect.width) l = ownerRect.width - targetRect.width - 5;
18149
-
18150
- const t = cellRect.top + cellRect.height - ownerRect.top;
18134
+ const { left: btnLeft } = filterButton.getBoundingClientRect();
18135
+ const { left: ownerLeft, width: ownerWidth, top: ownerTop } = this.#owner.getBoundingClientRect();
18136
+ const { top: cellTop, height: cellHeight } = cell.getBoundingClientRect();
18137
+ const { width: targetWidth } = this.getBoundingClientRect();
18151
18138
 
18152
- this.style.left = `${l}px`; // 위치 설정
18153
- this.style.top = `${t}px`;
18139
+ let l = Math.max(0, btnLeft - ownerLeft);
18140
+ l = Math.min(l, ownerWidth - targetWidth - 5);
18154
18141
 
18155
-
18156
-
18157
- //console.log(this, owner, filterButton.filterOptions, colnms);
18158
-
18159
- var col = filterButton.closest('th,td').dataset.col;
18160
- this.col = col;
18142
+ const t = cellTop + cellHeight - ownerTop;
18161
18143
 
18162
- this.#button = filterButton;
18163
-
18164
- this.style.display = 'flex';
18144
+ Object.assign(this.style, { left: `${l}px`, top: `${t}px`, display: "flex" });
18165
18145
  this.classList.add("loading");
18166
18146
 
18167
-
18168
18147
  this.shadowRoot.querySelector("input[type=text]").value = "";
18169
18148
 
18170
-
18171
- //$(this.shadowRoot).find("input[type=text]").val("");
18172
-
18173
18149
  setTimeout(() => {
18174
-
18150
+ const data = this.#owner.data.getValidDataNF();
18151
+ const col = cell.dataset.col;
18152
+ this.col = col;
18153
+ this.#button = filterButton;
18175
18154
 
18176
- let data = this.#owner.data.getValidDataNF();
18177
-
18178
- var ds = [];
18179
- filterButton.filterOptions.forEach((filterOption,i) => {
18180
-
18181
- ds.push({
18182
- LVL: 1,
18183
- CHK: 'N',
18184
- DATA2: '<span class="group">' + $(filterButton).closest('th,td').text() + (filterButton.filterOptions.length > 1 ? ` #${i+1} (${filterOption.colnm})` : '') + '</span>',
18185
- });
18155
+ const ds = filterButton.filterOptions.map((filterOption, i) => {
18156
+ const groupLabel = `<span class="group">${cell.textContent}${filterButton.filterOptions.length > 1 ? ` #${i + 1} (${filterOption.colnm})` : ""}</span>`;
18186
18157
 
18187
- /**
18188
- var cell = $(`[data-col=${col}][data-bind=${filterOption.colnm}]`, this.#owner.template);
18189
- var expr = cell.attr("data-expr");
18190
- var exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
18191
- */
18192
-
18193
- const cell = ninegrid.j.querySelectorAll(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`, this.#owner.tmpl).elem();
18194
- const expr = cell.getAttribute("data-expr");
18195
- const exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
18158
+ const cellEl = this.#owner.tmpl.querySelector(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`);
18159
+ const expr = cellEl?.getAttribute("data-expr");
18160
+ const exprFunc = expr ? this.#owner.exprFunction(expr) : null;
18196
18161
 
18197
- var data2 = [];
18198
- for (var rowData of data) {
18199
- var idx = this.#owner.fields.indexOf(filterOption.colnm);
18200
-
18201
- if (expr) {
18202
- var o = this.#owner.data.conv(rowData);
18203
- data2.push({v:o[filterOption.colnm],v2:exprFunc(o, rowData.__ng.rowidx, this.#owner.data)});
18204
- }
18205
- else {
18206
- data2.push({v:rowData.v[idx],v2:rowData.v[idx]});
18207
- }
18208
- }
18209
-
18210
- console.log(data, data2);
18211
-
18212
- [...new Set(data2.sort( (a,b) => { return (a.v2||'') > (b.v2||'') ? 1 : ((a.v2||'') < (b.v2||'') ? -1 : 0); } ).map((m) => JSON.stringify(m)))].map((m) => JSON.parse(m)).forEach(o => {
18213
- console.log(filterOption, o);
18214
- ds.push({
18215
- LVL : 2,
18216
- DATA : o.v,
18217
- DATA2 : o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
18218
- COLNM : filterOption.colnm,
18219
- CHK : filterOption.data.length == 0 || filterOption.data.nineBinarySearch(o.v || '') >= 0 ? "Y" : "N",
18220
- });
18162
+ const data2 = data.map(rowData => {
18163
+ const idx = this.#owner.fields.indexOf(filterOption.colnm);
18164
+ return expr ? { v: rowData.v[idx], v2: exprFunc(this.#owner.data.conv(rowData), rowData.__ng.rowidx, this.#owner.data) } : { v: rowData.v[idx], v2: rowData.v[idx] };
18221
18165
  });
18222
- });
18166
+
18167
+ return [
18168
+ { LVL: 1, CHK: "N", DATA2: groupLabel },
18169
+ ...[...new Set(data2.map(JSON.stringify))]
18170
+ .map(JSON.parse)
18171
+ .sort((a, b) => (a.v2 || "") > (b.v2 || "") ? 1 : (a.v2 || "") < (b.v2 || "") ? -1 : 0)
18172
+ .map(o => ({
18173
+ LVL: 2,
18174
+ DATA: o.v,
18175
+ DATA2: o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
18176
+ COLNM: filterOption.colnm,
18177
+ CHK: filterOption.data.length === 0 || filterOption.data.nineBinarySearch(o.v || "") >= 0 ? "Y" : "N",
18178
+ }))
18179
+ ];
18180
+ }).flat();
18223
18181
 
18224
18182
  const grd = this.shadowRoot.querySelector("nine-grid");
18225
18183
  //grd.dataSource = ds;
18226
18184
  grd.fields.add(["DATA","DATA2","COLNM"]);
18227
-
18228
18185
  grd.data.set(ds);
18229
18186
 
18230
18187
  // ✅ 데이터 필터링 및 체크 상태 결정
18231
18188
  const checkbox = this.shadowRoot.querySelector("input[type=checkbox]");
18232
- checkbox.checked = grd.data.getValidData().filter(item => item.LVL == 2 && item.CHK != "Y").length === 0; // ✅ 체크 상태 설정
18189
+ checkbox.checked = grd.data.getValidData().every(item => !(item.LVL === 2 && item.CHK !== "Y"));
18233
18190
 
18234
18191
  this.shadowRoot.querySelector("input").focus();
18235
-
18236
18192
  this.classList.remove("loading");
18237
- //ninegrid.j.querySelectorAll(this).removeClass("loading");
18238
18193
  });
18239
18194
  };
18240
18195
  }
@@ -18112,12 +18112,7 @@ class ngFilterPanel extends HTMLElement
18112
18112
 
18113
18113
  grd.data.resetRecords();
18114
18114
 
18115
- if (this.#timer) {
18116
- console.log("-------------", this.#timer);
18117
- clearTimeout(this.#timer);
18118
- console.log("===============", this.#timer);
18119
- this.#timer = null;
18120
- }
18115
+ clearTimeout(this.#timer);
18121
18116
  this.#timer = setTimeout(() => {
18122
18117
  grd.dataManager.viewRecords.reset();
18123
18118
  grd.dataManager.viewRecords.touch();
@@ -18131,108 +18126,68 @@ class ngFilterPanel extends HTMLElement
18131
18126
 
18132
18127
  open = (filterButton) => {
18133
18128
 
18134
- //const owner = this.shadow.closest("nine-grid");
18135
-
18136
18129
  /** 위치 */
18137
18130
  const cell = filterButton.closest("th,td");
18138
18131
 
18139
- const filterButtonRect = filterButton.getBoundingClientRect();
18140
- const ownerRect = this.#owner.getBoundingClientRect();
18141
- const cellRect = cell.getBoundingClientRect();
18142
- const targetRect = this.getBoundingClientRect();
18143
-
18144
- let l = filterButtonRect.left - ownerRect.left;
18145
- if (l < 0) l = 0;
18146
- if (l + targetRect.width > ownerRect.width) l = ownerRect.width - targetRect.width - 5;
18147
-
18148
- const t = cellRect.top + cellRect.height - ownerRect.top;
18132
+ const { left: btnLeft } = filterButton.getBoundingClientRect();
18133
+ const { left: ownerLeft, width: ownerWidth, top: ownerTop } = this.#owner.getBoundingClientRect();
18134
+ const { top: cellTop, height: cellHeight } = cell.getBoundingClientRect();
18135
+ const { width: targetWidth } = this.getBoundingClientRect();
18149
18136
 
18150
- this.style.left = `${l}px`; // 위치 설정
18151
- this.style.top = `${t}px`;
18137
+ let l = Math.max(0, btnLeft - ownerLeft);
18138
+ l = Math.min(l, ownerWidth - targetWidth - 5);
18152
18139
 
18153
-
18154
-
18155
- //console.log(this, owner, filterButton.filterOptions, colnms);
18156
-
18157
- var col = filterButton.closest('th,td').dataset.col;
18158
- this.col = col;
18140
+ const t = cellTop + cellHeight - ownerTop;
18159
18141
 
18160
- this.#button = filterButton;
18161
-
18162
- this.style.display = 'flex';
18142
+ Object.assign(this.style, { left: `${l}px`, top: `${t}px`, display: "flex" });
18163
18143
  this.classList.add("loading");
18164
18144
 
18165
-
18166
18145
  this.shadowRoot.querySelector("input[type=text]").value = "";
18167
18146
 
18168
-
18169
- //$(this.shadowRoot).find("input[type=text]").val("");
18170
-
18171
18147
  setTimeout(() => {
18172
-
18148
+ const data = this.#owner.data.getValidDataNF();
18149
+ const col = cell.dataset.col;
18150
+ this.col = col;
18151
+ this.#button = filterButton;
18173
18152
 
18174
- let data = this.#owner.data.getValidDataNF();
18175
-
18176
- var ds = [];
18177
- filterButton.filterOptions.forEach((filterOption,i) => {
18178
-
18179
- ds.push({
18180
- LVL: 1,
18181
- CHK: 'N',
18182
- DATA2: '<span class="group">' + $(filterButton).closest('th,td').text() + (filterButton.filterOptions.length > 1 ? ` #${i+1} (${filterOption.colnm})` : '') + '</span>',
18183
- });
18153
+ const ds = filterButton.filterOptions.map((filterOption, i) => {
18154
+ const groupLabel = `<span class="group">${cell.textContent}${filterButton.filterOptions.length > 1 ? ` #${i + 1} (${filterOption.colnm})` : ""}</span>`;
18184
18155
 
18185
- /**
18186
- var cell = $(`[data-col=${col}][data-bind=${filterOption.colnm}]`, this.#owner.template);
18187
- var expr = cell.attr("data-expr");
18188
- var exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
18189
- */
18190
-
18191
- const cell = ninegrid.j.querySelectorAll(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`, this.#owner.tmpl).elem();
18192
- const expr = cell.getAttribute("data-expr");
18193
- const exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
18156
+ const cellEl = this.#owner.tmpl.querySelector(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`);
18157
+ const expr = cellEl?.getAttribute("data-expr");
18158
+ const exprFunc = expr ? this.#owner.exprFunction(expr) : null;
18194
18159
 
18195
- var data2 = [];
18196
- for (var rowData of data) {
18197
- var idx = this.#owner.fields.indexOf(filterOption.colnm);
18198
-
18199
- if (expr) {
18200
- var o = this.#owner.data.conv(rowData);
18201
- data2.push({v:o[filterOption.colnm],v2:exprFunc(o, rowData.__ng.rowidx, this.#owner.data)});
18202
- }
18203
- else {
18204
- data2.push({v:rowData.v[idx],v2:rowData.v[idx]});
18205
- }
18206
- }
18207
-
18208
- console.log(data, data2);
18209
-
18210
- [...new Set(data2.sort( (a,b) => { return (a.v2||'') > (b.v2||'') ? 1 : ((a.v2||'') < (b.v2||'') ? -1 : 0); } ).map((m) => JSON.stringify(m)))].map((m) => JSON.parse(m)).forEach(o => {
18211
- console.log(filterOption, o);
18212
- ds.push({
18213
- LVL : 2,
18214
- DATA : o.v,
18215
- DATA2 : o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
18216
- COLNM : filterOption.colnm,
18217
- CHK : filterOption.data.length == 0 || filterOption.data.nineBinarySearch(o.v || '') >= 0 ? "Y" : "N",
18218
- });
18160
+ const data2 = data.map(rowData => {
18161
+ const idx = this.#owner.fields.indexOf(filterOption.colnm);
18162
+ return expr ? { v: rowData.v[idx], v2: exprFunc(this.#owner.data.conv(rowData), rowData.__ng.rowidx, this.#owner.data) } : { v: rowData.v[idx], v2: rowData.v[idx] };
18219
18163
  });
18220
- });
18164
+
18165
+ return [
18166
+ { LVL: 1, CHK: "N", DATA2: groupLabel },
18167
+ ...[...new Set(data2.map(JSON.stringify))]
18168
+ .map(JSON.parse)
18169
+ .sort((a, b) => (a.v2 || "") > (b.v2 || "") ? 1 : (a.v2 || "") < (b.v2 || "") ? -1 : 0)
18170
+ .map(o => ({
18171
+ LVL: 2,
18172
+ DATA: o.v,
18173
+ DATA2: o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
18174
+ COLNM: filterOption.colnm,
18175
+ CHK: filterOption.data.length === 0 || filterOption.data.nineBinarySearch(o.v || "") >= 0 ? "Y" : "N",
18176
+ }))
18177
+ ];
18178
+ }).flat();
18221
18179
 
18222
18180
  const grd = this.shadowRoot.querySelector("nine-grid");
18223
18181
  //grd.dataSource = ds;
18224
18182
  grd.fields.add(["DATA","DATA2","COLNM"]);
18225
-
18226
18183
  grd.data.set(ds);
18227
18184
 
18228
18185
  // ✅ 데이터 필터링 및 체크 상태 결정
18229
18186
  const checkbox = this.shadowRoot.querySelector("input[type=checkbox]");
18230
- checkbox.checked = grd.data.getValidData().filter(item => item.LVL == 2 && item.CHK != "Y").length === 0; // ✅ 체크 상태 설정
18187
+ checkbox.checked = grd.data.getValidData().every(item => !(item.LVL === 2 && item.CHK !== "Y"));
18231
18188
 
18232
18189
  this.shadowRoot.querySelector("input").focus();
18233
-
18234
18190
  this.classList.remove("loading");
18235
- //ninegrid.j.querySelectorAll(this).removeClass("loading");
18236
18191
  });
18237
18192
  };
18238
18193
  }
@@ -291,12 +291,7 @@ class ngFilterPanel extends HTMLElement
291
291
 
292
292
  grd.data.resetRecords();
293
293
 
294
- if (this.#timer) {
295
- console.log("-------------", this.#timer);
296
- clearTimeout(this.#timer);
297
- console.log("===============", this.#timer);
298
- this.#timer = null;
299
- }
294
+ clearTimeout(this.#timer);
300
295
  this.#timer = setTimeout(() => {
301
296
  grd.dataManager.viewRecords.reset();
302
297
  grd.dataManager.viewRecords.touch();
@@ -310,108 +305,68 @@ class ngFilterPanel extends HTMLElement
310
305
 
311
306
  open = (filterButton) => {
312
307
 
313
- //const owner = this.shadow.closest("nine-grid");
314
-
315
308
  /** 위치 */
316
309
  const cell = filterButton.closest("th,td");
317
310
 
318
- const filterButtonRect = filterButton.getBoundingClientRect();
319
- const ownerRect = this.#owner.getBoundingClientRect();
320
- const cellRect = cell.getBoundingClientRect();
321
- const targetRect = this.getBoundingClientRect();
322
-
323
- let l = filterButtonRect.left - ownerRect.left;
324
- if (l < 0) l = 0;
325
- if (l + targetRect.width > ownerRect.width) l = ownerRect.width - targetRect.width - 5;
326
-
327
- const t = cellRect.top + cellRect.height - ownerRect.top;
311
+ const { left: btnLeft } = filterButton.getBoundingClientRect();
312
+ const { left: ownerLeft, width: ownerWidth, top: ownerTop } = this.#owner.getBoundingClientRect();
313
+ const { top: cellTop, height: cellHeight } = cell.getBoundingClientRect();
314
+ const { width: targetWidth } = this.getBoundingClientRect();
328
315
 
329
- this.style.left = `${l}px`; // 위치 설정
330
- this.style.top = `${t}px`;
331
-
332
-
316
+ let l = Math.max(0, btnLeft - ownerLeft);
317
+ l = Math.min(l, ownerWidth - targetWidth - 5);
333
318
 
334
- //console.log(this, owner, filterButton.filterOptions, colnms);
335
-
336
- var col = filterButton.closest('th,td').dataset.col;
337
- this.col = col;
319
+ const t = cellTop + cellHeight - ownerTop;
338
320
 
339
- this.#button = filterButton;
340
-
341
- this.style.display = 'flex';
321
+ Object.assign(this.style, { left: `${l}px`, top: `${t}px`, display: "flex" });
342
322
  this.classList.add("loading");
343
323
 
344
-
345
324
  this.shadowRoot.querySelector("input[type=text]").value = "";
346
325
 
347
-
348
- //$(this.shadowRoot).find("input[type=text]").val("");
349
-
350
326
  setTimeout(() => {
351
-
352
-
353
- let data = this.#owner.data.getValidDataNF();
327
+ const data = this.#owner.data.getValidDataNF();
328
+ const col = cell.dataset.col;
329
+ this.col = col;
330
+ this.#button = filterButton;
354
331
 
355
- var ds = [];
356
- filterButton.filterOptions.forEach((filterOption,i) => {
332
+ const ds = filterButton.filterOptions.map((filterOption, i) => {
333
+ const groupLabel = `<span class="group">${cell.textContent}${filterButton.filterOptions.length > 1 ? ` #${i + 1} (${filterOption.colnm})` : ""}</span>`;
357
334
 
358
- ds.push({
359
- LVL: 1,
360
- CHK: 'N',
361
- DATA2: '<span class="group">' + $(filterButton).closest('th,td').text() + (filterButton.filterOptions.length > 1 ? ` #${i+1} (${filterOption.colnm})` : '') + '</span>',
362
- });
363
-
364
- /**
365
- var cell = $(`[data-col=${col}][data-bind=${filterOption.colnm}]`, this.#owner.template);
366
- var expr = cell.attr("data-expr");
367
- var exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
368
- */
369
-
370
- const cell = ninegrid.j.querySelectorAll(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`, this.#owner.tmpl).elem();
371
- const expr = cell.getAttribute("data-expr");
372
- const exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
373
-
374
- var data2 = [];
375
- for (var rowData of data) {
376
- var idx = this.#owner.fields.indexOf(filterOption.colnm);
377
-
378
- if (expr) {
379
- var o = this.#owner.data.conv(rowData);
380
- data2.push({v:o[filterOption.colnm],v2:exprFunc(o, rowData.__ng.rowidx, this.#owner.data)});
381
- }
382
- else {
383
- data2.push({v:rowData.v[idx],v2:rowData.v[idx]});
384
- }
385
- }
335
+ const cellEl = this.#owner.tmpl.querySelector(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`);
336
+ const expr = cellEl?.getAttribute("data-expr");
337
+ const exprFunc = expr ? this.#owner.exprFunction(expr) : null;
386
338
 
387
- console.log(data, data2);
388
-
389
- [...new Set(data2.sort( (a,b) => { return (a.v2||'') > (b.v2||'') ? 1 : ((a.v2||'') < (b.v2||'') ? -1 : 0); } ).map((m) => JSON.stringify(m)))].map((m) => JSON.parse(m)).forEach(o => {
390
- console.log(filterOption, o);
391
- ds.push({
392
- LVL : 2,
393
- DATA : o.v,
394
- DATA2 : o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
395
- COLNM : filterOption.colnm,
396
- CHK : filterOption.data.length == 0 || filterOption.data.nineBinarySearch(o.v || '') >= 0 ? "Y" : "N",
397
- });
339
+ const data2 = data.map(rowData => {
340
+ const idx = this.#owner.fields.indexOf(filterOption.colnm);
341
+ return expr ? { v: rowData.v[idx], v2: exprFunc(this.#owner.data.conv(rowData), rowData.__ng.rowidx, this.#owner.data) } : { v: rowData.v[idx], v2: rowData.v[idx] };
398
342
  });
399
- });
343
+
344
+ return [
345
+ { LVL: 1, CHK: "N", DATA2: groupLabel },
346
+ ...[...new Set(data2.map(JSON.stringify))]
347
+ .map(JSON.parse)
348
+ .sort((a, b) => (a.v2 || "") > (b.v2 || "") ? 1 : (a.v2 || "") < (b.v2 || "") ? -1 : 0)
349
+ .map(o => ({
350
+ LVL: 2,
351
+ DATA: o.v,
352
+ DATA2: o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
353
+ COLNM: filterOption.colnm,
354
+ CHK: filterOption.data.length === 0 || filterOption.data.nineBinarySearch(o.v || "") >= 0 ? "Y" : "N",
355
+ }))
356
+ ];
357
+ }).flat();
400
358
 
401
359
  const grd = this.shadowRoot.querySelector("nine-grid");
402
360
  //grd.dataSource = ds;
403
361
  grd.fields.add(["DATA","DATA2","COLNM"]);
404
-
405
362
  grd.data.set(ds);
406
363
 
407
364
  // ✅ 데이터 필터링 및 체크 상태 결정
408
365
  const checkbox = this.shadowRoot.querySelector("input[type=checkbox]");
409
- checkbox.checked = grd.data.getValidData().filter(item => item.LVL == 2 && item.CHK != "Y").length === 0; // ✅ 체크 상태 설정
366
+ checkbox.checked = grd.data.getValidData().every(item => !(item.LVL === 2 && item.CHK !== "Y"));
410
367
 
411
368
  this.shadowRoot.querySelector("input").focus();
412
-
413
369
  this.classList.remove("loading");
414
- //ninegrid.j.querySelectorAll(this).removeClass("loading");
415
370
  });
416
371
  };
417
372
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ninegrid2",
3
3
  "type": "module",
4
- "version": "6.246.0",
4
+ "version": "6.247.0",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
7
7
  "import": "./dist/index.js",
@@ -291,12 +291,7 @@ class ngFilterPanel extends HTMLElement
291
291
 
292
292
  grd.data.resetRecords();
293
293
 
294
- if (this.#timer) {
295
- console.log("-------------", this.#timer);
296
- clearTimeout(this.#timer);
297
- console.log("===============", this.#timer);
298
- this.#timer = null;
299
- }
294
+ clearTimeout(this.#timer);
300
295
  this.#timer = setTimeout(() => {
301
296
  grd.dataManager.viewRecords.reset();
302
297
  grd.dataManager.viewRecords.touch();
@@ -310,108 +305,68 @@ class ngFilterPanel extends HTMLElement
310
305
 
311
306
  open = (filterButton) => {
312
307
 
313
- //const owner = this.shadow.closest("nine-grid");
314
-
315
308
  /** 위치 */
316
309
  const cell = filterButton.closest("th,td");
317
310
 
318
- const filterButtonRect = filterButton.getBoundingClientRect();
319
- const ownerRect = this.#owner.getBoundingClientRect();
320
- const cellRect = cell.getBoundingClientRect();
321
- const targetRect = this.getBoundingClientRect();
322
-
323
- let l = filterButtonRect.left - ownerRect.left;
324
- if (l < 0) l = 0;
325
- if (l + targetRect.width > ownerRect.width) l = ownerRect.width - targetRect.width - 5;
326
-
327
- const t = cellRect.top + cellRect.height - ownerRect.top;
311
+ const { left: btnLeft } = filterButton.getBoundingClientRect();
312
+ const { left: ownerLeft, width: ownerWidth, top: ownerTop } = this.#owner.getBoundingClientRect();
313
+ const { top: cellTop, height: cellHeight } = cell.getBoundingClientRect();
314
+ const { width: targetWidth } = this.getBoundingClientRect();
328
315
 
329
- this.style.left = `${l}px`; // 위치 설정
330
- this.style.top = `${t}px`;
331
-
332
-
316
+ let l = Math.max(0, btnLeft - ownerLeft);
317
+ l = Math.min(l, ownerWidth - targetWidth - 5);
333
318
 
334
- //console.log(this, owner, filterButton.filterOptions, colnms);
335
-
336
- var col = filterButton.closest('th,td').dataset.col;
337
- this.col = col;
319
+ const t = cellTop + cellHeight - ownerTop;
338
320
 
339
- this.#button = filterButton;
340
-
341
- this.style.display = 'flex';
321
+ Object.assign(this.style, { left: `${l}px`, top: `${t}px`, display: "flex" });
342
322
  this.classList.add("loading");
343
323
 
344
-
345
324
  this.shadowRoot.querySelector("input[type=text]").value = "";
346
325
 
347
-
348
- //$(this.shadowRoot).find("input[type=text]").val("");
349
-
350
326
  setTimeout(() => {
351
-
352
-
353
- let data = this.#owner.data.getValidDataNF();
327
+ const data = this.#owner.data.getValidDataNF();
328
+ const col = cell.dataset.col;
329
+ this.col = col;
330
+ this.#button = filterButton;
354
331
 
355
- var ds = [];
356
- filterButton.filterOptions.forEach((filterOption,i) => {
332
+ const ds = filterButton.filterOptions.map((filterOption, i) => {
333
+ const groupLabel = `<span class="group">${cell.textContent}${filterButton.filterOptions.length > 1 ? ` #${i + 1} (${filterOption.colnm})` : ""}</span>`;
357
334
 
358
- ds.push({
359
- LVL: 1,
360
- CHK: 'N',
361
- DATA2: '<span class="group">' + $(filterButton).closest('th,td').text() + (filterButton.filterOptions.length > 1 ? ` #${i+1} (${filterOption.colnm})` : '') + '</span>',
362
- });
363
-
364
- /**
365
- var cell = $(`[data-col=${col}][data-bind=${filterOption.colnm}]`, this.#owner.template);
366
- var expr = cell.attr("data-expr");
367
- var exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
368
- */
369
-
370
- const cell = ninegrid.j.querySelectorAll(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`, this.#owner.tmpl).elem();
371
- const expr = cell.getAttribute("data-expr");
372
- const exprFunc = (expr) ? this.#owner.exprFunction(expr) : null;
373
-
374
- var data2 = [];
375
- for (var rowData of data) {
376
- var idx = this.#owner.fields.indexOf(filterOption.colnm);
377
-
378
- if (expr) {
379
- var o = this.#owner.data.conv(rowData);
380
- data2.push({v:o[filterOption.colnm],v2:exprFunc(o, rowData.__ng.rowidx, this.#owner.data)});
381
- }
382
- else {
383
- data2.push({v:rowData.v[idx],v2:rowData.v[idx]});
384
- }
385
- }
335
+ const cellEl = this.#owner.tmpl.querySelector(`[data-col="${col}"][data-bind="${filterOption.colnm}"]`);
336
+ const expr = cellEl?.getAttribute("data-expr");
337
+ const exprFunc = expr ? this.#owner.exprFunction(expr) : null;
386
338
 
387
- console.log(data, data2);
388
-
389
- [...new Set(data2.sort( (a,b) => { return (a.v2||'') > (b.v2||'') ? 1 : ((a.v2||'') < (b.v2||'') ? -1 : 0); } ).map((m) => JSON.stringify(m)))].map((m) => JSON.parse(m)).forEach(o => {
390
- console.log(filterOption, o);
391
- ds.push({
392
- LVL : 2,
393
- DATA : o.v,
394
- DATA2 : o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
395
- COLNM : filterOption.colnm,
396
- CHK : filterOption.data.length == 0 || filterOption.data.nineBinarySearch(o.v || '') >= 0 ? "Y" : "N",
397
- });
339
+ const data2 = data.map(rowData => {
340
+ const idx = this.#owner.fields.indexOf(filterOption.colnm);
341
+ return expr ? { v: rowData.v[idx], v2: exprFunc(this.#owner.data.conv(rowData), rowData.__ng.rowidx, this.#owner.data) } : { v: rowData.v[idx], v2: rowData.v[idx] };
398
342
  });
399
- });
343
+
344
+ return [
345
+ { LVL: 1, CHK: "N", DATA2: groupLabel },
346
+ ...[...new Set(data2.map(JSON.stringify))]
347
+ .map(JSON.parse)
348
+ .sort((a, b) => (a.v2 || "") > (b.v2 || "") ? 1 : (a.v2 || "") < (b.v2 || "") ? -1 : 0)
349
+ .map(o => ({
350
+ LVL: 2,
351
+ DATA: o.v,
352
+ DATA2: o.v2 || ` <span class="empty">(empty)</span> ${o.v}`,
353
+ COLNM: filterOption.colnm,
354
+ CHK: filterOption.data.length === 0 || filterOption.data.nineBinarySearch(o.v || "") >= 0 ? "Y" : "N",
355
+ }))
356
+ ];
357
+ }).flat();
400
358
 
401
359
  const grd = this.shadowRoot.querySelector("nine-grid");
402
360
  //grd.dataSource = ds;
403
361
  grd.fields.add(["DATA","DATA2","COLNM"]);
404
-
405
362
  grd.data.set(ds);
406
363
 
407
364
  // ✅ 데이터 필터링 및 체크 상태 결정
408
365
  const checkbox = this.shadowRoot.querySelector("input[type=checkbox]");
409
- checkbox.checked = grd.data.getValidData().filter(item => item.LVL == 2 && item.CHK != "Y").length === 0; // ✅ 체크 상태 설정
366
+ checkbox.checked = grd.data.getValidData().every(item => !(item.LVL === 2 && item.CHK !== "Y"));
410
367
 
411
368
  this.shadowRoot.querySelector("input").focus();
412
-
413
369
  this.classList.remove("loading");
414
- //ninegrid.j.querySelectorAll(this).removeClass("loading");
415
370
  });
416
371
  };
417
372
  }