@moda-grid/vue2 0.4.1 → 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 +601 -21
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -21,4 +21,5 @@ const { grid } = useGrid({ columns, data });
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
- 문서: https://github.com/park-taejoon/moda-grid-releases
|
|
24
|
-
-
|
|
24
|
+
- 홈페이지: https://www.modaolive.com/download/modagrid
|
|
25
|
+
- 이슈: https://github.com/park-taejoon/moda-grid-releases/issues
|
package/dist/DataGrid.vue
CHANGED
|
@@ -17,8 +17,10 @@ import {
|
|
|
17
17
|
formatAggregate,
|
|
18
18
|
} from "@moda-grid/core";
|
|
19
19
|
import type {
|
|
20
|
+
AggregateFn,
|
|
20
21
|
AppendScrollOptions,
|
|
21
22
|
PivotOptions,
|
|
23
|
+
PivotZone,
|
|
22
24
|
ContextMenuItem,
|
|
23
25
|
GridLocale,
|
|
24
26
|
CellEditorContext,
|
|
@@ -52,6 +54,8 @@ function editorInputValue(v: unknown): string {
|
|
|
52
54
|
|
|
53
55
|
const props = defineProps({
|
|
54
56
|
columns: { type: Array as PropType<ColumnDef[]>, required: true },
|
|
57
|
+
/** 모든 컬럼에 적용되는 공통 기본값 — 컬럼 명시 속성이 우선 (defaultColDef 대응) */
|
|
58
|
+
defaultColDef: { type: Object as PropType<Partial<ColumnDef>>, default: undefined },
|
|
55
59
|
/** 행 데이터. `grid`를 직접 넘기는 제어 모드에서는 생략 가능 */
|
|
56
60
|
data: { type: Array as PropType<Record<string, unknown>[]>, default: undefined },
|
|
57
61
|
/** 외부에서 생성/관리하는 GridCore. 생략하면 내부 인스턴스 생성 */
|
|
@@ -104,6 +108,34 @@ const props = defineProps({
|
|
|
104
108
|
groupPanel: { type: Boolean, default: false },
|
|
105
109
|
/** multiLine 셀 내용만큼 행 높이 자동 확장 — 가상 스크롤에서는 무시 */
|
|
106
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 },
|
|
107
139
|
/** 선언형 이벤트 핸들러 — 마운트 시 구독, 언마운트 시 해제 (grid.on과 동일) */
|
|
108
140
|
events: { type: Object as PropType<GridEventHandlers>, default: undefined },
|
|
109
141
|
/** GridCore 인스턴스가 준비되면 한 번 호출 — props 모드에서도 grid API 접근 가능 */
|
|
@@ -115,6 +147,7 @@ const internal = props.grid
|
|
|
115
147
|
? null
|
|
116
148
|
: useGrid({
|
|
117
149
|
columns: props.columns,
|
|
150
|
+
defaultColDef: props.defaultColDef,
|
|
118
151
|
data: props.data ?? [],
|
|
119
152
|
getRowId: props.getRowId,
|
|
120
153
|
serverSide: props.serverSide,
|
|
@@ -126,6 +159,19 @@ const internal = props.grid
|
|
|
126
159
|
contextMenu: props.contextMenu,
|
|
127
160
|
headerContextMenu: props.headerContextMenu,
|
|
128
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,
|
|
129
175
|
virtualScroll:
|
|
130
176
|
props.height != null && props.rowHeight != null && props.rowHeight > 0
|
|
131
177
|
? {
|
|
@@ -182,6 +228,23 @@ watchEffect(() => {
|
|
|
182
228
|
watchEffect(() => {
|
|
183
229
|
if (props.selectionMode) grid.setSelectionMode(props.selectionMode);
|
|
184
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
|
+
});
|
|
185
248
|
|
|
186
249
|
// 가상 스크롤: 코어가 보정한 scrollTop을 DOM에 동기화 (키보드 scrollIntoView)
|
|
187
250
|
const scrollEl = ref<HTMLElement | null>(null);
|
|
@@ -200,13 +263,223 @@ watch(
|
|
|
200
263
|
if (!req) return;
|
|
201
264
|
await nextTick();
|
|
202
265
|
(scrollEl.value ?? hostEl.value)
|
|
203
|
-
?.querySelector<HTMLElement>(
|
|
204
|
-
|
|
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" });
|
|
205
273
|
},
|
|
206
274
|
);
|
|
207
275
|
|
|
208
276
|
// autoRowHeight prop → core 동기화 (제어 모드 포함)
|
|
209
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
|
+
}
|
|
210
483
|
|
|
211
484
|
// 행 높이 — 가상 스크롤은 고정, 아니면 autoRowHeight 추정치 적용
|
|
212
485
|
function rowStyleOf(entry: AnyRow) {
|
|
@@ -223,6 +496,27 @@ function ungroupField(field: string) {
|
|
|
223
496
|
);
|
|
224
497
|
}
|
|
225
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
|
+
|
|
226
520
|
const virtual = computed(() => state.value.virtual);
|
|
227
521
|
// 그룹화 시: displayRows(그룹 헤더 포함)를 virtual 인덱스로 슬라이스
|
|
228
522
|
type RowT = Record<string, unknown>;
|
|
@@ -248,6 +542,17 @@ const hasFilterable = computed(() =>
|
|
|
248
542
|
const hasFilterRow = computed(
|
|
249
543
|
() => hasFilterable.value && state.value.filterRowVisible,
|
|
250
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
|
+
);
|
|
251
556
|
const showOverlay = computed(
|
|
252
557
|
() => props.columnController || (props.filterToggle && hasFilterable.value),
|
|
253
558
|
);
|
|
@@ -490,6 +795,14 @@ type HeaderCell =
|
|
|
490
795
|
rowSpan?: number;
|
|
491
796
|
};
|
|
492
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
|
+
|
|
493
806
|
const headerRows = computed<HeaderCell[][]>(() => {
|
|
494
807
|
const spans = state.value.headerGroups;
|
|
495
808
|
const cols = state.value.visibleColumns;
|
|
@@ -609,6 +922,7 @@ function onDragStart(col: ColumnDef, event: DragEvent) {
|
|
|
609
922
|
if (event.dataTransfer) {
|
|
610
923
|
event.dataTransfer.effectAllowed = "move";
|
|
611
924
|
event.dataTransfer.setData("text/plain", col.field);
|
|
925
|
+
event.dataTransfer.setData("application/x-mg-column", col.field);
|
|
612
926
|
}
|
|
613
927
|
}
|
|
614
928
|
|
|
@@ -694,6 +1008,16 @@ function cellClassOf(entry: AnyRow, rowIdx: number, col: ColumnDef) {
|
|
|
694
1008
|
return grid.getCellClass(row, entryIndexOf(entry, rowIdx), col);
|
|
695
1009
|
}
|
|
696
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
|
+
|
|
697
1021
|
function onRowDragStart(rowIndex: number, event: DragEvent) {
|
|
698
1022
|
if (!grid.beginRowDrag(rowIndex)) {
|
|
699
1023
|
event.preventDefault();
|
|
@@ -738,6 +1062,7 @@ const CELL_KEYS: Record<string, CellNavigation> = {
|
|
|
738
1062
|
};
|
|
739
1063
|
|
|
740
1064
|
function onGridKeydown(event: KeyboardEvent) {
|
|
1065
|
+
if (event.isComposing) return; // IME 조합 중 — 조합 확정 키가 그리드 키로 해석되지 않도록
|
|
741
1066
|
if ((event.target as HTMLElement).closest("input, textarea, select")) return;
|
|
742
1067
|
// 클립보드/이력: Ctrl+C 복사, Ctrl+Shift+C 헤더 포함 복사,
|
|
743
1068
|
// Ctrl+V 붙여넣기, Ctrl+Z 되돌리기, Ctrl+Y·Ctrl+Shift+Z 다시 실행
|
|
@@ -749,6 +1074,12 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
749
1074
|
event.preventDefault();
|
|
750
1075
|
void navigator.clipboard?.writeText(tsv);
|
|
751
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
|
+
}
|
|
752
1083
|
} else if (key === "v") {
|
|
753
1084
|
event.preventDefault();
|
|
754
1085
|
void navigator.clipboard?.readText().then((text) => grid.pasteTsv(text));
|
|
@@ -768,6 +1099,38 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
768
1099
|
return;
|
|
769
1100
|
event.preventDefault();
|
|
770
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 — 열 선택
|
|
771
1134
|
}
|
|
772
1135
|
return;
|
|
773
1136
|
}
|
|
@@ -777,12 +1140,30 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
777
1140
|
return;
|
|
778
1141
|
}
|
|
779
1142
|
if (event.key === "Delete" || event.key === "Backspace") {
|
|
780
|
-
// 선택
|
|
1143
|
+
// 선택 영역(없으면 활성 셀) 내용 지우기 — 타사 그리드 Del키 대응
|
|
781
1144
|
event.preventDefault();
|
|
782
1145
|
grid.clearRange();
|
|
783
1146
|
return;
|
|
784
1147
|
}
|
|
785
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
|
+
}
|
|
786
1167
|
if (event.key === "Enter" || event.key === "F2") {
|
|
787
1168
|
// 활성 셀에서 Enter → 편집 진입
|
|
788
1169
|
if (active) {
|
|
@@ -897,7 +1278,13 @@ function onCellMouseDown(
|
|
|
897
1278
|
if (e.button !== 0 || isEditingCell(rowIndex, col)) return;
|
|
898
1279
|
suppressCellClick = false;
|
|
899
1280
|
if (state.value.editingCell) grid.commitEditing();
|
|
900
|
-
|
|
1281
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1282
|
+
// Ctrl+드래그 — 기존 범위 유지 + 새 범위 추가
|
|
1283
|
+
grid.beginAdditionalRange(rowIndex, colIndex);
|
|
1284
|
+
suppressCellClick = true;
|
|
1285
|
+
} else {
|
|
1286
|
+
grid.setActiveCell(rowIndex, colIndex);
|
|
1287
|
+
}
|
|
901
1288
|
cellDragging = true;
|
|
902
1289
|
e.preventDefault(); // 드래그 중 텍스트 선택 방지
|
|
903
1290
|
}
|
|
@@ -907,7 +1294,10 @@ function onCellMouseEnter(rowIndex: number, colIndex: number) {
|
|
|
907
1294
|
grid.extendSelectionTo(rowIndex, colIndex);
|
|
908
1295
|
}
|
|
909
1296
|
function onCellClick(rowIndex: number, colIndex: number) {
|
|
910
|
-
if (!suppressCellClick)
|
|
1297
|
+
if (!suppressCellClick) {
|
|
1298
|
+
grid.setActiveCell(rowIndex, colIndex);
|
|
1299
|
+
grid.trySingleClickEdit(rowIndex, colIndex);
|
|
1300
|
+
}
|
|
911
1301
|
suppressCellClick = false;
|
|
912
1302
|
grid.notifyCellEvent("cellClick", rowIndex, colIndex);
|
|
913
1303
|
}
|
|
@@ -939,21 +1329,32 @@ function onMultiselectChange(event: Event) {
|
|
|
939
1329
|
grid.updateEditValue(Array.from(sel.selectedOptions).map((o) => o.value));
|
|
940
1330
|
}
|
|
941
1331
|
|
|
942
|
-
// 라디오 에디터 — 선택 즉시 커밋 (
|
|
1332
|
+
// 라디오 에디터 — 선택 즉시 커밋 (타사 그리드와 동일 UX)
|
|
943
1333
|
function onRadioPick(opt: string, _rowIndex: number, _colIndex: number) {
|
|
944
1334
|
grid.updateEditValue(opt);
|
|
945
1335
|
grid.commitEditing();
|
|
946
1336
|
}
|
|
947
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
|
+
|
|
948
1348
|
// textarea: Enter=줄바꿈, Ctrl/Meta+Enter=커밋, Tab=저장+이동, Esc=취소
|
|
949
1349
|
function onTextareaKeydown(event: KeyboardEvent) {
|
|
950
1350
|
event.stopPropagation();
|
|
1351
|
+
if (event.isComposing) return;
|
|
951
1352
|
if (event.key === "Enter" && (event.ctrlKey || event.metaKey)) {
|
|
952
1353
|
event.preventDefault();
|
|
953
|
-
|
|
1354
|
+
commitThenNavigate("down");
|
|
954
1355
|
} else if (event.key === "Tab") {
|
|
955
1356
|
event.preventDefault();
|
|
956
|
-
|
|
1357
|
+
commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
|
|
957
1358
|
} else if (event.key === "Escape") {
|
|
958
1359
|
event.preventDefault();
|
|
959
1360
|
grid.cancelEditing();
|
|
@@ -963,12 +1364,16 @@ function onTextareaKeydown(event: KeyboardEvent) {
|
|
|
963
1364
|
// 편집기 내부 키: Enter 저장, Tab 저장+이동, Escape 취소
|
|
964
1365
|
function onEditorKeydown(event: KeyboardEvent) {
|
|
965
1366
|
event.stopPropagation();
|
|
1367
|
+
if (event.isComposing) return; // IME 조합 확정 Enter가 커밋으로 오작동하지 않도록
|
|
966
1368
|
if (event.key === "Enter") {
|
|
967
1369
|
event.preventDefault();
|
|
968
|
-
if (
|
|
1370
|
+
if (event.ctrlKey || event.metaKey) {
|
|
1371
|
+
// 엑셀 Ctrl+Enter — 입력 값을 선택 범위 전체에 적용 (이동 없음)
|
|
1372
|
+
if (grid.commitEditing()) grid.fillActiveToSelection();
|
|
1373
|
+
} else commitThenNavigate("down");
|
|
969
1374
|
} else if (event.key === "Tab") {
|
|
970
1375
|
event.preventDefault();
|
|
971
|
-
|
|
1376
|
+
commitThenNavigate(event.shiftKey ? "tabLeft" : "tabRight");
|
|
972
1377
|
} else if (event.key === "Escape") {
|
|
973
1378
|
event.preventDefault();
|
|
974
1379
|
grid.cancelEditing();
|
|
@@ -987,9 +1392,137 @@ watch(
|
|
|
987
1392
|
</script>
|
|
988
1393
|
|
|
989
1394
|
<template>
|
|
990
|
-
<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
|
+
|
|
991
1517
|
<!-- 그룹 패널 — 그룹된 컬럼 칩, 클릭 시 해제 -->
|
|
992
|
-
<div
|
|
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
|
+
>
|
|
993
1526
|
<span v-if="state.groupBy.length === 0" class="mg-group-panel-empty">
|
|
994
1527
|
{{ state.locale.groupPanelEmpty }}
|
|
995
1528
|
</span>
|
|
@@ -1070,9 +1603,29 @@ watch(
|
|
|
1070
1603
|
"
|
|
1071
1604
|
@scroll="onScroll"
|
|
1072
1605
|
>
|
|
1073
|
-
<table
|
|
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>
|
|
1074
1623
|
<thead role="rowgroup">
|
|
1075
|
-
<tr
|
|
1624
|
+
<tr
|
|
1625
|
+
v-for="(row, rowIdx) in headerRows"
|
|
1626
|
+
:key="rowIdx"
|
|
1627
|
+
:style="headerTrStyle"
|
|
1628
|
+
>
|
|
1076
1629
|
<th
|
|
1077
1630
|
v-if="rowStatus && rowIdx === 0"
|
|
1078
1631
|
:rowspan="headerRowSpan"
|
|
@@ -1100,9 +1653,10 @@ watch(
|
|
|
1100
1653
|
:rowspan="headerRowSpan"
|
|
1101
1654
|
class="mg-rownum-cell"
|
|
1102
1655
|
></th>
|
|
1103
|
-
<template v-for="cell in row"
|
|
1656
|
+
<template v-for="cell in row">
|
|
1104
1657
|
<th
|
|
1105
1658
|
v-if="cell.kind === 'group'"
|
|
1659
|
+
:key="cell.key"
|
|
1106
1660
|
:colspan="cell.colSpan"
|
|
1107
1661
|
class="mg-colgroup"
|
|
1108
1662
|
>
|
|
@@ -1110,6 +1664,7 @@ watch(
|
|
|
1110
1664
|
</th>
|
|
1111
1665
|
<th
|
|
1112
1666
|
v-else
|
|
1667
|
+
:key="cell.key"
|
|
1113
1668
|
:rowspan="cell.rowSpan"
|
|
1114
1669
|
:style="
|
|
1115
1670
|
cell.col.pinned
|
|
@@ -1126,10 +1681,15 @@ watch(
|
|
|
1126
1681
|
'mg-pin-left-edge': cell.colIndex === lastLeftPinIdx,
|
|
1127
1682
|
'mg-pin-right-edge': cell.colIndex === firstRightPinIdx,
|
|
1128
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
|
+
: '',
|
|
1129
1688
|
grid.getHeaderClass(cell.col),
|
|
1130
1689
|
]"
|
|
1690
|
+
:title="cell.col.headerTooltip"
|
|
1131
1691
|
:aria-sort="sortAria(cell.col.field)"
|
|
1132
|
-
:draggable="reorderable"
|
|
1692
|
+
:draggable="reorderable && cell.col.movable !== false"
|
|
1133
1693
|
@dragstart="onDragStart(cell.col, $event)"
|
|
1134
1694
|
@dragover="onDragOver(cell.col, $event)"
|
|
1135
1695
|
@drop="onDrop(cell.col, $event)"
|
|
@@ -1155,6 +1715,18 @@ watch(
|
|
|
1155
1715
|
<span v-if="sortPriorityOf(cell.col.field)" class="mg-sort-priority">
|
|
1156
1716
|
{{ sortPriorityOf(cell.col.field) }}
|
|
1157
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>
|
|
1158
1730
|
<button
|
|
1159
1731
|
v-if="resizable && cell.col.resizable !== false"
|
|
1160
1732
|
type="button"
|
|
@@ -1270,10 +1842,11 @@ watch(
|
|
|
1270
1842
|
<tr v-if="bodyRows.length === 0">
|
|
1271
1843
|
<td class="mg-empty" :colspan="colSpan">{{ state.locale.noRows }}</td>
|
|
1272
1844
|
</tr>
|
|
1273
|
-
<template v-for="(entry, rowIdx) in bodyRows"
|
|
1845
|
+
<template v-for="(entry, rowIdx) in bodyRows">
|
|
1274
1846
|
<!-- 그룹 헤더 행 -->
|
|
1275
1847
|
<tr
|
|
1276
1848
|
v-if="isGroupRow(entry)"
|
|
1849
|
+
:key="rowKeyOf(entry)"
|
|
1277
1850
|
class="mg-group-row"
|
|
1278
1851
|
@click="onToggleGroup(entry)"
|
|
1279
1852
|
>
|
|
@@ -1310,6 +1883,7 @@ watch(
|
|
|
1310
1883
|
<!-- 그룹 소계 행 -->
|
|
1311
1884
|
<tr
|
|
1312
1885
|
v-else-if="isSubtotalRow(entry)"
|
|
1886
|
+
:key="rowKeyOf(entry)"
|
|
1313
1887
|
class="mg-subtotal-row"
|
|
1314
1888
|
>
|
|
1315
1889
|
<td v-if="rowStatus" class="mg-status-cell" />
|
|
@@ -1341,6 +1915,7 @@ watch(
|
|
|
1341
1915
|
<!-- 서버 사이드 미로드 행 → 스켈레톤 -->
|
|
1342
1916
|
<tr
|
|
1343
1917
|
v-else-if="rowDataOf(entry) == null"
|
|
1918
|
+
:key="rowKeyOf(entry)"
|
|
1344
1919
|
class="mg-skeleton-row"
|
|
1345
1920
|
aria-hidden="true"
|
|
1346
1921
|
>
|
|
@@ -1363,6 +1938,7 @@ watch(
|
|
|
1363
1938
|
<!-- 리프(데이터) 행 -->
|
|
1364
1939
|
<tr
|
|
1365
1940
|
v-else
|
|
1941
|
+
:key="rowKeyOf(entry)"
|
|
1366
1942
|
role="row"
|
|
1367
1943
|
:aria-selected="state.selectedRowIds.has(grid.getRowId(rowDataOf(entry)))"
|
|
1368
1944
|
:class="rowClassOf(entry, rowIdx)"
|
|
@@ -1391,6 +1967,7 @@ watch(
|
|
|
1391
1967
|
type="checkbox"
|
|
1392
1968
|
aria-label="행 선택"
|
|
1393
1969
|
:checked="isSelected(rowDataOf(entry))"
|
|
1970
|
+
:disabled="!grid.isRowSelectable(rowDataOf(entry))"
|
|
1394
1971
|
@change="
|
|
1395
1972
|
grid.toggleRowSelection(grid.getRowId(rowDataOf(entry)))
|
|
1396
1973
|
"
|
|
@@ -1414,12 +1991,15 @@ watch(
|
|
|
1414
1991
|
:rowspan="cellSpanOf(rowDataOf(entry), col).rowSpan"
|
|
1415
1992
|
:colspan="cellSpanOf(rowDataOf(entry), col).colSpan"
|
|
1416
1993
|
:class="[
|
|
1994
|
+
col.align && col.align !== 'left' ? `mg-align-${col.align}` : '',
|
|
1417
1995
|
{
|
|
1418
1996
|
'mg-cell-readonly': !grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex),
|
|
1419
1997
|
'mg-cell-active': grid.isActiveCell(entryIndexOf(entry, rowIdx), colIndex),
|
|
1420
1998
|
'mg-cell-selected': grid.isCellInRange(entryIndexOf(entry, rowIdx), colIndex),
|
|
1421
1999
|
'mg-cell-editing': isEditingCell(entryIndexOf(entry, rowIdx), col),
|
|
1422
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)),
|
|
1423
2003
|
'mg-multiline': !!col.multiLine,
|
|
1424
2004
|
'mg-pinned': !!col.pinned,
|
|
1425
2005
|
'mg-pin-left-edge': colIndex === lastLeftPinIdx,
|
|
@@ -1655,7 +2235,7 @@ watch(
|
|
|
1655
2235
|
type="checkbox"
|
|
1656
2236
|
class="mg-cell-checkbox"
|
|
1657
2237
|
:checked="grid.isCellChecked(rowDataOf(entry), col)"
|
|
1658
|
-
:disabled="
|
|
2238
|
+
:disabled="!grid.isCellEditable(entryIndexOf(entry, rowIdx), colIndex)"
|
|
1659
2239
|
@click.stop
|
|
1660
2240
|
@dblclick.stop
|
|
1661
2241
|
@change="grid.toggleCellChecked(rowDataOf(entry), col)"
|
|
@@ -1793,9 +2373,9 @@ watch(
|
|
|
1793
2373
|
role="menu"
|
|
1794
2374
|
:style="{ left: `${state.contextMenu.x}px`, top: `${state.contextMenu.y}px` }"
|
|
1795
2375
|
>
|
|
1796
|
-
<template v-for="item in state.contextMenu.items"
|
|
1797
|
-
<li v-if="item.separator" class="mg-ctx-separator" role="separator" />
|
|
1798
|
-
<li v-else role="none">
|
|
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">
|
|
1799
2379
|
<button
|
|
1800
2380
|
type="button"
|
|
1801
2381
|
role="menuitem"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda-grid/vue2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Vue 2.7 adapter for @moda-grid — DataGrid SFC and useGrid composable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/park-taejoon/moda-grid.git"
|
|
27
|
-
"directory": "packages/vue2"
|
|
26
|
+
"url": "git+https://github.com/park-taejoon/moda-grid-releases.git"
|
|
28
27
|
},
|
|
28
|
+
"homepage": "https://www.modaolive.com/download/modagrid",
|
|
29
|
+
"bugs": "https://github.com/park-taejoon/moda-grid-releases/issues",
|
|
29
30
|
"keywords": [
|
|
30
31
|
"vue",
|
|
31
32
|
"vue2",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"grid"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@moda-grid/core": "0.
|
|
39
|
+
"@moda-grid/core": "1.0.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"vue": "^2.7.0"
|