@moda-grid/vue2 2.1.2 → 2.2.3

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
@@ -21,15 +21,38 @@ import {
21
21
  createTouchDrag,
22
22
  DEFAULT_COLUMN_WIDTH,
23
23
  DEFAULT_OPERATOR_BY_TYPE,
24
+ describeCell,
25
+ dropRatioForY,
26
+ editorInputValue,
24
27
  FILTER_OPERATOR_LABELS,
25
28
  FILTER_OPERATORS_BY_TYPE,
26
29
  formatAggregate,
27
30
  gridThemeClasses,
28
31
  gridThemeVars,
32
+ groupLabelOf as coreGroupLabelOf,
33
+ groupOf,
34
+ handleGridKeydown,
35
+ isGroupRow,
29
36
  isInteractiveCellTarget,
37
+ isSubtotalRow,
38
+ leafDepthOf,
39
+ filterDropAnchorX,
40
+ leafExpanded,
41
+ leafHasChildren,
42
+ leafOf,
30
43
  logicalToDomScrollLeft,
31
- readClipboardText,
32
- writeClipboardText,
44
+ measureRowScrollPads,
45
+ pinPartition,
46
+ pinStyleProps,
47
+ resolveRowDrop,
48
+ resizeKeyDelta,
49
+ rowDataOf,
50
+ startColumnResize,
51
+ startFillDrag,
52
+ startRowResize,
53
+ syncGridOptions,
54
+ colKeyOf,
55
+ resolveColumn,
33
56
  } from "@moda-grid/core";
