open-grid 1.0.7 → 1.1.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/OpenGrid-5flQwc3W.js +8434 -0
  3. package/dist/OpenGrid-DahxRY7C.cjs +92 -0
  4. package/dist/open-grid-base.css +61 -0
  5. package/dist/open-grid-react.cjs +1 -1
  6. package/dist/open-grid-react.js +1 -1
  7. package/dist/open-grid-themes.css +96 -1
  8. package/dist/open-grid-vue.cjs +1 -1
  9. package/dist/open-grid-vue.js +1 -1
  10. package/dist/open-grid.cjs +1 -1
  11. package/dist/open-grid.js +2 -2
  12. package/dist/types/core/CellEditManager.d.ts +4 -0
  13. package/dist/types/core/CellEventHandler.d.ts +6 -0
  14. package/dist/types/core/ChartManager.d.ts +58 -0
  15. package/dist/types/core/DataLayer.d.ts +17 -0
  16. package/dist/types/core/DetailManager.d.ts +72 -0
  17. package/dist/types/core/FlatRowModel.d.ts +56 -0
  18. package/dist/types/core/GridRenderer.d.ts +34 -1
  19. package/dist/types/core/GroupTreeManager.d.ts +13 -0
  20. package/dist/types/core/KeyboardManager.d.ts +19 -0
  21. package/dist/types/core/OpenGrid.d.ts +109 -1
  22. package/dist/types/core/RangeSelectionManager.d.ts +95 -0
  23. package/dist/types/core/SortFilterManager.d.ts +2 -0
  24. package/dist/types/core/chart/CanvasAdapter.d.ts +52 -0
  25. package/dist/types/core/chart/DataExtractor.d.ts +49 -0
  26. package/dist/types/core/chart/a11y.d.ts +21 -0
  27. package/dist/types/core/chart/downsample.d.ts +25 -0
  28. package/dist/types/core/chart/hittest.d.ts +20 -0
  29. package/dist/types/core/chart/palette.d.ts +56 -0
  30. package/dist/types/core/chart/scales.d.ts +24 -0
  31. package/dist/types/core/chart/types.d.ts +181 -0
  32. package/dist/types/core/detail/DetailGlyph.d.ts +48 -0
  33. package/dist/types/core/detail/DetailSplice.d.ts +67 -0
  34. package/dist/types/core/detail/DetailState.d.ts +67 -0
  35. package/dist/types/core/detail/SubgridCache.d.ts +73 -0
  36. package/dist/types/core/detail/index.d.ts +14 -0
  37. package/dist/types/core/formula/FormulaEvaluator.d.ts +15 -0
  38. package/dist/types/core/formula/FormulaGraph.d.ts +43 -0
  39. package/dist/types/core/formula/FormulaParser.d.ts +6 -0
  40. package/dist/types/core/formula/FormulaStore.d.ts +17 -0
  41. package/dist/types/core/formula/RecalcCoordinator.d.ts +85 -0
  42. package/dist/types/core/formula/normalizeRefs.d.ts +15 -0
  43. package/dist/types/core/formula/numericLiteral.d.ts +7 -0
  44. package/dist/types/core/formula/serializeFormula.d.ts +6 -0
  45. package/dist/types/core/formula/types.d.ts +104 -0
  46. package/dist/types/core/range/ClipboardCodec.d.ts +30 -0
  47. package/dist/types/core/range/FillEngine.d.ts +63 -0
  48. package/dist/types/core/range/RangeModel.d.ts +53 -0
  49. package/dist/types/core/range/RangeQuery.d.ts +16 -0
  50. package/dist/types/core/range/types.d.ts +47 -0
  51. package/dist/types/core/renderers/CellRenderer.d.ts +3 -0
  52. package/dist/types/core/types.d.ts +242 -0
  53. package/dist/types/index.d.ts +2 -1
  54. package/package.json +1 -1
  55. package/dist/OpenGrid-tdspERot.cjs +0 -90
  56. package/dist/OpenGrid-zBt01Yim.js +0 -4867
