@moda-grid/vue2 0.3.0 → 1.0.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/README.md +2 -1
- package/dist/DataGrid.vue +1223 -45
- package/package.json +5 -4
package/dist/DataGrid.vue
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
nextTick,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onMounted,
|
|
7
|
+
ref,
|
|
8
|
+
watch,
|
|
9
|
+
watchEffect,
|
|
10
|
+
} from "vue";
|
|
3
11
|
import type { CSSProperties, PropType } from "vue";
|
|
4
12
|
import {
|
|
5
13
|
DEFAULT_COLUMN_WIDTH,
|
|
@@ -9,6 +17,12 @@ import {
|
|
|
9
17
|
formatAggregate,
|
|
10
18
|
} from "@moda-grid/core";
|
|
11
19
|
import type {
|
|
20
|
+
AggregateFn,
|
|
21
|
+
AppendScrollOptions,
|
|
22
|
+
PivotOptions,
|
|
23
|
+
PivotZone,
|
|
24
|
+
ContextMenuItem,
|
|
25
|
+
GridLocale,
|
|
12
26
|
CellEditorContext,
|
|
13
27
|
CellNavigation,
|
|
14
28
|
ColumnDef,
|
|
@@ -16,8 +30,12 @@ import type {
|
|
|
16
30
|
DisplayRow,
|
|
17
31
|
FilterOperator,
|
|
18
32
|
Grid,
|
|
33
|
+
GridEventHandlers,
|
|
34
|
+
GridEventMap,
|
|
35
|
+
GridOptions,
|
|
19
36
|
GroupNode,
|
|
20
37
|
LeafDisplayRow,
|
|
38
|
+
RowData,
|
|
21
39
|
SelectionMode,
|
|
22
40
|
ServerSideOptions,
|
|
23
41
|
TreeDataOptions,
|
|
@@ -25,8 +43,19 @@ import type {
|
|
|
25
43
|
import { useGrid, useGridState } from "./useGrid.js";
|
|
26
44
|
|
|
27
45
|
// Vue 2.7 script setup — runtime props 선언 사용
|
|
46
|
+
/** 편집기 input 씨드 값 — Date는 YYYY-MM-DD 로 변환 (input[type=date] 호환) */
|
|
47
|
+
function editorInputValue(v: unknown): string {
|
|
48
|
+
if (v instanceof Date) {
|
|
49
|
+
const pad = (n: number) => String(n).padStart(2, "0");
|
|
50
|
+
return `${v.getFullYear()}-${pad(v.getMonth() + 1)}-${pad(v.getDate())}`;
|
|
51
|
+
}
|
|
52
|
+
return String(v ?? "");
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
const props = defineProps({
|
|
29
56
|
columns: { type: Array as PropType<ColumnDef[]>, required: true },
|
|
57
|
+
/** 모든 컬럼에 적용되는 공통 기본값 — 컬럼 명시 속성이 우선 (defaultColDef 대응) */
|
|
58
|
+
defaultColDef: { type: Object as PropType<Partial<ColumnDef>>, default: undefined },
|
|
30
59
|
/** 행 데이터. `grid`를 직접 넘기는 제어 모드에서는 생략 가능 */
|
|
31
60
|
data: { type: Array as PropType<Record<string, unknown>[]>, default: undefined },
|
|
32
61
|
/** 외부에서 생성/관리하는 GridCore. 생략하면 내부 인스턴스 생성 */
|
|
@@ -44,12 +73,27 @@ const props = defineProps({
|
|
|
44
73
|
resizable: { type: Boolean, default: true },
|
|
45
74
|
/** 헤더 드래그로 컬럼 순서 변경 허용 */
|
|
46
75
|
reorderable: { type: Boolean, default: true },
|
|
76
|
+
rowResizable: { type: Boolean, default: false },
|
|
47
77
|
/** 셀 선택 모드: 방향키 이동 + Shift 범위 확장 */
|
|
48
78
|
selectionMode: { type: String as PropType<SelectionMode>, default: undefined },
|
|
49
79
|
/** 서버 사이드 데이터 소스 (내부 GridCore 생성 모드에서만 적용) */
|
|
50
80
|
serverSide: { type: Object as PropType<ServerSideOptions>, default: undefined },
|
|
81
|
+
/** Append Scroll 데이터 소스 — 스크롤 하단에서 자동으로 다음 페이지 로드 (내부 GridCore 생성 모드에서만 적용) */
|
|
82
|
+
appendScroll: { type: Object as PropType<AppendScrollOptions>, default: undefined },
|
|
51
83
|
/** 계층형 데이터: flat parentId 또는 nested children (내부 GridCore 생성 모드에서만 적용) */
|
|
52
84
|
treeData: { type: Object as PropType<TreeDataOptions>, default: undefined },
|
|
85
|
+
/** 피벗 모드 (내부 GridCore 생성 모드에서만 적용) */
|
|
86
|
+
pivot: { type: Object as PropType<PivotOptions>, default: undefined },
|
|
87
|
+
/** 그룹 소계 행 표시 */
|
|
88
|
+
groupSubtotals: { type: Boolean, default: false },
|
|
89
|
+
/** 내장 UI 문자열 로케일 */
|
|
90
|
+
locale: { type: Object as PropType<Partial<GridLocale>>, default: undefined },
|
|
91
|
+
/** 셀 우클릭 컨텍스트 메뉴 항목 (배열 또는 grid를 받는 함수) */
|
|
92
|
+
contextMenu: { type: [Array, Function] as PropType<GridOptions<RowData>["contextMenu"]>, default: undefined },
|
|
93
|
+
/** 헤더 우클릭 컨텍스트 메뉴 항목 */
|
|
94
|
+
headerContextMenu: { type: [Array, Function] as PropType<GridOptions<RowData>["headerContextMenu"]>, default: undefined },
|
|
95
|
+
/** 맨 왼쪽에 행 번호 컬럼 표시 */
|
|
96
|
+
rowNumbers: { type: Boolean, default: false },
|
|
53
97
|
/** 우상단 컬럼 관리 도구(체크박스 팝오버 + 전체 선택/해제) 표시 */
|
|
54
98
|
columnController: { type: Boolean, default: false },
|
|
55
99
|
/** 우상단 필터 행 표시/숨김 토글 버튼 표시 — filterable 컬럼이 있을 때만 렌더 */
|
|
@@ -60,6 +104,42 @@ const props = defineProps({
|
|
|
60
104
|
rowStatus: { type: Boolean, default: false },
|
|
61
105
|
/** 선택 영역 집계 상태바 표시 */
|
|
62
106
|
statusBar: { type: Boolean, default: true },
|
|
107
|
+
/** 그리드 상단에 그룹 패널 표시 — 그룹된 컬럼 칩 + 클릭으로 해제 */
|
|
108
|
+
groupPanel: { type: Boolean, default: false },
|
|
109
|
+
/** multiLine 셀 내용만큼 행 높이 자동 확장 — 가상 스크롤에서는 무시 */
|
|
110
|
+
autoRowHeight: { type: Boolean, default: false },
|
|
111
|
+
/** 채우기 시 숫자/날짜 소스를 등차·날짜 수열로 채움 — 엑셀 자동 채우기 */
|
|
112
|
+
fillSeries: { type: Boolean, default: false },
|
|
113
|
+
/** API/붙여넣기 등으로 바뀐 셀을 잠깐 강조 — 변경 플래시 */
|
|
114
|
+
cellFlash: { type: Boolean, default: false },
|
|
115
|
+
/** 복사 시 표시 문자열(formatter/format 적용) 사용 */
|
|
116
|
+
copyFormatted: { type: Boolean, default: false },
|
|
117
|
+
singleClickEdit: { type: Boolean, default: false },
|
|
118
|
+
/** 그리드 상단에 찾기 바 표시 — Enter 다음 매치 / Shift+Enter 이전 매치 */
|
|
119
|
+
findBox: { type: Boolean, default: false },
|
|
120
|
+
/** filterable 컬럼 헤더에 값 목록 필터 드롭다운 버튼 표시 — 엑셀 autofilter */
|
|
121
|
+
headerFilters: { type: Boolean, default: false },
|
|
122
|
+
/** 피벗 필드 패널 표시 — 필드 칩을 행/열/값 존으로 드래그해 피벗 구성 */
|
|
123
|
+
pivotPanel: { type: Boolean, default: false },
|
|
124
|
+
/** 헤더 영역 전체 높이(px) — 헤더 행 수로 균등 분할 */
|
|
125
|
+
headerHeight: { type: Number, default: undefined },
|
|
126
|
+
/** 파이프라인에서 숨길 행 id 목록 — 정렬/필터/집계에서 제외, 원본 데이터는 유지 */
|
|
127
|
+
hiddenRowIds: { type: Array as PropType<readonly string[]>, default: undefined },
|
|
128
|
+
/** zebra 줄무늬 행 배경 — 짝수 표시 행에 --grid-stripe-bg */
|
|
129
|
+
striped: { type: Boolean, default: false },
|
|
130
|
+
/** 편집 진입 직전 훅 — false 반환 시 편집 취소 (타사 그리드 OnBeforeEdit 대응) */
|
|
131
|
+
beforeEdit: { type: Function as PropType<GridOptions<RowData>["beforeEdit"]>, default: undefined },
|
|
132
|
+
isRowSelectable: { type: Function as PropType<GridOptions<RowData>["isRowSelectable"]>, default: undefined },
|
|
133
|
+
externalFilter: { type: Function as PropType<GridOptions<RowData>["externalFilter"]>, default: undefined },
|
|
134
|
+
postSort: { type: Function as PropType<GridOptions<RowData>["postSort"]>, default: undefined },
|
|
135
|
+
beforePaste: { type: Function as PropType<GridOptions<RowData>["beforePaste"]>, default: undefined },
|
|
136
|
+
beforeCopy: { type: Function as PropType<GridOptions<RowData>["beforeCopy"]>, default: undefined },
|
|
137
|
+
/** 그리드 자체 테마 — 지정 시 루트에 grid-theme-* 클래스 적용 */
|
|
138
|
+
theme: { type: String as PropType<"light" | "dark">, default: undefined },
|
|
139
|
+
/** 선언형 이벤트 핸들러 — 마운트 시 구독, 언마운트 시 해제 (grid.on과 동일) */
|
|
140
|
+
events: { type: Object as PropType<GridEventHandlers>, default: undefined },
|
|
141
|
+
/** GridCore 인스턴스가 준비되면 한 번 호출 — props 모드에서도 grid API 접근 가능 */
|
|
142
|
+
onReady: { type: Function as PropType<(grid: Grid) => void>, default: undefined },
|
|
63
143
|
});
|
|
64
144
|
|
|
65
145
|
// 내부 GridCore (grid prop이 없을 때만 생성)
|
|
@@ -67,10 +147,31 @@ const internal = props.grid
|
|
|
67
147
|
? null
|
|
68
148
|
: useGrid({
|
|
69
149
|
columns: props.columns,
|
|
150
|
+
defaultColDef: props.defaultColDef,
|
|
70
151
|
data: props.data ?? [],
|
|
71
152
|
getRowId: props.getRowId,
|
|
72
153
|
serverSide: props.serverSide,
|
|
154
|
+
appendScroll: props.appendScroll,
|
|
73
155
|
treeData: props.treeData,
|
|
156
|
+
pivot: props.pivot,
|
|
157
|
+
groupSubtotals: props.groupSubtotals,
|
|
158
|
+
locale: props.locale,
|
|
159
|
+
contextMenu: props.contextMenu,
|
|
160
|
+
headerContextMenu: props.headerContextMenu,
|
|
161
|
+
autoRowHeight: props.autoRowHeight,
|
|
162
|
+
fillSeries: props.fillSeries,
|
|
163
|
+
cellFlash: props.cellFlash,
|
|
164
|
+
copyFormatted: props.copyFormatted,
|
|
165
|
+
singleClickEdit: props.singleClickEdit,
|
|
166
|
+
headerHeight: props.headerHeight,
|
|
167
|
+
hiddenRowIds: props.hiddenRowIds ? [...props.hiddenRowIds] : undefined,
|
|
168
|
+
striped: props.striped,
|
|
169
|
+
beforeEdit: props.beforeEdit,
|
|
170
|
+
isRowSelectable: props.isRowSelectable,
|
|
171
|
+
externalFilter: props.externalFilter,
|
|
172
|
+
postSort: props.postSort,
|
|
173
|
+
beforePaste: props.beforePaste,
|
|
174
|
+
beforeCopy: props.beforeCopy,
|
|
74
175
|
virtualScroll:
|
|
75
176
|
props.height != null && props.rowHeight != null && props.rowHeight > 0
|
|
76
177
|
? {
|
|
@@ -82,6 +183,27 @@ const internal = props.grid
|
|
|
82
183
|
});
|
|
83
184
|
const grid = props.grid ?? internal!.grid;
|
|
84
185
|
const state = props.grid ? useGridState(grid).state : internal!.state;
|
|
186
|
+
|
|
187
|
+
// 선언형 이벤트 구독 — events 맵의 각 키를 grid.on에 연결
|
|
188
|
+
watch(
|
|
189
|
+
() => props.events,
|
|
190
|
+
(ev, _prev, onCleanup) => {
|
|
191
|
+
if (!ev) return;
|
|
192
|
+
const offs = Object.entries(ev).map(([name, handler]) =>
|
|
193
|
+
handler
|
|
194
|
+
? grid.on(
|
|
195
|
+
name as keyof GridEventMap,
|
|
196
|
+
handler as (e: GridEventMap[keyof GridEventMap]) => void,
|
|
197
|
+
)
|
|
198
|
+
: () => {},
|
|
199
|
+
);
|
|
200
|
+
onCleanup(() => offs.forEach((off) => off()));
|
|
201
|
+
},
|
|
202
|
+
{ immediate: true },
|
|
203
|
+
);
|
|
204
|
+
// 인스턴스 준비 콜백 + 템플릿 ref 노출 — props 모드에서도 grid 접근 가능
|
|
205
|
+
onMounted(() => props.onReady?.(grid));
|
|
206
|
+
defineExpose({ grid });
|
|
85
207
|
// 컬럼 관리 도구 팝오버 열림 상태
|
|
86
208
|
const colCtlOpen = ref(false);
|
|
87
209
|
|
|
@@ -106,6 +228,23 @@ watchEffect(() => {
|
|
|
106
228
|
watchEffect(() => {
|
|
107
229
|
if (props.selectionMode) grid.setSelectionMode(props.selectionMode);
|
|
108
230
|
});
|
|
231
|
+
watchEffect(() => {
|
|
232
|
+
grid.setHiddenRows([...(props.hiddenRowIds ?? [])]);
|
|
233
|
+
});
|
|
234
|
+
watchEffect(() => {
|
|
235
|
+
grid.setHeaderHeight(props.headerHeight ?? null);
|
|
236
|
+
});
|
|
237
|
+
watchEffect(() => {
|
|
238
|
+
grid.setStriped(props.striped ?? false);
|
|
239
|
+
});
|
|
240
|
+
watchEffect(() => {
|
|
241
|
+
grid.setBeforeEdit(props.beforeEdit ?? null);
|
|
242
|
+
grid.setIsRowSelectable(props.isRowSelectable ?? null);
|
|
243
|
+
grid.setExternalFilter(props.externalFilter ?? null);
|
|
244
|
+
grid.setPostSort(props.postSort ?? null);
|
|
245
|
+
grid.setBeforePaste(props.beforePaste ?? null);
|
|
246
|
+
grid.setBeforeCopy(props.beforeCopy ?? null);
|
|
247
|
+
});
|
|
109
248
|
|
|
110
249
|
// 가상 스크롤: 코어가 보정한 scrollTop을 DOM에 동기화 (키보드 scrollIntoView)
|
|
111
250
|
const scrollEl = ref<HTMLElement | null>(null);
|
|
@@ -115,6 +254,269 @@ watchEffect(() => {
|
|
|
115
254
|
if (v && el && el.scrollTop !== v.scrollTop) el.scrollTop = v.scrollTop;
|
|
116
255
|
});
|
|
117
256
|
|
|
257
|
+
// 비가상 스크롤: scrollToRow 요청을 scrollIntoView로 처리 (seq로 호출 구분)
|
|
258
|
+
const hostEl = ref<HTMLElement | null>(null);
|
|
259
|
+
watch(
|
|
260
|
+
() => state.value.scrollRequest?.seq,
|
|
261
|
+
async () => {
|
|
262
|
+
const req = state.value.scrollRequest;
|
|
263
|
+
if (!req) return;
|
|
264
|
+
await nextTick();
|
|
265
|
+
(scrollEl.value ?? hostEl.value)
|
|
266
|
+
?.querySelector<HTMLElement>(
|
|
267
|
+
`td[data-mg-row="${req.rowIndex}"]` +
|
|
268
|
+
(req.columnIndex != null
|
|
269
|
+
? `[data-mg-col="${req.columnIndex}"]`
|
|
270
|
+
: ""),
|
|
271
|
+
)
|
|
272
|
+
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
// autoRowHeight prop → core 동기화 (제어 모드 포함)
|
|
277
|
+
watchEffect(() => grid.setAutoRowHeight(!!props.autoRowHeight));
|
|
278
|
+
// fillSeries prop → core 동기화 (제어 모드 포함)
|
|
279
|
+
watchEffect(() => grid.setFillSeries(!!props.fillSeries));
|
|
280
|
+
// cellFlash prop → core 동기화
|
|
281
|
+
watchEffect(() => grid.setCellFlash(!!props.cellFlash));
|
|
282
|
+
// copyFormatted prop → core 동기화
|
|
283
|
+
watchEffect(() => grid.setCopyFormatted(!!props.copyFormatted));
|
|
284
|
+
watchEffect(() => grid.setSingleClickEdit(!!props.singleClickEdit));
|
|
285
|
+
|
|
286
|
+
// 찾기 바 — findNext로 다음/이전 매치 순환 (Enter / Shift+Enter)
|
|
287
|
+
const findInputEl = ref<HTMLInputElement | null>(null);
|
|
288
|
+
const findCount = ref("");
|
|
289
|
+
// 찾기 옵션 — 대소문자 구분 / 셀 전체 일치 (타사 그리드 찾기 옵션 대응)
|
|
290
|
+
const findCaseSensitive = ref(false);
|
|
291
|
+
const findWholeCell = ref(false);
|
|
292
|
+
function currentFindOpts() {
|
|
293
|
+
return {
|
|
294
|
+
caseSensitive: findCaseSensitive.value,
|
|
295
|
+
wholeCell: findWholeCell.value,
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function onFindOptChange() {
|
|
299
|
+
const q = findInputEl.value?.value ?? "";
|
|
300
|
+
grid.setFindQuery(q || null, currentFindOpts());
|
|
301
|
+
findCount.value = q ? `${grid.findCells(q, currentFindOpts()).length}건` : "";
|
|
302
|
+
}
|
|
303
|
+
// Vue2 템플릿은 TS 캐스트 미지원 — 체크박스 change는 스크립트 메서드로 처리
|
|
304
|
+
function onFindCaseChange(e: Event) {
|
|
305
|
+
findCaseSensitive.value = (e.target as HTMLInputElement).checked;
|
|
306
|
+
onFindOptChange();
|
|
307
|
+
}
|
|
308
|
+
function onFindWholeChange(e: Event) {
|
|
309
|
+
findWholeCell.value = (e.target as HTMLInputElement).checked;
|
|
310
|
+
onFindOptChange();
|
|
311
|
+
}
|
|
312
|
+
function goFind(backward: boolean) {
|
|
313
|
+
const q = findInputEl.value?.value ?? "";
|
|
314
|
+
grid.setFindQuery(q || null, currentFindOpts()); // 매치 셀 하이라이트
|
|
315
|
+
const total = grid.findCells(q, currentFindOpts()).length;
|
|
316
|
+
findCount.value = q ? `${total}건` : "";
|
|
317
|
+
if (!q || !total) return;
|
|
318
|
+
const m = grid.findNext(q, { ...currentFindOpts(), backward });
|
|
319
|
+
if (m) {
|
|
320
|
+
hostEl.value
|
|
321
|
+
?.querySelector<HTMLElement>(
|
|
322
|
+
`td[data-mg-row="${m.rowIndex}"][data-mg-col="${m.columnIndex}"]`,
|
|
323
|
+
)
|
|
324
|
+
?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function onFindKeydown(e: KeyboardEvent) {
|
|
328
|
+
if (e.isComposing) return; // IME 조합 확정 Enter가 매치 이동으로 오작동하지 않도록
|
|
329
|
+
if (e.key === "Enter") {
|
|
330
|
+
e.preventDefault();
|
|
331
|
+
goFind(e.shiftKey);
|
|
332
|
+
}
|
|
333
|
+
e.stopPropagation(); // 그리드 키 내비와 충돌 방지
|
|
334
|
+
}
|
|
335
|
+
function onFindInput(e: Event) {
|
|
336
|
+
const q = (e.target as HTMLInputElement).value;
|
|
337
|
+
grid.setFindQuery(q || null, currentFindOpts()); // 입력 즉시 매치 하이라이트
|
|
338
|
+
findCount.value = q ? `${grid.findCells(q, currentFindOpts()).length}건` : "";
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 헤더 필터 드롭다운 — 엑셀 autofilter식 값 체크리스트 (한 번에 하나)
|
|
342
|
+
const filterDrop = ref<{ field: string; x: number; y: number } | null>(null);
|
|
343
|
+
function toggleFilterDrop(col: ColumnDef, e: MouseEvent) {
|
|
344
|
+
e.stopPropagation();
|
|
345
|
+
if (filterDrop.value?.field === col.field) {
|
|
346
|
+
filterDrop.value = null;
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const b = (e.currentTarget as HTMLElement).getBoundingClientRect();
|
|
350
|
+
const h = hostEl.value?.getBoundingClientRect();
|
|
351
|
+
filterDrop.value = {
|
|
352
|
+
field: col.field,
|
|
353
|
+
x: b.right - (h?.left ?? 0),
|
|
354
|
+
y: b.bottom - (h?.top ?? 0) + 4,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const filterDropCol = computed(() =>
|
|
358
|
+
filterDrop.value
|
|
359
|
+
? (state.value.columns.find((c) => c.field === filterDrop.value!.field) ??
|
|
360
|
+
null)
|
|
361
|
+
: null,
|
|
362
|
+
);
|
|
363
|
+
const filterDropAll = computed(() =>
|
|
364
|
+
filterDropCol.value
|
|
365
|
+
? grid.getUniqueValues(filterDropCol.value.field)
|
|
366
|
+
: [],
|
|
367
|
+
);
|
|
368
|
+
const filterDropActive = computed(() =>
|
|
369
|
+
filterDropCol.value
|
|
370
|
+
? state.value.filters[filterDropCol.value.field]?.values
|
|
371
|
+
: undefined,
|
|
372
|
+
);
|
|
373
|
+
function filterDropChecked(v: string) {
|
|
374
|
+
const active = filterDropActive.value;
|
|
375
|
+
return active ? active.includes(v) : true;
|
|
376
|
+
}
|
|
377
|
+
function toggleFilterValue(v: string) {
|
|
378
|
+
const col = filterDropCol.value;
|
|
379
|
+
if (!col) return;
|
|
380
|
+
const all = filterDropAll.value;
|
|
381
|
+
const next = new Set(filterDropActive.value ?? all);
|
|
382
|
+
if (next.has(v)) next.delete(v);
|
|
383
|
+
else next.add(v);
|
|
384
|
+
if (next.size >= all.length) grid.setFilter(col.field, null);
|
|
385
|
+
else
|
|
386
|
+
grid.setFilter(col.field, {
|
|
387
|
+
operator: "set",
|
|
388
|
+
value: "",
|
|
389
|
+
values: [...next],
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function onFilterDropKeydown(e: KeyboardEvent) {
|
|
393
|
+
e.stopPropagation();
|
|
394
|
+
if (e.key === "Escape") filterDrop.value = null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ── 피벗 필드 패널 — 필드 칩을 행/열/값 존으로 드래그해 피벗 구성 ──
|
|
398
|
+
const PIVOT_DATA_TYPE = "application/x-mg-pivot";
|
|
399
|
+
const PIVOT_AGGS: AggregateFn[] = ["sum", "avg", "min", "max", "count"];
|
|
400
|
+
const pivotDropZone = ref<string | null>(null);
|
|
401
|
+
function pivotHeaderOf(field: string) {
|
|
402
|
+
return (
|
|
403
|
+
state.value.sourceColumns.find((c) => c.field === field)?.header ?? field
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
function onPivotAggChange(field: string, e: Event) {
|
|
407
|
+
const v = (e.target as HTMLSelectElement).value;
|
|
408
|
+
grid.setPivotValueAgg(field, v as AggregateFn);
|
|
409
|
+
}
|
|
410
|
+
function pivotChipsOf(zone: string) {
|
|
411
|
+
const p = state.value.pivot;
|
|
412
|
+
if (zone === "fields")
|
|
413
|
+
return state.value.sourceColumns.map((c) => ({
|
|
414
|
+
field: c.field,
|
|
415
|
+
label: c.header ?? c.field,
|
|
416
|
+
agg: undefined as AggregateFn | undefined,
|
|
417
|
+
}));
|
|
418
|
+
if (zone === "values")
|
|
419
|
+
return (p?.values ?? []).map((v) => ({
|
|
420
|
+
field: v.field,
|
|
421
|
+
label: pivotHeaderOf(v.field),
|
|
422
|
+
agg: v.agg,
|
|
423
|
+
}));
|
|
424
|
+
const list = zone === "rows" ? (p?.rows ?? []) : (p?.columns ?? []);
|
|
425
|
+
return list.map((f) => ({
|
|
426
|
+
field: f,
|
|
427
|
+
label: pivotHeaderOf(f),
|
|
428
|
+
agg: undefined as AggregateFn | undefined,
|
|
429
|
+
}));
|
|
430
|
+
}
|
|
431
|
+
const pivotPlaced = computed(
|
|
432
|
+
() =>
|
|
433
|
+
new Set<string>([
|
|
434
|
+
...(state.value.pivot?.rows ?? []),
|
|
435
|
+
...(state.value.pivot?.columns ?? []),
|
|
436
|
+
...(state.value.pivot?.values.map((v) => v.field) ?? []),
|
|
437
|
+
]),
|
|
438
|
+
);
|
|
439
|
+
function pivotZoneLabel(zone: string) {
|
|
440
|
+
return zone === "fields"
|
|
441
|
+
? state.value.locale.pivotFieldsLabel
|
|
442
|
+
: zone === "rows"
|
|
443
|
+
? state.value.locale.pivotRowsLabel
|
|
444
|
+
: zone === "columns"
|
|
445
|
+
? state.value.locale.pivotColumnsLabel
|
|
446
|
+
: state.value.locale.pivotValuesLabel;
|
|
447
|
+
}
|
|
448
|
+
function pivotDragField(e: DragEvent): string {
|
|
449
|
+
return (
|
|
450
|
+
e.dataTransfer?.getData(PIVOT_DATA_TYPE) ||
|
|
451
|
+
e.dataTransfer?.getData("application/x-mg-column") ||
|
|
452
|
+
""
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
function pivotDragAccepts(e: DragEvent): boolean {
|
|
456
|
+
const t = e.dataTransfer?.types;
|
|
457
|
+
return !!t && (t.includes(PIVOT_DATA_TYPE) || t.includes("application/x-mg-column"));
|
|
458
|
+
}
|
|
459
|
+
function onPivotZoneDragOver(zone: string, e: DragEvent) {
|
|
460
|
+
if (!pivotDragAccepts(e)) return;
|
|
461
|
+
e.preventDefault();
|
|
462
|
+
e.dataTransfer!.dropEffect = "move";
|
|
463
|
+
pivotDropZone.value = zone;
|
|
464
|
+
}
|
|
465
|
+
function onPivotZoneDrop(zone: string, e: DragEvent, index?: number) {
|
|
466
|
+
const f = pivotDragField(e);
|
|
467
|
+
pivotDropZone.value = null;
|
|
468
|
+
if (!f) return;
|
|
469
|
+
e.preventDefault();
|
|
470
|
+
e.stopPropagation();
|
|
471
|
+
if (zone === "fields") grid.removePivotField(f as string);
|
|
472
|
+
else grid.addPivotField(zone as PivotZone, f as string, { index });
|
|
473
|
+
}
|
|
474
|
+
function onPivotChipDragStart(field: string, e: DragEvent) {
|
|
475
|
+
e.dataTransfer!.effectAllowed = "move";
|
|
476
|
+
e.dataTransfer!.setData(PIVOT_DATA_TYPE, field);
|
|
477
|
+
}
|
|
478
|
+
function onPivotChipDragOver(e: DragEvent) {
|
|
479
|
+
if (!pivotDragAccepts(e)) return;
|
|
480
|
+
e.preventDefault();
|
|
481
|
+
e.stopPropagation();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// 행 높이 — 가상 스크롤은 고정, 아니면 autoRowHeight 추정치 적용
|
|
485
|
+
function rowStyleOf(entry: AnyRow) {
|
|
486
|
+
if (virtual.value && props.rowHeight)
|
|
487
|
+
return { height: `${props.rowHeight}px` };
|
|
488
|
+
const h = grid.getRowHeight(rowDataOf(entry));
|
|
489
|
+
return h ? { height: `${h}px` } : undefined;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// 그룹 패널 칩 — 클릭 시 해당 컬럼 그룹 해제
|
|
493
|
+
function ungroupField(field: string) {
|
|
494
|
+
grid.setGroupBy(
|
|
495
|
+
state.value.groupBy.filter((f) => f !== field) as (keyof RowT & string)[],
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// 헤더 컬럼을 그룹 패널에 드롭 → 그룹에 추가 (타사 그리드 그룹 패널 드래그)
|
|
500
|
+
const groupDropOver = ref(false);
|
|
501
|
+
function onGroupPanelDragOver(event: DragEvent) {
|
|
502
|
+
if (event.dataTransfer?.types.includes("application/x-mg-column")) {
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
event.dataTransfer.dropEffect = "copy";
|
|
505
|
+
groupDropOver.value = true;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function onGroupPanelDrop(event: DragEvent) {
|
|
509
|
+
event.preventDefault();
|
|
510
|
+
groupDropOver.value = false;
|
|
511
|
+
const field = event.dataTransfer?.getData("application/x-mg-column");
|
|
512
|
+
if (field && !state.value.groupBy.includes(field)) {
|
|
513
|
+
grid.setGroupBy([
|
|
514
|
+
...state.value.groupBy,
|
|
515
|
+
field,
|
|
516
|
+
] as (keyof RowT & string)[]);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
118
520
|
const virtual = computed(() => state.value.virtual);
|
|
119
521
|
// 그룹화 시: displayRows(그룹 헤더 포함)를 virtual 인덱스로 슬라이스
|
|
120
522
|
type RowT = Record<string, unknown>;
|
|
@@ -131,7 +533,8 @@ const colSpan = computed(
|
|
|
131
533
|
() =>
|
|
132
534
|
(state.value.visibleColumns.length || 1) +
|
|
133
535
|
(props.rowCheckboxes ? 1 : 0) +
|
|
134
|
-
(props.rowStatus ? 1 : 0)
|
|
536
|
+
(props.rowStatus ? 1 : 0) +
|
|
537
|
+
(props.rowNumbers ? 1 : 0),
|
|
135
538
|
);
|
|
136
539
|
const hasFilterable = computed(() =>
|
|
137
540
|
state.value.visibleColumns.some((c) => c.filterable),
|
|
@@ -139,6 +542,17 @@ const hasFilterable = computed(() =>
|
|
|
139
542
|
const hasFilterRow = computed(
|
|
140
543
|
() => hasFilterable.value && state.value.filterRowVisible,
|
|
141
544
|
);
|
|
545
|
+
// 고정 테이블 레이아웃용 최소 폭 — 전체 컬럼 너비 합(선행 셀 포함)
|
|
546
|
+
const tableMinWidth = computed(
|
|
547
|
+
() =>
|
|
548
|
+
(props.rowStatus ? 40 : 0) +
|
|
549
|
+
(props.rowCheckboxes ? 36 : 0) +
|
|
550
|
+
(props.rowNumbers ? 40 : 0) +
|
|
551
|
+
state.value.visibleColumns.reduce(
|
|
552
|
+
(s, c) => s + (c.width ?? DEFAULT_COLUMN_WIDTH),
|
|
553
|
+
0,
|
|
554
|
+
),
|
|
555
|
+
);
|
|
142
556
|
const showOverlay = computed(
|
|
143
557
|
() => props.columnController || (props.filterToggle && hasFilterable.value),
|
|
144
558
|
);
|
|
@@ -164,6 +578,7 @@ const firstRightPinIdx = computed(() =>
|
|
|
164
578
|
const hasPinned = computed(
|
|
165
579
|
() => lastLeftPinIdx.value >= 0 || firstRightPinIdx.value >= 0,
|
|
166
580
|
);
|
|
581
|
+
const hasAppend = computed(() => !!state.value.appendScroll);
|
|
167
582
|
|
|
168
583
|
function pinStyleOf(col: ColumnDef<RowT>): CSSProperties | undefined {
|
|
169
584
|
if (!col.pinned) return undefined;
|
|
@@ -206,7 +621,83 @@ function onColumnToggle(field: string, event: Event) {
|
|
|
206
621
|
}
|
|
207
622
|
|
|
208
623
|
function onScroll(event: Event) {
|
|
209
|
-
|
|
624
|
+
const el = event.target as HTMLElement;
|
|
625
|
+
grid.handleScroll(el.scrollTop);
|
|
626
|
+
grid.maybeLoadMore(el.scrollTop, el.clientHeight, el.scrollHeight);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function onLoadMore() {
|
|
630
|
+
void grid.loadMore();
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// ── 컨텍스트 메뉴 + 셀 타입 ──
|
|
634
|
+
function onHeaderContextMenu(e: MouseEvent, col: ColumnDef): void {
|
|
635
|
+
if (grid.openHeaderContextMenu(e.clientX, e.clientY, col.field)) {
|
|
636
|
+
e.preventDefault();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function onCellContextMenu(
|
|
641
|
+
e: MouseEvent,
|
|
642
|
+
rowIndex: number,
|
|
643
|
+
col: ColumnDef,
|
|
644
|
+
): void {
|
|
645
|
+
if (grid.openContextMenu(e.clientX, e.clientY, rowIndex, col.field)) {
|
|
646
|
+
e.preventDefault();
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function cellPosFromPoint(
|
|
651
|
+
x: number,
|
|
652
|
+
y: number,
|
|
653
|
+
): { row: number; col: number } | null {
|
|
654
|
+
const el = document.elementFromPoint(x, y)?.closest("td[data-mg-row]");
|
|
655
|
+
if (!el) return null;
|
|
656
|
+
const row = Number(el.getAttribute("data-mg-row"));
|
|
657
|
+
const col = Number(el.getAttribute("data-mg-col"));
|
|
658
|
+
return Number.isNaN(row) || Number.isNaN(col) ? null : { row, col };
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
let fillSource: { startRow: number; endRow: number; startCol: number; endCol: number } | null = null;
|
|
662
|
+
|
|
663
|
+
function onFillMouseDown(e: MouseEvent): void {
|
|
664
|
+
e.preventDefault();
|
|
665
|
+
e.stopPropagation();
|
|
666
|
+
const src = state.value.selectedRange;
|
|
667
|
+
if (!src) return;
|
|
668
|
+
fillSource = { ...src };
|
|
669
|
+
const onUp = (ev: MouseEvent) => {
|
|
670
|
+
window.removeEventListener("mouseup", onUp);
|
|
671
|
+
const source = fillSource;
|
|
672
|
+
fillSource = null;
|
|
673
|
+
const pos = cellPosFromPoint(ev.clientX, ev.clientY);
|
|
674
|
+
if (!source || !pos) return;
|
|
675
|
+
const target = {
|
|
676
|
+
startRow: Math.min(source.startRow, pos.row),
|
|
677
|
+
endRow: Math.max(source.endRow, pos.row),
|
|
678
|
+
startCol: Math.min(source.startCol, pos.col),
|
|
679
|
+
endCol: Math.max(source.endCol, pos.col),
|
|
680
|
+
};
|
|
681
|
+
grid.fillRange(source, target);
|
|
682
|
+
grid.setCellRange(target);
|
|
683
|
+
};
|
|
684
|
+
window.addEventListener("mouseup", onUp);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function cellLinkHref(row: RowData, col: ColumnDef): string {
|
|
688
|
+
const v = grid.getCellValue(row, col);
|
|
689
|
+
return col.cellOptions?.href?.(row) ?? (v == null ? "" : String(v));
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function progressValueOf(row: RowData, col: ColumnDef): number {
|
|
693
|
+
const v = grid.getCellValue(row, col);
|
|
694
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
695
|
+
return Number.isFinite(n) ? n : 0;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
function progressPctOf(row: RowData, col: ColumnDef): number {
|
|
699
|
+
const max = col.cellOptions?.max ?? 100;
|
|
700
|
+
return Math.min(100, Math.max(0, (progressValueOf(row, col) / max) * 100));
|
|
210
701
|
}
|
|
211
702
|
|
|
212
703
|
// ── 연산자 기반 필터 ──
|
|
@@ -261,7 +752,7 @@ function setValuesOf(col: ColumnDef<Record<string, unknown>>): string[] {
|
|
|
261
752
|
function setFilterLabel(col: ColumnDef<Record<string, unknown>>) {
|
|
262
753
|
const f = state.value.filters[col.field];
|
|
263
754
|
const vals = f && f.values;
|
|
264
|
-
return vals ?
|
|
755
|
+
return vals ? state.value.locale.setFilterCount(vals.length) : "전체";
|
|
265
756
|
}
|
|
266
757
|
|
|
267
758
|
function setCheckedOf(col: ColumnDef<Record<string, unknown>>, v: string) {
|
|
@@ -304,6 +795,14 @@ type HeaderCell =
|
|
|
304
795
|
rowSpan?: number;
|
|
305
796
|
};
|
|
306
797
|
|
|
798
|
+
// headerHeight는 헤더 행 수로 균등 분할 (멀티레벨 헤더 대응)
|
|
799
|
+
const headerTrStyle = computed(() => {
|
|
800
|
+
const h = state.value.headerHeight;
|
|
801
|
+
if (h == null) return undefined;
|
|
802
|
+
const rows = state.value.headerGroups ? 2 : 1;
|
|
803
|
+
return { height: `${h / rows}px` };
|
|
804
|
+
});
|
|
805
|
+
|
|
307
806
|
const headerRows = computed<HeaderCell[][]>(() => {
|
|
308
807
|
const spans = state.value.headerGroups;
|
|
309
808
|
const cols = state.value.visibleColumns;
|
|
@@ -383,6 +882,27 @@ function onResizeStart(col: ColumnDef, event: MouseEvent) {
|
|
|
383
882
|
document.addEventListener("mouseup", onUp);
|
|
384
883
|
}
|
|
385
884
|
|
|
885
|
+
// ── 행 높이 리사이즈: 행 번호 셀 하단 핸들 드래그 → setRowHeight ──
|
|
886
|
+
function onRowResizeStart(rowId: string, event: MouseEvent) {
|
|
887
|
+
event.preventDefault();
|
|
888
|
+
event.stopPropagation();
|
|
889
|
+
const tr = (event.currentTarget as HTMLElement).closest("tr");
|
|
890
|
+
const startHeight = tr?.getBoundingClientRect().height ?? 0;
|
|
891
|
+
const startY = event.clientY;
|
|
892
|
+
const onMove = (ev: MouseEvent) => {
|
|
893
|
+
grid.setRowHeight(
|
|
894
|
+
rowId,
|
|
895
|
+
Math.max(16, startHeight + (ev.clientY - startY)),
|
|
896
|
+
);
|
|
897
|
+
};
|
|
898
|
+
const onUp = () => {
|
|
899
|
+
document.removeEventListener("mousemove", onMove);
|
|
900
|
+
document.removeEventListener("mouseup", onUp);
|
|
901
|
+
};
|
|
902
|
+
document.addEventListener("mousemove", onMove);
|
|
903
|
+
document.addEventListener("mouseup", onUp);
|
|
904
|
+
}
|
|
905
|
+
|
|
386
906
|
// 키보드 리사이즈 (방향키 ±10px)
|
|
387
907
|
function onResizerKeydown(col: ColumnDef, event: KeyboardEvent) {
|
|
388
908
|
const delta = event.key === "ArrowLeft" ? -10 : event.key === "ArrowRight" ? 10 : 0;
|
|
@@ -402,6 +922,7 @@ function onDragStart(col: ColumnDef, event: DragEvent) {
|
|
|
402
922
|
if (event.dataTransfer) {
|
|
403
923
|
event.dataTransfer.effectAllowed = "move";
|
|
404
924
|
event.dataTransfer.setData("text/plain", col.field);
|
|
925
|
+
event.dataTransfer.setData("application/x-mg-column", col.field);
|
|
405
926
|
}
|
|
406
927
|
}
|
|
407
928
|
|
|
@@ -474,12 +995,29 @@ function cellErrorOf(entry: AnyRow, col: ColumnDef): string | null {
|
|
|
474
995
|
return grid.getCellError(row, col);
|
|
475
996
|
}
|
|
476
997
|
|
|
998
|
+
/** 셀 노트 텍스트 — 있으면 td에 mg-cell-note 클래스 + title로 표시 */
|
|
999
|
+
function cellNoteOf(entry: AnyRow, col: ColumnDef): string | null {
|
|
1000
|
+
const row = rowDataOf(entry);
|
|
1001
|
+
if (row == null) return null;
|
|
1002
|
+
return grid.getCellNote(row, col);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
477
1005
|
function cellClassOf(entry: AnyRow, rowIdx: number, col: ColumnDef) {
|
|
478
1006
|
const row = rowDataOf(entry);
|
|
479
1007
|
if (row == null) return "";
|
|
480
1008
|
return grid.getCellClass(row, entryIndexOf(entry, rowIdx), col);
|
|
481
1009
|
}
|
|
482
1010
|
|
|
1011
|
+
/** find 하이라이트 — findBox 검색어에 매치되는 셀인지 (그룹 헤더 등 null 행 제외) */
|
|
1012
|
+
function isFindMatch(entry: AnyRow, col: ColumnDef): boolean {
|
|
1013
|
+
const row = rowDataOf(entry);
|
|
1014
|
+
return (
|
|
1015
|
+
!!state.value.findQuery &&
|
|
1016
|
+
row != null &&
|
|
1017
|
+
grid.isFindMatch(row, String(col.field))
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
483
1021
|
function onRowDragStart(rowIndex: number, event: DragEvent) {
|
|
484
1022
|
if (!grid.beginRowDrag(rowIndex)) {
|
|
485
1023
|
event.preventDefault();
|
|
@@ -524,6 +1062,7 @@ const CELL_KEYS: Record<string, CellNavigation> = {
|
|
|
524
1062
|
};
|
|
525
1063
|
|
|
526
1064
|
function onGridKeydown(event: KeyboardEvent) {
|
|
1065
|
+
if (event.isComposing) return; // IME 조합 중 — 조합 확정 키가 그리드 키로 해석되지 않도록
|
|
527
1066
|
if ((event.target as HTMLElement).closest("input, textarea, select")) return;
|
|
528
1067
|
// 클립보드/이력: Ctrl+C 복사, Ctrl+Shift+C 헤더 포함 복사,
|
|
529
1068
|
// Ctrl+V 붙여넣기, Ctrl+Z 되돌리기, Ctrl+Y·Ctrl+Shift+Z 다시 실행
|
|
@@ -535,6 +1074,12 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
535
1074
|
event.preventDefault();
|
|
536
1075
|
void navigator.clipboard?.writeText(tsv);
|
|
537
1076
|
}
|
|
1077
|
+
} else if (key === "x") {
|
|
1078
|
+
const tsv = grid.cutSelectionTsv(); // 엑셀 Ctrl+X — 잘라내기
|
|
1079
|
+
if (tsv != null) {
|
|
1080
|
+
event.preventDefault();
|
|
1081
|
+
void navigator.clipboard?.writeText(tsv);
|
|
1082
|
+
}
|
|
538
1083
|
} else if (key === "v") {
|
|
539
1084
|
event.preventDefault();
|
|
540
1085
|
void navigator.clipboard?.readText().then((text) => grid.pasteTsv(text));
|
|
@@ -545,6 +1090,47 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
545
1090
|
} else if (key === "y") {
|
|
546
1091
|
event.preventDefault();
|
|
547
1092
|
grid.redo();
|
|
1093
|
+
} else if (key === "a") {
|
|
1094
|
+
// single-cell 모드의 selectAll은 전체 행 선택 — selectable일 때만
|
|
1095
|
+
if (
|
|
1096
|
+
state.value.selectionMode === "single-cell" &&
|
|
1097
|
+
props.selectable === false
|
|
1098
|
+
)
|
|
1099
|
+
return;
|
|
1100
|
+
event.preventDefault();
|
|
1101
|
+
grid.selectAll();
|
|
1102
|
+
} else if (key === "f") {
|
|
1103
|
+
if (!props.findBox) return; // findBox 없으면 브라우저 검색에 양보
|
|
1104
|
+
event.preventDefault();
|
|
1105
|
+
findInputEl.value?.focus();
|
|
1106
|
+
findInputEl.value?.select();
|
|
1107
|
+
} else if (key === "d") {
|
|
1108
|
+
event.preventDefault();
|
|
1109
|
+
grid.fillDown(); // 엑셀 Ctrl+D — 아래 채우기
|
|
1110
|
+
} else if (key === "r") {
|
|
1111
|
+
event.preventDefault();
|
|
1112
|
+
grid.fillRight(); // 엑셀 Ctrl+R — 오른쪽 채우기
|
|
1113
|
+
} else if (event.key === "Home") {
|
|
1114
|
+
event.preventDefault();
|
|
1115
|
+
grid.navigateCell("first", event.shiftKey); // Ctrl+Home — 첫 셀
|
|
1116
|
+
} else if (event.key === "End") {
|
|
1117
|
+
event.preventDefault();
|
|
1118
|
+
grid.navigateCell("last", event.shiftKey); // Ctrl+End — 마지막 셀
|
|
1119
|
+
} else if (event.key === "ArrowUp") {
|
|
1120
|
+
event.preventDefault();
|
|
1121
|
+
grid.navigateCell("top", event.shiftKey);
|
|
1122
|
+
} else if (event.key === "ArrowDown") {
|
|
1123
|
+
event.preventDefault();
|
|
1124
|
+
grid.navigateCell("bottom", event.shiftKey);
|
|
1125
|
+
} else if (event.key === "ArrowLeft") {
|
|
1126
|
+
event.preventDefault();
|
|
1127
|
+
grid.navigateCell("home", event.shiftKey);
|
|
1128
|
+
} else if (event.key === "ArrowRight") {
|
|
1129
|
+
event.preventDefault();
|
|
1130
|
+
grid.navigateCell("end", event.shiftKey);
|
|
1131
|
+
} else if (event.key === " ") {
|
|
1132
|
+
event.preventDefault();
|
|
1133
|
+
grid.selectEntireColumn(); // 엑셀 Ctrl+Space — 열 선택
|
|
548
1134
|
}
|
|
549
1135
|
return;
|
|
550
1136
|
}
|
|
@@ -553,7 +1139,31 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
553
1139
|
else grid.clearCellSelection();
|
|
554
1140
|
return;
|
|
555
1141
|
}
|
|
1142
|
+
if (event.key === "Delete" || event.key === "Backspace") {
|
|
1143
|
+
// 선택 영역(없으면 활성 셀) 내용 지우기 — 타사 그리드 Del키 대응
|
|
1144
|
+
event.preventDefault();
|
|
1145
|
+
grid.clearRange();
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
556
1148
|
const active = state.value.activeCell;
|
|
1149
|
+
if (event.key === " " && event.shiftKey) {
|
|
1150
|
+
// 엑셀 Shift+Space — 행 선택 (타이핑 경로보다 먼저 처리).
|
|
1151
|
+
// single-cell은 행 선택으로 대체되므로 selectable을 게이트한다
|
|
1152
|
+
if (
|
|
1153
|
+
state.value.selectionMode === "single-cell" &&
|
|
1154
|
+
props.selectable === false
|
|
1155
|
+
)
|
|
1156
|
+
return;
|
|
1157
|
+
event.preventDefault();
|
|
1158
|
+
grid.selectEntireRow();
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
if (event.key === "Tab" && active) {
|
|
1162
|
+
// 엑셀 Tab — 활성 셀 좌/우 이동
|
|
1163
|
+
event.preventDefault();
|
|
1164
|
+
grid.navigateCell(event.shiftKey ? "tabLeft" : "tabRight");
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
557
1167
|
if (event.key === "Enter" || event.key === "F2") {
|
|
558
1168
|
// 활성 셀에서 Enter → 편집 진입
|
|
559
1169
|
if (active) {
|
|
@@ -580,6 +1190,10 @@ function isGroupRow(entry: AnyRow) {
|
|
|
580
1190
|
return (entry as DisplayRow<RowT> | undefined)?.type === "group";
|
|
581
1191
|
}
|
|
582
1192
|
|
|
1193
|
+
function isSubtotalRow(entry: AnyRow) {
|
|
1194
|
+
return (entry as DisplayRow<RowT> | undefined)?.type === "subtotal";
|
|
1195
|
+
}
|
|
1196
|
+
|
|
583
1197
|
function groupOf(entry: AnyRow): GroupNode<RowT> {
|
|
584
1198
|
return entry as GroupNode<RowT>;
|
|
585
1199
|
}
|
|
@@ -637,11 +1251,57 @@ function onToggleGroup(entry: AnyRow) {
|
|
|
637
1251
|
}
|
|
638
1252
|
|
|
639
1253
|
// ── 인라인 셀 편집 ──
|
|
1254
|
+
// 셀 병합 정보 — td의 rowspan/colspan/hidden에 사용
|
|
1255
|
+
function cellSpanOf(row: RowT, col: ColumnDef<RowT>) {
|
|
1256
|
+
return grid.getCellSpan(row, col);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
640
1259
|
function isEditingCell(rowIndex: number, col: ColumnDef) {
|
|
641
1260
|
const cell = state.value.editingCell;
|
|
642
1261
|
return !!cell && cell.rowIndex === rowIndex && cell.columnKey === col.field;
|
|
643
1262
|
}
|
|
644
1263
|
|
|
1264
|
+
// 마우스 드래그 범위 선택
|
|
1265
|
+
let cellDragging = false;
|
|
1266
|
+
let suppressCellClick = false;
|
|
1267
|
+
const endCellDrag = () => {
|
|
1268
|
+
cellDragging = false;
|
|
1269
|
+
};
|
|
1270
|
+
onMounted(() => window.addEventListener("mouseup", endCellDrag));
|
|
1271
|
+
onBeforeUnmount(() => window.removeEventListener("mouseup", endCellDrag));
|
|
1272
|
+
function onCellMouseDown(
|
|
1273
|
+
e: MouseEvent,
|
|
1274
|
+
rowIndex: number,
|
|
1275
|
+
colIndex: number,
|
|
1276
|
+
col: ColumnDef,
|
|
1277
|
+
) {
|
|
1278
|
+
if (e.button !== 0 || isEditingCell(rowIndex, col)) return;
|
|
1279
|
+
suppressCellClick = false;
|
|
1280
|
+
if (state.value.editingCell) grid.commitEditing();
|
|
1281
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1282
|
+
// Ctrl+드래그 — 기존 범위 유지 + 새 범위 추가
|
|
1283
|
+
grid.beginAdditionalRange(rowIndex, colIndex);
|
|
1284
|
+
suppressCellClick = true;
|
|
1285
|
+
} else {
|
|
1286
|
+
grid.setActiveCell(rowIndex, colIndex);
|
|
1287
|
+
}
|
|
1288
|
+
cellDragging = true;
|
|
1289
|
+
e.preventDefault(); // 드래그 중 텍스트 선택 방지
|
|
1290
|
+
}
|
|
1291
|
+
function onCellMouseEnter(rowIndex: number, colIndex: number) {
|
|
1292
|
+
if (!cellDragging) return;
|
|
1293
|
+
suppressCellClick = true;
|
|
1294
|
+
grid.extendSelectionTo(rowIndex, colIndex);
|
|
1295
|
+
}
|
|
1296
|
+
function onCellClick(rowIndex: number, colIndex: number) {
|
|
1297
|
+
if (!suppressCellClick) {
|
|
1298
|
+
grid.setActiveCell(rowIndex, colIndex);
|
|
1299
|
+
grid.trySingleClickEdit(rowIndex, colIndex);
|
|
1300
|
+
}
|
|
1301
|
+
suppressCellClick = false;
|
|
1302
|
+
grid.notifyCellEvent("cellClick", rowIndex, colIndex);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
645
1305
|
function editorContext(rowIndex: number, colIndex: number) {
|
|
646
1306
|
return grid.getEditorContext(rowIndex, colIndex) as CellEditorContext;
|
|
647
1307
|
}
|
|
@@ -658,15 +1318,62 @@ function onEditorInput(event: Event) {
|
|
|
658
1318
|
grid.updateEditValue((event.target as HTMLInputElement | HTMLSelectElement).value);
|
|
659
1319
|
}
|
|
660
1320
|
|
|
1321
|
+
// multiselect 에디터 — 선택된 옵션들을 배열로 저장
|
|
1322
|
+
function isEditOptSelected(opt: string): boolean {
|
|
1323
|
+
const v = state.value.editValue;
|
|
1324
|
+
return Array.isArray(v) && (v as unknown[]).includes(opt);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
function onMultiselectChange(event: Event) {
|
|
1328
|
+
const sel = event.target as HTMLSelectElement;
|
|
1329
|
+
grid.updateEditValue(Array.from(sel.selectedOptions).map((o) => o.value));
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// 라디오 에디터 — 선택 즉시 커밋 (타사 그리드와 동일 UX)
|
|
1333
|
+
function onRadioPick(opt: string, _rowIndex: number, _colIndex: number) {
|
|
1334
|
+
grid.updateEditValue(opt);
|
|
1335
|
+
grid.commitEditing();
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// 커밋 후 이동 시 편집기 언마운트로 빠진 포커스를 그리드로 되돌린다
|
|
1339
|
+
function commitThenNavigate(
|
|
1340
|
+
dir: "up" | "down" | "left" | "right" | "tabLeft" | "tabRight",
|
|
1341
|
+
) {
|
|
1342
|
+
if (grid.commitEditing()) {
|
|
1343
|
+
grid.navigateCell(dir);
|
|
1344
|
+
scrollEl.value?.focus();
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// textarea: Enter=줄바꿈, Ctrl/Meta+Enter=커밋, Tab=저장+이동, Esc=취소
|
|
1349
|
+
function onTextareaKeydown(event: KeyboardEvent) {
|
|
1350
|
+
event.stopPropagation();
|
|
1351
|
+
if (event.isComposing) return;
|
|
1352
|
+
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
1353
|
+
event.preventDefault();
|
|
1354
|
+
commitThenNavigate("down");
|
|
1355
|
+
} else if (event.key === "Tab") {
|
|
1356
|
+
event.preventDefault();
|
|
1357
|
+
commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
|
|
1358
|
+
} else if (event.key === "Escape") {
|
|
1359
|
+
event.preventDefault();
|
|
1360
|
+
grid.cancelEditing();
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
|
|
661
1364
|
// 편집기 내부 키: Enter 저장, Tab 저장+이동, Escape 취소
|
|
662
1365
|
function onEditorKeydown(event: KeyboardEvent) {
|
|
663
1366
|
event.stopPropagation();
|
|
1367
|
+
if (event.isComposing) return; // IME 조합 확정 Enter가 커밋으로 오작동하지 않도록
|
|
664
1368
|
if (event.key === "Enter") {
|
|
665
1369
|
event.preventDefault();
|
|
666
|
-
if (
|
|
1370
|
+
if (event.ctrlKey || event.metaKey) {
|
|
1371
|
+
// 엑셀 Ctrl+Enter — 입력 값을 선택 범위 전체에 적용 (이동 없음)
|
|
1372
|
+
if (grid.commitEditing()) grid.fillActiveToSelection();
|
|
1373
|
+
} else commitThenNavigate("down");
|
|
667
1374
|
} else if (event.key === "Tab") {
|
|
668
1375
|
event.preventDefault();
|
|
669
|
-
|
|
1376
|
+
commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
|
|
670
1377
|
} else if (event.key === "Escape") {
|
|
671
1378
|
event.preventDefault();
|
|
672
1379
|
grid.cancelEditing();
|
|
@@ -685,7 +1392,152 @@ watch(
|
|
|
685
1392
|
</script>
|
|
686
1393
|
|
|
687
1394
|
<template>
|
|
688
|
-
<div
|
|
1395
|
+
<div
|
|
1396
|
+
ref="hostEl"
|
|
1397
|
+
:class="[
|
|
1398
|
+
showOverlay ? 'mg-colctl-host' : undefined,
|
|
1399
|
+
theme && `grid-theme-${theme}`,
|
|
1400
|
+
state.striped && 'mg-striped',
|
|
1401
|
+
]"
|
|
1402
|
+
>
|
|
1403
|
+
<!-- 피벗 필드 패널 — 칩을 존 사이로 드래그해 디멘션 구성 -->
|
|
1404
|
+
<div v-if="pivotPanel" class="mg-pivot-panel">
|
|
1405
|
+
<div
|
|
1406
|
+
v-for="zone in ['fields', 'rows', 'columns', 'values']"
|
|
1407
|
+
:key="zone"
|
|
1408
|
+
:class="['mg-pivot-zone', pivotDropZone === zone && 'mg-drop-over']"
|
|
1409
|
+
@dragover="onPivotZoneDragOver(zone, $event)"
|
|
1410
|
+
@dragleave="pivotDropZone = pivotDropZone === zone ? null : pivotDropZone"
|
|
1411
|
+
@drop="onPivotZoneDrop(zone, $event)"
|
|
1412
|
+
>
|
|
1413
|
+
<span class="mg-pivot-zone-label">{{ pivotZoneLabel(zone) }}</span>
|
|
1414
|
+
<span
|
|
1415
|
+
v-for="(chip, i) in pivotChipsOf(zone)"
|
|
1416
|
+
:key="chip.field"
|
|
1417
|
+
:class="[
|
|
1418
|
+
'mg-pivot-chip',
|
|
1419
|
+
zone === 'fields' && pivotPlaced.has(chip.field) && 'mg-pivot-chip-placed',
|
|
1420
|
+
]"
|
|
1421
|
+
draggable="true"
|
|
1422
|
+
@dragstart="onPivotChipDragStart(chip.field, $event)"
|
|
1423
|
+
@dragover="onPivotChipDragOver($event)"
|
|
1424
|
+
@drop="onPivotZoneDrop(zone, $event, i)"
|
|
1425
|
+
>
|
|
1426
|
+
{{ chip.label }}
|
|
1427
|
+
<select
|
|
1428
|
+
v-if="zone === 'values'"
|
|
1429
|
+
class="mg-pivot-agg"
|
|
1430
|
+
:value="chip.agg"
|
|
1431
|
+
@click.stop
|
|
1432
|
+
@change="onPivotAggChange(chip.field, $event)"
|
|
1433
|
+
>
|
|
1434
|
+
<option v-for="a in PIVOT_AGGS" :key="a" :value="a">{{ a }}</option>
|
|
1435
|
+
</select>
|
|
1436
|
+
<button
|
|
1437
|
+
v-if="zone !== 'fields'"
|
|
1438
|
+
type="button"
|
|
1439
|
+
class="mg-pivot-chip-x"
|
|
1440
|
+
:aria-label="`${chip.label} 제거`"
|
|
1441
|
+
@click="grid.removePivotField(chip.field)"
|
|
1442
|
+
>
|
|
1443
|
+
×
|
|
1444
|
+
</button>
|
|
1445
|
+
</span>
|
|
1446
|
+
</div>
|
|
1447
|
+
</div>
|
|
1448
|
+
|
|
1449
|
+
<!-- 헤더 필터 드롭다운 — 엑셀 autofilter식 값 체크리스트 -->
|
|
1450
|
+
<template v-if="filterDrop && filterDropCol">
|
|
1451
|
+
<div class="mg-colctl-overlay" @click="filterDrop = null" />
|
|
1452
|
+
<div
|
|
1453
|
+
class="mg-colctl-panel mg-filter-drop-panel"
|
|
1454
|
+
:style="{ left: `${filterDrop.x}px`, top: `${filterDrop.y}px` }"
|
|
1455
|
+
role="dialog"
|
|
1456
|
+
:aria-label="`${filterDropCol.header || filterDropCol.field} 필터`"
|
|
1457
|
+
@keydown="onFilterDropKeydown"
|
|
1458
|
+
>
|
|
1459
|
+
<label class="mg-colctl-item">
|
|
1460
|
+
<input
|
|
1461
|
+
type="checkbox"
|
|
1462
|
+
:checked="!filterDropActive || filterDropActive.length >= filterDropAll.length"
|
|
1463
|
+
@change="grid.setFilter(filterDropCol.field, null)"
|
|
1464
|
+
/>
|
|
1465
|
+
{{ state.locale.setFilterAll }}
|
|
1466
|
+
</label>
|
|
1467
|
+
<label
|
|
1468
|
+
v-for="v in filterDropAll"
|
|
1469
|
+
:key="v"
|
|
1470
|
+
class="mg-colctl-item"
|
|
1471
|
+
>
|
|
1472
|
+
<input
|
|
1473
|
+
type="checkbox"
|
|
1474
|
+
:checked="filterDropChecked(v)"
|
|
1475
|
+
@change="toggleFilterValue(v)"
|
|
1476
|
+
/>
|
|
1477
|
+
{{ v }}
|
|
1478
|
+
</label>
|
|
1479
|
+
</div>
|
|
1480
|
+
</template>
|
|
1481
|
+
|
|
1482
|
+
<!-- 찾기 바 — Enter 다음 / Shift+Enter 이전 매치 -->
|
|
1483
|
+
<div v-if="findBox" class="mg-find-bar">
|
|
1484
|
+
<input
|
|
1485
|
+
ref="findInputEl"
|
|
1486
|
+
type="search"
|
|
1487
|
+
class="mg-find-input"
|
|
1488
|
+
placeholder="셀 찾기…"
|
|
1489
|
+
@keydown="onFindKeydown"
|
|
1490
|
+
@input="onFindInput"
|
|
1491
|
+
/>
|
|
1492
|
+
<label class="mg-find-opt">
|
|
1493
|
+
<input
|
|
1494
|
+
type="checkbox"
|
|
1495
|
+
:checked="findCaseSensitive"
|
|
1496
|
+
@change="onFindCaseChange"
|
|
1497
|
+
/>
|
|
1498
|
+
{{ state.locale.findMatchCase }}
|
|
1499
|
+
</label>
|
|
1500
|
+
<label class="mg-find-opt">
|
|
1501
|
+
<input
|
|
1502
|
+
type="checkbox"
|
|
1503
|
+
:checked="findWholeCell"
|
|
1504
|
+
@change="onFindWholeChange"
|
|
1505
|
+
/>
|
|
1506
|
+
{{ state.locale.findWholeCell }}
|
|
1507
|
+
</label>
|
|
1508
|
+
<button type="button" class="mg-find-btn" @click="goFind(true)">
|
|
1509
|
+
▲ 이전
|
|
1510
|
+
</button>
|
|
1511
|
+
<button type="button" class="mg-find-btn" @click="goFind(false)">
|
|
1512
|
+
▼ 다음
|
|
1513
|
+
</button>
|
|
1514
|
+
<span class="mg-find-count">{{ findCount }}</span>
|
|
1515
|
+
</div>
|
|
1516
|
+
|
|
1517
|
+
<!-- 그룹 패널 — 그룹된 컬럼 칩, 클릭 시 해제 -->
|
|
1518
|
+
<div
|
|
1519
|
+
v-if="groupPanel"
|
|
1520
|
+
class="mg-group-panel"
|
|
1521
|
+
:class="{ 'mg-drop-target': groupDropOver }"
|
|
1522
|
+
@dragover="onGroupPanelDragOver"
|
|
1523
|
+
@dragleave="groupDropOver = false"
|
|
1524
|
+
@drop="onGroupPanelDrop"
|
|
1525
|
+
>
|
|
1526
|
+
<span v-if="state.groupBy.length === 0" class="mg-group-panel-empty">
|
|
1527
|
+
{{ state.locale.groupPanelEmpty }}
|
|
1528
|
+
</span>
|
|
1529
|
+
<button
|
|
1530
|
+
v-for="field in state.groupBy"
|
|
1531
|
+
v-else
|
|
1532
|
+
:key="field"
|
|
1533
|
+
type="button"
|
|
1534
|
+
class="mg-group-chip"
|
|
1535
|
+
title="클릭 시 그룹 해제"
|
|
1536
|
+
@click="ungroupField(field)"
|
|
1537
|
+
>
|
|
1538
|
+
{{ state.columns.find((c) => c.field === field)?.header ?? field }} ×
|
|
1539
|
+
</button>
|
|
1540
|
+
</div>
|
|
689
1541
|
<div v-if="showOverlay" class="mg-colctl">
|
|
690
1542
|
<button
|
|
691
1543
|
v-if="filterToggle && hasFilterable"
|
|
@@ -694,7 +1546,7 @@ watch(
|
|
|
694
1546
|
:aria-pressed="state.filterRowVisible"
|
|
695
1547
|
@click="grid.setFilterRowVisible(!state.filterRowVisible)"
|
|
696
1548
|
>
|
|
697
|
-
|
|
1549
|
+
{{ state.locale.filterToggle }} {{ state.filterRowVisible ? "▾" : "▸"
|
|
698
1550
|
}}<template v-if="activeFilterCount > 0">
|
|
699
1551
|
({{ activeFilterCount }})</template
|
|
700
1552
|
>
|
|
@@ -706,22 +1558,22 @@ watch(
|
|
|
706
1558
|
:aria-expanded="colCtlOpen"
|
|
707
1559
|
@click="colCtlOpen = !colCtlOpen"
|
|
708
1560
|
>
|
|
709
|
-
|
|
1561
|
+
{{ state.locale.columnsLabel }} ▾
|
|
710
1562
|
</button>
|
|
711
1563
|
<template v-if="colCtlOpen">
|
|
712
1564
|
<div class="mg-colctl-overlay" @click="colCtlOpen = false"></div>
|
|
713
1565
|
<div
|
|
714
1566
|
class="mg-colctl-panel"
|
|
715
1567
|
role="dialog"
|
|
716
|
-
aria-label="
|
|
1568
|
+
:aria-label="state.locale.columnsLabel"
|
|
717
1569
|
@keydown.esc="colCtlOpen = false"
|
|
718
1570
|
>
|
|
719
1571
|
<div class="mg-colctl-actions">
|
|
720
1572
|
<button type="button" @click="grid.setAllColumnsVisible(true)">
|
|
721
|
-
|
|
1573
|
+
{{ state.locale.selectAll }}
|
|
722
1574
|
</button>
|
|
723
1575
|
<button type="button" @click="grid.setAllColumnsVisible(false)">
|
|
724
|
-
|
|
1576
|
+
{{ state.locale.deselectAll }}
|
|
725
1577
|
</button>
|
|
726
1578
|
</div>
|
|
727
1579
|
<label
|
|
@@ -741,19 +1593,39 @@ watch(
|
|
|
741
1593
|
</div>
|
|
742
1594
|
<div
|
|
743
1595
|
ref="scrollEl"
|
|
744
|
-
:class="{ 'mg-scroll': virtual || hasPinned }"
|
|
1596
|
+
:class="{ 'mg-scroll': virtual || hasPinned || hasAppend }"
|
|
745
1597
|
:style="
|
|
746
|
-
virtual && height
|
|
1598
|
+
(virtual || (hasAppend && height))
|
|
747
1599
|
? { height: `${height}px`, overflow: 'auto' }
|
|
748
|
-
: hasPinned
|
|
749
|
-
? { overflowX: 'auto' }
|
|
1600
|
+
: hasPinned || hasAppend
|
|
1601
|
+
? { overflowX: 'auto', overflowY: height ? undefined : 'auto' }
|
|
750
1602
|
: undefined
|
|
751
1603
|
"
|
|
752
1604
|
@scroll="onScroll"
|
|
753
1605
|
>
|
|
754
|
-
<table
|
|
755
|
-
|
|
756
|
-
|
|
1606
|
+
<table
|
|
1607
|
+
class="mg-table"
|
|
1608
|
+
role="grid"
|
|
1609
|
+
tabindex="0"
|
|
1610
|
+
:style="{ minWidth: `${tableMinWidth}px` }"
|
|
1611
|
+
@keydown="onGridKeydown"
|
|
1612
|
+
>
|
|
1613
|
+
<colgroup>
|
|
1614
|
+
<col v-if="rowStatus" class="mg-col-status" />
|
|
1615
|
+
<col v-if="rowCheckboxes" class="mg-col-check" />
|
|
1616
|
+
<col v-if="rowNumbers" class="mg-col-rownum" />
|
|
1617
|
+
<col
|
|
1618
|
+
v-for="col in state.visibleColumns"
|
|
1619
|
+
:key="col.field"
|
|
1620
|
+
:style="{ width: `${col.width ?? DEFAULT_COLUMN_WIDTH}px` }"
|
|
1621
|
+
/>
|
|
1622
|
+
</colgroup>
|
|
1623
|
+
<thead role="rowgroup">
|
|
1624
|
+
<tr
|
|
1625
|
+
v-for="(row, rowIdx) in headerRows"
|
|
1626
|
+
:key="rowIdx"
|
|
1627
|
+
:style="headerTrStyle"
|
|
1628
|
+
>
|
|
757
1629
|
<th
|
|
758
1630
|
v-if="rowStatus && rowIdx === 0"
|
|
759
1631
|
:rowspan="headerRowSpan"
|
|
@@ -769,16 +1641,22 @@ watch(
|
|
|
769
1641
|
>
|
|
770
1642
|
<input
|
|
771
1643
|
type="checkbox"
|
|
772
|
-
aria-label="
|
|
1644
|
+
:aria-label="state.locale.selectAllRowsAria"
|
|
773
1645
|
:checked="grid.isAllSelected()"
|
|
774
1646
|
:indeterminate.prop="grid.isSomeSelected()"
|
|
775
1647
|
@click.stop
|
|
776
1648
|
@change="grid.toggleAllRows()"
|
|
777
1649
|
/>
|
|
778
1650
|
</th>
|
|
779
|
-
<
|
|
1651
|
+
<th
|
|
1652
|
+
v-if="rowNumbers && rowIdx === 0"
|
|
1653
|
+
:rowspan="headerRowSpan"
|
|
1654
|
+
class="mg-rownum-cell"
|
|
1655
|
+
></th>
|
|
1656
|
+
<template v-for="cell in row">
|
|
780
1657
|
<th
|
|
781
1658
|
v-if="cell.kind === 'group'"
|
|
1659
|
+
:key="cell.key"
|
|
782
1660
|
:colspan="cell.colSpan"
|
|
783
1661
|
class="mg-colgroup"
|
|
784
1662
|
>
|
|
@@ -786,6 +1664,7 @@ watch(
|
|
|
786
1664
|
</th>
|
|
787
1665
|
<th
|
|
788
1666
|
v-else
|
|
1667
|
+
:key="cell.key"
|
|
789
1668
|
:rowspan="cell.rowSpan"
|
|
790
1669
|
:style="
|
|
791
1670
|
cell.col.pinned
|
|
@@ -794,21 +1673,40 @@ watch(
|
|
|
794
1673
|
? { width: `${cell.col.width}px` }
|
|
795
1674
|
: undefined
|
|
796
1675
|
"
|
|
797
|
-
:class="
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1676
|
+
:class="[
|
|
1677
|
+
{
|
|
1678
|
+
'mg-sortable': cell.col.sortable !== false,
|
|
1679
|
+
'mg-col-dragover': dragOverField === cell.col.field,
|
|
1680
|
+
'mg-pinned': !!cell.col.pinned,
|
|
1681
|
+
'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
|
|
1682
|
+
'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
|
|
1683
|
+
},
|
|
1684
|
+
(cell.col.headerAlign ?? cell.col.align) &&
|
|
1685
|
+
(cell.col.headerAlign ?? cell.col.align) !== 'left'
|
|
1686
|
+
? `mg-halign-${cell.col.headerAlign ?? cell.col.align}`
|
|
1687
|
+
: '',
|
|
1688
|
+
grid.getHeaderClass(cell.col),
|
|
1689
|
+
]"
|
|
1690
|
+
:title="cell.col.headerTooltip"
|
|
804
1691
|
:aria-sort="sortAria(cell.col.field)"
|
|
805
|
-
:draggable="reorderable"
|
|
1692
|
+
:draggable="reorderable && cell.col.movable !== false"
|
|
806
1693
|
@dragstart="onDragStart(cell.col, $event)"
|
|
807
1694
|
@dragover="onDragOver(cell.col, $event)"
|
|
808
1695
|
@drop="onDrop(cell.col, $event)"
|
|
809
1696
|
@dragend="onDragEnd"
|
|
810
1697
|
@click="grid.toggleSort(cell.col.field, $event.shiftKey)"
|
|
1698
|
+
@contextmenu="onHeaderContextMenu($event, cell.col)"
|
|
811
1699
|
>
|
|
1700
|
+
<input
|
|
1701
|
+
v-if="cell.col.cellEditor === 'checkbox' && cell.col.headerCheckbox"
|
|
1702
|
+
type="checkbox"
|
|
1703
|
+
class="mg-header-checkbox"
|
|
1704
|
+
:aria-label="`${cell.col.header || cell.col.field} 전체 체크`"
|
|
1705
|
+
:checked="grid.checkboxColumnState(cell.col) === 'all'"
|
|
1706
|
+
:indeterminate.prop="grid.checkboxColumnState(cell.col) === 'some'"
|
|
1707
|
+
@click.stop
|
|
1708
|
+
@change="grid.toggleAllChecked(cell.col)"
|
|
1709
|
+
/>
|
|
812
1710
|
{{ cell.col.header || cell.col.field }}
|
|
813
1711
|
<span v-if="cell.col.required" class="mg-required-mark">*</span>
|
|
814
1712
|
<span v-if="sortArrowOf(cell.col.field)" class="mg-sort-arrow">
|
|
@@ -817,12 +1715,25 @@ watch(
|
|
|
817
1715
|
<span v-if="sortPriorityOf(cell.col.field)" class="mg-sort-priority">
|
|
818
1716
|
{{ sortPriorityOf(cell.col.field) }}
|
|
819
1717
|
</span>
|
|
1718
|
+
<button
|
|
1719
|
+
v-if="headerFilters && cell.col.filterable"
|
|
1720
|
+
type="button"
|
|
1721
|
+
:class="[
|
|
1722
|
+
'mg-header-filter-btn',
|
|
1723
|
+
state.filters[cell.col.field] && 'mg-active',
|
|
1724
|
+
]"
|
|
1725
|
+
:aria-label="`${cell.col.header || cell.col.field} 필터`"
|
|
1726
|
+
@click="toggleFilterDrop(cell.col, $event)"
|
|
1727
|
+
>
|
|
1728
|
+
▾
|
|
1729
|
+
</button>
|
|
820
1730
|
<button
|
|
821
1731
|
v-if="resizable && cell.col.resizable !== false"
|
|
822
1732
|
type="button"
|
|
823
1733
|
class="mg-resizer"
|
|
824
1734
|
:aria-label="`${cell.col.field} 너비 조절`"
|
|
825
1735
|
@mousedown.stop.prevent="onResizeStart(cell.col, $event)"
|
|
1736
|
+
@dblclick.stop="grid.autoSizeColumn(cell.col.field)"
|
|
826
1737
|
@keydown.stop="onResizerKeydown(cell.col, $event)"
|
|
827
1738
|
@click.stop
|
|
828
1739
|
/>
|
|
@@ -832,6 +1743,7 @@ watch(
|
|
|
832
1743
|
<tr v-if="hasFilterRow" class="mg-filter-row">
|
|
833
1744
|
<th v-if="rowStatus" class="mg-status-cell" />
|
|
834
1745
|
<th v-if="rowCheckboxes" class="mg-check-cell" />
|
|
1746
|
+
<th v-if="rowNumbers" class="mg-rownum-cell" />
|
|
835
1747
|
<th
|
|
836
1748
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
837
1749
|
:key="col.field"
|
|
@@ -852,7 +1764,7 @@ watch(
|
|
|
852
1764
|
:checked="setAllCheckedOf(col)"
|
|
853
1765
|
@change="grid.setFilter(col.field, null)"
|
|
854
1766
|
/>
|
|
855
|
-
|
|
1767
|
+
{{ state.locale.setFilterAll }}
|
|
856
1768
|
</label>
|
|
857
1769
|
<label
|
|
858
1770
|
v-for="v in setValuesOf(col)"
|
|
@@ -890,7 +1802,7 @@ watch(
|
|
|
890
1802
|
class="mg-filter-input mg-filter-to"
|
|
891
1803
|
:type="filterInputType(col)"
|
|
892
1804
|
:value="filterValueOf(col, 'valueTo')"
|
|
893
|
-
placeholder="
|
|
1805
|
+
:placeholder="state.locale.rangeEndPlaceholder"
|
|
894
1806
|
@input="onFilterInput(col, 'valueTo', $event)"
|
|
895
1807
|
/>
|
|
896
1808
|
</template>
|
|
@@ -898,7 +1810,7 @@ watch(
|
|
|
898
1810
|
</th>
|
|
899
1811
|
</tr>
|
|
900
1812
|
</thead>
|
|
901
|
-
<tbody>
|
|
1813
|
+
<tbody role="rowgroup">
|
|
902
1814
|
<tr
|
|
903
1815
|
v-for="(prow, pIdx) in state.pinnedTopRows"
|
|
904
1816
|
:key="`pin-top-${pIdx}`"
|
|
@@ -906,6 +1818,7 @@ watch(
|
|
|
906
1818
|
>
|
|
907
1819
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
908
1820
|
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
1821
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
909
1822
|
<td
|
|
910
1823
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
911
1824
|
:key="col.field"
|
|
@@ -927,17 +1840,19 @@ watch(
|
|
|
927
1840
|
<td :colspan="colSpan" :style="{ height: `${virtual.startOffset}px`, padding: 0 }" />
|
|
928
1841
|
</tr>
|
|
929
1842
|
<tr v-if="bodyRows.length === 0">
|
|
930
|
-
<td class="mg-empty" :colspan="colSpan">
|
|
1843
|
+
<td class="mg-empty" :colspan="colSpan">{{ state.locale.noRows }}</td>
|
|
931
1844
|
</tr>
|
|
932
|
-
<template v-for="(entry, rowIdx) in bodyRows"
|
|
1845
|
+
<template v-for="(entry, rowIdx) in bodyRows">
|
|
933
1846
|
<!-- 그룹 헤더 행 -->
|
|
934
1847
|
<tr
|
|
935
1848
|
v-if="isGroupRow(entry)"
|
|
1849
|
+
:key="rowKeyOf(entry)"
|
|
936
1850
|
class="mg-group-row"
|
|
937
1851
|
@click="onToggleGroup(entry)"
|
|
938
1852
|
>
|
|
939
1853
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
940
1854
|
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
1855
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
941
1856
|
<td
|
|
942
1857
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
943
1858
|
:key="col.field"
|
|
@@ -965,14 +1880,48 @@ watch(
|
|
|
965
1880
|
</span>
|
|
966
1881
|
</td>
|
|
967
1882
|
</tr>
|
|
1883
|
+
<!-- 그룹 소계 행 -->
|
|
1884
|
+
<tr
|
|
1885
|
+
v-else-if="isSubtotalRow(entry)"
|
|
1886
|
+
:key="rowKeyOf(entry)"
|
|
1887
|
+
class="mg-subtotal-row"
|
|
1888
|
+
>
|
|
1889
|
+
<td v-if="rowStatus" class="mg-status-cell" />
|
|
1890
|
+
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
1891
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
1892
|
+
<td
|
|
1893
|
+
v-for="(col, colIndex) in state.visibleColumns"
|
|
1894
|
+
:key="col.field"
|
|
1895
|
+
class="mg-subtotal-cell"
|
|
1896
|
+
:class="{
|
|
1897
|
+
'mg-pinned': !!col.pinned,
|
|
1898
|
+
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
1899
|
+
'mg-pin-right-edge': colIndex === firstRightPinIdx,
|
|
1900
|
+
}"
|
|
1901
|
+
:style="pinStyleOf(col)"
|
|
1902
|
+
>
|
|
1903
|
+
<span
|
|
1904
|
+
v-if="colIndex === 0"
|
|
1905
|
+
class="mg-subtotal-label"
|
|
1906
|
+
:style="{ paddingLeft: `${groupOf(entry).depth * 16}px` }"
|
|
1907
|
+
>
|
|
1908
|
+
{{ state.locale.subtotalLabel }}: {{ groupLabelOf(entry) }}
|
|
1909
|
+
</span>
|
|
1910
|
+
<span v-else-if="groupAggOf(entry, col)" class="mg-agg">
|
|
1911
|
+
{{ groupAggOf(entry, col) }}
|
|
1912
|
+
</span>
|
|
1913
|
+
</td>
|
|
1914
|
+
</tr>
|
|
968
1915
|
<!-- 서버 사이드 미로드 행 → 스켈레톤 -->
|
|
969
1916
|
<tr
|
|
970
1917
|
v-else-if="rowDataOf(entry) == null"
|
|
1918
|
+
:key="rowKeyOf(entry)"
|
|
971
1919
|
class="mg-skeleton-row"
|
|
972
1920
|
aria-hidden="true"
|
|
973
1921
|
>
|
|
974
1922
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
975
1923
|
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
1924
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
976
1925
|
<td
|
|
977
1926
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
978
1927
|
:key="col.field"
|
|
@@ -989,8 +1938,11 @@ watch(
|
|
|
989
1938
|
<!-- 리프(데이터) 행 -->
|
|
990
1939
|
<tr
|
|
991
1940
|
v-else
|
|
1941
|
+
:key="rowKeyOf(entry)"
|
|
1942
|
+
role="row"
|
|
1943
|
+
:aria-selected="state.selectedRowIds.has(grid.getRowId(rowDataOf(entry)))"
|
|
992
1944
|
:class="rowClassOf(entry, rowIdx)"
|
|
993
|
-
:style="
|
|
1945
|
+
:style="rowStyleOf(entry)"
|
|
994
1946
|
@click="selectable && grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))"
|
|
995
1947
|
@dragover="onRowDragOver(entryIndexOf(entry, rowIdx), $event)"
|
|
996
1948
|
@drop="onRowDrop($event)"
|
|
@@ -1015,35 +1967,86 @@ watch(
|
|
|
1015
1967
|
type="checkbox"
|
|
1016
1968
|
aria-label="행 선택"
|
|
1017
1969
|
:checked="isSelected(rowDataOf(entry))"
|
|
1970
|
+
:disabled="!grid.isRowSelectable(rowDataOf(entry))"
|
|
1018
1971
|
@change="
|
|
1019
1972
|
grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))
|
|
1020
1973
|
"
|
|
1021
1974
|
/>
|
|
1022
1975
|
</td>
|
|
1023
|
-
<td
|
|
1976
|
+
<td v-if="rowNumbers" class="mg-rownum-cell">
|
|
1977
|
+
{{ entryIndexOf(entry, rowIdx) + 1 }}
|
|
1978
|
+
<span
|
|
1979
|
+
v-if="rowResizable && !virtual"
|
|
1980
|
+
class="mg-row-resizer"
|
|
1981
|
+
title="행 높이 조정"
|
|
1982
|
+
@mousedown="onRowResizeStart(grid.getRowId(rowDataOf(entry)), $event)"
|
|
1983
|
+
/>
|
|
1984
|
+
</td>
|
|
1985
|
+
<template
|
|
1024
1986
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
1987
|
+
>
|
|
1988
|
+
<td
|
|
1989
|
+
v-if="!cellSpanOf(rowDataOf(entry), col).hidden"
|
|
1025
1990
|
:key="col.field"
|
|
1991
|
+
:rowspan="cellSpanOf(rowDataOf(entry), col).rowSpan"
|
|
1992
|
+
:colspan="cellSpanOf(rowDataOf(entry), col).colSpan"
|
|
1026
1993
|
:class="[
|
|
1994
|
+
col.align && col.align !== 'left' ? `mg-align-${col.align}` : '',
|
|
1027
1995
|
{
|
|
1996
|
+
'mg-cell-readonly': !grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex),
|
|
1028
1997
|
'mg-cell-active': grid.isActiveCell(entryIndexOf(entry, rowIdx), colIndex),
|
|
1029
1998
|
'mg-cell-selected': grid.isCellInRange(entryIndexOf(entry, rowIdx), colIndex),
|
|
1030
1999
|
'mg-cell-editing': isEditingCell(entryIndexOf(entry, rowIdx), col),
|
|
1031
2000
|
'mg-cell-invalid': !!cellErrorOf(entry, col),
|
|
2001
|
+
'mg-find-match': isFindMatch(entry, col),
|
|
2002
|
+
'mg-cell-flash': state.flashedCells?.has(grid.getRowId(rowDataOf(entry)) + '|' + String(col.field)),
|
|
2003
|
+
'mg-multiline': !!col.multiLine,
|
|
1032
2004
|
'mg-pinned': !!col.pinned,
|
|
1033
2005
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
1034
2006
|
'mg-pin-right-edge': colIndex === firstRightPinIdx,
|
|
1035
2007
|
},
|
|
1036
2008
|
cellClassOf(entry, rowIdx, col),
|
|
2009
|
+
cellNoteOf(entry, col) && 'mg-cell-note',
|
|
1037
2010
|
]"
|
|
1038
|
-
|
|
2011
|
+
role="gridcell"
|
|
2012
|
+
:title="
|
|
2013
|
+
cellErrorOf(entry, col) ||
|
|
2014
|
+
grid.getCellTooltip(rowDataOf(entry), col) ||
|
|
2015
|
+
cellNoteOf(entry, col) ||
|
|
2016
|
+
undefined
|
|
2017
|
+
"
|
|
1039
2018
|
:style="[
|
|
1040
2019
|
pinStyleOf(col),
|
|
1041
2020
|
colIndex === 0 && leafDepthOf(entry)
|
|
1042
2021
|
? { paddingLeft: `${leafDepthOf(entry) * 16 + 12}px` }
|
|
1043
2022
|
: undefined,
|
|
2023
|
+
grid.getCellStyle(
|
|
2024
|
+
rowDataOf(entry),
|
|
2025
|
+
entryIndexOf(entry, rowIdx),
|
|
2026
|
+
col,
|
|
2027
|
+
) ?? undefined,
|
|
1044
2028
|
]"
|
|
1045
|
-
|
|
1046
|
-
|
|
2029
|
+
:data-mg-row="entryIndexOf(entry, rowIdx)"
|
|
2030
|
+
:data-mg-col="colIndex"
|
|
2031
|
+
@mousedown="
|
|
2032
|
+
onCellMouseDown(
|
|
2033
|
+
$event,
|
|
2034
|
+
entryIndexOf(entry, rowIdx),
|
|
2035
|
+
colIndex,
|
|
2036
|
+
col,
|
|
2037
|
+
)
|
|
2038
|
+
"
|
|
2039
|
+
@mouseenter="
|
|
2040
|
+
onCellMouseEnter(entryIndexOf(entry, rowIdx), colIndex)
|
|
2041
|
+
"
|
|
2042
|
+
@click="
|
|
2043
|
+
onCellClick(entryIndexOf(entry, rowIdx), colIndex)
|
|
2044
|
+
"
|
|
2045
|
+
@dblclick="
|
|
2046
|
+
grid.notifyCellEvent('cellDblClick', entryIndexOf(entry, rowIdx), colIndex);
|
|
2047
|
+
grid.startEditing(entryIndexOf(entry, rowIdx), colIndex);
|
|
2048
|
+
"
|
|
2049
|
+
@contextmenu="onCellContextMenu($event, entryIndexOf(entry, rowIdx), col)"
|
|
1047
2050
|
>
|
|
1048
2051
|
<button
|
|
1049
2052
|
v-if="colIndex === 0 && leafHasChildren(entry) !== undefined"
|
|
@@ -1056,6 +2059,11 @@ watch(
|
|
|
1056
2059
|
>
|
|
1057
2060
|
{{ leafHasChildren(entry) ? (leafExpanded(entry) ? "▾" : "▸") : "" }}
|
|
1058
2061
|
</button>
|
|
2062
|
+
<span
|
|
2063
|
+
v-if="grid.isActiveCell(entryIndexOf(entry, rowIdx), colIndex) && !isEditingCell(entryIndexOf(entry, rowIdx), col)"
|
|
2064
|
+
class="mg-fill-handle"
|
|
2065
|
+
@mousedown="onFillMouseDown"
|
|
2066
|
+
></span>
|
|
1059
2067
|
<span
|
|
1060
2068
|
v-if="col.rowDrag && !isEditingCell(entryIndexOf(entry, rowIdx), col)"
|
|
1061
2069
|
class="mg-row-drag-handle"
|
|
@@ -1076,7 +2084,7 @@ watch(
|
|
|
1076
2084
|
v-if="col.cellEditor === 'select'"
|
|
1077
2085
|
class="mg-editor"
|
|
1078
2086
|
:class="{ 'mg-editor-error': state.editError }"
|
|
1079
|
-
:value="
|
|
2087
|
+
:value="editorInputValue(state.editValue)"
|
|
1080
2088
|
@change="onEditorInput"
|
|
1081
2089
|
@keydown="onEditorKeydown"
|
|
1082
2090
|
@click.stop
|
|
@@ -1086,17 +2094,87 @@ watch(
|
|
|
1086
2094
|
{{ opt }}
|
|
1087
2095
|
</option>
|
|
1088
2096
|
</select>
|
|
2097
|
+
<select
|
|
2098
|
+
v-else-if="col.cellEditor === 'multiselect'"
|
|
2099
|
+
class="mg-editor"
|
|
2100
|
+
:class="{ 'mg-editor-error': state.editError }"
|
|
2101
|
+
multiple
|
|
2102
|
+
:size="Math.min(Math.max((col.editorOptions || []).length, 2), 8)"
|
|
2103
|
+
@change="onMultiselectChange"
|
|
2104
|
+
@keydown="onEditorKeydown"
|
|
2105
|
+
@click.stop
|
|
2106
|
+
@mousedown.stop
|
|
2107
|
+
>
|
|
2108
|
+
<option
|
|
2109
|
+
v-for="opt in col.editorOptions || []"
|
|
2110
|
+
:key="opt"
|
|
2111
|
+
:value="opt"
|
|
2112
|
+
:selected="isEditOptSelected(opt)"
|
|
2113
|
+
>
|
|
2114
|
+
{{ opt }}
|
|
2115
|
+
</option>
|
|
2116
|
+
</select>
|
|
2117
|
+
<div
|
|
2118
|
+
v-else-if="col.cellEditor === 'radio'"
|
|
2119
|
+
class="mg-radio-group"
|
|
2120
|
+
role="radiogroup"
|
|
2121
|
+
>
|
|
2122
|
+
<label
|
|
2123
|
+
v-for="opt in col.editorOptions || []"
|
|
2124
|
+
:key="opt"
|
|
2125
|
+
class="mg-radio-label"
|
|
2126
|
+
>
|
|
2127
|
+
<input
|
|
2128
|
+
type="radio"
|
|
2129
|
+
:checked="String(state.editValue ?? '') === opt"
|
|
2130
|
+
@change="onRadioPick(opt, entryIndexOf(entry, rowIdx), colIndex)"
|
|
2131
|
+
@click.stop
|
|
2132
|
+
@mousedown.stop
|
|
2133
|
+
/>
|
|
2134
|
+
<span>{{ opt }}</span>
|
|
2135
|
+
</label>
|
|
2136
|
+
</div>
|
|
2137
|
+
<textarea
|
|
2138
|
+
v-else-if="col.cellEditor === 'textarea'"
|
|
2139
|
+
class="mg-editor mg-editor-textarea"
|
|
2140
|
+
:class="{ 'mg-editor-error': state.editError }"
|
|
2141
|
+
:value="editorInputValue(state.editValue)"
|
|
2142
|
+
@input="onEditorInput"
|
|
2143
|
+
@keydown="onTextareaKeydown"
|
|
2144
|
+
@blur="grid.commitEditing()"
|
|
2145
|
+
@click.stop
|
|
2146
|
+
@dblclick.stop
|
|
2147
|
+
@mousedown.stop
|
|
2148
|
+
/>
|
|
1089
2149
|
<input
|
|
1090
2150
|
v-else
|
|
1091
2151
|
:type="editorInputType(col)"
|
|
1092
2152
|
class="mg-editor"
|
|
1093
2153
|
:class="{ 'mg-editor-error': state.editError }"
|
|
1094
|
-
:value="
|
|
2154
|
+
:value="editorInputValue(state.editValue)"
|
|
2155
|
+
:list="
|
|
2156
|
+
editorInputType(col) === 'text' && col.editorOptions?.length
|
|
2157
|
+
? `mg-dl-${col.field}`
|
|
2158
|
+
: undefined
|
|
2159
|
+
"
|
|
1095
2160
|
@input="onEditorInput"
|
|
1096
2161
|
@keydown="onEditorKeydown"
|
|
1097
2162
|
@click.stop
|
|
1098
2163
|
@mousedown.stop
|
|
1099
2164
|
/>
|
|
2165
|
+
<datalist
|
|
2166
|
+
v-if="
|
|
2167
|
+
editorInputType(col) === 'text' &&
|
|
2168
|
+
col.editorOptions?.length
|
|
2169
|
+
"
|
|
2170
|
+
:id="`mg-dl-${col.field}`"
|
|
2171
|
+
>
|
|
2172
|
+
<option
|
|
2173
|
+
v-for="opt in col.editorOptions"
|
|
2174
|
+
:key="opt"
|
|
2175
|
+
:value="opt"
|
|
2176
|
+
/>
|
|
2177
|
+
</datalist>
|
|
1100
2178
|
</slot>
|
|
1101
2179
|
<span v-if="state.editError" class="mg-edit-error">{{ state.editError }}</span>
|
|
1102
2180
|
</template>
|
|
@@ -1108,9 +2186,64 @@ watch(
|
|
|
1108
2186
|
:row="rowDataOf(entry)"
|
|
1109
2187
|
:column="col"
|
|
1110
2188
|
>
|
|
1111
|
-
|
|
2189
|
+
<img
|
|
2190
|
+
v-if="col.cellType === 'image' && grid.getCellValue(rowDataOf(entry), col) != null"
|
|
2191
|
+
class="mg-cell-image"
|
|
2192
|
+
:src="String(grid.getCellValue(rowDataOf(entry), col))"
|
|
2193
|
+
:alt="col.cellOptions?.alt?.(rowDataOf(entry)) ?? ''"
|
|
2194
|
+
/>
|
|
2195
|
+
<button
|
|
2196
|
+
v-else-if="col.cellType === 'button'"
|
|
2197
|
+
type="button"
|
|
2198
|
+
class="mg-cell-button"
|
|
2199
|
+
@click.stop="col.cellOptions?.onClick?.(rowDataOf(entry))"
|
|
2200
|
+
@dblclick.stop
|
|
2201
|
+
>
|
|
2202
|
+
{{ grid.getCellText(rowDataOf(entry), col) }}
|
|
2203
|
+
</button>
|
|
2204
|
+
<a
|
|
2205
|
+
v-else-if="col.cellType === 'link'"
|
|
2206
|
+
class="mg-cell-link"
|
|
2207
|
+
:href="cellLinkHref(rowDataOf(entry), col)"
|
|
2208
|
+
:target="col.cellOptions?.target ?? '_blank'"
|
|
2209
|
+
rel="noreferrer"
|
|
2210
|
+
@click.stop
|
|
2211
|
+
>
|
|
2212
|
+
{{ grid.getCellText(rowDataOf(entry), col) }}
|
|
2213
|
+
</a>
|
|
2214
|
+
<span
|
|
2215
|
+
v-else-if="col.cellType === 'progress'"
|
|
2216
|
+
class="mg-cell-progress"
|
|
2217
|
+
role="progressbar"
|
|
2218
|
+
:aria-valuenow="progressValueOf(rowDataOf(entry), col)"
|
|
2219
|
+
:aria-valuemax="col.cellOptions?.max ?? 100"
|
|
2220
|
+
>
|
|
2221
|
+
<span
|
|
2222
|
+
class="mg-cell-progress-bar"
|
|
2223
|
+
:style="{ width: `${progressPctOf(rowDataOf(entry), col)}%` }"
|
|
2224
|
+
/>
|
|
2225
|
+
<span class="mg-cell-progress-text">{{ Math.round(progressPctOf(rowDataOf(entry), col)) }}%</span>
|
|
2226
|
+
</span>
|
|
2227
|
+
<!-- XSS 주의: html 셀은 신뢰할 수 있는 HTML만 -->
|
|
2228
|
+
<span
|
|
2229
|
+
v-else-if="col.cellType === 'html'"
|
|
2230
|
+
class="mg-cell-html"
|
|
2231
|
+
v-html="grid.getCellText(rowDataOf(entry), col)"
|
|
2232
|
+
/>
|
|
2233
|
+
<input
|
|
2234
|
+
v-else-if="col.cellEditor === 'checkbox'"
|
|
2235
|
+
type="checkbox"
|
|
2236
|
+
class="mg-cell-checkbox"
|
|
2237
|
+
:checked="grid.isCellChecked(rowDataOf(entry), col)"
|
|
2238
|
+
:disabled="!grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex)"
|
|
2239
|
+
@click.stop
|
|
2240
|
+
@dblclick.stop
|
|
2241
|
+
@change="grid.toggleCellChecked(rowDataOf(entry), col)"
|
|
2242
|
+
/>
|
|
2243
|
+
<template v-else>{{ grid.getCellText(rowDataOf(entry), col) }}</template>
|
|
1112
2244
|
</slot>
|
|
1113
2245
|
</td>
|
|
2246
|
+
</template>
|
|
1114
2247
|
</tr>
|
|
1115
2248
|
</template>
|
|
1116
2249
|
<tr
|
|
@@ -1127,6 +2260,7 @@ watch(
|
|
|
1127
2260
|
>
|
|
1128
2261
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
1129
2262
|
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
2263
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
1130
2264
|
<td
|
|
1131
2265
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
1132
2266
|
:key="col.field"
|
|
@@ -1140,11 +2274,28 @@ watch(
|
|
|
1140
2274
|
{{ grid.getCellText(prow, col) }}
|
|
1141
2275
|
</td>
|
|
1142
2276
|
</tr>
|
|
2277
|
+
<tr
|
|
2278
|
+
v-if="state.appendScroll && (state.appendScroll.loading || state.appendScroll.hasMore)"
|
|
2279
|
+
class="mg-append-row"
|
|
2280
|
+
>
|
|
2281
|
+
<td :colspan="colSpan">
|
|
2282
|
+
<span v-if="state.appendScroll.loading">{{ state.locale.loadingMore }}</span>
|
|
2283
|
+
<button
|
|
2284
|
+
v-else
|
|
2285
|
+
type="button"
|
|
2286
|
+
class="mg-append-btn"
|
|
2287
|
+
@click="onLoadMore"
|
|
2288
|
+
>
|
|
2289
|
+
더 보기
|
|
2290
|
+
</button>
|
|
2291
|
+
</td>
|
|
2292
|
+
</tr>
|
|
1143
2293
|
</tbody>
|
|
1144
2294
|
<tfoot v-if="state.grandTotals">
|
|
1145
2295
|
<tr class="mg-total-row">
|
|
1146
2296
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
1147
2297
|
<td v-if="rowCheckboxes" class="mg-check-cell" />
|
|
2298
|
+
<td v-if="rowNumbers" class="mg-rownum-cell" />
|
|
1148
2299
|
<td
|
|
1149
2300
|
v-for="(col, colIndex) in state.visibleColumns"
|
|
1150
2301
|
:key="col.field"
|
|
@@ -1161,12 +2312,12 @@ watch(
|
|
|
1161
2312
|
>
|
|
1162
2313
|
{{ formatAggregate(state.grandTotals[col.field]) }}
|
|
1163
2314
|
</span>
|
|
1164
|
-
<template v-else-if="colIndex === 0"
|
|
2315
|
+
<template v-else-if="colIndex === 0">{{ state.locale.totalLabel }}</template>
|
|
1165
2316
|
</td>
|
|
1166
2317
|
</tr>
|
|
1167
2318
|
</tfoot>
|
|
1168
2319
|
</table>
|
|
1169
|
-
<div v-if="state.serverSide?.loading" class="mg-loading">
|
|
2320
|
+
<div v-if="state.serverSide?.loading" class="mg-loading">{{ state.locale.loadingMore }}</div>
|
|
1170
2321
|
</div>
|
|
1171
2322
|
<div
|
|
1172
2323
|
v-if="statusBar && state.selectionAggregates"
|
|
@@ -1186,7 +2337,7 @@ watch(
|
|
|
1186
2337
|
</span>
|
|
1187
2338
|
</span>
|
|
1188
2339
|
<span>
|
|
1189
|
-
|
|
2340
|
+
{{ state.locale.totalLabel }}
|
|
1190
2341
|
<span class="mg-status-value">
|
|
1191
2342
|
{{ formatAggregate(state.selectionAggregates.sum) }}
|
|
1192
2343
|
</span>
|
|
@@ -1211,5 +2362,32 @@ watch(
|
|
|
1211
2362
|
</span>
|
|
1212
2363
|
</template>
|
|
1213
2364
|
</div>
|
|
2365
|
+
<template v-if="state.contextMenu">
|
|
2366
|
+
<div
|
|
2367
|
+
class="mg-ctx-overlay"
|
|
2368
|
+
@click="grid.closeContextMenu()"
|
|
2369
|
+
@contextmenu.prevent="grid.closeContextMenu()"
|
|
2370
|
+
/>
|
|
2371
|
+
<ul
|
|
2372
|
+
class="mg-ctx-menu"
|
|
2373
|
+
role="menu"
|
|
2374
|
+
:style="{ left: `${state.contextMenu.x}px`, top: `${state.contextMenu.y}px` }"
|
|
2375
|
+
>
|
|
2376
|
+
<template v-for="item in state.contextMenu.items">
|
|
2377
|
+
<li v-if="item.separator" :key="item.id" class="mg-ctx-separator" role="separator" />
|
|
2378
|
+
<li v-else :key="item.id" role="none">
|
|
2379
|
+
<button
|
|
2380
|
+
type="button"
|
|
2381
|
+
role="menuitem"
|
|
2382
|
+
class="mg-ctx-item"
|
|
2383
|
+
:disabled="item.disabled"
|
|
2384
|
+
@click="grid.runContextMenuItem(item.id)"
|
|
2385
|
+
>
|
|
2386
|
+
{{ item.label }}
|
|
2387
|
+
</button>
|
|
2388
|
+
</li>
|
|
2389
|
+
</template>
|
|
2390
|
+
</ul>
|
|
2391
|
+
</template>
|
|
1214
2392
|
</div>
|
|
1215
2393
|
</template>
|