34
57
  import type {
35
58
  AggregateFn,
@@ -37,10 +60,8 @@ import type {
37
60
  AppendScrollOptions,
38
61
  PivotOptions,
39
62
  PivotZone,
40
- ContextMenuItem,
41
63
  GridLocale,
42
64
  CellEditorContext,
43
- CellNavigation,
44
65
  ColumnDef,
45
66
  ColumnFilter,
46
67
  DisplayRow,
@@ -52,8 +73,7 @@ import type {
52
73
  GridEventHandlers,
53
74
  GridEventMap,
54
75
  GridOptions,
55
- GroupNode,
56
- LeafDisplayRow,
76
+ RangeTracking,
57
77
  RowData,
58
78
  SelectionMode,
59
79
  ServerSideOptions,
@@ -63,15 +83,6 @@ import type {
63
83
  import { useGrid, useGridState } from "./useGrid.js";
64
84
 
65
85
  // Vue 2.7 script setup — runtime props 선언 사용
66
- /** 편집기 input 씨드 값 — Date는 YYYY-MM-DD 로 변환 (input[type=date] 호환) */
67
- function editorInputValue(v: unknown): string {
68
- if (v instanceof Date) {
69
- const pad = (n: number) => String(n).padStart(2, "0");
70
- return `${v.getFullYear()}-${pad(v.getMonth() + 1)}-${pad(v.getDate())}`;
71
- }
72
- return String(v ?? "");
73
- }
74
-
75
86
  const slots = useSlots();
76
87
  /** 행 상세 패널 (master-detail) — #detail="{ row, rowIndex }" 슬롯이 있으면 각 행에 ▸ 토글 표시 */
77
88
  const hasDetailSlot = computed(() => !!slots.detail);
@@ -89,7 +100,10 @@ const props = defineProps({
89
100
  default: undefined,
90
101
  },
91
102
  /** 외부에서 생성/관리하는 GridCore. 생략하면 내부 인스턴스 생성 */
92
- grid: { type: Object as PropType<Grid<any>>, default: undefined },
103
+ grid: {
104
+ type: Object as PropType<Grid<Record<string, unknown>>>,
105
+ default: undefined,
106
+ },
93
107
  getRowId: {
94
108
  type: Function as PropType<(row: Record<string, unknown>) => string>,
95
109
  default: undefined,
@@ -100,6 +114,11 @@ const props = defineProps({
100
114
  height: { type: Number, default: undefined },
101
115
  /** 가상 스크롤: 행 높이(px) */
102
116
  rowHeight: { type: Number, default: undefined },
117
+ /** 가변 높이 가상화 — 행별 px 높이. height/rowHeight와 함께 지정 */
118
+ getRowHeight: {
119
+ type: Function as PropType<(row: unknown, index: number) => number>,
120
+ default: undefined,
121
+ },
103
122
  /** 가상 스크롤: overscan 행 수 */
104
123
  overscan: { type: Number, default: undefined },
105
124
  /**
@@ -127,6 +146,11 @@ const props = defineProps({
127
146
  type: String as PropType<SelectionMode>,
128
147
  default: undefined,
129
148
  },
149
+ /** 범위 선택 추적 방식 — 'identity'면 정렬/필터 후에도 같은 행·컬럼을 추적 */
150
+ rangeTracking: {
151
+ type: String as PropType<RangeTracking>,
152
+ default: undefined,
153
+ },
130
154
  /** 서버 사이드 데이터 소스 (내부 GridCore 생성 모드에서만 적용) */
131
155
  serverSide: {
132
156
  type: Object as PropType<ServerSideOptions>,
@@ -251,6 +275,8 @@ const props = defineProps({
251
275
  theme: { type: [String, Object] as PropType<GridTheme>, default: undefined },
252
276
  /** 밀도 프리셋 — "compact"/"comfortable"이 폰트·셀 패딩을 일괄 조정 */
253
277
  density: { type: String as PropType<GridDensity>, default: undefined },
278
+ /** 행 상세 패널 높이(px) — #detail 슬롯 사용 시 적용. 미지정 시 내용에 맞춤 */
279
+ detailHeight: { type: Number, default: undefined },
254
280
  /** 선언형 이벤트 핸들러 — 마운트 시 구독, 언마운트 시 해제 (grid.on과 동일) */
255
281
  events: { type: Object as PropType<GridEventHandlers>, default: undefined },
256
282
  /** GridCore 인스턴스가 준비되면 한 번 호출 — props 모드에서도 grid API 접근 가능 */
@@ -281,6 +307,7 @@ const internal = props.grid
281
307
  cellFlash: props.cellFlash,
282
308
  copyFormatted: props.copyFormatted,
283
309
  singleClickEdit: props.singleClickEdit,
310
+ rangeTracking: props.rangeTracking,
284
311
  editType: props.editType,
285
312
  pasteExtend: props.pasteExtend,
286
313
  headerHeight: props.headerHeight,
@@ -302,6 +329,7 @@ const internal = props.grid
302
329
  rowHeight: props.rowHeight,
303
330
  viewportHeight: props.height,
304
331
  overscan: props.overscan,
332
+ getRowHeight: props.getRowHeight,
305
333
  }
306
334
  : undefined,
307
335
  virtualColumns: props.virtualColumns,
@@ -341,69 +369,53 @@ defineExpose({ grid });
341
369
  // 컬럼 관리 도구 팝오버 열림 상태
342
370
  const colCtlOpen = ref(false);
343
371
 
344
- // props → core 동기화
345
- watchEffect(() => {
346
- if (props.data) grid.setData(props.data);
347
- });
348
- watchEffect(() => {
349
- // 외부 grid 경로에서도 defaultColDef prop이 적용되도록 먼저 동기화 —
350
- // undefined는 "미지정"이라 기존 기본값이 유지된다
351
- grid.setDefaultColDef(props.defaultColDef);
352
- grid.setColumns(props.columns);
353
- });
354
- watchEffect(() => {
355
- if (
356
- props.domLayout !== "autoHeight" &&
357
- props.height != null &&
358
- props.rowHeight != null &&
359
- props.rowHeight > 0
360
- ) {
361
- grid.setVirtualScroll({
362
- rowHeight: props.rowHeight,
363
- viewportHeight: props.height,
364
- overscan: props.overscan,
365
- });
366
- } else {
367
- grid.setVirtualScroll(null);
368
- }
369
- });
370
- watchEffect(() => {
371
- grid.setVirtualColumns(props.virtualColumns ?? null);
372
- });
373
- watchEffect(() => {
374
- grid.setRowDragAcceptExternal(props.rowDragAcceptExternal ?? null);
375
- });
376
- watchEffect(() => {
377
- grid.setDir(props.dir ?? null);
378
- });
372
+ // props → core 동기화 — 세터 디스패치·함수 prop 안정 래퍼는 코어
373
+ // syncGridOptions 단일 경로가 담당한다. watchEffect가 참조한 prop을
374
+ // 추적해 바뀌면 재실행되고, 코어가 엔트리별 deps 비교로 실제 세터
375
+ // 호출을 게이트한다
379
376
  watchEffect(() => {
380
- if (props.selectionMode) grid.setSelectionMode(props.selectionMode);
381
- });
382
- watchEffect(() => {
383
- grid.setHiddenRows([...(props.hiddenRowIds ?? [])]);
384
- });
385
- watchEffect(() => {
386
- grid.setHeaderHeight(props.headerHeight ?? null);
387
- });
388
- watchEffect(() => {
389
- grid.setStriped(props.striped ?? false);
390
- });
391
- watchEffect(() => {
392
- grid.setBeforeEdit(props.beforeEdit ?? null);
393
- grid.setIsRowSelectable(props.isRowSelectable ?? null);
394
- grid.setExternalFilter(props.externalFilter ?? null);
395
- grid.setPostSort(props.postSort ?? null);
396
- grid.setBeforePaste(props.beforePaste ?? null);
397
- grid.setBeforeCopy(props.beforeCopy ?? null);
398
- grid.setIsFullWidthRow(props.isFullWidthRow ?? null);
399
- grid.setAnimateRows(props.animateRows ?? false);
400
- // 외부 grid prop 경로에서도 컨텍스트 메뉴 prop이 적용되도록
401
- // 런타임 setter로 동기화한다
402
- grid.setContextMenu(props.contextMenu ?? null);
403
- grid.setHeaderContextMenu(props.headerContextMenu ?? null);
404
- });
405
- watchEffect(() => {
406
- grid.setClipboardDelimiter(props.clipboardDelimiter ?? null);
377
+ syncGridOptions(grid, {
378
+ data: props.data,
379
+ columns: props.columns,
380
+ defaultColDef: props.defaultColDef,
381
+ virtualScroll:
382
+ props.domLayout !== "autoHeight" &&
383
+ props.height != null &&
384
+ props.rowHeight != null &&
385
+ props.rowHeight > 0
386
+ ? {
387
+ rowHeight: props.rowHeight,
388
+ viewportHeight: props.height,
389
+ overscan: props.overscan,
390
+ getRowHeight: props.getRowHeight,
391
+ }
392
+ : null,
393
+ virtualColumns: props.virtualColumns,
394
+ rowDragAcceptExternal: props.rowDragAcceptExternal,
395
+ dir: props.dir,
396
+ clipboardDelimiter: props.clipboardDelimiter,
397
+ selectionMode: props.selectionMode,
398
+ rangeTracking: props.rangeTracking,
399
+ autoRowHeight: props.autoRowHeight,
400
+ fillSeries: props.fillSeries,
401
+ cellFlash: props.cellFlash,
402
+ copyFormatted: props.copyFormatted,
403
+ singleClickEdit: props.singleClickEdit,
404
+ editType: props.editType,
405
+ headerHeight: props.headerHeight,
406
+ hiddenRowIds: props.hiddenRowIds,
407
+ striped: props.striped,
408
+ beforeEdit: props.beforeEdit,
409
+ beforePaste: props.beforePaste,
410
+ beforeCopy: props.beforeCopy,
411
+ contextMenu: props.contextMenu,
412
+ headerContextMenu: props.headerContextMenu,
413
+ isRowSelectable: props.isRowSelectable,
414
+ externalFilter: props.externalFilter,
415
+ isFullWidthRow: props.isFullWidthRow,
416
+ postSort: props.postSort,
417
+ animateRows: props.animateRows,
418
+ });
407
419
  });
408
420
 
409
421
  // 가상 스크롤: 코어가 보정한 scrollTop을 DOM에 동기화 (키보드 scrollIntoView)
@@ -414,6 +426,17 @@ watchEffect(() => {
414
426
  if (v && el && el.scrollTop !== v.scrollTop) el.scrollTop = v.scrollTop;
415
427
  });
416
428
 
429
+ // scroll-padding: sticky thead/pinned-top·tfoot/pinned-bottom이 덮는 높이를
430
+ // 알려 scrollIntoView가 행을 오버레이 아래로 완전히 보이게 한다
431
+ watchEffect(() => {
432
+ void state.value; // 스냅샷 갱신마다 재측정
433
+ const el = scrollEl.value;
434
+ if (!el) return;
435
+ const { top, bottom } = measureRowScrollPads(el);
436
+ el.style.scrollPaddingTop = `${top}px`;
437
+ el.style.scrollPaddingBottom = `${bottom}px`;
438
+ });
439
+
417
440
  // 컬럼 가상화: 코어가 보정한 scrollLeft를 DOM에 동기화한다
418
441
  // (ensureColumnVisible/scrollToColumn 경로). 사용자 스크롤은 같은 값이라 no-op.
419
442
  watchEffect(() => {
@@ -469,25 +492,21 @@ watch(
469
492
  const req = state.value.scrollRequest;
470
493
  if (!req) return;
471
494
  await nextTick();
472
- (scrollEl.value ?? hostEl.value)
473
- ?.querySelector<HTMLElement>(
474
- `td[data-mg-row="${req.rowIndex}"]` +
475
- (req.columnIndex != null ? `[data-mg-col="${req.columnIndex}"]` : ""),
476
- )
477
- ?.scrollIntoView({ block: "nearest", inline: "nearest" });
495
+ const el = scrollEl.value ?? hostEl.value;
496
+ // scrollToBottom — 후행 소계/그룹 행까지 덮도록 스크롤 끝으로
497
+ if (req.toEnd) {
498
+ if (el) el.scrollTop = el.scrollHeight;
499
+ return;
500
+ }
501
+ el?.querySelector<HTMLElement>(
502
+ `td[data-mg-row="${req.rowIndex}"]` +
503
+ (req.columnIndex != null ? `[data-mg-col="${req.columnIndex}"]` : ""),
504
+ )?.scrollIntoView({ block: "nearest", inline: "nearest" });
478
505
  },
479
506
  );
480
507
 
481
- // autoRowHeight prop → core 동기화 (제어 모드 포함)
482
- watchEffect(() => grid.setAutoRowHeight(!!props.autoRowHeight));
483
- // fillSeries prop → core 동기화 (제어 모드 포함)
484
- watchEffect(() => grid.setFillSeries(!!props.fillSeries));
485
- // cellFlash prop → core 동기화
486
- watchEffect(() => grid.setCellFlash(!!props.cellFlash));
487
- // copyFormatted prop → core 동기화
488
- watchEffect(() => grid.setCopyFormatted(!!props.copyFormatted));
489
- watchEffect(() => grid.setSingleClickEdit(!!props.singleClickEdit));
490
- watchEffect(() => grid.setEditType(props.editType ?? "cell"));
508
+ // autoRowHeight·fillSeries·cellFlash·copyFormatted·singleClickEdit·editType은
509
+ // 위 syncGridOptions 단일 경로가 커버한다
491
510
 
492
511
  // 찾기 바 — findNext로 다음/이전 매치 순환 (Enter / Shift+Enter)
493
512
  const findInputEl = ref<HTMLInputElement | null>(null);
@@ -572,30 +591,31 @@ function onFindInput(e: Event) {
572
591
  const filterDrop = ref<{ field: string; x: number; y: number } | null>(null);
573
592
  function toggleFilterDrop(col: ColumnDef, e: MouseEvent) {
574
593
  e.stopPropagation();
575
- if (filterDrop.value?.field === col.field) {
594
+ if (filterDrop.value?.field === colKeyOf(col)) {
576
595
  filterDrop.value = null;
577
596
  return;
578
597
  }
579
598
  const b = (e.currentTarget as HTMLElement).getBoundingClientRect();
580
599
  const h = hostEl.value?.getBoundingClientRect();
581
600
  filterDrop.value = {
582
- field: col.field,
583
- x: b.right - (h?.left ?? 0),
601
+ field: colKeyOf(col),
602
+ x: filterDropAnchorX(b, h?.left ?? 0, state.value.dir),
584
603
  y: b.bottom - (h?.top ?? 0) + 4,
585
604
  };
586
605
  }
587
606
  const filterDropCol = computed(() =>
588
607
  filterDrop.value
589
- ? (state.value.columns.find((c) => c.field === filterDrop.value!.field) ??
590
- null)
608
+ ? (resolveColumn(state.value.columns, filterDrop.value.field) ?? null)
591
609
  : null,
592
610
  );
593
611
  const filterDropAll = computed(() =>
594
- filterDropCol.value ? grid.getUniqueValues(filterDropCol.value.field) : [],
612
+ filterDropCol.value
613
+ ? grid.getUniqueValues(colKeyOf(filterDropCol.value))
614
+ : [],
595
615
  );
596
616
  const filterDropActive = computed(() =>
597
617
  filterDropCol.value
598
- ? state.value.filters[filterDropCol.value.field]?.values
618
+ ? state.value.filters[colKeyOf(filterDropCol.value)]?.values
599
619
  : undefined,
600
620
  );
601
621
  // ── 필터 빌더 상태: 조건식(연산자+값)과 값 체크리스트를 분리해 다룬다 ──
@@ -612,7 +632,7 @@ const filterDropBuilder = computed<FilterBuilderInput>(() => {
612
632
  values: null,
613
633
  join: "and" as const,
614
634
  };
615
- const cur = state.value.filters[col.field];
635
+ const cur = state.value.filters[colKeyOf(col)];
616
636
  const condOn = cur != null && cur.operator !== "set";
617
637
  return {
618
638
  operator: condOn
@@ -632,7 +652,7 @@ function applyFilterBuilder(patch: Partial<FilterBuilderInput>) {
632
652
  const col = filterDropCol.value;
633
653
  if (!col) return;
634
654
  grid.setFilter(
635
- col.field,
655
+ colKeyOf(col),
636
656
  buildColumnFilter({ ...filterDropBuilder.value, ...patch }),
637
657
  );
638
658
  }
@@ -683,9 +703,7 @@ const PIVOT_AGGS: BuiltInAggregateFn[] = [
683
703
  ];
684
704
  const pivotDropZone = ref<string | null>(null);
685
705
  function pivotHeaderOf(field: string) {
686
- return (
687
- state.value.sourceColumns.find((c) => c.field === field)?.header ?? field
688
- );
706
+ return resolveColumn(state.value.sourceColumns, field)?.header ?? field;
689
707
  }
690
708
  function onPivotAggChange(field: string, e: Event) {
691
709
  const v = (e.target as HTMLSelectElement).value;
@@ -695,7 +713,7 @@ function pivotChipsOf(zone: string) {
695
713
  const p = state.value.pivot;
696
714
  if (zone === "fields")
697
715
  return state.value.sourceColumns.map((c) => ({
698
- field: c.field,
716
+ field: colKeyOf(c),
699
717
  label: c.header ?? c.field,
700
718
  agg: undefined as AggregateFn | undefined,
701
719
  }));
@@ -755,8 +773,8 @@ function onPivotZoneDrop(zone: string, e: DragEvent, index?: number) {
755
773
  if (!f) return;
756
774
  e.preventDefault();
757
775
  e.stopPropagation();
758
- if (zone === "fields") grid.removePivotField(f as string);
759
- else grid.addPivotField(zone as PivotZone, f as string, { index });
776
+ if (zone === "fields") grid.removePivotField(f);
777
+ else grid.addPivotField(zone as PivotZone, f, { index });
760
778
  }
761
779
  function onPivotChipDragStart(field: string, e: DragEvent) {
762
780
  e.dataTransfer!.effectAllowed = "move";
@@ -768,12 +786,13 @@ function onPivotChipDragOver(e: DragEvent) {
768
786
  e.stopPropagation();
769
787
  }
770
788
 
771
- // 행 높이 + rowStyle — 가상 스크롤은 고정, 아니면 autoRowHeight 추정치 적용
789
+ // 행 높이 + rowStyle — 가상 스크롤은 슬라이스 높이(가변)/고정, 아니면 autoRowHeight 추정치
772
790
  function rowStyleOf(entry: AnyRow, rowIdx: number) {
773
791
  const row = rowDataOf(entry);
774
792
  const base: Record<string, string> = {};
775
- const h =
776
- virtual.value && props.rowHeight ? props.rowHeight : grid.getRowHeight(row);
793
+ const h = virtual.value
794
+ ? (virtual.value.heights?.[rowIdx] ?? props.rowHeight)
795
+ : grid.getRowHeight(row);
777
796
  if (h) base.height = `${h}px`;
778
797
  // GridOptions/ColumnDef.rowStyle — kebab-case 맵 병합 (Vue :style이 그대로 적용)
779
798
  const custom = grid.getRowStyle(row, entryIndexOf(entry, rowIdx));
@@ -784,7 +803,7 @@ function rowStyleOf(entry: AnyRow, rowIdx: number) {
784
803
  // 그룹 패널 칩 — 클릭 시 해당 컬럼 그룹 해제
785
804
  function ungroupField(field: string) {
786
805
  grid.setGroupBy(
787
- state.value.groupBy.filter((f) => f !== field) as (keyof RowT & string)[],
806
+ state.value.groupBy.filter<keyof RowT & string>((f) => f !== field),
788
807
  );
789
808
  }
790
809
 
@@ -843,7 +862,7 @@ const bodyRows = computed<AnyRow[]>(() => {
843
862
  const v = virtual.value;
844
863
  return v ? displayRows.slice(v.startIndex, v.endIndex) : displayRows;
845
864
  }
846
- return (state.value.virtualRows || state.value.rows) as AnyRow[];
865
+ return state.value.virtualRows || state.value.rows;
847
866
  });
848
867
  const colSpan = computed(
849
868
  () =>
@@ -876,27 +895,16 @@ const activeFilterCount = computed(
876
895
  () => Object.keys(state.value.filters).length,
877
896
  );
878
897
  const bottomOffset = computed(() =>
879
- virtual.value && props.rowHeight
880
- ? Math.max(
881
- 0,
882
- virtual.value.totalHeight - virtual.value.endIndex * props.rowHeight,
883
- )
884
- : 0,
898
+ virtual.value ? virtual.value.endOffset : 0,
885
899
  );
886
900
 
887
901
  // ── 컬럼 고정: [Left | Scrollable | Right] 파티션 + sticky 오프셋 ──
888
- const lastLeftPinIdx = computed(() =>
889
- state.value.visibleColumns.reduce(
890
- (acc, c, i) => (c.pinned === "left" ? i : acc),
891
- -1,
892
- ),
893
- );
894
- const firstRightPinIdx = computed(() =>
895
- state.value.visibleColumns.findIndex((c) => c.pinned === "right"),
896
- );
897
- const hasPinned = computed(
898
- () => lastLeftPinIdx.value >= 0 || firstRightPinIdx.value >= 0,
899
- );
902
+ // 파티션 계산은 adapterDom 공용 — 템플릿의 edge 클래스 바인딩은
903
+ // lastLeftPinIdx/firstRightPinIdx 이름을 유지해 diff를 최소화한다
904
+ const pinPart = computed(() => pinPartition(state.value.visibleColumns));
905
+ const lastLeftPinIdx = computed(() => pinPart.value.lastLeftPinIdx);
906
+ const firstRightPinIdx = computed(() => pinPart.value.firstRightPinIdx);
907
+ const hasPinned = computed(() => pinPart.value.hasPinned);
900
908
  const hasAppend = computed(() => !!state.value.appendScroll);
901
909
 
902
910
  // ── 컬럼 가상화 — 윈도우 밖 연속 구간을 spacer 셀로 대체 ──
@@ -919,15 +927,11 @@ const renderCols = computed(() =>
919
927
  );
920
928
 
921
929
  function pinStyleOf(col: ColumnDef<RowT>): CSSProperties | undefined {
922
- if (!col.pinned) return undefined;
923
930
  // 논리 인셋 — pinned:"left"는 inline-start라 dir="rtl"이면 우측에 붙는다
924
- const side =
925
- col.pinned === "left" ? "inset-inline-start" : "inset-inline-end";
926
- return {
927
- position: "sticky",
928
- width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px`,
929
- [side]: `${state.value.pinOffsets[col.field] ?? 0}px`,
930
- };
931
+ // 계산은 adapterDom 공용 (5개 렌더러 동일 계약). PinStyleProps는 Vue
932
+ // CSSProperties가 요구하는 CSS 변수 인덱스 시그니처가 없어 캐스트한다
933
+ return pinStyleProps(col, state.value.pinOffsets) as
934
+ CSSProperties | undefined;
931
935
  }
932
936
 
933
937
  // ── 다중 정렬 ──
@@ -972,7 +976,7 @@ function onLoadMore() {
972
976
 
973
977
  // ── 컨텍스트 메뉴 + 셀 타입 ──
974
978
  function onHeaderContextMenu(e: MouseEvent, col: ColumnDef): void {
975
- if (grid.openHeaderContextMenu(e.clientX, e.clientY, col.field)) {
979
+ if (grid.openHeaderContextMenu(e.clientX, e.clientY, colKeyOf(col))) {
976
980
  e.preventDefault();
977
981
  }
978
982
  }
@@ -982,26 +986,33 @@ function onCellContextMenu(
982
986
  rowIndex: number,
983
987
  col: ColumnDef,
984
988
  ): void {
985
- if (grid.openContextMenu(e.clientX, e.clientY, rowIndex, col.field)) {
989
+ if (grid.openContextMenu(e.clientX, e.clientY, rowIndex, colKeyOf(col))) {
986
990
  e.preventDefault();
987
991
  }
988
992
  }
989
993
 
994
+ // 터치 제스처의 릴리즈 클릭 삼킘 해제 함수 레지스트리 — 언마운트 시
995
+ // 일괄 해제해, 삼킘 리스너가 다음 무관한 클릭을 삼키는 것을 막는다
996
+ const swallows = new Set<() => void>();
997
+ onBeforeUnmount(() => {
998
+ swallows.forEach((fn) => fn());
999
+ swallows.clear();
1000
+ });
990
1001
  // 터치 롱프레스 → contextmenu와 동일 동작 (헤더/셀 공용 트래커)
991
- const lp = createLongPressTracker();
1002
+ const lp = createLongPressTracker({ registry: swallows });
992
1003
 
993
1004
  function onCellPointerDown(
994
1005
  e: PointerEvent,
995
1006
  rowIndex: number,
996
1007
  col: ColumnDef,
997
1008
  ): void {
998
- lp.down(e, (x, y) => grid.openContextMenu(x, y, rowIndex, col.field));
1009
+ lp.down(e, (x, y) => grid.openContextMenu(x, y, rowIndex, colKeyOf(col)));
999
1010
  }
1000
1011
 
1001
1012
  function onHeaderPointerDown(e: PointerEvent, col: ColumnDef): void {
1002
- lp.down(e, (x, y) => grid.openHeaderContextMenu(x, y, col.field));
1013
+ lp.down(e, (x, y) => grid.openHeaderContextMenu(x, y, colKeyOf(col)));
1003
1014
  if (props.reorderable && col.movable !== false)
1004
- touchDrag.col.down(e, col.field);
1015
+ touchDrag.col.down(e, colKeyOf(col));
1005
1016
  }
1006
1017
 
1007
1018
  // ── 터치 커스텀 DnD — iOS/Android는 HTML5 DnD가 없어 포인터 제스처로 보강 ──
@@ -1054,16 +1065,13 @@ function touchRowDropAt(
1054
1065
  const rowIndex = Number(td.getAttribute("data-mg-row"));
1055
1066
  const tr = td.closest("tr");
1056
1067
  if (Number.isNaN(rowIndex) || !tr) return null;
1057
- const rect = tr.getBoundingClientRect();
1058
- const ratio = (y - rect.top) / rect.height;
1059
- // 트리 모드는 상하 25%=before/after, 가운데 50%=inside
1060
- if (grid.isTreeRowDraggable()) {
1061
- return {
1062
- index: rowIndex,
1063
- position: ratio < 0.25 ? "before" : ratio > 0.75 ? "after" : "inside",
1064
- };
1065
- }
1066
- return { index: ratio < 0.5 ? rowIndex : rowIndex + 1 };
1068
+ // 트리는 상하 25%=before/after·가운데 50%=inside, 평면은 상하반 gap
1069
+ // — adapterDom의 단일 드롭 계약
1070
+ return resolveRowDrop(
1071
+ dropRatioForY(y, tr.getBoundingClientRect()),
1072
+ rowIndex,
1073
+ grid.isTreeRowDraggable(),
1074
+ );
1067
1075
  }
1068
1076
 
1069
1077
  function applyTouchDrop(
@@ -1096,71 +1104,83 @@ function clearTouchDropMarks(): void {
1096
1104
 
1097
1105
  const touchDrag = {
1098
1106
  // 컬럼 헤더 — 수평 이동으로 확정 (th는 touch-action: pan-y)
1099
- col: createTouchDrag<string>("x", {
1100
- start: (field: string) => {
1101
- // 롱프레스 메뉴가 이미 열렸으면 드래그로 전환하지 않는다
1102
- if (grid.getSnapshot().contextMenu) return false;
1103
- lp.end();
1104
- touchColFieldRaw = field;
1105
- touchColField.value = field;
1106
- return true;
1107
- },
1108
- move: (_x: number, _y: number, target: Element | null) => {
1109
- const hit = touchHitAt(target);
1110
- dragOverField.value =
1111
- hit?.kind === "column" && hit.field !== touchColFieldRaw
1112
- ? hit.field
1113
- : null;
1114
- pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
1115
- groupDropOver.value = hit?.kind === "group";
1116
- },
1117
- up: (_x: number, _y: number, target: Element | null, field: string) => {
1118
- applyTouchDrop(touchHitAt(target), field);
1119
- clearTouchDropMarks();
1120
- touchColFieldRaw = null;
1121
- touchColField.value = null;
1122
- },
1123
- cancel: () => {
1124
- clearTouchDropMarks();
1125
- touchColFieldRaw = null;
1126
- touchColField.value = null;
1107
+ col: createTouchDrag<string>(
1108
+ "x",
1109
+ {
1110
+ start: (field: string) => {
1111
+ // 롱프레스 메뉴가 이미 열렸으면 드래그로 전환하지 않는다
1112
+ if (grid.getSnapshot().contextMenu) return false;
1113
+ lp.end();
1114
+ touchColFieldRaw = field;
1115
+ touchColField.value = field;
1116
+ return true;
1117
+ },
1118
+ move: (_x: number, _y: number, target: Element | null) => {
1119
+ const hit = touchHitAt(target);
1120
+ dragOverField.value =
1121
+ hit?.kind === "column" && hit.field !== touchColFieldRaw
1122
+ ? hit.field
1123
+ : null;
1124
+ pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
1125
+ groupDropOver.value = hit?.kind === "group";
1126
+ },
1127
+ up: (_x: number, _y: number, target: Element | null, field: string) => {
1128
+ applyTouchDrop(touchHitAt(target), field);
1129
+ clearTouchDropMarks();
1130
+ touchColFieldRaw = null;
1131
+ touchColField.value = null;
1132
+ },
1133
+ cancel: () => {
1134
+ clearTouchDropMarks();
1135
+ touchColFieldRaw = null;
1136
+ touchColField.value = null;
1137
+ },
1127
1138
  },
1128
- }),
1139
+ { registry: swallows },
1140
+ ),
1129
1141
  // 행 드래그 핸들 — 세로 이동으로 확정 (핸들은 touch-action: none)
1130
- row: createTouchDrag<number>("y", {
1131
- start: (rowIndex: number) => {
1132
- lp.end();
1133
- return grid.beginRowDrag(rowIndex);
1134
- },
1135
- move: (_x: number, y: number, target: Element | null) => {
1136
- const drop = touchRowDropAt(target, y);
1137
- if (drop != null) grid.updateRowDropPosition(drop.index, drop.position);
1142
+ row: createTouchDrag<number>(
1143
+ "y",
1144
+ {
1145
+ start: (rowIndex: number) => {
1146
+ lp.end();
1147
+ return grid.beginRowDrag(rowIndex);
1148
+ },
1149
+ move: (_x: number, y: number, target: Element | null) => {
1150
+ const drop = touchRowDropAt(target, y);
1151
+ if (drop != null) grid.updateRowDropPosition(drop.index, drop.position);
1152
+ },
1153
+ up: () => grid.endRowDrag(true),
1154
+ cancel: () => grid.endRowDrag(false),
1138
1155
  },
1139
- up: () => grid.endRowDrag(true),
1140
- cancel: () => grid.endRowDrag(false),
1141
- }),
1156
+ { registry: swallows },
1157
+ ),
1142
1158
  // 피벗 칩 — 아무 방향이든 이동으로 확정 (칩은 touch-action: none)
1143
- chip: createTouchDrag<string>("any", {
1144
- move: (_x: number, _y: number, target: Element | null) => {
1145
- const hit = touchHitAt(target);
1146
- pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
1147
- },
1148
- up: (_x: number, _y: number, target: Element | null, field: string) => {
1149
- const hit = touchHitAt(target);
1150
- pivotDropZone.value = null;
1151
- if (hit?.kind !== "pivot") return;
1152
- if (hit.zone === "fields") grid.removePivotField(field);
1153
- else
1154
- grid.addPivotField(
1155
- hit.zone as PivotZone,
1156
- field,
1157
- hit.index != null ? { index: hit.index } : {},
1158
- );
1159
- },
1160
- cancel: () => {
1161
- pivotDropZone.value = null;
1159
+ chip: createTouchDrag<string>(
1160
+ "any",
1161
+ {
1162
+ move: (_x: number, _y: number, target: Element | null) => {
1163
+ const hit = touchHitAt(target);
1164
+ pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
1165
+ },
1166
+ up: (_x: number, _y: number, target: Element | null, field: string) => {
1167
+ const hit = touchHitAt(target);
1168
+ pivotDropZone.value = null;
1169
+ if (hit?.kind !== "pivot") return;
1170
+ if (hit.zone === "fields") grid.removePivotField(field);
1171
+ else
1172
+ grid.addPivotField(
1173
+ hit.zone as PivotZone,
1174
+ field,
1175
+ hit.index != null ? { index: hit.index } : {},
1176
+ );
1177
+ },
1178
+ cancel: () => {
1179
+ pivotDropZone.value = null;
1180
+ },
1162
1181
  },
1163
- }),
1182
+ { registry: swallows },
1183
+ ),
1164
1184
  };
1165
1185
 
1166
1186
  function onPivotChipPointerDown(field: string, e: PointerEvent): void {
@@ -1203,48 +1223,18 @@ onMounted(() => {
1203
1223
  });
1204
1224
  });
1205
1225
 
1206
- function cellPosFromPoint(
1207
- x: number,
1208
- y: number,
1209
- ): { row: number; col: number } | null {
1210
- const el = document.elementFromPoint(x, y)?.closest("td[data-mg-row]");
1211
- if (!el) return null;
1212
- const row = Number(el.getAttribute("data-mg-row"));
1213
- const col = Number(el.getAttribute("data-mg-col"));
1214
- return Number.isNaN(row) || Number.isNaN(col) ? null : { row, col };
1215
- }
1216
-
1217
- let fillSource: {
1218
- startRow: number;
1219
- endRow: number;
1220
- startCol: number;
1221
- endCol: number;
1222
- } | null = null;
1226
+ // 진행 중 포인터 드래그의 취소 함수 — 언마운트 시 document 리스너 해제
1227
+ let dragCancel: (() => void) | null = null;
1228
+ onBeforeUnmount(() => dragCancel?.());
1223
1229
 
1230
+ // 채우기 핸들 — 릴리즈 좌표까지 범위 확장+fill은 adapterDom 컨트롤러.
1231
+ // hostEl을 넘겨 그리드 밖(다른 그리드 셀) 릴리즈를 무시한다
1224
1232
  function onFillPointerDown(e: PointerEvent): void {
1225
1233
  e.preventDefault();
1226
1234
  e.stopPropagation();
1227
1235
  const src = state.value.selectedRange;
1228
1236
  if (!src) return;
1229
- fillSource = { ...src };
1230
- const onUp = (ev: PointerEvent) => {
1231
- window.removeEventListener("pointerup", onUp);
1232
- window.removeEventListener("pointercancel", onUp);
1233
- const source = fillSource;
1234
- fillSource = null;
1235
- const pos = cellPosFromPoint(ev.clientX, ev.clientY);
1236
- if (!source || !pos) return;
1237
- const target = {
1238
- startRow: Math.min(source.startRow, pos.row),
1239
- endRow: Math.max(source.endRow, pos.row),
1240
- startCol: Math.min(source.startCol, pos.col),
1241
- endCol: Math.max(source.endCol, pos.col),
1242
- };
1243
- grid.fillRange(source, target);
1244
- grid.setCellRange(target);
1245
- };
1246
- window.addEventListener("pointerup", onUp);
1247
- window.addEventListener("pointercancel", onUp);
1237
+ dragCancel = startFillDrag(e, src, grid, hostEl.value);
1248
1238
  }
1249
1239
 
1250
1240
  function cellLinkHref(row: RowData, col: ColumnDef): string {
@@ -1269,7 +1259,7 @@ function filterOpsOf(col: ColumnDef<Record<string, unknown>>) {
1269
1259
  }
1270
1260
 
1271
1261
  function filterOpOf(col: ColumnDef<Record<string, unknown>>): FilterOperator {
1272
- const f = state.value.filters[col.field];
1262
+ const f = state.value.filters[colKeyOf(col)];
1273
1263
  return f ? f.operator : DEFAULT_OPERATOR_BY_TYPE[col.filterType || "text"];
1274
1264
  }
1275
1265
 
@@ -1282,7 +1272,7 @@ function filterValueOf(
1282
1272
  col: ColumnDef<Record<string, unknown>>,
1283
1273
  key: "value" | "valueTo",
1284
1274
  ) {
1285
- const f = state.value.filters[col.field];
1275
+ const f = state.value.filters[colKeyOf(col)];
1286
1276
  return f ? f[key] || "" : "";
1287
1277
  }
1288
1278
 
@@ -1290,8 +1280,8 @@ function updateFilter(
1290
1280
  col: ColumnDef<Record<string, unknown>>,
1291
1281
  patch: Partial<ColumnFilter>,
1292
1282
  ) {
1293
- const f = state.value.filters[col.field];
1294
- grid.setFilter(col.field, {
1283
+ const f = state.value.filters[colKeyOf(col)];
1284
+ grid.setFilter(colKeyOf(col), {
1295
1285
  operator: filterOpOf(col),
1296
1286
  value: f ? f.value : "",
1297
1287
  valueTo: f ? f.valueTo : undefined,
@@ -1322,23 +1312,23 @@ function isSetFilter(col: ColumnDef<Record<string, unknown>>) {
1322
1312
  }
1323
1313
 
1324
1314
  function setValuesOf(col: ColumnDef<Record<string, unknown>>): string[] {
1325
- return grid.getUniqueValues(col.field);
1315
+ return grid.getUniqueValues(colKeyOf(col));
1326
1316
  }
1327
1317
 
1328
1318
  function setFilterLabel(col: ColumnDef<Record<string, unknown>>) {
1329
- const f = state.value.filters[col.field];
1319
+ const f = state.value.filters[colKeyOf(col)];
1330
1320
  const vals = f && f.values;
1331
1321
  return vals ? state.value.locale.setFilterCount(vals.length) : "전체";
1332
1322
  }
1333
1323
 
1334
1324
  function setCheckedOf(col: ColumnDef<Record<string, unknown>>, v: string) {
1335
- const f = state.value.filters[col.field];
1325
+ const f = state.value.filters[colKeyOf(col)];
1336
1326
  const vals = f && f.values;
1337
1327
  return vals ? vals.includes(v) : true;
1338
1328
  }
1339
1329
 
1340
1330
  function setAllCheckedOf(col: ColumnDef<Record<string, unknown>>) {
1341
- const f = state.value.filters[col.field];
1331
+ const f = state.value.filters[colKeyOf(col)];
1342
1332
  const vals = f && f.values;
1343
1333
  return !vals || vals.length >= setValuesOf(col).length;
1344
1334
  }
@@ -1350,13 +1340,13 @@ function onSetToggle(
1350
1340
  ) {
1351
1341
  const checked = (event.target as HTMLInputElement).checked;
1352
1342
  const all = setValuesOf(col);
1353
- const f = state.value.filters[col.field];
1343
+ const f = state.value.filters[colKeyOf(col)];
1354
1344
  const next = new Set((f && f.values) || all);
1355
1345
  if (checked) next.add(v);
1356
1346
  else next.delete(v);
1357
- if (next.size >= all.length) grid.setFilter(col.field, null);
1347
+ if (next.size >= all.length) grid.setFilter(colKeyOf(col), null);
1358
1348
  else {
1359
- grid.setFilter(col.field, {
1349
+ grid.setFilter(colKeyOf(col), {
1360
1350
  operator: "set",
1361
1351
  value: "",
1362
1352
  values: [...next],
@@ -1400,7 +1390,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
1400
1390
  }
1401
1391
  : {
1402
1392
  kind: "col" as const,
1403
- key: it.col.field,
1393
+ key: colKeyOf(it.col),
1404
1394
  col: it.col,
1405
1395
  colIndex: it.index,
1406
1396
  },
@@ -1417,7 +1407,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
1417
1407
  }
1418
1408
  : {
1419
1409
  kind: "col",
1420
- key: cols[s.startIndex]!.field,
1410
+ key: colKeyOf(cols[s.startIndex]!),
1421
1411
  col: cols[s.startIndex]!,
1422
1412
  colIndex: s.startIndex,
1423
1413
  rowSpan: 2,
@@ -1427,7 +1417,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
1427
1417
  s.groupId
1428
1418
  ? cols.slice(s.startIndex, s.startIndex + s.colSpan).map((col, i) => ({
1429
1419
  kind: "col" as const,
1430
- key: col.field,
1420
+ key: colKeyOf(col),
1431
1421
  col,
1432
1422
  colIndex: s.startIndex + i,
1433
1423
  }))
@@ -1438,73 +1428,35 @@ const headerRows = computed<HeaderCell[][]>(() => {
1438
1428
 
1439
1429
  const headerRowSpan = computed(() => headerRows.value.length);
1440
1430
 
1441
- // ── 컬럼 리사이즈: document pointermove를 rAF로 스로틀 ──
1442
- // pointerdown/move/up — 마우스·터치·펜 공통 경로 (핸들은 touch-action:none)
1443
- let resizeRaf = 0;
1444
- let pendingWidth: { field: string; width: number } | null = null;
1445
-
1431
+ // ── 리사이즈: document 포인터 추적은 adapterDom 컨트롤러에 위임 ──
1432
+ // rAF 스로틀·RTL 부호 반전·최종값 확정이 코어에 단일화돼 있다
1446
1433
  function onResizeStart(col: ColumnDef, event: PointerEvent) {
1447
- const th = (event.currentTarget as HTMLElement).closest("th");
1448
- const startWidth = th?.getBoundingClientRect().width ?? 0;
1449
- const startX = event.clientX;
1450
- const field = col.field;
1451
-
1452
- const onMove = (ev: PointerEvent) => {
1453
- pendingWidth = { field, width: startWidth + (ev.clientX - startX) };
1454
- if (resizeRaf === 0) {
1455
- resizeRaf = requestAnimationFrame(() => {
1456
- resizeRaf = 0;
1457
- if (pendingWidth)
1458
- grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
1459
- });
1460
- }
1461
- };
1462
- const onUp = () => {
1463
- document.removeEventListener("pointermove", onMove);
1464
- document.removeEventListener("pointerup", onUp);
1465
- document.removeEventListener("pointercancel", onUp);
1466
- if (resizeRaf !== 0) {
1467
- cancelAnimationFrame(resizeRaf);
1468
- resizeRaf = 0;
1469
- }
1470
- if (pendingWidth)
1471
- grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
1472
- pendingWidth = null;
1473
- };
1474
- document.addEventListener("pointermove", onMove);
1475
- document.addEventListener("pointerup", onUp);
1476
- document.addEventListener("pointercancel", onUp);
1434
+ dragCancel = startColumnResize(event, {
1435
+ field: colKeyOf(col),
1436
+ dir: grid.getSnapshot().dir,
1437
+ setWidth: (f, w) => grid.setColumnWidth(f, w),
1438
+ });
1477
1439
  }
1478
1440
 
1479
1441
  // ── 행 높이 리사이즈: 행 번호 셀 하단 핸들 드래그 → setRowHeight ──
1480
1442
  function onRowResizeStart(rowId: string, event: PointerEvent) {
1481
1443
  event.preventDefault();
1482
1444
  event.stopPropagation();
1483
- const tr = (event.currentTarget as HTMLElement).closest("tr");
1484
- const startHeight = tr?.getBoundingClientRect().height ?? 0;
1485
- const startY = event.clientY;
1486
- const onMove = (ev: PointerEvent) => {
1487
- grid.setRowHeight(rowId, Math.max(16, startHeight + (ev.clientY - startY)));
1488
- };
1489
- const onUp = () => {
1490
- document.removeEventListener("pointermove", onMove);
1491
- document.removeEventListener("pointerup", onUp);
1492
- document.removeEventListener("pointercancel", onUp);
1493
- };
1494
- document.addEventListener("pointermove", onMove);
1495
- document.addEventListener("pointerup", onUp);
1496
- document.addEventListener("pointercancel", onUp);
1445
+ dragCancel = startRowResize(event, {
1446
+ setHeight: (h) => grid.setRowHeight(rowId, h),
1447
+ });
1497
1448
  }
1498
1449
 
1499
1450
  // 키보드 리사이즈 (방향키 ±10px)
1500
1451
  function onResizerKeydown(col: ColumnDef, event: KeyboardEvent) {
1501
- const delta =
1502
- event.key === "ArrowLeft" ? -10 : event.key === "ArrowRight" ? 10 : 0;
1452
+ if (event.isComposing) return;
1453
+ // ±10px — RTL 부호 반전은 adapterDom 계약
1454
+ const delta = resizeKeyDelta(event.key, grid.getSnapshot().dir);
1503
1455
  if (delta === 0) return;
1504
1456
  event.preventDefault();
1505
1457
  const th = (event.currentTarget as HTMLElement).closest("th");
1506
1458
  const w = th?.getBoundingClientRect().width ?? col.width ?? 0;
1507
- grid.setColumnWidth(col.field, w + delta);
1459
+ grid.setColumnWidth(colKeyOf(col), w + delta);
1508
1460
  }
1509
1461
 
1510
1462
  // ── 컬럼 드래그 재배치 (HTML5 DnD) ──
@@ -1512,25 +1464,26 @@ const dragOverField = ref<string | null>(null);
1512
1464
  let dragField: string | null = null;
1513
1465
 
1514
1466
  function onDragStart(col: ColumnDef, event: DragEvent) {
1515
- dragField = col.field;
1467
+ dragField = colKeyOf(col);
1516
1468
  if (event.dataTransfer) {
1517
1469
  event.dataTransfer.effectAllowed = "move";
1518
- event.dataTransfer.setData("text/plain", col.field);
1519
- event.dataTransfer.setData("application/x-mg-column", col.field);
1470
+ event.dataTransfer.setData("text/plain", colKeyOf(col));
1471
+ event.dataTransfer.setData("application/x-mg-column", colKeyOf(col));
1520
1472
  }
1521
1473
  }
1522
1474
 
1523
1475
  function onDragOver(col: ColumnDef, event: DragEvent) {
1524
- if (!props.reorderable || !dragField || dragField === col.field) return;
1476
+ if (!props.reorderable || !dragField || dragField === colKeyOf(col)) return;
1525
1477
  event.preventDefault();
1526
1478
  if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
1527
- if (dragOverField.value !== col.field) dragOverField.value = col.field;
1479
+ if (dragOverField.value !== colKeyOf(col))
1480
+ dragOverField.value = colKeyOf(col);
1528
1481
  }
1529
1482
 
1530
1483
  function onDrop(col: ColumnDef, event: DragEvent) {
1531
1484
  event.preventDefault();
1532
- if (dragField && dragField !== col.field) {
1533
- grid.reorderColumn(dragField, col.field);
1485
+ if (dragField && dragField !== colKeyOf(col)) {
1486
+ grid.reorderColumn(dragField, colKeyOf(col));
1534
1487
  }
1535
1488
  onDragEnd();
1536
1489
  }
@@ -1593,39 +1546,8 @@ function rowStateOf(row: RowT | null | undefined) {
1593
1546
  return row ? state.value.rowStates[grid.getRowId(row)] : undefined;
1594
1547
  }
1595
1548
 
1596
- /** 변경(I/U/D) 행의 셀 유효성 에러 — required/validate 검사. 없으면 null. */
1597
- function cellErrorOf(entry: AnyRow, col: ColumnDef): string | null {
1598
- const row = rowDataOf(entry);
1599
- if (!row) return null;
1600
- // setCellError 수동 마킹은 행 상태·validate 유무와 무관하게 표시한다
1601
- if (grid.hasManualCellError(row, col)) return grid.getCellError(row, col);
1602
- if (!rowStateOf(row)) return null;
1603
- if (!col.required && !col.validate) return null;
1604
- return grid.getCellError(row, col);
1605
- }
1606
-
1607
- /** 셀 노트 텍스트 — 있으면 td에 mg-cell-note 클래스 + title로 표시 */
1608
- function cellNoteOf(entry: AnyRow, col: ColumnDef): string | null {
1609
- const row = rowDataOf(entry);
1610
- if (row == null) return null;
1611
- return grid.getCellNote(row, col);
1612
- }
1613
-
1614
- function cellClassOf(entry: AnyRow, rowIdx: number, col: ColumnDef) {
1615
- const row = rowDataOf(entry);
1616
- if (row == null) return "";
1617
- return grid.getCellClass(row, entryIndexOf(entry, rowIdx), col);
1618
- }
1619
-
1620
- /** find 하이라이트 — findBox 검색어에 매치되는 셀인지 (그룹 헤더 등 null 행 제외) */
1621
- function isFindMatch(entry: AnyRow, col: ColumnDef): boolean {
1622
- const row = rowDataOf(entry);
1623
- return (
1624
- !!state.value.findQuery &&
1625
- row != null &&
1626
- grid.isFindMatch(row, String(col.field))
1627
- );
1628
- }
1549
+ // 셀 유효성 에러/노트/find 매칭/사용자 cellClass 표현은 코어
1550
+ // describeCell로 이동했다 (cellDescOf가 호출)
1629
1551
 
1630
1552
  function onRowDragStart(rowIndex: number, event: DragEvent) {
1631
1553
  if (!grid.beginRowDrag(rowIndex)) {
@@ -1645,17 +1567,13 @@ function onRowDragOver(rowIndex: number, event: DragEvent) {
1645
1567
  event.preventDefault();
1646
1568
  if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
1647
1569
  const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
1648
- const ratio = (event.clientY - rect.top) / rect.height;
1649
- // 트리 모드 — 상하 25%는 형제 위/아래, 가운데 50%는 자식(inside)
1650
- if (grid.isTreeRowDraggable()) {
1651
- grid.updateRowDropPosition(
1652
- rowIndex,
1653
- ratio < 0.25 ? "before" : ratio > 0.75 ? "after" : "inside",
1654
- );
1655
- return;
1656
- }
1657
- const gap = ratio < 0.5 ? rowIndex : rowIndex + 1;
1658
- grid.updateRowDropPosition(gap);
1570
+ // 트리는 상하 25%가 형제 위/아래·가운데 50%가 자식 — adapterDom 계약
1571
+ const drop = resolveRowDrop(
1572
+ dropRatioForY(event.clientY, rect),
1573
+ rowIndex,
1574
+ grid.isTreeRowDraggable(),
1575
+ );
1576
+ grid.updateRowDropPosition(drop.index, drop.position);
1659
1577
  }
1660
1578
 
1661
1579
  function onRowDrop(event: DragEvent) {
@@ -1669,192 +1587,24 @@ function onRowDragEnd() {
1669
1587
  }
1670
1588
 
1671
1589
  // ── 셀 선택: 방향키/Home/End/PageUp·Down → 코어 네비게이션 ──
1672
- const CELL_KEYS: Record<string, CellNavigation> = {
1673
- ArrowUp: "up",
1674
- ArrowDown: "down",
1675
- ArrowLeft: "left",
1676
- ArrowRight: "right",
1677
- Home: "home",
1678
- End: "end",
1679
- PageUp: "pageUp",
1680
- PageDown: "pageDown",
1681
- };
1682
-
1590
+ // 키 계약 전체(클립보드/이력/Escape/Delete/Tab/Enter/방향키/인쇄문자)는
1591
+ // adapterDom.handleGridKeydown에 단일화 — 5개 렌더러가 같은 코드를 실행한다
1683
1592
  function onGridKeydown(event: KeyboardEvent) {
1684
- if (event.isComposing) return; // IME 조합 중 — 조합 확정 키가 그리드 키로 해석되지 않도록
1685
- if ((event.target as HTMLElement).closest("input, textarea, select")) return;
1686
- // 클립보드/이력: Ctrl+C 복사, Ctrl+Shift+C 헤더 포함 복사,
1687
- // Ctrl+V 붙여넣기, Ctrl+Z 되돌리기, Ctrl+Y·Ctrl+Shift+Z 다시 실행
1688
- if (event.ctrlKey || event.metaKey) {
1689
- const key = event.key.toLowerCase();
1690
- if (key === "c") {
1691
- const tsv = grid.getSelectionTsv({ includeHeaders: event.shiftKey });
1692
- if (tsv != null) {
1693
- event.preventDefault();
1694
- void writeClipboardText(tsv);
1695
- }
1696
- } else if (key === "x") {
1697
- const tsv = grid.cutSelectionTsv(); // 엑셀 Ctrl+X — 잘라내기
1698
- if (tsv != null) {
1699
- event.preventDefault();
1700
- void writeClipboardText(tsv);
1701
- }
1702
- } else if (key === "v") {
1703
- event.preventDefault();
1704
- void readClipboardText().then((text) => {
1705
- if (text != null) grid.pasteTsv(text);
1706
- });
1707
- } else if (key === "z") {
1708
- event.preventDefault();
1709
- if (event.shiftKey) grid.redo();
1710
- else grid.undo();
1711
- } else if (key === "y") {
1712
- event.preventDefault();
1713
- grid.redo();
1714
- } else if (key === "a") {
1715
- // single-cell 모드의 selectAll은 전체 행 선택 — selectable일 때만
1716
- if (
1717
- state.value.selectionMode === "single-cell" &&
1718
- props.selectable === false
1719
- )
1720
- return;
1721
- event.preventDefault();
1722
- grid.selectAll();
1723
- } else if (key === "f") {
1724
- if (!props.findBox) return; // findBox 없으면 브라우저 검색에 양보
1725
- event.preventDefault();
1726
- findInputEl.value?.focus();
1727
- findInputEl.value?.select();
1728
- } else if (key === "d") {
1729
- event.preventDefault();
1730
- grid.fillDown(); // 엑셀 Ctrl+D — 아래 채우기
1731
- } else if (key === "r") {
1732
- event.preventDefault();
1733
- grid.fillRight(); // 엑셀 Ctrl+R — 오른쪽 채우기
1734
- } else if (event.key === "Home") {
1735
- event.preventDefault();
1736
- grid.navigateCell("first", event.shiftKey); // Ctrl+Home — 첫 셀
1737
- } else if (event.key === "End") {
1738
- event.preventDefault();
1739
- grid.navigateCell("last", event.shiftKey); // Ctrl+End — 마지막 셀
1740
- } else if (event.key === "ArrowUp") {
1741
- event.preventDefault();
1742
- grid.navigateCell("top", event.shiftKey);
1743
- } else if (event.key === "ArrowDown") {
1744
- event.preventDefault();
1745
- grid.navigateCell("bottom", event.shiftKey);
1746
- } else if (event.key === "ArrowLeft") {
1747
- event.preventDefault();
1748
- // Ctrl+←는 시각적 왼쪽 가장자리 — RTL에서는 논리적으로 마지막 컬럼
1749
- grid.navigateCell(
1750
- state.value.dir === "rtl" ? "end" : "home",
1751
- event.shiftKey,
1752
- );
1753
- } else if (event.key === "ArrowRight") {
1754
- event.preventDefault();
1755
- grid.navigateCell(
1756
- state.value.dir === "rtl" ? "home" : "end",
1757
- event.shiftKey,
1758
- );
1759
- } else if (event.key === " ") {
1760
- event.preventDefault();
1761
- grid.selectEntireColumn(); // 엑셀 Ctrl+Space — 열 선택
1762
- }
1763
- return;
1764
- }
1765
- if (event.key === "Escape") {
1766
- if (state.value.rowDrag) grid.endRowDrag(false);
1767
- else grid.clearCellSelection();
1768
- return;
1769
- }
1770
- if (event.key === "Delete" || event.key === "Backspace") {
1771
- // 선택 영역(없으면 활성 셀) 내용 지우기 — 타사 그리드 Del키 대응
1772
- event.preventDefault();
1773
- grid.clearRange();
1774
- return;
1775
- }
1776
- const active = state.value.activeCell;
1777
- if (event.key === " " && event.shiftKey) {
1778
- // 엑셀 Shift+Space — 행 선택 (타이핑 경로보다 먼저 처리).
1779
- // single-cell은 행 선택으로 대체되므로 selectable을 게이트한다
1780
- if (
1781
- state.value.selectionMode === "single-cell" &&
1782
- props.selectable === false
1783
- )
1784
- return;
1785
- event.preventDefault();
1786
- grid.selectEntireRow();
1787
- return;
1788
- }
1789
- if (event.key === "Tab" && active) {
1790
- // 엑셀 Tab — 활성 셀 좌/우 이동
1791
- event.preventDefault();
1792
- grid.navigateCell(event.shiftKey ? "tabLeft" : "tabRight");
1793
- return;
1794
- }
1795
- if (event.key === "Enter" || event.key === "F2") {
1796
- // 활성 셀에서 Enter → 편집 진입
1797
- if (active) {
1798
- event.preventDefault();
1799
- grid.startEditing(active.rowIndex, active.columnIndex);
1800
- }
1801
- return;
1802
- }
1803
- const dir = CELL_KEYS[event.key];
1804
- if (dir) {
1805
- event.preventDefault();
1806
- grid.navigateCell(dir, event.shiftKey);
1807
- return;
1808
- }
1809
- // 인쇄 가능한 문자 직접 입력 → 값을 교체하며 편집 진입
1810
- if (
1811
- event.key.length === 1 &&
1812
- !event.ctrlKey &&
1813
- !event.metaKey &&
1814
- !event.altKey &&
1815
- active
1816
- ) {
1817
- event.preventDefault();
1818
- grid.startEditing(active.rowIndex, active.columnIndex, event.key);
1819
- }
1593
+ handleGridKeydown(event, grid, {
1594
+ selectable: props.selectable,
1595
+ focusFind: props.findBox
1596
+ ? () => {
1597
+ findInputEl.value?.focus();
1598
+ findInputEl.value?.select();
1599
+ }
1600
+ : undefined,
1601
+ });
1820
1602
  }
1821
1603
 
1822
1604
  // 가상 스크롤/그룹화 시 행 인덱스 → visibleData 기준 인덱스
1823
- function isGroupRow(entry: AnyRow) {
1824
- return (entry as DisplayRow<RowT> | undefined)?.type === "group";
1825
- }
1826
-
1827
- function isSubtotalRow(entry: AnyRow) {
1828
- return (entry as DisplayRow<RowT> | undefined)?.type === "subtotal";
1829
- }
1830
-
1831
- function groupOf(entry: AnyRow): GroupNode<RowT> {
1832
- return entry as GroupNode<RowT>;
1833
- }
1834
-
1835
- function leafOf(entry: AnyRow): LeafDisplayRow<RowT> | null {
1836
- const e = entry as DisplayRow<RowT>;
1837
- return e && e.type === "leaf" ? (e as LeafDisplayRow<RowT>) : null;
1838
- }
1839
-
1840
- function rowDataOf(entry: AnyRow): RowT {
1841
- const l = leafOf(entry);
1842
- return l ? l.row : (entry as RowT);
1843
- }
1844
-
1845
- function leafDepthOf(entry: AnyRow) {
1846
- const l = leafOf(entry);
1847
- return l ? l.depth : 0;
1848
- }
1849
-
1850
- // 트리 노드 헬퍼 — 템플릿에서 non-null 단언(!)을 쓸 수 없어 함수로 노출
1851
- function leafHasChildren(entry: AnyRow): boolean | undefined {
1852
- return leafOf(entry)?.hasChildren;
1853
- }
1854
-
1855
- function leafExpanded(entry: AnyRow): boolean {
1856
- return leafOf(entry)?.expanded === true;
1857
- }
1605
+ // DisplayRow 판별/추출은 코어 displayRows 헬퍼를 import해 공유한다 —
1606
+ // 로컬에 두는 것은 어댑터 전용 상태(가상 스크롤, 스냅샷, grid)를
1607
+ // 읽는 wrapper뿐이다
1858
1608
 
1859
1609
  /** 전체 너비 행 판정 — leaf 행만 검사 (스켈레톤·그룹 행 제외) */
1860
1610
  function isFullWidthOf(entry: AnyRow, rowIdx: number): boolean {
@@ -1878,10 +1628,7 @@ function rowKeyOf(entry: AnyRow, rowIdx: number) {
1878
1628
  }
1879
1629
 
1880
1630
  function groupLabelOf(entry: AnyRow) {
1881
- const n = groupOf(entry);
1882
- const col = state.value.columns.find((c) => c.field === n.field);
1883
- const header = col && col.header ? col.header : n.field;
1884
- return `${header}: ${String(n.value == null ? "(빈 값)" : n.value)}`;
1631
+ return coreGroupLabelOf(groupOf(entry), state.value.columns);
1885
1632
  }
1886
1633
 
1887
1634
  function groupAggOf(entry: AnyRow, col: ColumnDef<RowT>) {
@@ -1894,9 +1641,24 @@ function onToggleGroup(entry: AnyRow) {
1894
1641
  }
1895
1642
 
1896
1643
  // ── 인라인 셀 편집 ──
1897
- // 셀 병합 정보 — td의 rowspan/colspan/hidden에 사용
1898
- function cellSpanOf(row: RowT, col: ColumnDef<RowT>) {
1899
- return grid.getCellSpan(row, col);
1644
+ // 셀 표현 디스크립터 — td의 클래스/스타일/title/병합 span은 코어
1645
+ // describeCell이 계산한다 (5개 렌더러 동일 계약, 스파스 행은 null)
1646
+ function cellDescOf(
1647
+ entry: AnyRow,
1648
+ rowIdx: number,
1649
+ col: ColumnDef,
1650
+ colIndex: number,
1651
+ ) {
1652
+ const row = rowDataOf(entry);
1653
+ if (row == null) return null;
1654
+ return describeCell(
1655
+ grid,
1656
+ row,
1657
+ entryIndexOf(entry, rowIdx),
1658
+ col,
1659
+ colIndex,
1660
+ leafHasChildren(entry) !== undefined ? leafDepthOf(entry) : null,
1661
+ );
1900
1662
  }
1901
1663
 
1902
1664
  function isEditingCell(rowIndex: number, colIndex: number) {
@@ -1907,13 +1669,13 @@ function isEditingCell(rowIndex: number, colIndex: number) {
1907
1669
  function editValueOf(col: ColumnDef) {
1908
1670
  const s = state.value;
1909
1671
  if (s.editType === "fullRow" && s.editingValues)
1910
- return s.editingValues[col.field];
1672
+ return s.editingValues[colKeyOf(col)];
1911
1673
  return s.editValue;
1912
1674
  }
1913
1675
  function editErrorOf(col: ColumnDef) {
1914
1676
  const s = state.value;
1915
1677
  if (s.editType === "fullRow" && s.editingErrors)
1916
- return s.editingErrors[col.field] ?? null;
1678
+ return s.editingErrors[colKeyOf(col)] ?? null;
1917
1679
  return s.editError;
1918
1680
  }
1919
1681
 
@@ -1929,7 +1691,7 @@ function onCellMouseDown(
1929
1691
  e: MouseEvent,
1930
1692
  rowIndex: number,
1931
1693
  colIndex: number,
1932
- col: ColumnDef,
1694
+ _col: ColumnDef,
1933
1695
  ) {
1934
1696
  if (e.button !== 0 || isEditingCell(rowIndex, colIndex)) return;
1935
1697
  // 인터랙티브 자식(체크박스·select·버튼·링크 등)은 건드리지 않는다 —
@@ -1954,8 +1716,13 @@ function onCellMouseDown(
1954
1716
  cellDragging = true;
1955
1717
  e.preventDefault(); // 드래그 중 텍스트 선택 방지
1956
1718
  }
1957
- function onCellMouseEnter(rowIndex: number, colIndex: number) {
1719
+ function onCellMouseEnter(e: MouseEvent, rowIndex: number, colIndex: number) {
1958
1720
  if (!cellDragging) return;
1721
+ // 창 밖 mouseup 유실로 남은 stale 드래그 — 버튼이 안 눌려 있으면 자가 치유
1722
+ if ((e.buttons & 1) === 0) {
1723
+ cellDragging = false;
1724
+ return;
1725
+ }
1959
1726
  suppressCellClick = true;
1960
1727
  grid.extendSelectionTo(rowIndex, colIndex);
1961
1728
  }
@@ -2006,7 +1773,7 @@ function onEditorInput(event: Event, col: ColumnDef) {
2006
1773
  el.setSelectionRange(next.length, next.length);
2007
1774
  }
2008
1775
  }
2009
- grid.updateEditValue(el.value, col.field);
1776
+ grid.updateEditValue(el.value, colKeyOf(col));
2010
1777
  }
2011
1778
 
2012
1779
  // text 에디터 표시 값 — editMask가 있으면 기존 저장값도 마스크 형태로 표시
@@ -2025,19 +1792,22 @@ function onMultiselectChange(event: Event, col: ColumnDef) {
2025
1792
  const sel = event.target as HTMLSelectElement;
2026
1793
  grid.updateEditValue(
2027
1794
  Array.from(sel.selectedOptions).map((o) => o.value),
2028
- col.field,
1795
+ colKeyOf(col),
2029
1796
  );
2030
1797
  }
2031
1798
 
2032
1799
  // 라디오 에디터 — 선택 즉시 커밋 (fullRow에서는 보류 값만 반영)
2033
1800
  function onRadioPick(opt: string, col: ColumnDef) {
2034
- grid.updateEditValue(opt, col.field);
1801
+ grid.updateEditValue(opt, colKeyOf(col));
2035
1802
  if (state.value.editType !== "fullRow") grid.commitEditing();
2036
1803
  }
2037
1804
 
2038
1805
  // select 에디터 — 고르는 즉시 커밋 (fullRow에서는 보류 값만 반영)
2039
1806
  function onSelectPick(event: Event, col: ColumnDef) {
2040
- grid.updateEditValue((event.target as HTMLSelectElement).value, col.field);
1807
+ grid.updateEditValue(
1808
+ (event.target as HTMLSelectElement).value,
1809
+ colKeyOf(col),
1810
+ );
2041
1811
  if (state.value.editType !== "fullRow") grid.commitEditing();
2042
1812
  }
2043
1813
 
@@ -2106,7 +1876,7 @@ watch(
2106
1876
  if (!cell) return;
2107
1877
  await nextTick();
2108
1878
  const colIdx = state.value.visibleColumns.findIndex(
2109
- (c) => c.field === cell.columnKey,
1879
+ (c) => colKeyOf(c) === cell.columnKey,
2110
1880
  );
2111
1881
  const target =
2112
1882
  scrollEl.value?.querySelector<HTMLElement>(
@@ -2335,7 +2105,7 @@ watch(
2335
2105
  title="클릭 시 그룹 해제"
2336
2106
  @click="ungroupField(field)"
2337
2107
  >
2338
- {{ state.columns.find((c) => c.field === field)?.header ?? field }} ×
2108
+ {{ resolveColumn(state.columns, field)?.header ?? field }} ×
2339
2109
  </button>
2340
2110
  </div>
2341
2111
  <div v-if="showOverlay" class="mg-colctl">
@@ -2378,13 +2148,13 @@ watch(
2378
2148
  </div>
2379
2149
  <label
2380
2150
  v-for="col in state.columns"
2381
- :key="col.field"
2151
+ :key="colKeyOf(col)"
2382
2152
  class="mg-colctl-item"
2383
2153
  >
2384
2154
  <input
2385
2155
  type="checkbox"
2386
2156
  :checked="col.visible !== false"
2387
- @change="onColumnToggle(col.field, $event)"
2157
+ @change="onColumnToggle(colKeyOf(col), $event)"
2388
2158
  />
2389
2159
  {{ col.header ?? col.field }}
2390
2160
  </label>
@@ -2427,7 +2197,7 @@ watch(
2427
2197
  <col v-if="rowNumbers" class="mg-col-rownum" />
2428
2198
  <col
2429
2199
  v-for="col in state.visibleColumns"
2430
- :key="col.field"
2200
+ :key="colKeyOf(col)"
2431
2201
  :style="{ width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px` }"
2432
2202
  />
2433
2203
  </colgroup>
@@ -2493,8 +2263,8 @@ watch(
2493
2263
  :class="[
2494
2264
  {
2495
2265
  'mg-sortable': cell.col.sortable !== false,
2496
- 'mg-col-dragover': dragOverField === cell.col.field,
2497
- 'mg-col-dragging': touchColField === cell.col.field,
2266
+ 'mg-col-dragover': dragOverField === colKeyOf(cell.col),
2267
+ 'mg-col-dragging': touchColField === colKeyOf(cell.col),
2498
2268
  'mg-pinned': !!cell.col.pinned,
2499
2269
  'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
2500
2270
  'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
@@ -2506,15 +2276,16 @@ watch(
2506
2276
  grid.getHeaderClass(cell.col),
2507
2277
  ]"
2508
2278
  :title="cell.col.headerTooltip"
2509
- :aria-sort="sortAria(cell.col.field)"
2279
+ role="columnheader"
2280
+ :aria-sort="sortAria(colKeyOf(cell.col))"
2510
2281
  :draggable="reorderable && cell.col.movable !== false"
2511
2282
  @dragstart="onDragStart(cell.col, $event)"
2512
2283
  @dragover="onDragOver(cell.col, $event)"
2513
2284
  @drop="onDrop(cell.col, $event)"
2514
2285
  @dragend="onDragEnd"
2515
- @click="grid.toggleSort(cell.col.field, $event.shiftKey)"
2286
+ @click="grid.toggleSort(colKeyOf(cell.col), $event.shiftKey)"
2516
2287
  @contextmenu="onHeaderContextMenu($event, cell.col)"
2517
- :data-mg-field="cell.col.field"
2288
+ :data-mg-field="colKeyOf(cell.col)"
2518
2289
  @pointerdown="onHeaderPointerDown($event, cell.col)"
2519
2290
  >
2520
2291
  <input
@@ -2534,25 +2305,30 @@ watch(
2534
2305
  @change="grid.toggleAllChecked(cell.col)"
2535
2306
  />
2536
2307
  <!-- 커스텀 헤더 슬롯: #header-{field}="{ column }" -->
2537
- <slot :name="`header-${cell.col.field}`" :column="cell.col">{{
2538
- cell.col.header || cell.col.field
2539
- }}</slot>
2308
+ <slot
2309
+ :name="`header-${colKeyOf(cell.col)}`"
2310
+ :column="cell.col"
2311
+ >{{ cell.col.header || cell.col.field }}</slot
2312
+ >
2540
2313
  <span v-if="cell.col.required" class="mg-required-mark">*</span>
2541
- <span v-if="sortArrowOf(cell.col.field)" class="mg-sort-arrow">
2542
- {{ sortArrowOf(cell.col.field) }}
2314
+ <span
2315
+ v-if="sortArrowOf(colKeyOf(cell.col))"
2316
+ class="mg-sort-arrow"
2317
+ >
2318
+ {{ sortArrowOf(colKeyOf(cell.col)) }}
2543
2319
  </span>
2544
2320
  <span
2545
- v-if="sortPriorityOf(cell.col.field)"
2321
+ v-if="sortPriorityOf(colKeyOf(cell.col))"
2546
2322
  class="mg-sort-priority"
2547
2323
  >
2548
- {{ sortPriorityOf(cell.col.field) }}
2324
+ {{ sortPriorityOf(colKeyOf(cell.col)) }}
2549
2325
  </span>
2550
2326
  <button
2551
2327
  v-if="headerFilters && cell.col.filterable"
2552
2328
  type="button"
2553
2329
  :class="[
2554
2330
  'mg-header-filter-btn',
2555
- state.filters[cell.col.field] && 'mg-active',
2331
+ state.filters[colKeyOf(cell.col)] && 'mg-active',
2556
2332
  ]"
2557
2333
  :aria-label="`${cell.col.header || cell.col.field} 필터`"
2558
2334
  @click="toggleFilterDrop(cell.col, $event)"
@@ -2565,7 +2341,7 @@ watch(
2565
2341
  class="mg-resizer"
2566
2342
  :aria-label="`${cell.col.field} 너비 조절`"
2567
2343
  @pointerdown.stop.prevent="onResizeStart(cell.col, $event)"
2568
- @dblclick.stop="grid.autoSizeColumn(cell.col.field)"
2344
+ @dblclick.stop="grid.autoSizeColumn(colKeyOf(cell.col))"
2569
2345
  @keydown.stop="onResizerKeydown(cell.col, $event)"
2570
2346
  @click.stop
2571
2347
  />
@@ -2588,7 +2364,7 @@ watch(
2588
2364
  ></th>
2589
2365
  <th
2590
2366
  v-else
2591
- :key="col.field"
2367
+ :key="colKeyOf(col)"
2592
2368
  :class="{
2593
2369
  'mg-pinned': !!col.pinned,
2594
2370
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -2604,7 +2380,7 @@ watch(
2604
2380
  <input
2605
2381
  type="checkbox"
2606
2382
  :checked="setAllCheckedOf(col)"
2607
- @change="grid.setFilter(col.field, null)"
2383
+ @change="grid.setFilter(colKeyOf(col), null)"
2608
2384
  />
2609
2385
  {{ state.locale.setFilterAll }}
2610
2386
  </label>
@@ -2681,7 +2457,7 @@ watch(
2681
2457
  />
2682
2458
  <td
2683
2459
  v-else
2684
- :key="col.field"
2460
+ :key="colKeyOf(col)"
2685
2461
  :class="{
2686
2462
  'mg-pinned': !!col.pinned,
2687
2463
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -2730,7 +2506,7 @@ watch(
2730
2506
  />
2731
2507
  <td
2732
2508
  v-else
2733
- :key="col.field"
2509
+ :key="colKeyOf(col)"
2734
2510
  class="mg-group-cell"
2735
2511
  :class="{
2736
2512
  'mg-pinned': !!col.pinned,
@@ -2778,7 +2554,7 @@ watch(
2778
2554
  />
2779
2555
  <td
2780
2556
  v-else
2781
- :key="col.field"
2557
+ :key="colKeyOf(col)"
2782
2558
  class="mg-subtotal-cell"
2783
2559
  :class="{
2784
2560
  'mg-pinned': !!col.pinned,
@@ -2821,7 +2597,7 @@ watch(
2821
2597
  />
2822
2598
  <td
2823
2599
  v-else
2824
- :key="col.field"
2600
+ :key="colKeyOf(col)"
2825
2601
  :class="{
2826
2602
  'mg-pinned': !!col.pinned,
2827
2603
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -2837,6 +2613,7 @@ watch(
2837
2613
  <tr
2838
2614
  v-else-if="isFullWidthOf(entry, rowIdx)"
2839
2615
  :key="rowKeyOf(entry, rowIdx)"
2616
+ role="row"
2840
2617
  class="mg-fullwidth-row"
2841
2618
  :data-mg-key="grid.getRowId(rowDataOf(entry))"
2842
2619
  >
@@ -2914,64 +2691,14 @@ watch(
2914
2691
  :colspan="count"
2915
2692
  />
2916
2693
  <td
2917
- v-else-if="!cellSpanOf(rowDataOf(entry), col).hidden"
2918
- :key="col.field"
2919
- :rowspan="cellSpanOf(rowDataOf(entry), col).rowSpan"
2920
- :colspan="cellSpanOf(rowDataOf(entry), col).colSpan"
2921
- :class="[
2922
- col.align && col.align !== 'left'
2923
- ? `mg-align-${col.align}`
2924
- : '',
2925
- {
2926
- 'mg-cell-readonly': !grid.isCellEditable(
2927
- entryIndexOf(entry, rowIdx),
2928
- colIndex,
2929
- ),
2930
- 'mg-cell-active': grid.isActiveCell(
2931
- entryIndexOf(entry, rowIdx),
2932
- colIndex,
2933
- ),
2934
- 'mg-cell-selected': grid.isCellInRange(
2935
- entryIndexOf(entry, rowIdx),
2936
- colIndex,
2937
- ),
2938
- 'mg-cell-editing': isEditingCell(
2939
- entryIndexOf(entry, rowIdx),
2940
- colIndex,
2941
- ),
2942
- 'mg-cell-invalid': !!cellErrorOf(entry, col),
2943
- 'mg-find-match': isFindMatch(entry, col),
2944
- 'mg-cell-flash': state.flashedCells?.has(
2945
- grid.getRowId(rowDataOf(entry)) +
2946
- '|' +
2947
- String(col.field),
2948
- ),
2949
- 'mg-multiline': !!col.multiLine,
2950
- 'mg-pinned': !!col.pinned,
2951
- 'mg-pin-left-edge': colIndex === lastLeftPinIdx,
2952
- 'mg-pin-right-edge': colIndex === firstRightPinIdx,
2953
- },
2954
- cellClassOf(entry, rowIdx, col),
2955
- cellNoteOf(entry, col) && 'mg-cell-note',
2956
- ]"
2694
+ v-else-if="!cellDescOf(entry, rowIdx, col, colIndex)?.hidden"
2695
+ :key="colKeyOf(col)"
2696
+ :rowspan="cellDescOf(entry, rowIdx, col, colIndex)?.rowSpan"
2697
+ :colspan="cellDescOf(entry, rowIdx, col, colIndex)?.colSpan"
2698
+ :class="cellDescOf(entry, rowIdx, col, colIndex)?.classes"
2957
2699
  role="gridcell"
2958
- :title="
2959
- cellErrorOf(entry, col) ||
2960
- grid.getCellTooltip(rowDataOf(entry), col) ||
2961
- cellNoteOf(entry, col) ||
2962
- undefined
2963
- "
2964
- :style="[
2965
- pinStyleOf(col),
2966
- colIndex === 0 && leafDepthOf(entry)
2967
- ? { paddingLeft: `${leafDepthOf(entry) * 16 + 12}px` }
2968
- : undefined,
2969
- grid.getCellStyle(
2970
- rowDataOf(entry),
2971
- entryIndexOf(entry, rowIdx),
2972
- col,
2973
- ) ?? undefined,
2974
- ]"
2700
+ :title="cellDescOf(entry, rowIdx, col, colIndex)?.title"
2701
+ :style="cellDescOf(entry, rowIdx, col, colIndex)?.styles"
2975
2702
  :data-mg-row="entryIndexOf(entry, rowIdx)"
2976
2703
  :data-mg-col="colIndex"
2977
2704
  @mousedown="
@@ -2983,15 +2710,15 @@ watch(
2983
2710
  )
2984
2711
  "
2985
2712
  @mouseenter="
2986
- onCellMouseEnter(entryIndexOf(entry, rowIdx), colIndex)
2987
- "
2988
- @click="
2989
- onCellClick(
2713
+ onCellMouseEnter(
2990
2714
  $event,
2991
2715
  entryIndexOf(entry, rowIdx),
2992
2716
  colIndex,
2993
2717
  )
2994
2718
  "
2719
+ @click="
2720
+ onCellClick($event, entryIndexOf(entry, rowIdx), colIndex)
2721
+ "
2995
2722
  @dblclick="
2996
2723
  onCellDblClick(
2997
2724
  $event,
@@ -3077,7 +2804,7 @@ watch(
3077
2804
  >
3078
2805
  <!-- 커스텀 에디터 슬롯: #editor-{field}="ctx" -->
3079
2806
  <slot
3080
- :name="`editor-${col.field}`"
2807
+ :name="`editor-${colKeyOf(col)}`"
3081
2808
  v-bind="
3082
2809
  editorContext(entryIndexOf(entry, rowIdx), colIndex)
3083
2810
  "
@@ -3132,6 +2859,8 @@ watch(
3132
2859
  v-else-if="col.cellEditor === 'radio'"
3133
2860
  class="mg-radio-group"
3134
2861
  role="radiogroup"
2862
+ tabindex="-1"
2863
+ @keydown="onEditorKeydown"
3135
2864
  >
3136
2865
  <label
3137
2866
  v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
@@ -3175,7 +2904,7 @@ watch(
3175
2904
  :list="
3176
2905
  editorInputType(col) === 'text' &&
3177
2906
  editorOptionsOf(col, rowDataOf(entry)).length
3178
- ? `mg-dl-${col.field}`
2907
+ ? `mg-dl-${colKeyOf(col)}`
3179
2908
  : undefined
3180
2909
  "
3181
2910
  @input="onEditorInput($event, col)"
@@ -3189,7 +2918,7 @@ watch(
3189
2918
  editorInputType(col) === 'text' &&
3190
2919
  editorOptionsOf(col, rowDataOf(entry)).length
3191
2920
  "
3192
- :id="`mg-dl-${col.field}`"
2921
+ :id="`mg-dl-${colKeyOf(col)}`"
3193
2922
  >
3194
2923
  <option
3195
2924
  v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
@@ -3205,7 +2934,7 @@ watch(
3205
2934
  <!-- 커스텀 셀 슬롯: #cell-{field}="{ value, row, column }" -->
3206
2935
  <slot
3207
2936
  v-else
3208
- :name="`cell-${col.field}`"
2937
+ :name="`cell-${colKeyOf(col)}`"
3209
2938
  :value="grid.getCellValue(rowDataOf(entry), col)"
3210
2939
  :row="rowDataOf(entry)"
3211
2940
  :column="col"
@@ -3298,7 +3027,15 @@ watch(
3298
3027
  :key="rowKeyOf(entry, rowIdx) + '-detail'"
3299
3028
  class="mg-detail-row"
3300
3029
  >
3301
- <td class="mg-detail-cell" :colspan="colSpan">
3030
+ <td
3031
+ class="mg-detail-cell"
3032
+ :colspan="colSpan"
3033
+ :style="
3034
+ detailHeight != null
3035
+ ? { height: `${detailHeight}px` }
3036
+ : undefined
3037
+ "
3038
+ >
3302
3039
  <div class="mg-detail-content">
3303
3040
  <slot
3304
3041
  name="detail"
@@ -3338,7 +3075,7 @@ watch(
3338
3075
  />
3339
3076
  <td
3340
3077
  v-else
3341
- :key="col.field"
3078
+ :key="colKeyOf(col)"
3342
3079
  :class="{
3343
3080
  'mg-pinned': !!col.pinned,
3344
3081
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,
@@ -3367,7 +3104,7 @@ watch(
3367
3104
  class="mg-append-btn"
3368
3105
  @click="onLoadMore"
3369
3106
  >
3370
- 더 보기
3107
+ {{ state.locale.appendMore }}
3371
3108
  </button>
3372
3109
  </td>
3373
3110
  </tr>
@@ -3388,7 +3125,7 @@ watch(
3388
3125
  />
3389
3126
  <td
3390
3127
  v-else
3391
- :key="col.field"
3128
+ :key="colKeyOf(col)"
3392
3129
  :class="{
3393
3130
  'mg-pinned': !!col.pinned,
3394
3131
  'mg-pin-left-edge': colIndex === lastLeftPinIdx,