@@ -1,4867 +0,0 @@
1
- class oe {
2
- constructor() {
3
- this.listeners = /* @__PURE__ */ new Map();
4
- }
5
- on(t, e) {
6
- const s = this.listeners.get(t) ?? [];
7
- return s.push({ handler: e, once: !1 }), this.listeners.set(t, s), this;
8
- }
9
- once(t, e) {
10
- const s = this.listeners.get(t) ?? [];
11
- return s.push({ handler: e, once: !0 }), this.listeners.set(t, s), this;
12
- }
13
- off(t, e) {
14
- if (!e)
15
- return this.listeners.delete(t), this;
16
- const s = this.listeners.get(t);
17
- if (s) {
18
- const i = s.filter((o) => o.handler !== e);
19
- i.length === 0 ? this.listeners.delete(t) : this.listeners.set(t, i);
20
- }
21
- return this;
22
- }
23
- emit(t, ...e) {
24
- const s = this.listeners.get(t);
25
- if (!s || s.length === 0) return !1;
26
- const i = [];
27
- for (const o of s)
28
- o.handler(...e), o.once || i.push(o);
29
- return i.length !== s.length && (i.length === 0 ? this.listeners.delete(t) : this.listeners.set(t, i)), !0;
30
- }
31
- removeAllListeners(t) {
32
- return t ? this.listeners.delete(t) : this.listeners.clear(), this;
33
- }
34
- listenerCount(t) {
35
- var e;
36
- return ((e = this.listeners.get(t)) == null ? void 0 : e.length) ?? 0;
37
- }
38
- }
39
- let ne = 0;
40
- function St() {
41
- return `og-r-${++ne}`;
42
- }
43
- class re {
44
- constructor(t = "_ogRowId") {
45
- this._data = [], this._original = [], this._meta = /* @__PURE__ */ new Map(), this._displayIndexes = [], this._idMap = /* @__PURE__ */ new Map(), this._findQuery = "", this._findFields = [], this._getStrategy = (e, s) => s, this._idField = t;
46
- }
47
- /** Phase 2: OpenGrid 가 OverrideKernel.getStrategy 를 주입(슬롯 sortComparator/filterPredicate 도달용). */
48
- setStrategyResolver(t) {
49
- this._getStrategy = t;
50
- }
51
- // ─── 데이터 설정 ──────────────────────────────────────
52
- setData(t) {
53
- this._data = t.map((e) => {
54
- const s = St(), i = { ...e, [this._idField]: s };
55
- return this._meta.set(s, { state: "none", rowId: s }), i;
56
- }), this._original = this._data.map((e) => ({ ...e })), this._rebuildIdMap(), this._displayIndexes = this._data.map((e, s) => s);
57
- }
58
- getData() {
59
- return this._displayIndexes.map((t) => this._data[t]);
60
- }
61
- getOriginalData() {
62
- return [...this._original];
63
- }
64
- getAllData() {
65
- return [...this._data];
66
- }
67
- clearData() {
68
- this._data = [], this._original = [], this._meta.clear(), this._idMap.clear(), this._displayIndexes = [];
69
- }
70
- get rowCount() {
71
- return this._displayIndexes.length;
72
- }
73
- get totalRowCount() {
74
- return this._data.length;
75
- }
76
- // ─── 행 CRUD ──────────────────────────────────────────
77
- addRow(t, e = "last") {
78
- const s = St(), i = { ...t, [this._idField]: s };
79
- if (this._meta.set(s, { state: "added", rowId: s }), e === "last") {
80
- const o = this._data.push(i) - 1;
81
- this._idMap.set(s, o), this._displayIndexes.push(o);
82
- } else if (e === "first")
83
- this._data.unshift(i), this._rebuildIdMap(), this._displayIndexes.unshift(0);
84
- else {
85
- const o = Math.min(e, this._displayIndexes.length), n = o < this._displayIndexes.length ? this._displayIndexes[o] : this._data.length;
86
- this._data.splice(n, 0, i), this._rebuildIdMap(), this._displayIndexes = this._data.map((r, l) => l);
87
- }
88
- }
89
- removeRow(t) {
90
- const e = this._displayIndexes[t];
91
- if (e === void 0) return;
92
- const s = this._data[e], i = s[this._idField], o = this._meta.get(i);
93
- return (o == null ? void 0 : o.state) === "added" ? (this._data.splice(e, 1), this._meta.delete(i)) : this._meta.set(i, { ...o, state: "removed" }), this._rebuildIdMap(), this._displayIndexes = this._data.map((n, r) => ({ r: n, i: r })).filter(({ r: n }) => {
94
- var r;
95
- return ((r = this._meta.get(n[this._idField])) == null ? void 0 : r.state) !== "removed";
96
- }).map(({ i: n }) => n), s;
97
- }
98
- moveRow(t, e) {
99
- const s = this._displayIndexes[t], i = this._displayIndexes[e];
100
- if (s === void 0 || i === void 0) return;
101
- const [o] = this._data.splice(s, 1), n = s < i ? i - 1 : i;
102
- this._data.splice(n, 0, o), this._rebuildIdMap(), this._displayIndexes = this._data.map((r, l) => ({ r, i: l })).filter(({ r }) => {
103
- var l;
104
- return ((l = this._meta.get(r[this._idField])) == null ? void 0 : l.state) !== "removed";
105
- }).map(({ i: r }) => r);
106
- }
107
- updateCell(t, e, s) {
108
- const i = this._displayIndexes[t];
109
- if (i === void 0) return !1;
110
- const n = this._data[i][this._idField], r = this._meta.get(n);
111
- return (r == null ? void 0 : r.state) === "none" && this._meta.set(n, {
112
- ...r,
113
- state: "edited",
114
- original: { ...this._original[i] }
115
- }), this._data[i][e] = s, !0;
116
- }
117
- getRowByIndex(t) {
118
- const e = this._displayIndexes[t];
119
- return e !== void 0 ? this._data[e] : void 0;
120
- }
121
- getCellValue(t, e) {
122
- var s;
123
- return (s = this.getRowByIndex(t)) == null ? void 0 : s[e];
124
- }
125
- // ─── 변경 추적 ────────────────────────────────────────
126
- /** 수정된 행만 반환 (추가/삭제 제외) */
127
- getEditedRows() {
128
- return this._data.filter(
129
- (t) => {
130
- var e;
131
- return ((e = this._meta.get(t[this._idField])) == null ? void 0 : e.state) === "edited";
132
- }
133
- );
134
- }
135
- /** 수정된 행만 반환 (하위 호환용 — 신규 코드는 getEditedRows() 사용) */
136
- getChangedRows() {
137
- return this.getEditedRows();
138
- }
139
- getAddedRows() {
140
- return this._data.filter(
141
- (t) => {
142
- var e;
143
- return ((e = this._meta.get(t[this._idField])) == null ? void 0 : e.state) === "added";
144
- }
145
- );
146
- }
147
- getRemovedRows() {
148
- return this._data.filter(
149
- (t) => {
150
- var e;
151
- return ((e = this._meta.get(t[this._idField])) == null ? void 0 : e.state) === "removed";
152
- }
153
- );
154
- }
155
- /**
156
- * 추가/수정/삭제 모든 변경사항을 한 번에 반환.
157
- * edited 행에는 _changedFields 배열도 포함.
158
- */
159
- getChanges() {
160
- const t = [], e = [], s = [];
161
- for (const i of this._data) {
162
- const o = i[this._idField], n = this._meta.get(o), r = (n == null ? void 0 : n.state) ?? "none";
163
- if (r === "added")
164
- t.push({ ...i });
165
- else if (r === "removed")
166
- s.push({ ...i });
167
- else if (r === "edited") {
168
- const l = n.original ?? {}, a = Object.keys(i).filter(
169
- (c) => c !== this._idField && i[c] !== l[c]
170
- );
171
- e.push({ ...i, _changedFields: a });
172
- }
173
- }
174
- return { added: t, edited: e, removed: s };
175
- }
176
- /**
177
- * 수정된 컬럼 정보 반환 — 각 edited 행에 대해 { row, fields, diff } 반환.
178
- * diff: { field, oldValue, newValue }[]
179
- */
180
- getChangedColumns() {
181
- return this._data.filter((t) => {
182
- var e;
183
- return ((e = this._meta.get(t[this._idField])) == null ? void 0 : e.state) === "edited";
184
- }).map((t) => {
185
- var i;
186
- const e = ((i = this._meta.get(t[this._idField])) == null ? void 0 : i.original) ?? {}, s = [];
187
- for (const o of Object.keys(t))
188
- o !== this._idField && t[o] !== e[o] && s.push({ field: o, oldValue: e[o], newValue: t[o] });
189
- return { row: { ...t }, fields: s.map((o) => o.field), diff: s };
190
- });
191
- }
192
- /** rowIndex 행의 원본(수정 전) 데이터 반환. 추가된 행은 undefined. */
193
- getOriginalRow(t) {
194
- const e = this._displayIndexes[t];
195
- if (e === void 0) return;
196
- const s = this._data[e], i = this._meta.get(s[this._idField]);
197
- if (!(!i || i.state === "added"))
198
- return i.state === "edited" && i.original ? { ...i.original } : { ...this._original[e] };
199
- }
200
- getRowsWithState(t) {
201
- return this._data.map((e) => {
202
- var i;
203
- const s = ((i = this._meta.get(e[this._idField])) == null ? void 0 : i.state) ?? "none";
204
- return { ...e, [t]: s };
205
- });
206
- }
207
- getRowState(t) {
208
- var s;
209
- const e = this.getRowByIndex(t);
210
- return e ? ((s = this._meta.get(e[this._idField])) == null ? void 0 : s.state) ?? "none" : "none";
211
- }
212
- // ─── 정렬 ─────────────────────────────────────────────
213
- applySort(t) {
214
- const e = (o) => {
215
- var n, r;
216
- return ((r = this._meta.get((n = this._data[o]) == null ? void 0 : n[this._idField])) == null ? void 0 : r.state) !== "removed";
217
- };
218
- if (t.length === 0) {
219
- this._displayIndexes = this._data.map((o, n) => n).filter(e);
220
- return;
221
- }
222
- const s = this._displayIndexes.filter(e).map((o) => {
223
- const n = this._data[o];
224
- return {
225
- idx: o,
226
- keys: t.map((r) => n[r.field])
227
- };
228
- }), i = this._getStrategy(
229
- "sortComparator",
230
- (o, n, r, l) => {
231
- if (o == null && n == null) return 0;
232
- if (o == null) return -1;
233
- if (n == null) return 1;
234
- if (typeof o == "number" && typeof n == "number") return o - n;
235
- const a = String(o), c = String(n);
236
- return a < c ? -1 : a > c ? 1 : 0;
237
- }
238
- );
239
- s.sort((o, n) => {
240
- for (let r = 0; r < t.length; r++) {
241
- const l = t[r].dir, a = t[r].field, c = o.keys[r], u = n.keys[r], h = i(c, u, a, l);
242
- if (h !== 0) return l === "asc" ? h : -h;
243
- }
244
- return 0;
245
- }), this._displayIndexes = s.map((o) => o.idx);
246
- }
247
- // ─── 필터 ─────────────────────────────────────────────
248
- applyFilter(t) {
249
- const e = Object.keys(t), s = this._getStrategy(
250
- "filterPredicate",
251
- (i, o, n) => le(i, o)
252
- );
253
- this._displayIndexes = this._data.map((i, o) => ({ r: i, i: o })).filter(({ r: i }) => {
254
- var o;
255
- if (((o = this._meta.get(i[this._idField])) == null ? void 0 : o.state) === "removed" || e.length > 0 && !e.every((n) => {
256
- const r = i[n];
257
- return t[n].every((l) => s(r, l, n));
258
- }))
259
- return !1;
260
- if (this._findQuery && this._findFields.length > 0) {
261
- const n = this._findQuery;
262
- if (!this._findFields.some((l) => {
263
- const a = i[l];
264
- return a != null && String(a).toLowerCase().includes(n);
265
- })) return !1;
266
- }
267
- return !0;
268
- }).map(({ i }) => i);
269
- }
270
- /** F3: 찾기 바 전체 컬럼 OR 검색 설정 */
271
- setFindFilter(t, e) {
272
- this._findQuery = t.toLowerCase(), this._findFields = e;
273
- }
274
- // ─── 내부 유틸 ────────────────────────────────────────
275
- _rebuildIdMap() {
276
- this._idMap.clear(), this._data.forEach((t, e) => {
277
- this._idMap.set(t[this._idField], e);
278
- });
279
- }
280
- }
281
- function le(d, t) {
282
- const e = d, s = t.value;
283
- switch (t.operator) {
284
- case "=":
285
- return e == s;
286
- case "!=":
287
- return e != s;
288
- case ">":
289
- return e > s;
290
- case ">=":
291
- return e >= s;
292
- case "<":
293
- return e < s;
294
- case "<=":
295
- return e <= s;
296
- case "contains":
297
- return String(e).includes(String(s));
298
- case "startsWith":
299
- return String(e).startsWith(String(s));
300
- case "endsWith":
301
- return String(e).endsWith(String(s));
302
- default:
303
- return !0;
304
- }
305
- }
306
- class ae {
307
- constructor(t, e) {
308
- this._totalRows = 0, this._scrollTop = 0, this._viewportHeight = 0, this._rafId = null, this._onScroll = () => {
309
- this._scrollTop = this.container.scrollTop, this._scheduleRender();
310
- }, this.container = t, this.rowHeight = e.rowHeight, this.overscan = e.overscan ?? 5, this.onRender = e.onRender, this.container.addEventListener("scroll", this._onScroll, { passive: !0 });
311
- }
312
- _scheduleRender() {
313
- this._rafId === null && (this._rafId = requestAnimationFrame(() => {
314
- this._rafId = null;
315
- const t = this.getVisibleRange();
316
- this.onRender(t.startIndex, t.endIndex);
317
- }));
318
- }
319
- getVisibleRange() {
320
- const t = Math.ceil(this._viewportHeight / this.rowHeight), e = Math.max(0, Math.floor(this._scrollTop / this.rowHeight) - this.overscan), s = Math.min(
321
- this._totalRows - 1,
322
- e + t + this.overscan * 2
323
- ), i = e * this.rowHeight;
324
- return { startIndex: e, endIndex: s, offsetY: i };
325
- }
326
- setTotalRows(t) {
327
- this._totalRows = t, this._updateSpacerHeight(), this._scheduleRender();
328
- }
329
- setViewportHeight(t) {
330
- this._viewportHeight = t, this._scheduleRender();
331
- }
332
- setRowHeight(t) {
333
- this.rowHeight = t, this._updateSpacerHeight(), this._scheduleRender();
334
- }
335
- scrollToRow(t) {
336
- const e = t * this.rowHeight, s = e + this.rowHeight, i = this._scrollTop + this._viewportHeight;
337
- if (e < this._scrollTop)
338
- this._scrollTop = e, this.container.scrollTop = e;
339
- else if (s > i) {
340
- const o = s - this._viewportHeight;
341
- this._scrollTop = o, this.container.scrollTop = o;
342
- }
343
- }
344
- getTotalHeight() {
345
- return this._totalRows * this.rowHeight;
346
- }
347
- _updateSpacerHeight() {
348
- const t = this.container.querySelector(".og-spacer");
349
- t && (t.style.height = `${this.getTotalHeight()}px`);
350
- }
351
- destroy() {
352
- this.container.removeEventListener("scroll", this._onScroll), this._rafId !== null && cancelAnimationFrame(this._rafId);
353
- }
354
- }
355
- class Lt {
356
- constructor(t, e = 0) {
357
- this._flatLeaves = [], this._maxDepth = 1, this._frozenCount = 0, this._columns = t, this._frozenCount = e, this._process();
358
- }
359
- _process() {
360
- const t = [];
361
- let e = 0;
362
- const s = (i, o) => {
363
- for (const n of i)
364
- n.children && n.children.length > 0 ? (s(n.children, o + 1), this._maxDepth = Math.max(this._maxDepth, o + 1)) : t.push({ ...n, _colIndex: e++, _depth: o, _leaf: !0 });
365
- };
366
- this._maxDepth = 1, s(this._columns, 1), this._flatLeaves = t;
367
- }
368
- get leaves() {
369
- return this._flatLeaves;
370
- }
371
- get visibleLeaves() {
372
- return this._flatLeaves.filter((t) => !t.hidden);
373
- }
374
- get headerDepth() {
375
- return this._maxDepth;
376
- }
377
- get frozenCount() {
378
- return this._frozenCount;
379
- }
380
- setFrozen(t) {
381
- this._frozenCount = t;
382
- }
383
- setColumns(t) {
384
- this._columns = t, this._process();
385
- }
386
- hideColumn(t) {
387
- const e = Array.isArray(t) ? t : [t];
388
- this._flatLeaves.forEach((s) => {
389
- e.includes(s.field) && (s.hidden = !0);
390
- });
391
- }
392
- showColumn(t) {
393
- const e = Array.isArray(t) ? t : [t];
394
- this._flatLeaves.forEach((s) => {
395
- e.includes(s.field) && (s.hidden = !1);
396
- });
397
- }
398
- addColumn(t, e = "last") {
399
- e === "last" ? this._columns.push(t) : e === "first" ? this._columns.unshift(t) : this._columns.splice(e, 0, t), this._process();
400
- }
401
- removeColumn(t) {
402
- const e = (s) => s.filter((i) => i.field === t ? !1 : (i.children && (i.children = e(i.children)), !0));
403
- this._columns = e(this._columns), this._process();
404
- }
405
- getColumnByField(t) {
406
- return this._flatLeaves.find((e) => e.field === t);
407
- }
408
- getColumnByIndex(t) {
409
- return this._flatLeaves[t];
410
- }
411
- getColumnIndex(t) {
412
- return this._flatLeaves.findIndex((e) => e.field === t);
413
- }
414
- /** 헤더 렌더링용 셀 계산 */
415
- buildHeaderCells() {
416
- const t = Array.from({ length: this._maxDepth }, () => []);
417
- let e = 0;
418
- const s = (i, o) => {
419
- let n = 0;
420
- for (const r of i)
421
- if (!r.hidden)
422
- if (r.children && r.children.length > 0) {
423
- const l = s(r.children, o + 1);
424
- l > 0 && (t[o - 1].push({
425
- column: r,
426
- colIndex: e,
427
- depth: o,
428
- colSpan: l,
429
- rowSpan: 1
430
- }), n += l);
431
- } else
432
- t[o - 1].push({
433
- column: r,
434
- colIndex: e++,
435
- depth: o,
436
- colSpan: 1,
437
- rowSpan: this._maxDepth - o + 1
438
- }), n++;
439
- return n;
440
- };
441
- return s(this._columns, 1), t;
442
- }
443
- /** 각 리프 컬럼의 계산된 너비 배열 반환 */
444
- computeWidths(t, e = 100) {
445
- const s = this.visibleLeaves, i = s.filter((l) => l.flex), o = s.filter((l) => !l.flex && l.width).reduce((l, a) => l + a.width, 0), n = i.reduce((l, a) => l + (a.flex ?? 1), 0), r = Math.max(0, t - o);
446
- return s.map((l) => l.flex ? Math.round(l.flex / n * r) : l.width ?? e);
447
- }
448
- }
449
- class de {
450
- constructor(t, e, s) {
451
- this._field = "", this._outsideHandler = null, this._onApply = e, this._onClear = s, this._el = document.createElement("div"), this._el.className = "og-filter-panel", this._el.style.cssText = `
452
- position:absolute;z-index:1000;min-width:200px;max-width:280px;
453
- background:var(--og-row-bg,#fff);border:1px solid var(--og-border-color,#e0e0e0);
454
- border-radius:4px;box-shadow:0 4px 16px rgba(0,0,0,0.15);
455
- padding:10px;box-sizing:border-box;display:none;font-size:13px;
456
- `, t.appendChild(this._el);
457
- }
458
- open(t, e, s) {
459
- var k;
460
- this._field = t, this._el.innerHTML = "";
461
- const i = document.createElement("div");
462
- i.textContent = "필터", i.style.cssText = "font-weight:600;margin-bottom:8px;color:var(--og-text-color,#333);", this._el.appendChild(i);
463
- const o = document.createElement("div");
464
- o.style.cssText = "display:flex;gap:4px;margin-bottom:6px;";
465
- const n = document.createElement("select");
466
- n.style.cssText = "flex:1;padding:3px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:12px;";
467
- const r = [
468
- { label: "포함", value: "contains" },
469
- { label: "같음", value: "=" },
470
- { label: "같지 않음", value: "!=" },
471
- { label: "시작", value: "startsWith" },
472
- { label: "끝남", value: "endsWith" },
473
- { label: "보다 큼", value: ">" },
474
- { label: "보다 작음", value: "<" },
475
- { label: "이상", value: ">=" },
476
- { label: "이하", value: "<=" }
477
- ];
478
- for (const m of r) {
479
- const w = document.createElement("option");
480
- w.value = m.value, w.textContent = m.label, n.appendChild(w);
481
- }
482
- s[0] && (n.value = s[0].operator), o.appendChild(n), this._el.appendChild(o);
483
- const l = document.createElement("input");
484
- l.type = "text", l.placeholder = "필터 값 입력...", l.value = ((k = s[0]) == null ? void 0 : k.value) ?? "", l.style.cssText = `
485
- width:100%;padding:4px 6px;border:1px solid var(--og-border-color,#e0e0e0);
486
- border-radius:3px;font-size:12px;box-sizing:border-box;margin-bottom:8px;
487
- outline:none;
488
- `, l.addEventListener("keydown", (m) => {
489
- m.key === "Enter" ? u.click() : m.key === "Escape" && this.close();
490
- }), this._el.appendChild(l);
491
- const a = document.createElement("div");
492
- a.style.cssText = "display:flex;gap:6px;justify-content:flex-end;";
493
- const c = document.createElement("button");
494
- c.textContent = "초기화", c.style.cssText = `
495
- padding:3px 10px;border:1px solid var(--og-border-color,#e0e0e0);
496
- border-radius:3px;background:#fff;cursor:pointer;font-size:12px;color:#666;
497
- `, c.addEventListener("click", () => {
498
- this._onClear(this._field), this.close();
499
- });
500
- const u = document.createElement("button");
501
- u.textContent = "적용", u.style.cssText = `
502
- padding:3px 10px;border:1px solid var(--og-primary,#1976d2);
503
- border-radius:3px;background:var(--og-primary,#1976d2);
504
- color:#fff;cursor:pointer;font-size:12px;
505
- `, u.addEventListener("click", () => {
506
- const m = l.value.trim();
507
- m ? this._onApply(this._field, [{ operator: n.value, value: m }]) : this._onClear(this._field), this.close();
508
- }), a.appendChild(c), a.appendChild(u), this._el.appendChild(a);
509
- const h = e.getBoundingClientRect(), g = this._el.parentElement.getBoundingClientRect();
510
- this._el.style.top = `${h.bottom - g.top + 2}px`, this._el.style.left = `${Math.min(h.left - g.left, g.width - 220)}px`, this._el.style.display = "block", requestAnimationFrame(() => l.focus()), this._outsideHandler && document.removeEventListener("mousedown", this._outsideHandler), this._outsideHandler = (m) => {
511
- !this._el.contains(m.target) && m.target !== e && this.close();
512
- }, setTimeout(() => document.addEventListener("mousedown", this._outsideHandler), 0);
513
- }
514
- close() {
515
- this._el.style.display = "none", this._outsideHandler && (document.removeEventListener("mousedown", this._outsideHandler), this._outsideHandler = null);
516
- }
517
- get isOpen() {
518
- return this._el.style.display !== "none";
519
- }
520
- destroy() {
521
- this.close(), this._el.remove();
522
- }
523
- }
524
- const ce = 10;
525
- function he(d, t = ce) {
526
- const e = Math.pow(10, t);
527
- return Math.round(d * e) / e;
528
- }
529
- class M {
530
- // scale = 소수점 아래 자릿수
531
- constructor(t, e) {
532
- this._c = t, this._s = e < 0 ? 0 : e;
533
- }
534
- // ── 생성 ─────────────────────────────────────────────────
535
- static from(t) {
536
- if (t instanceof M) return t;
537
- if (typeof t == "bigint") return new M(t, 0);
538
- const e = String(t).trim();
539
- if (!e || e === "null" || e === "undefined" || e === "NaN")
540
- return new M(0n, 0);
541
- const s = e.startsWith("-"), i = s ? e.slice(1) : e, o = i.indexOf(".");
542
- let n, r;
543
- if (o === -1)
544
- n = BigInt(i), r = 0;
545
- else {
546
- const l = i.slice(o + 1);
547
- n = BigInt(i.slice(0, o) + l), r = l.length;
548
- }
549
- return new M(s ? -n : n, r);
550
- }
551
- static zero() {
552
- return new M(0n, 0);
553
- }
554
- static one() {
555
- return new M(1n, 0);
556
- }
557
- // ── 내부: 두 값의 스케일 정렬 ────────────────────────────
558
- static _align(t, e) {
559
- return t._s === e._s ? [t._c, e._c, t._s] : t._s > e._s ? [t._c, e._c * 10n ** BigInt(t._s - e._s), t._s] : [t._c * 10n ** BigInt(e._s - t._s), e._c, e._s];
560
- }
561
- // ── 사칙연산 ─────────────────────────────────────────────
562
- add(t) {
563
- const [e, s, i] = M._align(this, M.from(t));
564
- return new M(e + s, i);
565
- }
566
- sub(t) {
567
- const [e, s, i] = M._align(this, M.from(t));
568
- return new M(e - s, i);
569
- }
570
- mul(t) {
571
- const e = M.from(t);
572
- return new M(this._c * e._c, this._s + e._s);
573
- }
574
- /**
575
- * 나눗셈. precision = 결과 소수점 자리수 (기본 20).
576
- * 수익 배분처럼 소수 수백 자리가 필요하면 precision을 높인다.
577
- */
578
- div(t, e = 20) {
579
- const s = M.from(t);
580
- if (s._c === 0n) throw new Error("OGDecimal: division by zero");
581
- const o = this._c * 10n ** BigInt(e + s._s) / s._c;
582
- return new M(o, e + this._s);
583
- }
584
- /** 나머지 (정수 나머지와 동일한 개념을 소수에 적용) */
585
- mod(t) {
586
- const e = M.from(t), [s, i, o] = M._align(this, e);
587
- return new M(s % i, o);
588
- }
589
- /** 부호 반전 */
590
- neg() {
591
- return new M(-this._c, this._s);
592
- }
593
- /** 절댓값 */
594
- abs() {
595
- return new M(this._c < 0n ? -this._c : this._c, this._s);
596
- }
597
- // ── 비교 ─────────────────────────────────────────────────
598
- eq(t) {
599
- const [e, s] = M._align(this, M.from(t));
600
- return e === s;
601
- }
602
- gt(t) {
603
- const [e, s] = M._align(this, M.from(t));
604
- return e > s;
605
- }
606
- lt(t) {
607
- const [e, s] = M._align(this, M.from(t));
608
- return e < s;
609
- }
610
- gte(t) {
611
- return !this.lt(t);
612
- }
613
- lte(t) {
614
- return !this.gt(t);
615
- }
616
- isZero() {
617
- return this._c === 0n;
618
- }
619
- isNeg() {
620
- return this._c < 0n;
621
- }
622
- isPos() {
623
- return this._c > 0n;
624
- }
625
- // ── 출력 ─────────────────────────────────────────────────
626
- /**
627
- * 지정 소수점 자리수로 반올림(Half-up) 후 문자열 반환.
628
- * 음원 배분 등 정확한 자리수 표시에 사용.
629
- */
630
- toFixed(t) {
631
- let e = this._c, s = this._s;
632
- if (s < t)
633
- e = e * 10n ** BigInt(t - s);
634
- else if (s > t) {
635
- const c = 10n ** BigInt(s - t), u = c / 2n, h = e < 0n, g = h ? -e : e, k = g % c;
636
- let m = g / c;
637
- k >= u && (m += 1n), e = h ? -m : m;
638
- }
639
- s = t;
640
- const i = e < 0n, n = (i ? -e : e).toString().padStart(t + 1, "0"), r = n.slice(0, n.length - t) || "0", l = t > 0 ? "." + n.slice(n.length - t) : "";
641
- return (i ? "-" : "") + r + l;
642
- }
643
- /** 정규화(후행 0 제거) 후 최소 표현 문자열 반환 */
644
- toString() {
645
- if (this._s === 0) return this._c.toString();
646
- let t = this._c, e = this._s;
647
- for (; e > 0 && t !== 0n && t % 10n === 0n; )
648
- t /= 10n, e--;
649
- return new M(t, e).toFixed(e);
650
- }
651
- /** number로 변환 (정밀도 손실 주의 — 표시 전용) */
652
- toNumber() {
653
- return parseFloat(this.toFixed(20));
654
- }
655
- // ── 집계 정적 메서드 ─────────────────────────────────────
656
- /** 정확한 합산 (내부적으로 BigInt 정수 연산) */
657
- static sum(t) {
658
- return t.reduce((e, s) => e.add(s), M.zero());
659
- }
660
- /** 정확한 평균. precision = 나눗셈 소수점 자리수 */
661
- static avg(t, e = 20) {
662
- return t.length ? M.sum(t).div(t.length, e) : M.zero();
663
- }
664
- /** 배열 최솟값 */
665
- static min(t) {
666
- if (!t.length) throw new Error("OGDecimal.min: empty array");
667
- return t.map(M.from).reduce((e, s) => e.lt(s) ? e : s);
668
- }
669
- /** 배열 최댓값 */
670
- static max(t) {
671
- if (!t.length) throw new Error("OGDecimal.max: empty array");
672
- return t.map(M.from).reduce((e, s) => e.gt(s) ? e : s);
673
- }
674
- }
675
- function Gt(d, t, e = 30) {
676
- return new ue(d, t, e).parse();
677
- }
678
- class ue {
679
- constructor(t, e, s) {
680
- this._ctx = e, this._prec = s, this._pos = 0, this._src = t.trim();
681
- }
682
- parse() {
683
- const t = this._additive();
684
- if (this._skip(), this._pos < this._src.length)
685
- throw new SyntaxError(
686
- `FormulaEngine: 예상치 못한 토큰 '${this._src[this._pos]}' (위치 ${this._pos})`
687
- );
688
- return t;
689
- }
690
- // ── expression layers ──────────────────────────────────
691
- _additive() {
692
- let t = this._multiplicative();
693
- for (this._skip(); this._pos < this._src.length; ) {
694
- const e = this._src[this._pos];
695
- if (e !== "+" && e !== "-") break;
696
- this._pos++, this._skip();
697
- const s = this._multiplicative();
698
- t = e === "+" ? t.add(s) : t.sub(s), this._skip();
699
- }
700
- return t;
701
- }
702
- _multiplicative() {
703
- let t = this._unary();
704
- for (this._skip(); this._pos < this._src.length; ) {
705
- const e = this._src[this._pos];
706
- if (e !== "*" && e !== "/" && e !== "%") break;
707
- this._pos++, this._skip();
708
- const s = this._unary();
709
- e === "*" ? t = t.mul(s) : e === "/" ? t = t.div(s, this._prec) : t = t.mod(s), this._skip();
710
- }
711
- return t;
712
- }
713
- _unary() {
714
- return this._skip(), this._src[this._pos] === "-" ? (this._pos++, this._unary().neg()) : this._primary();
715
- }
716
- _primary() {
717
- this._skip();
718
- const t = this._src[this._pos];
719
- if (t === "(") {
720
- this._pos++;
721
- const e = this._additive();
722
- if (this._skip(), this._src[this._pos] !== ")")
723
- throw new SyntaxError("FormulaEngine: 닫는 괄호 ) 누락");
724
- return this._pos++, e;
725
- }
726
- return t === "[" ? this._fieldRef() : this._literal();
727
- }
728
- // ── 토큰 파싱 ─────────────────────────────────────────
729
- /** [fieldName] → 행 데이터에서 값 추출 */
730
- _fieldRef() {
731
- this._pos++;
732
- const t = this._pos;
733
- for (; this._pos < this._src.length && this._src[this._pos] !== "]"; )
734
- this._pos++;
735
- if (this._pos >= this._src.length)
736
- throw new SyntaxError("FormulaEngine: 닫는 ] 누락");
737
- const e = this._src.slice(t, this._pos);
738
- this._pos++;
739
- const s = this._ctx[e];
740
- if (s == null)
741
- throw new ReferenceError(`FormulaEngine: 필드 '[${e}]'가 행 데이터에 없습니다`);
742
- return M.from(s);
743
- }
744
- /** 숫자 리터럴 파싱 (정수 / 소수 모두) */
745
- _literal() {
746
- const t = this._pos;
747
- for (; this._pos < this._src.length && /[0-9.]/.test(this._src[this._pos]); )
748
- this._pos++;
749
- const e = this._src.slice(t, this._pos);
750
- if (!e)
751
- throw new SyntaxError(
752
- `FormulaEngine: 숫자 또는 [필드]를 기대했지만 '${this._src[this._pos] ?? "EOF"}' 발견 (위치 ${t})`
753
- );
754
- return M.from(e);
755
- }
756
- /** 공백 스킵 */
757
- _skip() {
758
- for (; this._pos < this._src.length && /\s/.test(this._src[this._pos]); )
759
- this._pos++;
760
- }
761
- }
762
- function kt(d, t) {
763
- if (d == null || d === "") return d ?? "";
764
- const e = typeof t == "string" ? { type: t } : t, s = e.char ?? "*";
765
- switch (e.type) {
766
- case "ssn":
767
- return ge(d, s);
768
- case "phone":
769
- case "mobile":
770
- return pe(d, s);
771
- case "email":
772
- return _e(d, s);
773
- case "credit":
774
- return fe(d, s);
775
- case "account":
776
- return me(d, s, e.visiblePrefix ?? 3, e.visibleSuffix ?? 4);
777
- case "password":
778
- return s.repeat(Math.max(d.length, 6));
779
- case "name":
780
- return ye(d, s);
781
- case "ip":
782
- return we(d, s);
783
- case "partial":
784
- return rt(d, s, e.visiblePrefix ?? 0, e.visibleSuffix ?? 4);
785
- default:
786
- return d;
787
- }
788
- }
789
- function ge(d, t) {
790
- const e = d.replace(/[^0-9]/g, "");
791
- if (e.length < 7) {
792
- const n = d.includes("-") ? "-" : "", r = d.indexOf("-") >= 0 ? d.indexOf("-") : 6;
793
- return d.slice(0, r) + n + t.repeat(Math.max(1, d.length - r - n.length));
794
- }
795
- const s = e.slice(0, 6), i = e[6], o = e.length - 7;
796
- return `${s}-${i}${t.repeat(o)}`;
797
- }
798
- function pe(d, t) {
799
- const e = d.replace(/[^0-9]/g, "");
800
- return e.length === 11 ? `${e.slice(0, 3)}-${t.repeat(4)}-${e.slice(7)}` : e.length === 10 ? e.startsWith("02") ? `${e.slice(0, 2)}-${t.repeat(4)}-${e.slice(6)}` : `${e.slice(0, 3)}-${t.repeat(3)}-${e.slice(6)}` : e.length === 9 ? `${e.slice(0, 2)}-${t.repeat(3)}-${e.slice(5)}` : rt(d, t, 3, 4);
801
- }
802
- function _e(d, t) {
803
- const e = d.indexOf("@");
804
- if (e < 0) return rt(d, t, 2, 0);
805
- const s = d.slice(0, e), i = d.slice(e), o = Math.min(2, s.length), n = s.slice(0, o), r = Math.max(s.length - o, 3);
806
- return `${n}${t.repeat(r)}${i}`;
807
- }
808
- function fe(d, t) {
809
- const e = d.replace(/[^0-9]/g, "");
810
- if (e.length < 8) return d;
811
- const s = e.slice(0, 4), i = e.slice(-4), o = e.length - 8, n = t.repeat(Math.max(o, 8)), r = [s];
812
- for (let l = 0; l < n.length; l += 4) {
813
- const a = n.slice(l, l + 4);
814
- a && r.push(a);
815
- }
816
- return r.push(i), r.join("-");
817
- }
818
- function me(d, t, e, s) {
819
- const i = d.replace(/[^0-9]/g, "");
820
- if (i.length <= e + s)
821
- return rt(i, t, e, s);
822
- const o = i.slice(0, e), n = i.slice(-s), r = i.length - e - s;
823
- return `${o}-${t.repeat(r)}-${n}`;
824
- }
825
- function ye(d, t) {
826
- const e = d.trim();
827
- return e.length === 0 ? d : e.length === 1 ? t : e.length === 2 ? `${e[0]}${t}` : `${e[0]}${t.repeat(e.length - 2)}${e[e.length - 1]}`;
828
- }
829
- function we(d, t) {
830
- const e = d.split(".");
831
- if (e.length !== 4) return rt(d, t, 3, 0);
832
- const s = (i) => t.repeat(Math.max(i.length, 3));
833
- return `${e[0]}.${e[1]}.${s(e[2])}.${s(e[3])}`;
834
- }
835
- function rt(d, t, e, s) {
836
- if (d.length <= e + s) return d;
837
- const i = d.slice(0, e), o = s > 0 ? d.slice(-s) : "", n = d.length - e - s;
838
- return `${i}${t.repeat(n)}${o}`;
839
- }
840
- let ot = null;
841
- function be(d) {
842
- ot = d;
843
- }
844
- function qt(d) {
845
- const t = d.column;
846
- if (!t.formula) return null;
847
- const e = t.formulaPrecision ?? 30;
848
- try {
849
- let s;
850
- return typeof t.formula == "function" ? s = t.formula(d.row, M) : s = Gt(t.formula, d.row, e), s instanceof M ? t.precision != null ? s.toFixed(t.precision) : s.toString() : typeof s == "string" ? s : t.precision != null ? M.from(s).toFixed(t.precision) : String(s);
851
- } catch (s) {
852
- return console.warn("[OpenGrid] Formula error:", s), "#ERR";
853
- }
854
- }
855
- function ve(d, t, e, s, i, o) {
856
- if (ot) {
857
- const _ = ot(d, i ?? "", o);
858
- if (_ != null) return _;
859
- }
860
- if (d == null || d === "") return "";
861
- let n = Number(d);
862
- if (isNaN(n)) return String(d);
863
- if (e != null && (n = he(n, e)), s)
864
- try {
865
- return new Intl.NumberFormat(void 0, {
866
- style: "currency",
867
- currency: s,
868
- ...e != null ? { minimumFractionDigits: e, maximumFractionDigits: e } : {}
869
- }).format(n);
870
- } catch {
871
- }
872
- if (!t)
873
- return e != null ? n.toFixed(e) : String(n);
874
- const r = t.indexOf(";"), l = r >= 0 ? t.slice(r + 1) : null, a = n < 0 && l != null ? l : r >= 0 ? t.slice(0, r) : t, c = n < 0 && l != null ? Math.abs(n) : n, u = a.match(/[#0][#0,]*(?:\.[#0]+)?/);
875
- if (!u) return String(n);
876
- const h = u[0], g = a.slice(0, u.index), k = a.slice(u.index + h.length), m = h.includes(","), w = h.includes(".") ? h.split(".")[1].length : e ?? 0, x = c.toLocaleString("ko-KR", {
877
- minimumFractionDigits: w,
878
- maximumFractionDigits: w,
879
- useGrouping: m
880
- });
881
- return g + x + k;
882
- }
883
- function Xt(d, t = "yyyy-MM-dd", e, s) {
884
- if (ot) {
885
- const l = ot(d, e ?? "", s);
886
- if (l != null) return l;
887
- }
888
- if (!d) return "";
889
- const i = d instanceof Date ? d : new Date(d);
890
- if (isNaN(i.getTime())) return String(d);
891
- const o = i.getFullYear(), n = String(i.getMonth() + 1).padStart(2, "0"), r = String(i.getDate()).padStart(2, "0");
892
- return t.replace("yyyy", String(o)).replace("MM", n).replace("dd", r);
893
- }
894
- function xe(d, t, e) {
895
- const s = kt(d, t.mask), i = document.createElement("span");
896
- i.style.cssText = "display:flex;align-items:center;gap:3px;overflow:hidden;width:100%;box-sizing:border-box;";
897
- const o = document.createElement("span");
898
- o.style.cssText = "flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:monospace;letter-spacing:0.4px;color:var(--og-mask-text,#888);", o.textContent = s;
899
- const n = document.createElement("button");
900
- return n.title = "클릭하면 원문 표시", n.setAttribute("aria-label", "마스킹 해제"), n.innerHTML = '<svg width="13" height="13" viewBox="0 0 16 16" fill="currentColor"><path d="M16 8s-3-5.5-8-5.5S0 8 0 8s3 5.5 8 5.5S16 8 16 8z"/><path d="M8 5.5A2.5 2.5 0 1 0 8 10.5 2.5 2.5 0 0 0 8 5.5zm0 4A1.5 1.5 0 1 1 8 6.5a1.5 1.5 0 0 1 0 3z" fill="#fff"/></svg>', n.style.cssText = "flex-shrink:0;background:none;border:none;cursor:pointer;color:#c0c0c0;padding:1px 2px;line-height:0;border-radius:3px;display:flex;align-items:center;", n.addEventListener("mouseover", () => {
901
- n.style.color = "var(--og-primary,#1976d2)", n.style.background = "rgba(25,118,210,0.08)";
902
- }), n.addEventListener("mouseout", () => {
903
- n.style.color = "#c0c0c0", n.style.background = "none";
904
- }), n.addEventListener("click", (r) => {
905
- r.stopPropagation(), o.textContent = d, o.style.fontFamily = "", o.style.letterSpacing = "", o.style.color = "", n.remove(), (t._maskRevealedRows ?? (t._maskRevealedRows = /* @__PURE__ */ new Set())).add(e);
906
- }), i.appendChild(o), i.appendChild(n), i;
907
- }
908
- class ut {
909
- render(t) {
910
- var l;
911
- const e = document.createElement("span");
912
- e.className = "og-cell-text";
913
- const s = qt(t);
914
- if (s !== null)
915
- return e.textContent = s, e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;", e;
916
- const { value: i, column: o, rowIndex: n } = t;
917
- let r;
918
- if (o.valueMap && i != null && o.valueMap[i] ? r = o.valueMap[i] : r = i == null ? "" : String(i), o.mask) {
919
- const a = o._maskRevealed === !0, c = ((l = o._maskRevealedRows) == null ? void 0 : l.has(n)) === !0;
920
- if (!a && !c)
921
- return xe(r, o, n);
922
- }
923
- return e.textContent = r, e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;", e;
924
- }
925
- }
926
- class Ce {
927
- constructor(t = [], e) {
928
- this._opts = t.map(
929
- (s) => typeof s == "string" ? { label: s, value: s } : { label: s.label ?? s.text ?? String(s.value ?? ""), value: s.value }
930
- ), this._fn = e ?? null;
931
- }
932
- render(t) {
933
- const e = document.createElement("span");
934
- e.className = "og-cell-text", e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;";
935
- const s = t.value;
936
- if (s == null || s === "") return e;
937
- const i = String(s), n = (this._fn ? this._fn(t.row, t.rowIndex).map((r) => typeof r == "string" ? { label: r, value: r } : { label: r.label ?? r.text ?? String(r.value ?? ""), value: r.value }) : this._opts).find((r) => String(r.value) === i);
938
- return e.textContent = n ? n.label : i, e;
939
- }
940
- }
941
- class gt {
942
- render(t) {
943
- const e = document.createElement("span");
944
- e.className = "og-cell-number";
945
- const s = qt(t);
946
- return s !== null ? (e.textContent = s, e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;", e) : (e.textContent = ve(t.value, t.column.format ?? "#,##0", t.column.precision, t.column.currency, t.column.field, t.row), e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;width:100%;text-align:right;", e);
947
- }
948
- }
949
- class pt {
950
- render(t) {
951
- const e = document.createElement("span");
952
- return e.className = "og-cell-date", e.textContent = Xt(t.value, t.column.format, t.column.field, t.row), e.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;", e;
953
- }
954
- }
955
- class _t {
956
- render(t) {
957
- const e = document.createElement("span");
958
- e.className = "og-cell-checkbox", e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;";
959
- const s = document.createElement("input");
960
- return s.type = "checkbox", s.checked = !!t.value, s.disabled = !0, s.style.cssText += "cursor:pointer;pointer-events:none;", e.appendChild(s), e;
961
- }
962
- }
963
- class Ft {
964
- constructor(t) {
965
- this.def = t;
966
- }
967
- render(t) {
968
- var o, n, r;
969
- const e = document.createElement("span");
970
- e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;";
971
- const s = document.createElement("button");
972
- s.className = `og-cell-btn${(o = this.def) != null && o.buttonClass ? " " + this.def.buttonClass : ""}`;
973
- const i = (n = this.def) == null ? void 0 : n.label;
974
- return typeof i == "function" ? s.textContent = i(t.value, t.row) : s.textContent = i ?? String(t.value ?? "btn"), s.style.cssText = `
975
- padding:2px 10px;border:1px solid var(--og-primary,#1976d2);
976
- border-radius:4px;background:var(--og-row-bg,#fff);color:var(--og-primary,#1976d2);
977
- cursor:pointer;font-size:12px;white-space:nowrap;transition:background 0.12s;
978
- ${((r = this.def) == null ? void 0 : r.style) ?? ""}
979
- `, s.addEventListener("mouseover", () => s.style.background = "var(--og-primary-light,#e3f2fd)"), s.addEventListener("mouseout", () => s.style.background = "var(--og-row-bg,#fff)"), e.appendChild(s), e;
980
- }
981
- }
982
- class Tt {
983
- constructor(t, e) {
984
- this.colorMap = t, this.labelMap = e;
985
- }
986
- render(t) {
987
- var r, l, a;
988
- const e = document.createElement("span");
989
- e.style.cssText = "display:flex;align-items:center;height:100%;";
990
- const s = document.createElement("span"), i = t.value == null ? "" : String(t.value), o = ((r = this.labelMap) == null ? void 0 : r[i]) ?? ((l = t.column.valueMap) == null ? void 0 : l[i]) ?? i;
991
- s.textContent = o;
992
- const n = ((a = this.colorMap) == null ? void 0 : a[i]) ?? "#666";
993
- return s.style.cssText = `
994
- display:inline-block;padding:2px 8px;border-radius:12px;font-size:11px;
995
- background:${n}22;color:${n};border:1px solid ${n}66;
996
- white-space:nowrap;
997
- `, e.appendChild(s), e;
998
- }
999
- }
1000
- class Dt {
1001
- constructor(t, e) {
1002
- this.hrefFn = t, this.target = e;
1003
- }
1004
- render(t) {
1005
- const e = document.createElement("a");
1006
- return e.className = "og-cell-link", e.textContent = t.value == null ? "" : String(t.value), e.href = this.hrefFn ? this.hrefFn(t.value, t.row) : "#", this.target && (e.target = this.target), e.style.cssText = "color:var(--og-primary,#1976d2);text-decoration:underline;cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block;", this.hrefFn || e.addEventListener("click", (s) => s.preventDefault()), e;
1007
- }
1008
- }
1009
- class Me {
1010
- constructor(t) {
1011
- this.templateFn = t;
1012
- }
1013
- render(t) {
1014
- const e = document.createElement("div");
1015
- return e.className = "og-cell-template", e.style.cssText = "display:flex;align-items:center;height:100%;overflow:hidden;", e.innerHTML = this.templateFn(t.value, t.row, t.rowIndex), e;
1016
- }
1017
- }
1018
- class ke {
1019
- constructor(t) {
1020
- this.def = t;
1021
- }
1022
- render(t) {
1023
- var a, c, u, h, g;
1024
- const e = document.createElement("span");
1025
- e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;";
1026
- const s = document.createElement("img"), i = (a = this.def) != null && a.srcFn ? this.def.srcFn(t.value, t.row) : String(t.value ?? "");
1027
- s.src = i;
1028
- const o = ((c = this.def) == null ? void 0 : c.width) ?? 28, n = ((u = this.def) == null ? void 0 : u.height) ?? 28, r = ((h = this.def) == null ? void 0 : h.radius) ?? 4;
1029
- s.style.cssText = `width:${o}px;height:${n}px;object-fit:cover;border-radius:${r}px;display:block;`;
1030
- const l = (g = this.def) == null ? void 0 : g.alt;
1031
- return s.alt = typeof l == "function" ? l(t.value, t.row) : l ?? "", s.onerror = () => {
1032
- s.style.display = "none";
1033
- }, e.appendChild(s), e;
1034
- }
1035
- }
1036
- class Re {
1037
- constructor(t) {
1038
- this.def = t;
1039
- }
1040
- render(t) {
1041
- var a, c, u, h;
1042
- const e = document.createElement("span");
1043
- e.style.cssText = "display:flex;align-items:center;gap:5px;width:100%;padding:0 4px;box-sizing:border-box;";
1044
- const s = ((a = this.def) == null ? void 0 : a.max) ?? 100, i = Number(t.value) || 0, o = Math.min(100, Math.max(0, i / s * 100)), n = (c = this.def) != null && c.colorFn ? this.def.colorFn(i) : ((u = this.def) == null ? void 0 : u.color) ?? "var(--og-primary,#1976d2)", r = document.createElement("div");
1045
- r.className = "og-progress-track", r.style.cssText = "flex:1;height:10px;background:#e0e0e0;border-radius:5px;overflow:hidden;";
1046
- const l = document.createElement("div");
1047
- if (l.className = "og-progress-fill", l.style.cssText = `width:${o}%;height:100%;background:${n};border-radius:5px;`, r.appendChild(l), e.appendChild(r), ((h = this.def) == null ? void 0 : h.showLabel) !== !1) {
1048
- const g = document.createElement("span");
1049
- g.style.cssText = "font-size:11px;color:#666;white-space:nowrap;min-width:28px;text-align:right;", g.textContent = `${Math.round(o)}%`, e.appendChild(g);
1050
- }
1051
- return e;
1052
- }
1053
- }
1054
- class Ee {
1055
- constructor(t) {
1056
- this.def = t;
1057
- }
1058
- render(t) {
1059
- var c, u, h, g;
1060
- const e = document.createElement("span");
1061
- e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;";
1062
- const s = Array.isArray(t.value) ? t.value.map(Number) : [];
1063
- if (!s.length)
1064
- return e.textContent = "-", e;
1065
- const i = ((c = this.def) == null ? void 0 : c.width) ?? 80, o = ((u = this.def) == null ? void 0 : u.height) ?? 22, n = ((h = this.def) == null ? void 0 : h.color) ?? "#1976d2", r = ((g = this.def) == null ? void 0 : g.chartType) ?? "bar", l = document.createElement("canvas");
1066
- l.width = i, l.height = o, l.style.cssText = "display:block;";
1067
- const a = l.getContext("2d");
1068
- if (a) {
1069
- const k = Math.max(...s, 1), m = Math.min(...s, 0), w = k - m || 1, x = s.length;
1070
- if (r === "bar") {
1071
- const _ = i / x;
1072
- s.forEach((b, L) => {
1073
- const v = (b - m) / w * (o - 2);
1074
- a.fillStyle = n, a.fillRect(L * _ + 1, o - v - 1, _ - 2, v);
1075
- });
1076
- } else {
1077
- const _ = s.map((b, L) => ({
1078
- x: L / (x - 1 || 1) * i,
1079
- y: o - (b - m) / w * (o - 4) - 2
1080
- }));
1081
- r === "area" && (a.fillStyle = n + "33", a.beginPath(), a.moveTo(_[0].x, o), _.forEach((b) => a.lineTo(b.x, b.y)), a.lineTo(_[_.length - 1].x, o), a.closePath(), a.fill()), a.strokeStyle = n, a.lineWidth = 1.5, a.beginPath(), _.forEach((b, L) => L === 0 ? a.moveTo(b.x, b.y) : a.lineTo(b.x, b.y)), a.stroke();
1082
- }
1083
- }
1084
- return e.appendChild(l), e;
1085
- }
1086
- }
1087
- class $t {
1088
- render(t) {
1089
- const e = document.createElement("span");
1090
- e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;";
1091
- const s = !!t.value, i = document.createElement("span");
1092
- i.className = "og-switch" + (s ? " og-switch--on" : ""), i.style.cssText = `display:inline-block;width:34px;height:18px;border-radius:9px;
1093
- background:${s ? "var(--og-primary,#1976d2)" : "#bdbdbd"};
1094
- position:relative;transition:background 0.2s;cursor:pointer;flex-shrink:0;pointer-events:none;`;
1095
- const o = document.createElement("span");
1096
- return o.style.cssText = `position:absolute;top:2px;left:${s ? "16px" : "2px"};
1097
- width:14px;height:14px;border-radius:50%;background:#fff;
1098
- transition:left 0.2s;box-shadow:0 1px 3px rgba(0,0,0,0.3);`, i.appendChild(o), e.appendChild(i), e;
1099
- }
1100
- }
1101
- class Se {
1102
- constructor(t) {
1103
- this.def = t;
1104
- }
1105
- render(t) {
1106
- var n, r;
1107
- const e = document.createElement("span");
1108
- e.style.cssText = "display:flex;align-items:center;gap:1px;height:100%;";
1109
- const s = ((n = this.def) == null ? void 0 : n.max) ?? 5, i = Math.round(Number(t.value) || 0), o = ((r = this.def) == null ? void 0 : r.color) ?? "#ffa000";
1110
- for (let l = 1; l <= s; l++) {
1111
- const a = document.createElement("span");
1112
- a.textContent = "★", a.style.cssText = `font-size:14px;color:${l <= i ? o : "#e0e0e0"};line-height:1;`, e.appendChild(a);
1113
- }
1114
- return e;
1115
- }
1116
- }
1117
- class ft {
1118
- render(t) {
1119
- const e = document.createElement("span");
1120
- e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;pointer-events:none;";
1121
- const s = document.createElement("input");
1122
- return s.type = "radio", s.checked = !!t.value, s.setAttribute("aria-checked", t.value ? "true" : "false"), s.setAttribute("aria-label", t.column.header ?? "선택"), t.column.group && (s.name = `og-radio-${t.rowIndex}-${t.column.group}`), s.style.cssText = "width:14px;height:14px;cursor:pointer;accent-color:var(--og-primary,#1976d2);", e.appendChild(s), e;
1123
- }
1124
- }
1125
- class mt {
1126
- render(t) {
1127
- const e = document.createElement("span");
1128
- if (e.style.cssText = "display:flex;align-items:center;justify-content:center;height:100%;overflow:hidden;", !t.value) return e;
1129
- const s = document.createElement("img");
1130
- return s.src = String(t.value), s.alt = t.column.alt ?? t.column.field, s.style.cssText = "max-width:100%;max-height:100%;object-fit:contain;display:block;", s.setAttribute("role", "img"), e.appendChild(s), e;
1131
- }
1132
- }
1133
- function Le(d) {
1134
- const t = document.createElement("div");
1135
- return t.innerHTML = d, t.querySelectorAll("script,iframe,object,embed").forEach((e) => e.remove()), t.querySelectorAll("*").forEach((e) => {
1136
- for (const s of [...e.attributes])
1137
- s.name.startsWith("on") && e.removeAttribute(s.name);
1138
- if (e.tagName === "A") {
1139
- const s = e.getAttribute("href") ?? "";
1140
- /^javascript:/i.test(s) && e.removeAttribute("href");
1141
- }
1142
- }), t.innerHTML;
1143
- }
1144
- class yt {
1145
- render(t) {
1146
- const e = document.createElement("span");
1147
- e.style.cssText = "display:block;overflow:hidden;width:100%;";
1148
- const s = t.column.sanitize !== !1, i = String(t.value ?? "");
1149
- return e.innerHTML = s ? Le(i) : i, e;
1150
- }
1151
- }
1152
- const Fe = [
1153
- "212222",
1154
- "222122",
1155
- "222221",
1156
- "121223",
1157
- "121322",
1158
- "131222",
1159
- "122213",
1160
- "122312",
1161
- // 0-7
1162
- "132212",
1163
- "221213",
1164
- "221312",
1165
- "231212",
1166
- "112232",
1167
- "122132",
1168
- "122231",
1169
- "113222",
1170
- // 8-15
1171
- "123122",
1172
- "123221",
1173
- "223211",
1174
- "221132",
1175
- "221231",
1176
- "213212",
1177
- "223112",
1178
- "312131",
1179
- // 16-23
1180
- "311222",
1181
- "321122",
1182
- "321221",
1183
- "312212",
1184
- "322112",
1185
- "322211",
1186
- "212123",
1187
- "212321",
1188
- // 24-31
1189
- "232121",
1190
- "111323",
1191
- "131123",
1192
- "131321",
1193
- "112313",
1194
- "132113",
1195
- "132311",
1196
- "211313",
1197
- // 32-39
1198
- "231113",
1199
- "231311",
1200
- "112133",
1201
- "112331",
1202
- "132131",
1203
- "113123",
1204
- "113321",
1205
- "133121",
1206
- // 40-47
1207
- "313121",
1208
- "211331",
1209
- "231131",
1210
- "213113",
1211
- "213311",
1212
- "213131",
1213
- "311123",
1214
- "311321",
1215
- // 48-55
1216
- "331121",
1217
- "312113",
1218
- "312311",
1219
- "332111",
1220
- "314111",
1221
- "221411",
1222
- "431111",
1223
- "111224",
1224
- // 56-63
1225
- "111422",
1226
- "121124",
1227
- "121421",
1228
- "141122",
1229
- "141221",
1230
- "112214",
1231
- "112412",
1232
- "122114",
1233
- // 64-71
1234
- "122411",
1235
- "142112",
1236
- "142211",
1237
- "241211",
1238
- "221114",
1239
- "413111",
1240
- "241112",
1241
- "134111",
1242
- // 72-79
1243
- "111242",
1244
- "121142",
1245
- "121241",
1246
- "114212",
1247
- "124112",
1248
- "124211",
1249
- "411212",
1250
- "421112",
1251
- // 80-87
1252
- "421211",
1253
- "212141",
1254
- "214121",
1255
- "412121",
1256
- "111143",
1257
- "111341",
1258
- "131141",
1259
- "114113",
1260
- // 88-95
1261
- "114311",
1262
- "411113",
1263
- "411311",
1264
- "113141",
1265
- "114131",
1266
- "311141",
1267
- "411131",
1268
- "211412",
1269
- // 96-103
1270
- "211214",
1271
- "211232"
1272
- // 104 (Start B), 105 (Start C)
1273
- ], Te = "2331112";
1274
- function At(d) {
1275
- let t = "", e = !0;
1276
- for (const s of d)
1277
- t += (e ? "1" : "0").repeat(+s), e = !e;
1278
- return t;
1279
- }
1280
- function De(d) {
1281
- const t = [104];
1282
- for (const s of d) {
1283
- const i = s.charCodeAt(0) - 32;
1284
- i >= 0 && i <= 94 && t.push(i);
1285
- }
1286
- let e = 104;
1287
- for (let s = 1; s < t.length; s++) e += t[s] * s;
1288
- return t.push(e % 103), t.map((s) => At(Fe[s])).join("") + At(Te) + "11";
1289
- }
1290
- class wt {
1291
- render(t) {
1292
- const e = String(t.value ?? ""), s = t.column.barcodeHeight ?? 28, i = document.createElement("div");
1293
- i.style.cssText = "display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;overflow:hidden;gap:1px;", i.setAttribute("role", "img"), i.setAttribute("aria-label", `바코드: ${e}`), i.innerHTML = $e(e, s);
1294
- const o = document.createElement("span");
1295
- return o.textContent = e, o.style.cssText = "font-size:9px;font-family:monospace;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;", i.appendChild(o), i;
1296
- }
1297
- }
1298
- function $e(d, t) {
1299
- if (!d) return "";
1300
- const e = De(d), s = 1.4, i = 6, o = e.length * s + i * 2, n = [];
1301
- let r = 0, l = i;
1302
- for (; r < e.length; )
1303
- if (e[r] === "1") {
1304
- let a = 0;
1305
- for (; r + a < e.length && e[r + a] === "1"; ) a++;
1306
- n.push(`<rect x="${l.toFixed(2)}" y="0" width="${(a * s).toFixed(2)}" height="${t}"/>`), l += a * s, r += a;
1307
- } else
1308
- l += s, r++;
1309
- return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${o.toFixed(2)} ${t}" width="${o.toFixed(2)}" height="${t}" style="display:block" aria-hidden="true"><g fill="currentColor">${n.join("")}</g></svg>`;
1310
- }
1311
- function Ae(d) {
1312
- const t = d.renderer;
1313
- if (!t)
1314
- switch (d.type) {
1315
- case "number":
1316
- return new gt();
1317
- case "date":
1318
- return new pt();
1319
- case "boolean":
1320
- return new _t();
1321
- case "radio":
1322
- return new ft();
1323
- case "img":
1324
- return new mt();
1325
- case "html":
1326
- return new yt();
1327
- case "barcode":
1328
- return new wt();
1329
- case "select":
1330
- return new Ce(d.options ?? [], d.optionsFn);
1331
- default:
1332
- return new ut();
1333
- }
1334
- if (typeof t == "string")
1335
- switch (t) {
1336
- case "number":
1337
- return new gt();
1338
- case "date":
1339
- return new pt();
1340
- case "checkbox":
1341
- return new _t();
1342
- case "button":
1343
- return new Ft();
1344
- case "link":
1345
- return new Dt();
1346
- case "badge":
1347
- return new Tt();
1348
- case "switch":
1349
- return new $t();
1350
- case "radio":
1351
- return new ft();
1352
- case "img":
1353
- return new mt();
1354
- case "html":
1355
- return new yt();
1356
- case "barcode":
1357
- return new wt();
1358
- default:
1359
- return new ut();
1360
- }
1361
- switch (t.type) {
1362
- case "button":
1363
- return new Ft(t);
1364
- case "checkbox":
1365
- return new _t();
1366
- case "link":
1367
- return new Dt(t.hrefFn, t.target);
1368
- case "template":
1369
- return new Me(t.templateFn);
1370
- case "badge":
1371
- return new Tt(t.colorMap, t.labelMap ?? t.valueMap);
1372
- case "image":
1373
- return new ke(t);
1374
- case "progress":
1375
- return new Re(t);
1376
- case "sparkline":
1377
- return new Ee(t);
1378
- case "switch":
1379
- return new $t();
1380
- case "rating":
1381
- return new Se(t);
1382
- case "number":
1383
- return new gt();
1384
- case "date":
1385
- return new pt();
1386
- case "radio":
1387
- return new ft();
1388
- case "img":
1389
- return new mt();
1390
- case "html":
1391
- return new yt();
1392
- case "barcode":
1393
- return new wt();
1394
- default:
1395
- return new ut();
1396
- }
1397
- }
1398
- class He {
1399
- constructor(t, e, s) {
1400
- this._cellMap = /* @__PURE__ */ new Map(), this._root = t, this._opts = e, this._cbs = s, this._header = D("div", "og-header"), this._header.style.cssText = "flex-shrink:0;overflow-x:auto;overflow-y:hidden;border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);scrollbar-width:none;", this._bodyWrap = D("div", "og-body-wrapper"), this._bodyWrap.style.cssText = "flex:1;overflow:auto;position:relative;", this._bodyWrap.style.setProperty("--scrollbar-size", "8px"), this._body = D("div", "og-body"), this._body.style.cssText = "position:relative;", this._bodyWrap.appendChild(this._body), t.appendChild(this._header), t.appendChild(this._bodyWrap), this._bodyWrap.addEventListener("scroll", () => {
1401
- this._header.scrollLeft = this._bodyWrap.scrollLeft;
1402
- }, { passive: !0 });
1403
- }
1404
- get bodyWrapper() {
1405
- return this._bodyWrap;
1406
- }
1407
- updateSize(t, e) {
1408
- this._bodyWrap.style.height = `${t - e}px`;
1409
- }
1410
- /** 현재 렌더된 헤더 영역의 실제 높이(px). 헤더 줄바꿈으로 늘어난 높이를 레이아웃에 반영할 때 사용. */
1411
- getHeaderHeight() {
1412
- return this._header.offsetHeight;
1413
- }
1414
- renderHeader(t, e, s, i, o) {
1415
- var g, k;
1416
- this._header.innerHTML = "";
1417
- const n = o._frozenCount ?? 0;
1418
- let r = 0;
1419
- o.stateColumn && (r += 24), o.draggable && (r += 18), o.rowNumber && (r += 44), o.checkColumn && (r += 36);
1420
- const l = r + e.reduce((m, w, x) => m + (s[x] ?? o.defaultColumnWidth), 0);
1421
- this._header.style.background = "var(--og-header-bg,#f5f5f5)";
1422
- const a = D("table", "og-header-table");
1423
- a.setAttribute("role", "presentation"), a.style.cssText = `table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:0;width:${l}px;background:var(--og-header-bg,#f5f5f5);`;
1424
- const c = t.length;
1425
- let u = 0;
1426
- const h = (m, w, x, _ = "") => {
1427
- const b = D("th", `og-header-cell og-extra-col ${_}`);
1428
- b.setAttribute("rowspan", String(c)), b.textContent = x, zt(b, {
1429
- width: `${w}px`,
1430
- minWidth: `${w}px`,
1431
- textAlign: "center",
1432
- borderRight: "1px solid var(--og-border-color,#e0e0e0)",
1433
- borderBottom: "1px solid var(--og-border-color,#e0e0e0)",
1434
- // host isolation: extra 컬럼 th 도 호스트 th{} 침범 차단 (border/line-height)
1435
- borderTop: "0",
1436
- borderLeft: "0",
1437
- lineHeight: "normal",
1438
- verticalAlign: "middle",
1439
- padding: "0",
1440
- fontSize: "11px",
1441
- color: "#999",
1442
- userSelect: "none",
1443
- boxSizing: "border-box",
1444
- background: "var(--og-header-bg,#f5f5f5)"
1445
- }), n > 0 && (b.style.position = "sticky", b.style.left = `${u}px`, b.style.zIndex = "4"), u += w, m.appendChild(b);
1446
- };
1447
- for (let m = 0; m < t.length; m++) {
1448
- const w = D("tr", "og-header-row");
1449
- if (w.style.height = `${o.headerHeight}px`, m === 0 && (o.stateColumn && h(w, 24, ""), o.draggable && h(w, 18, ""), o.rowNumber && h(w, 44, "No"), o.checkColumn)) {
1450
- const x = D("th", "og-header-cell og-extra-col");
1451
- x.setAttribute("rowspan", String(c)), x.style.cssText = "width:36px;min-width:36px;text-align:center;border-right:1px solid var(--og-border-color,#e0e0e0);border-bottom:1px solid var(--og-border-color,#e0e0e0);border-top:0;border-left:0;line-height:normal;vertical-align:middle;background:var(--og-header-bg,#f5f5f5);box-sizing:border-box;", n > 0 && (x.style.position = "sticky", x.style.left = `${u}px`, x.style.zIndex = "4"), u += 36;
1452
- const _ = document.createElement("input");
1453
- _.type = "checkbox", _.setAttribute("aria-label", "전체 행 선택"), _.style.cssText = "width:16px;height:16px;", _.addEventListener("change", () => this._cbs.onAllCheck(_.checked)), x.appendChild(_), w.appendChild(x);
1454
- }
1455
- for (const x of t[m] ?? []) {
1456
- const _ = D("th", "og-header-cell"), b = x.column;
1457
- x.colSpan > 1 && (_.colSpan = x.colSpan), x.rowSpan > 1 && (_.rowSpan = x.rowSpan);
1458
- const L = x.colSpan === 1 ? e.findIndex((p) => p.field === b.field) : -1;
1459
- if (x.colSpan === 1) {
1460
- const p = L >= 0 ? s[L] ?? o.defaultColumnWidth : b.width ?? o.defaultColumnWidth;
1461
- _.style.width = `${p}px`, _.style.minWidth = `${p}px`;
1462
- }
1463
- const v = i.find((p) => p.field === b.field), R = b.sortable !== !1 && o.sortable && x.colSpan === 1;
1464
- if (_.setAttribute("role", "columnheader"), _.setAttribute("scope", "col"), R && (_.setAttribute("aria-sort", v ? v.dir === "asc" ? "ascending" : "descending" : "none"), _.tabIndex = L === 0 ? 0 : -1, _.addEventListener("keydown", (p) => {
1465
- if (p.key === "Enter" || p.key === " ")
1466
- p.preventDefault(), this._cbs.onHeaderClick(b.field, p.shiftKey);
1467
- else if (p.key === "ArrowRight") {
1468
- p.preventDefault();
1469
- const C = _.nextElementSibling;
1470
- (C == null ? void 0 : C.tagName) === "TH" && C.focus();
1471
- } else if (p.key === "ArrowLeft") {
1472
- p.preventDefault();
1473
- const C = _.previousElementSibling;
1474
- (C == null ? void 0 : C.tagName) === "TH" && C.focus();
1475
- }
1476
- })), L >= 0 && L < n) {
1477
- let p = 0;
1478
- o.stateColumn && (p += 24), o.draggable && (p += 18), o.rowNumber && (p += 44), o.checkColumn && (p += 36);
1479
- for (let C = 0; C < L; C++) p += s[C] ?? o.defaultColumnWidth;
1480
- _.classList.add("og-frozen"), L === n - 1 && _.classList.add("og-frozen-last"), _.style.left = `${p}px`;
1481
- }
1482
- const F = b.header ?? b.field, I = typeof F == "string" && F.indexOf(`
1483
- `) >= 0, T = b.headerWrap === !0 || I;
1484
- zt(_, {
1485
- padding: "4px 8px",
1486
- boxSizing: "border-box",
1487
- // host isolation: 헤더 <th> 의 모든 시각 속성을 인라인으로 고정한다.
1488
- // 임베드 호스트(WordPress 등)가 `.entry-content th`/`.fn-post-content th`(특이도 0,2,1)로
1489
- // 배경·글자·라인높이·보더·폰트크기를 덮어써도 인라인(최고 우선순위)이 이긴다.
1490
- // (var 참조라 setTheme 시 자동 반영. text-align/padding 은 그리드 의도값 유지)
1491
- background: "var(--og-header-bg)",
1492
- color: "var(--og-header-color)",
1493
- lineHeight: T ? "1.3" : "normal",
1494
- verticalAlign: "middle",
1495
- fontSize: "var(--og-font-size)",
1496
- textAlign: b.headerAlign ?? "center",
1497
- borderTop: "0",
1498
- borderLeft: "0",
1499
- borderRight: "1px solid var(--og-border-color,#e0e0e0)",
1500
- borderBottom: "1px solid var(--og-border-color,#e0e0e0)",
1501
- userSelect: "none",
1502
- cursor: R ? "pointer" : "default",
1503
- // 줄바꿈 컬럼: nowrap+ellipsis 대신 여러 줄 허용(word-break). 미설정 컬럼은 기존 동작 유지.
1504
- whiteSpace: T ? "normal" : "nowrap",
1505
- overflow: T ? "visible" : "hidden",
1506
- textOverflow: T ? "clip" : "ellipsis",
1507
- wordBreak: T ? "break-word" : "normal",
1508
- position: "relative"
1509
- }), _.title = (typeof b.tooltip == "string" ? b.tooltip : F) ?? "";
1510
- const A = D("span");
1511
- if (T ? (A.style.cssText = "overflow:visible;text-overflow:clip;white-space:normal;word-break:break-word;", String(F).split(`
1512
- `).forEach((C, O) => {
1513
- O > 0 && A.appendChild(document.createElement("br")), A.appendChild(document.createTextNode(C));
1514
- })) : (A.textContent = F, A.style.cssText = "overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"), _.appendChild(A), v) {
1515
- _.classList.add("og-sorted");
1516
- const p = D("span", "og-sort-icon");
1517
- p.textContent = v.dir === "asc" ? " ↑" : " ↓", _.appendChild(p);
1518
- }
1519
- if (b.filterable !== !1 && o.filterable && x.colSpan === 1) {
1520
- const p = D("span", "og-filter-icon"), C = ((k = (g = o._activeFilters) == null ? void 0 : g[b.field]) == null ? void 0 : k.length) > 0;
1521
- p.textContent = C ? "⊿" : "▿", p.title = "필터", p.style.cssText = "margin-left:3px;cursor:pointer;font-size:10px;opacity:0.6;", C && p.classList.add("og-filter-icon--active"), p.addEventListener("click", (O) => {
1522
- O.stopPropagation(), this._cbs.onFilterIconClick(b.field, p);
1523
- }), _.appendChild(p);
1524
- }
1525
- if (b.resizable !== !1) {
1526
- const p = D("div", "og-resize-handle");
1527
- p.style.cssText = "position:absolute;right:0;top:0;bottom:0;width:4px;cursor:col-resize;z-index:1;", _.appendChild(p);
1528
- const C = L;
1529
- ze(p, _, (O) => {
1530
- C >= 0 && this._cbs.onColResize(C, O);
1531
- });
1532
- }
1533
- o.columnReorder && L >= 0 && x.colSpan === 1 && (_.draggable = !0, _.addEventListener("dragstart", (p) => {
1534
- var C;
1535
- this._cbs.onColDragStart(L), _.classList.add("og-col-dragging"), (C = p.dataTransfer) == null || C.setData("text/plain", String(L));
1536
- }), _.addEventListener("dragend", () => {
1537
- _.classList.remove("og-col-dragging"), this._header.querySelectorAll(".og-col-drop-over").forEach((p) => p.classList.remove("og-col-drop-over"));
1538
- }), _.addEventListener("dragover", (p) => {
1539
- p.preventDefault();
1540
- const C = this._cbs.getColDragIdx();
1541
- C !== null && C !== L && (this._header.querySelectorAll(".og-col-drop-over").forEach((O) => O.classList.remove("og-col-drop-over")), _.classList.add("og-col-drop-over"));
1542
- }), _.addEventListener("dragleave", () => {
1543
- _.classList.remove("og-col-drop-over");
1544
- }), _.addEventListener("drop", (p) => {
1545
- p.preventDefault(), _.classList.remove("og-col-drop-over"), this._cbs.onColDrop(L);
1546
- })), R && _.addEventListener("click", (p) => {
1547
- p.target.classList.contains("og-resize-handle") || this._cbs.onHeaderClick(b.field, p.shiftKey);
1548
- }), w.appendChild(_);
1549
- }
1550
- a.appendChild(w);
1551
- }
1552
- this._header.appendChild(a);
1553
- }
1554
- renderBody(t, e, s, i, o, n, r, l, a, c, u = null, h, g, k = {}, m) {
1555
- var b, L;
1556
- Object.keys(k).length && (n = { ...n, ...k }), this._body.innerHTML = "", this._cellMap.clear();
1557
- const w = n.autoHeight === !0;
1558
- this._body.classList.toggle("og-autoheight", w), this._body.style.height = w ? "" : `${l}px`;
1559
- const x = n._frozenCount ?? 0;
1560
- {
1561
- let v = 0;
1562
- n.stateColumn && (v += 24), n.draggable && (v += 18), n.rowNumber && (v += 44), n.checkColumn && (v += 36);
1563
- const R = v + i.reduce((F, I, T) => F + (o[T] ?? n.defaultColumnWidth), 0);
1564
- this._body.style.minWidth = `${R}px`;
1565
- }
1566
- if (e < t) return;
1567
- const _ = document.createDocumentFragment();
1568
- for (let v = t; v <= e; v++) {
1569
- const R = u ? u[v] : null, F = R && R._isGroup === !0, I = R && R._isTree === !0;
1570
- if (F) {
1571
- const f = R, S = `__${f._groupField}:${f._groupValue}`, H = D("div", "og-group-row"), tt = r + (v - t) * n.rowHeight;
1572
- H.style.cssText = [
1573
- w ? "" : `top:${tt}px;height:${n.rowHeight}px;`,
1574
- "display:flex;align-items:stretch;cursor:pointer;",
1575
- `padding-left:${4 + f._depth * 12}px;`,
1576
- "background:var(--og-header-bg,#f5f5f5);",
1577
- // host isolation: border:0 선행 (WP :where([style*=border-color]) 의 3px 강제 차단)
1578
- "border:0;border-bottom:1px solid var(--og-border-color,#e0e0e0);"
1579
- ].join(""), H.setAttribute("role", "row"), H.setAttribute("aria-expanded", f._expanded ? "true" : "false"), H.setAttribute("aria-rowindex", String(v + 1)), H.setAttribute("aria-level", String(f._depth + 1));
1580
- let j = 0;
1581
- if (n.stateColumn && (j += 24), n.draggable && (j += 18), n.rowNumber && (j += 44), n.checkColumn && (j += 36), j > 0) {
1582
- const y = D("div", "og-group-state-cell");
1583
- y.style.cssText = [
1584
- `width:${j}px;min-width:${j}px;flex-shrink:0;`,
1585
- "display:flex;align-items:center;justify-content:center;",
1586
- "font-size:10px;font-weight:700;gap:2px;",
1587
- "border-right:1px solid var(--og-border-color,#e0e0e0);"
1588
- ].join("");
1589
- const B = f._states ?? { added: 0, edited: 0, removed: 0 };
1590
- if (B.added > 0) {
1591
- const z = D("span");
1592
- z.textContent = `+${B.added}`, z.style.cssText = "color:var(--og-row-added-bg,#2e7d32);background:#e8f5e9;padding:1px 3px;border-radius:3px;", y.appendChild(z);
1593
- }
1594
- if (B.edited > 0) {
1595
- const z = D("span");
1596
- z.textContent = `M${B.edited}`, z.style.cssText = "color:#e65100;background:#fff8e1;padding:1px 3px;border-radius:3px;", y.appendChild(z);
1597
- }
1598
- if (B.removed > 0) {
1599
- const z = D("span");
1600
- z.textContent = `D${B.removed}`, z.style.cssText = "color:var(--og-row-removed-bg,#c62828);background:#ffebee;padding:1px 3px;border-radius:3px;", y.appendChild(z);
1601
- }
1602
- H.appendChild(y);
1603
- }
1604
- let P = !1;
1605
- for (let y = 0; y < i.length; y++) {
1606
- const B = i[y], z = o[y] ?? n.defaultColumnWidth, at = f._summaryFmt !== void 0 && B.field in (f._summaryFmt ?? {}), W = D("div", "og-group-cell");
1607
- if (W.style.cssText = [
1608
- `width:${z}px;min-width:${z}px;flex-shrink:0;`,
1609
- "padding:2px 8px;box-sizing:border-box;overflow:hidden;",
1610
- "border-right:1px solid var(--og-border-color,#e0e0e0);",
1611
- "display:flex;align-items:center;",
1612
- "white-space:nowrap;text-overflow:ellipsis;"
1613
- ].join(""), at) {
1614
- const U = f._summaryFmt[B.field];
1615
- W.textContent = U !== "" ? U : "-", W.style.justifyContent = "flex-end", W.style.color = "var(--og-primary,#1976d2)", W.style.fontWeight = "600";
1616
- } else if (!P) {
1617
- P = !0;
1618
- const U = D("span", "og-group-arrow");
1619
- U.textContent = f._expanded ? "▾ " : "▸ ", U.style.cssText = "color:var(--og-primary,#1976d2);margin-right:4px;flex-shrink:0;", W.appendChild(U);
1620
- const G = D("span", "og-group-label");
1621
- G.textContent = `${f._groupLabel} (${f._childCount}건)`, G.style.cssText = "overflow:hidden;text-overflow:ellipsis;font-weight:600;", W.appendChild(G), W.style.gap = "0";
1622
- }
1623
- H.appendChild(W);
1624
- }
1625
- H.addEventListener("click", () => h == null ? void 0 : h(S)), _.appendChild(H);
1626
- continue;
1627
- }
1628
- const T = I ? R : null, A = T ? T.data : u ? R : s.getRowByIndex(v);
1629
- if (!A) continue;
1630
- const $ = I || F ? "none" : s.getRowState(v), p = D("div", "og-row");
1631
- if (p.setAttribute("role", "row"), p.setAttribute("aria-rowindex", String(v + 1)), !w) {
1632
- const f = r + (v - t) * n.rowHeight;
1633
- p.style.top = `${f}px`, p.style.height = `${n.rowHeight}px`;
1634
- }
1635
- let C = v % 2 === 0 ? "var(--og-row-bg,#fff)" : "var(--og-row-alt-bg,#fafafa)";
1636
- p.style.background = C, $ === "added" && p.classList.add("og-state-added"), $ === "edited" && p.classList.add("og-state-edited"), $ === "removed" && p.classList.add("og-state-removed"), a.has(v) && p.classList.add("og-selected"), p.setAttribute("aria-selected", a.has(v) ? "true" : "false"), $ === "added" && (C = "var(--og-row-added-bg,#e8f5e9)"), $ === "edited" && (C = "var(--og-row-edited-bg,#fff8e1)"), $ === "removed" && (C = "var(--og-row-removed-bg,#ffebee)"), a.has(v) && (C = "var(--og-row-selected-bg,#bbdefb)");
1637
- const O = v;
1638
- p.addEventListener("click", (f) => {
1639
- this._cbs.onCellClick(O, -1, f);
1640
- });
1641
- const lt = /* @__PURE__ */ new Map();
1642
- let X = 0;
1643
- if (n.stateColumn) {
1644
- const f = D("div", "og-cell og-col-state"), S = { added: "✚", edited: "✎", removed: "✖", none: "" }, H = { added: "#2e7d32", edited: "#bf360c", removed: "#c62828", none: "" };
1645
- f.textContent = S[$] ?? "", f.style.color = H[$] ?? "", f.title = $, x > 0 && (f.style.position = "sticky", f.style.left = `${X}px`, f.style.zIndex = "2", f.style.background = C), X += 24, p.appendChild(f);
1646
- }
1647
- const st = this._cbs.getDndManager();
1648
- if (n.draggable && st) {
1649
- const f = st.attachHandle(p, v, n._totalRows ?? e + 1);
1650
- x > 0 && (f.style.position = "sticky", f.style.left = `${X}px`, f.style.zIndex = "2", f.style.background = C), X += 18, p.appendChild(f);
1651
- }
1652
- if (n.rowNumber) {
1653
- const f = D("div", "og-cell og-col-rownum");
1654
- f.textContent = String(v + 1), x > 0 && (f.style.position = "sticky", f.style.left = `${X}px`, f.style.zIndex = "2", f.style.background = C), X += 44, p.appendChild(f);
1655
- }
1656
- if (n.checkColumn) {
1657
- const f = D("div", "og-cell og-col-check"), S = document.createElement("input");
1658
- S.type = "checkbox", S.checked = c.has(v), S.setAttribute("aria-label", `${v + 1}행 선택`), S.addEventListener("click", (H) => H.stopPropagation()), S.addEventListener("change", (H) => {
1659
- H.stopPropagation(), this._cbs.onRowCheck(v, S.checked);
1660
- }), f.appendChild(S), x > 0 && (f.style.position = "sticky", f.style.left = `${X}px`, f.style.zIndex = "2", f.style.background = C), X += 36, p.appendChild(f);
1661
- }
1662
- for (let f = 0; f < i.length; f++) {
1663
- const S = i[f], H = o[f] ?? n.defaultColumnWidth, tt = n.editable && S.editable !== !1, j = f === 0, P = m && !m.isEmpty ? m.getInfo(v, f) : null;
1664
- if (P != null && P.hidden) {
1665
- const E = D("div", "og-cell og-cell--merge-ph");
1666
- E.style.cssText = `width:${H}px;min-width:${H}px;flex-shrink:0;visibility:hidden;box-sizing:border-box;`, p.appendChild(E);
1667
- continue;
1668
- }
1669
- const y = D("div", "og-cell");
1670
- y.setAttribute("role", "gridcell"), y.setAttribute("aria-colindex", String(f + 1));
1671
- const B = (P == null ? void 0 : P.rowSpan) ?? 1, z = (P == null ? void 0 : P.colSpan) ?? 1, at = B > 1 ? B * n.rowHeight : n.rowHeight;
1672
- let W = H;
1673
- if (z > 1)
1674
- for (let E = 1; E < z; E++)
1675
- W += o[f + E] ?? n.defaultColumnWidth;
1676
- const U = f < x;
1677
- let G = 0;
1678
- if (U) {
1679
- n.stateColumn && (G += 24), n.draggable && (G += 18), n.rowNumber && (G += 44), n.checkColumn && (G += 36);
1680
- for (let E = 0; E < f; E++) G += o[E] ?? n.defaultColumnWidth;
1681
- y.classList.add("og-frozen-cell"), f === x - 1 && y.classList.add("og-frozen-last");
1682
- }
1683
- y.style.width = `${W}px`, y.style.minWidth = `${W}px`, y.style.maxWidth = `${W}px`, B > 1 && (y.style.height = `${at}px`), U && (y.style.background = C), T && j && (y.style.padding = "0"), y.style.overflow = "hidden", B > 1 ? (y.style.height = `${at}px`, y.style.position = "absolute", y.style.zIndex = "3", y.style.background = C && C !== "inherit" ? C : "var(--og-row-bg, #fff)", y.style.borderTop = "0", y.style.borderLeft = "0", y.style.borderBottom = "1px solid var(--og-border-color, #e0e0e0)") : U && (y.style.position = "sticky", y.style.left = `${G}px`, y.style.zIndex = "1"), S.type === "number" || S.align === "right" ? y.classList.add("og-cell--right") : S.align === "center" && y.classList.add("og-cell--center"), tt && y.classList.add("og-cell--editable"), S.wrap && y.classList.add("og-cell--wrap"), tt || y.setAttribute("aria-readonly", "true"), z > 1 && y.setAttribute("aria-colspan", String(z)), B > 1 && y.setAttribute("aria-rowspan", String(B)), ((b = n._focusCell) == null ? void 0 : b.ri) === v && ((L = n._focusCell) == null ? void 0 : L.ci) === f && (y.classList.add("og-cell-focused"), y.tabIndex = -1);
1684
- const et = A ? A[S.field] : null;
1685
- y.setAttribute("aria-label", `${S.header}: ${et == null ? "" : String(et)}`), S.tooltip != null ? y.title = typeof S.tooltip == "function" ? String(S.tooltip(et, A) ?? "") : String(S.tooltip) : n.tooltips && et != null && et !== "" && (y.title = String(et));
1686
- let Et = y;
1687
- if (T && j) {
1688
- const E = D("div", "og-tree-cell"), q = T._ancestorHasMore ?? [];
1689
- for (let K = 0; K < T._depth; K++) {
1690
- const Y = D("span", "og-tree-guide");
1691
- q[K] && Y.classList.add("og-tree-guide--line"), E.appendChild(Y);
1692
- }
1693
- if (T._depth > 0) {
1694
- const K = D("span", "og-tree-connector");
1695
- K.classList.add(
1696
- T._isLastChild ? "og-tree-connector--last" : "og-tree-connector--mid"
1697
- ), E.appendChild(K);
1698
- }
1699
- const dt = D("span", "og-tree-toggle-wrap");
1700
- if (!T._hasChildren) {
1701
- const K = D("span", "og-tree-leaf-dot");
1702
- dt.appendChild(K);
1703
- }
1704
- E.appendChild(dt);
1705
- const N = document.createElement("i");
1706
- if (T._hasChildren) {
1707
- const K = Ht(S.treeNodeIcon, A, !0, T._expanded);
1708
- N.className = T._expanded ? `${K} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--open og-tree-node-icon--toggle` : `${K} og-tree-node-icon og-tree-node-icon--branch og-tree-node-icon--toggle`, N.setAttribute("role", "button"), N.setAttribute("tabindex", "0"), N.setAttribute("aria-expanded", T._expanded ? "true" : "false"), N.setAttribute("aria-label", T._expanded ? "접기" : "펼치기"), N.addEventListener("click", (Y) => {
1709
- Y.stopPropagation(), g == null || g(T._treeId);
1710
- }), N.addEventListener("keydown", (Y) => {
1711
- (Y.key === "Enter" || Y.key === " ") && (Y.preventDefault(), Y.stopPropagation(), g == null || g(T._treeId));
1712
- });
1713
- } else {
1714
- const K = Ht(S.treeNodeIcon, A, !1, !1);
1715
- N.setAttribute("aria-hidden", "true"), N.className = `${K} og-tree-node-icon og-tree-node-icon--leaf`;
1716
- }
1717
- E.appendChild(N), y.appendChild(E), Et = E;
1718
- }
1719
- if (S.cellStyle) {
1720
- const E = A[S.field], q = typeof S.cellStyle == "function" ? S.cellStyle(E, A, v) : S.cellStyle;
1721
- Object.assign(y.style, q);
1722
- }
1723
- const ie = Ae(S).render({
1724
- value: A[S.field],
1725
- row: A,
1726
- rowIndex: v,
1727
- column: S,
1728
- colIndex: f,
1729
- isSelected: a.has(v),
1730
- rowState: $
1731
- });
1732
- Et.appendChild(ie);
1733
- const J = v, Q = f;
1734
- if (y.addEventListener("click", (E) => {
1735
- E.stopPropagation(), this._cbs.onCellClick(J, Q, E);
1736
- }), y.addEventListener("dblclick", (E) => {
1737
- E.stopPropagation(), this._cbs.onCellDblClick(J, Q, E);
1738
- }), y.addEventListener("mouseover", (E) => {
1739
- E.stopPropagation(), this._cbs.onCellMouseOver(J, Q, E);
1740
- }), y.addEventListener("mouseout", (E) => {
1741
- E.stopPropagation(), this._cbs.onCellMouseOut(J, Q, E);
1742
- }), y.addEventListener("mousedown", (E) => {
1743
- E.stopPropagation(), this._cbs.onCellMouseDown(J, Q, E);
1744
- }), y.addEventListener("mouseup", (E) => {
1745
- E.stopPropagation(), this._cbs.onCellMouseUp(J, Q, E);
1746
- }), y.addEventListener("mousemove", (E) => {
1747
- E.stopPropagation(), this._cbs.onCellMouseMove(J, Q, E);
1748
- }), lt.set(f, y), B > 1) {
1749
- const E = document.createElement("div");
1750
- E.style.cssText = [
1751
- `width:${H}px;min-width:${H}px;height:${n.rowHeight}px;`,
1752
- "flex-shrink:0;box-sizing:border-box;",
1753
- "border-right:1px solid var(--og-border-color,#e0e0e0);"
1754
- ].join(""), p.appendChild(E);
1755
- let q = 0;
1756
- n.stateColumn && (q += 24), n.draggable && (q += 18), n.rowNumber && (q += 44), n.checkColumn && (q += 36);
1757
- for (let N = 0; N < f; N++) q += o[N] ?? n.defaultColumnWidth;
1758
- const dt = r + (v - t) * n.rowHeight;
1759
- y.style.left = `${q}px`, y.style.top = `${dt}px`, _.appendChild(y);
1760
- } else
1761
- p.appendChild(y);
1762
- }
1763
- this._cellMap.set(v, lt), _.appendChild(p);
1764
- }
1765
- if (s.rowCount === 0) {
1766
- const v = D("div", "og-empty-message");
1767
- v.textContent = "데이터가 없습니다.", v.style.cssText = "width:100%;", _.appendChild(v);
1768
- }
1769
- this._body.appendChild(_);
1770
- }
1771
- getCellEl(t, e) {
1772
- var s;
1773
- return (s = this._cellMap.get(t)) == null ? void 0 : s.get(e);
1774
- }
1775
- destroy() {
1776
- this._root.innerHTML = "";
1777
- }
1778
- }
1779
- function Ht(d, t, e, s) {
1780
- let i;
1781
- return d ? typeof d == "function" ? i = d(t, e, s) : e ? i = s ? d.branchOpen ?? "bi-folder2-open" : d.branch ?? "bi-folder2" : i = d.leaf ?? "bi-file-earmark" : i = e ? s ? "bi-folder2-open" : "bi-folder2" : "bi-file-earmark", i.startsWith("bi ") ? i : `bi ${i}`;
1782
- }
1783
- function D(d, t) {
1784
- const e = document.createElement(d);
1785
- return t && (e.className = t), e;
1786
- }
1787
- function zt(d, t) {
1788
- Object.assign(d.style, t);
1789
- }
1790
- function It(d, t, e = "text/plain;charset=utf-8") {
1791
- const s = new Blob([d], { type: e }), i = URL.createObjectURL(s), o = document.createElement("a");
1792
- o.href = i, o.download = t, o.click(), URL.revokeObjectURL(i);
1793
- }
1794
- function ze(d, t, e) {
1795
- let s = 0, i = 0;
1796
- d.addEventListener("mousedown", (o) => {
1797
- o.stopPropagation(), o.preventDefault(), s = o.clientX, i = t.offsetWidth;
1798
- const n = (l) => {
1799
- const a = Math.max(40, i + l.clientX - s);
1800
- t.style.width = `${a}px`, t.style.minWidth = `${a}px`;
1801
- }, r = (l) => {
1802
- document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", r), e(Math.max(40, i + l.clientX - s));
1803
- };
1804
- document.addEventListener("mousemove", n), document.addEventListener("mouseup", r);
1805
- });
1806
- }
1807
- class Ie {
1808
- constructor(t) {
1809
- this._selectedRows = /* @__PURE__ */ new Set(), this._checkedRows = /* @__PURE__ */ new Set(), this._data = t;
1810
- }
1811
- // ─── Read-only 접근 ───────────────────────────────────────
1812
- get selectedRows() {
1813
- return this._selectedRows;
1814
- }
1815
- get checkedRows() {
1816
- return this._checkedRows;
1817
- }
1818
- // ─── 선택 변경 ───────────────────────────────────────────
1819
- selectSingle(t) {
1820
- this._selectedRows.clear(), this._selectedRows.add(t);
1821
- }
1822
- selectToggle(t) {
1823
- this._selectedRows.has(t) ? this._selectedRows.delete(t) : this._selectedRows.add(t);
1824
- }
1825
- clearSelection() {
1826
- this._selectedRows.clear();
1827
- }
1828
- // ─── 체크 변경 ───────────────────────────────────────────
1829
- check(t, e) {
1830
- e ? this._checkedRows.add(t) : this._checkedRows.delete(t);
1831
- }
1832
- checkAll(t, e) {
1833
- if (t)
1834
- for (let s = 0; s < e; s++) this._checkedRows.add(s);
1835
- else
1836
- this._checkedRows.clear();
1837
- }
1838
- checkByValue(t, e) {
1839
- for (let s = 0; s < this._data.rowCount; s++)
1840
- e.includes(this._data.getCellValue(s, t)) && this._checkedRows.add(s);
1841
- }
1842
- uncheckAll() {
1843
- this._checkedRows.clear();
1844
- }
1845
- checkById(t) {
1846
- }
1847
- addCheckById(t) {
1848
- }
1849
- uncheckById(t) {
1850
- }
1851
- // ─── 선택 쿼리 API ───────────────────────────────────────
1852
- getSelections() {
1853
- return [...this._selectedRows].map((t) => this._data.getRowByIndex(t)).filter(Boolean);
1854
- }
1855
- getChecked() {
1856
- return [...this._checkedRows].map((t) => ({
1857
- row: this._data.getRowByIndex(t),
1858
- rowIndex: t
1859
- }));
1860
- }
1861
- getAllChecked() {
1862
- return this.getChecked().map((t) => t.row);
1863
- }
1864
- getActiveRow() {
1865
- return this._selectedRows.size > 0 ? [...this._selectedRows][0] : -1;
1866
- }
1867
- activate(t) {
1868
- this._selectedRows.clear(), this._selectedRows.add(t);
1869
- }
1870
- deselect() {
1871
- this._selectedRows.clear();
1872
- }
1873
- // ─── 전체 초기화 (setData / clearData 시) ────────────────
1874
- reset() {
1875
- this._selectedRows.clear(), this._checkedRows.clear();
1876
- }
1877
- }
1878
- class bt {
1879
- constructor() {
1880
- this._onKeyDown = (t) => {
1881
- t.stopPropagation(), t.key === "Enter" ? (t.preventDefault(), this._onCommit(this.input.value)) : t.key === "Escape" && this._onCancel();
1882
- }, this._onBlur = () => {
1883
- this._onCommit(this.input.value);
1884
- };
1885
- }
1886
- mount(t, e, s, i) {
1887
- this._container = t, this._onCommit = s, this._onCancel = i, t.setAttribute("aria-haspopup", "dialog"), t.setAttribute("aria-expanded", "true"), this.input = document.createElement("input"), this.input.type = "date", this.input.className = "og-cell-input", this.input.setAttribute("aria-label", e.column.header ?? "날짜 선택");
1888
- const o = e.value;
1889
- if (o) {
1890
- const n = o instanceof Date ? o : new Date(o);
1891
- isNaN(n.getTime()) || (this.input.value = Xt(n, "yyyy-MM-dd"));
1892
- }
1893
- this.input.addEventListener("keydown", this._onKeyDown), this.input.addEventListener("blur", this._onBlur), t.appendChild(this.input);
1894
- }
1895
- getValue() {
1896
- var t;
1897
- return (t = this.input) == null ? void 0 : t.value;
1898
- }
1899
- focus() {
1900
- var t;
1901
- (t = this.input) == null || t.focus();
1902
- }
1903
- destroy() {
1904
- var t, e, s;
1905
- (t = this._container) == null || t.setAttribute("aria-expanded", "false"), (e = this.input) == null || e.removeEventListener("keydown", this._onKeyDown), (s = this.input) == null || s.removeEventListener("blur", this._onBlur);
1906
- }
1907
- }
1908
- function Bt(d) {
1909
- return d.map((t) => typeof t == "string" ? { label: t, value: t } : { label: t.label ?? t.text ?? String(t.value ?? ""), value: t.value });
1910
- }
1911
- class vt {
1912
- constructor(t = [], e) {
1913
- this._options = Bt(t), this._optionsFn = e ?? null;
1914
- }
1915
- mount(t, e, s, i) {
1916
- this._container = t, this._onCommit = s, this._onCancel = i, t.setAttribute("aria-haspopup", "listbox"), t.setAttribute("aria-expanded", "true"), this.select = document.createElement("select"), this.select.className = "og-cell-select", this.select.setAttribute("aria-label", e.column.header ?? "선택");
1917
- const o = this._optionsFn ? Bt(this._optionsFn(e.row, e.rowIndex)) : this._options;
1918
- for (const r of o) {
1919
- const l = document.createElement("option");
1920
- l.value = String(r.value), l.textContent = r.label, this.select.appendChild(l);
1921
- }
1922
- const n = e.value == null ? "" : String(e.value);
1923
- o.some((r) => String(r.value) === n) && (this.select.value = n), this.select.addEventListener("change", () => s(this.select.value)), this.select.addEventListener("blur", () => s(this.select.value)), this.select.addEventListener("keydown", (r) => {
1924
- r.key === "Escape" && i();
1925
- }), t.appendChild(this.select);
1926
- }
1927
- getValue() {
1928
- var t;
1929
- return (t = this.select) == null ? void 0 : t.value;
1930
- }
1931
- focus() {
1932
- var t;
1933
- (t = this.select) == null || t.focus();
1934
- }
1935
- destroy() {
1936
- var t;
1937
- (t = this._container) == null || t.setAttribute("aria-expanded", "false");
1938
- }
1939
- }
1940
- class xt {
1941
- constructor() {
1942
- this._onKeyDown = (t) => {
1943
- t.stopPropagation(), t.key === "Enter" || t.key === "Tab" ? (t.preventDefault(), this._onCommit(this.input.value)) : t.key === "Escape" && this._onCancel();
1944
- }, this._onBlur = () => {
1945
- this._onCommit(this.input.value);
1946
- };
1947
- }
1948
- mount(t, e, s, i) {
1949
- this._onCommit = s, this._onCancel = i, this.input = document.createElement("input"), this.input.type = "text", this.input.value = e.value == null ? "" : String(e.value), this.input.style.cssText = `
1950
- width:100%;height:100%;border:none;outline:none;padding:0 8px;
1951
- font-size:var(--og-font-size,13px);font-family:var(--og-font-family,sans-serif);
1952
- background:var(--og-row-bg,#fff);box-sizing:border-box;
1953
- `, this.input.addEventListener("keydown", this._onKeyDown), this.input.addEventListener("blur", this._onBlur), t.appendChild(this.input);
1954
- }
1955
- getValue() {
1956
- var t;
1957
- return (t = this.input) == null ? void 0 : t.value;
1958
- }
1959
- focus() {
1960
- var t, e;
1961
- (t = this.input) == null || t.focus(), (e = this.input) == null || e.select();
1962
- }
1963
- destroy() {
1964
- var t, e;
1965
- (t = this.input) == null || t.removeEventListener("keydown", this._onKeyDown), (e = this.input) == null || e.removeEventListener("blur", this._onBlur);
1966
- }
1967
- }
1968
- class Ct {
1969
- constructor(t) {
1970
- this._onKeyDown = (e) => {
1971
- e.stopPropagation(), e.key === "Enter" || e.key === "Tab" ? (e.preventDefault(), this._commit()) : e.key === "Escape" && this._onCancel();
1972
- }, this._onBlur = () => {
1973
- this._commit();
1974
- }, this.min = t == null ? void 0 : t.min, this.max = t == null ? void 0 : t.max, this.step = t == null ? void 0 : t.step;
1975
- }
1976
- mount(t, e, s, i) {
1977
- this._onCommit = s, this._onCancel = i, this.input = document.createElement("input"), this.input.type = "number", this.input.value = e.value == null ? "" : String(e.value), this.min != null && (this.input.min = String(this.min)), this.max != null && (this.input.max = String(this.max)), this.step != null && (this.input.step = String(this.step)), this.input.style.cssText = `
1978
- width:100%;height:100%;border:none;outline:none;padding:0 8px;
1979
- font-size:var(--og-font-size,13px);text-align:right;
1980
- background:var(--og-row-bg,#fff);box-sizing:border-box;
1981
- `, this.input.addEventListener("keydown", this._onKeyDown), this.input.addEventListener("blur", this._onBlur), t.appendChild(this.input);
1982
- }
1983
- _commit() {
1984
- const t = this.input.value === "" ? null : Number(this.input.value);
1985
- this._onCommit(t);
1986
- }
1987
- getValue() {
1988
- var t, e;
1989
- return ((t = this.input) == null ? void 0 : t.value) === "" ? null : Number((e = this.input) == null ? void 0 : e.value);
1990
- }
1991
- focus() {
1992
- var t, e;
1993
- (t = this.input) == null || t.focus(), (e = this.input) == null || e.select();
1994
- }
1995
- destroy() {
1996
- var t, e;
1997
- (t = this.input) == null || t.removeEventListener("keydown", this._onKeyDown), (e = this.input) == null || e.removeEventListener("blur", this._onBlur);
1998
- }
1999
- }
2000
- class Mt {
2001
- mount(t, e, s, i) {
2002
- this._onCommit = s, t.style.cssText += "display:flex;align-items:center;justify-content:center;", this.chk = document.createElement("input"), this.chk.type = "checkbox", this.chk.checked = !!e.value, this.chk.style.cursor = "pointer", this.chk.addEventListener("change", () => s(this.chk.checked)), t.appendChild(this.chk);
2003
- }
2004
- getValue() {
2005
- var t;
2006
- return (t = this.chk) == null ? void 0 : t.checked;
2007
- }
2008
- focus() {
2009
- var t;
2010
- (t = this.chk) == null || t.focus();
2011
- }
2012
- destroy() {
2013
- }
2014
- }
2015
- function Ot(d) {
2016
- const t = d.editor;
2017
- if (!t)
2018
- switch (d.type) {
2019
- case "number":
2020
- return new Ct();
2021
- case "date":
2022
- return new bt();
2023
- case "boolean":
2024
- return new Mt();
2025
- case "select":
2026
- return new vt(d.options ?? [], d.optionsFn);
2027
- default:
2028
- return new xt();
2029
- }
2030
- if (typeof t == "string")
2031
- switch (t) {
2032
- case "number":
2033
- return new Ct();
2034
- case "date":
2035
- return new bt();
2036
- case "select":
2037
- return new vt(d.options ?? [], d.optionsFn);
2038
- case "checkbox":
2039
- return new Mt();
2040
- default:
2041
- return new xt();
2042
- }
2043
- switch (t.type) {
2044
- case "number": {
2045
- const e = {};
2046
- return t.min != null && (e.min = t.min), t.max != null && (e.max = t.max), t.step != null && (e.step = t.step), new Ct(e);
2047
- }
2048
- case "date":
2049
- return new bt();
2050
- case "select":
2051
- return new vt(t.options ?? [], d.optionsFn);
2052
- case "checkbox":
2053
- return new Mt();
2054
- default:
2055
- return new xt();
2056
- }
2057
- }
2058
- function nt(d) {
2059
- const t = typeof d.renderer == "string" ? d.renderer : d.renderer && typeof d.renderer == "object" ? d.renderer.type : "";
2060
- return d.type === "boolean" || d.type === "checkbox" || t === "checkbox" || t === "switch";
2061
- }
2062
- class Be {
2063
- constructor(t) {
2064
- this._activeEditor = null, this._editCell = null, this._focusCell = null, this._dragColIdx = null, this._d = t;
2065
- }
2066
- // ─── 상태 접근자 ─────────────────────────────────────────
2067
- get activeEditor() {
2068
- return this._activeEditor;
2069
- }
2070
- get editCell() {
2071
- return this._editCell;
2072
- }
2073
- get focusCell() {
2074
- return this._focusCell;
2075
- }
2076
- get dragColIdx() {
2077
- return this._dragColIdx;
2078
- }
2079
- set dragColIdx(t) {
2080
- this._dragColIdx = t;
2081
- }
2082
- // ─── 포커스 셀 ───────────────────────────────────────────
2083
- setFocusCell(t, e) {
2084
- this._focusCell = { ri: t, ci: e }, this._d.scrollToRow(t), this._d.doRender();
2085
- const s = this._d.getVisibleLeaves()[e], i = this._d.data.getRowByIndex(t);
2086
- if (s && i) {
2087
- const o = i[s.field];
2088
- this._d.announce(
2089
- `${t + 1}행 ${e + 1}열, ${s.header}: ${o == null ? "빈 값" : String(o)}`
2090
- );
2091
- }
2092
- }
2093
- clearFocusCell() {
2094
- this._focusCell = null;
2095
- }
2096
- // ─── 편집 시작 (키보드) ──────────────────────────────────
2097
- startEditByKey(t, e) {
2098
- var a, c, u;
2099
- const s = this._d.getVisibleLeaves()[e];
2100
- if (!s) return;
2101
- if (nt(s)) {
2102
- const h = this._d.getOptions();
2103
- if (s.editable !== !1 && (s.editable !== void 0 || h.editable)) {
2104
- const k = this._d.data.getRowByIndex(t);
2105
- k && this._d.writeCell(t, s.field, !k[s.field]);
2106
- }
2107
- return;
2108
- }
2109
- const i = this._d.data.getRowByIndex(t);
2110
- if (s.editable === !1 || typeof s.editable == "function" && !s.editable(i, t)) return;
2111
- this.commitEdit();
2112
- const o = (a = this._d.getRenderer()) == null ? void 0 : a.getCellEl(t, e);
2113
- if (!o) return;
2114
- o.innerHTML = "";
2115
- const n = Ot(s);
2116
- this._activeEditor = n, this._editCell = { ri: t, ci: e };
2117
- const r = {
2118
- type: "editStart",
2119
- rowIndex: t,
2120
- columnIndex: e,
2121
- field: s.field,
2122
- oldValue: i == null ? void 0 : i[s.field],
2123
- newValue: i == null ? void 0 : i[s.field],
2124
- row: i,
2125
- column: s
2126
- };
2127
- this._d.emit("editStart", r), (u = (c = this._d.getOptions()).onEditStart) == null || u.call(c, r), o.classList.add("og-editing");
2128
- const l = {
2129
- value: i == null ? void 0 : i[s.field],
2130
- row: i,
2131
- rowIndex: t,
2132
- column: s,
2133
- colIndex: e,
2134
- isSelected: !0,
2135
- rowState: "none"
2136
- };
2137
- n.mount(
2138
- o,
2139
- l,
2140
- (h) => this.commitEditWithValue(t, e, h),
2141
- () => this.cancelEdit()
2142
- ), requestAnimationFrame(() => n.focus());
2143
- }
2144
- // ─── 편집 시작 (마우스) ──────────────────────────────────
2145
- startEdit(t, e, s) {
2146
- var u, h;
2147
- const i = this._d.getOptions();
2148
- if (!i.editable) return;
2149
- const o = this._d.getVisibleLeaves()[e];
2150
- if (!o || nt(o)) return;
2151
- const n = this._d.data.getRowByIndex(t);
2152
- if (o.editable === !1 || typeof o.editable == "function" && !o.editable(n, t) || !o.editable && !i.editable) return;
2153
- this.commitEdit();
2154
- const r = (u = this._d.getRenderer()) == null ? void 0 : u.getCellEl(t, e);
2155
- if (!r) return;
2156
- r.innerHTML = "";
2157
- const l = Ot(o);
2158
- this._activeEditor = l, this._editCell = { ri: t, ci: e };
2159
- const a = {
2160
- type: "editStart",
2161
- rowIndex: t,
2162
- columnIndex: e,
2163
- field: o.field,
2164
- oldValue: n == null ? void 0 : n[o.field],
2165
- newValue: n == null ? void 0 : n[o.field],
2166
- row: n,
2167
- column: o
2168
- };
2169
- this._d.emit("editStart", a), (h = i.onEditStart) == null || h.call(i, a), r.classList.add("og-editing");
2170
- const c = {
2171
- value: n == null ? void 0 : n[o.field],
2172
- row: n,
2173
- rowIndex: t,
2174
- column: o,
2175
- colIndex: e,
2176
- isSelected: !0,
2177
- rowState: "none"
2178
- };
2179
- l.mount(
2180
- r,
2181
- c,
2182
- (g) => this.commitEditWithValue(t, e, g),
2183
- () => this.cancelEdit()
2184
- ), requestAnimationFrame(() => l.focus());
2185
- }
2186
- // ─── 편집 종료 ───────────────────────────────────────────
2187
- commitEdit() {
2188
- if (!this._activeEditor || !this._editCell) return;
2189
- const t = this._activeEditor.getValue(), { ri: e, ci: s } = this._editCell;
2190
- this._finishEdit(e, s, t, !1);
2191
- }
2192
- commitEditWithValue(t, e, s) {
2193
- this._finishEdit(t, e, s, !1);
2194
- }
2195
- cancelEdit() {
2196
- if (!this._editCell) return;
2197
- const { ri: t, ci: e } = this._editCell;
2198
- this._finishEdit(t, e, void 0, !0);
2199
- }
2200
- _finishEdit(t, e, s, i) {
2201
- var r, l, a;
2202
- if (!this._activeEditor) return;
2203
- const o = this._d.getVisibleLeaves()[e], n = (r = this._d.getRenderer()) == null ? void 0 : r.getCellEl(t, e);
2204
- if (n && (this._activeEditor.destroy(), n.classList.remove("og-editing")), this._activeEditor = null, this._editCell = null, !i && o) {
2205
- const c = this._d.data.getCellValue(t, o.field);
2206
- if (s !== c) {
2207
- this._d.data.updateCell(t, o.field, s);
2208
- const u = this._d.data.getRowByIndex(t), h = this._d.getOptions(), g = {
2209
- type: "editEnd",
2210
- rowIndex: t,
2211
- columnIndex: e,
2212
- field: o.field,
2213
- oldValue: c,
2214
- newValue: s,
2215
- row: u,
2216
- column: o
2217
- };
2218
- this._d.emit("editEnd", g), (l = h.onEditEnd) == null || l.call(h, g), this._d.emit("dataChange", this._d.data.getData()), (a = h.onDataChange) == null || a.call(h, this._d.data.getData());
2219
- }
2220
- }
2221
- this._d.doRender(), requestAnimationFrame(() => this._d.getContainer().focus({ preventScroll: !0 }));
2222
- }
2223
- }
2224
- class Oe {
2225
- constructor(t, e, s, i, o) {
2226
- this._selects = /* @__PURE__ */ new Map(), this._selected = {}, this._config = e, this._onFilter = s, this._onReset = i, this._el = document.createElement("fieldset"), this._el.className = "og-filter-select";
2227
- const n = document.createElement("legend");
2228
- n.className = "og-filter-select-legend", n.textContent = e.legend ?? "필터", this._el.appendChild(n);
2229
- const r = document.createElement("div");
2230
- r.className = "og-filter-select-row";
2231
- for (const a of e.columns) {
2232
- const c = `og-fsel-${a.field}`, u = document.createElement("div");
2233
- u.className = "og-filter-select-group";
2234
- const h = document.createElement("label");
2235
- h.htmlFor = c, h.textContent = a.label, h.className = "og-filter-select-label";
2236
- const g = document.createElement("select");
2237
- g.id = c, g.className = "og-filter-select-sel", g.setAttribute("aria-label", a.label), o && g.setAttribute("aria-controls", o), a.dependsOn ? this._fill(g, [], !1) : this._fill(g, this._resolve(a, ""), !0), g.addEventListener("change", () => this._onChange(a.field, g.value)), u.appendChild(h), u.appendChild(g), r.appendChild(u), this._selects.set(a.field, g);
2238
- }
2239
- const l = document.createElement("button");
2240
- l.type = "button", l.textContent = "초기화", l.className = "og-filter-select-reset", l.setAttribute("aria-label", "필터 초기화"), l.addEventListener("click", () => this._reset()), this._el.appendChild(r), this._el.appendChild(l), t.insertBefore(this._el, t.firstChild);
2241
- }
2242
- // ─── 옵션 해결 ────────────────────────────────────────
2243
- /**
2244
- * 컬럼의 옵션 목록을 계산한다.
2245
- *
2246
- * @param col 대상 컬럼 정의
2247
- * @param parentValue 부모 선택값 (캐스케이딩 필터에 사용)
2248
- */
2249
- _resolve(t, e) {
2250
- if (t.options) return t.options;
2251
- let s = t.data ?? [];
2252
- t.dependsOn && t.dependsOnKey && e && (s = s.filter(
2253
- (n) => String(n[t.dependsOnKey] ?? "") === e
2254
- ));
2255
- const i = t.valueKey ?? "value", o = t.textKey ?? i;
2256
- return s.map((n) => ({
2257
- value: String(n[i] ?? ""),
2258
- text: String(n[o] ?? n[i] ?? "")
2259
- }));
2260
- }
2261
- // ─── select DOM 채우기 ────────────────────────────────
2262
- _fill(t, e, s) {
2263
- t.innerHTML = "";
2264
- const i = document.createElement("option");
2265
- i.value = "", i.textContent = "전체", t.appendChild(i);
2266
- for (const o of e) {
2267
- const n = document.createElement("option");
2268
- n.value = o.value, n.textContent = o.text, t.appendChild(n);
2269
- }
2270
- t.disabled = !s;
2271
- }
2272
- // ─── 선택 변경 처리 ───────────────────────────────────
2273
- _onChange(t, e) {
2274
- const s = this._config.columns.find((o) => o.field === t), i = s.filterKey ?? s.field;
2275
- e ? (this._selected[t] = e, this._onFilter(i, [{ operator: "=", value: e }])) : (delete this._selected[t], this._onReset(i)), this._cascade(t);
2276
- }
2277
- /**
2278
- * 부모 컬럼 변경 후 자식 컬럼 옵션을 재계산한다 (재귀).
2279
- */
2280
- _cascade(t) {
2281
- const e = this._selected[t] ?? "";
2282
- for (const s of this._config.columns) {
2283
- if (s.dependsOn !== t) continue;
2284
- const i = this._selects.get(s.field);
2285
- if (!i) continue;
2286
- const o = s.filterKey ?? s.field;
2287
- e ? (this._fill(i, this._resolve(s, e), !0), i.value = "", delete this._selected[s.field], this._onReset(o)) : (this._fill(i, [], !1), delete this._selected[s.field], this._onReset(o), this._cascade(s.field));
2288
- }
2289
- }
2290
- // ─── 전체 초기화 ──────────────────────────────────────
2291
- _reset() {
2292
- this._selected = {};
2293
- for (const t of this._config.columns) {
2294
- const e = this._selects.get(t.field), s = t.filterKey ?? t.field;
2295
- e && (t.dependsOn ? this._fill(e, [], !1) : (e.value = "", e.disabled = !1), this._onReset(s));
2296
- }
2297
- }
2298
- // ─── 공개 API ─────────────────────────────────────────
2299
- reset() {
2300
- this._reset();
2301
- }
2302
- destroy() {
2303
- this._el.remove();
2304
- }
2305
- }
2306
- class We {
2307
- constructor(t, e, s) {
2308
- this._page = 1, this._totalRows = 0, this._pageSize = e, this._onChange = s, this._el = document.createElement("div"), this._el.className = "og-pagination", this._el.style.cssText = `
2309
- display:flex;align-items:center;justify-content:center;gap:4px;
2310
- padding:6px 8px;border-top:1px solid var(--og-border-color,#e0e0e0);
2311
- background:var(--og-header-bg,#f5f5f5);flex-shrink:0;user-select:none;
2312
- font-size:12px;color:var(--og-text-color,#333);
2313
- `, t.appendChild(this._el), this._render();
2314
- }
2315
- get page() {
2316
- return this._page;
2317
- }
2318
- get pageSize() {
2319
- return this._pageSize;
2320
- }
2321
- get totalPages() {
2322
- return Math.max(1, Math.ceil(this._totalRows / this._pageSize));
2323
- }
2324
- /** 전체 행 수 갱신 → 현재 페이지 유효성 검사 후 재렌더 */
2325
- setTotalRows(t) {
2326
- this._totalRows = t, this._page > this.totalPages && (this._page = this.totalPages), this._render();
2327
- }
2328
- setPageSize(t) {
2329
- this._pageSize = t, this._page = 1, this._render(), this._emit();
2330
- }
2331
- goTo(t) {
2332
- const e = Math.max(1, Math.min(t, this.totalPages));
2333
- e !== this._page && (this._page = e, this._render(), this._emit());
2334
- }
2335
- /** 현재 페이지의 [startIndex, endIndex] 반환 (DataLayer 인덱스 기준) */
2336
- getRange() {
2337
- const t = (this._page - 1) * this._pageSize, e = Math.min(t + this._pageSize - 1, this._totalRows - 1);
2338
- return { start: t, end: e };
2339
- }
2340
- _emit() {
2341
- this._onChange({
2342
- page: this._page,
2343
- pageSize: this._pageSize,
2344
- totalRows: this._totalRows,
2345
- totalPages: this.totalPages
2346
- });
2347
- }
2348
- _render() {
2349
- this._el.innerHTML = "";
2350
- const t = this.totalPages, e = document.createElement("span");
2351
- e.style.cssText = "display:flex;align-items:center;gap:3px;margin-right:8px;";
2352
- const s = document.createElement("span");
2353
- s.textContent = "행/페이지:", s.style.color = "#888";
2354
- const i = document.createElement("select");
2355
- i.style.cssText = "padding:2px 4px;border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;font-size:11px;cursor:pointer;";
2356
- for (const c of [10, 20, 50, 100, 200]) {
2357
- const u = document.createElement("option");
2358
- u.value = String(c), u.textContent = String(c), c === this._pageSize && (u.selected = !0), i.appendChild(u);
2359
- }
2360
- i.addEventListener("change", () => this.setPageSize(Number(i.value))), e.appendChild(s), e.appendChild(i), this._el.appendChild(e);
2361
- const o = document.createElement("span"), { start: n, end: r } = this.getRange();
2362
- o.textContent = this._totalRows > 0 ? `${n + 1}–${r + 1} / ${this._totalRows}건` : "0건", o.style.cssText = "margin-right:8px;color:#888;", this._el.appendChild(o);
2363
- const l = (c, u, h) => {
2364
- const g = document.createElement("button");
2365
- return g.textContent = c, g.disabled = h, g.style.cssText = `
2366
- min-width:28px;height:24px;padding:0 6px;
2367
- border:1px solid var(--og-border-color,#e0e0e0);border-radius:3px;
2368
- background:${h ? "#f5f5f5" : "#fff"};
2369
- color:${h ? "#bbb" : "var(--og-text-color,#333)"};
2370
- cursor:${h ? "default" : "pointer"};font-size:12px;
2371
- `, h || g.addEventListener("click", () => this.goTo(u)), g;
2372
- };
2373
- this._el.appendChild(l("«", 1, this._page === 1)), this._el.appendChild(l("‹", this._page - 1, this._page === 1));
2374
- const a = Ne(this._page, t);
2375
- for (const c of a)
2376
- if (c === -1) {
2377
- const u = document.createElement("span");
2378
- u.textContent = "…", u.style.padding = "0 3px", this._el.appendChild(u);
2379
- } else {
2380
- const u = l(String(c), c, c === this._page);
2381
- c === this._page && (u.style.background = "var(--og-primary,#1976d2)", u.style.color = "#fff", u.style.borderColor = "var(--og-primary,#1976d2)"), this._el.appendChild(u);
2382
- }
2383
- this._el.appendChild(l("›", this._page + 1, this._page === t)), this._el.appendChild(l("»", t, this._page === t));
2384
- }
2385
- destroy() {
2386
- this._el.remove();
2387
- }
2388
- }
2389
- function Ne(d, t) {
2390
- if (t <= 7) return Array.from({ length: t }, (s, i) => i + 1);
2391
- const e = [1];
2392
- d > 3 && e.push(-1);
2393
- for (let s = Math.max(2, d - 1); s <= Math.min(t - 1, d + 1); s++)
2394
- e.push(s);
2395
- return d < t - 2 && e.push(-1), e.push(t), e;
2396
- }
2397
- class Ke {
2398
- // grab 지점의 상단 오프셋
2399
- constructor(t, e, s, i) {
2400
- this._dx = e - t.left, this._dy = s - t.top;
2401
- const o = document.createElement("div");
2402
- o.className = "og-drag-ghost", o.style.cssText = `position:fixed;left:0;top:0;width:${t.width}px;height:${Math.min(t.height, 40)}px;transform:translate(${t.left}px,${t.top}px);background:rgba(25,118,210,0.12);border:2px dashed #1976d2;box-sizing:border-box;pointer-events:none;z-index:10000;border-radius:3px;opacity:0.92;display:flex;align-items:center;padding-left:10px;font-size:12px;color:#1565c0;font-weight:600;white-space:nowrap;overflow:hidden;`, i > 1 && (o.textContent = `${i}개 행 이동`), document.body.appendChild(o), this._el = o;
2403
- }
2404
- /** 커서 위치로 이동 (grab 오프셋 유지) */
2405
- move(t, e) {
2406
- this._el.style.transform = `translate(${t - this._dx}px,${e - this._dy}px)`;
2407
- }
2408
- destroy() {
2409
- this._el.remove();
2410
- }
2411
- }
2412
- class Wt {
2413
- constructor(t = "#1976d2") {
2414
- const e = document.createElement("div");
2415
- e.className = "og-drop-indicator", e.style.cssText = "position:absolute;left:0;right:0;display:none;align-items:center;pointer-events:none;z-index:9998;transform:translateY(-50%);";
2416
- const s = (o) => {
2417
- const n = document.createElement("div"), r = o === "left" ? `border-left:7px solid ${t}` : `border-right:7px solid ${t}`;
2418
- return n.style.cssText = `width:0;height:0;flex-shrink:0;border-top:5px solid transparent;border-bottom:5px solid transparent;${r};`, n;
2419
- }, i = document.createElement("div");
2420
- i.style.cssText = `flex:1;height:3px;background:${t};border-radius:2px;box-shadow:0 0 0 1px rgba(255,255,255,0.7);`, e.append(s("left"), i, s("right")), this._el = e;
2421
- }
2422
- /** parent(그리드 바디) 안의 top(행 경계) 위치에 표시 */
2423
- showIn(t, e) {
2424
- this._el.parentElement !== t && (this._el.remove(), t.appendChild(this._el)), this._el.style.display = "flex", this._el.style.top = `${e}px`;
2425
- }
2426
- hide() {
2427
- this._el.style.display = "none";
2428
- }
2429
- destroy() {
2430
- this._el.remove();
2431
- }
2432
- }
2433
- const Nt = (d, t, e) => Math.max(t, Math.min(e, d));
2434
- class Pe {
2435
- // 다른 그리드 드롭
2436
- constructor(t, e, s, i = null, o = () => 1) {
2437
- this._bodyEl = t, this._rowHeight = e, this._onDrop = s, this._cross = i, this._getDragCount = o, this._drag = null, this._selfIndicator = new Wt("#1976d2"), this._crossIndicator = new Wt("#2e7d32"), this._onMouseMove = this._onMouseMove.bind(this), this._onMouseUp = this._onMouseUp.bind(this);
2438
- }
2439
- /** 행 엘리먼트에 드래그 핸들 삽입 */
2440
- attachHandle(t, e, s) {
2441
- const i = document.createElement("div");
2442
- return i.className = "og-drag-handle", i.innerHTML = "⠿", i.style.cssText = `
2443
- width:18px;min-width:18px;height:100%;
2444
- display:flex;align-items:center;justify-content:center;
2445
- cursor:grab;font-size:14px;color:#bbb;flex-shrink:0;
2446
- user-select:none;border-right:1px solid var(--og-border-color,#e0e0e0);
2447
- `, i.addEventListener("mousedown", (o) => {
2448
- o.preventDefault(), o.stopPropagation(), this._startDrag(o, t, e, s);
2449
- }), i;
2450
- }
2451
- _startDrag(t, e, s, i) {
2452
- const o = e.getBoundingClientRect(), n = this._getDragCount(s);
2453
- this._drag = {
2454
- fromIndex: s,
2455
- bodyEl: this._bodyEl,
2456
- rowHeight: this._rowHeight,
2457
- totalRows: i,
2458
- ghost: new Ke(o, t.clientX, t.clientY, n),
2459
- currentTarget: s,
2460
- crossTarget: null
2461
- }, document.addEventListener("mousemove", this._onMouseMove, !0), document.addEventListener("mouseup", this._onMouseUp, !0);
2462
- }
2463
- _onMouseMove(t) {
2464
- if (!this._drag) return;
2465
- const e = this._drag;
2466
- if (e.ghost.move(t.clientX, t.clientY), this._cross) {
2467
- const o = this._cross.resolveTarget(t.clientX, t.clientY);
2468
- if (o && o.bodyEl !== e.bodyEl) {
2469
- const n = o.bodyEl.getBoundingClientRect(), r = t.clientY - n.top + o.bodyEl.scrollTop, l = Nt(Math.round(r / o.rowHeight), 0, o.totalRows);
2470
- e.crossTarget = { bodyEl: o.bodyEl, index: l }, this._selfIndicator.hide(), this._crossIndicator.showIn(o.bodyEl, l * o.rowHeight);
2471
- return;
2472
- }
2473
- }
2474
- e.crossTarget = null, this._crossIndicator.hide();
2475
- const s = e.bodyEl.getBoundingClientRect(), i = t.clientY - s.top + e.bodyEl.scrollTop;
2476
- e.currentTarget = Nt(Math.round(i / e.rowHeight), 0, e.totalRows - 1), this._selfIndicator.showIn(e.bodyEl, e.currentTarget * e.rowHeight);
2477
- }
2478
- _onMouseUp(t) {
2479
- if (document.removeEventListener("mousemove", this._onMouseMove, !0), document.removeEventListener("mouseup", this._onMouseUp, !0), !this._drag) return;
2480
- const { fromIndex: e, currentTarget: s, ghost: i, crossTarget: o } = this._drag;
2481
- this._drag = null, i.destroy(), this._selfIndicator.hide(), this._crossIndicator.hide(), o && this._cross ? this._cross.onCrossDrop(e, o.bodyEl, o.index) : e !== s && this._onDrop(e, s);
2482
- }
2483
- destroy() {
2484
- var t;
2485
- document.removeEventListener("mousemove", this._onMouseMove, !0), document.removeEventListener("mouseup", this._onMouseUp, !0), (t = this._drag) == null || t.ghost.destroy(), this._selfIndicator.destroy(), this._crossIndicator.destroy(), this._drag = null;
2486
- }
2487
- }
2488
- class Z {
2489
- constructor() {
2490
- this._map = /* @__PURE__ */ new Map();
2491
- }
2492
- static _key(t, e) {
2493
- return `${t}:${e}`;
2494
- }
2495
- /** 수동 병합 정의 목록으로 맵 구성 */
2496
- applyMergeCells(t) {
2497
- this._map.clear();
2498
- for (const e of t) {
2499
- const s = Math.max(1, e.rowSpan ?? 1), i = Math.max(1, e.colSpan ?? 1);
2500
- this._map.set(Z._key(e.row, e.col), {
2501
- rowSpan: s,
2502
- colSpan: i,
2503
- hidden: !1
2504
- });
2505
- for (let o = 0; o < s; o++)
2506
- for (let n = 0; n < i; n++)
2507
- o === 0 && n === 0 || this._map.set(Z._key(e.row + o, e.col + n), {
2508
- rowSpan: 1,
2509
- colSpan: 1,
2510
- hidden: !0
2511
- });
2512
- }
2513
- }
2514
- /**
2515
- * 자동 병합: 지정 컬럼 인덱스 목록에 대해 연속 같은 값을 rowSpan으로 병합.
2516
- * data: 현재 표시 순서의 행 배열, colIndexes: 자동병합할 leaf 컬럼 인덱스
2517
- * fields: colIndexes[i] 에 대응하는 field 이름
2518
- */
2519
- applyAutoMerge(t, e, s) {
2520
- var i, o;
2521
- this._map.clear();
2522
- for (let n = 0; n < e.length; n++) {
2523
- const r = e[n], l = s[n];
2524
- let a = 0;
2525
- for (let c = 1; c <= t.length; c++) {
2526
- const u = (i = t[c - 1]) == null ? void 0 : i[l], h = c < t.length ? (o = t[c]) == null ? void 0 : o[l] : void 0;
2527
- if (c === t.length || h !== u) {
2528
- const g = c - a;
2529
- if (g > 1) {
2530
- this._map.set(Z._key(a, r), {
2531
- rowSpan: g,
2532
- colSpan: 1,
2533
- hidden: !1
2534
- });
2535
- for (let k = a + 1; k < c; k++)
2536
- this._map.set(Z._key(k, r), {
2537
- rowSpan: 1,
2538
- colSpan: 1,
2539
- hidden: !0
2540
- });
2541
- }
2542
- a = c;
2543
- }
2544
- }
2545
- }
2546
- }
2547
- /** 셀 병합 정보 조회. 없으면 null */
2548
- getInfo(t, e) {
2549
- return this._map.get(Z._key(t, e)) ?? null;
2550
- }
2551
- /** 병합 맵 초기화 */
2552
- clear() {
2553
- this._map.clear();
2554
- }
2555
- get isEmpty() {
2556
- return this._map.size === 0;
2557
- }
2558
- }
2559
- const Ve = [
2560
- { id: "sort-asc", label: "오름차순 정렬", icon: "↑", action: "sortAsc" },
2561
- { id: "sort-desc", label: "내림차순 정렬", icon: "↓", action: "sortDesc" },
2562
- { type: "divider" },
2563
- { id: "find", label: "찾기", icon: "🔍", action: "find" },
2564
- { type: "divider" },
2565
- { id: "excel", label: "Excel로 저장", icon: "📊", action: "excel" },
2566
- { id: "csv", label: "CSV로 저장", icon: "📄", action: "csv" },
2567
- { id: "print", label: "인쇄", icon: "🖨", action: "print" }
2568
- ];
2569
- class je {
2570
- /**
2571
- * @param _anchor 그리드 컨테이너 엘리먼트 — CSS 변수 상속 기준점
2572
- * @param _actions 기본 액션 핸들러 (OpenGrid에서 주입)
2573
- */
2574
- constructor(t, e) {
2575
- this._anchor = t, this._actions = e, this._el = null, this._docClick = null, this._docKey = null, this._docScroll = null, this._docMouseMove = null, this._focusIdx = -1;
2576
- }
2577
- open(t, e) {
2578
- this.close();
2579
- const s = e ?? Ve, i = document.createElement("div");
2580
- i.className = "og-context-menu", i.setAttribute("role", "menu");
2581
- for (const r of s) {
2582
- if (r.type === "divider") {
2583
- const c = document.createElement("div");
2584
- c.className = "og-cm-divider", c.setAttribute("role", "separator"), i.appendChild(c);
2585
- continue;
2586
- }
2587
- const l = document.createElement("button");
2588
- if (l.className = "og-cm-item", l.setAttribute("role", "menuitem"), l.setAttribute("tabindex", "-1"), r.disabled && (l.classList.add("og-cm-disabled"), l.setAttribute("aria-disabled", "true")), r.icon) {
2589
- const c = document.createElement("span");
2590
- if (c.className = "og-cm-icon", /^[a-zA-Z][\w-]*(\s+[\w-]+)+$/.test(r.icon.trim())) {
2591
- const u = document.createElement("i");
2592
- u.className = r.icon, c.appendChild(u);
2593
- } else
2594
- c.textContent = r.icon;
2595
- c.setAttribute("aria-hidden", "true"), l.appendChild(c);
2596
- }
2597
- const a = document.createElement("span");
2598
- a.className = "og-cm-label", a.textContent = r.label ?? "", l.appendChild(a), l.addEventListener("click", (c) => {
2599
- c.stopPropagation(), r.disabled || this._runAction(r), this.close();
2600
- }), i.appendChild(l);
2601
- }
2602
- const o = this._anchor.closest("[data-og-theme]"), n = o == null ? void 0 : o.getAttribute("data-og-theme");
2603
- n && i.setAttribute("data-og-theme", n), document.body.appendChild(i), this._el = i, this._docMouseMove = (r) => {
2604
- if (!this._el) return;
2605
- const l = this._el.getBoundingClientRect();
2606
- (r.clientX < l.left - 4 || r.clientX > l.right + 4 || r.clientY < l.top - 4 || r.clientY > l.bottom + 4) && this.close();
2607
- }, this._position(i, t.clientX, t.clientY, () => {
2608
- this._el === i && document.addEventListener("mousemove", this._docMouseMove, { capture: !0, passive: !0 });
2609
- }), this._docClick = (r) => {
2610
- i.contains(r.target) || this.close();
2611
- }, this._docKey = (r) => {
2612
- if (r.key === "Escape") {
2613
- this.close();
2614
- return;
2615
- }
2616
- if (r.key === "ArrowDown") {
2617
- r.preventDefault(), this._moveFocus(1);
2618
- return;
2619
- }
2620
- if (r.key === "ArrowUp") {
2621
- r.preventDefault(), this._moveFocus(-1);
2622
- return;
2623
- }
2624
- if (r.key === "Enter") {
2625
- const l = i.querySelector(".og-cm-item:focus");
2626
- l == null || l.click();
2627
- }
2628
- }, this._docScroll = () => this.close(), setTimeout(() => {
2629
- document.addEventListener("click", this._docClick), document.addEventListener("keydown", this._docKey), window.addEventListener("scroll", this._docScroll, { passive: !0 });
2630
- }, 0), this._focusIdx = -1, this._moveFocus(1);
2631
- }
2632
- close() {
2633
- var t;
2634
- (t = this._el) == null || t.remove(), this._el = null, this._docClick && document.removeEventListener("click", this._docClick), this._docKey && document.removeEventListener("keydown", this._docKey), this._docScroll && window.removeEventListener("scroll", this._docScroll), this._docMouseMove && document.removeEventListener("mousemove", this._docMouseMove, { capture: !0 }), this._docClick = this._docKey = this._docScroll = this._docMouseMove = null, this._focusIdx = -1;
2635
- }
2636
- destroy() {
2637
- this.close();
2638
- }
2639
- // ── 위치 결정 ─────────────────────────────────────────────
2640
- _position(t, e, s, i) {
2641
- t.style.cssText = "position:fixed;visibility:hidden;left:0;top:0;", requestAnimationFrame(() => {
2642
- const { width: o, height: n } = t.getBoundingClientRect(), r = window.innerWidth, l = window.innerHeight, a = e + o > r ? Math.max(0, e - o) : e, c = s + n > l ? Math.max(0, s - n) : s;
2643
- t.style.cssText = `position:fixed;left:${a}px;top:${c}px;z-index:9999;`, i == null || i();
2644
- });
2645
- }
2646
- // ── 키보드 포커스 이동 ────────────────────────────────────
2647
- _moveFocus(t) {
2648
- var s;
2649
- if (!this._el) return;
2650
- const e = Array.from(
2651
- this._el.querySelectorAll(".og-cm-item:not(.og-cm-disabled)")
2652
- );
2653
- e.length && (this._focusIdx = (this._focusIdx + t + e.length) % e.length, (s = e[this._focusIdx]) == null || s.focus());
2654
- }
2655
- // ── 액션 실행 ─────────────────────────────────────────────
2656
- _runAction(t) {
2657
- if (typeof t.action == "function") {
2658
- t.action();
2659
- return;
2660
- }
2661
- switch (t.action) {
2662
- case "sortAsc":
2663
- this._actions.onSortAsc();
2664
- break;
2665
- case "sortDesc":
2666
- this._actions.onSortDesc();
2667
- break;
2668
- case "find":
2669
- this._actions.onFind();
2670
- break;
2671
- case "excel":
2672
- this._actions.onExcel();
2673
- break;
2674
- case "csv":
2675
- this._actions.onCsv();
2676
- break;
2677
- case "print":
2678
- this._actions.onPrint();
2679
- break;
2680
- }
2681
- }
2682
- }
2683
- class Kt {
2684
- constructor(t, e) {
2685
- this._sheets = /* @__PURE__ */ new Map(), this._active = "", this._onSwitch = e, this._tabBar = this._buildTabBar(t);
2686
- }
2687
- // ── 시트 CRUD ────────────────────────────────────────────
2688
- add(t, e = [], s = []) {
2689
- if (this._sheets.has(t))
2690
- throw new Error(`WorksheetManager: 시트 '${t}'이 이미 존재합니다`);
2691
- this._sheets.set(t, { name: t, columns: e, data: s }), this._renderTabs(), this._sheets.size === 1 && this.switch(t);
2692
- }
2693
- remove(t) {
2694
- if (!this._sheets.has(t)) return;
2695
- if (this._sheets.size === 1)
2696
- throw new Error("WorksheetManager: 마지막 시트는 삭제할 수 없습니다");
2697
- const e = this._active === t;
2698
- this._sheets.delete(t), this._renderTabs(), e && this.switch(this._sheets.keys().next().value);
2699
- }
2700
- rename(t, e) {
2701
- if (!this._sheets.has(t)) return;
2702
- if (this._sheets.has(e))
2703
- throw new Error(`WorksheetManager: 시트 '${e}'이 이미 존재합니다`);
2704
- this._sheets.get(t);
2705
- const s = Array.from(this._sheets.entries()).map(
2706
- ([i, o]) => i === t ? [e, { ...o, name: e }] : [i, o]
2707
- );
2708
- this._sheets = new Map(s), this._active === t && (this._active = e), this._renderTabs();
2709
- }
2710
- switch(t) {
2711
- const e = this._sheets.get(t);
2712
- if (!e) throw new Error(`WorksheetManager: 시트 '${t}'을 찾을 수 없습니다`);
2713
- this._active = t, this._renderTabs(), this._onSwitch(t, e);
2714
- }
2715
- get(t) {
2716
- return this._sheets.get(t);
2717
- }
2718
- getNames() {
2719
- return Array.from(this._sheets.keys());
2720
- }
2721
- getActive() {
2722
- return this._active;
2723
- }
2724
- /** 현재 활성 시트의 data를 갱신 (그리드 편집 동기화용) */
2725
- syncData(t, e) {
2726
- const s = this._sheets.get(t);
2727
- s && (s.data = e);
2728
- }
2729
- destroy() {
2730
- this._tabBar.remove();
2731
- }
2732
- // ── 탭 UI ────────────────────────────────────────────────
2733
- _buildTabBar(t) {
2734
- const e = document.createElement("div");
2735
- return e.className = "og-sheet-tabs", t.appendChild(e), e;
2736
- }
2737
- _renderTabs() {
2738
- this._tabBar.innerHTML = "";
2739
- for (const e of this._sheets.keys()) {
2740
- const s = document.createElement("button");
2741
- s.className = "og-sheet-tab", s.textContent = e, s.setAttribute("role", "tab"), s.setAttribute("aria-selected", e === this._active ? "true" : "false"), e === this._active && s.classList.add("og-sheet-tab--active"), s.addEventListener("click", () => {
2742
- e !== this._active && this.switch(e);
2743
- }), s.addEventListener("dblclick", () => this._startRename(s, e)), this._tabBar.appendChild(s);
2744
- }
2745
- const t = document.createElement("button");
2746
- t.className = "og-sheet-add", t.textContent = "+", t.setAttribute("aria-label", "새 워크시트 추가"), t.addEventListener("click", () => {
2747
- const e = `Sheet${this._sheets.size + 1}`;
2748
- this.add(e, [], []), this.switch(e);
2749
- }), this._tabBar.appendChild(t);
2750
- }
2751
- /** 탭 더블클릭 → input으로 전환해 이름 변경 */
2752
- _startRename(t, e) {
2753
- const s = document.createElement("input");
2754
- s.className = "og-sheet-tab-rename", s.value = e, t.replaceWith(s), s.focus(), s.select();
2755
- const i = () => {
2756
- const o = s.value.trim() || e;
2757
- try {
2758
- o !== e ? this.rename(e, o) : this._renderTabs();
2759
- } catch {
2760
- this._renderTabs();
2761
- }
2762
- };
2763
- s.addEventListener("blur", i), s.addEventListener("keydown", (o) => {
2764
- o.key === "Enter" && s.blur(), o.key === "Escape" && (s.value = e, s.blur());
2765
- });
2766
- }
2767
- }
2768
- class Ue {
2769
- constructor(t) {
2770
- this._d = t;
2771
- }
2772
- _readCssVar(t) {
2773
- return getComputedStyle(this._d.getContainer()).getPropertyValue(t).trim();
2774
- }
2775
- _hexToXlsxRgb(t) {
2776
- const e = t.trim(), s = e.match(/^rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)/i);
2777
- if (s)
2778
- return [s[1], s[2], s[3]].map((o) => parseInt(o).toString(16).padStart(2, "0")).join("").toUpperCase();
2779
- const i = e.replace("#", "").toUpperCase();
2780
- return i.length === 3 ? i[0] + i[0] + i[1] + i[1] + i[2] + i[2] : i.length === 6 ? i : "";
2781
- }
2782
- exportExcel(t) {
2783
- const e = typeof t == "string" ? { filename: t } : t ?? {};
2784
- let s = e.filename ?? "export";
2785
- s.toLowerCase().endsWith(".xlsx") || (s += ".xlsx");
2786
- const i = e.sheetName ?? (this._d.getOptions().ariaLabel || "Sheet1"), o = this._d.getData(), n = this._d.getColLayout().visibleLeaves.filter((a) => {
2787
- var c;
2788
- return !((c = e.exceptFields) != null && c.includes(a.field));
2789
- }), r = e.includeHeader !== !1, l = (this._d.getStrategy ?? ((a, c) => c))(
2790
- "cellSerializer",
2791
- (a, c, u) => c.type === "number" && typeof a == "number" ? a : typeof a == "boolean" ? a ? "✓" : "" : typeof a == "object" ? "" : String(a)
2792
- );
2793
- import("./xlsx.min-Wavxcamn.js").then((a) => a.x).then(({ utils: a, writeFile: c }) => {
2794
- var A;
2795
- const u = [];
2796
- r && u.push(n.map(($) => $.header));
2797
- for (const $ of o)
2798
- u.push(n.map((p) => {
2799
- const C = $[p.field];
2800
- if (e.maskOnExport && p.mask && this._d.getMaskEnabled(p.field))
2801
- return kt(C == null ? "" : String(C), p.mask);
2802
- const O = C;
2803
- return O == null || O === "" ? "" : l(O, p, $);
2804
- }));
2805
- const h = a.aoa_to_sheet(u), g = this._d.getColWidths(), k = this._d.getColLayout();
2806
- h["!cols"] = n.map(($) => ({
2807
- wpx: g[k.getColumnIndex($.field)] ?? 100
2808
- })), h["!rows"] = u.map(($, p) => ({ hpx: p === 0 && r ? 22 : 19 }));
2809
- const m = e.styleMode ?? "theme";
2810
- let w = "1565C0", x = "FFFFFF", _ = "FFFFFF", b = "EEF2FF", L = "212121", v = "BDBDBD", R = 10;
2811
- if (m === "theme") {
2812
- const $ = (C) => this._hexToXlsxRgb(C);
2813
- w = $(this._readCssVar("--og-header-bg")) || w, x = $(this._readCssVar("--og-header-color")) || x, _ = $(this._readCssVar("--og-row-bg")) || _, b = $(this._readCssVar("--og-row-alt-bg")) || b, L = $(this._readCssVar("--og-row-color")) || L, v = $(this._readCssVar("--og-border-color")) || v;
2814
- const p = this._readCssVar("--og-font-size");
2815
- p && (R = Math.max(8, Math.round(parseFloat(p) * 0.75)));
2816
- }
2817
- const F = m === "none", I = {
2818
- hdrFont: F ? {} : { bold: !0, color: { rgb: x }, sz: R, name: "맑은 고딕" },
2819
- dataFont: F ? {} : { sz: R, color: { rgb: L }, name: "맑은 고딕" },
2820
- hdrFill: F ? {} : { patternType: "solid", fgColor: { rgb: w } },
2821
- evenFill: F ? {} : { patternType: "solid", fgColor: { rgb: _ } },
2822
- oddFill: F ? {} : { patternType: "solid", fgColor: { rgb: b } },
2823
- hdrBorder: F ? {} : {
2824
- top: { style: "medium", color: { rgb: w } },
2825
- bottom: { style: "medium", color: { rgb: w } },
2826
- left: { style: "thin", color: { rgb: w } },
2827
- right: { style: "thin", color: { rgb: w } }
2828
- },
2829
- dataBorder: F ? {} : {
2830
- top: { style: "thin", color: { rgb: v } },
2831
- bottom: { style: "thin", color: { rgb: v } },
2832
- left: { style: "thin", color: { rgb: v } },
2833
- right: { style: "thin", color: { rgb: v } }
2834
- }
2835
- };
2836
- u.forEach(($, p) => {
2837
- const C = r && p === 0, lt = (r ? p - 1 : p) % 2 === 0;
2838
- $.forEach((X, st) => {
2839
- const f = a.encode_cell({ r: p, c: st });
2840
- h[f] || (h[f] = { t: "s", v: "" });
2841
- const S = n[st], H = S.type === "number" || S.align === "right", tt = C ? "center" : H ? "right" : S.align ?? "left";
2842
- h[f].s = {
2843
- font: C ? I.hdrFont : I.dataFont,
2844
- fill: C ? I.hdrFill : lt ? I.evenFill : I.oddFill,
2845
- border: C ? I.hdrBorder : I.dataBorder,
2846
- alignment: { horizontal: tt, vertical: "center", wrapText: !1 }
2847
- };
2848
- });
2849
- });
2850
- const T = a.book_new();
2851
- a.book_append_sheet(T, h, i), c(T, s, { cellStyles: !0 }), (A = e.onAfter) == null || A.call(e, new Blob([]));
2852
- }).catch(() => {
2853
- console.error("Excel 내보내기 실패: xlsx 패키지를 확인하세요.");
2854
- });
2855
- }
2856
- exportCsv(t) {
2857
- const e = typeof t == "string" ? { filename: t } : t ?? {}, s = this._d.getData(), i = this._d.getColLayout().visibleLeaves, o = i.map((l) => `"${l.header}"`).join(","), n = s.map((l) => i.map((a) => {
2858
- const c = l[a.field] ?? "";
2859
- if (e.maskOnExport && a.mask && this._d.getMaskEnabled(a.field))
2860
- return kt(String(c), a.mask);
2861
- const u = c;
2862
- return typeof u == "string" && u.includes(",") ? `"${u}"` : u;
2863
- }).join(",")), r = e.filename ?? "export.csv";
2864
- It("\uFEFF" + [o, ...n].join(`
2865
- `), r);
2866
- }
2867
- exportJson(t) {
2868
- const e = typeof t == "string" ? t : (t == null ? void 0 : t.filename) ?? "export.json";
2869
- It(JSON.stringify(this._d.getData(), null, 2), e, "application/json");
2870
- }
2871
- print(t) {
2872
- const e = (t == null ? void 0 : t.title) ?? "OPEN_GRID", s = (t == null ? void 0 : t.footerText) ?? "", i = this._d.getData(), o = this._d.getColLayout().visibleLeaves.filter((u) => {
2873
- var h;
2874
- return !((h = t == null ? void 0 : t.excludeFields) != null && h.includes(u.field));
2875
- }), n = o.map((u) => `<th>${u.header ?? u.field}</th>`).join(""), r = i.map(
2876
- (u) => `<tr>${o.map((h) => `<td>${String(u[h.field] ?? "")}</td>`).join("")}</tr>`
2877
- ).join(""), l = s ? `<div class="og-print-footer">${s}</div>` : "", a = `<!DOCTYPE html>
2878
- <html lang="ko"><head>
2879
- <meta charset="UTF-8"><title>${e}</title>
2880
- <style>
2881
- @page{margin:0;}
2882
- body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;font-size:12px;margin:0;padding:1cm;}
2883
- h2{margin:0 0 10px;font-size:14px;color:#333;}
2884
- p{margin:0 0 8px;font-size:11px;color:#999;}
2885
- table{border-collapse:collapse;width:100%;}
2886
- th,td{border:1px solid #ccc;padding:5px 8px;text-align:left;white-space:nowrap;}
2887
- th{background:#f5f5f5;font-weight:600;color:#333;}
2888
- tr:nth-child(even) td{background:#fafafa;}
2889
- .og-print-footer{position:fixed;bottom:0;left:0;right:0;padding:6px 1cm;font-size:10px;color:#888;border-top:1px solid #e5e7eb;background:#fff;text-align:center;}
2890
- </style>
2891
- </head><body>
2892
- <h2>${e}</h2>
2893
- <p>${i.length}행 × ${o.length}열 · ${(/* @__PURE__ */ new Date()).toLocaleString("ko-KR")}</p>
2894
- <table>
2895
- <thead><tr>${n}</tr></thead>
2896
- <tbody>${r}</tbody>
2897
- </table>
2898
- ${l}
2899
- <script>window.addEventListener('load',()=>{window.print();window.addEventListener('afterprint',()=>window.close());});<\/script>
2900
- </body></html>`, c = window.open("", "_blank", "width=960,height=640");
2901
- c && (c.document.write(a), c.document.close());
2902
- }
2903
- exportSheetsExcel(t) {
2904
- const e = this._d.getWsManager();
2905
- if (!e) {
2906
- this.exportExcel(t ?? "workbook");
2907
- return;
2908
- }
2909
- const s = t ?? "workbook.xlsx", i = (this._d.getStrategy ?? ((o, n) => n))(
2910
- "cellSerializer",
2911
- (o, n, r) => typeof o == "boolean" ? o ? "✓" : "" : n.type === "number" && typeof o == "number" ? o : String(o)
2912
- );
2913
- import("./xlsx.min-Wavxcamn.js").then((o) => o.x).then(({ utils: o, writeFile: n }) => {
2914
- const r = o.book_new(), l = this._d.getOptions();
2915
- for (const a of e.getNames()) {
2916
- const c = e.get(a), u = c.columns.length ? c.columns : l.columns, h = [u.map((k) => k.header)];
2917
- for (const k of c.data)
2918
- h.push(u.map((m) => {
2919
- const w = k[m.field];
2920
- return w == null ? "" : i(w, m, k);
2921
- }));
2922
- const g = o.aoa_to_sheet(h);
2923
- g["!cols"] = u.map(() => ({ wpx: 100 })), o.book_append_sheet(r, g, a);
2924
- }
2925
- n(r, s.endsWith(".xlsx") ? s : s + ".xlsx", { cellStyles: !0 });
2926
- }).catch(() => console.error("exportSheetsExcel: xlsx 패키지를 확인하세요."));
2927
- }
2928
- }
2929
- class Ge {
2930
- constructor(t) {
2931
- this._d = t;
2932
- }
2933
- fmtNum(t, e) {
2934
- if (!e)
2935
- return Math.round(t).toLocaleString("ko-KR");
2936
- const s = e.match(/[#0][#0,]*(?:\.[#0]+)?|\d+/), i = s ? e.slice(0, s.index) : "", o = s ? e.slice(s.index + s[0].length) : "", n = s ? s[0] : e, r = n.includes("#") || n.includes(","), l = n.match(/\.(\d+)$/), a = l ? parseInt(l[1], 10) : /^\d+$/.test(n) ? parseInt(n, 10) : 0, c = Math.abs(t).toFixed(a), [u = "0", h] = c.split("."), g = r ? u.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : u, k = h !== void 0 ? `${g}.${h}` : g, m = `${i}${k}${o}`;
2937
- return t < 0 ? `-${m}` : m;
2938
- }
2939
- computeValues() {
2940
- const t = this._d.getOptions().footer;
2941
- if (!t || t.length === 0) return [];
2942
- const e = this._d.getData();
2943
- return t.filter((s) => s.field && s.op).map((s) => {
2944
- const i = s.field, o = s.op, n = e.map((h) => h[i]).filter((h) => h != null && h !== "");
2945
- let r = null;
2946
- const l = o.toUpperCase(), a = (this._d.getStrategy ?? ((h, g) => g))(
2947
- "summaryOp",
2948
- null
2949
- );
2950
- if (a) {
2951
- const h = a(l, n, i);
2952
- if (h != null)
2953
- return { _field: i, _value: h, _formatted: this.fmtNum(h, s.format) };
2954
- }
2955
- if (l === "SUM")
2956
- r = n.length > 0 ? M.sum(n.map((h) => String(h))) : null;
2957
- else if (l === "AVG")
2958
- r = n.length > 0 ? M.sum(n.map((h) => String(h))).div(M.from(String(n.length))) : null;
2959
- else if (l === "COUNT") {
2960
- const h = n.length;
2961
- return { _field: i, _value: h, _formatted: h.toLocaleString("ko-KR") };
2962
- } else l === "MAX" ? r = n.length > 0 ? M.max(n.map((h) => String(h))) : null : l === "MIN" && (r = n.length > 0 ? M.min(n.map((h) => String(h))) : null);
2963
- if (!r) return { _field: i, _value: null, _formatted: "" };
2964
- const c = r.toNumber(), u = this.fmtNum(c, s.format);
2965
- return { _field: i, _value: c, _formatted: u };
2966
- });
2967
- }
2968
- render() {
2969
- var u;
2970
- const t = this._d.getContainer(), e = t.querySelector(".og-footer-bar");
2971
- e == null || e.remove();
2972
- const s = this._d.getOptions(), i = s.footer;
2973
- if (!i || i.length === 0) return;
2974
- const o = this._d.getColLayout().visibleLeaves, n = this._d.getColWidths() ?? o.map((h) => h.width ?? 100), r = new Map(
2975
- this.computeValues().map((h) => [h._field, h])
2976
- ), l = document.createElement("div");
2977
- l.className = "og-footer-bar", l.style.cssText = [
2978
- "display:flex;align-items:stretch;",
2979
- `min-height:${s.footerHeight}px;`,
2980
- "border-top:2px solid var(--og-primary,#1976d2);",
2981
- "background:var(--og-header-bg,#f5f5f5);",
2982
- "overflow:hidden;flex-shrink:0;font-size:13px;font-weight:600;"
2983
- ].join("");
2984
- let a = 0;
2985
- if (s.stateColumn && (a += 24), s.draggable && (a += 18), s.rowNumber && (a += 44), s.checkColumn && (a += 36), a > 0) {
2986
- const h = document.createElement("div");
2987
- h.style.cssText = `width:${a}px;flex-shrink:0;border-right:1px solid var(--og-border-color,#e0e0e0);`, l.appendChild(h);
2988
- }
2989
- let c = 0;
2990
- for (const h of i) {
2991
- const g = Math.max(1, h.colspan ?? 1);
2992
- let k = 0;
2993
- for (let b = 0; b < g; b++)
2994
- k += n[c + b] ?? 100;
2995
- const m = o[c];
2996
- c += g;
2997
- const w = document.createElement("div");
2998
- w.style.cssText = [
2999
- `width:${k}px;min-width:${k}px;flex-shrink:0;`,
3000
- "padding:4px 8px;box-sizing:border-box;overflow:hidden;",
3001
- "border-right:1px solid var(--og-border-color,#e0e0e0);",
3002
- "white-space:nowrap;text-overflow:ellipsis;"
3003
- ].join("");
3004
- const x = h.field, _ = x ? r.get(x) : null;
3005
- if (_) {
3006
- const b = _._formatted ?? String(_._value ?? ""), L = h.label ? `${h.label}: ` : "";
3007
- w.textContent = L + b, w.title = `${((u = h.op) == null ? void 0 : u.toUpperCase()) ?? ""} = ${b}`, w.style.color = "var(--og-primary,#1976d2)", w.style.textAlign = h.align ?? ((m == null ? void 0 : m.type) === "number", "right");
3008
- } else h.label && (w.textContent = h.label, w.style.textAlign = h.align ?? "left", w.style.color = "var(--og-row-color,#212121)");
3009
- l.appendChild(w);
3010
- }
3011
- s.footerPosition === "top" ? t.insertBefore(l, t.firstChild) : t.appendChild(l);
3012
- }
3013
- }
3014
- class qe {
3015
- constructor(t) {
3016
- this._d = t;
3017
- }
3018
- handleKeyDown(t) {
3019
- const e = this._d.getEditMgr();
3020
- if (e.activeEditor) return;
3021
- this._d.handleCellKeyEvt("cellKeyDown", t);
3022
- const s = this._d.getData(), i = this._d.getColLayout(), o = s.rowCount, n = i.visibleLeaves.length;
3023
- if (o === 0 || n === 0) return;
3024
- if ((t.ctrlKey || t.metaKey) && t.key === "c") {
3025
- t.preventDefault(), this._copyToClipboard();
3026
- return;
3027
- }
3028
- if ((t.ctrlKey || t.metaKey) && t.key === "v") {
3029
- t.preventDefault(), this._pasteFromClipboard();
3030
- return;
3031
- }
3032
- const r = this._d.getOptions();
3033
- if ((t.ctrlKey || t.metaKey) && r.draggable && e.focusCell) {
3034
- if (t.key === "ArrowDown") {
3035
- t.preventDefault();
3036
- const l = e.focusCell.ci !== void 0 ? e.focusCell.ri : 0;
3037
- l < o - 1 && (this._d.handleRowDrop(l, l + 1), this._d.setFocusCell(l + 1, e.focusCell.ci), this._d.announce(`행 ${l + 1}을(를) ${l + 2}번째 위치로 이동`));
3038
- return;
3039
- }
3040
- if (t.key === "ArrowUp") {
3041
- t.preventDefault();
3042
- const l = e.focusCell.ri;
3043
- l > 0 && (this._d.handleRowDrop(l, l - 1), this._d.setFocusCell(l - 1, e.focusCell.ci), this._d.announce(`행 ${l + 1}을(를) ${l}번째 위치로 이동`));
3044
- return;
3045
- }
3046
- }
3047
- switch (t.key) {
3048
- case "ArrowDown": {
3049
- t.preventDefault();
3050
- const l = e.focusCell, a = l ? Math.min(l.ri + 1, o - 1) : 0;
3051
- this._d.setFocusCell(a, (l == null ? void 0 : l.ci) ?? 0);
3052
- break;
3053
- }
3054
- case "ArrowUp": {
3055
- t.preventDefault();
3056
- const l = e.focusCell, a = l ? Math.max(l.ri - 1, 0) : 0;
3057
- this._d.setFocusCell(a, (l == null ? void 0 : l.ci) ?? 0);
3058
- break;
3059
- }
3060
- case "ArrowRight": {
3061
- t.preventDefault();
3062
- const l = e.focusCell;
3063
- if (!l) {
3064
- this._d.setFocusCell(0, 0);
3065
- break;
3066
- }
3067
- l.ci < n - 1 ? this._d.setFocusCell(l.ri, l.ci + 1) : l.ri < o - 1 && this._d.setFocusCell(l.ri + 1, 0);
3068
- break;
3069
- }
3070
- case "ArrowLeft": {
3071
- t.preventDefault();
3072
- const l = e.focusCell;
3073
- if (!l) {
3074
- this._d.setFocusCell(0, 0);
3075
- break;
3076
- }
3077
- l.ci > 0 ? this._d.setFocusCell(l.ri, l.ci - 1) : l.ri > 0 && this._d.setFocusCell(l.ri - 1, n - 1);
3078
- break;
3079
- }
3080
- case "Tab": {
3081
- t.preventDefault();
3082
- const l = e.focusCell;
3083
- if (!l) {
3084
- this._d.setFocusCell(0, 0);
3085
- break;
3086
- }
3087
- t.shiftKey ? l.ci > 0 ? this._d.setFocusCell(l.ri, l.ci - 1) : l.ri > 0 && this._d.setFocusCell(l.ri - 1, n - 1) : l.ci < n - 1 ? this._d.setFocusCell(l.ri, l.ci + 1) : l.ri < o - 1 && this._d.setFocusCell(l.ri + 1, 0);
3088
- break;
3089
- }
3090
- case "Home": {
3091
- if (t.preventDefault(), t.ctrlKey || t.metaKey)
3092
- this._d.setFocusCell(0, 0);
3093
- else {
3094
- const l = e.focusCell;
3095
- this._d.setFocusCell((l == null ? void 0 : l.ri) ?? 0, 0);
3096
- }
3097
- break;
3098
- }
3099
- case "End": {
3100
- if (t.preventDefault(), t.ctrlKey || t.metaKey)
3101
- this._d.setFocusCell(o - 1, n - 1);
3102
- else {
3103
- const l = e.focusCell;
3104
- this._d.setFocusCell((l == null ? void 0 : l.ri) ?? 0, n - 1);
3105
- }
3106
- break;
3107
- }
3108
- case "PageDown": {
3109
- t.preventDefault();
3110
- const l = e.focusCell, a = this._d.getOptions().pageSize ?? 10, c = Math.min(l ? l.ri + a : a - 1, o - 1);
3111
- this._d.setFocusCell(c, (l == null ? void 0 : l.ci) ?? 0);
3112
- break;
3113
- }
3114
- case "PageUp": {
3115
- t.preventDefault();
3116
- const l = e.focusCell, a = this._d.getOptions().pageSize ?? 10, c = l ? Math.max(l.ri - a, 0) : 0;
3117
- this._d.setFocusCell(c, (l == null ? void 0 : l.ci) ?? 0);
3118
- break;
3119
- }
3120
- case " ": {
3121
- if (e.focusCell) {
3122
- t.preventDefault();
3123
- const l = e.focusCell.ri, a = this._d.getRowMgr();
3124
- this._d.getOptions().checkColumn ? (a.check(l, !a.checkedRows.has(l)), this._d.doRender()) : (a.selectToggle(l), this._d.doRender());
3125
- }
3126
- break;
3127
- }
3128
- case "F2":
3129
- case "Enter": {
3130
- e.focusCell && this._d.getOptions().editable && (t.preventDefault(), e.startEditByKey(e.focusCell.ri, e.focusCell.ci));
3131
- break;
3132
- }
3133
- case "Escape": {
3134
- e.clearFocusCell(), this._d.doRender();
3135
- break;
3136
- }
3137
- }
3138
- }
3139
- _copyToClipboard() {
3140
- var n;
3141
- if (!this._d.getOptions().clipboard) return;
3142
- const e = this._d.getEditMgr(), s = this._d.getColLayout(), i = this._d.getData();
3143
- let o = "";
3144
- if (e.focusCell) {
3145
- const { ri: r, ci: l } = e.focusCell, a = s.visibleLeaves[l];
3146
- a && (o = String(i.getCellValue(r, a.field) ?? ""));
3147
- } else if (this._d.getRowMgr().selectedRows.size > 0) {
3148
- const r = s.visibleLeaves;
3149
- o = [...this._d.getRowMgr().selectedRows].sort((a, c) => a - c).map((a) => {
3150
- const c = i.getRowByIndex(a);
3151
- return r.map((u) => String((c == null ? void 0 : c[u.field]) ?? "")).join(" ");
3152
- }).join(`
3153
- `);
3154
- }
3155
- o && ((n = navigator.clipboard) == null || n.writeText(o).catch(() => {
3156
- }));
3157
- }
3158
- _pasteFromClipboard() {
3159
- var s;
3160
- const t = this._d.getOptions();
3161
- if (!t.clipboard || !t.editable) return;
3162
- const e = this._d.getEditMgr();
3163
- e.focusCell && ((s = navigator.clipboard) == null || s.readText().then((i) => {
3164
- if (!i) return;
3165
- const { ri: o, ci: n } = e.focusCell, r = i.split(`
3166
- `), l = this._d.getColLayout().visibleLeaves, a = this._d.getData();
3167
- for (let c = 0; c < r.length; c++) {
3168
- const u = r[c].split(" ");
3169
- for (let h = 0; h < u.length; h++) {
3170
- const g = o + c, k = n + h, m = l[k];
3171
- m && g < a.rowCount && a.updateCell(g, m.field, u[h]);
3172
- }
3173
- }
3174
- this._d.emit("dataChange", a.getData()), this._d.doRender();
3175
- }).catch(() => {
3176
- }));
3177
- }
3178
- }
3179
- class Xe {
3180
- constructor(t) {
3181
- this._bar = null, this._input = null, this._count = null, this._filter = "", this._d = t;
3182
- }
3183
- get findFilter() {
3184
- return this._filter;
3185
- }
3186
- init(t) {
3187
- const e = document.createElement("div");
3188
- e.className = "og-find-bar", e.hidden = !0;
3189
- const s = document.createElement("span");
3190
- s.className = "og-find-label", s.textContent = "찾기";
3191
- const i = document.createElement("input");
3192
- i.type = "text", i.className = "og-find-input", i.placeholder = "검색어 입력...", i.setAttribute("aria-label", "그리드 내 검색");
3193
- const o = document.createElement("span");
3194
- o.className = "og-find-count";
3195
- const n = document.createElement("button");
3196
- n.className = "og-find-close", n.textContent = "✕", n.setAttribute("aria-label", "찾기 닫기"), e.appendChild(s), e.appendChild(i), e.appendChild(o), e.appendChild(n), t.insertBefore(e, t.firstChild), i.addEventListener("input", () => {
3197
- this._filter = i.value.trim(), this._apply();
3198
- }), i.addEventListener("keydown", (r) => {
3199
- r.key === "Escape" && this.close();
3200
- }), n.addEventListener("click", () => this.close()), this._bar = e, this._input = i, this._count = o;
3201
- }
3202
- open() {
3203
- this._bar && (this._bar.hidden = !1, this._input.focus(), this._input.select());
3204
- }
3205
- close() {
3206
- this._bar && (this._bar.hidden = !0, this._filter = "", this._input.value = "", this._count && (this._count.textContent = ""), this._apply());
3207
- }
3208
- _apply() {
3209
- var i, o;
3210
- const t = this._d.getData(), e = this._d.getColLayout().visibleLeaves.map((n) => n.field);
3211
- t.setFindFilter(this._filter, e), t.applyFilter(this._d.getFilters());
3212
- const s = t.rowCount;
3213
- (i = this._d.getVs()) == null || i.setTotalRows(s), (o = this._d.getPagination()) == null || o.setTotalRows(s), this._count && (this._count.textContent = this._filter ? `${s}건` : ""), this._d.doRender();
3214
- }
3215
- }
3216
- function Yt(d) {
3217
- return d && d._isGroup === !0;
3218
- }
3219
- function Pt(d, t, e = [], s = /* @__PURE__ */ new Set(), i, o) {
3220
- return t.length ? Jt(d, t, 0, e, s, "", i, o) : [];
3221
- }
3222
- function Jt(d, t, e, s, i, o, n, r) {
3223
- const l = t[e], a = /* @__PURE__ */ new Map();
3224
- for (const u of d) {
3225
- const h = r ? r(u, t.slice(e)) : u[l];
3226
- a.has(h) || a.set(h, []), a.get(h).push(u);
3227
- }
3228
- const c = [];
3229
- for (const [u, h] of a) {
3230
- const g = `${o}__${l}:${u}`, k = i.has(g);
3231
- let m;
3232
- e < t.length - 1 ? m = Jt(h, t, e + 1, s, i, g, n, r) : m = h;
3233
- const { summary: w, summaryFmt: x } = Ye(h, s), _ = Je(h, n);
3234
- c.push({
3235
- _isGroup: !0,
3236
- _groupField: l,
3237
- _groupValue: u,
3238
- _groupLabel: u == null ? "(없음)" : String(u),
3239
- _depth: e,
3240
- _expanded: k,
3241
- _childCount: h.length,
3242
- _summary: w,
3243
- _summaryFmt: x,
3244
- _states: _,
3245
- children: m
3246
- });
3247
- }
3248
- return c;
3249
- }
3250
- function Ye(d, t) {
3251
- const e = {}, s = {};
3252
- for (const i of t) {
3253
- const o = d.map((a) => a[i.field]).filter((a) => a != null && a !== "");
3254
- let n = null;
3255
- const r = i.op.toUpperCase();
3256
- if (r === "SUM")
3257
- n = o.length > 0 ? M.sum(o.map(String)) : null;
3258
- else if (r === "AVG")
3259
- n = o.length > 0 ? M.sum(o.map(String)).div(M.from(String(o.length))) : null;
3260
- else if (r === "COUNT") {
3261
- e[i.field] = d.length, s[i.field] = d.length.toLocaleString("ko-KR");
3262
- continue;
3263
- } else r === "MAX" ? n = o.length > 0 ? M.max(o.map(String)) : null : r === "MIN" && (n = o.length > 0 ? M.min(o.map(String)) : null);
3264
- if (!n) {
3265
- e[i.field] = null, s[i.field] = "";
3266
- continue;
3267
- }
3268
- const l = n.toNumber();
3269
- e[i.field] = l, s[i.field] = Qe(l, i.format);
3270
- }
3271
- return { summary: e, summaryFmt: s };
3272
- }
3273
- function Je(d, t) {
3274
- if (!t) return { added: 0, edited: 0, removed: 0 };
3275
- let e = 0, s = 0, i = 0;
3276
- for (const o of d) {
3277
- const n = t(o);
3278
- n === "added" ? e++ : n === "edited" ? s++ : n === "removed" && i++;
3279
- }
3280
- return { added: e, edited: s, removed: i };
3281
- }
3282
- function Qe(d, t) {
3283
- if (t == null)
3284
- return d % 1 === 0 ? d.toLocaleString("ko-KR") : parseFloat(d.toFixed(6)).toLocaleString("ko-KR", {
3285
- minimumFractionDigits: 2,
3286
- maximumFractionDigits: 6
3287
- });
3288
- const e = t.includes("#") || t.includes(","), s = t.match(/\.(\d+)$/), i = s ? parseInt(s[1], 10) : /^\d+$/.test(t) ? parseInt(t, 10) : 0, o = Math.abs(d).toFixed(i), [n = "0", r] = o.split("."), l = e ? n.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : n, a = r !== void 0 ? `${l}.${r}` : l;
3289
- return d < 0 ? `-${a}` : a;
3290
- }
3291
- function Qt(d) {
3292
- const t = [];
3293
- for (const e of d)
3294
- if (t.push(e), e._expanded)
3295
- for (const s of e.children)
3296
- Yt(s) ? t.push(...Qt([s])) : t.push(s);
3297
- return t;
3298
- }
3299
- function Zt(d, t = "") {
3300
- const e = [];
3301
- for (const s of d) {
3302
- const i = `${t}__${s._groupField}:${s._groupValue}`;
3303
- e.push(i);
3304
- const o = s.children.filter((n) => Yt(n));
3305
- o.length && e.push(...Zt(o, i));
3306
- }
3307
- return e;
3308
- }
3309
- function Vt(d, t, e = /* @__PURE__ */ new Set()) {
3310
- const { idField: s, parentIdField: i, expandOnLoad: o = !1 } = t, n = /* @__PURE__ */ new Map(), r = [];
3311
- for (const c of d) {
3312
- const u = c[s], h = {
3313
- _isTree: !0,
3314
- _treeId: u,
3315
- _treeParentId: c[i],
3316
- _depth: 0,
3317
- _expanded: o || e.has(u),
3318
- _hasChildren: !1,
3319
- _childCount: 0,
3320
- _isLastChild: !1,
3321
- _ancestorHasMore: [],
3322
- data: c,
3323
- children: []
3324
- };
3325
- n.set(u, h);
3326
- }
3327
- for (const c of n.values()) {
3328
- const u = c._treeParentId;
3329
- if (u == null || u === "" || !n.has(u))
3330
- r.push(c);
3331
- else {
3332
- const g = n.get(u);
3333
- g.children.push(c), g._hasChildren = !0;
3334
- }
3335
- }
3336
- function l(c, u) {
3337
- for (const h of c)
3338
- h._depth = u, h._childCount = te(h), l(h.children, u + 1);
3339
- }
3340
- l(r, 0);
3341
- function a(c, u) {
3342
- for (let h = 0; h < c.length; h++) {
3343
- const g = c[h], k = h === c.length - 1;
3344
- g._isLastChild = k, g._ancestorHasMore = u, g.children.length > 0 && a(g.children, [...u, !k]);
3345
- }
3346
- }
3347
- return a(r, []), r;
3348
- }
3349
- function te(d) {
3350
- let t = d.children.length;
3351
- for (const e of d.children) t += te(e);
3352
- return t;
3353
- }
3354
- function ee(d) {
3355
- const t = [];
3356
- for (const e of d)
3357
- t.push(e), e._expanded && e.children.length > 0 && t.push(...ee(e.children));
3358
- return t;
3359
- }
3360
- function Ze(d, t) {
3361
- d.has(t) ? d.delete(t) : d.add(t);
3362
- }
3363
- function Rt(d) {
3364
- const t = [];
3365
- for (const e of d)
3366
- t.push(e._treeId), e.children.length && t.push(...Rt(e.children));
3367
- return t;
3368
- }
3369
- class ts {
3370
- constructor(t) {
3371
- this._groupFields = [], this._groupExpandedKeys = /* @__PURE__ */ new Set(), this._groupFlatRows = [], this._isGroupMode = !1, this._treeRoots = [], this._treeFlatRows = [], this._treeExpandedKeys = /* @__PURE__ */ new Set(), this._isTreeMode = !1, this._d = t;
3372
- }
3373
- // ─── 상태 접근자 ─────────────────────────────────────────
3374
- get isGroupMode() {
3375
- return this._isGroupMode;
3376
- }
3377
- get isTreeMode() {
3378
- return this._isTreeMode;
3379
- }
3380
- get groupFlatRows() {
3381
- return this._groupFlatRows;
3382
- }
3383
- get treeFlatRows() {
3384
- return this._treeFlatRows;
3385
- }
3386
- // ─── 그룹 ─────────────────────────────────────────────────
3387
- groupBy(t) {
3388
- this._groupFields = t, this._groupExpandedKeys.clear(), this._isGroupMode = t.length > 0, this.rebuildGroups();
3389
- }
3390
- clearGroup() {
3391
- var e;
3392
- this._groupFields = [], this._groupExpandedKeys.clear(), this._isGroupMode = !1, this._groupFlatRows = [];
3393
- const t = this._d.getData().length;
3394
- (e = this._d.getVs()) == null || e.setTotalRows(t), this._d.doRender();
3395
- }
3396
- expandAll() {
3397
- if (!this._isGroupMode) return;
3398
- const t = Pt(this._d.getData(), this._groupFields, this._getSummaryDefs(), void 0, void 0, this._groupKeyFn());
3399
- Zt(t).forEach((e) => this._groupExpandedKeys.add(e)), this.rebuildGroups();
3400
- }
3401
- /** Phase 2 슬롯 #5: groupKeyFn resolver. default = undefined(→ GroupEngine 가 row[field] 사용). */
3402
- _groupKeyFn() {
3403
- return this._d.getStrategy ? this._d.getStrategy("groupKeyFn", void 0) : void 0;
3404
- }
3405
- collapseAll() {
3406
- this._groupExpandedKeys.clear(), this._isGroupMode && this.rebuildGroups();
3407
- }
3408
- handleGroupToggle(t) {
3409
- this._groupExpandedKeys.has(t) ? this._groupExpandedKeys.delete(t) : this._groupExpandedKeys.add(t), this.rebuildGroups();
3410
- }
3411
- rebuildGroups() {
3412
- var o;
3413
- const t = this._d.getData(), e = this._d.getDataLayer(), s = (n) => {
3414
- const r = t.indexOf(n);
3415
- return r >= 0 ? e.getRowState(r) : "none";
3416
- }, i = Pt(t, this._groupFields, this._getSummaryDefs(), this._groupExpandedKeys, s, this._groupKeyFn());
3417
- this._groupFlatRows = Qt(i), (o = this._d.getVs()) == null || o.setTotalRows(this._groupFlatRows.length), this._d.doRenderFull(this._groupFlatRows.length);
3418
- }
3419
- // ─── 트리 ─────────────────────────────────────────────────
3420
- enableTree() {
3421
- this._isTreeMode = !0, this._isGroupMode = !1;
3422
- const t = this._d.getOptions();
3423
- if (t.expandOnLoad) {
3424
- const e = Vt(this._d.getData(), {
3425
- idField: t.treeId,
3426
- parentIdField: t.treeParentId
3427
- });
3428
- Rt(e).forEach((s) => this._treeExpandedKeys.add(s));
3429
- }
3430
- this.rebuildTree();
3431
- }
3432
- disableTree() {
3433
- var e;
3434
- this._isTreeMode = !1, this._treeRoots = [], this._treeFlatRows = [], this._treeExpandedKeys.clear();
3435
- const t = this._d.getData().length;
3436
- (e = this._d.getVs()) == null || e.setTotalRows(t), this._d.doRender();
3437
- }
3438
- expandNodes(t, e = !0) {
3439
- const s = Array.isArray(t) ? t : [t];
3440
- for (const i of s)
3441
- e ? this._treeExpandedKeys.add(i) : this._treeExpandedKeys.delete(i);
3442
- this._isTreeMode && this.rebuildTree();
3443
- }
3444
- expandAllNodes() {
3445
- this._isTreeMode && (Rt(this._treeRoots).forEach((t) => this._treeExpandedKeys.add(t)), this.rebuildTree());
3446
- }
3447
- collapseAllNodes() {
3448
- this._isTreeMode && (this._treeExpandedKeys.clear(), this.rebuildTree());
3449
- }
3450
- handleTreeToggle(t) {
3451
- Ze(this._treeExpandedKeys, t), this.rebuildTree();
3452
- }
3453
- rebuildTree() {
3454
- var e;
3455
- const t = this._d.getOptions();
3456
- this._treeRoots = Vt(this._d.getData(), {
3457
- idField: t.treeId,
3458
- parentIdField: t.treeParentId,
3459
- expandOnLoad: t.expandOnLoad
3460
- }, this._treeExpandedKeys), this._treeFlatRows = ee(this._treeRoots), (e = this._d.getVs()) == null || e.setTotalRows(this._treeFlatRows.length), this._d.doRenderFull(this._treeFlatRows.length);
3461
- }
3462
- // ─── 내부 헬퍼 ───────────────────────────────────────────
3463
- _getSummaryDefs() {
3464
- const t = this._d.getOptions().summary;
3465
- if (!t) return [];
3466
- if (t.rows && t.rows.length > 0)
3467
- return t.fields.flatMap(
3468
- (s) => t.rows.map((i) => ({ field: s, op: i.op, format: i.format }))
3469
- );
3470
- const e = Array.isArray(t.ops) ? t.ops : t.ops ? [t.ops] : ["SUM"];
3471
- return t.fields.map((s) => ({ field: s, op: e[0] ?? "SUM", format: t.format }));
3472
- }
3473
- }
3474
- class es {
3475
- constructor(t) {
3476
- this._sortList = [], this._filters = {}, this._d = t;
3477
- }
3478
- // ─── 상태 접근자 ─────────────────────────────────────────
3479
- get sortList() {
3480
- return this._sortList;
3481
- }
3482
- get filters() {
3483
- return this._filters;
3484
- }
3485
- // ─── 정렬 ─────────────────────────────────────────────────
3486
- handleSortClick(t, e) {
3487
- var r;
3488
- const s = this._d.getOptions();
3489
- if (!s.sortable) return;
3490
- const i = this._sortList.findIndex((l) => l.field === t);
3491
- if (i >= 0) {
3492
- const l = this._sortList[i];
3493
- l.dir === "asc" ? l.dir = "desc" : this._sortList.splice(i, 1);
3494
- } else
3495
- (!e || !s.multiSort) && (this._sortList = []), this._sortList.push({ field: t, dir: "asc" });
3496
- this._d.getData().applySort(this._sortList), this._d.renderHeader(), this._d.doRender();
3497
- const o = this._sortList.find((l) => l.field === t), n = o ? o.dir === "asc" ? "오름차순" : "내림차순" : "정렬 해제";
3498
- this._d.announce(`${t} ${n} 정렬`), this._d.emit("sortChange", { sortList: this._sortList }), (r = s.onSortChange) == null || r.call(s, { field: t, dir: (o == null ? void 0 : o.dir) ?? "asc", sortList: this._sortList });
3499
- }
3500
- sort(t, e = "asc") {
3501
- if (Array.isArray(t))
3502
- this._sortList = t;
3503
- else {
3504
- const s = this._sortList.findIndex((i) => i.field === t);
3505
- s >= 0 ? this._sortList[s].dir = e : this._sortList = [{ field: t, dir: e }], this._d.getOptions().multiSort || (this._sortList = this._sortList.slice(-1));
3506
- }
3507
- this._d.getData().applySort(this._sortList), this._d.renderHeader(), this._d.doRender(), this._d.emit("sortChange", { sortList: this._sortList });
3508
- }
3509
- resetSort() {
3510
- this._sortList = [], this._d.getData().applySort([]), this._d.renderHeader(), this._d.doRender();
3511
- }
3512
- initSort(t) {
3513
- this._sortList = [...t], this._d.getData().applySort(this._sortList);
3514
- }
3515
- getSortState() {
3516
- return [...this._sortList];
3517
- }
3518
- // ─── 필터 ─────────────────────────────────────────────────
3519
- setFilter(t, e) {
3520
- var s, i;
3521
- this._filters[t] = e, this.applyFilters(), this._d.renderHeader(), this._d.doRender(), this._d.emit("filterChange", { field: t, filterItems: e, allFilters: this._filters }), (i = (s = this._d.getOptions()).onFilterChange) == null || i.call(s, { field: t, filterItems: e, allFilters: this._filters });
3522
- }
3523
- resetFilter(t) {
3524
- t ? delete this._filters[t] : this._filters = {}, this.applyFilters(), this._d.renderHeader(), this._d.doRender();
3525
- }
3526
- getFilterState() {
3527
- return { ...this._filters };
3528
- }
3529
- restoreFilter(t) {
3530
- this._filters = { ...t }, this.applyFilters();
3531
- }
3532
- applyFilters() {
3533
- var s, i;
3534
- const t = this._d.getData();
3535
- t.setFindFilter(this._d.getFindFilter(), this._d.getColLayout().visibleLeaves.map((o) => o.field)), t.applyFilter(this._filters);
3536
- const e = t.rowCount;
3537
- (s = this._d.getVs()) == null || s.setTotalRows(e), (i = this._d.getPagination()) == null || i.setTotalRows(e);
3538
- }
3539
- }
3540
- class ss {
3541
- constructor(t) {
3542
- this._d = t;
3543
- }
3544
- handleCellClick(t, e, s) {
3545
- var a, c, u, h, g, k, m;
3546
- const i = this._d.getOptions(), o = this._d.getRowMgr(), n = this._d.getEditMgr();
3547
- i.selection === "single" || i.selection === "row" ? o.selectSingle(t) : i.selection === "multiple" && (s.ctrlKey || s.metaKey ? o.selectToggle(t) : o.selectSingle(t));
3548
- const r = this._d.getData().getRowByIndex(t), l = this._d.getColLayout().visibleLeaves[e];
3549
- if (r && l) {
3550
- const w = l.editable !== !1 && (l.editable !== void 0 || i.editable);
3551
- if (nt(l) && w) {
3552
- const R = r[l.field];
3553
- this._d.writeCell(t, l.field, !R);
3554
- }
3555
- if (l.type === "radio") {
3556
- const R = l.group;
3557
- for (const F of this._d.getColLayout().visibleLeaves)
3558
- F.type === "radio" && F.field !== l.field && (!R || F.group === R) && this._d.getData().updateCell(t, F.field, !1);
3559
- this._d.writeCell(t, l.field, !0);
3560
- }
3561
- let x = r[l.field];
3562
- if (x === void 0 && l.formula)
3563
- try {
3564
- const R = l.formulaPrecision ?? 30, F = Gt(l.formula, r, R);
3565
- x = F instanceof M ? l.precision != null ? F.toFixed(l.precision) : F.toString() : String(F);
3566
- } catch {
3567
- }
3568
- const _ = {
3569
- type: "cellClick",
3570
- rowIndex: t,
3571
- columnIndex: e,
3572
- field: l.field,
3573
- value: x,
3574
- row: r,
3575
- column: l,
3576
- target: s.target,
3577
- originalEvent: s
3578
- };
3579
- this._d.emit("cellClick", _), (a = i.onCellClick) == null || a.call(i, _);
3580
- const b = { type: "rowClick", rowIndex: t, row: r, target: s.target, originalEvent: s };
3581
- this._d.emit("rowClick", b), (c = i.onRowClick) == null || c.call(i, b);
3582
- const L = l.type === "select";
3583
- !(n.activeEditor != null && ((u = n.editCell) == null ? void 0 : u.ri) === t && ((h = n.editCell) == null ? void 0 : h.ci) === e) && (i.editMode === "click" || L) && !nt(l) && n.startEdit(t, e, s);
3584
- }
3585
- n.activeEditor && ((g = n.editCell) == null ? void 0 : g.ri) === t && ((k = n.editCell) == null ? void 0 : k.ci) === e || (this._d.doRender(), this._d.emit("selectionChange", {
3586
- rows: o.getSelections(),
3587
- rowIndexes: [...o.selectedRows]
3588
- }), (m = i.onSelectionChange) == null || m.call(i, { rows: o.getSelections(), rowIndexes: [...o.selectedRows], cells: [] }));
3589
- }
3590
- handleCellDblClick(t, e, s) {
3591
- var a, c;
3592
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3593
- if (!i || !o) return;
3594
- const n = this._d.getOptions(), r = {
3595
- type: "cellDblClick",
3596
- rowIndex: t,
3597
- columnIndex: e,
3598
- field: o.field,
3599
- value: i[o.field],
3600
- row: i,
3601
- column: o,
3602
- target: s.target,
3603
- originalEvent: s
3604
- };
3605
- this._d.emit("cellDblClick", r), (a = n.onCellDblClick) == null || a.call(n, r);
3606
- const l = { type: "rowDblClick", rowIndex: t, row: i, target: s.target, originalEvent: s };
3607
- this._d.emit("rowDblClick", l), (c = n.onRowDblClick) == null || c.call(n, l), n.editMode === "dblclick" && this._d.getEditMgr().startEdit(t, e, s);
3608
- }
3609
- handleCellMouseOver(t, e, s) {
3610
- var a, c;
3611
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3612
- if (!i || !o) return;
3613
- const n = this._d.getOptions(), r = { type: "cellMouseOver", rowIndex: t, columnIndex: e, field: o.field, value: i[o.field], row: i, column: o, target: s.target, originalEvent: s };
3614
- this._d.emit("cellMouseOver", r), (a = n.onCellMouseOver) == null || a.call(n, r);
3615
- const l = { type: "rowMouseOver", rowIndex: t, row: i, target: s.target, originalEvent: s };
3616
- this._d.emit("rowMouseOver", l), (c = n.onRowMouseOver) == null || c.call(n, l);
3617
- }
3618
- handleCellMouseOut(t, e, s) {
3619
- var a, c;
3620
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3621
- if (!i || !o) return;
3622
- const n = this._d.getOptions(), r = { type: "cellMouseOut", rowIndex: t, columnIndex: e, field: o.field, value: i[o.field], row: i, column: o, target: s.target, originalEvent: s };
3623
- this._d.emit("cellMouseOut", r), (a = n.onCellMouseOut) == null || a.call(n, r);
3624
- const l = { type: "rowMouseOut", rowIndex: t, row: i, target: s.target, originalEvent: s };
3625
- this._d.emit("rowMouseOut", l), (c = n.onRowMouseOut) == null || c.call(n, l);
3626
- }
3627
- handleCellMouseDown(t, e, s) {
3628
- var a, c;
3629
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3630
- if (!i || !o) return;
3631
- const n = this._d.getOptions(), r = { type: "cellMouseDown", rowIndex: t, columnIndex: e, field: o.field, value: i[o.field], row: i, column: o, target: s.target, originalEvent: s };
3632
- this._d.emit("cellMouseDown", r), (a = n.onCellMouseDown) == null || a.call(n, r);
3633
- const l = { type: "rowMouseDown", rowIndex: t, row: i, target: s.target, originalEvent: s };
3634
- this._d.emit("rowMouseDown", l), (c = n.onRowMouseDown) == null || c.call(n, l);
3635
- }
3636
- handleCellMouseUp(t, e, s) {
3637
- var a, c;
3638
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3639
- if (!i || !o) return;
3640
- const n = this._d.getOptions(), r = { type: "cellMouseUp", rowIndex: t, columnIndex: e, field: o.field, value: i[o.field], row: i, column: o, target: s.target, originalEvent: s };
3641
- this._d.emit("cellMouseUp", r), (a = n.onCellMouseUp) == null || a.call(n, r);
3642
- const l = { type: "rowMouseUp", rowIndex: t, row: i, target: s.target, originalEvent: s };
3643
- this._d.emit("rowMouseUp", l), (c = n.onRowMouseUp) == null || c.call(n, l);
3644
- }
3645
- handleCellMouseMove(t, e, s) {
3646
- var a, c;
3647
- const i = this._d.getData().getRowByIndex(t), o = this._d.getColLayout().visibleLeaves[e];
3648
- if (!i || !o) return;
3649
- const n = this._d.getOptions(), r = { type: "cellMouseMove", rowIndex: t, columnIndex: e, field: o.field, value: i[o.field], row: i, column: o, target: s.target, originalEvent: s };
3650
- this._d.emit("cellMouseMove", r), (a = n.onCellMouseMove) == null || a.call(n, r);
3651
- const l = { type: "rowMouseMove", rowIndex: t, row: i, target: s.target, originalEvent: s };
3652
- this._d.emit("rowMouseMove", l), (c = n.onRowMouseMove) == null || c.call(n, l);
3653
- }
3654
- handleCellKeyEvt(t, e) {
3655
- var c, u, h;
3656
- const s = this._d.getEditMgr();
3657
- if (!s.focusCell || s.activeEditor) return;
3658
- const { ri: i, ci: o } = s.focusCell, n = this._d.getData().getRowByIndex(i), r = this._d.getColLayout().visibleLeaves[o];
3659
- if (!n || !r) return;
3660
- const l = this._d.getOptions(), a = { type: t, rowIndex: i, columnIndex: o, field: r.field, value: n[r.field], row: n, column: r, key: e.key, target: this._d.getContainer(), originalEvent: e };
3661
- this._d.emit(t, a), t === "cellKeyDown" ? (c = l.onCellKeyDown) == null || c.call(l, a) : t === "cellKeyUp" ? (u = l.onCellKeyUp) == null || u.call(l, a) : (h = l.onCellKeyPress) == null || h.call(l, a);
3662
- }
3663
- }
3664
- class is {
3665
- constructor() {
3666
- this._triggers = /* @__PURE__ */ new Map();
3667
- }
3668
- add(t, e) {
3669
- this._triggers.has(t) || this._triggers.set(t, []), this._triggers.get(t).push(e);
3670
- }
3671
- remove(t, e) {
3672
- const s = this._triggers.get(t);
3673
- if (s) {
3674
- const i = s.indexOf(e);
3675
- i >= 0 && s.splice(i, 1);
3676
- }
3677
- }
3678
- clear(t) {
3679
- t ? this._triggers.delete(t) : this._triggers.clear();
3680
- }
3681
- mkCtx(t, e) {
3682
- let s = !1;
3683
- return {
3684
- operation: t,
3685
- args: e,
3686
- result: void 0,
3687
- extra: {},
3688
- timestamp: Date.now(),
3689
- get cancelled() {
3690
- return s;
3691
- },
3692
- cancel() {
3693
- s = !0;
3694
- }
3695
- };
3696
- }
3697
- exec(t, e) {
3698
- const s = this._triggers.get(t) ?? [];
3699
- for (const i of s)
3700
- if (i(e), e.cancelled) return !1;
3701
- if (t.startsWith("after:")) {
3702
- const i = this._triggers.get("complete") ?? [];
3703
- for (const o of i) o(e);
3704
- }
3705
- return !0;
3706
- }
3707
- }
3708
- const ht = "";
3709
- function se(d) {
3710
- const t = Object.entries(d).filter(([, e]) => e !== ht).map(([e, s]) => ` ${JSON.stringify(e)}: src[${JSON.stringify(s)}],`);
3711
- return `// crossGridMapping 옵션에 이 함수를 그대로 지정하세요.
3712
- function mapRow(src) {
3713
- return {
3714
- ` + t.join(`
3715
- `) + (t.length ? `
3716
- ` : "") + ` };
3717
- }`;
3718
- }
3719
- function os(d) {
3720
- return (t) => {
3721
- const e = {};
3722
- for (const [s, i] of Object.entries(d))
3723
- i !== ht && (e[s] = t[i]);
3724
- return e;
3725
- };
3726
- }
3727
- function ns(d, t) {
3728
- if (d.length !== t.length) return !1;
3729
- const e = new Set(t);
3730
- return d.every((s) => e.has(s));
3731
- }
3732
- function rs(d, t) {
3733
- return new Promise((e) => {
3734
- const s = new Set(d.map((R) => R.field)), i = {};
3735
- for (const R of t) i[R.field] = s.has(R.field) ? R.field : ht;
3736
- const o = document.createElement("div");
3737
- o.className = "og-mapper-overlay", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.setAttribute("aria-label", "그리드 필드 매핑"), o.style.cssText = "position:fixed;inset:0;z-index:100000;background:rgba(0,0,0,0.45);display:flex;align-items:center;justify-content:center;font-family:var(--og-font-family,-apple-system,sans-serif);";
3738
- const n = document.createElement("div");
3739
- n.style.cssText = "background:#fff;border-radius:10px;box-shadow:0 12px 40px rgba(0,0,0,0.3);width:min(620px,92vw);max-height:88vh;overflow:auto;color:#222;", o.appendChild(n);
3740
- const r = document.createElement("div");
3741
- r.style.cssText = "padding:18px 20px 8px;", r.innerHTML = '<div style="font-size:16px;font-weight:700;">필드 매핑</div><div style="font-size:12.5px;color:#666;margin-top:4px;line-height:1.5;">두 그리드의 필드 구조가 다릅니다. <b>타깃 필드</b>마다 어떤 <b>소스 필드</b>의 값을 가져올지 지정하세요. 아래 스크립트를 복사해 <code>crossGridMapping</code> 에 baking 하면 다음부터는 이 창 없이 자동 변환됩니다.</div>', n.appendChild(r);
3742
- const l = document.createElement("div");
3743
- l.style.cssText = "padding:6px 20px;";
3744
- const a = '<option value="">(비움)</option>' + d.map(
3745
- (R) => `<option value="${it(R.field)}">${it(R.header)} &lt;${it(R.field)}&gt;</option>`
3746
- ).join("");
3747
- for (const R of t) {
3748
- const F = document.createElement("div");
3749
- F.style.cssText = "display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid #f0f0f0;";
3750
- const I = document.createElement("div");
3751
- I.style.cssText = "flex:1;font-size:13px;min-width:0;", I.innerHTML = `<span style="font-weight:600;">${it(R.header)}</span><span style="color:#999;font-size:11.5px;"> &lt;${it(R.field)}&gt;</span>`;
3752
- const T = document.createElement("span");
3753
- T.textContent = "←", T.style.cssText = "color:#888;flex-shrink:0;";
3754
- const A = document.createElement("select");
3755
- A.style.cssText = "flex:1;min-width:0;padding:6px 8px;border:1px solid #ccc;border-radius:6px;font-size:13px;background:#fff;", A.innerHTML = a, A.value = i[R.field] ?? ht, A.addEventListener("change", () => {
3756
- i[R.field] = A.value, m();
3757
- }), F.append(I, T, A), l.appendChild(F);
3758
- }
3759
- n.appendChild(l);
3760
- const c = document.createElement("div");
3761
- c.style.cssText = "padding:10px 20px 4px;";
3762
- const u = document.createElement("div");
3763
- u.style.cssText = "display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;", u.innerHTML = '<span style="font-size:12.5px;font-weight:600;color:#444;">생성된 변환 스크립트</span>';
3764
- const h = document.createElement("button");
3765
- h.type = "button", h.textContent = "복사", h.style.cssText = "font-size:12px;padding:4px 10px;border:1px solid #ccc;border-radius:6px;background:#f7f7f7;cursor:pointer;", u.appendChild(h);
3766
- const g = document.createElement("pre");
3767
- g.style.cssText = "margin:0;background:#0d1117;color:#c9d1d9;padding:12px;border-radius:8px;font-family:ui-monospace,Consolas,monospace;font-size:12px;line-height:1.5;overflow:auto;max-height:180px;", c.append(u, g), n.appendChild(c);
3768
- function k() {
3769
- return se(i);
3770
- }
3771
- function m() {
3772
- g.textContent = k();
3773
- }
3774
- m(), h.addEventListener("click", () => {
3775
- var F;
3776
- const R = k();
3777
- (F = navigator.clipboard) == null || F.writeText(R).then(
3778
- () => {
3779
- h.textContent = "복사됨!", setTimeout(() => h.textContent = "복사", 1200);
3780
- },
3781
- () => {
3782
- h.textContent = "복사 실패", setTimeout(() => h.textContent = "복사", 1200);
3783
- }
3784
- );
3785
- });
3786
- const w = document.createElement("div");
3787
- w.style.cssText = "display:flex;justify-content:flex-end;gap:8px;padding:14px 20px 18px;";
3788
- const x = document.createElement("button");
3789
- x.type = "button", x.textContent = "취소", x.style.cssText = "font-size:13px;padding:8px 16px;border:1px solid #ccc;border-radius:7px;background:#fff;cursor:pointer;";
3790
- const _ = document.createElement("button");
3791
- _.type = "button", _.textContent = "적용 후 이동", _.style.cssText = "font-size:13px;padding:8px 16px;border:0;border-radius:7px;background:#1976d2;color:#fff;cursor:pointer;font-weight:600;", w.append(x, _), n.appendChild(w);
3792
- let b = !1;
3793
- function L(R) {
3794
- b || (b = !0, document.removeEventListener("keydown", v), o.remove(), e(R));
3795
- }
3796
- function v(R) {
3797
- R.key === "Escape" && L(null);
3798
- }
3799
- x.addEventListener("click", () => L(null)), o.addEventListener("mousedown", (R) => {
3800
- R.target === o && L(null);
3801
- }), _.addEventListener("click", () => L({ mapping: { ...i }, script: k() })), document.addEventListener("keydown", v), document.body.appendChild(o), _.focus();
3802
- });
3803
- }
3804
- function it(d) {
3805
- return String(d).replace(/[&<>"]/g, (t) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[t]);
3806
- }
3807
- class ls {
3808
- constructor() {
3809
- this._map = /* @__PURE__ */ new Map();
3810
- }
3811
- register(t, e) {
3812
- this._map.set(t, e);
3813
- }
3814
- unregister(t) {
3815
- this._map.delete(t);
3816
- }
3817
- get(t) {
3818
- return this._map.get(t);
3819
- }
3820
- get size() {
3821
- return this._map.size;
3822
- }
3823
- /** 커서 좌표 아래의 다른(crossGrid 허용) 그리드 반환. 없으면 null */
3824
- resolveAt(t, e, s) {
3825
- const i = document.elementFromPoint(t, e), o = i == null ? void 0 : i.closest(".og-body-wrapper");
3826
- if (!o) return null;
3827
- const n = this._map.get(o);
3828
- return !n || n === s ? null : n;
3829
- }
3830
- }
3831
- const ct = new ls();
3832
- class as {
3833
- constructor(t, e) {
3834
- this._originals = /* @__PURE__ */ new Map(), this._hadOwn = /* @__PURE__ */ new Map(), this._stack = /* @__PURE__ */ new Map(), this._strategies = /* @__PURE__ */ new Map(), this._callPath = [], this._host = t, this._strict = (e == null ? void 0 : e.strict) ?? !0, this._maxDepth = (e == null ? void 0 : e.maxDepth) ?? 32;
3835
- }
3836
- /**
3837
- * 메서드 override 등록.
3838
- * 1. 최초 1회 원본을 this-bound 로 보존.
3839
- * 2. 레이어 push (FIFO 등록순).
3840
- * 3. reduce 좌측폴드로 합성(나중 등록 = 최외곽).
3841
- * 4. 재진입 가드 + 에러 격리로 감싼 dispatcher 를 host[name] 인스턴스 프로퍼티에 할당.
3842
- */
3843
- override(t, e, s = {}) {
3844
- if (typeof e != "function")
3845
- throw new TypeError(`OverrideKernel.override: fn for "${t}" must be a function`);
3846
- if (!this._originals.has(t)) {
3847
- const o = this._host[t];
3848
- if (typeof o != "function")
3849
- throw new TypeError(`OverrideKernel.override: host["${t}"] is not a function`);
3850
- this._hadOwn.set(t, Object.prototype.hasOwnProperty.call(this._host, t)), this._originals.set(t, o.bind(this._host));
3851
- }
3852
- const i = this._stack.get(t) ?? [];
3853
- return i.push({ fn: e, opts: s }), this._stack.set(t, i), this._host[t] = this._buildDispatcher(t), this._host;
3854
- }
3855
- /** 합성된 dispatcher 생성. override/restore 시점마다 재구성. */
3856
- _buildDispatcher(t) {
3857
- var a;
3858
- const e = this._originals.get(t), s = this._stack.get(t) ?? [], i = s.reduce(
3859
- (c, u) => (...h) => u.fn(c, ...h),
3860
- e
3861
- ), o = ((a = s[s.length - 1]) == null ? void 0 : a.opts) ?? {}, n = o.reentrant === !0, r = o.onError === "fallback", l = this;
3862
- return function(...c) {
3863
- if (!n && l._callPath.indexOf(t) !== -1)
3864
- return e(...c);
3865
- if (l._callPath.length >= l._maxDepth) {
3866
- if (l._strict && !r)
3867
- throw new Error(
3868
- `OverrideKernel: max override depth (${l._maxDepth}) exceeded at "${t}"`
3869
- );
3870
- return e(...c);
3871
- }
3872
- l._callPath.push(t);
3873
- try {
3874
- return i(...c);
3875
- } catch (u) {
3876
- if (r && !l._strict)
3877
- return console.warn(`[og.override:${t}]`, u), e(...c);
3878
- if (r && l._strict)
3879
- return console.warn(`[og.override:${t}]`, u), e(...c);
3880
- throw u;
3881
- } finally {
3882
- l._callPath.pop();
3883
- }
3884
- };
3885
- }
3886
- /** strategy 슬롯 등록 (Phase 2 매니저 배선용 API). */
3887
- strategy(t, e) {
3888
- if (typeof e != "function")
3889
- throw new TypeError(`OverrideKernel.strategy: fn for "${t}" must be a function`);
3890
- return this._strategies.set(t, e), this._host;
3891
- }
3892
- /** strategy 슬롯 조회 — 미등록 시 fallback 반환 (매니저 read API). */
3893
- getStrategy(t, e) {
3894
- return this._strategies.get(t) ?? e;
3895
- }
3896
- /** 슬롯 등록 여부. */
3897
- hasStrategy(t) {
3898
- return this._strategies.has(t);
3899
- }
3900
- /** 단일 메서드 원본 복구. 없으면 no-op. */
3901
- restore(t) {
3902
- return this._originals.has(t) ? (this._hadOwn.get(t) ? this._host[t] = this._originals.get(t) : delete this._host[t], this._originals.delete(t), this._hadOwn.delete(t), this._stack.delete(t), this._host) : this._host;
3903
- }
3904
- /** 전체 복구 + strategy clear. destroy 시 호출. */
3905
- restoreAll() {
3906
- for (const t of [...this._originals.keys()]) this.restore(t);
3907
- return this._strategies.clear(), this._callPath = [], this._host;
3908
- }
3909
- /** override 등록 여부. */
3910
- hasOverride(t) {
3911
- return this._originals.has(t);
3912
- }
3913
- /** override 등록된 메서드 이름 목록. */
3914
- getOverrideNames() {
3915
- return [...this._originals.keys()];
3916
- }
3917
- }
3918
- const jt = "_ogRowId", V = class V extends oe {
3919
- constructor(t, e) {
3920
- var o;
3921
- super(), this._vs = null, this._ro = null, this._renderer = null, this._trigMgr = new is(), this._destroyed = !1, this._autoHeightWarned = !1, this._colWidths = [], this._userWidths = /* @__PURE__ */ new Map(), this._filterPanel = null, this._filterSelect = null, this._pagination = null, this._dnd = null, this._mergeEngine = new Z(), this._liveRegion = null, this._ctxMenu = null, this._cmHandler = null, this._cmKbdHandler = null, this._wsManager = null;
3922
- const s = typeof t == "string" ? document.querySelector(t) : t;
3923
- if (!s) throw new Error(`OpenGrid: container not found: ${t}`);
3924
- this._container = s, this._options = {
3925
- height: "100%",
3926
- width: "100%",
3927
- rowHeight: 32,
3928
- headerHeight: 34,
3929
- footerHeight: 30,
3930
- autoHeight: !1,
3931
- fillWidth: !1,
3932
- defaultColumnWidth: 100,
3933
- editable: !1,
3934
- editMode: "dblclick",
3935
- history: !0,
3936
- historySize: 100,
3937
- selection: "single",
3938
- clipboard: !0,
3939
- sortable: !0,
3940
- multiSort: !0,
3941
- filterable: !0,
3942
- defaultSort: [],
3943
- frozenColumns: 0,
3944
- frozenRows: 0,
3945
- rowNumber: !1,
3946
- stateColumn: !1,
3947
- checkColumn: !1,
3948
- draggable: !1,
3949
- crossGrid: !1,
3950
- crossGridMapping: "auto",
3951
- mergeCells: !1,
3952
- groupBy: [],
3953
- summary: void 0,
3954
- treeMode: "auto",
3955
- treeId: "id",
3956
- treeParentId: "parentId",
3957
- expandOnLoad: !1,
3958
- pagination: !1,
3959
- pageSize: 50,
3960
- footer: void 0,
3961
- footerPosition: "bottom",
3962
- theme: "default",
3963
- cssVars: {},
3964
- ariaLabel: "OPEN_GRID 데이터 그리드",
3965
- ...e
3966
- }, this._data = new re(jt), this._rowMgr = new Ie(this._data), this._colLayout = new Lt(this._options.columns, this._options.frozenColumns), this._editMgr = new Be({
3967
- data: this._data,
3968
- colLayout: this._colLayout,
3969
- getRenderer: () => this._renderer,
3970
- getContainer: () => this._container,
3971
- getOptions: () => this._options,
3972
- emit: (n, ...r) => this.emit(n, ...r),
3973
- doRender: () => this._doRender(...this._visRange()),
3974
- announce: (n) => this._announce(n),
3975
- writeCell: (n, r, l) => this.writeCell(n, r, l),
3976
- scrollToRow: (n) => {
3977
- var r;
3978
- return (r = this._vs) == null ? void 0 : r.scrollToRow(n);
3979
- },
3980
- getVisibleLeaves: () => this._colLayout.visibleLeaves
3981
- }), this._exportMgr = new Ue({
3982
- getData: () => this._data.getData(),
3983
- getColLayout: () => this._colLayout,
3984
- getColWidths: () => this._colWidths,
3985
- getOptions: () => this._options,
3986
- getContainer: () => this._container,
3987
- getMaskEnabled: (n) => this.getMaskEnabled(n),
3988
- getWsManager: () => this._wsManager,
3989
- getStrategy: (n, r) => this._ovk.getStrategy(n, r)
3990
- }), this._footerMgr = new Ge({
3991
- getData: () => this._data.getData(),
3992
- getColLayout: () => this._colLayout,
3993
- getColWidths: () => this._colWidths,
3994
- getOptions: () => this._options,
3995
- getContainer: () => this._container,
3996
- getStrategy: (n, r) => this._ovk.getStrategy(n, r)
3997
- }), this._kbdMgr = new qe({
3998
- getEditMgr: () => this._editMgr,
3999
- getRowMgr: () => this._rowMgr,
4000
- getData: () => this._data,
4001
- getColLayout: () => this._colLayout,
4002
- getOptions: () => this._options,
4003
- setFocusCell: (n, r) => this._setFocusCell(n, r),
4004
- handleRowDrop: (n, r) => this._handleRowDrop(n, r),
4005
- doRender: () => this._doRender(...this._visRange()),
4006
- announce: (n) => this._announce(n),
4007
- emit: (n, ...r) => this.emit(n, ...r),
4008
- visRange: () => this._visRange(),
4009
- handleCellKeyEvt: (n, r) => this._handleCellKeyEvt(n, r)
4010
- }), this._sfMgr = new es({
4011
- getData: () => this._data,
4012
- getColLayout: () => this._colLayout,
4013
- getFindFilter: () => this._findMgr.findFilter,
4014
- getVs: () => this._vs,
4015
- getPagination: () => this._pagination,
4016
- getOptions: () => this._options,
4017
- renderHeader: () => this._renderHeader(),
4018
- doRender: () => this._doRender(...this._visRange()),
4019
- announce: (n) => this._announce(n),
4020
- emit: (n, ...r) => this.emit(n, ...r)
4021
- }), this._findMgr = new Xe({
4022
- getColLayout: () => this._colLayout,
4023
- getData: () => this._data,
4024
- getFilters: () => this._sfMgr.filters,
4025
- getVs: () => this._vs,
4026
- getPagination: () => this._pagination,
4027
- doRender: () => this._doRender(...this._visRange())
4028
- }), this._cellEvt = new ss({
4029
- getData: () => this._data,
4030
- getColLayout: () => this._colLayout,
4031
- getOptions: () => this._options,
4032
- getEditMgr: () => this._editMgr,
4033
- getRowMgr: () => this._rowMgr,
4034
- emit: (n, ...r) => this.emit(n, ...r),
4035
- writeCell: (n, r, l) => this.writeCell(n, r, l),
4036
- doRender: () => this._doRender(...this._visRange()),
4037
- getContainer: () => this._container
4038
- }), this._grpMgr = new ts({
4039
- getData: () => this._data.getData(),
4040
- getDataLayer: () => this._data,
4041
- getOptions: () => this._options,
4042
- getVs: () => this._vs,
4043
- doRenderFull: (n) => this._doRender(0, n - 1),
4044
- doRender: () => this._doRender(...this._visRange()),
4045
- getStrategy: (n, r) => this._ovk.getStrategy(n, r)
4046
- }), this._ovk = new as(this, { strict: this._options.overrideStrict ?? !0 }), this._data.setStrategyResolver((n, r) => this._ovk.getStrategy(n, r)), be(
4047
- (n, r, l) => {
4048
- var a;
4049
- return ((a = this._ovk.getStrategy("displayFormatter", null)) == null ? void 0 : a(n, r, l)) ?? null;
4050
- }
4051
- ), this._mount(), this._bindOptionEvents(), (o = this._options.defaultSort) != null && o.length && this._sfMgr.initSort(this._options.defaultSort), this.override = Object.assign(
4052
- (n, r, l) => this._ovk.override(n, r, l),
4053
- { strategy: (n, r) => this._ovk.strategy(n, r) }
4054
- );
4055
- const i = this.destroy.bind(this);
4056
- this.destroy = () => {
4057
- try {
4058
- i();
4059
- } finally {
4060
- this._ovk.restoreAll();
4061
- }
4062
- };
4063
- for (const [n, r] of V._defaultStrategies) this._ovk.strategy(n, r);
4064
- for (const [n, r, l] of V._defaultOverrides) this._ovk.override(n, r, l);
4065
- requestAnimationFrame(() => {
4066
- var n, r;
4067
- this.emit("ready", this), (r = (n = this._options).onReady) == null || r.call(n, this);
4068
- });
4069
- }
4070
- /** 정적: 모든 신규 그리드에 적용될 override 레이어 등록. */
4071
- static defaultOverride(t, e, s = {}) {
4072
- return V._defaultOverrides.push([t, e, s]), V;
4073
- }
4074
- // ── grid.override() 위임 메서드 ──────────────────────────
4075
- restore(t) {
4076
- return this._ovk.restore(t), this;
4077
- }
4078
- restoreAll() {
4079
- return this._ovk.restoreAll(), this;
4080
- }
4081
- hasOverride(t) {
4082
- return this._ovk.hasOverride(t);
4083
- }
4084
- getOverrideNames() {
4085
- return this._ovk.getOverrideNames();
4086
- }
4087
- getStrategy(t, e) {
4088
- return this._ovk.getStrategy(t, e);
4089
- }
4090
- _mount() {
4091
- var s, i;
4092
- this._container.classList.add("og-container");
4093
- const t = this._options.height, e = this._options.width;
4094
- this._container.style.height = typeof t == "number" ? `${t}px` : String(t), this._container.style.width = typeof e == "number" ? `${e}px` : String(e), this._container.style.display = "flex", this._container.style.flexDirection = "column", this._container.style.overflow = "hidden", this._container.style.boxSizing = "border-box", this._container.style.border = "1px solid var(--og-border-color, #e0e0e0)", this._container.style.fontFamily = "var(--og-font-family, -apple-system, sans-serif)", this._container.style.fontSize = "var(--og-font-size, 13px)", this._container.setAttribute("data-og-theme", this._options.theme);
4095
- for (const [o, n] of Object.entries(this._options.cssVars))
4096
- this._container.style.setProperty(o, n);
4097
- this._renderer = new He(this._container, this._options, {
4098
- onHeaderClick: (o, n) => this._handleSortClick(o, n),
4099
- onCellClick: (o, n, r) => this._handleCellClick(o, n, r),
4100
- onCellDblClick: (o, n, r) => this._handleCellDblClick(o, n, r),
4101
- onCellMouseOver: (o, n, r) => this._handleCellMouseOver(o, n, r),
4102
- onCellMouseOut: (o, n, r) => this._handleCellMouseOut(o, n, r),
4103
- onCellMouseDown: (o, n, r) => this._handleCellMouseDown(o, n, r),
4104
- onCellMouseUp: (o, n, r) => this._handleCellMouseUp(o, n, r),
4105
- onCellMouseMove: (o, n, r) => this._handleCellMouseMove(o, n, r),
4106
- onRowCheck: (o, n) => this._handleRowCheck(o, n),
4107
- onAllCheck: (o) => this._handleAllCheck(o),
4108
- onColResize: (o, n) => this._handleColResize(o, n),
4109
- onFilterIconClick: (o, n) => this._handleFilterIconClick(o, n),
4110
- getDndManager: () => this._dnd,
4111
- onColDragStart: (o) => {
4112
- this._editMgr.dragColIdx = o;
4113
- },
4114
- onColDrop: (o) => {
4115
- this._editMgr.dragColIdx !== null && this._editMgr.dragColIdx !== o && this._reorderColumn(this._editMgr.dragColIdx, o), this._editMgr.dragColIdx = null;
4116
- },
4117
- getColDragIdx: () => this._editMgr.dragColIdx
4118
- }), this._filterPanel = new de(
4119
- this._container,
4120
- (o, n) => this.setFilter(o, n),
4121
- (o) => this.resetFilter(o)
4122
- ), this._container.setAttribute("role", "grid"), this._container.setAttribute("aria-label", this._options.ariaLabel ?? ((s = this._options.cssVars) == null ? void 0 : s["aria-label"]) ?? "OPEN_GRID 데이터 그리드"), this._container.setAttribute("aria-rowcount", "0"), this._container.setAttribute("aria-colcount", String(this._options.columns.filter((o) => !o.hidden).length)), this._liveRegion = document.createElement("div"), this._liveRegion.setAttribute("aria-live", "polite"), this._liveRegion.setAttribute("aria-atomic", "true"), this._liveRegion.className = "og-live-region", this._container.insertAdjacentElement("beforebegin", this._liveRegion), this._container.tabIndex = 0, this._container.addEventListener("keydown", (o) => this._handleKeyDown(o)), this._container.addEventListener("keyup", (o) => this._handleCellKeyEvt("cellKeyUp", o)), this._container.addEventListener("keypress", (o) => this._handleCellKeyEvt("cellKeyPress", o)), this._vs = new ae(this._renderer.bodyWrapper, {
4123
- rowHeight: this._options.rowHeight,
4124
- onRender: (o, n) => this._doRender(o, n)
4125
- }), ct.register(this._renderer.bodyWrapper, this), this._options.draggable && (this._dnd = new Pe(
4126
- this._renderer.bodyWrapper,
4127
- this._options.rowHeight,
4128
- (o, n) => this._handleRowDrop(o, n),
4129
- this._options.crossGrid ? {
4130
- resolveTarget: (o, n) => {
4131
- const r = ct.resolveAt(o, n, this);
4132
- return !r || !r._options.crossGrid ? null : { bodyEl: r._crossBodyEl(), rowHeight: r._options.rowHeight, totalRows: r._data.rowCount };
4133
- },
4134
- onCrossDrop: (o, n, r) => this._handleCrossGridDrop(o, n, r)
4135
- } : void 0,
4136
- (o) => this._dragRowSet(o).length
4137
- )), this._options.pagination && (this._pagination = new We(
4138
- this._container,
4139
- this._options.pageSize,
4140
- (o) => {
4141
- this.emit("pageChange", o), this._doRender(...this._visRange());
4142
- }
4143
- )), this._findMgr.init(this._container), this._initContextMenu(), (i = this._options.worksheets) != null && i.length && this._initWorksheets(), this._ro = new ResizeObserver(() => this._onResize()), this._ro.observe(this._container), this._onResize();
4144
- }
4145
- _initContextMenu() {
4146
- const t = this._options.contextMenu;
4147
- t !== !1 && (this._cmHandler && this._container.removeEventListener("contextmenu", this._cmHandler), this._cmKbdHandler && this._container.removeEventListener("keydown", this._cmKbdHandler), this._cmHandler = this._cmKbdHandler = null, this._ctxMenu = new je(this._container, {
4148
- onSortAsc: () => {
4149
- const e = this._colLayout.visibleLeaves[0];
4150
- e && this.orderBy(e.field, "asc");
4151
- },
4152
- onSortDesc: () => {
4153
- const e = this._colLayout.visibleLeaves[0];
4154
- e && this.orderBy(e.field, "desc");
4155
- },
4156
- onFind: () => this._findMgr.open(),
4157
- onExcel: () => this.exportExcel(),
4158
- onCsv: () => this.exportCsv(),
4159
- onPrint: () => this.print()
4160
- }), this._cmHandler = (e) => {
4161
- var r;
4162
- const s = e.target.closest(".og-cell");
4163
- if (!s) return;
4164
- e.preventDefault();
4165
- const i = Number(s.dataset.colIndex ?? -1), o = this._colLayout.visibleLeaves[i];
4166
- o && this._ctxMenu && (this._ctxMenu._actions.onSortAsc = () => this.orderBy(o.field, "asc"), this._ctxMenu._actions.onSortDesc = () => this.orderBy(o.field, "desc"));
4167
- const n = Array.isArray(t) ? t : void 0;
4168
- (r = this._ctxMenu) == null || r.open(e, n);
4169
- }, this._container.addEventListener("contextmenu", this._cmHandler), this._cmKbdHandler = (e) => {
4170
- var s;
4171
- if (e.shiftKey && e.key === "F10") {
4172
- e.preventDefault();
4173
- const i = this._container.getBoundingClientRect(), o = { clientX: i.left + 80, clientY: i.top + 40 };
4174
- (s = this._ctxMenu) == null || s.open(o);
4175
- }
4176
- }, this._container.addEventListener("keydown", this._cmKbdHandler));
4177
- }
4178
- // openContextMenu / closeContextMenu 공개 API
4179
- openContextMenu(t, e) {
4180
- var s;
4181
- (s = this._ctxMenu) == null || s.open(t, e);
4182
- }
4183
- closeContextMenu() {
4184
- var t;
4185
- (t = this._ctxMenu) == null || t.close();
4186
- }
4187
- setFilterSelect(t) {
4188
- var e;
4189
- (e = this._filterSelect) == null || e.destroy(), this._filterSelect = null, t && (this._container.id || (this._container.id = `og-${Math.random().toString(36).slice(2, 7)}`), this._filterSelect = new Oe(
4190
- this._container,
4191
- t,
4192
- (s, i) => this.setFilter(s, i),
4193
- (s) => this.resetFilter(s),
4194
- this._container.id
4195
- ));
4196
- }
4197
- // 옵션을 런타임에 바꿀 때 호출 (contextMenu 재초기화, groupBy 재구성 등)
4198
- setOptions(t) {
4199
- var e;
4200
- if (Object.assign(this._options, t), "contextMenu" in t && ((e = this._ctxMenu) == null || e.destroy(), this._ctxMenu = null, this._initContextMenu()), "groupBy" in t || "summary" in t) {
4201
- const s = t.groupBy ?? [];
4202
- s.length > 0 ? this._grpMgr.groupBy(s) : this.clearGroup();
4203
- return;
4204
- }
4205
- this._renderHeader(), this._doRender(...this._visRange());
4206
- }
4207
- /**
4208
- * 컬럼 마스킹 ON/OFF 전환.
4209
- * enabled=true → 마스킹 적용 (기본 상태)
4210
- * enabled=false → 컬럼 전체 마스킹 해제 (원문 표시)
4211
- */
4212
- setMaskEnabled(t, e) {
4213
- var i;
4214
- const s = this._colLayout.getColumnByField(t);
4215
- s && (e ? (s._maskRevealed = !1, (i = s._maskRevealedRows) == null || i.clear()) : s._maskRevealed = !0, this._doRender(...this._visRange()));
4216
- }
4217
- /** 현재 컬럼 마스킹 활성 여부 반환. true=마스킹 중, false=해제됨 */
4218
- getMaskEnabled(t) {
4219
- const e = this._colLayout.getColumnByField(t);
4220
- return e ? e._maskRevealed !== !0 : !1;
4221
- }
4222
- _initWorksheets() {
4223
- const t = this._options.worksheets;
4224
- this._wsManager = new Kt(
4225
- this._container,
4226
- (e, s) => this._loadWorksheetState(s)
4227
- );
4228
- for (const e of t)
4229
- this._wsManager.add(e.name, e.columns ?? this._options.columns, e.data ?? []);
4230
- }
4231
- // 탭(워크시트) 전환 시 데이터·컬럼을 화면에 반영한다.
4232
- // 핵심(Why): _data.setData 만으로는 가상 스크롤(_vs)의 총 행수가 갱신되지 않아
4233
- // _visRange 가 빈 범위를 돌려줘 행이 렌더되지 않는다(데이터 미표시 버그).
4234
- // 공개 setData 와 동일하게 _vs.setTotalRows + aria + 컬럼폭 재계산까지 수행한다.
4235
- _loadWorksheetState(t) {
4236
- var s, i;
4237
- this._rowMgr.reset(), this._data.setData(t.data), this._colLayout = new Lt(
4238
- t.columns.length ? t.columns : this._options.columns,
4239
- this._options.frozenColumns
4240
- ), (s = this._vs) == null || s.setTotalRows(this._data.rowCount), (i = this._pagination) == null || i.setTotalRows(this._data.rowCount), this._container.setAttribute("aria-rowcount", String(this._data.rowCount)), this._container.setAttribute("aria-colcount", String(this._colLayout.visibleLeaves.length));
4241
- const { width: e } = this._container.getBoundingClientRect();
4242
- e && this._recalcWidths(e), this._renderHeader(), this._doRender(...this._visRange());
4243
- }
4244
- addWorksheet(t, e, s) {
4245
- this._wsManager || (this._wsManager = new Kt(
4246
- this._container,
4247
- (i, o) => this._loadWorksheetState(o)
4248
- )), this._wsManager.add(t, e ?? this._options.columns, s ?? []);
4249
- }
4250
- removeWorksheet(t) {
4251
- var e;
4252
- (e = this._wsManager) == null || e.remove(t);
4253
- }
4254
- switchWorksheet(t) {
4255
- var e;
4256
- (e = this._wsManager) == null || e.switch(t);
4257
- }
4258
- renameWorksheet(t, e) {
4259
- var s;
4260
- (s = this._wsManager) == null || s.rename(t, e);
4261
- }
4262
- getWorksheet(t) {
4263
- var e;
4264
- return (e = this._wsManager) == null ? void 0 : e.get(t);
4265
- }
4266
- getWorksheetNames() {
4267
- var t;
4268
- return ((t = this._wsManager) == null ? void 0 : t.getNames()) ?? [];
4269
- }
4270
- exportSheetsExcel(t) {
4271
- this._exportMgr.exportSheetsExcel(t);
4272
- }
4273
- _paginationHeight() {
4274
- return this._options.pagination ? 38 : 0;
4275
- }
4276
- _onResize() {
4277
- const { width: t } = this._container.getBoundingClientRect();
4278
- t && (this._recalcWidths(t), this._renderHeader(), this._doRender(...this._visRange()));
4279
- }
4280
- _recalcWidths(t) {
4281
- this._colWidths = this._colLayout.computeWidths(
4282
- t - (this._options.stateColumn ? 24 : 0) - (this._options.draggable ? 18 : 0) - (this._options.rowNumber ? 44 : 0) - (this._options.checkColumn ? 36 : 0),
4283
- this._options.defaultColumnWidth
4284
- ), this._userWidths.size && this._colLayout.visibleLeaves.forEach((e, s) => {
4285
- const i = this._userWidths.get(e.field);
4286
- i != null && (this._colWidths[s] = i);
4287
- });
4288
- }
4289
- // 헤더(컬럼 제목 행)를 다시 그린다
4290
- _renderHeader() {
4291
- var t;
4292
- (t = this._renderer) == null || t.renderHeader(
4293
- this._colLayout.buildHeaderCells(),
4294
- this._colLayout.visibleLeaves,
4295
- this._colWidths,
4296
- this._sfMgr.sortList,
4297
- { ...this._options, _activeFilters: this._sfMgr.filters, _frozenCount: this._colLayout.frozenCount }
4298
- ), this._syncHeaderLayout();
4299
- }
4300
- /**
4301
- * 렌더된 헤더의 실제 높이를 측정해 본문(bodyWrap) 높이와 뷰포트 높이에 반영한다.
4302
- * 줄바꿈이 없는 헤더는 측정 높이가 headerHeight 이하라 기존 고정 동작과 동일하다.
4303
- */
4304
- _syncHeaderLayout() {
4305
- if (!this._renderer || !this._vs) return;
4306
- const { height: t } = this._container.getBoundingClientRect();
4307
- if (!t) return;
4308
- const e = this._renderer.getHeaderHeight(), s = e > this._options.headerHeight ? e : this._options.headerHeight;
4309
- this._renderer.updateSize(t - this._paginationHeight(), s), this._vs.setViewportHeight(t - s - this._paginationHeight());
4310
- }
4311
- _doRender(t, e) {
4312
- var o;
4313
- if (!this._renderer || !this._vs) return;
4314
- const s = this._vs.getVisibleRange(), i = this._options.autoHeight === !0;
4315
- i && ([t, e] = this._visRange(), !this._autoHeightWarned && e - t + 1 > 2e3 && (this._autoHeightWarned = !0, console.warn(
4316
- `[OpenGrid] autoHeight 는 가상 스크롤이 아니라 전 행(${e - t + 1}행)을 렌더합니다. 행이 많으면 고정 rowHeight(가상 스크롤) 사용을 권장합니다.`
4317
- ))), this._renderer.renderBody(
4318
- t,
4319
- e,
4320
- this._data,
4321
- this._colLayout.visibleLeaves,
4322
- this._colWidths,
4323
- this._options,
4324
- i ? 0 : s.offsetY,
4325
- i ? 0 : this._vs.getTotalHeight(),
4326
- this._rowMgr.selectedRows,
4327
- this._rowMgr.checkedRows,
4328
- this._grpMgr.isGroupMode ? this._grpMgr.groupFlatRows : this._grpMgr.isTreeMode ? this._grpMgr.treeFlatRows : null,
4329
- (n) => this._grpMgr.handleGroupToggle(n),
4330
- this._grpMgr.isTreeMode ? (n) => this._grpMgr.handleTreeToggle(n) : void 0,
4331
- { _totalRows: this._data.rowCount, _frozenCount: this._colLayout.frozenCount, _focusCell: this._editMgr.focusCell },
4332
- this._mergeEngine
4333
- ), (o = this._options.footer) != null && o.length && this._renderFooterEl();
4334
- }
4335
- _handleGroupToggle(t) {
4336
- this._grpMgr.handleGroupToggle(t);
4337
- }
4338
- // 현재 화면에 보이는 행 범위를 반환한다
4339
- _visRange() {
4340
- var e;
4341
- if (this._options.pagination && this._pagination) {
4342
- const { start: s, end: i } = this._pagination.getRange();
4343
- return [s, i];
4344
- }
4345
- if (this._options.autoHeight)
4346
- return [0, (this._grpMgr.isGroupMode ? this._grpMgr.groupFlatRows.length : this._grpMgr.isTreeMode ? this._grpMgr.treeFlatRows.length : this._data.rowCount) - 1];
4347
- const t = (e = this._vs) == null ? void 0 : e.getVisibleRange();
4348
- return [(t == null ? void 0 : t.startIndex) ?? 0, Math.min(((t == null ? void 0 : t.endIndex) ?? 30) + this._visCount() + 5, this._data.rowCount - 1)];
4349
- }
4350
- _visCount() {
4351
- const t = this._container.getBoundingClientRect().height;
4352
- return Math.ceil((t - this._options.headerHeight - this._paginationHeight()) / this._options.rowHeight) + 5;
4353
- }
4354
- _handleSortClick(t, e) {
4355
- this._sfMgr.handleSortClick(t, e);
4356
- }
4357
- _isToggleCol(t) {
4358
- return nt(t);
4359
- }
4360
- _handleCellClick(t, e, s) {
4361
- this._cellEvt.handleCellClick(t, e, s);
4362
- }
4363
- _handleCellDblClick(t, e, s) {
4364
- this._cellEvt.handleCellDblClick(t, e, s);
4365
- }
4366
- _handleCellMouseOver(t, e, s) {
4367
- this._cellEvt.handleCellMouseOver(t, e, s);
4368
- }
4369
- _handleCellMouseOut(t, e, s) {
4370
- this._cellEvt.handleCellMouseOut(t, e, s);
4371
- }
4372
- _handleCellMouseDown(t, e, s) {
4373
- this._cellEvt.handleCellMouseDown(t, e, s);
4374
- }
4375
- _handleCellMouseUp(t, e, s) {
4376
- this._cellEvt.handleCellMouseUp(t, e, s);
4377
- }
4378
- _handleCellMouseMove(t, e, s) {
4379
- this._cellEvt.handleCellMouseMove(t, e, s);
4380
- }
4381
- _handleCellKeyEvt(t, e) {
4382
- this._cellEvt.handleCellKeyEvt(t, e);
4383
- }
4384
- _handleRowCheck(t, e) {
4385
- this._rowMgr.check(t, e), this._doRender(...this._visRange()), this.emit("rowCheck", { rowIndex: t, checked: e, row: this._data.getRowByIndex(t) });
4386
- }
4387
- _handleFilterIconClick(t, e) {
4388
- var i, o;
4389
- if ((i = this._filterPanel) != null && i.isOpen) {
4390
- this._filterPanel.close();
4391
- return;
4392
- }
4393
- const s = this._sfMgr.filters[t] ?? [];
4394
- (o = this._filterPanel) == null || o.open(t, e, s);
4395
- }
4396
- _handleAllCheck(t) {
4397
- this._rowMgr.checkAll(t, this._data.rowCount), this._doRender(...this._visRange()), this.emit("allCheck", { checked: t });
4398
- }
4399
- _handleRowDrop(t, e) {
4400
- var s, i;
4401
- this._data.moveRow(t, e), this._doRender(...this._visRange()), this.emit("rowDrop", { fromIndex: t, toIndex: e }), (i = (s = this._options).onRowDrop) == null || i.call(s, { fromIndex: t, toIndex: e });
4402
- }
4403
- // ── 크로스그리드 내부 헬퍼 ──
4404
- /** 드래그/셔틀이 참조하는 바디 엘리먼트 (레지스트리 해석용) */
4405
- _crossBodyEl() {
4406
- return this._renderer.bodyWrapper;
4407
- }
4408
- /** fromIndex 를 잡고 드래그할 때 함께 이동할 행 집합 (다중선택에 포함되면 선택 전체) */
4409
- _dragRowSet(t) {
4410
- const e = [...this._rowMgr.selectedRows];
4411
- return e.length > 1 && e.includes(t) ? e.sort((s, i) => s - i) : [t];
4412
- }
4413
- /** 드래그 드롭 어댑터 → 공개 moveRowsTo 로 위임 */
4414
- _handleCrossGridDrop(t, e, s) {
4415
- const i = ct.get(e);
4416
- !i || i === this || this.moveRowsTo(i, this._dragRowSet(t), s);
4417
- }
4418
- /**
4419
- * 이 그리드의 행들을 다른 그리드로 이동(move)한다. 드래그·화살표 셔틀 공통 경로.
4420
- * 3단계 이벤트(before→after→complete)와 crossGridMapping(필드 매핑)을 적용한다.
4421
- * @param targetGrid 대상 그리드
4422
- * @param sourceIndexes 이동할 (표시)행 인덱스들
4423
- * @param targetIndex 대상에서 삽입 위치 (생략 시 맨 끝에 추가)
4424
- * @returns 이동 성공 true, 취소/무효 false
4425
- */
4426
- async moveRowsTo(t, e, s) {
4427
- const i = t;
4428
- if (!i || i === this || !e.length) return !1;
4429
- const o = [...new Set(e)].sort((c, u) => c - u), n = s ?? i._data.rowCount;
4430
- let r = o.map((c) => {
4431
- const u = { ...this._data.getRowByIndex(c) };
4432
- return delete u[jt], u;
4433
- });
4434
- const l = await this._resolveCrossTransform(i);
4435
- if (l === !1) return !1;
4436
- l && (r = r.map((c) => l(c)));
4437
- const a = {
4438
- sourceGrid: this,
4439
- targetGrid: i,
4440
- rows: r,
4441
- sourceIndexes: o,
4442
- targetIndex: n
4443
- };
4444
- return this._fireGridDropBefore(a) === !1 || a.cancel || i._fireGridDropBefore(a) === !1 || a.cancel ? !1 : (r.forEach((c, u) => i.insertRow(c, n + u)), [...o].sort((c, u) => u - c).forEach((c) => this.deleteRow(c)), this._fireGridDropAfter(a), i._fireGridDropAfter(a), this._fireGridDropComplete(a), i._fireGridDropComplete(a), !0);
4445
- }
4446
- /** 체크된 행을 다른 그리드로 이동 (화살표 셔틀용). 체크 없으면 무시. */
4447
- async moveCheckedTo(t) {
4448
- const e = this._rowMgr.getChecked().map((s) => s.rowIndex);
4449
- return e.length ? (this._rowMgr.uncheckAll(), this.moveRowsTo(t, e)) : !1;
4450
- }
4451
- /**
4452
- * 크로스그리드 이동의 행 변환 함수를 결정한다.
4453
- * 반환: null=변환 불필요(그대로) / 함수=변환 적용 / false=매핑 모달 취소(이동 중단)
4454
- */
4455
- async _resolveCrossTransform(t) {
4456
- var r, l;
4457
- const e = this._options.crossGridMapping;
4458
- if (typeof e == "function") return e;
4459
- if (e !== "interactive") return null;
4460
- const s = this._colLayout.visibleLeaves.map((a) => ({ field: a.field, header: a.header })), i = t._colLayout.visibleLeaves.map((a) => ({ field: a.field, header: a.header }));
4461
- if (ns(s.map((a) => a.field), i.map((a) => a.field))) return null;
4462
- const o = await rs(s, i);
4463
- if (!o) return !1;
4464
- const n = {
4465
- sourceGrid: this,
4466
- targetGrid: t,
4467
- mapping: o.mapping,
4468
- script: o.script
4469
- };
4470
- return this.emit("gridDropMapping", n), (l = (r = this._options).onGridDropMapping) == null || l.call(r, n), console.log(`[OpenGrid] cross-grid mapping script:
4471
- ` + se(o.mapping)), os(o.mapping);
4472
- }
4473
- _fireGridDropBefore(t) {
4474
- var e, s;
4475
- return this.emit("gridDropBefore", t), (s = (e = this._options).onGridDropBefore) == null ? void 0 : s.call(e, t);
4476
- }
4477
- _fireGridDropAfter(t) {
4478
- var e, s;
4479
- this.emit("gridDropAfter", t), (s = (e = this._options).onGridDropAfter) == null || s.call(e, t);
4480
- }
4481
- _fireGridDropComplete(t) {
4482
- var e, s;
4483
- this.emit("gridDropComplete", t), (s = (e = this._options).onGridDropComplete) == null || s.call(e, t);
4484
- }
4485
- /** 행을 드롭으로 이동할 때 실행된다 */
4486
- /** ???꾩튂 ?대룞 */
4487
- reorderRow(t, e) {
4488
- this._data.moveRow(t, e), this._doRender(...this._visRange());
4489
- }
4490
- _handleColResize(t, e) {
4491
- this._colWidths[t] !== void 0 && (this._colWidths[t] = e);
4492
- const s = this._colLayout.visibleLeaves[t];
4493
- s && this._userWidths.set(s.field, e), this._renderHeader(), this._doRender(...this._visRange());
4494
- }
4495
- _handleKeyDown(t) {
4496
- this._kbdMgr.handleKeyDown(t);
4497
- }
4498
- _setFocusCell(t, e) {
4499
- this._rowMgr.selectSingle(t), this._editMgr.setFocusCell(t, e);
4500
- }
4501
- // 스크린리더에게 텍스트를 읽어준다 (aria-live)
4502
- _announce(t) {
4503
- this._liveRegion && (this._liveRegion.textContent = "", setTimeout(() => {
4504
- this._liveRegion && (this._liveRegion.textContent = t);
4505
- }, 50));
4506
- }
4507
- _bindOptionEvents() {
4508
- this._options.onCellClick && this.on("cellClick", this._options.onCellClick), this._options.onCellDblClick && this.on("cellDblClick", this._options.onCellDblClick), this._options.onRowClick && this.on("rowClick", this._options.onRowClick), this._options.onEditStart && this.on("editStart", this._options.onEditStart), this._options.onEditEnd && this.on("editEnd", this._options.onEditEnd), this._options.onSortChange && this.on("sortChange", this._options.onSortChange), this._options.onFilterChange && this.on("filterChange", this._options.onFilterChange), this._options.onScroll && this.on("scroll", this._options.onScroll), this._options.onDataChange && this.on("dataChange", this._options.onDataChange), this._options.onSelectionChange && this.on("selectionChange", this._options.onSelectionChange), this._options.onRowDblClick && this.on("rowDblClick", this._options.onRowDblClick), this._options.onRowMouseOver && this.on("rowMouseOver", this._options.onRowMouseOver), this._options.onRowMouseOut && this.on("rowMouseOut", this._options.onRowMouseOut), this._options.onRowMouseDown && this.on("rowMouseDown", this._options.onRowMouseDown), this._options.onRowMouseUp && this.on("rowMouseUp", this._options.onRowMouseUp), this._options.onRowMouseMove && this.on("rowMouseMove", this._options.onRowMouseMove), this._options.onCellMouseOver && this.on("cellMouseOver", this._options.onCellMouseOver), this._options.onCellMouseOut && this.on("cellMouseOut", this._options.onCellMouseOut), this._options.onCellMouseDown && this.on("cellMouseDown", this._options.onCellMouseDown), this._options.onCellMouseUp && this.on("cellMouseUp", this._options.onCellMouseUp), this._options.onCellMouseMove && this.on("cellMouseMove", this._options.onCellMouseMove), this._options.onCellKeyDown && this.on("cellKeyDown", this._options.onCellKeyDown), this._options.onCellKeyUp && this.on("cellKeyUp", this._options.onCellKeyUp), this._options.onCellKeyPress && this.on("cellKeyPress", this._options.onCellKeyPress);
4509
- }
4510
- setData(t) {
4511
- var s;
4512
- const e = this._trigMgr.mkCtx("setData", [t]);
4513
- this._trigMgr.exec("before:setData", e) && (this._rowMgr.reset(), this._data.setData(t), this._applyFilters(), this._grpMgr.isTreeMode ? this._grpMgr.rebuildTree() : this._grpMgr.isGroupMode ? this._grpMgr.rebuildGroups() : (s = this._vs) == null || s.setTotalRows(this._data.rowCount), this._container.setAttribute("aria-rowcount", String(this._data.rowCount)), this._container.setAttribute("aria-colcount", String(this._colLayout.visibleLeaves.length)), this._announce(`${this._data.rowCount}행 데이터 로드됨`), this.emit("dataChange", this._data.getData()), e.result = t.length, this._trigMgr.exec("after:setData", e));
4514
- }
4515
- getData() {
4516
- return this._data.getData();
4517
- }
4518
- getSourceRows() {
4519
- return this._data.getOriginalData();
4520
- }
4521
- pushData(t) {
4522
- var i, o;
4523
- const e = [...this._data.getAllData(), ...t];
4524
- this._data.setData(e);
4525
- const s = this._data.rowCount;
4526
- (i = this._vs) == null || i.setTotalRows(s), (o = this._pagination) == null || o.setTotalRows(s);
4527
- }
4528
- prefixData(t) {
4529
- var i, o;
4530
- const e = [...t, ...this._data.getAllData()];
4531
- this._data.setData(e);
4532
- const s = this._data.rowCount;
4533
- (i = this._vs) == null || i.setTotalRows(s), (o = this._pagination) == null || o.setTotalRows(s);
4534
- }
4535
- clearData() {
4536
- var t, e;
4537
- this._rowMgr.reset(), this._data.clearData(), (t = this._vs) == null || t.setTotalRows(0), (e = this._pagination) == null || e.setTotalRows(0), this._doRender(0, -1), this.emit("dataChange", []);
4538
- }
4539
- insertRow(t, e = "last") {
4540
- var n, r, l, a;
4541
- const s = this._trigMgr.mkCtx("insertRow", [t, e]);
4542
- if (!this._trigMgr.exec("before:insertRow", s)) return;
4543
- const i = e === "before" ? 0 : e === "after" ? this._data.rowCount : e;
4544
- this._data.addRow(t, i);
4545
- const o = this._data.rowCount;
4546
- (n = this._vs) == null || n.setTotalRows(o), (r = this._pagination) == null || r.setTotalRows(o), this._doRender(...this._visRange()), this.emit("dataChange", this._data.getData()), (a = (l = this._options).onDataChange) == null || a.call(l, this._data.getData()), s.result = { rowCount: o, item: t }, this._trigMgr.exec("after:insertRow", s);
4547
- }
4548
- pushRow(t) {
4549
- var i, o, n, r;
4550
- (Array.isArray(t) ? t : [t]).forEach((l) => this._data.addRow(l, "last"));
4551
- const s = this._data.rowCount;
4552
- (i = this._vs) == null || i.setTotalRows(s), (o = this._pagination) == null || o.setTotalRows(s), this._doRender(...this._visRange()), this.emit("dataChange", this._data.getData()), (r = (n = this._options).onDataChange) == null || r.call(n, this._data.getData());
4553
- }
4554
- /** @deprecated 하위호환 alias → pushRow */
4555
- appendRows(t) {
4556
- this.pushRow(t);
4557
- }
4558
- unshiftRow(t) {
4559
- var i, o, n, r;
4560
- (Array.isArray(t) ? t : [t]).forEach((l) => this._data.addRow(l, "first"));
4561
- const s = this._data.rowCount;
4562
- (i = this._vs) == null || i.setTotalRows(s), (o = this._pagination) == null || o.setTotalRows(s), this._doRender(...this._visRange()), this.emit("dataChange", this._data.getData()), (r = (n = this._options).onDataChange) == null || r.call(n, this._data.getData());
4563
- }
4564
- /** @deprecated 하위호환 alias → unshiftRow */
4565
- prependRows(t) {
4566
- this.unshiftRow(t);
4567
- }
4568
- deleteRow(t) {
4569
- var n, r, l, a;
4570
- const e = this._trigMgr.mkCtx("deleteRow", [t]), s = Array.isArray(t) ? [...t] : [t];
4571
- if (e.extra = { rows: s.map((c) => this._data.getRowByIndex(c)) }, !this._trigMgr.exec("before:deleteRow", e)) return;
4572
- const i = s.sort((c, u) => u - c);
4573
- i.forEach((c) => this._data.removeRow(c));
4574
- const o = this._data.rowCount;
4575
- (n = this._vs) == null || n.setTotalRows(o), (r = this._pagination) == null || r.setTotalRows(o), this._doRender(...this._visRange()), this.emit("dataChange", this._data.getData()), (a = (l = this._options).onDataChange) == null || a.call(l, this._data.getData()), e.result = { deleted: i.length, rowCount: o }, this._trigMgr.exec("after:deleteRow", e);
4576
- }
4577
- deleteById(t) {
4578
- }
4579
- readCell(t, e) {
4580
- return this._data.getCellValue(t, e);
4581
- }
4582
- getDisplayValue(t, e) {
4583
- const s = this.readCell(t, e);
4584
- return this._ovk.getStrategy(
4585
- "displayFormatter",
4586
- (o, n, r) => o == null ? "" : String(o)
4587
- )(s, e, this._data.getRowByIndex(t));
4588
- }
4589
- writeCell(t, e, s) {
4590
- var c, u, h, g;
4591
- const i = this.readCell(t, e), o = this._trigMgr.mkCtx("writeCell", [t, e, s]);
4592
- if (o.extra = { oldValue: i, rowIndex: t, field: e }, !this._trigMgr.exec("before:writeCell", o)) return;
4593
- this._data.updateCell(t, e, s);
4594
- const n = this._data.getRowByIndex(t), r = this._colLayout.getColumnByField(e), l = this._colLayout.getColumnIndex(e), a = { type: "editEnd", rowIndex: t, columnIndex: l, field: e, oldValue: i, newValue: s, row: n, column: r };
4595
- this.emit("editEnd", a), (u = (c = this._options).onEditEnd) == null || u.call(c, a), this.emit("dataChange", this._data.getData()), (g = (h = this._options).onDataChange) == null || g.call(h, this._data.getData()), this._doRender(...this._visRange()), o.result = { rowIndex: t, field: e, oldValue: i, newValue: s }, this._trigMgr.exec("after:writeCell", o);
4596
- }
4597
- getRowAt(t) {
4598
- return this._data.getRowByIndex(t);
4599
- }
4600
- getChanges() {
4601
- return this._data.getChanges();
4602
- }
4603
- getEditedRows() {
4604
- return this._data.getEditedRows();
4605
- }
4606
- getChangedRows() {
4607
- return this._data.getChangedRows();
4608
- }
4609
- // ?섏쐞 ?명솚
4610
- getChangedColumns() {
4611
- return this._data.getChangedColumns();
4612
- }
4613
- getAddedRows() {
4614
- return this._data.getAddedRows();
4615
- }
4616
- getRemovedRows() {
4617
- return this._data.getRemovedRows();
4618
- }
4619
- getOriginalRow(t) {
4620
- return this._data.getOriginalRow(t);
4621
- }
4622
- getRowsWithState(t) {
4623
- return this._data.getRowsWithState(t);
4624
- }
4625
- undo() {
4626
- }
4627
- redo() {
4628
- }
4629
- clearHistory() {
4630
- }
4631
- getColumnDefs() {
4632
- return this._colLayout.visibleLeaves;
4633
- }
4634
- getAllColumnDefs() {
4635
- return this._colLayout.leaves;
4636
- }
4637
- getColumnCount() {
4638
- return this._colLayout.visibleLeaves.length;
4639
- }
4640
- applyColumns(t) {
4641
- const e = this._trigMgr.mkCtx("applyColumns", [t]);
4642
- this._trigMgr.exec("before:applyColumns", e) && (this._colLayout.setColumns(t), this._recalcWidths(this._container.getBoundingClientRect().width), this._renderHeader(), this._doRender(...this._visRange()), e.result = { columnCount: t.length }, this._trigMgr.exec("after:applyColumns", e));
4643
- }
4644
- insertColumn(t, e) {
4645
- this._colLayout.addColumn(t, e), this._recalcWidths(this._container.getBoundingClientRect().width), this._renderHeader(), this._doRender(...this._visRange());
4646
- }
4647
- deleteColumn(t) {
4648
- this._colLayout.removeColumn(t), this._recalcWidths(this._container.getBoundingClientRect().width), this._renderHeader(), this._doRender(...this._visRange());
4649
- }
4650
- _reorderColumn(t, e) {
4651
- var n, r;
4652
- const s = this._colLayout.visibleLeaves.map((l) => l);
4653
- if (t < 0 || e < 0 || t >= s.length || e >= s.length) return;
4654
- const i = [...this._options.columns], [o] = i.splice(t, 1);
4655
- i.splice(e, 0, o), this._options.columns = i, this.applyColumns(i), (r = (n = this._options).onColumnReorder) == null || r.call(n, { fromIndex: t, toIndex: e, field: o.field ?? "" });
4656
- }
4657
- hideColumn(t) {
4658
- this._colLayout.hideColumn(t), this._recalcWidths(this._container.getBoundingClientRect().width), this._renderHeader(), this._doRender(...this._visRange());
4659
- }
4660
- showColumn(t) {
4661
- this._colLayout.showColumn(t), this._recalcWidths(this._container.getBoundingClientRect().width), this._renderHeader(), this._doRender(...this._visRange());
4662
- }
4663
- getColumnIndex(t) {
4664
- return this._colLayout.getColumnIndex(t);
4665
- }
4666
- getFieldAt(t) {
4667
- var e;
4668
- return ((e = this._colLayout.getColumnByIndex(t)) == null ? void 0 : e.field) ?? "";
4669
- }
4670
- getColValues(t, e = !1) {
4671
- return this._data.getData().map((s) => s[t]);
4672
- }
4673
- getUniqueValues(t, e = !1) {
4674
- return [...new Set(this.getColValues(t, e))];
4675
- }
4676
- setColWidths(t) {
4677
- }
4678
- calcColWidths(t = !1) {
4679
- return [];
4680
- }
4681
- getSelections() {
4682
- return this._rowMgr.getSelections();
4683
- }
4684
- getActiveRow() {
4685
- return this._rowMgr.getActiveRow();
4686
- }
4687
- activate(t) {
4688
- this._rowMgr.activate(t), this._doRender(...this._visRange());
4689
- }
4690
- deselect() {
4691
- this._rowMgr.deselect(), this._doRender(...this._visRange());
4692
- }
4693
- getChecked() {
4694
- return this._rowMgr.getChecked();
4695
- }
4696
- getAllChecked() {
4697
- return this._rowMgr.getAllChecked();
4698
- }
4699
- checkById(t) {
4700
- }
4701
- addCheckById(t) {
4702
- }
4703
- checkByValue(t, e) {
4704
- this._rowMgr.checkByValue(t, e), this._doRender(...this._visRange());
4705
- }
4706
- uncheckById(t) {
4707
- }
4708
- uncheckAll() {
4709
- this._rowMgr.uncheckAll(), this._doRender(...this._visRange());
4710
- }
4711
- orderBy(t, e = "asc") {
4712
- const s = this._trigMgr.mkCtx("orderBy", [t, e]);
4713
- this._trigMgr.exec("before:orderBy", s) && (this._sfMgr.sort(t, e), s.result = { sortList: this._sfMgr.sortList }, this._trigMgr.exec("after:orderBy", s));
4714
- }
4715
- resetOrder() {
4716
- this._sfMgr.resetSort();
4717
- }
4718
- setFilter(t, e) {
4719
- const s = this._trigMgr.mkCtx("setFilter", [t, e]);
4720
- this._trigMgr.exec("before:setFilter", s) && (this._sfMgr.setFilter(t, e), s.result = { field: t, filteredCount: this._data.rowCount }, this._trigMgr.exec("after:setFilter", s));
4721
- }
4722
- resetFilter(t) {
4723
- this._sfMgr.resetFilter(t);
4724
- }
4725
- getFilterState() {
4726
- return this._sfMgr.getFilterState();
4727
- }
4728
- restoreFilter(t) {
4729
- this._sfMgr.restoreFilter(t);
4730
- }
4731
- _applyFilters() {
4732
- this._sfMgr.applyFilters();
4733
- }
4734
- freeze(t) {
4735
- this._colLayout.setFrozen(t), this._renderHeader(), this._doRender(...this._visRange());
4736
- }
4737
- /** ?섎룞 蹂묓빀: [{row, col, rowSpan?, colSpan?}] */
4738
- mergeCells(t) {
4739
- this._mergeEngine.applyMergeCells(t), this._doRender(...this._visRange());
4740
- }
4741
- /** 자동 병합: 지정 필드 컬럼에서 연속 같은 값을 rowSpan으로 묶는다 */
4742
- /** ?먮룞 蹂묓빀: 吏€??field 而щ읆?먯꽌 ?곗냽 媛숈? 媛믪쓣 rowSpan */
4743
- autoMerge(t) {
4744
- const e = this._colLayout.visibleLeaves, s = [], i = [];
4745
- for (const o of t) {
4746
- const n = e.findIndex((r) => r.field === o);
4747
- n >= 0 && (s.push(n), i.push(o));
4748
- }
4749
- this._mergeEngine.applyAutoMerge(this._data.getData(), s, i), this._doRender(...this._visRange());
4750
- }
4751
- /** 蹂묓빀 ?댁젣 */
4752
- clearMerge() {
4753
- this._mergeEngine.clear(), this._doRender(...this._visRange());
4754
- }
4755
- freezeRows(t) {
4756
- }
4757
- groupBy(t) {
4758
- const e = this._trigMgr.mkCtx("groupBy", [t]);
4759
- this._trigMgr.exec("before:groupBy", e) && (this._grpMgr.groupBy(t), e.result = { fields: t }, this._trigMgr.exec("after:groupBy", e));
4760
- }
4761
- clearGroup() {
4762
- this._grpMgr.clearGroup();
4763
- }
4764
- expandAll() {
4765
- this._grpMgr.expandAll();
4766
- }
4767
- collapseAll() {
4768
- this._grpMgr.collapseAll();
4769
- }
4770
- enableTree() {
4771
- this._grpMgr.enableTree();
4772
- }
4773
- disableTree() {
4774
- this._grpMgr.disableTree();
4775
- }
4776
- expandNodes(t, e = !0) {
4777
- this._grpMgr.expandNodes(t, e);
4778
- }
4779
- expandAllNodes() {
4780
- this._grpMgr.expandAllNodes();
4781
- }
4782
- collapseAllNodes() {
4783
- this._grpMgr.collapseAllNodes();
4784
- }
4785
- addTreeRow(t, e, s) {
4786
- }
4787
- exportExcel(t) {
4788
- this._exportMgr.exportExcel(t);
4789
- }
4790
- exportCsv(t) {
4791
- this._exportMgr.exportCsv(t);
4792
- }
4793
- exportJson(t) {
4794
- this._exportMgr.exportJson(t);
4795
- }
4796
- print(t) {
4797
- this._exportMgr.print(t);
4798
- }
4799
- toArray(t = !0) {
4800
- const e = this._data.getData();
4801
- if (t) return e;
4802
- const s = this._colLayout.visibleLeaves;
4803
- return e.map((i) => s.map((o) => i[o.field]));
4804
- }
4805
- jumpToRow(t) {
4806
- var e;
4807
- this._rowMgr.selectSingle(t), (e = this._vs) == null || e.scrollToRow(t), this._doRender(...this._visRange());
4808
- }
4809
- jumpToCol(t) {
4810
- }
4811
- getScrollPos() {
4812
- var t, e;
4813
- return { x: ((t = this._renderer) == null ? void 0 : t.bodyWrapper.scrollLeft) ?? 0, y: ((e = this._renderer) == null ? void 0 : e.bodyWrapper.scrollTop) ?? 0 };
4814
- }
4815
- setFooter(t) {
4816
- this._options.footer = t, this._renderFooterEl();
4817
- }
4818
- getFooterData() {
4819
- return this._footerMgr.computeValues();
4820
- }
4821
- getFooterValue(t) {
4822
- var e;
4823
- return ((e = this._footerMgr.computeValues().find((s) => s._field === t)) == null ? void 0 : e._value) ?? null;
4824
- }
4825
- _renderFooterEl() {
4826
- this._footerMgr.render();
4827
- }
4828
- resize(t, e) {
4829
- t && (this._container.style.width = `${t}px`), e && (this._container.style.height = `${e}px`), this._onResize();
4830
- }
4831
- setTheme(t) {
4832
- this._container.setAttribute("data-og-theme", t);
4833
- }
4834
- setThemeVar(t, e) {
4835
- this._container.style.setProperty(t, e);
4836
- }
4837
- addTrigger(t, e) {
4838
- return this._trigMgr.add(t, e), this;
4839
- }
4840
- removeTrigger(t, e) {
4841
- return this._trigMgr.remove(t, e), this;
4842
- }
4843
- clearTriggers(t) {
4844
- return this._trigMgr.clear(t), this;
4845
- }
4846
- _mkCtx(t, e) {
4847
- return this._trigMgr.mkCtx(t, e);
4848
- }
4849
- _trig(t, e) {
4850
- return this._trigMgr.exec(t, e);
4851
- }
4852
- destroy() {
4853
- var t, e, s, i, o, n, r, l;
4854
- this._destroyed || (this._destroyed = !0, this._renderer && ct.unregister(this._renderer.bodyWrapper), this._trigMgr.clear(), (t = this._ro) == null || t.disconnect(), (e = this._vs) == null || e.destroy(), (s = this._filterPanel) == null || s.destroy(), (i = this._dnd) == null || i.destroy(), this._cmHandler && this._container.removeEventListener("contextmenu", this._cmHandler), this._cmKbdHandler && this._container.removeEventListener("keydown", this._cmKbdHandler), this._cmHandler = this._cmKbdHandler = null, (o = this._ctxMenu) == null || o.destroy(), (n = this._wsManager) == null || n.destroy(), (r = this._renderer) == null || r.destroy(), (l = this._liveRegion) == null || l.remove(), this._liveRegion = null, this._container.innerHTML = "", this._container.classList.remove("og-container"), this.removeAllListeners());
4855
- }
4856
- };
4857
- V._defaultOverrides = [], V._defaultStrategies = [], V.defaults = {
4858
- strategy(t, e) {
4859
- return V._defaultStrategies.push([t, e]), V;
4860
- }
4861
- };
4862
- let Ut = V;
4863
- export {
4864
- Ut as O,
4865
- Vt as b
4866
- };
4867
- //# sourceMappingURL=OpenGrid-zBt01Yim.js.map