@moda-grid/vue2 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DataGrid.vue +45 -13
- package/package.json +2 -2
package/dist/DataGrid.vue
CHANGED
|
@@ -27,6 +27,8 @@ import {
|
|
|
27
27
|
gridThemeClasses,
|
|
28
28
|
gridThemeVars,
|
|
29
29
|
logicalToDomScrollLeft,
|
|
30
|
+
readClipboardText,
|
|
31
|
+
writeClipboardText,
|
|
30
32
|
} from "@moda-grid/core";
|
|
31
33
|
import type {
|
|
32
34
|
AggregateFn,
|
|
@@ -55,6 +57,7 @@ import type {
|
|
|
55
57
|
SelectionMode,
|
|
56
58
|
ServerSideOptions,
|
|
57
59
|
TreeDataOptions,
|
|
60
|
+
TreeDropPosition,
|
|
58
61
|
} from "@moda-grid/core";
|
|
59
62
|
import { useGrid, useGridState } from "./useGrid.js";
|
|
60
63
|
|
|
@@ -789,7 +792,8 @@ const groupDropOver = ref(false);
|
|
|
789
792
|
function onGroupPanelDragOver(event: DragEvent) {
|
|
790
793
|
if (event.dataTransfer?.types.includes("application/x-mg-column")) {
|
|
791
794
|
event.preventDefault();
|
|
792
|
-
|
|
795
|
+
// effectAllowed=move 세션에서 dropEffect=copy는 실제 DnD가 drop을 거부한다
|
|
796
|
+
event.dataTransfer.dropEffect = "move";
|
|
793
797
|
groupDropOver.value = true;
|
|
794
798
|
}
|
|
795
799
|
}
|
|
@@ -1032,8 +1036,11 @@ function touchHitAt(target: Element | null) {
|
|
|
1032
1036
|
return null;
|
|
1033
1037
|
}
|
|
1034
1038
|
|
|
1035
|
-
/** 포인터 아래 행의 삽입
|
|
1036
|
-
function
|
|
1039
|
+
/** 포인터 아래 행의 삽입 위치 — td의 data-mg-row로 행 인덱스를 해석한다 */
|
|
1040
|
+
function touchRowDropAt(
|
|
1041
|
+
target: Element | null,
|
|
1042
|
+
y: number,
|
|
1043
|
+
): { index: number; position?: TreeDropPosition } | null {
|
|
1037
1044
|
const root = hostEl.value;
|
|
1038
1045
|
const t = target as HTMLElement | null;
|
|
1039
1046
|
let td = t?.closest?.("td[data-mg-row]") as HTMLElement | null;
|
|
@@ -1047,7 +1054,15 @@ function touchRowGapAt(target: Element | null, y: number): number | null {
|
|
|
1047
1054
|
const tr = td.closest("tr");
|
|
1048
1055
|
if (Number.isNaN(rowIndex) || !tr) return null;
|
|
1049
1056
|
const rect = tr.getBoundingClientRect();
|
|
1050
|
-
|
|
1057
|
+
const ratio = (y - rect.top) / rect.height;
|
|
1058
|
+
// 트리 모드는 상하 25%=before/after, 가운데 50%=inside
|
|
1059
|
+
if (grid.isTreeRowDraggable()) {
|
|
1060
|
+
return {
|
|
1061
|
+
index: rowIndex,
|
|
1062
|
+
position: ratio < 0.25 ? "before" : ratio > 0.75 ? "after" : "inside",
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
return { index: ratio < 0.5 ? rowIndex : rowIndex + 1 };
|
|
1051
1066
|
}
|
|
1052
1067
|
|
|
1053
1068
|
function applyTouchDrop(
|
|
@@ -1117,8 +1132,8 @@ const touchDrag = {
|
|
|
1117
1132
|
return grid.beginRowDrag(rowIndex);
|
|
1118
1133
|
},
|
|
1119
1134
|
move: (_x: number, y: number, target: Element | null) => {
|
|
1120
|
-
const
|
|
1121
|
-
if (
|
|
1135
|
+
const drop = touchRowDropAt(target, y);
|
|
1136
|
+
if (drop != null) grid.updateRowDropPosition(drop.index, drop.position);
|
|
1122
1137
|
},
|
|
1123
1138
|
up: () => grid.endRowDrag(true),
|
|
1124
1139
|
cancel: () => grid.endRowDrag(false),
|
|
@@ -1539,6 +1554,8 @@ const rowCount = computed(() => state.value.rows.length);
|
|
|
1539
1554
|
const dropGap = computed(() => {
|
|
1540
1555
|
const rd = state.value.rowDrag;
|
|
1541
1556
|
if (!rd || rd.dropIndex == null) return null;
|
|
1557
|
+
// 트리 모드는 position이 대상 행 인덱스를 가리킨다 — 갭 인디케이터는 안 쓴다
|
|
1558
|
+
if (rd.position != null) return null;
|
|
1542
1559
|
if (
|
|
1543
1560
|
!rd.external &&
|
|
1544
1561
|
(rd.dropIndex === rd.draggingIndex || rd.dropIndex === rd.draggingIndex + 1)
|
|
@@ -1556,9 +1573,14 @@ function rowClassOf(entry: AnyRow, rowIdx: number) {
|
|
|
1556
1573
|
{
|
|
1557
1574
|
"mg-selected": isSelected(row),
|
|
1558
1575
|
"mg-row-dragging": rd?.draggingIndex === rowIndex,
|
|
1559
|
-
"mg-drop-before":
|
|
1576
|
+
"mg-drop-before":
|
|
1577
|
+
dropGap.value === rowIndex ||
|
|
1578
|
+
(rd?.position === "before" && rd.dropIndex === rowIndex),
|
|
1560
1579
|
"mg-drop-after":
|
|
1561
|
-
dropGap.value === rowCount.value && rowIndex === rowCount.value - 1
|
|
1580
|
+
(dropGap.value === rowCount.value && rowIndex === rowCount.value - 1) ||
|
|
1581
|
+
(rd?.position === "after" && rd.dropIndex === rowIndex),
|
|
1582
|
+
"mg-drop-inside": rd?.position === "inside" && rd.dropIndex === rowIndex,
|
|
1583
|
+
"mg-drop-denied": rd?.denied === true && rd.dropIndex === rowIndex,
|
|
1562
1584
|
},
|
|
1563
1585
|
status ? `mg-row-${status}` : "",
|
|
1564
1586
|
// 커스텀 행 클래스 (GridOptions/ColumnDef.rowClass)
|
|
@@ -1622,8 +1644,16 @@ function onRowDragOver(rowIndex: number, event: DragEvent) {
|
|
|
1622
1644
|
event.preventDefault();
|
|
1623
1645
|
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
|
|
1624
1646
|
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1647
|
+
const ratio = (event.clientY - rect.top) / rect.height;
|
|
1648
|
+
// 트리 모드 — 상하 25%는 형제 위/아래, 가운데 50%는 자식(inside)
|
|
1649
|
+
if (grid.isTreeRowDraggable()) {
|
|
1650
|
+
grid.updateRowDropPosition(
|
|
1651
|
+
rowIndex,
|
|
1652
|
+
ratio < 0.25 ? "before" : ratio > 0.75 ? "after" : "inside",
|
|
1653
|
+
);
|
|
1654
|
+
return;
|
|
1655
|
+
}
|
|
1656
|
+
const gap = ratio < 0.5 ? rowIndex : rowIndex + 1;
|
|
1627
1657
|
grid.updateRowDropPosition(gap);
|
|
1628
1658
|
}
|
|
1629
1659
|
|
|
@@ -1660,17 +1690,19 @@ function onGridKeydown(event: KeyboardEvent) {
|
|
|
1660
1690
|
const tsv = grid.getSelectionTsv({ includeHeaders: event.shiftKey });
|
|
1661
1691
|
if (tsv != null) {
|
|
1662
1692
|
event.preventDefault();
|
|
1663
|
-
void
|
|
1693
|
+
void writeClipboardText(tsv);
|
|
1664
1694
|
}
|
|
1665
1695
|
} else if (key === "x") {
|
|
1666
1696
|
const tsv = grid.cutSelectionTsv(); // 엑셀 Ctrl+X — 잘라내기
|
|
1667
1697
|
if (tsv != null) {
|
|
1668
1698
|
event.preventDefault();
|
|
1669
|
-
void
|
|
1699
|
+
void writeClipboardText(tsv);
|
|
1670
1700
|
}
|
|
1671
1701
|
} else if (key === "v") {
|
|
1672
1702
|
event.preventDefault();
|
|
1673
|
-
void
|
|
1703
|
+
void readClipboardText().then((text) => {
|
|
1704
|
+
if (text != null) grid.pasteTsv(text);
|
|
1705
|
+
});
|
|
1674
1706
|
} else if (key === "z") {
|
|
1675
1707
|
event.preventDefault();
|
|
1676
1708
|
if (event.shiftKey) grid.redo();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda-grid/vue2",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Vue 2.7 adapter for @moda-grid — DataGrid SFC and useGrid composable",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"grid"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@moda-grid/core": "2.
|
|
39
|
+
"@moda-grid/core": "2.1.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"vue": "^2.7.0"
|