@moda-grid/vue2 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataGrid.vue +349 -584
- package/dist/conformance.test.js +10 -1
- package/dist/conformance.test.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/DataGrid.vue
CHANGED
|
@@ -21,14 +21,36 @@ 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,
|
|
36
|
+
isInteractiveCellTarget,
|
|
37
|
+
isSubtotalRow,
|
|
38
|
+
leafDepthOf,
|
|
39
|
+
filterDropAnchorX,
|
|
40
|
+
leafExpanded,
|
|
41
|
+
leafHasChildren,
|
|
42
|
+
leafOf,
|
|
29
43
|
logicalToDomScrollLeft,
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
pinPartition,
|
|
45
|
+
pinStyleProps,
|
|
46
|
+
resolveRowDrop,
|
|
47
|
+
resizeKeyDelta,
|
|
48
|
+
rowDataOf,
|
|
49
|
+
startColumnResize,
|
|
50
|
+
startFillDrag,
|
|
51
|
+
startRowResize,
|
|
52
|
+
colKeyOf,
|
|
53
|
+
resolveColumn,
|
|
32
54
|
} from "@moda-grid/core";
|
|
33
55
|
import type {
|
|
34
56
|
AggregateFn,
|
|
@@ -36,10 +58,8 @@ import type {
|
|
|
36
58
|
AppendScrollOptions,
|
|
37
59
|
PivotOptions,
|
|
38
60
|
PivotZone,
|
|
39
|
-
ContextMenuItem,
|
|
40
61
|
GridLocale,
|
|
41
62
|
CellEditorContext,
|
|
42
|
-
CellNavigation,
|
|
43
63
|
ColumnDef,
|
|
44
64
|
ColumnFilter,
|
|
45
65
|
DisplayRow,
|
|
@@ -51,8 +71,7 @@ import type {
|
|
|
51
71
|
GridEventHandlers,
|
|
52
72
|
GridEventMap,
|
|
53
73
|
GridOptions,
|
|
54
|
-
|
|
55
|
-
LeafDisplayRow,
|
|
74
|
+
RangeTracking,
|
|
56
75
|
RowData,
|
|
57
76
|
SelectionMode,
|
|
58
77
|
ServerSideOptions,
|
|
@@ -62,15 +81,6 @@ import type {
|
|
|
62
81
|
import { useGrid, useGridState } from "./useGrid.js";
|
|
63
82
|
|
|
64
83
|
// Vue 2.7 script setup — runtime props 선언 사용
|
|
65
|
-
/** 편집기 input 씨드 값 — Date는 YYYY-MM-DD 로 변환 (input[type=date] 호환) */
|
|
66
|
-
function editorInputValue(v: unknown): string {
|
|
67
|
-
if (v instanceof Date) {
|
|
68
|
-
const pad = (n: number) => String(n).padStart(2, "0");
|
|
69
|
-
return `${v.getFullYear()}-${pad(v.getMonth() + 1)}-${pad(v.getDate())}`;
|
|
70
|
-
}
|
|
71
|
-
return String(v ?? "");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
84
|
const slots = useSlots();
|
|
75
85
|
/** 행 상세 패널 (master-detail) — #detail="{ row, rowIndex }" 슬롯이 있으면 각 행에 ▸ 토글 표시 */
|
|
76
86
|
const hasDetailSlot = computed(() => !!slots.detail);
|
|
@@ -88,7 +98,10 @@ const props = defineProps({
|
|
|
88
98
|
default: undefined,
|
|
89
99
|
},
|
|
90
100
|
/** 외부에서 생성/관리하는 GridCore. 생략하면 내부 인스턴스 생성 */
|
|
91
|
-
grid: {
|
|
101
|
+
grid: {
|
|
102
|
+
type: Object as PropType<Grid<Record<string, unknown>>>,
|
|
103
|
+
default: undefined,
|
|
104
|
+
},
|
|
92
105
|
getRowId: {
|
|
93
106
|
type: Function as PropType<(row: Record<string, unknown>) => string>,
|
|
94
107
|
default: undefined,
|
|
@@ -99,6 +112,11 @@ const props = defineProps({
|
|
|
99
112
|
height: { type: Number, default: undefined },
|
|
100
113
|
/** 가상 스크롤: 행 높이(px) */
|
|
101
114
|
rowHeight: { type: Number, default: undefined },
|
|
115
|
+
/** 가변 높이 가상화 — 행별 px 높이. height/rowHeight와 함께 지정 */
|
|
116
|
+
getRowHeight: {
|
|
117
|
+
type: Function as PropType<(row: unknown, index: number) => number>,
|
|
118
|
+
default: undefined,
|
|
119
|
+
},
|
|
102
120
|
/** 가상 스크롤: overscan 행 수 */
|
|
103
121
|
overscan: { type: Number, default: undefined },
|
|
104
122
|
/**
|
|
@@ -126,6 +144,11 @@ const props = defineProps({
|
|
|
126
144
|
type: String as PropType<SelectionMode>,
|
|
127
145
|
default: undefined,
|
|
128
146
|
},
|
|
147
|
+
/** 범위 선택 추적 방식 — 'identity'면 정렬/필터 후에도 같은 행·컬럼을 추적 */
|
|
148
|
+
rangeTracking: {
|
|
149
|
+
type: String as PropType<RangeTracking>,
|
|
150
|
+
default: undefined,
|
|
151
|
+
},
|
|
129
152
|
/** 서버 사이드 데이터 소스 (내부 GridCore 생성 모드에서만 적용) */
|
|
130
153
|
serverSide: {
|
|
131
154
|
type: Object as PropType<ServerSideOptions>,
|
|
@@ -250,6 +273,8 @@ const props = defineProps({
|
|
|
250
273
|
theme: { type: [String, Object] as PropType<GridTheme>, default: undefined },
|
|
251
274
|
/** 밀도 프리셋 — "compact"/"comfortable"이 폰트·셀 패딩을 일괄 조정 */
|
|
252
275
|
density: { type: String as PropType<GridDensity>, default: undefined },
|
|
276
|
+
/** 행 상세 패널 높이(px) — #detail 슬롯 사용 시 적용. 미지정 시 내용에 맞춤 */
|
|
277
|
+
detailHeight: { type: Number, default: undefined },
|
|
253
278
|
/** 선언형 이벤트 핸들러 — 마운트 시 구독, 언마운트 시 해제 (grid.on과 동일) */
|
|
254
279
|
events: { type: Object as PropType<GridEventHandlers>, default: undefined },
|
|
255
280
|
/** GridCore 인스턴스가 준비되면 한 번 호출 — props 모드에서도 grid API 접근 가능 */
|
|
@@ -280,6 +305,7 @@ const internal = props.grid
|
|
|
280
305
|
cellFlash: props.cellFlash,
|
|
281
306
|
copyFormatted: props.copyFormatted,
|
|
282
307
|
singleClickEdit: props.singleClickEdit,
|
|
308
|
+
rangeTracking: props.rangeTracking,
|
|
283
309
|
editType: props.editType,
|
|
284
310
|
pasteExtend: props.pasteExtend,
|
|
285
311
|
headerHeight: props.headerHeight,
|
|
@@ -301,6 +327,7 @@ const internal = props.grid
|
|
|
301
327
|
rowHeight: props.rowHeight,
|
|
302
328
|
viewportHeight: props.height,
|
|
303
329
|
overscan: props.overscan,
|
|
330
|
+
getRowHeight: props.getRowHeight,
|
|
304
331
|
}
|
|
305
332
|
: undefined,
|
|
306
333
|
virtualColumns: props.virtualColumns,
|
|
@@ -361,6 +388,7 @@ watchEffect(() => {
|
|
|
361
388
|
rowHeight: props.rowHeight,
|
|
362
389
|
viewportHeight: props.height,
|
|
363
390
|
overscan: props.overscan,
|
|
391
|
+
getRowHeight: props.getRowHeight,
|
|
364
392
|
});
|
|
365
393
|
} else {
|
|
366
394
|
grid.setVirtualScroll(null);
|
|
@@ -377,6 +405,7 @@ watchEffect(() => {
|
|
|
377
405
|
});
|
|
378
406
|
watchEffect(() => {
|
|
379
407
|
if (props.selectionMode) grid.setSelectionMode(props.selectionMode);
|
|
408
|
+
if (props.rangeTracking) grid.setRangeTracking(props.rangeTracking);
|
|
380
409
|
});
|
|
381
410
|
watchEffect(() => {
|
|
382
411
|
grid.setHiddenRows([...(props.hiddenRowIds ?? [])]);
|
|
@@ -571,30 +600,31 @@ function onFindInput(e: Event) {
|
|
|
571
600
|
const filterDrop = ref<{ field: string; x: number; y: number } | null>(null);
|
|
572
601
|
function toggleFilterDrop(col: ColumnDef, e: MouseEvent) {
|
|
573
602
|
e.stopPropagation();
|
|
574
|
-
if (filterDrop.value?.field === col
|
|
603
|
+
if (filterDrop.value?.field === colKeyOf(col)) {
|
|
575
604
|
filterDrop.value = null;
|
|
576
605
|
return;
|
|
577
606
|
}
|
|
578
607
|
const b = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
|
579
608
|
const h = hostEl.value?.getBoundingClientRect();
|
|
580
609
|
filterDrop.value = {
|
|
581
|
-
field: col
|
|
582
|
-
x: b
|
|
610
|
+
field: colKeyOf(col),
|
|
611
|
+
x: filterDropAnchorX(b, h?.left ?? 0, state.value.dir),
|
|
583
612
|
y: b.bottom - (h?.top ?? 0) + 4,
|
|
584
613
|
};
|
|
585
614
|
}
|
|
586
615
|
const filterDropCol = computed(() =>
|
|
587
616
|
filterDrop.value
|
|
588
|
-
? (state.value.columns
|
|
589
|
-
null)
|
|
617
|
+
? (resolveColumn(state.value.columns, filterDrop.value.field) ?? null)
|
|
590
618
|
: null,
|
|
591
619
|
);
|
|
592
620
|
const filterDropAll = computed(() =>
|
|
593
|
-
filterDropCol.value
|
|
621
|
+
filterDropCol.value
|
|
622
|
+
? grid.getUniqueValues(colKeyOf(filterDropCol.value))
|
|
623
|
+
: [],
|
|
594
624
|
);
|
|
595
625
|
const filterDropActive = computed(() =>
|
|
596
626
|
filterDropCol.value
|
|
597
|
-
? state.value.filters[filterDropCol.value
|
|
627
|
+
? state.value.filters[colKeyOf(filterDropCol.value)]?.values
|
|
598
628
|
: undefined,
|
|
599
629
|
);
|
|
600
630
|
// ── 필터 빌더 상태: 조건식(연산자+값)과 값 체크리스트를 분리해 다룬다 ──
|
|
@@ -611,7 +641,7 @@ const filterDropBuilder = computed<FilterBuilderInput>(() => {
|
|
|
611
641
|
values: null,
|
|
612
642
|
join: "and" as const,
|
|
613
643
|
};
|
|
614
|
-
const cur = state.value.filters[col
|
|
644
|
+
const cur = state.value.filters[colKeyOf(col)];
|
|
615
645
|
const condOn = cur != null && cur.operator !== "set";
|
|
616
646
|
return {
|
|
617
647
|
operator: condOn
|
|
@@ -631,7 +661,7 @@ function applyFilterBuilder(patch: Partial<FilterBuilderInput>) {
|
|
|
631
661
|
const col = filterDropCol.value;
|
|
632
662
|
if (!col) return;
|
|
633
663
|
grid.setFilter(
|
|
634
|
-
col
|
|
664
|
+
colKeyOf(col),
|
|
635
665
|
buildColumnFilter({ ...filterDropBuilder.value, ...patch }),
|
|
636
666
|
);
|
|
637
667
|
}
|
|
@@ -682,9 +712,7 @@ const PIVOT_AGGS: BuiltInAggregateFn[] = [
|
|
|
682
712
|
];
|
|
683
713
|
const pivotDropZone = ref<string | null>(null);
|
|
684
714
|
function pivotHeaderOf(field: string) {
|
|
685
|
-
return (
|
|
686
|
-
state.value.sourceColumns.find((c) => c.field === field)?.header ?? field
|
|
687
|
-
);
|
|
715
|
+
return resolveColumn(state.value.sourceColumns, field)?.header ?? field;
|
|
688
716
|
}
|
|
689
717
|
function onPivotAggChange(field: string, e: Event) {
|
|
690
718
|
const v = (e.target as HTMLSelectElement).value;
|
|
@@ -694,7 +722,7 @@ function pivotChipsOf(zone: string) {
|
|
|
694
722
|
const p = state.value.pivot;
|
|
695
723
|
if (zone === "fields")
|
|
696
724
|
return state.value.sourceColumns.map((c) => ({
|
|
697
|
-
field: c
|
|
725
|
+
field: colKeyOf(c),
|
|
698
726
|
label: c.header ?? c.field,
|
|
699
727
|
agg: undefined as AggregateFn | undefined,
|
|
700
728
|
}));
|
|
@@ -754,8 +782,8 @@ function onPivotZoneDrop(zone: string, e: DragEvent, index?: number) {
|
|
|
754
782
|
if (!f) return;
|
|
755
783
|
e.preventDefault();
|
|
756
784
|
e.stopPropagation();
|
|
757
|
-
if (zone === "fields") grid.removePivotField(f
|
|
758
|
-
else grid.addPivotField(zone as PivotZone, f
|
|
785
|
+
if (zone === "fields") grid.removePivotField(f);
|
|
786
|
+
else grid.addPivotField(zone as PivotZone, f, { index });
|
|
759
787
|
}
|
|
760
788
|
function onPivotChipDragStart(field: string, e: DragEvent) {
|
|
761
789
|
e.dataTransfer!.effectAllowed = "move";
|
|
@@ -767,12 +795,13 @@ function onPivotChipDragOver(e: DragEvent) {
|
|
|
767
795
|
e.stopPropagation();
|
|
768
796
|
}
|
|
769
797
|
|
|
770
|
-
// 행 높이 + rowStyle — 가상 스크롤은
|
|
798
|
+
// 행 높이 + rowStyle — 가상 스크롤은 슬라이스 높이(가변)/고정, 아니면 autoRowHeight 추정치
|
|
771
799
|
function rowStyleOf(entry: AnyRow, rowIdx: number) {
|
|
772
800
|
const row = rowDataOf(entry);
|
|
773
801
|
const base: Record<string, string> = {};
|
|
774
|
-
const h =
|
|
775
|
-
virtual.value
|
|
802
|
+
const h = virtual.value
|
|
803
|
+
? (virtual.value.heights?.[rowIdx] ?? props.rowHeight)
|
|
804
|
+
: grid.getRowHeight(row);
|
|
776
805
|
if (h) base.height = `${h}px`;
|
|
777
806
|
// GridOptions/ColumnDef.rowStyle — kebab-case 맵 병합 (Vue :style이 그대로 적용)
|
|
778
807
|
const custom = grid.getRowStyle(row, entryIndexOf(entry, rowIdx));
|
|
@@ -783,7 +812,7 @@ function rowStyleOf(entry: AnyRow, rowIdx: number) {
|
|
|
783
812
|
// 그룹 패널 칩 — 클릭 시 해당 컬럼 그룹 해제
|
|
784
813
|
function ungroupField(field: string) {
|
|
785
814
|
grid.setGroupBy(
|
|
786
|
-
state.value.groupBy.filter((f) => f !== field)
|
|
815
|
+
state.value.groupBy.filter<keyof RowT & string>((f) => f !== field),
|
|
787
816
|
);
|
|
788
817
|
}
|
|
789
818
|
|
|
@@ -842,7 +871,7 @@ const bodyRows = computed<AnyRow[]>(() => {
|
|
|
842
871
|
const v = virtual.value;
|
|
843
872
|
return v ? displayRows.slice(v.startIndex, v.endIndex) : displayRows;
|
|
844
873
|
}
|
|
845
|
-
return
|
|
874
|
+
return state.value.virtualRows || state.value.rows;
|
|
846
875
|
});
|
|
847
876
|
const colSpan = computed(
|
|
848
877
|
() =>
|
|
@@ -875,27 +904,16 @@ const activeFilterCount = computed(
|
|
|
875
904
|
() => Object.keys(state.value.filters).length,
|
|
876
905
|
);
|
|
877
906
|
const bottomOffset = computed(() =>
|
|
878
|
-
virtual.value
|
|
879
|
-
? Math.max(
|
|
880
|
-
0,
|
|
881
|
-
virtual.value.totalHeight - virtual.value.endIndex * props.rowHeight,
|
|
882
|
-
)
|
|
883
|
-
: 0,
|
|
907
|
+
virtual.value ? virtual.value.endOffset : 0,
|
|
884
908
|
);
|
|
885
909
|
|
|
886
910
|
// ── 컬럼 고정: [Left | Scrollable | Right] 파티션 + sticky 오프셋 ──
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
);
|
|
893
|
-
const firstRightPinIdx = computed(() =>
|
|
894
|
-
state.value.visibleColumns.findIndex((c) => c.pinned === "right"),
|
|
895
|
-
);
|
|
896
|
-
const hasPinned = computed(
|
|
897
|
-
() => lastLeftPinIdx.value >= 0 || firstRightPinIdx.value >= 0,
|
|
898
|
-
);
|
|
911
|
+
// 파티션 계산은 adapterDom 공용 — 템플릿의 edge 클래스 바인딩은
|
|
912
|
+
// lastLeftPinIdx/firstRightPinIdx 이름을 유지해 diff를 최소화한다
|
|
913
|
+
const pinPart = computed(() => pinPartition(state.value.visibleColumns));
|
|
914
|
+
const lastLeftPinIdx = computed(() => pinPart.value.lastLeftPinIdx);
|
|
915
|
+
const firstRightPinIdx = computed(() => pinPart.value.firstRightPinIdx);
|
|
916
|
+
const hasPinned = computed(() => pinPart.value.hasPinned);
|
|
899
917
|
const hasAppend = computed(() => !!state.value.appendScroll);
|
|
900
918
|
|
|
901
919
|
// ── 컬럼 가상화 — 윈도우 밖 연속 구간을 spacer 셀로 대체 ──
|
|
@@ -918,15 +936,11 @@ const renderCols = computed(() =>
|
|
|
918
936
|
);
|
|
919
937
|
|
|
920
938
|
function pinStyleOf(col: ColumnDef<RowT>): CSSProperties | undefined {
|
|
921
|
-
if (!col.pinned) return undefined;
|
|
922
939
|
// 논리 인셋 — pinned:"left"는 inline-start라 dir="rtl"이면 우측에 붙는다
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
return
|
|
926
|
-
|
|
927
|
-
width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px`,
|
|
928
|
-
[side]: `${state.value.pinOffsets[col.field] ?? 0}px`,
|
|
929
|
-
};
|
|
940
|
+
// 계산은 adapterDom 공용 (5개 렌더러 동일 계약). PinStyleProps는 Vue
|
|
941
|
+
// CSSProperties가 요구하는 CSS 변수 인덱스 시그니처가 없어 캐스트한다
|
|
942
|
+
return pinStyleProps(col, state.value.pinOffsets) as
|
|
943
|
+
CSSProperties | undefined;
|
|
930
944
|
}
|
|
931
945
|
|
|
932
946
|
// ── 다중 정렬 ──
|
|
@@ -971,7 +985,7 @@ function onLoadMore() {
|
|
|
971
985
|
|
|
972
986
|
// ── 컨텍스트 메뉴 + 셀 타입 ──
|
|
973
987
|
function onHeaderContextMenu(e: MouseEvent, col: ColumnDef): void {
|
|
974
|
-
if (grid.openHeaderContextMenu(e.clientX, e.clientY, col
|
|
988
|
+
if (grid.openHeaderContextMenu(e.clientX, e.clientY, colKeyOf(col))) {
|
|
975
989
|
e.preventDefault();
|
|
976
990
|
}
|
|
977
991
|
}
|
|
@@ -981,26 +995,33 @@ function onCellContextMenu(
|
|
|
981
995
|
rowIndex: number,
|
|
982
996
|
col: ColumnDef,
|
|
983
997
|
): void {
|
|
984
|
-
if (grid.openContextMenu(e.clientX, e.clientY, rowIndex, col
|
|
998
|
+
if (grid.openContextMenu(e.clientX, e.clientY, rowIndex, colKeyOf(col))) {
|
|
985
999
|
e.preventDefault();
|
|
986
1000
|
}
|
|
987
1001
|
}
|
|
988
1002
|
|
|
1003
|
+
// 터치 제스처의 릴리즈 클릭 삼킘 해제 함수 레지스트리 — 언마운트 시
|
|
1004
|
+
// 일괄 해제해, 삼킘 리스너가 다음 무관한 클릭을 삼키는 것을 막는다
|
|
1005
|
+
const swallows = new Set<() => void>();
|
|
1006
|
+
onBeforeUnmount(() => {
|
|
1007
|
+
swallows.forEach((fn) => fn());
|
|
1008
|
+
swallows.clear();
|
|
1009
|
+
});
|
|
989
1010
|
// 터치 롱프레스 → contextmenu와 동일 동작 (헤더/셀 공용 트래커)
|
|
990
|
-
const lp = createLongPressTracker();
|
|
1011
|
+
const lp = createLongPressTracker({ registry: swallows });
|
|
991
1012
|
|
|
992
1013
|
function onCellPointerDown(
|
|
993
1014
|
e: PointerEvent,
|
|
994
1015
|
rowIndex: number,
|
|
995
1016
|
col: ColumnDef,
|
|
996
1017
|
): void {
|
|
997
|
-
lp.down(e, (x, y) => grid.openContextMenu(x, y, rowIndex, col
|
|
1018
|
+
lp.down(e, (x, y) => grid.openContextMenu(x, y, rowIndex, colKeyOf(col)));
|
|
998
1019
|
}
|
|
999
1020
|
|
|
1000
1021
|
function onHeaderPointerDown(e: PointerEvent, col: ColumnDef): void {
|
|
1001
|
-
lp.down(e, (x, y) => grid.openHeaderContextMenu(x, y, col
|
|
1022
|
+
lp.down(e, (x, y) => grid.openHeaderContextMenu(x, y, colKeyOf(col)));
|
|
1002
1023
|
if (props.reorderable && col.movable !== false)
|
|
1003
|
-
touchDrag.col.down(e, col
|
|
1024
|
+
touchDrag.col.down(e, colKeyOf(col));
|
|
1004
1025
|
}
|
|
1005
1026
|
|
|
1006
1027
|
// ── 터치 커스텀 DnD — iOS/Android는 HTML5 DnD가 없어 포인터 제스처로 보강 ──
|
|
@@ -1053,16 +1074,13 @@ function touchRowDropAt(
|
|
|
1053
1074
|
const rowIndex = Number(td.getAttribute("data-mg-row"));
|
|
1054
1075
|
const tr = td.closest("tr");
|
|
1055
1076
|
if (Number.isNaN(rowIndex) || !tr) return null;
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
return { index: ratio < 0.5 ? rowIndex : rowIndex + 1 };
|
|
1077
|
+
// 트리는 상하 25%=before/after·가운데 50%=inside, 평면은 상하반 gap
|
|
1078
|
+
// — adapterDom의 단일 드롭 계약
|
|
1079
|
+
return resolveRowDrop(
|
|
1080
|
+
dropRatioForY(y, tr.getBoundingClientRect()),
|
|
1081
|
+
rowIndex,
|
|
1082
|
+
grid.isTreeRowDraggable(),
|
|
1083
|
+
);
|
|
1066
1084
|
}
|
|
1067
1085
|
|
|
1068
1086
|
function applyTouchDrop(
|
|
@@ -1095,71 +1113,83 @@ function clearTouchDropMarks(): void {
|
|
|
1095
1113
|
|
|
1096
1114
|
const touchDrag = {
|
|
1097
1115
|
// 컬럼 헤더 — 수평 이동으로 확정 (th는 touch-action: pan-y)
|
|
1098
|
-
col: createTouchDrag<string>(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1116
|
+
col: createTouchDrag<string>(
|
|
1117
|
+
"x",
|
|
1118
|
+
{
|
|
1119
|
+
start: (field: string) => {
|
|
1120
|
+
// 롱프레스 메뉴가 이미 열렸으면 드래그로 전환하지 않는다
|
|
1121
|
+
if (grid.getSnapshot().contextMenu) return false;
|
|
1122
|
+
lp.end();
|
|
1123
|
+
touchColFieldRaw = field;
|
|
1124
|
+
touchColField.value = field;
|
|
1125
|
+
return true;
|
|
1126
|
+
},
|
|
1127
|
+
move: (_x: number, _y: number, target: Element | null) => {
|
|
1128
|
+
const hit = touchHitAt(target);
|
|
1129
|
+
dragOverField.value =
|
|
1130
|
+
hit?.kind === "column" && hit.field !== touchColFieldRaw
|
|
1131
|
+
? hit.field
|
|
1132
|
+
: null;
|
|
1133
|
+
pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
|
|
1134
|
+
groupDropOver.value = hit?.kind === "group";
|
|
1135
|
+
},
|
|
1136
|
+
up: (_x: number, _y: number, target: Element | null, field: string) => {
|
|
1137
|
+
applyTouchDrop(touchHitAt(target), field);
|
|
1138
|
+
clearTouchDropMarks();
|
|
1139
|
+
touchColFieldRaw = null;
|
|
1140
|
+
touchColField.value = null;
|
|
1141
|
+
},
|
|
1142
|
+
cancel: () => {
|
|
1143
|
+
clearTouchDropMarks();
|
|
1144
|
+
touchColFieldRaw = null;
|
|
1145
|
+
touchColField.value = null;
|
|
1146
|
+
},
|
|
1126
1147
|
},
|
|
1127
|
-
|
|
1148
|
+
{ registry: swallows },
|
|
1149
|
+
),
|
|
1128
1150
|
// 행 드래그 핸들 — 세로 이동으로 확정 (핸들은 touch-action: none)
|
|
1129
|
-
row: createTouchDrag<number>(
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1151
|
+
row: createTouchDrag<number>(
|
|
1152
|
+
"y",
|
|
1153
|
+
{
|
|
1154
|
+
start: (rowIndex: number) => {
|
|
1155
|
+
lp.end();
|
|
1156
|
+
return grid.beginRowDrag(rowIndex);
|
|
1157
|
+
},
|
|
1158
|
+
move: (_x: number, y: number, target: Element | null) => {
|
|
1159
|
+
const drop = touchRowDropAt(target, y);
|
|
1160
|
+
if (drop != null) grid.updateRowDropPosition(drop.index, drop.position);
|
|
1161
|
+
},
|
|
1162
|
+
up: () => grid.endRowDrag(true),
|
|
1163
|
+
cancel: () => grid.endRowDrag(false),
|
|
1137
1164
|
},
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
}),
|
|
1165
|
+
{ registry: swallows },
|
|
1166
|
+
),
|
|
1141
1167
|
// 피벗 칩 — 아무 방향이든 이동으로 확정 (칩은 touch-action: none)
|
|
1142
|
-
chip: createTouchDrag<string>(
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
grid.
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1168
|
+
chip: createTouchDrag<string>(
|
|
1169
|
+
"any",
|
|
1170
|
+
{
|
|
1171
|
+
move: (_x: number, _y: number, target: Element | null) => {
|
|
1172
|
+
const hit = touchHitAt(target);
|
|
1173
|
+
pivotDropZone.value = hit?.kind === "pivot" ? hit.zone : null;
|
|
1174
|
+
},
|
|
1175
|
+
up: (_x: number, _y: number, target: Element | null, field: string) => {
|
|
1176
|
+
const hit = touchHitAt(target);
|
|
1177
|
+
pivotDropZone.value = null;
|
|
1178
|
+
if (hit?.kind !== "pivot") return;
|
|
1179
|
+
if (hit.zone === "fields") grid.removePivotField(field);
|
|
1180
|
+
else
|
|
1181
|
+
grid.addPivotField(
|
|
1182
|
+
hit.zone as PivotZone,
|
|
1183
|
+
field,
|
|
1184
|
+
hit.index != null ? { index: hit.index } : {},
|
|
1185
|
+
);
|
|
1186
|
+
},
|
|
1187
|
+
cancel: () => {
|
|
1188
|
+
pivotDropZone.value = null;
|
|
1189
|
+
},
|
|
1161
1190
|
},
|
|
1162
|
-
|
|
1191
|
+
{ registry: swallows },
|
|
1192
|
+
),
|
|
1163
1193
|
};
|
|
1164
1194
|
|
|
1165
1195
|
function onPivotChipPointerDown(field: string, e: PointerEvent): void {
|
|
@@ -1202,48 +1232,18 @@ onMounted(() => {
|
|
|
1202
1232
|
});
|
|
1203
1233
|
});
|
|
1204
1234
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
): { row: number; col: number } | null {
|
|
1209
|
-
const el = document.elementFromPoint(x, y)?.closest("td[data-mg-row]");
|
|
1210
|
-
if (!el) return null;
|
|
1211
|
-
const row = Number(el.getAttribute("data-mg-row"));
|
|
1212
|
-
const col = Number(el.getAttribute("data-mg-col"));
|
|
1213
|
-
return Number.isNaN(row) || Number.isNaN(col) ? null : { row, col };
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
let fillSource: {
|
|
1217
|
-
startRow: number;
|
|
1218
|
-
endRow: number;
|
|
1219
|
-
startCol: number;
|
|
1220
|
-
endCol: number;
|
|
1221
|
-
} | null = null;
|
|
1235
|
+
// 진행 중 포인터 드래그의 취소 함수 — 언마운트 시 document 리스너 해제
|
|
1236
|
+
let dragCancel: (() => void) | null = null;
|
|
1237
|
+
onBeforeUnmount(() => dragCancel?.());
|
|
1222
1238
|
|
|
1239
|
+
// 채우기 핸들 — 릴리즈 좌표까지 범위 확장+fill은 adapterDom 컨트롤러.
|
|
1240
|
+
// hostEl을 넘겨 그리드 밖(다른 그리드 셀) 릴리즈를 무시한다
|
|
1223
1241
|
function onFillPointerDown(e: PointerEvent): void {
|
|
1224
1242
|
e.preventDefault();
|
|
1225
1243
|
e.stopPropagation();
|
|
1226
1244
|
const src = state.value.selectedRange;
|
|
1227
1245
|
if (!src) return;
|
|
1228
|
-
|
|
1229
|
-
const onUp = (ev: PointerEvent) => {
|
|
1230
|
-
window.removeEventListener("pointerup", onUp);
|
|
1231
|
-
window.removeEventListener("pointercancel", onUp);
|
|
1232
|
-
const source = fillSource;
|
|
1233
|
-
fillSource = null;
|
|
1234
|
-
const pos = cellPosFromPoint(ev.clientX, ev.clientY);
|
|
1235
|
-
if (!source || !pos) return;
|
|
1236
|
-
const target = {
|
|
1237
|
-
startRow: Math.min(source.startRow, pos.row),
|
|
1238
|
-
endRow: Math.max(source.endRow, pos.row),
|
|
1239
|
-
startCol: Math.min(source.startCol, pos.col),
|
|
1240
|
-
endCol: Math.max(source.endCol, pos.col),
|
|
1241
|
-
};
|
|
1242
|
-
grid.fillRange(source, target);
|
|
1243
|
-
grid.setCellRange(target);
|
|
1244
|
-
};
|
|
1245
|
-
window.addEventListener("pointerup", onUp);
|
|
1246
|
-
window.addEventListener("pointercancel", onUp);
|
|
1246
|
+
dragCancel = startFillDrag(e, src, grid, hostEl.value);
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
1249
|
function cellLinkHref(row: RowData, col: ColumnDef): string {
|
|
@@ -1268,7 +1268,7 @@ function filterOpsOf(col: ColumnDef<Record<string, unknown>>) {
|
|
|
1268
1268
|
}
|
|
1269
1269
|
|
|
1270
1270
|
function filterOpOf(col: ColumnDef<Record<string, unknown>>): FilterOperator {
|
|
1271
|
-
const f = state.value.filters[col
|
|
1271
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1272
1272
|
return f ? f.operator : DEFAULT_OPERATOR_BY_TYPE[col.filterType || "text"];
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
@@ -1281,7 +1281,7 @@ function filterValueOf(
|
|
|
1281
1281
|
col: ColumnDef<Record<string, unknown>>,
|
|
1282
1282
|
key: "value" | "valueTo",
|
|
1283
1283
|
) {
|
|
1284
|
-
const f = state.value.filters[col
|
|
1284
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1285
1285
|
return f ? f[key] || "" : "";
|
|
1286
1286
|
}
|
|
1287
1287
|
|
|
@@ -1289,8 +1289,8 @@ function updateFilter(
|
|
|
1289
1289
|
col: ColumnDef<Record<string, unknown>>,
|
|
1290
1290
|
patch: Partial<ColumnFilter>,
|
|
1291
1291
|
) {
|
|
1292
|
-
const f = state.value.filters[col
|
|
1293
|
-
grid.setFilter(col
|
|
1292
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1293
|
+
grid.setFilter(colKeyOf(col), {
|
|
1294
1294
|
operator: filterOpOf(col),
|
|
1295
1295
|
value: f ? f.value : "",
|
|
1296
1296
|
valueTo: f ? f.valueTo : undefined,
|
|
@@ -1321,23 +1321,23 @@ function isSetFilter(col: ColumnDef<Record<string, unknown>>) {
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
function setValuesOf(col: ColumnDef<Record<string, unknown>>): string[] {
|
|
1324
|
-
return grid.getUniqueValues(col
|
|
1324
|
+
return grid.getUniqueValues(colKeyOf(col));
|
|
1325
1325
|
}
|
|
1326
1326
|
|
|
1327
1327
|
function setFilterLabel(col: ColumnDef<Record<string, unknown>>) {
|
|
1328
|
-
const f = state.value.filters[col
|
|
1328
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1329
1329
|
const vals = f && f.values;
|
|
1330
1330
|
return vals ? state.value.locale.setFilterCount(vals.length) : "전체";
|
|
1331
1331
|
}
|
|
1332
1332
|
|
|
1333
1333
|
function setCheckedOf(col: ColumnDef<Record<string, unknown>>, v: string) {
|
|
1334
|
-
const f = state.value.filters[col
|
|
1334
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1335
1335
|
const vals = f && f.values;
|
|
1336
1336
|
return vals ? vals.includes(v) : true;
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
1339
|
function setAllCheckedOf(col: ColumnDef<Record<string, unknown>>) {
|
|
1340
|
-
const f = state.value.filters[col
|
|
1340
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1341
1341
|
const vals = f && f.values;
|
|
1342
1342
|
return !vals || vals.length >= setValuesOf(col).length;
|
|
1343
1343
|
}
|
|
@@ -1349,13 +1349,13 @@ function onSetToggle(
|
|
|
1349
1349
|
) {
|
|
1350
1350
|
const checked = (event.target as HTMLInputElement).checked;
|
|
1351
1351
|
const all = setValuesOf(col);
|
|
1352
|
-
const f = state.value.filters[col
|
|
1352
|
+
const f = state.value.filters[colKeyOf(col)];
|
|
1353
1353
|
const next = new Set((f && f.values) || all);
|
|
1354
1354
|
if (checked) next.add(v);
|
|
1355
1355
|
else next.delete(v);
|
|
1356
|
-
if (next.size >= all.length) grid.setFilter(col
|
|
1356
|
+
if (next.size >= all.length) grid.setFilter(colKeyOf(col), null);
|
|
1357
1357
|
else {
|
|
1358
|
-
grid.setFilter(col
|
|
1358
|
+
grid.setFilter(colKeyOf(col), {
|
|
1359
1359
|
operator: "set",
|
|
1360
1360
|
value: "",
|
|
1361
1361
|
values: [...next],
|
|
@@ -1399,7 +1399,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
: {
|
|
1401
1401
|
kind: "col" as const,
|
|
1402
|
-
key: it.col
|
|
1402
|
+
key: colKeyOf(it.col),
|
|
1403
1403
|
col: it.col,
|
|
1404
1404
|
colIndex: it.index,
|
|
1405
1405
|
},
|
|
@@ -1416,7 +1416,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
: {
|
|
1418
1418
|
kind: "col",
|
|
1419
|
-
key: cols[s.startIndex]
|
|
1419
|
+
key: colKeyOf(cols[s.startIndex]!),
|
|
1420
1420
|
col: cols[s.startIndex]!,
|
|
1421
1421
|
colIndex: s.startIndex,
|
|
1422
1422
|
rowSpan: 2,
|
|
@@ -1426,7 +1426,7 @@ const headerRows = computed<HeaderCell[][]>(() => {
|
|
|
1426
1426
|
s.groupId
|
|
1427
1427
|
? cols.slice(s.startIndex, s.startIndex + s.colSpan).map((col, i) => ({
|
|
1428
1428
|
kind: "col" as const,
|
|
1429
|
-
key: col
|
|
1429
|
+
key: colKeyOf(col),
|
|
1430
1430
|
col,
|
|
1431
1431
|
colIndex: s.startIndex + i,
|
|
1432
1432
|
}))
|
|
@@ -1437,73 +1437,35 @@ const headerRows = computed<HeaderCell[][]>(() => {
|
|
|
1437
1437
|
|
|
1438
1438
|
const headerRowSpan = computed(() => headerRows.value.length);
|
|
1439
1439
|
|
|
1440
|
-
// ──
|
|
1441
|
-
//
|
|
1442
|
-
let resizeRaf = 0;
|
|
1443
|
-
let pendingWidth: { field: string; width: number } | null = null;
|
|
1444
|
-
|
|
1440
|
+
// ── 리사이즈: document 포인터 추적은 adapterDom 컨트롤러에 위임 ──
|
|
1441
|
+
// rAF 스로틀·RTL 부호 반전·최종값 확정이 코어에 단일화돼 있다
|
|
1445
1442
|
function onResizeStart(col: ColumnDef, event: PointerEvent) {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
const onMove = (ev: PointerEvent) => {
|
|
1452
|
-
pendingWidth = { field, width: startWidth + (ev.clientX - startX) };
|
|
1453
|
-
if (resizeRaf === 0) {
|
|
1454
|
-
resizeRaf = requestAnimationFrame(() => {
|
|
1455
|
-
resizeRaf = 0;
|
|
1456
|
-
if (pendingWidth)
|
|
1457
|
-
grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
|
|
1458
|
-
});
|
|
1459
|
-
}
|
|
1460
|
-
};
|
|
1461
|
-
const onUp = () => {
|
|
1462
|
-
document.removeEventListener("pointermove", onMove);
|
|
1463
|
-
document.removeEventListener("pointerup", onUp);
|
|
1464
|
-
document.removeEventListener("pointercancel", onUp);
|
|
1465
|
-
if (resizeRaf !== 0) {
|
|
1466
|
-
cancelAnimationFrame(resizeRaf);
|
|
1467
|
-
resizeRaf = 0;
|
|
1468
|
-
}
|
|
1469
|
-
if (pendingWidth)
|
|
1470
|
-
grid.setColumnWidth(pendingWidth.field, pendingWidth.width);
|
|
1471
|
-
pendingWidth = null;
|
|
1472
|
-
};
|
|
1473
|
-
document.addEventListener("pointermove", onMove);
|
|
1474
|
-
document.addEventListener("pointerup", onUp);
|
|
1475
|
-
document.addEventListener("pointercancel", onUp);
|
|
1443
|
+
dragCancel = startColumnResize(event, {
|
|
1444
|
+
field: colKeyOf(col),
|
|
1445
|
+
dir: grid.getSnapshot().dir,
|
|
1446
|
+
setWidth: (f, w) => grid.setColumnWidth(f, w),
|
|
1447
|
+
});
|
|
1476
1448
|
}
|
|
1477
1449
|
|
|
1478
1450
|
// ── 행 높이 리사이즈: 행 번호 셀 하단 핸들 드래그 → setRowHeight ──
|
|
1479
1451
|
function onRowResizeStart(rowId: string, event: PointerEvent) {
|
|
1480
1452
|
event.preventDefault();
|
|
1481
1453
|
event.stopPropagation();
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
const onMove = (ev: PointerEvent) => {
|
|
1486
|
-
grid.setRowHeight(rowId, Math.max(16, startHeight + (ev.clientY - startY)));
|
|
1487
|
-
};
|
|
1488
|
-
const onUp = () => {
|
|
1489
|
-
document.removeEventListener("pointermove", onMove);
|
|
1490
|
-
document.removeEventListener("pointerup", onUp);
|
|
1491
|
-
document.removeEventListener("pointercancel", onUp);
|
|
1492
|
-
};
|
|
1493
|
-
document.addEventListener("pointermove", onMove);
|
|
1494
|
-
document.addEventListener("pointerup", onUp);
|
|
1495
|
-
document.addEventListener("pointercancel", onUp);
|
|
1454
|
+
dragCancel = startRowResize(event, {
|
|
1455
|
+
setHeight: (h) => grid.setRowHeight(rowId, h),
|
|
1456
|
+
});
|
|
1496
1457
|
}
|
|
1497
1458
|
|
|
1498
1459
|
// 키보드 리사이즈 (방향키 ±10px)
|
|
1499
1460
|
function onResizerKeydown(col: ColumnDef, event: KeyboardEvent) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1461
|
+
if (event.isComposing) return;
|
|
1462
|
+
// ±10px — RTL 부호 반전은 adapterDom 계약
|
|
1463
|
+
const delta = resizeKeyDelta(event.key, grid.getSnapshot().dir);
|
|
1502
1464
|
if (delta === 0) return;
|
|
1503
1465
|
event.preventDefault();
|
|
1504
1466
|
const th = (event.currentTarget as HTMLElement).closest("th");
|
|
1505
1467
|
const w = th?.getBoundingClientRect().width ?? col.width ?? 0;
|
|
1506
|
-
grid.setColumnWidth(col
|
|
1468
|
+
grid.setColumnWidth(colKeyOf(col), w + delta);
|
|
1507
1469
|
}
|
|
1508
1470
|
|
|
1509
1471
|
// ── 컬럼 드래그 재배치 (HTML5 DnD) ──
|
|
@@ -1511,25 +1473,26 @@ const dragOverField = ref<string | null>(null);
|
|
|
1511
1473
|
let dragField: string | null = null;
|
|
1512
1474
|
|
|
1513
1475
|
function onDragStart(col: ColumnDef, event: DragEvent) {
|
|
1514
|
-
dragField = col
|
|
1476
|
+
dragField = colKeyOf(col);
|
|
1515
1477
|
if (event.dataTransfer) {
|
|
1516
1478
|
event.dataTransfer.effectAllowed = "move";
|
|
1517
|
-
event.dataTransfer.setData("text/plain", col
|
|
1518
|
-
event.dataTransfer.setData("application/x-mg-column", col
|
|
1479
|
+
event.dataTransfer.setData("text/plain", colKeyOf(col));
|
|
1480
|
+
event.dataTransfer.setData("application/x-mg-column", colKeyOf(col));
|
|
1519
1481
|
}
|
|
1520
1482
|
}
|
|
1521
1483
|
|
|
1522
1484
|
function onDragOver(col: ColumnDef, event: DragEvent) {
|
|
1523
|
-
if (!props.reorderable || !dragField || dragField === col
|
|
1485
|
+
if (!props.reorderable || !dragField || dragField === colKeyOf(col)) return;
|
|
1524
1486
|
event.preventDefault();
|
|
1525
1487
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
|
1526
|
-
if (dragOverField.value !== col
|
|
1488
|
+
if (dragOverField.value !== colKeyOf(col))
|
|
1489
|
+
dragOverField.value = colKeyOf(col);
|
|
1527
1490
|
}
|
|
1528
1491
|
|
|
1529
1492
|
function onDrop(col: ColumnDef, event: DragEvent) {
|
|
1530
1493
|
event.preventDefault();
|
|
1531
|
-
if (dragField && dragField !== col
|
|
1532
|
-
grid.reorderColumn(dragField, col
|
|
1494
|
+
if (dragField && dragField !== colKeyOf(col)) {
|
|
1495
|
+
grid.reorderColumn(dragField, colKeyOf(col));
|
|
1533
1496
|
}
|
|
1534
1497
|
onDragEnd();
|
|
1535
1498
|
}
|
|
@@ -1592,39 +1555,8 @@ function rowStateOf(row: RowT | null | undefined) {
|
|
|
1592
1555
|
return row ? state.value.rowStates[grid.getRowId(row)] : undefined;
|
|
1593
1556
|
}
|
|
1594
1557
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
const row = rowDataOf(entry);
|
|
1598
|
-
if (!row) return null;
|
|
1599
|
-
// setCellError 수동 마킹은 행 상태·validate 유무와 무관하게 표시한다
|
|
1600
|
-
if (grid.hasManualCellError(row, col)) return grid.getCellError(row, col);
|
|
1601
|
-
if (!rowStateOf(row)) return null;
|
|
1602
|
-
if (!col.required && !col.validate) return null;
|
|
1603
|
-
return grid.getCellError(row, col);
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
/** 셀 노트 텍스트 — 있으면 td에 mg-cell-note 클래스 + title로 표시 */
|
|
1607
|
-
function cellNoteOf(entry: AnyRow, col: ColumnDef): string | null {
|
|
1608
|
-
const row = rowDataOf(entry);
|
|
1609
|
-
if (row == null) return null;
|
|
1610
|
-
return grid.getCellNote(row, col);
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
function cellClassOf(entry: AnyRow, rowIdx: number, col: ColumnDef) {
|
|
1614
|
-
const row = rowDataOf(entry);
|
|
1615
|
-
if (row == null) return "";
|
|
1616
|
-
return grid.getCellClass(row, entryIndexOf(entry, rowIdx), col);
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
/** find 하이라이트 — findBox 검색어에 매치되는 셀인지 (그룹 헤더 등 null 행 제외) */
|
|
1620
|
-
function isFindMatch(entry: AnyRow, col: ColumnDef): boolean {
|
|
1621
|
-
const row = rowDataOf(entry);
|
|
1622
|
-
return (
|
|
1623
|
-
!!state.value.findQuery &&
|
|
1624
|
-
row != null &&
|
|
1625
|
-
grid.isFindMatch(row, String(col.field))
|
|
1626
|
-
);
|
|
1627
|
-
}
|
|
1558
|
+
// 셀 유효성 에러/노트/find 매칭/사용자 cellClass 표현은 코어
|
|
1559
|
+
// describeCell로 이동했다 (cellDescOf가 호출)
|
|
1628
1560
|
|
|
1629
1561
|
function onRowDragStart(rowIndex: number, event: DragEvent) {
|
|
1630
1562
|
if (!grid.beginRowDrag(rowIndex)) {
|
|
@@ -1644,17 +1576,13 @@ function onRowDragOver(rowIndex: number, event: DragEvent) {
|
|
|
1644
1576
|
event.preventDefault();
|
|
1645
1577
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
|
1646
1578
|
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
return;
|
|
1655
|
-
}
|
|
1656
|
-
const gap = ratio < 0.5 ? rowIndex : rowIndex + 1;
|
|
1657
|
-
grid.updateRowDropPosition(gap);
|
|
1579
|
+
// 트리는 상하 25%가 형제 위/아래·가운데 50%가 자식 — adapterDom 계약
|
|
1580
|
+
const drop = resolveRowDrop(
|
|
1581
|
+
dropRatioForY(event.clientY, rect),
|
|
1582
|
+
rowIndex,
|
|
1583
|
+
grid.isTreeRowDraggable(),
|
|
1584
|
+
);
|
|
1585
|
+
grid.updateRowDropPosition(drop.index, drop.position);
|
|
1658
1586
|
}
|
|
1659
1587
|
|
|
1660
1588
|
function onRowDrop(event: DragEvent) {
|
|
@@ -1668,192 +1596,24 @@ function onRowDragEnd() {
|
|
|
1668
1596
|
}
|
|
1669
1597
|
|
|
1670
1598
|
// ── 셀 선택: 방향키/Home/End/PageUp·Down → 코어 네비게이션 ──
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
ArrowDown: "down",
|
|
1674
|
-
ArrowLeft: "left",
|
|
1675
|
-
ArrowRight: "right",
|
|
1676
|
-
Home: "home",
|
|
1677
|
-
End: "end",
|
|
1678
|
-
PageUp: "pageUp",
|
|
1679
|
-
PageDown: "pageDown",
|
|
1680
|
-
};
|
|
1681
|
-
|
|
1599
|
+
// 키 계약 전체(클립보드/이력/Escape/Delete/Tab/Enter/방향키/인쇄문자)는
|
|
1600
|
+
// adapterDom.handleGridKeydown에 단일화 — 5개 렌더러가 같은 코드를 실행한다
|
|
1682
1601
|
function onGridKeydown(event: KeyboardEvent) {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
event.preventDefault();
|
|
1693
|
-
void writeClipboardText(tsv);
|
|
1694
|
-
}
|
|
1695
|
-
} else if (key === "x") {
|
|
1696
|
-
const tsv = grid.cutSelectionTsv(); // 엑셀 Ctrl+X — 잘라내기
|
|
1697
|
-
if (tsv != null) {
|
|
1698
|
-
event.preventDefault();
|
|
1699
|
-
void writeClipboardText(tsv);
|
|
1700
|
-
}
|
|
1701
|
-
} else if (key === "v") {
|
|
1702
|
-
event.preventDefault();
|
|
1703
|
-
void readClipboardText().then((text) => {
|
|
1704
|
-
if (text != null) grid.pasteTsv(text);
|
|
1705
|
-
});
|
|
1706
|
-
} else if (key === "z") {
|
|
1707
|
-
event.preventDefault();
|
|
1708
|
-
if (event.shiftKey) grid.redo();
|
|
1709
|
-
else grid.undo();
|
|
1710
|
-
} else if (key === "y") {
|
|
1711
|
-
event.preventDefault();
|
|
1712
|
-
grid.redo();
|
|
1713
|
-
} else if (key === "a") {
|
|
1714
|
-
// single-cell 모드의 selectAll은 전체 행 선택 — selectable일 때만
|
|
1715
|
-
if (
|
|
1716
|
-
state.value.selectionMode === "single-cell" &&
|
|
1717
|
-
props.selectable === false
|
|
1718
|
-
)
|
|
1719
|
-
return;
|
|
1720
|
-
event.preventDefault();
|
|
1721
|
-
grid.selectAll();
|
|
1722
|
-
} else if (key === "f") {
|
|
1723
|
-
if (!props.findBox) return; // findBox 없으면 브라우저 검색에 양보
|
|
1724
|
-
event.preventDefault();
|
|
1725
|
-
findInputEl.value?.focus();
|
|
1726
|
-
findInputEl.value?.select();
|
|
1727
|
-
} else if (key === "d") {
|
|
1728
|
-
event.preventDefault();
|
|
1729
|
-
grid.fillDown(); // 엑셀 Ctrl+D — 아래 채우기
|
|
1730
|
-
} else if (key === "r") {
|
|
1731
|
-
event.preventDefault();
|
|
1732
|
-
grid.fillRight(); // 엑셀 Ctrl+R — 오른쪽 채우기
|
|
1733
|
-
} else if (event.key === "Home") {
|
|
1734
|
-
event.preventDefault();
|
|
1735
|
-
grid.navigateCell("first", event.shiftKey); // Ctrl+Home — 첫 셀
|
|
1736
|
-
} else if (event.key === "End") {
|
|
1737
|
-
event.preventDefault();
|
|
1738
|
-
grid.navigateCell("last", event.shiftKey); // Ctrl+End — 마지막 셀
|
|
1739
|
-
} else if (event.key === "ArrowUp") {
|
|
1740
|
-
event.preventDefault();
|
|
1741
|
-
grid.navigateCell("top", event.shiftKey);
|
|
1742
|
-
} else if (event.key === "ArrowDown") {
|
|
1743
|
-
event.preventDefault();
|
|
1744
|
-
grid.navigateCell("bottom", event.shiftKey);
|
|
1745
|
-
} else if (event.key === "ArrowLeft") {
|
|
1746
|
-
event.preventDefault();
|
|
1747
|
-
// Ctrl+←는 시각적 왼쪽 가장자리 — RTL에서는 논리적으로 마지막 컬럼
|
|
1748
|
-
grid.navigateCell(
|
|
1749
|
-
state.value.dir === "rtl" ? "end" : "home",
|
|
1750
|
-
event.shiftKey,
|
|
1751
|
-
);
|
|
1752
|
-
} else if (event.key === "ArrowRight") {
|
|
1753
|
-
event.preventDefault();
|
|
1754
|
-
grid.navigateCell(
|
|
1755
|
-
state.value.dir === "rtl" ? "home" : "end",
|
|
1756
|
-
event.shiftKey,
|
|
1757
|
-
);
|
|
1758
|
-
} else if (event.key === " ") {
|
|
1759
|
-
event.preventDefault();
|
|
1760
|
-
grid.selectEntireColumn(); // 엑셀 Ctrl+Space — 열 선택
|
|
1761
|
-
}
|
|
1762
|
-
return;
|
|
1763
|
-
}
|
|
1764
|
-
if (event.key === "Escape") {
|
|
1765
|
-
if (state.value.rowDrag) grid.endRowDrag(false);
|
|
1766
|
-
else grid.clearCellSelection();
|
|
1767
|
-
return;
|
|
1768
|
-
}
|
|
1769
|
-
if (event.key === "Delete" || event.key === "Backspace") {
|
|
1770
|
-
// 선택 영역(없으면 활성 셀) 내용 지우기 — 타사 그리드 Del키 대응
|
|
1771
|
-
event.preventDefault();
|
|
1772
|
-
grid.clearRange();
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
const active = state.value.activeCell;
|
|
1776
|
-
if (event.key === " " && event.shiftKey) {
|
|
1777
|
-
// 엑셀 Shift+Space — 행 선택 (타이핑 경로보다 먼저 처리).
|
|
1778
|
-
// single-cell은 행 선택으로 대체되므로 selectable을 게이트한다
|
|
1779
|
-
if (
|
|
1780
|
-
state.value.selectionMode === "single-cell" &&
|
|
1781
|
-
props.selectable === false
|
|
1782
|
-
)
|
|
1783
|
-
return;
|
|
1784
|
-
event.preventDefault();
|
|
1785
|
-
grid.selectEntireRow();
|
|
1786
|
-
return;
|
|
1787
|
-
}
|
|
1788
|
-
if (event.key === "Tab" && active) {
|
|
1789
|
-
// 엑셀 Tab — 활성 셀 좌/우 이동
|
|
1790
|
-
event.preventDefault();
|
|
1791
|
-
grid.navigateCell(event.shiftKey ? "tabLeft" : "tabRight");
|
|
1792
|
-
return;
|
|
1793
|
-
}
|
|
1794
|
-
if (event.key === "Enter" || event.key === "F2") {
|
|
1795
|
-
// 활성 셀에서 Enter → 편집 진입
|
|
1796
|
-
if (active) {
|
|
1797
|
-
event.preventDefault();
|
|
1798
|
-
grid.startEditing(active.rowIndex, active.columnIndex);
|
|
1799
|
-
}
|
|
1800
|
-
return;
|
|
1801
|
-
}
|
|
1802
|
-
const dir = CELL_KEYS[event.key];
|
|
1803
|
-
if (dir) {
|
|
1804
|
-
event.preventDefault();
|
|
1805
|
-
grid.navigateCell(dir, event.shiftKey);
|
|
1806
|
-
return;
|
|
1807
|
-
}
|
|
1808
|
-
// 인쇄 가능한 문자 직접 입력 → 값을 교체하며 편집 진입
|
|
1809
|
-
if (
|
|
1810
|
-
event.key.length === 1 &&
|
|
1811
|
-
!event.ctrlKey &&
|
|
1812
|
-
!event.metaKey &&
|
|
1813
|
-
!event.altKey &&
|
|
1814
|
-
active
|
|
1815
|
-
) {
|
|
1816
|
-
event.preventDefault();
|
|
1817
|
-
grid.startEditing(active.rowIndex, active.columnIndex, event.key);
|
|
1818
|
-
}
|
|
1602
|
+
handleGridKeydown(event, grid, {
|
|
1603
|
+
selectable: props.selectable,
|
|
1604
|
+
focusFind: props.findBox
|
|
1605
|
+
? () => {
|
|
1606
|
+
findInputEl.value?.focus();
|
|
1607
|
+
findInputEl.value?.select();
|
|
1608
|
+
}
|
|
1609
|
+
: undefined,
|
|
1610
|
+
});
|
|
1819
1611
|
}
|
|
1820
1612
|
|
|
1821
1613
|
// 가상 스크롤/그룹화 시 행 인덱스 → visibleData 기준 인덱스
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
function isSubtotalRow(entry: AnyRow) {
|
|
1827
|
-
return (entry as DisplayRow<RowT> | undefined)?.type === "subtotal";
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
function groupOf(entry: AnyRow): GroupNode<RowT> {
|
|
1831
|
-
return entry as GroupNode<RowT>;
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
function leafOf(entry: AnyRow): LeafDisplayRow<RowT> | null {
|
|
1835
|
-
const e = entry as DisplayRow<RowT>;
|
|
1836
|
-
return e && e.type === "leaf" ? (e as LeafDisplayRow<RowT>) : null;
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
function rowDataOf(entry: AnyRow): RowT {
|
|
1840
|
-
const l = leafOf(entry);
|
|
1841
|
-
return l ? l.row : (entry as RowT);
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
function leafDepthOf(entry: AnyRow) {
|
|
1845
|
-
const l = leafOf(entry);
|
|
1846
|
-
return l ? l.depth : 0;
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
// 트리 노드 헬퍼 — 템플릿에서 non-null 단언(!)을 쓸 수 없어 함수로 노출
|
|
1850
|
-
function leafHasChildren(entry: AnyRow): boolean | undefined {
|
|
1851
|
-
return leafOf(entry)?.hasChildren;
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
function leafExpanded(entry: AnyRow): boolean {
|
|
1855
|
-
return leafOf(entry)?.expanded === true;
|
|
1856
|
-
}
|
|
1614
|
+
// DisplayRow 판별/추출은 코어 displayRows 헬퍼를 import해 공유한다 —
|
|
1615
|
+
// 로컬에 두는 것은 어댑터 전용 상태(가상 스크롤, 스냅샷, grid)를
|
|
1616
|
+
// 읽는 wrapper뿐이다
|
|
1857
1617
|
|
|
1858
1618
|
/** 전체 너비 행 판정 — leaf 행만 검사 (스켈레톤·그룹 행 제외) */
|
|
1859
1619
|
function isFullWidthOf(entry: AnyRow, rowIdx: number): boolean {
|
|
@@ -1877,10 +1637,7 @@ function rowKeyOf(entry: AnyRow, rowIdx: number) {
|
|
|
1877
1637
|
}
|
|
1878
1638
|
|
|
1879
1639
|
function groupLabelOf(entry: AnyRow) {
|
|
1880
|
-
|
|
1881
|
-
const col = state.value.columns.find((c) => c.field === n.field);
|
|
1882
|
-
const header = col && col.header ? col.header : n.field;
|
|
1883
|
-
return `${header}: ${String(n.value == null ? "(빈 값)" : n.value)}`;
|
|
1640
|
+
return coreGroupLabelOf(groupOf(entry), state.value.columns);
|
|
1884
1641
|
}
|
|
1885
1642
|
|
|
1886
1643
|
function groupAggOf(entry: AnyRow, col: ColumnDef<RowT>) {
|
|
@@ -1893,9 +1650,24 @@ function onToggleGroup(entry: AnyRow) {
|
|
|
1893
1650
|
}
|
|
1894
1651
|
|
|
1895
1652
|
// ── 인라인 셀 편집 ──
|
|
1896
|
-
// 셀
|
|
1897
|
-
|
|
1898
|
-
|
|
1653
|
+
// 셀 표현 디스크립터 — td의 클래스/스타일/title/병합 span은 코어
|
|
1654
|
+
// describeCell이 계산한다 (5개 렌더러 동일 계약, 스파스 행은 null)
|
|
1655
|
+
function cellDescOf(
|
|
1656
|
+
entry: AnyRow,
|
|
1657
|
+
rowIdx: number,
|
|
1658
|
+
col: ColumnDef,
|
|
1659
|
+
colIndex: number,
|
|
1660
|
+
) {
|
|
1661
|
+
const row = rowDataOf(entry);
|
|
1662
|
+
if (row == null) return null;
|
|
1663
|
+
return describeCell(
|
|
1664
|
+
grid,
|
|
1665
|
+
row,
|
|
1666
|
+
entryIndexOf(entry, rowIdx),
|
|
1667
|
+
col,
|
|
1668
|
+
colIndex,
|
|
1669
|
+
leafHasChildren(entry) !== undefined ? leafDepthOf(entry) : null,
|
|
1670
|
+
);
|
|
1899
1671
|
}
|
|
1900
1672
|
|
|
1901
1673
|
function isEditingCell(rowIndex: number, colIndex: number) {
|
|
@@ -1906,13 +1678,13 @@ function isEditingCell(rowIndex: number, colIndex: number) {
|
|
|
1906
1678
|
function editValueOf(col: ColumnDef) {
|
|
1907
1679
|
const s = state.value;
|
|
1908
1680
|
if (s.editType === "fullRow" && s.editingValues)
|
|
1909
|
-
return s.editingValues[col
|
|
1681
|
+
return s.editingValues[colKeyOf(col)];
|
|
1910
1682
|
return s.editValue;
|
|
1911
1683
|
}
|
|
1912
1684
|
function editErrorOf(col: ColumnDef) {
|
|
1913
1685
|
const s = state.value;
|
|
1914
1686
|
if (s.editType === "fullRow" && s.editingErrors)
|
|
1915
|
-
return s.editingErrors[col
|
|
1687
|
+
return s.editingErrors[colKeyOf(col)] ?? null;
|
|
1916
1688
|
return s.editError;
|
|
1917
1689
|
}
|
|
1918
1690
|
|
|
@@ -1928,9 +1700,13 @@ function onCellMouseDown(
|
|
|
1928
1700
|
e: MouseEvent,
|
|
1929
1701
|
rowIndex: number,
|
|
1930
1702
|
colIndex: number,
|
|
1931
|
-
|
|
1703
|
+
_col: ColumnDef,
|
|
1932
1704
|
) {
|
|
1933
1705
|
if (e.button !== 0 || isEditingCell(rowIndex, colIndex)) return;
|
|
1706
|
+
// 인터랙티브 자식(체크박스·select·버튼·링크 등)은 건드리지 않는다 —
|
|
1707
|
+
// preventDefault가 select 네이티브 드롭다운을 죽이고, setActiveCell의
|
|
1708
|
+
// 리렌더가 자식의 click/change를 소실시킨다 (vanilla와 같은 가드)
|
|
1709
|
+
if (isInteractiveCellTarget(e.target)) return;
|
|
1934
1710
|
// fullRow — 편집 행 안 클릭은 커밋/선택 변경 없이 통과
|
|
1935
1711
|
if (
|
|
1936
1712
|
state.value.editType === "fullRow" &&
|
|
@@ -1949,12 +1725,23 @@ function onCellMouseDown(
|
|
|
1949
1725
|
cellDragging = true;
|
|
1950
1726
|
e.preventDefault(); // 드래그 중 텍스트 선택 방지
|
|
1951
1727
|
}
|
|
1952
|
-
function onCellMouseEnter(rowIndex: number, colIndex: number) {
|
|
1728
|
+
function onCellMouseEnter(e: MouseEvent, rowIndex: number, colIndex: number) {
|
|
1953
1729
|
if (!cellDragging) return;
|
|
1730
|
+
// 창 밖 mouseup 유실로 남은 stale 드래그 — 버튼이 안 눌려 있으면 자가 치유
|
|
1731
|
+
if ((e.buttons & 1) === 0) {
|
|
1732
|
+
cellDragging = false;
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1954
1735
|
suppressCellClick = true;
|
|
1955
1736
|
grid.extendSelectionTo(rowIndex, colIndex);
|
|
1956
1737
|
}
|
|
1957
|
-
function onCellClick(rowIndex: number, colIndex: number) {
|
|
1738
|
+
function onCellClick(e: MouseEvent, rowIndex: number, colIndex: number) {
|
|
1739
|
+
// 인터랙티브 자식의 click은 셀 클릭으로 처리하지 않는다 — vanilla는
|
|
1740
|
+
// mousedown 가드로 pendingCellClick 자체가 안 세워져 같은 결과다
|
|
1741
|
+
if (isInteractiveCellTarget(e.target)) {
|
|
1742
|
+
suppressCellClick = false;
|
|
1743
|
+
return;
|
|
1744
|
+
}
|
|
1958
1745
|
if (!suppressCellClick) {
|
|
1959
1746
|
grid.setActiveCell(rowIndex, colIndex);
|
|
1960
1747
|
grid.trySingleClickEdit(rowIndex, colIndex);
|
|
@@ -1962,6 +1749,11 @@ function onCellClick(rowIndex: number, colIndex: number) {
|
|
|
1962
1749
|
suppressCellClick = false;
|
|
1963
1750
|
grid.notifyCellEvent("cellClick", rowIndex, colIndex);
|
|
1964
1751
|
}
|
|
1752
|
+
function onCellDblClick(e: MouseEvent, rowIndex: number, colIndex: number) {
|
|
1753
|
+
if (isInteractiveCellTarget(e.target)) return;
|
|
1754
|
+
grid.notifyCellEvent("cellDblClick", rowIndex, colIndex);
|
|
1755
|
+
grid.startEditing(rowIndex, colIndex);
|
|
1756
|
+
}
|
|
1965
1757
|
|
|
1966
1758
|
function editorContext(rowIndex: number, colIndex: number) {
|
|
1967
1759
|
return grid.getEditorContext(rowIndex, colIndex) as CellEditorContext;
|
|
@@ -1990,7 +1782,7 @@ function onEditorInput(event: Event, col: ColumnDef) {
|
|
|
1990
1782
|
el.setSelectionRange(next.length, next.length);
|
|
1991
1783
|
}
|
|
1992
1784
|
}
|
|
1993
|
-
grid.updateEditValue(el.value, col
|
|
1785
|
+
grid.updateEditValue(el.value, colKeyOf(col));
|
|
1994
1786
|
}
|
|
1995
1787
|
|
|
1996
1788
|
// text 에디터 표시 값 — editMask가 있으면 기존 저장값도 마스크 형태로 표시
|
|
@@ -2009,19 +1801,22 @@ function onMultiselectChange(event: Event, col: ColumnDef) {
|
|
|
2009
1801
|
const sel = event.target as HTMLSelectElement;
|
|
2010
1802
|
grid.updateEditValue(
|
|
2011
1803
|
Array.from(sel.selectedOptions).map((o) => o.value),
|
|
2012
|
-
col
|
|
1804
|
+
colKeyOf(col),
|
|
2013
1805
|
);
|
|
2014
1806
|
}
|
|
2015
1807
|
|
|
2016
1808
|
// 라디오 에디터 — 선택 즉시 커밋 (fullRow에서는 보류 값만 반영)
|
|
2017
1809
|
function onRadioPick(opt: string, col: ColumnDef) {
|
|
2018
|
-
grid.updateEditValue(opt, col
|
|
1810
|
+
grid.updateEditValue(opt, colKeyOf(col));
|
|
2019
1811
|
if (state.value.editType !== "fullRow") grid.commitEditing();
|
|
2020
1812
|
}
|
|
2021
1813
|
|
|
2022
1814
|
// select 에디터 — 고르는 즉시 커밋 (fullRow에서는 보류 값만 반영)
|
|
2023
1815
|
function onSelectPick(event: Event, col: ColumnDef) {
|
|
2024
|
-
grid.updateEditValue(
|
|
1816
|
+
grid.updateEditValue(
|
|
1817
|
+
(event.target as HTMLSelectElement).value,
|
|
1818
|
+
colKeyOf(col),
|
|
1819
|
+
);
|
|
2025
1820
|
if (state.value.editType !== "fullRow") grid.commitEditing();
|
|
2026
1821
|
}
|
|
2027
1822
|
|
|
@@ -2090,7 +1885,7 @@ watch(
|
|
|
2090
1885
|
if (!cell) return;
|
|
2091
1886
|
await nextTick();
|
|
2092
1887
|
const colIdx = state.value.visibleColumns.findIndex(
|
|
2093
|
-
(c) => c
|
|
1888
|
+
(c) => colKeyOf(c) === cell.columnKey,
|
|
2094
1889
|
);
|
|
2095
1890
|
const target =
|
|
2096
1891
|
scrollEl.value?.querySelector<HTMLElement>(
|
|
@@ -2319,7 +2114,7 @@ watch(
|
|
|
2319
2114
|
title="클릭 시 그룹 해제"
|
|
2320
2115
|
@click="ungroupField(field)"
|
|
2321
2116
|
>
|
|
2322
|
-
{{ state.columns
|
|
2117
|
+
{{ resolveColumn(state.columns, field)?.header ?? field }} ×
|
|
2323
2118
|
</button>
|
|
2324
2119
|
</div>
|
|
2325
2120
|
<div v-if="showOverlay" class="mg-colctl">
|
|
@@ -2362,13 +2157,13 @@ watch(
|
|
|
2362
2157
|
</div>
|
|
2363
2158
|
<label
|
|
2364
2159
|
v-for="col in state.columns"
|
|
2365
|
-
:key="col
|
|
2160
|
+
:key="colKeyOf(col)"
|
|
2366
2161
|
class="mg-colctl-item"
|
|
2367
2162
|
>
|
|
2368
2163
|
<input
|
|
2369
2164
|
type="checkbox"
|
|
2370
2165
|
:checked="col.visible !== false"
|
|
2371
|
-
@change="onColumnToggle(col
|
|
2166
|
+
@change="onColumnToggle(colKeyOf(col), $event)"
|
|
2372
2167
|
/>
|
|
2373
2168
|
{{ col.header ?? col.field }}
|
|
2374
2169
|
</label>
|
|
@@ -2411,7 +2206,7 @@ watch(
|
|
|
2411
2206
|
<col v-if="rowNumbers" class="mg-col-rownum" />
|
|
2412
2207
|
<col
|
|
2413
2208
|
v-for="col in state.visibleColumns"
|
|
2414
|
-
:key="col
|
|
2209
|
+
:key="colKeyOf(col)"
|
|
2415
2210
|
:style="{ width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px` }"
|
|
2416
2211
|
/>
|
|
2417
2212
|
</colgroup>
|
|
@@ -2477,8 +2272,8 @@ watch(
|
|
|
2477
2272
|
:class="[
|
|
2478
2273
|
{
|
|
2479
2274
|
'mg-sortable': cell.col.sortable !== false,
|
|
2480
|
-
'mg-col-dragover': dragOverField === cell.col
|
|
2481
|
-
'mg-col-dragging': touchColField === cell.col
|
|
2275
|
+
'mg-col-dragover': dragOverField === colKeyOf(cell.col),
|
|
2276
|
+
'mg-col-dragging': touchColField === colKeyOf(cell.col),
|
|
2482
2277
|
'mg-pinned': !!cell.col.pinned,
|
|
2483
2278
|
'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
|
|
2484
2279
|
'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
|
|
@@ -2490,15 +2285,15 @@ watch(
|
|
|
2490
2285
|
grid.getHeaderClass(cell.col),
|
|
2491
2286
|
]"
|
|
2492
2287
|
:title="cell.col.headerTooltip"
|
|
2493
|
-
:aria-sort="sortAria(cell.col
|
|
2288
|
+
:aria-sort="sortAria(colKeyOf(cell.col))"
|
|
2494
2289
|
:draggable="reorderable && cell.col.movable !== false"
|
|
2495
2290
|
@dragstart="onDragStart(cell.col, $event)"
|
|
2496
2291
|
@dragover="onDragOver(cell.col, $event)"
|
|
2497
2292
|
@drop="onDrop(cell.col, $event)"
|
|
2498
2293
|
@dragend="onDragEnd"
|
|
2499
|
-
@click="grid.toggleSort(cell.col
|
|
2294
|
+
@click="grid.toggleSort(colKeyOf(cell.col), $event.shiftKey)"
|
|
2500
2295
|
@contextmenu="onHeaderContextMenu($event, cell.col)"
|
|
2501
|
-
:data-mg-field="cell.col
|
|
2296
|
+
:data-mg-field="colKeyOf(cell.col)"
|
|
2502
2297
|
@pointerdown="onHeaderPointerDown($event, cell.col)"
|
|
2503
2298
|
>
|
|
2504
2299
|
<input
|
|
@@ -2518,25 +2313,30 @@ watch(
|
|
|
2518
2313
|
@change="grid.toggleAllChecked(cell.col)"
|
|
2519
2314
|
/>
|
|
2520
2315
|
<!-- 커스텀 헤더 슬롯: #header-{field}="{ column }" -->
|
|
2521
|
-
<slot
|
|
2522
|
-
|
|
2523
|
-
|
|
2316
|
+
<slot
|
|
2317
|
+
:name="`header-${colKeyOf(cell.col)}`"
|
|
2318
|
+
:column="cell.col"
|
|
2319
|
+
>{{ cell.col.header || cell.col.field }}</slot
|
|
2320
|
+
>
|
|
2524
2321
|
<span v-if="cell.col.required" class="mg-required-mark">*</span>
|
|
2525
|
-
<span
|
|
2526
|
-
|
|
2322
|
+
<span
|
|
2323
|
+
v-if="sortArrowOf(colKeyOf(cell.col))"
|
|
2324
|
+
class="mg-sort-arrow"
|
|
2325
|
+
>
|
|
2326
|
+
{{ sortArrowOf(colKeyOf(cell.col)) }}
|
|
2527
2327
|
</span>
|
|
2528
2328
|
<span
|
|
2529
|
-
v-if="sortPriorityOf(cell.col
|
|
2329
|
+
v-if="sortPriorityOf(colKeyOf(cell.col))"
|
|
2530
2330
|
class="mg-sort-priority"
|
|
2531
2331
|
>
|
|
2532
|
-
{{ sortPriorityOf(cell.col
|
|
2332
|
+
{{ sortPriorityOf(colKeyOf(cell.col)) }}
|
|
2533
2333
|
</span>
|
|
2534
2334
|
<button
|
|
2535
2335
|
v-if="headerFilters && cell.col.filterable"
|
|
2536
2336
|
type="button"
|
|
2537
2337
|
:class="[
|
|
2538
2338
|
'mg-header-filter-btn',
|
|
2539
|
-
state.filters[cell.col
|
|
2339
|
+
state.filters[colKeyOf(cell.col)] && 'mg-active',
|
|
2540
2340
|
]"
|
|
2541
2341
|
:aria-label="`${cell.col.header || cell.col.field} 필터`"
|
|
2542
2342
|
@click="toggleFilterDrop(cell.col, $event)"
|
|
@@ -2549,7 +2349,7 @@ watch(
|
|
|
2549
2349
|
class="mg-resizer"
|
|
2550
2350
|
:aria-label="`${cell.col.field} 너비 조절`"
|
|
2551
2351
|
@pointerdown.stop.prevent="onResizeStart(cell.col, $event)"
|
|
2552
|
-
@dblclick.stop="grid.autoSizeColumn(cell.col
|
|
2352
|
+
@dblclick.stop="grid.autoSizeColumn(colKeyOf(cell.col))"
|
|
2553
2353
|
@keydown.stop="onResizerKeydown(cell.col, $event)"
|
|
2554
2354
|
@click.stop
|
|
2555
2355
|
/>
|
|
@@ -2572,7 +2372,7 @@ watch(
|
|
|
2572
2372
|
></th>
|
|
2573
2373
|
<th
|
|
2574
2374
|
v-else
|
|
2575
|
-
:key="col
|
|
2375
|
+
:key="colKeyOf(col)"
|
|
2576
2376
|
:class="{
|
|
2577
2377
|
'mg-pinned': !!col.pinned,
|
|
2578
2378
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
@@ -2588,7 +2388,7 @@ watch(
|
|
|
2588
2388
|
<input
|
|
2589
2389
|
type="checkbox"
|
|
2590
2390
|
:checked="setAllCheckedOf(col)"
|
|
2591
|
-
@change="grid.setFilter(col
|
|
2391
|
+
@change="grid.setFilter(colKeyOf(col), null)"
|
|
2592
2392
|
/>
|
|
2593
2393
|
{{ state.locale.setFilterAll }}
|
|
2594
2394
|
</label>
|
|
@@ -2665,7 +2465,7 @@ watch(
|
|
|
2665
2465
|
/>
|
|
2666
2466
|
<td
|
|
2667
2467
|
v-else
|
|
2668
|
-
:key="col
|
|
2468
|
+
:key="colKeyOf(col)"
|
|
2669
2469
|
:class="{
|
|
2670
2470
|
'mg-pinned': !!col.pinned,
|
|
2671
2471
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
@@ -2714,7 +2514,7 @@ watch(
|
|
|
2714
2514
|
/>
|
|
2715
2515
|
<td
|
|
2716
2516
|
v-else
|
|
2717
|
-
:key="col
|
|
2517
|
+
:key="colKeyOf(col)"
|
|
2718
2518
|
class="mg-group-cell"
|
|
2719
2519
|
:class="{
|
|
2720
2520
|
'mg-pinned': !!col.pinned,
|
|
@@ -2762,7 +2562,7 @@ watch(
|
|
|
2762
2562
|
/>
|
|
2763
2563
|
<td
|
|
2764
2564
|
v-else
|
|
2765
|
-
:key="col
|
|
2565
|
+
:key="colKeyOf(col)"
|
|
2766
2566
|
class="mg-subtotal-cell"
|
|
2767
2567
|
:class="{
|
|
2768
2568
|
'mg-pinned': !!col.pinned,
|
|
@@ -2805,7 +2605,7 @@ watch(
|
|
|
2805
2605
|
/>
|
|
2806
2606
|
<td
|
|
2807
2607
|
v-else
|
|
2808
|
-
:key="col
|
|
2608
|
+
:key="colKeyOf(col)"
|
|
2809
2609
|
:class="{
|
|
2810
2610
|
'mg-pinned': !!col.pinned,
|
|
2811
2611
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
@@ -2898,64 +2698,14 @@ watch(
|
|
|
2898
2698
|
:colspan="count"
|
|
2899
2699
|
/>
|
|
2900
2700
|
<td
|
|
2901
|
-
v-else-if="!
|
|
2902
|
-
:key="col
|
|
2903
|
-
:rowspan="
|
|
2904
|
-
:colspan="
|
|
2905
|
-
:class="
|
|
2906
|
-
col.align && col.align !== 'left'
|
|
2907
|
-
? `mg-align-${col.align}`
|
|
2908
|
-
: '',
|
|
2909
|
-
{
|
|
2910
|
-
'mg-cell-readonly': !grid.isCellEditable(
|
|
2911
|
-
entryIndexOf(entry, rowIdx),
|
|
2912
|
-
colIndex,
|
|
2913
|
-
),
|
|
2914
|
-
'mg-cell-active': grid.isActiveCell(
|
|
2915
|
-
entryIndexOf(entry, rowIdx),
|
|
2916
|
-
colIndex,
|
|
2917
|
-
),
|
|
2918
|
-
'mg-cell-selected': grid.isCellInRange(
|
|
2919
|
-
entryIndexOf(entry, rowIdx),
|
|
2920
|
-
colIndex,
|
|
2921
|
-
),
|
|
2922
|
-
'mg-cell-editing': isEditingCell(
|
|
2923
|
-
entryIndexOf(entry, rowIdx),
|
|
2924
|
-
colIndex,
|
|
2925
|
-
),
|
|
2926
|
-
'mg-cell-invalid': !!cellErrorOf(entry, col),
|
|
2927
|
-
'mg-find-match': isFindMatch(entry, col),
|
|
2928
|
-
'mg-cell-flash': state.flashedCells?.has(
|
|
2929
|
-
grid.getRowId(rowDataOf(entry)) +
|
|
2930
|
-
'|' +
|
|
2931
|
-
String(col.field),
|
|
2932
|
-
),
|
|
2933
|
-
'mg-multiline': !!col.multiLine,
|
|
2934
|
-
'mg-pinned': !!col.pinned,
|
|
2935
|
-
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
2936
|
-
'mg-pin-right-edge': colIndex === firstRightPinIdx,
|
|
2937
|
-
},
|
|
2938
|
-
cellClassOf(entry, rowIdx, col),
|
|
2939
|
-
cellNoteOf(entry, col) && 'mg-cell-note',
|
|
2940
|
-
]"
|
|
2701
|
+
v-else-if="!cellDescOf(entry, rowIdx, col, colIndex)?.hidden"
|
|
2702
|
+
:key="colKeyOf(col)"
|
|
2703
|
+
:rowspan="cellDescOf(entry, rowIdx, col, colIndex)?.rowSpan"
|
|
2704
|
+
:colspan="cellDescOf(entry, rowIdx, col, colIndex)?.colSpan"
|
|
2705
|
+
:class="cellDescOf(entry, rowIdx, col, colIndex)?.classes"
|
|
2941
2706
|
role="gridcell"
|
|
2942
|
-
:title="
|
|
2943
|
-
|
|
2944
|
-
grid.getCellTooltip(rowDataOf(entry), col) ||
|
|
2945
|
-
cellNoteOf(entry, col) ||
|
|
2946
|
-
undefined
|
|
2947
|
-
"
|
|
2948
|
-
:style="[
|
|
2949
|
-
pinStyleOf(col),
|
|
2950
|
-
colIndex === 0 && leafDepthOf(entry)
|
|
2951
|
-
? { paddingLeft: `${leafDepthOf(entry) * 16 + 12}px` }
|
|
2952
|
-
: undefined,
|
|
2953
|
-
grid.getCellStyle(
|
|
2954
|
-
rowDataOf(entry),
|
|
2955
|
-
entryIndexOf(entry, rowIdx),
|
|
2956
|
-
col,
|
|
2957
|
-
) ?? undefined,
|
|
2958
|
-
]"
|
|
2707
|
+
:title="cellDescOf(entry, rowIdx, col, colIndex)?.title"
|
|
2708
|
+
:style="cellDescOf(entry, rowIdx, col, colIndex)?.styles"
|
|
2959
2709
|
:data-mg-row="entryIndexOf(entry, rowIdx)"
|
|
2960
2710
|
:data-mg-col="colIndex"
|
|
2961
2711
|
@mousedown="
|
|
@@ -2967,16 +2717,21 @@ watch(
|
|
|
2967
2717
|
)
|
|
2968
2718
|
"
|
|
2969
2719
|
@mouseenter="
|
|
2970
|
-
onCellMouseEnter(
|
|
2720
|
+
onCellMouseEnter(
|
|
2721
|
+
$event,
|
|
2722
|
+
entryIndexOf(entry, rowIdx),
|
|
2723
|
+
colIndex,
|
|
2724
|
+
)
|
|
2725
|
+
"
|
|
2726
|
+
@click="
|
|
2727
|
+
onCellClick($event, entryIndexOf(entry, rowIdx), colIndex)
|
|
2971
2728
|
"
|
|
2972
|
-
@click="onCellClick(entryIndexOf(entry, rowIdx), colIndex)"
|
|
2973
2729
|
@dblclick="
|
|
2974
|
-
|
|
2975
|
-
|
|
2730
|
+
onCellDblClick(
|
|
2731
|
+
$event,
|
|
2976
2732
|
entryIndexOf(entry, rowIdx),
|
|
2977
2733
|
colIndex,
|
|
2978
|
-
)
|
|
2979
|
-
grid.startEditing(entryIndexOf(entry, rowIdx), colIndex);
|
|
2734
|
+
)
|
|
2980
2735
|
"
|
|
2981
2736
|
@contextmenu="
|
|
2982
2737
|
onCellContextMenu($event, entryIndexOf(entry, rowIdx), col)
|
|
@@ -3056,7 +2811,7 @@ watch(
|
|
|
3056
2811
|
>
|
|
3057
2812
|
<!-- 커스텀 에디터 슬롯: #editor-{field}="ctx" -->
|
|
3058
2813
|
<slot
|
|
3059
|
-
:name="`editor-${col
|
|
2814
|
+
:name="`editor-${colKeyOf(col)}`"
|
|
3060
2815
|
v-bind="
|
|
3061
2816
|
editorContext(entryIndexOf(entry, rowIdx), colIndex)
|
|
3062
2817
|
"
|
|
@@ -3111,6 +2866,8 @@ watch(
|
|
|
3111
2866
|
v-else-if="col.cellEditor === 'radio'"
|
|
3112
2867
|
class="mg-radio-group"
|
|
3113
2868
|
role="radiogroup"
|
|
2869
|
+
tabindex="-1"
|
|
2870
|
+
@keydown="onEditorKeydown"
|
|
3114
2871
|
>
|
|
3115
2872
|
<label
|
|
3116
2873
|
v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
|
|
@@ -3154,7 +2911,7 @@ watch(
|
|
|
3154
2911
|
:list="
|
|
3155
2912
|
editorInputType(col) === 'text' &&
|
|
3156
2913
|
editorOptionsOf(col, rowDataOf(entry)).length
|
|
3157
|
-
? `mg-dl-${col
|
|
2914
|
+
? `mg-dl-${colKeyOf(col)}`
|
|
3158
2915
|
: undefined
|
|
3159
2916
|
"
|
|
3160
2917
|
@input="onEditorInput($event, col)"
|
|
@@ -3168,7 +2925,7 @@ watch(
|
|
|
3168
2925
|
editorInputType(col) === 'text' &&
|
|
3169
2926
|
editorOptionsOf(col, rowDataOf(entry)).length
|
|
3170
2927
|
"
|
|
3171
|
-
:id="`mg-dl-${col
|
|
2928
|
+
:id="`mg-dl-${colKeyOf(col)}`"
|
|
3172
2929
|
>
|
|
3173
2930
|
<option
|
|
3174
2931
|
v-for="opt in editorOptionsOf(col, rowDataOf(entry))"
|
|
@@ -3184,7 +2941,7 @@ watch(
|
|
|
3184
2941
|
<!-- 커스텀 셀 슬롯: #cell-{field}="{ value, row, column }" -->
|
|
3185
2942
|
<slot
|
|
3186
2943
|
v-else
|
|
3187
|
-
:name="`cell-${col
|
|
2944
|
+
:name="`cell-${colKeyOf(col)}`"
|
|
3188
2945
|
:value="grid.getCellValue(rowDataOf(entry), col)"
|
|
3189
2946
|
:row="rowDataOf(entry)"
|
|
3190
2947
|
:column="col"
|
|
@@ -3277,7 +3034,15 @@ watch(
|
|
|
3277
3034
|
:key="rowKeyOf(entry, rowIdx) + '-detail'"
|
|
3278
3035
|
class="mg-detail-row"
|
|
3279
3036
|
>
|
|
3280
|
-
<td
|
|
3037
|
+
<td
|
|
3038
|
+
class="mg-detail-cell"
|
|
3039
|
+
:colspan="colSpan"
|
|
3040
|
+
:style="
|
|
3041
|
+
detailHeight != null
|
|
3042
|
+
? { height: `${detailHeight}px` }
|
|
3043
|
+
: undefined
|
|
3044
|
+
"
|
|
3045
|
+
>
|
|
3281
3046
|
<div class="mg-detail-content">
|
|
3282
3047
|
<slot
|
|
3283
3048
|
name="detail"
|
|
@@ -3317,7 +3082,7 @@ watch(
|
|
|
3317
3082
|
/>
|
|
3318
3083
|
<td
|
|
3319
3084
|
v-else
|
|
3320
|
-
:key="col
|
|
3085
|
+
:key="colKeyOf(col)"
|
|
3321
3086
|
:class="{
|
|
3322
3087
|
'mg-pinned': !!col.pinned,
|
|
3323
3088
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
@@ -3367,7 +3132,7 @@ watch(
|
|
|
3367
3132
|
/>
|
|
3368
3133
|
<td
|
|
3369
3134
|
v-else
|
|
3370
|
-
:key="col
|
|
3135
|
+
:key="colKeyOf(col)"
|
|
3371
3136
|
:class="{
|
|
3372
3137
|
'mg-pinned': !!col.pinned,
|
|
3373
3138
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|