@moda-grid/vue2 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/DataGrid.vue CHANGED
@@ -5,19 +5,25 @@ import {
5
5
  onBeforeUnmount,
6
6
  onMounted,
7
7
  ref,
8
+ useSlots,
8
9
  watch,
9
10
  watchEffect,
10
11
  } from "vue";
11
12
  import type { CSSProperties, PropType } from "vue";
12
13
  import {
14
+ createLongPressTracker,
15
+ createTouchDrag,
13
16
  DEFAULT_COLUMN_WIDTH,
14
17
  DEFAULT_OPERATOR_BY_TYPE,
15
18
  FILTER_OPERATOR_LABELS,
16
19
  FILTER_OPERATORS_BY_TYPE,
17
20
  formatAggregate,
21
+ gridThemeClasses,
22
+ gridThemeVars,
18
23
  } from "@moda-grid/core";
19
24
  import type {
20
25
  AggregateFn,
26
+ BuiltInAggregateFn,
21
27
  AppendScrollOptions,
22
28
  PivotOptions,
23
29
  PivotZone,
@@ -30,6 +36,8 @@ import type {
30
36
  DisplayRow,
31
37
  FilterOperator,
32
38
  Grid,
39
+ GridDensity,
40
+ GridTheme,
33
41
  GridEventHandlers,
34
42
  GridEventMap,
35
43
  GridOptions,
@@ -52,15 +60,28 @@ function editorInputValue(v: unknown): string {
52
60
  return String(v ?? "");
53
61
  }
54
62
 
63
+ const slots = useSlots();
64
+ /** 행 상세 패널 (master-detail) — #detail="{ row, rowIndex }" 슬롯이 있으면 각 행에 ▸ 토글 표시 */
65
+ const hasDetailSlot = computed(() => !!slots.detail);
66
+
55
67
  const props = defineProps({
56
68
  columns: { type: Array as PropType<ColumnDef[]>, required: true },
57
69
  /** 모든 컬럼에 적용되는 공통 기본값 — 컬럼 명시 속성이 우선 (defaultColDef 대응) */
58
- defaultColDef: { type: Object as PropType<Partial<ColumnDef>>, default: undefined },
70
+ defaultColDef: {
71
+ type: Object as PropType<Partial<ColumnDef>>,
72
+ default: undefined,
73
+ },
59
74
  /** 행 데이터. `grid`를 직접 넘기는 제어 모드에서는 생략 가능 */
60
- data: { type: Array as PropType<Record<string, unknown>[]>, default: undefined },
75
+ data: {
76
+ type: Array as PropType<Record<string, unknown>[]>,
77
+ default: undefined,
78
+ },
61
79
  /** 외부에서 생성/관리하는 GridCore. 생략하면 내부 인스턴스 생성 */
62
80
  grid: { type: Object as PropType<Grid<any>>, default: undefined },
63
- getRowId: { type: Function as PropType<(row: Record<string, unknown>) => string>, default: undefined },
81
+ getRowId: {
82
+ type: Function as PropType<(row: Record<string, unknown>) => string>,
83
+ default: undefined,
84
+ },
64
85
  /** 행 클릭 시 선택 토글 */
65
86
  selectable: { type: Boolean, default: true },
66
87
  /** 가상 스크롤: 뷰포트 높이(px). `rowHeight`와 함께 지정 시 활성 */
@@ -75,11 +96,20 @@ const props = defineProps({
75
96
  reorderable: { type: Boolean, default: true },
76
97
  rowResizable: { type: Boolean, default: false },
77
98
  /** 셀 선택 모드: 방향키 이동 + Shift 범위 확장 */
78
- selectionMode: { type: String as PropType<SelectionMode>, default: undefined },
99
+ selectionMode: {
100
+ type: String as PropType<SelectionMode>,
101
+ default: undefined,
102
+ },
79
103
  /** 서버 사이드 데이터 소스 (내부 GridCore 생성 모드에서만 적용) */
80
- serverSide: { type: Object as PropType<ServerSideOptions>, default: undefined },
104
+ serverSide: {
105
+ type: Object as PropType<ServerSideOptions>,
106
+ default: undefined,
107
+ },
81
108
  /** Append Scroll 데이터 소스 — 스크롤 하단에서 자동으로 다음 페이지 로드 (내부 GridCore 생성 모드에서만 적용) */
82
- appendScroll: { type: Object as PropType<AppendScrollOptions>, default: undefined },
109
+ appendScroll: {
110
+ type: Object as PropType<AppendScrollOptions>,
111
+ default: undefined,
112
+ },
83
113
  /** 계층형 데이터: flat parentId 또는 nested children (내부 GridCore 생성 모드에서만 적용) */
84
114
  treeData: { type: Object as PropType<TreeDataOptions>, default: undefined },
85
115
  /** 피벗 모드 (내부 GridCore 생성 모드에서만 적용) */
@@ -89,9 +119,17 @@ const props = defineProps({
89
119
  /** 내장 UI 문자열 로케일 */
90
120
  locale: { type: Object as PropType<Partial<GridLocale>>, default: undefined },
91
121
  /** 셀 우클릭 컨텍스트 메뉴 항목 (배열 또는 grid를 받는 함수) */
92
- contextMenu: { type: [Array, Function] as PropType<GridOptions<RowData>["contextMenu"]>, default: undefined },
122
+ contextMenu: {
123
+ type: [Array, Function] as PropType<GridOptions<RowData>["contextMenu"]>,
124
+ default: undefined,
125
+ },
93
126
  /** 헤더 우클릭 컨텍스트 메뉴 항목 */
94
- headerContextMenu: { type: [Array, Function] as PropType<GridOptions<RowData>["headerContextMenu"]>, default: undefined },
127
+ headerContextMenu: {
128
+ type: [Array, Function] as PropType<
129
+ GridOptions<RowData>["headerContextMenu"]
130
+ >,
131
+ default: undefined,
132
+ },
95
133
  /** 맨 왼쪽에 행 번호 컬럼 표시 */
96
134
  rowNumbers: { type: Boolean, default: false },
97
135
  /** 우상단 컬럼 관리 도구(체크박스 팝오버 + 전체 선택/해제) 표시 */
@@ -115,6 +153,9 @@ const props = defineProps({
115
153
  /** 복사 시 표시 문자열(formatter/format 적용) 사용 */
116
154
  copyFormatted: { type: Boolean, default: false },
117
155
  singleClickEdit: { type: Boolean, default: false },
156
+ /** 편집 단위 — "cell"(기본) / "fullRow"(행 전체 동시 편집) */
157
+ editType: { type: String as () => "cell" | "fullRow", default: "cell" },
158
+ pasteExtend: { type: Boolean, default: false },
118
159
  /** 그리드 상단에 찾기 바 표시 — Enter 다음 매치 / Shift+Enter 이전 매치 */
119
160
  findBox: { type: Boolean, default: false },
120
161
  /** filterable 컬럼 헤더에 값 목록 필터 드롭다운 버튼 표시 — 엑셀 autofilter */
@@ -124,22 +165,62 @@ const props = defineProps({
124
165
  /** 헤더 영역 전체 높이(px) — 헤더 행 수로 균등 분할 */
125
166
  headerHeight: { type: Number, default: undefined },
126
167
  /** 파이프라인에서 숨길 행 id 목록 — 정렬/필터/집계에서 제외, 원본 데이터는 유지 */
127
- hiddenRowIds: { type: Array as PropType<readonly string[]>, default: undefined },
168
+ hiddenRowIds: {
169
+ type: Array as PropType<readonly string[]>,
170
+ default: undefined,
171
+ },
128
172
  /** zebra 줄무늬 행 배경 — 짝수 표시 행에 --grid-stripe-bg */
129
173
  striped: { type: Boolean, default: false },
130
174
  /** 편집 진입 직전 훅 — false 반환 시 편집 취소 (타사 그리드 OnBeforeEdit 대응) */
131
- beforeEdit: { type: Function as PropType<GridOptions<RowData>["beforeEdit"]>, default: undefined },
132
- isRowSelectable: { type: Function as PropType<GridOptions<RowData>["isRowSelectable"]>, default: undefined },
133
- externalFilter: { type: Function as PropType<GridOptions<RowData>["externalFilter"]>, default: undefined },
134
- postSort: { type: Function as PropType<GridOptions<RowData>["postSort"]>, default: undefined },
135
- beforePaste: { type: Function as PropType<GridOptions<RowData>["beforePaste"]>, default: undefined },
136
- beforeCopy: { type: Function as PropType<GridOptions<RowData>["beforeCopy"]>, default: undefined },
137
- /** 그리드 자체 테마 — 지정 시 루트에 grid-theme-* 클래스 적용 */
138
- theme: { type: String as PropType<"light" | "dark">, default: undefined },
175
+ beforeEdit: {
176
+ type: Function as PropType<GridOptions<RowData>["beforeEdit"]>,
177
+ default: undefined,
178
+ },
179
+ isRowSelectable: {
180
+ type: Function as PropType<GridOptions<RowData>["isRowSelectable"]>,
181
+ default: undefined,
182
+ },
183
+ externalFilter: {
184
+ type: Function as PropType<GridOptions<RowData>["externalFilter"]>,
185
+ default: undefined,
186
+ },
187
+ postSort: {
188
+ type: Function as PropType<GridOptions<RowData>["postSort"]>,
189
+ default: undefined,
190
+ },
191
+ beforePaste: {
192
+ type: Function as PropType<GridOptions<RowData>["beforePaste"]>,
193
+ default: undefined,
194
+ },
195
+ beforeCopy: {
196
+ type: Function as PropType<GridOptions<RowData>["beforeCopy"]>,
197
+ default: undefined,
198
+ },
199
+ /** 레이아웃 모드 — "autoHeight"면 내용만큼 늘어남 (내부 스크롤·가상 스크롤 무시) */
200
+ domLayout: {
201
+ type: String as PropType<"normal" | "autoHeight">,
202
+ default: undefined,
203
+ },
204
+ /** 뷰포트 높이/행 높이로 페이지 크기 자동 계산 — height/rowHeight 필요 */
205
+ autoPageSize: { type: Boolean, default: false },
206
+ /** 클립보드 셀 구분자 — 복사/붙여넣기 양쪽에 적용 (기본값: 탭) */
207
+ clipboardDelimiter: { type: String, default: undefined },
208
+ /** 로딩 오버레이 표시 — 그리드 전체를 반투명 레이어로 덮음 */
209
+ loading: { type: Boolean, default: false },
210
+ /**
211
+ * 그리드 테마 — "light"/"dark" 팔레트 또는 `{ base, vars }` 오브젝트로
212
+ * --grid-* 변수를 루트에 인라인 적용한다
213
+ */
214
+ theme: { type: [String, Object] as PropType<GridTheme>, default: undefined },
215
+ /** 밀도 프리셋 — "compact"/"comfortable"이 폰트·셀 패딩을 일괄 조정 */
216
+ density: { type: String as PropType<GridDensity>, default: undefined },
139
217
  /** 선언형 이벤트 핸들러 — 마운트 시 구독, 언마운트 시 해제 (grid.on과 동일) */
140
218
  events: { type: Object as PropType<GridEventHandlers>, default: undefined },
141
219
  /** GridCore 인스턴스가 준비되면 한 번 호출 — props 모드에서도 grid API 접근 가능 */
142
- onReady: { type: Function as PropType<(grid: Grid) => void>, default: undefined },
220
+ onReady: {
221
+ type: Function as PropType<(grid: Grid) => void>,
222
+ default: undefined,
223
+ },
143
224
  });
144
225
 
145
226
  // 내부 GridCore (grid prop이 없을 때만 생성)
@@ -163,6 +244,8 @@ const internal = props.grid
163
244
  cellFlash: props.cellFlash,
164
245
  copyFormatted: props.copyFormatted,
165
246
  singleClickEdit: props.singleClickEdit,
247
+ editType: props.editType,
248
+ pasteExtend: props.pasteExtend,
166
249
  headerHeight: props.headerHeight,
167
250
  hiddenRowIds: props.hiddenRowIds ? [...props.hiddenRowIds] : undefined,
168
251
  striped: props.striped,
@@ -173,7 +256,10 @@ const internal = props.grid
173
256
  beforePaste: props.beforePaste,
174
257
  beforeCopy: props.beforeCopy,
175
258
  virtualScroll:
176
- props.height != null && props.rowHeight != null && props.rowHeight > 0
259
+ props.domLayout !== "autoHeight" &&
260
+ props.height != null &&
261
+ props.rowHeight != null &&
262
+ props.rowHeight > 0
177
263
  ? {
178
264
  rowHeight: props.rowHeight,
179
265
  viewportHeight: props.height,
@@ -183,6 +269,13 @@ const internal = props.grid
183
269
  });
184
270
  const grid = props.grid ?? internal!.grid;
185
271
  const state = props.grid ? useGridState(grid).state : internal!.state;
272
+ // 로딩 오버레이 — prop 또는 코어 상태(grid.setLoading → state.loading) 합산
273
+ const isLoading = computed(() => props.loading || state.value.loading);
274
+ // 테마·밀도 — 코어 헬퍼로 클래스/인라인 var를 선언적 바인딩한다
275
+ const themeClasses = computed(() =>
276
+ gridThemeClasses(props.theme, props.density),
277
+ );
278
+ const themeStyle = computed(() => gridThemeVars(props.theme) as CSSProperties);
186
279
 
187
280
  // 선언형 이벤트 구독 — events 맵의 각 키를 grid.on에 연결
188
281
  watch(
@@ -212,10 +305,18 @@ watchEffect(() => {
212
305
  if (props.data) grid.setData(props.data);
213
306
  });
214
307
  watchEffect(() => {
308
+ // 외부 grid 경로에서도 defaultColDef prop이 적용되도록 먼저 동기화 —
309
+ // undefined는 "미지정"이라 기존 기본값이 유지된다
310
+ grid.setDefaultColDef(props.defaultColDef);
215
311
  grid.setColumns(props.columns);
216
312
  });
217
313
  watchEffect(() => {
218
- if (props.height != null && props.rowHeight != null && props.rowHeight > 0) {
314
+ if (
315
+ props.domLayout !== "autoHeight" &&
316
+ props.height != null &&
317
+ props.rowHeight != null &&
318
+ props.rowHeight > 0
319
+ ) {
219
320
  grid.setVirtualScroll({
220
321
  rowHeight: props.rowHeight,
221
322
  viewportHeight: props.height,
@@ -244,6 +345,13 @@ watchEffect(() => {
244
345
  grid.setPostSort(props.postSort ?? null);
245
346
  grid.setBeforePaste(props.beforePaste ?? null);
246
347
  grid.setBeforeCopy(props.beforeCopy ?? null);
348
+ // 외부 grid prop 경로에서도 컨텍스트 메뉴 prop이 적용되도록
349
+ // 런타임 setter로 동기화한다
350
+ grid.setContextMenu(props.contextMenu ?? null);
351
+ grid.setHeaderContextMenu(props.headerContextMenu ?? null);
352
+ });
353
+ watchEffect(() => {
354
+ grid.setClipboardDelimiter(props.clipboardDelimiter ?? null);
247
355
  });
248
356
 
249
357
  // 가상 스크롤: 코어가 보정한 scrollTop을 DOM에 동기화 (키보드 scrollIntoView)
@@ -265,9 +373,7 @@ watch(
265
373
  (scrollEl.value ?? hostEl.value)
266
374
  ?.querySelector<HTMLElement>(
267
375
  `td[data-mg-row="${req.rowIndex}"]` +
268
- (req.columnIndex != null
269
- ? `[data-mg-col="${req.columnIndex}"]`
270
- : ""),
376
+ (req.columnIndex != null ? `[data-mg-col="${req.columnIndex}"]` : ""),
271
377
  )
272
378
  ?.scrollIntoView({ block: "nearest", inline: "nearest" });
273
379
  },
@@ -282,9 +388,11 @@ watchEffect(() => grid.setCellFlash(!!props.cellFlash));
282
388
  // copyFormatted prop → core 동기화
283
389
  watchEffect(() => grid.setCopyFormatted(!!props.copyFormatted));
284
390
  watchEffect(() => grid.setSingleClickEdit(!!props.singleClickEdit));
391
+ watchEffect(() => grid.setEditType(props.editType ?? "cell"));
285
392
 
286
393
  // 찾기 바 — findNext로 다음/이전 매치 순환 (Enter / Shift+Enter)
287
394
  const findInputEl = ref<HTMLInputElement | null>(null);
395
+ const replaceInputEl = ref<HTMLInputElement | null>(null);
288
396
  const findCount = ref("");
289
397
  // 찾기 옵션 — 대소문자 구분 / 셀 전체 일치 (타사 그리드 찾기 옵션 대응)
290
398
  const findCaseSensitive = ref(false);
@@ -298,7 +406,9 @@ function currentFindOpts() {
298
406
  function onFindOptChange() {
299
407
  const q = findInputEl.value?.value ?? "";
300
408
  grid.setFindQuery(q || null, currentFindOpts());
301
- findCount.value = q ? `${grid.findCells(q, currentFindOpts()).length}건` : "";
409
+ findCount.value = q
410
+ ? grid.locale.findResult(grid.findCells(q, currentFindOpts()).length)
411
+ : "";
302
412
  }
303
413
  // Vue2 템플릿은 TS 캐스트 미지원 — 체크박스 change는 스크립트 메서드로 처리
304
414
  function onFindCaseChange(e: Event) {
@@ -313,7 +423,7 @@ function goFind(backward: boolean) {
313
423
  const q = findInputEl.value?.value ?? "";
314
424
  grid.setFindQuery(q || null, currentFindOpts()); // 매치 셀 하이라이트
315
425
  const total = grid.findCells(q, currentFindOpts()).length;
316
- findCount.value = q ? `${total}건` : "";
426
+ findCount.value = q ? grid.locale.findResult(total) : "";
317
427
  if (!q || !total) return;
318
428
  const m = grid.findNext(q, { ...currentFindOpts(), backward });
319
429
  if (m) {
@@ -324,6 +434,25 @@ function goFind(backward: boolean) {
324
434
  ?.scrollIntoView({ block: "nearest", inline: "nearest" });
325
435
  }
326
436
  }
437
+ // 찾기 바 바꾸기 — 모든 매치를 바꿀 값으로 치환 (grid.replaceAll 경유)
438
+ function replaceAll() {
439
+ const q = findInputEl.value?.value ?? "";
440
+ if (!q) return;
441
+ const n = grid.replaceAll(
442
+ q,
443
+ replaceInputEl.value?.value ?? "",
444
+ currentFindOpts(),
445
+ );
446
+ findCount.value = grid.locale.replaceResult(n);
447
+ }
448
+ function onReplaceKeydown(e: KeyboardEvent) {
449
+ if (e.isComposing) return; // IME 조합 확정 Enter가 바꾸기로 오작동하지 않도록
450
+ if (e.key === "Enter") {
451
+ e.preventDefault();
452
+ replaceAll();
453
+ }
454
+ e.stopPropagation(); // 그리드 키 내비와 충돌 방지
455
+ }
327
456
  function onFindKeydown(e: KeyboardEvent) {
328
457
  if (e.isComposing) return; // IME 조합 확정 Enter가 매치 이동으로 오작동하지 않도록
329
458
  if (e.key === "Enter") {
@@ -335,7 +464,9 @@ function onFindKeydown(e: KeyboardEvent) {
335
464
  function onFindInput(e: Event) {
336
465
  const q = (e.target as HTMLInputElement).value;
337
466
  grid.setFindQuery(q || null, currentFindOpts()); // 입력 즉시 매치 하이라이트
338
- findCount.value = q ? `${grid.findCells(q, currentFindOpts()).length}건` : "";
467
+ findCount.value = q
468
+ ? grid.locale.findResult(grid.findCells(q, currentFindOpts()).length)
469
+ : "";
339
470
  }
340
471
 
341
472
  // 헤더 필터 드롭다운 — 엑셀 autofilter식 값 체크리스트 (한 번에 하나)
@@ -361,9 +492,7 @@ const filterDropCol = computed(() =>
361
492
  : null,
362
493
  );
363
494
  const filterDropAll = computed(() =>
364
- filterDropCol.value
365
- ? grid.getUniqueValues(filterDropCol.value.field)
366
- : [],
495
+ filterDropCol.value ? grid.getUniqueValues(filterDropCol.value.field) : [],
367
496
  );
368
497
  const filterDropActive = computed(() =>
369
498
  filterDropCol.value
@@ -396,7 +525,15 @@ function onFilterDropKeydown(e: KeyboardEvent) {
396
525
 
397
526
  // ── 피벗 필드 패널 — 필드 칩을 행/열/값 존으로 드래그해 피벗 구성 ──
398
527
  const PIVOT_DATA_TYPE = "application/x-mg-pivot";
399
- const PIVOT_AGGS: AggregateFn[] = ["sum", "avg", "min", "max", "count"];
528
+ const PIVOT_AGGS: BuiltInAggregateFn[] = [
529
+ "sum",
530
+ "avg",
531
+ "min",
532
+ "max",
533
+ "count",
534
+ "first",
535
+ "last",
536
+ ];
400
537
  const pivotDropZone = ref<string | null>(null);
401
538
  function pivotHeaderOf(field: string) {
402
539
  return (
@@ -405,7 +542,7 @@ function pivotHeaderOf(field: string) {
405
542
  }
406
543
  function onPivotAggChange(field: string, e: Event) {
407
544
  const v = (e.target as HTMLSelectElement).value;
408
- grid.setPivotValueAgg(field, v as AggregateFn);
545
+ grid.setPivotValueAgg(field, v as BuiltInAggregateFn);
409
546
  }
410
547
  function pivotChipsOf(zone: string) {
411
548
  const p = state.value.pivot;
@@ -454,7 +591,10 @@ function pivotDragField(e: DragEvent): string {
454
591
  }
455
592
  function pivotDragAccepts(e: DragEvent): boolean {
456
593
  const t = e.dataTransfer?.types;
457
- return !!t && (t.includes(PIVOT_DATA_TYPE) || t.includes("application/x-mg-column"));
594
+ return (
595
+ !!t &&
596
+ (t.includes(PIVOT_DATA_TYPE) || t.includes("application/x-mg-column"))
597
+ );
458
598
  }
459
599
  function onPivotZoneDragOver(zone: string, e: DragEvent) {
460
600
  if (!pivotDragAccepts(e)) return;
@@ -481,12 +621,17 @@ function onPivotChipDragOver(e: DragEvent) {
481
621
  e.stopPropagation();
482
622
  }
483
623
 
484
- // 행 높이 — 가상 스크롤은 고정, 아니면 autoRowHeight 추정치 적용
485
- function rowStyleOf(entry: AnyRow) {
486
- if (virtual.value && props.rowHeight)
487
- return { height: `${props.rowHeight}px` };
488
- const h = grid.getRowHeight(rowDataOf(entry));
489
- return h ? { height: `${h}px` } : undefined;
624
+ // 행 높이 + rowStyle — 가상 스크롤은 고정, 아니면 autoRowHeight 추정치 적용
625
+ function rowStyleOf(entry: AnyRow, rowIdx: number) {
626
+ const row = rowDataOf(entry);
627
+ const base: Record<string, string> = {};
628
+ const h =
629
+ virtual.value && props.rowHeight ? props.rowHeight : grid.getRowHeight(row);
630
+ if (h) base.height = `${h}px`;
631
+ // GridOptions/ColumnDef.rowStyle — kebab-case 맵 병합 (Vue :style이 그대로 적용)
632
+ const custom = grid.getRowStyle(row, entryIndexOf(entry, rowIdx));
633
+ if (custom) Object.assign(base, custom);
634
+ return Object.keys(base).length ? base : undefined;
490
635
  }
491
636
 
492
637
  // 그룹 패널 칩 — 클릭 시 해당 컬럼 그룹 해제
@@ -510,14 +655,37 @@ function onGroupPanelDrop(event: DragEvent) {
510
655
  groupDropOver.value = false;
511
656
  const field = event.dataTransfer?.getData("application/x-mg-column");
512
657
  if (field && !state.value.groupBy.includes(field)) {
513
- grid.setGroupBy([
514
- ...state.value.groupBy,
515
- field,
516
- ] as (keyof RowT & string)[]);
658
+ grid.setGroupBy([...state.value.groupBy, field] as (keyof RowT & string)[]);
517
659
  }
518
660
  }
519
661
 
520
662
  const virtual = computed(() => state.value.virtual);
663
+ const autoHeight = computed(() => props.domLayout === "autoHeight");
664
+
665
+ // autoPageSize — 뷰포트 높이/행 높이로 pageSize 자동 계산 (리사이즈 재계산)
666
+ let pageSizeObs: ResizeObserver | null = null;
667
+ onMounted(() => {
668
+ const rh = props.rowHeight;
669
+ if (!props.autoPageSize || !rh) return;
670
+ const sync = () => {
671
+ const host = hostEl.value;
672
+ if (!host) return;
673
+ const headH =
674
+ host.querySelector("thead")?.getBoundingClientRect().height ?? 0;
675
+ const pagerH =
676
+ host.querySelector(".mg-pager")?.getBoundingClientRect().height ?? 0;
677
+ const avail = (props.height ?? host.clientHeight) - headH - pagerH;
678
+ const size = Math.max(1, Math.floor(avail / rh));
679
+ const snap = grid.getSnapshot();
680
+ if (size !== snap.pageSize) grid.setPage(snap.pageIndex, size);
681
+ };
682
+ nextTick(sync);
683
+ if (typeof ResizeObserver !== "undefined") {
684
+ pageSizeObs = new ResizeObserver(sync);
685
+ if (hostEl.value) pageSizeObs.observe(hostEl.value);
686
+ }
687
+ });
688
+ onBeforeUnmount(() => pageSizeObs?.disconnect());
521
689
  // 그룹화 시: displayRows(그룹 헤더 포함)를 virtual 인덱스로 슬라이스
522
690
  type RowT = Record<string, unknown>;
523
691
  type AnyRow = DisplayRow<RowT> | RowT;
@@ -561,7 +729,10 @@ const activeFilterCount = computed(
561
729
  );
562
730
  const bottomOffset = computed(() =>
563
731
  virtual.value && props.rowHeight
564
- ? Math.max(0, virtual.value.totalHeight - virtual.value.endIndex * props.rowHeight)
732
+ ? Math.max(
733
+ 0,
734
+ virtual.value.totalHeight - virtual.value.endIndex * props.rowHeight,
735
+ )
565
736
  : 0,
566
737
  );
567
738
 
@@ -647,6 +818,211 @@ function onCellContextMenu(
647
818
  }
648
819
  }
649
820
 
821
+ // 터치 롱프레스 → contextmenu와 동일 동작 (헤더/셀 공용 트래커)
822
+ const lp = createLongPressTracker();
823
+
824
+ function onCellPointerDown(
825
+ e: PointerEvent,
826
+ rowIndex: number,
827
+ col: ColumnDef,
828
+ ): void {
829
+ lp.down(e, (x, y) => grid.openContextMenu(x, y, rowIndex, col.field));
830
+ }
831
+
832
+ function onHeaderPointerDown(e: PointerEvent, col: ColumnDef): void {
833
+ lp.down(e, (x, y) => grid.openHeaderContextMenu(x, y, col.field));
834
+ if (props.reorderable && col.movable !== false)
835
+ touchDrag.col.down(e, col.field);
836
+ }
837
+
838
+ // ── 터치 커스텀 DnD — iOS/Android는 HTML5 DnD가 없어 포인터 제스처로 보강 ──
839
+ const touchColField = ref<string | null>(null); // mg-col-dragging 표시용
840
+ let touchColFieldRaw: string | null = null;
841
+
842
+ /** 터치 드롭 대상 해석 — 컬럼 헤더/피벗 존/그룹 패널 */
843
+ function touchHitAt(target: Element | null) {
844
+ const root = hostEl.value;
845
+ const t = target as HTMLElement | null;
846
+ if (!root || !t?.closest) return null;
847
+ const zoneEl = t.closest<HTMLElement>(".mg-pivot-zone");
848
+ if (zoneEl && root.contains(zoneEl)) {
849
+ const chip = t.closest<HTMLElement>(".mg-pivot-chip");
850
+ const idx =
851
+ chip && zoneEl.contains(chip)
852
+ ? chip.getAttribute("data-mg-pivot-index")
853
+ : null;
854
+ return {
855
+ kind: "pivot" as const,
856
+ zone: zoneEl.getAttribute("data-mg-pivot-zone") ?? "",
857
+ index: idx != null ? Number(idx) : undefined,
858
+ };
859
+ }
860
+ const gp = t.closest<HTMLElement>(".mg-group-panel");
861
+ if (gp && root.contains(gp)) return { kind: "group" as const };
862
+ const th = t.closest<HTMLElement>("th[data-mg-field]");
863
+ if (th && root.contains(th))
864
+ return {
865
+ kind: "column" as const,
866
+ field: th.getAttribute("data-mg-field")!,
867
+ };
868
+ return null;
869
+ }
870
+
871
+ /** 포인터 아래 행의 삽입 갭 — td의 data-mg-row로 행 인덱스를 해석한다 */
872
+ function touchRowGapAt(target: Element | null, y: number): number | null {
873
+ const root = hostEl.value;
874
+ const t = target as HTMLElement | null;
875
+ let td = t?.closest?.("td[data-mg-row]") as HTMLElement | null;
876
+ if (!td)
877
+ td =
878
+ (t?.closest?.("tr") as HTMLElement | null)?.querySelector?.(
879
+ "td[data-mg-row]",
880
+ ) ?? null;
881
+ if (!root || !td || !root.contains(td)) return null;
882
+ const rowIndex = Number(td.getAttribute("data-mg-row"));
883
+ const tr = td.closest("tr");
884
+ if (Number.isNaN(rowIndex) || !tr) return null;
885
+ const rect = tr.getBoundingClientRect();
886
+ return y < rect.top + rect.height / 2 ? rowIndex : rowIndex + 1;
887
+ }
888
+
889
+ function applyTouchDrop(
890
+ hit: ReturnType<typeof touchHitAt>,
891
+ field: string,
892
+ ): void {
893
+ if (!hit || !field) return;
894
+ if (hit.kind === "pivot") {
895
+ if (hit.zone === "fields") grid.removePivotField(field);
896
+ else
897
+ grid.addPivotField(
898
+ hit.zone as PivotZone,
899
+ field,
900
+ hit.index != null ? { index: hit.index } : {},
901
+ );
902
+ } else if (hit.kind === "group") {
903
+ const snap = grid.getSnapshot();
904
+ if (!snap.groupBy.includes(field))
905
+ grid.setGroupBy([...snap.groupBy, field]);
906
+ } else if (hit.field !== field) {
907
+ grid.reorderColumn(field, hit.field);
908
+ }
909
+ }
910
+
911
+ function clearTouchDropMarks(): void {
912
+ dragOverField.value = null;
913
+ pivotDropZone.value = null;
914
+ groupDropOver.value = false;
915
+ }
916
+
917
+ const touchDrag = {
918
+ // 컬럼 헤더 — 수평 이동으로 확정 (th는 touch-action: pan-y)
919
+ col: createTouchDrag<string>("x", {
920
+ start: (field: string) => {
921
+ // 롱프레스 메뉴가 이미 열렸으면 드래그로 전환하지 않는다
922
+ if (grid.getSnapshot().contextMenu) return false;
923
+ lp.end();
924
+ touchColFieldRaw = field;
925
+ touchColField.value = field;
926
+ return true;
927
+ },
928
+ move: (_x: number, _y: number, target: Element | null) => {
929
+ const hit = touchHitAt(target);
930
+ dragOverField.value =
931
+ hit?.kind === "column" && hit.field !== touchColFieldRaw
932
+ ? hit.field
933
+ : null;
934
+ pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
935
+ groupDropOver.value = hit?.kind === "group";
936
+ },
937
+ up: (_x: number, _y: number, target: Element | null, field: string) => {
938
+ applyTouchDrop(touchHitAt(target), field);
939
+ clearTouchDropMarks();
940
+ touchColFieldRaw = null;
941
+ touchColField.value = null;
942
+ },
943
+ cancel: () => {
944
+ clearTouchDropMarks();
945
+ touchColFieldRaw = null;
946
+ touchColField.value = null;
947
+ },
948
+ }),
949
+ // 행 드래그 핸들 — 세로 이동으로 확정 (핸들은 touch-action: none)
950
+ row: createTouchDrag<number>("y", {
951
+ start: (rowIndex: number) => {
952
+ lp.end();
953
+ return grid.beginRowDrag(rowIndex);
954
+ },
955
+ move: (_x: number, y: number, target: Element | null) => {
956
+ const gap = touchRowGapAt(target, y);
957
+ if (gap != null) grid.updateRowDropPosition(gap);
958
+ },
959
+ up: () => grid.endRowDrag(true),
960
+ cancel: () => grid.endRowDrag(false),
961
+ }),
962
+ // 피벗 칩 — 아무 방향이든 이동으로 확정 (칩은 touch-action: none)
963
+ chip: createTouchDrag<string>("any", {
964
+ move: (_x: number, _y: number, target: Element | null) => {
965
+ const hit = touchHitAt(target);
966
+ pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
967
+ },
968
+ up: (_x: number, _y: number, target: Element | null, field: string) => {
969
+ const hit = touchHitAt(target);
970
+ pivotDropZone.value = null;
971
+ if (hit?.kind !== "pivot") return;
972
+ if (hit.zone === "fields") grid.removePivotField(field);
973
+ else
974
+ grid.addPivotField(
975
+ hit.zone as PivotZone,
976
+ field,
977
+ hit.index != null ? { index: hit.index } : {},
978
+ );
979
+ },
980
+ cancel: () => {
981
+ pivotDropZone.value = null;
982
+ },
983
+ }),
984
+ };
985
+
986
+ function onPivotChipPointerDown(field: string, e: PointerEvent): void {
987
+ e.stopPropagation();
988
+ touchDrag.chip.down(e, field);
989
+ }
990
+
991
+ function onRowDragPointerDown(e: PointerEvent, rowIndex: number): void {
992
+ e.stopPropagation();
993
+ if (rowDraggable.value) touchDrag.row.down(e, rowIndex);
994
+ }
995
+
996
+ // 포인터 추적을 document에 위임 — 드래그 중 소스 노드가 재생성돼도 계속된다
997
+ onMounted(() => {
998
+ const move = (e: PointerEvent) => {
999
+ lp.move(e);
1000
+ touchDrag.col.move(e);
1001
+ touchDrag.row.move(e);
1002
+ touchDrag.chip.move(e);
1003
+ };
1004
+ const up = (e: PointerEvent) => {
1005
+ lp.end();
1006
+ touchDrag.col.up(e);
1007
+ touchDrag.row.up(e);
1008
+ touchDrag.chip.up(e);
1009
+ };
1010
+ const cancel = () => {
1011
+ lp.end();
1012
+ touchDrag.col.cancel();
1013
+ touchDrag.row.cancel();
1014
+ touchDrag.chip.cancel();
1015
+ };
1016
+ document.addEventListener("pointermove", move);
1017
+ document.addEventListener("pointerup", up);
1018
+ document.addEventListener("pointercancel", cancel);
1019
+ onBeforeUnmount(() => {
1020
+ document.removeEventListener("pointermove", move);
1021
+ document.removeEventListener("pointerup", up);
1022
+ document.removeEventListener("pointercancel", cancel);
1023
+ });
1024
+ });
1025
+
650
1026
  function cellPosFromPoint(
651
1027
  x: number,
652
1028
  y: number,
@@ -658,16 +1034,22 @@ function cellPosFromPoint(
658
1034
  return Number.isNaN(row) || Number.isNaN(col) ? null : { row, col };
659
1035
  }
660
1036
 
661
- let fillSource: { startRow: number; endRow: number; startCol: number; endCol: number } | null = null;
1037
+ let fillSource: {
1038
+ startRow: number;
1039
+ endRow: number;
1040
+ startCol: number;
1041
+ endCol: number;
1042
+ } | null = null;
662
1043
 
663
- function onFillMouseDown(e: MouseEvent): void {
1044
+ function onFillPointerDown(e: PointerEvent): void {
664
1045
  e.preventDefault();
665
1046
  e.stopPropagation();
666
1047
  const src = state.value.selectedRange;
667
1048
  if (!src) return;
668
1049
  fillSource = { ...src };
669
- const onUp = (ev: MouseEvent) => {
670
- window.removeEventListener("mouseup", onUp);
1050
+ const onUp = (ev: PointerEvent) => {
1051
+ window.removeEventListener("pointerup", onUp);
1052
+ window.removeEventListener("pointercancel", onUp);
671
1053
  const source = fillSource;
672
1054
  fillSource = null;
673
1055
  const pos = cellPosFromPoint(ev.clientX, ev.clientY);
@@ -681,7 +1063,8 @@ function onFillMouseDown(e: MouseEvent): void {
681
1063
  grid.fillRange(source, target);
682
1064
  grid.setCellRange(target);
683
1065
  };
684
- window.addEventListener("mouseup", onUp);
1066
+ window.addEventListener("pointerup", onUp);
1067
+ window.addEventListener("pointercancel", onUp);
685
1068
  }
686
1069
 
687
1070
  function cellLinkHref(row: RowData, col: ColumnDef): string {
@@ -715,12 +1098,18 @@ function filterInputType(col: ColumnDef<Record<string, unknown>>) {
715
1098
  return t === "number" ? "number" : t === "date" ? "date" : "text";
716
1099
  }
717
1100
 
718
- function filterValueOf(col: ColumnDef<Record<string, unknown>>, key: "value" | "valueTo") {
1101
+ function filterValueOf(
1102
+ col: ColumnDef<Record<string, unknown>>,
1103
+ key: "value" | "valueTo",
1104
+ ) {
719
1105
  const f = state.value.filters[col.field];
720
1106
  return f ? f[key] || "" : "";
721
1107
  }
722
1108
 
723
- function updateFilter(col: ColumnDef<Record<string, unknown>>, patch: Partial<ColumnFilter>) {
1109
+ function updateFilter(
1110
+ col: ColumnDef<Record<string, unknown>>,
1111
+ patch: Partial<ColumnFilter>,
1112
+ ) {
724
1113
  const f = state.value.filters[col.field];
725
1114
  grid.setFilter(col.field, {
726
1115
  operator: filterOpOf(col),
@@ -730,13 +1119,20 @@ function updateFilter(col: ColumnDef<Record<string, unknown>>, patch: Partial<Co
730
1119
  });
731
1120
  }
732
1121
 
733
- function onFilterOpChange(col: ColumnDef<Record<string, unknown>>, event: Event) {
1122
+ function onFilterOpChange(
1123
+ col: ColumnDef<Record<string, unknown>>,
1124
+ event: Event,
1125
+ ) {
734
1126
  updateFilter(col, {
735
1127
  operator: (event.target as HTMLSelectElement).value as FilterOperator,
736
1128
  });
737
1129
  }
738
1130
 
739
- function onFilterInput(col: ColumnDef<Record<string, unknown>>, key: "value" | "valueTo", event: Event) {
1131
+ function onFilterInput(
1132
+ col: ColumnDef<Record<string, unknown>>,
1133
+ key: "value" | "valueTo",
1134
+ event: Event,
1135
+ ) {
740
1136
  updateFilter(col, { [key]: (event.target as HTMLInputElement).value });
741
1137
  }
742
1138
 
@@ -767,7 +1163,11 @@ function setAllCheckedOf(col: ColumnDef<Record<string, unknown>>) {
767
1163
  return !vals || vals.length >= setValuesOf(col).length;
768
1164
  }
769
1165
 
770
- function onSetToggle(col: ColumnDef<Record<string, unknown>>, v: string, event: Event) {
1166
+ function onSetToggle(
1167
+ col: ColumnDef<Record<string, unknown>>,
1168
+ v: string,
1169
+ event: Event,
1170
+ ) {
771
1171
  const checked = (event.target as HTMLInputElement).checked;
772
1172
  const all = setValuesOf(col);
773
1173
  const f = state.value.filters[col.field];
@@ -834,14 +1234,12 @@ const headerRows = computed<HeaderCell[][]>(() => {
834
1234
  );
835
1235
  const row2: HeaderCell[] = spans.flatMap((s) =>
836
1236
  s.groupId
837
- ? cols
838
- .slice(s.startIndex, s.startIndex + s.colSpan)
839
- .map((col, i) => ({
840
- kind: "col" as const,
841
- key: col.field,
842
- col,
843
- colIndex: s.startIndex + i,
844
- }))
1237
+ ? cols.slice(s.startIndex, s.startIndex + s.colSpan).map((col, i) => ({
1238
+ kind: "col" as const,
1239
+ key: col.field,
1240
+ col,
1241
+ colIndex: s.startIndex + i,
1242
+ }))
845
1243
  : [],
846
1244
  );
847
1245
  return row2.length > 0 ? [row1, row2] : [row1];
@@ -849,63 +1247,68 @@ const headerRows = computed<HeaderCell[][]>(() => {
849
1247
 
850
1248
  const headerRowSpan = computed(() => headerRows.value.length);
851
1249
 
852
- // ── 컬럼 리사이즈: document mousemove를 rAF로 스로틀 ──
1250
+ // ── 컬럼 리사이즈: document pointermove를 rAF로 스로틀 ──
1251
+ // pointerdown/move/up — 마우스·터치·펜 공통 경로 (핸들은 touch-action:none)
853
1252
  let resizeRaf = 0;
854
1253
  let pendingWidth: { field: string; width: number } | null = null;
855
1254
 
856
- function onResizeStart(col: ColumnDef, event: MouseEvent) {
1255
+ function onResizeStart(col: ColumnDef, event: PointerEvent) {
857
1256
  const th = (event.currentTarget as HTMLElement).closest("th");
858
1257
  const startWidth = th?.getBoundingClientRect().width ?? 0;
859
1258
  const startX = event.clientX;
860
1259
  const field = col.field;
861
1260
 
862
- const onMove = (ev: MouseEvent) => {
1261
+ const onMove = (ev: PointerEvent) => {
863
1262
  pendingWidth = { field, width: startWidth + (ev.clientX - startX) };
864
1263
  if (resizeRaf === 0) {
865
1264
  resizeRaf = requestAnimationFrame(() => {
866
1265
  resizeRaf = 0;
867
- if (pendingWidth) grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
1266
+ if (pendingWidth)
1267
+ grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
868
1268
  });
869
1269
  }
870
1270
  };
871
1271
  const onUp = () => {
872
- document.removeEventListener("mousemove", onMove);
873
- document.removeEventListener("mouseup", onUp);
1272
+ document.removeEventListener("pointermove", onMove);
1273
+ document.removeEventListener("pointerup", onUp);
1274
+ document.removeEventListener("pointercancel", onUp);
874
1275
  if (resizeRaf !== 0) {
875
1276
  cancelAnimationFrame(resizeRaf);
876
1277
  resizeRaf = 0;
877
1278
  }
878
- if (pendingWidth) grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
1279
+ if (pendingWidth)
1280
+ grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
879
1281
  pendingWidth = null;
880
1282
  };
881
- document.addEventListener("mousemove", onMove);
882
- document.addEventListener("mouseup", onUp);
1283
+ document.addEventListener("pointermove", onMove);
1284
+ document.addEventListener("pointerup", onUp);
1285
+ document.addEventListener("pointercancel", onUp);
883
1286
  }
884
1287
 
885
1288
  // ── 행 높이 리사이즈: 행 번호 셀 하단 핸들 드래그 → setRowHeight ──
886
- function onRowResizeStart(rowId: string, event: MouseEvent) {
1289
+ function onRowResizeStart(rowId: string, event: PointerEvent) {
887
1290
  event.preventDefault();
888
1291
  event.stopPropagation();
889
1292
  const tr = (event.currentTarget as HTMLElement).closest("tr");
890
1293
  const startHeight = tr?.getBoundingClientRect().height ?? 0;
891
1294
  const startY = event.clientY;
892
- const onMove = (ev: MouseEvent) => {
893
- grid.setRowHeight(
894
- rowId,
895
- Math.max(16, startHeight + (ev.clientY - startY)),
896
- );
1295
+ const onMove = (ev: PointerEvent) => {
1296
+ grid.setRowHeight(rowId, Math.max(16, startHeight + (ev.clientY - startY)));
897
1297
  };
898
1298
  const onUp = () => {
899
- document.removeEventListener("mousemove", onMove);
900
- document.removeEventListener("mouseup", onUp);
1299
+ document.removeEventListener("pointermove", onMove);
1300
+ document.removeEventListener("pointerup", onUp);
1301
+ document.removeEventListener("pointercancel", onUp);
901
1302
  };
902
- document.addEventListener("mousemove", onMove);
903
- document.addEventListener("mouseup", onUp);
1303
+ document.addEventListener("pointermove", onMove);
1304
+ document.addEventListener("pointerup", onUp);
1305
+ document.addEventListener("pointercancel", onUp);
904
1306
  }
905
1307
 
906
1308
  // 키보드 리사이즈 (방향키 ±10px)
907
1309
  function onResizerKeydown(col: ColumnDef, event: KeyboardEvent) {
908
- const delta = event.key === "ArrowLeft" ? -10 : event.key === "ArrowRight" ? 10 : 0;
1310
+ const delta =
1311
+ event.key === "ArrowLeft" ? -10 : event.key === "ArrowRight" ? 10 : 0;
909
1312
  if (delta === 0) return;
910
1313
  event.preventDefault();
911
1314
  const th = (event.currentTarget as HTMLElement).closest("th");
@@ -959,7 +1362,10 @@ const rowCount = computed(() => state.value.rows.length);
959
1362
  const dropGap = computed(() => {
960
1363
  const rd = state.value.rowDrag;
961
1364
  if (!rd || rd.dropIndex == null) return null;
962
- if (rd.dropIndex === rd.draggingIndex || rd.dropIndex === rd.draggingIndex + 1)
1365
+ if (
1366
+ rd.dropIndex === rd.draggingIndex ||
1367
+ rd.dropIndex === rd.draggingIndex + 1
1368
+ )
963
1369
  return null;
964
1370
  return rd.dropIndex;
965
1371
  });
@@ -990,7 +1396,10 @@ function rowStateOf(row: RowT | null | undefined) {
990
1396
  /** 변경(I/U/D) 행의 셀 유효성 에러 — required/validate 검사. 없으면 null. */
991
1397
  function cellErrorOf(entry: AnyRow, col: ColumnDef): string | null {
992
1398
  const row = rowDataOf(entry);
993
- if (!row || !rowStateOf(row)) return null;
1399
+ if (!row) return null;
1400
+ // setCellError 수동 마킹은 행 상태·validate 유무와 무관하게 표시한다
1401
+ if (grid.hasManualCellError(row, col)) return grid.getCellError(row, col);
1402
+ if (!rowStateOf(row)) return null;
994
1403
  if (!col.required && !col.validate) return null;
995
1404
  return grid.getCellError(row, col);
996
1405
  }
@@ -1179,7 +1588,13 @@ function onGridKeydown(event: KeyboardEvent) {
1179
1588
  return;
1180
1589
  }
1181
1590
  // 인쇄 가능한 문자 직접 입력 → 값을 교체하며 편집 진입
1182
- if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey && active) {
1591
+ if (
1592
+ event.key.length === 1 &&
1593
+ !event.ctrlKey &&
1594
+ !event.metaKey &&
1595
+ !event.altKey &&
1596
+ active
1597
+ ) {
1183
1598
  event.preventDefault();
1184
1599
  grid.startEditing(active.rowIndex, active.columnIndex, event.key);
1185
1600
  }
@@ -1228,10 +1643,12 @@ function entryIndexOf(entry: AnyRow, rowIdx: number) {
1228
1643
  return virtual.value ? virtual.value.startIndex + rowIdx : rowIdx;
1229
1644
  }
1230
1645
 
1231
- function rowKeyOf(entry: AnyRow) {
1232
- return isGroupRow(entry)
1233
- ? groupOf(entry).key
1234
- : grid.getRowId(rowDataOf(entry));
1646
+ function rowKeyOf(entry: AnyRow, rowIdx: number) {
1647
+ if (isGroupRow(entry)) return groupOf(entry).key;
1648
+ const row = rowDataOf(entry);
1649
+ // 서버 사이드 미로드(스파스) 행은 id가 없으므로 위치로 키잉 — getRowId(undefined) 크래시 방지
1650
+ if (row == null) return `skeleton-${rowIdx}`;
1651
+ return grid.getRowId(row);
1235
1652
  }
1236
1653
 
1237
1654
  function groupLabelOf(entry: AnyRow) {
@@ -1256,9 +1673,22 @@ function cellSpanOf(row: RowT, col: ColumnDef<RowT>) {
1256
1673
  return grid.getCellSpan(row, col);
1257
1674
  }
1258
1675
 
1259
- function isEditingCell(rowIndex: number, col: ColumnDef) {
1260
- const cell = state.value.editingCell;
1261
- return !!cell && cell.rowIndex === rowIndex && cell.columnKey === col.field;
1676
+ function isEditingCell(rowIndex: number, colIndex: number) {
1677
+ return grid.isEditing(rowIndex, colIndex);
1678
+ }
1679
+
1680
+ // fullRow 편집 — 셀별 보류 값/에러 (cell 모드면 단일 editValue/editError)
1681
+ function editValueOf(col: ColumnDef) {
1682
+ const s = state.value;
1683
+ if (s.editType === "fullRow" && s.editingValues)
1684
+ return s.editingValues[col.field];
1685
+ return s.editValue;
1686
+ }
1687
+ function editErrorOf(col: ColumnDef) {
1688
+ const s = state.value;
1689
+ if (s.editType === "fullRow" && s.editingErrors)
1690
+ return s.editingErrors[col.field] ?? null;
1691
+ return s.editError;
1262
1692
  }
1263
1693
 
1264
1694
  // 마우스 드래그 범위 선택
@@ -1275,7 +1705,13 @@ function onCellMouseDown(
1275
1705
  colIndex: number,
1276
1706
  col: ColumnDef,
1277
1707
  ) {
1278
- if (e.button !== 0 || isEditingCell(rowIndex, col)) return;
1708
+ if (e.button !== 0 || isEditingCell(rowIndex, colIndex)) return;
1709
+ // fullRow — 편집 행 안 클릭은 커밋/선택 변경 없이 통과
1710
+ if (
1711
+ state.value.editType === "fullRow" &&
1712
+ state.value.editingCell?.rowIndex === rowIndex
1713
+ )
1714
+ return;
1279
1715
  suppressCellClick = false;
1280
1716
  if (state.value.editingCell) grid.commitEditing();
1281
1717
  if (e.ctrlKey || e.metaKey) {
@@ -1306,6 +1742,11 @@ function editorContext(rowIndex: number, colIndex: number) {
1306
1742
  return grid.getEditorContext(rowIndex, colIndex) as CellEditorContext;
1307
1743
  }
1308
1744
 
1745
+ // editorOptions — 배열 또는 행별 함수(종속 콤보) 해석
1746
+ function editorOptionsOf(col: ColumnDef, row: RowT) {
1747
+ return grid.getEditorOptions(col, row);
1748
+ }
1749
+
1309
1750
  function editorInputType(col: ColumnDef) {
1310
1751
  return col.cellEditor === "number"
1311
1752
  ? "number"
@@ -1314,31 +1755,49 @@ function editorInputType(col: ColumnDef) {
1314
1755
  : "text";
1315
1756
  }
1316
1757
 
1317
- function onEditorInput(event: Event) {
1318
- grid.updateEditValue((event.target as HTMLInputElement | HTMLSelectElement).value);
1758
+ function onEditorInput(event: Event, col: ColumnDef) {
1759
+ grid.updateEditValue(
1760
+ (event.target as HTMLInputElement | HTMLSelectElement).value,
1761
+ col.field,
1762
+ );
1319
1763
  }
1320
1764
 
1321
1765
  // multiselect 에디터 — 선택된 옵션들을 배열로 저장
1322
- function isEditOptSelected(opt: string): boolean {
1323
- const v = state.value.editValue;
1766
+ function isEditOptSelected(opt: string, col: ColumnDef): boolean {
1767
+ const v = editValueOf(col);
1324
1768
  return Array.isArray(v) && (v as unknown[]).includes(opt);
1325
1769
  }
1326
1770
 
1327
- function onMultiselectChange(event: Event) {
1771
+ function onMultiselectChange(event: Event, col: ColumnDef) {
1328
1772
  const sel = event.target as HTMLSelectElement;
1329
- grid.updateEditValue(Array.from(sel.selectedOptions).map((o) => o.value));
1773
+ grid.updateEditValue(
1774
+ Array.from(sel.selectedOptions).map((o) => o.value),
1775
+ col.field,
1776
+ );
1777
+ }
1778
+
1779
+ // 라디오 에디터 — 선택 즉시 커밋 (fullRow에서는 보류 값만 반영)
1780
+ function onRadioPick(opt: string, col: ColumnDef) {
1781
+ grid.updateEditValue(opt, col.field);
1782
+ if (state.value.editType !== "fullRow") grid.commitEditing();
1783
+ }
1784
+
1785
+ // select 에디터 — 고르는 즉시 커밋 (fullRow에서는 보류 값만 반영)
1786
+ function onSelectPick(event: Event, col: ColumnDef) {
1787
+ grid.updateEditValue((event.target as HTMLSelectElement).value, col.field);
1788
+ if (state.value.editType !== "fullRow") grid.commitEditing();
1330
1789
  }
1331
1790
 
1332
- // 라디오 에디터 — 선택 즉시 커밋 (타사 그리드와 동일 UX)
1333
- function onRadioPick(opt: string, _rowIndex: number, _colIndex: number) {
1334
- grid.updateEditValue(opt);
1335
- grid.commitEditing();
1791
+ // date 에디터 — 날짜 선택(완성 입력) 즉시 커밋. text/number의 blur change는 무시
1792
+ function onDatePick(event: Event, col: ColumnDef) {
1793
+ if (col.cellEditor !== "date") return;
1794
+ onSelectPick(event, col);
1336
1795
  }
1337
1796
 
1338
1797
  // 커밋 후 이동 시 편집기 언마운트로 빠진 포커스를 그리드로 되돌린다
1339
1798
  function commitThenNavigate(
1340
- dir: "up" | "down" | "left" | "right" | "tabLeft" | "tabRight",
1341
- ) {
1799
+ dir: "up" | "down" | "left" | "right" | "tabLeft" | "tabRight",
1800
+ ) {
1342
1801
  if (grid.commitEditing()) {
1343
1802
  grid.navigateCell(dir);
1344
1803
  scrollEl.value?.focus();
@@ -1354,7 +1813,11 @@ function onTextareaKeydown(event: KeyboardEvent) {
1354
1813
  commitThenNavigate("down");
1355
1814
  } else if (event.key === "Tab") {
1356
1815
  event.preventDefault();
1357
- commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
1816
+ const dir = event.shiftKey ? "left" : "right";
1817
+ // fullRow — 행 안 다음 편집 셀로 포커스 이동, 끝이면 행 커밋
1818
+ if (state.value.editType === "fullRow" && grid.navigateEditingCell(dir))
1819
+ return;
1820
+ commitThenNavigate(dir === "left" ? "tabLeft" : "tabRight");
1358
1821
  } else if (event.key === "Escape") {
1359
1822
  event.preventDefault();
1360
1823
  grid.cancelEditing();
@@ -1373,20 +1836,30 @@ function onEditorKeydown(event: KeyboardEvent) {
1373
1836
  } else commitThenNavigate("down");
1374
1837
  } else if (event.key === "Tab") {
1375
1838
  event.preventDefault();
1376
- commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
1839
+ const dir = event.shiftKey ? "left" : "right";
1840
+ if (state.value.editType === "fullRow" && grid.navigateEditingCell(dir))
1841
+ return;
1842
+ commitThenNavigate(dir === "left" ? "tabLeft" : "tabRight");
1377
1843
  } else if (event.key === "Escape") {
1378
1844
  event.preventDefault();
1379
1845
  grid.cancelEditing();
1380
1846
  }
1381
1847
  }
1382
1848
 
1383
- // 편집 진입 시 에디터 포커스
1849
+ // 편집 진입 시 에디터 포커스 — fullRow에서는 포커스된 컬럼의 에디터를 찾는다
1384
1850
  watch(
1385
1851
  () => state.value.editingCell,
1386
1852
  async (cell) => {
1387
1853
  if (!cell) return;
1388
1854
  await nextTick();
1389
- scrollEl.value?.querySelector<HTMLElement>(".mg-editor")?.focus();
1855
+ const colIdx = state.value.visibleColumns.findIndex(
1856
+ (c) => c.field === cell.columnKey,
1857
+ );
1858
+ const target =
1859
+ scrollEl.value?.querySelector<HTMLElement>(
1860
+ `td[data-mg-col="${colIdx}"] .mg-editor`,
1861
+ ) ?? scrollEl.value?.querySelector<HTMLElement>(".mg-editor");
1862
+ target?.focus();
1390
1863
  },
1391
1864
  );
1392
1865
  </script>
@@ -1396,9 +1869,11 @@ watch(
1396
1869
  ref="hostEl"
1397
1870
  :class="[
1398
1871
  showOverlay ? 'mg-colctl-host' : undefined,
1399
- theme && `grid-theme-${theme}`,
1872
+ ...themeClasses,
1400
1873
  state.striped && 'mg-striped',
1874
+ isLoading && 'mg-loading-host',
1401
1875
  ]"
1876
+ :style="themeStyle"
1402
1877
  >
1403
1878
  <!-- 피벗 필드 패널 — 칩을 존 사이로 드래그해 디멘션 구성 -->
1404
1879
  <div v-if="pivotPanel" class="mg-pivot-panel">
@@ -1406,8 +1881,11 @@ watch(
1406
1881
  v-for="zone in ['fields', 'rows', 'columns', 'values']"
1407
1882
  :key="zone"
1408
1883
  :class="['mg-pivot-zone', pivotDropZone === zone && 'mg-drop-over']"
1884
+ :data-mg-pivot-zone="zone"
1409
1885
  @dragover="onPivotZoneDragOver(zone, $event)"
1410
- @dragleave="pivotDropZone = pivotDropZone === zone ? null : pivotDropZone"
1886
+ @dragleave="
1887
+ pivotDropZone = pivotDropZone === zone ? null : pivotDropZone
1888
+ "
1411
1889
  @drop="onPivotZoneDrop(zone, $event)"
1412
1890
  >
1413
1891
  <span class="mg-pivot-zone-label">{{ pivotZoneLabel(zone) }}</span>
@@ -1416,9 +1894,13 @@ watch(
1416
1894
  :key="chip.field"
1417
1895
  :class="[
1418
1896
  'mg-pivot-chip',
1419
- zone === 'fields' && pivotPlaced.has(chip.field) && 'mg-pivot-chip-placed',
1897
+ zone === 'fields' &&
1898
+ pivotPlaced.has(chip.field) &&
1899
+ 'mg-pivot-chip-placed',
1420
1900
  ]"
1421
1901
  draggable="true"
1902
+ :data-mg-pivot-index="i"
1903
+ @pointerdown="onPivotChipPointerDown(chip.field, $event)"
1422
1904
  @dragstart="onPivotChipDragStart(chip.field, $event)"
1423
1905
  @dragover="onPivotChipDragOver($event)"
1424
1906
  @drop="onPivotZoneDrop(zone, $event, i)"
@@ -1427,7 +1909,7 @@ watch(
1427
1909
  <select
1428
1910
  v-if="zone === 'values'"
1429
1911
  class="mg-pivot-agg"
1430
- :value="chip.agg"
1912
+ :value="typeof chip.agg === 'string' ? chip.agg : 'sum'"
1431
1913
  @click.stop
1432
1914
  @change="onPivotAggChange(chip.field, $event)"
1433
1915
  >
@@ -1459,16 +1941,15 @@ watch(
1459
1941
  <label class="mg-colctl-item">
1460
1942
  <input
1461
1943
  type="checkbox"
1462
- :checked="!filterDropActive || filterDropActive.length >= filterDropAll.length"
1944
+ :checked="
1945
+ !filterDropActive ||
1946
+ filterDropActive.length >= filterDropAll.length
1947
+ "
1463
1948
  @change="grid.setFilter(filterDropCol.field, null)"
1464
1949
  />
1465
1950
  {{ state.locale.setFilterAll }}
1466
1951
  </label>
1467
- <label
1468
- v-for="v in filterDropAll"
1469
- :key="v"
1470
- class="mg-colctl-item"
1471
- >
1952
+ <label v-for="v in filterDropAll" :key="v" class="mg-colctl-item">
1472
1953
  <input
1473
1954
  type="checkbox"
1474
1955
  :checked="filterDropChecked(v)"
@@ -1485,7 +1966,7 @@ watch(
1485
1966
  ref="findInputEl"
1486
1967
  type="search"
1487
1968
  class="mg-find-input"
1488
- placeholder="셀 찾기…"
1969
+ :placeholder="state.locale.findPlaceholder"
1489
1970
  @keydown="onFindKeydown"
1490
1971
  @input="onFindInput"
1491
1972
  />
@@ -1506,10 +1987,24 @@ watch(
1506
1987
  {{ state.locale.findWholeCell }}
1507
1988
  </label>
1508
1989
  <button type="button" class="mg-find-btn" @click="goFind(true)">
1509
- ▲ 이전
1990
+ {{ state.locale.findPrev }}
1510
1991
  </button>
1511
1992
  <button type="button" class="mg-find-btn" @click="goFind(false)">
1512
- ▼ 다음
1993
+ {{ state.locale.findNext }}
1994
+ </button>
1995
+ <input
1996
+ ref="replaceInputEl"
1997
+ type="text"
1998
+ class="mg-replace-input"
1999
+ :placeholder="state.locale.replacePlaceholder"
2000
+ @keydown="onReplaceKeydown"
2001
+ />
2002
+ <button
2003
+ type="button"
2004
+ class="mg-find-btn mg-replace-all"
2005
+ @click="replaceAll"
2006
+ >
2007
+ {{ state.locale.replaceAllLabel }}
1513
2008
  </button>
1514
2009
  <span class="mg-find-count">{{ findCount }}</span>
1515
2010
  </div>
@@ -1593,270 +2088,176 @@ watch(
1593
2088
  </div>
1594
2089
  <div
1595
2090
  ref="scrollEl"
1596
- :class="{ 'mg-scroll': virtual || hasPinned || hasAppend }"
2091
+ :class="{
2092
+ 'mg-scroll': (virtual || hasPinned || hasAppend) && !autoHeight,
2093
+ }"
1597
2094
  :style="
1598
- (virtual || (hasAppend && height))
1599
- ? { height: `${height}px`, overflow: 'auto' }
1600
- : hasPinned || hasAppend
1601
- ? { overflowX: 'auto', overflowY: height ? undefined : 'auto' }
1602
- : undefined
2095
+ autoHeight
2096
+ ? undefined
2097
+ : virtual || (hasAppend && height)
2098
+ ? { height: `${height}px`, overflow: 'auto' }
2099
+ : hasPinned || hasAppend
2100
+ ? { overflowX: 'auto', overflowY: height ? undefined : 'auto' }
2101
+ : undefined
1603
2102
  "
1604
2103
  @scroll="onScroll"
1605
2104
  >
1606
- <table
1607
- class="mg-table"
1608
- role="grid"
1609
- tabindex="0"
1610
- :style="{ minWidth: `${tableMinWidth}px` }"
1611
- @keydown="onGridKeydown"
1612
- >
1613
- <colgroup>
1614
- <col v-if="rowStatus" class="mg-col-status" />
1615
- <col v-if="rowCheckboxes" class="mg-col-check" />
1616
- <col v-if="rowNumbers" class="mg-col-rownum" />
1617
- <col
1618
- v-for="col in state.visibleColumns"
1619
- :key="col.field"
1620
- :style="{ width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px` }"
1621
- />
1622
- </colgroup>
1623
- <thead role="rowgroup">
1624
- <tr
1625
- v-for="(row, rowIdx) in headerRows"
1626
- :key="rowIdx"
1627
- :style="headerTrStyle"
1628
- >
1629
- <th
1630
- v-if="rowStatus && rowIdx === 0"
1631
- :rowspan="headerRowSpan"
1632
- class="mg-status-cell"
1633
- title="행 상태 — I: 입력, U: 수정, D: 삭제"
1634
- >
1635
- 상태
1636
- </th>
1637
- <th
1638
- v-if="rowCheckboxes && rowIdx === 0"
1639
- :rowspan="headerRowSpan"
1640
- class="mg-check-cell"
2105
+ <table
2106
+ class="mg-table"
2107
+ role="grid"
2108
+ tabindex="0"
2109
+ :style="{ minWidth: `${tableMinWidth}px` }"
2110
+ @keydown="onGridKeydown"
2111
+ >
2112
+ <colgroup>
2113
+ <col v-if="rowStatus" class="mg-col-status" />
2114
+ <col v-if="rowCheckboxes" class="mg-col-check" />
2115
+ <col v-if="rowNumbers" class="mg-col-rownum" />
2116
+ <col
2117
+ v-for="col in state.visibleColumns"
2118
+ :key="col.field"
2119
+ :style="{ width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px` }"
2120
+ />
2121
+ </colgroup>
2122
+ <thead role="rowgroup">
2123
+ <tr
2124
+ v-for="(row, rowIdx) in headerRows"
2125
+ :key="rowIdx"
2126
+ :style="headerTrStyle"
1641
2127
  >
1642
- <input
1643
- type="checkbox"
1644
- :aria-label="state.locale.selectAllRowsAria"
1645
- :checked="grid.isAllSelected()"
1646
- :indeterminate.prop="grid.isSomeSelected()"
1647
- @click.stop
1648
- @change="grid.toggleAllRows()"
1649
- />
1650
- </th>
1651
- <th
1652
- v-if="rowNumbers && rowIdx === 0"
1653
- :rowspan="headerRowSpan"
1654
- class="mg-rownum-cell"
1655
- ></th>
1656
- <template v-for="cell in row">
1657
2128
  <th
1658
- v-if="cell.kind === 'group'"
1659
- :key="cell.key"
1660
- :colspan="cell.colSpan"
1661
- class="mg-colgroup"
2129
+ v-if="rowStatus && rowIdx === 0"
2130
+ :rowspan="headerRowSpan"
2131
+ class="mg-status-cell"
2132
+ title="행 상태 — I: 입력, U: 수정, D: 삭제"
1662
2133
  >
1663
- {{ cell.header }}
2134
+ 상태
1664
2135
  </th>
1665
2136
  <th
1666
- v-else
1667
- :key="cell.key"
1668
- :rowspan="cell.rowSpan"
1669
- :style="
1670
- cell.col.pinned
1671
- ? pinStyleOf(cell.col)
1672
- : cell.col.width
1673
- ? { width: `${cell.col.width}px` }
1674
- : undefined
1675
- "
1676
- :class="[
1677
- {
1678
- 'mg-sortable': cell.col.sortable !== false,
1679
- 'mg-col-dragover': dragOverField === cell.col.field,
1680
- 'mg-pinned': !!cell.col.pinned,
1681
- 'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
1682
- 'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
1683
- },
1684
- (cell.col.headerAlign ?? cell.col.align) &&
1685
- (cell.col.headerAlign ?? cell.col.align) !== 'left'
1686
- ? `mg-halign-${cell.col.headerAlign ?? cell.col.align}`
1687
- : '',
1688
- grid.getHeaderClass(cell.col),
1689
- ]"
1690
- :title="cell.col.headerTooltip"
1691
- :aria-sort="sortAria(cell.col.field)"
1692
- :draggable="reorderable && cell.col.movable !== false"
1693
- @dragstart="onDragStart(cell.col, $event)"
1694
- @dragover="onDragOver(cell.col, $event)"
1695
- @drop="onDrop(cell.col, $event)"
1696
- @dragend="onDragEnd"
1697
- @click="grid.toggleSort(cell.col.field, $event.shiftKey)"
1698
- @contextmenu="onHeaderContextMenu($event, cell.col)"
2137
+ v-if="rowCheckboxes && rowIdx === 0"
2138
+ :rowspan="headerRowSpan"
2139
+ class="mg-check-cell"
1699
2140
  >
1700
2141
  <input
1701
- v-if="cell.col.cellEditor === 'checkbox' && cell.col.headerCheckbox"
1702
2142
  type="checkbox"
1703
- class="mg-header-checkbox"
1704
- :aria-label="`${cell.col.header || cell.col.field} 전체 체크`"
1705
- :checked="grid.checkboxColumnState(cell.col) === 'all'"
1706
- :indeterminate.prop="grid.checkboxColumnState(cell.col) === 'some'"
2143
+ :aria-label="state.locale.selectAllRowsAria"
2144
+ :checked="grid.isAllSelected()"
2145
+ :indeterminate.prop="grid.isSomeSelected()"
1707
2146
  @click.stop
1708
- @change="grid.toggleAllChecked(cell.col)"
2147
+ @change="grid.toggleAllRows()"
1709
2148
  />
1710
- {{ cell.col.header || cell.col.field }}
1711
- <span v-if="cell.col.required" class="mg-required-mark">*</span>
1712
- <span v-if="sortArrowOf(cell.col.field)" class="mg-sort-arrow">
1713
- {{ sortArrowOf(cell.col.field) }}
1714
- </span>
1715
- <span v-if="sortPriorityOf(cell.col.field)" class="mg-sort-priority">
1716
- {{ sortPriorityOf(cell.col.field) }}
1717
- </span>
1718
- <button
1719
- v-if="headerFilters && cell.col.filterable"
1720
- type="button"
2149
+ </th>
2150
+ <th
2151
+ v-if="rowNumbers && rowIdx === 0"
2152
+ :rowspan="headerRowSpan"
2153
+ class="mg-rownum-cell"
2154
+ ></th>
2155
+ <template v-for="cell in row">
2156
+ <th
2157
+ v-if="cell.kind === 'group'"
2158
+ :key="cell.key"
2159
+ :colspan="cell.colSpan"
2160
+ class="mg-colgroup"
2161
+ >
2162
+ {{ cell.header }}
2163
+ </th>
2164
+ <th
2165
+ v-else
2166
+ :key="cell.key"
2167
+ :rowspan="cell.rowSpan"
2168
+ :style="
2169
+ cell.col.pinned
2170
+ ? pinStyleOf(cell.col)
2171
+ : cell.col.width
2172
+ ? { width: `${cell.col.width}px` }
2173
+ : undefined
2174
+ "
1721
2175
  :class="[
1722
- 'mg-header-filter-btn',
1723
- state.filters[cell.col.field] && 'mg-active',
2176
+ {
2177
+ 'mg-sortable': cell.col.sortable !== false,
2178
+ 'mg-col-dragover': dragOverField === cell.col.field,
2179
+ 'mg-col-dragging': touchColField === cell.col.field,
2180
+ 'mg-pinned': !!cell.col.pinned,
2181
+ 'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
2182
+ 'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
2183
+ },
2184
+ (cell.col.headerAlign ?? cell.col.align) &&
2185
+ (cell.col.headerAlign ?? cell.col.align) !== 'left'
2186
+ ? `mg-halign-${cell.col.headerAlign ?? cell.col.align}`
2187
+ : '',
2188
+ grid.getHeaderClass(cell.col),
1724
2189
  ]"
1725
- :aria-label="`${cell.col.header || cell.col.field} 필터`"
1726
- @click="toggleFilterDrop(cell.col, $event)"
2190
+ :title="cell.col.headerTooltip"
2191
+ :aria-sort="sortAria(cell.col.field)"
2192
+ :draggable="reorderable && cell.col.movable !== false"
2193
+ @dragstart="onDragStart(cell.col, $event)"
2194
+ @dragover="onDragOver(cell.col, $event)"
2195
+ @drop="onDrop(cell.col, $event)"
2196
+ @dragend="onDragEnd"
2197
+ @click="grid.toggleSort(cell.col.field, $event.shiftKey)"
2198
+ @contextmenu="onHeaderContextMenu($event, cell.col)"
2199
+ :data-mg-field="cell.col.field"
2200
+ @pointerdown="onHeaderPointerDown($event, cell.col)"
1727
2201
  >
1728
- ▾
1729
- </button>
1730
- <button
1731
- v-if="resizable && cell.col.resizable !== false"
1732
- type="button"
1733
- class="mg-resizer"
1734
- :aria-label="`${cell.col.field} 너비 조절`"
1735
- @mousedown.stop.prevent="onResizeStart(cell.col, $event)"
1736
- @dblclick.stop="grid.autoSizeColumn(cell.col.field)"
1737
- @keydown.stop="onResizerKeydown(cell.col, $event)"
1738
- @click.stop
1739
- />
1740
- </th>
1741
- </template>
1742
- </tr>
1743
- <tr v-if="hasFilterRow" class="mg-filter-row">
1744
- <th v-if="rowStatus" class="mg-status-cell" />
1745
- <th v-if="rowCheckboxes" class="mg-check-cell" />
1746
- <th v-if="rowNumbers" class="mg-rownum-cell" />
1747
- <th
1748
- v-for="(col, colIndex) in state.visibleColumns"
1749
- :key="col.field"
1750
- :class="{
1751
- 'mg-pinned': !!col.pinned,
1752
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
1753
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
1754
- }"
1755
- :style="pinStyleOf(col)"
1756
- >
1757
- <div v-if="col.filterable" class="mg-filter-cell">
1758
- <details v-if="isSetFilter(col)" class="mg-setfilter">
1759
- <summary>{{ setFilterLabel(col) }}</summary>
1760
- <div class="mg-setfilter-panel">
1761
- <label class="mg-setfilter-item">
1762
- <input
1763
- type="checkbox"
1764
- :checked="setAllCheckedOf(col)"
1765
- @change="grid.setFilter(col.field, null)"
1766
- />
1767
- {{ state.locale.setFilterAll }}
1768
- </label>
1769
- <label
1770
- v-for="v in setValuesOf(col)"
1771
- :key="v"
1772
- class="mg-setfilter-item"
1773
- >
1774
- <input
1775
- type="checkbox"
1776
- :checked="setCheckedOf(col, v)"
1777
- @change="onSetToggle(col, v, $event)"
1778
- />
1779
- {{ v }}
1780
- </label>
1781
- </div>
1782
- </details>
1783
- <template v-else>
1784
- <select
1785
- class="mg-filter-op"
1786
- :value="filterOpOf(col)"
1787
- @change="onFilterOpChange(col, $event)"
1788
- >
1789
- <option v-for="op in filterOpsOf(col)" :key="op" :value="op">
1790
- {{ FILTER_OPERATOR_LABELS[op] }}
1791
- </option>
1792
- </select>
1793
2202
  <input
1794
- class="mg-filter-input"
1795
- :type="filterInputType(col)"
1796
- :value="filterValueOf(col, 'value')"
1797
- :placeholder="`${col.header || col.field} 필터`"
1798
- @input="onFilterInput(col, 'value', $event)"
2203
+ v-if="
2204
+ cell.col.cellEditor === 'checkbox' &&
2205
+ cell.col.headerCheckbox
2206
+ "
2207
+ type="checkbox"
2208
+ class="mg-header-checkbox"
2209
+ :aria-label="`${cell.col.header || cell.col.field} 전체 체크`"
2210
+ :checked="grid.checkboxColumnState(cell.col) === 'all'"
2211
+ :indeterminate.prop="
2212
+ grid.checkboxColumnState(cell.col) === 'some'
2213
+ "
2214
+ :disabled="!grid.isCheckboxColumnEditable(cell.col)"
2215
+ @click.stop
2216
+ @change="grid.toggleAllChecked(cell.col)"
1799
2217
  />
1800
- <input
1801
- v-if="filterOpOf(col) === 'inRange'"
1802
- class="mg-filter-input mg-filter-to"
1803
- :type="filterInputType(col)"
1804
- :value="filterValueOf(col, 'valueTo')"
1805
- :placeholder="state.locale.rangeEndPlaceholder"
1806
- @input="onFilterInput(col, 'valueTo', $event)"
2218
+ {{ cell.col.header || cell.col.field }}
2219
+ <span v-if="cell.col.required" class="mg-required-mark">*</span>
2220
+ <span v-if="sortArrowOf(cell.col.field)" class="mg-sort-arrow">
2221
+ {{ sortArrowOf(cell.col.field) }}
2222
+ </span>
2223
+ <span
2224
+ v-if="sortPriorityOf(cell.col.field)"
2225
+ class="mg-sort-priority"
2226
+ >
2227
+ {{ sortPriorityOf(cell.col.field) }}
2228
+ </span>
2229
+ <button
2230
+ v-if="headerFilters && cell.col.filterable"
2231
+ type="button"
2232
+ :class="[
2233
+ 'mg-header-filter-btn',
2234
+ state.filters[cell.col.field] && 'mg-active',
2235
+ ]"
2236
+ :aria-label="`${cell.col.header || cell.col.field} 필터`"
2237
+ @click="toggleFilterDrop(cell.col, $event)"
2238
+ >
2239
+ ▾
2240
+ </button>
2241
+ <button
2242
+ v-if="resizable && cell.col.resizable !== false"
2243
+ type="button"
2244
+ class="mg-resizer"
2245
+ :aria-label="`${cell.col.field} 너비 조절`"
2246
+ @pointerdown.stop.prevent="onResizeStart(cell.col, $event)"
2247
+ @dblclick.stop="grid.autoSizeColumn(cell.col.field)"
2248
+ @keydown.stop="onResizerKeydown(cell.col, $event)"
2249
+ @click.stop
1807
2250
  />
1808
- </template>
1809
- </div>
1810
- </th>
1811
- </tr>
1812
- </thead>
1813
- <tbody role="rowgroup">
1814
- <tr
1815
- v-for="(prow, pIdx) in state.pinnedTopRows"
1816
- :key="`pin-top-${pIdx}`"
1817
- class="mg-pinned-top-row"
1818
- >
1819
- <td v-if="rowStatus" class="mg-status-cell" />
1820
- <td v-if="rowCheckboxes" class="mg-check-cell" />
1821
- <td v-if="rowNumbers" class="mg-rownum-cell" />
1822
- <td
1823
- v-for="(col, colIndex) in state.visibleColumns"
1824
- :key="col.field"
1825
- :class="{
1826
- 'mg-pinned': !!col.pinned,
1827
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
1828
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
1829
- }"
1830
- :style="pinStyleOf(col)"
1831
- >
1832
- {{ grid.getCellText(prow, col) }}
1833
- </td>
1834
- </tr>
1835
- <tr
1836
- v-if="virtual && virtual.startOffset > 0"
1837
- class="mg-spacer"
1838
- aria-hidden="true"
1839
- >
1840
- <td :colspan="colSpan" :style="{ height: `${virtual.startOffset}px`, padding: 0 }" />
1841
- </tr>
1842
- <tr v-if="bodyRows.length === 0">
1843
- <td class="mg-empty" :colspan="colSpan">{{ state.locale.noRows }}</td>
1844
- </tr>
1845
- <template v-for="(entry, rowIdx) in bodyRows">
1846
- <!-- 그룹 헤더 행 -->
1847
- <tr
1848
- v-if="isGroupRow(entry)"
1849
- :key="rowKeyOf(entry)"
1850
- class="mg-group-row"
1851
- @click="onToggleGroup(entry)"
1852
- >
1853
- <td v-if="rowStatus" class="mg-status-cell" />
1854
- <td v-if="rowCheckboxes" class="mg-check-cell" />
1855
- <td v-if="rowNumbers" class="mg-rownum-cell" />
1856
- <td
2251
+ </th>
2252
+ </template>
2253
+ </tr>
2254
+ <tr v-if="hasFilterRow" class="mg-filter-row">
2255
+ <th v-if="rowStatus" class="mg-status-cell" />
2256
+ <th v-if="rowCheckboxes" class="mg-check-cell" />
2257
+ <th v-if="rowNumbers" class="mg-rownum-cell" />
2258
+ <th
1857
2259
  v-for="(col, colIndex) in state.visibleColumns"
1858
2260
  :key="col.field"
1859
- class="mg-group-cell"
1860
2261
  :class="{
1861
2262
  'mg-pinned': !!col.pinned,
1862
2263
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -1864,35 +2265,78 @@ watch(
1864
2265
  }"
1865
2266
  :style="pinStyleOf(col)"
1866
2267
  >
1867
- <span
1868
- v-if="colIndex === 0"
1869
- class="mg-group-label"
1870
- :style="{ paddingLeft: `${groupOf(entry).depth * 16}px` }"
1871
- >
1872
- <span class="mg-group-toggle">
1873
- {{ groupOf(entry).expanded ? "▾" : "▸" }}
1874
- </span>
1875
- <strong>{{ groupLabelOf(entry) }}</strong>
1876
- <span class="mg-group-count">({{ groupOf(entry).rowCount }})</span>
1877
- </span>
1878
- <span v-else-if="groupAggOf(entry, col)" class="mg-agg">
1879
- {{ groupAggOf(entry, col) }}
1880
- </span>
1881
- </td>
2268
+ <div v-if="col.filterable" class="mg-filter-cell">
2269
+ <details v-if="isSetFilter(col)" class="mg-setfilter">
2270
+ <summary>{{ setFilterLabel(col) }}</summary>
2271
+ <div class="mg-setfilter-panel">
2272
+ <label class="mg-setfilter-item">
2273
+ <input
2274
+ type="checkbox"
2275
+ :checked="setAllCheckedOf(col)"
2276
+ @change="grid.setFilter(col.field, null)"
2277
+ />
2278
+ {{ state.locale.setFilterAll }}
2279
+ </label>
2280
+ <label
2281
+ v-for="v in setValuesOf(col)"
2282
+ :key="v"
2283
+ class="mg-setfilter-item"
2284
+ >
2285
+ <input
2286
+ type="checkbox"
2287
+ :checked="setCheckedOf(col, v)"
2288
+ @change="onSetToggle(col, v, $event)"
2289
+ />
2290
+ {{ v }}
2291
+ </label>
2292
+ </div>
2293
+ </details>
2294
+ <template v-else>
2295
+ <select
2296
+ class="mg-filter-op"
2297
+ :value="filterOpOf(col)"
2298
+ @change="onFilterOpChange(col, $event)"
2299
+ >
2300
+ <option
2301
+ v-for="op in filterOpsOf(col)"
2302
+ :key="op"
2303
+ :value="op"
2304
+ >
2305
+ {{ FILTER_OPERATOR_LABELS[op] }}
2306
+ </option>
2307
+ </select>
2308
+ <input
2309
+ class="mg-filter-input"
2310
+ :type="filterInputType(col)"
2311
+ :value="filterValueOf(col, 'value')"
2312
+ :placeholder="`${col.header || col.field} 필터`"
2313
+ @input="onFilterInput(col, 'value', $event)"
2314
+ />
2315
+ <input
2316
+ v-if="filterOpOf(col) === 'inRange'"
2317
+ class="mg-filter-input mg-filter-to"
2318
+ :type="filterInputType(col)"
2319
+ :value="filterValueOf(col, 'valueTo')"
2320
+ :placeholder="state.locale.rangeEndPlaceholder"
2321
+ @input="onFilterInput(col, 'valueTo', $event)"
2322
+ />
2323
+ </template>
2324
+ </div>
2325
+ </th>
1882
2326
  </tr>
1883
- <!-- 그룹 소계 행 -->
2327
+ </thead>
2328
+ <tbody role="rowgroup">
1884
2329
  <tr
1885
- v-else-if="isSubtotalRow(entry)"
1886
- :key="rowKeyOf(entry)"
1887
- class="mg-subtotal-row"
2330
+ v-for="(prow, pIdx) in state.pinnedTopRows"
2331
+ :key="`pin-top-${pIdx}`"
2332
+ class="mg-pinned-top-row"
1888
2333
  >
1889
2334
  <td v-if="rowStatus" class="mg-status-cell" />
1890
2335
  <td v-if="rowCheckboxes" class="mg-check-cell" />
1891
- <td v-if="rowNumbers" class="mg-rownum-cell" />
2336
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
1892
2337
  <td
1893
2338
  v-for="(col, colIndex) in state.visibleColumns"
1894
2339
  :key="col.field"
1895
- class="mg-subtotal-cell"
1896
2340
  :class="{
1897
2341
  'mg-pinned': !!col.pinned,
1898
2342
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -1900,434 +2344,656 @@ watch(
1900
2344
  }"
1901
2345
  :style="pinStyleOf(col)"
1902
2346
  >
1903
- <span
1904
- v-if="colIndex === 0"
1905
- class="mg-subtotal-label"
1906
- :style="{ paddingLeft: `${groupOf(entry).depth * 16}px` }"
1907
- >
1908
- {{ state.locale.subtotalLabel }}: {{ groupLabelOf(entry) }}
1909
- </span>
1910
- <span v-else-if="groupAggOf(entry, col)" class="mg-agg">
1911
- {{ groupAggOf(entry, col) }}
1912
- </span>
2347
+ {{ grid.getCellText(prow, col) }}
1913
2348
  </td>
1914
2349
  </tr>
1915
- <!-- 서버 사이드 미로드 행 → 스켈레톤 -->
1916
2350
  <tr
1917
- v-else-if="rowDataOf(entry) == null"
1918
- :key="rowKeyOf(entry)"
1919
- class="mg-skeleton-row"
2351
+ v-if="virtual && virtual.startOffset > 0"
2352
+ class="mg-spacer"
1920
2353
  aria-hidden="true"
1921
2354
  >
1922
- <td v-if="rowStatus" class="mg-status-cell" />
1923
- <td v-if="rowCheckboxes" class="mg-check-cell" />
1924
- <td v-if="rowNumbers" class="mg-rownum-cell" />
1925
2355
  <td
1926
- v-for="(col, colIndex) in state.visibleColumns"
1927
- :key="col.field"
1928
- :class="{
1929
- 'mg-pinned': !!col.pinned,
1930
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
1931
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
1932
- }"
1933
- :style="pinStyleOf(col)"
1934
- >
1935
- <span class="mg-skeleton-bar" />
2356
+ :colspan="colSpan"
2357
+ :style="{ height: `${virtual.startOffset}px`, padding: 0 }"
2358
+ />
2359
+ </tr>
2360
+ <tr v-if="bodyRows.length === 0">
2361
+ <td class="mg-empty" :colspan="colSpan">
2362
+ {{ state.locale.noRows }}
1936
2363
  </td>
1937
2364
  </tr>
1938
- <!-- 리프(데이터) 행 -->
1939
- <tr
1940
- v-else
1941
- :key="rowKeyOf(entry)"
1942
- role="row"
1943
- :aria-selected="state.selectedRowIds.has(grid.getRowId(rowDataOf(entry)))"
1944
- :class="rowClassOf(entry, rowIdx)"
1945
- :style="rowStyleOf(entry)"
1946
- @click="selectable && grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))"
1947
- @dragover="onRowDragOver(entryIndexOf(entry, rowIdx), $event)"
1948
- @drop="onRowDrop($event)"
1949
- >
1950
- <td
1951
- v-if="rowStatus"
1952
- class="mg-status-cell"
1953
- :class="
1954
- rowStateOf(rowDataOf(entry))
1955
- ? `mg-status-${rowStateOf(rowDataOf(entry))}`
1956
- : undefined
1957
- "
2365
+ <template v-for="(entry, rowIdx) in bodyRows">
2366
+ <!-- 그룹 헤더 행 -->
2367
+ <tr
2368
+ v-if="isGroupRow(entry)"
2369
+ :key="rowKeyOf(entry, rowIdx)"
2370
+ class="mg-group-row"
2371
+ @click="onToggleGroup(entry)"
1958
2372
  >
1959
- {{ rowStateOf(rowDataOf(entry)) ?? "" }}
1960
- </td>
1961
- <td
1962
- v-if="rowCheckboxes"
1963
- class="mg-check-cell"
1964
- @click.stop
2373
+ <td v-if="rowStatus" class="mg-status-cell" />
2374
+ <td v-if="rowCheckboxes" class="mg-check-cell" />
2375
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
2376
+ <td
2377
+ v-for="(col, colIndex) in state.visibleColumns"
2378
+ :key="col.field"
2379
+ class="mg-group-cell"
2380
+ :class="{
2381
+ 'mg-pinned': !!col.pinned,
2382
+ 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2383
+ 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2384
+ }"
2385
+ :style="pinStyleOf(col)"
2386
+ >
2387
+ <span
2388
+ v-if="colIndex === 0"
2389
+ class="mg-group-label"
2390
+ :style="{ paddingLeft: `${groupOf(entry).depth * 16}px` }"
2391
+ >
2392
+ <span class="mg-group-toggle">
2393
+ {{ groupOf(entry).expanded ? "▾" : "▸" }}
2394
+ </span>
2395
+ <strong>{{ groupLabelOf(entry) }}</strong>
2396
+ <span class="mg-group-count"
2397
+ >({{ groupOf(entry).rowCount }})</span
2398
+ >
2399
+ </span>
2400
+ <span v-else-if="groupAggOf(entry, col)" class="mg-agg">
2401
+ {{ groupAggOf(entry, col) }}
2402
+ </span>
2403
+ </td>
2404
+ </tr>
2405
+ <!-- 그룹 소계 행 -->
2406
+ <tr
2407
+ v-else-if="isSubtotalRow(entry)"
2408
+ :key="rowKeyOf(entry, rowIdx)"
2409
+ class="mg-subtotal-row"
1965
2410
  >
1966
- <input
1967
- type="checkbox"
1968
- aria-label="행 선택"
1969
- :checked="isSelected(rowDataOf(entry))"
1970
- :disabled="!grid.isRowSelectable(rowDataOf(entry))"
1971
- @change="
1972
- grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))
1973
- "
1974
- />
1975
- </td>
1976
- <td v-if="rowNumbers" class="mg-rownum-cell">
1977
- {{ entryIndexOf(entry, rowIdx) + 1 }}
1978
- <span
1979
- v-if="rowResizable && !virtual"
1980
- class="mg-row-resizer"
1981
- title="행 높이 조정"
1982
- @mousedown="onRowResizeStart(grid.getRowId(rowDataOf(entry)), $event)"
1983
- />
1984
- </td>
1985
- <template
1986
- v-for="(col, colIndex) in state.visibleColumns"
2411
+ <td v-if="rowStatus" class="mg-status-cell" />
2412
+ <td v-if="rowCheckboxes" class="mg-check-cell" />
2413
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
2414
+ <td
2415
+ v-for="(col, colIndex) in state.visibleColumns"
2416
+ :key="col.field"
2417
+ class="mg-subtotal-cell"
2418
+ :class="{
2419
+ 'mg-pinned': !!col.pinned,
2420
+ 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2421
+ 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2422
+ }"
2423
+ :style="pinStyleOf(col)"
2424
+ >
2425
+ <span
2426
+ v-if="colIndex === 0"
2427
+ class="mg-subtotal-label"
2428
+ :style="{ paddingLeft: `${groupOf(entry).depth * 16}px` }"
2429
+ >
2430
+ {{ state.locale.subtotalLabel }}: {{ groupLabelOf(entry) }}
2431
+ </span>
2432
+ <span v-else-if="groupAggOf(entry, col)" class="mg-agg">
2433
+ {{ groupAggOf(entry, col) }}
2434
+ </span>
2435
+ </td>
2436
+ </tr>
2437
+ <!-- 서버 사이드 미로드 행 → 스켈레톤 -->
2438
+ <tr
2439
+ v-else-if="rowDataOf(entry) == null"
2440
+ :key="rowKeyOf(entry, rowIdx)"
2441
+ class="mg-skeleton-row"
2442
+ aria-hidden="true"
1987
2443
  >
1988
- <td
1989
- v-if="!cellSpanOf(rowDataOf(entry), col).hidden"
1990
- :key="col.field"
1991
- :rowspan="cellSpanOf(rowDataOf(entry), col).rowSpan"
1992
- :colspan="cellSpanOf(rowDataOf(entry), col).colSpan"
1993
- :class="[
1994
- col.align && col.align !== 'left' ? `mg-align-${col.align}` : '',
1995
- {
1996
- 'mg-cell-readonly': !grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex),
1997
- 'mg-cell-active': grid.isActiveCell(entryIndexOf(entry, rowIdx), colIndex),
1998
- 'mg-cell-selected': grid.isCellInRange(entryIndexOf(entry, rowIdx), colIndex),
1999
- 'mg-cell-editing': isEditingCell(entryIndexOf(entry, rowIdx), col),
2000
- 'mg-cell-invalid': !!cellErrorOf(entry, col),
2001
- 'mg-find-match': isFindMatch(entry, col),
2002
- 'mg-cell-flash': state.flashedCells?.has(grid.getRowId(rowDataOf(entry)) + '|' + String(col.field)),
2003
- 'mg-multiline': !!col.multiLine,
2444
+ <td v-if="rowStatus" class="mg-status-cell" />
2445
+ <td v-if="rowCheckboxes" class="mg-check-cell" />
2446
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
2447
+ <td
2448
+ v-for="(col, colIndex) in state.visibleColumns"
2449
+ :key="col.field"
2450
+ :class="{
2004
2451
  'mg-pinned': !!col.pinned,
2005
2452
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2006
2453
  'mg-pin-right-edge': colIndex === firstRightPinIdx,
2007
- },
2008
- cellClassOf(entry, rowIdx, col),
2009
- cellNoteOf(entry, col) && 'mg-cell-note',
2010
- ]"
2011
- role="gridcell"
2012
- :title="
2013
- cellErrorOf(entry, col) ||
2014
- grid.getCellTooltip(rowDataOf(entry), col) ||
2015
- cellNoteOf(entry, col) ||
2016
- undefined
2017
- "
2018
- :style="[
2019
- pinStyleOf(col),
2020
- colIndex === 0 && leafDepthOf(entry)
2021
- ? { paddingLeft: `${leafDepthOf(entry) * 16 + 12}px` }
2022
- : undefined,
2023
- grid.getCellStyle(
2024
- rowDataOf(entry),
2025
- entryIndexOf(entry, rowIdx),
2026
- col,
2027
- ) ?? undefined,
2028
- ]"
2029
- :data-mg-row="entryIndexOf(entry, rowIdx)"
2030
- :data-mg-col="colIndex"
2031
- @mousedown="
2032
- onCellMouseDown(
2033
- $event,
2034
- entryIndexOf(entry, rowIdx),
2035
- colIndex,
2036
- col,
2037
- )
2038
- "
2039
- @mouseenter="
2040
- onCellMouseEnter(entryIndexOf(entry, rowIdx), colIndex)
2454
+ }"
2455
+ :style="pinStyleOf(col)"
2456
+ >
2457
+ <span class="mg-skeleton-bar" />
2458
+ </td>
2459
+ </tr>
2460
+ <!-- 리프(데이터) 행 -->
2461
+ <tr
2462
+ v-else
2463
+ :key="rowKeyOf(entry, rowIdx)"
2464
+ role="row"
2465
+ :aria-selected="
2466
+ state.selectedRowIds.has(grid.getRowId(rowDataOf(entry)))
2041
2467
  "
2468
+ :class="rowClassOf(entry, rowIdx)"
2469
+ :style="rowStyleOf(entry, rowIdx)"
2042
2470
  @click="
2043
- onCellClick(entryIndexOf(entry, rowIdx), colIndex)
2044
- "
2045
- @dblclick="
2046
- grid.notifyCellEvent('cellDblClick', entryIndexOf(entry, rowIdx), colIndex);
2047
- grid.startEditing(entryIndexOf(entry, rowIdx), colIndex);
2471
+ selectable &&
2472
+ grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))
2048
2473
  "
2049
- @contextmenu="onCellContextMenu($event, entryIndexOf(entry, rowIdx), col)"
2474
+ @dragover="onRowDragOver(entryIndexOf(entry, rowIdx), $event)"
2475
+ @drop="onRowDrop($event)"
2050
2476
  >
2051
- <button
2052
- v-if="colIndex === 0 && leafHasChildren(entry) !== undefined"
2053
- type="button"
2054
- class="mg-tree-toggle"
2055
- :class="{ 'mg-tree-leaf': !leafHasChildren(entry) }"
2056
- :aria-label="leafExpanded(entry) ? '접기' : '펼치기'"
2057
- :disabled="!leafHasChildren(entry)"
2058
- @click.stop="grid.toggleTreeExpanded(grid.getRowId(rowDataOf(entry)))"
2059
- >
2060
- {{ leafHasChildren(entry) ? (leafExpanded(entry) ? "▾" : "▸") : "" }}
2061
- </button>
2062
- <span
2063
- v-if="grid.isActiveCell(entryIndexOf(entry, rowIdx), colIndex) && !isEditingCell(entryIndexOf(entry, rowIdx), col)"
2064
- class="mg-fill-handle"
2065
- @mousedown="onFillMouseDown"
2066
- ></span>
2067
- <span
2068
- v-if="col.rowDrag && !isEditingCell(entryIndexOf(entry, rowIdx), col)"
2069
- class="mg-row-drag-handle"
2070
- :class="{ 'mg-disabled': !rowDraggable }"
2071
- :draggable="rowDraggable"
2072
- title="행 이동"
2073
- @dragstart="onRowDragStart(entryIndexOf(entry, rowIdx), $event)"
2074
- @dragend="onRowDragEnd"
2075
- >⠿</span
2477
+ <td
2478
+ v-if="rowStatus"
2479
+ class="mg-status-cell"
2480
+ :class="
2481
+ rowStateOf(rowDataOf(entry))
2482
+ ? `mg-status-${rowStateOf(rowDataOf(entry))}`
2483
+ : undefined
2484
+ "
2076
2485
  >
2077
- <template v-if="isEditingCell(entryIndexOf(entry, rowIdx), col)">
2078
- <!-- 커스텀 에디터 슬롯: #editor-{field}="ctx" -->
2079
- <slot
2080
- :name="`editor-${col.field}`"
2081
- v-bind="editorContext(entryIndexOf(entry, rowIdx), colIndex)"
2486
+ {{ rowStateOf(rowDataOf(entry)) ?? "" }}
2487
+ </td>
2488
+ <td v-if="rowCheckboxes" class="mg-check-cell" @click.stop>
2489
+ <input
2490
+ type="checkbox"
2491
+ aria-label="행 선택"
2492
+ :checked="isSelected(rowDataOf(entry))"
2493
+ :indeterminate.prop="
2494
+ grid.isRowSelectionIndeterminate(
2495
+ grid.getRowId(rowDataOf(entry)),
2496
+ )
2497
+ "
2498
+ :disabled="!grid.isRowSelectable(rowDataOf(entry))"
2499
+ @change="
2500
+ grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))
2501
+ "
2502
+ />
2503
+ </td>
2504
+ <td v-if="rowNumbers" class="mg-rownum-cell">
2505
+ {{ entryIndexOf(entry, rowIdx) + 1 }}
2506
+ <span
2507
+ v-if="rowResizable && !virtual"
2508
+ class="mg-row-resizer"
2509
+ title="행 높이 조정"
2510
+ @pointerdown="
2511
+ onRowResizeStart(grid.getRowId(rowDataOf(entry)), $event)
2512
+ "
2513
+ />
2514
+ </td>
2515
+ <template v-for="(col, colIndex) in state.visibleColumns">
2516
+ <td
2517
+ v-if="!cellSpanOf(rowDataOf(entry), col).hidden"
2518
+ :key="col.field"
2519
+ :rowspan="cellSpanOf(rowDataOf(entry), col).rowSpan"
2520
+ :colspan="cellSpanOf(rowDataOf(entry), col).colSpan"
2521
+ :class="[
2522
+ col.align && col.align !== 'left'
2523
+ ? `mg-align-${col.align}`
2524
+ : '',
2525
+ {
2526
+ 'mg-cell-readonly': !grid.isCellEditable(
2527
+ entryIndexOf(entry, rowIdx),
2528
+ colIndex,
2529
+ ),
2530
+ 'mg-cell-active': grid.isActiveCell(
2531
+ entryIndexOf(entry, rowIdx),
2532
+ colIndex,
2533
+ ),
2534
+ 'mg-cell-selected': grid.isCellInRange(
2535
+ entryIndexOf(entry, rowIdx),
2536
+ colIndex,
2537
+ ),
2538
+ 'mg-cell-editing': isEditingCell(
2539
+ entryIndexOf(entry, rowIdx),
2540
+ colIndex,
2541
+ ),
2542
+ 'mg-cell-invalid': !!cellErrorOf(entry, col),
2543
+ 'mg-find-match': isFindMatch(entry, col),
2544
+ 'mg-cell-flash': state.flashedCells?.has(
2545
+ grid.getRowId(rowDataOf(entry)) +
2546
+ '|' +
2547
+ String(col.field),
2548
+ ),
2549
+ 'mg-multiline': !!col.multiLine,
2550
+ 'mg-pinned': !!col.pinned,
2551
+ 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2552
+ 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2553
+ },
2554
+ cellClassOf(entry, rowIdx, col),
2555
+ cellNoteOf(entry, col) && 'mg-cell-note',
2556
+ ]"
2557
+ role="gridcell"
2558
+ :title="
2559
+ cellErrorOf(entry, col) ||
2560
+ grid.getCellTooltip(rowDataOf(entry), col) ||
2561
+ cellNoteOf(entry, col) ||
2562
+ undefined
2563
+ "
2564
+ :style="[
2565
+ pinStyleOf(col),
2566
+ colIndex === 0 && leafDepthOf(entry)
2567
+ ? { paddingLeft: `${leafDepthOf(entry) * 16 + 12}px` }
2568
+ : undefined,
2569
+ grid.getCellStyle(
2570
+ rowDataOf(entry),
2571
+ entryIndexOf(entry, rowIdx),
2572
+ col,
2573
+ ) ?? undefined,
2574
+ ]"
2575
+ :data-mg-row="entryIndexOf(entry, rowIdx)"
2576
+ :data-mg-col="colIndex"
2577
+ @mousedown="
2578
+ onCellMouseDown(
2579
+ $event,
2580
+ entryIndexOf(entry, rowIdx),
2581
+ colIndex,
2582
+ col,
2583
+ )
2584
+ "
2585
+ @mouseenter="
2586
+ onCellMouseEnter(entryIndexOf(entry, rowIdx), colIndex)
2587
+ "
2588
+ @click="onCellClick(entryIndexOf(entry, rowIdx), colIndex)"
2589
+ @dblclick="
2590
+ grid.notifyCellEvent(
2591
+ 'cellDblClick',
2592
+ entryIndexOf(entry, rowIdx),
2593
+ colIndex,
2594
+ );
2595
+ grid.startEditing(entryIndexOf(entry, rowIdx), colIndex);
2596
+ "
2597
+ @contextmenu="
2598
+ onCellContextMenu($event, entryIndexOf(entry, rowIdx), col)
2599
+ "
2600
+ @pointerdown="
2601
+ onCellPointerDown($event, entryIndexOf(entry, rowIdx), col)
2602
+ "
2082
2603
  >
2083
- <select
2084
- v-if="col.cellEditor === 'select'"
2085
- class="mg-editor"
2086
- :class="{ 'mg-editor-error': state.editError }"
2087
- :value="editorInputValue(state.editValue)"
2088
- @change="onEditorInput"
2089
- @keydown="onEditorKeydown"
2090
- @click.stop
2604
+ <button
2605
+ v-if="hasDetailSlot && colIndex === 0"
2606
+ type="button"
2607
+ class="mg-detail-toggle"
2608
+ title="행 상세"
2609
+ aria-label="행 상세 펼치기/접기"
2091
2610
  @mousedown.stop
2611
+ @click.stop="
2612
+ grid.toggleRowDetail(grid.getRowId(rowDataOf(entry)))
2613
+ "
2092
2614
  >
2093
- <option v-for="opt in col.editorOptions || []" :key="opt" :value="opt">
2094
- {{ opt }}
2095
- </option>
2096
- </select>
2097
- <select
2098
- v-else-if="col.cellEditor === 'multiselect'"
2099
- class="mg-editor"
2100
- :class="{ 'mg-editor-error': state.editError }"
2101
- multiple
2102
- :size="Math.min(Math.max((col.editorOptions || []).length, 2), 8)"
2103
- @change="onMultiselectChange"
2104
- @keydown="onEditorKeydown"
2105
- @click.stop
2106
- @mousedown.stop
2615
+ {{
2616
+ state.detailExpanded.has(grid.getRowId(rowDataOf(entry)))
2617
+ ? "▾"
2618
+ : "▸"
2619
+ }}
2620
+ </button>
2621
+ <button
2622
+ v-if="
2623
+ colIndex === 0 && leafHasChildren(entry) !== undefined
2624
+ "
2625
+ type="button"
2626
+ class="mg-tree-toggle"
2627
+ :class="{ 'mg-tree-leaf': !leafHasChildren(entry) }"
2628
+ :aria-label="leafExpanded(entry) ? '접기' : '펼치기'"
2629
+ :disabled="!leafHasChildren(entry)"
2630
+ @click.stop="
2631
+ grid.toggleTreeExpanded(grid.getRowId(rowDataOf(entry)))
2632
+ "
2107
2633
  >
2108
- <option
2109
- v-for="opt in col.editorOptions || []"
2110
- :key="opt"
2111
- :value="opt"
2112
- :selected="isEditOptSelected(opt)"
2113
- >
2114
- {{ opt }}
2115
- </option>
2116
- </select>
2117
- <div
2118
- v-else-if="col.cellEditor === 'radio'"
2119
- class="mg-radio-group"
2120
- role="radiogroup"
2634
+ {{
2635
+ leafHasChildren(entry)
2636
+ ? leafExpanded(entry)
2637
+ ? "▾"
2638
+ : "▸"
2639
+ : ""
2640
+ }}
2641
+ </button>
2642
+ <span
2643
+ v-if="
2644
+ grid.isActiveCell(
2645
+ entryIndexOf(entry, rowIdx),
2646
+ colIndex,
2647
+ ) && !isEditingCell(entryIndexOf(entry, rowIdx), colIndex)
2648
+ "
2649
+ class="mg-fill-handle"
2650
+ @pointerdown="onFillPointerDown"
2651
+ ></span>
2652
+ <span
2653
+ v-if="
2654
+ col.rowDrag &&
2655
+ !isEditingCell(entryIndexOf(entry, rowIdx), colIndex)
2656
+ "
2657
+ class="mg-row-drag-handle"
2658
+ :class="{ 'mg-disabled': !rowDraggable }"
2659
+ :draggable="rowDraggable"
2660
+ title="행 이동"
2661
+ @pointerdown="
2662
+ onRowDragPointerDown($event, entryIndexOf(entry, rowIdx))
2663
+ "
2664
+ @dragstart="
2665
+ onRowDragStart(entryIndexOf(entry, rowIdx), $event)
2666
+ "
2667
+ @dragend="onRowDragEnd"
2668
+ >⠿</span
2121
2669
  >
2122
- <label
2123
- v-for="opt in col.editorOptions || []"
2124
- :key="opt"
2125
- class="mg-radio-label"
2670
+ <template
2671
+ v-if="isEditingCell(entryIndexOf(entry, rowIdx), colIndex)"
2672
+ >
2673
+ <!-- 커스텀 에디터 슬롯: #editor-{field}="ctx" -->
2674
+ <slot
2675
+ :name="`editor-${col.field}`"
2676
+ v-bind="
2677
+ editorContext(entryIndexOf(entry, rowIdx), colIndex)
2678
+ "
2126
2679
  >
2680
+ <select
2681
+ v-if="col.cellEditor === 'select'"
2682
+ class="mg-editor"
2683
+ :class="{ 'mg-editor-error': editErrorOf(col) }"
2684
+ :value="editorInputValue(editValueOf(col))"
2685
+ @change="onSelectPick($event, col)"
2686
+ @keydown="onEditorKeydown"
2687
+ @click.stop
2688
+ @mousedown.stop
2689
+ >
2690
+ <option
2691
+ v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
2692
+ :key="opt"
2693
+ :value="opt"
2694
+ >
2695
+ {{ opt }}
2696
+ </option>
2697
+ </select>
2698
+ <select
2699
+ v-else-if="col.cellEditor === 'multiselect'"
2700
+ class="mg-editor"
2701
+ :class="{ 'mg-editor-error': editErrorOf(col) }"
2702
+ multiple
2703
+ :size="
2704
+ Math.min(
2705
+ Math.max(
2706
+ editorOptionsOf(col, rowDataOf(entry)).length,
2707
+ 2,
2708
+ ),
2709
+ 8,
2710
+ )
2711
+ "
2712
+ @change="onMultiselectChange($event, col)"
2713
+ @keydown="onEditorKeydown"
2714
+ @click.stop
2715
+ @mousedown.stop
2716
+ >
2717
+ <option
2718
+ v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
2719
+ :key="opt"
2720
+ :value="opt"
2721
+ :selected="isEditOptSelected(opt, col)"
2722
+ >
2723
+ {{ opt }}
2724
+ </option>
2725
+ </select>
2726
+ <div
2727
+ v-else-if="col.cellEditor === 'radio'"
2728
+ class="mg-radio-group"
2729
+ role="radiogroup"
2730
+ >
2731
+ <label
2732
+ v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
2733
+ :key="opt"
2734
+ class="mg-radio-label"
2735
+ >
2736
+ <input
2737
+ type="radio"
2738
+ :checked="String(editValueOf(col) ?? '') === opt"
2739
+ @change="onRadioPick(opt, col)"
2740
+ @click.stop
2741
+ @mousedown.stop
2742
+ />
2743
+ <span>{{ opt }}</span>
2744
+ </label>
2745
+ </div>
2746
+ <textarea
2747
+ v-else-if="col.cellEditor === 'textarea'"
2748
+ class="mg-editor mg-editor-textarea"
2749
+ :class="{ 'mg-editor-error': editErrorOf(col) }"
2750
+ :value="editorInputValue(editValueOf(col))"
2751
+ @input="onEditorInput($event, col)"
2752
+ @keydown="onTextareaKeydown"
2753
+ @blur="
2754
+ state.editType !== 'fullRow' && grid.commitEditing()
2755
+ "
2756
+ @click.stop
2757
+ @dblclick.stop
2758
+ @mousedown.stop
2759
+ />
2127
2760
  <input
2128
- type="radio"
2129
- :checked="String(state.editValue ?? '') === opt"
2130
- @change="onRadioPick(opt, entryIndexOf(entry, rowIdx), colIndex)"
2761
+ v-else
2762
+ :type="editorInputType(col)"
2763
+ class="mg-editor"
2764
+ :class="{ 'mg-editor-error': editErrorOf(col) }"
2765
+ :value="editorInputValue(editValueOf(col))"
2766
+ :list="
2767
+ editorInputType(col) === 'text' &&
2768
+ editorOptionsOf(col, rowDataOf(entry)).length
2769
+ ? `mg-dl-${col.field}`
2770
+ : undefined
2771
+ "
2772
+ @input="onEditorInput($event, col)"
2773
+ @change="onDatePick($event, col)"
2774
+ @keydown="onEditorKeydown"
2131
2775
  @click.stop
2132
2776
  @mousedown.stop
2133
2777
  />
2134
- <span>{{ opt }}</span>
2135
- </label>
2136
- </div>
2137
- <textarea
2138
- v-else-if="col.cellEditor === 'textarea'"
2139
- class="mg-editor mg-editor-textarea"
2140
- :class="{ 'mg-editor-error': state.editError }"
2141
- :value="editorInputValue(state.editValue)"
2142
- @input="onEditorInput"
2143
- @keydown="onTextareaKeydown"
2144
- @blur="grid.commitEditing()"
2145
- @click.stop
2146
- @dblclick.stop
2147
- @mousedown.stop
2148
- />
2149
- <input
2778
+ <datalist
2779
+ v-if="
2780
+ editorInputType(col) === 'text' &&
2781
+ editorOptionsOf(col, rowDataOf(entry)).length
2782
+ "
2783
+ :id="`mg-dl-${col.field}`"
2784
+ >
2785
+ <option
2786
+ v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
2787
+ :key="opt"
2788
+ :value="opt"
2789
+ />
2790
+ </datalist>
2791
+ </slot>
2792
+ <span v-if="editErrorOf(col)" class="mg-edit-error">{{
2793
+ editErrorOf(col)
2794
+ }}</span>
2795
+ </template>
2796
+ <!-- 커스텀 셀 슬롯: #cell-{field}="{ value, row, column }" -->
2797
+ <slot
2150
2798
  v-else
2151
- :type="editorInputType(col)"
2152
- class="mg-editor"
2153
- :class="{ 'mg-editor-error': state.editError }"
2154
- :value="editorInputValue(state.editValue)"
2155
- :list="
2156
- editorInputType(col) === 'text' && col.editorOptions?.length
2157
- ? `mg-dl-${col.field}`
2158
- : undefined
2159
- "
2160
- @input="onEditorInput"
2161
- @keydown="onEditorKeydown"
2162
- @click.stop
2163
- @mousedown.stop
2164
- />
2165
- <datalist
2166
- v-if="
2167
- editorInputType(col) === 'text' &&
2168
- col.editorOptions?.length
2169
- "
2170
- :id="`mg-dl-${col.field}`"
2799
+ :name="`cell-${col.field}`"
2800
+ :value="grid.getCellValue(rowDataOf(entry), col)"
2801
+ :row="rowDataOf(entry)"
2802
+ :column="col"
2171
2803
  >
2172
- <option
2173
- v-for="opt in col.editorOptions"
2174
- :key="opt"
2175
- :value="opt"
2804
+ <img
2805
+ v-if="
2806
+ col.cellType === 'image' &&
2807
+ grid.getCellValue(rowDataOf(entry), col) != null
2808
+ "
2809
+ class="mg-cell-image"
2810
+ :src="String(grid.getCellValue(rowDataOf(entry), col))"
2811
+ :alt="col.cellOptions?.alt?.(rowDataOf(entry)) ?? ''"
2812
+ />
2813
+ <button
2814
+ v-else-if="col.cellType === 'button'"
2815
+ type="button"
2816
+ class="mg-cell-button"
2817
+ @click.stop="col.cellOptions?.onClick?.(rowDataOf(entry))"
2818
+ @dblclick.stop
2819
+ >
2820
+ {{ grid.getCellText(rowDataOf(entry), col) }}
2821
+ </button>
2822
+ <a
2823
+ v-else-if="col.cellType === 'link'"
2824
+ class="mg-cell-link"
2825
+ :href="cellLinkHref(rowDataOf(entry), col)"
2826
+ :target="col.cellOptions?.target ?? '_blank'"
2827
+ rel="noreferrer"
2828
+ @click.stop
2829
+ >
2830
+ {{ grid.getCellText(rowDataOf(entry), col) }}
2831
+ </a>
2832
+ <span
2833
+ v-else-if="col.cellType === 'progress'"
2834
+ class="mg-cell-progress"
2835
+ role="progressbar"
2836
+ :aria-valuenow="progressValueOf(rowDataOf(entry), col)"
2837
+ :aria-valuemax="col.cellOptions?.max ?? 100"
2838
+ >
2839
+ <span
2840
+ class="mg-cell-progress-bar"
2841
+ :style="{
2842
+ width: `${progressPctOf(rowDataOf(entry), col)}%`,
2843
+ }"
2844
+ />
2845
+ <span class="mg-cell-progress-text"
2846
+ >{{
2847
+ Math.round(progressPctOf(rowDataOf(entry), col))
2848
+ }}%</span
2849
+ >
2850
+ </span>
2851
+ <!-- XSS 주의: html 셀은 신뢰할 수 있는 HTML만 -->
2852
+ <span
2853
+ v-else-if="col.cellType === 'html'"
2854
+ class="mg-cell-html"
2855
+ v-html="grid.getCellText(rowDataOf(entry), col)"
2856
+ />
2857
+ <input
2858
+ v-else-if="col.cellEditor === 'checkbox'"
2859
+ type="checkbox"
2860
+ class="mg-cell-checkbox"
2861
+ :checked="grid.isCellChecked(rowDataOf(entry), col)"
2862
+ :disabled="
2863
+ !grid.isCellEditable(
2864
+ entryIndexOf(entry, rowIdx),
2865
+ colIndex,
2866
+ )
2867
+ "
2868
+ @click.stop
2869
+ @dblclick.stop
2870
+ @change="grid.toggleCellChecked(rowDataOf(entry), col)"
2176
2871
  />
2177
- </datalist>
2178
- </slot>
2179
- <span v-if="state.editError" class="mg-edit-error">{{ state.editError }}</span>
2872
+ <template v-else>{{
2873
+ grid.getCellText(rowDataOf(entry), col)
2874
+ }}</template>
2875
+ </slot>
2876
+ </td>
2180
2877
  </template>
2181
- <!-- 커스텀 셀 슬롯: #cell-{field}="{ value, row, column }" -->
2182
- <slot
2183
- v-else
2184
- :name="`cell-${col.field}`"
2185
- :value="grid.getCellValue(rowDataOf(entry), col)"
2186
- :row="rowDataOf(entry)"
2187
- :column="col"
2188
- >
2189
- <img
2190
- v-if="col.cellType === 'image' && grid.getCellValue(rowDataOf(entry), col) != null"
2191
- class="mg-cell-image"
2192
- :src="String(grid.getCellValue(rowDataOf(entry), col))"
2193
- :alt="col.cellOptions?.alt?.(rowDataOf(entry)) ?? ''"
2194
- />
2195
- <button
2196
- v-else-if="col.cellType === 'button'"
2197
- type="button"
2198
- class="mg-cell-button"
2199
- @click.stop="col.cellOptions?.onClick?.(rowDataOf(entry))"
2200
- @dblclick.stop
2201
- >
2202
- {{ grid.getCellText(rowDataOf(entry), col) }}
2203
- </button>
2204
- <a
2205
- v-else-if="col.cellType === 'link'"
2206
- class="mg-cell-link"
2207
- :href="cellLinkHref(rowDataOf(entry), col)"
2208
- :target="col.cellOptions?.target ?? '_blank'"
2209
- rel="noreferrer"
2210
- @click.stop
2211
- >
2212
- {{ grid.getCellText(rowDataOf(entry), col) }}
2213
- </a>
2214
- <span
2215
- v-else-if="col.cellType === 'progress'"
2216
- class="mg-cell-progress"
2217
- role="progressbar"
2218
- :aria-valuenow="progressValueOf(rowDataOf(entry), col)"
2219
- :aria-valuemax="col.cellOptions?.max ?? 100"
2220
- >
2221
- <span
2222
- class="mg-cell-progress-bar"
2223
- :style="{ width: `${progressPctOf(rowDataOf(entry), col)}%` }"
2878
+ </tr>
2879
+ <!-- 행 상세 패널 (master-detail) — #detail 슬롯 -->
2880
+ <tr
2881
+ v-if="
2882
+ hasDetailSlot &&
2883
+ !isGroupRow(entry) &&
2884
+ !isSubtotalRow(entry) &&
2885
+ rowDataOf(entry) != null &&
2886
+ state.detailExpanded.has(grid.getRowId(rowDataOf(entry)))
2887
+ "
2888
+ :key="rowKeyOf(entry, rowIdx) + '-detail'"
2889
+ class="mg-detail-row"
2890
+ >
2891
+ <td class="mg-detail-cell" :colspan="colSpan">
2892
+ <div class="mg-detail-content">
2893
+ <slot
2894
+ name="detail"
2895
+ :row="rowDataOf(entry)"
2896
+ :row-index="entryIndexOf(entry, rowIdx)"
2224
2897
  />
2225
- <span class="mg-cell-progress-text">{{ Math.round(progressPctOf(rowDataOf(entry), col)) }}%</span>
2226
- </span>
2227
- <!-- XSS 주의: html 셀은 신뢰할 수 있는 HTML만 -->
2228
- <span
2229
- v-else-if="col.cellType === 'html'"
2230
- class="mg-cell-html"
2231
- v-html="grid.getCellText(rowDataOf(entry), col)"
2232
- />
2233
- <input
2234
- v-else-if="col.cellEditor === 'checkbox'"
2235
- type="checkbox"
2236
- class="mg-cell-checkbox"
2237
- :checked="grid.isCellChecked(rowDataOf(entry), col)"
2238
- :disabled="!grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex)"
2239
- @click.stop
2240
- @dblclick.stop
2241
- @change="grid.toggleCellChecked(rowDataOf(entry), col)"
2242
- />
2243
- <template v-else>{{ grid.getCellText(rowDataOf(entry), col) }}</template>
2244
- </slot>
2245
- </td>
2246
- </template>
2898
+ </div>
2899
+ </td>
2900
+ </tr>
2901
+ </template>
2902
+ <tr
2903
+ v-if="virtual && bottomOffset > 0"
2904
+ class="mg-spacer"
2905
+ aria-hidden="true"
2906
+ >
2907
+ <td
2908
+ :colspan="colSpan"
2909
+ :style="{ height: `${bottomOffset}px`, padding: 0 }"
2910
+ />
2247
2911
  </tr>
2248
- </template>
2249
- <tr
2250
- v-if="virtual && bottomOffset > 0"
2251
- class="mg-spacer"
2252
- aria-hidden="true"
2253
- >
2254
- <td :colspan="colSpan" :style="{ height: `${bottomOffset}px`, padding: 0 }" />
2255
- </tr>
2256
- <tr
2257
- v-for="(prow, pIdx) in state.pinnedBottomRows"
2258
- :key="`pin-bottom-${pIdx}`"
2259
- class="mg-pinned-bottom-row"
2260
- >
2261
- <td v-if="rowStatus" class="mg-status-cell" />
2262
- <td v-if="rowCheckboxes" class="mg-check-cell" />
2263
- <td v-if="rowNumbers" class="mg-rownum-cell" />
2264
- <td
2265
- v-for="(col, colIndex) in state.visibleColumns"
2266
- :key="col.field"
2267
- :class="{
2268
- 'mg-pinned': !!col.pinned,
2269
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2270
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2271
- }"
2272
- :style="pinStyleOf(col)"
2912
+ <tr
2913
+ v-for="(prow, pIdx) in state.pinnedBottomRows"
2914
+ :key="`pin-bottom-${pIdx}`"
2915
+ class="mg-pinned-bottom-row"
2273
2916
  >
2274
- {{ grid.getCellText(prow, col) }}
2275
- </td>
2276
- </tr>
2277
- <tr
2278
- v-if="state.appendScroll && (state.appendScroll.loading || state.appendScroll.hasMore)"
2279
- class="mg-append-row"
2280
- >
2281
- <td :colspan="colSpan">
2282
- <span v-if="state.appendScroll.loading">{{ state.locale.loadingMore }}</span>
2283
- <button
2284
- v-else
2285
- type="button"
2286
- class="mg-append-btn"
2287
- @click="onLoadMore"
2917
+ <td v-if="rowStatus" class="mg-status-cell" />
2918
+ <td v-if="rowCheckboxes" class="mg-check-cell" />
2919
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
2920
+ <td
2921
+ v-for="(col, colIndex) in state.visibleColumns"
2922
+ :key="col.field"
2923
+ :class="{
2924
+ 'mg-pinned': !!col.pinned,
2925
+ 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2926
+ 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2927
+ }"
2928
+ :style="pinStyleOf(col)"
2288
2929
  >
2289
- 더 보기
2290
- </button>
2291
- </td>
2292
- </tr>
2293
- </tbody>
2294
- <tfoot v-if="state.grandTotals">
2295
- <tr class="mg-total-row">
2296
- <td v-if="rowStatus" class="mg-status-cell" />
2297
- <td v-if="rowCheckboxes" class="mg-check-cell" />
2298
- <td v-if="rowNumbers" class="mg-rownum-cell" />
2299
- <td
2300
- v-for="(col, colIndex) in state.visibleColumns"
2301
- :key="col.field"
2302
- :class="{
2303
- 'mg-pinned': !!col.pinned,
2304
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2305
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2306
- }"
2307
- :style="pinStyleOf(col)"
2930
+ {{ grid.getCellText(prow, col) }}
2931
+ </td>
2932
+ </tr>
2933
+ <tr
2934
+ v-if="
2935
+ state.appendScroll &&
2936
+ (state.appendScroll.loading || state.appendScroll.hasMore)
2937
+ "
2938
+ class="mg-append-row"
2308
2939
  >
2309
- <span
2310
- v-if="col.aggregationFn && state.grandTotals[col.field] != null"
2311
- class="mg-agg"
2940
+ <td :colspan="colSpan">
2941
+ <span v-if="state.appendScroll.loading">{{
2942
+ state.locale.loadingMore
2943
+ }}</span>
2944
+ <button
2945
+ v-else
2946
+ type="button"
2947
+ class="mg-append-btn"
2948
+ @click="onLoadMore"
2949
+ >
2950
+ 더 보기
2951
+ </button>
2952
+ </td>
2953
+ </tr>
2954
+ </tbody>
2955
+ <tfoot v-if="state.grandTotals">
2956
+ <tr class="mg-total-row">
2957
+ <td v-if="rowStatus" class="mg-status-cell" />
2958
+ <td v-if="rowCheckboxes" class="mg-check-cell" />
2959
+ <td v-if="rowNumbers" class="mg-rownum-cell" />
2960
+ <td
2961
+ v-for="(col, colIndex) in state.visibleColumns"
2962
+ :key="col.field"
2963
+ :class="{
2964
+ 'mg-pinned': !!col.pinned,
2965
+ 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2966
+ 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2967
+ }"
2968
+ :style="pinStyleOf(col)"
2312
2969
  >
2313
- {{ formatAggregate(state.grandTotals[col.field]) }}
2314
- </span>
2315
- <template v-else-if="colIndex === 0">{{ state.locale.totalLabel }}</template>
2316
- </td>
2317
- </tr>
2318
- </tfoot>
2319
- </table>
2320
- <div v-if="state.serverSide?.loading" class="mg-loading">{{ state.locale.loadingMore }}</div>
2970
+ <span
2971
+ v-if="col.aggregationFn && state.grandTotals[col.field] != null"
2972
+ class="mg-agg"
2973
+ >
2974
+ {{ formatAggregate(state.grandTotals[col.field]) }}
2975
+ </span>
2976
+ <template v-else-if="colIndex === 0">{{
2977
+ state.locale.totalLabel
2978
+ }}</template>
2979
+ </td>
2980
+ </tr>
2981
+ </tfoot>
2982
+ </table>
2983
+ <div v-if="state.serverSide?.loading" class="mg-loading">
2984
+ {{ state.locale.loadingMore }}
2985
+ </div>
2321
2986
  </div>
2322
- <div
2323
- v-if="statusBar && state.selectionAggregates"
2324
- class="mg-statusbar"
2325
- >
2987
+ <div v-if="statusBar && state.selectionAggregates" class="mg-statusbar">
2326
2988
  <span>
2327
2989
  <span class="mg-status-value">
2328
- {{ state.selectionAggregates.cells }}
2990
+ {{
2991
+ state.selectionAggregates.rows > 0
2992
+ ? state.selectionAggregates.rows
2993
+ : state.selectionAggregates.cells
2994
+ }}
2329
2995
  </span>
2330
- 셀 선택
2996
+ {{ state.selectionAggregates.rows > 0 ? "행 선택" : "셀 선택" }}
2331
2997
  </span>
2332
2998
  <template v-if="state.selectionAggregates.count > 0">
2333
2999
  <span>
@@ -2371,10 +3037,18 @@ watch(
2371
3037
  <ul
2372
3038
  class="mg-ctx-menu"
2373
3039
  role="menu"
2374
- :style="{ left: `${state.contextMenu.x}px`, top: `${state.contextMenu.y}px` }"
3040
+ :style="{
3041
+ left: `${state.contextMenu.x}px`,
3042
+ top: `${state.contextMenu.y}px`,
3043
+ }"
2375
3044
  >
2376
3045
  <template v-for="item in state.contextMenu.items">
2377
- <li v-if="item.separator" :key="item.id" class="mg-ctx-separator" role="separator" />
3046
+ <li
3047
+ v-if="item.separator"
3048
+ :key="item.id"
3049
+ class="mg-ctx-separator"
3050
+ role="separator"
3051
+ />
2378
3052
  <li v-else :key="item.id" role="none">
2379
3053
  <button
2380
3054
  type="button"
@@ -2389,5 +3063,8 @@ watch(
2389
3063
  </template>
2390
3064
  </ul>
2391
3065
  </template>
3066
+ <div v-if="isLoading" class="mg-loading-overlay">
3067
+ {{ state.locale.loadingMore }}
3068
+ </div>
2392
3069
  </div>
2393
3070
  </template>